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,61 @@
|
|
|
1
|
+
import { JourneyConfig } from "../config.mjs";
|
|
2
|
+
import { Contract } from "../contract.mjs";
|
|
3
|
+
import { EmailRenderer } from "../email-sender.mjs";
|
|
4
|
+
import { BundleIR } from "../ir.mjs";
|
|
5
|
+
import { TrackingOptions } from "../reporting/tracking.mjs";
|
|
6
|
+
import { BundleVersion, JourneyStore } from "../store/index.mjs";
|
|
7
|
+
import { Authorize } from "./auth.mjs";
|
|
8
|
+
import { SweepResult } from "./ingest.mjs";
|
|
9
|
+
import { JourneyEnv } from "./platform.mjs";
|
|
10
|
+
/**
|
|
11
|
+
* The HTTP surface, as one route table: the bare ingest API (`handleRequest`) and the routes
|
|
12
|
+
* the full host adds (`serve` with its parts — the bundle, previews, tracking, the sweep). A
|
|
13
|
+
* route whose part is absent answers 404, so the two share the table, the bearer check, the
|
|
14
|
+
* body validation and the error mapping.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* How the ingest API applies a contract: 'enforce' refuses an invalid event or
|
|
18
|
+
* patch with a 400 before anything is stored, woken or started; 'report' logs
|
|
19
|
+
* the issues (event id, name, field paths — never the payload) and accepts it,
|
|
20
|
+
* for checking real producers before turning enforcement on.
|
|
21
|
+
*/
|
|
22
|
+
export interface IngestValidation {
|
|
23
|
+
contract?: Contract | undefined;
|
|
24
|
+
mode?: 'enforce' | 'report' | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** What the full host serves beyond the ingest API. A route whose part is absent answers 404. */
|
|
27
|
+
export interface HostParts {
|
|
28
|
+
/** The bundle compiled into the code: `GET /bundle` shows it, `POST /bundle/deploy` makes it live. */
|
|
29
|
+
bundle?: (() => BundleIR) | undefined;
|
|
30
|
+
/** The code version serving this request, recorded as live by `POST /bundle/deploy`. */
|
|
31
|
+
bundleVersion?: BundleVersion | undefined;
|
|
32
|
+
/** The config the code serves: a deploy checks the templates pinned journeys still send against it. */
|
|
33
|
+
config?: JourneyConfig | undefined;
|
|
34
|
+
/** `GET /preview/:id?props=<JSON>`: the email templates, rendered. */
|
|
35
|
+
preview?: {
|
|
36
|
+
has(id: string): boolean;
|
|
37
|
+
render: EmailRenderer;
|
|
38
|
+
} | undefined;
|
|
39
|
+
/** `/t/*`, what recipients open (no bearer): served on a store that keeps reporting. */
|
|
40
|
+
tracking?: TrackingOptions | undefined;
|
|
41
|
+
/** `POST /segments/sweep`. */
|
|
42
|
+
sweep?: (() => Promise<SweepResult>) | undefined;
|
|
43
|
+
}
|
|
44
|
+
export interface ServeContext {
|
|
45
|
+
env: JourneyEnv;
|
|
46
|
+
store: JourneyStore;
|
|
47
|
+
validation?: IngestValidation | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The host's parts. Their presence is what makes this a deployed host rather than the bare
|
|
50
|
+
* API: production then refuses to serve without `API_TOKEN` — unless the host authorizes
|
|
51
|
+
* callers itself (`authorize`).
|
|
52
|
+
*/
|
|
53
|
+
host?: HostParts | undefined;
|
|
54
|
+
/** The host's own authorization for the API routes; the env's `API_TOKEN` bearer without one. */
|
|
55
|
+
authorize?: Authorize<JourneyEnv> | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** One request through the table: the production gate, the bearer, the route, the error mapping. */
|
|
58
|
+
export declare function serve(request: Request, ctx: ServeContext): Promise<Response>;
|
|
59
|
+
/** The bare ingest API over one store: `/health`, `/events`, `/identify`, `/devices*`, `/messages/opened`, `/subscriptions/:userId`, `/subscriptions/by-message/:messageId`, `/users/forget`, `/deploy`. */
|
|
60
|
+
export declare function handleRequest(request: Request, env: JourneyEnv, store: JourneyStore, validation?: IngestValidation): Promise<Response>;
|
|
61
|
+
//# sourceMappingURL=http.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.mts","names":[],"sources":["../../src/host/http.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;iBAkDiB;EACf,WAAW;EACX;;;iBAIe;;EAEf,gBAAgB;;EAEhB,gBAAgB;;EAEhB,SAAS;;EAET;IAAY,IAAI;IAAsB,QAAQ;;;EAE9C,WAAW;;EAEX,eAAe,QAAQ;;iBAGR;EACf,KAAK;EACL,OAAO;EACP,aAAa;;;;;;EAMb,OAAO;;EAEP,YAAY,UAAU;;;wBA8ZF,MAAM,SAAS,SAAS,KAAK,eAAe,QAAQ;;wBA8C1D,cACd,SAAS,SACT,KAAK,YACL,OAAO,cACP,aAAY,mBACX,QAAQ"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
2
|
+
import { PREVIEW_MESSAGE_ID } from "../email.mjs";
|
|
3
|
+
import { handleTracking, recordPushOpen } from "../reporting/tracking.mjs";
|
|
4
|
+
import { UserErasedError } from "../store/erasure.mjs";
|
|
5
|
+
import { visitorSubject } from "../store/identity.mjs";
|
|
6
|
+
import { SchemaMismatchError } from "../store/index.mjs";
|
|
7
|
+
import { TemplateValidationError } from "../templates.mjs";
|
|
8
|
+
import { isPushServiceEndpoint, subscriptionEndpoint } from "../webpush.mjs";
|
|
9
|
+
import { authorized } from "./auth.mjs";
|
|
10
|
+
import { identityError, ingestBatch, isNonEmptyString, isPlainObject, parseBatch } from "./batch.mjs";
|
|
11
|
+
import { journeyMode } from "./channels.mjs";
|
|
12
|
+
import { BundleIntegrityError, EventPayloadTooLargeError, InFlightError, deployBundle, forgetUser, getSubscriptions, getSubscriptionsByMessage, parseSubscriptionsPatch, registerDevice, removeDevice, setSubscriptions, setSubscriptionsByMessage, unbindDevice } from "./ingest.mjs";
|
|
13
|
+
// src/host/http.ts
|
|
14
|
+
/** `?force=1` on a deploy route: deploy although it breaks in-flight journeys (see `DeployOptions`). */
|
|
15
|
+
const breaksInFlight = (url) => url.searchParams.get("force") === "1";
|
|
16
|
+
const json = (body, status = 200) => new Response(JSON.stringify(body), {
|
|
17
|
+
status,
|
|
18
|
+
headers: { "content-type": "application/json" }
|
|
19
|
+
});
|
|
20
|
+
const notFound = () => json({ error: "not found" }, 404);
|
|
21
|
+
/** The request body is not JSON: the caller's to fix (a 400), not a server fault. */
|
|
22
|
+
var InvalidJsonError = class extends Error {
|
|
23
|
+
name = "InvalidJsonError";
|
|
24
|
+
};
|
|
25
|
+
async function readJson(request) {
|
|
26
|
+
try {
|
|
27
|
+
return await request.json();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new InvalidJsonError("invalid JSON body", { cause: error });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Request bodies are untrusted JSON. They are read as unknown fields and
|
|
34
|
+
* checked, never cast into the shape they are supposed to have: a cast only
|
|
35
|
+
* silences the compiler, and what arrives here reaches SQL parameters.
|
|
36
|
+
*/
|
|
37
|
+
async function readBody(request) {
|
|
38
|
+
const body = await readJson(request);
|
|
39
|
+
return isPlainObject(body) ? body : {};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The topics the engine knows: the deployed bundle's list (compiled from the contract), or the
|
|
43
|
+
* contract's when the bare API runs without a host — never the caller's.
|
|
44
|
+
*/
|
|
45
|
+
function declaredTopics(ctx) {
|
|
46
|
+
return ctx.host.bundle?.().subscriptions?.topics ?? ctx.validation.contract?.topics ?? [];
|
|
47
|
+
}
|
|
48
|
+
const SUBSCRIPTIONS = /^\/subscriptions\/[^/]+$/;
|
|
49
|
+
const subscriptionsUser = (url) => decodeURIComponent(url.pathname.slice(15));
|
|
50
|
+
/**
|
|
51
|
+
* The same record, reached by one of the user's copies instead of their id: for the app's
|
|
52
|
+
* preference page opened from an email's `preferencesUrl?m=<message>` without a sign-in. The
|
|
53
|
+
* message id is the capability (an unguessable UUID, as `/t/u` trusts it); the bearer still
|
|
54
|
+
* guards the route, so the page's own API proxies it, and rate-limits it as it sees fit.
|
|
55
|
+
*/
|
|
56
|
+
const SUBSCRIPTIONS_BY_MESSAGE = /^\/subscriptions\/by-message\/[^/]+$/;
|
|
57
|
+
const subscriptionsMessage = (url) => decodeURIComponent(url.pathname.slice(26));
|
|
58
|
+
const routes = [
|
|
59
|
+
{
|
|
60
|
+
method: "GET",
|
|
61
|
+
path: "/health",
|
|
62
|
+
auth: "none",
|
|
63
|
+
handle: async () => json({ ok: true })
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
method: "*",
|
|
67
|
+
path: /^\/t\//,
|
|
68
|
+
auth: "none",
|
|
69
|
+
async handle({ request, store, host }) {
|
|
70
|
+
if (host.tracking === void 0) return notFound();
|
|
71
|
+
return await handleTracking(request, store.reporting, host.tracking) ?? notFound();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
method: "POST",
|
|
76
|
+
path: "/ingest",
|
|
77
|
+
auth: "api",
|
|
78
|
+
async handle({ request, env, store, validation }) {
|
|
79
|
+
const parsed = parseBatch(await readJson(request), validation);
|
|
80
|
+
if (!parsed.ok) {
|
|
81
|
+
const { error, issues } = parsed;
|
|
82
|
+
return json({
|
|
83
|
+
error,
|
|
84
|
+
...issues === void 0 ? {} : { issues }
|
|
85
|
+
}, 400);
|
|
86
|
+
}
|
|
87
|
+
return json(await ingestBatch(env, parsed.batch, store));
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: "/devices",
|
|
93
|
+
auth: "api",
|
|
94
|
+
async handle({ request, env, store, host }) {
|
|
95
|
+
const { deviceId, userId, visitorId, token, platform } = await readBody(request);
|
|
96
|
+
const refused = identityError(userId, visitorId);
|
|
97
|
+
if (refused !== void 0) return json({ error: refused }, 400);
|
|
98
|
+
if (deviceId !== void 0 && !isNonEmptyString(deviceId)) return json({ error: "deviceId must be a non-empty string" }, 400);
|
|
99
|
+
if (!isNonEmptyString(token)) return json({ error: "token required" }, 400);
|
|
100
|
+
if (platform !== "ios" && platform !== "android" && platform !== "web") return json({ error: "platform must be 'ios', 'android' or 'web'" }, 400);
|
|
101
|
+
if (platform === "web") {
|
|
102
|
+
const endpoint = subscriptionEndpoint(token);
|
|
103
|
+
if (endpoint === void 0) return json({ error: "token must be a PushSubscription as JSON for platform web" }, 400);
|
|
104
|
+
if (!isPushServiceEndpoint(endpoint, host.config?.webPush?.pushServices)) return json({ error: "the subscription's endpoint is not a known push service's (https, on FCM, Mozilla, WNS or Apple); other hosts are named in the config's webPush.pushServices" }, 400);
|
|
105
|
+
}
|
|
106
|
+
return json(await registerDevice(env, {
|
|
107
|
+
deviceId,
|
|
108
|
+
userId,
|
|
109
|
+
visitorId,
|
|
110
|
+
token,
|
|
111
|
+
platform
|
|
112
|
+
}, store));
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
method: "POST",
|
|
117
|
+
path: "/devices/unbind",
|
|
118
|
+
auth: "api",
|
|
119
|
+
async handle({ request, env, store }) {
|
|
120
|
+
const { token } = await readBody(request);
|
|
121
|
+
if (!isNonEmptyString(token)) return json({ error: "token required" }, 400);
|
|
122
|
+
return json(await unbindDevice(env, token, store));
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
method: "POST",
|
|
127
|
+
path: "/devices/remove",
|
|
128
|
+
auth: "api",
|
|
129
|
+
async handle({ request, env, store }) {
|
|
130
|
+
const { token } = await readBody(request);
|
|
131
|
+
if (!isNonEmptyString(token)) return json({ error: "token required" }, 400);
|
|
132
|
+
return json(await removeDevice(env, token, store));
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
method: "POST",
|
|
137
|
+
path: "/messages/opened",
|
|
138
|
+
auth: "api",
|
|
139
|
+
async handle({ request, store }) {
|
|
140
|
+
const { userId, messageId } = await readBody(request);
|
|
141
|
+
if (!isNonEmptyString(userId)) return json({ error: "userId required" }, 400);
|
|
142
|
+
if (!isNonEmptyString(messageId)) return json({ error: "messageId required" }, 400);
|
|
143
|
+
const recorded = await recordPushOpen(store.reporting, userId, messageId);
|
|
144
|
+
return json({
|
|
145
|
+
ok: true,
|
|
146
|
+
recorded
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
method: "GET",
|
|
152
|
+
path: SUBSCRIPTIONS,
|
|
153
|
+
auth: "api",
|
|
154
|
+
async handle(ctx) {
|
|
155
|
+
const userId = subscriptionsUser(ctx.url);
|
|
156
|
+
if (userId === "") return json({ error: "userId required" }, 400);
|
|
157
|
+
return json(await getSubscriptions(ctx.store, userId, declaredTopics(ctx)));
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
method: "PUT",
|
|
162
|
+
path: SUBSCRIPTIONS,
|
|
163
|
+
auth: "api",
|
|
164
|
+
async handle(ctx) {
|
|
165
|
+
const userId = subscriptionsUser(ctx.url);
|
|
166
|
+
if (userId === "") return json({ error: "userId required" }, 400);
|
|
167
|
+
const topics = declaredTopics(ctx);
|
|
168
|
+
const parsed = parseSubscriptionsPatch(await readJson(ctx.request), topics);
|
|
169
|
+
if (!parsed.ok) return json({
|
|
170
|
+
error: "subscriptions refused",
|
|
171
|
+
issues: parsed.issues
|
|
172
|
+
}, 400);
|
|
173
|
+
return json(await setSubscriptions(ctx.env, ctx.store, userId, parsed.patch, topics));
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
method: "GET",
|
|
178
|
+
path: SUBSCRIPTIONS_BY_MESSAGE,
|
|
179
|
+
auth: "api",
|
|
180
|
+
async handle(ctx) {
|
|
181
|
+
const messageId = subscriptionsMessage(ctx.url);
|
|
182
|
+
const found = await getSubscriptionsByMessage(ctx.store, messageId, declaredTopics(ctx));
|
|
183
|
+
return found === void 0 ? json({ error: "unknown message" }, 404) : json(found);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
method: "PUT",
|
|
188
|
+
path: SUBSCRIPTIONS_BY_MESSAGE,
|
|
189
|
+
auth: "api",
|
|
190
|
+
async handle(ctx) {
|
|
191
|
+
const messageId = subscriptionsMessage(ctx.url);
|
|
192
|
+
const topics = declaredTopics(ctx);
|
|
193
|
+
const parsed = parseSubscriptionsPatch(await readJson(ctx.request), topics);
|
|
194
|
+
if (!parsed.ok) return json({
|
|
195
|
+
error: "subscriptions refused",
|
|
196
|
+
issues: parsed.issues
|
|
197
|
+
}, 400);
|
|
198
|
+
const found = await setSubscriptionsByMessage(ctx.env, ctx.store, messageId, parsed.patch, topics);
|
|
199
|
+
return found === void 0 ? json({ error: "unknown message" }, 404) : json(found);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
method: "POST",
|
|
204
|
+
path: "/users/forget",
|
|
205
|
+
auth: "api",
|
|
206
|
+
async handle({ request, env, store }) {
|
|
207
|
+
const { userId, visitorId } = await readBody(request);
|
|
208
|
+
if (isNonEmptyString(visitorId)) return json(await forgetUser(env, visitorSubject(visitorId), store));
|
|
209
|
+
if (!isNonEmptyString(userId)) return json({ error: "userId or visitorId required" }, 400);
|
|
210
|
+
return json(await forgetUser(env, userId, store));
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
method: "POST",
|
|
215
|
+
path: "/deploy",
|
|
216
|
+
auth: "api",
|
|
217
|
+
async handle({ request, url, env, store, host }) {
|
|
218
|
+
if (host.bundle !== void 0 && journeyMode(env) === "production") return json({ error: "deploy by publishing a version (POST /bundle/deploy applies its own bundle)" }, 409);
|
|
219
|
+
const options = {
|
|
220
|
+
config: host.config,
|
|
221
|
+
breakInFlight: breaksInFlight(url)
|
|
222
|
+
};
|
|
223
|
+
return json(await deployBundle(env, await readJson(request), store, options));
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
method: "GET",
|
|
228
|
+
path: "/bundle",
|
|
229
|
+
auth: "api",
|
|
230
|
+
async handle({ host }) {
|
|
231
|
+
return host.bundle === void 0 ? notFound() : json(host.bundle());
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
method: "POST",
|
|
236
|
+
path: "/bundle/deploy",
|
|
237
|
+
auth: "api",
|
|
238
|
+
async handle({ url, env, store, host }) {
|
|
239
|
+
if (host.bundle === void 0) return notFound();
|
|
240
|
+
const options = {
|
|
241
|
+
version: host.bundleVersion,
|
|
242
|
+
force: true,
|
|
243
|
+
config: host.config,
|
|
244
|
+
breakInFlight: breaksInFlight(url)
|
|
245
|
+
};
|
|
246
|
+
return json(await deployBundle(env, host.bundle(), store, options));
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
method: "POST",
|
|
251
|
+
path: "/segments/sweep",
|
|
252
|
+
auth: "api",
|
|
253
|
+
async handle({ host }) {
|
|
254
|
+
return host.sweep === void 0 ? notFound() : json(await host.sweep());
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
method: "GET",
|
|
259
|
+
path: /^\/preview\//,
|
|
260
|
+
auth: "api",
|
|
261
|
+
async handle({ url, host }) {
|
|
262
|
+
const { preview } = host;
|
|
263
|
+
if (preview === void 0) return notFound();
|
|
264
|
+
const key = url.pathname.slice(9);
|
|
265
|
+
if (!preview.has(key)) return json({ error: `unknown email template: ${key}` }, 404);
|
|
266
|
+
let props;
|
|
267
|
+
try {
|
|
268
|
+
props = JSON.parse(url.searchParams.get("props") ?? "{}");
|
|
269
|
+
} catch {
|
|
270
|
+
return json({ error: "props must be a JSON object" }, 400);
|
|
271
|
+
}
|
|
272
|
+
if (!isPlainObject(props)) return json({ error: "props must be a JSON object" }, 400);
|
|
273
|
+
const { subject, html } = await preview.render(key, props, { messageId: PREVIEW_MESSAGE_ID });
|
|
274
|
+
return new Response(html, { headers: {
|
|
275
|
+
"content-type": "text/html; charset=utf-8",
|
|
276
|
+
"x-subject": encodeURIComponent(subject)
|
|
277
|
+
} });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
];
|
|
281
|
+
function matches(path, pathname) {
|
|
282
|
+
if (typeof path === "string") return path === pathname;
|
|
283
|
+
if (path instanceof RegExp) return path.test(pathname);
|
|
284
|
+
return path(pathname);
|
|
285
|
+
}
|
|
286
|
+
/** The modes that run open without being named anywhere: local work and test runs. */
|
|
287
|
+
const OPEN_MODES = /* @__PURE__ */ new Set(["development", "test"]);
|
|
288
|
+
/**
|
|
289
|
+
* Whether `ENVIRONMENT` names a mode that may serve without a token. Open is what has to be
|
|
290
|
+
* asked for, by name: `development`, `test`, or a mode the config gives a `runtime` entry of its
|
|
291
|
+
* own (`rehearsal`). Anything else is held to production's rule — `production` itself, an
|
|
292
|
+
* unset var, and a value nobody declared, which is how a typo reads (`prod`, `Production`,
|
|
293
|
+
* a `staging` copied from another project): comparing against the one string `production`
|
|
294
|
+
* would serve all of those open, `/deploy` and `/users/forget` included.
|
|
295
|
+
*/
|
|
296
|
+
function runsOpen(ctx) {
|
|
297
|
+
const mode = journeyMode(ctx.env);
|
|
298
|
+
if (mode === "production") return false;
|
|
299
|
+
if (OPEN_MODES.has(mode)) return true;
|
|
300
|
+
const declared = ctx.host?.config?.runtime;
|
|
301
|
+
return declared !== void 0 && Object.hasOwn(declared, mode);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Without a bearer token (and no authorizer of the host's own) a mode that does not run open
|
|
305
|
+
* is not an open instance, it is a mistake: anyone could ingest, identify and deploy. Only what
|
|
306
|
+
* recipients open (`/t/*`) and the health check stay up.
|
|
307
|
+
*/
|
|
308
|
+
function refusesOpen(request, ctx, pathname) {
|
|
309
|
+
return ctx.authorize === void 0 && ctx.env.API_TOKEN === void 0 && !runsOpen(ctx) && !pathname.startsWith("/t/") && !(request.method === "GET" && pathname === "/health");
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Whether the caller may use an API route: the host's authorizer on a copy of the request (so a
|
|
313
|
+
* body it verifies is still there for the route), or the env's `API_TOKEN` as a bearer. An
|
|
314
|
+
* authorizer that throws is a failure, never an admission.
|
|
315
|
+
*/
|
|
316
|
+
async function allowed(request, ctx) {
|
|
317
|
+
if (ctx.authorize === void 0) return authorized(request, ctx.env);
|
|
318
|
+
return ctx.authorize(request.clone(), ctx.env);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* What a failed request answers. Validation problems are the caller's to fix (a 400, saying
|
|
322
|
+
* what); anything else stays out of the response body (internals are logged, not leaked).
|
|
323
|
+
*/
|
|
324
|
+
function failure(error) {
|
|
325
|
+
if (error instanceof InvalidJsonError) return json({ error: "invalid JSON body" }, 400);
|
|
326
|
+
if (error instanceof z.core.$ZodError) return json({ error: `invalid payload: ${error.message}` }, 400);
|
|
327
|
+
if (error instanceof BundleIntegrityError) return json({ error: error.message }, 400);
|
|
328
|
+
if (error instanceof InFlightError) return json({
|
|
329
|
+
error: error.message,
|
|
330
|
+
problems: error.problems
|
|
331
|
+
}, 409);
|
|
332
|
+
if (error instanceof TemplateValidationError) return json({
|
|
333
|
+
error: error.message,
|
|
334
|
+
issues: error.issues
|
|
335
|
+
}, 400);
|
|
336
|
+
if (error instanceof UserErasedError) return json({ error: "user is erased" }, 410);
|
|
337
|
+
if (error instanceof EventPayloadTooLargeError) return json({ error: error.message }, 413);
|
|
338
|
+
if (error instanceof SchemaMismatchError) return json({
|
|
339
|
+
error: error.message,
|
|
340
|
+
problems: error.problems
|
|
341
|
+
}, 503);
|
|
342
|
+
console.error("[workflow http]", error);
|
|
343
|
+
return json({ error: "internal error" }, 500);
|
|
344
|
+
}
|
|
345
|
+
/** One request through the table: the production gate, the bearer, the route, the error mapping. */
|
|
346
|
+
async function serve(request, ctx) {
|
|
347
|
+
const url = new URL(request.url);
|
|
348
|
+
if (refusesOpen(request, ctx, url.pathname)) {
|
|
349
|
+
const mode = journeyMode(ctx.env);
|
|
350
|
+
return json({ error: mode === "production" ? "API_TOKEN is not set: production refuses to serve without it (set ENVIRONMENT=development to run open)" : `API_TOKEN is not set, and ENVIRONMENT=${JSON.stringify(mode)} is not a mode that runs open: set API_TOKEN, or use 'development', 'test' or a mode with a runtime entry in the config` }, 503);
|
|
351
|
+
}
|
|
352
|
+
const candidates = routes.filter((route) => matches(route.path, url.pathname));
|
|
353
|
+
if (candidates.length === 0) return notFound();
|
|
354
|
+
if (candidates.some((route) => route.auth === "api")) {
|
|
355
|
+
let ok;
|
|
356
|
+
try {
|
|
357
|
+
ok = await allowed(request, ctx);
|
|
358
|
+
} catch (error) {
|
|
359
|
+
console.error("[workflow http] authorize failed", error);
|
|
360
|
+
return json({ error: "internal error" }, 500);
|
|
361
|
+
}
|
|
362
|
+
if (!ok) return json({ error: "unauthorized" }, 401);
|
|
363
|
+
}
|
|
364
|
+
const route = candidates.find((r) => r.method === "*" || r.method === request.method);
|
|
365
|
+
if (route === void 0) return json({ error: "method not allowed" }, 405);
|
|
366
|
+
try {
|
|
367
|
+
return await route.handle({
|
|
368
|
+
request,
|
|
369
|
+
url,
|
|
370
|
+
env: ctx.env,
|
|
371
|
+
store: ctx.store,
|
|
372
|
+
validation: ctx.validation ?? {},
|
|
373
|
+
host: ctx.host ?? {}
|
|
374
|
+
});
|
|
375
|
+
} catch (error) {
|
|
376
|
+
return failure(error);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/** The bare ingest API over one store: `/health`, `/events`, `/identify`, `/devices*`, `/messages/opened`, `/subscriptions/:userId`, `/subscriptions/by-message/:messageId`, `/users/forget`, `/deploy`. */
|
|
380
|
+
function handleRequest(request, env, store, validation = {}) {
|
|
381
|
+
return serve(request, {
|
|
382
|
+
env,
|
|
383
|
+
store,
|
|
384
|
+
validation
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
export { handleRequest, serve };
|
|
388
|
+
|
|
389
|
+
//# sourceMappingURL=http.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.mjs","names":[],"sources":["../../src/host/http.ts"],"sourcesContent":["import * as z from 'zod/mini';\nimport type { JourneyConfig } from '../config';\nimport type { Contract } from '../contract';\nimport { PREVIEW_MESSAGE_ID } from '../email';\nimport type { EmailRenderer } from '../email-sender';\nimport type { BundleIR, ScalarIR } from '../ir';\nimport { type TrackingOptions, handleTracking, recordPushOpen } from '../reporting/tracking';\nimport {\n type BundleVersion,\n type JourneyStore,\n SchemaMismatchError,\n UserErasedError,\n visitorSubject,\n} from '../store/index';\nimport { TemplateValidationError } from '../templates';\nimport { isPushServiceEndpoint, subscriptionEndpoint } from '../webpush';\nimport { type Authorize, authorized } from './auth';\nimport { identityError, ingestBatch, isNonEmptyString, isPlainObject, parseBatch } from './batch';\nimport { journeyMode } from './channels';\nimport {\n BundleIntegrityError,\n EventPayloadTooLargeError,\n InFlightError,\n type SweepResult,\n deployBundle,\n forgetUser,\n getSubscriptions,\n getSubscriptionsByMessage,\n parseSubscriptionsPatch,\n registerDevice,\n removeDevice,\n setSubscriptions,\n setSubscriptionsByMessage,\n unbindDevice,\n} from './ingest';\nimport type { JourneyEnv } from './platform';\n\n/**\n * The HTTP surface, as one route table: the bare ingest API (`handleRequest`) and the routes\n * the full host adds (`serve` with its parts — the bundle, previews, tracking, the sweep). A\n * route whose part is absent answers 404, so the two share the table, the bearer check, the\n * body validation and the error mapping.\n */\n\n/**\n * How the ingest API applies a contract: 'enforce' refuses an invalid event or\n * patch with a 400 before anything is stored, woken or started; 'report' logs\n * the issues (event id, name, field paths — never the payload) and accepts it,\n * for checking real producers before turning enforcement on.\n */\nexport interface IngestValidation {\n contract?: Contract | undefined;\n mode?: 'enforce' | 'report' | undefined;\n}\n\n/** What the full host serves beyond the ingest API. A route whose part is absent answers 404. */\nexport interface HostParts {\n /** The bundle compiled into the code: `GET /bundle` shows it, `POST /bundle/deploy` makes it live. */\n bundle?: (() => BundleIR) | undefined;\n /** The code version serving this request, recorded as live by `POST /bundle/deploy`. */\n bundleVersion?: BundleVersion | undefined;\n /** The config the code serves: a deploy checks the templates pinned journeys still send against it. */\n config?: JourneyConfig | undefined;\n /** `GET /preview/:id?props=<JSON>`: the email templates, rendered. */\n preview?: { has(id: string): boolean; render: EmailRenderer } | undefined;\n /** `/t/*`, what recipients open (no bearer): served on a store that keeps reporting. */\n tracking?: TrackingOptions | undefined;\n /** `POST /segments/sweep`. */\n sweep?: (() => Promise<SweepResult>) | undefined;\n}\n\nexport interface ServeContext {\n env: JourneyEnv;\n store: JourneyStore;\n validation?: IngestValidation | undefined;\n /**\n * The host's parts. Their presence is what makes this a deployed host rather than the bare\n * API: production then refuses to serve without `API_TOKEN` — unless the host authorizes\n * callers itself (`authorize`).\n */\n host?: HostParts | undefined;\n /** The host's own authorization for the API routes; the env's `API_TOKEN` bearer without one. */\n authorize?: Authorize<JourneyEnv> | undefined;\n}\n\ninterface RouteContext {\n request: Request;\n url: URL;\n env: JourneyEnv;\n store: JourneyStore;\n validation: IngestValidation;\n host: HostParts;\n}\n\ninterface Route {\n /** '*' takes every method (the tracking routes answer GET, HEAD and POST themselves). */\n method: 'GET' | 'POST' | 'PUT' | '*';\n path: string | RegExp | ((pathname: string) => boolean);\n /** `api`: the caller must be authorized (the host's `authorize`, or the bearer); `none`: public. */\n auth: 'none' | 'api';\n handle(ctx: RouteContext): Promise<Response>;\n}\n\n/** `?force=1` on a deploy route: deploy although it breaks in-flight journeys (see `DeployOptions`). */\nconst breaksInFlight = (url: URL): boolean => url.searchParams.get('force') === '1';\n\nconst json = (body: unknown, status = 200): Response =>\n new Response(JSON.stringify(body), {\n status,\n headers: { 'content-type': 'application/json' },\n });\n\nconst notFound = () => json({ error: 'not found' }, 404);\n\n/* --------------------------------- bodies ---------------------------------- */\n\n/** The request body is not JSON: the caller's to fix (a 400), not a server fault. */\nclass InvalidJsonError extends Error {\n override readonly name = 'InvalidJsonError';\n}\n\nasync function readJson(request: Request): Promise<unknown> {\n try {\n return await request.json();\n } catch (error) {\n throw new InvalidJsonError('invalid JSON body', { cause: error });\n }\n}\n\n/**\n * Request bodies are untrusted JSON. They are read as unknown fields and\n * checked, never cast into the shape they are supposed to have: a cast only\n * silences the compiler, and what arrives here reaches SQL parameters.\n */\nasync function readBody(request: Request): Promise<Record<string, unknown>> {\n const body = await readJson(request);\n return isPlainObject(body) ? body : {};\n}\n\n/**\n * The topics the engine knows: the deployed bundle's list (compiled from the contract), or the\n * contract's when the bare API runs without a host — never the caller's.\n */\nfunction declaredTopics(ctx: Pick<RouteContext, 'host' | 'validation'>): readonly string[] {\n return ctx.host.bundle?.().subscriptions?.topics ?? ctx.validation.contract?.topics ?? [];\n}\n\nconst SUBSCRIPTIONS = /^\\/subscriptions\\/[^/]+$/;\nconst subscriptionsUser = (url: URL) =>\n decodeURIComponent(url.pathname.slice('/subscriptions/'.length));\n/**\n * The same record, reached by one of the user's copies instead of their id: for the app's\n * preference page opened from an email's `preferencesUrl?m=<message>` without a sign-in. The\n * message id is the capability (an unguessable UUID, as `/t/u` trusts it); the bearer still\n * guards the route, so the page's own API proxies it, and rate-limits it as it sees fit.\n */\nconst SUBSCRIPTIONS_BY_MESSAGE = /^\\/subscriptions\\/by-message\\/[^/]+$/;\nconst subscriptionsMessage = (url: URL) =>\n decodeURIComponent(url.pathname.slice('/subscriptions/by-message/'.length));\n\n/* --------------------------------- routes ---------------------------------- */\n\nconst routes: readonly Route[] = [\n { method: 'GET', path: '/health', auth: 'none', handle: async () => json({ ok: true }) },\n {\n // Opened by recipients, so no bearer: the routes only record, and redirect to recorded URLs\n method: '*',\n path: /^\\/t\\//,\n auth: 'none',\n async handle({ request, store, host }) {\n if (host.tracking === undefined) return notFound();\n return (await handleTracking(request, store.reporting, host.tracking)) ?? notFound();\n },\n },\n {\n method: 'POST',\n path: '/ingest',\n auth: 'api',\n async handle({ request, env, store, validation }) {\n const parsed = parseBatch(await readJson(request), validation);\n if (!parsed.ok) {\n const { error, issues } = parsed;\n return json({ error, ...(issues === undefined ? {} : { issues }) }, 400);\n }\n return json(await ingestBatch(env, parsed.batch, store));\n },\n },\n {\n method: 'POST',\n path: '/devices',\n auth: 'api',\n async handle({ request, env, store, host }) {\n const { deviceId, userId, visitorId, token, platform } = await readBody(request);\n const refused = identityError(userId, visitorId);\n if (refused !== undefined) return json({ error: refused }, 400);\n if (deviceId !== undefined && !isNonEmptyString(deviceId)) {\n return json({ error: 'deviceId must be a non-empty string' }, 400);\n }\n if (!isNonEmptyString(token)) return json({ error: 'token required' }, 400);\n if (platform !== 'ios' && platform !== 'android' && platform !== 'web') {\n return json({ error: \"platform must be 'ios', 'android' or 'web'\" }, 400);\n }\n // A browser's subscription names the URL pushes are POSTed to: one that is not a push\n // service's is refused here, where the caller can be told, rather than kept and dropped\n // at its first send\n if (platform === 'web') {\n const endpoint = subscriptionEndpoint(token);\n if (endpoint === undefined) {\n return json({ error: 'token must be a PushSubscription as JSON for platform web' }, 400);\n }\n if (!isPushServiceEndpoint(endpoint, host.config?.webPush?.pushServices)) {\n return json(\n {\n error:\n \"the subscription's endpoint is not a known push service's (https, on FCM, Mozilla, WNS or Apple); other hosts are named in the config's webPush.pushServices\",\n },\n 400\n );\n }\n }\n const device = {\n deviceId,\n userId: userId as string | undefined,\n visitorId: visitorId as string | undefined,\n token,\n platform,\n };\n return json(await registerDevice(env, device, store));\n },\n },\n {\n method: 'POST',\n path: '/devices/unbind',\n auth: 'api',\n async handle({ request, env, store }) {\n const { token } = await readBody(request);\n if (!isNonEmptyString(token)) return json({ error: 'token required' }, 400);\n return json(await unbindDevice(env, token, store));\n },\n },\n {\n method: 'POST',\n path: '/devices/remove',\n auth: 'api',\n async handle({ request, env, store }) {\n const { token } = await readBody(request);\n if (!isNonEmptyString(token)) return json({ error: 'token required' }, 400);\n return json(await removeDevice(env, token, store));\n },\n },\n {\n method: 'POST',\n path: '/messages/opened',\n auth: 'api',\n async handle({ request, store }) {\n const { userId, messageId } = await readBody(request);\n if (!isNonEmptyString(userId)) return json({ error: 'userId required' }, 400);\n if (!isNonEmptyString(messageId)) return json({ error: 'messageId required' }, 400);\n const recorded = await recordPushOpen(store.reporting, userId, messageId);\n return json({ ok: true, recorded });\n },\n },\n {\n method: 'GET',\n path: SUBSCRIPTIONS,\n auth: 'api',\n async handle(ctx) {\n const userId = subscriptionsUser(ctx.url);\n if (userId === '') return json({ error: 'userId required' }, 400);\n return json(await getSubscriptions(ctx.store, userId, declaredTopics(ctx)));\n },\n },\n {\n method: 'PUT',\n path: SUBSCRIPTIONS,\n auth: 'api',\n async handle(ctx) {\n const userId = subscriptionsUser(ctx.url);\n if (userId === '') return json({ error: 'userId required' }, 400);\n const topics = declaredTopics(ctx);\n const parsed = parseSubscriptionsPatch(await readJson(ctx.request), topics);\n if (!parsed.ok) return json({ error: 'subscriptions refused', issues: parsed.issues }, 400);\n return json(await setSubscriptions(ctx.env, ctx.store, userId, parsed.patch, topics));\n },\n },\n {\n method: 'GET',\n path: SUBSCRIPTIONS_BY_MESSAGE,\n auth: 'api',\n async handle(ctx) {\n const messageId = subscriptionsMessage(ctx.url);\n const found = await getSubscriptionsByMessage(ctx.store, messageId, declaredTopics(ctx));\n return found === undefined ? json({ error: 'unknown message' }, 404) : json(found);\n },\n },\n {\n method: 'PUT',\n path: SUBSCRIPTIONS_BY_MESSAGE,\n auth: 'api',\n async handle(ctx) {\n const messageId = subscriptionsMessage(ctx.url);\n const topics = declaredTopics(ctx);\n const parsed = parseSubscriptionsPatch(await readJson(ctx.request), topics);\n if (!parsed.ok) return json({ error: 'subscriptions refused', issues: parsed.issues }, 400);\n const found = await setSubscriptionsByMessage(\n ctx.env,\n ctx.store,\n messageId,\n parsed.patch,\n topics\n );\n return found === undefined ? json({ error: 'unknown message' }, 404) : json(found);\n },\n },\n {\n method: 'POST',\n path: '/users/forget',\n auth: 'api',\n async handle({ request, env, store }) {\n const { userId, visitorId } = await readBody(request);\n if (isNonEmptyString(visitorId)) {\n return json(await forgetUser(env, visitorSubject(visitorId), store));\n }\n if (!isNonEmptyString(userId)) return json({ error: 'userId or visitorId required' }, 400);\n return json(await forgetUser(env, userId, store));\n },\n },\n {\n method: 'POST',\n path: '/deploy',\n auth: 'api',\n async handle({ request, url, env, store, host }) {\n // A host that carries its bundle deploys it by publishing a version (the new version applies\n // its own on its first request, `POST /bundle/deploy` re-applies it after a rollback): in\n // production a bundle posted by hand is never legitimate, only what a leaked bearer would\n // do with the routing table. The bare API, which carries none, has no other way to deploy.\n if (host.bundle !== undefined && journeyMode(env) === 'production') {\n return json(\n { error: 'deploy by publishing a version (POST /bundle/deploy applies its own bundle)' },\n 409\n );\n }\n const options = { config: host.config, breakInFlight: breaksInFlight(url) };\n return json(await deployBundle(env, await readJson(request), store, options));\n },\n },\n {\n method: 'GET',\n path: '/bundle',\n auth: 'api',\n async handle({ host }) {\n return host.bundle === undefined ? notFound() : json(host.bundle());\n },\n },\n {\n method: 'POST',\n path: '/bundle/deploy',\n auth: 'api',\n async handle({ url, env, store, host }) {\n if (host.bundle === undefined) return notFound();\n // Forced, and recording the serving version: otherwise an older version still serving\n // during a rollout would put its routes live while the row kept naming the newer one —\n // which then never re-applies its own bundle\n const options = {\n version: host.bundleVersion,\n force: true,\n config: host.config,\n breakInFlight: breaksInFlight(url),\n };\n return json(await deployBundle(env, host.bundle(), store, options));\n },\n },\n {\n method: 'POST',\n path: '/segments/sweep',\n auth: 'api',\n async handle({ host }) {\n return host.sweep === undefined ? notFound() : json(await host.sweep());\n },\n },\n {\n method: 'GET',\n path: /^\\/preview\\//,\n auth: 'api',\n async handle({ url, host }) {\n const { preview } = host;\n if (preview === undefined) return notFound();\n const key = url.pathname.slice('/preview/'.length);\n if (!preview.has(key)) return json({ error: `unknown email template: ${key}` }, 404);\n // `?props=<JSON object>`: JSON keeps numbers and booleans typed, which query strings cannot\n let props: unknown;\n try {\n props = JSON.parse(url.searchParams.get('props') ?? '{}');\n } catch {\n return json({ error: 'props must be a JSON object' }, 400);\n }\n if (!isPlainObject(props)) return json({ error: 'props must be a JSON object' }, 400);\n // A preview is no copy, but it shows the footer a sent one has: the preferences link\n // renders with a placeholder message id\n const { subject, html } = await preview.render(key, props as Record<string, ScalarIR>, {\n messageId: PREVIEW_MESSAGE_ID,\n });\n // A header holds bytes, not text: a subject with a non-Latin-1 character would throw\n // here, so it travels percent-encoded (the reader `decodeURIComponent`s it)\n return new Response(html, {\n headers: {\n 'content-type': 'text/html; charset=utf-8',\n 'x-subject': encodeURIComponent(subject),\n },\n });\n },\n },\n];\n\nfunction matches(path: Route['path'], pathname: string): boolean {\n if (typeof path === 'string') return path === pathname;\n if (path instanceof RegExp) return path.test(pathname);\n return path(pathname);\n}\n\n/** The modes that run open without being named anywhere: local work and test runs. */\nconst OPEN_MODES: ReadonlySet<string> = new Set(['development', 'test']);\n\n/**\n * Whether `ENVIRONMENT` names a mode that may serve without a token. Open is what has to be\n * asked for, by name: `development`, `test`, or a mode the config gives a `runtime` entry of its\n * own (`rehearsal`). Anything else is held to production's rule — `production` itself, an\n * unset var, and a value nobody declared, which is how a typo reads (`prod`, `Production`,\n * a `staging` copied from another project): comparing against the one string `production`\n * would serve all of those open, `/deploy` and `/users/forget` included.\n */\nfunction runsOpen(ctx: ServeContext): boolean {\n const mode = journeyMode(ctx.env);\n if (mode === 'production') return false;\n if (OPEN_MODES.has(mode)) return true;\n const declared = ctx.host?.config?.runtime;\n return declared !== undefined && Object.hasOwn(declared, mode);\n}\n\n/**\n * Without a bearer token (and no authorizer of the host's own) a mode that does not run open\n * is not an open instance, it is a mistake: anyone could ingest, identify and deploy. Only what\n * recipients open (`/t/*`) and the health check stay up.\n */\nfunction refusesOpen(request: Request, ctx: ServeContext, pathname: string): boolean {\n return (\n ctx.authorize === undefined &&\n ctx.env.API_TOKEN === undefined &&\n !runsOpen(ctx) &&\n !pathname.startsWith('/t/') &&\n !(request.method === 'GET' && pathname === '/health')\n );\n}\n\n/**\n * Whether the caller may use an API route: the host's authorizer on a copy of the request (so a\n * body it verifies is still there for the route), or the env's `API_TOKEN` as a bearer. An\n * authorizer that throws is a failure, never an admission.\n */\nasync function allowed(request: Request, ctx: ServeContext): Promise<boolean> {\n if (ctx.authorize === undefined) return authorized(request, ctx.env);\n return ctx.authorize(request.clone(), ctx.env);\n}\n\n/**\n * What a failed request answers. Validation problems are the caller's to fix (a 400, saying\n * what); anything else stays out of the response body (internals are logged, not leaked).\n */\nfunction failure(error: unknown): Response {\n if (error instanceof InvalidJsonError) return json({ error: 'invalid JSON body' }, 400);\n if (error instanceof z.core.$ZodError) {\n return json({ error: `invalid payload: ${error.message}` }, 400);\n }\n // The caller sent a self-inconsistent bundle: their problem to fix, so say what is wrong\n if (error instanceof BundleIntegrityError) return json({ error: error.message }, 400);\n // The bundle would break journeys still running: the deploy is refused until the bundle keeps\n // them (or the caller says `?force=1`), and the answer lists which ones and why\n if (error instanceof InFlightError) {\n return json({ error: error.message, problems: error.problems }, 409);\n }\n // The query string is the props: a refusal is the caller's to fix, with the field paths\n if (error instanceof TemplateValidationError) {\n return json({ error: error.message, issues: error.issues }, 400);\n }\n // The user has an erasure tombstone: gone, and nothing about them is taken, now or later\n if (error instanceof UserErasedError) return json({ error: 'user is erased' }, 410);\n if (error instanceof EventPayloadTooLargeError) return json({ error: error.message }, 413);\n // The operator's to fix (run the migrations), so the response says what is missing\n if (error instanceof SchemaMismatchError) {\n return json({ error: error.message, problems: error.problems }, 503);\n }\n console.error('[workflow http]', error);\n return json({ error: 'internal error' }, 500);\n}\n\n/** One request through the table: the production gate, the bearer, the route, the error mapping. */\nexport async function serve(request: Request, ctx: ServeContext): Promise<Response> {\n const url = new URL(request.url);\n if (refusesOpen(request, ctx, url.pathname)) {\n const mode = journeyMode(ctx.env);\n return json(\n {\n error:\n mode === 'production'\n ? 'API_TOKEN is not set: production refuses to serve without it (set ENVIRONMENT=development to run open)'\n : `API_TOKEN is not set, and ENVIRONMENT=${JSON.stringify(mode)} is not a mode that runs open: set API_TOKEN, or use 'development', 'test' or a mode with a runtime entry in the config`,\n },\n 503\n );\n }\n const candidates = routes.filter((route) => matches(route.path, url.pathname));\n if (candidates.length === 0) return notFound();\n // Every API route asks the authorizer; the health check and the recipients' routes never do.\n // An unset token and no authorizer means an open dev instance (see JourneyEnv.API_TOKEN);\n // production refuses to run that way\n if (candidates.some((route) => route.auth === 'api')) {\n let ok: boolean;\n try {\n ok = await allowed(request, ctx);\n } catch (error) {\n console.error('[workflow http] authorize failed', error);\n return json({ error: 'internal error' }, 500);\n }\n if (!ok) return json({ error: 'unauthorized' }, 401);\n }\n const route = candidates.find((r) => r.method === '*' || r.method === request.method);\n if (route === undefined) return json({ error: 'method not allowed' }, 405);\n try {\n return await route.handle({\n request,\n url,\n env: ctx.env,\n store: ctx.store,\n validation: ctx.validation ?? {},\n host: ctx.host ?? {},\n });\n } catch (error) {\n return failure(error);\n }\n}\n\n/** The bare ingest API over one store: `/health`, `/events`, `/identify`, `/devices*`, `/messages/opened`, `/subscriptions/:userId`, `/subscriptions/by-message/:messageId`, `/users/forget`, `/deploy`. */\nexport function handleRequest(\n request: Request,\n env: JourneyEnv,\n store: JourneyStore,\n validation: IngestValidation = {}\n): Promise<Response> {\n return serve(request, { env, store, validation });\n}\n"],"mappings":";;;;;;;;;;;;;;AAwGA,MAAM,kBAAkB,QAAsB,IAAI,aAAa,IAAI,OAAO,MAAM;AAEhF,MAAM,QAAQ,MAAe,SAAS,QACpC,IAAI,SAAS,KAAK,UAAU,IAAI,GAAG;CACjC;CACA,SAAS,EAAE,gBAAgB,mBAAmB;AAChD,CAAC;AAEH,MAAM,iBAAiB,KAAK,EAAE,OAAO,YAAY,GAAG,GAAG;;AAKvD,IAAM,mBAAN,cAA+B,MAAM;CACjB,OAAO;AAC3B;AAEA,eAAe,SAAS,SAAoC;CAC1D,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK;CAC5B,SAAS,OAAO;EACd,MAAM,IAAI,iBAAiB,qBAAqB,EAAE,OAAO,MAAM,CAAC;CAClE;AACF;;;;;;AAOA,eAAe,SAAS,SAAoD;CAC1E,MAAM,OAAO,MAAM,SAAS,OAAO;CACnC,OAAO,cAAc,IAAI,IAAI,OAAO,CAAC;AACvC;;;;;AAMA,SAAS,eAAe,KAAmE;CACzF,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,eAAe,UAAU,IAAI,WAAW,UAAU,UAAU,CAAC;AAC1F;AAEA,MAAM,gBAAgB;AACtB,MAAM,qBAAqB,QACzB,mBAAmB,IAAI,SAAS,MAAM,EAAwB,CAAC;;;;;;;AAOjE,MAAM,2BAA2B;AACjC,MAAM,wBAAwB,QAC5B,mBAAmB,IAAI,SAAS,MAAM,EAAmC,CAAC;AAI5E,MAAM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