rebrand to useSend (#210)

This commit is contained in:
KM Koushik
2025-09-03 08:21:55 +10:00
committed by GitHub
parent b1a59d2705
commit 07c53d3f58
219 changed files with 1349 additions and 2835 deletions

View File

@@ -1,7 +1,7 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@unsend/eslint-config/library.js"],
extends: ["@usesend/eslint-config/library.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Unsend
Copyright (c) 2025 UseSend
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,51 +1,51 @@
# Unsend SDK
# useSend SDK
## Prerequisites
- [Unsend API key](https://app.unsend.dev/dev-settings/api-keys)
- [Verified domain](https://app.unsend.dev/domains)
- [useSend API key](https://app.usesend.com/dev-settings/api-keys)
- [Verified domain](https://app.usesend.com/domains)
## Installation
### NPM
```bash
npm install unsend
npm install usesend
```
### Yarn
```bash
yarn add unsend
yarn add usesend
```
### PNPM
```bash
pnpm add unsend
pnpm add usesend
```
### Bun
```bash
bun add unsend
bun add usesend
```
## Usage
```javascript
import { Unsend } from "unsend";
import { UseSend } from "usesend";
const unsend = new Unsend("us_12345");
const usesend = new UseSend("us_12345");
// for self-hosted installations you can pass your base URL
// const unsend = new Unsend("us_12345", "https://my-unsend-instance.com");
// const usesend = new UseSend("us_12345", "https://app.usesend.com");
unsend.emails.send({
usesend.emails.send({
to: "hello@acme.com",
from: "hello@company.com",
subject: "Unsend email",
html: "<p>Unsend is the best open source product to send emails</p>",
text: "Unsend is the best open source product to send emails",
subject: "useSend email",
html: "<p>useSend is the best open source product to send emails</p>",
text: "useSend is the best open source product to send emails",
});
```

View File

@@ -1 +1,2 @@
export { Unsend } from "./src/unsend";
export { UseSend } from "./src/usesend";
export { UseSend as Unsend } from "./src/usesend"; // deprecated alias

View File

@@ -1,6 +1,6 @@
{
"name": "unsend",
"version": "1.5.1",
"name": "usesend-js",
"version": "1.5.2",
"description": "",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@@ -18,8 +18,8 @@
"devDependencies": {
"@types/node": "^22.15.2",
"@types/react": "^19.1.2",
"@unsend/eslint-config": "workspace:*",
"@unsend/typescript-config": "workspace:*",
"@usesend/eslint-config": "workspace:*",
"@usesend/typescript-config": "workspace:*",
"openapi-typescript": "^7.6.1",
"tsup": "^8.4.0",
"typescript": "^5.8.3"

View File

@@ -1,4 +1,4 @@
import { Unsend } from "./unsend";
import { UseSend } from "./usesend";
import { paths } from "../types/schema";
import { ErrorResponse } from "../types";
@@ -49,15 +49,15 @@ type DeleteContactResponse = {
};
export class Contacts {
constructor(private readonly unsend: Unsend) {
this.unsend = unsend;
constructor(private readonly usesend: UseSend) {
this.usesend = usesend;
}
async create(
contactBookId: string,
payload: CreateContactPayload
): Promise<CreateContactResponse> {
const data = await this.unsend.post<CreateContactResponseSuccess>(
const data = await this.usesend.post<CreateContactResponseSuccess>(
`/contactBooks/${contactBookId}/contacts`,
payload
);
@@ -69,7 +69,7 @@ export class Contacts {
contactBookId: string,
contactId: string
): Promise<GetContactResponse> {
const data = await this.unsend.get<GetContactResponseSuccess>(
const data = await this.usesend.get<GetContactResponseSuccess>(
`/contactBooks/${contactBookId}/contacts/${contactId}`
);
return data;
@@ -80,7 +80,7 @@ export class Contacts {
contactId: string,
payload: UpdateContactPayload
): Promise<UpdateContactResponse> {
const data = await this.unsend.patch<UpdateContactResponseSuccess>(
const data = await this.usesend.patch<UpdateContactResponseSuccess>(
`/contactBooks/${contactBookId}/contacts/${contactId}`,
payload
);
@@ -93,7 +93,7 @@ export class Contacts {
contactId: string,
payload: UpsertContactPayload
): Promise<UpsertContactResponse> {
const data = await this.unsend.put<UpsertContactResponseSuccess>(
const data = await this.usesend.put<UpsertContactResponseSuccess>(
`/contactBooks/${contactBookId}/contacts/${contactId}`,
payload
);
@@ -105,7 +105,7 @@ export class Contacts {
contactBookId: string,
contactId: string
): Promise<DeleteContactResponse> {
const data = await this.unsend.delete<{ success: boolean }>(
const data = await this.usesend.delete<{ success: boolean }>(
`/contactBooks/${contactBookId}/contacts/${contactId}`
);

View File

@@ -1,6 +1,6 @@
import { paths } from "../types/schema";
import { ErrorResponse } from "../types";
import { Unsend } from "./unsend";
import { UseSend } from "./usesend";
type CreateDomainPayload =
paths["/v1/domains"]["post"]["requestBody"]["content"]["application/json"];
@@ -30,17 +30,17 @@ type VerifyDomainResponseSuccess =
paths["/v1/domains/{id}/verify"]["put"]["responses"]["200"]["content"]["application/json"];
export class Domains {
constructor(private readonly unsend: Unsend) {
this.unsend = unsend;
constructor(private readonly usesend: UseSend) {
this.usesend = usesend;
}
async list(): Promise<GetDomainsResponse> {
const data = await this.unsend.get<GetDomainsResponseSuccess>("/domains");
const data = await this.usesend.get<GetDomainsResponseSuccess>("/domains");
return data;
}
async create(payload: CreateDomainPayload): Promise<CreateDomainResponse> {
const data = await this.unsend.post<CreateDomainResponseSuccess>(
const data = await this.usesend.post<CreateDomainResponseSuccess>(
"/domains",
payload
);
@@ -48,7 +48,7 @@ export class Domains {
}
async verify(id: number): Promise<VerifyDomainResponse> {
const data = await this.unsend.put<VerifyDomainResponseSuccess>(
const data = await this.usesend.put<VerifyDomainResponseSuccess>(
`/domains/${id}/verify`,
{}
);

View File

@@ -1,6 +1,6 @@
import { render } from "@react-email/render";
import * as React from "react";
import { Unsend } from "./unsend";
import { UseSend } from "./usesend";
import { paths } from "../types/schema";
import { ErrorResponse } from "../types";
@@ -68,8 +68,8 @@ type BatchEmailResponse = {
};
export class Emails {
constructor(private readonly unsend: Unsend) {
this.unsend = unsend;
constructor(private readonly usesend: UseSend) {
this.usesend = usesend;
}
async send(payload: SendEmailPayload) {
@@ -82,7 +82,7 @@ export class Emails {
delete payload.react;
}
const data = await this.unsend.post<CreateEmailResponseSuccess>(
const data = await this.usesend.post<CreateEmailResponseSuccess>(
"/emails",
payload
);
@@ -98,7 +98,7 @@ export class Emails {
*/
async batch(payload: BatchEmailPayload): Promise<BatchEmailResponse> {
// Note: React element rendering is not supported in batch mode.
const response = await this.unsend.post<BatchEmailResponseSuccess>(
const response = await this.usesend.post<BatchEmailResponseSuccess>(
"/emails/batch",
payload
);
@@ -109,7 +109,7 @@ export class Emails {
}
async get(id: string): Promise<GetEmailResponse> {
const data = await this.unsend.get<GetEmailResponseSuccess>(
const data = await this.usesend.get<GetEmailResponseSuccess>(
`/emails/${id}`
);
return data;
@@ -119,7 +119,7 @@ export class Emails {
id: string,
payload: UpdateEmailPayload
): Promise<UpdateEmailResponse> {
const data = await this.unsend.patch<UpdateEmailResponseSuccess>(
const data = await this.usesend.patch<UpdateEmailResponseSuccess>(
`/emails/${id}`,
payload
);
@@ -127,7 +127,7 @@ export class Emails {
}
async cancel(id: string): Promise<CancelEmailResponse> {
const data = await this.unsend.post<CancelEmailResponseSuccess>(
const data = await this.usesend.post<CancelEmailResponseSuccess>(
`/emails/${id}/cancel`,
{}
);

View File

@@ -2,15 +2,15 @@ import { ErrorResponse } from "../types";
import { Contacts } from "./contact";
import { Emails } from "./email";
const defaultBaseUrl = "https://app.unsend.dev";
const defaultBaseUrl = "https://app.usesend.com";
// eslint-disable-next-line turbo/no-undeclared-env-vars
const baseUrl = `${process?.env?.UNSEND_BASE_URL ?? defaultBaseUrl}/api/v1`;
const baseUrl = `${process?.env?.USESEND_BASE_URL ?? process?.env?.UNSEND_BASE_URL ?? defaultBaseUrl}/api/v1`;
function isUNSENDErrorResponse(error: { error: ErrorResponse }) {
function isUseSendErrorResponse(error: { error: ErrorResponse }) {
return error.error.code !== undefined;
}
export class Unsend {
export class UseSend {
private readonly headers: Headers;
// readonly domains = new Domains(this);
@@ -24,12 +24,12 @@ export class Unsend {
) {
if (!key) {
if (typeof process !== "undefined" && process.env) {
this.key = process.env.UNSEND_API_KEY;
this.key = process.env.USESEND_API_KEY ?? process.env.UNSEND_API_KEY;
}
if (!this.key) {
throw new Error(
'Missing API key. Pass it to the constructor `new Unsend("us_123")`'
'Missing API key. Pass it to the constructor `new UseSend("us_123")`'
);
}
}
@@ -57,7 +57,7 @@ export class Unsend {
if (!response.ok) {
try {
const resp = await response.json();
if (isUNSENDErrorResponse(resp)) {
if (isUseSendErrorResponse(resp)) {
return { data: null, error: resp };
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@unsend/typescript-config/base.json",
"extends": "@usesend/typescript-config/base.json",
"compilerOptions": {
"outDir": "dist"
},