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/index.cjs CHANGED
@@ -3676,22 +3676,189 @@ function lowercaseHeaders(h) {
3676
3676
  return out;
3677
3677
  }
3678
3678
 
3679
+ // src/shared/options.ts
3680
+ var FLOW_STEP_KINDS = [
3681
+ { value: "wait", label: "Wait", icon: "Clock", iconClass: "wait", description: "Pause the run for a duration before continuing." },
3682
+ { value: "condition", label: "Condition", icon: "Branch", iconClass: "condition", description: "Evaluate a predicate. Exit or skip on false." },
3683
+ { value: "branch", label: "Branch", icon: "Branch", iconClass: "condition", description: "Evaluate a predicate. Recurse into one of two sub-lists." },
3684
+ { value: "send", label: "Send", icon: "Mail", iconClass: "send", description: "Send a template to the contact." },
3685
+ { value: "tag", label: "Tag", icon: "Tag", iconClass: "tag", description: "Add or remove tags on the contact." },
3686
+ { value: "fire_event", label: "Fire event", icon: "Activity", iconClass: "send", description: "Insert a synthetic event (cross-flow handoff)." },
3687
+ { value: "webhook", label: "Webhook", icon: "Webhook", iconClass: "tag", description: "POST to an external URL." },
3688
+ { value: "exit", label: "Exit", icon: "Exit", iconClass: "exit", description: "End the run with an optional reason." }
3689
+ ];
3690
+ function defaultFlowStep(type) {
3691
+ switch (type) {
3692
+ case "wait":
3693
+ return { type: "wait", value: 1, unit: "days" };
3694
+ case "condition":
3695
+ return { type: "condition", test: { hasTag: "engaged" }, ifFalse: "exit" };
3696
+ case "branch":
3697
+ return { type: "branch", test: { hasTag: "vip" }, ifTrueSteps: [], ifFalseSteps: [] };
3698
+ case "send":
3699
+ return { type: "send", templateSlug: "" };
3700
+ case "tag":
3701
+ return { type: "tag", addTags: [], removeTags: [] };
3702
+ case "fire_event":
3703
+ return { type: "fire_event", eventName: "" };
3704
+ case "webhook":
3705
+ return { type: "webhook", url: "", method: "POST" };
3706
+ case "exit":
3707
+ return { type: "exit" };
3708
+ }
3709
+ }
3710
+ var PREDICATE_KINDS = [
3711
+ { value: "hasTag", label: "has tag" },
3712
+ { value: "notHasTag", label: "does NOT have tag" },
3713
+ { value: "fieldEquals", label: "field equals" },
3714
+ { value: "fieldExists", label: "field exists" },
3715
+ { value: "hasFiredEvent", label: "fired event" },
3716
+ { value: "notHasFiredEvent", label: "has NOT fired event" },
3717
+ { value: "subscriptionStatus", label: "subscription status" },
3718
+ { value: "hasOpened", label: "opened", noisy: true },
3719
+ { value: "hasClicked", label: "clicked", noisy: true },
3720
+ { value: "hasOpenedExcludingBots", label: "opened (excl. bots)" },
3721
+ { value: "hasClickedExcludingBots", label: "clicked (excl. bots)" },
3722
+ { value: "openedAtLeastN", label: "opened at least N" },
3723
+ { value: "clickedAtLeastN", label: "clicked at least N" }
3724
+ ];
3725
+ function predicateKind(p) {
3726
+ if (!p) return null;
3727
+ for (const k of PREDICATE_KINDS) {
3728
+ if (k.value in p) return k.value;
3729
+ }
3730
+ return null;
3731
+ }
3732
+ function defaultPredicate(kind) {
3733
+ switch (kind) {
3734
+ case "hasTag":
3735
+ return { hasTag: "engaged" };
3736
+ case "notHasTag":
3737
+ return { notHasTag: "cold" };
3738
+ case "fieldEquals":
3739
+ return { fieldEquals: { field: "tier", value: "Pro" } };
3740
+ case "fieldExists":
3741
+ return { fieldExists: "tier" };
3742
+ case "hasFiredEvent":
3743
+ return { hasFiredEvent: "Activated app" };
3744
+ case "notHasFiredEvent":
3745
+ return { notHasFiredEvent: "Cancelled" };
3746
+ case "subscriptionStatus":
3747
+ return { subscriptionStatus: "subscribed" };
3748
+ case "hasOpened":
3749
+ return { hasOpened: { sinceFlowStart: true } };
3750
+ case "hasClicked":
3751
+ return { hasClicked: { sinceFlowStart: true } };
3752
+ case "hasOpenedExcludingBots":
3753
+ return { hasOpenedExcludingBots: { sinceFlowStart: true } };
3754
+ case "hasClickedExcludingBots":
3755
+ return { hasClickedExcludingBots: { sinceFlowStart: true } };
3756
+ case "openedAtLeastN":
3757
+ return { openedAtLeastN: { count: 1, withinDays: 7 } };
3758
+ case "clickedAtLeastN":
3759
+ return { clickedAtLeastN: { count: 1, withinDays: 7 } };
3760
+ }
3761
+ }
3762
+ var SEGMENT_FILTER_KINDS = [
3763
+ { value: "subscriptionStatus", label: "Subscription status", side: "mailer" },
3764
+ { value: "hasTag", label: "Has tag", side: "host" },
3765
+ { value: "notHasTag", label: "Does NOT have tag", side: "host" },
3766
+ { value: "fieldEquals", label: "Field equals", side: "host" },
3767
+ { value: "fieldIn", label: "Field in list", side: "host" },
3768
+ { value: "fieldExists", label: "Field exists", side: "host" },
3769
+ { value: "firedEvent", label: "Fired event", side: "mailer" },
3770
+ { value: "notFiredEvent", label: "Has NOT fired event", side: "mailer" },
3771
+ { value: "subscribedAfter", label: "Subscribed after", side: "mailer" },
3772
+ { value: "subscribedBefore", label: "Subscribed before", side: "mailer" },
3773
+ { value: "opened", label: "Opened", side: "mailer" },
3774
+ { value: "notOpened", label: "Did NOT open", side: "mailer" },
3775
+ { value: "any", label: "Any of (OR)", side: "composite" },
3776
+ { value: "not", label: "NOT", side: "composite" }
3777
+ ];
3778
+ function defaultSegmentFilter(kind) {
3779
+ switch (kind) {
3780
+ case "subscriptionStatus":
3781
+ return { kind: "subscriptionStatus", equals: "subscribed" };
3782
+ case "hasTag":
3783
+ return { kind: "hasTag", tag: "" };
3784
+ case "notHasTag":
3785
+ return { kind: "notHasTag", tag: "" };
3786
+ case "fieldEquals":
3787
+ return { kind: "fieldEquals", field: "", value: "" };
3788
+ case "fieldIn":
3789
+ return { kind: "fieldIn", field: "", values: [] };
3790
+ case "fieldExists":
3791
+ return { kind: "fieldExists", field: "" };
3792
+ case "firedEvent":
3793
+ return { kind: "firedEvent", eventName: "", withinDays: 30 };
3794
+ case "notFiredEvent":
3795
+ return { kind: "notFiredEvent", eventName: "", withinDays: 90 };
3796
+ case "subscribedAfter":
3797
+ return { kind: "subscribedAfter", date: new Date(Date.now() - 30 * 864e5) };
3798
+ case "subscribedBefore":
3799
+ return { kind: "subscribedBefore", date: /* @__PURE__ */ new Date() };
3800
+ case "opened":
3801
+ return { kind: "opened", withinDays: 14 };
3802
+ case "notOpened":
3803
+ return { kind: "notOpened", withinDays: 14 };
3804
+ case "any":
3805
+ return { kind: "any", filters: [] };
3806
+ case "not":
3807
+ return { kind: "not", filter: { kind: "hasTag", tag: "" } };
3808
+ }
3809
+ }
3810
+ var DEDUPE_POLICIES = [
3811
+ {
3812
+ value: "once-per-contact",
3813
+ label: "Once per contact",
3814
+ description: "Lifecycle markers (Created, Activated)",
3815
+ derivedKeyShape: "${externalId}:${eventName}"
3816
+ },
3817
+ {
3818
+ value: "once-per-day",
3819
+ label: "Once per day",
3820
+ description: "Daily behaviors (Viewed Storyboard)",
3821
+ derivedKeyShape: "${externalId}:${eventName}:${YYYY-MM-DD}"
3822
+ },
3823
+ {
3824
+ value: "every-time",
3825
+ label: "Every time",
3826
+ description: "True every-occurrence events (Imported)",
3827
+ derivedKeyShape: "${externalId}:${eventName}:${UUIDv4}"
3828
+ }
3829
+ ];
3830
+
3679
3831
  // src/server/index.ts
3680
3832
  var VERSION = "0.1.0";
3681
3833
 
3834
+ exports.DEDUPE_POLICIES = DEDUPE_POLICIES;
3835
+ exports.FLOW_STEP_KINDS = FLOW_STEP_KINDS;
3682
3836
  exports.Mailer = Mailer;
3683
3837
  exports.NullProvider = NullProvider;
3838
+ exports.PREDICATE_KINDS = PREDICATE_KINDS;
3839
+ exports.SEGMENT_FILTER_KINDS = SEGMENT_FILTER_KINDS;
3684
3840
  exports.VERSION = VERSION;
3685
3841
  exports.applyTracking = applyTracking;
3842
+ exports.applyWebhookEvent = applyWebhookEvent;
3843
+ exports.compileMailyTemplate = compileMailyTemplate;
3686
3844
  exports.compileTemplate = compileTemplate;
3687
3845
  exports.createAdminRouter = createAdminRouter;
3688
3846
  exports.createPublicRouter = createPublicRouter;
3847
+ exports.defaultFlowStep = defaultFlowStep;
3848
+ exports.defaultPredicate = defaultPredicate;
3849
+ exports.defaultSegmentFilter = defaultSegmentFilter;
3689
3850
  exports.derivePlaintext = derivePlaintext;
3851
+ exports.dispatchSend = dispatchSend;
3690
3852
  exports.ensureIndexes = ensureIndexes;
3691
3853
  exports.getCollections = getCollections;
3854
+ exports.predicateKind = predicateKind;
3855
+ exports.processNewlyFiredEventTriggers = processNewlyFiredEventTriggers;
3856
+ exports.processOneRunStep = processOneRunStep;
3692
3857
  exports.renderTemplate = renderTemplate;
3858
+ exports.runTick = runTick;
3693
3859
  exports.sha256Hex = sha256Hex;
3694
3860
  exports.signUnsubscribeToken = signUnsubscribeToken;
3861
+ exports.sweepStrandedFlowRuns = sweepStrandedFlowRuns;
3695
3862
  exports.verifyUnsubscribeToken = verifyUnsubscribeToken;
3696
3863
  //# sourceMappingURL=index.cjs.map
3697
3864
  //# sourceMappingURL=index.cjs.map