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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, D as DeliveryWindow, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-CwXmiVLe.cjs';
2
- export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RESERVED_VAR_KEYS, u as RedisOptions, v as SegmentDefinition, w as SendDoc, x as SendStatus, y as SenderDomainConfig, z as SenderDomainRegistry, G as SenderDomainValidation, I as SubscriptionDoc, J as SubscriptionStatus, K as SuppressionDoc, Q as SuppressionReason, U as TemplateKind, V as TemplateVersionDoc, W as VarsAdapter, X as VarsResolveInfo, Y as WebhookEventDoc, Z as defineVars, _ as ensureIndexes, $ as getCollections, a0 as validateSenderDomain, a1 as varsJsonSchema } from './null-CwXmiVLe.cjs';
1
+ import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, D as DeliveryWindow, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-BRSHAxvg.cjs';
2
+ export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RESERVED_VAR_KEYS, u as RedisOptions, v as SegmentDefinition, w as SendDoc, x as SendStatus, y as SenderDomainConfig, z as SenderDomainRegistry, G as SenderDomainValidation, I as SubscriptionDoc, J as SubscriptionStatus, K as SuppressionDoc, Q as SuppressionReason, U as TemplateKind, V as TemplateVersionDoc, W as VarsAdapter, X as VarsResolveInfo, Y as WebhookEventDoc, Z as defineVars, _ as ensureIndexes, $ as getCollections, a0 as validateSenderDomain, a1 as varsJsonSchema } from './null-BRSHAxvg.cjs';
3
3
  import { ObjectId, Db, Filter } from 'mongodb';
4
4
  import { Request, Router } from 'express';
5
5
  import Handlebars from 'handlebars';
@@ -398,6 +398,10 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
398
398
  /**
399
399
  * Public exports for the `mailery` package.
400
400
  */
401
- declare const VERSION = "0.8.1";
401
+ /**
402
+ * Library version, stamped from package.json at build time (tsup/vitest
403
+ * `define`). 'dev' when the source runs without a bundler define (plain tsx).
404
+ */
405
+ declare const VERSION: string;
402
406
 
403
407
  export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, DeliveryWindow, FLOW_STEP_KINDS, FlowStep, type FlowStepKindOption, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, D as DeliveryWindow, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-CwXmiVLe.js';
2
- export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RESERVED_VAR_KEYS, u as RedisOptions, v as SegmentDefinition, w as SendDoc, x as SendStatus, y as SenderDomainConfig, z as SenderDomainRegistry, G as SenderDomainValidation, I as SubscriptionDoc, J as SubscriptionStatus, K as SuppressionDoc, Q as SuppressionReason, U as TemplateKind, V as TemplateVersionDoc, W as VarsAdapter, X as VarsResolveInfo, Y as WebhookEventDoc, Z as defineVars, _ as ensureIndexes, $ as getCollections, a0 as validateSenderDomain, a1 as varsJsonSchema } from './null-CwXmiVLe.js';
1
+ import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, D as DeliveryWindow, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-BRSHAxvg.js';
2
+ export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RESERVED_VAR_KEYS, u as RedisOptions, v as SegmentDefinition, w as SendDoc, x as SendStatus, y as SenderDomainConfig, z as SenderDomainRegistry, G as SenderDomainValidation, I as SubscriptionDoc, J as SubscriptionStatus, K as SuppressionDoc, Q as SuppressionReason, U as TemplateKind, V as TemplateVersionDoc, W as VarsAdapter, X as VarsResolveInfo, Y as WebhookEventDoc, Z as defineVars, _ as ensureIndexes, $ as getCollections, a0 as validateSenderDomain, a1 as varsJsonSchema } from './null-BRSHAxvg.js';
3
3
  import { ObjectId, Db, Filter } from 'mongodb';
4
4
  import { Request, Router } from 'express';
5
5
  import Handlebars from 'handlebars';
@@ -398,6 +398,10 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
398
398
  /**
399
399
  * Public exports for the `mailery` package.
400
400
  */
401
- declare const VERSION = "0.8.1";
401
+ /**
402
+ * Library version, stamped from package.json at build time (tsup/vitest
403
+ * `define`). 'dev' when the source runs without a bundler define (plain tsx).
404
+ */
405
+ declare const VERSION: string;
402
406
 
403
407
  export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, DeliveryWindow, FLOW_STEP_KINDS, FlowStep, type FlowStepKindOption, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
package/dist/index.js CHANGED
@@ -879,7 +879,7 @@ var BullDriver = class _BullDriver {
879
879
  bullQueues;
880
880
  workers = null;
881
881
  bull;
882
- static async create(redisConfig) {
882
+ static async create(redisConfig, prefix) {
883
883
  let bull;
884
884
  try {
885
885
  bull = await import('bullmq');
@@ -888,14 +888,22 @@ var BullDriver = class _BullDriver {
888
888
  "mailery: queue driver 'bull' requires the 'bullmq' peer dependency. Run `npm install bullmq ioredis`."
889
889
  );
890
890
  }
891
+ if (prefix?.includes(":")) {
892
+ throw new Error(
893
+ `mailery: queue prefix "${prefix}" must not contain ':' \u2014 BullMQ uses it as the Redis key separator.`
894
+ );
895
+ }
891
896
  const redis = isRedisLike(redisConfig) ? redisConfig : connect(redisConfig);
892
- return new _BullDriver(bull, redis);
897
+ return new _BullDriver(bull, redis, prefix);
893
898
  }
894
- constructor(bull, redis) {
899
+ prefix;
900
+ constructor(bull, redis, prefix) {
895
901
  this.bull = bull;
896
902
  this.redis = redis;
903
+ this.prefix = prefix;
897
904
  const opts = {
898
905
  connection: redis,
906
+ prefix,
899
907
  defaultJobOptions: {
900
908
  removeOnComplete: { age: 24 * 3600, count: 1e3 },
901
909
  removeOnFail: { age: 7 * 24 * 3600 }
@@ -927,7 +935,7 @@ var BullDriver = class _BullDriver {
927
935
  }
928
936
  async startWorkers(opts) {
929
937
  if (this.workers) return;
930
- const base = { connection: this.redis };
938
+ const base = { connection: this.redis, prefix: this.prefix };
931
939
  const { Worker } = this.bull;
932
940
  const tick = new Worker(
933
941
  QUEUE_NAMES.tick,
@@ -1179,7 +1187,7 @@ var NoopDriver = class {
1179
1187
  async function createQueueDriver(config, fallbackDb) {
1180
1188
  switch (config.driver) {
1181
1189
  case "bull":
1182
- return BullDriver.create(config.redis);
1190
+ return BullDriver.create(config.redis, config.prefix);
1183
1191
  case "agenda":
1184
1192
  return AgendaDriver.create({
1185
1193
  db: config.db ?? fallbackDb,
@@ -3923,6 +3931,7 @@ var Mailer = class _Mailer {
3923
3931
  * MAILER_MONGODB_URI — Mongo connection string (required)
3924
3932
  * MAILER_MONGODB_DB — database name (optional; defaults to the URI default)
3925
3933
  * MAILER_REDIS_URL — Redis connection URL (required)
3934
+ * MAILER_QUEUE_PREFIX — Redis key prefix to namespace this instance (optional)
3926
3935
  * MAILER_PUBLIC_URL — base for tracking/unsub URLs (required)
3927
3936
  * MAILER_UNSUBSCRIBE_SECRET — HMAC key (required)
3928
3937
  * MAILER_SENDER_ADDRESS — postal address for CAN-SPAM (optional)
@@ -3971,7 +3980,11 @@ var Mailer = class _Mailer {
3971
3980
  }
3972
3981
  const defaultProvider = env.MAILER_DEFAULT_PROVIDER ?? Object.keys(providers)[0];
3973
3982
  const driverEnv = env.MAILER_QUEUE_DRIVER ?? "bull";
3974
- const queue = driverEnv === "agenda" ? { driver: "agenda" } : driverEnv === "noop" ? { driver: "noop" } : { driver: "bull", redis: { url: required("MAILER_REDIS_URL") } };
3983
+ const queue = driverEnv === "agenda" ? { driver: "agenda" } : driverEnv === "noop" ? { driver: "noop" } : {
3984
+ driver: "bull",
3985
+ redis: { url: required("MAILER_REDIS_URL") },
3986
+ prefix: env.MAILER_QUEUE_PREFIX
3987
+ };
3975
3988
  return _Mailer.init({
3976
3989
  db,
3977
3990
  adapter,
@@ -7520,7 +7533,7 @@ var DEDUPE_POLICIES = [
7520
7533
  ];
7521
7534
 
7522
7535
  // src/server/index.ts
7523
- var VERSION = "0.8.1";
7536
+ var VERSION = "0.9.0" ;
7524
7537
 
7525
7538
  export { DEDUPE_POLICIES, FLOW_STEP_KINDS, Mailer, MongoContactAdapter, NullProvider, PREDICATE_KINDS, RESERVED_VAR_KEYS, SEGMENT_FILTER_KINDS, SendGridProvider, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, defineVars, derivePlaintext, dispatchSend, ensureIndexes, getCollections, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, validateSenderDomain, varsJsonSchema, verifyUnsubscribeToken };
7526
7539
  //# sourceMappingURL=index.js.map