mailery 0.19.1 → 0.20.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 +54 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -26
- package/dist/index.js.map +1 -1
- package/dist/{null-DxTHQSrJ.d.cts → null-B3N6bTpc.d.cts} +33 -5
- package/dist/{null-DxTHQSrJ.d.ts → null-B3N6bTpc.d.ts} +33 -5
- package/dist/testing.cjs +52 -24
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +52 -24
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
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, b as AdapterSort, M as MailProvider, S as SendArgs, c as SendResult, d as MailTesterFeedback, e as Mailer, T as TemplateDoc, F as FlowStep, f as Collections, g as FlowDoc, h as SuppressionScope, D as DeliveryWindow, i as SegmentFilter, P as Predicate } from './null-
|
|
2
|
-
export { j as AuditLogDoc, B as BotFilterConfig, k as BroadcastDoc, l as BroadcastOrder, m as BroadcastPauseReason, n as BroadcastStatus, o as CircuitBreakerThresholds, p as ContactTagDoc, E as EventDoc,
|
|
1
|
+
import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, b as AdapterSort, M as MailProvider, S as SendArgs, c as SendResult, d as MailTesterFeedback, e as Mailer, T as TemplateDoc, F as FlowStep, f as Collections, g as FlowDoc, h as SuppressionScope, D as DeliveryWindow, i as SegmentFilter, P as Predicate } from './null-B3N6bTpc.cjs';
|
|
2
|
+
export { j as AuditLogDoc, B as BotFilterConfig, k as BroadcastDoc, l as BroadcastOrder, m as BroadcastPauseReason, n as BroadcastStatus, o as CircuitBreakerThresholds, p as ContactAdapterFactory, q as ContactTagDoc, E as EventDoc, r as FlowGoal, s as FlowRunDoc, t as FlowRunStatus, u as FlowVersionDoc, H as HealthDoc, v as HealthStatus, L as LeadDoc, w as MailerConfig, x as MailerMongoConnection, y as NullProvider, O as OutboxDoc, z as RESERVED_VAR_KEYS, G as RedisOptions, I as SegmentDefinition, J as SendDoc, K as SendStatus, Q as SenderDomainConfig, U as SenderDomainRegistry, V as SenderDomainValidation, W as SubscriptionDoc, X as SubscriptionStatus, Y as SuppressionDoc, Z as SuppressionReason, _ as TemplateKind, $ as TemplateVersionDoc, a0 as VarsAdapter, a1 as VarsResolveInfo, a2 as WebhookEventDoc, a3 as defineVars, a4 as ensureIndexes, a5 as getCollections, a6 as validateSenderDomain, a7 as varsJsonSchema } from './null-B3N6bTpc.cjs';
|
|
3
3
|
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
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, b as AdapterSort, M as MailProvider, S as SendArgs, c as SendResult, d as MailTesterFeedback, e as Mailer, T as TemplateDoc, F as FlowStep, f as Collections, g as FlowDoc, h as SuppressionScope, D as DeliveryWindow, i as SegmentFilter, P as Predicate } from './null-
|
|
2
|
-
export { j as AuditLogDoc, B as BotFilterConfig, k as BroadcastDoc, l as BroadcastOrder, m as BroadcastPauseReason, n as BroadcastStatus, o as CircuitBreakerThresholds, p as ContactTagDoc, E as EventDoc,
|
|
1
|
+
import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, b as AdapterSort, M as MailProvider, S as SendArgs, c as SendResult, d as MailTesterFeedback, e as Mailer, T as TemplateDoc, F as FlowStep, f as Collections, g as FlowDoc, h as SuppressionScope, D as DeliveryWindow, i as SegmentFilter, P as Predicate } from './null-B3N6bTpc.js';
|
|
2
|
+
export { j as AuditLogDoc, B as BotFilterConfig, k as BroadcastDoc, l as BroadcastOrder, m as BroadcastPauseReason, n as BroadcastStatus, o as CircuitBreakerThresholds, p as ContactAdapterFactory, q as ContactTagDoc, E as EventDoc, r as FlowGoal, s as FlowRunDoc, t as FlowRunStatus, u as FlowVersionDoc, H as HealthDoc, v as HealthStatus, L as LeadDoc, w as MailerConfig, x as MailerMongoConnection, y as NullProvider, O as OutboxDoc, z as RESERVED_VAR_KEYS, G as RedisOptions, I as SegmentDefinition, J as SendDoc, K as SendStatus, Q as SenderDomainConfig, U as SenderDomainRegistry, V as SenderDomainValidation, W as SubscriptionDoc, X as SubscriptionStatus, Y as SuppressionDoc, Z as SuppressionReason, _ as TemplateKind, $ as TemplateVersionDoc, a0 as VarsAdapter, a1 as VarsResolveInfo, a2 as WebhookEventDoc, a3 as defineVars, a4 as ensureIndexes, a5 as getCollections, a6 as validateSenderDomain, a7 as varsJsonSchema } from './null-B3N6bTpc.js';
|
|
3
3
|
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
package/dist/index.js
CHANGED
|
@@ -2482,7 +2482,7 @@ function derivePlaintext(html) {
|
|
|
2482
2482
|
var PLAIN_TEXT = { noEscape: true };
|
|
2483
2483
|
async function renderTemplate(template, ctx, opts = {}) {
|
|
2484
2484
|
const hb = makeHandlebars(opts.helpers);
|
|
2485
|
-
const subject = hb.compile(template.subject)(ctx);
|
|
2485
|
+
const subject = hb.compile(template.subject, PLAIN_TEXT)(ctx).replace(/[\r\n]+/g, " ");
|
|
2486
2486
|
const preheader = hb.compile(template.preheader)(ctx);
|
|
2487
2487
|
let html;
|
|
2488
2488
|
if (template.body.html) {
|
|
@@ -5130,6 +5130,7 @@ async function processScheduledBroadcasts2(ctx) {
|
|
|
5130
5130
|
}
|
|
5131
5131
|
|
|
5132
5132
|
// src/server/mailer.ts
|
|
5133
|
+
var STORAGE_REQUIRED = "Mailer.init: give exactly one of `db` (an open Db) or `mongo` (a connection mailery opens)";
|
|
5133
5134
|
var Mailer = class _Mailer {
|
|
5134
5135
|
db;
|
|
5135
5136
|
collections;
|
|
@@ -5139,6 +5140,8 @@ var Mailer = class _Mailer {
|
|
|
5139
5140
|
config;
|
|
5140
5141
|
events;
|
|
5141
5142
|
queueDriver;
|
|
5143
|
+
/** The client `Mailer.init` opened from `config.mongo`; closed by `stop()`. Null when the host gave `db`. */
|
|
5144
|
+
ownedClient;
|
|
5142
5145
|
workersStarted = false;
|
|
5143
5146
|
runnerContext;
|
|
5144
5147
|
constructor(args) {
|
|
@@ -5148,6 +5151,7 @@ var Mailer = class _Mailer {
|
|
|
5148
5151
|
this.adapter = args.adapter;
|
|
5149
5152
|
this.providers = args.providers;
|
|
5150
5153
|
this.queueDriver = args.queueDriver;
|
|
5154
|
+
this.ownedClient = args.ownedClient;
|
|
5151
5155
|
this.queues = args.queueDriver.queues;
|
|
5152
5156
|
this.events = args.events;
|
|
5153
5157
|
this.runnerContext = {
|
|
@@ -5244,36 +5248,58 @@ var Mailer = class _Mailer {
|
|
|
5244
5248
|
});
|
|
5245
5249
|
}
|
|
5246
5250
|
static async init(input) {
|
|
5247
|
-
|
|
5248
|
-
if (!resolveProvider(
|
|
5251
|
+
if (input.db == null === (input.mongo == null)) throw new Error(STORAGE_REQUIRED);
|
|
5252
|
+
if (!resolveProvider(input.providers, input.defaultProvider)) {
|
|
5249
5253
|
throw new Error(
|
|
5250
|
-
`defaultProvider "${
|
|
5254
|
+
`defaultProvider "${input.defaultProvider}" is not a registered provider. Registered: ${registeredProviderNames(input.providers).join(", ") || "(none)"}`
|
|
5251
5255
|
);
|
|
5252
5256
|
}
|
|
5253
|
-
if (
|
|
5257
|
+
if (input.defaultTransactionalProvider != null && !resolveProvider(input.providers, input.defaultTransactionalProvider)) {
|
|
5254
5258
|
throw new Error(
|
|
5255
|
-
`defaultTransactionalProvider "${
|
|
5259
|
+
`defaultTransactionalProvider "${input.defaultTransactionalProvider}" is not a registered provider. Registered: ${registeredProviderNames(input.providers).join(", ") || "(none)"}`
|
|
5256
5260
|
);
|
|
5257
5261
|
}
|
|
5258
|
-
if (
|
|
5262
|
+
if (input.varsAdapter) {
|
|
5259
5263
|
const { assertNoReservedVarKeys: assertNoReservedVarKeys2 } = await Promise.resolve().then(() => (init_vars(), vars_exports));
|
|
5260
|
-
assertNoReservedVarKeys2(
|
|
5261
|
-
}
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
await
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5264
|
+
assertNoReservedVarKeys2(input.varsAdapter);
|
|
5265
|
+
}
|
|
5266
|
+
let ownedClient = null;
|
|
5267
|
+
let db;
|
|
5268
|
+
if (input.mongo) {
|
|
5269
|
+
const { MongoClient } = await import('mongodb');
|
|
5270
|
+
ownedClient = await MongoClient.connect(input.mongo.uri, input.mongo.clientOptions);
|
|
5271
|
+
db = ownedClient.db(input.mongo.dbName);
|
|
5272
|
+
} else if (input.db) {
|
|
5273
|
+
db = input.db;
|
|
5274
|
+
} else {
|
|
5275
|
+
throw new Error(STORAGE_REQUIRED);
|
|
5276
|
+
}
|
|
5277
|
+
try {
|
|
5278
|
+
const config = resolveConfig({
|
|
5279
|
+
...input,
|
|
5280
|
+
db,
|
|
5281
|
+
adapter: typeof input.adapter === "function" ? input.adapter(db) : input.adapter
|
|
5282
|
+
});
|
|
5283
|
+
const collections = getCollections(config.db, config.collectionPrefix);
|
|
5284
|
+
await ensureIndexes(config.db, config.collectionPrefix);
|
|
5285
|
+
const queueDriver = await createQueueDriver(config.queue, config.db);
|
|
5286
|
+
if (!config.workerless && config.queue.driver !== "noop") {
|
|
5287
|
+
await queueDriver.scheduleRepeatingTick(config.tickIntervalSeconds);
|
|
5288
|
+
}
|
|
5289
|
+
return new _Mailer({
|
|
5290
|
+
config,
|
|
5291
|
+
db: config.db,
|
|
5292
|
+
collections,
|
|
5293
|
+
adapter: config.adapter,
|
|
5294
|
+
providers: config.providers,
|
|
5295
|
+
queueDriver,
|
|
5296
|
+
events: new EventRegistry(),
|
|
5297
|
+
ownedClient
|
|
5298
|
+
});
|
|
5299
|
+
} catch (err) {
|
|
5300
|
+
await ownedClient?.close();
|
|
5301
|
+
throw err;
|
|
5302
|
+
}
|
|
5277
5303
|
}
|
|
5278
5304
|
// -------------------------------------------------------------------------
|
|
5279
5305
|
// Event registration + firing
|
|
@@ -5746,6 +5772,8 @@ var Mailer = class _Mailer {
|
|
|
5746
5772
|
async stop() {
|
|
5747
5773
|
await this.queueDriver.close();
|
|
5748
5774
|
this.workersStarted = false;
|
|
5775
|
+
await this.ownedClient?.close();
|
|
5776
|
+
this.ownedClient = null;
|
|
5749
5777
|
}
|
|
5750
5778
|
/** Used internally by the admin router and tests; not part of the public API. */
|
|
5751
5779
|
getRunnerContext() {
|
|
@@ -9561,7 +9589,7 @@ function unitToMs2(value, unit) {
|
|
|
9561
9589
|
}
|
|
9562
9590
|
|
|
9563
9591
|
// src/server/api/agent.ts
|
|
9564
|
-
var VERSION = "0.
|
|
9592
|
+
var VERSION = "0.20.0" ;
|
|
9565
9593
|
var broadcastCountSchema = z.object({
|
|
9566
9594
|
recipientCap: z.number().int().positive().max(1e7).nullable().optional()
|
|
9567
9595
|
});
|
|
@@ -11628,7 +11656,7 @@ var DEDUPE_POLICIES = [
|
|
|
11628
11656
|
];
|
|
11629
11657
|
|
|
11630
11658
|
// src/server/index.ts
|
|
11631
|
-
var VERSION2 = "0.
|
|
11659
|
+
var VERSION2 = "0.20.0" ;
|
|
11632
11660
|
|
|
11633
11661
|
export { DEDUPE_POLICIES, DEFAULT_BOT_UA_RE, FLOW_STEP_KINDS, FlowOperationError, MIN_AGENT_TOKEN_LENGTH, Mailer, MongoContactAdapter, NullProvider, PREDICATE_KINDS, RESERVED_VAR_KEYS, SEGMENT_FILTER_KINDS, SendGridProvider, TRACKING_SIG_LENGTH, VERSION2 as VERSION, applyTracking, applyWebhookEvent, armFlow, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminApiRouter, createAdminRouter, createAgentRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, defineVars, derivePlaintext, disarmFlow, dispatchSend, drainPendingUnsubscribes, ensureIndexes, gateFlow, getCollections, isCanaryGate, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, referencedPaths, renderForContact, renderTemplate, runTick, sendgridInboundParser, sha256Hex, signTrackingToken, signUnsubscribeToken, simulateFlow, stampWatermarkIfNull, sweepStrandedFlowRuns, ungateFlow, validateSenderDomain, varsJsonSchema, verifyTemplate, verifyTrackingToken, verifyUnsubscribeToken };
|
|
11634
11662
|
//# sourceMappingURL=index.js.map
|