@meghjs/core 0.6.0 → 0.6.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/README.md +62 -15
- package/dist/core/application.d.ts +50 -0
- package/dist/core/application.js +105 -0
- package/dist/core/application.js.map +1 -1
- package/dist/core/interfaces.d.ts +10 -0
- package/dist/core/router.d.ts +28 -0
- package/dist/core/router.js +26 -1
- package/dist/core/router.js.map +1 -1
- package/dist/core/types.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mail/config.d.ts +141 -0
- package/dist/mail/config.js +199 -0
- package/dist/mail/config.js.map +1 -0
- package/dist/mail/errors.d.ts +4 -0
- package/dist/mail/errors.js +12 -0
- package/dist/mail/errors.js.map +1 -0
- package/dist/mail/http-transports.d.ts +44 -0
- package/dist/mail/http-transports.js +319 -0
- package/dist/mail/http-transports.js.map +1 -0
- package/dist/mail/index.d.ts +8 -0
- package/dist/mail/index.js +46 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/mail/mailable.d.ts +34 -0
- package/dist/mail/mailable.js +38 -0
- package/dist/mail/mailable.js.map +1 -0
- package/dist/mail/mailer.d.ts +208 -0
- package/dist/mail/mailer.js +502 -0
- package/dist/mail/mailer.js.map +1 -0
- package/dist/mail/queue.d.ts +32 -0
- package/dist/mail/queue.js +59 -0
- package/dist/mail/queue.js.map +1 -0
- package/dist/mail/transports.d.ts +37 -0
- package/dist/mail/transports.js +152 -0
- package/dist/mail/transports.js.map +1 -0
- package/dist/mail/types.d.ts +95 -0
- package/dist/mail/types.js +3 -0
- package/dist/mail/types.js.map +1 -0
- package/dist/security/headers.d.ts +65 -0
- package/dist/security/headers.js +148 -0
- package/dist/security/headers.js.map +1 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -1
- package/dist/security/rate-limit.d.ts +129 -0
- package/dist/security/rate-limit.js +260 -0
- package/dist/security/rate-limit.js.map +1 -0
- package/package.json +10 -13
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { MailgunMailerConfig, PostmarkMailerConfig, ResendMailerConfig, SendGridMailerConfig } from "./config";
|
|
2
|
+
import { MailError } from "./errors";
|
|
3
|
+
import type { MailAddress, MailAttachment, MailMessage, MailTransport, MailTransportResult } from "./types";
|
|
4
|
+
/** A provider refused the message, or could not be reached. */
|
|
5
|
+
export declare class MailTransportError extends MailError {
|
|
6
|
+
readonly provider: string;
|
|
7
|
+
/** The HTTP status, when there was a response. */
|
|
8
|
+
readonly status: number | undefined;
|
|
9
|
+
/** The response body, when there was one. */
|
|
10
|
+
readonly body: string | undefined;
|
|
11
|
+
constructor(provider: string,
|
|
12
|
+
/** The HTTP status, when there was a response. */
|
|
13
|
+
status: number | undefined,
|
|
14
|
+
/** The response body, when there was one. */
|
|
15
|
+
body: string | undefined, message: string);
|
|
16
|
+
}
|
|
17
|
+
/** An attachment's bytes, read from `content` or `path` (a file or an http(s) URL). */
|
|
18
|
+
export declare function attachmentBytes(a: MailAttachment): Promise<Buffer>;
|
|
19
|
+
/** `Name <a@x.io>`, quoting the name when it has characters that need it. */
|
|
20
|
+
export declare function formatAddress(a: MailAddress): string;
|
|
21
|
+
/** Twilio SendGrid's v3 Mail Send API. */
|
|
22
|
+
export declare class SendGridTransport implements MailTransport {
|
|
23
|
+
private readonly config;
|
|
24
|
+
constructor(config: SendGridMailerConfig);
|
|
25
|
+
send(message: MailMessage): Promise<MailTransportResult>;
|
|
26
|
+
}
|
|
27
|
+
/** Mailgun's Messages API. EU domains use `endpoint: "https://api.eu.mailgun.net"`. */
|
|
28
|
+
export declare class MailgunTransport implements MailTransport {
|
|
29
|
+
private readonly config;
|
|
30
|
+
constructor(config: MailgunMailerConfig);
|
|
31
|
+
send(message: MailMessage): Promise<MailTransportResult>;
|
|
32
|
+
}
|
|
33
|
+
/** Postmark's Email API. */
|
|
34
|
+
export declare class PostmarkTransport implements MailTransport {
|
|
35
|
+
private readonly config;
|
|
36
|
+
constructor(config: PostmarkMailerConfig);
|
|
37
|
+
send(message: MailMessage): Promise<MailTransportResult>;
|
|
38
|
+
}
|
|
39
|
+
/** Resend's Send Email API. */
|
|
40
|
+
export declare class ResendTransport implements MailTransport {
|
|
41
|
+
private readonly config;
|
|
42
|
+
constructor(config: ResendMailerConfig);
|
|
43
|
+
send(message: MailMessage): Promise<MailTransportResult>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ResendTransport = exports.PostmarkTransport = exports.MailgunTransport = exports.SendGridTransport = exports.MailTransportError = void 0;
|
|
7
|
+
exports.attachmentBytes = attachmentBytes;
|
|
8
|
+
exports.formatAddress = formatAddress;
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const mime_1 = __importDefault(require("mime"));
|
|
11
|
+
const errors_1 = require("./errors");
|
|
12
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
13
|
+
/** A provider refused the message, or could not be reached. */
|
|
14
|
+
class MailTransportError extends errors_1.MailError {
|
|
15
|
+
provider;
|
|
16
|
+
status;
|
|
17
|
+
body;
|
|
18
|
+
constructor(provider,
|
|
19
|
+
/** The HTTP status, when there was a response. */
|
|
20
|
+
status,
|
|
21
|
+
/** The response body, when there was one. */
|
|
22
|
+
body, message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.provider = provider;
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.body = body;
|
|
27
|
+
this.name = "MailTransportError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.MailTransportError = MailTransportError;
|
|
31
|
+
/** POST to a provider's API, turning network errors and non-2xx replies into a MailTransportError. */
|
|
32
|
+
async function post(provider, url, init, timeout = DEFAULT_TIMEOUT) {
|
|
33
|
+
let res;
|
|
34
|
+
try {
|
|
35
|
+
res = await fetch(url, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: init.headers,
|
|
38
|
+
body: init.body,
|
|
39
|
+
signal: AbortSignal.timeout(timeout),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const why = err instanceof Error ? err.message : String(err);
|
|
44
|
+
throw new MailTransportError(provider, undefined, undefined, `${provider} could not be reached: ${why}`);
|
|
45
|
+
}
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
const body = await res.text().catch(() => "");
|
|
48
|
+
throw new MailTransportError(provider, res.status, body, `${provider} rejected the message (HTTP ${res.status}): ${body.slice(0, 500)}`);
|
|
49
|
+
}
|
|
50
|
+
return res;
|
|
51
|
+
}
|
|
52
|
+
/** An attachment's bytes, read from `content` or `path` (a file or an http(s) URL). */
|
|
53
|
+
async function attachmentBytes(a) {
|
|
54
|
+
if (Buffer.isBuffer(a.content))
|
|
55
|
+
return a.content;
|
|
56
|
+
if (typeof a.content === "string") {
|
|
57
|
+
return Buffer.from(a.content, a.encoding === "base64" ? "base64" : "utf8");
|
|
58
|
+
}
|
|
59
|
+
if (a.path) {
|
|
60
|
+
if (/^https?:\/\//i.test(a.path)) {
|
|
61
|
+
const res = await fetch(a.path, {
|
|
62
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
63
|
+
});
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
throw new errors_1.MailError(`Could not download attachment ${a.path} (HTTP ${res.status}).`);
|
|
66
|
+
}
|
|
67
|
+
return Buffer.from(await res.arrayBuffer());
|
|
68
|
+
}
|
|
69
|
+
return fs_1.promises.readFile(a.path);
|
|
70
|
+
}
|
|
71
|
+
throw new errors_1.MailError(`Attachment${a.filename ? ` ${a.filename}` : ""} has neither content nor path.`);
|
|
72
|
+
}
|
|
73
|
+
function attachmentName(a) {
|
|
74
|
+
return (a.filename ??
|
|
75
|
+
(a.path ? a.path.split(/[\\/]/).pop() : undefined) ??
|
|
76
|
+
"attachment");
|
|
77
|
+
}
|
|
78
|
+
function attachmentType(a) {
|
|
79
|
+
return (a.contentType ??
|
|
80
|
+
mime_1.default.getType(attachmentName(a)) ??
|
|
81
|
+
"application/octet-stream");
|
|
82
|
+
}
|
|
83
|
+
/** `Name <a@x.io>`, quoting the name when it has characters that need it. */
|
|
84
|
+
function formatAddress(a) {
|
|
85
|
+
if (!a.name)
|
|
86
|
+
return a.address;
|
|
87
|
+
const name = /[()<>[\]:;@\\,."]/.test(a.name)
|
|
88
|
+
? `"${a.name.replace(/(["\\])/g, "\\$1")}"`
|
|
89
|
+
: a.name;
|
|
90
|
+
return `${name} <${a.address}>`;
|
|
91
|
+
}
|
|
92
|
+
function requireSetting(value, what) {
|
|
93
|
+
if (!value)
|
|
94
|
+
throw new errors_1.MailError(`${what} is not set.`);
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
function trimSlash(url) {
|
|
98
|
+
return url.replace(/\/+$/, "");
|
|
99
|
+
}
|
|
100
|
+
// ─── SendGrid ────────────────────────────────────────────────────────────────
|
|
101
|
+
/** Twilio SendGrid's v3 Mail Send API. */
|
|
102
|
+
class SendGridTransport {
|
|
103
|
+
config;
|
|
104
|
+
constructor(config) {
|
|
105
|
+
this.config = config;
|
|
106
|
+
}
|
|
107
|
+
async send(message) {
|
|
108
|
+
const apiKey = requireSetting(this.config.apiKey, "The sendgrid mailer's API key (MEGH_MAIL_SENDGRID_API_KEY)");
|
|
109
|
+
const person = (list) => list.map((a) => a.name ? { email: a.address, name: a.name } : { email: a.address });
|
|
110
|
+
// SendGrid rejects an address that appears twice across to, cc and bcc.
|
|
111
|
+
const seen = new Set();
|
|
112
|
+
const unique = (list) => list.filter((a) => {
|
|
113
|
+
const key = a.address.toLowerCase();
|
|
114
|
+
if (seen.has(key))
|
|
115
|
+
return false;
|
|
116
|
+
seen.add(key);
|
|
117
|
+
return true;
|
|
118
|
+
});
|
|
119
|
+
const to = unique(message.to);
|
|
120
|
+
const cc = unique(message.cc);
|
|
121
|
+
const bcc = unique(message.bcc);
|
|
122
|
+
const personalization = { to: person(to) };
|
|
123
|
+
if (cc.length)
|
|
124
|
+
personalization.cc = person(cc);
|
|
125
|
+
if (bcc.length)
|
|
126
|
+
personalization.bcc = person(bcc);
|
|
127
|
+
const content = [];
|
|
128
|
+
if (message.text !== undefined)
|
|
129
|
+
content.push({ type: "text/plain", value: message.text });
|
|
130
|
+
if (message.html !== undefined)
|
|
131
|
+
content.push({ type: "text/html", value: message.html });
|
|
132
|
+
const body = {
|
|
133
|
+
personalizations: [personalization],
|
|
134
|
+
from: person([message.from])[0],
|
|
135
|
+
subject: message.subject,
|
|
136
|
+
content,
|
|
137
|
+
};
|
|
138
|
+
if (message.replyTo.length === 1)
|
|
139
|
+
body.reply_to = person(message.replyTo)[0];
|
|
140
|
+
if (message.replyTo.length > 1)
|
|
141
|
+
body.reply_to_list = person(message.replyTo);
|
|
142
|
+
if (Object.keys(message.headers).length)
|
|
143
|
+
body.headers = message.headers;
|
|
144
|
+
if (message.attachments.length) {
|
|
145
|
+
body.attachments = await Promise.all(message.attachments.map(async (a) => ({
|
|
146
|
+
content: (await attachmentBytes(a)).toString("base64"),
|
|
147
|
+
filename: attachmentName(a),
|
|
148
|
+
type: attachmentType(a),
|
|
149
|
+
...(a.cid ? { disposition: "inline", content_id: a.cid } : {}),
|
|
150
|
+
})));
|
|
151
|
+
}
|
|
152
|
+
const res = await post("SendGrid", `${trimSlash(this.config.endpoint ?? "https://api.sendgrid.com")}/v3/mail/send`, {
|
|
153
|
+
headers: {
|
|
154
|
+
Authorization: `Bearer ${apiKey}`,
|
|
155
|
+
"Content-Type": "application/json",
|
|
156
|
+
},
|
|
157
|
+
body: JSON.stringify(body),
|
|
158
|
+
}, this.config.timeout);
|
|
159
|
+
return {
|
|
160
|
+
messageId: res.headers.get("x-message-id") ?? undefined,
|
|
161
|
+
response: { status: res.status },
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.SendGridTransport = SendGridTransport;
|
|
166
|
+
// ─── Mailgun ─────────────────────────────────────────────────────────────────
|
|
167
|
+
/** Mailgun's Messages API. EU domains use `endpoint: "https://api.eu.mailgun.net"`. */
|
|
168
|
+
class MailgunTransport {
|
|
169
|
+
config;
|
|
170
|
+
constructor(config) {
|
|
171
|
+
this.config = config;
|
|
172
|
+
}
|
|
173
|
+
async send(message) {
|
|
174
|
+
const apiKey = requireSetting(this.config.apiKey, "The mailgun mailer's API key (MEGH_MAIL_MAILGUN_API_KEY)");
|
|
175
|
+
const domain = requireSetting(this.config.domain, "The mailgun mailer's domain (MEGH_MAIL_MAILGUN_DOMAIN)");
|
|
176
|
+
const form = new FormData();
|
|
177
|
+
form.append("from", formatAddress(message.from));
|
|
178
|
+
// One field per address: a comma inside a display name stays safe.
|
|
179
|
+
for (const a of message.to)
|
|
180
|
+
form.append("to", formatAddress(a));
|
|
181
|
+
for (const a of message.cc)
|
|
182
|
+
form.append("cc", formatAddress(a));
|
|
183
|
+
for (const a of message.bcc)
|
|
184
|
+
form.append("bcc", formatAddress(a));
|
|
185
|
+
form.append("subject", message.subject);
|
|
186
|
+
if (message.text !== undefined)
|
|
187
|
+
form.append("text", message.text);
|
|
188
|
+
if (message.html !== undefined)
|
|
189
|
+
form.append("html", message.html);
|
|
190
|
+
if (message.replyTo.length) {
|
|
191
|
+
form.append("h:Reply-To", message.replyTo.map(formatAddress).join(", "));
|
|
192
|
+
}
|
|
193
|
+
for (const [key, value] of Object.entries(message.headers)) {
|
|
194
|
+
form.append(`h:${key}`, value);
|
|
195
|
+
}
|
|
196
|
+
for (const a of message.attachments) {
|
|
197
|
+
const blob = new Blob([new Uint8Array(await attachmentBytes(a))], {
|
|
198
|
+
type: attachmentType(a),
|
|
199
|
+
});
|
|
200
|
+
// Mailgun uses an inline file's name as its content ID.
|
|
201
|
+
if (a.cid)
|
|
202
|
+
form.append("inline", blob, a.cid);
|
|
203
|
+
else
|
|
204
|
+
form.append("attachment", blob, attachmentName(a));
|
|
205
|
+
}
|
|
206
|
+
const res = await post("Mailgun", `${trimSlash(this.config.endpoint ?? "https://api.mailgun.net")}/v3/${encodeURIComponent(domain)}/messages`, {
|
|
207
|
+
headers: {
|
|
208
|
+
Authorization: `Basic ${Buffer.from(`api:${apiKey}`).toString("base64")}`,
|
|
209
|
+
},
|
|
210
|
+
body: form,
|
|
211
|
+
}, this.config.timeout);
|
|
212
|
+
const json = (await res.json().catch(() => ({})));
|
|
213
|
+
return { messageId: json.id, response: json };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.MailgunTransport = MailgunTransport;
|
|
217
|
+
// ─── Postmark ────────────────────────────────────────────────────────────────
|
|
218
|
+
/** Postmark's Email API. */
|
|
219
|
+
class PostmarkTransport {
|
|
220
|
+
config;
|
|
221
|
+
constructor(config) {
|
|
222
|
+
this.config = config;
|
|
223
|
+
}
|
|
224
|
+
async send(message) {
|
|
225
|
+
const token = requireSetting(this.config.token, "The postmark mailer's server token (MEGH_MAIL_POSTMARK_TOKEN)");
|
|
226
|
+
const list = (addresses) => addresses.map(formatAddress).join(", ");
|
|
227
|
+
const body = {
|
|
228
|
+
From: formatAddress(message.from),
|
|
229
|
+
To: list(message.to),
|
|
230
|
+
Subject: message.subject,
|
|
231
|
+
};
|
|
232
|
+
if (message.cc.length)
|
|
233
|
+
body.Cc = list(message.cc);
|
|
234
|
+
if (message.bcc.length)
|
|
235
|
+
body.Bcc = list(message.bcc);
|
|
236
|
+
if (message.replyTo.length)
|
|
237
|
+
body.ReplyTo = list(message.replyTo);
|
|
238
|
+
if (message.html !== undefined)
|
|
239
|
+
body.HtmlBody = message.html;
|
|
240
|
+
if (message.text !== undefined)
|
|
241
|
+
body.TextBody = message.text;
|
|
242
|
+
if (Object.keys(message.headers).length) {
|
|
243
|
+
body.Headers = Object.entries(message.headers).map(([Name, Value]) => ({
|
|
244
|
+
Name,
|
|
245
|
+
Value,
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
if (this.config.messageStream)
|
|
249
|
+
body.MessageStream = this.config.messageStream;
|
|
250
|
+
if (message.attachments.length) {
|
|
251
|
+
body.Attachments = await Promise.all(message.attachments.map(async (a) => ({
|
|
252
|
+
Name: attachmentName(a),
|
|
253
|
+
Content: (await attachmentBytes(a)).toString("base64"),
|
|
254
|
+
ContentType: attachmentType(a),
|
|
255
|
+
...(a.cid ? { ContentID: `cid:${a.cid}` } : {}),
|
|
256
|
+
})));
|
|
257
|
+
}
|
|
258
|
+
const res = await post("Postmark", `${trimSlash(this.config.endpoint ?? "https://api.postmarkapp.com")}/email`, {
|
|
259
|
+
headers: {
|
|
260
|
+
"X-Postmark-Server-Token": token,
|
|
261
|
+
Accept: "application/json",
|
|
262
|
+
"Content-Type": "application/json",
|
|
263
|
+
},
|
|
264
|
+
body: JSON.stringify(body),
|
|
265
|
+
}, this.config.timeout);
|
|
266
|
+
const json = (await res.json().catch(() => ({})));
|
|
267
|
+
if (json.ErrorCode) {
|
|
268
|
+
throw new MailTransportError("Postmark", res.status, JSON.stringify(json), `Postmark rejected the message (error ${json.ErrorCode}): ${json.Message ?? ""}`);
|
|
269
|
+
}
|
|
270
|
+
return { messageId: json.MessageID, response: json };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.PostmarkTransport = PostmarkTransport;
|
|
274
|
+
// ─── Resend ──────────────────────────────────────────────────────────────────
|
|
275
|
+
/** Resend's Send Email API. */
|
|
276
|
+
class ResendTransport {
|
|
277
|
+
config;
|
|
278
|
+
constructor(config) {
|
|
279
|
+
this.config = config;
|
|
280
|
+
}
|
|
281
|
+
async send(message) {
|
|
282
|
+
const apiKey = requireSetting(this.config.apiKey, "The resend mailer's API key (MEGH_MAIL_RESEND_API_KEY)");
|
|
283
|
+
const body = {
|
|
284
|
+
from: formatAddress(message.from),
|
|
285
|
+
to: message.to.map(formatAddress),
|
|
286
|
+
subject: message.subject,
|
|
287
|
+
};
|
|
288
|
+
if (message.cc.length)
|
|
289
|
+
body.cc = message.cc.map(formatAddress);
|
|
290
|
+
if (message.bcc.length)
|
|
291
|
+
body.bcc = message.bcc.map(formatAddress);
|
|
292
|
+
if (message.replyTo.length)
|
|
293
|
+
body.reply_to = message.replyTo.map(formatAddress);
|
|
294
|
+
if (message.html !== undefined)
|
|
295
|
+
body.html = message.html;
|
|
296
|
+
if (message.text !== undefined)
|
|
297
|
+
body.text = message.text;
|
|
298
|
+
if (Object.keys(message.headers).length)
|
|
299
|
+
body.headers = message.headers;
|
|
300
|
+
if (message.attachments.length) {
|
|
301
|
+
body.attachments = await Promise.all(message.attachments.map(async (a) => ({
|
|
302
|
+
filename: attachmentName(a),
|
|
303
|
+
content: (await attachmentBytes(a)).toString("base64"),
|
|
304
|
+
...(a.cid ? { content_id: a.cid } : {}),
|
|
305
|
+
})));
|
|
306
|
+
}
|
|
307
|
+
const res = await post("Resend", `${trimSlash(this.config.endpoint ?? "https://api.resend.com")}/emails`, {
|
|
308
|
+
headers: {
|
|
309
|
+
Authorization: `Bearer ${apiKey}`,
|
|
310
|
+
"Content-Type": "application/json",
|
|
311
|
+
},
|
|
312
|
+
body: JSON.stringify(body),
|
|
313
|
+
}, this.config.timeout);
|
|
314
|
+
const json = (await res.json().catch(() => ({})));
|
|
315
|
+
return { messageId: json.id, response: json };
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.ResendTransport = ResendTransport;
|
|
319
|
+
//# sourceMappingURL=http-transports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-transports.js","sourceRoot":"","sources":["../../src/mail/http-transports.ts"],"names":[],"mappings":";;;;;;AAuEA,0CAsBC;AAmBD,sCAMC;AAtHD,2BAAoC;AACpC,gDAAwB;AAOxB,qCAAqC;AASrC,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,+DAA+D;AAC/D,MAAa,kBAA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AAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChD,CAAC;CACF;AA7CD,0CA6CC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export { MailError } from "./errors";
|
|
3
|
+
export { mailConfigFromEnv, resolveMailConfig, type MailConfig, type MailerConfig, type ResolvedMailConfig, type SmtpMailerConfig, type LogMailerConfig, type ArrayMailerConfig, type MailQueueConfig, type SendGridMailerConfig, type MailgunMailerConfig, type PostmarkMailerConfig, type ResendMailerConfig, type FailoverMailerConfig, mailerProblem, } from "./config";
|
|
4
|
+
export { MailQueue, DEFAULT_MAIL_JOB_OPTIONS, type QueuedMailPayload, } from "./queue";
|
|
5
|
+
export { Mailable } from "./mailable";
|
|
6
|
+
export { Mailer, PendingMail, MailFake, SentMail } from "./mailer";
|
|
7
|
+
export { SmtpTransport, LogTransport, ArrayTransport, FailoverTransport, } from "./transports";
|
|
8
|
+
export { SendGridTransport, MailgunTransport, PostmarkTransport, ResendTransport, MailTransportError, } from "./http-transports";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.MailTransportError = exports.ResendTransport = exports.PostmarkTransport = exports.MailgunTransport = exports.SendGridTransport = exports.FailoverTransport = exports.ArrayTransport = exports.LogTransport = exports.SmtpTransport = exports.SentMail = exports.MailFake = exports.PendingMail = exports.Mailer = exports.Mailable = exports.DEFAULT_MAIL_JOB_OPTIONS = exports.MailQueue = exports.mailerProblem = exports.resolveMailConfig = exports.mailConfigFromEnv = exports.MailError = void 0;
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
var errors_1 = require("./errors");
|
|
20
|
+
Object.defineProperty(exports, "MailError", { enumerable: true, get: function () { return errors_1.MailError; } });
|
|
21
|
+
var config_1 = require("./config");
|
|
22
|
+
Object.defineProperty(exports, "mailConfigFromEnv", { enumerable: true, get: function () { return config_1.mailConfigFromEnv; } });
|
|
23
|
+
Object.defineProperty(exports, "resolveMailConfig", { enumerable: true, get: function () { return config_1.resolveMailConfig; } });
|
|
24
|
+
Object.defineProperty(exports, "mailerProblem", { enumerable: true, get: function () { return config_1.mailerProblem; } });
|
|
25
|
+
var queue_1 = require("./queue");
|
|
26
|
+
Object.defineProperty(exports, "MailQueue", { enumerable: true, get: function () { return queue_1.MailQueue; } });
|
|
27
|
+
Object.defineProperty(exports, "DEFAULT_MAIL_JOB_OPTIONS", { enumerable: true, get: function () { return queue_1.DEFAULT_MAIL_JOB_OPTIONS; } });
|
|
28
|
+
var mailable_1 = require("./mailable");
|
|
29
|
+
Object.defineProperty(exports, "Mailable", { enumerable: true, get: function () { return mailable_1.Mailable; } });
|
|
30
|
+
var mailer_1 = require("./mailer");
|
|
31
|
+
Object.defineProperty(exports, "Mailer", { enumerable: true, get: function () { return mailer_1.Mailer; } });
|
|
32
|
+
Object.defineProperty(exports, "PendingMail", { enumerable: true, get: function () { return mailer_1.PendingMail; } });
|
|
33
|
+
Object.defineProperty(exports, "MailFake", { enumerable: true, get: function () { return mailer_1.MailFake; } });
|
|
34
|
+
Object.defineProperty(exports, "SentMail", { enumerable: true, get: function () { return mailer_1.SentMail; } });
|
|
35
|
+
var transports_1 = require("./transports");
|
|
36
|
+
Object.defineProperty(exports, "SmtpTransport", { enumerable: true, get: function () { return transports_1.SmtpTransport; } });
|
|
37
|
+
Object.defineProperty(exports, "LogTransport", { enumerable: true, get: function () { return transports_1.LogTransport; } });
|
|
38
|
+
Object.defineProperty(exports, "ArrayTransport", { enumerable: true, get: function () { return transports_1.ArrayTransport; } });
|
|
39
|
+
Object.defineProperty(exports, "FailoverTransport", { enumerable: true, get: function () { return transports_1.FailoverTransport; } });
|
|
40
|
+
var http_transports_1 = require("./http-transports");
|
|
41
|
+
Object.defineProperty(exports, "SendGridTransport", { enumerable: true, get: function () { return http_transports_1.SendGridTransport; } });
|
|
42
|
+
Object.defineProperty(exports, "MailgunTransport", { enumerable: true, get: function () { return http_transports_1.MailgunTransport; } });
|
|
43
|
+
Object.defineProperty(exports, "PostmarkTransport", { enumerable: true, get: function () { return http_transports_1.PostmarkTransport; } });
|
|
44
|
+
Object.defineProperty(exports, "ResendTransport", { enumerable: true, get: function () { return http_transports_1.ResendTransport; } });
|
|
45
|
+
Object.defineProperty(exports, "MailTransportError", { enumerable: true, get: function () { return http_transports_1.MailTransportError; } });
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mail/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAClB,mCAgBkB;AAfhB,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AAajB,uGAAA,aAAa,OAAA;AAEf,iCAIiB;AAHf,kGAAA,SAAS,OAAA;AACT,iHAAA,wBAAwB,OAAA;AAG1B,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAmE;AAA1D,gGAAA,MAAM,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAChD,2CAKsB;AAJpB,2GAAA,aAAa,OAAA;AACb,0GAAA,YAAY,OAAA;AACZ,4GAAA,cAAc,OAAA;AACd,+GAAA,iBAAiB,OAAA;AAEnB,qDAM2B;AALzB,oHAAA,iBAAiB,OAAA;AACjB,mHAAA,gBAAgB,OAAA;AAChB,oHAAA,iBAAiB,OAAA;AACjB,kHAAA,eAAe,OAAA;AACf,qHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { MailAttachment, MailContent, MailEnvelope } from "./types";
|
|
2
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* One kind of email, as a class: its subject, body and attachments. Create
|
|
5
|
+
* it with the data it needs and hand it to the {@link Mailer}.
|
|
6
|
+
*
|
|
7
|
+
* Each method may be `async`, to load data or render a template.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* export class WelcomeMail extends Mailable {
|
|
11
|
+
* constructor(private readonly user: User) {
|
|
12
|
+
* super();
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* envelope() {
|
|
16
|
+
* return { subject: `Welcome, ${this.user.name}` };
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* content() {
|
|
20
|
+
* return { html: `<p>Hi ${this.user.name}!</p>`, text: `Hi ${this.user.name}!` };
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* await mailer.to(user.email).send(new WelcomeMail(user));
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class Mailable {
|
|
27
|
+
/** Subject, sender and extra recipients. All optional. */
|
|
28
|
+
envelope(): MaybePromise<MailEnvelope>;
|
|
29
|
+
/** The body: `html`, `text` or both. */
|
|
30
|
+
abstract content(): MaybePromise<MailContent>;
|
|
31
|
+
/** Files to attach. None by default. */
|
|
32
|
+
attachments(): MaybePromise<MailAttachment[]>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mailable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* One kind of email, as a class: its subject, body and attachments. Create
|
|
6
|
+
* it with the data it needs and hand it to the {@link Mailer}.
|
|
7
|
+
*
|
|
8
|
+
* Each method may be `async`, to load data or render a template.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* export class WelcomeMail extends Mailable {
|
|
12
|
+
* constructor(private readonly user: User) {
|
|
13
|
+
* super();
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* envelope() {
|
|
17
|
+
* return { subject: `Welcome, ${this.user.name}` };
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* content() {
|
|
21
|
+
* return { html: `<p>Hi ${this.user.name}!</p>`, text: `Hi ${this.user.name}!` };
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* await mailer.to(user.email).send(new WelcomeMail(user));
|
|
26
|
+
*/
|
|
27
|
+
class Mailable {
|
|
28
|
+
/** Subject, sender and extra recipients. All optional. */
|
|
29
|
+
envelope() {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
/** Files to attach. None by default. */
|
|
33
|
+
attachments() {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Mailable = Mailable;
|
|
38
|
+
//# sourceMappingURL=mailable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailable.js","sourceRoot":"","sources":["../../src/mail/mailable.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAsB,QAAQ;IAC5B,0DAA0D;IAC1D,QAAQ;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;IAKD,wCAAwC;IACxC,WAAW;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAbD,4BAaC"}
|