resend 2.0.0 → 2.0.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +353 -0
- package/dist/index.d.ts +353 -0
- package/dist/index.js +300 -0
- package/dist/index.mjs +276 -0
- package/package.json +19 -5
- package/build/package.json +0 -50
- package/build/src/__snapshots__/resend.spec.js.snap +0 -3
- package/build/src/api-keys/api-keys.d.ts +0 -9
- package/build/src/api-keys/api-keys.js +0 -36
- package/build/src/api-keys/api-keys.spec.d.ts +0 -1
- package/build/src/api-keys/api-keys.spec.js +0 -349
- package/build/src/api-keys/interfaces/create-api-key-options.interface.d.ts +0 -17
- package/build/src/api-keys/interfaces/create-api-key-options.interface.js +0 -2
- package/build/src/api-keys/interfaces/index.d.ts +0 -3
- package/build/src/api-keys/interfaces/index.js +0 -19
- package/build/src/api-keys/interfaces/list-api-keys.interface.d.ts +0 -10
- package/build/src/api-keys/interfaces/list-api-keys.interface.js +0 -2
- package/build/src/api-keys/interfaces/remove-api-keys.interface.d.ts +0 -8
- package/build/src/api-keys/interfaces/remove-api-keys.interface.js +0 -2
- package/build/src/batch/batch.d.ts +0 -8
- package/build/src/batch/batch.js +0 -36
- package/build/src/batch/batch.spec.d.ts +0 -1
- package/build/src/batch/batch.spec.js +0 -122
- package/build/src/batch/interfaces/create-batch-options.interface.d.ts +0 -16
- package/build/src/batch/interfaces/create-batch-options.interface.js +0 -2
- package/build/src/batch/interfaces/index.d.ts +0 -1
- package/build/src/batch/interfaces/index.js +0 -17
- package/build/src/common/interfaces/get-option.interface.d.ts +0 -3
- package/build/src/common/interfaces/get-option.interface.js +0 -2
- package/build/src/common/interfaces/index.d.ts +0 -4
- package/build/src/common/interfaces/index.js +0 -20
- package/build/src/common/interfaces/list-option.interface.d.ts +0 -4
- package/build/src/common/interfaces/list-option.interface.js +0 -2
- package/build/src/common/interfaces/post-option.interface.d.ts +0 -5
- package/build/src/common/interfaces/post-option.interface.js +0 -2
- package/build/src/common/interfaces/put-option.interface.d.ts +0 -5
- package/build/src/common/interfaces/put-option.interface.js +0 -2
- package/build/src/domains/domains.d.ts +0 -11
- package/build/src/domains/domains.js +0 -48
- package/build/src/domains/domains.spec.d.ts +0 -1
- package/build/src/domains/domains.spec.js +0 -496
- package/build/src/domains/interfaces/create-domain-options.interface.d.ts +0 -16
- package/build/src/domains/interfaces/create-domain-options.interface.js +0 -2
- package/build/src/domains/interfaces/domain.d.ts +0 -33
- package/build/src/domains/interfaces/domain.js +0 -2
- package/build/src/domains/interfaces/get-domain.interface.d.ts +0 -10
- package/build/src/domains/interfaces/get-domain.interface.js +0 -2
- package/build/src/domains/interfaces/index.d.ts +0 -5
- package/build/src/domains/interfaces/index.js +0 -21
- package/build/src/domains/interfaces/list-domains.interface.d.ts +0 -7
- package/build/src/domains/interfaces/list-domains.interface.js +0 -2
- package/build/src/domains/interfaces/remove-domain.interface.d.ts +0 -7
- package/build/src/domains/interfaces/remove-domain.interface.js +0 -2
- package/build/src/domains/interfaces/verify-domain.interface.d.ts +0 -7
- package/build/src/domains/interfaces/verify-domain.interface.js +0 -2
- package/build/src/emails/emails.d.ts +0 -9
- package/build/src/emails/emails.js +0 -40
- package/build/src/emails/emails.spec.d.ts +0 -1
- package/build/src/emails/emails.spec.js +0 -190
- package/build/src/emails/interfaces/create-email-options.interface.d.ts +0 -113
- package/build/src/emails/interfaces/create-email-options.interface.js +0 -2
- package/build/src/emails/interfaces/get-email-options.interface.d.ts +0 -19
- package/build/src/emails/interfaces/get-email-options.interface.js +0 -2
- package/build/src/emails/interfaces/index.d.ts +0 -2
- package/build/src/emails/interfaces/index.js +0 -18
- package/build/src/error.d.ts +0 -7
- package/build/src/error.js +0 -21
- package/build/src/guards.d.ts +0 -9
- package/build/src/guards.js +0 -36
- package/build/src/index.d.ts +0 -2
- package/build/src/index.js +0 -5
- package/build/src/interfaces.d.ts +0 -24
- package/build/src/interfaces.js +0 -18
- package/build/src/resend.d.ts +0 -35
- package/build/src/resend.js +0 -83
- package/build/src/resend.spec.d.ts +0 -1
- package/build/src/resend.spec.js +0 -267
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
|
|
2
|
-
export type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
|
|
3
|
-
export type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
|
|
4
|
-
export type DomainRecords = DomainSpfRecord | DomainDkimRecord;
|
|
5
|
-
export interface DomainSpfRecord {
|
|
6
|
-
record: 'SPF';
|
|
7
|
-
name: string;
|
|
8
|
-
value: string;
|
|
9
|
-
type: 'MX' | 'TXT';
|
|
10
|
-
ttl: string;
|
|
11
|
-
status: DomainStatus;
|
|
12
|
-
routing_policy?: string;
|
|
13
|
-
priority?: number;
|
|
14
|
-
proxy_status?: 'enable' | 'disable';
|
|
15
|
-
}
|
|
16
|
-
export interface DomainDkimRecord {
|
|
17
|
-
record: 'DKIM';
|
|
18
|
-
name: string;
|
|
19
|
-
value: string;
|
|
20
|
-
type: 'CNAME' | 'TXT';
|
|
21
|
-
ttl: string;
|
|
22
|
-
status: DomainStatus;
|
|
23
|
-
routing_policy?: string;
|
|
24
|
-
priority?: number;
|
|
25
|
-
proxy_status?: 'enable' | 'disable';
|
|
26
|
-
}
|
|
27
|
-
export interface Domain {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
status: DomainStatus;
|
|
31
|
-
created_at: string;
|
|
32
|
-
region: DomainRegion;
|
|
33
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from '../../interfaces';
|
|
2
|
-
import { Domain, DomainRecords } from './domain';
|
|
3
|
-
export interface GetDomainResponseSuccess extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
|
|
4
|
-
object: 'domain';
|
|
5
|
-
records: DomainRecords[];
|
|
6
|
-
}
|
|
7
|
-
export interface GetDomainResponse {
|
|
8
|
-
data: GetDomainResponseSuccess | null;
|
|
9
|
-
error: ErrorResponse | null;
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./create-domain-options.interface"), exports);
|
|
18
|
-
__exportStar(require("./list-domains.interface"), exports);
|
|
19
|
-
__exportStar(require("./get-domain.interface"), exports);
|
|
20
|
-
__exportStar(require("./remove-domain.interface"), exports);
|
|
21
|
-
__exportStar(require("./verify-domain.interface"), exports);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from '../../interfaces';
|
|
2
|
-
import { Domain } from './domain';
|
|
3
|
-
export type RemoveDomainsResponseSuccess = Pick<Domain, 'id'>;
|
|
4
|
-
export interface RemoveDomainsResponse {
|
|
5
|
-
data: RemoveDomainsResponseSuccess | null;
|
|
6
|
-
error: ErrorResponse | null;
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Resend } from '../resend';
|
|
2
|
-
import { CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, GetEmailResponse } from './interfaces';
|
|
3
|
-
export declare class Emails {
|
|
4
|
-
private readonly resend;
|
|
5
|
-
constructor(resend: Resend);
|
|
6
|
-
send(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
7
|
-
create(payload: CreateEmailOptions, options?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
8
|
-
get(id: string): Promise<GetEmailResponse>;
|
|
9
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Emails = void 0;
|
|
13
|
-
const render_1 = require("@react-email/render");
|
|
14
|
-
class Emails {
|
|
15
|
-
constructor(resend) {
|
|
16
|
-
this.resend = resend;
|
|
17
|
-
}
|
|
18
|
-
send(payload, options = {}) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
return this.create(payload, options);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
create(payload, options = {}) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
if (payload.react) {
|
|
26
|
-
payload.html = yield (0, render_1.renderAsync)(payload.react);
|
|
27
|
-
delete payload.react;
|
|
28
|
-
}
|
|
29
|
-
const data = yield this.resend.post('/emails', payload, options);
|
|
30
|
-
return data;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
get(id) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const data = yield this.resend.get(`/emails/${id}`);
|
|
36
|
-
return data;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.Emails = Emails;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const jest_fetch_mock_1 = require("jest-fetch-mock");
|
|
13
|
-
const resend_1 = require("../resend");
|
|
14
|
-
(0, jest_fetch_mock_1.enableFetchMocks)();
|
|
15
|
-
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
16
|
-
describe('Emails', () => {
|
|
17
|
-
afterEach(() => fetchMock.resetMocks());
|
|
18
|
-
describe('create', () => {
|
|
19
|
-
it('sends email', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const errorResponse = {
|
|
21
|
-
name: 'missing_required_field',
|
|
22
|
-
message: 'Missing `from` field.',
|
|
23
|
-
};
|
|
24
|
-
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
25
|
-
status: 422,
|
|
26
|
-
headers: {
|
|
27
|
-
'content-type': 'application/json',
|
|
28
|
-
Authorization: 'Bearer re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
const data = yield resend.emails.create({});
|
|
32
|
-
console.log({ data });
|
|
33
|
-
expect(data).toMatchInlineSnapshot(`
|
|
34
|
-
{
|
|
35
|
-
"data": null,
|
|
36
|
-
"error": {
|
|
37
|
-
"message": "Missing \`from\` field.",
|
|
38
|
-
"name": "missing_required_field",
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
`);
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
44
|
-
describe('send', () => {
|
|
45
|
-
it('sends email', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
const payload = {
|
|
47
|
-
from: 'bu@resend.com',
|
|
48
|
-
to: 'zeno@resend.com',
|
|
49
|
-
subject: 'Hello World',
|
|
50
|
-
html: '<h1>Hello world</h1>',
|
|
51
|
-
};
|
|
52
|
-
fetchMock.mockOnce(JSON.stringify({ id: '1234' }), {
|
|
53
|
-
status: 200,
|
|
54
|
-
headers: {
|
|
55
|
-
'content-type': 'application/json',
|
|
56
|
-
Authorization: 'Bearer re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop',
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
const data = yield resend.emails.send(payload);
|
|
60
|
-
expect(data).toMatchInlineSnapshot(`
|
|
61
|
-
{
|
|
62
|
-
"data": {
|
|
63
|
-
"id": "1234",
|
|
64
|
-
},
|
|
65
|
-
"error": null,
|
|
66
|
-
}
|
|
67
|
-
`);
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
describe('get', () => {
|
|
71
|
-
describe('when email not found', () => {
|
|
72
|
-
it('returns error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
const errorResponse = {
|
|
74
|
-
name: 'not_found',
|
|
75
|
-
message: 'Email not found',
|
|
76
|
-
};
|
|
77
|
-
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
78
|
-
status: 404,
|
|
79
|
-
headers: {
|
|
80
|
-
'content-type': 'application/json',
|
|
81
|
-
Authorization: 'Bearer re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop',
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
const result = resend.emails.get('1234');
|
|
85
|
-
yield expect(result).resolves.toMatchInlineSnapshot(`
|
|
86
|
-
{
|
|
87
|
-
"data": null,
|
|
88
|
-
"error": {
|
|
89
|
-
"message": "Email not found",
|
|
90
|
-
"name": "not_found",
|
|
91
|
-
},
|
|
92
|
-
}
|
|
93
|
-
`);
|
|
94
|
-
}));
|
|
95
|
-
});
|
|
96
|
-
describe('when email found', () => {
|
|
97
|
-
it('returns emails with only to', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
-
const response = {
|
|
99
|
-
object: 'email',
|
|
100
|
-
id: '123',
|
|
101
|
-
to: ['zeno@resend.com'],
|
|
102
|
-
from: 'bu@resend.com',
|
|
103
|
-
created_at: '321',
|
|
104
|
-
subject: 'Test email',
|
|
105
|
-
html: '<p>hello hello</p>',
|
|
106
|
-
text: null,
|
|
107
|
-
bcc: null,
|
|
108
|
-
cc: null,
|
|
109
|
-
reply_to: null,
|
|
110
|
-
last_event: 'sent',
|
|
111
|
-
};
|
|
112
|
-
fetchMock.mockOnce(JSON.stringify(response), {
|
|
113
|
-
status: 200,
|
|
114
|
-
headers: {
|
|
115
|
-
'content-type': 'application/json',
|
|
116
|
-
Authorization: 'Bearer re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop',
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
yield expect(resend.emails.get('1234')).resolves.toMatchInlineSnapshot(`
|
|
120
|
-
{
|
|
121
|
-
"data": {
|
|
122
|
-
"bcc": null,
|
|
123
|
-
"cc": null,
|
|
124
|
-
"created_at": "321",
|
|
125
|
-
"from": "bu@resend.com",
|
|
126
|
-
"html": "<p>hello hello</p>",
|
|
127
|
-
"id": "123",
|
|
128
|
-
"last_event": "sent",
|
|
129
|
-
"object": "email",
|
|
130
|
-
"reply_to": null,
|
|
131
|
-
"subject": "Test email",
|
|
132
|
-
"text": null,
|
|
133
|
-
"to": [
|
|
134
|
-
"zeno@resend.com",
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
"error": null,
|
|
138
|
-
}
|
|
139
|
-
`);
|
|
140
|
-
}));
|
|
141
|
-
it('returns emails with to and multiple cc', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
const response = {
|
|
143
|
-
object: 'email',
|
|
144
|
-
id: '123',
|
|
145
|
-
to: ['zeno@resend.com'],
|
|
146
|
-
from: 'bu@resend.com',
|
|
147
|
-
created_at: '321',
|
|
148
|
-
subject: 'Test email',
|
|
149
|
-
html: '<p>hello hello</p>',
|
|
150
|
-
text: null,
|
|
151
|
-
bcc: null,
|
|
152
|
-
cc: ['zeno@resend.com', 'bu@resend.com'],
|
|
153
|
-
reply_to: null,
|
|
154
|
-
last_event: 'sent',
|
|
155
|
-
};
|
|
156
|
-
fetchMock.mockOnce(JSON.stringify(response), {
|
|
157
|
-
status: 200,
|
|
158
|
-
headers: {
|
|
159
|
-
'content-type': 'application/json',
|
|
160
|
-
Authorization: 'Bearer re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop',
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
yield expect(resend.emails.get('1234')).resolves.toMatchInlineSnapshot(`
|
|
164
|
-
{
|
|
165
|
-
"data": {
|
|
166
|
-
"bcc": null,
|
|
167
|
-
"cc": [
|
|
168
|
-
"zeno@resend.com",
|
|
169
|
-
"bu@resend.com",
|
|
170
|
-
],
|
|
171
|
-
"created_at": "321",
|
|
172
|
-
"from": "bu@resend.com",
|
|
173
|
-
"html": "<p>hello hello</p>",
|
|
174
|
-
"id": "123",
|
|
175
|
-
"last_event": "sent",
|
|
176
|
-
"object": "email",
|
|
177
|
-
"reply_to": null,
|
|
178
|
-
"subject": "Test email",
|
|
179
|
-
"text": null,
|
|
180
|
-
"to": [
|
|
181
|
-
"zeno@resend.com",
|
|
182
|
-
],
|
|
183
|
-
},
|
|
184
|
-
"error": null,
|
|
185
|
-
}
|
|
186
|
-
`);
|
|
187
|
-
}));
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { PostOptions } from '../../common/interfaces';
|
|
4
|
-
import { ErrorResponse } from '../../interfaces';
|
|
5
|
-
type RequireAtLeastOne<T> = {
|
|
6
|
-
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
7
|
-
}[keyof T];
|
|
8
|
-
interface EmailRenderOptions {
|
|
9
|
-
/**
|
|
10
|
-
* The React component used to write the message.
|
|
11
|
-
*
|
|
12
|
-
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
13
|
-
*/
|
|
14
|
-
react?: React.ReactElement | React.ReactNode | null;
|
|
15
|
-
/**
|
|
16
|
-
* The HTML version of the message.
|
|
17
|
-
*
|
|
18
|
-
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
19
|
-
*/
|
|
20
|
-
html?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The plain text version of the message.
|
|
23
|
-
*
|
|
24
|
-
* @link https://resend.com/api-reference/emails/send-email#body-parameters
|
|
25
|
-
*/
|
|
26
|
-
text?: string;
|
|
27
|
-
}
|
|
28
|
-
interface CreateEmailBaseOptions extends EmailRenderOptions {
|
|
29
|
-
/**
|
|
30
|
-
* Filename and content of attachments (max 40mb per email)
|
|
31
|
-
*
|
|
32
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
33
|
-
*/
|
|
34
|
-
attachments?: Attachment[];
|
|
35
|
-
/**
|
|
36
|
-
* Blind carbon copy recipient email address. For multiple addresses, send as an array of strings.
|
|
37
|
-
*
|
|
38
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
39
|
-
*/
|
|
40
|
-
bcc?: string | string[];
|
|
41
|
-
/**
|
|
42
|
-
* Carbon copy recipient email address. For multiple addresses, send as an array of strings.
|
|
43
|
-
*
|
|
44
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
45
|
-
*/
|
|
46
|
-
cc?: string | string[];
|
|
47
|
-
/**
|
|
48
|
-
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
|
|
49
|
-
*
|
|
50
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
51
|
-
*/
|
|
52
|
-
from: string;
|
|
53
|
-
/**
|
|
54
|
-
* Custom headers to add to the email.
|
|
55
|
-
*
|
|
56
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
57
|
-
*/
|
|
58
|
-
headers?: Record<string, string>;
|
|
59
|
-
/**
|
|
60
|
-
* Reply-to email address. For multiple addresses, send as an array of strings.
|
|
61
|
-
*
|
|
62
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
63
|
-
*/
|
|
64
|
-
reply_to?: string | string[];
|
|
65
|
-
/**
|
|
66
|
-
* Email subject.
|
|
67
|
-
*
|
|
68
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
69
|
-
*/
|
|
70
|
-
subject: string;
|
|
71
|
-
/**
|
|
72
|
-
* Email tags
|
|
73
|
-
*
|
|
74
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
75
|
-
*/
|
|
76
|
-
tags?: Tag[];
|
|
77
|
-
/**
|
|
78
|
-
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
|
|
79
|
-
*
|
|
80
|
-
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
|
|
81
|
-
*/
|
|
82
|
-
to: string | string[];
|
|
83
|
-
}
|
|
84
|
-
export type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions> & CreateEmailBaseOptions;
|
|
85
|
-
export interface CreateEmailRequestOptions extends PostOptions {
|
|
86
|
-
}
|
|
87
|
-
export interface CreateEmailResponseSuccess {
|
|
88
|
-
/** The ID of the newly created email. */
|
|
89
|
-
id: string;
|
|
90
|
-
}
|
|
91
|
-
export interface CreateEmailResponse {
|
|
92
|
-
data: CreateEmailResponseSuccess | null;
|
|
93
|
-
error: ErrorResponse | null;
|
|
94
|
-
}
|
|
95
|
-
interface Attachment {
|
|
96
|
-
/** Content of an attached file. */
|
|
97
|
-
content?: string | Buffer;
|
|
98
|
-
/** Name of attached file. */
|
|
99
|
-
filename?: string | false | undefined;
|
|
100
|
-
/** Path where the attachment file is hosted */
|
|
101
|
-
path?: string;
|
|
102
|
-
}
|
|
103
|
-
export type Tag = {
|
|
104
|
-
/**
|
|
105
|
-
* The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
106
|
-
*/
|
|
107
|
-
name: string;
|
|
108
|
-
/**
|
|
109
|
-
* The value of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
110
|
-
*/
|
|
111
|
-
value: string;
|
|
112
|
-
};
|
|
113
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from '../../interfaces';
|
|
2
|
-
export interface GetEmailResponseSuccess {
|
|
3
|
-
bcc: string[] | null;
|
|
4
|
-
cc: string[] | null;
|
|
5
|
-
created_at: string;
|
|
6
|
-
from: string;
|
|
7
|
-
html: string | null;
|
|
8
|
-
id: string;
|
|
9
|
-
last_event: string;
|
|
10
|
-
reply_to: string[] | null;
|
|
11
|
-
subject: string;
|
|
12
|
-
text: string | null;
|
|
13
|
-
to: string[];
|
|
14
|
-
object: 'email';
|
|
15
|
-
}
|
|
16
|
-
export interface GetEmailResponse {
|
|
17
|
-
data: GetEmailResponseSuccess | null;
|
|
18
|
-
error: ErrorResponse | null;
|
|
19
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./create-email-options.interface"), exports);
|
|
18
|
-
__exportStar(require("./get-email-options.interface"), exports);
|
package/build/src/error.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse, RESEND_ERROR_CODE_KEY } from './interfaces';
|
|
2
|
-
export declare class ResendError extends Error {
|
|
3
|
-
readonly name: RESEND_ERROR_CODE_KEY;
|
|
4
|
-
constructor(message: string, name: RESEND_ERROR_CODE_KEY);
|
|
5
|
-
static fromResponse(response: ErrorResponse): ResendError;
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
package/build/src/error.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResendError = void 0;
|
|
4
|
-
class ResendError extends Error {
|
|
5
|
-
constructor(message, name) {
|
|
6
|
-
super();
|
|
7
|
-
this.message = message;
|
|
8
|
-
this.name = name;
|
|
9
|
-
}
|
|
10
|
-
static fromResponse(response) {
|
|
11
|
-
const error = response;
|
|
12
|
-
return new ResendError(error.message, error.name);
|
|
13
|
-
}
|
|
14
|
-
toString() {
|
|
15
|
-
return JSON.stringify({
|
|
16
|
-
message: this.message,
|
|
17
|
-
name: this.name,
|
|
18
|
-
}, null, 2);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.ResendError = ResendError;
|
package/build/src/guards.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from './interfaces';
|
|
2
|
-
export declare const isResendErrorResponse: (response: unknown) => response is ErrorResponse;
|
|
3
|
-
/**
|
|
4
|
-
* Consider whether to use this stricter version of the type guard.
|
|
5
|
-
*
|
|
6
|
-
* Right now, it's not used as there is a risk that an API error will not be
|
|
7
|
-
* caught due to the API being ahead of the current types.
|
|
8
|
-
*/
|
|
9
|
-
export declare const isResendErrorResponseStrict: (response: unknown) => response is ErrorResponse;
|
package/build/src/guards.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isResendErrorResponseStrict = exports.isResendErrorResponse = void 0;
|
|
4
|
-
const interfaces_1 = require("./interfaces");
|
|
5
|
-
const isResendErrorResponse = (response) => {
|
|
6
|
-
if (typeof response !== 'object' || response === null) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const error = response;
|
|
10
|
-
if (typeof error !== 'object' || error === null) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const { message, name } = error;
|
|
14
|
-
return typeof message === 'string' && typeof name === 'string';
|
|
15
|
-
};
|
|
16
|
-
exports.isResendErrorResponse = isResendErrorResponse;
|
|
17
|
-
/**
|
|
18
|
-
* Consider whether to use this stricter version of the type guard.
|
|
19
|
-
*
|
|
20
|
-
* Right now, it's not used as there is a risk that an API error will not be
|
|
21
|
-
* caught due to the API being ahead of the current types.
|
|
22
|
-
*/
|
|
23
|
-
const isResendErrorResponseStrict = (response) => {
|
|
24
|
-
if (typeof response !== 'object' || response === null) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
const error = response;
|
|
28
|
-
if (typeof error !== 'object' || error === null) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const { message, name } = error;
|
|
32
|
-
return (typeof message === 'string' &&
|
|
33
|
-
typeof name === 'string' &&
|
|
34
|
-
name in interfaces_1.RESEND_ERROR_CODES_BY_KEY);
|
|
35
|
-
};
|
|
36
|
-
exports.isResendErrorResponseStrict = isResendErrorResponseStrict;
|
package/build/src/index.d.ts
DELETED
package/build/src/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
2
|
-
readonly missing_required_field: 422;
|
|
3
|
-
readonly invalid_access: 422;
|
|
4
|
-
readonly invalid_parameter: 422;
|
|
5
|
-
readonly invalid_region: 422;
|
|
6
|
-
readonly rate_limit_exceeded: 429;
|
|
7
|
-
readonly missing_api_key: 401;
|
|
8
|
-
readonly invalid_api_Key: 403;
|
|
9
|
-
readonly invalid_from_address: 403;
|
|
10
|
-
readonly validation_error: 403;
|
|
11
|
-
readonly not_found: 404;
|
|
12
|
-
readonly method_not_allowed: 405;
|
|
13
|
-
readonly application_error: 500;
|
|
14
|
-
readonly internal_server_error: 500;
|
|
15
|
-
};
|
|
16
|
-
export type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
|
|
17
|
-
export interface ErrorResponse {
|
|
18
|
-
message: string;
|
|
19
|
-
name: RESEND_ERROR_CODE_KEY;
|
|
20
|
-
}
|
|
21
|
-
export type Tag = {
|
|
22
|
-
name: string;
|
|
23
|
-
value: string;
|
|
24
|
-
};
|