resend 0.16.0 → 0.17.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "0.16.0",
3
+ "version": "0.17.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,15 +31,15 @@
31
31
  "axios": "1.4.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/jest": "29.5.2",
34
+ "@types/jest": "29.5.3",
35
35
  "@types/node": "18.16.2",
36
36
  "@types/react": "18.2.0",
37
37
  "axios-mock-adapter": "1.21.5",
38
- "jest": "29.5.0",
39
- "prettier": "2.8.8",
38
+ "jest": "29.6.1",
39
+ "prettier": "3.0.0",
40
40
  "supertest": "6.3.3",
41
- "ts-jest": "29.1.0",
41
+ "ts-jest": "29.1.1",
42
42
  "tslint": "6.1.3",
43
- "typescript": "5.1.3"
43
+ "typescript": "5.1.6"
44
44
  }
45
45
  }
@@ -1,19 +1,27 @@
1
1
  /// <reference types="node" />
2
- import { ReactElement } from 'react';
2
+ import * as React from 'react';
3
3
  import { PostOptions } from '../../common/interfaces';
4
- export interface CreateEmailOptions {
4
+ interface CreateEmailBaseOptions {
5
5
  attachments?: Attachment[];
6
6
  bcc?: string | string[];
7
7
  cc?: string | string[];
8
8
  from: string;
9
- html?: string;
10
- react?: ReactElement | null;
9
+ headers?: Record<string, string>;
10
+ react?: React.ReactElement | React.ReactNode | null;
11
11
  reply_to?: string | string[];
12
12
  subject: string;
13
13
  tags?: Tag[];
14
- text?: string;
15
14
  to: string | string[];
16
15
  }
16
+ interface CreateEmailWithHtmlOptions extends CreateEmailBaseOptions {
17
+ html: string;
18
+ text?: string;
19
+ }
20
+ interface CreateEmailWithTextOptions extends CreateEmailBaseOptions {
21
+ html?: string;
22
+ text: string;
23
+ }
24
+ export type CreateEmailOptions = CreateEmailWithHtmlOptions | CreateEmailWithTextOptions;
17
25
  export interface CreateEmailRequestOptions extends PostOptions {
18
26
  }
19
27
  export interface CreateEmailResponse {
@@ -27,6 +27,7 @@ describe('Resend', () => {
27
27
  from: 'bu@resend.com',
28
28
  to: 'zeno@resend.com',
29
29
  subject: 'Hello World',
30
+ html: '<h1>Hello world</h1>',
30
31
  };
31
32
  mock.onPost('/emails', payload).replyOnce(200, {
32
33
  id: '1234',
@@ -49,6 +50,7 @@ describe('Resend', () => {
49
50
  from: 'admin@resend.com',
50
51
  to: ['bu@resend.com', 'zeno@resend.com'],
51
52
  subject: 'Hello World',
53
+ text: 'Hello world',
52
54
  };
53
55
  mock.onPost('/emails', payload).replyOnce(200, {
54
56
  id: '1234',
@@ -75,6 +77,7 @@ describe('Resend', () => {
75
77
  to: 'bu@resend.com',
76
78
  bcc: ['foo@resend.com', 'bar@resend.com'],
77
79
  subject: 'Hello World',
80
+ text: 'Hello world',
78
81
  };
79
82
  mock.onPost('/emails', payload).replyOnce(200, {
80
83
  id: '1234',
@@ -103,6 +106,7 @@ describe('Resend', () => {
103
106
  to: 'bu@resend.com',
104
107
  cc: ['foo@resend.com', 'bar@resend.com'],
105
108
  subject: 'Hello World',
109
+ text: 'Hello world',
106
110
  };
107
111
  mock.onPost('/emails', payload).replyOnce(200, {
108
112
  id: '1234',
@@ -131,6 +135,7 @@ describe('Resend', () => {
131
135
  to: 'bu@resend.com',
132
136
  reply_to: ['foo@resend.com', 'bar@resend.com'],
133
137
  subject: 'Hello World',
138
+ text: 'Hello world',
134
139
  };
135
140
  mock.onPost('/emails', apiPayload).replyOnce(200, {
136
141
  id: '1234',
@@ -144,6 +149,7 @@ describe('Resend', () => {
144
149
  to: 'bu@resend.com',
145
150
  reply_to: ['foo@resend.com', 'bar@resend.com'],
146
151
  subject: 'Hello World',
152
+ text: 'Hello world',
147
153
  };
148
154
  const data = yield resend.emails.send(payload);
149
155
  expect(data).toMatchInlineSnapshot(`
@@ -159,4 +165,24 @@ describe('Resend', () => {
159
165
  }
160
166
  `);
161
167
  }));
168
+ it('can send an email with headers', () => __awaiter(void 0, void 0, void 0, function* () {
169
+ const payload = {
170
+ from: 'admin@resend.com',
171
+ headers: {
172
+ 'X-Entity-Ref-ID': '123',
173
+ },
174
+ subject: 'Hello World',
175
+ text: 'Hello world',
176
+ to: 'bu@resend.com',
177
+ };
178
+ mock.onPost('/emails', payload).replyOnce(200, {
179
+ id: '1234',
180
+ });
181
+ const data = yield resend.emails.send(payload);
182
+ expect(data).toMatchInlineSnapshot(`
183
+ {
184
+ "id": "1234",
185
+ }
186
+ `);
187
+ }));
162
188
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "0.16.0",
3
+ "version": "0.17.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,15 +31,15 @@
31
31
  "axios": "1.4.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/jest": "29.5.2",
34
+ "@types/jest": "29.5.3",
35
35
  "@types/node": "18.16.2",
36
36
  "@types/react": "18.2.0",
37
37
  "axios-mock-adapter": "1.21.5",
38
- "jest": "29.5.0",
39
- "prettier": "2.8.8",
38
+ "jest": "29.6.1",
39
+ "prettier": "3.0.0",
40
40
  "supertest": "6.3.3",
41
- "ts-jest": "29.1.0",
41
+ "ts-jest": "29.1.1",
42
42
  "tslint": "6.1.3",
43
- "typescript": "5.1.3"
43
+ "typescript": "5.1.6"
44
44
  }
45
45
  }