resend 1.1.0 → 2.0.0-canary.1

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