resend 3.2.0 → 3.3.0-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 CHANGED
@@ -1,18 +1,18 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  interface GetOptions {
4
- query?: Record<string, any>;
4
+ query?: Record<string, unknown>;
5
5
  }
6
6
 
7
7
  interface PostOptions {
8
8
  query?: {
9
- [key: string]: any;
9
+ [key: string]: unknown;
10
10
  };
11
11
  }
12
12
 
13
13
  interface PutOptions {
14
14
  query?: {
15
- [key: string]: any;
15
+ [key: string]: unknown;
16
16
  };
17
17
  }
18
18
 
@@ -65,8 +65,7 @@ interface ListApiKeysResponse {
65
65
  error: ErrorResponse | null;
66
66
  }
67
67
 
68
- interface RemoveApiKeyResponseSuccess {
69
- }
68
+ type RemoveApiKeyResponseSuccess = {};
70
69
  interface RemoveApiKeyResponse {
71
70
  data: RemoveApiKeyResponseSuccess | null;
72
71
  error: ErrorResponse | null;
@@ -142,19 +141,19 @@ interface EmailRenderOptions {
142
141
  /**
143
142
  * The React component used to write the message.
144
143
  *
145
- * @link https://resend.com/api-reference/emails/send-email#body-parameters
144
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
146
145
  */
147
146
  react?: React.ReactElement | React.ReactNode | null;
148
147
  /**
149
148
  * The HTML version of the message.
150
149
  *
151
- * @link https://resend.com/api-reference/emails/send-email#body-parameters
150
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
152
151
  */
153
152
  html?: string;
154
153
  /**
155
154
  * The plain text version of the message.
156
155
  *
157
- * @link https://resend.com/api-reference/emails/send-email#body-parameters
156
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
158
157
  */
159
158
  text?: string;
160
159
  }
@@ -267,7 +266,7 @@ declare class Batch {
267
266
 
268
267
  interface PatchOptions {
269
268
  query?: {
270
- [key: string]: any;
269
+ [key: string]: unknown;
271
270
  };
272
271
  }
273
272
 
@@ -330,13 +329,13 @@ interface RemoveByOptions {
330
329
  /**
331
330
  * The contact id.
332
331
  *
333
- * @link https://resend.com/api-reference/contacts/delete-contact#body-parameters
332
+ * @link https://resend.com/docs/api-reference/contacts/delete-contact#body-parameters
334
333
  */
335
334
  id?: string;
336
335
  /**
337
336
  * The contact email.
338
337
  *
339
- * @link https://resend.com/api-reference/contacts/delete-contact#body-parameters
338
+ * @link https://resend.com/docs/api-reference/contacts/delete-contact#body-parameters
340
339
  */
341
340
  email?: string;
342
341
  }
@@ -352,10 +351,12 @@ interface UpdateContactOptions {
352
351
  id: string;
353
352
  audienceId: string;
354
353
  unsubscribed?: boolean;
355
- fistName?: string;
354
+ firstName?: string;
356
355
  lastName?: string;
357
356
  }
358
- type UpdateContactResponseSuccess = Pick<Contact, 'id'>;
357
+ type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
358
+ object: 'contact';
359
+ };
359
360
  interface UpdateContactResponse {
360
361
  data: UpdateContactResponseSuccess | null;
361
362
  error: ErrorResponse | null;
@@ -371,7 +372,7 @@ declare class Contacts {
371
372
  remove(payload: RemoveContactOptions): Promise<RemoveContactsResponse>;
372
373
  }
373
374
 
374
- type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
375
+ type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
375
376
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
376
377
  type DomainRecords = DomainSpfRecord | DomainDkimRecord;
377
378
  interface DomainSpfRecord {
@@ -435,10 +436,20 @@ interface ListDomainsResponse {
435
436
  error: ErrorResponse | null;
436
437
  }
437
438
 
439
+ type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
440
+ object: 'domain';
441
+ deleted: boolean;
442
+ };
443
+ interface RemoveDomainsResponse {
444
+ data: RemoveDomainsResponseSuccess | null;
445
+ error: ErrorResponse | null;
446
+ }
447
+
438
448
  interface UpdateDomainsOptions {
439
449
  id: string;
440
450
  clickTracking?: boolean;
441
451
  openTracking?: boolean;
452
+ tls?: 'enforced' | 'opportunistic';
442
453
  }
443
454
  type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
444
455
  object: 'domain';
@@ -448,13 +459,9 @@ interface UpdateDomainsResponse {
448
459
  error: ErrorResponse | null;
449
460
  }
450
461
 
451
- type RemoveDomainsResponseSuccess = Pick<Domain, 'id'>;
452
- interface RemoveDomainsResponse {
453
- data: RemoveDomainsResponseSuccess | null;
454
- error: ErrorResponse | null;
455
- }
456
-
457
- type VerifyDomainsResponseSuccess = Domain[];
462
+ type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
463
+ object: 'domain';
464
+ };
458
465
  interface VerifyDomainsResponse {
459
466
  data: VerifyDomainsResponseSuccess | null;
460
467
  error: ErrorResponse | null;
@@ -478,7 +485,7 @@ interface GetEmailResponseSuccess {
478
485
  from: string;
479
486
  html: string | null;
480
487
  id: string;
481
- last_event: string;
488
+ last_event: 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained' | 'delivery_delayed';
482
489
  reply_to: string[] | null;
483
490
  subject: string;
484
491
  text: string | null;
@@ -520,11 +527,11 @@ declare class Resend {
520
527
  data: T | null;
521
528
  error: ErrorResponse | null;
522
529
  }>;
523
- put<T>(path: string, entity: any, options?: PutOptions): Promise<{
530
+ put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
524
531
  data: T | null;
525
532
  error: ErrorResponse | null;
526
533
  }>;
527
- patch<T>(path: string, entity: any, options?: PatchOptions): Promise<{
534
+ patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
528
535
  data: T | null;
529
536
  error: ErrorResponse | null;
530
537
  }>;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  interface GetOptions {
4
- query?: Record<string, any>;
4
+ query?: Record<string, unknown>;
5
5
  }
6
6
 
7
7
  interface PostOptions {
8
8
  query?: {
9
- [key: string]: any;
9
+ [key: string]: unknown;
10
10
  };
11
11
  }
12
12
 
13
13
  interface PutOptions {
14
14
  query?: {
15
- [key: string]: any;
15
+ [key: string]: unknown;
16
16
  };
17
17
  }
18
18
 
@@ -65,8 +65,7 @@ interface ListApiKeysResponse {
65
65
  error: ErrorResponse | null;
66
66
  }
67
67
 
68
- interface RemoveApiKeyResponseSuccess {
69
- }
68
+ type RemoveApiKeyResponseSuccess = {};
70
69
  interface RemoveApiKeyResponse {
71
70
  data: RemoveApiKeyResponseSuccess | null;
72
71
  error: ErrorResponse | null;
@@ -142,19 +141,19 @@ interface EmailRenderOptions {
142
141
  /**
143
142
  * The React component used to write the message.
144
143
  *
145
- * @link https://resend.com/api-reference/emails/send-email#body-parameters
144
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
146
145
  */
147
146
  react?: React.ReactElement | React.ReactNode | null;
148
147
  /**
149
148
  * The HTML version of the message.
150
149
  *
151
- * @link https://resend.com/api-reference/emails/send-email#body-parameters
150
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
152
151
  */
153
152
  html?: string;
154
153
  /**
155
154
  * The plain text version of the message.
156
155
  *
157
- * @link https://resend.com/api-reference/emails/send-email#body-parameters
156
+ * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
158
157
  */
159
158
  text?: string;
160
159
  }
@@ -267,7 +266,7 @@ declare class Batch {
267
266
 
268
267
  interface PatchOptions {
269
268
  query?: {
270
- [key: string]: any;
269
+ [key: string]: unknown;
271
270
  };
272
271
  }
273
272
 
@@ -330,13 +329,13 @@ interface RemoveByOptions {
330
329
  /**
331
330
  * The contact id.
332
331
  *
333
- * @link https://resend.com/api-reference/contacts/delete-contact#body-parameters
332
+ * @link https://resend.com/docs/api-reference/contacts/delete-contact#body-parameters
334
333
  */
335
334
  id?: string;
336
335
  /**
337
336
  * The contact email.
338
337
  *
339
- * @link https://resend.com/api-reference/contacts/delete-contact#body-parameters
338
+ * @link https://resend.com/docs/api-reference/contacts/delete-contact#body-parameters
340
339
  */
341
340
  email?: string;
342
341
  }
@@ -352,10 +351,12 @@ interface UpdateContactOptions {
352
351
  id: string;
353
352
  audienceId: string;
354
353
  unsubscribed?: boolean;
355
- fistName?: string;
354
+ firstName?: string;
356
355
  lastName?: string;
357
356
  }
358
- type UpdateContactResponseSuccess = Pick<Contact, 'id'>;
357
+ type UpdateContactResponseSuccess = Pick<Contact, 'id'> & {
358
+ object: 'contact';
359
+ };
359
360
  interface UpdateContactResponse {
360
361
  data: UpdateContactResponseSuccess | null;
361
362
  error: ErrorResponse | null;
@@ -371,7 +372,7 @@ declare class Contacts {
371
372
  remove(payload: RemoveContactOptions): Promise<RemoveContactsResponse>;
372
373
  }
373
374
 
374
- type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
375
+ type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
375
376
  type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
376
377
  type DomainRecords = DomainSpfRecord | DomainDkimRecord;
377
378
  interface DomainSpfRecord {
@@ -435,10 +436,20 @@ interface ListDomainsResponse {
435
436
  error: ErrorResponse | null;
436
437
  }
437
438
 
439
+ type RemoveDomainsResponseSuccess = Pick<Domain, 'id'> & {
440
+ object: 'domain';
441
+ deleted: boolean;
442
+ };
443
+ interface RemoveDomainsResponse {
444
+ data: RemoveDomainsResponseSuccess | null;
445
+ error: ErrorResponse | null;
446
+ }
447
+
438
448
  interface UpdateDomainsOptions {
439
449
  id: string;
440
450
  clickTracking?: boolean;
441
451
  openTracking?: boolean;
452
+ tls?: 'enforced' | 'opportunistic';
442
453
  }
443
454
  type UpdateDomainsResponseSuccess = Pick<Domain, 'id'> & {
444
455
  object: 'domain';
@@ -448,13 +459,9 @@ interface UpdateDomainsResponse {
448
459
  error: ErrorResponse | null;
449
460
  }
450
461
 
451
- type RemoveDomainsResponseSuccess = Pick<Domain, 'id'>;
452
- interface RemoveDomainsResponse {
453
- data: RemoveDomainsResponseSuccess | null;
454
- error: ErrorResponse | null;
455
- }
456
-
457
- type VerifyDomainsResponseSuccess = Domain[];
462
+ type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
463
+ object: 'domain';
464
+ };
458
465
  interface VerifyDomainsResponse {
459
466
  data: VerifyDomainsResponseSuccess | null;
460
467
  error: ErrorResponse | null;
@@ -478,7 +485,7 @@ interface GetEmailResponseSuccess {
478
485
  from: string;
479
486
  html: string | null;
480
487
  id: string;
481
- last_event: string;
488
+ last_event: 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained' | 'delivery_delayed';
482
489
  reply_to: string[] | null;
483
490
  subject: string;
484
491
  text: string | null;
@@ -520,11 +527,11 @@ declare class Resend {
520
527
  data: T | null;
521
528
  error: ErrorResponse | null;
522
529
  }>;
523
- put<T>(path: string, entity: any, options?: PutOptions): Promise<{
530
+ put<T>(path: string, entity: unknown, options?: PutOptions): Promise<{
524
531
  data: T | null;
525
532
  error: ErrorResponse | null;
526
533
  }>;
527
- patch<T>(path: string, entity: any, options?: PatchOptions): Promise<{
534
+ patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<{
528
535
  data: T | null;
529
536
  error: ErrorResponse | null;
530
537
  }>;
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
@@ -17,6 +19,7 @@ var __spreadValues = (a, b) => {
17
19
  }
18
20
  return a;
19
21
  };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
23
  var __export = (target, all) => {
21
24
  for (var name in all)
22
25
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -59,7 +62,7 @@ __export(src_exports, {
59
62
  module.exports = __toCommonJS(src_exports);
60
63
 
61
64
  // package.json
62
- var version = "3.2.0";
65
+ var version = "3.3.0-canary.0";
63
66
 
64
67
  // src/api-keys/api-keys.ts
65
68
  var ApiKeys = class {
@@ -202,7 +205,7 @@ var Contacts = class {
202
205
  `/audiences/${payload.audienceId}/contacts/${payload.id}`,
203
206
  {
204
207
  unsubscribed: payload.unsubscribed,
205
- first_name: payload.fistName,
208
+ first_name: payload.firstName,
206
209
  last_name: payload.lastName
207
210
  }
208
211
  );
@@ -254,7 +257,8 @@ var Domains = class {
254
257
  `/domains/${payload.id}`,
255
258
  {
256
259
  click_tracking: payload.clickTracking,
257
- open_tracking: payload.openTracking
260
+ open_tracking: payload.openTracking,
261
+ tls: payload.tls
258
262
  }
259
263
  );
260
264
  return data;
@@ -360,11 +364,22 @@ var Resend = class {
360
364
  return __async(this, arguments, function* (path, options = {}) {
361
365
  const response = yield fetch(`${baseUrl}${path}`, options);
362
366
  if (!response.ok) {
363
- const error = yield response.json();
364
- if (isResendErrorResponse(error)) {
367
+ let error = {
368
+ message: response.statusText,
369
+ name: "application_error"
370
+ };
371
+ try {
372
+ error = yield response.json();
373
+ if (isResendErrorResponse(error)) {
374
+ return { data: null, error };
375
+ }
376
+ return { data: null, error };
377
+ } catch (err) {
378
+ if (err instanceof Error) {
379
+ return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
380
+ }
365
381
  return { data: null, error };
366
382
  }
367
- return { data: null, error };
368
383
  }
369
384
  const data = yield response.json();
370
385
  return { data, error: null };
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  var __async = (__this, __arguments, generator) => {
18
21
  return new Promise((resolve, reject) => {
19
22
  var fulfilled = (value) => {
@@ -36,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
36
39
  };
37
40
 
38
41
  // package.json
39
- var version = "3.2.0";
42
+ var version = "3.3.0-canary.0";
40
43
 
41
44
  // src/api-keys/api-keys.ts
42
45
  var ApiKeys = class {
@@ -179,7 +182,7 @@ var Contacts = class {
179
182
  `/audiences/${payload.audienceId}/contacts/${payload.id}`,
180
183
  {
181
184
  unsubscribed: payload.unsubscribed,
182
- first_name: payload.fistName,
185
+ first_name: payload.firstName,
183
186
  last_name: payload.lastName
184
187
  }
185
188
  );
@@ -231,7 +234,8 @@ var Domains = class {
231
234
  `/domains/${payload.id}`,
232
235
  {
233
236
  click_tracking: payload.clickTracking,
234
- open_tracking: payload.openTracking
237
+ open_tracking: payload.openTracking,
238
+ tls: payload.tls
235
239
  }
236
240
  );
237
241
  return data;
@@ -337,11 +341,22 @@ var Resend = class {
337
341
  return __async(this, arguments, function* (path, options = {}) {
338
342
  const response = yield fetch(`${baseUrl}${path}`, options);
339
343
  if (!response.ok) {
340
- const error = yield response.json();
341
- if (isResendErrorResponse(error)) {
344
+ let error = {
345
+ message: response.statusText,
346
+ name: "application_error"
347
+ };
348
+ try {
349
+ error = yield response.json();
350
+ if (isResendErrorResponse(error)) {
351
+ return { data: null, error };
352
+ }
353
+ return { data: null, error };
354
+ } catch (err) {
355
+ if (err instanceof Error) {
356
+ return { data: null, error: __spreadProps(__spreadValues({}, error), { message: err.message }) };
357
+ }
342
358
  return { data: null, error };
343
359
  }
344
- return { data: null, error };
345
360
  }
346
361
  const data = yield response.json();
347
362
  return { data, error: null };
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "3.2.0",
3
+ "version": "3.3.0-canary.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist/**"
10
- ],
8
+ "files": ["dist/**"],
11
9
  "engines": {
12
10
  "node": ">=18"
13
11
  },
@@ -23,15 +21,15 @@
23
21
  }
24
22
  }
25
23
  },
26
- "packageManager": "yarn@3.8.0",
27
24
  "scripts": {
28
25
  "build": "tsup src/index.ts --format esm,cjs --dts",
29
26
  "test": "jest",
30
27
  "test:watch": "jest --watch",
31
- "lint": "eslint --fix --ext .ts ./src",
32
- "format:check": "prettier --check \"**/*.{ts,tsx}\"",
33
- "format": "prettier --write .",
34
- "prepublishOnly": "yarn run build"
28
+ "format:apply": "biome check --apply .",
29
+ "format:check": "biome format .",
30
+ "format": "biome format --write .",
31
+ "lint": "biome check .",
32
+ "prepublishOnly": "pnpm run build"
35
33
  },
36
34
  "repository": {
37
35
  "type": "git",
@@ -44,21 +42,19 @@
44
42
  },
45
43
  "homepage": "https://github.com/resendlabs/resend-node#readme",
46
44
  "dependencies": {
47
- "@react-email/render": "0.0.12"
45
+ "@react-email/render": "0.0.15"
48
46
  },
49
47
  "devDependencies": {
48
+ "@biomejs/biome": "1.8.1",
50
49
  "@types/jest": "29.5.12",
51
- "@types/node": "18.19.15",
52
- "@types/react": "18.2.55",
53
- "@typescript-eslint/eslint-plugin": "6.21.0",
54
- "@typescript-eslint/parser": "6.21.0",
55
- "eslint": "8.56.0",
50
+ "@types/node": "18.19.34",
51
+ "@types/react": "18.3.3",
56
52
  "jest": "29.7.0",
57
53
  "jest-fetch-mock": "3.0.3",
58
- "prettier": "3.2.5",
59
- "ts-jest": "29.1.2",
54
+ "ts-jest": "29.1.4",
60
55
  "ts-node": "10.9.2",
61
56
  "tsup": "7.2.0",
62
- "typescript": "5.3.3"
63
- }
57
+ "typescript": "5.4.5"
58
+ },
59
+ "packageManager": "pnpm@9.3.0"
64
60
  }
package/readme.md CHANGED
@@ -61,9 +61,7 @@ Start by creating your email template as a React component.
61
61
  ```jsx
62
62
  import React from 'react';
63
63
 
64
- export default function EmailTemplate(props) {
65
- const { firstName, product } = props;
66
-
64
+ export default function EmailTemplate({ firstName, product }) {
67
65
  return (
68
66
  <div>
69
67
  <h1>Welcome, {firstName}!</h1>