mailery 0.1.0 → 0.1.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/admin/spa/index-DlhleV6M.js +41 -0
- package/dist/admin/spa/index-DlhleV6M.js.map +1 -0
- package/dist/admin/spa/index.html +1 -1
- package/dist/admin/spa/{template-editor-Cx1ky7rr.js → template-editor-DUZfzI5F.js} +65 -65
- package/dist/admin/spa/{template-editor-Cx1ky7rr.js.map → template-editor-DUZfzI5F.js.map} +1 -1
- package/dist/index.cjs +167 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -4
- package/dist/index.d.ts +106 -4
- package/dist/index.js +153 -1
- package/dist/index.js.map +1 -1
- package/dist/{null-7gnz1V98.d.cts → null-OzIqP7A8.d.cts} +1 -1
- package/dist/{null-7gnz1V98.d.ts → null-OzIqP7A8.d.ts} +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/package.json +5 -1
- package/dist/admin/spa/index-C_FJL_E_.js +0 -41
- package/dist/admin/spa/index-C_FJL_E_.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
|
-
import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult,
|
|
2
|
-
export {
|
|
3
|
-
import { Db, Filter } from 'mongodb';
|
|
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 Mailer, T as TemplateDoc, d as SuppressionScope, F as FlowStep, e as SegmentFilter, P as Predicate } from './null-OzIqP7A8.cjs';
|
|
2
|
+
export { f as AuditLogDoc, B as BroadcastDoc, g as BroadcastStatus, h as CircuitBreakerThresholds, i as Collections, j as ContactTagDoc, E as EventDoc, k as FlowDoc, l as FlowGoal, m as FlowRunDoc, n as FlowRunStatus, o as FlowVersionDoc, H as HealthDoc, p as HealthStatus, L as LeadDoc, q as MailerConfig, r as NullProvider, O as OutboxDoc, s as RedisOptions, t as SegmentDefinition, u as SendDoc, v as SendStatus, w as SubscriptionDoc, x as SubscriptionStatus, y as SuppressionDoc, z as SuppressionReason, D as TemplateKind, G as TemplateVersionDoc, W as WebhookEventDoc, I as ensureIndexes, J as getCollections } from './null-OzIqP7A8.cjs';
|
|
3
|
+
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
6
6
|
import 'ioredis';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The mailer:tick handler. Orchestrates all the periodic work that doesn't
|
|
11
|
+
* fit a delayed-job model: event-trigger scanning, recovery sweep,
|
|
12
|
+
* scheduled-broadcast dispatch, outbox draining, rollups.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare function runTick(ctx: RunnerContext): Promise<void>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Flow_run state machine. One step transition per `processOneRunStep` call.
|
|
19
|
+
* Idempotent — optimistic concurrency on `currentStepIndex` means two workers
|
|
20
|
+
* racing on the same run advance exactly once.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
declare function processOneRunStep(runId: ObjectId, ctx: RunnerContext): Promise<void>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Send pipeline. `handleSend` is called by the runner state machine; it creates
|
|
27
|
+
* the Send document and enqueues a mailer:send job. `dispatchSend` is the
|
|
28
|
+
* worker — re-checks suppression + circuit breaker, applies tracking, calls
|
|
29
|
+
* the provider, updates the Send row.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
declare function dispatchSend(sendId: ObjectId, ctx: RunnerContext): Promise<void>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Event-trigger scan. Finds new event firings since each flow's
|
|
36
|
+
* lastTriggerScanAt watermark, creates flow_runs for matching contacts,
|
|
37
|
+
* enqueues immediate-advance jobs.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
declare function processNewlyFiredEventTriggers(ctx: RunnerContext): Promise<void>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Recovery sweep: finds active flow_runs whose `nextActionAt` has passed but
|
|
44
|
+
* weren't woken by their delayed `mailer:advance` job (worker restart, BullMQ
|
|
45
|
+
* data loss). Processes each one inline.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
declare function sweepStrandedFlowRuns(ctx: RunnerContext): Promise<void>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Apply a normalized provider event to the corresponding Send + cascading
|
|
52
|
+
* suppression / subscription updates. Called from the webhook worker.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
declare function applyWebhookEvent(event: NormalizedEvent, ctx: RunnerContext): Promise<void>;
|
|
56
|
+
|
|
9
57
|
/**
|
|
10
58
|
* MongoContactAdapter — reads contacts directly from the host's `users`
|
|
11
59
|
* collection (read-mostly; optional narrow tag writes). Mailer never
|
|
@@ -157,6 +205,12 @@ interface CompileResult {
|
|
|
157
205
|
}
|
|
158
206
|
/** Compile MJML → HTML, then derive plain text. Called at template publish time. */
|
|
159
207
|
declare function compileTemplate(mjml: string): Promise<CompileResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Compile Maily editor JSON (Tiptap-shape) → HTML via `@maily-to/render`, then
|
|
210
|
+
* derive plain text. Called at template publish time when the template was
|
|
211
|
+
* authored via the WYSIWYG editor.
|
|
212
|
+
*/
|
|
213
|
+
declare function compileMailyTemplate(content: unknown): Promise<CompileResult>;
|
|
160
214
|
/** Auto-derive plain text from compiled HTML. */
|
|
161
215
|
declare function derivePlaintext(html: string): string;
|
|
162
216
|
interface RenderContext {
|
|
@@ -235,9 +289,57 @@ declare function verifyUnsubscribeToken(token: string, secret: string, now?: Dat
|
|
|
235
289
|
*/
|
|
236
290
|
declare function sha256Hex(input: string): string;
|
|
237
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Enumerable option lists for the union types in `./types.ts`. Used by the
|
|
294
|
+
* admin client to render dropdowns + by tooling to enumerate the surface.
|
|
295
|
+
*
|
|
296
|
+
* Kept in `shared/` so the client and server agree on the canonical labels +
|
|
297
|
+
* default constructors. Pure data + pure functions — no React, no DOM.
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
interface FlowStepKindOption {
|
|
301
|
+
value: FlowStep['type'];
|
|
302
|
+
label: string;
|
|
303
|
+
/** Icon name from the client's icon set (lookup at render time). */
|
|
304
|
+
icon: string;
|
|
305
|
+
/** Visual class on the canvas chip. */
|
|
306
|
+
iconClass: string;
|
|
307
|
+
/** One-line description for tooltips / docs generation. */
|
|
308
|
+
description: string;
|
|
309
|
+
}
|
|
310
|
+
declare const FLOW_STEP_KINDS: readonly FlowStepKindOption[];
|
|
311
|
+
declare function defaultFlowStep(type: FlowStep['type']): FlowStep;
|
|
312
|
+
type PredicateKind = 'hasTag' | 'notHasTag' | 'fieldEquals' | 'fieldExists' | 'hasFiredEvent' | 'notHasFiredEvent' | 'subscriptionStatus' | 'hasOpened' | 'hasClicked' | 'hasOpenedExcludingBots' | 'hasClickedExcludingBots' | 'openedAtLeastN' | 'clickedAtLeastN';
|
|
313
|
+
interface PredicateKindOption {
|
|
314
|
+
value: PredicateKind;
|
|
315
|
+
label: string;
|
|
316
|
+
/** True when this predicate's signal is noisy (Apple MPP, bot prefetch). */
|
|
317
|
+
noisy?: boolean;
|
|
318
|
+
}
|
|
319
|
+
declare const PREDICATE_KINDS: readonly PredicateKindOption[];
|
|
320
|
+
/** Identify which kind of predicate this object is (or null for composites/unknown). */
|
|
321
|
+
declare function predicateKind(p: Predicate | null | undefined): PredicateKind | null;
|
|
322
|
+
declare function defaultPredicate(kind: PredicateKind): Predicate;
|
|
323
|
+
type SegmentFilterKind = SegmentFilter['kind'];
|
|
324
|
+
interface SegmentFilterKindOption {
|
|
325
|
+
value: SegmentFilterKind;
|
|
326
|
+
label: string;
|
|
327
|
+
/** Where the filter is evaluated: host-side via adapter, or mailer-side post-filter. */
|
|
328
|
+
side: 'host' | 'mailer' | 'composite';
|
|
329
|
+
}
|
|
330
|
+
declare const SEGMENT_FILTER_KINDS: readonly SegmentFilterKindOption[];
|
|
331
|
+
declare function defaultSegmentFilter(kind: SegmentFilterKind): SegmentFilter;
|
|
332
|
+
interface DedupePolicyOption {
|
|
333
|
+
value: 'once-per-contact' | 'once-per-day' | 'every-time';
|
|
334
|
+
label: string;
|
|
335
|
+
description: string;
|
|
336
|
+
derivedKeyShape: string;
|
|
337
|
+
}
|
|
338
|
+
declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
|
|
339
|
+
|
|
238
340
|
/**
|
|
239
341
|
* Public exports for the `mailery` package.
|
|
240
342
|
*/
|
|
241
343
|
declare const VERSION = "0.1.0";
|
|
242
344
|
|
|
243
|
-
export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, type PublicRouterOptions, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, compileTemplate, createAdminRouter, createPublicRouter, derivePlaintext, renderTemplate, sha256Hex, signUnsubscribeToken, verifyUnsubscribeToken };
|
|
345
|
+
export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, 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, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
|
-
import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult,
|
|
2
|
-
export {
|
|
3
|
-
import { Db, Filter } from 'mongodb';
|
|
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 Mailer, T as TemplateDoc, d as SuppressionScope, F as FlowStep, e as SegmentFilter, P as Predicate } from './null-OzIqP7A8.js';
|
|
2
|
+
export { f as AuditLogDoc, B as BroadcastDoc, g as BroadcastStatus, h as CircuitBreakerThresholds, i as Collections, j as ContactTagDoc, E as EventDoc, k as FlowDoc, l as FlowGoal, m as FlowRunDoc, n as FlowRunStatus, o as FlowVersionDoc, H as HealthDoc, p as HealthStatus, L as LeadDoc, q as MailerConfig, r as NullProvider, O as OutboxDoc, s as RedisOptions, t as SegmentDefinition, u as SendDoc, v as SendStatus, w as SubscriptionDoc, x as SubscriptionStatus, y as SuppressionDoc, z as SuppressionReason, D as TemplateKind, G as TemplateVersionDoc, W as WebhookEventDoc, I as ensureIndexes, J as getCollections } from './null-OzIqP7A8.js';
|
|
3
|
+
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
6
6
|
import 'ioredis';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The mailer:tick handler. Orchestrates all the periodic work that doesn't
|
|
11
|
+
* fit a delayed-job model: event-trigger scanning, recovery sweep,
|
|
12
|
+
* scheduled-broadcast dispatch, outbox draining, rollups.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare function runTick(ctx: RunnerContext): Promise<void>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Flow_run state machine. One step transition per `processOneRunStep` call.
|
|
19
|
+
* Idempotent — optimistic concurrency on `currentStepIndex` means two workers
|
|
20
|
+
* racing on the same run advance exactly once.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
declare function processOneRunStep(runId: ObjectId, ctx: RunnerContext): Promise<void>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Send pipeline. `handleSend` is called by the runner state machine; it creates
|
|
27
|
+
* the Send document and enqueues a mailer:send job. `dispatchSend` is the
|
|
28
|
+
* worker — re-checks suppression + circuit breaker, applies tracking, calls
|
|
29
|
+
* the provider, updates the Send row.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
declare function dispatchSend(sendId: ObjectId, ctx: RunnerContext): Promise<void>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Event-trigger scan. Finds new event firings since each flow's
|
|
36
|
+
* lastTriggerScanAt watermark, creates flow_runs for matching contacts,
|
|
37
|
+
* enqueues immediate-advance jobs.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
declare function processNewlyFiredEventTriggers(ctx: RunnerContext): Promise<void>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Recovery sweep: finds active flow_runs whose `nextActionAt` has passed but
|
|
44
|
+
* weren't woken by their delayed `mailer:advance` job (worker restart, BullMQ
|
|
45
|
+
* data loss). Processes each one inline.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
declare function sweepStrandedFlowRuns(ctx: RunnerContext): Promise<void>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Apply a normalized provider event to the corresponding Send + cascading
|
|
52
|
+
* suppression / subscription updates. Called from the webhook worker.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
declare function applyWebhookEvent(event: NormalizedEvent, ctx: RunnerContext): Promise<void>;
|
|
56
|
+
|
|
9
57
|
/**
|
|
10
58
|
* MongoContactAdapter — reads contacts directly from the host's `users`
|
|
11
59
|
* collection (read-mostly; optional narrow tag writes). Mailer never
|
|
@@ -157,6 +205,12 @@ interface CompileResult {
|
|
|
157
205
|
}
|
|
158
206
|
/** Compile MJML → HTML, then derive plain text. Called at template publish time. */
|
|
159
207
|
declare function compileTemplate(mjml: string): Promise<CompileResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Compile Maily editor JSON (Tiptap-shape) → HTML via `@maily-to/render`, then
|
|
210
|
+
* derive plain text. Called at template publish time when the template was
|
|
211
|
+
* authored via the WYSIWYG editor.
|
|
212
|
+
*/
|
|
213
|
+
declare function compileMailyTemplate(content: unknown): Promise<CompileResult>;
|
|
160
214
|
/** Auto-derive plain text from compiled HTML. */
|
|
161
215
|
declare function derivePlaintext(html: string): string;
|
|
162
216
|
interface RenderContext {
|
|
@@ -235,9 +289,57 @@ declare function verifyUnsubscribeToken(token: string, secret: string, now?: Dat
|
|
|
235
289
|
*/
|
|
236
290
|
declare function sha256Hex(input: string): string;
|
|
237
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Enumerable option lists for the union types in `./types.ts`. Used by the
|
|
294
|
+
* admin client to render dropdowns + by tooling to enumerate the surface.
|
|
295
|
+
*
|
|
296
|
+
* Kept in `shared/` so the client and server agree on the canonical labels +
|
|
297
|
+
* default constructors. Pure data + pure functions — no React, no DOM.
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
interface FlowStepKindOption {
|
|
301
|
+
value: FlowStep['type'];
|
|
302
|
+
label: string;
|
|
303
|
+
/** Icon name from the client's icon set (lookup at render time). */
|
|
304
|
+
icon: string;
|
|
305
|
+
/** Visual class on the canvas chip. */
|
|
306
|
+
iconClass: string;
|
|
307
|
+
/** One-line description for tooltips / docs generation. */
|
|
308
|
+
description: string;
|
|
309
|
+
}
|
|
310
|
+
declare const FLOW_STEP_KINDS: readonly FlowStepKindOption[];
|
|
311
|
+
declare function defaultFlowStep(type: FlowStep['type']): FlowStep;
|
|
312
|
+
type PredicateKind = 'hasTag' | 'notHasTag' | 'fieldEquals' | 'fieldExists' | 'hasFiredEvent' | 'notHasFiredEvent' | 'subscriptionStatus' | 'hasOpened' | 'hasClicked' | 'hasOpenedExcludingBots' | 'hasClickedExcludingBots' | 'openedAtLeastN' | 'clickedAtLeastN';
|
|
313
|
+
interface PredicateKindOption {
|
|
314
|
+
value: PredicateKind;
|
|
315
|
+
label: string;
|
|
316
|
+
/** True when this predicate's signal is noisy (Apple MPP, bot prefetch). */
|
|
317
|
+
noisy?: boolean;
|
|
318
|
+
}
|
|
319
|
+
declare const PREDICATE_KINDS: readonly PredicateKindOption[];
|
|
320
|
+
/** Identify which kind of predicate this object is (or null for composites/unknown). */
|
|
321
|
+
declare function predicateKind(p: Predicate | null | undefined): PredicateKind | null;
|
|
322
|
+
declare function defaultPredicate(kind: PredicateKind): Predicate;
|
|
323
|
+
type SegmentFilterKind = SegmentFilter['kind'];
|
|
324
|
+
interface SegmentFilterKindOption {
|
|
325
|
+
value: SegmentFilterKind;
|
|
326
|
+
label: string;
|
|
327
|
+
/** Where the filter is evaluated: host-side via adapter, or mailer-side post-filter. */
|
|
328
|
+
side: 'host' | 'mailer' | 'composite';
|
|
329
|
+
}
|
|
330
|
+
declare const SEGMENT_FILTER_KINDS: readonly SegmentFilterKindOption[];
|
|
331
|
+
declare function defaultSegmentFilter(kind: SegmentFilterKind): SegmentFilter;
|
|
332
|
+
interface DedupePolicyOption {
|
|
333
|
+
value: 'once-per-contact' | 'once-per-day' | 'every-time';
|
|
334
|
+
label: string;
|
|
335
|
+
description: string;
|
|
336
|
+
derivedKeyShape: string;
|
|
337
|
+
}
|
|
338
|
+
declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
|
|
339
|
+
|
|
238
340
|
/**
|
|
239
341
|
* Public exports for the `mailery` package.
|
|
240
342
|
*/
|
|
241
343
|
declare const VERSION = "0.1.0";
|
|
242
344
|
|
|
243
|
-
export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, type PublicRouterOptions, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, compileTemplate, createAdminRouter, createPublicRouter, derivePlaintext, renderTemplate, sha256Hex, signUnsubscribeToken, verifyUnsubscribeToken };
|
|
345
|
+
export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, 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, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
|
package/dist/index.js
CHANGED
|
@@ -3662,9 +3662,161 @@ function lowercaseHeaders(h) {
|
|
|
3662
3662
|
return out;
|
|
3663
3663
|
}
|
|
3664
3664
|
|
|
3665
|
+
// src/shared/options.ts
|
|
3666
|
+
var FLOW_STEP_KINDS = [
|
|
3667
|
+
{ value: "wait", label: "Wait", icon: "Clock", iconClass: "wait", description: "Pause the run for a duration before continuing." },
|
|
3668
|
+
{ value: "condition", label: "Condition", icon: "Branch", iconClass: "condition", description: "Evaluate a predicate. Exit or skip on false." },
|
|
3669
|
+
{ value: "branch", label: "Branch", icon: "Branch", iconClass: "condition", description: "Evaluate a predicate. Recurse into one of two sub-lists." },
|
|
3670
|
+
{ value: "send", label: "Send", icon: "Mail", iconClass: "send", description: "Send a template to the contact." },
|
|
3671
|
+
{ value: "tag", label: "Tag", icon: "Tag", iconClass: "tag", description: "Add or remove tags on the contact." },
|
|
3672
|
+
{ value: "fire_event", label: "Fire event", icon: "Activity", iconClass: "send", description: "Insert a synthetic event (cross-flow handoff)." },
|
|
3673
|
+
{ value: "webhook", label: "Webhook", icon: "Webhook", iconClass: "tag", description: "POST to an external URL." },
|
|
3674
|
+
{ value: "exit", label: "Exit", icon: "Exit", iconClass: "exit", description: "End the run with an optional reason." }
|
|
3675
|
+
];
|
|
3676
|
+
function defaultFlowStep(type) {
|
|
3677
|
+
switch (type) {
|
|
3678
|
+
case "wait":
|
|
3679
|
+
return { type: "wait", value: 1, unit: "days" };
|
|
3680
|
+
case "condition":
|
|
3681
|
+
return { type: "condition", test: { hasTag: "engaged" }, ifFalse: "exit" };
|
|
3682
|
+
case "branch":
|
|
3683
|
+
return { type: "branch", test: { hasTag: "vip" }, ifTrueSteps: [], ifFalseSteps: [] };
|
|
3684
|
+
case "send":
|
|
3685
|
+
return { type: "send", templateSlug: "" };
|
|
3686
|
+
case "tag":
|
|
3687
|
+
return { type: "tag", addTags: [], removeTags: [] };
|
|
3688
|
+
case "fire_event":
|
|
3689
|
+
return { type: "fire_event", eventName: "" };
|
|
3690
|
+
case "webhook":
|
|
3691
|
+
return { type: "webhook", url: "", method: "POST" };
|
|
3692
|
+
case "exit":
|
|
3693
|
+
return { type: "exit" };
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
var PREDICATE_KINDS = [
|
|
3697
|
+
{ value: "hasTag", label: "has tag" },
|
|
3698
|
+
{ value: "notHasTag", label: "does NOT have tag" },
|
|
3699
|
+
{ value: "fieldEquals", label: "field equals" },
|
|
3700
|
+
{ value: "fieldExists", label: "field exists" },
|
|
3701
|
+
{ value: "hasFiredEvent", label: "fired event" },
|
|
3702
|
+
{ value: "notHasFiredEvent", label: "has NOT fired event" },
|
|
3703
|
+
{ value: "subscriptionStatus", label: "subscription status" },
|
|
3704
|
+
{ value: "hasOpened", label: "opened", noisy: true },
|
|
3705
|
+
{ value: "hasClicked", label: "clicked", noisy: true },
|
|
3706
|
+
{ value: "hasOpenedExcludingBots", label: "opened (excl. bots)" },
|
|
3707
|
+
{ value: "hasClickedExcludingBots", label: "clicked (excl. bots)" },
|
|
3708
|
+
{ value: "openedAtLeastN", label: "opened at least N" },
|
|
3709
|
+
{ value: "clickedAtLeastN", label: "clicked at least N" }
|
|
3710
|
+
];
|
|
3711
|
+
function predicateKind(p) {
|
|
3712
|
+
if (!p) return null;
|
|
3713
|
+
for (const k of PREDICATE_KINDS) {
|
|
3714
|
+
if (k.value in p) return k.value;
|
|
3715
|
+
}
|
|
3716
|
+
return null;
|
|
3717
|
+
}
|
|
3718
|
+
function defaultPredicate(kind) {
|
|
3719
|
+
switch (kind) {
|
|
3720
|
+
case "hasTag":
|
|
3721
|
+
return { hasTag: "engaged" };
|
|
3722
|
+
case "notHasTag":
|
|
3723
|
+
return { notHasTag: "cold" };
|
|
3724
|
+
case "fieldEquals":
|
|
3725
|
+
return { fieldEquals: { field: "tier", value: "Pro" } };
|
|
3726
|
+
case "fieldExists":
|
|
3727
|
+
return { fieldExists: "tier" };
|
|
3728
|
+
case "hasFiredEvent":
|
|
3729
|
+
return { hasFiredEvent: "Activated app" };
|
|
3730
|
+
case "notHasFiredEvent":
|
|
3731
|
+
return { notHasFiredEvent: "Cancelled" };
|
|
3732
|
+
case "subscriptionStatus":
|
|
3733
|
+
return { subscriptionStatus: "subscribed" };
|
|
3734
|
+
case "hasOpened":
|
|
3735
|
+
return { hasOpened: { sinceFlowStart: true } };
|
|
3736
|
+
case "hasClicked":
|
|
3737
|
+
return { hasClicked: { sinceFlowStart: true } };
|
|
3738
|
+
case "hasOpenedExcludingBots":
|
|
3739
|
+
return { hasOpenedExcludingBots: { sinceFlowStart: true } };
|
|
3740
|
+
case "hasClickedExcludingBots":
|
|
3741
|
+
return { hasClickedExcludingBots: { sinceFlowStart: true } };
|
|
3742
|
+
case "openedAtLeastN":
|
|
3743
|
+
return { openedAtLeastN: { count: 1, withinDays: 7 } };
|
|
3744
|
+
case "clickedAtLeastN":
|
|
3745
|
+
return { clickedAtLeastN: { count: 1, withinDays: 7 } };
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
var SEGMENT_FILTER_KINDS = [
|
|
3749
|
+
{ value: "subscriptionStatus", label: "Subscription status", side: "mailer" },
|
|
3750
|
+
{ value: "hasTag", label: "Has tag", side: "host" },
|
|
3751
|
+
{ value: "notHasTag", label: "Does NOT have tag", side: "host" },
|
|
3752
|
+
{ value: "fieldEquals", label: "Field equals", side: "host" },
|
|
3753
|
+
{ value: "fieldIn", label: "Field in list", side: "host" },
|
|
3754
|
+
{ value: "fieldExists", label: "Field exists", side: "host" },
|
|
3755
|
+
{ value: "firedEvent", label: "Fired event", side: "mailer" },
|
|
3756
|
+
{ value: "notFiredEvent", label: "Has NOT fired event", side: "mailer" },
|
|
3757
|
+
{ value: "subscribedAfter", label: "Subscribed after", side: "mailer" },
|
|
3758
|
+
{ value: "subscribedBefore", label: "Subscribed before", side: "mailer" },
|
|
3759
|
+
{ value: "opened", label: "Opened", side: "mailer" },
|
|
3760
|
+
{ value: "notOpened", label: "Did NOT open", side: "mailer" },
|
|
3761
|
+
{ value: "any", label: "Any of (OR)", side: "composite" },
|
|
3762
|
+
{ value: "not", label: "NOT", side: "composite" }
|
|
3763
|
+
];
|
|
3764
|
+
function defaultSegmentFilter(kind) {
|
|
3765
|
+
switch (kind) {
|
|
3766
|
+
case "subscriptionStatus":
|
|
3767
|
+
return { kind: "subscriptionStatus", equals: "subscribed" };
|
|
3768
|
+
case "hasTag":
|
|
3769
|
+
return { kind: "hasTag", tag: "" };
|
|
3770
|
+
case "notHasTag":
|
|
3771
|
+
return { kind: "notHasTag", tag: "" };
|
|
3772
|
+
case "fieldEquals":
|
|
3773
|
+
return { kind: "fieldEquals", field: "", value: "" };
|
|
3774
|
+
case "fieldIn":
|
|
3775
|
+
return { kind: "fieldIn", field: "", values: [] };
|
|
3776
|
+
case "fieldExists":
|
|
3777
|
+
return { kind: "fieldExists", field: "" };
|
|
3778
|
+
case "firedEvent":
|
|
3779
|
+
return { kind: "firedEvent", eventName: "", withinDays: 30 };
|
|
3780
|
+
case "notFiredEvent":
|
|
3781
|
+
return { kind: "notFiredEvent", eventName: "", withinDays: 90 };
|
|
3782
|
+
case "subscribedAfter":
|
|
3783
|
+
return { kind: "subscribedAfter", date: new Date(Date.now() - 30 * 864e5) };
|
|
3784
|
+
case "subscribedBefore":
|
|
3785
|
+
return { kind: "subscribedBefore", date: /* @__PURE__ */ new Date() };
|
|
3786
|
+
case "opened":
|
|
3787
|
+
return { kind: "opened", withinDays: 14 };
|
|
3788
|
+
case "notOpened":
|
|
3789
|
+
return { kind: "notOpened", withinDays: 14 };
|
|
3790
|
+
case "any":
|
|
3791
|
+
return { kind: "any", filters: [] };
|
|
3792
|
+
case "not":
|
|
3793
|
+
return { kind: "not", filter: { kind: "hasTag", tag: "" } };
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
var DEDUPE_POLICIES = [
|
|
3797
|
+
{
|
|
3798
|
+
value: "once-per-contact",
|
|
3799
|
+
label: "Once per contact",
|
|
3800
|
+
description: "Lifecycle markers (Created, Activated)",
|
|
3801
|
+
derivedKeyShape: "${externalId}:${eventName}"
|
|
3802
|
+
},
|
|
3803
|
+
{
|
|
3804
|
+
value: "once-per-day",
|
|
3805
|
+
label: "Once per day",
|
|
3806
|
+
description: "Daily behaviors (Viewed Storyboard)",
|
|
3807
|
+
derivedKeyShape: "${externalId}:${eventName}:${YYYY-MM-DD}"
|
|
3808
|
+
},
|
|
3809
|
+
{
|
|
3810
|
+
value: "every-time",
|
|
3811
|
+
label: "Every time",
|
|
3812
|
+
description: "True every-occurrence events (Imported)",
|
|
3813
|
+
derivedKeyShape: "${externalId}:${eventName}:${UUIDv4}"
|
|
3814
|
+
}
|
|
3815
|
+
];
|
|
3816
|
+
|
|
3665
3817
|
// src/server/index.ts
|
|
3666
3818
|
var VERSION = "0.1.0";
|
|
3667
3819
|
|
|
3668
|
-
export { Mailer, MongoContactAdapter, NullProvider, SendGridProvider, VERSION, applyTracking, compileTemplate, createAdminRouter, createPublicRouter, derivePlaintext, ensureIndexes, getCollections, renderTemplate, sha256Hex, signUnsubscribeToken, verifyUnsubscribeToken };
|
|
3820
|
+
export { DEDUPE_POLICIES, FLOW_STEP_KINDS, Mailer, MongoContactAdapter, NullProvider, PREDICATE_KINDS, SEGMENT_FILTER_KINDS, SendGridProvider, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, ensureIndexes, getCollections, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
|
|
3669
3821
|
//# sourceMappingURL=index.js.map
|
|
3670
3822
|
//# sourceMappingURL=index.js.map
|