resend 2.0.0-canary.0 → 2.0.0-canary.2
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 +2 -2
- package/build/src/api-keys/api-keys.d.ts +4 -4
- package/build/src/api-keys/api-keys.js +2 -1
- package/build/src/api-keys/api-keys.spec.js +195 -131
- package/build/src/api-keys/interfaces/create-api-key-options.interface.d.ts +6 -1
- package/build/src/api-keys/interfaces/index.d.ts +1 -0
- package/build/src/api-keys/interfaces/index.js +1 -0
- package/build/src/api-keys/interfaces/list-api-keys.interface.d.ts +7 -2
- package/build/src/api-keys/interfaces/remove-api-keys.interface.d.ts +8 -0
- package/build/src/api-keys/interfaces/remove-api-keys.interface.js +2 -0
- package/build/src/batch/batch.js +1 -1
- package/build/src/batch/batch.spec.js +36 -6
- package/build/src/batch/interfaces/create-batch-options.interface.d.ts +5 -3
- package/build/src/domains/domains.d.ts +4 -4
- package/build/src/domains/domains.js +4 -2
- package/build/src/domains/domains.spec.js +211 -198
- package/build/src/domains/interfaces/create-domain-options.interface.d.ts +6 -31
- package/build/src/domains/interfaces/get-domain.interface.d.ts +6 -9
- package/build/src/domains/interfaces/index.d.ts +2 -0
- package/build/src/domains/interfaces/index.js +2 -0
- package/build/src/domains/interfaces/list-domains.interface.d.ts +6 -3
- package/build/src/domains/interfaces/remove-domain.interface.d.ts +7 -0
- package/build/src/domains/interfaces/remove-domain.interface.js +2 -0
- package/build/src/domains/interfaces/verify-domain.interface.d.ts +7 -0
- package/build/src/domains/interfaces/verify-domain.interface.js +2 -0
- package/build/src/emails/emails.d.ts +1 -1
- package/build/src/emails/emails.js +1 -1
- package/build/src/emails/emails.spec.js +76 -71
- package/build/src/emails/interfaces/create-email-options.interface.d.ts +5 -2
- package/build/src/emails/interfaces/get-email-options.interface.d.ts +6 -1
- package/build/src/error.d.ts +2 -3
- package/build/src/error.js +3 -5
- package/build/src/guards.js +5 -8
- package/build/src/interfaces.d.ts +2 -8
- package/build/src/resend.d.ts +20 -7
- package/build/src/resend.js +8 -14
- package/build/src/resend.spec.js +82 -67
- package/package.json +2 -2
package/build/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "2.0.0-canary.
|
|
3
|
+
"version": "2.0.0-canary.2",
|
|
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,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/resendlabs/resend-node#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@react-email/render": "0.0.
|
|
34
|
+
"@react-email/render": "0.0.9-canary.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "29.5.6",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Resend } from '../resend';
|
|
2
|
-
import { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, ListApiKeysResponse } from './interfaces';
|
|
2
|
+
import { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, ListApiKeysResponse, RemoveApiKeyResponse } from './interfaces';
|
|
3
3
|
export declare class ApiKeys {
|
|
4
4
|
private readonly resend;
|
|
5
5
|
constructor(resend: Resend);
|
|
6
|
-
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<
|
|
7
|
-
list(): Promise<
|
|
8
|
-
remove(id: string): Promise<
|
|
6
|
+
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
|
|
7
|
+
list(): Promise<ListApiKeysResponse>;
|
|
8
|
+
remove(id: string): Promise<RemoveApiKeyResponse>;
|
|
9
9
|
}
|
|
@@ -17,8 +17,11 @@ describe('API Keys', () => {
|
|
|
17
17
|
describe('create', () => {
|
|
18
18
|
it('creates an api key', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
fetchMock.mockOnce(JSON.stringify({
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
data: {
|
|
21
|
+
token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
22
|
+
id: '430eed87-632a-4ea6-90db-0aace67ec228',
|
|
23
|
+
},
|
|
24
|
+
error: null,
|
|
22
25
|
}), {
|
|
23
26
|
status: 201,
|
|
24
27
|
headers: {
|
|
@@ -29,19 +32,22 @@ describe('API Keys', () => {
|
|
|
29
32
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
30
33
|
yield expect(resend.apiKeys.create({ name: 'Test' })).resolves
|
|
31
34
|
.toMatchInlineSnapshot(`
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
{
|
|
36
|
+
"data": {
|
|
37
|
+
"data": {
|
|
38
|
+
"id": "430eed87-632a-4ea6-90db-0aace67ec228",
|
|
39
|
+
"token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
40
|
+
},
|
|
41
|
+
"error": null,
|
|
42
|
+
},
|
|
43
|
+
"error": null,
|
|
44
|
+
}
|
|
45
|
+
`);
|
|
37
46
|
}));
|
|
38
47
|
it('throws error when missing name', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
48
|
const errorResponse = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
name: 'missing_required_field',
|
|
43
|
-
message: 'Missing "name" field',
|
|
44
|
-
},
|
|
49
|
+
name: 'missing_required_field',
|
|
50
|
+
message: 'Missing "name" field',
|
|
45
51
|
};
|
|
46
52
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
47
53
|
status: 422,
|
|
@@ -53,20 +59,23 @@ describe('API Keys', () => {
|
|
|
53
59
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
54
60
|
const result = resend.apiKeys.create({ name: '' });
|
|
55
61
|
yield expect(result).resolves.toMatchInlineSnapshot(`
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
{
|
|
63
|
+
"data": null,
|
|
64
|
+
"error": {
|
|
65
|
+
"message": "Missing "name" field",
|
|
66
|
+
"name": "missing_required_field",
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
`);
|
|
64
70
|
}));
|
|
65
71
|
describe('with access', () => {
|
|
66
72
|
it('creates api key with access `full_access`', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
73
|
fetchMock.mockOnce(JSON.stringify({
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
data: {
|
|
75
|
+
token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
76
|
+
id: '430eed87-632a-4ea6-90db-0aace67ec228',
|
|
77
|
+
},
|
|
78
|
+
error: null,
|
|
70
79
|
}), {
|
|
71
80
|
status: 201,
|
|
72
81
|
headers: {
|
|
@@ -76,16 +85,25 @@ describe('API Keys', () => {
|
|
|
76
85
|
});
|
|
77
86
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
78
87
|
yield expect(resend.apiKeys.create({ name: 'Test', permission: 'full_access' })).resolves.toMatchInlineSnapshot(`
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
{
|
|
89
|
+
"data": {
|
|
90
|
+
"data": {
|
|
91
|
+
"id": "430eed87-632a-4ea6-90db-0aace67ec228",
|
|
92
|
+
"token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
93
|
+
},
|
|
94
|
+
"error": null,
|
|
95
|
+
},
|
|
96
|
+
"error": null,
|
|
97
|
+
}
|
|
98
|
+
`);
|
|
84
99
|
}));
|
|
85
100
|
it('creates api key with access `sending_access`', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
101
|
fetchMock.mockOnce(JSON.stringify({
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
data: {
|
|
103
|
+
token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
104
|
+
id: '430eed87-632a-4ea6-90db-0aace67ec228',
|
|
105
|
+
},
|
|
106
|
+
error: null,
|
|
89
107
|
}), {
|
|
90
108
|
status: 201,
|
|
91
109
|
headers: {
|
|
@@ -98,19 +116,22 @@ describe('API Keys', () => {
|
|
|
98
116
|
name: 'Test',
|
|
99
117
|
permission: 'sending_access',
|
|
100
118
|
})).resolves.toMatchInlineSnapshot(`
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
119
|
+
{
|
|
120
|
+
"data": {
|
|
121
|
+
"data": {
|
|
122
|
+
"id": "430eed87-632a-4ea6-90db-0aace67ec228",
|
|
123
|
+
"token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
124
|
+
},
|
|
125
|
+
"error": null,
|
|
126
|
+
},
|
|
127
|
+
"error": null,
|
|
128
|
+
}
|
|
129
|
+
`);
|
|
106
130
|
}));
|
|
107
131
|
it('throws error with wrong access', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
132
|
const errorResponse = {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
name: 'invalid_access',
|
|
112
|
-
message: 'Access must be "full_access" | "sending_access"',
|
|
113
|
-
},
|
|
133
|
+
name: 'invalid_access',
|
|
134
|
+
message: 'Access must be "full_access" | "sending_access"',
|
|
114
135
|
};
|
|
115
136
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
116
137
|
status: 422,
|
|
@@ -124,71 +145,84 @@ describe('API Keys', () => {
|
|
|
124
145
|
name: 'Test',
|
|
125
146
|
permission: 'wrong_access',
|
|
126
147
|
})).resolves.toMatchInlineSnapshot(`
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}));
|
|
136
|
-
});
|
|
137
|
-
describe('restricted by domain', () => {
|
|
138
|
-
it('creates api key restricted by domain', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
fetchMock.mockOnce(JSON.stringify({
|
|
140
|
-
token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
141
|
-
id: '430eed87-632a-4ea6-90db-0aace67ec228',
|
|
142
|
-
}), {
|
|
143
|
-
status: 201,
|
|
144
|
-
headers: {
|
|
145
|
-
'content-type': 'application/json',
|
|
146
|
-
Authorization: 'Bearer re_924b3rjh2387fbewf823',
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
150
|
-
yield expect(resend.apiKeys.create({
|
|
151
|
-
name: 'Test',
|
|
152
|
-
permission: 'sending_access',
|
|
153
|
-
domain_id: '7dfcf219-9900-4169-86f3-801e6d9b935e',
|
|
154
|
-
})).resolves.toMatchInlineSnapshot(`
|
|
155
|
-
{
|
|
156
|
-
"id": "430eed87-632a-4ea6-90db-0aace67ec228",
|
|
157
|
-
"token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
158
|
-
}
|
|
159
|
-
`);
|
|
160
|
-
}));
|
|
161
|
-
it('throws error with wrong access', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
-
const errorResponse = {
|
|
163
|
-
error: {
|
|
164
|
-
name: 'application_error',
|
|
165
|
-
message: 'Something went wrong',
|
|
166
|
-
statusCode: 500,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
170
|
-
status: 500,
|
|
171
|
-
headers: {
|
|
172
|
-
'content-type': 'application/json',
|
|
173
|
-
Authorization: 'Bearer re_924b3rjh2387fbewf823',
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
177
|
-
yield expect(resend.apiKeys.create({
|
|
178
|
-
name: 'Test',
|
|
179
|
-
permission: 'sending_access',
|
|
180
|
-
domain_id: '1234',
|
|
181
|
-
})).resolves.toMatchInlineSnapshot(`
|
|
182
|
-
{
|
|
183
|
-
"error": {
|
|
184
|
-
"message": "Something went wrong",
|
|
185
|
-
"name": "application_error",
|
|
186
|
-
"statusCode": 500,
|
|
187
|
-
},
|
|
188
|
-
}
|
|
189
|
-
`);
|
|
148
|
+
{
|
|
149
|
+
"data": null,
|
|
150
|
+
"error": {
|
|
151
|
+
"message": "Access must be "full_access" | "sending_access"",
|
|
152
|
+
"name": "invalid_access",
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
`);
|
|
190
156
|
}));
|
|
191
157
|
});
|
|
158
|
+
// describe('restricted by domain', () => {
|
|
159
|
+
// it('creates api key restricted by domain', async () => {
|
|
160
|
+
// fetchMock.mockOnce(
|
|
161
|
+
// JSON.stringify({
|
|
162
|
+
// data: {
|
|
163
|
+
// token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
164
|
+
// id: '430eed87-632a-4ea6-90db-0aace67ec228',
|
|
165
|
+
// },
|
|
166
|
+
// error: null,
|
|
167
|
+
// }),
|
|
168
|
+
// {
|
|
169
|
+
// status: 201,
|
|
170
|
+
// headers: {
|
|
171
|
+
// 'content-type': 'application/json',
|
|
172
|
+
// Authorization: 'Bearer re_924b3rjh2387fbewf823',
|
|
173
|
+
// },
|
|
174
|
+
// },
|
|
175
|
+
// );
|
|
176
|
+
// const resend = new Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
177
|
+
// await expect(
|
|
178
|
+
// resend.apiKeys.create({
|
|
179
|
+
// name: 'Test',
|
|
180
|
+
// permission: 'sending_access',
|
|
181
|
+
// domain_id: '7dfcf219-9900-4169-86f3-801e6d9b935e',
|
|
182
|
+
// }),
|
|
183
|
+
// ).resolves.toMatchInlineSnapshot(`
|
|
184
|
+
// {
|
|
185
|
+
// "id": "430eed87-632a-4ea6-90db-0aace67ec228",
|
|
186
|
+
// "token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
187
|
+
// }
|
|
188
|
+
// `);
|
|
189
|
+
// });
|
|
190
|
+
// it('throws error with wrong access', async () => {
|
|
191
|
+
// const errorResponse: ErrorResponse = {
|
|
192
|
+
// name: 'application_error',
|
|
193
|
+
// message: 'Something went wrong',
|
|
194
|
+
//
|
|
195
|
+
// };
|
|
196
|
+
// fetchMock.mockOnce(
|
|
197
|
+
// JSON.stringify(errorResponse),
|
|
198
|
+
// {
|
|
199
|
+
// status: 500,
|
|
200
|
+
// headers: {
|
|
201
|
+
// 'content-type': 'application/json',
|
|
202
|
+
// Authorization: 'Bearer re_924b3rjh2387fbewf823',
|
|
203
|
+
// },
|
|
204
|
+
// },
|
|
205
|
+
// );
|
|
206
|
+
// const resend = new Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
207
|
+
// await expect(
|
|
208
|
+
// resend.apiKeys.create({
|
|
209
|
+
// name: 'Test',
|
|
210
|
+
// permission: 'sending_access',
|
|
211
|
+
// domain_id: '1234',
|
|
212
|
+
// }),
|
|
213
|
+
// ).resolves.toMatchInlineSnapshot(
|
|
214
|
+
// `
|
|
215
|
+
// {
|
|
216
|
+
// "error": {
|
|
217
|
+
// "message": "Something went wrong",
|
|
218
|
+
// "name": "application_error",
|
|
219
|
+
// "statusCode": 500,
|
|
220
|
+
// },
|
|
221
|
+
// }
|
|
222
|
+
// `,
|
|
223
|
+
// );
|
|
224
|
+
// });
|
|
225
|
+
// });
|
|
192
226
|
});
|
|
193
227
|
describe('list', () => {
|
|
194
228
|
it('lists api keys', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -205,6 +239,7 @@ describe('API Keys', () => {
|
|
|
205
239
|
created_at: '2023-04-06T23:09:49.093947+00:00',
|
|
206
240
|
},
|
|
207
241
|
],
|
|
242
|
+
error: null,
|
|
208
243
|
}), {
|
|
209
244
|
status: 200,
|
|
210
245
|
headers: {
|
|
@@ -214,26 +249,35 @@ describe('API Keys', () => {
|
|
|
214
249
|
});
|
|
215
250
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
216
251
|
yield expect(resend.apiKeys.list()).resolves.toMatchInlineSnapshot(`
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
252
|
+
{
|
|
253
|
+
"data": {
|
|
254
|
+
"data": [
|
|
255
|
+
{
|
|
256
|
+
"created_at": "2023-04-07T20:29:10.666968+00:00",
|
|
257
|
+
"id": "5262504e-8ed7-4fac-bd16-0d4be94bc9f2",
|
|
258
|
+
"name": "My API Key 1",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"created_at": "2023-04-06T23:09:49.093947+00:00",
|
|
262
|
+
"id": "98c37b35-1473-4afe-a627-78e975a36fab",
|
|
263
|
+
"name": "My API Key 2",
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
"error": null,
|
|
267
|
+
},
|
|
268
|
+
"error": null,
|
|
269
|
+
}
|
|
270
|
+
`);
|
|
232
271
|
}));
|
|
233
272
|
});
|
|
234
273
|
describe('remove', () => {
|
|
235
274
|
it('removes an api key', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
236
|
-
fetchMock.mockOnce(JSON.stringify({
|
|
275
|
+
fetchMock.mockOnce(JSON.stringify({
|
|
276
|
+
data: {
|
|
277
|
+
id: '5262504e-8ed7-4fac-bd16-0d4be94bc9f2',
|
|
278
|
+
},
|
|
279
|
+
error: null,
|
|
280
|
+
}), {
|
|
237
281
|
status: 200,
|
|
238
282
|
headers: {
|
|
239
283
|
'content-type': 'application/json',
|
|
@@ -241,15 +285,22 @@ describe('API Keys', () => {
|
|
|
241
285
|
},
|
|
242
286
|
});
|
|
243
287
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
244
|
-
yield expect(resend.apiKeys.remove('5262504e-8ed7-4fac-bd16-0d4be94bc9f2')).resolves.toMatchInlineSnapshot(
|
|
288
|
+
yield expect(resend.apiKeys.remove('5262504e-8ed7-4fac-bd16-0d4be94bc9f2')).resolves.toMatchInlineSnapshot(`
|
|
289
|
+
{
|
|
290
|
+
"data": {
|
|
291
|
+
"data": {
|
|
292
|
+
"id": "5262504e-8ed7-4fac-bd16-0d4be94bc9f2",
|
|
293
|
+
},
|
|
294
|
+
"error": null,
|
|
295
|
+
},
|
|
296
|
+
"error": null,
|
|
297
|
+
}
|
|
298
|
+
`);
|
|
245
299
|
}));
|
|
246
300
|
it('throws error when missing id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
301
|
const errorResponse = {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
message: 'Something went wrong',
|
|
251
|
-
statusCode: 500,
|
|
252
|
-
},
|
|
302
|
+
name: 'application_error',
|
|
303
|
+
message: 'Something went wrong',
|
|
253
304
|
};
|
|
254
305
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
255
306
|
status: 500,
|
|
@@ -260,15 +311,20 @@ describe('API Keys', () => {
|
|
|
260
311
|
});
|
|
261
312
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
262
313
|
const result = resend.apiKeys.remove('');
|
|
263
|
-
yield expect(result).resolves.toMatchInlineSnapshot(
|
|
314
|
+
yield expect(result).resolves.toMatchInlineSnapshot(`
|
|
315
|
+
{
|
|
316
|
+
"data": null,
|
|
317
|
+
"error": {
|
|
318
|
+
"message": "Something went wrong",
|
|
319
|
+
"name": "application_error",
|
|
320
|
+
},
|
|
321
|
+
}
|
|
322
|
+
`);
|
|
264
323
|
}));
|
|
265
324
|
it('throws error when wrong id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
266
325
|
const errorResponse = {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
message: 'API key not found',
|
|
270
|
-
statusCode: 404,
|
|
271
|
-
},
|
|
326
|
+
name: 'not_found',
|
|
327
|
+
message: 'API key not found',
|
|
272
328
|
};
|
|
273
329
|
fetchMock.mockOnce(JSON.stringify(errorResponse), {
|
|
274
330
|
status: 404,
|
|
@@ -279,7 +335,15 @@ describe('API Keys', () => {
|
|
|
279
335
|
});
|
|
280
336
|
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
281
337
|
const result = resend.apiKeys.remove('34bd250e-615a-400c-be11-5912572ee15b');
|
|
282
|
-
yield expect(result).resolves.toMatchInlineSnapshot(
|
|
338
|
+
yield expect(result).resolves.toMatchInlineSnapshot(`
|
|
339
|
+
{
|
|
340
|
+
"data": null,
|
|
341
|
+
"error": {
|
|
342
|
+
"message": "API key not found",
|
|
343
|
+
"name": "not_found",
|
|
344
|
+
},
|
|
345
|
+
}
|
|
346
|
+
`);
|
|
283
347
|
}));
|
|
284
348
|
});
|
|
285
349
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PostOptions } from '../../common/interfaces';
|
|
2
|
+
import { ErrorResponse } from '../../interfaces';
|
|
2
3
|
export interface CreateApiKeyOptions {
|
|
3
4
|
name: string;
|
|
4
5
|
permission?: 'full_access' | 'sending_access';
|
|
@@ -6,7 +7,11 @@ export interface CreateApiKeyOptions {
|
|
|
6
7
|
}
|
|
7
8
|
export interface CreateApiKeyRequestOptions extends PostOptions {
|
|
8
9
|
}
|
|
9
|
-
export interface
|
|
10
|
+
export interface CreateApiKeyResponseSuccess {
|
|
10
11
|
token: string;
|
|
11
12
|
id: string;
|
|
12
13
|
}
|
|
14
|
+
export interface CreateApiKeyResponse {
|
|
15
|
+
data: CreateApiKeyResponseSuccess | null;
|
|
16
|
+
error: ErrorResponse | null;
|
|
17
|
+
}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-api-key-options.interface"), exports);
|
|
18
18
|
__exportStar(require("./list-api-keys.interface"), exports);
|
|
19
|
+
__exportStar(require("./remove-api-keys.interface"), exports);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { ErrorResponse } from '../../interfaces';
|
|
2
|
+
export interface ListApiKeysResponseSuccess {
|
|
2
3
|
name: string;
|
|
3
4
|
id: string;
|
|
4
5
|
created_at: string;
|
|
5
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export interface ListApiKeysResponse {
|
|
8
|
+
data: ListApiKeysResponseSuccess[] | null;
|
|
9
|
+
error: ErrorResponse | null;
|
|
10
|
+
}
|
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
|
}
|
|
@@ -47,9 +47,24 @@ describe('Batch', () => {
|
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
49
|
const data = yield resend.batch.create(payload);
|
|
50
|
-
expect(data).
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
expect(data).toMatchInlineSnapshot(`
|
|
51
|
+
{
|
|
52
|
+
"data": {
|
|
53
|
+
"data": [
|
|
54
|
+
{
|
|
55
|
+
"id": "1234",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "4567",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "4242",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
"error": null,
|
|
66
|
+
}
|
|
67
|
+
`);
|
|
53
68
|
}));
|
|
54
69
|
});
|
|
55
70
|
describe('send', () => {
|
|
@@ -84,9 +99,24 @@ describe('Batch', () => {
|
|
|
84
99
|
},
|
|
85
100
|
});
|
|
86
101
|
const data = yield resend.batch.send(payload);
|
|
87
|
-
expect(data).
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
expect(data).toMatchInlineSnapshot(`
|
|
103
|
+
{
|
|
104
|
+
"data": {
|
|
105
|
+
"data": [
|
|
106
|
+
{
|
|
107
|
+
"id": "1234",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "4567",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "4242",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
"error": null,
|
|
118
|
+
}
|
|
119
|
+
`);
|
|
90
120
|
}));
|
|
91
121
|
});
|
|
92
122
|
});
|
|
@@ -4,11 +4,13 @@ import { ErrorResponse } from '../../interfaces';
|
|
|
4
4
|
export type CreateBatchOptions = CreateEmailOptions[];
|
|
5
5
|
export interface CreateBatchRequestOptions extends PostOptions {
|
|
6
6
|
}
|
|
7
|
-
interface CreateBatchSuccessResponse {
|
|
7
|
+
export interface CreateBatchSuccessResponse {
|
|
8
8
|
data: {
|
|
9
9
|
/** The ID of the newly created email. */
|
|
10
10
|
id: string;
|
|
11
11
|
}[];
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export interface CreateBatchResponse {
|
|
14
|
+
data: CreateBatchSuccessResponse | null;
|
|
15
|
+
error: ErrorResponse | null;
|
|
16
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Resend } from '../resend';
|
|
2
|
-
import { CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, GetDomainResponse, ListDomainsResponse } from './interfaces';
|
|
2
|
+
import { CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, GetDomainResponse, ListDomainsResponse, RemoveDomainsResponse, VerifyDomainsResponse } from './interfaces';
|
|
3
3
|
export declare class Domains {
|
|
4
4
|
private readonly resend;
|
|
5
5
|
constructor(resend: Resend);
|
|
6
6
|
create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
7
|
-
list(): Promise<
|
|
7
|
+
list(): Promise<ListDomainsResponse>;
|
|
8
8
|
get(id: string): Promise<GetDomainResponse>;
|
|
9
|
-
remove(id: string): Promise<
|
|
10
|
-
verify(id: string): Promise<
|
|
9
|
+
remove(id: string): Promise<RemoveDomainsResponse>;
|
|
10
|
+
verify(id: string): Promise<VerifyDomainsResponse>;
|
|
11
11
|
}
|
|
@@ -34,12 +34,14 @@ class Domains {
|
|
|
34
34
|
}
|
|
35
35
|
remove(id) {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
yield this.resend.delete(`/domains/${id}`);
|
|
37
|
+
const data = yield this.resend.delete(`/domains/${id}`);
|
|
38
|
+
return data;
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
verify(id) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
yield this.resend.post(`/domains/${id}/verify`);
|
|
43
|
+
const data = yield this.resend.post(`/domains/${id}/verify`);
|
|
44
|
+
return data;
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
}
|