mailery 0.8.1 → 0.10.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/admin/spa/index-BTww-4AA.js +41 -0
- package/dist/admin/spa/index-BTww-4AA.js.map +1 -0
- package/dist/admin/spa/index.html +1 -1
- package/dist/admin/spa/{template-editor-DwMKy5sw.js → template-editor-CrOKLpSw.js} +2 -2
- package/dist/admin/spa/{template-editor-DwMKy5sw.js.map → template-editor-CrOKLpSw.js.map} +1 -1
- package/dist/index.cjs +82 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +82 -12
- package/dist/index.js.map +1 -1
- package/dist/{null-CwXmiVLe.d.cts → null-CU_EApC6.d.cts} +24 -0
- package/dist/{null-CwXmiVLe.d.ts → null-CU_EApC6.d.ts} +24 -0
- package/dist/testing.cjs +75 -11
- 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 +75 -11
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/admin/spa/index-B3ndbezm.js +0 -41
- package/dist/admin/spa/index-B3ndbezm.js.map +0 -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, 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-
|
|
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-
|
|
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-CU_EApC6.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-CU_EApC6.cjs';
|
|
3
3
|
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
@@ -367,7 +367,7 @@ interface FlowStepKindOption {
|
|
|
367
367
|
}
|
|
368
368
|
declare const FLOW_STEP_KINDS: readonly FlowStepKindOption[];
|
|
369
369
|
declare function defaultFlowStep(type: FlowStep['type']): FlowStep;
|
|
370
|
-
type PredicateKind = 'hasTag' | 'notHasTag' | 'fieldEquals' | 'fieldExists' | 'hasFiredEvent' | 'notHasFiredEvent' | 'subscriptionStatus' | 'hasOpened' | 'hasClicked' | 'hasOpenedExcludingBots' | 'hasClickedExcludingBots' | 'openedAtLeastN' | 'clickedAtLeastN';
|
|
370
|
+
type PredicateKind = 'hasTag' | 'notHasTag' | 'fieldEquals' | 'fieldExists' | 'triggerPropertyEquals' | 'triggerPropertyTruthy' | 'hasFiredEvent' | 'notHasFiredEvent' | 'subscriptionStatus' | 'hasOpened' | 'hasClicked' | 'hasOpenedExcludingBots' | 'hasClickedExcludingBots' | 'openedAtLeastN' | 'clickedAtLeastN';
|
|
371
371
|
interface PredicateKindOption {
|
|
372
372
|
value: PredicateKind;
|
|
373
373
|
label: string;
|
|
@@ -398,6 +398,10 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
|
|
|
398
398
|
/**
|
|
399
399
|
* Public exports for the `mailery` package.
|
|
400
400
|
*/
|
|
401
|
-
|
|
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-
|
|
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-
|
|
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-CU_EApC6.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-CU_EApC6.js';
|
|
3
3
|
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
@@ -367,7 +367,7 @@ interface FlowStepKindOption {
|
|
|
367
367
|
}
|
|
368
368
|
declare const FLOW_STEP_KINDS: readonly FlowStepKindOption[];
|
|
369
369
|
declare function defaultFlowStep(type: FlowStep['type']): FlowStep;
|
|
370
|
-
type PredicateKind = 'hasTag' | 'notHasTag' | 'fieldEquals' | 'fieldExists' | 'hasFiredEvent' | 'notHasFiredEvent' | 'subscriptionStatus' | 'hasOpened' | 'hasClicked' | 'hasOpenedExcludingBots' | 'hasClickedExcludingBots' | 'openedAtLeastN' | 'clickedAtLeastN';
|
|
370
|
+
type PredicateKind = 'hasTag' | 'notHasTag' | 'fieldEquals' | 'fieldExists' | 'triggerPropertyEquals' | 'triggerPropertyTruthy' | 'hasFiredEvent' | 'notHasFiredEvent' | 'subscriptionStatus' | 'hasOpened' | 'hasClicked' | 'hasOpenedExcludingBots' | 'hasClickedExcludingBots' | 'openedAtLeastN' | 'clickedAtLeastN';
|
|
371
371
|
interface PredicateKindOption {
|
|
372
372
|
value: PredicateKind;
|
|
373
373
|
label: string;
|
|
@@ -398,6 +398,10 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
|
|
|
398
398
|
/**
|
|
399
399
|
* Public exports for the `mailery` package.
|
|
400
400
|
*/
|
|
401
|
-
|
|
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
|
@@ -396,7 +396,25 @@ var tagInputSchema = z.object({
|
|
|
396
396
|
var abortFlowInputSchema = z.object({
|
|
397
397
|
flowSlug: slugSchema,
|
|
398
398
|
externalId: externalIdSchema,
|
|
399
|
-
reason: z.string().min(1).max(200).optional()
|
|
399
|
+
reason: z.string().min(1).max(200).optional(),
|
|
400
|
+
/**
|
|
401
|
+
* Restrict the abort to runs whose trigger event carried these properties —
|
|
402
|
+
* e.g. `{ accountId }` to cancel one account's series while the same
|
|
403
|
+
* contact's other accounts keep running. Omit to abort every active run for
|
|
404
|
+
* the contact on this flow.
|
|
405
|
+
*
|
|
406
|
+
* Keys and values are both constrained because these go straight into a
|
|
407
|
+
* Mongo query. Values are primitives only: an object value like
|
|
408
|
+
* `{ $ne: null }` would reach the query as an OPERATOR and match every
|
|
409
|
+
* scoped run, turning a one-account abort into abort-everything. Hosts
|
|
410
|
+
* typically pass an id from a request body, so treat it as untrusted. The
|
|
411
|
+
* key regex likewise blocks `$`-prefixed keys and dots (a dot would silently
|
|
412
|
+
* extend the path and change match semantics).
|
|
413
|
+
*/
|
|
414
|
+
matchTriggerProperties: z.record(
|
|
415
|
+
z.string().regex(/^[A-Za-z0-9_]+$/),
|
|
416
|
+
z.union([z.string(), z.number(), z.boolean(), z.null()])
|
|
417
|
+
).optional()
|
|
400
418
|
});
|
|
401
419
|
var abortAllFlowsInputSchema = abortFlowInputSchema.omit({ flowSlug: true });
|
|
402
420
|
var sendOneOffInputSchema = z.object({
|
|
@@ -465,6 +483,13 @@ var predicateSchema = z.lazy(
|
|
|
465
483
|
z.object({ notHasTag: z.string() }),
|
|
466
484
|
z.object({ fieldEquals: z.object({ field: z.string(), value: z.unknown() }) }),
|
|
467
485
|
z.object({ fieldExists: z.string() }),
|
|
486
|
+
z.object({
|
|
487
|
+
triggerPropertyEquals: z.object({
|
|
488
|
+
key: z.string().min(1),
|
|
489
|
+
value: z.union([z.string(), z.number(), z.boolean(), z.null()])
|
|
490
|
+
})
|
|
491
|
+
}),
|
|
492
|
+
z.object({ triggerPropertyTruthy: z.string().min(1) }),
|
|
468
493
|
z.object({
|
|
469
494
|
hasFiredEvent: z.string(),
|
|
470
495
|
sinceFlowStart: z.boolean().optional(),
|
|
@@ -879,7 +904,7 @@ var BullDriver = class _BullDriver {
|
|
|
879
904
|
bullQueues;
|
|
880
905
|
workers = null;
|
|
881
906
|
bull;
|
|
882
|
-
static async create(redisConfig) {
|
|
907
|
+
static async create(redisConfig, prefix) {
|
|
883
908
|
let bull;
|
|
884
909
|
try {
|
|
885
910
|
bull = await import('bullmq');
|
|
@@ -888,14 +913,22 @@ var BullDriver = class _BullDriver {
|
|
|
888
913
|
"mailery: queue driver 'bull' requires the 'bullmq' peer dependency. Run `npm install bullmq ioredis`."
|
|
889
914
|
);
|
|
890
915
|
}
|
|
916
|
+
if (prefix?.includes(":")) {
|
|
917
|
+
throw new Error(
|
|
918
|
+
`mailery: queue prefix "${prefix}" must not contain ':' \u2014 BullMQ uses it as the Redis key separator.`
|
|
919
|
+
);
|
|
920
|
+
}
|
|
891
921
|
const redis = isRedisLike(redisConfig) ? redisConfig : connect(redisConfig);
|
|
892
|
-
return new _BullDriver(bull, redis);
|
|
922
|
+
return new _BullDriver(bull, redis, prefix);
|
|
893
923
|
}
|
|
894
|
-
|
|
924
|
+
prefix;
|
|
925
|
+
constructor(bull, redis, prefix) {
|
|
895
926
|
this.bull = bull;
|
|
896
927
|
this.redis = redis;
|
|
928
|
+
this.prefix = prefix;
|
|
897
929
|
const opts = {
|
|
898
930
|
connection: redis,
|
|
931
|
+
prefix,
|
|
899
932
|
defaultJobOptions: {
|
|
900
933
|
removeOnComplete: { age: 24 * 3600, count: 1e3 },
|
|
901
934
|
removeOnFail: { age: 7 * 24 * 3600 }
|
|
@@ -927,7 +960,7 @@ var BullDriver = class _BullDriver {
|
|
|
927
960
|
}
|
|
928
961
|
async startWorkers(opts) {
|
|
929
962
|
if (this.workers) return;
|
|
930
|
-
const base = { connection: this.redis };
|
|
963
|
+
const base = { connection: this.redis, prefix: this.prefix };
|
|
931
964
|
const { Worker } = this.bull;
|
|
932
965
|
const tick = new Worker(
|
|
933
966
|
QUEUE_NAMES.tick,
|
|
@@ -1179,7 +1212,7 @@ var NoopDriver = class {
|
|
|
1179
1212
|
async function createQueueDriver(config, fallbackDb) {
|
|
1180
1213
|
switch (config.driver) {
|
|
1181
1214
|
case "bull":
|
|
1182
|
-
return BullDriver.create(config.redis);
|
|
1215
|
+
return BullDriver.create(config.redis, config.prefix);
|
|
1183
1216
|
case "agenda":
|
|
1184
1217
|
return AgendaDriver.create({
|
|
1185
1218
|
db: config.db ?? fallbackDb,
|
|
@@ -1640,6 +1673,12 @@ async function evaluatePredicate(predicate, ctx) {
|
|
|
1640
1673
|
if ("fieldExists" in p) {
|
|
1641
1674
|
return ctx.contact.fields[p.fieldExists] !== void 0;
|
|
1642
1675
|
}
|
|
1676
|
+
if ("triggerPropertyEquals" in p) {
|
|
1677
|
+
return (ctx.run.triggerEvent?.properties ?? {})[p.triggerPropertyEquals.key] === p.triggerPropertyEquals.value;
|
|
1678
|
+
}
|
|
1679
|
+
if ("triggerPropertyTruthy" in p) {
|
|
1680
|
+
return Boolean((ctx.run.triggerEvent?.properties ?? {})[p.triggerPropertyTruthy]);
|
|
1681
|
+
}
|
|
1643
1682
|
if ("subscriptionStatus" in p) {
|
|
1644
1683
|
const sub = await ctx.collections.subscriptions.findOne({ externalId: ctx.contact.externalId });
|
|
1645
1684
|
return sub?.status === p.subscriptionStatus;
|
|
@@ -2392,7 +2431,14 @@ async function handleFireEvent(run, step, ctx) {
|
|
|
2392
2431
|
await ctx.collections.events.insertOne({
|
|
2393
2432
|
externalId: run.externalId,
|
|
2394
2433
|
name: step.eventName,
|
|
2395
|
-
|
|
2434
|
+
// Inherit the triggering event's properties so a handoff carries the
|
|
2435
|
+
// context that identifies what the run is ABOUT (which account, order,
|
|
2436
|
+
// subscription, ...). A step's `properties` are static — authored once in
|
|
2437
|
+
// the flow definition — so without this a fired event can only ever say
|
|
2438
|
+
// "this contact", losing the scope the originating event supplied, and
|
|
2439
|
+
// the receiving flow has nothing to resolve variables against. Explicit
|
|
2440
|
+
// step.properties win on conflict.
|
|
2441
|
+
properties: { ...run.triggerEvent?.properties ?? {}, ...step.properties ?? {} },
|
|
2396
2442
|
dedupeKey,
|
|
2397
2443
|
occurredAt: /* @__PURE__ */ new Date(),
|
|
2398
2444
|
createdAt: /* @__PURE__ */ new Date()
|
|
@@ -3923,6 +3969,7 @@ var Mailer = class _Mailer {
|
|
|
3923
3969
|
* MAILER_MONGODB_URI — Mongo connection string (required)
|
|
3924
3970
|
* MAILER_MONGODB_DB — database name (optional; defaults to the URI default)
|
|
3925
3971
|
* MAILER_REDIS_URL — Redis connection URL (required)
|
|
3972
|
+
* MAILER_QUEUE_PREFIX — Redis key prefix to namespace this instance (optional)
|
|
3926
3973
|
* MAILER_PUBLIC_URL — base for tracking/unsub URLs (required)
|
|
3927
3974
|
* MAILER_UNSUBSCRIBE_SECRET — HMAC key (required)
|
|
3928
3975
|
* MAILER_SENDER_ADDRESS — postal address for CAN-SPAM (optional)
|
|
@@ -3971,7 +4018,11 @@ var Mailer = class _Mailer {
|
|
|
3971
4018
|
}
|
|
3972
4019
|
const defaultProvider = env.MAILER_DEFAULT_PROVIDER ?? Object.keys(providers)[0];
|
|
3973
4020
|
const driverEnv = env.MAILER_QUEUE_DRIVER ?? "bull";
|
|
3974
|
-
const queue = driverEnv === "agenda" ? { driver: "agenda" } : driverEnv === "noop" ? { driver: "noop" } : {
|
|
4021
|
+
const queue = driverEnv === "agenda" ? { driver: "agenda" } : driverEnv === "noop" ? { driver: "noop" } : {
|
|
4022
|
+
driver: "bull",
|
|
4023
|
+
redis: { url: required("MAILER_REDIS_URL") },
|
|
4024
|
+
prefix: env.MAILER_QUEUE_PREFIX
|
|
4025
|
+
};
|
|
3975
4026
|
return _Mailer.init({
|
|
3976
4027
|
db,
|
|
3977
4028
|
adapter,
|
|
@@ -4222,14 +4273,25 @@ var Mailer = class _Mailer {
|
|
|
4222
4273
|
* same handler that processes the business event ("user upgraded").
|
|
4223
4274
|
*/
|
|
4224
4275
|
async abortFlow(flowSlug, externalId, opts = {}) {
|
|
4225
|
-
const parsed = abortFlowInputSchema.parse({
|
|
4276
|
+
const parsed = abortFlowInputSchema.parse({
|
|
4277
|
+
flowSlug,
|
|
4278
|
+
externalId,
|
|
4279
|
+
reason: opts.reason,
|
|
4280
|
+
matchTriggerProperties: opts.matchTriggerProperties
|
|
4281
|
+
});
|
|
4226
4282
|
const flow = await this.collections.flows.findOne(
|
|
4227
4283
|
{ slug: parsed.flowSlug },
|
|
4228
4284
|
{ projection: { _id: 1 } }
|
|
4229
4285
|
);
|
|
4230
4286
|
if (!flow) throw new Error(`abortFlow: unknown flow slug "${parsed.flowSlug}"`);
|
|
4287
|
+
const triggerMatch = Object.fromEntries(
|
|
4288
|
+
Object.entries(parsed.matchTriggerProperties ?? {}).map(([k, v]) => [
|
|
4289
|
+
`triggerEvent.properties.${k}`,
|
|
4290
|
+
v
|
|
4291
|
+
])
|
|
4292
|
+
);
|
|
4231
4293
|
const result = await this.abortActiveRuns(
|
|
4232
|
-
{ externalId: parsed.externalId, flowId: flow._id },
|
|
4294
|
+
{ externalId: parsed.externalId, flowId: flow._id, ...triggerMatch },
|
|
4233
4295
|
parsed.reason ? `aborted_by_host:${parsed.reason}` : "aborted_by_host"
|
|
4234
4296
|
);
|
|
4235
4297
|
if (result.abortedRuns > 0 || result.cancelledSends > 0) {
|
|
@@ -4237,7 +4299,9 @@ var Mailer = class _Mailer {
|
|
|
4237
4299
|
actor: "host",
|
|
4238
4300
|
action: "flow.abort",
|
|
4239
4301
|
resource: { collection: "mailer_flow_runs", slug: parsed.flowSlug },
|
|
4240
|
-
|
|
4302
|
+
// Record the scope: without it a one-account abort and an abort-every-
|
|
4303
|
+
// run-for-this-contact are indistinguishable in the audit trail.
|
|
4304
|
+
diffSummary: `abortFlow slug=${parsed.flowSlug} externalId=${parsed.externalId} scope=${parsed.matchTriggerProperties ? JSON.stringify(parsed.matchTriggerProperties) : "all"} runs=${result.abortedRuns} sends=${result.cancelledSends}${parsed.reason ? ` reason=${parsed.reason}` : ""}`
|
|
4241
4305
|
});
|
|
4242
4306
|
}
|
|
4243
4307
|
return result;
|
|
@@ -7403,6 +7467,8 @@ var PREDICATE_KINDS = [
|
|
|
7403
7467
|
{ value: "notHasTag", label: "does NOT have tag" },
|
|
7404
7468
|
{ value: "fieldEquals", label: "field equals" },
|
|
7405
7469
|
{ value: "fieldExists", label: "field exists" },
|
|
7470
|
+
{ value: "triggerPropertyEquals", label: "trigger property equals" },
|
|
7471
|
+
{ value: "triggerPropertyTruthy", label: "trigger property is set" },
|
|
7406
7472
|
{ value: "hasFiredEvent", label: "fired event" },
|
|
7407
7473
|
{ value: "notHasFiredEvent", label: "has NOT fired event" },
|
|
7408
7474
|
{ value: "subscriptionStatus", label: "subscription status" },
|
|
@@ -7430,6 +7496,10 @@ function defaultPredicate(kind) {
|
|
|
7430
7496
|
return { fieldEquals: { field: "tier", value: "Pro" } };
|
|
7431
7497
|
case "fieldExists":
|
|
7432
7498
|
return { fieldExists: "tier" };
|
|
7499
|
+
case "triggerPropertyEquals":
|
|
7500
|
+
return { triggerPropertyEquals: { key: "plan", value: "pro" } };
|
|
7501
|
+
case "triggerPropertyTruthy":
|
|
7502
|
+
return { triggerPropertyTruthy: "wasReferred" };
|
|
7433
7503
|
case "hasFiredEvent":
|
|
7434
7504
|
return { hasFiredEvent: "Activated app" };
|
|
7435
7505
|
case "notHasFiredEvent":
|
|
@@ -7520,7 +7590,7 @@ var DEDUPE_POLICIES = [
|
|
|
7520
7590
|
];
|
|
7521
7591
|
|
|
7522
7592
|
// src/server/index.ts
|
|
7523
|
-
var VERSION = "0.
|
|
7593
|
+
var VERSION = "0.10.0" ;
|
|
7524
7594
|
|
|
7525
7595
|
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
7596
|
//# sourceMappingURL=index.js.map
|