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.
Files changed (38) hide show
  1. package/build/package.json +2 -2
  2. package/build/src/api-keys/api-keys.d.ts +4 -4
  3. package/build/src/api-keys/api-keys.js +2 -1
  4. package/build/src/api-keys/api-keys.spec.js +195 -131
  5. package/build/src/api-keys/interfaces/create-api-key-options.interface.d.ts +6 -1
  6. package/build/src/api-keys/interfaces/index.d.ts +1 -0
  7. package/build/src/api-keys/interfaces/index.js +1 -0
  8. package/build/src/api-keys/interfaces/list-api-keys.interface.d.ts +7 -2
  9. package/build/src/api-keys/interfaces/remove-api-keys.interface.d.ts +8 -0
  10. package/build/src/api-keys/interfaces/remove-api-keys.interface.js +2 -0
  11. package/build/src/batch/batch.js +1 -1
  12. package/build/src/batch/batch.spec.js +36 -6
  13. package/build/src/batch/interfaces/create-batch-options.interface.d.ts +5 -3
  14. package/build/src/domains/domains.d.ts +4 -4
  15. package/build/src/domains/domains.js +4 -2
  16. package/build/src/domains/domains.spec.js +211 -198
  17. package/build/src/domains/interfaces/create-domain-options.interface.d.ts +6 -31
  18. package/build/src/domains/interfaces/get-domain.interface.d.ts +6 -9
  19. package/build/src/domains/interfaces/index.d.ts +2 -0
  20. package/build/src/domains/interfaces/index.js +2 -0
  21. package/build/src/domains/interfaces/list-domains.interface.d.ts +6 -3
  22. package/build/src/domains/interfaces/remove-domain.interface.d.ts +7 -0
  23. package/build/src/domains/interfaces/remove-domain.interface.js +2 -0
  24. package/build/src/domains/interfaces/verify-domain.interface.d.ts +7 -0
  25. package/build/src/domains/interfaces/verify-domain.interface.js +2 -0
  26. package/build/src/emails/emails.d.ts +1 -1
  27. package/build/src/emails/emails.js +1 -1
  28. package/build/src/emails/emails.spec.js +76 -71
  29. package/build/src/emails/interfaces/create-email-options.interface.d.ts +5 -2
  30. package/build/src/emails/interfaces/get-email-options.interface.d.ts +6 -1
  31. package/build/src/error.d.ts +2 -3
  32. package/build/src/error.js +3 -5
  33. package/build/src/guards.js +5 -8
  34. package/build/src/interfaces.d.ts +2 -8
  35. package/build/src/resend.d.ts +20 -7
  36. package/build/src/resend.js +8 -14
  37. package/build/src/resend.spec.js +82 -67
  38. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "2.0.0-canary.0",
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.8"
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<import("..").ErrorResponse | CreateApiKeyResponse>;
7
- list(): Promise<import("..").ErrorResponse | ListApiKeysResponse>;
8
- remove(id: string): Promise<void>;
6
+ create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
7
+ list(): Promise<ListApiKeysResponse>;
8
+ remove(id: string): Promise<RemoveApiKeyResponse>;
9
9
  }
@@ -28,7 +28,8 @@ class ApiKeys {
28
28
  }
29
29
  remove(id) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- yield this.resend.delete(`/api-keys/${id}`);
31
+ const data = yield this.resend.delete(`/api-keys/${id}`);
32
+ return data;
32
33
  });
33
34
  }
34
35
  }
@@ -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
- token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
21
- id: '430eed87-632a-4ea6-90db-0aace67ec228',
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
- "id": "430eed87-632a-4ea6-90db-0aace67ec228",
34
- "token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
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
- error: {
41
- statusCode: 422,
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
- "error": {
58
- "message": "Missing "name" field",
59
- "name": "missing_required_field",
60
- "statusCode": 422,
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
- token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
69
- id: '430eed87-632a-4ea6-90db-0aace67ec228',
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
- "id": "430eed87-632a-4ea6-90db-0aace67ec228",
81
- "token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
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
- token: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
88
- id: '430eed87-632a-4ea6-90db-0aace67ec228',
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
- "id": "430eed87-632a-4ea6-90db-0aace67ec228",
103
- "token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
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
- error: {
110
- statusCode: 422,
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
- "error": {
129
- "message": "Access must be "full_access" | "sending_access"",
130
- "name": "invalid_access",
131
- "statusCode": 422,
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
- "data": [
219
- {
220
- "created_at": "2023-04-07T20:29:10.666968+00:00",
221
- "id": "5262504e-8ed7-4fac-bd16-0d4be94bc9f2",
222
- "name": "My API Key 1",
223
- },
224
- {
225
- "created_at": "2023-04-06T23:09:49.093947+00:00",
226
- "id": "98c37b35-1473-4afe-a627-78e975a36fab",
227
- "name": "My API Key 2",
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('undefined');
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
- error: {
249
- name: 'application_error',
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('undefined');
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
- error: {
268
- name: 'not_found',
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('undefined');
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 CreateApiKeyResponse {
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
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './create-api-key-options.interface';
2
2
  export * from './list-api-keys.interface';
3
+ export * from './remove-api-keys.interface';
@@ -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
- export type ListApiKeysResponse = {
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
+ }
@@ -0,0 +1,8 @@
1
+ import { ErrorResponse } from '../../interfaces';
2
+ export interface RemoveApiKeyResponseSuccess {
3
+ id: string;
4
+ }
5
+ export interface RemoveApiKeyResponse {
6
+ data: RemoveApiKeyResponseSuccess | null;
7
+ error: ErrorResponse | null;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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.render)(email.react);
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).toMatchObject({
51
- data: [{ id: '1234' }, { id: '4567' }, { id: '4242' }],
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).toMatchObject({
88
- data: [{ id: '1234' }, { id: '4567' }, { id: '4242' }],
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 type CreateBatchResponse = CreateBatchSuccessResponse | ErrorResponse;
14
- export {};
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<import("..").ErrorResponse | ListDomainsResponse>;
7
+ list(): Promise<ListDomainsResponse>;
8
8
  get(id: string): Promise<GetDomainResponse>;
9
- remove(id: string): Promise<void>;
10
- verify(id: string): Promise<void>;
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
  }