-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathcreate-email-options.interface.ts
More file actions
169 lines (158 loc) · 5.19 KB
/
create-email-options.interface.ts
File metadata and controls
169 lines (158 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import type * as React from 'react';
import type { PostOptions } from '../../common/interfaces';
import type { IdempotentRequest } from '../../common/interfaces/idempotent-request.interface';
import type { RequireAtLeastOne } from '../../common/interfaces/require-at-least-one';
import type { Response } from '../../interfaces';
interface EmailRenderOptions {
/**
* The React component used to write the message.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
react: React.ReactNode;
/**
* The HTML version of the message.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
html: string;
/**
* The plain text version of the message.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
text: string;
}
interface EmailTemplateOptions {
template: {
id: string;
variables?: Record<string, string | number>;
};
}
type ToTestingAddress =
| 'delivered@resend.dev'
| 'bounced@resend.dev'
| 'complained@resend.dev';
interface CreateEmailBaseOptionsWithTemplate
extends Omit<CreateEmailBaseOptions, 'from' | 'subject'> {
from?: string;
subject?: string;
}
interface CreateEmailBaseOptions {
/**
* Filename and content of attachments (max 40mb per email)
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
attachments?: Attachment[];
/**
* Blind carbon copy recipient email address. For multiple addresses, send as an array of strings.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
bcc?: string | string[];
/**
* Carbon copy recipient email address. For multiple addresses, send as an array of strings.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
cc?: string | string[];
/**
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
from: string;
/**
* Custom headers to add to the email.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
headers?: Record<string, string>;
/**
* Reply-to email address. For multiple addresses, send as an array of strings.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
replyTo?: string | string[];
/**
* Email subject.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
subject: string;
/**
* Email tags
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
tags?: Tag[];
/**
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*
* Can also be one of the following testing email addresses
* - `delivered@resend.dev`
* - `bounced@resend.dev`
* - `complained@resend.dev`
*
* @link https://resend.com/docs/dashboard/emails/send-test-emails
*/
to: ToTestingAddress | (string & {}) | (ToTestingAddress | (string & {}))[];
/**
* The id of the topic you want to send to
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
topicId?: string | null;
/**
* Schedule email to be sent later.
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z).
*
* @link https://resend.com/docs/api-reference/emails/send-email#body-parameters
*/
scheduledAt?: string;
}
export type CreateEmailOptions =
| ((RequireAtLeastOne<EmailRenderOptions> & CreateEmailBaseOptions) & {
template?: never;
})
| ((EmailTemplateOptions & CreateEmailBaseOptionsWithTemplate) & {
react?: never;
html?: never;
text?: never;
});
export interface CreateEmailRequestOptions
extends PostOptions,
IdempotentRequest {}
export interface CreateEmailResponseSuccess {
/** The ID of the newly created email. */
id: string;
}
export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
export interface Attachment {
/** Content of an attached file. */
content?: string | Buffer;
/** Name of attached file. */
filename?: string | false | undefined;
/** Path where the attachment file is hosted */
path?: string;
/** Optional content type for the attachment, if not set will be derived from the filename property */
contentType?: string;
/**
* Optional content ID for the attachment, to be used as a reference in the HTML content.
* If set, this attachment will be sent as an inline attachment and you can reference it in the HTML content using the `cid:` prefix.
*/
contentId?: string;
}
export type Tag = {
/**
* The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
*/
name: string;
/**
* The value of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
*/
value: string;
};