sendwend 0.0.1 → 12.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +2065 -22
- package/dist/_virtual/_rolldown/runtime.cjs +22 -0
- package/dist/apns-relay.cjs +91 -0
- package/dist/apns-relay.cjs.map +1 -0
- package/dist/apns-relay.d.cts +26 -0
- package/dist/apns-relay.d.cts.map +1 -0
- package/dist/apns-relay.d.mts +26 -0
- package/dist/apns-relay.d.mts.map +1 -0
- package/dist/apns-relay.mjs +90 -0
- package/dist/apns-relay.mjs.map +1 -0
- package/dist/apns.cjs +215 -0
- package/dist/apns.cjs.map +1 -0
- package/dist/apns.d.cts +110 -0
- package/dist/apns.d.cts.map +1 -0
- package/dist/apns.d.mts +110 -0
- package/dist/apns.d.mts.map +1 -0
- package/dist/apns.mjs +207 -0
- package/dist/apns.mjs.map +1 -0
- package/dist/aws/engine-step.cjs +105 -0
- package/dist/aws/engine-step.cjs.map +1 -0
- package/dist/aws/engine-step.d.cts +42 -0
- package/dist/aws/engine-step.d.cts.map +1 -0
- package/dist/aws/engine-step.d.mts +42 -0
- package/dist/aws/engine-step.d.mts.map +1 -0
- package/dist/aws/engine-step.mjs +103 -0
- package/dist/aws/engine-step.mjs.map +1 -0
- package/dist/aws/function-url.cjs +53 -0
- package/dist/aws/function-url.cjs.map +1 -0
- package/dist/aws/function-url.d.cts +36 -0
- package/dist/aws/function-url.d.cts.map +1 -0
- package/dist/aws/function-url.d.mts +36 -0
- package/dist/aws/function-url.d.mts.map +1 -0
- package/dist/aws/function-url.mjs +50 -0
- package/dist/aws/function-url.mjs.map +1 -0
- package/dist/aws/index.cjs +232 -0
- package/dist/aws/index.cjs.map +1 -0
- package/dist/aws/index.d.cts +73 -0
- package/dist/aws/index.d.cts.map +1 -0
- package/dist/aws/index.d.mts +73 -0
- package/dist/aws/index.d.mts.map +1 -0
- package/dist/aws/index.mjs +218 -0
- package/dist/aws/index.mjs.map +1 -0
- package/dist/aws/instances.cjs +218 -0
- package/dist/aws/instances.cjs.map +1 -0
- package/dist/aws/instances.d.cts +102 -0
- package/dist/aws/instances.d.cts.map +1 -0
- package/dist/aws/instances.d.mts +102 -0
- package/dist/aws/instances.d.mts.map +1 -0
- package/dist/aws/instances.mjs +214 -0
- package/dist/aws/instances.mjs.map +1 -0
- package/dist/aws/lambda-api.cjs +86 -0
- package/dist/aws/lambda-api.cjs.map +1 -0
- package/dist/aws/lambda-api.d.cts +41 -0
- package/dist/aws/lambda-api.d.cts.map +1 -0
- package/dist/aws/lambda-api.d.mts +41 -0
- package/dist/aws/lambda-api.d.mts.map +1 -0
- package/dist/aws/lambda-api.mjs +85 -0
- package/dist/aws/lambda-api.mjs.map +1 -0
- package/dist/client.cjs +216 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +193 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +193 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +212 -0
- package/dist/client.mjs.map +1 -0
- package/dist/cloudflare/bindings.cjs +49 -0
- package/dist/cloudflare/bindings.cjs.map +1 -0
- package/dist/cloudflare/bindings.d.cts +31 -0
- package/dist/cloudflare/bindings.d.cts.map +1 -0
- package/dist/cloudflare/bindings.d.mts +31 -0
- package/dist/cloudflare/bindings.d.mts.map +1 -0
- package/dist/cloudflare/bindings.mjs +46 -0
- package/dist/cloudflare/bindings.mjs.map +1 -0
- package/dist/cloudflare/index.cjs +73 -0
- package/dist/cloudflare/index.d.cts +25 -0
- package/dist/cloudflare/index.d.mts +25 -0
- package/dist/cloudflare/index.mjs +20 -0
- package/dist/cloudflare/runner.cjs +200 -0
- package/dist/cloudflare/runner.cjs.map +1 -0
- package/dist/cloudflare/runner.d.cts +83 -0
- package/dist/cloudflare/runner.d.cts.map +1 -0
- package/dist/cloudflare/runner.d.mts +83 -0
- package/dist/cloudflare/runner.d.mts.map +1 -0
- package/dist/cloudflare/runner.mjs +199 -0
- package/dist/cloudflare/runner.mjs.map +1 -0
- package/dist/cloudflare/worker.cjs +106 -0
- package/dist/cloudflare/worker.cjs.map +1 -0
- package/dist/cloudflare/worker.d.cts +52 -0
- package/dist/cloudflare/worker.d.cts.map +1 -0
- package/dist/cloudflare/worker.d.mts +52 -0
- package/dist/cloudflare/worker.d.mts.map +1 -0
- package/dist/cloudflare/worker.mjs +104 -0
- package/dist/cloudflare/worker.mjs.map +1 -0
- package/dist/cloudflare/workers.d.cjs +0 -0
- package/dist/cloudflare/workers.d.cts +42 -0
- package/dist/cloudflare/workers.d.cts.map +1 -0
- package/dist/cloudflare/workers.d.mts +42 -0
- package/dist/cloudflare/workers.d.mts.map +1 -0
- package/dist/config.cjs +257 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +184 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +184 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +246 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract.cjs +222 -0
- package/dist/contract.cjs.map +1 -0
- package/dist/contract.d.cts +110 -0
- package/dist/contract.d.cts.map +1 -0
- package/dist/contract.d.mts +110 -0
- package/dist/contract.d.mts.map +1 -0
- package/dist/contract.mjs +216 -0
- package/dist/contract.mjs.map +1 -0
- package/dist/date-time.cjs +22 -0
- package/dist/date-time.cjs.map +1 -0
- package/dist/date-time.d.cts +10 -0
- package/dist/date-time.d.cts.map +1 -0
- package/dist/date-time.d.mts +10 -0
- package/dist/date-time.d.mts.map +1 -0
- package/dist/date-time.mjs +21 -0
- package/dist/date-time.mjs.map +1 -0
- package/dist/dsl/action.cjs +25 -0
- package/dist/dsl/action.cjs.map +1 -0
- package/dist/dsl/action.d.cts +63 -0
- package/dist/dsl/action.d.cts.map +1 -0
- package/dist/dsl/action.d.mts +63 -0
- package/dist/dsl/action.d.mts.map +1 -0
- package/dist/dsl/action.mjs +24 -0
- package/dist/dsl/action.mjs.map +1 -0
- package/dist/dsl/base.cjs +33 -0
- package/dist/dsl/base.cjs.map +1 -0
- package/dist/dsl/base.d.cts +43 -0
- package/dist/dsl/base.d.cts.map +1 -0
- package/dist/dsl/base.d.mts +43 -0
- package/dist/dsl/base.d.mts.map +1 -0
- package/dist/dsl/base.mjs +29 -0
- package/dist/dsl/base.mjs.map +1 -0
- package/dist/dsl/bundle.cjs +287 -0
- package/dist/dsl/bundle.cjs.map +1 -0
- package/dist/dsl/bundle.d.cts +33 -0
- package/dist/dsl/bundle.d.cts.map +1 -0
- package/dist/dsl/bundle.d.mts +33 -0
- package/dist/dsl/bundle.d.mts.map +1 -0
- package/dist/dsl/bundle.mjs +284 -0
- package/dist/dsl/bundle.mjs.map +1 -0
- package/dist/dsl/condition.cjs +200 -0
- package/dist/dsl/condition.cjs.map +1 -0
- package/dist/dsl/condition.d.cts +151 -0
- package/dist/dsl/condition.d.cts.map +1 -0
- package/dist/dsl/condition.d.mts +151 -0
- package/dist/dsl/condition.d.mts.map +1 -0
- package/dist/dsl/condition.mjs +178 -0
- package/dist/dsl/condition.mjs.map +1 -0
- package/dist/dsl/flow.cjs +335 -0
- package/dist/dsl/flow.cjs.map +1 -0
- package/dist/dsl/flow.d.cts +278 -0
- package/dist/dsl/flow.d.cts.map +1 -0
- package/dist/dsl/flow.d.mts +278 -0
- package/dist/dsl/flow.d.mts.map +1 -0
- package/dist/dsl/flow.mjs +331 -0
- package/dist/dsl/flow.mjs.map +1 -0
- package/dist/dsl/index.cjs +37 -0
- package/dist/dsl/index.d.cts +34 -0
- package/dist/dsl/index.d.mts +34 -0
- package/dist/dsl/index.mjs +9 -0
- package/dist/dsl/refs.cjs +101 -0
- package/dist/dsl/refs.cjs.map +1 -0
- package/dist/dsl/refs.d.cts +127 -0
- package/dist/dsl/refs.d.cts.map +1 -0
- package/dist/dsl/refs.d.mts +127 -0
- package/dist/dsl/refs.d.mts.map +1 -0
- package/dist/dsl/refs.mjs +93 -0
- package/dist/dsl/refs.mjs.map +1 -0
- package/dist/dsl/template.cjs +19 -0
- package/dist/dsl/template.cjs.map +1 -0
- package/dist/dsl/template.d.cts +30 -0
- package/dist/dsl/template.d.cts.map +1 -0
- package/dist/dsl/template.d.mts +30 -0
- package/dist/dsl/template.d.mts.map +1 -0
- package/dist/dsl/template.mjs +18 -0
- package/dist/dsl/template.mjs.map +1 -0
- package/dist/dsl/trigger.cjs +53 -0
- package/dist/dsl/trigger.cjs.map +1 -0
- package/dist/dsl/trigger.d.cts +112 -0
- package/dist/dsl/trigger.d.cts.map +1 -0
- package/dist/dsl/trigger.d.mts +112 -0
- package/dist/dsl/trigger.d.mts.map +1 -0
- package/dist/dsl/trigger.mjs +52 -0
- package/dist/dsl/trigger.mjs.map +1 -0
- package/dist/dsl/workflow.cjs +143 -0
- package/dist/dsl/workflow.cjs.map +1 -0
- package/dist/dsl/workflow.d.cts +88 -0
- package/dist/dsl/workflow.d.cts.map +1 -0
- package/dist/dsl/workflow.d.mts +88 -0
- package/dist/dsl/workflow.d.mts.map +1 -0
- package/dist/dsl/workflow.mjs +142 -0
- package/dist/dsl/workflow.mjs.map +1 -0
- package/dist/email-context.cjs +28 -0
- package/dist/email-context.cjs.map +1 -0
- package/dist/email-context.d.cts +9 -0
- package/dist/email-context.d.cts.map +1 -0
- package/dist/email-context.d.mts +9 -0
- package/dist/email-context.d.mts.map +1 -0
- package/dist/email-context.mjs +26 -0
- package/dist/email-context.mjs.map +1 -0
- package/dist/email-sender.cjs +93 -0
- package/dist/email-sender.cjs.map +1 -0
- package/dist/email-sender.d.cts +88 -0
- package/dist/email-sender.d.cts.map +1 -0
- package/dist/email-sender.d.mts +88 -0
- package/dist/email-sender.d.mts.map +1 -0
- package/dist/email-sender.mjs +90 -0
- package/dist/email-sender.mjs.map +1 -0
- package/dist/email.cjs +73 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +59 -0
- package/dist/email.d.cts.map +1 -0
- package/dist/email.d.mts +59 -0
- package/dist/email.d.mts.map +1 -0
- package/dist/email.mjs +68 -0
- package/dist/email.mjs.map +1 -0
- package/dist/engine/actions.cjs +19 -0
- package/dist/engine/actions.cjs.map +1 -0
- package/dist/engine/actions.d.cts +27 -0
- package/dist/engine/actions.d.cts.map +1 -0
- package/dist/engine/actions.d.mts +27 -0
- package/dist/engine/actions.d.mts.map +1 -0
- package/dist/engine/actions.mjs +18 -0
- package/dist/engine/actions.mjs.map +1 -0
- package/dist/engine/bucket.cjs +71 -0
- package/dist/engine/bucket.cjs.map +1 -0
- package/dist/engine/bucket.d.cts +30 -0
- package/dist/engine/bucket.d.cts.map +1 -0
- package/dist/engine/bucket.d.mts +30 -0
- package/dist/engine/bucket.d.mts.map +1 -0
- package/dist/engine/bucket.mjs +68 -0
- package/dist/engine/bucket.mjs.map +1 -0
- package/dist/engine/condition.cjs +199 -0
- package/dist/engine/condition.cjs.map +1 -0
- package/dist/engine/condition.d.cts +76 -0
- package/dist/engine/condition.d.cts.map +1 -0
- package/dist/engine/condition.d.mts +76 -0
- package/dist/engine/condition.d.mts.map +1 -0
- package/dist/engine/condition.mjs +192 -0
- package/dist/engine/condition.mjs.map +1 -0
- package/dist/engine/duration.cjs +33 -0
- package/dist/engine/duration.cjs.map +1 -0
- package/dist/engine/duration.d.cts +3 -0
- package/dist/engine/duration.d.cts.map +1 -0
- package/dist/engine/duration.d.mts +3 -0
- package/dist/engine/duration.d.mts.map +1 -0
- package/dist/engine/duration.mjs +32 -0
- package/dist/engine/duration.mjs.map +1 -0
- package/dist/engine/index.cjs +33 -0
- package/dist/engine/index.d.cts +10 -0
- package/dist/engine/index.d.mts +10 -0
- package/dist/engine/index.mjs +9 -0
- package/dist/engine/interpreter.cjs +613 -0
- package/dist/engine/interpreter.cjs.map +1 -0
- package/dist/engine/interpreter.d.cts +4 -0
- package/dist/engine/interpreter.d.cts.map +1 -0
- package/dist/engine/interpreter.d.mts +4 -0
- package/dist/engine/interpreter.d.mts.map +1 -0
- package/dist/engine/interpreter.mjs +612 -0
- package/dist/engine/interpreter.mjs.map +1 -0
- package/dist/engine/ports.cjs +0 -0
- package/dist/engine/ports.d.cts +373 -0
- package/dist/engine/ports.d.cts.map +1 -0
- package/dist/engine/ports.d.mts +373 -0
- package/dist/engine/ports.d.mts.map +1 -0
- package/dist/engine/ports.mjs +1 -0
- package/dist/engine/recipient.cjs +22 -0
- package/dist/engine/recipient.cjs.map +1 -0
- package/dist/engine/recipient.d.cts +11 -0
- package/dist/engine/recipient.d.cts.map +1 -0
- package/dist/engine/recipient.d.mts +11 -0
- package/dist/engine/recipient.d.mts.map +1 -0
- package/dist/engine/recipient.mjs +21 -0
- package/dist/engine/recipient.mjs.map +1 -0
- package/dist/engine/retry.cjs +106 -0
- package/dist/engine/retry.cjs.map +1 -0
- package/dist/engine/retry.d.cts +73 -0
- package/dist/engine/retry.d.cts.map +1 -0
- package/dist/engine/retry.d.mts +73 -0
- package/dist/engine/retry.d.mts.map +1 -0
- package/dist/engine/retry.mjs +98 -0
- package/dist/engine/retry.mjs.map +1 -0
- package/dist/engine/time-scale.cjs +153 -0
- package/dist/engine/time-scale.cjs.map +1 -0
- package/dist/engine/time-scale.d.cts +41 -0
- package/dist/engine/time-scale.d.cts.map +1 -0
- package/dist/engine/time-scale.d.mts +41 -0
- package/dist/engine/time-scale.d.mts.map +1 -0
- package/dist/engine/time-scale.mjs +150 -0
- package/dist/engine/time-scale.mjs.map +1 -0
- package/dist/engine/time-window.cjs +148 -0
- package/dist/engine/time-window.cjs.map +1 -0
- package/dist/engine/time-window.d.cts +20 -0
- package/dist/engine/time-window.d.cts.map +1 -0
- package/dist/engine/time-window.d.mts +20 -0
- package/dist/engine/time-window.d.mts.map +1 -0
- package/dist/engine/time-window.mjs +146 -0
- package/dist/engine/time-window.mjs.map +1 -0
- package/dist/fcm.cjs +208 -0
- package/dist/fcm.cjs.map +1 -0
- package/dist/fcm.d.cts +89 -0
- package/dist/fcm.d.cts.map +1 -0
- package/dist/fcm.d.mts +89 -0
- package/dist/fcm.d.mts.map +1 -0
- package/dist/fcm.mjs +202 -0
- package/dist/fcm.mjs.map +1 -0
- package/dist/hash.cjs +244 -0
- package/dist/hash.cjs.map +1 -0
- package/dist/hash.d.cts +28 -0
- package/dist/hash.d.cts.map +1 -0
- package/dist/hash.d.mts +28 -0
- package/dist/hash.d.mts.map +1 -0
- package/dist/hash.mjs +238 -0
- package/dist/hash.mjs.map +1 -0
- package/dist/host/auth.cjs +48 -0
- package/dist/host/auth.cjs.map +1 -0
- package/dist/host/auth.d.cts +33 -0
- package/dist/host/auth.d.cts.map +1 -0
- package/dist/host/auth.d.mts +33 -0
- package/dist/host/auth.d.mts.map +1 -0
- package/dist/host/auth.mjs +45 -0
- package/dist/host/auth.mjs.map +1 -0
- package/dist/host/batch.cjs +178 -0
- package/dist/host/batch.cjs.map +1 -0
- package/dist/host/batch.d.cts +92 -0
- package/dist/host/batch.d.cts.map +1 -0
- package/dist/host/batch.d.mts +92 -0
- package/dist/host/batch.d.mts.map +1 -0
- package/dist/host/batch.mjs +169 -0
- package/dist/host/batch.mjs.map +1 -0
- package/dist/host/channels.cjs +256 -0
- package/dist/host/channels.cjs.map +1 -0
- package/dist/host/channels.d.cts +66 -0
- package/dist/host/channels.d.cts.map +1 -0
- package/dist/host/channels.d.mts +66 -0
- package/dist/host/channels.d.mts.map +1 -0
- package/dist/host/channels.mjs +252 -0
- package/dist/host/channels.mjs.map +1 -0
- package/dist/host/execute.cjs +102 -0
- package/dist/host/execute.cjs.map +1 -0
- package/dist/host/execute.d.cts +38 -0
- package/dist/host/execute.d.cts.map +1 -0
- package/dist/host/execute.d.mts +38 -0
- package/dist/host/execute.d.mts.map +1 -0
- package/dist/host/execute.mjs +101 -0
- package/dist/host/execute.mjs.map +1 -0
- package/dist/host/fresh-read.cjs +29 -0
- package/dist/host/fresh-read.cjs.map +1 -0
- package/dist/host/fresh-read.d.cts +16 -0
- package/dist/host/fresh-read.d.cts.map +1 -0
- package/dist/host/fresh-read.d.mts +16 -0
- package/dist/host/fresh-read.d.mts.map +1 -0
- package/dist/host/fresh-read.mjs +28 -0
- package/dist/host/fresh-read.mjs.map +1 -0
- package/dist/host/http.cjs +393 -0
- package/dist/host/http.cjs.map +1 -0
- package/dist/host/http.d.cts +61 -0
- package/dist/host/http.d.cts.map +1 -0
- package/dist/host/http.d.mts +61 -0
- package/dist/host/http.d.mts.map +1 -0
- package/dist/host/http.mjs +389 -0
- package/dist/host/http.mjs.map +1 -0
- package/dist/host/ingest.cjs +1210 -0
- package/dist/host/ingest.cjs.map +1 -0
- package/dist/host/ingest.d.cts +497 -0
- package/dist/host/ingest.d.cts.map +1 -0
- package/dist/host/ingest.d.mts +497 -0
- package/dist/host/ingest.d.mts.map +1 -0
- package/dist/host/ingest.mjs +1172 -0
- package/dist/host/ingest.mjs.map +1 -0
- package/dist/host/journey-host.cjs +223 -0
- package/dist/host/journey-host.cjs.map +1 -0
- package/dist/host/journey-host.d.cts +118 -0
- package/dist/host/journey-host.d.cts.map +1 -0
- package/dist/host/journey-host.d.mts +118 -0
- package/dist/host/journey-host.d.mts.map +1 -0
- package/dist/host/journey-host.mjs +219 -0
- package/dist/host/journey-host.mjs.map +1 -0
- package/dist/host/platform.cjs +20 -0
- package/dist/host/platform.cjs.map +1 -0
- package/dist/host/platform.d.cts +120 -0
- package/dist/host/platform.d.cts.map +1 -0
- package/dist/host/platform.d.mts +120 -0
- package/dist/host/platform.d.mts.map +1 -0
- package/dist/host/platform.mjs +18 -0
- package/dist/host/platform.mjs.map +1 -0
- package/dist/host/senders.cjs +71 -0
- package/dist/host/senders.cjs.map +1 -0
- package/dist/host/senders.d.cts +34 -0
- package/dist/host/senders.d.cts.map +1 -0
- package/dist/host/senders.d.mts +34 -0
- package/dist/host/senders.d.mts.map +1 -0
- package/dist/host/senders.mjs +67 -0
- package/dist/host/senders.mjs.map +1 -0
- package/dist/host/workflow-cache.cjs +47 -0
- package/dist/host/workflow-cache.cjs.map +1 -0
- package/dist/host/workflow-cache.d.cts +21 -0
- package/dist/host/workflow-cache.d.cts.map +1 -0
- package/dist/host/workflow-cache.d.mts +21 -0
- package/dist/host/workflow-cache.d.mts.map +1 -0
- package/dist/host/workflow-cache.mjs +46 -0
- package/dist/host/workflow-cache.mjs.map +1 -0
- package/dist/http2-client.cjs +89 -0
- package/dist/http2-client.cjs.map +1 -0
- package/dist/http2-client.d.cts +45 -0
- package/dist/http2-client.d.cts.map +1 -0
- package/dist/http2-client.d.mts +45 -0
- package/dist/http2-client.d.mts.map +1 -0
- package/dist/http2-client.mjs +87 -0
- package/dist/http2-client.mjs.map +1 -0
- package/dist/index.cjs +130 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.mjs +20 -0
- package/dist/inflight.cjs +116 -0
- package/dist/inflight.cjs.map +1 -0
- package/dist/inflight.d.cts +49 -0
- package/dist/inflight.d.cts.map +1 -0
- package/dist/inflight.d.mts +49 -0
- package/dist/inflight.d.mts.map +1 -0
- package/dist/inflight.mjs +113 -0
- package/dist/inflight.mjs.map +1 -0
- package/dist/ir.cjs +429 -0
- package/dist/ir.cjs.map +1 -0
- package/dist/ir.d.cts +593 -0
- package/dist/ir.d.cts.map +1 -0
- package/dist/ir.d.mts +593 -0
- package/dist/ir.d.mts.map +1 -0
- package/dist/ir.mjs +404 -0
- package/dist/ir.mjs.map +1 -0
- package/dist/jwt.cjs +17 -0
- package/dist/jwt.cjs.map +1 -0
- package/dist/jwt.d.cts +7 -0
- package/dist/jwt.d.cts.map +1 -0
- package/dist/jwt.d.mts +7 -0
- package/dist/jwt.d.mts.map +1 -0
- package/dist/jwt.mjs +15 -0
- package/dist/jwt.mjs.map +1 -0
- package/dist/node/index.cjs +231 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +59 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.d.mts +59 -0
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/index.mjs +225 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/runs.cjs +222 -0
- package/dist/node/runs.cjs.map +1 -0
- package/dist/node/runs.d.cts +93 -0
- package/dist/node/runs.d.cts.map +1 -0
- package/dist/node/runs.d.mts +93 -0
- package/dist/node/runs.d.mts.map +1 -0
- package/dist/node/runs.mjs +221 -0
- package/dist/node/runs.mjs.map +1 -0
- package/dist/node/runtime.cjs +351 -0
- package/dist/node/runtime.cjs.map +1 -0
- package/dist/node/runtime.d.cts +96 -0
- package/dist/node/runtime.d.cts.map +1 -0
- package/dist/node/runtime.d.mts +96 -0
- package/dist/node/runtime.d.mts.map +1 -0
- package/dist/node/runtime.mjs +348 -0
- package/dist/node/runtime.mjs.map +1 -0
- package/dist/plan.cjs +221 -0
- package/dist/plan.cjs.map +1 -0
- package/dist/plan.d.cts +68 -0
- package/dist/plan.d.cts.map +1 -0
- package/dist/plan.d.mts +68 -0
- package/dist/plan.d.mts.map +1 -0
- package/dist/plan.mjs +218 -0
- package/dist/plan.mjs.map +1 -0
- package/dist/postgres-js.cjs +51 -0
- package/dist/postgres-js.cjs.map +1 -0
- package/dist/postgres-js.d.cts +32 -0
- package/dist/postgres-js.d.cts.map +1 -0
- package/dist/postgres-js.d.mts +32 -0
- package/dist/postgres-js.d.mts.map +1 -0
- package/dist/postgres-js.mjs +46 -0
- package/dist/postgres-js.mjs.map +1 -0
- package/dist/provenance.cjs +66 -0
- package/dist/provenance.cjs.map +1 -0
- package/dist/provenance.d.cts +40 -0
- package/dist/provenance.d.cts.map +1 -0
- package/dist/provenance.d.mts +40 -0
- package/dist/provenance.d.mts.map +1 -0
- package/dist/provenance.mjs +64 -0
- package/dist/provenance.mjs.map +1 -0
- package/dist/push.cjs +11 -0
- package/dist/push.cjs.map +1 -0
- package/dist/push.d.cts +14 -0
- package/dist/push.d.cts.map +1 -0
- package/dist/push.d.mts +14 -0
- package/dist/push.d.mts.map +1 -0
- package/dist/push.mjs +10 -0
- package/dist/push.mjs.map +1 -0
- package/dist/react-email.cjs +56 -0
- package/dist/react-email.cjs.map +1 -0
- package/dist/react-email.d.cts +5 -0
- package/dist/react-email.d.cts.map +1 -0
- package/dist/react-email.d.mts +5 -0
- package/dist/react-email.d.mts.map +1 -0
- package/dist/react-email.mjs +55 -0
- package/dist/react-email.mjs.map +1 -0
- package/dist/reporting/classify.cjs +46 -0
- package/dist/reporting/classify.cjs.map +1 -0
- package/dist/reporting/classify.d.cts +65 -0
- package/dist/reporting/classify.d.cts.map +1 -0
- package/dist/reporting/classify.d.mts +65 -0
- package/dist/reporting/classify.d.mts.map +1 -0
- package/dist/reporting/classify.mjs +42 -0
- package/dist/reporting/classify.mjs.map +1 -0
- package/dist/reporting/observer.cjs +137 -0
- package/dist/reporting/observer.cjs.map +1 -0
- package/dist/reporting/observer.d.cts +31 -0
- package/dist/reporting/observer.d.cts.map +1 -0
- package/dist/reporting/observer.d.mts +31 -0
- package/dist/reporting/observer.d.mts.map +1 -0
- package/dist/reporting/observer.mjs +134 -0
- package/dist/reporting/observer.mjs.map +1 -0
- package/dist/reporting/tracking.cjs +185 -0
- package/dist/reporting/tracking.cjs.map +1 -0
- package/dist/reporting/tracking.d.cts +63 -0
- package/dist/reporting/tracking.d.cts.map +1 -0
- package/dist/reporting/tracking.d.mts +63 -0
- package/dist/reporting/tracking.d.mts.map +1 -0
- package/dist/reporting/tracking.mjs +182 -0
- package/dist/reporting/tracking.mjs.map +1 -0
- package/dist/runtime.cjs +18 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +44 -0
- package/dist/runtime.d.cts.map +1 -0
- package/dist/runtime.d.mts +44 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +17 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/store/condition-sql.cjs +145 -0
- package/dist/store/condition-sql.cjs.map +1 -0
- package/dist/store/condition-sql.d.cts +38 -0
- package/dist/store/condition-sql.d.cts.map +1 -0
- package/dist/store/condition-sql.d.mts +38 -0
- package/dist/store/condition-sql.d.mts.map +1 -0
- package/dist/store/condition-sql.mjs +144 -0
- package/dist/store/condition-sql.mjs.map +1 -0
- package/dist/store/erasure.cjs +21 -0
- package/dist/store/erasure.cjs.map +1 -0
- package/dist/store/erasure.d.cts +16 -0
- package/dist/store/erasure.d.cts.map +1 -0
- package/dist/store/erasure.d.mts +16 -0
- package/dist/store/erasure.d.mts.map +1 -0
- package/dist/store/erasure.mjs +20 -0
- package/dist/store/erasure.mjs.map +1 -0
- package/dist/store/facts.cjs +79 -0
- package/dist/store/facts.cjs.map +1 -0
- package/dist/store/facts.d.cts +41 -0
- package/dist/store/facts.d.cts.map +1 -0
- package/dist/store/facts.d.mts +41 -0
- package/dist/store/facts.d.mts.map +1 -0
- package/dist/store/facts.mjs +77 -0
- package/dist/store/facts.mjs.map +1 -0
- package/dist/store/identity.cjs +34 -0
- package/dist/store/identity.cjs.map +1 -0
- package/dist/store/identity.d.cts +13 -0
- package/dist/store/identity.d.cts.map +1 -0
- package/dist/store/identity.d.mts +13 -0
- package/dist/store/identity.d.mts.map +1 -0
- package/dist/store/identity.mjs +30 -0
- package/dist/store/identity.mjs.map +1 -0
- package/dist/store/index.cjs +35 -0
- package/dist/store/index.cjs.map +1 -0
- package/dist/store/index.d.cts +766 -0
- package/dist/store/index.d.cts.map +1 -0
- package/dist/store/index.d.mts +766 -0
- package/dist/store/index.d.mts.map +1 -0
- package/dist/store/index.mjs +22 -0
- package/dist/store/index.mjs.map +1 -0
- package/dist/store/postgres-reporting.cjs +327 -0
- package/dist/store/postgres-reporting.cjs.map +1 -0
- package/dist/store/postgres-reporting.d.cts +95 -0
- package/dist/store/postgres-reporting.d.cts.map +1 -0
- package/dist/store/postgres-reporting.d.mts +95 -0
- package/dist/store/postgres-reporting.d.mts.map +1 -0
- package/dist/store/postgres-reporting.mjs +326 -0
- package/dist/store/postgres-reporting.mjs.map +1 -0
- package/dist/store/postgres.cjs +1173 -0
- package/dist/store/postgres.cjs.map +1 -0
- package/dist/store/postgres.d.cts +199 -0
- package/dist/store/postgres.d.cts.map +1 -0
- package/dist/store/postgres.d.mts +199 -0
- package/dist/store/postgres.d.mts.map +1 -0
- package/dist/store/postgres.mjs +1170 -0
- package/dist/store/postgres.mjs.map +1 -0
- package/dist/store/sql.cjs +24 -0
- package/dist/store/sql.cjs.map +1 -0
- package/dist/store/sql.d.cts +26 -0
- package/dist/store/sql.d.cts.map +1 -0
- package/dist/store/sql.d.mts +26 -0
- package/dist/store/sql.d.mts.map +1 -0
- package/dist/store/sql.mjs +23 -0
- package/dist/store/sql.mjs.map +1 -0
- package/dist/store/tables.cjs +660 -0
- package/dist/store/tables.cjs.map +1 -0
- package/dist/store/tables.d.cts +103 -0
- package/dist/store/tables.d.cts.map +1 -0
- package/dist/store/tables.d.mts +103 -0
- package/dist/store/tables.d.mts.map +1 -0
- package/dist/store/tables.mjs +653 -0
- package/dist/store/tables.mjs.map +1 -0
- package/dist/store/user-lock.cjs +42 -0
- package/dist/store/user-lock.cjs.map +1 -0
- package/dist/store/user-lock.d.cts +30 -0
- package/dist/store/user-lock.d.cts.map +1 -0
- package/dist/store/user-lock.d.mts +30 -0
- package/dist/store/user-lock.d.mts.map +1 -0
- package/dist/store/user-lock.mjs +39 -0
- package/dist/store/user-lock.mjs.map +1 -0
- package/dist/template-rules.cjs +94 -0
- package/dist/template-rules.cjs.map +1 -0
- package/dist/template-rules.d.cts +80 -0
- package/dist/template-rules.d.cts.map +1 -0
- package/dist/template-rules.d.mts +80 -0
- package/dist/template-rules.d.mts.map +1 -0
- package/dist/template-rules.mjs +86 -0
- package/dist/template-rules.mjs.map +1 -0
- package/dist/templates.cjs +375 -0
- package/dist/templates.cjs.map +1 -0
- package/dist/templates.d.cts +358 -0
- package/dist/templates.d.cts.map +1 -0
- package/dist/templates.d.mts +358 -0
- package/dist/templates.d.mts.map +1 -0
- package/dist/templates.mjs +353 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/transports/cloudflare-email.cjs +69 -0
- package/dist/transports/cloudflare-email.cjs.map +1 -0
- package/dist/transports/cloudflare-email.d.cts +63 -0
- package/dist/transports/cloudflare-email.d.cts.map +1 -0
- package/dist/transports/cloudflare-email.d.mts +63 -0
- package/dist/transports/cloudflare-email.d.mts.map +1 -0
- package/dist/transports/cloudflare-email.mjs +67 -0
- package/dist/transports/cloudflare-email.mjs.map +1 -0
- package/dist/transports/ses.cjs +142 -0
- package/dist/transports/ses.cjs.map +1 -0
- package/dist/transports/ses.d.cts +49 -0
- package/dist/transports/ses.d.cts.map +1 -0
- package/dist/transports/ses.d.mts +49 -0
- package/dist/transports/ses.d.mts.map +1 -0
- package/dist/transports/ses.mjs +139 -0
- package/dist/transports/ses.mjs.map +1 -0
- package/dist/transports/sigv4.cjs +86 -0
- package/dist/transports/sigv4.cjs.map +1 -0
- package/dist/transports/sigv4.d.cts +25 -0
- package/dist/transports/sigv4.d.cts.map +1 -0
- package/dist/transports/sigv4.d.mts +25 -0
- package/dist/transports/sigv4.d.mts.map +1 -0
- package/dist/transports/sigv4.mjs +85 -0
- package/dist/transports/sigv4.mjs.map +1 -0
- package/dist/webhooks.cjs +97 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +23 -0
- package/dist/webhooks.d.cts.map +1 -0
- package/dist/webhooks.d.mts +23 -0
- package/dist/webhooks.d.mts.map +1 -0
- package/dist/webhooks.mjs +95 -0
- package/dist/webhooks.mjs.map +1 -0
- package/dist/webpush.cjs +361 -0
- package/dist/webpush.cjs.map +1 -0
- package/dist/webpush.d.cts +135 -0
- package/dist/webpush.d.cts.map +1 -0
- package/dist/webpush.d.mts +135 -0
- package/dist/webpush.d.mts.map +1 -0
- package/dist/webpush.mjs +350 -0
- package/dist/webpush.mjs.map +1 -0
- package/package.json +270 -31
- package/src/cloudflare/workers.d.ts +44 -0
- package/index.cjs +0 -18
- package/index.d.cts +0 -4
- package/index.d.mts +0 -4
- package/index.mjs +0 -1
package/dist/plan.cjs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_hash = require("./hash.cjs");
|
|
3
|
+
// src/plan.ts
|
|
4
|
+
/** Whether a status warrants human attention (metadata-only edits do not). */
|
|
5
|
+
function isSemanticChange(status) {
|
|
6
|
+
return status === "added" || status === "removed" || status === "changed";
|
|
7
|
+
}
|
|
8
|
+
/** Every node of a flow, nested ones included, in document order. */
|
|
9
|
+
function nodesOf(flow) {
|
|
10
|
+
return [...flatten(flow, /* @__PURE__ */ new Map()).values()];
|
|
11
|
+
}
|
|
12
|
+
/** Walk the node tree into a flat id → node map (branch arms, cohort arms and timeout flows included). */
|
|
13
|
+
function flatten(nodes, into) {
|
|
14
|
+
for (const node of nodes) {
|
|
15
|
+
into.set(node.id, node);
|
|
16
|
+
switch (node.type) {
|
|
17
|
+
case "branch":
|
|
18
|
+
for (const branchCase of node.cases) flatten(branchCase.flow, into);
|
|
19
|
+
if (node.otherwise) flatten(node.otherwise, into);
|
|
20
|
+
break;
|
|
21
|
+
case "cohort":
|
|
22
|
+
for (const arm of node.arms) flatten(arm.flow, into);
|
|
23
|
+
break;
|
|
24
|
+
case "wait_until": if (Array.isArray(node.onTimeout)) flatten(node.onTimeout, into);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return into;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A node's semantic fingerprint: metadata stripped, child flows excluded (they
|
|
31
|
+
* diff on their own ids). Everything else a compound node owns — branch case
|
|
32
|
+
* conditions, cohort arm names and weights, *having* a default arm or a
|
|
33
|
+
* timeout flow — is this node's semantics and stays in the fingerprint, so
|
|
34
|
+
* editing a branch condition or reweighting an A/B shows up on the node itself.
|
|
35
|
+
*/
|
|
36
|
+
function nodeFingerprint(node) {
|
|
37
|
+
const bare = { ...node };
|
|
38
|
+
if (node.type === "branch") {
|
|
39
|
+
bare.cases = node.cases.map((branchCase) => ({ condition: branchCase.condition }));
|
|
40
|
+
delete bare.otherwise;
|
|
41
|
+
if (node.otherwise !== void 0) bare.otherwise = "<flow>";
|
|
42
|
+
}
|
|
43
|
+
if (node.type === "cohort") bare.arms = node.arms.map((arm) => ({
|
|
44
|
+
name: arm.name,
|
|
45
|
+
weight: arm.weight
|
|
46
|
+
}));
|
|
47
|
+
if (node.type === "wait_until" && Array.isArray(node.onTimeout)) bare.onTimeout = "<flow>";
|
|
48
|
+
return require_hash.fullHash(require_hash.stripMeta(bare));
|
|
49
|
+
}
|
|
50
|
+
function diffNodes(local, deployed) {
|
|
51
|
+
const localNodes = flatten(local.flow, /* @__PURE__ */ new Map());
|
|
52
|
+
const deployedNodes = flatten(deployed.flow, /* @__PURE__ */ new Map());
|
|
53
|
+
const changes = [];
|
|
54
|
+
for (const [id, node] of localNodes) {
|
|
55
|
+
const before = deployedNodes.get(id);
|
|
56
|
+
if (!before) changes.push({
|
|
57
|
+
id,
|
|
58
|
+
status: "added",
|
|
59
|
+
type: node.type
|
|
60
|
+
});
|
|
61
|
+
else if (nodeFingerprint(node) !== nodeFingerprint(before)) changes.push({
|
|
62
|
+
id,
|
|
63
|
+
status: "changed",
|
|
64
|
+
type: node.type
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
for (const [id, node] of deployedNodes) if (!localNodes.has(id)) changes.push({
|
|
68
|
+
id,
|
|
69
|
+
status: "removed",
|
|
70
|
+
type: node.type
|
|
71
|
+
});
|
|
72
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
73
|
+
}
|
|
74
|
+
function diffFields(local, deployed) {
|
|
75
|
+
const fields = [];
|
|
76
|
+
for (const field of [
|
|
77
|
+
"trigger",
|
|
78
|
+
"goal",
|
|
79
|
+
"exitWhen"
|
|
80
|
+
]) if (require_hash.fullHash(require_hash.stripMeta(local[field])) !== require_hash.fullHash(require_hash.stripMeta(deployed[field]))) fields.push(field);
|
|
81
|
+
return fields;
|
|
82
|
+
}
|
|
83
|
+
function statusOf(local, deployed) {
|
|
84
|
+
if (local.contentHash !== deployed.contentHash) return "changed";
|
|
85
|
+
return require_hash.fullHash(require_hash.stripProvenance(local)) === require_hash.fullHash(require_hash.stripProvenance(deployed)) ? "unchanged" : "metadata_only";
|
|
86
|
+
}
|
|
87
|
+
function diffWorkflows(local, deployed) {
|
|
88
|
+
const deployedByName = new Map(deployed.map((item) => [item.id, item]));
|
|
89
|
+
const changes = [];
|
|
90
|
+
for (const item of local) {
|
|
91
|
+
const before = deployedByName.get(item.id);
|
|
92
|
+
if (!before) {
|
|
93
|
+
changes.push({
|
|
94
|
+
id: item.id,
|
|
95
|
+
status: "added",
|
|
96
|
+
after: item.contentHash,
|
|
97
|
+
fields: [],
|
|
98
|
+
nodes: []
|
|
99
|
+
});
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const status = statusOf(item, before);
|
|
103
|
+
changes.push({
|
|
104
|
+
id: item.id,
|
|
105
|
+
status,
|
|
106
|
+
before: before.contentHash,
|
|
107
|
+
after: item.contentHash,
|
|
108
|
+
fields: status === "changed" ? diffFields(item, before) : [],
|
|
109
|
+
nodes: status === "changed" ? diffNodes(item, before) : []
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const localNames = new Set(local.map((item) => item.id));
|
|
113
|
+
for (const item of deployed) if (!localNames.has(item.id)) changes.push({
|
|
114
|
+
id: item.id,
|
|
115
|
+
status: "removed",
|
|
116
|
+
before: item.contentHash,
|
|
117
|
+
fields: [],
|
|
118
|
+
nodes: []
|
|
119
|
+
});
|
|
120
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
121
|
+
}
|
|
122
|
+
function diffSegments(local, deployed) {
|
|
123
|
+
const deployedByName = new Map(deployed.map((item) => [item.id, item]));
|
|
124
|
+
const changes = local.map((item) => {
|
|
125
|
+
const before = deployedByName.get(item.id);
|
|
126
|
+
if (!before) return {
|
|
127
|
+
id: item.id,
|
|
128
|
+
status: "added",
|
|
129
|
+
after: item.contentHash
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
id: item.id,
|
|
133
|
+
status: statusOf(item, before),
|
|
134
|
+
before: before.contentHash,
|
|
135
|
+
after: item.contentHash
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
const localNames = new Set(local.map((item) => item.id));
|
|
139
|
+
for (const item of deployed) if (!localNames.has(item.id)) changes.push({
|
|
140
|
+
id: item.id,
|
|
141
|
+
status: "removed",
|
|
142
|
+
before: item.contentHash
|
|
143
|
+
});
|
|
144
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A template's identity is its key *within its channel* — an email and a push
|
|
148
|
+
* of one nudge share a key — so the diff is keyed, and reported, by
|
|
149
|
+
* `channel:key`. Keyed by bare key, two channels sharing one collapsed into a
|
|
150
|
+
* single entry that flipped between `changed` and `unchanged` depending on
|
|
151
|
+
* which came first.
|
|
152
|
+
*/
|
|
153
|
+
function diffTemplates(local, deployed) {
|
|
154
|
+
const idOf = (item) => `${item.channel}:${item.key}`;
|
|
155
|
+
const deployedIds = new Set(deployed.map(idOf));
|
|
156
|
+
const changes = local.map((item) => ({
|
|
157
|
+
id: idOf(item),
|
|
158
|
+
status: deployedIds.has(idOf(item)) ? "unchanged" : "added"
|
|
159
|
+
}));
|
|
160
|
+
const localIds = new Set(local.map(idOf));
|
|
161
|
+
for (const item of deployed) if (!localIds.has(idOf(item))) changes.push({
|
|
162
|
+
id: idOf(item),
|
|
163
|
+
status: "removed"
|
|
164
|
+
});
|
|
165
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Actions diff by name only: the manifest records identity, and the code
|
|
169
|
+
* itself lives in the Worker bundle. A hash of the handler's printed source
|
|
170
|
+
* would depend on the bundler and report changes nobody made.
|
|
171
|
+
*/
|
|
172
|
+
function diffActions(local, deployed) {
|
|
173
|
+
const deployedNames = new Set(deployed.map((item) => item.name));
|
|
174
|
+
const changes = local.map((item) => ({
|
|
175
|
+
id: item.name,
|
|
176
|
+
status: deployedNames.has(item.name) ? "unchanged" : "added"
|
|
177
|
+
}));
|
|
178
|
+
const localNames = new Set(local.map((item) => item.name));
|
|
179
|
+
for (const item of deployed) if (!localNames.has(item.name)) changes.push({
|
|
180
|
+
id: item.name,
|
|
181
|
+
status: "removed"
|
|
182
|
+
});
|
|
183
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
184
|
+
}
|
|
185
|
+
/** Empty bundle: the default `deployed` on a first deploy, so everything reports as added. */
|
|
186
|
+
const EMPTY = {
|
|
187
|
+
workflows: [],
|
|
188
|
+
segments: [],
|
|
189
|
+
templates: [],
|
|
190
|
+
actions: []
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Compute a deployment plan. Omitting `deployed` means a first deploy.
|
|
194
|
+
*
|
|
195
|
+
* const changes = plan(compileBundle({ workflows }), await fetchDeployed());
|
|
196
|
+
* if (changes.hasChanges) { ... }
|
|
197
|
+
*/
|
|
198
|
+
function plan(local, deployed) {
|
|
199
|
+
const base = deployed ?? EMPTY;
|
|
200
|
+
const workflows = diffWorkflows(local.workflows, base.workflows);
|
|
201
|
+
const segments = diffSegments(local.segments, base.segments);
|
|
202
|
+
const templates = diffTemplates(local.templates, base.templates);
|
|
203
|
+
const actions = diffActions(local.actions, base.actions);
|
|
204
|
+
return {
|
|
205
|
+
workflows,
|
|
206
|
+
segments,
|
|
207
|
+
templates,
|
|
208
|
+
actions,
|
|
209
|
+
hasChanges: [
|
|
210
|
+
...workflows,
|
|
211
|
+
...segments,
|
|
212
|
+
...templates,
|
|
213
|
+
...actions
|
|
214
|
+
].some((change) => isSemanticChange(change.status))
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
exports.isSemanticChange = isSemanticChange;
|
|
218
|
+
exports.nodesOf = nodesOf;
|
|
219
|
+
exports.plan = plan;
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=plan.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.cjs","names":["fullHash","stripMeta","stripProvenance"],"sources":["../src/plan.ts"],"sourcesContent":["import { fullHash, stripMeta, stripProvenance } from './hash';\nimport type { BundleIR, NodeIR, SegmentIR, WorkflowIR } from './ir';\n\n/**\n * Plan — the diff between local definitions and what is deployed (terraform\n * plan, same mental model).\n *\n * This is the core advantage of code-first over a UI canvas: before deploying,\n * a machine can answer \"what changed, and how many in-flight users does it\n * affect\". Pure function, zero IO — CLI, UI and CI share one verdict.\n *\n * Status comes from two levels of comparison:\n * - contentHash differs → `changed` (semantics moved; in-flight users may need\n * migration)\n * - contentHash equal but full content differs → `metadata_only` (description\n * or labels only, nothing about execution) — exactly what keeping metadata\n * out of the hash buys us.\n */\n\nexport type ChangeStatus = 'added' | 'removed' | 'changed' | 'metadata_only' | 'unchanged';\n\n/** Whether a status warrants human attention (metadata-only edits do not). */\nexport function isSemanticChange(status: ChangeStatus): boolean {\n return status === 'added' || status === 'removed' || status === 'changed';\n}\n\nexport interface NodeChange {\n id: string;\n status: 'added' | 'removed' | 'changed';\n /** Node type: taken from the deployed side when removed, local otherwise. */\n type: NodeIR['type'];\n}\n\nexport interface WorkflowChange {\n /** The workflow's id. */\n id: string;\n status: ChangeStatus;\n /** Deployed contentHash (absent when added). */\n before?: string;\n /** Local contentHash (absent when removed). */\n after?: string;\n /** Workflow-level semantic fields that moved (trigger / goal / exitWhen). */\n fields: ('trigger' | 'goal' | 'exitWhen')[];\n /**\n * Node-level detail, matched by structural-path id — so **inserting a node\n * shifts the ids of its later siblings**, and one insert can report as a run\n * of `changed` entries. That is the known trade-off of structural ids (see\n * ir.ts): the verdict stays correct, it is just noisier than ideal.\n */\n nodes: NodeChange[];\n}\n\nexport interface ResourceChange {\n /** The resource's identity: a segment's id, a template's `channel:key`, an action's name. */\n id: string;\n status: ChangeStatus;\n before?: string;\n after?: string;\n}\n\nexport interface BundlePlan {\n workflows: WorkflowChange[];\n segments: ResourceChange[];\n templates: ResourceChange[];\n actions: ResourceChange[];\n /** Whether any semantic change exists (metadata-only edits do not count). */\n hasChanges: boolean;\n}\n\n/** Every node of a flow, nested ones included, in document order. */\nexport function nodesOf(flow: readonly NodeIR[]): NodeIR[] {\n return [...flatten(flow, new Map()).values()];\n}\n\n/** Walk the node tree into a flat id → node map (branch arms, cohort arms and timeout flows included). */\nfunction flatten(nodes: readonly NodeIR[], into: Map<string, NodeIR>): Map<string, NodeIR> {\n for (const node of nodes) {\n into.set(node.id, node);\n switch (node.type) {\n case 'branch':\n for (const branchCase of node.cases) flatten(branchCase.flow, into);\n if (node.otherwise) flatten(node.otherwise, into);\n break;\n case 'cohort':\n for (const arm of node.arms) flatten(arm.flow, into);\n break;\n case 'wait_until':\n if (Array.isArray(node.onTimeout)) flatten(node.onTimeout, into);\n break;\n default:\n break;\n }\n }\n return into;\n}\n\n/**\n * A node's semantic fingerprint: metadata stripped, child flows excluded (they\n * diff on their own ids). Everything else a compound node owns — branch case\n * conditions, cohort arm names and weights, *having* a default arm or a\n * timeout flow — is this node's semantics and stays in the fingerprint, so\n * editing a branch condition or reweighting an A/B shows up on the node itself.\n */\nfunction nodeFingerprint(node: NodeIR): string {\n const bare: Record<string, unknown> = { ...node };\n if (node.type === 'branch') {\n bare.cases = node.cases.map((branchCase) => ({ condition: branchCase.condition }));\n delete bare.otherwise;\n if (node.otherwise !== undefined) bare.otherwise = '<flow>';\n }\n if (node.type === 'cohort') {\n bare.arms = node.arms.map((arm) => ({ name: arm.name, weight: arm.weight }));\n }\n if (node.type === 'wait_until' && Array.isArray(node.onTimeout)) {\n bare.onTimeout = '<flow>';\n }\n return fullHash(stripMeta(bare));\n}\n\nfunction diffNodes(local: WorkflowIR, deployed: WorkflowIR): NodeChange[] {\n const localNodes = flatten(local.flow, new Map());\n const deployedNodes = flatten(deployed.flow, new Map());\n const changes: NodeChange[] = [];\n\n for (const [id, node] of localNodes) {\n const before = deployedNodes.get(id);\n if (!before) {\n changes.push({ id, status: 'added', type: node.type });\n } else if (nodeFingerprint(node) !== nodeFingerprint(before)) {\n changes.push({ id, status: 'changed', type: node.type });\n }\n }\n for (const [id, node] of deployedNodes) {\n if (!localNodes.has(id)) changes.push({ id, status: 'removed', type: node.type });\n }\n\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\nfunction diffFields(local: WorkflowIR, deployed: WorkflowIR): WorkflowChange['fields'] {\n const fields: WorkflowChange['fields'] = [];\n for (const field of ['trigger', 'goal', 'exitWhen'] as const) {\n if (fullHash(stripMeta(local[field])) !== fullHash(stripMeta(deployed[field]))) {\n fields.push(field);\n }\n }\n return fields;\n}\n\nfunction statusOf(local: { contentHash: string }, deployed: { contentHash: string }): ChangeStatus {\n if (local.contentHash !== deployed.contentHash) return 'changed';\n /*\n * Provenance is deliberately not part of the comparison: a recorded loc is a\n * source map, and its path depends on the machine and the directory the\n * compile ran from ('packages/sendwend/src/wf.ts' from the workspace root,\n * 'src/wf.ts' from the package). Comparing it turned every CI run into a\n * wall of metadata_only against a locally compiled deploy. Descriptions,\n * labels and reasons still count — those are edits somebody made.\n */\n return fullHash(stripProvenance(local)) === fullHash(stripProvenance(deployed))\n ? 'unchanged'\n : 'metadata_only';\n}\n\nfunction diffWorkflows(\n local: readonly WorkflowIR[],\n deployed: readonly WorkflowIR[]\n): WorkflowChange[] {\n const deployedByName = new Map(deployed.map((item) => [item.id, item]));\n const changes: WorkflowChange[] = [];\n\n for (const item of local) {\n const before = deployedByName.get(item.id);\n if (!before) {\n changes.push({\n id: item.id,\n status: 'added',\n after: item.contentHash,\n fields: [],\n nodes: [],\n });\n continue;\n }\n const status = statusOf(item, before);\n changes.push({\n id: item.id,\n status,\n before: before.contentHash,\n after: item.contentHash,\n fields: status === 'changed' ? diffFields(item, before) : [],\n nodes: status === 'changed' ? diffNodes(item, before) : [],\n });\n }\n\n const localNames = new Set(local.map((item) => item.id));\n for (const item of deployed) {\n if (!localNames.has(item.id)) {\n changes.push({\n id: item.id,\n status: 'removed',\n before: item.contentHash,\n fields: [],\n nodes: [],\n });\n }\n }\n\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\nfunction diffSegments(\n local: readonly SegmentIR[],\n deployed: readonly SegmentIR[]\n): ResourceChange[] {\n const deployedByName = new Map(deployed.map((item) => [item.id, item]));\n const changes: ResourceChange[] = local.map((item) => {\n const before = deployedByName.get(item.id);\n if (!before) return { id: item.id, status: 'added' as const, after: item.contentHash };\n return {\n id: item.id,\n status: statusOf(item, before),\n before: before.contentHash,\n after: item.contentHash,\n };\n });\n\n const localNames = new Set(local.map((item) => item.id));\n for (const item of deployed) {\n if (!localNames.has(item.id)) {\n changes.push({ id: item.id, status: 'removed', before: item.contentHash });\n }\n }\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/**\n * A template's identity is its key *within its channel* — an email and a push\n * of one nudge share a key — so the diff is keyed, and reported, by\n * `channel:key`. Keyed by bare key, two channels sharing one collapsed into a\n * single entry that flipped between `changed` and `unchanged` depending on\n * which came first.\n */\nfunction diffTemplates(local: BundleIR['templates'], deployed: BundleIR['templates']) {\n const idOf = (item: BundleIR['templates'][number]) => `${item.channel}:${item.key}`;\n const deployedIds = new Set(deployed.map(idOf));\n const changes: ResourceChange[] = local.map((item) => ({\n id: idOf(item),\n status: deployedIds.has(idOf(item)) ? ('unchanged' as const) : ('added' as const),\n }));\n\n const localIds = new Set(local.map(idOf));\n for (const item of deployed) {\n if (!localIds.has(idOf(item))) changes.push({ id: idOf(item), status: 'removed' });\n }\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/**\n * Actions diff by name only: the manifest records identity, and the code\n * itself lives in the Worker bundle. A hash of the handler's printed source\n * would depend on the bundler and report changes nobody made.\n */\nfunction diffActions(local: BundleIR['actions'], deployed: BundleIR['actions']) {\n const deployedNames = new Set(deployed.map((item) => item.name));\n const changes: ResourceChange[] = local.map((item) => ({\n id: item.name,\n status: deployedNames.has(item.name) ? ('unchanged' as const) : ('added' as const),\n }));\n\n const localNames = new Set(local.map((item) => item.name));\n for (const item of deployed) {\n if (!localNames.has(item.name)) changes.push({ id: item.name, status: 'removed' });\n }\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/** Empty bundle: the default `deployed` on a first deploy, so everything reports as added. */\nconst EMPTY: Pick<BundleIR, 'workflows' | 'segments' | 'templates' | 'actions'> = {\n workflows: [],\n segments: [],\n templates: [],\n actions: [],\n};\n\n/**\n * Compute a deployment plan. Omitting `deployed` means a first deploy.\n *\n * const changes = plan(compileBundle({ workflows }), await fetchDeployed());\n * if (changes.hasChanges) { ... }\n */\nexport function plan(local: BundleIR, deployed?: BundleIR): BundlePlan {\n const base = deployed ?? EMPTY;\n const workflows = diffWorkflows(local.workflows, base.workflows);\n const segments = diffSegments(local.segments, base.segments);\n const templates = diffTemplates(local.templates, base.templates);\n const actions = diffActions(local.actions, base.actions);\n\n const hasChanges = [...workflows, ...segments, ...templates, ...actions].some((change) =>\n isSemanticChange(change.status)\n );\n\n return { workflows, segments, templates, actions, hasChanges };\n}\n"],"mappings":";;;;AAsBA,SAAgB,iBAAiB,QAA+B;CAC9D,OAAO,WAAW,WAAW,WAAW,aAAa,WAAW;AAClE;;AA8CA,SAAgB,QAAQ,MAAmC;CACzD,OAAO,CAAC,GAAG,QAAQ,sBAAM,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9C;;AAGA,SAAS,QAAQ,OAA0B,MAAgD;CACzF,KAAK,MAAM,QAAQ,OAAO;EACxB,KAAK,IAAI,KAAK,IAAI,IAAI;EACtB,QAAQ,KAAK,MAAb;GACE,KAAK;IACH,KAAK,MAAM,cAAc,KAAK,OAAO,QAAQ,WAAW,MAAM,IAAI;IAClE,IAAI,KAAK,WAAW,QAAQ,KAAK,WAAW,IAAI;IAChD;GACF,KAAK;IACH,KAAK,MAAM,OAAO,KAAK,MAAM,QAAQ,IAAI,MAAM,IAAI;IACnD;GACF,KAAK,cACH,IAAI,MAAM,QAAQ,KAAK,SAAS,GAAG,QAAQ,KAAK,WAAW,IAAI;EAInE;CACF;CACA,OAAO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odeIR } from "./ir.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Plan — the diff between local definitions and what is deployed (terraform
|
|
4
|
+
* plan, same mental model).
|
|
5
|
+
*
|
|
6
|
+
* This is the core advantage of code-first over a UI canvas: before deploying,
|
|
7
|
+
* a machine can answer "what changed, and how many in-flight users does it
|
|
8
|
+
* affect". Pure function, zero IO — CLI, UI and CI share one verdict.
|
|
9
|
+
*
|
|
10
|
+
* Status comes from two levels of comparison:
|
|
11
|
+
* - contentHash differs → `changed` (semantics moved; in-flight users may need
|
|
12
|
+
* migration)
|
|
13
|
+
* - contentHash equal but full content differs → `metadata_only` (description
|
|
14
|
+
* or labels only, nothing about execution) — exactly what keeping metadata
|
|
15
|
+
* out of the hash buys us.
|
|
16
|
+
*/
|
|
17
|
+
export type ChangeStatus = 'added' | 'removed' | 'changed' | 'metadata_only' | 'unchanged';
|
|
18
|
+
/** Whether a status warrants human attention (metadata-only edits do not). */
|
|
19
|
+
export declare function isSemanticChange(status: ChangeStatus): boolean;
|
|
20
|
+
export interface NodeChange {
|
|
21
|
+
id: string;
|
|
22
|
+
status: 'added' | 'removed' | 'changed';
|
|
23
|
+
/** Node type: taken from the deployed side when removed, local otherwise. */
|
|
24
|
+
type: NodeIR['type'];
|
|
25
|
+
}
|
|
26
|
+
export interface WorkflowChange {
|
|
27
|
+
/** The workflow's id. */
|
|
28
|
+
id: string;
|
|
29
|
+
status: ChangeStatus;
|
|
30
|
+
/** Deployed contentHash (absent when added). */
|
|
31
|
+
before?: string;
|
|
32
|
+
/** Local contentHash (absent when removed). */
|
|
33
|
+
after?: string;
|
|
34
|
+
/** Workflow-level semantic fields that moved (trigger / goal / exitWhen). */
|
|
35
|
+
fields: ('trigger' | 'goal' | 'exitWhen')[];
|
|
36
|
+
/**
|
|
37
|
+
* Node-level detail, matched by structural-path id — so **inserting a node
|
|
38
|
+
* shifts the ids of its later siblings**, and one insert can report as a run
|
|
39
|
+
* of `changed` entries. That is the known trade-off of structural ids (see
|
|
40
|
+
* ir.ts): the verdict stays correct, it is just noisier than ideal.
|
|
41
|
+
*/
|
|
42
|
+
nodes: NodeChange[];
|
|
43
|
+
}
|
|
44
|
+
export interface ResourceChange {
|
|
45
|
+
/** The resource's identity: a segment's id, a template's `channel:key`, an action's name. */
|
|
46
|
+
id: string;
|
|
47
|
+
status: ChangeStatus;
|
|
48
|
+
before?: string;
|
|
49
|
+
after?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface BundlePlan {
|
|
52
|
+
workflows: WorkflowChange[];
|
|
53
|
+
segments: ResourceChange[];
|
|
54
|
+
templates: ResourceChange[];
|
|
55
|
+
actions: ResourceChange[];
|
|
56
|
+
/** Whether any semantic change exists (metadata-only edits do not count). */
|
|
57
|
+
hasChanges: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Every node of a flow, nested ones included, in document order. */
|
|
60
|
+
export declare function nodesOf(flow: readonly NodeIR[]): NodeIR[];
|
|
61
|
+
/**
|
|
62
|
+
* Compute a deployment plan. Omitting `deployed` means a first deploy.
|
|
63
|
+
*
|
|
64
|
+
* const changes = plan(compileBundle({ workflows }), await fetchDeployed());
|
|
65
|
+
* if (changes.hasChanges) { ... }
|
|
66
|
+
*/
|
|
67
|
+
export declare function plan(local: BundleIR, deployed?: BundleIR): BundlePlan;
|
|
68
|
+
//# sourceMappingURL=plan.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.cts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;;;;;;;;;;;YAmBY;;wBAGI,iBAAiB,QAAQ;iBAIxB;EACf;EACA;;EAEA,MAAM;;iBAGS;;EAEf;EACA,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;EAOA,OAAO;;iBAGQ;;EAEf;EACA,QAAQ;EACR;EACA;;iBAGe;EACf,WAAW;EACX,UAAU;EACV,WAAW;EACX,SAAS;;EAET;;;wBAIc,QAAQ,eAAe,WAAW;;;;;;;wBA4NlC,KAAK,OAAO,UAAU,WAAW,WAAW"}
|
package/dist/plan.d.mts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BundleIR, NodeIR } from "./ir.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Plan — the diff between local definitions and what is deployed (terraform
|
|
4
|
+
* plan, same mental model).
|
|
5
|
+
*
|
|
6
|
+
* This is the core advantage of code-first over a UI canvas: before deploying,
|
|
7
|
+
* a machine can answer "what changed, and how many in-flight users does it
|
|
8
|
+
* affect". Pure function, zero IO — CLI, UI and CI share one verdict.
|
|
9
|
+
*
|
|
10
|
+
* Status comes from two levels of comparison:
|
|
11
|
+
* - contentHash differs → `changed` (semantics moved; in-flight users may need
|
|
12
|
+
* migration)
|
|
13
|
+
* - contentHash equal but full content differs → `metadata_only` (description
|
|
14
|
+
* or labels only, nothing about execution) — exactly what keeping metadata
|
|
15
|
+
* out of the hash buys us.
|
|
16
|
+
*/
|
|
17
|
+
export type ChangeStatus = 'added' | 'removed' | 'changed' | 'metadata_only' | 'unchanged';
|
|
18
|
+
/** Whether a status warrants human attention (metadata-only edits do not). */
|
|
19
|
+
export declare function isSemanticChange(status: ChangeStatus): boolean;
|
|
20
|
+
export interface NodeChange {
|
|
21
|
+
id: string;
|
|
22
|
+
status: 'added' | 'removed' | 'changed';
|
|
23
|
+
/** Node type: taken from the deployed side when removed, local otherwise. */
|
|
24
|
+
type: NodeIR['type'];
|
|
25
|
+
}
|
|
26
|
+
export interface WorkflowChange {
|
|
27
|
+
/** The workflow's id. */
|
|
28
|
+
id: string;
|
|
29
|
+
status: ChangeStatus;
|
|
30
|
+
/** Deployed contentHash (absent when added). */
|
|
31
|
+
before?: string;
|
|
32
|
+
/** Local contentHash (absent when removed). */
|
|
33
|
+
after?: string;
|
|
34
|
+
/** Workflow-level semantic fields that moved (trigger / goal / exitWhen). */
|
|
35
|
+
fields: ('trigger' | 'goal' | 'exitWhen')[];
|
|
36
|
+
/**
|
|
37
|
+
* Node-level detail, matched by structural-path id — so **inserting a node
|
|
38
|
+
* shifts the ids of its later siblings**, and one insert can report as a run
|
|
39
|
+
* of `changed` entries. That is the known trade-off of structural ids (see
|
|
40
|
+
* ir.ts): the verdict stays correct, it is just noisier than ideal.
|
|
41
|
+
*/
|
|
42
|
+
nodes: NodeChange[];
|
|
43
|
+
}
|
|
44
|
+
export interface ResourceChange {
|
|
45
|
+
/** The resource's identity: a segment's id, a template's `channel:key`, an action's name. */
|
|
46
|
+
id: string;
|
|
47
|
+
status: ChangeStatus;
|
|
48
|
+
before?: string;
|
|
49
|
+
after?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface BundlePlan {
|
|
52
|
+
workflows: WorkflowChange[];
|
|
53
|
+
segments: ResourceChange[];
|
|
54
|
+
templates: ResourceChange[];
|
|
55
|
+
actions: ResourceChange[];
|
|
56
|
+
/** Whether any semantic change exists (metadata-only edits do not count). */
|
|
57
|
+
hasChanges: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Every node of a flow, nested ones included, in document order. */
|
|
60
|
+
export declare function nodesOf(flow: readonly NodeIR[]): NodeIR[];
|
|
61
|
+
/**
|
|
62
|
+
* Compute a deployment plan. Omitting `deployed` means a first deploy.
|
|
63
|
+
*
|
|
64
|
+
* const changes = plan(compileBundle({ workflows }), await fetchDeployed());
|
|
65
|
+
* if (changes.hasChanges) { ... }
|
|
66
|
+
*/
|
|
67
|
+
export declare function plan(local: BundleIR, deployed?: BundleIR): BundlePlan;
|
|
68
|
+
//# sourceMappingURL=plan.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.mts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;;;;;;;;;;;YAmBY;;wBAGI,iBAAiB,QAAQ;iBAIxB;EACf;EACA;;EAEA,MAAM;;iBAGS;;EAEf;EACA,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;EAOA,OAAO;;iBAGQ;;EAEf;EACA,QAAQ;EACR;EACA;;iBAGe;EACf,WAAW;EACX,UAAU;EACV,WAAW;EACX,SAAS;;EAET;;;wBAIc,QAAQ,eAAe,WAAW;;;;;;;wBA4NlC,KAAK,OAAO,UAAU,WAAW,WAAW"}
|
package/dist/plan.mjs
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { fullHash, stripMeta, stripProvenance } from "./hash.mjs";
|
|
2
|
+
// src/plan.ts
|
|
3
|
+
/** Whether a status warrants human attention (metadata-only edits do not). */
|
|
4
|
+
function isSemanticChange(status) {
|
|
5
|
+
return status === "added" || status === "removed" || status === "changed";
|
|
6
|
+
}
|
|
7
|
+
/** Every node of a flow, nested ones included, in document order. */
|
|
8
|
+
function nodesOf(flow) {
|
|
9
|
+
return [...flatten(flow, /* @__PURE__ */ new Map()).values()];
|
|
10
|
+
}
|
|
11
|
+
/** Walk the node tree into a flat id → node map (branch arms, cohort arms and timeout flows included). */
|
|
12
|
+
function flatten(nodes, into) {
|
|
13
|
+
for (const node of nodes) {
|
|
14
|
+
into.set(node.id, node);
|
|
15
|
+
switch (node.type) {
|
|
16
|
+
case "branch":
|
|
17
|
+
for (const branchCase of node.cases) flatten(branchCase.flow, into);
|
|
18
|
+
if (node.otherwise) flatten(node.otherwise, into);
|
|
19
|
+
break;
|
|
20
|
+
case "cohort":
|
|
21
|
+
for (const arm of node.arms) flatten(arm.flow, into);
|
|
22
|
+
break;
|
|
23
|
+
case "wait_until": if (Array.isArray(node.onTimeout)) flatten(node.onTimeout, into);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return into;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A node's semantic fingerprint: metadata stripped, child flows excluded (they
|
|
30
|
+
* diff on their own ids). Everything else a compound node owns — branch case
|
|
31
|
+
* conditions, cohort arm names and weights, *having* a default arm or a
|
|
32
|
+
* timeout flow — is this node's semantics and stays in the fingerprint, so
|
|
33
|
+
* editing a branch condition or reweighting an A/B shows up on the node itself.
|
|
34
|
+
*/
|
|
35
|
+
function nodeFingerprint(node) {
|
|
36
|
+
const bare = { ...node };
|
|
37
|
+
if (node.type === "branch") {
|
|
38
|
+
bare.cases = node.cases.map((branchCase) => ({ condition: branchCase.condition }));
|
|
39
|
+
delete bare.otherwise;
|
|
40
|
+
if (node.otherwise !== void 0) bare.otherwise = "<flow>";
|
|
41
|
+
}
|
|
42
|
+
if (node.type === "cohort") bare.arms = node.arms.map((arm) => ({
|
|
43
|
+
name: arm.name,
|
|
44
|
+
weight: arm.weight
|
|
45
|
+
}));
|
|
46
|
+
if (node.type === "wait_until" && Array.isArray(node.onTimeout)) bare.onTimeout = "<flow>";
|
|
47
|
+
return fullHash(stripMeta(bare));
|
|
48
|
+
}
|
|
49
|
+
function diffNodes(local, deployed) {
|
|
50
|
+
const localNodes = flatten(local.flow, /* @__PURE__ */ new Map());
|
|
51
|
+
const deployedNodes = flatten(deployed.flow, /* @__PURE__ */ new Map());
|
|
52
|
+
const changes = [];
|
|
53
|
+
for (const [id, node] of localNodes) {
|
|
54
|
+
const before = deployedNodes.get(id);
|
|
55
|
+
if (!before) changes.push({
|
|
56
|
+
id,
|
|
57
|
+
status: "added",
|
|
58
|
+
type: node.type
|
|
59
|
+
});
|
|
60
|
+
else if (nodeFingerprint(node) !== nodeFingerprint(before)) changes.push({
|
|
61
|
+
id,
|
|
62
|
+
status: "changed",
|
|
63
|
+
type: node.type
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
for (const [id, node] of deployedNodes) if (!localNodes.has(id)) changes.push({
|
|
67
|
+
id,
|
|
68
|
+
status: "removed",
|
|
69
|
+
type: node.type
|
|
70
|
+
});
|
|
71
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
72
|
+
}
|
|
73
|
+
function diffFields(local, deployed) {
|
|
74
|
+
const fields = [];
|
|
75
|
+
for (const field of [
|
|
76
|
+
"trigger",
|
|
77
|
+
"goal",
|
|
78
|
+
"exitWhen"
|
|
79
|
+
]) if (fullHash(stripMeta(local[field])) !== fullHash(stripMeta(deployed[field]))) fields.push(field);
|
|
80
|
+
return fields;
|
|
81
|
+
}
|
|
82
|
+
function statusOf(local, deployed) {
|
|
83
|
+
if (local.contentHash !== deployed.contentHash) return "changed";
|
|
84
|
+
return fullHash(stripProvenance(local)) === fullHash(stripProvenance(deployed)) ? "unchanged" : "metadata_only";
|
|
85
|
+
}
|
|
86
|
+
function diffWorkflows(local, deployed) {
|
|
87
|
+
const deployedByName = new Map(deployed.map((item) => [item.id, item]));
|
|
88
|
+
const changes = [];
|
|
89
|
+
for (const item of local) {
|
|
90
|
+
const before = deployedByName.get(item.id);
|
|
91
|
+
if (!before) {
|
|
92
|
+
changes.push({
|
|
93
|
+
id: item.id,
|
|
94
|
+
status: "added",
|
|
95
|
+
after: item.contentHash,
|
|
96
|
+
fields: [],
|
|
97
|
+
nodes: []
|
|
98
|
+
});
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const status = statusOf(item, before);
|
|
102
|
+
changes.push({
|
|
103
|
+
id: item.id,
|
|
104
|
+
status,
|
|
105
|
+
before: before.contentHash,
|
|
106
|
+
after: item.contentHash,
|
|
107
|
+
fields: status === "changed" ? diffFields(item, before) : [],
|
|
108
|
+
nodes: status === "changed" ? diffNodes(item, before) : []
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const localNames = new Set(local.map((item) => item.id));
|
|
112
|
+
for (const item of deployed) if (!localNames.has(item.id)) changes.push({
|
|
113
|
+
id: item.id,
|
|
114
|
+
status: "removed",
|
|
115
|
+
before: item.contentHash,
|
|
116
|
+
fields: [],
|
|
117
|
+
nodes: []
|
|
118
|
+
});
|
|
119
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
120
|
+
}
|
|
121
|
+
function diffSegments(local, deployed) {
|
|
122
|
+
const deployedByName = new Map(deployed.map((item) => [item.id, item]));
|
|
123
|
+
const changes = local.map((item) => {
|
|
124
|
+
const before = deployedByName.get(item.id);
|
|
125
|
+
if (!before) return {
|
|
126
|
+
id: item.id,
|
|
127
|
+
status: "added",
|
|
128
|
+
after: item.contentHash
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
id: item.id,
|
|
132
|
+
status: statusOf(item, before),
|
|
133
|
+
before: before.contentHash,
|
|
134
|
+
after: item.contentHash
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
const localNames = new Set(local.map((item) => item.id));
|
|
138
|
+
for (const item of deployed) if (!localNames.has(item.id)) changes.push({
|
|
139
|
+
id: item.id,
|
|
140
|
+
status: "removed",
|
|
141
|
+
before: item.contentHash
|
|
142
|
+
});
|
|
143
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A template's identity is its key *within its channel* — an email and a push
|
|
147
|
+
* of one nudge share a key — so the diff is keyed, and reported, by
|
|
148
|
+
* `channel:key`. Keyed by bare key, two channels sharing one collapsed into a
|
|
149
|
+
* single entry that flipped between `changed` and `unchanged` depending on
|
|
150
|
+
* which came first.
|
|
151
|
+
*/
|
|
152
|
+
function diffTemplates(local, deployed) {
|
|
153
|
+
const idOf = (item) => `${item.channel}:${item.key}`;
|
|
154
|
+
const deployedIds = new Set(deployed.map(idOf));
|
|
155
|
+
const changes = local.map((item) => ({
|
|
156
|
+
id: idOf(item),
|
|
157
|
+
status: deployedIds.has(idOf(item)) ? "unchanged" : "added"
|
|
158
|
+
}));
|
|
159
|
+
const localIds = new Set(local.map(idOf));
|
|
160
|
+
for (const item of deployed) if (!localIds.has(idOf(item))) changes.push({
|
|
161
|
+
id: idOf(item),
|
|
162
|
+
status: "removed"
|
|
163
|
+
});
|
|
164
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Actions diff by name only: the manifest records identity, and the code
|
|
168
|
+
* itself lives in the Worker bundle. A hash of the handler's printed source
|
|
169
|
+
* would depend on the bundler and report changes nobody made.
|
|
170
|
+
*/
|
|
171
|
+
function diffActions(local, deployed) {
|
|
172
|
+
const deployedNames = new Set(deployed.map((item) => item.name));
|
|
173
|
+
const changes = local.map((item) => ({
|
|
174
|
+
id: item.name,
|
|
175
|
+
status: deployedNames.has(item.name) ? "unchanged" : "added"
|
|
176
|
+
}));
|
|
177
|
+
const localNames = new Set(local.map((item) => item.name));
|
|
178
|
+
for (const item of deployed) if (!localNames.has(item.name)) changes.push({
|
|
179
|
+
id: item.name,
|
|
180
|
+
status: "removed"
|
|
181
|
+
});
|
|
182
|
+
return changes.sort((a, b) => a.id.localeCompare(b.id));
|
|
183
|
+
}
|
|
184
|
+
/** Empty bundle: the default `deployed` on a first deploy, so everything reports as added. */
|
|
185
|
+
const EMPTY = {
|
|
186
|
+
workflows: [],
|
|
187
|
+
segments: [],
|
|
188
|
+
templates: [],
|
|
189
|
+
actions: []
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Compute a deployment plan. Omitting `deployed` means a first deploy.
|
|
193
|
+
*
|
|
194
|
+
* const changes = plan(compileBundle({ workflows }), await fetchDeployed());
|
|
195
|
+
* if (changes.hasChanges) { ... }
|
|
196
|
+
*/
|
|
197
|
+
function plan(local, deployed) {
|
|
198
|
+
const base = deployed ?? EMPTY;
|
|
199
|
+
const workflows = diffWorkflows(local.workflows, base.workflows);
|
|
200
|
+
const segments = diffSegments(local.segments, base.segments);
|
|
201
|
+
const templates = diffTemplates(local.templates, base.templates);
|
|
202
|
+
const actions = diffActions(local.actions, base.actions);
|
|
203
|
+
return {
|
|
204
|
+
workflows,
|
|
205
|
+
segments,
|
|
206
|
+
templates,
|
|
207
|
+
actions,
|
|
208
|
+
hasChanges: [
|
|
209
|
+
...workflows,
|
|
210
|
+
...segments,
|
|
211
|
+
...templates,
|
|
212
|
+
...actions
|
|
213
|
+
].some((change) => isSemanticChange(change.status))
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export { isSemanticChange, nodesOf, plan };
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=plan.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.mjs","names":[],"sources":["../src/plan.ts"],"sourcesContent":["import { fullHash, stripMeta, stripProvenance } from './hash';\nimport type { BundleIR, NodeIR, SegmentIR, WorkflowIR } from './ir';\n\n/**\n * Plan — the diff between local definitions and what is deployed (terraform\n * plan, same mental model).\n *\n * This is the core advantage of code-first over a UI canvas: before deploying,\n * a machine can answer \"what changed, and how many in-flight users does it\n * affect\". Pure function, zero IO — CLI, UI and CI share one verdict.\n *\n * Status comes from two levels of comparison:\n * - contentHash differs → `changed` (semantics moved; in-flight users may need\n * migration)\n * - contentHash equal but full content differs → `metadata_only` (description\n * or labels only, nothing about execution) — exactly what keeping metadata\n * out of the hash buys us.\n */\n\nexport type ChangeStatus = 'added' | 'removed' | 'changed' | 'metadata_only' | 'unchanged';\n\n/** Whether a status warrants human attention (metadata-only edits do not). */\nexport function isSemanticChange(status: ChangeStatus): boolean {\n return status === 'added' || status === 'removed' || status === 'changed';\n}\n\nexport interface NodeChange {\n id: string;\n status: 'added' | 'removed' | 'changed';\n /** Node type: taken from the deployed side when removed, local otherwise. */\n type: NodeIR['type'];\n}\n\nexport interface WorkflowChange {\n /** The workflow's id. */\n id: string;\n status: ChangeStatus;\n /** Deployed contentHash (absent when added). */\n before?: string;\n /** Local contentHash (absent when removed). */\n after?: string;\n /** Workflow-level semantic fields that moved (trigger / goal / exitWhen). */\n fields: ('trigger' | 'goal' | 'exitWhen')[];\n /**\n * Node-level detail, matched by structural-path id — so **inserting a node\n * shifts the ids of its later siblings**, and one insert can report as a run\n * of `changed` entries. That is the known trade-off of structural ids (see\n * ir.ts): the verdict stays correct, it is just noisier than ideal.\n */\n nodes: NodeChange[];\n}\n\nexport interface ResourceChange {\n /** The resource's identity: a segment's id, a template's `channel:key`, an action's name. */\n id: string;\n status: ChangeStatus;\n before?: string;\n after?: string;\n}\n\nexport interface BundlePlan {\n workflows: WorkflowChange[];\n segments: ResourceChange[];\n templates: ResourceChange[];\n actions: ResourceChange[];\n /** Whether any semantic change exists (metadata-only edits do not count). */\n hasChanges: boolean;\n}\n\n/** Every node of a flow, nested ones included, in document order. */\nexport function nodesOf(flow: readonly NodeIR[]): NodeIR[] {\n return [...flatten(flow, new Map()).values()];\n}\n\n/** Walk the node tree into a flat id → node map (branch arms, cohort arms and timeout flows included). */\nfunction flatten(nodes: readonly NodeIR[], into: Map<string, NodeIR>): Map<string, NodeIR> {\n for (const node of nodes) {\n into.set(node.id, node);\n switch (node.type) {\n case 'branch':\n for (const branchCase of node.cases) flatten(branchCase.flow, into);\n if (node.otherwise) flatten(node.otherwise, into);\n break;\n case 'cohort':\n for (const arm of node.arms) flatten(arm.flow, into);\n break;\n case 'wait_until':\n if (Array.isArray(node.onTimeout)) flatten(node.onTimeout, into);\n break;\n default:\n break;\n }\n }\n return into;\n}\n\n/**\n * A node's semantic fingerprint: metadata stripped, child flows excluded (they\n * diff on their own ids). Everything else a compound node owns — branch case\n * conditions, cohort arm names and weights, *having* a default arm or a\n * timeout flow — is this node's semantics and stays in the fingerprint, so\n * editing a branch condition or reweighting an A/B shows up on the node itself.\n */\nfunction nodeFingerprint(node: NodeIR): string {\n const bare: Record<string, unknown> = { ...node };\n if (node.type === 'branch') {\n bare.cases = node.cases.map((branchCase) => ({ condition: branchCase.condition }));\n delete bare.otherwise;\n if (node.otherwise !== undefined) bare.otherwise = '<flow>';\n }\n if (node.type === 'cohort') {\n bare.arms = node.arms.map((arm) => ({ name: arm.name, weight: arm.weight }));\n }\n if (node.type === 'wait_until' && Array.isArray(node.onTimeout)) {\n bare.onTimeout = '<flow>';\n }\n return fullHash(stripMeta(bare));\n}\n\nfunction diffNodes(local: WorkflowIR, deployed: WorkflowIR): NodeChange[] {\n const localNodes = flatten(local.flow, new Map());\n const deployedNodes = flatten(deployed.flow, new Map());\n const changes: NodeChange[] = [];\n\n for (const [id, node] of localNodes) {\n const before = deployedNodes.get(id);\n if (!before) {\n changes.push({ id, status: 'added', type: node.type });\n } else if (nodeFingerprint(node) !== nodeFingerprint(before)) {\n changes.push({ id, status: 'changed', type: node.type });\n }\n }\n for (const [id, node] of deployedNodes) {\n if (!localNodes.has(id)) changes.push({ id, status: 'removed', type: node.type });\n }\n\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\nfunction diffFields(local: WorkflowIR, deployed: WorkflowIR): WorkflowChange['fields'] {\n const fields: WorkflowChange['fields'] = [];\n for (const field of ['trigger', 'goal', 'exitWhen'] as const) {\n if (fullHash(stripMeta(local[field])) !== fullHash(stripMeta(deployed[field]))) {\n fields.push(field);\n }\n }\n return fields;\n}\n\nfunction statusOf(local: { contentHash: string }, deployed: { contentHash: string }): ChangeStatus {\n if (local.contentHash !== deployed.contentHash) return 'changed';\n /*\n * Provenance is deliberately not part of the comparison: a recorded loc is a\n * source map, and its path depends on the machine and the directory the\n * compile ran from ('packages/sendwend/src/wf.ts' from the workspace root,\n * 'src/wf.ts' from the package). Comparing it turned every CI run into a\n * wall of metadata_only against a locally compiled deploy. Descriptions,\n * labels and reasons still count — those are edits somebody made.\n */\n return fullHash(stripProvenance(local)) === fullHash(stripProvenance(deployed))\n ? 'unchanged'\n : 'metadata_only';\n}\n\nfunction diffWorkflows(\n local: readonly WorkflowIR[],\n deployed: readonly WorkflowIR[]\n): WorkflowChange[] {\n const deployedByName = new Map(deployed.map((item) => [item.id, item]));\n const changes: WorkflowChange[] = [];\n\n for (const item of local) {\n const before = deployedByName.get(item.id);\n if (!before) {\n changes.push({\n id: item.id,\n status: 'added',\n after: item.contentHash,\n fields: [],\n nodes: [],\n });\n continue;\n }\n const status = statusOf(item, before);\n changes.push({\n id: item.id,\n status,\n before: before.contentHash,\n after: item.contentHash,\n fields: status === 'changed' ? diffFields(item, before) : [],\n nodes: status === 'changed' ? diffNodes(item, before) : [],\n });\n }\n\n const localNames = new Set(local.map((item) => item.id));\n for (const item of deployed) {\n if (!localNames.has(item.id)) {\n changes.push({\n id: item.id,\n status: 'removed',\n before: item.contentHash,\n fields: [],\n nodes: [],\n });\n }\n }\n\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\nfunction diffSegments(\n local: readonly SegmentIR[],\n deployed: readonly SegmentIR[]\n): ResourceChange[] {\n const deployedByName = new Map(deployed.map((item) => [item.id, item]));\n const changes: ResourceChange[] = local.map((item) => {\n const before = deployedByName.get(item.id);\n if (!before) return { id: item.id, status: 'added' as const, after: item.contentHash };\n return {\n id: item.id,\n status: statusOf(item, before),\n before: before.contentHash,\n after: item.contentHash,\n };\n });\n\n const localNames = new Set(local.map((item) => item.id));\n for (const item of deployed) {\n if (!localNames.has(item.id)) {\n changes.push({ id: item.id, status: 'removed', before: item.contentHash });\n }\n }\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/**\n * A template's identity is its key *within its channel* — an email and a push\n * of one nudge share a key — so the diff is keyed, and reported, by\n * `channel:key`. Keyed by bare key, two channels sharing one collapsed into a\n * single entry that flipped between `changed` and `unchanged` depending on\n * which came first.\n */\nfunction diffTemplates(local: BundleIR['templates'], deployed: BundleIR['templates']) {\n const idOf = (item: BundleIR['templates'][number]) => `${item.channel}:${item.key}`;\n const deployedIds = new Set(deployed.map(idOf));\n const changes: ResourceChange[] = local.map((item) => ({\n id: idOf(item),\n status: deployedIds.has(idOf(item)) ? ('unchanged' as const) : ('added' as const),\n }));\n\n const localIds = new Set(local.map(idOf));\n for (const item of deployed) {\n if (!localIds.has(idOf(item))) changes.push({ id: idOf(item), status: 'removed' });\n }\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/**\n * Actions diff by name only: the manifest records identity, and the code\n * itself lives in the Worker bundle. A hash of the handler's printed source\n * would depend on the bundler and report changes nobody made.\n */\nfunction diffActions(local: BundleIR['actions'], deployed: BundleIR['actions']) {\n const deployedNames = new Set(deployed.map((item) => item.name));\n const changes: ResourceChange[] = local.map((item) => ({\n id: item.name,\n status: deployedNames.has(item.name) ? ('unchanged' as const) : ('added' as const),\n }));\n\n const localNames = new Set(local.map((item) => item.name));\n for (const item of deployed) {\n if (!localNames.has(item.name)) changes.push({ id: item.name, status: 'removed' });\n }\n return changes.sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/** Empty bundle: the default `deployed` on a first deploy, so everything reports as added. */\nconst EMPTY: Pick<BundleIR, 'workflows' | 'segments' | 'templates' | 'actions'> = {\n workflows: [],\n segments: [],\n templates: [],\n actions: [],\n};\n\n/**\n * Compute a deployment plan. Omitting `deployed` means a first deploy.\n *\n * const changes = plan(compileBundle({ workflows }), await fetchDeployed());\n * if (changes.hasChanges) { ... }\n */\nexport function plan(local: BundleIR, deployed?: BundleIR): BundlePlan {\n const base = deployed ?? EMPTY;\n const workflows = diffWorkflows(local.workflows, base.workflows);\n const segments = diffSegments(local.segments, base.segments);\n const templates = diffTemplates(local.templates, base.templates);\n const actions = diffActions(local.actions, base.actions);\n\n const hasChanges = [...workflows, ...segments, ...templates, ...actions].some((change) =>\n isSemanticChange(change.status)\n );\n\n return { workflows, segments, templates, actions, hasChanges };\n}\n"],"mappings":";;;AAsBA,SAAgB,iBAAiB,QAA+B;CAC9D,OAAO,WAAW,WAAW,WAAW,aAAa,WAAW;AAClE;;AA8CA,SAAgB,QAAQ,MAAmC;CACzD,OAAO,CAAC,GAAG,QAAQ,sBAAM,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9C;;AAGA,SAAS,QAAQ,OAA0B,MAAgD;CACzF,KAAK,MAAM,QAAQ,OAAO;EACxB,KAAK,IAAI,KAAK,IAAI,IAAI;EACtB,QAAQ,KAAK,MAAb;GACE,KAAK;IACH,KAAK,MAAM,cAAc,KAAK,OAAO,QAAQ,WAAW,MAAM,IAAI;IAClE,IAAI,KAAK,WAAW,QAAQ,KAAK,WAAW,IAAI;IAChD;GACF,KAAK;IACH,KAAK,MAAM,OAAO,KAAK,MAAM,QAAQ,IAAI,MAAM,IAAI;IACnD;GACF,KAAK,cACH,IAAI,MAAM,QAAQ,KAAK,SAAS,GAAG,QAAQ,K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