@maestro-js/mail 1.0.0-alpha.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/README.md +360 -0
- package/dist/index.d.ts +478 -0
- package/dist/index.js +554 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { Iso } from 'iso-fns2';
|
|
2
|
+
import { Queue } from '@maestro-js/queue';
|
|
3
|
+
import { Log } from '@maestro-js/log';
|
|
4
|
+
|
|
5
|
+
type MailAddress = string | {
|
|
6
|
+
name?: string;
|
|
7
|
+
email: string;
|
|
8
|
+
};
|
|
9
|
+
type MailContent = {
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
html: string;
|
|
13
|
+
};
|
|
14
|
+
interface MailAttachment {
|
|
15
|
+
/** Base64 encoded string */
|
|
16
|
+
content: string;
|
|
17
|
+
filename: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
disposition?: string;
|
|
20
|
+
contentId?: string;
|
|
21
|
+
}
|
|
22
|
+
interface MailHeaders {
|
|
23
|
+
listUnsubscribePost?: string;
|
|
24
|
+
listUnsubscribe?: string;
|
|
25
|
+
replyTo?: MailAddress;
|
|
26
|
+
}
|
|
27
|
+
interface MailEnvelope {
|
|
28
|
+
to: MailAddress | MailAddress[];
|
|
29
|
+
from?: MailAddress;
|
|
30
|
+
cc?: MailAddress | MailAddress[];
|
|
31
|
+
bcc?: MailAddress | MailAddress[];
|
|
32
|
+
attachments?: MailAttachment[];
|
|
33
|
+
subject: string | null;
|
|
34
|
+
content: MailContent;
|
|
35
|
+
headers?: MailHeaders;
|
|
36
|
+
category?: string | null;
|
|
37
|
+
extras?: Record<string, string | null>;
|
|
38
|
+
}
|
|
39
|
+
type MailEventType = 'delivery' | 'softBounce' | 'bounce' | 'suspension' | 'unsubscribe' | 'open' | 'spamComplaint' | 'click' | 'reject';
|
|
40
|
+
interface MailEvent {
|
|
41
|
+
eventId: string;
|
|
42
|
+
/** a combination of email, event, and messageId should be unique */
|
|
43
|
+
event: MailEventType;
|
|
44
|
+
email: string;
|
|
45
|
+
messageId: string;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
category: string | null;
|
|
48
|
+
extras: Record<string, string>;
|
|
49
|
+
driverName: string;
|
|
50
|
+
}
|
|
51
|
+
interface MailDriver {
|
|
52
|
+
send(envelope: MailEnvelope): Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
driverName: string;
|
|
55
|
+
messages: {
|
|
56
|
+
id: string;
|
|
57
|
+
email: string;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
type MailLogMessage = ({
|
|
62
|
+
type: 'event';
|
|
63
|
+
} & MailEvent) | {
|
|
64
|
+
type: 'envelope';
|
|
65
|
+
driverName: string;
|
|
66
|
+
messageId: string;
|
|
67
|
+
to: {
|
|
68
|
+
name?: string;
|
|
69
|
+
email: string;
|
|
70
|
+
};
|
|
71
|
+
from: {
|
|
72
|
+
name?: string;
|
|
73
|
+
email: string;
|
|
74
|
+
};
|
|
75
|
+
attachments: MailAttachment[];
|
|
76
|
+
subject: string | null;
|
|
77
|
+
content: MailContent;
|
|
78
|
+
headers: MailHeaders;
|
|
79
|
+
category: string | null;
|
|
80
|
+
extras: Record<string, string>;
|
|
81
|
+
mailable: string | null;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type EmailData = string | {
|
|
85
|
+
name?: string;
|
|
86
|
+
email: string;
|
|
87
|
+
};
|
|
88
|
+
type Response$1 = {
|
|
89
|
+
statusCode: number;
|
|
90
|
+
headers: {
|
|
91
|
+
'x-message-id': string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
interface SendGrid {
|
|
95
|
+
send(data: {
|
|
96
|
+
to?: EmailData | EmailData[];
|
|
97
|
+
cc?: EmailData | EmailData[];
|
|
98
|
+
bcc?: EmailData | EmailData[];
|
|
99
|
+
from: EmailData;
|
|
100
|
+
subject?: string;
|
|
101
|
+
attachments?: {
|
|
102
|
+
content: string;
|
|
103
|
+
filename: string;
|
|
104
|
+
type?: string;
|
|
105
|
+
disposition?: string;
|
|
106
|
+
contentId?: string;
|
|
107
|
+
}[];
|
|
108
|
+
category?: string;
|
|
109
|
+
customArgs?: {
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
};
|
|
112
|
+
} & ({
|
|
113
|
+
text: string;
|
|
114
|
+
} | {
|
|
115
|
+
html: string;
|
|
116
|
+
}), isMultiple?: boolean, cb?: (err: unknown, result: [Response$1, {}]) => void): Promise<[Response$1, {}]>;
|
|
117
|
+
}
|
|
118
|
+
interface SendGridWebhookEvent {
|
|
119
|
+
timestamp: number;
|
|
120
|
+
category?: string | string[];
|
|
121
|
+
sg_event_id: string;
|
|
122
|
+
sg_message_id: string;
|
|
123
|
+
event: 'processed' | 'dropped' | 'delivered' | 'bounce' | 'open' | 'click' | 'spamreport' | 'unsubscribe' | 'group_unsubscribe' | 'group_resubscribe';
|
|
124
|
+
__extraKeys__?: string;
|
|
125
|
+
email: string;
|
|
126
|
+
}
|
|
127
|
+
interface SendGridMailDriver extends MailDriver {
|
|
128
|
+
toMailEvent(mtEvent: SendGridWebhookEvent): MailEvent | null;
|
|
129
|
+
}
|
|
130
|
+
declare function sendGridMailDriver(sendGrid: SendGrid): SendGridMailDriver;
|
|
131
|
+
|
|
132
|
+
type Address = {
|
|
133
|
+
name?: string;
|
|
134
|
+
email: string;
|
|
135
|
+
};
|
|
136
|
+
type Response = {
|
|
137
|
+
success: true;
|
|
138
|
+
message_ids: string[];
|
|
139
|
+
};
|
|
140
|
+
interface MailTrap {
|
|
141
|
+
send(data: {
|
|
142
|
+
to: Address[];
|
|
143
|
+
cc?: Address[];
|
|
144
|
+
bcc?: Address[];
|
|
145
|
+
from: Address;
|
|
146
|
+
subject: string;
|
|
147
|
+
text?: string;
|
|
148
|
+
html?: string;
|
|
149
|
+
attachments?: {
|
|
150
|
+
content: string;
|
|
151
|
+
filename: string;
|
|
152
|
+
type?: string;
|
|
153
|
+
disposition?: string;
|
|
154
|
+
contentId?: string;
|
|
155
|
+
}[];
|
|
156
|
+
category?: string;
|
|
157
|
+
custom_variables?: Record<string, string | number | boolean>;
|
|
158
|
+
} & ({
|
|
159
|
+
text?: string;
|
|
160
|
+
} | {
|
|
161
|
+
html?: string;
|
|
162
|
+
})): Promise<Response>;
|
|
163
|
+
}
|
|
164
|
+
interface MailTrapWebhookEvent {
|
|
165
|
+
email: string;
|
|
166
|
+
timestamp: number;
|
|
167
|
+
category?: string;
|
|
168
|
+
event_id: string;
|
|
169
|
+
message_id: string;
|
|
170
|
+
custom_variables?: Record<string, string>;
|
|
171
|
+
event: 'delivery' | 'soft_bounce' | 'bounce' | 'suspension' | 'unsubscribe' | 'open' | 'spam_complaint' | 'click' | 'reject';
|
|
172
|
+
}
|
|
173
|
+
interface MailTrapMailDriver extends MailDriver {
|
|
174
|
+
toMailEvent(mtEvent: MailTrapWebhookEvent): MailEvent;
|
|
175
|
+
}
|
|
176
|
+
declare function mailTrapMailDriver(mailTrap: MailTrap): MailTrapMailDriver;
|
|
177
|
+
|
|
178
|
+
interface SesWebhookEvent {
|
|
179
|
+
eventId: string;
|
|
180
|
+
eventType: 'Bounce' | 'Complaint' | 'Delivery' | 'Reject' | 'Open' | 'Click' | 'Subscription';
|
|
181
|
+
mail: {
|
|
182
|
+
messageId: string;
|
|
183
|
+
timestamp: string;
|
|
184
|
+
destination: string[];
|
|
185
|
+
tags?: Record<string, string[]>;
|
|
186
|
+
};
|
|
187
|
+
delivery?: {
|
|
188
|
+
timestamp: string;
|
|
189
|
+
};
|
|
190
|
+
open?: {
|
|
191
|
+
timestamp: string;
|
|
192
|
+
};
|
|
193
|
+
click?: {
|
|
194
|
+
timestamp: string;
|
|
195
|
+
};
|
|
196
|
+
bounce?: {
|
|
197
|
+
bouncedRecipients: {
|
|
198
|
+
emailAddress: string;
|
|
199
|
+
}[];
|
|
200
|
+
timestamp: string;
|
|
201
|
+
};
|
|
202
|
+
complaint?: {
|
|
203
|
+
complainedRecipients: {
|
|
204
|
+
emailAddress: string;
|
|
205
|
+
}[];
|
|
206
|
+
timestamp: string;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
interface SesClientAdapter {
|
|
210
|
+
send(command: {
|
|
211
|
+
input: {
|
|
212
|
+
RawMessage: {
|
|
213
|
+
Data: Buffer;
|
|
214
|
+
};
|
|
215
|
+
Destinations?: string[];
|
|
216
|
+
ConfigurationSetName?: string;
|
|
217
|
+
};
|
|
218
|
+
}): Promise<{
|
|
219
|
+
MessageId?: string;
|
|
220
|
+
}>;
|
|
221
|
+
}
|
|
222
|
+
interface SesMailDriver extends MailDriver {
|
|
223
|
+
toMailEvent(event: SesWebhookEvent): MailEvent | null;
|
|
224
|
+
}
|
|
225
|
+
declare function sesMailDriver(ses: SesClientAdapter, configurationSetName: string): SesMailDriver;
|
|
226
|
+
|
|
227
|
+
interface IcsAttachmentOptions {
|
|
228
|
+
filename?: string;
|
|
229
|
+
start: Iso.Instant | Iso.ZonedDateTime | Iso.DateTime;
|
|
230
|
+
end: Iso.Instant | Iso.ZonedDateTime | Iso.DateTime | Iso.Duration;
|
|
231
|
+
title?: string;
|
|
232
|
+
description?: string;
|
|
233
|
+
location?: string;
|
|
234
|
+
geo?: {
|
|
235
|
+
lat: number;
|
|
236
|
+
lon: number;
|
|
237
|
+
};
|
|
238
|
+
url?: string;
|
|
239
|
+
status?: 'TENTATIVE' | 'CONFIRMED' | 'CANCELLED';
|
|
240
|
+
busyStatus?: 'FREE' | 'BUSY' | 'TENTATIVE' | 'OOF';
|
|
241
|
+
organizer?: {
|
|
242
|
+
name?: string;
|
|
243
|
+
email?: string;
|
|
244
|
+
dir?: string;
|
|
245
|
+
};
|
|
246
|
+
attendees?: {
|
|
247
|
+
name?: string;
|
|
248
|
+
email?: string;
|
|
249
|
+
dir?: string;
|
|
250
|
+
rsvp?: boolean;
|
|
251
|
+
partstat?: 'NEEDS-ACTION' | 'ACCEPTED' | 'DECLINED' | 'TENTATIVE' | 'DELEGATED' | 'COMPLETED' | 'IN-PROCESS';
|
|
252
|
+
role?: 'CHAIR' | 'REQ-PARTICIPANT' | 'OPT-PARTICIPANT' | 'NON-PARTICIPANT';
|
|
253
|
+
}[];
|
|
254
|
+
categories?: string[];
|
|
255
|
+
productId?: string;
|
|
256
|
+
uid?: string;
|
|
257
|
+
method?: string;
|
|
258
|
+
recurrenceRule?: string;
|
|
259
|
+
sequence?: number;
|
|
260
|
+
calName?: string;
|
|
261
|
+
classification?: 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL' | string;
|
|
262
|
+
created?: Iso.Instant;
|
|
263
|
+
lastModified?: Iso.Instant;
|
|
264
|
+
htmlContent?: string;
|
|
265
|
+
alarms?: {
|
|
266
|
+
action?: 'audio' | 'display' | 'email' | 'procedure';
|
|
267
|
+
description?: string;
|
|
268
|
+
summary?: string;
|
|
269
|
+
duration?: Iso.Duration;
|
|
270
|
+
trigger?: Iso.Duration;
|
|
271
|
+
repeat?: number;
|
|
272
|
+
attachType?: string;
|
|
273
|
+
attach?: string;
|
|
274
|
+
}[];
|
|
275
|
+
}
|
|
276
|
+
declare function icsAttachment(options: IcsAttachmentOptions): MailAttachment;
|
|
277
|
+
|
|
278
|
+
declare function stubMailDriver({ logger }?: {
|
|
279
|
+
logger?: Log.LogFunctions<[MailEnvelope]>;
|
|
280
|
+
}): MailDriver;
|
|
281
|
+
|
|
282
|
+
declare const EMPTY_ENVELOPE: unique symbol;
|
|
283
|
+
declare function create(config: Mail.Provider.MailServiceConfig): Mail.MailService;
|
|
284
|
+
/**
|
|
285
|
+
* A mailable encapsulates generating content for a particular type of email.
|
|
286
|
+
* Mailables can input "args" which effect the generated content.
|
|
287
|
+
* Mailables are first "rendered" by passing in input args. Then the mailable can
|
|
288
|
+
* be send, queued, or sent later.
|
|
289
|
+
*/
|
|
290
|
+
declare function mailable<Args extends Record<string, any>>(name: string, fn: Mail.MailableRenderFunction<Args>): {
|
|
291
|
+
/**
|
|
292
|
+
* Prepares the mailable with the renderArgs so that the mailable
|
|
293
|
+
* can be sent.
|
|
294
|
+
*/
|
|
295
|
+
render(renderArgs: Args): {
|
|
296
|
+
content: () => Promise<MailContent>;
|
|
297
|
+
send: () => Promise<void>;
|
|
298
|
+
queue: () => Promise<void>;
|
|
299
|
+
later: (scheduledDate: Iso.Instant) => Promise<void>;
|
|
300
|
+
provider: (key: Mail.Provider.Key) => {
|
|
301
|
+
content: () => Promise<MailContent>;
|
|
302
|
+
send: () => Promise<void>;
|
|
303
|
+
queue: () => Promise<void>;
|
|
304
|
+
later: (scheduledDate: Iso.Instant) => Promise<void>;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
declare function provider(key: Mail.Provider.Key): {
|
|
309
|
+
send: (envelope: Mail.Envelope) => Promise<{
|
|
310
|
+
messages: {
|
|
311
|
+
id: string;
|
|
312
|
+
email: string;
|
|
313
|
+
}[];
|
|
314
|
+
success: boolean;
|
|
315
|
+
}>;
|
|
316
|
+
later: (envelope: Mail.Envelope, scheduledDate: Iso.Instant) => void;
|
|
317
|
+
queue: (envelope: Mail.Envelope) => void;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Driver-based email sending with queued delivery, scheduled sending, and reusable mailable templates.
|
|
321
|
+
*
|
|
322
|
+
* Each mail service wraps a driver (SendGrid, SES, MailTrap, Stub) behind a unified `send()` call.
|
|
323
|
+
* Queue integration lets you offload delivery with `queue()` or schedule it with `later()`.
|
|
324
|
+
* Mailables encapsulate data fetching and envelope generation so the same template can be sent
|
|
325
|
+
* from anywhere — and when queued, data is fetched at send time, not enqueue time.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* // Send an order confirmation immediately
|
|
330
|
+
* await Mail.send({
|
|
331
|
+
* to: 'alice@example.com',
|
|
332
|
+
* subject: 'Order #1042 Confirmed',
|
|
333
|
+
* content: { html: '<h1>Thank you for your order!</h1>' }
|
|
334
|
+
* })
|
|
335
|
+
*
|
|
336
|
+
* // Queue a password reset for async delivery
|
|
337
|
+
* Mail.queue({ to: 'bob@example.com', subject: 'Reset Password', content: { html: '...' } })
|
|
338
|
+
*
|
|
339
|
+
* // Register and use a mailable template
|
|
340
|
+
* const Welcome = Mail.mailable('Welcome', async (args: { userId: string }) => {
|
|
341
|
+
* const user = await db.query('SELECT * FROM users WHERE id = ?', [args.userId])
|
|
342
|
+
* return { to: user.email, subject: 'Welcome!', content: { html: `<h1>Hi ${user.name}!</h1>` } }
|
|
343
|
+
* })
|
|
344
|
+
* await Welcome.render({ userId: '456' }).queue()
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
declare namespace Mail {
|
|
348
|
+
/** Email recipient or sender — either a plain email string or an object with optional display name */
|
|
349
|
+
type Address = MailAddress;
|
|
350
|
+
/** Email body — either `{ text: string }` for plain text or `{ html: string }` for HTML */
|
|
351
|
+
type Content = MailContent;
|
|
352
|
+
/** File attachment with base64-encoded content, filename, optional MIME type and disposition */
|
|
353
|
+
type Attachment = MailAttachment;
|
|
354
|
+
/** Email headers: `listUnsubscribe`, `listUnsubscribePost`, and `replyTo` */
|
|
355
|
+
type Headers = MailHeaders;
|
|
356
|
+
/** Complete email message: recipients, subject, content, optional attachments, headers, category, and extras */
|
|
357
|
+
type Envelope = MailEnvelope;
|
|
358
|
+
/** Union of normalized event types: `'delivery'`, `'bounce'`, `'open'`, `'click'`, `'unsubscribe'`, etc. */
|
|
359
|
+
type EventType = MailEventType;
|
|
360
|
+
/** Normalized webhook event with eventId, event type, email, messageId, timestamp, and extras */
|
|
361
|
+
type Event = MailEvent;
|
|
362
|
+
/** Driver interface — implements `send(envelope)` returning `{ success, driverName, messages }` */
|
|
363
|
+
type Driver = MailDriver;
|
|
364
|
+
/** Render function for a mailable — takes args and returns an envelope or `EMPTY_ENVELOPE` to skip */
|
|
365
|
+
type MailableRenderFunction<Args extends Record<string, any>> = (args: Args) => Promise<Mail.Envelope | typeof EMPTY_ENVELOPE> | Mail.Envelope | typeof EMPTY_ENVELOPE;
|
|
366
|
+
/** Structured log entry — either an envelope record or a webhook event record */
|
|
367
|
+
type LogMessage = MailLogMessage;
|
|
368
|
+
namespace Provider {
|
|
369
|
+
/**
|
|
370
|
+
* Configuration for creating a mail service instance.
|
|
371
|
+
*
|
|
372
|
+
* Requires a driver, instance name (used for queue naming), a default sender address,
|
|
373
|
+
* a logger for structured envelope records, and a queue service for async delivery.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* Mail.Provider.create({
|
|
378
|
+
* driver: Mail.drivers.sendGrid(sendGridMail),
|
|
379
|
+
* name: 'default',
|
|
380
|
+
* globalFrom: { email: 'orders@mystore.com', name: 'MyStore' },
|
|
381
|
+
* logger: mailLogger,
|
|
382
|
+
* queueService: Queue.provider('default')
|
|
383
|
+
* })
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
interface MailServiceConfig {
|
|
387
|
+
/** The mail driver instance (SendGrid, SES, MailTrap, or Stub) */
|
|
388
|
+
driver: Driver;
|
|
389
|
+
/** Instance name, used for queue naming (`Maestro.Mail.{name}` and `Maestro.Mailable.{name}`) */
|
|
390
|
+
name: string;
|
|
391
|
+
/** Default sender address — overridden by `envelope.from` when provided */
|
|
392
|
+
globalFrom: MailAddress;
|
|
393
|
+
/** Logger for recording sent envelopes and webhook events */
|
|
394
|
+
logger: Log.Logger<[MailLogMessage]>;
|
|
395
|
+
/** Queue service for {@link queue} and {@link later} delivery */
|
|
396
|
+
queueService: Queue.QueueService;
|
|
397
|
+
/** Optional callback invoked when a send fails, before the error is rethrown */
|
|
398
|
+
onMessageSendFailure?(envelope: Envelope, error: unknown): unknown;
|
|
399
|
+
}
|
|
400
|
+
type Key = keyof Keys;
|
|
401
|
+
interface Keys {
|
|
402
|
+
default: unknown;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Mail service instance providing immediate, queued, and scheduled email delivery.
|
|
407
|
+
*
|
|
408
|
+
* Use {@link send} for immediate delivery within the current process, {@link queue} to
|
|
409
|
+
* offload to the job queue, or {@link later} to schedule for a future date. Internal
|
|
410
|
+
* methods {@link sendMailable} and {@link queueMailable} are used by the mailable
|
|
411
|
+
* system and are not typically called directly.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```ts
|
|
415
|
+
* await Mail.send({ to: 'alice@example.com', subject: 'Order Confirmed', content: { html: '...' } })
|
|
416
|
+
* Mail.queue({ to: 'bob@example.com', subject: 'Password Reset', content: { html: '...' } })
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
interface MailService {
|
|
420
|
+
/** Sends an email immediately using the configured driver and returns message IDs */
|
|
421
|
+
send(envelope: Envelope): Promise<{
|
|
422
|
+
messages: {
|
|
423
|
+
id: string;
|
|
424
|
+
email: string;
|
|
425
|
+
}[];
|
|
426
|
+
success: boolean;
|
|
427
|
+
}>;
|
|
428
|
+
/** Enqueues an email for immediate processing by the queue worker */
|
|
429
|
+
queue(envelope: Envelope): void;
|
|
430
|
+
/** Enqueues an email for delivery at the specified future date */
|
|
431
|
+
later(envelope: Mail.Envelope, scheduledDate: Iso.Instant): void;
|
|
432
|
+
/** Sends a mailable by name, resolving it from the global mailable registry */
|
|
433
|
+
sendMailable(input: {
|
|
434
|
+
mailableName: string;
|
|
435
|
+
renderArgs: Record<string, any>;
|
|
436
|
+
}): Promise<void>;
|
|
437
|
+
/** Enqueues a mailable for async or scheduled processing */
|
|
438
|
+
queueMailable(input: {
|
|
439
|
+
mailableName: string;
|
|
440
|
+
renderArgs: Record<string, any>;
|
|
441
|
+
}, options: {
|
|
442
|
+
scheduledDate: Iso.Instant | null;
|
|
443
|
+
}): Promise<void>;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Driver-based email sending with queued delivery, scheduled sending, and mailable templates.
|
|
448
|
+
* Call `Mail.Provider.create()` with a driver and register it, or use the default instance directly.
|
|
449
|
+
*/
|
|
450
|
+
declare const Mail: {
|
|
451
|
+
provider: typeof provider;
|
|
452
|
+
drivers: {
|
|
453
|
+
sendGrid: typeof sendGridMailDriver;
|
|
454
|
+
mailTrap: typeof mailTrapMailDriver;
|
|
455
|
+
ses: typeof sesMailDriver;
|
|
456
|
+
stub: typeof stubMailDriver;
|
|
457
|
+
};
|
|
458
|
+
attachments: {
|
|
459
|
+
ics: typeof icsAttachment;
|
|
460
|
+
};
|
|
461
|
+
send: (envelope: Mail.Envelope) => Promise<{
|
|
462
|
+
messages: {
|
|
463
|
+
id: string;
|
|
464
|
+
email: string;
|
|
465
|
+
}[];
|
|
466
|
+
success: boolean;
|
|
467
|
+
}>;
|
|
468
|
+
later: (envelope: Mail.Envelope, scheduledDate: Iso.Instant) => void;
|
|
469
|
+
queue: (envelope: Mail.Envelope) => void;
|
|
470
|
+
EMPTY_ENVELOPE: typeof EMPTY_ENVELOPE;
|
|
471
|
+
mailable: typeof mailable;
|
|
472
|
+
Provider: {
|
|
473
|
+
create: typeof create;
|
|
474
|
+
register: (name: Mail.Provider.Key, item: Mail.MailService) => void;
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
export { Mail };
|