@maestro-js/mail 1.0.0-alpha.19 → 1.0.0-alpha.2
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/dist/index.d.ts +2 -3
- package/dist/index.js +19 -23
- package/package.json +5 -8
package/dist/index.d.ts
CHANGED
|
@@ -218,12 +218,11 @@ interface SesClientAdapter {
|
|
|
218
218
|
}): Promise<{
|
|
219
219
|
MessageId?: string;
|
|
220
220
|
}>;
|
|
221
|
-
configurationSetName: string;
|
|
222
221
|
}
|
|
223
222
|
interface SesMailDriver extends MailDriver {
|
|
224
223
|
toMailEvent(event: SesWebhookEvent): MailEvent | null;
|
|
225
224
|
}
|
|
226
|
-
declare function sesMailDriver(ses: SesClientAdapter): SesMailDriver;
|
|
225
|
+
declare function sesMailDriver(ses: SesClientAdapter, configurationSetName: string): SesMailDriver;
|
|
227
226
|
|
|
228
227
|
interface IcsAttachmentOptions {
|
|
229
228
|
filename?: string;
|
|
@@ -394,7 +393,7 @@ declare namespace Mail {
|
|
|
394
393
|
/** Logger for recording sent envelopes and webhook events */
|
|
395
394
|
logger: Log.Logger<[MailLogMessage]>;
|
|
396
395
|
/** Queue service for {@link queue} and {@link later} delivery */
|
|
397
|
-
|
|
396
|
+
queueService: Queue.QueueService;
|
|
398
397
|
/** Optional callback invoked when a send fails, before the error is rethrown */
|
|
399
398
|
onMessageSendFailure?(envelope: Envelope, error: unknown): unknown;
|
|
400
399
|
}
|
package/dist/index.js
CHANGED
|
@@ -145,7 +145,7 @@ var sesToMaestroEventMapping = {
|
|
|
145
145
|
Click: "click",
|
|
146
146
|
Subscription: "unsubscribe"
|
|
147
147
|
};
|
|
148
|
-
function sesMailDriver(ses) {
|
|
148
|
+
function sesMailDriver(ses, configurationSetName) {
|
|
149
149
|
async function send(envelope) {
|
|
150
150
|
assert3.ok(envelope.from, "missing from address");
|
|
151
151
|
function getsComposerAddr(addresses) {
|
|
@@ -200,7 +200,7 @@ function sesMailDriver(ses) {
|
|
|
200
200
|
input: {
|
|
201
201
|
RawMessage: { Data: rawBuffer },
|
|
202
202
|
Destinations: [recipient],
|
|
203
|
-
ConfigurationSetName:
|
|
203
|
+
ConfigurationSetName: configurationSetName,
|
|
204
204
|
Tags: messageTags.length ? messageTags : void 0
|
|
205
205
|
}
|
|
206
206
|
};
|
|
@@ -320,10 +320,12 @@ function parseIsoToDurationObject(iso) {
|
|
|
320
320
|
|
|
321
321
|
// src/index.ts
|
|
322
322
|
import assert5 from "assert";
|
|
323
|
+
import { Log as Log2 } from "@maestro-js/log";
|
|
323
324
|
|
|
324
325
|
// src/stub-mail-driver.ts
|
|
325
326
|
import assert4 from "assert";
|
|
326
327
|
import { randomUUID } from "crypto";
|
|
328
|
+
import "@maestro-js/log";
|
|
327
329
|
function stubMailDriver({ logger } = {}) {
|
|
328
330
|
async function send(envelope) {
|
|
329
331
|
assert4.ok(envelope.from, "missing from address");
|
|
@@ -348,16 +350,16 @@ function stubMailDriver({ logger } = {}) {
|
|
|
348
350
|
import { ServiceRegistry } from "@maestro-js/service-registry";
|
|
349
351
|
var EMPTY_ENVELOPE = /* @__PURE__ */ Symbol("EMPTY_ENVELOPE");
|
|
350
352
|
function create(config) {
|
|
351
|
-
const queueService = config.
|
|
352
|
-
const mailQueue = queueService
|
|
353
|
+
const queueService = config.queueService;
|
|
354
|
+
const mailQueue = queueService.create({
|
|
353
355
|
name: ["Maestro.Mail", config.name].filter(Boolean).join("."),
|
|
354
|
-
async
|
|
356
|
+
async workFn(envelope) {
|
|
355
357
|
return send(envelope);
|
|
356
358
|
}
|
|
357
359
|
});
|
|
358
|
-
const mailableQueue = queueService
|
|
360
|
+
const mailableQueue = queueService.create({
|
|
359
361
|
name: ["Maestro.Mailable", config.name].filter(Boolean).join("."),
|
|
360
|
-
async
|
|
362
|
+
async workFn(props) {
|
|
361
363
|
const mailable2 = mailableRegistry.get(props.mailableName);
|
|
362
364
|
if (!mailable2) {
|
|
363
365
|
throw new Error(`No mailable found with name ${props.mailableName}`);
|
|
@@ -416,16 +418,10 @@ function create(config) {
|
|
|
416
418
|
}
|
|
417
419
|
}
|
|
418
420
|
function queue(envelope) {
|
|
419
|
-
|
|
420
|
-
throw new Error("Queueing not configured for Mail");
|
|
421
|
-
}
|
|
422
|
-
mailQueue.dispatch(envelope);
|
|
421
|
+
mailQueue.addMessage(envelope, { scheduledDate: null });
|
|
423
422
|
}
|
|
424
423
|
function later(envelope, scheduledDate) {
|
|
425
|
-
|
|
426
|
-
throw new Error("Queueing not configured for Mail");
|
|
427
|
-
}
|
|
428
|
-
mailQueue.dispatchWithDelay(envelope, scheduledDate);
|
|
424
|
+
mailQueue.addMessage(envelope, { scheduledDate });
|
|
429
425
|
}
|
|
430
426
|
async function sendMailable(props) {
|
|
431
427
|
const mailable2 = mailableRegistry.get(props.mailableName);
|
|
@@ -450,14 +446,7 @@ function create(config) {
|
|
|
450
446
|
}
|
|
451
447
|
}
|
|
452
448
|
async function queueMailable(props, options) {
|
|
453
|
-
|
|
454
|
-
throw new Error("Queueing not configured for Mail");
|
|
455
|
-
}
|
|
456
|
-
if (options.scheduledDate) {
|
|
457
|
-
await mailableQueue.dispatchWithDelay(props, options.scheduledDate);
|
|
458
|
-
} else {
|
|
459
|
-
await mailableQueue.dispatch(props);
|
|
460
|
-
}
|
|
449
|
+
await mailableQueue.addMessage(props, options);
|
|
461
450
|
}
|
|
462
451
|
function formatEnvelope(envelope) {
|
|
463
452
|
function formatAddress(mailAddress) {
|
|
@@ -469,6 +458,13 @@ function create(config) {
|
|
|
469
458
|
const formattedToUniq = [...new Set(formattedTo.map((f) => typeof f === "string" ? f : f.email))].map(
|
|
470
459
|
(email) => formattedTo.find((t) => typeof t === "string" ? t === email : t.email === email)
|
|
471
460
|
);
|
|
461
|
+
if (formattedToUniq.length !== formattedTo.length) {
|
|
462
|
+
Log2.warn({
|
|
463
|
+
message: "Addresses were not unique in the request. Duplicate email addresses have been removed",
|
|
464
|
+
original: formattedTo,
|
|
465
|
+
modified: formattedToUniq
|
|
466
|
+
});
|
|
467
|
+
}
|
|
472
468
|
return {
|
|
473
469
|
...envelope,
|
|
474
470
|
to: formattedToUniq,
|
package/package.json
CHANGED
|
@@ -12,21 +12,18 @@
|
|
|
12
12
|
"ics": "^3.8.1",
|
|
13
13
|
"iso-fns2": "npm:iso-fns@2.0.0-alpha.26",
|
|
14
14
|
"nodemailer": "^7.0.5",
|
|
15
|
-
"@maestro-js/helpers": "1.0.0-alpha.
|
|
16
|
-
"@maestro-js/
|
|
17
|
-
|
|
18
|
-
"peerDependencies": {
|
|
19
|
-
"@maestro-js/log": "1.0.0-alpha.19"
|
|
15
|
+
"@maestro-js/helpers": "1.0.0-alpha.2",
|
|
16
|
+
"@maestro-js/log": "1.0.0-alpha.2",
|
|
17
|
+
"@maestro-js/service-registry": "1.0.0-alpha.2"
|
|
20
18
|
},
|
|
21
19
|
"devDependencies": {
|
|
22
20
|
"@react-email/render": "0.0.7",
|
|
23
21
|
"@types/node": "^22.19.11",
|
|
24
22
|
"@types/nodemailer": "^6.4.17",
|
|
25
23
|
"@types/react": "^19.0.0",
|
|
26
|
-
"@maestro-js/
|
|
27
|
-
"@maestro-js/queue": "1.0.0-alpha.19"
|
|
24
|
+
"@maestro-js/queue": "1.0.0-alpha.2"
|
|
28
25
|
},
|
|
29
|
-
"version": "1.0.0-alpha.
|
|
26
|
+
"version": "1.0.0-alpha.2",
|
|
30
27
|
"publishConfig": {
|
|
31
28
|
"access": "restricted"
|
|
32
29
|
},
|