resend 0.14.0 → 0.15.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/build/package.json +1 -1
- package/build/src/emails/interfaces/create-email-options.interface.d.ts +20 -5
- package/build/src/index.d.ts +1 -1
- package/build/src/interfaces.d.ts +1 -58
- package/build/src/resend.d.ts +2 -2
- package/build/src/resend.spec.js +10 -10
- package/package.json +1 -1
- package/readme.md +4 -4
package/build/package.json
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ReactElement } from 'react';
|
|
1
3
|
import { PostOptions } from '../../common/interfaces';
|
|
2
4
|
export interface CreateEmailOptions {
|
|
3
|
-
|
|
4
|
-
bcc?: string[];
|
|
5
|
-
cc?: string[];
|
|
5
|
+
attachments?: Attachment[];
|
|
6
|
+
bcc?: string | string[];
|
|
7
|
+
cc?: string | string[];
|
|
6
8
|
from: string;
|
|
7
9
|
html?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
react?: ReactElement;
|
|
11
|
+
reply_to?: string | string[];
|
|
10
12
|
subject: string;
|
|
13
|
+
tags?: Tag[];
|
|
14
|
+
text?: string;
|
|
15
|
+
to: string | string[];
|
|
11
16
|
}
|
|
12
17
|
export interface CreateEmailRequestOptions extends PostOptions {
|
|
13
18
|
}
|
|
14
19
|
export interface CreateEmailResponse {
|
|
15
20
|
id: string;
|
|
16
21
|
}
|
|
22
|
+
interface Attachment {
|
|
23
|
+
content?: string | Buffer;
|
|
24
|
+
filename?: string | false | undefined;
|
|
25
|
+
path?: string;
|
|
26
|
+
}
|
|
27
|
+
export type Tag = {
|
|
28
|
+
name: string;
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Resend } from './resend';
|
|
2
|
-
export {
|
|
2
|
+
export { ErrorResponse } from './interfaces';
|
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
export interface SendEmailData {
|
|
4
|
-
/** Sender email address. */
|
|
5
|
-
from: string;
|
|
6
|
-
/** Recipient email address. Max 50. */
|
|
7
|
-
to: string | string[];
|
|
8
|
-
/** Bcc recipient email address. Max 50. */
|
|
9
|
-
bcc?: string | string[];
|
|
10
|
-
/** Cc recipient email address. Max 50. */
|
|
11
|
-
cc?: string | string[];
|
|
12
|
-
/** Reply-to email address. Max 50. */
|
|
13
|
-
reply_to?: string | string[];
|
|
14
|
-
/** Email subject. */
|
|
15
|
-
subject: string;
|
|
16
|
-
/** The plain text version of the message. */
|
|
17
|
-
text?: string;
|
|
18
|
-
/** The HTML version of the message. */
|
|
19
|
-
html?: string;
|
|
20
|
-
/** The React version of the message. */
|
|
21
|
-
react?: ReactElement;
|
|
22
|
-
/** Attachments */
|
|
23
|
-
attachments?: Attachment[];
|
|
24
|
-
/** Email tags */
|
|
25
|
-
tags?: Tag[];
|
|
26
|
-
}
|
|
27
|
-
interface Attachment {
|
|
28
|
-
content?: string | Buffer;
|
|
29
|
-
filename?: string | false | undefined;
|
|
30
|
-
}
|
|
31
|
-
export interface SendEmailRequest {
|
|
32
|
-
/** Sender email address. */
|
|
33
|
-
from: string;
|
|
34
|
-
/** Recipient email address. Max 50. */
|
|
35
|
-
to: string | string[];
|
|
36
|
-
/** Bcc recipient email address. Max 50. */
|
|
37
|
-
bcc?: string | string[];
|
|
38
|
-
/** Cc recipient email address. Max 50. */
|
|
39
|
-
cc?: string | string[];
|
|
40
|
-
/** Reply-to email address. Max 50. */
|
|
41
|
-
reply_to?: string | string[];
|
|
42
|
-
/** Email subject. */
|
|
43
|
-
subject: string;
|
|
44
|
-
/** The HTML version of the message. */
|
|
45
|
-
text?: string;
|
|
46
|
-
/** The plain text version of the message. */
|
|
47
|
-
html?: string;
|
|
48
|
-
/** Attachments */
|
|
49
|
-
attachments?: Attachment[];
|
|
50
|
-
/** Email tags */
|
|
51
|
-
tags?: Tag[];
|
|
52
|
-
}
|
|
53
1
|
export declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
54
2
|
readonly missing_required_fields: 422;
|
|
55
3
|
readonly missing_api_key: 401;
|
|
@@ -62,10 +10,6 @@ export declare const RESEND_ERROR_CODES_BY_KEY: {
|
|
|
62
10
|
type ValueOf<TObj> = TObj[keyof TObj];
|
|
63
11
|
export type RESEND_ERROR_CODE_NUMBER = ValueOf<typeof RESEND_ERROR_CODES_BY_KEY>;
|
|
64
12
|
export type RESEND_ERROR_CODE_KEY = keyof typeof RESEND_ERROR_CODES_BY_KEY;
|
|
65
|
-
interface EmailResponse extends Pick<SendEmailRequest, 'to' | 'from'> {
|
|
66
|
-
id: string;
|
|
67
|
-
created_at: string;
|
|
68
|
-
}
|
|
69
13
|
interface ErrorResponse {
|
|
70
14
|
error: {
|
|
71
15
|
message: string;
|
|
@@ -73,8 +17,7 @@ interface ErrorResponse {
|
|
|
73
17
|
type: RESEND_ERROR_CODE_KEY;
|
|
74
18
|
};
|
|
75
19
|
}
|
|
76
|
-
export
|
|
77
|
-
export { EmailResponse, ErrorResponse };
|
|
20
|
+
export { ErrorResponse };
|
|
78
21
|
export type Tag = {
|
|
79
22
|
name: string;
|
|
80
23
|
value: string;
|
package/build/src/resend.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { SendEmailData, SendEmailResponse } from './interfaces';
|
|
3
2
|
import { GetOptions, PostOptions, PutOptions } from './common/interfaces';
|
|
4
3
|
import { ApiKeys } from './api-keys/api-keys';
|
|
5
4
|
import { Domains } from './domains/domains';
|
|
6
5
|
import { Emails } from './emails/emails';
|
|
6
|
+
import { CreateEmailOptions, CreateEmailResponse } from './emails/interfaces';
|
|
7
7
|
export declare class Resend {
|
|
8
8
|
readonly key?: string | undefined;
|
|
9
9
|
readonly baseUrl: string;
|
|
@@ -17,5 +17,5 @@ export declare class Resend {
|
|
|
17
17
|
get<T>(path: string, options?: GetOptions): Promise<T>;
|
|
18
18
|
put(path: string, entity: any, options?: PutOptions): Promise<AxiosResponse>;
|
|
19
19
|
delete(path: string, query?: any): Promise<AxiosResponse>;
|
|
20
|
-
sendEmail(data:
|
|
20
|
+
sendEmail(data: CreateEmailOptions): Promise<CreateEmailResponse>;
|
|
21
21
|
}
|
package/build/src/resend.spec.js
CHANGED
|
@@ -28,13 +28,13 @@ describe('Resend', () => {
|
|
|
28
28
|
to: 'zeno@resend.com',
|
|
29
29
|
subject: 'Hello World',
|
|
30
30
|
};
|
|
31
|
-
mock.onPost('/
|
|
31
|
+
mock.onPost('/emails', payload).replyOnce(200, {
|
|
32
32
|
id: '1234',
|
|
33
33
|
from: 'bu@resend.com',
|
|
34
34
|
to: 'zeno@resend.com',
|
|
35
35
|
created_at: '123',
|
|
36
36
|
});
|
|
37
|
-
const data = yield resend.
|
|
37
|
+
const data = yield resend.emails.send(payload);
|
|
38
38
|
expect(data).toMatchInlineSnapshot(`
|
|
39
39
|
{
|
|
40
40
|
"created_at": "123",
|
|
@@ -50,13 +50,13 @@ describe('Resend', () => {
|
|
|
50
50
|
to: ['bu@resend.com', 'zeno@resend.com'],
|
|
51
51
|
subject: 'Hello World',
|
|
52
52
|
};
|
|
53
|
-
mock.onPost('/
|
|
53
|
+
mock.onPost('/emails', payload).replyOnce(200, {
|
|
54
54
|
id: '1234',
|
|
55
55
|
from: 'admin@resend.com',
|
|
56
56
|
to: ['bu@resend.com', 'zeno@resend.com'],
|
|
57
57
|
created_at: '123',
|
|
58
58
|
});
|
|
59
|
-
const data = yield resend.
|
|
59
|
+
const data = yield resend.emails.send(payload);
|
|
60
60
|
expect(data).toMatchInlineSnapshot(`
|
|
61
61
|
{
|
|
62
62
|
"created_at": "123",
|
|
@@ -76,14 +76,14 @@ describe('Resend', () => {
|
|
|
76
76
|
bcc: ['foo@resend.com', 'bar@resend.com'],
|
|
77
77
|
subject: 'Hello World',
|
|
78
78
|
};
|
|
79
|
-
mock.onPost('/
|
|
79
|
+
mock.onPost('/emails', payload).replyOnce(200, {
|
|
80
80
|
id: '1234',
|
|
81
81
|
from: 'admin@resend.com',
|
|
82
82
|
to: 'bu@resend.com',
|
|
83
83
|
bcc: ['foo@resend.com', 'bar@resend.com'],
|
|
84
84
|
created_at: '123',
|
|
85
85
|
});
|
|
86
|
-
const data = yield resend.
|
|
86
|
+
const data = yield resend.emails.send(payload);
|
|
87
87
|
expect(data).toMatchInlineSnapshot(`
|
|
88
88
|
{
|
|
89
89
|
"bcc": [
|
|
@@ -104,14 +104,14 @@ describe('Resend', () => {
|
|
|
104
104
|
cc: ['foo@resend.com', 'bar@resend.com'],
|
|
105
105
|
subject: 'Hello World',
|
|
106
106
|
};
|
|
107
|
-
mock.onPost('/
|
|
107
|
+
mock.onPost('/emails', payload).replyOnce(200, {
|
|
108
108
|
id: '1234',
|
|
109
109
|
from: 'admin@resend.com',
|
|
110
110
|
to: 'bu@resend.com',
|
|
111
111
|
cc: ['foo@resend.com', 'bar@resend.com'],
|
|
112
112
|
created_at: '123',
|
|
113
113
|
});
|
|
114
|
-
const data = yield resend.
|
|
114
|
+
const data = yield resend.emails.send(payload);
|
|
115
115
|
expect(data).toMatchInlineSnapshot(`
|
|
116
116
|
{
|
|
117
117
|
"cc": [
|
|
@@ -132,7 +132,7 @@ describe('Resend', () => {
|
|
|
132
132
|
reply_to: ['foo@resend.com', 'bar@resend.com'],
|
|
133
133
|
subject: 'Hello World',
|
|
134
134
|
};
|
|
135
|
-
mock.onPost('/
|
|
135
|
+
mock.onPost('/emails', apiPayload).replyOnce(200, {
|
|
136
136
|
id: '1234',
|
|
137
137
|
from: 'admin@resend.com',
|
|
138
138
|
to: 'bu@resend.com',
|
|
@@ -145,7 +145,7 @@ describe('Resend', () => {
|
|
|
145
145
|
reply_to: ['foo@resend.com', 'bar@resend.com'],
|
|
146
146
|
subject: 'Hello World',
|
|
147
147
|
};
|
|
148
|
-
const data = yield resend.
|
|
148
|
+
const data = yield resend.emails.send(payload);
|
|
149
149
|
expect(data).toMatchInlineSnapshot(`
|
|
150
150
|
{
|
|
151
151
|
"created_at": "123",
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -24,7 +24,7 @@ const resend = new Resend('re_123');
|
|
|
24
24
|
Send your first email:
|
|
25
25
|
|
|
26
26
|
```js
|
|
27
|
-
await resend.
|
|
27
|
+
await resend.emails.send({
|
|
28
28
|
from: 'you@example.com',
|
|
29
29
|
to: 'user@gmail.com',
|
|
30
30
|
subject: 'hello world',
|
|
@@ -37,7 +37,7 @@ await resend.sendEmail({
|
|
|
37
37
|
Send an email custom HTML content:
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
|
-
await resend.
|
|
40
|
+
await resend.emails.send({
|
|
41
41
|
from: 'you@example.com',
|
|
42
42
|
to: 'user@gmail.com',
|
|
43
43
|
subject: 'hello world',
|
|
@@ -69,7 +69,7 @@ Then import the template component and pass it to the `react` property.
|
|
|
69
69
|
```jsx
|
|
70
70
|
import EmailTemplate from '../components/EmailTemplate'
|
|
71
71
|
|
|
72
|
-
await resend.
|
|
72
|
+
await resend.emails.send({
|
|
73
73
|
from: 'you@example.com',
|
|
74
74
|
to: 'user@gmail.com',
|
|
75
75
|
subject: 'hello world',
|
|
@@ -79,4 +79,4 @@ await resend.sendEmail({
|
|
|
79
79
|
|
|
80
80
|
## License
|
|
81
81
|
|
|
82
|
-
MIT License
|
|
82
|
+
MIT License
|