resend 0.8.0 → 0.9.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -8,6 +8,8 @@ export interface SendEmailData {
8
8
  bcc?: string | string[];
9
9
  /** Cc recipient email address. Max 50. */
10
10
  cc?: string | string[];
11
+ /** Reply-to email address. Max 50. */
12
+ replyTo?: string | string[];
11
13
  /** Email subject. */
12
14
  subject?: string;
13
15
  /** The HTML version of the message. */
@@ -17,3 +19,21 @@ export interface SendEmailData {
17
19
  /** The React version of the message. */
18
20
  react?: ReactElement;
19
21
  }
22
+ export interface SendEmailRequest {
23
+ /** Sender email address. */
24
+ from: string;
25
+ /** Recipient email address. Max 50. */
26
+ to: string | string[];
27
+ /** Bcc recipient email address. Max 50. */
28
+ bcc?: string | string[];
29
+ /** Cc recipient email address. Max 50. */
30
+ cc?: string | string[];
31
+ /** Reply-to email address. Max 50. */
32
+ reply_to?: string | string[];
33
+ /** Email subject. */
34
+ subject?: string;
35
+ /** The HTML version of the message. */
36
+ text?: string;
37
+ /** The plain text version of the message. */
38
+ html?: string;
39
+ }
@@ -45,7 +45,20 @@ class Resend {
45
45
  data.html = (0, render_1.render)(data.react);
46
46
  delete data.react;
47
47
  }
48
- const response = yield this.request(path, { method: 'POST', data });
48
+ const requestData = {
49
+ from: data.from,
50
+ to: data.to,
51
+ bcc: data.bcc,
52
+ cc: data.cc,
53
+ reply_to: data.replyTo,
54
+ subject: data.subject,
55
+ text: data.text,
56
+ html: data.html,
57
+ };
58
+ const response = yield this.request(path, {
59
+ method: 'POST',
60
+ data: requestData,
61
+ });
49
62
  return response.data;
50
63
  }
51
64
  catch (error) {
@@ -86,4 +86,27 @@ describe('Resend', () => {
86
86
  const data = yield resend.sendEmail(payload);
87
87
  expect(data).toMatchSnapshot();
88
88
  }));
89
+ it('sends email with multiple replyTo emails', () => __awaiter(void 0, void 0, void 0, function* () {
90
+ const apiPayload = {
91
+ from: 'admin@resend.com',
92
+ to: 'bu@resend.com',
93
+ reply_to: ['foo@resend.com', 'bar@resend.com'],
94
+ subject: 'Hello World',
95
+ };
96
+ mock.onPost('https://api.resend.com/email', apiPayload).replyOnce(200, {
97
+ id: '1234',
98
+ from: 'admin@resend.com',
99
+ to: 'bu@resend.com',
100
+ reply_to: ['foo@resend.com', 'bar@resend.com'],
101
+ created_at: '123',
102
+ });
103
+ const payload = {
104
+ from: 'admin@resend.com',
105
+ to: 'bu@resend.com',
106
+ replyTo: ['foo@resend.com', 'bar@resend.com'],
107
+ subject: 'Hello World',
108
+ };
109
+ const data = yield resend.sendEmail(payload);
110
+ expect(data).toMatchSnapshot();
111
+ }));
89
112
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",