resend 0.9.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.
- package/build/package.json +1 -1
- package/build/src/interfaces.d.ts +19 -1
- package/build/src/resend.js +14 -1
- package/build/src/resend.spec.js +9 -3
- package/package.json +1 -1
package/build/package.json
CHANGED
|
@@ -9,7 +9,7 @@ export interface SendEmailData {
|
|
|
9
9
|
/** Cc recipient email address. Max 50. */
|
|
10
10
|
cc?: string | string[];
|
|
11
11
|
/** Reply-to email address. Max 50. */
|
|
12
|
-
|
|
12
|
+
replyTo?: string | string[];
|
|
13
13
|
/** Email subject. */
|
|
14
14
|
subject?: string;
|
|
15
15
|
/** The HTML version of the message. */
|
|
@@ -19,3 +19,21 @@ export interface SendEmailData {
|
|
|
19
19
|
/** The React version of the message. */
|
|
20
20
|
react?: ReactElement;
|
|
21
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
|
+
}
|
package/build/src/resend.js
CHANGED
|
@@ -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
|
|
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) {
|
package/build/src/resend.spec.js
CHANGED
|
@@ -86,20 +86,26 @@ describe('Resend', () => {
|
|
|
86
86
|
const data = yield resend.sendEmail(payload);
|
|
87
87
|
expect(data).toMatchSnapshot();
|
|
88
88
|
}));
|
|
89
|
-
it('sends email with multiple
|
|
90
|
-
const
|
|
89
|
+
it('sends email with multiple replyTo emails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const apiPayload = {
|
|
91
91
|
from: 'admin@resend.com',
|
|
92
92
|
to: 'bu@resend.com',
|
|
93
93
|
reply_to: ['foo@resend.com', 'bar@resend.com'],
|
|
94
94
|
subject: 'Hello World',
|
|
95
95
|
};
|
|
96
|
-
mock.onPost('https://api.resend.com/email',
|
|
96
|
+
mock.onPost('https://api.resend.com/email', apiPayload).replyOnce(200, {
|
|
97
97
|
id: '1234',
|
|
98
98
|
from: 'admin@resend.com',
|
|
99
99
|
to: 'bu@resend.com',
|
|
100
100
|
reply_to: ['foo@resend.com', 'bar@resend.com'],
|
|
101
101
|
created_at: '123',
|
|
102
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
|
+
};
|
|
103
109
|
const data = yield resend.sendEmail(payload);
|
|
104
110
|
expect(data).toMatchSnapshot();
|
|
105
111
|
}));
|