sendwend 0.0.0-stage → 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 +21 -0
- package/README.md +2082 -2
- 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 +279 -3
- package/src/cloudflare/workers.d.ts +44 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_engine_bucket = require("./bucket.cjs");
|
|
3
|
+
const require_engine_condition = require("./condition.cjs");
|
|
4
|
+
const require_engine_recipient = require("./recipient.cjs");
|
|
5
|
+
const require_engine_retry = require("./retry.cjs");
|
|
6
|
+
const require_engine_time_window = require("./time-window.cjs");
|
|
7
|
+
// src/engine/interpreter.ts
|
|
8
|
+
/**
|
|
9
|
+
* IR interpreter: the execution core for one user's journey instance.
|
|
10
|
+
*
|
|
11
|
+
* Pure logic — it imports nothing platform-specific; every external effect
|
|
12
|
+
* arrives through the JourneyContext ports, and durable semantics
|
|
13
|
+
* (checkpoint/replay) are the EngineStep adapter's job.
|
|
14
|
+
*
|
|
15
|
+
* Step naming: an IR node id *is* the step name (derived from the structural
|
|
16
|
+
* path, so it is deterministic and unique). When one node needs several steps,
|
|
17
|
+
* a suffix is appended (`${id}:guard`, `${id}:check:${n}`).
|
|
18
|
+
*
|
|
19
|
+
* Guard semantics: goal / exitWhen are checked at journey entry and after
|
|
20
|
+
* every suspension point (delay / random_delay / time_window / wait_until) —
|
|
21
|
+
* the moments where wall-clock time passed and the user's state may have
|
|
22
|
+
* moved. Between two synchronous nodes no meaningful time passes, so checking
|
|
23
|
+
* there would only burn step budget (each checkpoint costs a state write).
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Cap on wait_until re-evaluations, so a wake-up storm cannot exhaust the platform's step
|
|
27
|
+
* budget. Each loop iteration costs a handful of steps, so 64 checks stay well inside the
|
|
28
|
+
* platform step budgets while absorbing far more wake churn than 16 did. Past the cap the wait
|
|
29
|
+
* is not given up: it sleeps to its deadline and checks once more there (see waitLoop) — the
|
|
30
|
+
* answer is still right at the deadline, it just stops being event-driven in between.
|
|
31
|
+
*/
|
|
32
|
+
const MAX_WAIT_CHECKS = 64;
|
|
33
|
+
/**
|
|
34
|
+
* The user property holding an IANA zone id, read when a time_window says tz: 'user'. Snake case,
|
|
35
|
+
* like the analytics `time_zone` tag a host fills it from. Same convention-table status as
|
|
36
|
+
* RECIPIENT_PROPERTY.
|
|
37
|
+
*/
|
|
38
|
+
const TIMEZONE_PROPERTY = "time_zone";
|
|
39
|
+
const FALL_THROUGH = { kind: "fall_through" };
|
|
40
|
+
/** Who a message or report is about now: a journey started by a visitor moves when they sign in. */
|
|
41
|
+
function ownerOf(ctx) {
|
|
42
|
+
return ctx.currentUserId?.() ?? Promise.resolve(ctx.userId);
|
|
43
|
+
}
|
|
44
|
+
const goalStates = /* @__PURE__ */ new WeakMap();
|
|
45
|
+
function goalState(ctx) {
|
|
46
|
+
let state = goalStates.get(ctx);
|
|
47
|
+
if (state === void 0) {
|
|
48
|
+
state = {};
|
|
49
|
+
goalStates.set(ctx, state);
|
|
50
|
+
}
|
|
51
|
+
return state;
|
|
52
|
+
}
|
|
53
|
+
/** When the goal's attribution window closes, measured from entry; none without `within`. */
|
|
54
|
+
function goalDeadline(ir, ctx) {
|
|
55
|
+
return ir.goal?.within === void 0 ? void 0 : ctx.enteredAtMs + ir.goal.within.ms;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether the goal holds for events inside its window: after entry, and not after the window
|
|
59
|
+
* closed — an instance resumed past the deadline must not count a purchase made after it. The
|
|
60
|
+
* conversion time is when the check saw it, capped at the deadline.
|
|
61
|
+
*/
|
|
62
|
+
async function goalReached(ir, ctx, now) {
|
|
63
|
+
const goal = ir.goal;
|
|
64
|
+
if (goal === void 0) return null;
|
|
65
|
+
const deadline = goalDeadline(ir, ctx);
|
|
66
|
+
return await holds(goal.condition, ctx, now, {
|
|
67
|
+
anchorMs: ctx.enteredAtMs,
|
|
68
|
+
...ctx.trigger === void 0 ? {} : { after: {
|
|
69
|
+
event: ctx.trigger.event,
|
|
70
|
+
ms: ctx.trigger.ts
|
|
71
|
+
} },
|
|
72
|
+
...deadline === void 0 ? {} : { untilMs: deadline }
|
|
73
|
+
}) ? { at: deadline === void 0 ? now : Math.min(now, deadline) } : null;
|
|
74
|
+
}
|
|
75
|
+
async function runJourney(ir, ctx) {
|
|
76
|
+
await started(ir, ctx);
|
|
77
|
+
let signal = await checkGuards("entry", ir, ctx) ?? await runFlow(ir.flow, ir, ctx);
|
|
78
|
+
if (signal.kind === "fall_through") signal = await awaitTail(ir, ctx) ?? FALL_THROUGH;
|
|
79
|
+
const { convertedAt } = goalState(ctx);
|
|
80
|
+
const converted = convertedAt === void 0 ? {} : { convertedAt };
|
|
81
|
+
switch (signal.kind) {
|
|
82
|
+
case "fall_through": return {
|
|
83
|
+
status: "completed",
|
|
84
|
+
...converted
|
|
85
|
+
};
|
|
86
|
+
case "exit": return signal.reason !== void 0 ? {
|
|
87
|
+
status: "exited",
|
|
88
|
+
reason: signal.reason,
|
|
89
|
+
...converted
|
|
90
|
+
} : {
|
|
91
|
+
status: "exited",
|
|
92
|
+
...converted
|
|
93
|
+
};
|
|
94
|
+
case "goal": return {
|
|
95
|
+
status: "goal",
|
|
96
|
+
...converted
|
|
97
|
+
};
|
|
98
|
+
case "exit_when": return {
|
|
99
|
+
status: "exit_when",
|
|
100
|
+
...converted
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function runFlow(nodes, ir, ctx) {
|
|
105
|
+
for (const node of nodes) {
|
|
106
|
+
await reached(node, ir, ctx);
|
|
107
|
+
const signal = await runNode(node, ir, ctx);
|
|
108
|
+
if (signal.kind !== "fall_through") return signal;
|
|
109
|
+
}
|
|
110
|
+
return FALL_THROUGH;
|
|
111
|
+
}
|
|
112
|
+
/** The engine's own reports: the same over again, and nothing the journey's path depends on. */
|
|
113
|
+
const BOOKKEEPING = { idempotent: true };
|
|
114
|
+
/**
|
|
115
|
+
* Tell the observer the instance entered — before the entry guards, which can end it before the
|
|
116
|
+
* first node: an instance is counted from its entry, not from its first node.
|
|
117
|
+
*/
|
|
118
|
+
async function started(ir, ctx) {
|
|
119
|
+
const observer = ctx.observer;
|
|
120
|
+
if (observer?.started === void 0) return;
|
|
121
|
+
await ctx.step.do("entry:started", async () => {
|
|
122
|
+
await observer.started?.({
|
|
123
|
+
workflow: ir.id,
|
|
124
|
+
instanceId: ctx.instanceId,
|
|
125
|
+
userId: await ownerOf(ctx),
|
|
126
|
+
at: ctx.enteredAtMs
|
|
127
|
+
});
|
|
128
|
+
}, BOOKKEEPING);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Tell the observer the instance is at `node`. A step of its own, so a replay does not report
|
|
132
|
+
* the nodes it passes on the way back again, and the arrival time stays the first one.
|
|
133
|
+
*/
|
|
134
|
+
async function reached(node, ir, ctx) {
|
|
135
|
+
const observer = ctx.observer;
|
|
136
|
+
if (observer?.nodeReached === void 0) return;
|
|
137
|
+
await ctx.step.do(`${node.id}:reached`, async () => {
|
|
138
|
+
await observer.nodeReached?.({
|
|
139
|
+
workflow: ir.id,
|
|
140
|
+
instanceId: ctx.instanceId,
|
|
141
|
+
userId: await ownerOf(ctx),
|
|
142
|
+
nodeId: node.id,
|
|
143
|
+
at: Date.now()
|
|
144
|
+
});
|
|
145
|
+
}, BOOKKEEPING);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* One copy out through the host's sender, with the observer around it: settled? → prepared
|
|
149
|
+
* (the row, the tracking) → claimed (handed to the transport, committed before the send) →
|
|
150
|
+
* send → sent.
|
|
151
|
+
*
|
|
152
|
+
* Delivery is at most once. A send that throws is a definite failure — the provider answered
|
|
153
|
+
* with a refusal, or the sender never got as far as asking. What happens next depends on whether
|
|
154
|
+
* another attempt could go differently:
|
|
155
|
+
*
|
|
156
|
+
* - it could (a 429, a 5xx, a token that expired): the claim is released, the step retries, and
|
|
157
|
+
* the copy is reported when it settles. So it is for the engine's own refusals raised inside a
|
|
158
|
+
* sender (a template refusing its props or content, an erased user), which no retry fixes: the
|
|
159
|
+
* claim is released and the step fails, because that is the workflow, not the recipient;
|
|
160
|
+
* - it could not (`isRefusedSend`: a `PermanentError`, a transport's `retryable: false` — the
|
|
161
|
+
* provider refused this token, this address or this payload, or the channel is not
|
|
162
|
+
* configured): the copy settles
|
|
163
|
+
* undelivered under the refusal's reason and the journey goes on. One device, one address or
|
|
164
|
+
* one misconfigured channel does not end the journey for the user — the copies to their other
|
|
165
|
+
* devices and the steps after this one still run, and the report counts the refusals.
|
|
166
|
+
*
|
|
167
|
+
* Two cases are uncertain, and in neither is the copy sent again:
|
|
168
|
+
*
|
|
169
|
+
* - the provider never answered (`UnansweredSendError`: the connection dropped, the fetch timed
|
|
170
|
+
* out) — it may have taken the message, so the claim is kept and the copy settles undelivered
|
|
171
|
+
* as `no_answer`, and the journey goes on;
|
|
172
|
+
* - the copy was claimed and never settled — the earlier run died between the transport taking
|
|
173
|
+
* it and the report (or the step's checkpoint) — and a replay settles it as `unconfirmed`.
|
|
174
|
+
*
|
|
175
|
+
* Both are in the report under those reasons: what at-most-once cost is countable. The templates
|
|
176
|
+
* that must arrive opt out per template (`redelivery: 'resend'`), and are sent again as the step
|
|
177
|
+
* retries. A report that fails after the send is logged, never thrown: the step would retry,
|
|
178
|
+
* and the copy — now claimed — would be skipped.
|
|
179
|
+
*
|
|
180
|
+
* Why at most once (decided 2026-11-10, after reviewing the alternatives): exactly-once is out of
|
|
181
|
+
* reach — Cloudflare Email Service (the `send_email` binding and the REST endpoint alike) and SES
|
|
182
|
+
* accept no idempotency key or client message id, FCM does not de-duplicate, only APNs and Web
|
|
183
|
+
* Push collapse a repeat on the device. Between the two remaining options, a duplicate marketing
|
|
184
|
+
* email costs spam complaints, unsubscribes and sender reputation, while a lost nudge is invisible
|
|
185
|
+
* to the user and a journey has later steps; this is how Customer.io and Braze behave (the
|
|
186
|
+
* delivery record is the source of truth, no resend on uncertainty). Do not "fix" this back to
|
|
187
|
+
* at-least-once: set `redelivery: 'resend'` on the templates that need it instead.
|
|
188
|
+
*/
|
|
189
|
+
async function deliver(message, ctx) {
|
|
190
|
+
const observer = ctx.observer;
|
|
191
|
+
if (await observer?.messageSettled?.(message)) return;
|
|
192
|
+
const tracking = await observer?.messagePrepared?.(message);
|
|
193
|
+
const copy = tracking === void 0 ? message : {
|
|
194
|
+
...message,
|
|
195
|
+
tracking
|
|
196
|
+
};
|
|
197
|
+
if (!(await observer?.messageClaimed?.(copy) ?? true) && copy.redelivery !== "resend") {
|
|
198
|
+
console.warn(`[workflow] ${copy.idempotencyKey} was handed to the transport by an earlier run and never settled: not sent again (redelivery: 'skip')`);
|
|
199
|
+
await settleUncertain(copy, "unconfirmed", ctx);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
let result;
|
|
203
|
+
try {
|
|
204
|
+
result = await ctx.messages.send(copy);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (require_engine_retry.isUnanswered(error) && copy.redelivery !== "resend") {
|
|
207
|
+
console.warn(`[workflow] ${copy.idempotencyKey} got no answer from the provider: not sent again (redelivery: 'skip')`, error);
|
|
208
|
+
await settleUncertain(copy, "no_answer", ctx);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (require_engine_retry.isRefusedSend(error)) {
|
|
212
|
+
const reason = require_engine_retry.refusalReason(error);
|
|
213
|
+
console.error(`[workflow] ${copy.idempotencyKey} (${copy.channel} '${copy.template}') was refused, settled as undelivered (${reason}) and the journey goes on`, error);
|
|
214
|
+
try {
|
|
215
|
+
await observer?.messageSent?.(copy, {
|
|
216
|
+
delivered: false,
|
|
217
|
+
reason
|
|
218
|
+
});
|
|
219
|
+
} catch (reportError) {
|
|
220
|
+
console.error(`[workflow] reporting ${copy.idempotencyKey} as refused failed`, reportError);
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
await observer?.messageReleased?.(copy);
|
|
226
|
+
} catch (releaseError) {
|
|
227
|
+
console.error(`[workflow] releasing ${copy.idempotencyKey} after a failed send failed`, releaseError);
|
|
228
|
+
}
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
await observer?.messageSent?.(copy, result ?? { delivered: true });
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error(`[workflow] reporting ${copy.idempotencyKey} as sent failed`, error);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A copy that may or may not have reached the user, settled as undelivered under the reason that
|
|
239
|
+
* says which uncertainty it was. Logged, never thrown, like every report after a send.
|
|
240
|
+
*/
|
|
241
|
+
async function settleUncertain(copy, reason, ctx) {
|
|
242
|
+
try {
|
|
243
|
+
await ctx.observer?.messageSent?.(copy, {
|
|
244
|
+
delivered: false,
|
|
245
|
+
reason
|
|
246
|
+
});
|
|
247
|
+
} catch (error) {
|
|
248
|
+
console.error(`[workflow] reporting ${copy.idempotencyKey} as ${reason} failed`, error);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Goal / exitWhen guards (see the header for when they run).
|
|
253
|
+
*
|
|
254
|
+
* The goal condition is anchored at workflow entry: a `performed` inside it
|
|
255
|
+
* only counts events after the user entered, so pre-existing history cannot
|
|
256
|
+
* register as a conversion. exitWhen is deliberately unanchored — "user
|
|
257
|
+
* unsubscribed" should exit no matter when it happened.
|
|
258
|
+
*/
|
|
259
|
+
async function checkGuards(stepId, ir, ctx) {
|
|
260
|
+
const goal = ir.goal;
|
|
261
|
+
const exitWhen = ir.exitWhen;
|
|
262
|
+
if (goal === void 0 && exitWhen === void 0) return null;
|
|
263
|
+
const state = goalState(ctx);
|
|
264
|
+
const result = await ctx.step.do(`${stepId}:guard`, async () => {
|
|
265
|
+
const now = Date.now();
|
|
266
|
+
const goalHit = goal !== void 0 && state.convertedAt === void 0 ? await goalReached(ir, ctx, now) : null;
|
|
267
|
+
const exitMet = exitWhen !== void 0 && await holds(exitWhen, ctx, now);
|
|
268
|
+
return {
|
|
269
|
+
goalAt: goalHit?.at ?? null,
|
|
270
|
+
exitMet
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
if (result.goalAt !== null) {
|
|
274
|
+
state.convertedAt ??= result.goalAt;
|
|
275
|
+
if (goal?.exitOnMatch ?? true) return { kind: "goal" };
|
|
276
|
+
}
|
|
277
|
+
if (result.exitMet) return { kind: "exit_when" };
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The host's template check, with the instance and node added to the message:
|
|
282
|
+
* a refused message must point at the journey that produced it. The error
|
|
283
|
+
* keeps its class (and `name`), so adapters can stop retrying it.
|
|
284
|
+
*/
|
|
285
|
+
function validate(node, props, ctx) {
|
|
286
|
+
if (ctx.validator === void 0) return props;
|
|
287
|
+
try {
|
|
288
|
+
return ctx.validator.validate({
|
|
289
|
+
channel: node.channel,
|
|
290
|
+
template: node.template,
|
|
291
|
+
props
|
|
292
|
+
});
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (error instanceof Error) error.message = `[${ctx.instanceId} ${node.id}] ${error.message}${missingRefs(node, props)}`;
|
|
295
|
+
throw error;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* What a refused message most often lacks: a prop written as a reference (`{ name: u.name }`)
|
|
300
|
+
* that this user has no value for. A profile field the contract declares as required is still
|
|
301
|
+
* absent until someone writes it — the contract checks what is written, not that it was — so
|
|
302
|
+
* the refusal says which field, and the author knows whether to write the data or to declare
|
|
303
|
+
* the field (and the template's prop) optional.
|
|
304
|
+
*/
|
|
305
|
+
function missingRefs(node, props) {
|
|
306
|
+
const missing = [];
|
|
307
|
+
for (const [key, value] of Object.entries(node.props)) {
|
|
308
|
+
if (typeof value !== "object" || props[key] !== void 0) continue;
|
|
309
|
+
const source = value.type === "trigger_payload" ? `trigger payload field '${value.path}'` : `profile field '${value.path}'`;
|
|
310
|
+
missing.push(`props.${key} reads ${source}, which this user has no value for`);
|
|
311
|
+
}
|
|
312
|
+
return missing.length > 0 ? ` (${missing.join("; ")})` : "";
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The message's opt-out topic and redelivery policy at the moment of the send. The template is
|
|
316
|
+
* resolved when it is used — the latest content goes out — and so is what it says about itself:
|
|
317
|
+
* a template moved to another topic, or from transactional to a topic, since this journey's
|
|
318
|
+
* workflow was compiled is sent under what it declares today. The node's own values (the
|
|
319
|
+
* compile-time snapshot) stand only where no registry answers: a host without a validator, a
|
|
320
|
+
* channel without templates. Called inside the send's step, so a replay reads the checkpoint.
|
|
321
|
+
*/
|
|
322
|
+
function policyOf(node, ctx) {
|
|
323
|
+
const live = ctx.validator?.describe?.({
|
|
324
|
+
channel: node.channel,
|
|
325
|
+
template: node.template
|
|
326
|
+
});
|
|
327
|
+
if (live !== void 0) return live;
|
|
328
|
+
return {
|
|
329
|
+
...node.topic !== void 0 ? { topic: node.topic } : {},
|
|
330
|
+
...node.redelivery === "resend" ? { redelivery: "resend" } : {}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The policy as the copy carries it: what the observer records and the senders may read. An
|
|
335
|
+
* email or a push always says its topic — one with none known (a node compiled before topics
|
|
336
|
+
* existed) is recorded as transactional, as it always was.
|
|
337
|
+
*/
|
|
338
|
+
function carried(node, policy) {
|
|
339
|
+
return {
|
|
340
|
+
...node.channel === "email" || node.channel === "push" ? { topic: policy.topic ?? null } : {},
|
|
341
|
+
...policy.redelivery === "resend" ? { redelivery: "resend" } : {}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Whether the user opted out of what this step sends. An email or push step checks its topic —
|
|
346
|
+
* an opt-out of the topic on that channel or of the whole channel skips it — and a transactional
|
|
347
|
+
* message (`topic: null`) is never skipped: a receipt or a code goes out whatever the user opted
|
|
348
|
+
* out of. With no topic known (a node compiled before topics existed, on a host whose registry
|
|
349
|
+
* does not answer for it) the channel-wide opt-out alone is checked, as it always was. Other
|
|
350
|
+
* channels check the channel.
|
|
351
|
+
*/
|
|
352
|
+
async function suppressed(node, policy, ctx) {
|
|
353
|
+
if (policy.topic === null) return false;
|
|
354
|
+
return await ctx.facts.isSuppressed?.(node.channel, policy.topic) === true;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* A push goes to devices, not to a profile address: one copy per device the
|
|
358
|
+
* host's directory lists (or only the most recent, `devices: 'latest'`). Each
|
|
359
|
+
* copy's idempotency key carries its token, so a retried step that already
|
|
360
|
+
* reached some devices re-sends to the rest and skips the ones it reached —
|
|
361
|
+
* keyed by token rather than position, because the list can change between
|
|
362
|
+
* attempts. A user with no device is skipped, not failed: being unreachable is
|
|
363
|
+
* a state of the user, and `reachable('push')` is how a journey branches on it.
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* A push: one step settles what goes out and to which devices, then each device gets a step of
|
|
367
|
+
* its own — a failure on one device retries that device alone, and the copies already delivered
|
|
368
|
+
* or claimed are not sent again (see `deliver`; APNs collapses a repeat on the device, FCM does
|
|
369
|
+
* not de-duplicate at all).
|
|
370
|
+
*/
|
|
371
|
+
async function sendPush(node, ir, ctx) {
|
|
372
|
+
const plan = await ctx.step.do(`${node.id}:send`, async () => {
|
|
373
|
+
const props = validate(node, await resolveValues(node.props, ctx), ctx);
|
|
374
|
+
const policy = policyOf(node, ctx);
|
|
375
|
+
if (await suppressed(node, policy, ctx)) return null;
|
|
376
|
+
const listed = await ctx.facts.listDevices();
|
|
377
|
+
return {
|
|
378
|
+
props,
|
|
379
|
+
devices: node.devices === "latest" ? listed.slice(0, 1) : listed,
|
|
380
|
+
policy
|
|
381
|
+
};
|
|
382
|
+
});
|
|
383
|
+
if (plan === null) return;
|
|
384
|
+
if (plan.devices.length === 0) {
|
|
385
|
+
console.log(`[journey] push ${node.template} skipped: no device for user ${ctx.userId}`);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const policy = plan.policy ?? policyOf(node, ctx);
|
|
389
|
+
for (const [index, device] of plan.devices.entries()) await ctx.step.do(`${node.id}:send:${index}`, async () => {
|
|
390
|
+
await deliver({
|
|
391
|
+
workflow: ir.id,
|
|
392
|
+
instanceId: ctx.instanceId,
|
|
393
|
+
nodeId: node.id,
|
|
394
|
+
channel: "push",
|
|
395
|
+
template: node.template,
|
|
396
|
+
props: plan.props,
|
|
397
|
+
userId: await ownerOf(ctx),
|
|
398
|
+
recipient: device.token,
|
|
399
|
+
device,
|
|
400
|
+
idempotencyKey: `${ctx.instanceId}:${node.id}:${device.token}`,
|
|
401
|
+
...carried(node, policy)
|
|
402
|
+
}, ctx);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async function runNode(node, ir, ctx) {
|
|
406
|
+
switch (node.type) {
|
|
407
|
+
case "message":
|
|
408
|
+
if (node.channel === "push") {
|
|
409
|
+
await sendPush(node, ir, ctx);
|
|
410
|
+
return FALL_THROUGH;
|
|
411
|
+
}
|
|
412
|
+
await ctx.step.do(`${node.id}:send`, async () => {
|
|
413
|
+
const props = validate(node, await resolveValues(node.props, ctx), ctx);
|
|
414
|
+
const policy = policyOf(node, ctx);
|
|
415
|
+
if (await suppressed(node, policy, ctx)) return;
|
|
416
|
+
const recipientPath = require_engine_recipient.RECIPIENT_PROPERTY[node.channel];
|
|
417
|
+
const recipient = recipientPath === void 0 ? void 0 : await ctx.facts.getProperty(recipientPath);
|
|
418
|
+
await deliver({
|
|
419
|
+
workflow: ir.id,
|
|
420
|
+
instanceId: ctx.instanceId,
|
|
421
|
+
nodeId: node.id,
|
|
422
|
+
channel: node.channel,
|
|
423
|
+
template: node.template,
|
|
424
|
+
props,
|
|
425
|
+
userId: await ownerOf(ctx),
|
|
426
|
+
recipient: recipient === void 0 ? void 0 : String(recipient),
|
|
427
|
+
idempotencyKey: `${ctx.instanceId}:${node.id}`,
|
|
428
|
+
...carried(node, policy)
|
|
429
|
+
}, ctx);
|
|
430
|
+
});
|
|
431
|
+
return FALL_THROUGH;
|
|
432
|
+
case "delay":
|
|
433
|
+
await ctx.step.sleep(node.id, node.duration.ms);
|
|
434
|
+
return await checkGuards(node.id, ir, ctx) ?? FALL_THROUGH;
|
|
435
|
+
case "random_delay": {
|
|
436
|
+
const ms = await ctx.step.do(`${node.id}:roll`, async () => {
|
|
437
|
+
const span = node.max.ms - node.min.ms;
|
|
438
|
+
return node.min.ms + Math.floor(Math.random() * Math.max(span, 0));
|
|
439
|
+
});
|
|
440
|
+
await ctx.step.sleep(`${node.id}:sleep`, ms);
|
|
441
|
+
return await checkGuards(node.id, ir, ctx) ?? FALL_THROUGH;
|
|
442
|
+
}
|
|
443
|
+
case "time_window": {
|
|
444
|
+
const target = await ctx.step.do(`${node.id}:target`, async () => {
|
|
445
|
+
const tz = node.tz === "user" ? String(await ctx.facts.getProperty(TIMEZONE_PROPERTY) ?? "UTC") : node.tz;
|
|
446
|
+
return require_engine_time_window.nextWindowStart(Date.now(), node.days, node.between, tz);
|
|
447
|
+
});
|
|
448
|
+
if (target === null) return FALL_THROUGH;
|
|
449
|
+
const ms = await ctx.step.do(`${node.id}:remaining`, async () => target - Date.now());
|
|
450
|
+
if (ms > 0) await ctx.step.sleep(`${node.id}:sleep`, ms);
|
|
451
|
+
return await checkGuards(node.id, ir, ctx) ?? FALL_THROUGH;
|
|
452
|
+
}
|
|
453
|
+
case "wait_until": {
|
|
454
|
+
const met = await waitUntil(node, ctx);
|
|
455
|
+
const guard = await checkGuards(node.id, ir, ctx);
|
|
456
|
+
if (guard) return guard;
|
|
457
|
+
if (met) return FALL_THROUGH;
|
|
458
|
+
const onTimeout = node.onTimeout;
|
|
459
|
+
if (onTimeout === "continue") return FALL_THROUGH;
|
|
460
|
+
if (onTimeout === "exit") return {
|
|
461
|
+
kind: "exit",
|
|
462
|
+
reason: `${node.id}:timeout`
|
|
463
|
+
};
|
|
464
|
+
return runFlow(onTimeout, ir, ctx);
|
|
465
|
+
}
|
|
466
|
+
case "branch": {
|
|
467
|
+
const matched = await ctx.step.do(`${node.id}:eval`, async () => {
|
|
468
|
+
const now = Date.now();
|
|
469
|
+
for (const [i, branchCase] of node.cases.entries()) if (await holds(branchCase.condition, ctx, now)) return i;
|
|
470
|
+
return -1;
|
|
471
|
+
});
|
|
472
|
+
const flow = matched >= 0 ? node.cases[matched]?.flow : node.otherwise;
|
|
473
|
+
if (flow === void 0) return FALL_THROUGH;
|
|
474
|
+
return await runFlow(flow, ir, ctx);
|
|
475
|
+
}
|
|
476
|
+
case "filter": return await ctx.step.do(`${node.id}:eval`, async () => holds(node.condition, ctx, Date.now())) ? FALL_THROUGH : {
|
|
477
|
+
kind: "exit",
|
|
478
|
+
reason: node.reason ?? `${node.id}:filtered`
|
|
479
|
+
};
|
|
480
|
+
case "cohort": {
|
|
481
|
+
const bucket = require_engine_bucket.hashToBucket(`${ctx.userId}:${node.key ?? `${ir.id}:${node.id}`}`);
|
|
482
|
+
let cumulative = 0;
|
|
483
|
+
for (const arm of node.arms) {
|
|
484
|
+
cumulative += Math.round(arm.weight * 100);
|
|
485
|
+
if (bucket < cumulative) return runFlow(arm.flow, ir, ctx);
|
|
486
|
+
}
|
|
487
|
+
return FALL_THROUGH;
|
|
488
|
+
}
|
|
489
|
+
case "exit": return node.reason !== void 0 ? {
|
|
490
|
+
kind: "exit",
|
|
491
|
+
reason: node.reason
|
|
492
|
+
} : { kind: "exit" };
|
|
493
|
+
case "send_event":
|
|
494
|
+
await ctx.step.do(`${node.id}:emit`, async () => {
|
|
495
|
+
const payload = await resolveValues(node.payload, ctx);
|
|
496
|
+
try {
|
|
497
|
+
await ctx.events.emit(node.event, payload, `${ctx.instanceId}:${node.id}`);
|
|
498
|
+
} catch (error) {
|
|
499
|
+
if (error instanceof Error) error.message = `[${ctx.instanceId} ${node.id}] ${error.message}`;
|
|
500
|
+
throw error;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
return FALL_THROUGH;
|
|
504
|
+
case "action": {
|
|
505
|
+
const invoker = ctx.actions;
|
|
506
|
+
if (invoker === void 0) throw new Error(`action '${node.action}': this runtime has no ActionInvoker configured — register the action on the adapter (see engine/actions.ts)`);
|
|
507
|
+
await ctx.step.do(`${node.id}:run`, async () => {
|
|
508
|
+
const args = await resolveValues(node.args, ctx);
|
|
509
|
+
await invoker.invoke({
|
|
510
|
+
action: node.action,
|
|
511
|
+
args,
|
|
512
|
+
userId: await ownerOf(ctx),
|
|
513
|
+
idempotencyKey: `${ctx.instanceId}:${node.id}`
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
return FALL_THROUGH;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
async function waitUntil(node, ctx) {
|
|
521
|
+
const deadline = await ctx.step.do(`${node.id}:deadline`, async () => Date.now() + node.timeout.ms);
|
|
522
|
+
const events = await ctx.step.do(`${node.id}:events`, async () => require_engine_condition.relevantEvents(node.condition, ctx.facts));
|
|
523
|
+
const anchorMs = deadline - node.timeout.ms;
|
|
524
|
+
const met = await waitLoop(node.id, ctx, deadline, events, async (now) => await holds(node.condition, ctx, now, {
|
|
525
|
+
anchorMs,
|
|
526
|
+
untilMs: deadline
|
|
527
|
+
}) ? true : null);
|
|
528
|
+
await ctx.step.unsubscribe(`${node.id}:unsubscribe`);
|
|
529
|
+
return met === true;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* The conversion window outlives the flow: a journey whose steps are done while its goal's
|
|
533
|
+
* `within` is still open keeps watching until the window closes — the purchase that follows the
|
|
534
|
+
* last offer email is that email's conversion, and ending the instance at the email would report
|
|
535
|
+
* it as a plain completion. `exitWhen` still applies while it waits. Nothing to wait for without
|
|
536
|
+
* a window, or once the instance has converted.
|
|
537
|
+
*/
|
|
538
|
+
async function awaitTail(ir, ctx) {
|
|
539
|
+
const deadline = goalDeadline(ir, ctx);
|
|
540
|
+
const goal = ir.goal;
|
|
541
|
+
if (goal === void 0 || deadline === void 0) return null;
|
|
542
|
+
const state = goalState(ctx);
|
|
543
|
+
if (state.convertedAt !== void 0) return null;
|
|
544
|
+
if (!await ctx.step.do("goal:open", async () => deadline > Date.now())) return null;
|
|
545
|
+
const exitWhen = ir.exitWhen;
|
|
546
|
+
const hit = await waitLoop("goal", ctx, deadline, await ctx.step.do("goal:events", async () => [.../* @__PURE__ */ new Set([...await require_engine_condition.relevantEvents(goal.condition, ctx.facts), ...exitWhen === void 0 ? [] : await require_engine_condition.relevantEvents(exitWhen, ctx.facts)])]), async (now) => {
|
|
547
|
+
const reached = await goalReached(ir, ctx, now);
|
|
548
|
+
if (reached !== null) return {
|
|
549
|
+
kind: "goal",
|
|
550
|
+
at: reached.at
|
|
551
|
+
};
|
|
552
|
+
if (exitWhen !== void 0 && await holds(exitWhen, ctx, now)) return {
|
|
553
|
+
kind: "exit_when",
|
|
554
|
+
at: now
|
|
555
|
+
};
|
|
556
|
+
return null;
|
|
557
|
+
});
|
|
558
|
+
await ctx.step.unsubscribe("goal:unsubscribe");
|
|
559
|
+
if (hit === null) return null;
|
|
560
|
+
if (hit.kind === "goal") {
|
|
561
|
+
state.convertedAt ??= hit.at;
|
|
562
|
+
return { kind: "goal" };
|
|
563
|
+
}
|
|
564
|
+
return { kind: "exit_when" };
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Wait until `check` finds something or the deadline passes: subscribe, check, sleep until a
|
|
568
|
+
* relevant event wakes the instance or time runs out. `check` runs inside a step, so its result
|
|
569
|
+
* must be serializable; null means "not yet". Null from here means the deadline passed with
|
|
570
|
+
* nothing found — never a failure, and never a wait given up on early.
|
|
571
|
+
*/
|
|
572
|
+
async function waitLoop(id, ctx, deadline, events, check) {
|
|
573
|
+
for (let attempt = 0; attempt < MAX_WAIT_CHECKS; attempt++) {
|
|
574
|
+
await ctx.step.subscribe(`${id}:subscribe:${attempt}`, events, { deadlineMs: deadline });
|
|
575
|
+
const met = await ctx.step.do(`${id}:check:${attempt}`, async () => check(Date.now()));
|
|
576
|
+
if (met !== null) return met;
|
|
577
|
+
const remaining = await ctx.step.do(`${id}:remaining:${attempt}`, async () => deadline - Date.now());
|
|
578
|
+
if (remaining <= 0) return null;
|
|
579
|
+
if (await ctx.step.waitForWake(`${id}:wait:${attempt}`, {
|
|
580
|
+
timeoutMs: remaining,
|
|
581
|
+
deadlineMs: deadline
|
|
582
|
+
}) === "timeout") return finalCheck(id, ctx, check);
|
|
583
|
+
}
|
|
584
|
+
console.warn(`[journey] ${ctx.instanceId} ${id}: ${MAX_WAIT_CHECKS} wake-ups without the condition holding — sleeping to the deadline`);
|
|
585
|
+
const budgetRemaining = await ctx.step.do(`${id}:budget:remaining`, async () => deadline - Date.now());
|
|
586
|
+
if (budgetRemaining > 0) await ctx.step.sleep(`${id}:budget:sleep`, budgetRemaining);
|
|
587
|
+
return finalCheck(id, ctx, check);
|
|
588
|
+
}
|
|
589
|
+
/** The check once the deadline is reached — one step for all the ways of getting there. */
|
|
590
|
+
async function finalCheck(id, ctx, check) {
|
|
591
|
+
return ctx.step.do(`${id}:final`, async () => check(Date.now()));
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* A journey's condition: the facts are the user's, and the trigger payload is the instance's
|
|
595
|
+
* own. An instance started with none (a segment or webhook trigger) reads an empty payload —
|
|
596
|
+
* the compiler refuses trigger references in such a workflow, so only hand-built IR gets here.
|
|
597
|
+
*/
|
|
598
|
+
function holds(condition, ctx, nowMs, opts) {
|
|
599
|
+
return require_engine_condition.evaluateCondition(condition, ctx.facts, nowMs, {
|
|
600
|
+
...opts,
|
|
601
|
+
triggerPayload: ctx.triggerPayload ?? {}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
async function resolveValues(values, ctx) {
|
|
605
|
+
const resolved = {};
|
|
606
|
+
for (const [key, value] of Object.entries(values)) if (typeof value !== "object") resolved[key] = value;
|
|
607
|
+
else if (value.type === "trigger_payload") resolved[key] = require_engine_condition.payloadScalar(ctx.triggerPayload, value.path);
|
|
608
|
+
else resolved[key] = await ctx.facts.getProperty(value.path);
|
|
609
|
+
return resolved;
|
|
610
|
+
}
|
|
611
|
+
exports.runJourney = runJourney;
|
|
612
|
+
|
|
613
|
+
//# sourceMappingURL=interpreter.cjs.map
|