sendwend 0.0.1 → 12.7.3
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/LICENSE +1 -1
- package/README.md +2065 -22
- package/dist/_virtual/_rolldown/runtime.cjs +22 -0
- package/dist/apns-relay.cjs +91 -0
- package/dist/apns-relay.cjs.map +1 -0
- package/dist/apns-relay.d.cts +26 -0
- package/dist/apns-relay.d.cts.map +1 -0
- package/dist/apns-relay.d.mts +26 -0
- package/dist/apns-relay.d.mts.map +1 -0
- package/dist/apns-relay.mjs +90 -0
- package/dist/apns-relay.mjs.map +1 -0
- package/dist/apns.cjs +215 -0
- package/dist/apns.cjs.map +1 -0
- package/dist/apns.d.cts +110 -0
- package/dist/apns.d.cts.map +1 -0
- package/dist/apns.d.mts +110 -0
- package/dist/apns.d.mts.map +1 -0
- package/dist/apns.mjs +207 -0
- package/dist/apns.mjs.map +1 -0
- package/dist/aws/engine-step.cjs +105 -0
- package/dist/aws/engine-step.cjs.map +1 -0
- package/dist/aws/engine-step.d.cts +42 -0
- package/dist/aws/engine-step.d.cts.map +1 -0
- package/dist/aws/engine-step.d.mts +42 -0
- package/dist/aws/engine-step.d.mts.map +1 -0
- package/dist/aws/engine-step.mjs +103 -0
- package/dist/aws/engine-step.mjs.map +1 -0
- package/dist/aws/function-url.cjs +53 -0
- package/dist/aws/function-url.cjs.map +1 -0
- package/dist/aws/function-url.d.cts +36 -0
- package/dist/aws/function-url.d.cts.map +1 -0
- package/dist/aws/function-url.d.mts +36 -0
- package/dist/aws/function-url.d.mts.map +1 -0
- package/dist/aws/function-url.mjs +50 -0
- package/dist/aws/function-url.mjs.map +1 -0
- package/dist/aws/index.cjs +232 -0
- package/dist/aws/index.cjs.map +1 -0
- package/dist/aws/index.d.cts +73 -0
- package/dist/aws/index.d.cts.map +1 -0
- package/dist/aws/index.d.mts +73 -0
- package/dist/aws/index.d.mts.map +1 -0
- package/dist/aws/index.mjs +218 -0
- package/dist/aws/index.mjs.map +1 -0
- package/dist/aws/instances.cjs +218 -0
- package/dist/aws/instances.cjs.map +1 -0
- package/dist/aws/instances.d.cts +102 -0
- package/dist/aws/instances.d.cts.map +1 -0
- package/dist/aws/instances.d.mts +102 -0
- package/dist/aws/instances.d.mts.map +1 -0
- package/dist/aws/instances.mjs +214 -0
- package/dist/aws/instances.mjs.map +1 -0
- package/dist/aws/lambda-api.cjs +86 -0
- package/dist/aws/lambda-api.cjs.map +1 -0
- package/dist/aws/lambda-api.d.cts +41 -0
- package/dist/aws/lambda-api.d.cts.map +1 -0
- package/dist/aws/lambda-api.d.mts +41 -0
- package/dist/aws/lambda-api.d.mts.map +1 -0
- package/dist/aws/lambda-api.mjs +85 -0
- package/dist/aws/lambda-api.mjs.map +1 -0
- package/dist/client.cjs +216 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +193 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +193 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +212 -0
- package/dist/client.mjs.map +1 -0
- package/dist/cloudflare/bindings.cjs +49 -0
- package/dist/cloudflare/bindings.cjs.map +1 -0
- package/dist/cloudflare/bindings.d.cts +31 -0
- package/dist/cloudflare/bindings.d.cts.map +1 -0
- package/dist/cloudflare/bindings.d.mts +31 -0
- package/dist/cloudflare/bindings.d.mts.map +1 -0
- package/dist/cloudflare/bindings.mjs +46 -0
- package/dist/cloudflare/bindings.mjs.map +1 -0
- package/dist/cloudflare/index.cjs +73 -0
- package/dist/cloudflare/index.d.cts +25 -0
- package/dist/cloudflare/index.d.mts +25 -0
- package/dist/cloudflare/index.mjs +20 -0
- package/dist/cloudflare/runner.cjs +200 -0
- package/dist/cloudflare/runner.cjs.map +1 -0
- package/dist/cloudflare/runner.d.cts +83 -0
- package/dist/cloudflare/runner.d.cts.map +1 -0
- package/dist/cloudflare/runner.d.mts +83 -0
- package/dist/cloudflare/runner.d.mts.map +1 -0
- package/dist/cloudflare/runner.mjs +199 -0
- package/dist/cloudflare/runner.mjs.map +1 -0
- package/dist/cloudflare/worker.cjs +106 -0
- package/dist/cloudflare/worker.cjs.map +1 -0
- package/dist/cloudflare/worker.d.cts +52 -0
- package/dist/cloudflare/worker.d.cts.map +1 -0
- package/dist/cloudflare/worker.d.mts +52 -0
- package/dist/cloudflare/worker.d.mts.map +1 -0
- package/dist/cloudflare/worker.mjs +104 -0
- package/dist/cloudflare/worker.mjs.map +1 -0
- package/dist/cloudflare/workers.d.cjs +0 -0
- package/dist/cloudflare/workers.d.cts +42 -0
- package/dist/cloudflare/workers.d.cts.map +1 -0
- package/dist/cloudflare/workers.d.mts +42 -0
- package/dist/cloudflare/workers.d.mts.map +1 -0
- package/dist/config.cjs +257 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +184 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +184 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +246 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract.cjs +222 -0
- package/dist/contract.cjs.map +1 -0
- package/dist/contract.d.cts +110 -0
- package/dist/contract.d.cts.map +1 -0
- package/dist/contract.d.mts +110 -0
- package/dist/contract.d.mts.map +1 -0
- package/dist/contract.mjs +216 -0
- package/dist/contract.mjs.map +1 -0
- package/dist/date-time.cjs +22 -0
- package/dist/date-time.cjs.map +1 -0
- package/dist/date-time.d.cts +10 -0
- package/dist/date-time.d.cts.map +1 -0
- package/dist/date-time.d.mts +10 -0
- package/dist/date-time.d.mts.map +1 -0
- package/dist/date-time.mjs +21 -0
- package/dist/date-time.mjs.map +1 -0
- package/dist/dsl/action.cjs +25 -0
- package/dist/dsl/action.cjs.map +1 -0
- package/dist/dsl/action.d.cts +63 -0
- package/dist/dsl/action.d.cts.map +1 -0
- package/dist/dsl/action.d.mts +63 -0
- package/dist/dsl/action.d.mts.map +1 -0
- package/dist/dsl/action.mjs +24 -0
- package/dist/dsl/action.mjs.map +1 -0
- package/dist/dsl/base.cjs +33 -0
- package/dist/dsl/base.cjs.map +1 -0
- package/dist/dsl/base.d.cts +43 -0
- package/dist/dsl/base.d.cts.map +1 -0
- package/dist/dsl/base.d.mts +43 -0
- package/dist/dsl/base.d.mts.map +1 -0
- package/dist/dsl/base.mjs +29 -0
- package/dist/dsl/base.mjs.map +1 -0
- package/dist/dsl/bundle.cjs +287 -0
- package/dist/dsl/bundle.cjs.map +1 -0
- package/dist/dsl/bundle.d.cts +33 -0
- package/dist/dsl/bundle.d.cts.map +1 -0
- package/dist/dsl/bundle.d.mts +33 -0
- package/dist/dsl/bundle.d.mts.map +1 -0
- package/dist/dsl/bundle.mjs +284 -0
- package/dist/dsl/bundle.mjs.map +1 -0
- package/dist/dsl/condition.cjs +200 -0
- package/dist/dsl/condition.cjs.map +1 -0
- package/dist/dsl/condition.d.cts +151 -0
- package/dist/dsl/condition.d.cts.map +1 -0
- package/dist/dsl/condition.d.mts +151 -0
- package/dist/dsl/condition.d.mts.map +1 -0
- package/dist/dsl/condition.mjs +178 -0
- package/dist/dsl/condition.mjs.map +1 -0
- package/dist/dsl/flow.cjs +335 -0
- package/dist/dsl/flow.cjs.map +1 -0
- package/dist/dsl/flow.d.cts +278 -0
- package/dist/dsl/flow.d.cts.map +1 -0
- package/dist/dsl/flow.d.mts +278 -0
- package/dist/dsl/flow.d.mts.map +1 -0
- package/dist/dsl/flow.mjs +331 -0
- package/dist/dsl/flow.mjs.map +1 -0
- package/dist/dsl/index.cjs +37 -0
- package/dist/dsl/index.d.cts +34 -0
- package/dist/dsl/index.d.mts +34 -0
- package/dist/dsl/index.mjs +9 -0
- package/dist/dsl/refs.cjs +101 -0
- package/dist/dsl/refs.cjs.map +1 -0
- package/dist/dsl/refs.d.cts +127 -0
- package/dist/dsl/refs.d.cts.map +1 -0
- package/dist/dsl/refs.d.mts +127 -0
- package/dist/dsl/refs.d.mts.map +1 -0
- package/dist/dsl/refs.mjs +93 -0
- package/dist/dsl/refs.mjs.map +1 -0
- package/dist/dsl/template.cjs +19 -0
- package/dist/dsl/template.cjs.map +1 -0
- package/dist/dsl/template.d.cts +30 -0
- package/dist/dsl/template.d.cts.map +1 -0
- package/dist/dsl/template.d.mts +30 -0
- package/dist/dsl/template.d.mts.map +1 -0
- package/dist/dsl/template.mjs +18 -0
- package/dist/dsl/template.mjs.map +1 -0
- package/dist/dsl/trigger.cjs +53 -0
- package/dist/dsl/trigger.cjs.map +1 -0
- package/dist/dsl/trigger.d.cts +112 -0
- package/dist/dsl/trigger.d.cts.map +1 -0
- package/dist/dsl/trigger.d.mts +112 -0
- package/dist/dsl/trigger.d.mts.map +1 -0
- package/dist/dsl/trigger.mjs +52 -0
- package/dist/dsl/trigger.mjs.map +1 -0
- package/dist/dsl/workflow.cjs +143 -0
- package/dist/dsl/workflow.cjs.map +1 -0
- package/dist/dsl/workflow.d.cts +88 -0
- package/dist/dsl/workflow.d.cts.map +1 -0
- package/dist/dsl/workflow.d.mts +88 -0
- package/dist/dsl/workflow.d.mts.map +1 -0
- package/dist/dsl/workflow.mjs +142 -0
- package/dist/dsl/workflow.mjs.map +1 -0
- package/dist/email-context.cjs +28 -0
- package/dist/email-context.cjs.map +1 -0
- package/dist/email-context.d.cts +9 -0
- package/dist/email-context.d.cts.map +1 -0
- package/dist/email-context.d.mts +9 -0
- package/dist/email-context.d.mts.map +1 -0
- package/dist/email-context.mjs +26 -0
- package/dist/email-context.mjs.map +1 -0
- package/dist/email-sender.cjs +93 -0
- package/dist/email-sender.cjs.map +1 -0
- package/dist/email-sender.d.cts +88 -0
- package/dist/email-sender.d.cts.map +1 -0
- package/dist/email-sender.d.mts +88 -0
- package/dist/email-sender.d.mts.map +1 -0
- package/dist/email-sender.mjs +90 -0
- package/dist/email-sender.mjs.map +1 -0
- package/dist/email.cjs +73 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +59 -0
- package/dist/email.d.cts.map +1 -0
- package/dist/email.d.mts +59 -0
- package/dist/email.d.mts.map +1 -0
- package/dist/email.mjs +68 -0
- package/dist/email.mjs.map +1 -0
- package/dist/engine/actions.cjs +19 -0
- package/dist/engine/actions.cjs.map +1 -0
- package/dist/engine/actions.d.cts +27 -0
- package/dist/engine/actions.d.cts.map +1 -0
- package/dist/engine/actions.d.mts +27 -0
- package/dist/engine/actions.d.mts.map +1 -0
- package/dist/engine/actions.mjs +18 -0
- package/dist/engine/actions.mjs.map +1 -0
- package/dist/engine/bucket.cjs +71 -0
- package/dist/engine/bucket.cjs.map +1 -0
- package/dist/engine/bucket.d.cts +30 -0
- package/dist/engine/bucket.d.cts.map +1 -0
- package/dist/engine/bucket.d.mts +30 -0
- package/dist/engine/bucket.d.mts.map +1 -0
- package/dist/engine/bucket.mjs +68 -0
- package/dist/engine/bucket.mjs.map +1 -0
- package/dist/engine/condition.cjs +199 -0
- package/dist/engine/condition.cjs.map +1 -0
- package/dist/engine/condition.d.cts +76 -0
- package/dist/engine/condition.d.cts.map +1 -0
- package/dist/engine/condition.d.mts +76 -0
- package/dist/engine/condition.d.mts.map +1 -0
- package/dist/engine/condition.mjs +192 -0
- package/dist/engine/condition.mjs.map +1 -0
- package/dist/engine/duration.cjs +33 -0
- package/dist/engine/duration.cjs.map +1 -0
- package/dist/engine/duration.d.cts +3 -0
- package/dist/engine/duration.d.cts.map +1 -0
- package/dist/engine/duration.d.mts +3 -0
- package/dist/engine/duration.d.mts.map +1 -0
- package/dist/engine/duration.mjs +32 -0
- package/dist/engine/duration.mjs.map +1 -0
- package/dist/engine/index.cjs +33 -0
- package/dist/engine/index.d.cts +10 -0
- package/dist/engine/index.d.mts +10 -0
- package/dist/engine/index.mjs +9 -0
- package/dist/engine/interpreter.cjs +613 -0
- package/dist/engine/interpreter.cjs.map +1 -0
- package/dist/engine/interpreter.d.cts +4 -0
- package/dist/engine/interpreter.d.cts.map +1 -0
- package/dist/engine/interpreter.d.mts +4 -0
- package/dist/engine/interpreter.d.mts.map +1 -0
- package/dist/engine/interpreter.mjs +612 -0
- package/dist/engine/interpreter.mjs.map +1 -0
- package/dist/engine/ports.cjs +0 -0
- package/dist/engine/ports.d.cts +373 -0
- package/dist/engine/ports.d.cts.map +1 -0
- package/dist/engine/ports.d.mts +373 -0
- package/dist/engine/ports.d.mts.map +1 -0
- package/dist/engine/ports.mjs +1 -0
- package/dist/engine/recipient.cjs +22 -0
- package/dist/engine/recipient.cjs.map +1 -0
- package/dist/engine/recipient.d.cts +11 -0
- package/dist/engine/recipient.d.cts.map +1 -0
- package/dist/engine/recipient.d.mts +11 -0
- package/dist/engine/recipient.d.mts.map +1 -0
- package/dist/engine/recipient.mjs +21 -0
- package/dist/engine/recipient.mjs.map +1 -0
- package/dist/engine/retry.cjs +106 -0
- package/dist/engine/retry.cjs.map +1 -0
- package/dist/engine/retry.d.cts +73 -0
- package/dist/engine/retry.d.cts.map +1 -0
- package/dist/engine/retry.d.mts +73 -0
- package/dist/engine/retry.d.mts.map +1 -0
- package/dist/engine/retry.mjs +98 -0
- package/dist/engine/retry.mjs.map +1 -0
- package/dist/engine/time-scale.cjs +153 -0
- package/dist/engine/time-scale.cjs.map +1 -0
- package/dist/engine/time-scale.d.cts +41 -0
- package/dist/engine/time-scale.d.cts.map +1 -0
- package/dist/engine/time-scale.d.mts +41 -0
- package/dist/engine/time-scale.d.mts.map +1 -0
- package/dist/engine/time-scale.mjs +150 -0
- package/dist/engine/time-scale.mjs.map +1 -0
- package/dist/engine/time-window.cjs +148 -0
- package/dist/engine/time-window.cjs.map +1 -0
- package/dist/engine/time-window.d.cts +20 -0
- package/dist/engine/time-window.d.cts.map +1 -0
- package/dist/engine/time-window.d.mts +20 -0
- package/dist/engine/time-window.d.mts.map +1 -0
- package/dist/engine/time-window.mjs +146 -0
- package/dist/engine/time-window.mjs.map +1 -0
- package/dist/fcm.cjs +208 -0
- package/dist/fcm.cjs.map +1 -0
- package/dist/fcm.d.cts +89 -0
- package/dist/fcm.d.cts.map +1 -0
- package/dist/fcm.d.mts +89 -0
- package/dist/fcm.d.mts.map +1 -0
- package/dist/fcm.mjs +202 -0
- package/dist/fcm.mjs.map +1 -0
- package/dist/hash.cjs +244 -0
- package/dist/hash.cjs.map +1 -0
- package/dist/hash.d.cts +28 -0
- package/dist/hash.d.cts.map +1 -0
- package/dist/hash.d.mts +28 -0
- package/dist/hash.d.mts.map +1 -0
- package/dist/hash.mjs +238 -0
- package/dist/hash.mjs.map +1 -0
- package/dist/host/auth.cjs +48 -0
- package/dist/host/auth.cjs.map +1 -0
- package/dist/host/auth.d.cts +33 -0
- package/dist/host/auth.d.cts.map +1 -0
- package/dist/host/auth.d.mts +33 -0
- package/dist/host/auth.d.mts.map +1 -0
- package/dist/host/auth.mjs +45 -0
- package/dist/host/auth.mjs.map +1 -0
- package/dist/host/batch.cjs +178 -0
- package/dist/host/batch.cjs.map +1 -0
- package/dist/host/batch.d.cts +92 -0
- package/dist/host/batch.d.cts.map +1 -0
- package/dist/host/batch.d.mts +92 -0
- package/dist/host/batch.d.mts.map +1 -0
- package/dist/host/batch.mjs +169 -0
- package/dist/host/batch.mjs.map +1 -0
- package/dist/host/channels.cjs +256 -0
- package/dist/host/channels.cjs.map +1 -0
- package/dist/host/channels.d.cts +66 -0
- package/dist/host/channels.d.cts.map +1 -0
- package/dist/host/channels.d.mts +66 -0
- package/dist/host/channels.d.mts.map +1 -0
- package/dist/host/channels.mjs +252 -0
- package/dist/host/channels.mjs.map +1 -0
- package/dist/host/execute.cjs +102 -0
- package/dist/host/execute.cjs.map +1 -0
- package/dist/host/execute.d.cts +38 -0
- package/dist/host/execute.d.cts.map +1 -0
- package/dist/host/execute.d.mts +38 -0
- package/dist/host/execute.d.mts.map +1 -0
- package/dist/host/execute.mjs +101 -0
- package/dist/host/execute.mjs.map +1 -0
- package/dist/host/fresh-read.cjs +29 -0
- package/dist/host/fresh-read.cjs.map +1 -0
- package/dist/host/fresh-read.d.cts +16 -0
- package/dist/host/fresh-read.d.cts.map +1 -0
- package/dist/host/fresh-read.d.mts +16 -0
- package/dist/host/fresh-read.d.mts.map +1 -0
- package/dist/host/fresh-read.mjs +28 -0
- package/dist/host/fresh-read.mjs.map +1 -0
- package/dist/host/http.cjs +393 -0
- package/dist/host/http.cjs.map +1 -0
- package/dist/host/http.d.cts +61 -0
- package/dist/host/http.d.cts.map +1 -0
- package/dist/host/http.d.mts +61 -0
- package/dist/host/http.d.mts.map +1 -0
- package/dist/host/http.mjs +389 -0
- package/dist/host/http.mjs.map +1 -0
- package/dist/host/ingest.cjs +1210 -0
- package/dist/host/ingest.cjs.map +1 -0
- package/dist/host/ingest.d.cts +497 -0
- package/dist/host/ingest.d.cts.map +1 -0
- package/dist/host/ingest.d.mts +497 -0
- package/dist/host/ingest.d.mts.map +1 -0
- package/dist/host/ingest.mjs +1172 -0
- package/dist/host/ingest.mjs.map +1 -0
- package/dist/host/journey-host.cjs +223 -0
- package/dist/host/journey-host.cjs.map +1 -0
- package/dist/host/journey-host.d.cts +118 -0
- package/dist/host/journey-host.d.cts.map +1 -0
- package/dist/host/journey-host.d.mts +118 -0
- package/dist/host/journey-host.d.mts.map +1 -0
- package/dist/host/journey-host.mjs +219 -0
- package/dist/host/journey-host.mjs.map +1 -0
- package/dist/host/platform.cjs +20 -0
- package/dist/host/platform.cjs.map +1 -0
- package/dist/host/platform.d.cts +120 -0
- package/dist/host/platform.d.cts.map +1 -0
- package/dist/host/platform.d.mts +120 -0
- package/dist/host/platform.d.mts.map +1 -0
- package/dist/host/platform.mjs +18 -0
- package/dist/host/platform.mjs.map +1 -0
- package/dist/host/senders.cjs +71 -0
- package/dist/host/senders.cjs.map +1 -0
- package/dist/host/senders.d.cts +34 -0
- package/dist/host/senders.d.cts.map +1 -0
- package/dist/host/senders.d.mts +34 -0
- package/dist/host/senders.d.mts.map +1 -0
- package/dist/host/senders.mjs +67 -0
- package/dist/host/senders.mjs.map +1 -0
- package/dist/host/workflow-cache.cjs +47 -0
- package/dist/host/workflow-cache.cjs.map +1 -0
- package/dist/host/workflow-cache.d.cts +21 -0
- package/dist/host/workflow-cache.d.cts.map +1 -0
- package/dist/host/workflow-cache.d.mts +21 -0
- package/dist/host/workflow-cache.d.mts.map +1 -0
- package/dist/host/workflow-cache.mjs +46 -0
- package/dist/host/workflow-cache.mjs.map +1 -0
- package/dist/http2-client.cjs +89 -0
- package/dist/http2-client.cjs.map +1 -0
- package/dist/http2-client.d.cts +45 -0
- package/dist/http2-client.d.cts.map +1 -0
- package/dist/http2-client.d.mts +45 -0
- package/dist/http2-client.d.mts.map +1 -0
- package/dist/http2-client.mjs +87 -0
- package/dist/http2-client.mjs.map +1 -0
- package/dist/index.cjs +130 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.mjs +20 -0
- package/dist/inflight.cjs +116 -0
- package/dist/inflight.cjs.map +1 -0
- package/dist/inflight.d.cts +49 -0
- package/dist/inflight.d.cts.map +1 -0
- package/dist/inflight.d.mts +49 -0
- package/dist/inflight.d.mts.map +1 -0
- package/dist/inflight.mjs +113 -0
- package/dist/inflight.mjs.map +1 -0
- package/dist/ir.cjs +429 -0
- package/dist/ir.cjs.map +1 -0
- package/dist/ir.d.cts +593 -0
- package/dist/ir.d.cts.map +1 -0
- package/dist/ir.d.mts +593 -0
- package/dist/ir.d.mts.map +1 -0
- package/dist/ir.mjs +404 -0
- package/dist/ir.mjs.map +1 -0
- package/dist/jwt.cjs +17 -0
- package/dist/jwt.cjs.map +1 -0
- package/dist/jwt.d.cts +7 -0
- package/dist/jwt.d.cts.map +1 -0
- package/dist/jwt.d.mts +7 -0
- package/dist/jwt.d.mts.map +1 -0
- package/dist/jwt.mjs +15 -0
- package/dist/jwt.mjs.map +1 -0
- package/dist/node/index.cjs +231 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +59 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.d.mts +59 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.mjs +225 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/runs.cjs +222 -0
- package/dist/node/runs.cjs.map +1 -0
- package/dist/node/runs.d.cts +93 -0
- package/dist/node/runs.d.cts.map +1 -0
- package/dist/node/runs.d.mts +93 -0
- package/dist/node/runs.d.mts.map +1 -0
- package/dist/node/runs.mjs +221 -0
- package/dist/node/runs.mjs.map +1 -0
- package/dist/node/runtime.cjs +351 -0
- package/dist/node/runtime.cjs.map +1 -0
- package/dist/node/runtime.d.cts +96 -0
- package/dist/node/runtime.d.cts.map +1 -0
- package/dist/node/runtime.d.mts +96 -0
- package/dist/node/runtime.d.mts.map +1 -0
- package/dist/node/runtime.mjs +348 -0
- package/dist/node/runtime.mjs.map +1 -0
- package/dist/plan.cjs +221 -0
- package/dist/plan.cjs.map +1 -0
- package/dist/plan.d.cts +68 -0
- package/dist/plan.d.cts.map +1 -0
- package/dist/plan.d.mts +68 -0
- package/dist/plan.d.mts.map +1 -0
- package/dist/plan.mjs +218 -0
- package/dist/plan.mjs.map +1 -0
- package/dist/postgres-js.cjs +51 -0
- package/dist/postgres-js.cjs.map +1 -0
- package/dist/postgres-js.d.cts +32 -0
- package/dist/postgres-js.d.cts.map +1 -0
- package/dist/postgres-js.d.mts +32 -0
- package/dist/postgres-js.d.mts.map +1 -0
- package/dist/postgres-js.mjs +46 -0
- package/dist/postgres-js.mjs.map +1 -0
- package/dist/provenance.cjs +66 -0
- package/dist/provenance.cjs.map +1 -0
- package/dist/provenance.d.cts +40 -0
- package/dist/provenance.d.cts.map +1 -0
- package/dist/provenance.d.mts +40 -0
- package/dist/provenance.d.mts.map +1 -0
- package/dist/provenance.mjs +64 -0
- package/dist/provenance.mjs.map +1 -0
- package/dist/push.cjs +11 -0
- package/dist/push.cjs.map +1 -0
- package/dist/push.d.cts +14 -0
- package/dist/push.d.cts.map +1 -0
- package/dist/push.d.mts +14 -0
- package/dist/push.d.mts.map +1 -0
- package/dist/push.mjs +10 -0
- package/dist/push.mjs.map +1 -0
- package/dist/react-email.cjs +56 -0
- package/dist/react-email.cjs.map +1 -0
- package/dist/react-email.d.cts +5 -0
- package/dist/react-email.d.cts.map +1 -0
- package/dist/react-email.d.mts +5 -0
- package/dist/react-email.d.mts.map +1 -0
- package/dist/react-email.mjs +55 -0
- package/dist/react-email.mjs.map +1 -0
- package/dist/reporting/classify.cjs +46 -0
- package/dist/reporting/classify.cjs.map +1 -0
- package/dist/reporting/classify.d.cts +65 -0
- package/dist/reporting/classify.d.cts.map +1 -0
- package/dist/reporting/classify.d.mts +65 -0
- package/dist/reporting/classify.d.mts.map +1 -0
- package/dist/reporting/classify.mjs +42 -0
- package/dist/reporting/classify.mjs.map +1 -0
- package/dist/reporting/observer.cjs +137 -0
- package/dist/reporting/observer.cjs.map +1 -0
- package/dist/reporting/observer.d.cts +31 -0
- package/dist/reporting/observer.d.cts.map +1 -0
- package/dist/reporting/observer.d.mts +31 -0
- package/dist/reporting/observer.d.mts.map +1 -0
- package/dist/reporting/observer.mjs +134 -0
- package/dist/reporting/observer.mjs.map +1 -0
- package/dist/reporting/tracking.cjs +185 -0
- package/dist/reporting/tracking.cjs.map +1 -0
- package/dist/reporting/tracking.d.cts +63 -0
- package/dist/reporting/tracking.d.cts.map +1 -0
- package/dist/reporting/tracking.d.mts +63 -0
- package/dist/reporting/tracking.d.mts.map +1 -0
- package/dist/reporting/tracking.mjs +182 -0
- package/dist/reporting/tracking.mjs.map +1 -0
- package/dist/runtime.cjs +18 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +44 -0
- package/dist/runtime.d.cts.map +1 -0
- package/dist/runtime.d.mts +44 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +17 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/store/condition-sql.cjs +145 -0
- package/dist/store/condition-sql.cjs.map +1 -0
- package/dist/store/condition-sql.d.cts +38 -0
- package/dist/store/condition-sql.d.cts.map +1 -0
- package/dist/store/condition-sql.d.mts +38 -0
- package/dist/store/condition-sql.d.mts.map +1 -0
- package/dist/store/condition-sql.mjs +144 -0
- package/dist/store/condition-sql.mjs.map +1 -0
- package/dist/store/erasure.cjs +21 -0
- package/dist/store/erasure.cjs.map +1 -0
- package/dist/store/erasure.d.cts +16 -0
- package/dist/store/erasure.d.cts.map +1 -0
- package/dist/store/erasure.d.mts +16 -0
- package/dist/store/erasure.d.mts.map +1 -0
- package/dist/store/erasure.mjs +20 -0
- package/dist/store/erasure.mjs.map +1 -0
- package/dist/store/facts.cjs +79 -0
- package/dist/store/facts.cjs.map +1 -0
- package/dist/store/facts.d.cts +41 -0
- package/dist/store/facts.d.cts.map +1 -0
- package/dist/store/facts.d.mts +41 -0
- package/dist/store/facts.d.mts.map +1 -0
- package/dist/store/facts.mjs +77 -0
- package/dist/store/facts.mjs.map +1 -0
- package/dist/store/identity.cjs +34 -0
- package/dist/store/identity.cjs.map +1 -0
- package/dist/store/identity.d.cts +13 -0
- package/dist/store/identity.d.cts.map +1 -0
- package/dist/store/identity.d.mts +13 -0
- package/dist/store/identity.d.mts.map +1 -0
- package/dist/store/identity.mjs +30 -0
- package/dist/store/identity.mjs.map +1 -0
- package/dist/store/index.cjs +35 -0
- package/dist/store/index.cjs.map +1 -0
- package/dist/store/index.d.cts +766 -0
- package/dist/store/index.d.cts.map +1 -0
- package/dist/store/index.d.mts +766 -0
- package/dist/store/index.d.mts.map +1 -0
- package/dist/store/index.mjs +22 -0
- package/dist/store/index.mjs.map +1 -0
- package/dist/store/postgres-reporting.cjs +327 -0
- package/dist/store/postgres-reporting.cjs.map +1 -0
- package/dist/store/postgres-reporting.d.cts +95 -0
- package/dist/store/postgres-reporting.d.cts.map +1 -0
- package/dist/store/postgres-reporting.d.mts +95 -0
- package/dist/store/postgres-reporting.d.mts.map +1 -0
- package/dist/store/postgres-reporting.mjs +326 -0
- package/dist/store/postgres-reporting.mjs.map +1 -0
- package/dist/store/postgres.cjs +1173 -0
- package/dist/store/postgres.cjs.map +1 -0
- package/dist/store/postgres.d.cts +199 -0
- package/dist/store/postgres.d.cts.map +1 -0
- package/dist/store/postgres.d.mts +199 -0
- package/dist/store/postgres.d.mts.map +1 -0
- package/dist/store/postgres.mjs +1170 -0
- package/dist/store/postgres.mjs.map +1 -0
- package/dist/store/sql.cjs +24 -0
- package/dist/store/sql.cjs.map +1 -0
- package/dist/store/sql.d.cts +26 -0
- package/dist/store/sql.d.cts.map +1 -0
- package/dist/store/sql.d.mts +26 -0
- package/dist/store/sql.d.mts.map +1 -0
- package/dist/store/sql.mjs +23 -0
- package/dist/store/sql.mjs.map +1 -0
- package/dist/store/tables.cjs +660 -0
- package/dist/store/tables.cjs.map +1 -0
- package/dist/store/tables.d.cts +103 -0
- package/dist/store/tables.d.cts.map +1 -0
- package/dist/store/tables.d.mts +103 -0
- package/dist/store/tables.d.mts.map +1 -0
- package/dist/store/tables.mjs +653 -0
- package/dist/store/tables.mjs.map +1 -0
- package/dist/store/user-lock.cjs +42 -0
- package/dist/store/user-lock.cjs.map +1 -0
- package/dist/store/user-lock.d.cts +30 -0
- package/dist/store/user-lock.d.cts.map +1 -0
- package/dist/store/user-lock.d.mts +30 -0
- package/dist/store/user-lock.d.mts.map +1 -0
- package/dist/store/user-lock.mjs +39 -0
- package/dist/store/user-lock.mjs.map +1 -0
- package/dist/template-rules.cjs +94 -0
- package/dist/template-rules.cjs.map +1 -0
- package/dist/template-rules.d.cts +80 -0
- package/dist/template-rules.d.cts.map +1 -0
- package/dist/template-rules.d.mts +80 -0
- package/dist/template-rules.d.mts.map +1 -0
- package/dist/template-rules.mjs +86 -0
- package/dist/template-rules.mjs.map +1 -0
- package/dist/templates.cjs +375 -0
- package/dist/templates.cjs.map +1 -0
- package/dist/templates.d.cts +358 -0
- package/dist/templates.d.cts.map +1 -0
- package/dist/templates.d.mts +358 -0
- package/dist/templates.d.mts.map +1 -0
- package/dist/templates.mjs +353 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/transports/cloudflare-email.cjs +69 -0
- package/dist/transports/cloudflare-email.cjs.map +1 -0
- package/dist/transports/cloudflare-email.d.cts +63 -0
- package/dist/transports/cloudflare-email.d.cts.map +1 -0
- package/dist/transports/cloudflare-email.d.mts +63 -0
- package/dist/transports/cloudflare-email.d.mts.map +1 -0
- package/dist/transports/cloudflare-email.mjs +67 -0
- package/dist/transports/cloudflare-email.mjs.map +1 -0
- package/dist/transports/ses.cjs +142 -0
- package/dist/transports/ses.cjs.map +1 -0
- package/dist/transports/ses.d.cts +49 -0
- package/dist/transports/ses.d.cts.map +1 -0
- package/dist/transports/ses.d.mts +49 -0
- package/dist/transports/ses.d.mts.map +1 -0
- package/dist/transports/ses.mjs +139 -0
- package/dist/transports/ses.mjs.map +1 -0
- package/dist/transports/sigv4.cjs +86 -0
- package/dist/transports/sigv4.cjs.map +1 -0
- package/dist/transports/sigv4.d.cts +25 -0
- package/dist/transports/sigv4.d.cts.map +1 -0
- package/dist/transports/sigv4.d.mts +25 -0
- package/dist/transports/sigv4.d.mts.map +1 -0
- package/dist/transports/sigv4.mjs +85 -0
- package/dist/transports/sigv4.mjs.map +1 -0
- package/dist/webhooks.cjs +97 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +23 -0
- package/dist/webhooks.d.cts.map +1 -0
- package/dist/webhooks.d.mts +23 -0
- package/dist/webhooks.d.mts.map +1 -0
- package/dist/webhooks.mjs +95 -0
- package/dist/webhooks.mjs.map +1 -0
- package/dist/webpush.cjs +361 -0
- package/dist/webpush.cjs.map +1 -0
- package/dist/webpush.d.cts +135 -0
- package/dist/webpush.d.cts.map +1 -0
- package/dist/webpush.d.mts +135 -0
- package/dist/webpush.d.mts.map +1 -0
- package/dist/webpush.mjs +350 -0
- package/dist/webpush.mjs.map +1 -0
- package/package.json +270 -31
- package/src/cloudflare/workers.d.ts +44 -0
- package/index.cjs +0 -18
- package/index.d.cts +0 -4
- package/index.d.mts +0 -4
- package/index.mjs +0 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { TriggerIR } from "../ir.cjs";
|
|
2
|
+
import { Condition, PayloadWhere, SegmentRef } from "./condition.cjs";
|
|
3
|
+
import { EventRef, TriggerPayloadRefs } from "./refs.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* Triggers — the four ways into a workflow, mirroring customer.io's campaign
|
|
6
|
+
* trigger types. A trigger is a plain reusable object; the event name and
|
|
7
|
+
* payload types flow in from an e.xxx reference, so the factory itself needs
|
|
8
|
+
* no generics.
|
|
9
|
+
*/
|
|
10
|
+
/** 'YYYY-MM-DD HH:mm:ss', UTC. `trigger.date` refuses anything else when the workflow is built. */
|
|
11
|
+
export type DateTime = string;
|
|
12
|
+
export interface DateTriggerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Who enters: the users the condition holds for when the time comes — a segment
|
|
15
|
+
* (`{ filter: purchaser }`), a profile predicate, or both. Everyone known to the engine
|
|
16
|
+
* without it. Checked before an instance is created, so a user it turns away has not
|
|
17
|
+
* entered: no instance, no entry held against the `reentry` policy.
|
|
18
|
+
*/
|
|
19
|
+
filter?: Condition;
|
|
20
|
+
}
|
|
21
|
+
/** Trigger reference: what trigger.xxx() returns, reusable across workflows. */
|
|
22
|
+
export interface TriggerRef {
|
|
23
|
+
readonly type: 'event' | 'segment' | 'date' | 'webhook';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What `trigger.event()` returns: the trigger, and a handle on the event that
|
|
27
|
+
* fired it. `payload` is the table of that event's fields as the journey
|
|
28
|
+
* entered with them:
|
|
29
|
+
*
|
|
30
|
+
* const checkout = trigger.event(e.begin_checkout);
|
|
31
|
+
* workflow({ id: 'checkout_recovery', trigger: checkout })
|
|
32
|
+
* .branch([gte(checkout.payload.value, 100), (w) => w.email(email.vip_offer)])
|
|
33
|
+
* .email(email.reminder, { total: checkout.payload.value });
|
|
34
|
+
*
|
|
35
|
+
* The value is a snapshot: a later begin_checkout does not change what a
|
|
36
|
+
* running journey reads. A reference is only valid in the workflow this
|
|
37
|
+
* trigger starts — compileBundle refuses it anywhere else.
|
|
38
|
+
*/
|
|
39
|
+
export interface EventTriggerRef<P = unknown> extends TriggerRef {
|
|
40
|
+
readonly type: 'event';
|
|
41
|
+
readonly payload: TriggerPayloadRefs<P>;
|
|
42
|
+
}
|
|
43
|
+
/** @internal the compiled shape behind a TriggerRef — workflow.toIR reads .ir off it */
|
|
44
|
+
export interface TriggerInternal extends TriggerRef {
|
|
45
|
+
readonly ir: TriggerIR;
|
|
46
|
+
}
|
|
47
|
+
export interface EventTriggerOptions {
|
|
48
|
+
filter?: Condition;
|
|
49
|
+
/**
|
|
50
|
+
* Let a visitor who has not signed in enter: such a journey reaches them by push, having no
|
|
51
|
+
* address to email. Off by default, because an entry made as a visitor is still theirs after
|
|
52
|
+
* signing in, and counts against the workflow's `reentry` policy like any other entry.
|
|
53
|
+
*/
|
|
54
|
+
visitors?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Trigger factory: four ways in, mirroring customer.io's campaign trigger types. */
|
|
57
|
+
export interface TriggerFactory {
|
|
58
|
+
/**
|
|
59
|
+
* Event trigger: the event name comes from an e.xxx reference (types flow in
|
|
60
|
+
* from it, so the factory itself needs no generics). Two independent gates:
|
|
61
|
+
* - the optional second argument is a payload where clause (typed refs, the
|
|
62
|
+
* ordinary predicates — compiles to IR data the UI renders):
|
|
63
|
+
* trigger.event(e.login, (p) => eq(p.platform, 'web'))
|
|
64
|
+
* - `filter` tests the user's profile (customer.io's trigger Filters).
|
|
65
|
+
* The user enters only if the event fired *and* both gates hold.
|
|
66
|
+
*/
|
|
67
|
+
event<P>(event: EventRef<P>, opts?: EventTriggerOptions): EventTriggerRef<P>;
|
|
68
|
+
event<P>(event: EventRef<P>, where: PayloadWhere<P>, opts?: EventTriggerOptions): EventTriggerRef<P>;
|
|
69
|
+
/**
|
|
70
|
+
* Segment-entry trigger: the journey starts when the user goes from not
|
|
71
|
+
* matching the segment to matching it. It is about entering, not about being
|
|
72
|
+
* in: someone who already matched when the segment was deployed (or when its
|
|
73
|
+
* condition last changed) is recorded as a member and starts nothing. Each
|
|
74
|
+
* fresh qualification (left the segment, matched again) is one entry attempt
|
|
75
|
+
* under the workflow's `reentry` policy; staying a member never enters again.
|
|
76
|
+
*
|
|
77
|
+
* Only a named segment is accepted — entry needs a membership table, which an
|
|
78
|
+
* anonymous expression cannot have. Membership is re-evaluated on the user's
|
|
79
|
+
* own activity (ingest, identify) and by the scheduled sweep, which is what
|
|
80
|
+
* sees a segment entered by the clock alone (`not(performed(e.login, {
|
|
81
|
+
* within: '7 days' }))`).
|
|
82
|
+
*
|
|
83
|
+
* To act on everyone who is in a segment now, name it in a condition instead
|
|
84
|
+
* (a trigger's `filter`, a `branch`): that asks each user at that moment.
|
|
85
|
+
*/
|
|
86
|
+
enters(segment: SegmentRef): TriggerRef;
|
|
87
|
+
/** @deprecated Renamed `trigger.enters`: the same trigger, named for what it waits for. */
|
|
88
|
+
segment(segment: SegmentRef): TriggerRef;
|
|
89
|
+
/**
|
|
90
|
+
* Scheduled trigger: once, at a time (e.g. '2026-12-25 09:00:00', UTC), a
|
|
91
|
+
* journey starts for every known user the `filter` holds for at that moment —
|
|
92
|
+
* long-standing members of a segment included, unlike `trigger.enters`.
|
|
93
|
+
*
|
|
94
|
+
* trigger.date('2026-11-27 09:00:00', { filter: purchaser })
|
|
95
|
+
*
|
|
96
|
+
* The scheduled sweep (the cron trigger) does the starting, page by page, so
|
|
97
|
+
* the send begins at the first sweep after the time and takes as many sweeps
|
|
98
|
+
* as the audience needs. One (workflow, time) pair runs once: redeploying
|
|
99
|
+
* does not repeat it, and changing the time is another run. A time already
|
|
100
|
+
* past when the trigger is first deployed is not run. TODO: a recurring form.
|
|
101
|
+
*/
|
|
102
|
+
date(at: DateTime, opts?: DateTriggerOptions): TriggerRef;
|
|
103
|
+
/** Webhook trigger: third-party or external code fires it via a URL; the runtime allocates the endpoint. */
|
|
104
|
+
webhook(): TriggerRef;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Trigger definition: a plain object — event names come from e.xxx references.
|
|
108
|
+
*
|
|
109
|
+
* const login = trigger.event(e.login, { filter: newUsers7d });
|
|
110
|
+
*/
|
|
111
|
+
export declare const trigger: TriggerFactory;
|
|
112
|
+
//# sourceMappingURL=trigger.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.d.cts","names":[],"sources":["../../src/dsl/trigger.ts"],"mappings":";;;;;;;;;;YAaY;iBAEK;;;;;;;EAOf,SAAS;;;iBAIM;WACN;;;;;;;;;;;;;;;;iBAiBM,gBAAgB,qBAAqB;WAC3C;WACA,SAAS,mBAAmB;;;iBAItB,wBAAwB;WAC9B,IAAI;;iBAQE;EACf,SAAS;;;;;;EAMT;;;iBAIe;;;;;;;;;;EAUf,MAAM,GAAG,OAAO,SAAS,IAAI,OAAO,sBAAsB,gBAAgB;EAC1E,MAAM,GACJ,OAAO,SAAS,IAChB,OAAO,aAAa,IACpB,OAAO,sBACN,gBAAgB;;;;;;;;;;;;;;;;;;EAmBnB,OAAO,SAAS,aAAa;;EAG7B,QAAQ,SAAS,aAAa;;;;;;;;;;;;;;EAe9B,KAAK,IAAI,UAAU,OAAO,qBAAqB;;EAG/C,WAAW;;;;;;;qBAQA,SAAS"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { TriggerIR } from "../ir.mjs";
|
|
2
|
+
import { Condition, PayloadWhere, SegmentRef } from "./condition.mjs";
|
|
3
|
+
import { EventRef, TriggerPayloadRefs } from "./refs.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Triggers — the four ways into a workflow, mirroring customer.io's campaign
|
|
6
|
+
* trigger types. A trigger is a plain reusable object; the event name and
|
|
7
|
+
* payload types flow in from an e.xxx reference, so the factory itself needs
|
|
8
|
+
* no generics.
|
|
9
|
+
*/
|
|
10
|
+
/** 'YYYY-MM-DD HH:mm:ss', UTC. `trigger.date` refuses anything else when the workflow is built. */
|
|
11
|
+
export type DateTime = string;
|
|
12
|
+
export interface DateTriggerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Who enters: the users the condition holds for when the time comes — a segment
|
|
15
|
+
* (`{ filter: purchaser }`), a profile predicate, or both. Everyone known to the engine
|
|
16
|
+
* without it. Checked before an instance is created, so a user it turns away has not
|
|
17
|
+
* entered: no instance, no entry held against the `reentry` policy.
|
|
18
|
+
*/
|
|
19
|
+
filter?: Condition;
|
|
20
|
+
}
|
|
21
|
+
/** Trigger reference: what trigger.xxx() returns, reusable across workflows. */
|
|
22
|
+
export interface TriggerRef {
|
|
23
|
+
readonly type: 'event' | 'segment' | 'date' | 'webhook';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What `trigger.event()` returns: the trigger, and a handle on the event that
|
|
27
|
+
* fired it. `payload` is the table of that event's fields as the journey
|
|
28
|
+
* entered with them:
|
|
29
|
+
*
|
|
30
|
+
* const checkout = trigger.event(e.begin_checkout);
|
|
31
|
+
* workflow({ id: 'checkout_recovery', trigger: checkout })
|
|
32
|
+
* .branch([gte(checkout.payload.value, 100), (w) => w.email(email.vip_offer)])
|
|
33
|
+
* .email(email.reminder, { total: checkout.payload.value });
|
|
34
|
+
*
|
|
35
|
+
* The value is a snapshot: a later begin_checkout does not change what a
|
|
36
|
+
* running journey reads. A reference is only valid in the workflow this
|
|
37
|
+
* trigger starts — compileBundle refuses it anywhere else.
|
|
38
|
+
*/
|
|
39
|
+
export interface EventTriggerRef<P = unknown> extends TriggerRef {
|
|
40
|
+
readonly type: 'event';
|
|
41
|
+
readonly payload: TriggerPayloadRefs<P>;
|
|
42
|
+
}
|
|
43
|
+
/** @internal the compiled shape behind a TriggerRef — workflow.toIR reads .ir off it */
|
|
44
|
+
export interface TriggerInternal extends TriggerRef {
|
|
45
|
+
readonly ir: TriggerIR;
|
|
46
|
+
}
|
|
47
|
+
export interface EventTriggerOptions {
|
|
48
|
+
filter?: Condition;
|
|
49
|
+
/**
|
|
50
|
+
* Let a visitor who has not signed in enter: such a journey reaches them by push, having no
|
|
51
|
+
* address to email. Off by default, because an entry made as a visitor is still theirs after
|
|
52
|
+
* signing in, and counts against the workflow's `reentry` policy like any other entry.
|
|
53
|
+
*/
|
|
54
|
+
visitors?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Trigger factory: four ways in, mirroring customer.io's campaign trigger types. */
|
|
57
|
+
export interface TriggerFactory {
|
|
58
|
+
/**
|
|
59
|
+
* Event trigger: the event name comes from an e.xxx reference (types flow in
|
|
60
|
+
* from it, so the factory itself needs no generics). Two independent gates:
|
|
61
|
+
* - the optional second argument is a payload where clause (typed refs, the
|
|
62
|
+
* ordinary predicates — compiles to IR data the UI renders):
|
|
63
|
+
* trigger.event(e.login, (p) => eq(p.platform, 'web'))
|
|
64
|
+
* - `filter` tests the user's profile (customer.io's trigger Filters).
|
|
65
|
+
* The user enters only if the event fired *and* both gates hold.
|
|
66
|
+
*/
|
|
67
|
+
event<P>(event: EventRef<P>, opts?: EventTriggerOptions): EventTriggerRef<P>;
|
|
68
|
+
event<P>(event: EventRef<P>, where: PayloadWhere<P>, opts?: EventTriggerOptions): EventTriggerRef<P>;
|
|
69
|
+
/**
|
|
70
|
+
* Segment-entry trigger: the journey starts when the user goes from not
|
|
71
|
+
* matching the segment to matching it. It is about entering, not about being
|
|
72
|
+
* in: someone who already matched when the segment was deployed (or when its
|
|
73
|
+
* condition last changed) is recorded as a member and starts nothing. Each
|
|
74
|
+
* fresh qualification (left the segment, matched again) is one entry attempt
|
|
75
|
+
* under the workflow's `reentry` policy; staying a member never enters again.
|
|
76
|
+
*
|
|
77
|
+
* Only a named segment is accepted — entry needs a membership table, which an
|
|
78
|
+
* anonymous expression cannot have. Membership is re-evaluated on the user's
|
|
79
|
+
* own activity (ingest, identify) and by the scheduled sweep, which is what
|
|
80
|
+
* sees a segment entered by the clock alone (`not(performed(e.login, {
|
|
81
|
+
* within: '7 days' }))`).
|
|
82
|
+
*
|
|
83
|
+
* To act on everyone who is in a segment now, name it in a condition instead
|
|
84
|
+
* (a trigger's `filter`, a `branch`): that asks each user at that moment.
|
|
85
|
+
*/
|
|
86
|
+
enters(segment: SegmentRef): TriggerRef;
|
|
87
|
+
/** @deprecated Renamed `trigger.enters`: the same trigger, named for what it waits for. */
|
|
88
|
+
segment(segment: SegmentRef): TriggerRef;
|
|
89
|
+
/**
|
|
90
|
+
* Scheduled trigger: once, at a time (e.g. '2026-12-25 09:00:00', UTC), a
|
|
91
|
+
* journey starts for every known user the `filter` holds for at that moment —
|
|
92
|
+
* long-standing members of a segment included, unlike `trigger.enters`.
|
|
93
|
+
*
|
|
94
|
+
* trigger.date('2026-11-27 09:00:00', { filter: purchaser })
|
|
95
|
+
*
|
|
96
|
+
* The scheduled sweep (the cron trigger) does the starting, page by page, so
|
|
97
|
+
* the send begins at the first sweep after the time and takes as many sweeps
|
|
98
|
+
* as the audience needs. One (workflow, time) pair runs once: redeploying
|
|
99
|
+
* does not repeat it, and changing the time is another run. A time already
|
|
100
|
+
* past when the trigger is first deployed is not run. TODO: a recurring form.
|
|
101
|
+
*/
|
|
102
|
+
date(at: DateTime, opts?: DateTriggerOptions): TriggerRef;
|
|
103
|
+
/** Webhook trigger: third-party or external code fires it via a URL; the runtime allocates the endpoint. */
|
|
104
|
+
webhook(): TriggerRef;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Trigger definition: a plain object — event names come from e.xxx references.
|
|
108
|
+
*
|
|
109
|
+
* const login = trigger.event(e.login, { filter: newUsers7d });
|
|
110
|
+
*/
|
|
111
|
+
export declare const trigger: TriggerFactory;
|
|
112
|
+
//# sourceMappingURL=trigger.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.d.mts","names":[],"sources":["../../src/dsl/trigger.ts"],"mappings":";;;;;;;;;;YAaY;iBAEK;;;;;;;EAOf,SAAS;;;iBAIM;WACN;;;;;;;;;;;;;;;;iBAiBM,gBAAgB,qBAAqB;WAC3C;WACA,SAAS,mBAAmB;;;iBAItB,wBAAwB;WAC9B,IAAI;;iBAQE;EACf,SAAS;;;;;;EAMT;;;iBAIe;;;;;;;;;;EAUf,MAAM,GAAG,OAAO,SAAS,IAAI,OAAO,sBAAsB,gBAAgB;EAC1E,MAAM,GACJ,OAAO,SAAS,IAChB,OAAO,aAAa,IACpB,OAAO,sBACN,gBAAgB;;;;;;;;;;;;;;;;;;EAmBnB,OAAO,SAAS,aAAa;;EAG7B,QAAQ,SAAS,aAAa;;;;;;;;;;;;;;EAe9B,KAAK,IAAI,UAAU,OAAO,qBAAqB;;EAG/C,WAAW;;;;;;;qBAQA,SAAS"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { dateTimeMs } from "../date-time.mjs";
|
|
2
|
+
import { condIR } from "./condition.mjs";
|
|
3
|
+
import { payloadRefs, triggerPayloadRefs } from "./refs.mjs";
|
|
4
|
+
// src/dsl/trigger.ts
|
|
5
|
+
const makeTrigger = (ir) => {
|
|
6
|
+
return {
|
|
7
|
+
type: ir.type,
|
|
8
|
+
ir
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Trigger definition: a plain object — event names come from e.xxx references.
|
|
13
|
+
*
|
|
14
|
+
* const login = trigger.event(e.login, { filter: newUsers7d });
|
|
15
|
+
*/
|
|
16
|
+
const trigger = {
|
|
17
|
+
event: (ev, whereOrOpts, maybeOpts) => {
|
|
18
|
+
const where = typeof whereOrOpts === "function" ? whereOrOpts : void 0;
|
|
19
|
+
const opts = typeof whereOrOpts === "function" ? maybeOpts : whereOrOpts;
|
|
20
|
+
return {
|
|
21
|
+
type: "event",
|
|
22
|
+
ir: {
|
|
23
|
+
type: "event",
|
|
24
|
+
event: ev.name,
|
|
25
|
+
...where !== void 0 ? { where: condIR(where(payloadRefs())) } : {},
|
|
26
|
+
...opts?.filter !== void 0 ? { filter: condIR(opts.filter) } : {},
|
|
27
|
+
...opts?.visitors === true ? { visitors: true } : {}
|
|
28
|
+
},
|
|
29
|
+
payload: triggerPayloadRefs(ev.name)
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
enters: (seg) => makeTrigger({
|
|
33
|
+
type: "segment",
|
|
34
|
+
segment: seg.id
|
|
35
|
+
}),
|
|
36
|
+
segment: (seg) => makeTrigger({
|
|
37
|
+
type: "segment",
|
|
38
|
+
segment: seg.id
|
|
39
|
+
}),
|
|
40
|
+
date: (at, opts) => {
|
|
41
|
+
if (dateTimeMs(at) === void 0) throw new TypeError(`trigger.date(): '${at}' is not a time — write it as 'YYYY-MM-DD HH:mm:ss' (UTC)`);
|
|
42
|
+
return makeTrigger({
|
|
43
|
+
type: "date",
|
|
44
|
+
at,
|
|
45
|
+
...opts?.filter !== void 0 ? { filter: condIR(opts.filter) } : {}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
webhook: () => makeTrigger({ type: "webhook" })
|
|
49
|
+
};
|
|
50
|
+
export { trigger };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=trigger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.mjs","names":[],"sources":["../../src/dsl/trigger.ts"],"sourcesContent":["import { dateTimeMs } from '../date-time';\nimport type { TriggerIR } from '../ir';\nimport { type Condition, type PayloadWhere, type SegmentRef, condIR } from './condition';\nimport { type EventRef, type TriggerPayloadRefs, payloadRefs, triggerPayloadRefs } from './refs';\n\n/**\n * Triggers — the four ways into a workflow, mirroring customer.io's campaign\n * trigger types. A trigger is a plain reusable object; the event name and\n * payload types flow in from an e.xxx reference, so the factory itself needs\n * no generics.\n */\n\n/** 'YYYY-MM-DD HH:mm:ss', UTC. `trigger.date` refuses anything else when the workflow is built. */\nexport type DateTime = string;\n\nexport interface DateTriggerOptions {\n /**\n * Who enters: the users the condition holds for when the time comes — a segment\n * (`{ filter: purchaser }`), a profile predicate, or both. Everyone known to the engine\n * without it. Checked before an instance is created, so a user it turns away has not\n * entered: no instance, no entry held against the `reentry` policy.\n */\n filter?: Condition;\n}\n\n/** Trigger reference: what trigger.xxx() returns, reusable across workflows. */\nexport interface TriggerRef {\n readonly type: 'event' | 'segment' | 'date' | 'webhook';\n}\n\n/**\n * What `trigger.event()` returns: the trigger, and a handle on the event that\n * fired it. `payload` is the table of that event's fields as the journey\n * entered with them:\n *\n * const checkout = trigger.event(e.begin_checkout);\n * workflow({ id: 'checkout_recovery', trigger: checkout })\n * .branch([gte(checkout.payload.value, 100), (w) => w.email(email.vip_offer)])\n * .email(email.reminder, { total: checkout.payload.value });\n *\n * The value is a snapshot: a later begin_checkout does not change what a\n * running journey reads. A reference is only valid in the workflow this\n * trigger starts — compileBundle refuses it anywhere else.\n */\nexport interface EventTriggerRef<P = unknown> extends TriggerRef {\n readonly type: 'event';\n readonly payload: TriggerPayloadRefs<P>;\n}\n\n/** @internal the compiled shape behind a TriggerRef — workflow.toIR reads .ir off it */\nexport interface TriggerInternal extends TriggerRef {\n readonly ir: TriggerIR;\n}\n\nconst makeTrigger = (ir: TriggerIR): TriggerRef => {\n const impl: TriggerInternal = { type: ir.type, ir };\n return impl;\n};\n\nexport interface EventTriggerOptions {\n filter?: Condition;\n /**\n * Let a visitor who has not signed in enter: such a journey reaches them by push, having no\n * address to email. Off by default, because an entry made as a visitor is still theirs after\n * signing in, and counts against the workflow's `reentry` policy like any other entry.\n */\n visitors?: boolean;\n}\n\n/** Trigger factory: four ways in, mirroring customer.io's campaign trigger types. */\nexport interface TriggerFactory {\n /**\n * Event trigger: the event name comes from an e.xxx reference (types flow in\n * from it, so the factory itself needs no generics). Two independent gates:\n * - the optional second argument is a payload where clause (typed refs, the\n * ordinary predicates — compiles to IR data the UI renders):\n * trigger.event(e.login, (p) => eq(p.platform, 'web'))\n * - `filter` tests the user's profile (customer.io's trigger Filters).\n * The user enters only if the event fired *and* both gates hold.\n */\n event<P>(event: EventRef<P>, opts?: EventTriggerOptions): EventTriggerRef<P>;\n event<P>(\n event: EventRef<P>,\n where: PayloadWhere<P>,\n opts?: EventTriggerOptions\n ): EventTriggerRef<P>;\n\n /**\n * Segment-entry trigger: the journey starts when the user goes from not\n * matching the segment to matching it. It is about entering, not about being\n * in: someone who already matched when the segment was deployed (or when its\n * condition last changed) is recorded as a member and starts nothing. Each\n * fresh qualification (left the segment, matched again) is one entry attempt\n * under the workflow's `reentry` policy; staying a member never enters again.\n *\n * Only a named segment is accepted — entry needs a membership table, which an\n * anonymous expression cannot have. Membership is re-evaluated on the user's\n * own activity (ingest, identify) and by the scheduled sweep, which is what\n * sees a segment entered by the clock alone (`not(performed(e.login, {\n * within: '7 days' }))`).\n *\n * To act on everyone who is in a segment now, name it in a condition instead\n * (a trigger's `filter`, a `branch`): that asks each user at that moment.\n */\n enters(segment: SegmentRef): TriggerRef;\n\n /** @deprecated Renamed `trigger.enters`: the same trigger, named for what it waits for. */\n segment(segment: SegmentRef): TriggerRef;\n\n /**\n * Scheduled trigger: once, at a time (e.g. '2026-12-25 09:00:00', UTC), a\n * journey starts for every known user the `filter` holds for at that moment —\n * long-standing members of a segment included, unlike `trigger.enters`.\n *\n * trigger.date('2026-11-27 09:00:00', { filter: purchaser })\n *\n * The scheduled sweep (the cron trigger) does the starting, page by page, so\n * the send begins at the first sweep after the time and takes as many sweeps\n * as the audience needs. One (workflow, time) pair runs once: redeploying\n * does not repeat it, and changing the time is another run. A time already\n * past when the trigger is first deployed is not run. TODO: a recurring form.\n */\n date(at: DateTime, opts?: DateTriggerOptions): TriggerRef;\n\n /** Webhook trigger: third-party or external code fires it via a URL; the runtime allocates the endpoint. */\n webhook(): TriggerRef;\n}\n\n/**\n * Trigger definition: a plain object — event names come from e.xxx references.\n *\n * const login = trigger.event(e.login, { filter: newUsers7d });\n */\nexport const trigger: TriggerFactory = {\n event: <P>(\n ev: EventRef<P>,\n whereOrOpts?: PayloadWhere<P> | EventTriggerOptions,\n maybeOpts?: EventTriggerOptions\n ) => {\n const where = typeof whereOrOpts === 'function' ? whereOrOpts : undefined;\n const opts = typeof whereOrOpts === 'function' ? maybeOpts : whereOrOpts;\n const impl: TriggerInternal & EventTriggerRef<P> = {\n type: 'event',\n ir: {\n type: 'event',\n event: ev.name,\n ...(where !== undefined ? { where: condIR(where(payloadRefs<P>())) } : {}),\n ...(opts?.filter !== undefined ? { filter: condIR(opts.filter) } : {}),\n ...(opts?.visitors === true ? { visitors: true } : {}),\n },\n payload: triggerPayloadRefs<P>(ev.name),\n };\n return impl;\n },\n enters: (seg) => makeTrigger({ type: 'segment', segment: seg.id }),\n // oxlint-disable-next-line typescript/no-deprecated -- the alias itself\n segment: (seg) => makeTrigger({ type: 'segment', segment: seg.id }),\n date: (at, opts) => {\n if (dateTimeMs(at) === undefined) {\n throw new TypeError(\n `trigger.date(): '${at}' is not a time — write it as 'YYYY-MM-DD HH:mm:ss' (UTC)`\n );\n }\n return makeTrigger({\n type: 'date',\n at,\n ...(opts?.filter !== undefined ? { filter: condIR(opts.filter) } : {}),\n });\n },\n webhook: () => makeTrigger({ type: 'webhook' }),\n};\n"],"mappings":";;;;AAsDA,MAAM,eAAe,OAA8B;CAEjD,OAAO;EADyB,MAAM,GAAG;EAAM;CACrC;AACZ;;;;;;AA4EA,MAAa,UAA0B;CACrC,QACE,IACA,aACA,cACG;EACH,MAAM,QAAQ,OAAO,gBAAgB,aAAa,cAAc,KAAA;EAChE,MAAM,OAAO,OAAO,gBAAgB,aAAa,YAAY;EAY7D,OAAO;GAVL,MAAM;GACN,IAAI;IACF,MAAM;IACN,OAAO,GAAG;IACV,GAAI,UAAU,KAAA,IAAY,EAAE,OAAO,OAAO,MAAM,YAAe,CAAC,CAAC,EAAE,IAAI,CAAC;IACxE,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,KAAK,MAAM,EAAE,IAAI,CAAC;IACpE,GAAI,MAAM,aAAa,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;GACtD;GACA,SAAS,mBAAsB,GAAG,IAAI;EAE9B;CACZ;CACA,SAAS,QAAQ,YAAY;EAAE,MAAM;EAAW,SAAS,IAAI;CAAG,CAAC;CAEjE,UAAU,QAAQ,YAAY;EAAE,MAAM;EAAW,SAAS,IAAI;CAAG,CAAC;CAClE,OAAO,IAAI,SAAS;EAClB,IAAI,WAAW,EAAE,MAAM,KAAA,GACrB,MAAM,IAAI,UACR,oBAAoB,GAAG,0DACzB;EAEF,OAAO,YAAY;GACjB,MAAM;GACN;GACA,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,KAAK,MAAM,EAAE,IAAI,CAAC;EACtE,CAAC;CACH;CACA,eAAe,YAAY,EAAE,MAAM,UAAU,CAAC;AAChD"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_hash = require("../hash.cjs");
|
|
3
|
+
const require_ir = require("../ir.cjs");
|
|
4
|
+
const require_provenance = require("../provenance.cjs");
|
|
5
|
+
const require_dsl_condition = require("./condition.cjs");
|
|
6
|
+
const require_dsl_flow = require("./flow.cjs");
|
|
7
|
+
// src/dsl/workflow.ts
|
|
8
|
+
/**
|
|
9
|
+
* Validate and compile the policy. The types already refuse a bad one; this is for a caller
|
|
10
|
+
* without them (plain JS, a value cast through `any`), so the message names what is allowed.
|
|
11
|
+
*/
|
|
12
|
+
function reentryIR(value) {
|
|
13
|
+
if (typeof value !== "object" || value === null) throw new Error("workflow(): `reentry` is required — { mode: 'never' }, { mode: 'after_exit' } or { mode: 'concurrent' }");
|
|
14
|
+
const { mode, cooldown, ...extra } = value;
|
|
15
|
+
if (mode !== "never" && mode !== "after_exit" && mode !== "concurrent") throw new Error(`workflow(): reentry.mode must be 'never', 'after_exit' or 'concurrent', got ${JSON.stringify(mode)}`);
|
|
16
|
+
const unknownKeys = Object.keys(extra);
|
|
17
|
+
if (unknownKeys.length > 0) throw new Error(`workflow(): reentry takes only \`mode\` and \`cooldown\`, got '${unknownKeys.join("', '")}'`);
|
|
18
|
+
if (mode === "never") {
|
|
19
|
+
if (cooldown !== void 0) throw new Error("workflow(): reentry { mode: 'never' } takes no cooldown — a user enters once");
|
|
20
|
+
return { mode };
|
|
21
|
+
}
|
|
22
|
+
if (cooldown === void 0) return { mode };
|
|
23
|
+
if (typeof cooldown !== "string") throw new TypeError(`workflow(): reentry.cooldown must be a duration such as '7 days', got ${JSON.stringify(cooldown)}`);
|
|
24
|
+
return {
|
|
25
|
+
mode,
|
|
26
|
+
cooldown: require_dsl_condition.positiveDurationIR(cooldown, "reentry.cooldown")
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Assign node ids from the structural path (rules in ir.ts's header). Written
|
|
31
|
+
* in place into the tree toIR deep-cloned, never into the builder's own nodes.
|
|
32
|
+
*/
|
|
33
|
+
function assignIds(nodes, prefix) {
|
|
34
|
+
nodes.forEach((node, i) => {
|
|
35
|
+
const id = prefix === "" ? String(i) : `${prefix}.${i}`;
|
|
36
|
+
node.id = id;
|
|
37
|
+
switch (node.type) {
|
|
38
|
+
case "branch":
|
|
39
|
+
node.cases.forEach((c, ci) => assignIds(c.flow, `${id}.c${ci}`));
|
|
40
|
+
if (node.otherwise) assignIds(node.otherwise, `${id}.o`);
|
|
41
|
+
break;
|
|
42
|
+
case "cohort":
|
|
43
|
+
node.arms.forEach((arm) => assignIds(arm.flow, `${id}.${arm.name}`));
|
|
44
|
+
break;
|
|
45
|
+
case "wait_until": if (Array.isArray(node.onTimeout)) assignIds(node.onTimeout, `${id}.t`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Ids are derived, never authored, so a duplicate is always a compiler bug —
|
|
51
|
+
* and a silent one: assignIds writes in place, so the second write simply wins
|
|
52
|
+
* and two nodes ship as one. What that costs is concrete, because an id is the
|
|
53
|
+
* durable step name (`step.do('{id}:send')`), the message idempotency key
|
|
54
|
+
* (`{instanceId}:{id}`) and the cohort bucket seed: the twins share a
|
|
55
|
+
* checkpoint, and the second send is suppressed as a duplicate of the first.
|
|
56
|
+
* Cheap to check once at the end of the compile, so it is checked.
|
|
57
|
+
*/
|
|
58
|
+
function assertUniqueIds(nodes, seen = /* @__PURE__ */ new Set()) {
|
|
59
|
+
for (const node of nodes) {
|
|
60
|
+
if (seen.has(node.id)) throw new Error(`toIR(): node id '${node.id}' is used twice — ids are durable step names and message idempotency keys, so they must be unique`);
|
|
61
|
+
seen.add(node.id);
|
|
62
|
+
switch (node.type) {
|
|
63
|
+
case "branch":
|
|
64
|
+
for (const branchCase of node.cases) assertUniqueIds(branchCase.flow, seen);
|
|
65
|
+
if (node.otherwise) assertUniqueIds(node.otherwise, seen);
|
|
66
|
+
break;
|
|
67
|
+
case "cohort":
|
|
68
|
+
for (const arm of node.arms) assertUniqueIds(arm.flow, seen);
|
|
69
|
+
break;
|
|
70
|
+
case "wait_until": if (Array.isArray(node.onTimeout)) assertUniqueIds(node.onTimeout, seen);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
var WorkflowBuilderImpl = class extends require_dsl_flow.FlowBuilderImpl {
|
|
75
|
+
options;
|
|
76
|
+
loc;
|
|
77
|
+
constructor(options, loc) {
|
|
78
|
+
super();
|
|
79
|
+
this.options = options;
|
|
80
|
+
this.loc = loc;
|
|
81
|
+
}
|
|
82
|
+
goalIR() {
|
|
83
|
+
const goal = this.options.goal;
|
|
84
|
+
if (goal === void 0) return void 0;
|
|
85
|
+
if ("__condition" in goal) return {
|
|
86
|
+
condition: require_dsl_condition.condIR(goal),
|
|
87
|
+
exitOnMatch: true
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
condition: require_dsl_condition.condIR(goal.condition),
|
|
91
|
+
...goal.within !== void 0 ? { within: require_dsl_condition.positiveDurationIR(goal.within, "goal.within") } : {},
|
|
92
|
+
exitOnMatch: goal.exitOnMatch ?? true
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
metaIR() {
|
|
96
|
+
const { name, description } = this.options;
|
|
97
|
+
if (name === void 0 && description === void 0 && this.loc === void 0) return;
|
|
98
|
+
return {
|
|
99
|
+
...name !== void 0 ? { name } : {},
|
|
100
|
+
...description !== void 0 ? { description } : {},
|
|
101
|
+
...this.loc !== void 0 ? { loc: this.loc } : {}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
toIR() {
|
|
105
|
+
const flowNodes = structuredClone(this.nodes);
|
|
106
|
+
assignIds(flowNodes, "");
|
|
107
|
+
assertUniqueIds(flowNodes);
|
|
108
|
+
const reentry = reentryIR(this.options.reentry);
|
|
109
|
+
const goal = this.goalIR();
|
|
110
|
+
const meta = this.metaIR();
|
|
111
|
+
const body = {
|
|
112
|
+
irVersion: 3,
|
|
113
|
+
id: this.options.id,
|
|
114
|
+
...meta !== void 0 ? { meta } : {},
|
|
115
|
+
trigger: this.options.trigger.ir,
|
|
116
|
+
reentry,
|
|
117
|
+
...goal !== void 0 ? { goal } : {},
|
|
118
|
+
...this.options.exitWhen !== void 0 ? { exitWhen: require_dsl_condition.condIR(this.options.exitWhen) } : {},
|
|
119
|
+
flow: flowNodes
|
|
120
|
+
};
|
|
121
|
+
return require_ir.WorkflowIR.parse({
|
|
122
|
+
...body,
|
|
123
|
+
contentHash: require_hash.semanticHash(body)
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Workflow definition: an id, configuration (trigger / reentry / goal / exitWhen),
|
|
129
|
+
* optional labels, and chained steps.
|
|
130
|
+
*
|
|
131
|
+
* export const onboarding = workflow({
|
|
132
|
+
* id: 'onboarding',
|
|
133
|
+
* name: 'Onboarding',
|
|
134
|
+
* trigger: trigger.event(e.sign_up),
|
|
135
|
+
* reentry: { mode: 'never' },
|
|
136
|
+
* }).email(email.welcome);
|
|
137
|
+
*/
|
|
138
|
+
function workflow(definition) {
|
|
139
|
+
return new WorkflowBuilderImpl(definition, require_provenance.captureLoc(workflow));
|
|
140
|
+
}
|
|
141
|
+
exports.workflow = workflow;
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=workflow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.cjs","names":["positiveDurationIR","FlowBuilderImpl","condIR","WorkflowIRSchema","semanticHash","captureLoc"],"sources":["../../src/dsl/workflow.ts"],"sourcesContent":["import { semanticHash } from '../hash';\nimport {\n type GoalIR,\n IR_VERSION,\n type MetaIR,\n type NodeIR,\n type ReentryIR,\n type SourceLocIR,\n type WorkflowIR,\n WorkflowIR as WorkflowIRSchema,\n} from '../ir';\nimport { captureLoc } from '../provenance';\nimport type { Duration } from './base';\nimport { type Condition, condIR, positiveDurationIR } from './condition';\nimport { type FlowBuilder, FlowBuilderImpl } from './flow';\nimport type { TriggerInternal, TriggerRef } from './trigger';\n\n/**\n * The workflow — a named flow chain plus its configuration (options =\n * configuration, the chain = steps), and the compiler back half: `toIR()`\n * deep-clones the collected nodes, assigns structural-path ids, computes the\n * contentHash (metadata stripped, see hash.ts) and self-checks the result\n * against the authoritative IR schema.\n */\n\n/** Full conversion-goal configuration (customer.io's Goal & Exit semantics). */\nexport interface GoalOptions {\n condition: Condition;\n /** Attribution window: how long after entry a match still counts as a conversion. Unbounded by default. */\n within?: Duration;\n /** Exit on conversion. Defaults to true — this is what absorbs all those True→Exit arms in a UI canvas. */\n exitOnMatch?: boolean;\n}\n\n/**\n * Re-entry policy: whether a user who already entered this workflow may enter it again (README\n * \"Re-entry\"). Required, with no default, and written one way only — an object naming its `mode`:\n *\n * - `{ mode: 'never' }` — a user enters once (onboarding).\n * - `{ mode: 'after_exit' }` — again, but only once their previous instance of this workflow has\n * ended (completed, converted, exited or failed): at most one runs per user at a time.\n * - `{ mode: 'concurrent' }` — again even while a previous instance still runs.\n *\n * `cooldown` (positive) is the least time from the user's previous entry — not its exit — to the\n * next one; with `after_exit` both conditions must hold. `never` takes no cooldown. A\n * segment-triggered workflow re-enters a user only when they qualify afresh (left the segment and\n * matched again), never on every evaluation while they stay a member.\n *\n * workflow({ id: 'checkout_recovery', trigger, reentry: { mode: 'after_exit', cooldown: '7 days' } })\n */\nexport type Reentry =\n | { mode: 'never' }\n | { mode: 'after_exit'; cooldown?: Duration }\n | { mode: 'concurrent'; cooldown?: Duration };\n\n/**\n * Validate and compile the policy. The types already refuse a bad one; this is for a caller\n * without them (plain JS, a value cast through `any`), so the message names what is allowed.\n */\nfunction reentryIR(value: unknown): ReentryIR {\n if (typeof value !== 'object' || value === null) {\n throw new Error(\n \"workflow(): `reentry` is required — { mode: 'never' }, { mode: 'after_exit' } or { mode: 'concurrent' }\"\n );\n }\n const { mode, cooldown, ...extra } = value as { mode?: unknown; cooldown?: unknown };\n if (mode !== 'never' && mode !== 'after_exit' && mode !== 'concurrent') {\n throw new Error(\n `workflow(): reentry.mode must be 'never', 'after_exit' or 'concurrent', got ${JSON.stringify(mode)}`\n );\n }\n const unknownKeys = Object.keys(extra);\n if (unknownKeys.length > 0) {\n throw new Error(\n `workflow(): reentry takes only \\`mode\\` and \\`cooldown\\`, got '${unknownKeys.join(\"', '\")}'`\n );\n }\n if (mode === 'never') {\n if (cooldown !== undefined) {\n throw new Error(\n \"workflow(): reentry { mode: 'never' } takes no cooldown — a user enters once\"\n );\n }\n return { mode };\n }\n if (cooldown === undefined) return { mode };\n if (typeof cooldown !== 'string') {\n throw new TypeError(\n `workflow(): reentry.cooldown must be a duration such as '7 days', got ${JSON.stringify(cooldown)}`\n );\n }\n return { mode, cooldown: positiveDurationIR(cooldown as Duration, 'reentry.cooldown') };\n}\n\nexport interface WorkflowDefinition {\n /**\n * Wire identity — engine instances, the entry ledger and stats keys are all\n * built on it (`WorkflowIR.id`), so it is not something to rename for\n * readability; `name` is.\n */\n id: string;\n\n /** Trigger: a trigger.xxx() asset. TODO: multiple triggers. */\n trigger: TriggerRef;\n\n /**\n * Re-entry policy, required: whether a user may enter again after their first entry\n * (`Reentry`). There is no default, so a recurring workflow cannot silently enter users once.\n */\n reentry: Reentry;\n\n /**\n * Conversion goal: feeds reporting (conversion rate / attribution) and by\n * default exits on match. Checked before each node runs. Pass a condition\n * for the shorthand, or GoalOptions for the full form.\n */\n goal?: Condition | GoalOptions;\n\n /** Plain exit condition: leaving without counting as a conversion (unsubscribed, no longer eligible). Coexists with goal. */\n exitWhen?: Condition;\n\n /*\n * Everything below is human-facing metadata: it lands in IR's `meta` field\n * and is **excluded from contentHash**. Editing it neither invalidates the\n * version in-flight users are pinned to nor shows up as a change in plan.\n */\n\n /** Human label: what the studio shows instead of the id. */\n name?: string;\n\n /** One line on what this flow does (UI lists, plan output). */\n description?: string;\n}\n\nexport interface WorkflowBuilder extends FlowBuilder {\n toIR(): WorkflowIR;\n}\n\n/**\n * Assign node ids from the structural path (rules in ir.ts's header). Written\n * in place into the tree toIR deep-cloned, never into the builder's own nodes.\n */\nfunction assignIds(nodes: NodeIR[], prefix: string): void {\n nodes.forEach((node, i) => {\n const id = prefix === '' ? String(i) : `${prefix}.${i}`;\n node.id = id;\n switch (node.type) {\n case 'branch':\n node.cases.forEach((c, ci) => assignIds(c.flow, `${id}.c${ci}`));\n if (node.otherwise) assignIds(node.otherwise, `${id}.o`);\n break;\n case 'cohort':\n node.arms.forEach((arm) => assignIds(arm.flow, `${id}.${arm.name}`));\n break;\n case 'wait_until':\n if (Array.isArray(node.onTimeout)) assignIds(node.onTimeout, `${id}.t`);\n break;\n default:\n break;\n }\n });\n}\n\n/**\n * Ids are derived, never authored, so a duplicate is always a compiler bug —\n * and a silent one: assignIds writes in place, so the second write simply wins\n * and two nodes ship as one. What that costs is concrete, because an id is the\n * durable step name (`step.do('{id}:send')`), the message idempotency key\n * (`{instanceId}:{id}`) and the cohort bucket seed: the twins share a\n * checkpoint, and the second send is suppressed as a duplicate of the first.\n * Cheap to check once at the end of the compile, so it is checked.\n */\nfunction assertUniqueIds(nodes: readonly NodeIR[], seen = new Set<string>()): void {\n for (const node of nodes) {\n if (seen.has(node.id)) {\n throw new Error(\n `toIR(): node id '${node.id}' is used twice — ids are durable step names and message idempotency keys, so they must be unique`\n );\n }\n seen.add(node.id);\n switch (node.type) {\n case 'branch':\n for (const branchCase of node.cases) assertUniqueIds(branchCase.flow, seen);\n if (node.otherwise) assertUniqueIds(node.otherwise, seen);\n break;\n case 'cohort':\n for (const arm of node.arms) assertUniqueIds(arm.flow, seen);\n break;\n case 'wait_until':\n if (Array.isArray(node.onTimeout)) assertUniqueIds(node.onTimeout, seen);\n break;\n default:\n break;\n }\n }\n}\n\nclass WorkflowBuilderImpl extends FlowBuilderImpl implements WorkflowBuilder {\n constructor(\n private readonly options: WorkflowDefinition,\n /** Callsite of the workflow() call (provenance; lands in meta.loc). */\n private readonly loc: SourceLocIR | undefined\n ) {\n super();\n }\n\n private goalIR(): GoalIR | undefined {\n const goal = this.options.goal;\n if (goal === undefined) return undefined;\n if ('__condition' in goal) {\n return { condition: condIR(goal), exitOnMatch: true };\n }\n return {\n condition: condIR(goal.condition),\n ...(goal.within !== undefined\n ? { within: positiveDurationIR(goal.within, 'goal.within') }\n : {}),\n exitOnMatch: goal.exitOnMatch ?? true,\n };\n }\n\n private metaIR(): MetaIR | undefined {\n const { name, description } = this.options;\n if (name === undefined && description === undefined && this.loc === undefined) {\n return undefined;\n }\n return {\n ...(name !== undefined ? { name } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(this.loc !== undefined ? { loc: this.loc } : {}),\n };\n }\n\n toIR(): WorkflowIR {\n const flowNodes = structuredClone(this.nodes);\n assignIds(flowNodes, '');\n assertUniqueIds(flowNodes);\n const reentry = reentryIR(this.options.reentry);\n const goal = this.goalIR();\n const meta = this.metaIR();\n const body = {\n irVersion: IR_VERSION,\n id: this.options.id,\n ...(meta !== undefined ? { meta } : {}),\n trigger: (this.options.trigger as TriggerInternal).ir,\n reentry,\n ...(goal !== undefined ? { goal } : {}),\n ...(this.options.exitWhen !== undefined ? { exitWhen: condIR(this.options.exitWhen) } : {}),\n flow: flowNodes,\n };\n // semanticHash strips meta / label / reason, so metadata edits leave contentHash alone\n // Self-check: the compiler's output must pass IR's authoritative schema\n return WorkflowIRSchema.parse({ ...body, contentHash: semanticHash(body) });\n }\n}\n\n/**\n * Workflow definition: an id, configuration (trigger / reentry / goal / exitWhen),\n * optional labels, and chained steps.\n *\n * export const onboarding = workflow({\n * id: 'onboarding',\n * name: 'Onboarding',\n * trigger: trigger.event(e.sign_up),\n * reentry: { mode: 'never' },\n * }).email(email.welcome);\n */\nexport function workflow(definition: WorkflowDefinition): WorkflowBuilder {\n return new WorkflowBuilderImpl(definition, captureLoc(workflow));\n}\n"],"mappings":";;;;;;;;;;;AA2DA,SAAS,UAAU,OAA2B;CAC5C,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,MAAM,IAAI,MACR,yGACF;CAEF,MAAM,EAAE,MAAM,UAAU,GAAG,UAAU;CACrC,IAAI,SAAS,WAAW,SAAS,gBAAgB,SAAS,cACxD,MAAM,IAAI,MACR,+EAA+E,KAAK,UAAU,IAAI,GACpG;CAEF,MAAM,cAAc,OAAO,KAAK,KAAK;CACrC,IAAI,YAAY,SAAS,GACvB,MAAM,IAAI,MACR,kEAAkE,YAAY,KAAK,MAAM,EAAE,EAC7F;CAEF,IAAI,SAAS,SAAS;EACpB,IAAI,aAAa,KAAA,GACf,MAAM,IAAI,MACR,8EACF;EAEF,OAAO,EAAE,KAAK;CAChB;CACA,IAAI,aAAa,KAAA,GAAW,OAAO,EAAE,KAAK;CAC1C,IAAI,OAAO,aAAa,UACtB,MAAM,IAAI,UACR,yEAAyE,KAAK,UAAU,QAAQ,GAClG;CAEF,OAAO;EAAE;EAAM,UAAUA,sBAAAA,mBAAmB,UAAsB,kBAAkB;CAAE;AACxF;;;;;AAkDA,SAAS,UAAU,OAAiB,QAAsB;CACxD,MAAM,SAAS,MAAM,MAAM;EACzB,MAAM,KAAK,WAAW,KAAK,OAAO,CAAC,IAAI,GAAG,OAAO,GAAG;EACpD,KAAK,KAAK;EACV,QAAQ,KAAK,MAAb;GACE,KAAK;IACH,KAAK,MAAM,SAAS,GAAG,OAAO,UAAU,EAAE,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC;IAC/D,IAAI,KAAK,WAAW,UAAU,KAAK,WAAW,GAAG,GAAG,GAAG;IACvD;GACF,KAAK;IACH,KAAK,KAAK,SAAS,QAAQ,UAAU,IAAI,MAAM,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC;IACnE;GACF,KAAK,cACH,IAAI,MAAM,QAAQ,KAAK,SAAS,GAAG,UAAU,KAAK,WAAW,GAAG,GAAG,GAAG;EAI1E;CACF,CAAC;AACH;;;;;;;;;;AAWA,SAAS,gBAAgB,OAA0B,uBAAO,IAAI,IAAY,GAAS;CACjF,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,IAAI,KAAK,EAAE,GAClB,MAAM,IAAI,MACR,oBAAoB,KAAK,GAAG,kGAC9B;EAEF,KAAK,IAAI,KAAK,EAAE;EAChB,QAAQ,KAAK,MAAb;GACE,KAAK;IACH,KAAK,MAAM,cAAc,KAAK,OAAO,gBAAgB,WAAW,MAAM,IAAI;IAC1E,IAAI,KAAK,WAAW,gBAAgB,KAAK,WAAW,IAAI;IACxD;GACF,KAAK;IACH,KAAK,MAAM,OAAO,KAAK,MAAM,gBAAgB,IAAI,MAAM,IAAI;IAC3D;GACF,KAAK,cACH,IAAI,MAAM,QAAQ,KAAK,SAAS,GAAG,gBAAgB,KAAK,WAAW,IAAI;EAI3E;CACF;AACF;AAEA,IAAM,sBAAN,cAAkCC,iBAAAA,gBAA2C;CAExD;CAEA;CAHnB,YACmB,SAEA,KACjB;EACA,MAAM;EAJW,KAAA,UAAA;EAEA,KAAA,MAAA;CAGnB;CAEQ,SAA6B;EACnC,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;EAC/B,IAAI,iBAAiB,MACnB,OAAO;GAAE,WAAWC,sBAAAA,OAAO,IAAI;GAAG,aAAa;EAAK;EAEtD,OAAO;GACL,WAAWA,sBAAAA,OAAO,KAAK,SAAS;GAChC,GAAI,KAAK,WAAW,KAAA,IAChB,EAAE,QAAQF,sBAAAA,mBAAmB,KAAK,QAAQ,aAAa,EAAE,IACzD,CAAC;GACL,aAAa,KAAK,eAAe;EACnC;CACF;CAEQ,SAA6B;EACnC,MAAM,EAAE,MAAM,gBAAgB,KAAK;EACnC,IAAI,SAAS,KAAA,KAAa,gBAAgB,KAAA,KAAa,KAAK,QAAQ,KAAA,GAClE;EAEF,OAAO;GACL,GAAI,SAAS,KAAA,IAAY,EAAE,KAAK,IAAI,CAAC;GACrC,GAAI,gBAAgB,KAAA,IAAY,EAAE,YAAY,IAAI,CAAC;GACnD,GAAI,KAAK,QAAQ,KAAA,IAAY,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;EACpD;CACF;CAEA,OAAmB;EACjB,MAAM,YAAY,gBAAgB,KAAK,KAAK;EAC5C,UAAU,WAAW,EAAE;EACvB,gBAAgB,SAAS;EACzB,MAAM,UAAU,UAAU,KAAK,QAAQ,OAAO;EAC9C,MAAM,OAAO,KAAK,OAAO;EACzB,MAAM,OAAO,KAAK,OAAO;EACzB,MAAM,OAAO;GACX,WAAA;GACA,IAAI,KAAK,QAAQ;GACjB,GAAI,SAAS,KAAA,IAAY,EAAE,KAAK,IAAI,CAAC;GACrC,SAAU,KAAK,QAAQ,QAA4B;GACnD;GACA,GAAI,SAAS,KAAA,IAAY,EAAE,KAAK,IAAI,CAAC;GACrC,GAAI,KAAK,QAAQ,aAAa,KAAA,IAAY,EAAE,UAAUE,sBAAAA,OAAO,KAAK,QAAQ,QAAQ,EAAE,IAAI,CAAC;GACzF,MAAM;EACR;EAGA,OAAOC,WAAAA,WAAiB,MAAM;GAAE,GAAG;GAAM,aAAaC,aAAAA,aAAa,IAAI;EAAE,CAAC;CAC5E;AACF;;;;;;;;;;;;AAaA,SAAgB,SAAS,YAAiD;CACxE,OAAO,IAAI,oBAAoB,YAAYC,mBAAAA,WAAW,QAAQ,CAAC;AACjE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { WorkflowIR } from "../ir.cjs";
|
|
2
|
+
import { Duration } from "./base.cjs";
|
|
3
|
+
import { Condition } from "./condition.cjs";
|
|
4
|
+
import { FlowBuilder } from "./flow.cjs";
|
|
5
|
+
import { TriggerRef } from "./trigger.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* The workflow — a named flow chain plus its configuration (options =
|
|
8
|
+
* configuration, the chain = steps), and the compiler back half: `toIR()`
|
|
9
|
+
* deep-clones the collected nodes, assigns structural-path ids, computes the
|
|
10
|
+
* contentHash (metadata stripped, see hash.ts) and self-checks the result
|
|
11
|
+
* against the authoritative IR schema.
|
|
12
|
+
*/
|
|
13
|
+
/** Full conversion-goal configuration (customer.io's Goal & Exit semantics). */
|
|
14
|
+
export interface GoalOptions {
|
|
15
|
+
condition: Condition;
|
|
16
|
+
/** Attribution window: how long after entry a match still counts as a conversion. Unbounded by default. */
|
|
17
|
+
within?: Duration;
|
|
18
|
+
/** Exit on conversion. Defaults to true — this is what absorbs all those True→Exit arms in a UI canvas. */
|
|
19
|
+
exitOnMatch?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Re-entry policy: whether a user who already entered this workflow may enter it again (README
|
|
23
|
+
* "Re-entry"). Required, with no default, and written one way only — an object naming its `mode`:
|
|
24
|
+
*
|
|
25
|
+
* - `{ mode: 'never' }` — a user enters once (onboarding).
|
|
26
|
+
* - `{ mode: 'after_exit' }` — again, but only once their previous instance of this workflow has
|
|
27
|
+
* ended (completed, converted, exited or failed): at most one runs per user at a time.
|
|
28
|
+
* - `{ mode: 'concurrent' }` — again even while a previous instance still runs.
|
|
29
|
+
*
|
|
30
|
+
* `cooldown` (positive) is the least time from the user's previous entry — not its exit — to the
|
|
31
|
+
* next one; with `after_exit` both conditions must hold. `never` takes no cooldown. A
|
|
32
|
+
* segment-triggered workflow re-enters a user only when they qualify afresh (left the segment and
|
|
33
|
+
* matched again), never on every evaluation while they stay a member.
|
|
34
|
+
*
|
|
35
|
+
* workflow({ id: 'checkout_recovery', trigger, reentry: { mode: 'after_exit', cooldown: '7 days' } })
|
|
36
|
+
*/
|
|
37
|
+
export type Reentry = {
|
|
38
|
+
mode: 'never';
|
|
39
|
+
} | {
|
|
40
|
+
mode: 'after_exit';
|
|
41
|
+
cooldown?: Duration;
|
|
42
|
+
} | {
|
|
43
|
+
mode: 'concurrent';
|
|
44
|
+
cooldown?: Duration;
|
|
45
|
+
};
|
|
46
|
+
export interface WorkflowDefinition {
|
|
47
|
+
/**
|
|
48
|
+
* Wire identity — engine instances, the entry ledger and stats keys are all
|
|
49
|
+
* built on it (`WorkflowIR.id`), so it is not something to rename for
|
|
50
|
+
* readability; `name` is.
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
/** Trigger: a trigger.xxx() asset. TODO: multiple triggers. */
|
|
54
|
+
trigger: TriggerRef;
|
|
55
|
+
/**
|
|
56
|
+
* Re-entry policy, required: whether a user may enter again after their first entry
|
|
57
|
+
* (`Reentry`). There is no default, so a recurring workflow cannot silently enter users once.
|
|
58
|
+
*/
|
|
59
|
+
reentry: Reentry;
|
|
60
|
+
/**
|
|
61
|
+
* Conversion goal: feeds reporting (conversion rate / attribution) and by
|
|
62
|
+
* default exits on match. Checked before each node runs. Pass a condition
|
|
63
|
+
* for the shorthand, or GoalOptions for the full form.
|
|
64
|
+
*/
|
|
65
|
+
goal?: Condition | GoalOptions;
|
|
66
|
+
/** Plain exit condition: leaving without counting as a conversion (unsubscribed, no longer eligible). Coexists with goal. */
|
|
67
|
+
exitWhen?: Condition;
|
|
68
|
+
/** Human label: what the studio shows instead of the id. */
|
|
69
|
+
name?: string;
|
|
70
|
+
/** One line on what this flow does (UI lists, plan output). */
|
|
71
|
+
description?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface WorkflowBuilder extends FlowBuilder {
|
|
74
|
+
toIR(): WorkflowIR;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Workflow definition: an id, configuration (trigger / reentry / goal / exitWhen),
|
|
78
|
+
* optional labels, and chained steps.
|
|
79
|
+
*
|
|
80
|
+
* export const onboarding = workflow({
|
|
81
|
+
* id: 'onboarding',
|
|
82
|
+
* name: 'Onboarding',
|
|
83
|
+
* trigger: trigger.event(e.sign_up),
|
|
84
|
+
* reentry: { mode: 'never' },
|
|
85
|
+
* }).email(email.welcome);
|
|
86
|
+
*/
|
|
87
|
+
export declare function workflow(definition: WorkflowDefinition): WorkflowBuilder;
|
|
88
|
+
//# sourceMappingURL=workflow.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.cts","names":[],"sources":["../../src/dsl/workflow.ts"],"mappings":";;;;;;;;;;;;;iBA0BiB;EACf,WAAW;;EAEX,SAAS;;EAET;;;;;;;;;;;;;;;;;;YAmBU;EACN;;EACA;EAAoB,WAAW;;EAC/B;EAAoB,WAAW;;iBAyCpB;;;;;;EAMf;;EAGA,SAAS;;;;;EAMT,SAAS;;;;;;EAOT,OAAO,YAAY;;EAGnB,WAAW;;EASX;;EAGA;;iBAGe,wBAAwB;EACvC,QAAQ;;;;;;;;;;;;;wBAoIM,SAAS,YAAY,qBAAqB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { WorkflowIR } from "../ir.mjs";
|
|
2
|
+
import { Duration } from "./base.mjs";
|
|
3
|
+
import { Condition } from "./condition.mjs";
|
|
4
|
+
import { FlowBuilder } from "./flow.mjs";
|
|
5
|
+
import { TriggerRef } from "./trigger.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* The workflow — a named flow chain plus its configuration (options =
|
|
8
|
+
* configuration, the chain = steps), and the compiler back half: `toIR()`
|
|
9
|
+
* deep-clones the collected nodes, assigns structural-path ids, computes the
|
|
10
|
+
* contentHash (metadata stripped, see hash.ts) and self-checks the result
|
|
11
|
+
* against the authoritative IR schema.
|
|
12
|
+
*/
|
|
13
|
+
/** Full conversion-goal configuration (customer.io's Goal & Exit semantics). */
|
|
14
|
+
export interface GoalOptions {
|
|
15
|
+
condition: Condition;
|
|
16
|
+
/** Attribution window: how long after entry a match still counts as a conversion. Unbounded by default. */
|
|
17
|
+
within?: Duration;
|
|
18
|
+
/** Exit on conversion. Defaults to true — this is what absorbs all those True→Exit arms in a UI canvas. */
|
|
19
|
+
exitOnMatch?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Re-entry policy: whether a user who already entered this workflow may enter it again (README
|
|
23
|
+
* "Re-entry"). Required, with no default, and written one way only — an object naming its `mode`:
|
|
24
|
+
*
|
|
25
|
+
* - `{ mode: 'never' }` — a user enters once (onboarding).
|
|
26
|
+
* - `{ mode: 'after_exit' }` — again, but only once their previous instance of this workflow has
|
|
27
|
+
* ended (completed, converted, exited or failed): at most one runs per user at a time.
|
|
28
|
+
* - `{ mode: 'concurrent' }` — again even while a previous instance still runs.
|
|
29
|
+
*
|
|
30
|
+
* `cooldown` (positive) is the least time from the user's previous entry — not its exit — to the
|
|
31
|
+
* next one; with `after_exit` both conditions must hold. `never` takes no cooldown. A
|
|
32
|
+
* segment-triggered workflow re-enters a user only when they qualify afresh (left the segment and
|
|
33
|
+
* matched again), never on every evaluation while they stay a member.
|
|
34
|
+
*
|
|
35
|
+
* workflow({ id: 'checkout_recovery', trigger, reentry: { mode: 'after_exit', cooldown: '7 days' } })
|
|
36
|
+
*/
|
|
37
|
+
export type Reentry = {
|
|
38
|
+
mode: 'never';
|
|
39
|
+
} | {
|
|
40
|
+
mode: 'after_exit';
|
|
41
|
+
cooldown?: Duration;
|
|
42
|
+
} | {
|
|
43
|
+
mode: 'concurrent';
|
|
44
|
+
cooldown?: Duration;
|
|
45
|
+
};
|
|
46
|
+
export interface WorkflowDefinition {
|
|
47
|
+
/**
|
|
48
|
+
* Wire identity — engine instances, the entry ledger and stats keys are all
|
|
49
|
+
* built on it (`WorkflowIR.id`), so it is not something to rename for
|
|
50
|
+
* readability; `name` is.
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
/** Trigger: a trigger.xxx() asset. TODO: multiple triggers. */
|
|
54
|
+
trigger: TriggerRef;
|
|
55
|
+
/**
|
|
56
|
+
* Re-entry policy, required: whether a user may enter again after their first entry
|
|
57
|
+
* (`Reentry`). There is no default, so a recurring workflow cannot silently enter users once.
|
|
58
|
+
*/
|
|
59
|
+
reentry: Reentry;
|
|
60
|
+
/**
|
|
61
|
+
* Conversion goal: feeds reporting (conversion rate / attribution) and by
|
|
62
|
+
* default exits on match. Checked before each node runs. Pass a condition
|
|
63
|
+
* for the shorthand, or GoalOptions for the full form.
|
|
64
|
+
*/
|
|
65
|
+
goal?: Condition | GoalOptions;
|
|
66
|
+
/** Plain exit condition: leaving without counting as a conversion (unsubscribed, no longer eligible). Coexists with goal. */
|
|
67
|
+
exitWhen?: Condition;
|
|
68
|
+
/** Human label: what the studio shows instead of the id. */
|
|
69
|
+
name?: string;
|
|
70
|
+
/** One line on what this flow does (UI lists, plan output). */
|
|
71
|
+
description?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface WorkflowBuilder extends FlowBuilder {
|
|
74
|
+
toIR(): WorkflowIR;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Workflow definition: an id, configuration (trigger / reentry / goal / exitWhen),
|
|
78
|
+
* optional labels, and chained steps.
|
|
79
|
+
*
|
|
80
|
+
* export const onboarding = workflow({
|
|
81
|
+
* id: 'onboarding',
|
|
82
|
+
* name: 'Onboarding',
|
|
83
|
+
* trigger: trigger.event(e.sign_up),
|
|
84
|
+
* reentry: { mode: 'never' },
|
|
85
|
+
* }).email(email.welcome);
|
|
86
|
+
*/
|
|
87
|
+
export declare function workflow(definition: WorkflowDefinition): WorkflowBuilder;
|
|
88
|
+
//# sourceMappingURL=workflow.d.mts.map
|