mailery 0.8.1 → 0.9.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/dist/index.cjs +20 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/{null-CwXmiVLe.d.cts → null-BRSHAxvg.d.cts} +8 -0
- package/dist/{null-CwXmiVLe.d.ts → null-BRSHAxvg.d.ts} +8 -0
- package/dist/testing.cjs +19 -6
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +19 -6
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Db } from 'mongodb';
|
|
2
|
-
import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-
|
|
3
|
-
export { s as NullProvider } from './null-
|
|
2
|
+
import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-BRSHAxvg.cjs';
|
|
3
|
+
export { s as NullProvider } from './null-BRSHAxvg.cjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'handlebars';
|
|
6
6
|
import 'ioredis';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Db } from 'mongodb';
|
|
2
|
-
import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-
|
|
3
|
-
export { s as NullProvider } from './null-
|
|
2
|
+
import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-BRSHAxvg.js';
|
|
3
|
+
export { s as NullProvider } from './null-BRSHAxvg.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'handlebars';
|
|
6
6
|
import 'ioredis';
|
package/dist/testing.js
CHANGED
|
@@ -14623,7 +14623,7 @@ var BullDriver = class _BullDriver {
|
|
|
14623
14623
|
bullQueues;
|
|
14624
14624
|
workers = null;
|
|
14625
14625
|
bull;
|
|
14626
|
-
static async create(redisConfig) {
|
|
14626
|
+
static async create(redisConfig, prefix) {
|
|
14627
14627
|
let bull;
|
|
14628
14628
|
try {
|
|
14629
14629
|
bull = await import('bullmq');
|
|
@@ -14632,14 +14632,22 @@ var BullDriver = class _BullDriver {
|
|
|
14632
14632
|
"mailery: queue driver 'bull' requires the 'bullmq' peer dependency. Run `npm install bullmq ioredis`."
|
|
14633
14633
|
);
|
|
14634
14634
|
}
|
|
14635
|
+
if (prefix?.includes(":")) {
|
|
14636
|
+
throw new Error(
|
|
14637
|
+
`mailery: queue prefix "${prefix}" must not contain ':' \u2014 BullMQ uses it as the Redis key separator.`
|
|
14638
|
+
);
|
|
14639
|
+
}
|
|
14635
14640
|
const redis = isRedisLike(redisConfig) ? redisConfig : connect(redisConfig);
|
|
14636
|
-
return new _BullDriver(bull, redis);
|
|
14641
|
+
return new _BullDriver(bull, redis, prefix);
|
|
14637
14642
|
}
|
|
14638
|
-
|
|
14643
|
+
prefix;
|
|
14644
|
+
constructor(bull, redis, prefix) {
|
|
14639
14645
|
this.bull = bull;
|
|
14640
14646
|
this.redis = redis;
|
|
14647
|
+
this.prefix = prefix;
|
|
14641
14648
|
const opts = {
|
|
14642
14649
|
connection: redis,
|
|
14650
|
+
prefix,
|
|
14643
14651
|
defaultJobOptions: {
|
|
14644
14652
|
removeOnComplete: { age: 24 * 3600, count: 1e3 },
|
|
14645
14653
|
removeOnFail: { age: 7 * 24 * 3600 }
|
|
@@ -14671,7 +14679,7 @@ var BullDriver = class _BullDriver {
|
|
|
14671
14679
|
}
|
|
14672
14680
|
async startWorkers(opts) {
|
|
14673
14681
|
if (this.workers) return;
|
|
14674
|
-
const base = { connection: this.redis };
|
|
14682
|
+
const base = { connection: this.redis, prefix: this.prefix };
|
|
14675
14683
|
const { Worker } = this.bull;
|
|
14676
14684
|
const tick = new Worker(
|
|
14677
14685
|
QUEUE_NAMES.tick,
|
|
@@ -14923,7 +14931,7 @@ var NoopDriver = class {
|
|
|
14923
14931
|
async function createQueueDriver(config, fallbackDb) {
|
|
14924
14932
|
switch (config.driver) {
|
|
14925
14933
|
case "bull":
|
|
14926
|
-
return BullDriver.create(config.redis);
|
|
14934
|
+
return BullDriver.create(config.redis, config.prefix);
|
|
14927
14935
|
case "agenda":
|
|
14928
14936
|
return AgendaDriver.create({
|
|
14929
14937
|
db: config.db ?? fallbackDb,
|
|
@@ -17351,6 +17359,7 @@ var Mailer = class _Mailer {
|
|
|
17351
17359
|
* MAILER_MONGODB_URI — Mongo connection string (required)
|
|
17352
17360
|
* MAILER_MONGODB_DB — database name (optional; defaults to the URI default)
|
|
17353
17361
|
* MAILER_REDIS_URL — Redis connection URL (required)
|
|
17362
|
+
* MAILER_QUEUE_PREFIX — Redis key prefix to namespace this instance (optional)
|
|
17354
17363
|
* MAILER_PUBLIC_URL — base for tracking/unsub URLs (required)
|
|
17355
17364
|
* MAILER_UNSUBSCRIBE_SECRET — HMAC key (required)
|
|
17356
17365
|
* MAILER_SENDER_ADDRESS — postal address for CAN-SPAM (optional)
|
|
@@ -17399,7 +17408,11 @@ var Mailer = class _Mailer {
|
|
|
17399
17408
|
}
|
|
17400
17409
|
const defaultProvider = env.MAILER_DEFAULT_PROVIDER ?? Object.keys(providers)[0];
|
|
17401
17410
|
const driverEnv = env.MAILER_QUEUE_DRIVER ?? "bull";
|
|
17402
|
-
const queue = driverEnv === "agenda" ? { driver: "agenda" } : driverEnv === "noop" ? { driver: "noop" } : {
|
|
17411
|
+
const queue = driverEnv === "agenda" ? { driver: "agenda" } : driverEnv === "noop" ? { driver: "noop" } : {
|
|
17412
|
+
driver: "bull",
|
|
17413
|
+
redis: { url: required("MAILER_REDIS_URL") },
|
|
17414
|
+
prefix: env.MAILER_QUEUE_PREFIX
|
|
17415
|
+
};
|
|
17403
17416
|
return _Mailer.init({
|
|
17404
17417
|
db,
|
|
17405
17418
|
adapter,
|