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,653 @@
|
|
|
1
|
+
// src/store/tables.ts
|
|
2
|
+
function table(spec) {
|
|
3
|
+
return spec;
|
|
4
|
+
}
|
|
5
|
+
const uuid = { type: "uuid" };
|
|
6
|
+
const text = { type: "text" };
|
|
7
|
+
const jsonb = { type: "jsonb" };
|
|
8
|
+
const ts = { type: "timestamptz" };
|
|
9
|
+
const integer = { type: "integer" };
|
|
10
|
+
const boolean = { type: "boolean" };
|
|
11
|
+
const nullable = (column, doc) => ({
|
|
12
|
+
...column,
|
|
13
|
+
nullable: true,
|
|
14
|
+
...doc === void 0 ? {} : { doc }
|
|
15
|
+
});
|
|
16
|
+
const TABLES = {
|
|
17
|
+
event: table({
|
|
18
|
+
name: "event",
|
|
19
|
+
doc: "Every ingested event, the fact base for `performed(...)` conditions. `event_id` is the occurrence's identity as the sender chose it (a retrying producer sends the same one again), scoped to the user: the (user_id, event_id) unique index makes a second delivery a no-op, and one sender's id can never block another user's event.",
|
|
20
|
+
columns: {
|
|
21
|
+
id: uuid,
|
|
22
|
+
eventId: text,
|
|
23
|
+
userId: text,
|
|
24
|
+
name: text,
|
|
25
|
+
ts,
|
|
26
|
+
payload: jsonb
|
|
27
|
+
},
|
|
28
|
+
primaryKey: ["id"],
|
|
29
|
+
uuidV7: "id",
|
|
30
|
+
uniqueIndexes: [["userId", "eventId"]],
|
|
31
|
+
indexes: [[
|
|
32
|
+
"userId",
|
|
33
|
+
"name",
|
|
34
|
+
"ts"
|
|
35
|
+
]]
|
|
36
|
+
}),
|
|
37
|
+
profile: table({
|
|
38
|
+
name: "profile",
|
|
39
|
+
doc: "Identified properties per user (`/ingest` merges into `props`; a null value means unset).",
|
|
40
|
+
columns: {
|
|
41
|
+
userId: text,
|
|
42
|
+
props: jsonb,
|
|
43
|
+
propsAt: nullable(jsonb, "When each property was last written, epoch ms by key (a cleared one too): an older patch cannot overwrite it. Null for a row older than this column.")
|
|
44
|
+
},
|
|
45
|
+
primaryKey: ["userId"]
|
|
46
|
+
}),
|
|
47
|
+
device: table({
|
|
48
|
+
name: "device",
|
|
49
|
+
doc: "Push devices, one row per device, holding only who it belongs to now (`JourneyClient.registerDevice`): a signed-in `user_id`, or a `visitor_id` alone before sign-in. Signing out clears both rather than removing the row; a token APNs / FCM reports as gone is removed.",
|
|
50
|
+
columns: {
|
|
51
|
+
deviceId: nullable(text, "The device across token rotations: a new token replaces the old one. Null when the producer sent none."),
|
|
52
|
+
userId: nullable(text),
|
|
53
|
+
visitorId: nullable(text, "The visitor on the device now, kept once signed in: it tells one of a user's devices from another."),
|
|
54
|
+
token: text,
|
|
55
|
+
platform: text,
|
|
56
|
+
createdAt: ts,
|
|
57
|
+
updatedAt: ts
|
|
58
|
+
},
|
|
59
|
+
primaryKey: ["token"],
|
|
60
|
+
uniqueIndexes: [["deviceId"]],
|
|
61
|
+
indexes: [["userId"], ["visitorId"]]
|
|
62
|
+
}),
|
|
63
|
+
visitor: table({
|
|
64
|
+
name: "visitor",
|
|
65
|
+
doc: "Visitors the engine has heard from. `user_id` is who they became (`linkVisitor`): a late event of the visitor reaches the user, and the row outlives the user's erasure, so such an event finds the tombstone instead of starting a new visitor. One that never signs in is pruned once idle.",
|
|
66
|
+
columns: {
|
|
67
|
+
visitorId: text,
|
|
68
|
+
userId: nullable(text),
|
|
69
|
+
createdAt: ts,
|
|
70
|
+
updatedAt: ts
|
|
71
|
+
},
|
|
72
|
+
primaryKey: ["visitorId"],
|
|
73
|
+
indexes: [["userId"], ["updatedAt"]]
|
|
74
|
+
}),
|
|
75
|
+
erasure: table({
|
|
76
|
+
name: "erasure",
|
|
77
|
+
doc: "Erasure tombstones (`forgetUser`): every write about a user is conditional on no row here. While `erased_at` is null the user's data stays until every running instance is stopped, and the scheduled sweep retries what is left; once set, the data is gone and the row stays so the user id is never written again.",
|
|
78
|
+
columns: {
|
|
79
|
+
userId: text,
|
|
80
|
+
requestedAt: ts,
|
|
81
|
+
erasedAt: nullable(ts, "When the data was erased; null while the erasure is under way.")
|
|
82
|
+
},
|
|
83
|
+
primaryKey: ["userId"]
|
|
84
|
+
}),
|
|
85
|
+
suppression: table({
|
|
86
|
+
name: "suppression",
|
|
87
|
+
doc: "What a user opted out of: a topic on a channel (an email unsubscribe from one topic, a push topic switched off in the app), or the whole channel when `topic` is null — the engine sends nothing there, and `reachable(channel)` is false. One row per (user, channel, topic), nulls included.",
|
|
88
|
+
columns: {
|
|
89
|
+
userId: text,
|
|
90
|
+
channel: text,
|
|
91
|
+
topic: nullable(text, "The subscription topic opted out of; null for the whole channel (every row from before topics existed)."),
|
|
92
|
+
ts
|
|
93
|
+
},
|
|
94
|
+
uniqueConstraints: [{
|
|
95
|
+
columns: [
|
|
96
|
+
"userId",
|
|
97
|
+
"channel",
|
|
98
|
+
"topic"
|
|
99
|
+
],
|
|
100
|
+
nullsNotDistinct: true
|
|
101
|
+
}]
|
|
102
|
+
}),
|
|
103
|
+
segment: table({
|
|
104
|
+
name: "segment",
|
|
105
|
+
doc: "Deployed segment definitions, resolved by name at evaluation time.",
|
|
106
|
+
columns: {
|
|
107
|
+
id: text,
|
|
108
|
+
condition: jsonb,
|
|
109
|
+
hash: text,
|
|
110
|
+
seedingSince: nullable(ts, "Set when a deploy brings the segment in new or with a changed condition, cleared by the first sweep to complete after it. While set, whoever matches is recorded as a member without a journey being started: they were already in it, they did not enter.")
|
|
111
|
+
},
|
|
112
|
+
primaryKey: ["id"]
|
|
113
|
+
}),
|
|
114
|
+
trigger: table({
|
|
115
|
+
name: "trigger",
|
|
116
|
+
doc: "Event-trigger routes: `where` gates on the event payload, `filter` on the profile.",
|
|
117
|
+
columns: {
|
|
118
|
+
workflow: text,
|
|
119
|
+
hash: text,
|
|
120
|
+
reentry: {
|
|
121
|
+
type: "jsonb",
|
|
122
|
+
doc: "The workflow's re-entry policy (`ReentryIR`), carried with the route so an entry is decided without reading the IR."
|
|
123
|
+
},
|
|
124
|
+
event: text,
|
|
125
|
+
where: nullable(jsonb),
|
|
126
|
+
filter: nullable(jsonb),
|
|
127
|
+
visitors: nullable({ type: "boolean" }, "Whether a visitor not signed in may enter (`trigger.event(e.x, { visitors: true })`); signed-in users only otherwise."),
|
|
128
|
+
version: nullable(text, "The code version whose compiled bundle put this route here (null after a forced deploy): an instance it starts runs on that version, so its IR and its code always match.")
|
|
129
|
+
},
|
|
130
|
+
primaryKey: ["workflow"],
|
|
131
|
+
indexes: [["event"]]
|
|
132
|
+
}),
|
|
133
|
+
dateTrigger: table({
|
|
134
|
+
name: "date_trigger",
|
|
135
|
+
doc: "Date-trigger routes: at `at`, a journey for every known user `filter` holds for.",
|
|
136
|
+
columns: {
|
|
137
|
+
workflow: text,
|
|
138
|
+
hash: text,
|
|
139
|
+
reentry: {
|
|
140
|
+
type: "jsonb",
|
|
141
|
+
doc: "The workflow's re-entry policy (`ReentryIR`), as on `trigger`."
|
|
142
|
+
},
|
|
143
|
+
at: ts,
|
|
144
|
+
filter: nullable(jsonb),
|
|
145
|
+
version: nullable(text, "As on `trigger`.")
|
|
146
|
+
},
|
|
147
|
+
primaryKey: ["workflow"]
|
|
148
|
+
}),
|
|
149
|
+
dateRun: table({
|
|
150
|
+
name: "date_run",
|
|
151
|
+
doc: "One row per (workflow, time) a date trigger was deployed with, kept across deploys: how far its fan-out got. Written when the route is first deployed — already finished when the time had passed by then (`skipped`: 'past') — so a time runs once, and a redeploy after it neither repeats nor cancels it.",
|
|
152
|
+
columns: {
|
|
153
|
+
workflow: text,
|
|
154
|
+
at: ts,
|
|
155
|
+
cursor: nullable(text, "The last user id the fan-out went past; the next page starts after it."),
|
|
156
|
+
entered: {
|
|
157
|
+
type: "integer",
|
|
158
|
+
doc: "Journeys started so far."
|
|
159
|
+
},
|
|
160
|
+
finishedAt: nullable(ts),
|
|
161
|
+
skipped: nullable(text, "Why it ended without running: 'past' (the time had passed when first deployed) or 'missed' (no sweep picked it up within the grace period).")
|
|
162
|
+
},
|
|
163
|
+
primaryKey: ["workflow", "at"]
|
|
164
|
+
}),
|
|
165
|
+
sweepPass: table({
|
|
166
|
+
name: "sweep_pass",
|
|
167
|
+
doc: "The segment sweep's pass over every user, while one is under way: at most one row (`id` is 'segments'), written when a pass begins and removed when it has been through everyone. It is what lets a sweep that ran out of time be carried on by the next instead of starting over.",
|
|
168
|
+
columns: {
|
|
169
|
+
id: text,
|
|
170
|
+
startedAt: ts,
|
|
171
|
+
cursor: nullable(text, "The last user id the pass went past; the next page starts after it."),
|
|
172
|
+
seeding: {
|
|
173
|
+
type: "jsonb",
|
|
174
|
+
doc: "The segments that were being seeded when the pass began (`SeedingSegment[]`): the ones its end seeds."
|
|
175
|
+
},
|
|
176
|
+
evaluated: {
|
|
177
|
+
type: "integer",
|
|
178
|
+
doc: "Users evaluated so far."
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
primaryKey: ["id"]
|
|
182
|
+
}),
|
|
183
|
+
segmentTrigger: table({
|
|
184
|
+
name: "segment_trigger",
|
|
185
|
+
doc: "Segment-entry trigger routes.",
|
|
186
|
+
columns: {
|
|
187
|
+
workflow: text,
|
|
188
|
+
hash: text,
|
|
189
|
+
reentry: {
|
|
190
|
+
type: "jsonb",
|
|
191
|
+
doc: "The workflow's re-entry policy (`ReentryIR`), carried with the route so an entry is decided without reading the IR."
|
|
192
|
+
},
|
|
193
|
+
segment: text,
|
|
194
|
+
version: nullable(text, "The code version whose compiled bundle put this route here (null after a forced deploy): an instance it starts runs on that version, so its IR and its code always match.")
|
|
195
|
+
},
|
|
196
|
+
primaryKey: ["workflow"],
|
|
197
|
+
indexes: [["segment"]]
|
|
198
|
+
}),
|
|
199
|
+
segmentMember: table({
|
|
200
|
+
name: "segment_member",
|
|
201
|
+
doc: "Who is in each deployed segment and since when: kept by the scheduled sweep, and for trigger-routed segments on every event too.",
|
|
202
|
+
columns: {
|
|
203
|
+
segment: text,
|
|
204
|
+
userId: text,
|
|
205
|
+
ts
|
|
206
|
+
},
|
|
207
|
+
primaryKey: ["segment", "userId"],
|
|
208
|
+
indexes: [["userId"]]
|
|
209
|
+
}),
|
|
210
|
+
segmentStart: table({
|
|
211
|
+
name: "segment_start",
|
|
212
|
+
doc: "Workflows a segment entry still has to start for a member: written with the membership, removed as each one starts, so a failed start is retried by the next evaluation instead of being hidden behind the membership.",
|
|
213
|
+
columns: {
|
|
214
|
+
segment: text,
|
|
215
|
+
workflow: text,
|
|
216
|
+
userId: text,
|
|
217
|
+
ts
|
|
218
|
+
},
|
|
219
|
+
primaryKey: [
|
|
220
|
+
"segment",
|
|
221
|
+
"workflow",
|
|
222
|
+
"userId"
|
|
223
|
+
],
|
|
224
|
+
indexes: [["userId"]]
|
|
225
|
+
}),
|
|
226
|
+
segmentSnapshot: table({
|
|
227
|
+
name: "segment_snapshot",
|
|
228
|
+
doc: "Each segment's size at every sweep, the Studio's sparklines.",
|
|
229
|
+
columns: {
|
|
230
|
+
segment: text,
|
|
231
|
+
takenAt: ts,
|
|
232
|
+
size: integer
|
|
233
|
+
},
|
|
234
|
+
primaryKey: ["segment", "takenAt"]
|
|
235
|
+
}),
|
|
236
|
+
entry: table({
|
|
237
|
+
name: "entry",
|
|
238
|
+
doc: "Entry ledger, one row per entry: the instance it started and how that ended (`status`). The workflow's `reentry` policy is decided on a user's rows of the workflow; the (workflow, user, occurrence) key makes a redelivered trigger enter at most once in every mode.",
|
|
239
|
+
columns: {
|
|
240
|
+
workflow: text,
|
|
241
|
+
userId: text,
|
|
242
|
+
instanceId: text,
|
|
243
|
+
occurrence: {
|
|
244
|
+
type: "text",
|
|
245
|
+
doc: "The triggering occurrence: the event id, or `$segment:<segment>:<membership since>` for a segment trigger."
|
|
246
|
+
},
|
|
247
|
+
hash: text,
|
|
248
|
+
status: text,
|
|
249
|
+
ts,
|
|
250
|
+
admittedAt: nullable(ts, "When the runner admitted itself (`admitInstance`), before its first observable effect; null until then, so an erasure knows nothing of the instance has run yet."),
|
|
251
|
+
claimedAt: nullable(ts, "When this attempt claimed the entry (insert or reclaim), by the host's clock. `ts` is the triggering event's own time, which a producer may set far in the past, so only this tells how long an entry has waited for its instance; maintenance fails an entry left unadmitted with no instance behind it. Null on rows written before the column existed.")
|
|
252
|
+
},
|
|
253
|
+
primaryKey: ["instanceId"],
|
|
254
|
+
uniqueIndexes: [[
|
|
255
|
+
"workflow",
|
|
256
|
+
"userId",
|
|
257
|
+
"occurrence"
|
|
258
|
+
]],
|
|
259
|
+
indexes: [["admittedAt"], ["userId"]]
|
|
260
|
+
}),
|
|
261
|
+
subscription: table({
|
|
262
|
+
name: "subscription",
|
|
263
|
+
doc: "wait_until wake routing; the primary key makes repeated subscribes idempotent.",
|
|
264
|
+
columns: {
|
|
265
|
+
userId: text,
|
|
266
|
+
event: text,
|
|
267
|
+
wakeHandle: text,
|
|
268
|
+
ts
|
|
269
|
+
},
|
|
270
|
+
primaryKey: ["wakeHandle", "event"],
|
|
271
|
+
indexes: [["userId", "event"]]
|
|
272
|
+
}),
|
|
273
|
+
execution: table({
|
|
274
|
+
name: "execution",
|
|
275
|
+
doc: "Durable executions whose start is an asynchronous submit (AWS Lambda durable functions): written with the entry, so a lost submit response is retried with the same name, target and payload instead of starting a second execution; and the wake callback the instance is parked on now. Unused on Cloudflare.",
|
|
276
|
+
columns: {
|
|
277
|
+
instanceId: text,
|
|
278
|
+
workflow: text,
|
|
279
|
+
userId: text,
|
|
280
|
+
name: text,
|
|
281
|
+
target: text,
|
|
282
|
+
input: text,
|
|
283
|
+
createdAt: ts,
|
|
284
|
+
submittedAt: nullable(ts, "The runtime accepted the start; null while it may still have to be retried."),
|
|
285
|
+
arn: nullable(text),
|
|
286
|
+
unresolvedAt: nullable(ts, "Retries ran out before the runtime confirmed the start: whether it runs is unknown, and nothing retries it."),
|
|
287
|
+
callbackId: nullable(text, "The callback the current wait parks on; a wake completes it."),
|
|
288
|
+
generation: integer,
|
|
289
|
+
deadlineAt: nullable(ts),
|
|
290
|
+
checkedAt: nullable(ts, "When maintenance last compared the runtime's status with the ledger."),
|
|
291
|
+
stoppedAt: nullable(ts, "When it was stopped (an erasure): an invocation already running goes on to its next checkpoint, so the data waits until it has drained.")
|
|
292
|
+
},
|
|
293
|
+
primaryKey: ["instanceId"],
|
|
294
|
+
indexes: [
|
|
295
|
+
["workflow", "userId"],
|
|
296
|
+
["submittedAt"],
|
|
297
|
+
["userId"]
|
|
298
|
+
]
|
|
299
|
+
}),
|
|
300
|
+
run: table({
|
|
301
|
+
name: "run",
|
|
302
|
+
doc: "Instances of the self-hosted runtime (`sendwend/node`), where the process itself is the durable runtime: what Cloudflare Workflows and Lambda durable functions keep on their side. Unused on those.",
|
|
303
|
+
columns: {
|
|
304
|
+
instanceId: text,
|
|
305
|
+
params: jsonb,
|
|
306
|
+
enteredAt: ts,
|
|
307
|
+
status: {
|
|
308
|
+
type: "text",
|
|
309
|
+
doc: "`queued`, `running`, `sleeping`, `waiting`; or how it ended: `complete`, `errored`, `terminated`."
|
|
310
|
+
},
|
|
311
|
+
wakeAt: nullable(ts, "When a worker may next pick it up: at once, at the end of a sleep or a retry backoff, at a wait's deadline. Null once ended."),
|
|
312
|
+
signals: {
|
|
313
|
+
type: "integer",
|
|
314
|
+
doc: "Incremented by every wake: a wait compares it with the value read when it subscribed, so a wake that lands while a turn is running is not lost."
|
|
315
|
+
},
|
|
316
|
+
leaseOwner: nullable(text),
|
|
317
|
+
leaseUntil: nullable(ts, "Until when the worker running it holds it; past that, another may."),
|
|
318
|
+
leaseGen: {
|
|
319
|
+
type: "integer",
|
|
320
|
+
doc: "Incremented at every claim. Every write of a turn carries the value it claimed with, so a worker that was only slow, not dead, cannot write over its successor."
|
|
321
|
+
},
|
|
322
|
+
error: nullable(text),
|
|
323
|
+
createdAt: ts,
|
|
324
|
+
finishedAt: nullable(ts)
|
|
325
|
+
},
|
|
326
|
+
primaryKey: ["instanceId"],
|
|
327
|
+
indexes: [["wakeAt"], ["finishedAt"]]
|
|
328
|
+
}),
|
|
329
|
+
runStep: table({
|
|
330
|
+
name: "run_step",
|
|
331
|
+
doc: "A run's checkpoints: what a step returned, when a sleep ends, how a wait ended. A turn replays the journey from the top and answers from these.",
|
|
332
|
+
columns: {
|
|
333
|
+
instanceId: text,
|
|
334
|
+
key: {
|
|
335
|
+
type: "text",
|
|
336
|
+
doc: "The step name, and from its second occurrence in the run which one it is (`n3:send`, `n3:send#2`): a name used twice is two steps."
|
|
337
|
+
},
|
|
338
|
+
kind: {
|
|
339
|
+
type: "text",
|
|
340
|
+
doc: "`do`, `sleep` or `wait`."
|
|
341
|
+
},
|
|
342
|
+
done: {
|
|
343
|
+
type: "boolean",
|
|
344
|
+
doc: "False while a step that threw is waiting for its retry."
|
|
345
|
+
},
|
|
346
|
+
result: nullable(jsonb),
|
|
347
|
+
attempts: integer,
|
|
348
|
+
createdAt: ts
|
|
349
|
+
},
|
|
350
|
+
primaryKey: ["instanceId", "key"]
|
|
351
|
+
}),
|
|
352
|
+
deployment: table({
|
|
353
|
+
name: "deployment",
|
|
354
|
+
doc: "The Worker version whose compiled bundle the routes came from, one row (`scope` = 'routes'): journeyWorker applies its own bundle only over an older version, so one still serving during a rollout cannot put its routes back. A forced `POST /bundle/deploy` records the version that served it; a hand-posted `POST /deploy` leaves it as it is.",
|
|
355
|
+
columns: {
|
|
356
|
+
scope: text,
|
|
357
|
+
versionId: text,
|
|
358
|
+
versionCreatedAt: ts,
|
|
359
|
+
appliedAt: ts
|
|
360
|
+
},
|
|
361
|
+
primaryKey: ["scope"]
|
|
362
|
+
}),
|
|
363
|
+
ir: table({
|
|
364
|
+
name: "ir",
|
|
365
|
+
doc: "Workflow bodies (WorkflowIR), content-addressed.",
|
|
366
|
+
columns: {
|
|
367
|
+
contentHash: text,
|
|
368
|
+
ir: jsonb
|
|
369
|
+
},
|
|
370
|
+
primaryKey: ["contentHash"]
|
|
371
|
+
}),
|
|
372
|
+
instance: table({
|
|
373
|
+
name: "instance",
|
|
374
|
+
doc: "One row per journey instance, written when it enters: the node it sits on or last passed (none when a guard ended it before the first), and how it ended (`running` until then; `goal` is a conversion, at `finished_at`).",
|
|
375
|
+
columns: {
|
|
376
|
+
instanceId: text,
|
|
377
|
+
workflow: text,
|
|
378
|
+
userId: text,
|
|
379
|
+
enteredAt: ts,
|
|
380
|
+
nodeId: nullable(text),
|
|
381
|
+
nodeAt: nullable(ts),
|
|
382
|
+
status: text,
|
|
383
|
+
finishedAt: nullable(ts),
|
|
384
|
+
convertedAt: nullable(ts, "When the goal was met, whatever the status: with `exitOnMatch: false` a converted instance ends `completed`.")
|
|
385
|
+
},
|
|
386
|
+
primaryKey: ["instanceId"],
|
|
387
|
+
indexes: [
|
|
388
|
+
["workflow", "status"],
|
|
389
|
+
["workflow", "finishedAt"],
|
|
390
|
+
["userId"]
|
|
391
|
+
]
|
|
392
|
+
}),
|
|
393
|
+
message: table({
|
|
394
|
+
name: "message",
|
|
395
|
+
doc: "One row per message copy (a push fans out per device). The idempotency key is the engine's copy identity, so a retried step finds the row it wrote; `channel` is where the copy landed (`email`, `push_ios`, `push_android`).",
|
|
396
|
+
columns: {
|
|
397
|
+
id: uuid,
|
|
398
|
+
idempotencyKey: text,
|
|
399
|
+
workflow: text,
|
|
400
|
+
instanceId: text,
|
|
401
|
+
nodeId: text,
|
|
402
|
+
template: text,
|
|
403
|
+
channel: text,
|
|
404
|
+
userId: text,
|
|
405
|
+
topic: nullable(text, "An email or push copy: its template's subscription topic (what an email's unsubscribe link opts out of); null for a transactional message, and for every other channel."),
|
|
406
|
+
sentAt: ts,
|
|
407
|
+
claimedAt: nullable(ts, "The copy was handed to the transport (written just before the send, cleared when the send threw). Claimed and never settled: the transport may have taken it — the engine does not send it again unless the template says `redelivery: 'resend'`."),
|
|
408
|
+
deliveredAt: nullable(ts, "The transport accepted it."),
|
|
409
|
+
deviceDeliveredAt: nullable(ts, "A push: the device reported it received (iOS's notification service extension, a browser's service worker)."),
|
|
410
|
+
undeliveredReason: nullable(text, "The transport settled it without delivering (a dead push token)."),
|
|
411
|
+
openedAt: nullable(ts, "First open of any kind, by a person or a machine."),
|
|
412
|
+
humanOpenedAt: nullable(ts, "First open a person made."),
|
|
413
|
+
clickedAt: nullable(ts),
|
|
414
|
+
humanClickedAt: nullable(ts),
|
|
415
|
+
unsubscribedAt: nullable(ts)
|
|
416
|
+
},
|
|
417
|
+
primaryKey: ["id"],
|
|
418
|
+
uuidV7: "id",
|
|
419
|
+
uniqueIndexes: [["idempotencyKey"]],
|
|
420
|
+
indexes: [
|
|
421
|
+
["workflow", "sentAt"],
|
|
422
|
+
["instanceId"],
|
|
423
|
+
["userId"]
|
|
424
|
+
]
|
|
425
|
+
}),
|
|
426
|
+
messageLink: table({
|
|
427
|
+
name: "message_link",
|
|
428
|
+
doc: "A sent email's links in document order: the tracked URL names a message and a position, and the redirect goes only to the URL recorded here.",
|
|
429
|
+
columns: {
|
|
430
|
+
messageId: uuid,
|
|
431
|
+
position: integer,
|
|
432
|
+
url: text,
|
|
433
|
+
purpose: nullable(text, "Null for a link of the email's content; 'unsubscribe' for its unsubscribe link, whose clicks are not engagement.")
|
|
434
|
+
},
|
|
435
|
+
primaryKey: ["messageId", "position"],
|
|
436
|
+
references: [{
|
|
437
|
+
columns: ["messageId"],
|
|
438
|
+
table: "message",
|
|
439
|
+
foreignColumns: ["id"]
|
|
440
|
+
}]
|
|
441
|
+
}),
|
|
442
|
+
messageOpen: table({
|
|
443
|
+
name: "message_open",
|
|
444
|
+
doc: "Every open-pixel load or push tap, classified when recorded: `machine` when no person caused it, with the deciding rule in `reason`; the request's network (never its address) kept for revisiting the rules.",
|
|
445
|
+
columns: {
|
|
446
|
+
id: uuid,
|
|
447
|
+
messageId: uuid,
|
|
448
|
+
openedAt: ts,
|
|
449
|
+
machine: boolean,
|
|
450
|
+
reason: nullable(text),
|
|
451
|
+
userAgent: nullable(text),
|
|
452
|
+
asn: nullable(integer),
|
|
453
|
+
asOrganization: nullable(text),
|
|
454
|
+
country: nullable(text)
|
|
455
|
+
},
|
|
456
|
+
primaryKey: ["id"],
|
|
457
|
+
uuidV7: "id",
|
|
458
|
+
indexes: [["messageId"]],
|
|
459
|
+
references: [{
|
|
460
|
+
columns: ["messageId"],
|
|
461
|
+
table: "message",
|
|
462
|
+
foreignColumns: ["id"]
|
|
463
|
+
}]
|
|
464
|
+
}),
|
|
465
|
+
messageClick: table({
|
|
466
|
+
name: "message_click",
|
|
467
|
+
doc: "Every click on a tracked link, classified like opens.",
|
|
468
|
+
columns: {
|
|
469
|
+
id: uuid,
|
|
470
|
+
messageId: uuid,
|
|
471
|
+
position: integer,
|
|
472
|
+
url: text,
|
|
473
|
+
clickedAt: ts,
|
|
474
|
+
machine: boolean,
|
|
475
|
+
reason: nullable(text),
|
|
476
|
+
userAgent: nullable(text),
|
|
477
|
+
asn: nullable(integer),
|
|
478
|
+
asOrganization: nullable(text),
|
|
479
|
+
country: nullable(text)
|
|
480
|
+
},
|
|
481
|
+
primaryKey: ["id"],
|
|
482
|
+
uuidV7: "id",
|
|
483
|
+
indexes: [["messageId"]],
|
|
484
|
+
references: [{
|
|
485
|
+
columns: ["messageId"],
|
|
486
|
+
table: "message",
|
|
487
|
+
foreignColumns: ["id"]
|
|
488
|
+
}]
|
|
489
|
+
})
|
|
490
|
+
};
|
|
491
|
+
/** The engine's schema when the config names none. */
|
|
492
|
+
const DEFAULT_SCHEMA = "workflow";
|
|
493
|
+
/** `eventId` → `event_id`. */
|
|
494
|
+
function columnName(key) {
|
|
495
|
+
return key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
496
|
+
}
|
|
497
|
+
const quote = (name) => `"${name.replace(/"/g, "\"\"")}"`;
|
|
498
|
+
/** `<table>_<columns>_unique`: drizzle's name for an unnamed `unique()`, and the index behind it. */
|
|
499
|
+
function uniqueConstraintName(spec, unique) {
|
|
500
|
+
return `${spec.name}_${unique.columns.map(columnName).join("_")}_unique`;
|
|
501
|
+
}
|
|
502
|
+
/** `<table>_<columns>_index`: the name drizzle-kit and `renderPostgresDdl` both give an unnamed index. */
|
|
503
|
+
function indexName(spec, keys) {
|
|
504
|
+
return `${spec.name}_${keys.map(columnName).join("_")}_index`;
|
|
505
|
+
}
|
|
506
|
+
const SQL_TYPES = {
|
|
507
|
+
uuid: "uuid",
|
|
508
|
+
text: "text",
|
|
509
|
+
jsonb: "jsonb",
|
|
510
|
+
timestamptz: "timestamptz",
|
|
511
|
+
integer: "integer",
|
|
512
|
+
boolean: "boolean"
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
515
|
+
* Plain Postgres DDL for every table — for a host without a migration tool, and the tests. A
|
|
516
|
+
* host that migrates with drizzle generates `renderDrizzleSchema` instead and lets drizzle-kit
|
|
517
|
+
* write the migration.
|
|
518
|
+
*/
|
|
519
|
+
function renderPostgresDdl(schema = DEFAULT_SCHEMA) {
|
|
520
|
+
const s = quote(schema);
|
|
521
|
+
const out = [`CREATE SCHEMA IF NOT EXISTS ${s};`];
|
|
522
|
+
for (const spec of Object.values(TABLES)) {
|
|
523
|
+
const lines = Object.entries(spec.columns).map(([key, column]) => ` ${quote(columnName(key))} ${SQL_TYPES[column.type]}${column.nullable ? "" : " NOT NULL"}`);
|
|
524
|
+
if (spec.primaryKey !== void 0) lines.push(` PRIMARY KEY (${spec.primaryKey.map((k) => quote(columnName(k))).join(", ")})`);
|
|
525
|
+
for (const unique of spec.uniqueConstraints ?? []) {
|
|
526
|
+
const cols = unique.columns.map(columnName);
|
|
527
|
+
lines.push(` CONSTRAINT ${quote(uniqueConstraintName(spec, unique))} UNIQUE NULLS NOT DISTINCT (${cols.map(quote).join(", ")})`);
|
|
528
|
+
}
|
|
529
|
+
if (spec.uuidV7 !== void 0) lines.push(` CONSTRAINT ${quote(`${spec.name}_uuid_v7`)} CHECK (substring(${quote(columnName(spec.uuidV7))}::text, 15, 1) = '7')`);
|
|
530
|
+
for (const ref of spec.references ?? []) {
|
|
531
|
+
const target = TABLES[ref.table];
|
|
532
|
+
lines.push(` FOREIGN KEY (${ref.columns.map((k) => quote(columnName(k))).join(", ")}) REFERENCES ${s}.${quote(target.name)} (${ref.foreignColumns.map((k) => quote(columnName(k))).join(", ")})`);
|
|
533
|
+
}
|
|
534
|
+
out.push(`CREATE TABLE IF NOT EXISTS ${s}.${quote(spec.name)} (\n${lines.join(",\n")}\n);`);
|
|
535
|
+
const index = (unique) => (keys) => {
|
|
536
|
+
const cols = keys.map(columnName);
|
|
537
|
+
out.push(`CREATE ${unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS ${quote(indexName(spec, keys))} ON ${s}.${quote(spec.name)} (${cols.map(quote).join(", ")});`);
|
|
538
|
+
};
|
|
539
|
+
(spec.uniqueIndexes ?? []).forEach(index(true));
|
|
540
|
+
(spec.indexes ?? []).forEach(index(false));
|
|
541
|
+
}
|
|
542
|
+
return `${out.join("\n")}\n`;
|
|
543
|
+
}
|
|
544
|
+
const TIMESTAMP_OPTIONS = "{ mode: 'string', withTimezone: true }";
|
|
545
|
+
const DRIZZLE_TYPES = {
|
|
546
|
+
uuid: (c) => `uuid('${c}')`,
|
|
547
|
+
text: (c) => `text('${c}')`,
|
|
548
|
+
jsonb: (c) => `jsonb('${c}')`,
|
|
549
|
+
timestamptz: (c) => `timestamp('${c}', ${TIMESTAMP_OPTIONS})`,
|
|
550
|
+
integer: (c) => `integer('${c}')`,
|
|
551
|
+
boolean: (c) => `boolean('${c}')`
|
|
552
|
+
};
|
|
553
|
+
/** The line width the generated file is laid out for: the formatters' common default. */
|
|
554
|
+
const PRINT_WIDTH = 100;
|
|
555
|
+
/**
|
|
556
|
+
* One `workflowSchema.table(...)` statement, laid out the way a prettier-compatible formatter
|
|
557
|
+
* (prettier, oxfmt, biome) at `PRINT_WIDTH` lays it out, so that formatting the generated file
|
|
558
|
+
* changes nothing and a regeneration shows only real changes: on one line when it fits; else
|
|
559
|
+
* with the last argument "hugged" (the columns object, or the constraints arrow when the columns
|
|
560
|
+
* fit on the first line) and its items one per line; else every argument on its own line, the
|
|
561
|
+
* constraints array still collapsed when it fits. A column with a doc comment keeps the columns
|
|
562
|
+
* object expanded, as a comment does for a formatter.
|
|
563
|
+
*/
|
|
564
|
+
/** A column line past the width: a formatter breaks the timestamp options object, so this does too. */
|
|
565
|
+
function wrapColumn(text, indent) {
|
|
566
|
+
if (`${indent}${text},`.length <= PRINT_WIDTH || !text.includes(TIMESTAMP_OPTIONS)) return text;
|
|
567
|
+
return text.replace(TIMESTAMP_OPTIONS, `{\n${indent} mode: 'string',\n${indent} withTimezone: true,\n${indent}}`);
|
|
568
|
+
}
|
|
569
|
+
function renderTable(name, table, columns, extras) {
|
|
570
|
+
const head = `export const ${name} = workflowSchema.table(`;
|
|
571
|
+
const flatColumns = columns.some((c) => c.doc !== void 0) ? void 0 : `{ ${columns.map((c) => c.text).join(", ")} }`;
|
|
572
|
+
const expandedColumns = (indent) => `{\n${columns.map((c) => `${c.doc === void 0 ? "" : `${indent} /** ${c.doc} */\n`}${indent} ${wrapColumn(c.text, `${indent} `)},`).join("\n")}\n${indent}}`;
|
|
573
|
+
const flatExtras = `(table) => [${extras.join(", ")}]`;
|
|
574
|
+
const expandedExtras = (indent) => `(table) => [\n${extras.map((e) => `${indent} ${e},`).join("\n")}\n${indent}]`;
|
|
575
|
+
const fits = (line) => line.length <= PRINT_WIDTH;
|
|
576
|
+
if (flatColumns !== void 0) {
|
|
577
|
+
const oneLine = `${head}'${table}', ${flatColumns}${extras.length === 0 ? "" : `, ${flatExtras}`});`;
|
|
578
|
+
if (fits(oneLine)) return oneLine;
|
|
579
|
+
}
|
|
580
|
+
if (extras.length === 0) return `${head}'${table}', ${expandedColumns("")});`;
|
|
581
|
+
if (flatColumns !== void 0) {
|
|
582
|
+
const first = `${head}'${table}', ${flatColumns}, (table) => [`;
|
|
583
|
+
if (fits(first)) return `${first}\n${extras.map((e) => ` ${e},`).join("\n")}\n]);`;
|
|
584
|
+
}
|
|
585
|
+
const third = fits(` ${flatExtras}`) ? flatExtras : expandedExtras(" ");
|
|
586
|
+
return `${head}\n '${table}',\n ${expandedColumns(" ")},\n ${third}\n);`;
|
|
587
|
+
}
|
|
588
|
+
const exportName = (key) => `workflow${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
589
|
+
/**
|
|
590
|
+
* The tables as one drizzle file: `export const workflowSchema = pgSchema(<schema>)` and every
|
|
591
|
+
* table as `workflowSchema.table(...)`. The host re-exports it from its drizzle schema and
|
|
592
|
+
* generates the migration with drizzle-kit, so the migration history stays the host's. The
|
|
593
|
+
* output is deterministic — regenerate and diff it in CI to catch an SDK upgrade that changed the
|
|
594
|
+
* tables.
|
|
595
|
+
*/
|
|
596
|
+
function renderDrizzleSchema(schema = DEFAULT_SCHEMA) {
|
|
597
|
+
const specs = Object.entries(TABLES);
|
|
598
|
+
const used = /* @__PURE__ */ new Set(["pgSchema"]);
|
|
599
|
+
const body = [];
|
|
600
|
+
let needsSql = false;
|
|
601
|
+
for (const [key, spec] of specs) {
|
|
602
|
+
const columns = Object.entries(spec.columns).map(([prop, column]) => {
|
|
603
|
+
used.add(column.type === "timestamptz" ? "timestamp" : column.type);
|
|
604
|
+
const key = spec.primaryKey?.length === 1 && spec.primaryKey[0] === prop ? ".primaryKey()" : "";
|
|
605
|
+
return {
|
|
606
|
+
doc: column.doc,
|
|
607
|
+
text: `${prop}: ${DRIZZLE_TYPES[column.type](columnName(prop))}${key}${column.nullable ? "" : ".notNull()"}`
|
|
608
|
+
};
|
|
609
|
+
});
|
|
610
|
+
const extras = [];
|
|
611
|
+
if (spec.primaryKey !== void 0 && spec.primaryKey.length > 1) {
|
|
612
|
+
used.add("primaryKey");
|
|
613
|
+
extras.push(`primaryKey({ columns: [${spec.primaryKey.map((k) => `table.${k}`).join(", ")}] })`);
|
|
614
|
+
}
|
|
615
|
+
for (const keys of spec.uniqueIndexes ?? []) {
|
|
616
|
+
used.add("uniqueIndex");
|
|
617
|
+
extras.push(`uniqueIndex().on(${keys.map((k) => `table.${k}`).join(", ")})`);
|
|
618
|
+
}
|
|
619
|
+
for (const unique of spec.uniqueConstraints ?? []) {
|
|
620
|
+
used.add("unique");
|
|
621
|
+
extras.push(`unique().on(${unique.columns.map((k) => `table.${k}`).join(", ")}).nullsNotDistinct()`);
|
|
622
|
+
}
|
|
623
|
+
for (const keys of spec.indexes ?? []) {
|
|
624
|
+
used.add("index");
|
|
625
|
+
extras.push(`index().on(${keys.map((k) => `table.${k}`).join(", ")})`);
|
|
626
|
+
}
|
|
627
|
+
for (const ref of spec.references ?? []) {
|
|
628
|
+
used.add("foreignKey");
|
|
629
|
+
extras.push(`foreignKey({ columns: [${ref.columns.map((k) => `table.${k}`).join(", ")}], foreignColumns: [${ref.foreignColumns.map((k) => `${exportName(ref.table)}.${k}`).join(", ")}] })`);
|
|
630
|
+
}
|
|
631
|
+
if (spec.uuidV7 !== void 0) {
|
|
632
|
+
used.add("check");
|
|
633
|
+
needsSql = true;
|
|
634
|
+
extras.push(`check('${spec.name}_uuid_v7', sql\`substring(\${table.${spec.uuidV7}}::text, 15, 1) = '7'\`)`);
|
|
635
|
+
}
|
|
636
|
+
body.push(`/** ${spec.doc} */\n${renderTable(exportName(key), spec.name, columns, extras)}`);
|
|
637
|
+
}
|
|
638
|
+
const imports = [...used].sort();
|
|
639
|
+
return [
|
|
640
|
+
"// Generated by `sendwend-studio generate` from sendwend — do not edit; regenerate after",
|
|
641
|
+
"// upgrading the SDK and let drizzle-kit write the migration.",
|
|
642
|
+
...needsSql ? ["import { sql } from 'drizzle-orm';"] : [],
|
|
643
|
+
`import {\n${imports.map((name) => ` ${name},`).join("\n")}\n} from 'drizzle-orm/pg-core';`,
|
|
644
|
+
"",
|
|
645
|
+
`export const workflowSchema = pgSchema('${schema}');`,
|
|
646
|
+
"",
|
|
647
|
+
body.join("\n\n"),
|
|
648
|
+
""
|
|
649
|
+
].join("\n");
|
|
650
|
+
}
|
|
651
|
+
export { DEFAULT_SCHEMA, TABLES, columnName, indexName, renderDrizzleSchema, renderPostgresDdl, uniqueConstraintName };
|
|
652
|
+
|
|
653
|
+
//# sourceMappingURL=tables.mjs.map
|