resend 2.0.0-canary.1 → 2.0.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/build/package.json +6 -6
- package/build/src/api-keys/api-keys.spec.js +1 -9
- package/build/src/batch/batch.js +1 -1
- package/build/src/domains/domains.spec.js +0 -6
- package/build/src/emails/emails.js +1 -1
- package/build/src/emails/emails.spec.js +0 -4
- package/build/src/error.d.ts +2 -3
- package/build/src/error.js +2 -4
- package/build/src/guards.js +3 -6
- package/build/src/interfaces.d.ts +0 -4
- package/build/src/resend.spec.js +0 -2
- package/package.json +6 -6
package/build/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/resendlabs/resend-node#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@react-email/render": "0.0.9
|
|
34
|
+
"@react-email/render": "0.0.9"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/jest": "29.5.
|
|
38
|
-
"@types/node": "18.18.
|
|
37
|
+
"@types/jest": "29.5.7",
|
|
38
|
+
"@types/node": "18.18.8",
|
|
39
39
|
"@types/react": "18.2.33",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "6.9.
|
|
41
|
-
"@typescript-eslint/parser": "6.9.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "6.9.1",
|
|
41
|
+
"@typescript-eslint/parser": "6.9.1",
|
|
42
42
|
"eslint": "8.52.0",
|
|
43
43
|
"jest": "29.7.0",
|
|
44
44
|
"jest-fetch-mock": "3.0.3",
|
|
@@ -46,7 +46,6 @@ describe('API Keys', () => {
|
|
|
46
46
|
}));
|
|
47
47
|
it('throws error when missing name', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
48
|
const errorResponse = {
|
|
49
|
-
statusCode: 422,
|
|
50
49
|
name: 'missing_required_field',
|
|
51
50
|
message: 'Missing "name" field',
|
|
52
51
|
};
|
|
@@ -65,7 +64,6 @@ describe('API Keys', () => {
|
|
|
65
64
|
"error": {
|
|
66
65
|
"message": "Missing "name" field",
|
|
67
66
|
"name": "missing_required_field",
|
|
68
|
-
"statusCode": 422,
|
|
69
67
|
},
|
|
70
68
|
}
|
|
71
69
|
`);
|
|
@@ -132,7 +130,6 @@ describe('API Keys', () => {
|
|
|
132
130
|
}));
|
|
133
131
|
it('throws error with wrong access', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
132
|
const errorResponse = {
|
|
135
|
-
statusCode: 422,
|
|
136
133
|
name: 'invalid_access',
|
|
137
134
|
message: 'Access must be "full_access" | "sending_access"',
|
|
138
135
|
};
|
|
@@ -153,7 +150,6 @@ describe('API Keys', () => {
|
|
|
153
150
|
"error": {
|
|
154
151
|
"message": "Access must be "full_access" | "sending_access"",
|
|
155
152
|
"name": "invalid_access",
|
|
156
|
-
"statusCode": 422,
|
|
157
153
|
},
|
|
158
154
|
}
|
|
159
155
|
`);
|
|
@@ -195,7 +191,7 @@ describe('API Keys', () => {
|
|
|
195
191
|
// const errorResponse: ErrorResponse = {
|
|
196
192
|
// name: 'application_error',
|
|
197
193
|
// message: 'Something went wrong',
|
|
198
|
-
//
|
|
194
|
+
//
|
|
199
195
|
// };
|
|
200
196
|
// fetchMock.mockOnce(
|
|
201
197
|
// JSON.stringify(errorResponse),
|
|
@@ -305,7 +301,6 @@ describe('API Keys', () => {
|
|
|
305
301
|
const errorResponse = {
|
|
306
302
|
name: 'application_error',
|
|
307
303
|
message: 'Something went wrong',
|
|
308
|
-
statusCode: 500,
|
|
309
304
|
};
|
|
310
305
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
311
306
|
status: 500,
|
|
@@ -322,7 +317,6 @@ describe('API Keys', () => {
|
|
|
322
317
|
"error": {
|
|
323
318
|
"message": "Something went wrong",
|
|
324
319
|
"name": "application_error",
|
|
325
|
-
"statusCode": 500,
|
|
326
320
|
},
|
|
327
321
|
}
|
|
328
322
|
`);
|
|
@@ -331,7 +325,6 @@ describe('API Keys', () => {
|
|
|
331
325
|
const errorResponse = {
|
|
332
326
|
name: 'not_found',
|
|
333
327
|
message: 'API key not found',
|
|
334
|
-
statusCode: 404,
|
|
335
328
|
};
|
|
336
329
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
337
330
|
status: 404,
|
|
@@ -348,7 +341,6 @@ describe('API Keys', () => {
|
|
|
348
341
|
"error": {
|
|
349
342
|
"message": "API key not found",
|
|
350
343
|
"name": "not_found",
|
|
351
|
-
"statusCode": 404,
|
|
352
344
|
},
|
|
353
345
|
}
|
|
354
346
|
`);
|
package/build/src/batch/batch.js
CHANGED
|
@@ -24,7 +24,7 @@ class Batch {
|
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
for (const email of payload) {
|
|
26
26
|
if (email.react) {
|
|
27
|
-
email.html = (0, render_1.
|
|
27
|
+
email.html = yield (0, render_1.renderAsync)(email.react);
|
|
28
28
|
delete email.react;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -132,7 +132,6 @@ describe('Domains', () => {
|
|
|
132
132
|
}));
|
|
133
133
|
it('throws error when missing name', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
134
|
const errorResponse = {
|
|
135
|
-
statusCode: 422,
|
|
136
135
|
name: 'missing_required_field',
|
|
137
136
|
message: 'Missing "name" field',
|
|
138
137
|
};
|
|
@@ -151,7 +150,6 @@ describe('Domains', () => {
|
|
|
151
150
|
"error": {
|
|
152
151
|
"message": "Missing "name" field",
|
|
153
152
|
"name": "missing_required_field",
|
|
154
|
-
"statusCode": 422,
|
|
155
153
|
},
|
|
156
154
|
}
|
|
157
155
|
`);
|
|
@@ -267,7 +265,6 @@ describe('Domains', () => {
|
|
|
267
265
|
}));
|
|
268
266
|
it('throws error with wrong region', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
269
267
|
const errorResponse = {
|
|
270
|
-
statusCode: 422,
|
|
271
268
|
name: 'invalid_region',
|
|
272
269
|
message: 'Region must be "us-east-1" | "eu-west-1" | "sa-east-1"',
|
|
273
270
|
};
|
|
@@ -289,7 +286,6 @@ describe('Domains', () => {
|
|
|
289
286
|
"error": {
|
|
290
287
|
"message": "Region must be "us-east-1" | "eu-west-1" | "sa-east-1"",
|
|
291
288
|
"name": "invalid_region",
|
|
292
|
-
"statusCode": 422,
|
|
293
289
|
},
|
|
294
290
|
}
|
|
295
291
|
`);
|
|
@@ -354,7 +350,6 @@ describe('Domains', () => {
|
|
|
354
350
|
const errorResponse = {
|
|
355
351
|
name: 'not_found',
|
|
356
352
|
message: 'Domain not found',
|
|
357
|
-
statusCode: 404,
|
|
358
353
|
};
|
|
359
354
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
360
355
|
status: 404,
|
|
@@ -371,7 +366,6 @@ describe('Domains', () => {
|
|
|
371
366
|
"error": {
|
|
372
367
|
"message": "Domain not found",
|
|
373
368
|
"name": "not_found",
|
|
374
|
-
"statusCode": 404,
|
|
375
369
|
},
|
|
376
370
|
}
|
|
377
371
|
`);
|
|
@@ -23,7 +23,7 @@ class Emails {
|
|
|
23
23
|
create(payload, options = {}) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
if (payload.react) {
|
|
26
|
-
payload.html = (0, render_1.
|
|
26
|
+
payload.html = yield (0, render_1.renderAsync)(payload.react);
|
|
27
27
|
delete payload.react;
|
|
28
28
|
}
|
|
29
29
|
const data = yield this.resend.post('/emails', payload, options);
|
|
@@ -19,7 +19,6 @@ describe('Emails', () => {
|
|
|
19
19
|
it('sends email', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
const errorResponse = {
|
|
21
21
|
name: 'missing_required_field',
|
|
22
|
-
statusCode: 422,
|
|
23
22
|
message: 'Missing `from` field.',
|
|
24
23
|
};
|
|
25
24
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
@@ -37,7 +36,6 @@ describe('Emails', () => {
|
|
|
37
36
|
"error": {
|
|
38
37
|
"message": "Missing \`from\` field.",
|
|
39
38
|
"name": "missing_required_field",
|
|
40
|
-
"statusCode": 422,
|
|
41
39
|
},
|
|
42
40
|
}
|
|
43
41
|
`);
|
|
@@ -75,7 +73,6 @@ describe('Emails', () => {
|
|
|
75
73
|
const errorResponse = {
|
|
76
74
|
name: 'not_found',
|
|
77
75
|
message: 'Email not found',
|
|
78
|
-
statusCode: 404,
|
|
79
76
|
};
|
|
80
77
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
81
78
|
status: 404,
|
|
@@ -91,7 +88,6 @@ describe('Emails', () => {
|
|
|
91
88
|
"error": {
|
|
92
89
|
"message": "Email not found",
|
|
93
90
|
"name": "not_found",
|
|
94
|
-
"statusCode": 404,
|
|
95
91
|
},
|
|
96
92
|
}
|
|
97
93
|
`);
|
package/build/src/error.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ErrorResponse, RESEND_ERROR_CODE_KEY
|
|
1
|
+
import { ErrorResponse, RESEND_ERROR_CODE_KEY } from './interfaces';
|
|
2
2
|
export declare class ResendError extends Error {
|
|
3
|
-
readonly statusCode: RESEND_ERROR_CODE_NUMBER | number;
|
|
4
3
|
readonly name: RESEND_ERROR_CODE_KEY;
|
|
5
|
-
constructor(message: string, name: RESEND_ERROR_CODE_KEY
|
|
4
|
+
constructor(message: string, name: RESEND_ERROR_CODE_KEY);
|
|
6
5
|
static fromResponse(response: ErrorResponse): ResendError;
|
|
7
6
|
toString(): string;
|
|
8
7
|
}
|
package/build/src/error.js
CHANGED
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ResendError = void 0;
|
|
4
4
|
class ResendError extends Error {
|
|
5
|
-
constructor(message, name
|
|
5
|
+
constructor(message, name) {
|
|
6
6
|
super();
|
|
7
7
|
this.message = message;
|
|
8
8
|
this.name = name;
|
|
9
|
-
this.statusCode = statusCode;
|
|
10
9
|
}
|
|
11
10
|
static fromResponse(response) {
|
|
12
11
|
const error = response;
|
|
13
|
-
return new ResendError(error.message, error.name
|
|
12
|
+
return new ResendError(error.message, error.name);
|
|
14
13
|
}
|
|
15
14
|
toString() {
|
|
16
15
|
return JSON.stringify({
|
|
17
16
|
message: this.message,
|
|
18
17
|
name: this.name,
|
|
19
|
-
statusCode: this.statusCode,
|
|
20
18
|
}, null, 2);
|
|
21
19
|
}
|
|
22
20
|
}
|
package/build/src/guards.js
CHANGED
|
@@ -10,10 +10,8 @@ const isResendErrorResponse = (response) => {
|
|
|
10
10
|
if (typeof error !== 'object' || error === null) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
|
-
const { message,
|
|
14
|
-
return
|
|
15
|
-
typeof statusCode === 'number' &&
|
|
16
|
-
typeof name === 'string');
|
|
13
|
+
const { message, name } = error;
|
|
14
|
+
return typeof message === 'string' && typeof name === 'string';
|
|
17
15
|
};
|
|
18
16
|
exports.isResendErrorResponse = isResendErrorResponse;
|
|
19
17
|
/**
|
|
@@ -30,9 +28,8 @@ const isResendErrorResponseStrict = (response) => {
|
|
|
30
28
|
if (typeof error !== 'object' || error === null) {
|
|
31
29
|
return false;
|
|
32
30
|
}
|
|
33
|
-
const { message,
|
|
31
|
+
const { message, name } = error;
|
|
34
32
|
return (typeof message === 'string' &&
|
|
35
|
-
typeof statusCode === 'number' &&
|
|
36
33
|
typeof name === 'string' &&
|
|
37
34
|
name in interfaces_1.RESEND_ERROR_CODES_BY_KEY);
|
|
38
35
|
};
|
|
@@ -13,16 +13,12 @@ export declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
|
13
13
|
readonly application_error: 500;
|
|
14
14
|
readonly internal_server_error: 500;
|
|
15
15
|
};
|
|
16
|
-
type ValueOf<TObj> = TObj[keyof TObj];
|
|
17
|
-
export type RESEND_ERROR_CODE_NUMBER = ValueOf<typeof RESEND_ERROR_CODES_BY_KEY>;
|
|
18
16
|
export type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
|
|
19
17
|
export interface ErrorResponse {
|
|
20
18
|
message: string;
|
|
21
|
-
statusCode: RESEND_ERROR_CODE_NUMBER | number;
|
|
22
19
|
name: RESEND_ERROR_CODE_KEY;
|
|
23
20
|
}
|
|
24
21
|
export type Tag = {
|
|
25
22
|
name: string;
|
|
26
23
|
value: string;
|
|
27
24
|
};
|
|
28
|
-
export {};
|
package/build/src/resend.spec.js
CHANGED
|
@@ -243,7 +243,6 @@ describe('Resend', () => {
|
|
|
243
243
|
text: 'Hello world',
|
|
244
244
|
};
|
|
245
245
|
const errorResponse = {
|
|
246
|
-
statusCode: 422,
|
|
247
246
|
name: 'invalid_parameter',
|
|
248
247
|
message: 'Invalid `from` field. The email address needs to follow the `email@example.com` or `Name <email@example.com>` format',
|
|
249
248
|
};
|
|
@@ -261,7 +260,6 @@ describe('Resend', () => {
|
|
|
261
260
|
"error": {
|
|
262
261
|
"message": "Invalid \`from\` field. The email address needs to follow the \`email@example.com\` or \`Name <email@example.com>\` format",
|
|
263
262
|
"name": "invalid_parameter",
|
|
264
|
-
"statusCode": 422,
|
|
265
263
|
},
|
|
266
264
|
}
|
|
267
265
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/resendlabs/resend-node#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@react-email/render": "0.0.9
|
|
34
|
+
"@react-email/render": "0.0.9"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/jest": "29.5.
|
|
38
|
-
"@types/node": "18.18.
|
|
37
|
+
"@types/jest": "29.5.7",
|
|
38
|
+
"@types/node": "18.18.8",
|
|
39
39
|
"@types/react": "18.2.33",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "6.9.
|
|
41
|
-
"@typescript-eslint/parser": "6.9.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "6.9.1",
|
|
41
|
+
"@typescript-eslint/parser": "6.9.1",
|
|
42
42
|
"eslint": "8.52.0",
|
|
43
43
|
"jest": "29.7.0",
|
|
44
44
|
"jest-fetch-mock": "3.0.3",
|