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 @@
|
|
|
1
|
+
{"version":3,"file":"journey-host.d.cts","names":[],"sources":["../../src/host/journey-host.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBA2CiB,mBAAmB,YAAY;;;;;;;;EAQ9C,QAAQ;;;;;;;;EAQR,QAAQ,KAAK,KAAK;IAAY;QAAqB,eAAe;;;;;;EAMlE,SAAS,KAAK,QAAQ;;;;;;;;;;;EAWtB,YAAY,KAAK,KAAK,OAAO,iBAAiB;;EAE9C,YAAY,KAAK,KAAK,OAAO,iBAAiB;;EAE9C,WAAW,KAAK,KAAK,QAAQ,kBAAkB;;;;;;;EAO/C,MAAM,KAAK;;EAEX;;;;;;;;;;;EAWA,YAAY,UAAU;;;qBAIX,2BAA2B;WAEjB;WADH;EAClB,YAAqB;;iBAKN,YAAY,YAAY;EACvC,QAAQ;;EAER,SAAS,KAAK,MAAM;;EAEpB,MAAM,KAAK,MAAM,SAAS;;EAE1B,UAAU;;EAEV,SAAS,KAAK,KAAK,OAAO,cAAc,QAAQ,gBAAgB;;;;;EAKhE,OACE,SAAS,SACT,KAAK,KACL,OAAO,cACP,UAAU,gBACT,QAAQ;;EAEX,MAAM,KAAK,MAAM,QAAQ;;EAEzB,QAAQ,mBAAmB,oBAAoB,KAAK,KAAK,OAAO,eAAe;;;;;;EAM/E,eAAe,KAAK,KAAK,SAAS,4BAA4B;;;iBAI/C;;EAEf,mBAAmB;;wBAqCL,kBAAkB,YAAY,YAC5C,SAAS,mBAAmB,MAC5B,WAAU,kBACT,YAAY"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as core from "zod/v4/core";
|
|
2
|
+
import { JourneyConfig } from "../config.mjs";
|
|
3
|
+
import { EmailTransport } from "../email-sender.mjs";
|
|
4
|
+
import { JourneyObserver, MessageSender } from "../engine/ports.mjs";
|
|
5
|
+
import { BundleIR } from "../ir.mjs";
|
|
6
|
+
import { JourneyRuntimeOptions } from "../runtime.mjs";
|
|
7
|
+
import { BundleVersion, JourneyStore, StoreLease } from "../store/index.mjs";
|
|
8
|
+
import { Authorize } from "./auth.mjs";
|
|
9
|
+
import { QueueMessageLike } from "./batch.mjs";
|
|
10
|
+
import { JourneyRunParts } from "./execute.mjs";
|
|
11
|
+
import { SweepResult } from "./ingest.mjs";
|
|
12
|
+
import { JourneyEnv, JourneyParams } from "./platform.mjs";
|
|
13
|
+
/**
|
|
14
|
+
* What a journey host is, apart from the runtime it runs on: the validated environment, the
|
|
15
|
+
* store lease, the outlets a run is wired to, the HTTP API (`http.ts`, with the host's parts
|
|
16
|
+
* plugged in) and the bundle that goes live with the code. `journeyWorker` (Cloudflare) and
|
|
17
|
+
* `journeyLambda` (AWS) are this plus how their platform starts, wakes and stops instances.
|
|
18
|
+
*/
|
|
19
|
+
export interface JourneyHostOptions<Env extends JourneyEnv> {
|
|
20
|
+
/**
|
|
21
|
+
* The project's `workflow.config.ts` (`defineConfig`): what the host deploys (`GET /bundle`,
|
|
22
|
+
* `POST /bundle/deploy` serve `compileConfig`), the template registries the senders, the
|
|
23
|
+
* validator and `/preview` render from, the contract every `/ingest` is
|
|
24
|
+
* checked against, the email defaults, actions, and the runtime / APNs / FCM settings.
|
|
25
|
+
* Secrets come from the env under the names `JourneyEnv` documents.
|
|
26
|
+
*/
|
|
27
|
+
config: JourneyConfig;
|
|
28
|
+
/**
|
|
29
|
+
* The data plane, opened per request and per workflow run. Return a `StoreLease` when the
|
|
30
|
+
* client must be released afterwards (a Postgres connection). `database` is the config's
|
|
31
|
+
* (`schema` defaulting to `workflow`):
|
|
32
|
+
*
|
|
33
|
+
* store: (env, database) => postgresJsStore(env.DATABASE_URL, database)
|
|
34
|
+
*/
|
|
35
|
+
store: (env: Env, database: {
|
|
36
|
+
schema: string;
|
|
37
|
+
}) => JourneyStore | StoreLease;
|
|
38
|
+
/**
|
|
39
|
+
* Where journey emails go: a transport built from the validated env — `sesEmailTransport(...)`,
|
|
40
|
+
* `cloudflareEmailTransport(...)`, or your own. Which one is independent of where the workflow
|
|
41
|
+
* runs. Without it the email channel fails its sends, saying so.
|
|
42
|
+
*/
|
|
43
|
+
email?: (env: Env) => EmailTransport;
|
|
44
|
+
/**
|
|
45
|
+
* Reporting hooks: node arrivals, every copy sent (with the tracking it should carry — click
|
|
46
|
+
* links and an open pixel for email, payload data for a push), and how each instance ended.
|
|
47
|
+
* By default the store records them itself, and the host serves the email tracking routes
|
|
48
|
+
* (`/t/...`, on `WORKFLOW_ORIGIN`). An observer given here is added to that one, not put in
|
|
49
|
+
* its place: the store's record is what delivers each copy at most once (the claim), so it is
|
|
50
|
+
* kept and the hooks here run after its own, to report elsewhere as well. Only an observer
|
|
51
|
+
* that decides delivery itself — one implementing `messageSettled`, `messageClaimed` and
|
|
52
|
+
* `messageReleased`, as `reportingObserver` wrapped by hand does — stands alone.
|
|
53
|
+
*/
|
|
54
|
+
observer?: (env: Env, store: JourneyStore) => JourneyObserver;
|
|
55
|
+
/** Message outlet override (tests, a custom gateway): replaces every channel, `email` included. */
|
|
56
|
+
messages?: (env: Env, store: JourneyStore) => MessageSender;
|
|
57
|
+
/** Per-instance runtime options override (a tester in fast-forward); by default `config.runtime` for `ENVIRONMENT`. */
|
|
58
|
+
runtime?: (env: Env, params: JourneyParams) => JourneyRuntimeOptions;
|
|
59
|
+
/**
|
|
60
|
+
* The host's environment, as a zod schema over its vars and secrets (bindings pass through
|
|
61
|
+
* untouched): checked the first time the host runs, so a missing or malformed variable fails
|
|
62
|
+
* there — every problem listed — not at the send that needs it. Webhook templates read their
|
|
63
|
+
* URL from the parsed values: `webhook: (env: Env) => env.WEBHOOK_DISCORD_ALERTS`.
|
|
64
|
+
*/
|
|
65
|
+
env?: core.$ZodType<object>;
|
|
66
|
+
/** 'enforce' (default) answers an event or patch the contract refuses with a 400; 'report' only logs it. */
|
|
67
|
+
contractMode?: 'enforce' | 'report';
|
|
68
|
+
/**
|
|
69
|
+
* Who may call the API routes, in whatever form the host chooses: an HMAC over the body, a
|
|
70
|
+
* JWT, a header its proxy adds. Receives a copy of the request and the env; true lets it
|
|
71
|
+
* through, false answers 401, a throw answers 500. The tracking routes and `/health` stay
|
|
72
|
+
* public. Without it, the env's `API_TOKEN` as a bearer (`bearerMatches`), which production
|
|
73
|
+
* then requires.
|
|
74
|
+
*
|
|
75
|
+
* authorize: async (request, env) =>
|
|
76
|
+
* timingSafeEqual(request.headers.get('x-signature') ?? '', await hmac(env.SECRET, await request.text()))
|
|
77
|
+
*/
|
|
78
|
+
authorize?: Authorize<Env>;
|
|
79
|
+
}
|
|
80
|
+
/** The host's environment failed its schema (`env` option). */
|
|
81
|
+
export declare class EnvValidationError extends Error {
|
|
82
|
+
readonly issues: readonly string[];
|
|
83
|
+
readonly name = "EnvValidationError";
|
|
84
|
+
constructor(issues: readonly string[]);
|
|
85
|
+
}
|
|
86
|
+
export interface JourneyHost<Env extends JourneyEnv> {
|
|
87
|
+
config: JourneyConfig;
|
|
88
|
+
/** The env, parsed by the schema once per env object (throws EnvValidationError). */
|
|
89
|
+
checkEnv(env: Env): Env;
|
|
90
|
+
/** A store for one request or run, its segment windows scaled with the runtime. */
|
|
91
|
+
lease(env: Env): Required<StoreLease>;
|
|
92
|
+
/** The bundle compiled into this code. */
|
|
93
|
+
bundle(): BundleIR;
|
|
94
|
+
/** The outlets one run is wired to (the store is the run's). */
|
|
95
|
+
runParts(env: Env, store: JourneyStore, params: JourneyParams): JourneyRunParts;
|
|
96
|
+
/**
|
|
97
|
+
* The HTTP API over one store: the ingest API plus tracking, the sweep, the bundle and previews.
|
|
98
|
+
* `version` is the code version serving the request, recorded by `POST /bundle/deploy`.
|
|
99
|
+
*/
|
|
100
|
+
handle(request: Request, env: Env, store: JourneyStore, version?: BundleVersion): Promise<Response>;
|
|
101
|
+
/** The scheduled sweep (`sweepSegments`) on a store of its own. */
|
|
102
|
+
sweep(env: Env): Promise<SweepResult>;
|
|
103
|
+
/** Delivered `JourneyBatch` messages over one store, acknowledged or retried one by one. */
|
|
104
|
+
consume(messages: readonly QueueMessageLike[], env: Env, store: JourneyStore): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Make the bundle compiled into `version` live, once per process, only over an older live
|
|
107
|
+
* version (the store records it). Undefined when there is nothing to do; a failure is logged
|
|
108
|
+
* and retried a minute later.
|
|
109
|
+
*/
|
|
110
|
+
applyOwnBundle(env: Env, version: BundleVersion | undefined): Promise<void> | undefined;
|
|
111
|
+
}
|
|
112
|
+
/** What the platform adapter itself contributes. */
|
|
113
|
+
export interface JourneyPlatform {
|
|
114
|
+
/** An HTTP/2 fetch for APNs, where the runtime's own fetch is HTTP/1.1 (Node). */
|
|
115
|
+
apnsFetch?: typeof fetch;
|
|
116
|
+
}
|
|
117
|
+
export declare function createJourneyHost<Env extends JourneyEnv>(options: JourneyHostOptions<Env>, platform?: JourneyPlatform): JourneyHost<Env>;
|
|
118
|
+
//# sourceMappingURL=journey-host.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journey-host.d.mts","names":[],"sources":["../../src/host/journey-host.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBA2CiB,mBAAmB,YAAY;;;;;;;;EAQ9C,QAAQ;;;;;;;;EAQR,QAAQ,KAAK,KAAK;IAAY;QAAqB,eAAe;;;;;;EAMlE,SAAS,KAAK,QAAQ;;;;;;;;;;;EAWtB,YAAY,KAAK,KAAK,OAAO,iBAAiB;;EAE9C,YAAY,KAAK,KAAK,OAAO,iBAAiB;;EAE9C,WAAW,KAAK,KAAK,QAAQ,kBAAkB;;;;;;;EAO/C,MAAM,KAAK;;EAEX;;;;;;;;;;;EAWA,YAAY,UAAU;;;qBAIX,2BAA2B;WAEjB;WADH;EAClB,YAAqB;;iBAKN,YAAY,YAAY;EACvC,QAAQ;;EAER,SAAS,KAAK,MAAM;;EAEpB,MAAM,KAAK,MAAM,SAAS;;EAE1B,UAAU;;EAEV,SAAS,KAAK,KAAK,OAAO,cAAc,QAAQ,gBAAgB;;;;;EAKhE,OACE,SAAS,SACT,KAAK,KACL,OAAO,cACP,UAAU,gBACT,QAAQ;;EAEX,MAAM,KAAK,MAAM,QAAQ;;EAEzB,QAAQ,mBAAmB,oBAAoB,KAAK,KAAK,OAAO,eAAe;;;;;;EAM/E,eAAe,KAAK,KAAK,SAAS,4BAA4B;;;iBAI/C;;EAEf,mBAAmB;;wBAqCL,kBAAkB,YAAY,YAC5C,SAAS,mBAAmB,MAC5B,WAAU,kBACT,YAAY"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
import { compileConfig } from "../config.mjs";
|
|
3
|
+
import { ContractValidationError, checkEvent } from "../contract.mjs";
|
|
4
|
+
import { RegistryActionInvoker } from "../engine/actions.mjs";
|
|
5
|
+
import { profileUpdatedEvent } from "../engine/condition.mjs";
|
|
6
|
+
import { RECIPIENT_PROPERTY } from "../engine/recipient.mjs";
|
|
7
|
+
import { scaleSegmentWindows } from "../engine/time-scale.mjs";
|
|
8
|
+
import { registryRenderer } from "../react-email.mjs";
|
|
9
|
+
import { composeObservers, decidesDelivery, reportingObserver } from "../reporting/observer.mjs";
|
|
10
|
+
import "../store/tables.mjs";
|
|
11
|
+
import { assertEmailConfig } from "../template-rules.mjs";
|
|
12
|
+
import { indexTemplates, registryValidator } from "../templates.mjs";
|
|
13
|
+
import { consumeBatches } from "./batch.mjs";
|
|
14
|
+
import { channelsFromConfig, createProviderCache, runtimeFromConfig } from "./channels.mjs";
|
|
15
|
+
import { serve } from "./http.mjs";
|
|
16
|
+
import { InFlightError, deployBundle, ingestEvent, removeDevice, sweepSegments, wakeSubscribers } from "./ingest.mjs";
|
|
17
|
+
import { WorkflowCache } from "./workflow-cache.mjs";
|
|
18
|
+
// src/host/journey-host.ts
|
|
19
|
+
/** The host's environment failed its schema (`env` option). */
|
|
20
|
+
var EnvValidationError = class extends Error {
|
|
21
|
+
issues;
|
|
22
|
+
name = "EnvValidationError";
|
|
23
|
+
constructor(issues) {
|
|
24
|
+
super(`the host's environment is invalid:\n ${issues.join("\n ")}`);
|
|
25
|
+
this.issues = issues;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function sendsEmail(nodes) {
|
|
29
|
+
return nodes.some((node) => {
|
|
30
|
+
switch (node.type) {
|
|
31
|
+
case "message": return node.channel === "email";
|
|
32
|
+
case "wait_until": return Array.isArray(node.onTimeout) && sendsEmail(node.onTimeout);
|
|
33
|
+
case "branch": return node.cases.some((branch) => sendsEmail(branch.flow)) || sendsEmail(node.otherwise ?? []);
|
|
34
|
+
case "cohort": return node.arms.some((arm) => sendsEmail(arm.flow));
|
|
35
|
+
default: return false;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const describeIssue = (issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`;
|
|
40
|
+
/** An event the host emits itself, checked against the contract like any ingest. */
|
|
41
|
+
function checkedPayload(contract, event, payload) {
|
|
42
|
+
if (contract === void 0) return payload;
|
|
43
|
+
const verdict = checkEvent(contract, event, payload);
|
|
44
|
+
if (!verdict.ok) throw new ContractValidationError(event, verdict.issues);
|
|
45
|
+
return verdict.data;
|
|
46
|
+
}
|
|
47
|
+
function createJourneyHost(options, platform = {}) {
|
|
48
|
+
const { config } = options;
|
|
49
|
+
const emailIds = indexTemplates("email", config.templates?.email);
|
|
50
|
+
assertEmailConfig(config, emailIds.values());
|
|
51
|
+
let compiled;
|
|
52
|
+
const bundle = () => compiled ??= compileConfig(config);
|
|
53
|
+
const emailing = bundle().workflows.filter((workflow) => sendsEmail(workflow.flow));
|
|
54
|
+
if (options.email === void 0 && options.messages === void 0 && emailing.length > 0) throw new TypeError(`workflows ${emailing.map((w) => `'${w.id}'`).join(", ")} send email, but the host has no \`email\` transport: pass \`email: (env) => cloudflareEmailTransport(...)\` or \`sesEmailTransport(...)\``);
|
|
55
|
+
const checked = /* @__PURE__ */ new WeakMap();
|
|
56
|
+
const checkEnv = (env) => {
|
|
57
|
+
if (options.env === void 0) return env;
|
|
58
|
+
const cached = checked.get(env);
|
|
59
|
+
if (cached !== void 0) return cached;
|
|
60
|
+
const result = z.safeParse(options.env, env);
|
|
61
|
+
if (!result.success) throw new EnvValidationError(result.error.issues.map(describeIssue));
|
|
62
|
+
const merged = {
|
|
63
|
+
...env,
|
|
64
|
+
...result.data
|
|
65
|
+
};
|
|
66
|
+
checked.set(env, merged);
|
|
67
|
+
return merged;
|
|
68
|
+
};
|
|
69
|
+
const emails = config.templates?.email;
|
|
70
|
+
const database = { schema: config.database?.schema ?? "workflow" };
|
|
71
|
+
const lease = (env) => {
|
|
72
|
+
const opened = options.store(env, database);
|
|
73
|
+
const noop = async () => {};
|
|
74
|
+
const factor = runtimeFromConfig(config, env).timeScale;
|
|
75
|
+
return "store" in opened ? {
|
|
76
|
+
store: scaleSegmentWindows(opened.store, factor),
|
|
77
|
+
close: opened.close ?? noop
|
|
78
|
+
} : {
|
|
79
|
+
store: scaleSegmentWindows(opened, factor),
|
|
80
|
+
close: noop
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const providers = createProviderCache();
|
|
84
|
+
const messages = (env, store) => {
|
|
85
|
+
if (options.messages !== void 0) return options.messages(env, store);
|
|
86
|
+
return channelsFromConfig(config, env, {
|
|
87
|
+
onDeadToken: (token) => removeDevice(env, token, store),
|
|
88
|
+
email: options.email?.(env),
|
|
89
|
+
apnsFetch: platform.apnsFetch,
|
|
90
|
+
providers
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const observer = (env, store) => {
|
|
94
|
+
const reporting = reportingObserver(store.reporting, env.WORKFLOW_ORIGIN);
|
|
95
|
+
if (options.observer === void 0) return reporting;
|
|
96
|
+
const own = options.observer(env, store);
|
|
97
|
+
return decidesDelivery(own) ? own : composeObservers(reporting, own);
|
|
98
|
+
};
|
|
99
|
+
/** One for the host's life: every run of a version after the first reads its body from here. */
|
|
100
|
+
const workflows = new WorkflowCache();
|
|
101
|
+
const runParts = (env, store, params) => ({
|
|
102
|
+
store,
|
|
103
|
+
env,
|
|
104
|
+
runtime: options.runtime === void 0 ? runtimeFromConfig(config, env) : options.runtime(env, params),
|
|
105
|
+
messages: messages(env, store),
|
|
106
|
+
actions: new RegistryActionInvoker(config.actions ?? []),
|
|
107
|
+
contract: config.contract,
|
|
108
|
+
validator: registryValidator(config.templates ?? {}),
|
|
109
|
+
observer: observer(env, store),
|
|
110
|
+
workflows
|
|
111
|
+
});
|
|
112
|
+
const preview = emails === void 0 ? void 0 : registryRenderer(emails, config.email);
|
|
113
|
+
/**
|
|
114
|
+
* The recipients' routes (`/t/*`): a push tapped open is recorded as the config's
|
|
115
|
+
* `webPush.openedEvent` — keyed by the copy, so a second tap of the same notification is the
|
|
116
|
+
* same event — and an unsubscribe from all email wakes the waits reading email reachability
|
|
117
|
+
* (`reachable('email')` subscribes to the email property's channel), so an `exitWhen:
|
|
118
|
+
* not(reachable('email'))` takes effect without waiting for a timeout. An unsubscribe from one
|
|
119
|
+
* topic wakes nothing: the user is still reachable.
|
|
120
|
+
*/
|
|
121
|
+
const tracking = (env, store) => {
|
|
122
|
+
const opened = config.webPush?.openedEvent;
|
|
123
|
+
return {
|
|
124
|
+
product: config.title,
|
|
125
|
+
quickMs: config.email?.tracking?.quickClickMs,
|
|
126
|
+
pushOpened: opened === void 0 ? void 0 : async ({ messageId, userId, at }) => {
|
|
127
|
+
const payload = checkedPayload(config.contract, opened, { message_id: messageId });
|
|
128
|
+
const input = {
|
|
129
|
+
id: `${opened}:${messageId}`,
|
|
130
|
+
userId,
|
|
131
|
+
event: opened,
|
|
132
|
+
payload,
|
|
133
|
+
ts: at
|
|
134
|
+
};
|
|
135
|
+
await ingestEvent(env, input, store);
|
|
136
|
+
},
|
|
137
|
+
onUnsubscribed: async ({ userId, all }) => {
|
|
138
|
+
if (!all) return;
|
|
139
|
+
const email = profileUpdatedEvent(RECIPIENT_PROPERTY.email ?? "email");
|
|
140
|
+
await wakeSubscribers(env, store, userId, [email]);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
const handle = (request, env, store, version) => serve(request, {
|
|
145
|
+
env,
|
|
146
|
+
store,
|
|
147
|
+
validation: {
|
|
148
|
+
contract: config.contract,
|
|
149
|
+
mode: options.contractMode
|
|
150
|
+
},
|
|
151
|
+
authorize: options.authorize,
|
|
152
|
+
host: {
|
|
153
|
+
bundle,
|
|
154
|
+
bundleVersion: version,
|
|
155
|
+
config,
|
|
156
|
+
preview: preview === void 0 ? void 0 : {
|
|
157
|
+
has: (id) => emailIds.has(id),
|
|
158
|
+
render: preview
|
|
159
|
+
},
|
|
160
|
+
tracking: tracking(env, store),
|
|
161
|
+
sweep: () => sweepSegments(env, store)
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
const sweep = async (env) => {
|
|
165
|
+
const { store, close } = lease(env);
|
|
166
|
+
try {
|
|
167
|
+
return await sweepSegments(env, store);
|
|
168
|
+
} finally {
|
|
169
|
+
await close();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
let applying;
|
|
173
|
+
let retryAt = 0;
|
|
174
|
+
const applyOwnBundle = (env, version) => {
|
|
175
|
+
if (version === void 0 || version.id === "" || Number.isNaN(version.createdAt)) return;
|
|
176
|
+
if (applying !== void 0 || Date.now() < retryAt) return void 0;
|
|
177
|
+
applying = (async () => {
|
|
178
|
+
const { store, close } = lease(env);
|
|
179
|
+
try {
|
|
180
|
+
const live = await store.liveBundleVersion();
|
|
181
|
+
if (live !== void 0 && (live.id === version.id || live.createdAt >= version.createdAt)) return;
|
|
182
|
+
if ((await deployBundle(env, bundle(), store, {
|
|
183
|
+
version,
|
|
184
|
+
config
|
|
185
|
+
})).applied) console.log(`[workflow] version ${version.id} is live`);
|
|
186
|
+
} finally {
|
|
187
|
+
await close();
|
|
188
|
+
}
|
|
189
|
+
})().catch((error) => {
|
|
190
|
+
applying = void 0;
|
|
191
|
+
if (error instanceof InFlightError) {
|
|
192
|
+
retryAt = Number.POSITIVE_INFINITY;
|
|
193
|
+
console.error(`[workflow] version ${version.id} is not applied: it would break in-flight journeys`, error.problems);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
retryAt = Date.now() + 6e4;
|
|
197
|
+
console.error(`[workflow] could not make version ${version.id} live`, error);
|
|
198
|
+
});
|
|
199
|
+
return applying;
|
|
200
|
+
};
|
|
201
|
+
const consume = (messages, env, store) => consumeBatches(env, messages, store, {
|
|
202
|
+
contract: config.contract,
|
|
203
|
+
mode: options.contractMode
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
config,
|
|
207
|
+
checkEnv,
|
|
208
|
+
lease,
|
|
209
|
+
bundle,
|
|
210
|
+
runParts,
|
|
211
|
+
handle,
|
|
212
|
+
sweep,
|
|
213
|
+
consume,
|
|
214
|
+
applyOwnBundle
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
export { EnvValidationError, createJourneyHost };
|
|
218
|
+
|
|
219
|
+
//# sourceMappingURL=journey-host.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journey-host.mjs","names":[],"sources":["../../src/host/journey-host.ts"],"sourcesContent":["import * as z from 'zod/mini';\nimport type * as core from 'zod/v4/core';\nimport { type JourneyConfig, compileConfig } from '../config';\nimport { type Contract, ContractValidationError, checkEvent } from '../contract';\nimport type { EmailTransport } from '../email-sender';\nimport { RegistryActionInvoker } from '../engine/actions';\nimport { profileUpdatedEvent } from '../engine/condition';\nimport type { JourneyObserver, MessageSender } from '../engine/ports';\nimport { RECIPIENT_PROPERTY } from '../engine/recipient';\nimport { scaleSegmentWindows } from '../engine/time-scale';\nimport type { BundleIR, NodeIR } from '../ir';\nimport { registryRenderer } from '../react-email';\nimport { composeObservers, decidesDelivery, reportingObserver } from '../reporting/observer';\nimport type { TrackingOptions } from '../reporting/tracking';\nimport type { JourneyRuntimeOptions } from '../runtime';\nimport type { BundleVersion, JourneyStore, StoreLease } from '../store/index';\nimport { DEFAULT_SCHEMA } from '../store/tables';\nimport { assertEmailConfig } from '../template-rules';\nimport { indexTemplates, registryValidator } from '../templates';\nimport type { Authorize } from './auth';\nimport { type QueueMessageLike, consumeBatches } from './batch';\nimport { channelsFromConfig, createProviderCache, runtimeFromConfig } from './channels';\nimport type { JourneyRunParts } from './execute';\nimport { serve } from './http';\nimport {\n InFlightError,\n type SweepResult,\n deployBundle,\n ingestEvent,\n removeDevice,\n sweepSegments,\n wakeSubscribers,\n} from './ingest';\nimport type { JourneyEnv, JourneyParams } from './platform';\nimport { WorkflowCache } from './workflow-cache';\n\n/**\n * What a journey host is, apart from the runtime it runs on: the validated environment, the\n * store lease, the outlets a run is wired to, the HTTP API (`http.ts`, with the host's parts\n * plugged in) and the bundle that goes live with the code. `journeyWorker` (Cloudflare) and\n * `journeyLambda` (AWS) are this plus how their platform starts, wakes and stops instances.\n */\n\nexport interface JourneyHostOptions<Env extends JourneyEnv> {\n /**\n * The project's `workflow.config.ts` (`defineConfig`): what the host deploys (`GET /bundle`,\n * `POST /bundle/deploy` serve `compileConfig`), the template registries the senders, the\n * validator and `/preview` render from, the contract every `/ingest` is\n * checked against, the email defaults, actions, and the runtime / APNs / FCM settings.\n * Secrets come from the env under the names `JourneyEnv` documents.\n */\n config: JourneyConfig;\n /**\n * The data plane, opened per request and per workflow run. Return a `StoreLease` when the\n * client must be released afterwards (a Postgres connection). `database` is the config's\n * (`schema` defaulting to `workflow`):\n *\n * store: (env, database) => postgresJsStore(env.DATABASE_URL, database)\n */\n store: (env: Env, database: { schema: string }) => JourneyStore | StoreLease;\n /**\n * Where journey emails go: a transport built from the validated env — `sesEmailTransport(...)`,\n * `cloudflareEmailTransport(...)`, or your own. Which one is independent of where the workflow\n * runs. Without it the email channel fails its sends, saying so.\n */\n email?: (env: Env) => EmailTransport;\n /**\n * Reporting hooks: node arrivals, every copy sent (with the tracking it should carry — click\n * links and an open pixel for email, payload data for a push), and how each instance ended.\n * By default the store records them itself, and the host serves the email tracking routes\n * (`/t/...`, on `WORKFLOW_ORIGIN`). An observer given here is added to that one, not put in\n * its place: the store's record is what delivers each copy at most once (the claim), so it is\n * kept and the hooks here run after its own, to report elsewhere as well. Only an observer\n * that decides delivery itself — one implementing `messageSettled`, `messageClaimed` and\n * `messageReleased`, as `reportingObserver` wrapped by hand does — stands alone.\n */\n observer?: (env: Env, store: JourneyStore) => JourneyObserver;\n /** Message outlet override (tests, a custom gateway): replaces every channel, `email` included. */\n messages?: (env: Env, store: JourneyStore) => MessageSender;\n /** Per-instance runtime options override (a tester in fast-forward); by default `config.runtime` for `ENVIRONMENT`. */\n runtime?: (env: Env, params: JourneyParams) => JourneyRuntimeOptions;\n /**\n * The host's environment, as a zod schema over its vars and secrets (bindings pass through\n * untouched): checked the first time the host runs, so a missing or malformed variable fails\n * there — every problem listed — not at the send that needs it. Webhook templates read their\n * URL from the parsed values: `webhook: (env: Env) => env.WEBHOOK_DISCORD_ALERTS`.\n */\n env?: core.$ZodType<object>;\n /** 'enforce' (default) answers an event or patch the contract refuses with a 400; 'report' only logs it. */\n contractMode?: 'enforce' | 'report';\n /**\n * Who may call the API routes, in whatever form the host chooses: an HMAC over the body, a\n * JWT, a header its proxy adds. Receives a copy of the request and the env; true lets it\n * through, false answers 401, a throw answers 500. The tracking routes and `/health` stay\n * public. Without it, the env's `API_TOKEN` as a bearer (`bearerMatches`), which production\n * then requires.\n *\n * authorize: async (request, env) =>\n * timingSafeEqual(request.headers.get('x-signature') ?? '', await hmac(env.SECRET, await request.text()))\n */\n authorize?: Authorize<Env>;\n}\n\n/** The host's environment failed its schema (`env` option). */\nexport class EnvValidationError extends Error {\n override readonly name = 'EnvValidationError';\n constructor(readonly issues: readonly string[]) {\n super(`the host's environment is invalid:\\n ${issues.join('\\n ')}`);\n }\n}\n\nexport interface JourneyHost<Env extends JourneyEnv> {\n config: JourneyConfig;\n /** The env, parsed by the schema once per env object (throws EnvValidationError). */\n checkEnv(env: Env): Env;\n /** A store for one request or run, its segment windows scaled with the runtime. */\n lease(env: Env): Required<StoreLease>;\n /** The bundle compiled into this code. */\n bundle(): BundleIR;\n /** The outlets one run is wired to (the store is the run's). */\n runParts(env: Env, store: JourneyStore, params: JourneyParams): JourneyRunParts;\n /**\n * The HTTP API over one store: the ingest API plus tracking, the sweep, the bundle and previews.\n * `version` is the code version serving the request, recorded by `POST /bundle/deploy`.\n */\n handle(\n request: Request,\n env: Env,\n store: JourneyStore,\n version?: BundleVersion\n ): Promise<Response>;\n /** The scheduled sweep (`sweepSegments`) on a store of its own. */\n sweep(env: Env): Promise<SweepResult>;\n /** Delivered `JourneyBatch` messages over one store, acknowledged or retried one by one. */\n consume(messages: readonly QueueMessageLike[], env: Env, store: JourneyStore): Promise<void>;\n /**\n * Make the bundle compiled into `version` live, once per process, only over an older live\n * version (the store records it). Undefined when there is nothing to do; a failure is logged\n * and retried a minute later.\n */\n applyOwnBundle(env: Env, version: BundleVersion | undefined): Promise<void> | undefined;\n}\n\n/** What the platform adapter itself contributes. */\nexport interface JourneyPlatform {\n /** An HTTP/2 fetch for APNs, where the runtime's own fetch is HTTP/1.1 (Node). */\n apnsFetch?: typeof fetch;\n}\n\nfunction sendsEmail(nodes: readonly NodeIR[]): boolean {\n return nodes.some((node) => {\n switch (node.type) {\n case 'message':\n return node.channel === 'email';\n case 'wait_until':\n return Array.isArray(node.onTimeout) && sendsEmail(node.onTimeout);\n case 'branch':\n return (\n node.cases.some((branch) => sendsEmail(branch.flow)) || sendsEmail(node.otherwise ?? [])\n );\n case 'cohort':\n return node.arms.some((arm) => sendsEmail(arm.flow));\n default:\n return false;\n }\n });\n}\n\nconst describeIssue = (issue: { path: PropertyKey[]; message: string }): string =>\n `${issue.path.join('.') || '(root)'}: ${issue.message}`;\n\n/** An event the host emits itself, checked against the contract like any ingest. */\nfunction checkedPayload(\n contract: Contract | undefined,\n event: string,\n payload: Record<string, unknown>\n): Record<string, unknown> {\n if (contract === undefined) return payload;\n const verdict = checkEvent(contract, event, payload);\n if (!verdict.ok) throw new ContractValidationError(event, verdict.issues);\n return verdict.data;\n}\n\nexport function createJourneyHost<Env extends JourneyEnv>(\n options: JourneyHostOptions<Env>,\n platform: JourneyPlatform = {}\n): JourneyHost<Env> {\n const { config } = options;\n const emailIds = indexTemplates('email', config.templates?.email);\n // A config still on `emails` (its sender would be silently dropped) fails here, not at a send\n assertEmailConfig(config, emailIds.values());\n let compiled: BundleIR | undefined;\n const bundle = () => (compiled ??= compileConfig(config));\n // A journey that emails with nowhere to send fails here too, not at its first email\n const emailing = bundle().workflows.filter((workflow) => sendsEmail(workflow.flow));\n if (options.email === undefined && options.messages === undefined && emailing.length > 0) {\n throw new TypeError(\n `workflows ${emailing.map((w) => `'${w.id}'`).join(', ')} send email, but the host has no ` +\n '`email` transport: pass `email: (env) => cloudflareEmailTransport(...)` or `sesEmailTransport(...)`'\n );\n }\n // Parsed once per env object: the runtime hands the same one to every request of an isolate\n const checked = new WeakMap<object, Env>();\n const checkEnv = (env: Env): Env => {\n if (options.env === undefined) return env;\n const cached = checked.get(env);\n if (cached !== undefined) return cached;\n const result = z.safeParse(options.env, env);\n // Names and reasons only: the values are secrets\n if (!result.success) throw new EnvValidationError(result.error.issues.map(describeIssue));\n const merged: Env = { ...env, ...result.data };\n checked.set(env, merged);\n return merged;\n };\n const emails = config.templates?.email;\n const database = { schema: config.database?.schema ?? DEFAULT_SCHEMA };\n // In fast-forward, segment windows scale with the journeys reading them (time-scale.ts)\n const lease = (env: Env): Required<StoreLease> => {\n const opened = options.store(env, database);\n const noop = async () => {};\n const factor = runtimeFromConfig(config, env).timeScale;\n return 'store' in opened\n ? { store: scaleSegmentWindows(opened.store, factor), close: opened.close ?? noop }\n : { store: scaleSegmentWindows(opened, factor), close: noop };\n };\n\n // The provider clients (APNs JWT, FCM access token) live with the host, not with a run: a\n // run's env is a fresh object on every Lambda invocation, so nothing keyed on it would be reused\n const providers = createProviderCache();\n const messages = (env: Env, store: JourneyStore): MessageSender => {\n if (options.messages !== undefined) return options.messages(env, store);\n return channelsFromConfig(config, env, {\n onDeadToken: (token) => removeDevice(env, token, store),\n email: options.email?.(env),\n apnsFetch: platform.apnsFetch,\n providers,\n });\n };\n\n // The host's own observer joins the store's instead of replacing it: the at-most-once claim\n // lives in the store's, and a host that only wanted to hear of sends would lose it unnoticed\n const observer = (env: Env, store: JourneyStore): JourneyObserver => {\n const reporting = reportingObserver(store.reporting, env.WORKFLOW_ORIGIN);\n if (options.observer === undefined) return reporting;\n const own = options.observer(env, store);\n return decidesDelivery(own) ? own : composeObservers(reporting, own);\n };\n\n /** One for the host's life: every run of a version after the first reads its body from here. */\n const workflows = new WorkflowCache();\n const runParts = (env: Env, store: JourneyStore, params: JourneyParams): JourneyRunParts => ({\n store,\n env,\n runtime:\n options.runtime === undefined ? runtimeFromConfig(config, env) : options.runtime(env, params),\n messages: messages(env, store),\n // An action ref is a registered action structurally: the same object carries name, code and hash\n actions: new RegistryActionInvoker(config.actions ?? []),\n contract: config.contract,\n validator: registryValidator(config.templates ?? {}),\n observer: observer(env, store),\n workflows,\n });\n\n const preview = emails === undefined ? undefined : registryRenderer(emails, config.email);\n\n /**\n * The recipients' routes (`/t/*`): a push tapped open is recorded as the config's\n * `webPush.openedEvent` — keyed by the copy, so a second tap of the same notification is the\n * same event — and an unsubscribe from all email wakes the waits reading email reachability\n * (`reachable('email')` subscribes to the email property's channel), so an `exitWhen:\n * not(reachable('email'))` takes effect without waiting for a timeout. An unsubscribe from one\n * topic wakes nothing: the user is still reachable.\n */\n const tracking = (env: Env, store: JourneyStore): TrackingOptions => {\n const opened = config.webPush?.openedEvent;\n return {\n product: config.title,\n quickMs: config.email?.tracking?.quickClickMs,\n pushOpened:\n opened === undefined\n ? undefined\n : async ({ messageId, userId, at }) => {\n const payload = checkedPayload(config.contract, opened, { message_id: messageId });\n const input = {\n id: `${opened}:${messageId}`,\n userId,\n event: opened,\n payload,\n ts: at,\n };\n await ingestEvent(env, input, store);\n },\n onUnsubscribed: async ({ userId, all }) => {\n // A topic opt-out leaves the user reachable by email: only the channel-wide one wakes\n if (!all) return;\n const email = profileUpdatedEvent(RECIPIENT_PROPERTY.email ?? 'email');\n await wakeSubscribers(env, store, userId, [email]);\n },\n };\n };\n\n const handle = (\n request: Request,\n env: Env,\n store: JourneyStore,\n version?: BundleVersion\n ): Promise<Response> =>\n serve(request, {\n env,\n store,\n validation: { contract: config.contract, mode: options.contractMode },\n authorize: options.authorize as Authorize<JourneyEnv> | undefined,\n host: {\n bundle,\n bundleVersion: version,\n config,\n preview:\n preview === undefined ? undefined : { has: (id) => emailIds.has(id), render: preview },\n tracking: tracking(env, store),\n sweep: () => sweepSegments(env, store),\n },\n });\n\n const sweep = async (env: Env) => {\n const { store, close } = lease(env);\n try {\n return await sweepSegments(env, store);\n } finally {\n await close();\n }\n };\n\n // The bundle compiled into this version goes live on its own, once per process: the first\n // request or scheduled run reads which version's bundle is live (one row) and applies this one\n // only over an older version, so one still serving during a rollout can never put its routes\n // back. A failure (say the migrations have not run) is logged and retried a minute later. Only\n // the request that starts the check gets its promise back: a request context cannot wait on\n // another's I/O.\n let applying: Promise<void> | undefined;\n let retryAt = 0;\n const applyOwnBundle = (env: Env, version: BundleVersion | undefined) => {\n if (version === undefined || version.id === '' || Number.isNaN(version.createdAt)) {\n return undefined;\n }\n if (applying !== undefined || Date.now() < retryAt) return undefined;\n applying = (async () => {\n const { store, close } = lease(env);\n try {\n const live = await store.liveBundleVersion();\n if (live !== undefined && (live.id === version.id || live.createdAt >= version.createdAt))\n return;\n const result = await deployBundle(env, bundle(), store, { version, config });\n if (result.applied) console.log(`[workflow] version ${version.id} is live`);\n } finally {\n await close();\n }\n })().catch((error: unknown) => {\n applying = undefined;\n if (error instanceof InFlightError) {\n // Nothing a retry would change: the routes stay as they are until a version that keeps\n // those journeys serving (or `POST /bundle/deploy?force=1`) — and the code of this one is\n // already serving, which is why the check belongs before publishing (`sendwend-studio plan`)\n retryAt = Number.POSITIVE_INFINITY;\n console.error(\n `[workflow] version ${version.id} is not applied: it would break in-flight journeys`,\n error.problems\n );\n return;\n }\n retryAt = Date.now() + 60_000;\n console.error(`[workflow] could not make version ${version.id} live`, error);\n });\n return applying;\n };\n\n const consume: JourneyHost<Env>['consume'] = (messages, env, store) =>\n consumeBatches(env, messages, store, {\n contract: config.contract,\n mode: options.contractMode,\n });\n\n return { config, checkEnv, lease, bundle, runParts, handle, sweep, consume, applyOwnBundle };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
// src/host/platform.ts
|
|
3
|
+
/**
|
|
4
|
+
* The runtime does not know the instance: the only lookup failure that lets the host drop the
|
|
5
|
+
* instance's wakes, or count it as stopped. Every `WorkflowBindingLike.get` answers it this way.
|
|
6
|
+
*/
|
|
7
|
+
var InstanceNotFoundError = class extends Error {
|
|
8
|
+
instanceId;
|
|
9
|
+
name = "InstanceNotFoundError";
|
|
10
|
+
constructor(instanceId, options) {
|
|
11
|
+
super(`no such instance: ${instanceId}`, options);
|
|
12
|
+
this.instanceId = instanceId;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** The event type the host uses to wake waiting instances (sendEvent's `type`). */
|
|
16
|
+
const WAKE_EVENT_TYPE = "wake";
|
|
17
|
+
exports.InstanceNotFoundError = InstanceNotFoundError;
|
|
18
|
+
exports.WAKE_EVENT_TYPE = WAKE_EVENT_TYPE;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=platform.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.cjs","names":[],"sources":["../../src/host/platform.ts"],"sourcesContent":["import type { ExecutionStart } from '../store/index';\nimport type { EmailBindingLike } from '../transports/cloudflare-email';\n\n/**\n * The runtime port: what the host needs from the platform it runs on, whichever one that is.\n * Cloudflare's Workflow binding satisfies it (`cloudflareJourneyBinding`), the AWS adapter's\n * `AwsInstances` implements it over durable executions.\n */\n\nexport interface WorkflowInstanceLike {\n id: string;\n sendEvent(event: { type: string; payload?: unknown }): Promise<void>;\n /** Stop the instance for good (Cloudflare Workflows' `terminate`). */\n terminate?(): Promise<void>;\n /** Where it stands (`complete`, `errored`, `terminated`, `running`, …). */\n status?(): Promise<{ status: string }>;\n}\n\n/** How the host starts, wakes and stops instances. */\nexport interface WorkflowBindingLike {\n create(options: { id: string; params: unknown }): Promise<WorkflowInstanceLike>;\n /** The instance, or an `InstanceNotFoundError` when the runtime does not know the id. */\n get(id: string): Promise<WorkflowInstanceLike>;\n /**\n * For a runtime whose start is a submit that can be lost in flight (AWS): the start to record\n * with the entry, in one transaction. A failed `create` then keeps the entry — its recorded\n * start is retried by the next ingest for the pair (`resume`) or by maintenance, never rolled\n * back and re-entered as a second execution.\n */\n plan?(options: {\n id: string;\n params: JourneyParams;\n ts: number;\n /** The code version whose routes named `params.contentHash` (absent after a forced deploy). */\n version?: string | undefined;\n }): Promise<ExecutionStart>;\n /** Retry the recorded, unconfirmed start of the (workflow, user) entry still running, if any. */\n resume?(entry: { workflow: string; userId: string }): Promise<void>;\n /**\n * Maintenance the sweep runs first: old unconfirmed starts retried (or given up on), and\n * executions the platform ended on its own (timeout, stop, crash) reconciled into the ledger.\n */\n maintain?(): Promise<void>;\n}\n\n/**\n * The runtime does not know the instance: the only lookup failure that lets the host drop the\n * instance's wakes, or count it as stopped. Every `WorkflowBindingLike.get` answers it this way.\n */\nexport class InstanceNotFoundError extends Error {\n override readonly name = 'InstanceNotFoundError';\n constructor(\n readonly instanceId: string,\n options?: ErrorOptions\n ) {\n super(`no such instance: ${instanceId}`, options);\n }\n}\n\n/** The event type the host uses to wake waiting instances (sendEvent's `type`). */\nexport const WAKE_EVENT_TYPE = 'wake';\n\n/** Journey instance parameters, passed by the host when it creates one. */\nexport interface JourneyParams {\n workflowId: string;\n /** The IR version pinned at entry. */\n contentHash: string;\n userId: string;\n /** `ts`: when the trigger happened, which can be long before a delayed delivery created this. */\n trigger: { event: string; payload: Record<string, unknown>; ts?: number };\n [key: string]: unknown;\n}\n\n/** Every binding, variable and secret the journey host reads (names match the wrangler config). */\nexport interface JourneyEnv {\n /** The runtime port: creating instances, waking and stopping them. */\n JOURNEY: WorkflowBindingLike;\n /** Optional message-delivery webhook (defaults to the console logging sender). */\n MESSAGE_WEBHOOK_URL?: string;\n /**\n * Bearer token required on every mutating HTTP endpoint (`Authorization:\n * Bearer <token>`). Unset = open — acceptable only for local dev; /deploy in\n * particular rewrites the whole routing table, so production must set this.\n */\n API_TOKEN?: string;\n /**\n * The host's public origin. With a store that keeps reporting (Postgres), journey emails'\n * links and open pixel point at its `/t/...` routes; without it emails go out untracked.\n */\n WORKFLOW_ORIGIN?: string;\n /** Which `workflow.config.ts` entry applies (`development`, `production`, …); production when unset. */\n ENVIRONMENT?: string;\n /** Cloudflare Email Sending, when the config has `emails`. */\n EMAIL?: EmailBindingLike;\n /** The APNs auth key (`.p8`, base64) named by the config's `apns.keyId`. */\n APNS_PRIVATE_KEY_BASE64?: string;\n /** The Firebase service account (base64 JSON) the config's `fcm` sends with. */\n GOOGLE_APPLICATION_CREDENTIALS_BASE64?: string;\n /** The VAPID key pair web pushes are signed with (`generateVapidKeys`); the config's `webPush` turns the channel on. */\n VAPID_PUBLIC_KEY?: string;\n VAPID_PRIVATE_KEY?: string;\n /**\n * Cloudflare's version metadata binding (wrangler `\"version_metadata\": { \"binding\":\n * \"CF_VERSION_METADATA\" }`). With it, and a store that records the live version (Postgres),\n * journeyWorker makes the bundle compiled into each new version live by itself: `wrangler\n * deploy` is the whole deploy.\n */\n CF_VERSION_METADATA?: { id: string; tag?: string; timestamp: string };\n /** Development only: the HTTP/2 relay `wrangler dev` sends APNs requests through (see `sendwend/apns-relay`). */\n APNS_RELAY_ORIGIN?: string;\n}\n"],"mappings":";;;;;;AAiDA,IAAa,wBAAb,cAA2C,MAAM;CAGpC;CAFO,OAAO;CACzB,YACW,YACT,SACA;EACA,MAAM,qBAAqB,cAAc,OAAO;EAHvC,KAAA,aAAA;CAIX;AACF;;AAGA,MAAa,kBAAkB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ExecutionStart } from "../store/index.cjs";
|
|
2
|
+
import { EmailBindingLike } from "../transports/cloudflare-email.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* The runtime port: what the host needs from the platform it runs on, whichever one that is.
|
|
5
|
+
* Cloudflare's Workflow binding satisfies it (`cloudflareJourneyBinding`), the AWS adapter's
|
|
6
|
+
* `AwsInstances` implements it over durable executions.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkflowInstanceLike {
|
|
9
|
+
id: string;
|
|
10
|
+
sendEvent(event: {
|
|
11
|
+
type: string;
|
|
12
|
+
payload?: unknown;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
/** Stop the instance for good (Cloudflare Workflows' `terminate`). */
|
|
15
|
+
terminate?(): Promise<void>;
|
|
16
|
+
/** Where it stands (`complete`, `errored`, `terminated`, `running`, …). */
|
|
17
|
+
status?(): Promise<{
|
|
18
|
+
status: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
/** How the host starts, wakes and stops instances. */
|
|
22
|
+
export interface WorkflowBindingLike {
|
|
23
|
+
create(options: {
|
|
24
|
+
id: string;
|
|
25
|
+
params: unknown;
|
|
26
|
+
}): Promise<WorkflowInstanceLike>;
|
|
27
|
+
/** The instance, or an `InstanceNotFoundError` when the runtime does not know the id. */
|
|
28
|
+
get(id: string): Promise<WorkflowInstanceLike>;
|
|
29
|
+
/**
|
|
30
|
+
* For a runtime whose start is a submit that can be lost in flight (AWS): the start to record
|
|
31
|
+
* with the entry, in one transaction. A failed `create` then keeps the entry — its recorded
|
|
32
|
+
* start is retried by the next ingest for the pair (`resume`) or by maintenance, never rolled
|
|
33
|
+
* back and re-entered as a second execution.
|
|
34
|
+
*/
|
|
35
|
+
plan?(options: {
|
|
36
|
+
id: string;
|
|
37
|
+
params: JourneyParams;
|
|
38
|
+
ts: number;
|
|
39
|
+
/** The code version whose routes named `params.contentHash` (absent after a forced deploy). */
|
|
40
|
+
version?: string | undefined;
|
|
41
|
+
}): Promise<ExecutionStart>;
|
|
42
|
+
/** Retry the recorded, unconfirmed start of the (workflow, user) entry still running, if any. */
|
|
43
|
+
resume?(entry: {
|
|
44
|
+
workflow: string;
|
|
45
|
+
userId: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Maintenance the sweep runs first: old unconfirmed starts retried (or given up on), and
|
|
49
|
+
* executions the platform ended on its own (timeout, stop, crash) reconciled into the ledger.
|
|
50
|
+
*/
|
|
51
|
+
maintain?(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The runtime does not know the instance: the only lookup failure that lets the host drop the
|
|
55
|
+
* instance's wakes, or count it as stopped. Every `WorkflowBindingLike.get` answers it this way.
|
|
56
|
+
*/
|
|
57
|
+
export declare class InstanceNotFoundError extends Error {
|
|
58
|
+
readonly instanceId: string;
|
|
59
|
+
readonly name = "InstanceNotFoundError";
|
|
60
|
+
constructor(instanceId: string, options?: ErrorOptions);
|
|
61
|
+
}
|
|
62
|
+
/** The event type the host uses to wake waiting instances (sendEvent's `type`). */
|
|
63
|
+
export declare const WAKE_EVENT_TYPE = "wake";
|
|
64
|
+
/** Journey instance parameters, passed by the host when it creates one. */
|
|
65
|
+
export interface JourneyParams {
|
|
66
|
+
workflowId: string;
|
|
67
|
+
/** The IR version pinned at entry. */
|
|
68
|
+
contentHash: string;
|
|
69
|
+
userId: string;
|
|
70
|
+
/** `ts`: when the trigger happened, which can be long before a delayed delivery created this. */
|
|
71
|
+
trigger: {
|
|
72
|
+
event: string;
|
|
73
|
+
payload: Record<string, unknown>;
|
|
74
|
+
ts?: number;
|
|
75
|
+
};
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
/** Every binding, variable and secret the journey host reads (names match the wrangler config). */
|
|
79
|
+
export interface JourneyEnv {
|
|
80
|
+
/** The runtime port: creating instances, waking and stopping them. */
|
|
81
|
+
JOURNEY: WorkflowBindingLike;
|
|
82
|
+
/** Optional message-delivery webhook (defaults to the console logging sender). */
|
|
83
|
+
MESSAGE_WEBHOOK_URL?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Bearer token required on every mutating HTTP endpoint (`Authorization:
|
|
86
|
+
* Bearer <token>`). Unset = open — acceptable only for local dev; /deploy in
|
|
87
|
+
* particular rewrites the whole routing table, so production must set this.
|
|
88
|
+
*/
|
|
89
|
+
API_TOKEN?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The host's public origin. With a store that keeps reporting (Postgres), journey emails'
|
|
92
|
+
* links and open pixel point at its `/t/...` routes; without it emails go out untracked.
|
|
93
|
+
*/
|
|
94
|
+
WORKFLOW_ORIGIN?: string;
|
|
95
|
+
/** Which `workflow.config.ts` entry applies (`development`, `production`, …); production when unset. */
|
|
96
|
+
ENVIRONMENT?: string;
|
|
97
|
+
/** Cloudflare Email Sending, when the config has `emails`. */
|
|
98
|
+
EMAIL?: EmailBindingLike;
|
|
99
|
+
/** The APNs auth key (`.p8`, base64) named by the config's `apns.keyId`. */
|
|
100
|
+
APNS_PRIVATE_KEY_BASE64?: string;
|
|
101
|
+
/** The Firebase service account (base64 JSON) the config's `fcm` sends with. */
|
|
102
|
+
GOOGLE_APPLICATION_CREDENTIALS_BASE64?: string;
|
|
103
|
+
/** The VAPID key pair web pushes are signed with (`generateVapidKeys`); the config's `webPush` turns the channel on. */
|
|
104
|
+
VAPID_PUBLIC_KEY?: string;
|
|
105
|
+
VAPID_PRIVATE_KEY?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Cloudflare's version metadata binding (wrangler `"version_metadata": { "binding":
|
|
108
|
+
* "CF_VERSION_METADATA" }`). With it, and a store that records the live version (Postgres),
|
|
109
|
+
* journeyWorker makes the bundle compiled into each new version live by itself: `wrangler
|
|
110
|
+
* deploy` is the whole deploy.
|
|
111
|
+
*/
|
|
112
|
+
CF_VERSION_METADATA?: {
|
|
113
|
+
id: string;
|
|
114
|
+
tag?: string;
|
|
115
|
+
timestamp: string;
|
|
116
|
+
};
|
|
117
|
+
/** Development only: the HTTP/2 relay `wrangler dev` sends APNs requests through (see `sendwend/apns-relay`). */
|
|
118
|
+
APNS_RELAY_ORIGIN?: string;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=platform.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.cts","names":[],"sources":["../../src/host/platform.ts"],"mappings":";;;;;;;iBASiB;EACf;EACA,UAAU;IAAS;IAAc;MAAsB;;EAEvD,cAAc;;EAEd,WAAW;IAAU;;;;iBAIN;EACf,OAAO;IAAW;IAAY;MAAoB,QAAQ;;EAE1D,IAAI,aAAa,QAAQ;;;;;;;EAOzB,MAAM;IACJ;IACA,QAAQ;IACR;;IAEA;MACE,QAAQ;;EAEZ,QAAQ;IAAS;IAAkB;MAAmB;;;;;EAKtD,aAAa;;;;;;qBAOF,8BAA8B;WAG9B;WAFO;EAClB,YACW,oBACT,UAAU;;;qBAOD;;iBAGI;EACf;;EAEA;EACA;;EAEA;IAAW;IAAe,SAAS;IAAyB;;GAC3D;;;iBAIc;;EAEf,SAAS;;EAET;;;;;;EAMA;;;;;EAKA;;EAEA;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;EACA;;;;;;;EAOA;IAAwB;IAAY;IAAc;;;EAElD"}
|