@shware/workflow 4.1.1 → 5.0.1
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/README.md +16 -38
- package/dist/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/apns-relay.cjs +1 -2
- package/dist/apns-relay.d.cts +0 -2
- package/dist/apns-relay.d.cts.map +1 -1
- package/dist/apns-relay.d.mts +0 -2
- package/dist/apns-relay.d.mts.map +1 -1
- package/dist/apns-relay.mjs +1 -2
- package/dist/apns.cjs +1 -2
- package/dist/apns.d.cts +0 -2
- package/dist/apns.d.cts.map +1 -1
- package/dist/apns.d.mts +0 -2
- package/dist/apns.d.mts.map +1 -1
- package/dist/apns.mjs +1 -2
- package/dist/aws/engine-step.cjs +1 -2
- package/dist/aws/engine-step.d.cts +0 -2
- package/dist/aws/engine-step.d.cts.map +1 -1
- package/dist/aws/engine-step.d.mts +0 -2
- package/dist/aws/engine-step.d.mts.map +1 -1
- package/dist/aws/engine-step.mjs +1 -2
- package/dist/aws/function-url.cjs +1 -2
- package/dist/aws/function-url.d.cts +0 -2
- package/dist/aws/function-url.d.cts.map +1 -1
- package/dist/aws/function-url.d.mts +0 -2
- package/dist/aws/function-url.d.mts.map +1 -1
- package/dist/aws/function-url.mjs +1 -2
- package/dist/aws/index.cjs +3 -5
- package/dist/aws/index.cjs.map +1 -1
- package/dist/aws/index.d.cts +1 -3
- package/dist/aws/index.d.cts.map +1 -1
- package/dist/aws/index.d.mts +1 -3
- package/dist/aws/index.d.mts.map +1 -1
- package/dist/aws/index.mjs +3 -5
- package/dist/aws/index.mjs.map +1 -1
- package/dist/aws/instances.cjs +2 -3
- package/dist/aws/instances.cjs.map +1 -1
- package/dist/aws/instances.d.cts +1 -3
- package/dist/aws/instances.d.cts.map +1 -1
- package/dist/aws/instances.d.mts +1 -3
- package/dist/aws/instances.d.mts.map +1 -1
- package/dist/aws/instances.mjs +2 -3
- package/dist/aws/instances.mjs.map +1 -1
- package/dist/aws/lambda-api.cjs +1 -2
- package/dist/aws/lambda-api.d.cts +0 -2
- package/dist/aws/lambda-api.d.cts.map +1 -1
- package/dist/aws/lambda-api.d.mts +0 -2
- package/dist/aws/lambda-api.d.mts.map +1 -1
- package/dist/aws/lambda-api.mjs +1 -2
- package/dist/client.cjs +1 -2
- package/dist/client.d.cts +0 -2
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts +0 -2
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +1 -2
- package/dist/cloudflare/bindings.cjs +1 -2
- package/dist/cloudflare/bindings.cjs.map +1 -1
- package/dist/cloudflare/bindings.d.cts +0 -21
- package/dist/cloudflare/bindings.d.cts.map +1 -1
- package/dist/cloudflare/bindings.d.mts +0 -21
- package/dist/cloudflare/bindings.d.mts.map +1 -1
- package/dist/cloudflare/bindings.mjs +1 -2
- package/dist/cloudflare/bindings.mjs.map +1 -1
- package/dist/cloudflare/index.cjs +0 -5
- package/dist/cloudflare/index.d.cts +4 -6
- package/dist/cloudflare/index.d.mts +4 -6
- package/dist/cloudflare/index.mjs +2 -4
- package/dist/cloudflare/runner.cjs +4 -6
- package/dist/cloudflare/runner.cjs.map +1 -1
- package/dist/cloudflare/runner.d.cts +3 -5
- package/dist/cloudflare/runner.d.cts.map +1 -1
- package/dist/cloudflare/runner.d.mts +3 -5
- package/dist/cloudflare/runner.d.mts.map +1 -1
- package/dist/cloudflare/runner.mjs +4 -6
- package/dist/cloudflare/runner.mjs.map +1 -1
- package/dist/cloudflare/worker.cjs +1 -2
- package/dist/cloudflare/worker.d.cts +0 -2
- package/dist/cloudflare/worker.d.cts.map +1 -1
- package/dist/cloudflare/worker.d.mts +0 -2
- package/dist/cloudflare/worker.d.mts.map +1 -1
- package/dist/cloudflare/worker.mjs +1 -2
- package/dist/cloudflare/workers.d.cts +0 -2
- package/dist/cloudflare/workers.d.cts.map +1 -1
- package/dist/cloudflare/workers.d.mts +0 -2
- package/dist/cloudflare/workers.d.mts.map +1 -1
- package/dist/config.cjs +1 -2
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +1 -3
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +1 -3
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +1 -2
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +1 -2
- package/dist/contract.d.cts +0 -2
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +0 -2
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs +1 -2
- package/dist/dsl/action.cjs +1 -2
- package/dist/dsl/action.d.cts +0 -2
- package/dist/dsl/action.d.cts.map +1 -1
- package/dist/dsl/action.d.mts +0 -2
- package/dist/dsl/action.d.mts.map +1 -1
- package/dist/dsl/action.mjs +1 -2
- package/dist/dsl/base.cjs +1 -2
- package/dist/dsl/base.d.cts +0 -2
- package/dist/dsl/base.d.cts.map +1 -1
- package/dist/dsl/base.d.mts +0 -2
- package/dist/dsl/base.d.mts.map +1 -1
- package/dist/dsl/base.mjs +1 -2
- package/dist/dsl/bundle.cjs +1 -2
- package/dist/dsl/bundle.d.cts +0 -2
- package/dist/dsl/bundle.d.cts.map +1 -1
- package/dist/dsl/bundle.d.mts +0 -2
- package/dist/dsl/bundle.d.mts.map +1 -1
- package/dist/dsl/bundle.mjs +1 -2
- package/dist/dsl/condition.cjs +1 -2
- package/dist/dsl/condition.d.cts +0 -2
- package/dist/dsl/condition.d.cts.map +1 -1
- package/dist/dsl/condition.d.mts +0 -2
- package/dist/dsl/condition.d.mts.map +1 -1
- package/dist/dsl/condition.mjs +1 -2
- package/dist/dsl/flow.cjs +1 -2
- package/dist/dsl/flow.d.cts +0 -2
- package/dist/dsl/flow.d.cts.map +1 -1
- package/dist/dsl/flow.d.mts +0 -2
- package/dist/dsl/flow.d.mts.map +1 -1
- package/dist/dsl/flow.mjs +1 -2
- package/dist/dsl/refs.cjs +1 -2
- package/dist/dsl/refs.d.cts +0 -2
- package/dist/dsl/refs.d.cts.map +1 -1
- package/dist/dsl/refs.d.mts +0 -2
- package/dist/dsl/refs.d.mts.map +1 -1
- package/dist/dsl/refs.mjs +1 -2
- package/dist/dsl/template.cjs +1 -2
- package/dist/dsl/template.d.cts +0 -2
- package/dist/dsl/template.d.cts.map +1 -1
- package/dist/dsl/template.d.mts +0 -2
- package/dist/dsl/template.d.mts.map +1 -1
- package/dist/dsl/template.mjs +1 -2
- package/dist/dsl/trigger.cjs +1 -2
- package/dist/dsl/trigger.d.cts +0 -2
- package/dist/dsl/trigger.d.cts.map +1 -1
- package/dist/dsl/trigger.d.mts +0 -2
- package/dist/dsl/trigger.d.mts.map +1 -1
- package/dist/dsl/trigger.mjs +1 -2
- package/dist/dsl/workflow.cjs +1 -2
- package/dist/dsl/workflow.d.cts +0 -2
- package/dist/dsl/workflow.d.cts.map +1 -1
- package/dist/dsl/workflow.d.mts +0 -2
- package/dist/dsl/workflow.d.mts.map +1 -1
- package/dist/dsl/workflow.mjs +1 -2
- package/dist/email-context.cjs +1 -2
- package/dist/email-context.d.cts +0 -2
- package/dist/email-context.d.cts.map +1 -1
- package/dist/email-context.d.mts +0 -2
- package/dist/email-context.d.mts.map +1 -1
- package/dist/email-context.mjs +1 -2
- package/dist/email-sender.cjs +1 -2
- package/dist/email-sender.d.cts +0 -2
- package/dist/email-sender.d.cts.map +1 -1
- package/dist/email-sender.d.mts +0 -2
- package/dist/email-sender.d.mts.map +1 -1
- package/dist/email-sender.mjs +1 -2
- package/dist/email.cjs +1 -2
- package/dist/email.d.cts +0 -2
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +0 -2
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +1 -2
- package/dist/engine/actions.cjs +1 -2
- package/dist/engine/actions.d.cts +0 -2
- package/dist/engine/actions.d.cts.map +1 -1
- package/dist/engine/actions.d.mts +0 -2
- package/dist/engine/actions.d.mts.map +1 -1
- package/dist/engine/actions.mjs +1 -2
- package/dist/engine/bucket.cjs +1 -2
- package/dist/engine/bucket.d.cts +0 -2
- package/dist/engine/bucket.d.cts.map +1 -1
- package/dist/engine/bucket.d.mts +0 -2
- package/dist/engine/bucket.d.mts.map +1 -1
- package/dist/engine/bucket.mjs +1 -2
- package/dist/engine/condition.cjs +3 -4
- package/dist/engine/condition.cjs.map +1 -1
- package/dist/engine/condition.d.cts +1 -3
- package/dist/engine/condition.d.cts.map +1 -1
- package/dist/engine/condition.d.mts +1 -3
- package/dist/engine/condition.d.mts.map +1 -1
- package/dist/engine/condition.mjs +3 -4
- package/dist/engine/condition.mjs.map +1 -1
- package/dist/engine/duration.cjs +1 -2
- package/dist/engine/duration.d.cts +0 -2
- package/dist/engine/duration.d.cts.map +1 -1
- package/dist/engine/duration.d.mts +0 -2
- package/dist/engine/duration.d.mts.map +1 -1
- package/dist/engine/duration.mjs +1 -2
- package/dist/engine/interpreter.cjs +1 -2
- package/dist/engine/interpreter.d.cts +0 -2
- package/dist/engine/interpreter.d.cts.map +1 -1
- package/dist/engine/interpreter.d.mts +0 -2
- package/dist/engine/interpreter.d.mts.map +1 -1
- package/dist/engine/interpreter.mjs +1 -2
- package/dist/engine/ports.d.cts +1 -3
- package/dist/engine/ports.d.cts.map +1 -1
- package/dist/engine/ports.d.mts +1 -3
- package/dist/engine/ports.d.mts.map +1 -1
- package/dist/engine/recipient.cjs +1 -2
- package/dist/engine/recipient.d.cts +0 -2
- package/dist/engine/recipient.d.cts.map +1 -1
- package/dist/engine/recipient.d.mts +0 -2
- package/dist/engine/recipient.d.mts.map +1 -1
- package/dist/engine/recipient.mjs +1 -2
- package/dist/engine/retry.cjs +1 -2
- package/dist/engine/retry.d.cts +0 -2
- package/dist/engine/retry.d.cts.map +1 -1
- package/dist/engine/retry.d.mts +0 -2
- package/dist/engine/retry.d.mts.map +1 -1
- package/dist/engine/retry.mjs +1 -2
- package/dist/engine/time-scale.cjs +1 -2
- package/dist/engine/time-scale.d.cts +0 -2
- package/dist/engine/time-scale.d.cts.map +1 -1
- package/dist/engine/time-scale.d.mts +0 -2
- package/dist/engine/time-scale.d.mts.map +1 -1
- package/dist/engine/time-scale.mjs +1 -2
- package/dist/engine/time-window.cjs +1 -2
- package/dist/engine/time-window.d.cts +0 -2
- package/dist/engine/time-window.d.cts.map +1 -1
- package/dist/engine/time-window.d.mts +0 -2
- package/dist/engine/time-window.d.mts.map +1 -1
- package/dist/engine/time-window.mjs +1 -2
- package/dist/fcm.cjs +1 -2
- package/dist/fcm.d.cts +0 -2
- package/dist/fcm.d.cts.map +1 -1
- package/dist/fcm.d.mts +0 -2
- package/dist/fcm.d.mts.map +1 -1
- package/dist/fcm.mjs +1 -2
- package/dist/hash.cjs +1 -2
- package/dist/hash.d.cts +0 -2
- package/dist/hash.d.cts.map +1 -1
- package/dist/hash.d.mts +0 -2
- package/dist/hash.d.mts.map +1 -1
- package/dist/hash.mjs +1 -2
- package/dist/host/auth.cjs +1 -2
- package/dist/host/auth.d.cts +0 -2
- package/dist/host/auth.d.cts.map +1 -1
- package/dist/host/auth.d.mts +0 -2
- package/dist/host/auth.d.mts.map +1 -1
- package/dist/host/auth.mjs +1 -2
- package/dist/host/channels.cjs +1 -2
- package/dist/host/channels.d.cts +1 -3
- package/dist/host/channels.d.cts.map +1 -1
- package/dist/host/channels.d.mts +1 -3
- package/dist/host/channels.d.mts.map +1 -1
- package/dist/host/channels.mjs +1 -2
- package/dist/host/execute.cjs +1 -2
- package/dist/host/execute.d.cts +1 -3
- package/dist/host/execute.d.cts.map +1 -1
- package/dist/host/execute.d.mts +1 -3
- package/dist/host/execute.d.mts.map +1 -1
- package/dist/host/execute.mjs +1 -2
- package/dist/host/fresh-read.cjs +1 -2
- package/dist/host/fresh-read.d.cts +0 -2
- package/dist/host/fresh-read.d.cts.map +1 -1
- package/dist/host/fresh-read.d.mts +0 -2
- package/dist/host/fresh-read.d.mts.map +1 -1
- package/dist/host/fresh-read.mjs +1 -2
- package/dist/host/http.cjs +4 -6
- package/dist/host/http.cjs.map +1 -1
- package/dist/host/http.d.cts +2 -4
- package/dist/host/http.d.cts.map +1 -1
- package/dist/host/http.d.mts +2 -4
- package/dist/host/http.d.mts.map +1 -1
- package/dist/host/http.mjs +4 -6
- package/dist/host/http.mjs.map +1 -1
- package/dist/host/ingest.cjs +12 -24
- package/dist/host/ingest.cjs.map +1 -1
- package/dist/host/ingest.d.cts +8 -15
- package/dist/host/ingest.d.cts.map +1 -1
- package/dist/host/ingest.d.mts +8 -15
- package/dist/host/ingest.d.mts.map +1 -1
- package/dist/host/ingest.mjs +13 -24
- package/dist/host/ingest.mjs.map +1 -1
- package/dist/host/journey-host.cjs +3 -6
- package/dist/host/journey-host.cjs.map +1 -1
- package/dist/host/journey-host.d.cts +6 -8
- package/dist/host/journey-host.d.cts.map +1 -1
- package/dist/host/journey-host.d.mts +6 -8
- package/dist/host/journey-host.d.mts.map +1 -1
- package/dist/host/journey-host.mjs +3 -6
- package/dist/host/journey-host.mjs.map +1 -1
- package/dist/host/platform.cjs +1 -2
- package/dist/host/platform.cjs.map +1 -1
- package/dist/host/platform.d.cts +1 -9
- package/dist/host/platform.d.cts.map +1 -1
- package/dist/host/platform.d.mts +1 -9
- package/dist/host/platform.d.mts.map +1 -1
- package/dist/host/platform.mjs +1 -2
- package/dist/host/platform.mjs.map +1 -1
- package/dist/host/senders.cjs +1 -2
- package/dist/host/senders.d.cts +0 -2
- package/dist/host/senders.d.cts.map +1 -1
- package/dist/host/senders.d.mts +0 -2
- package/dist/host/senders.d.mts.map +1 -1
- package/dist/host/senders.mjs +1 -2
- package/dist/http2-client.cjs +1 -2
- package/dist/http2-client.d.cts +0 -2
- package/dist/http2-client.d.cts.map +1 -1
- package/dist/http2-client.d.mts +0 -2
- package/dist/http2-client.d.mts.map +1 -1
- package/dist/http2-client.mjs +1 -2
- package/dist/ir.cjs +1 -2
- package/dist/ir.d.cts +0 -2
- package/dist/ir.d.cts.map +1 -1
- package/dist/ir.d.mts +0 -2
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +1 -2
- package/dist/jwt.cjs +1 -2
- package/dist/jwt.d.cts +0 -2
- package/dist/jwt.d.cts.map +1 -1
- package/dist/jwt.d.mts +0 -2
- package/dist/jwt.d.mts.map +1 -1
- package/dist/jwt.mjs +1 -2
- package/dist/plan.cjs +1 -2
- package/dist/plan.d.cts +0 -2
- package/dist/plan.d.cts.map +1 -1
- package/dist/plan.d.mts +0 -2
- package/dist/plan.d.mts.map +1 -1
- package/dist/plan.mjs +1 -2
- package/dist/postgres-js.cjs +1 -2
- package/dist/postgres-js.d.cts +0 -2
- package/dist/postgres-js.d.cts.map +1 -1
- package/dist/postgres-js.d.mts +0 -2
- package/dist/postgres-js.d.mts.map +1 -1
- package/dist/postgres-js.mjs +1 -2
- package/dist/provenance.cjs +1 -2
- package/dist/provenance.d.cts +0 -2
- package/dist/provenance.d.cts.map +1 -1
- package/dist/provenance.d.mts +0 -2
- package/dist/provenance.d.mts.map +1 -1
- package/dist/provenance.mjs +1 -2
- package/dist/push.cjs +1 -2
- package/dist/push.d.cts +0 -2
- package/dist/push.d.cts.map +1 -1
- package/dist/push.d.mts +0 -2
- package/dist/push.d.mts.map +1 -1
- package/dist/push.mjs +1 -2
- package/dist/react-email.cjs +1 -2
- package/dist/react-email.d.cts +0 -2
- package/dist/react-email.d.cts.map +1 -1
- package/dist/react-email.d.mts +0 -2
- package/dist/react-email.d.mts.map +1 -1
- package/dist/react-email.mjs +1 -2
- package/dist/reporting/classify.cjs +1 -2
- package/dist/reporting/classify.d.cts +0 -2
- package/dist/reporting/classify.d.cts.map +1 -1
- package/dist/reporting/classify.d.mts +0 -2
- package/dist/reporting/classify.d.mts.map +1 -1
- package/dist/reporting/classify.mjs +1 -2
- package/dist/reporting/observer.cjs +1 -2
- package/dist/reporting/observer.d.cts +0 -2
- package/dist/reporting/observer.d.cts.map +1 -1
- package/dist/reporting/observer.d.mts +0 -2
- package/dist/reporting/observer.d.mts.map +1 -1
- package/dist/reporting/observer.mjs +1 -2
- package/dist/reporting/tracking.cjs +1 -2
- package/dist/reporting/tracking.d.cts +0 -2
- package/dist/reporting/tracking.d.cts.map +1 -1
- package/dist/reporting/tracking.d.mts +0 -2
- package/dist/reporting/tracking.d.mts.map +1 -1
- package/dist/reporting/tracking.mjs +1 -2
- package/dist/runtime.cjs +1 -2
- package/dist/runtime.d.cts +0 -2
- package/dist/runtime.d.cts.map +1 -1
- package/dist/runtime.d.mts +0 -2
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -2
- package/dist/store/erasure.cjs +1 -2
- package/dist/store/erasure.d.cts +0 -2
- package/dist/store/erasure.d.cts.map +1 -1
- package/dist/store/erasure.d.mts +0 -2
- package/dist/store/erasure.d.mts.map +1 -1
- package/dist/store/erasure.mjs +1 -2
- package/dist/store/facts.cjs +2 -3
- package/dist/store/facts.cjs.map +1 -1
- package/dist/store/facts.d.cts +0 -2
- package/dist/store/facts.d.cts.map +1 -1
- package/dist/store/facts.d.mts +0 -2
- package/dist/store/facts.d.mts.map +1 -1
- package/dist/store/facts.mjs +2 -3
- package/dist/store/facts.mjs.map +1 -1
- package/dist/store/index.cjs +1 -4
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +21 -28
- package/dist/store/index.d.cts.map +1 -1
- package/dist/store/index.d.mts +21 -28
- package/dist/store/index.d.mts.map +1 -1
- package/dist/store/index.mjs +2 -4
- package/dist/store/index.mjs.map +1 -1
- package/dist/store/postgres-reporting.cjs +1 -2
- package/dist/store/postgres-reporting.d.cts +0 -2
- package/dist/store/postgres-reporting.d.cts.map +1 -1
- package/dist/store/postgres-reporting.d.mts +0 -2
- package/dist/store/postgres-reporting.d.mts.map +1 -1
- package/dist/store/postgres-reporting.mjs +1 -2
- package/dist/store/postgres.cjs +3 -5
- package/dist/store/postgres.cjs.map +1 -1
- package/dist/store/postgres.d.cts +2 -5
- package/dist/store/postgres.d.cts.map +1 -1
- package/dist/store/postgres.d.mts +2 -5
- package/dist/store/postgres.d.mts.map +1 -1
- package/dist/store/postgres.mjs +3 -5
- package/dist/store/postgres.mjs.map +1 -1
- package/dist/store/sql.cjs +1 -2
- package/dist/store/sql.d.cts +0 -2
- package/dist/store/sql.d.cts.map +1 -1
- package/dist/store/sql.d.mts +0 -2
- package/dist/store/sql.d.mts.map +1 -1
- package/dist/store/sql.mjs +1 -2
- package/dist/store/tables.cjs +1 -2
- package/dist/store/tables.d.cts +0 -2
- package/dist/store/tables.d.cts.map +1 -1
- package/dist/store/tables.d.mts +0 -2
- package/dist/store/tables.d.mts.map +1 -1
- package/dist/store/tables.mjs +1 -2
- package/dist/store/user-lock.cjs +1 -2
- package/dist/store/user-lock.d.cts +0 -2
- package/dist/store/user-lock.d.cts.map +1 -1
- package/dist/store/user-lock.d.mts +0 -2
- package/dist/store/user-lock.d.mts.map +1 -1
- package/dist/store/user-lock.mjs +1 -2
- package/dist/templates.cjs +1 -2
- package/dist/templates.d.cts +0 -2
- package/dist/templates.d.cts.map +1 -1
- package/dist/templates.d.mts +0 -2
- package/dist/templates.d.mts.map +1 -1
- package/dist/templates.mjs +1 -2
- package/dist/transports/cloudflare-email.cjs +1 -2
- package/dist/transports/cloudflare-email.d.cts +1 -3
- package/dist/transports/cloudflare-email.d.cts.map +1 -1
- package/dist/transports/cloudflare-email.d.mts +1 -3
- package/dist/transports/cloudflare-email.d.mts.map +1 -1
- package/dist/transports/cloudflare-email.mjs +1 -2
- package/dist/transports/ses.cjs +1 -2
- package/dist/transports/ses.d.cts +0 -2
- package/dist/transports/ses.d.cts.map +1 -1
- package/dist/transports/ses.d.mts +0 -2
- package/dist/transports/ses.d.mts.map +1 -1
- package/dist/transports/ses.mjs +1 -2
- package/dist/transports/sigv4.cjs +1 -2
- package/dist/transports/sigv4.d.cts +0 -2
- package/dist/transports/sigv4.d.cts.map +1 -1
- package/dist/transports/sigv4.d.mts +0 -2
- package/dist/transports/sigv4.d.mts.map +1 -1
- package/dist/transports/sigv4.mjs +1 -2
- package/dist/webhooks.cjs +1 -2
- package/dist/webhooks.d.cts +0 -2
- package/dist/webhooks.d.cts.map +1 -1
- package/dist/webhooks.d.mts +0 -2
- package/dist/webhooks.d.mts.map +1 -1
- package/dist/webhooks.mjs +1 -2
- package/dist/webpush.cjs +1 -2
- package/dist/webpush.d.cts +0 -2
- package/dist/webpush.d.cts.map +1 -1
- package/dist/webpush.d.mts +0 -2
- package/dist/webpush.d.mts.map +1 -1
- package/dist/webpush.mjs +1 -2
- package/package.json +5 -7
- package/dist/cloudflare/d1-env.cjs +0 -17
- package/dist/cloudflare/d1-env.cjs.map +0 -1
- package/dist/cloudflare/d1-env.d.cts +0 -12
- package/dist/cloudflare/d1-env.d.cts.map +0 -1
- package/dist/cloudflare/d1-env.d.mts +0 -12
- package/dist/cloudflare/d1-env.d.mts.map +0 -1
- package/dist/cloudflare/d1-env.mjs +0 -16
- package/dist/cloudflare/d1-env.mjs.map +0 -1
- package/dist/cloudflare/schema.sql +0 -148
- package/dist/store/d1.cjs +0 -245
- package/dist/store/d1.cjs.map +0 -1
- package/dist/store/d1.d.cts +0 -73
- package/dist/store/d1.d.cts.map +0 -1
- package/dist/store/d1.d.mts +0 -73
- package/dist/store/d1.d.mts.map +0 -1
- package/dist/store/d1.mjs +0 -244
- package/dist/store/d1.mjs.map +0 -1
- package/src/cloudflare/schema.sql +0 -148
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ versioned IR, and executed by a single generic runner: the IR is data, so one
|
|
|
5
5
|
deployed Worker runs every journey. Events and profile fields are typed by a
|
|
6
6
|
shared Zod contract, messages are typed templates (React email, push, Slack,
|
|
7
7
|
Discord), and the host is a Cloudflare Worker on Cloudflare Workflows, with its
|
|
8
|
-
data in
|
|
8
|
+
data in your own Postgres.
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
11
|
const welcome = workflow({ id: 'welcome', trigger: trigger.event(e.sign_up) })
|
|
@@ -189,8 +189,7 @@ export const AcmeJourneyRunner = journeys.Runner;
|
|
|
189
189
|
export default { fetch: journeys.fetch, scheduled: journeys.scheduled };
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
[Cloudflare setup](#cloudflare-setup)). On Postgres, create the engine's tables
|
|
192
|
+
`store` names the engine's Postgres (here through Hyperdrive); create its tables
|
|
194
193
|
first (see [Postgres](#postgres)).
|
|
195
194
|
|
|
196
195
|
```jsonc
|
|
@@ -742,19 +741,15 @@ backward-compatible changes, so a new required prop means a new id.
|
|
|
742
741
|
|
|
743
742
|
## Cloudflare setup
|
|
744
743
|
|
|
745
|
-
The
|
|
744
|
+
The Worker needs two bindings, named as in `JourneyEnv` and the quick start's `wrangler.jsonc`:
|
|
746
745
|
|
|
747
|
-
| Binding
|
|
748
|
-
|
|
|
749
|
-
| `
|
|
750
|
-
| `
|
|
751
|
-
|
|
752
|
-
The compiled IR lives in D1 with the routes, never in a KV namespace: KV is eventually consistent
|
|
753
|
-
while the routes in D1 are not, so an instance started in another colo right after a deploy could
|
|
754
|
-
miss its IR.
|
|
746
|
+
| Binding | Type | Holds |
|
|
747
|
+
| ------------ | ---------- | ----------------------------------------------------------- |
|
|
748
|
+
| `JOURNEY` | Workflow | The `JourneyRunner` entrypoint |
|
|
749
|
+
| `HYPERDRIVE` | Hyperdrive | The connection to the engine's Postgres (`postgresJsStore`) |
|
|
755
750
|
|
|
756
751
|
The Worker needs the `nodejs_compat` compatibility flag (the bearer check uses
|
|
757
|
-
`node:crypto`'s `timingSafeEqual`).
|
|
752
|
+
`node:crypto`'s `timingSafeEqual`). Add the `EMAIL` send_email binding
|
|
758
753
|
when it sends through Cloudflare Email (`cloudflareEmailTransport({ binding: env.EMAIL })`), and a `triggers.crons` entry with `scheduled`
|
|
759
754
|
exported to run the segment sweep.
|
|
760
755
|
|
|
@@ -780,24 +775,9 @@ window to come back for and no second pass; the tombstone stays, so a late
|
|
|
780
775
|
write cannot bring the user back.
|
|
781
776
|
|
|
782
777
|
One database per host. The routing tables are global (`triggers`, `segments`, the live
|
|
783
|
-
`deployment` row), so two Workers on one
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
The D1 schema ships with the package. Apply it before the first deploy:
|
|
788
|
-
|
|
789
|
-
```bash
|
|
790
|
-
wrangler d1 execute <database> --file node_modules/@shware/workflow/dist/cloudflare/schema.sql
|
|
791
|
-
```
|
|
792
|
-
|
|
793
|
-
Nothing in the adapter creates these tables at runtime, so this step is not
|
|
794
|
-
optional. The same file lives at `src/cloudflare/schema.sql` in this repo and is
|
|
795
|
-
the single source for both.
|
|
796
|
-
|
|
797
|
-
There are no migrations, and re-applying the file is not one: every statement is
|
|
798
|
-
`CREATE TABLE IF NOT EXISTS`, so an existing database keeps its old tables and
|
|
799
|
-
the first insert needing a new column fails. Recreate it instead. The demo has
|
|
800
|
-
`pnpm db:reset`. The `events` key is `(user_id, id)`, and `workflow_ir` holds the compiled IR.
|
|
778
|
+
`deployment` row), so two Workers on one Postgres schema would swap each other's routes on
|
|
779
|
+
every deploy: give staging and production their own schema (`database: { schema }`) or
|
|
780
|
+
database.
|
|
801
781
|
|
|
802
782
|
### Cloudflare deployment notes
|
|
803
783
|
|
|
@@ -817,8 +797,8 @@ the first insert needing a new column fails. Recreate it instead. The demo has
|
|
|
817
797
|
- A completed instance's state is kept 30 days.
|
|
818
798
|
- **Authorization.** Set `API_TOKEN` with `wrangler secret put`, or pass `authorize` (below).
|
|
819
799
|
The tracking routes (`/t/...`) stay public by design.
|
|
820
|
-
- **Deploying.** With the `CF_VERSION_METADATA` binding
|
|
821
|
-
|
|
800
|
+
- **Deploying.** With the `CF_VERSION_METADATA` binding, each `wrangler deploy` makes its own
|
|
801
|
+
bundle live (see [Postgres](#postgres)); `POST /bundle/deploy` forces it.
|
|
822
802
|
- **APNs in development.** `wrangler dev` (workerd) cannot make HTTP/2 subrequests: run
|
|
823
803
|
`@shware/workflow/apns-relay` and point `APNS_RELAY_ORIGIN` at it. A deployed Worker needs no
|
|
824
804
|
relay.
|
|
@@ -1068,8 +1048,7 @@ that version serves its first request, whatever share of traffic it has.
|
|
|
1068
1048
|
|
|
1069
1049
|
`wrangler rollback` restores an older version, which does not apply itself over
|
|
1070
1050
|
the newer one. Call `POST /bundle/deploy` after a rollback: it applies the
|
|
1071
|
-
running version's bundle whatever is live.
|
|
1072
|
-
on D1 every deploy is that call.
|
|
1051
|
+
running version's bundle whatever is live.
|
|
1073
1052
|
|
|
1074
1053
|
On Postgres the engine also keeps:
|
|
1075
1054
|
|
|
@@ -1154,8 +1133,8 @@ is a design question this package does not yet answer.
|
|
|
1154
1133
|
| ------------------------------ | -------------------------------------------------------------------------------------------------- |
|
|
1155
1134
|
| `@shware/workflow` | The DSL, `defineContract`, `defineConfig`, `compileConfig`, `compileBundle`, `plan`, templates, IR |
|
|
1156
1135
|
| `@shware/workflow/engine` | The interpreter (`runJourney`) and its ports, condition evaluation, bucketing |
|
|
1157
|
-
| `@shware/workflow/cloudflare` | `journeyWorker`, `JourneyRunner`, `handleRequest`, the
|
|
1158
|
-
| `@shware/workflow/store` | The `JourneyStore` port,
|
|
1136
|
+
| `@shware/workflow/cloudflare` | `journeyWorker`, `JourneyRunner`, `handleRequest`, the ingest functions, senders, the store |
|
|
1137
|
+
| `@shware/workflow/store` | The `JourneyStore` port, the Postgres store, `renderPostgresDdl`, `renderDrizzleSchema` |
|
|
1159
1138
|
| `@shware/workflow/client` | `JourneyClient`, the producer side of the HTTP API |
|
|
1160
1139
|
| `@shware/workflow/postgres-js` | `postgresJsStore`, the Postgres store over postgres.js (peer `postgres`) |
|
|
1161
1140
|
| `@shware/workflow/react-email` | `registryRenderer`, the email renderer over the registry (peers `react`, `react-dom`) |
|
|
@@ -1165,7 +1144,6 @@ is a design question this package does not yet answer.
|
|
|
1165
1144
|
| `@shware/workflow/fcm` | `FcmPushSender` over an `FcmAccessToken`, FCM HTTP v1 for Android |
|
|
1166
1145
|
| `@shware/workflow/webpush` | `WebPushSender` over a `VapidSigner`, `generateVapidKeys`; standard Web Push with VAPID |
|
|
1167
1146
|
| `@shware/workflow/webhooks` | `SlackWebhookSender` and `DiscordWebhookSender` |
|
|
1168
|
-
| `@shware/workflow/schema.sql` | The D1 schema file |
|
|
1169
1147
|
|
|
1170
1148
|
## Testing
|
|
1171
1149
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,5 +19,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
22
|
exports.__toESM = __toESM;
|
package/dist/apns-relay.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_http2_client = require("./http2-client.cjs");
|
|
3
3
|
let node_http = require("node:http");
|
|
4
|
-
|
|
4
|
+
// src/apns-relay.ts
|
|
5
5
|
const DEFAULT_ALLOW = ["https://api.push.apple.com", "https://api.sandbox.push.apple.com"];
|
|
6
6
|
/** Request headers APNs reads; everything else (host, content-length, …) is the relay's own business. */
|
|
7
7
|
const FORWARDED = [
|
|
@@ -86,7 +86,6 @@ function startApnsRelay(options) {
|
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
//#endregion
|
|
90
89
|
exports.startApnsRelay = startApnsRelay;
|
|
91
90
|
|
|
92
91
|
//# sourceMappingURL=apns-relay.cjs.map
|
package/dist/apns-relay.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/apns-relay.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* `@shware/workflow/apns-relay` — a development-only HTTP/1.1 → HTTP/2 relay
|
|
4
3
|
* for APNs, run under Node next to `wrangler dev`.
|
|
@@ -24,5 +23,4 @@ export interface ApnsRelay {
|
|
|
24
23
|
close(): Promise<void>;
|
|
25
24
|
}
|
|
26
25
|
export declare function startApnsRelay(options: ApnsRelayOptions): Promise<ApnsRelay>;
|
|
27
|
-
//#endregion
|
|
28
26
|
//# sourceMappingURL=apns-relay.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apns-relay.d.cts","names":[],"sources":["../src/apns-relay.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apns-relay.d.cts","names":[],"sources":["../src/apns-relay.ts"],"mappings":";;;;;;;;;;;;;iBAiBiB;EACf;;EAEA;;EAEA;;iBAGe;EACf;EACA,SAAS;;wBAiBK,eAAe,SAAS,mBAAmB,QAAQ"}
|
package/dist/apns-relay.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/apns-relay.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* `@shware/workflow/apns-relay` — a development-only HTTP/1.1 → HTTP/2 relay
|
|
4
3
|
* for APNs, run under Node next to `wrangler dev`.
|
|
@@ -24,5 +23,4 @@ export interface ApnsRelay {
|
|
|
24
23
|
close(): Promise<void>;
|
|
25
24
|
}
|
|
26
25
|
export declare function startApnsRelay(options: ApnsRelayOptions): Promise<ApnsRelay>;
|
|
27
|
-
//#endregion
|
|
28
26
|
//# sourceMappingURL=apns-relay.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apns-relay.d.mts","names":[],"sources":["../src/apns-relay.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apns-relay.d.mts","names":[],"sources":["../src/apns-relay.ts"],"mappings":";;;;;;;;;;;;;iBAiBiB;EACf;;EAEA;;EAEA;;iBAGe;EACf;EACA,SAAS;;wBAiBK,eAAe,SAAS,mBAAmB,QAAQ"}
|
package/dist/apns-relay.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { http2Sessions } from "./http2-client.mjs";
|
|
2
2
|
import { createServer } from "node:http";
|
|
3
|
-
|
|
3
|
+
// src/apns-relay.ts
|
|
4
4
|
const DEFAULT_ALLOW = ["https://api.push.apple.com", "https://api.sandbox.push.apple.com"];
|
|
5
5
|
/** Request headers APNs reads; everything else (host, content-length, …) is the relay's own business. */
|
|
6
6
|
const FORWARDED = [
|
|
@@ -85,7 +85,6 @@ function startApnsRelay(options) {
|
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
//#endregion
|
|
89
88
|
export { startApnsRelay };
|
|
90
89
|
|
|
91
90
|
//# sourceMappingURL=apns-relay.mjs.map
|
package/dist/apns.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_engine_retry = require("./engine/retry.cjs");
|
|
3
3
|
const require_jwt = require("./jwt.cjs");
|
|
4
4
|
let node_buffer = require("node:buffer");
|
|
5
|
-
|
|
5
|
+
// src/apns.ts
|
|
6
6
|
const APNS_HOSTS = {
|
|
7
7
|
sandbox: "https://api.sandbox.push.apple.com",
|
|
8
8
|
production: "https://api.push.apple.com"
|
|
@@ -196,7 +196,6 @@ function apnsKeyFromBase64(value) {
|
|
|
196
196
|
if (!pem.includes("-----BEGIN PRIVATE KEY-----")) throw new require_engine_retry.PermanentError("APNs key is not a PKCS #8 PEM (.p8) file");
|
|
197
197
|
return pem;
|
|
198
198
|
}
|
|
199
|
-
//#endregion
|
|
200
199
|
exports.APNS_HOSTS = APNS_HOSTS;
|
|
201
200
|
exports.ApnsProviderToken = ApnsProviderToken;
|
|
202
201
|
exports.ApnsPushSender = ApnsPushSender;
|
package/dist/apns.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MessageSender, OutboundMessage, SendResult } from "./engine/ports.cjs";
|
|
2
2
|
import "./engine/index.cjs";
|
|
3
3
|
import { PushRenderer } from "./push.cjs";
|
|
4
|
-
//#region src/apns.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* `@shware/workflow/apns` — iOS push delivery straight to the Apple Push
|
|
7
6
|
* Notification service, token-based (an APNs auth key, the `.p8` file from the
|
|
@@ -105,5 +104,4 @@ export declare function apnsReason(body: string): string;
|
|
|
105
104
|
export declare function signApnsJwt(key: ApnsProviderTokenOptions, nowMs?: number): Promise<string>;
|
|
106
105
|
/** The `.p8` as it is usually shipped in a secret: base64 of the file. */
|
|
107
106
|
export declare function apnsKeyFromBase64(value: string): string;
|
|
108
|
-
//#endregion
|
|
109
107
|
//# sourceMappingURL=apns.d.cts.map
|
package/dist/apns.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apns.d.cts","names":[],"sources":["../src/apns.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apns.d.cts","names":[],"sources":["../src/apns.ts"],"mappings":";;;;;;;;;;;;;;;;iBAoBiB;;EAEf;;EAEA;;EAEA;;iBAGe;;EAEf,aAAa;;EAEb;;;;;;;EAOA;EACA,QAAQ;;;;;;EAMR;;EAEA,eAAe;;qBAGJ;WACX;WACA;;;;;;;;;;;;;;;;;;;;;qBAsBW,oBAAoB;;;;;;;;wBAsBX,cAAc,yBAAyB;;;;;;;;qBAqBhD;mBAIkB;UAHrB;UACA;EAER,YAA6B,SAAS;;EAGhC,MAAM,eAAmB;;EAgB/B;;qBAKW,0BAA0B;mBACR;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB,eAAe;;;wBAkFvC,WAAW;;wBAUL,YACpB,KAAK,0BACL,iBACC;;wBAoBa,kBAAkB"}
|
package/dist/apns.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MessageSender, OutboundMessage, SendResult } from "./engine/ports.mjs";
|
|
2
2
|
import "./engine/index.mjs";
|
|
3
3
|
import { PushRenderer } from "./push.mjs";
|
|
4
|
-
//#region src/apns.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* `@shware/workflow/apns` — iOS push delivery straight to the Apple Push
|
|
7
6
|
* Notification service, token-based (an APNs auth key, the `.p8` file from the
|
|
@@ -105,5 +104,4 @@ export declare function apnsReason(body: string): string;
|
|
|
105
104
|
export declare function signApnsJwt(key: ApnsProviderTokenOptions, nowMs?: number): Promise<string>;
|
|
106
105
|
/** The `.p8` as it is usually shipped in a secret: base64 of the file. */
|
|
107
106
|
export declare function apnsKeyFromBase64(value: string): string;
|
|
108
|
-
//#endregion
|
|
109
107
|
//# sourceMappingURL=apns.d.mts.map
|
package/dist/apns.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apns.d.mts","names":[],"sources":["../src/apns.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apns.d.mts","names":[],"sources":["../src/apns.ts"],"mappings":";;;;;;;;;;;;;;;;iBAoBiB;;EAEf;;EAEA;;EAEA;;iBAGe;;EAEf,aAAa;;EAEb;;;;;;;EAOA;EACA,QAAQ;;;;;;EAMR;;EAEA,eAAe;;qBAGJ;WACX;WACA;;;;;;;;;;;;;;;;;;;;;qBAsBW,oBAAoB;;;;;;;;wBAsBX,cAAc,yBAAyB;;;;;;;;qBAqBhD;mBAIkB;UAHrB;UACA;EAER,YAA6B,SAAS;;EAGhC,MAAM,eAAmB;;EAgB/B;;qBAKW,0BAA0B;mBACR;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB,eAAe;;;wBAkFvC,WAAW;;wBAUL,YACpB,KAAK,0BACL,iBACC;;wBAoBa,kBAAkB"}
|
package/dist/apns.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PermanentError, isRetryableStatus } from "./engine/retry.mjs";
|
|
2
2
|
import { base64url, pemToDer } from "./jwt.mjs";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
|
-
|
|
4
|
+
// src/apns.ts
|
|
5
5
|
const APNS_HOSTS = {
|
|
6
6
|
sandbox: "https://api.sandbox.push.apple.com",
|
|
7
7
|
production: "https://api.push.apple.com"
|
|
@@ -195,7 +195,6 @@ function apnsKeyFromBase64(value) {
|
|
|
195
195
|
if (!pem.includes("-----BEGIN PRIVATE KEY-----")) throw new PermanentError("APNs key is not a PKCS #8 PEM (.p8) file");
|
|
196
196
|
return pem;
|
|
197
197
|
}
|
|
198
|
-
//#endregion
|
|
199
198
|
export { APNS_HOSTS, ApnsProviderToken, ApnsPushSender, DEAD_TOKEN_REASONS, apnsIdFromKey, apnsKeyFromBase64, apnsReason, signApnsJwt };
|
|
200
199
|
|
|
201
200
|
//# sourceMappingURL=apns.mjs.map
|
package/dist/aws/engine-step.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_engine_retry = require("../engine/retry.cjs");
|
|
3
3
|
let _aws_durable_execution_sdk_js = require("@aws/durable-execution-sdk-js");
|
|
4
|
-
|
|
4
|
+
// src/aws/engine-step.ts
|
|
5
5
|
/**
|
|
6
6
|
* EngineStep over a Lambda durable execution.
|
|
7
7
|
*
|
|
@@ -96,7 +96,6 @@ var AwsEngineStep = class {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
//#endregion
|
|
100
99
|
exports.AwsEngineStep = AwsEngineStep;
|
|
101
100
|
exports.stepRetry = stepRetry;
|
|
102
101
|
|
|
@@ -2,7 +2,6 @@ import { EngineStep } from "../engine/ports.cjs";
|
|
|
2
2
|
import { ExecutionRegistry, JourneyStore } from "../store/index.cjs";
|
|
3
3
|
import { LambdaApi } from "./lambda-api.cjs";
|
|
4
4
|
import { DurableContext, RetryDecision } from "@aws/durable-execution-sdk-js";
|
|
5
|
-
//#region src/aws/engine-step.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* EngineStep over a Lambda durable execution.
|
|
8
7
|
*
|
|
@@ -40,5 +39,4 @@ export declare class AwsEngineStep implements EngineStep {
|
|
|
40
39
|
deadlineMs: number;
|
|
41
40
|
}): Promise<'event' | 'timeout'>;
|
|
42
41
|
}
|
|
43
|
-
//#endregion
|
|
44
42
|
//# sourceMappingURL=engine-step.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-step.d.cts","names":[],"sources":["../../src/aws/engine-step.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine-step.d.cts","names":[],"sources":["../../src/aws/engine-step.ts"],"mappings":";;;;;;;;;;;;;;;wBAuBgB,UAAU,OAAO,OAAO,kBAAkB;qBAa7C,yBAAyB;mBAKjB;mBACA;mBACA;mBACA;mBACA;mBACA;UATX;UACA;EAER,YACmB,SAAS,gBACT,OAAO,cACP,YAAY,mBACZ,QAAQ,WACR,gBACA;EAGnB,GAAG,GAAG,cAAc,UAAU,QAAQ,KAAK,QAAQ;EAI7C,MAAM,cAAc,aAAa;EAMjC,UACJ,cACA,2BACA;IAAW;MACV;EAoCG,YAAY,eAAe;;;;;EAsB3B,YACJ,cACA;IAAS;IAAmB;MAC3B"}
|
|
@@ -2,7 +2,6 @@ import { EngineStep } from "../engine/ports.mjs";
|
|
|
2
2
|
import { ExecutionRegistry, JourneyStore } from "../store/index.mjs";
|
|
3
3
|
import { LambdaApi } from "./lambda-api.mjs";
|
|
4
4
|
import { DurableContext, RetryDecision } from "@aws/durable-execution-sdk-js";
|
|
5
|
-
//#region src/aws/engine-step.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* EngineStep over a Lambda durable execution.
|
|
8
7
|
*
|
|
@@ -40,5 +39,4 @@ export declare class AwsEngineStep implements EngineStep {
|
|
|
40
39
|
deadlineMs: number;
|
|
41
40
|
}): Promise<'event' | 'timeout'>;
|
|
42
41
|
}
|
|
43
|
-
//#endregion
|
|
44
42
|
//# sourceMappingURL=engine-step.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-step.d.mts","names":[],"sources":["../../src/aws/engine-step.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine-step.d.mts","names":[],"sources":["../../src/aws/engine-step.ts"],"mappings":";;;;;;;;;;;;;;;wBAuBgB,UAAU,OAAO,OAAO,kBAAkB;qBAa7C,yBAAyB;mBAKjB;mBACA;mBACA;mBACA;mBACA;mBACA;UATX;UACA;EAER,YACmB,SAAS,gBACT,OAAO,cACP,YAAY,mBACZ,QAAQ,WACR,gBACA;EAGnB,GAAG,GAAG,cAAc,UAAU,QAAQ,KAAK,QAAQ;EAI7C,MAAM,cAAc,aAAa;EAMjC,UACJ,cACA,2BACA;IAAW;MACV;EAoCG,YAAY,eAAe;;;;;EAsB3B,YACJ,cACA;IAAS;IAAmB;MAC3B"}
|
package/dist/aws/engine-step.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isRetryable } from "../engine/retry.mjs";
|
|
2
2
|
import { CallbackTimeoutError } from "@aws/durable-execution-sdk-js";
|
|
3
|
-
|
|
3
|
+
// src/aws/engine-step.ts
|
|
4
4
|
/**
|
|
5
5
|
* EngineStep over a Lambda durable execution.
|
|
6
6
|
*
|
|
@@ -95,7 +95,6 @@ var AwsEngineStep = class {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
//#endregion
|
|
99
98
|
export { AwsEngineStep, stepRetry };
|
|
100
99
|
|
|
101
100
|
//# sourceMappingURL=engine-step.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let node_buffer = require("node:buffer");
|
|
3
|
-
|
|
3
|
+
// src/aws/function-url.ts
|
|
4
4
|
/**
|
|
5
5
|
* An HTTP request, told apart by the event's own top-level shape — the Function URL wraps
|
|
6
6
|
* every request in `requestContext.http`, so no request body can pass for anything else.
|
|
@@ -46,7 +46,6 @@ async function fromResponse(response, method) {
|
|
|
46
46
|
isBase64Encoded: !textual
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
//#endregion
|
|
50
49
|
exports.fromResponse = fromResponse;
|
|
51
50
|
exports.isFunctionUrlEvent = isFunctionUrlEvent;
|
|
52
51
|
exports.toRequest = toRequest;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/aws/function-url.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Lambda Function URL events (payload format 2.0) as fetch `Request`s, and `Response`s back as
|
|
4
3
|
* the result Lambda turns into the HTTP response — so the host's HTTP API runs unchanged.
|
|
@@ -34,5 +33,4 @@ export interface FunctionUrlResult {
|
|
|
34
33
|
export declare function isFunctionUrlEvent(event: unknown): event is FunctionUrlEvent;
|
|
35
34
|
export declare function toRequest(event: FunctionUrlEvent): Request;
|
|
36
35
|
export declare function fromResponse(response: Response, method: string): Promise<FunctionUrlResult>;
|
|
37
|
-
//#endregion
|
|
38
36
|
//# sourceMappingURL=function-url.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-url.d.cts","names":[],"sources":["../../src/aws/function-url.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"function-url.d.cts","names":[],"sources":["../../src/aws/function-url.ts"],"mappings":";;;;iBAMiB;EACf;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;IACE;IACA;MAAQ;MAAgB;MAAmB;;;;iBAI9B;EACf;EACA,SAAS;EACT;EACA;EACA;;;;;;wBAOc,mBAAmB,iBAAiB,SAAS;wBAoB7C,UAAU,OAAO,mBAAmB;wBA4B9B,aAAa,UAAU,UAAU,iBAAiB,QAAQ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/aws/function-url.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Lambda Function URL events (payload format 2.0) as fetch `Request`s, and `Response`s back as
|
|
4
3
|
* the result Lambda turns into the HTTP response — so the host's HTTP API runs unchanged.
|
|
@@ -34,5 +33,4 @@ export interface FunctionUrlResult {
|
|
|
34
33
|
export declare function isFunctionUrlEvent(event: unknown): event is FunctionUrlEvent;
|
|
35
34
|
export declare function toRequest(event: FunctionUrlEvent): Request;
|
|
36
35
|
export declare function fromResponse(response: Response, method: string): Promise<FunctionUrlResult>;
|
|
37
|
-
//#endregion
|
|
38
36
|
//# sourceMappingURL=function-url.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-url.d.mts","names":[],"sources":["../../src/aws/function-url.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"function-url.d.mts","names":[],"sources":["../../src/aws/function-url.ts"],"mappings":";;;;iBAMiB;EACf;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;IACE;IACA;MAAQ;MAAgB;MAAmB;;;;iBAI9B;EACf;EACA,SAAS;EACT;EACA;EACA;;;;;;wBAOc,mBAAmB,iBAAiB,SAAS;wBAoB7C,UAAU,OAAO,mBAAmB;wBA4B9B,aAAa,UAAU,UAAU,iBAAiB,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
|
-
|
|
2
|
+
// src/aws/function-url.ts
|
|
3
3
|
/**
|
|
4
4
|
* An HTTP request, told apart by the event's own top-level shape — the Function URL wraps
|
|
5
5
|
* every request in `requestContext.http`, so no request body can pass for anything else.
|
|
@@ -45,7 +45,6 @@ async function fromResponse(response, method) {
|
|
|
45
45
|
isBase64Encoded: !textual
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { fromResponse, isFunctionUrlEvent, toRequest };
|
|
50
49
|
|
|
51
50
|
//# sourceMappingURL=function-url.mjs.map
|
package/dist/aws/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ const require_aws_instances = require("./instances.cjs");
|
|
|
13
13
|
const require_aws_lambda_api = require("./lambda-api.cjs");
|
|
14
14
|
let _aws_durable_execution_sdk_js = require("@aws/durable-execution-sdk-js");
|
|
15
15
|
let node_async_hooks = require("node:async_hooks");
|
|
16
|
-
|
|
16
|
+
// src/aws/index.ts
|
|
17
17
|
/**
|
|
18
18
|
* `@shware/workflow/aws` — the journey host as one Lambda durable function behind a Function
|
|
19
19
|
* URL, on Postgres.
|
|
@@ -75,8 +75,7 @@ function journeyLambda(options) {
|
|
|
75
75
|
const placeholder = { ...baseEnv };
|
|
76
76
|
invocation.lease ??= host.lease(placeholder);
|
|
77
77
|
const { store } = invocation.lease;
|
|
78
|
-
const executions = store
|
|
79
|
-
if (executions === void 0) throw new Error("journeyLambda needs a store with an execution registry (PostgresJourneyStore)");
|
|
78
|
+
const { executions } = store;
|
|
80
79
|
const functionArn = unqualified(context.lambdaContext.invokedFunctionArn);
|
|
81
80
|
const target = async (contentHash, version) => {
|
|
82
81
|
if (version !== void 0 && /^\d+$/.test(version)) return `${functionArn}:${version}`;
|
|
@@ -167,7 +166,7 @@ function journeyLambda(options) {
|
|
|
167
166
|
}
|
|
168
167
|
const sizes = await context.step("sweep:snapshot", async () => {
|
|
169
168
|
const { store } = open(context);
|
|
170
|
-
return
|
|
169
|
+
return store.reporting.snapshotSegments(Date.now());
|
|
171
170
|
}, once);
|
|
172
171
|
return {
|
|
173
172
|
users,
|
|
@@ -193,7 +192,6 @@ function journeyLambda(options) {
|
|
|
193
192
|
};
|
|
194
193
|
return { handler };
|
|
195
194
|
}
|
|
196
|
-
//#endregion
|
|
197
195
|
exports.AwsEngineStep = require_aws_engine_step.AwsEngineStep;
|
|
198
196
|
exports.AwsInstances = require_aws_instances.AwsInstances;
|
|
199
197
|
exports.RUN_EVENT_TYPE = require_aws_instances.RUN_EVENT_TYPE;
|
package/dist/aws/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createJourneyHost","http2Fetch","longestJourneyMs","sdkLambdaApi","AsyncLocalStorage","AwsInstances","readWithRetry","PermanentError","executeJourney","AwsEngineStep","toRequest","fromResponse","sweepMaintenance","sweepSegmentsPaged","withDurableExecution","isFunctionUrlEvent","isRunInput"],"sources":["../../src/aws/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport {\n type DurableContext,\n type DurableExecutionInvocationInput,\n type DurableExecutionInvocationOutput,\n withDurableExecution,\n} from '@aws/durable-execution-sdk-js';\nimport { longestJourneyMs } from '../engine/duration';\nimport type { JourneyOutcome } from '../engine/ports';\nimport { PermanentError } from '../engine/retry';\nimport { executeJourney } from '../host/execute';\nimport { readWithRetry } from '../host/fresh-read';\nimport {\n SWEEP_PAGE_SIZE,\n type SweepResult,\n sweepMaintenance,\n sweepSegmentsPaged,\n} from '../host/ingest';\nimport { type JourneyHostOptions, createJourneyHost } from '../host/journey-host';\nimport type { JourneyEnv } from '../host/platform';\nimport { http2Fetch } from '../http2-client';\nimport type { BundleVersion, ExecutionRegistry, JourneyStore, StoreLease } from '../store/index';\nimport { AwsEngineStep } from './engine-step';\nimport {\n type FunctionUrlEvent,\n type FunctionUrlResult,\n fromResponse,\n isFunctionUrlEvent,\n toRequest,\n} from './function-url';\nimport { AwsInstances, type RunInput, isRunInput } from './instances';\nimport { type LambdaApi, sdkLambdaApi } from './lambda-api';\n\n/**\n * `@shware/workflow/aws` — the journey host as one Lambda durable function behind a Function\n * URL, on Postgres.\n *\n * The one handler tells three inputs apart by the event's top-level shape: a Function URL\n * request (the HTTP API — ingest, identify, devices, tracking, bundle, preview), an internal run\n * (one journey instance: one durable execution, started by an asynchronous invoke of this\n * function's own numbered version), and a scheduled maintenance tick. An HTTP body can never\n * pass for the other two: the Function URL always wraps it.\n *\n * const journeys = journeyLambda({\n * config,\n * env, // parsed from process.env (zod)\n * store: (env, database) => postgresJsStore(env.DATABASE_URL, database),\n * email: (env) => sesEmailTransport({ region: env.AWS_REGION }),\n * });\n * export const handler = journeys.handler;\n */\n\n/** The scheduled tick (EventBridge Scheduler's payload): the segment sweep and maintenance. */\nexport const SWEEP_EVENT_TYPE = '$workflow.sweep';\n\n/** What journeyLambda reads from its env: `JourneyEnv` without the binding it supplies itself. */\nexport type JourneyLambdaEnv = Omit<JourneyEnv, 'JOURNEY' | 'DB' | 'EMAIL'>;\n\nexport interface JourneyLambdaOptions<Env extends JourneyLambdaEnv> extends Omit<\n JourneyHostOptions<Env & JourneyEnv>,\n 'env' | 'store'\n> {\n /** The validated environment (parsed from `process.env` with zod by the app). */\n env: Env;\n /** The Postgres store: AWS needs its execution registry (`postgresJsStore`). */\n store: (env: Env, database: { schema: string }) => JourneyStore | StoreLease;\n /** The Lambda control plane; `@aws-sdk/client-lambda` with the execution role by default. */\n lambda?: LambdaApi;\n /** How long an unconfirmed start is retried (default 12 hours; keep it under the retention). */\n startRetryMs?: number;\n /**\n * How long an erasure waits after stopping an execution before it erases: an invocation\n * running at the stop goes on to its next checkpoint. Set it to at least the function's\n * timeout; 15 minutes (Lambda's maximum) by default.\n */\n stopDrainMs?: number;\n /**\n * The function's `DurableConfig.ExecutionTimeout`, in milliseconds. With it, a workflow that\n * can outlive it (`longestJourneyMs`) fails the handler's creation — a deploy's smoke test —\n * instead of being stopped by the platform midway and recorded as failed.\n */\n executionTimeoutMs?: number;\n}\n\n/**\n * The Lambda invocation context, as far as the handler's signature needs it — declared here so\n * the package's types do not depend on `@types/aws-lambda`. Lambda passes the full object.\n */\nexport interface LambdaContext {\n functionName: string;\n functionVersion: string;\n invokedFunctionArn: string;\n awsRequestId: string;\n getRemainingTimeInMillis(): number;\n}\n\nexport interface JourneyLambda {\n /** Export as the function's handler. */\n handler: (\n event: DurableExecutionInvocationInput,\n context: LambdaContext\n ) => Promise<DurableExecutionInvocationOutput>;\n}\n\ninterface Invocation {\n lease?: Required<StoreLease>;\n}\n\n/** This function's ARN without its qualifier, from the ARN it was invoked under. */\nfunction unqualified(invokedFunctionArn: string): string {\n return invokedFunctionArn.split(':').slice(0, 7).join(':');\n}\n\nconst json = (body: unknown, status = 200) =>\n new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });\n\nexport function journeyLambda<Env extends JourneyLambdaEnv>(\n options: JourneyLambdaOptions<Env>\n): JourneyLambda {\n type HostEnv = Env & JourneyEnv;\n const {\n env: baseEnv,\n lambda: lambdaOption,\n startRetryMs,\n stopDrainMs,\n executionTimeoutMs,\n ...hostOptions\n } = options;\n const host = createJourneyHost<HostEnv>(\n { ...hostOptions, store: (env, database) => options.store(env, database) },\n // Node 24's fetch cannot reach APNs (HTTP/2 only): see http2-client.ts for when this can go\n { apnsFetch: http2Fetch() }\n );\n if (executionTimeoutMs !== undefined) {\n const tooLong = host\n .bundle()\n .workflows.filter((workflow) => longestJourneyMs(workflow) > executionTimeoutMs);\n if (tooLong.length > 0) {\n const days = (ms: number) => `${Math.ceil(ms / 86_400_000)} days`;\n throw new RangeError(\n `${tooLong.map((w) => `'${w.id}' can run ${days(longestJourneyMs(w))}`).join(', ')}, ` +\n `longer than the execution timeout (${days(executionTimeoutMs)}): raise ExecutionTimeout (up to 366 days)`\n );\n }\n }\n const lambda = lambdaOption ?? sdkLambdaApi();\n const ownHashes = new Set(host.bundle().workflows.map((workflow) => workflow.contentHash));\n const scope = new AsyncLocalStorage<Invocation>();\n\n /** The version this code was published as: `$LATEST` while developing. */\n const ownVersion = () => process.env.AWS_LAMBDA_FUNCTION_VERSION ?? '$LATEST';\n /** Numbered versions are ordered: the bundle compiled into a later one goes live by itself. */\n const bundleVersion = (): BundleVersion | undefined => {\n const version = ownVersion();\n return /^\\d+$/.test(version) ? { id: version, createdAt: Number(version) } : undefined;\n };\n\n /** The store and the env (with the instance port) of this invocation, opened on first use. */\n const open = (\n context: DurableContext\n ): { store: JourneyStore; env: HostEnv; executions: ExecutionRegistry } => {\n const invocation = scope.getStore();\n if (invocation === undefined) throw new Error('journeyLambda: outside an invocation');\n const placeholder = { ...baseEnv } as unknown as HostEnv;\n invocation.lease ??= host.lease(placeholder);\n const { store } = invocation.lease;\n const executions = store.executions;\n if (executions === undefined) {\n throw new Error(\n 'journeyLambda needs a store with an execution registry (PostgresJourneyStore)'\n );\n }\n const functionArn = unqualified(context.lambdaContext.invokedFunctionArn);\n const target = async (contentHash: string, version?: string): Promise<string> => {\n // An execution runs the code its IR was compiled with: the version whose bundle put the\n // route there, read in the same row as the hash — never a separately read \"live\" version,\n // which a release between the two reads would make another bundle's\n if (version !== undefined && /^\\d+$/.test(version)) return `${functionArn}:${version}`;\n // A forced deploy records no version: only this code's own workflows can run here\n if (ownHashes.has(contentHash)) return `${functionArn}:${ownVersion()}`;\n throw new Error(`no published version is known to carry workflow IR ${contentHash}`);\n };\n const instances = new AwsInstances({\n store,\n executions,\n lambda,\n target,\n ...(startRetryMs === undefined ? {} : { startRetryMs }),\n ...(stopDrainMs === undefined ? {} : { stopDrainMs }),\n });\n return { store, env: { ...baseEnv, JOURNEY: instances }, executions };\n };\n\n const run = async (input: RunInput, context: DurableContext): Promise<JourneyOutcome> => {\n const { store, env, executions } = open(context);\n const { instanceId, params } = input;\n // Only a start the router recorded may run, byte for byte: the function can be invoked by\n // anything its policy lets through, and an input of this shape would otherwise run any\n // workflow for any user. A stopped execution (an erasure) may not come back either. Outside\n // any step — a step would replay the first invocation's \"not stopped\" on every wake — so the\n // execution fails at once on a refusal; only the read itself is retried, briefly, when the\n // database stumbled.\n const record = await readWithRetry(() => executions.get(instanceId), {\n what: 'run entry',\n instanceId,\n });\n if (\n record === undefined ||\n record.stoppedAt !== undefined ||\n record.input !== JSON.stringify(input)\n ) {\n throw new PermanentError('journeyLambda: run input is not a recorded start');\n }\n // Running is the proof the start got through, whatever became of the invoke's response\n await context.step('$workflow:started', async () => {\n await executions.markSubmitted(\n instanceId,\n context.executionContext.durableExecutionArn,\n Date.now()\n );\n });\n return executeJourney(\n {\n instanceId,\n params,\n enteredAtMs: input.enteredAtMs,\n step: new AwsEngineStep(context, store, executions, lambda, params.userId, instanceId),\n },\n host.runParts(env, store, params)\n );\n };\n\n const http = (event: FunctionUrlEvent, context: DurableContext): Promise<FunctionUrlResult> => {\n const serve = async (): Promise<FunctionUrlResult> => {\n const method = event.requestContext.http.method;\n try {\n const { store, env } = open(context);\n const request = toRequest(event);\n // Only the bundle compiled into a version may route: one is never swapped in by hand\n if (new URL(request.url).pathname === '/deploy') {\n return await fromResponse(\n json(\n {\n error:\n 'deploy by publishing a version (POST /bundle/deploy applies its own bundle)',\n },\n 409\n ),\n method\n );\n }\n await host.applyOwnBundle(env, bundleVersion());\n return await fromResponse(await host.handle(request, env, store), method);\n } catch (error) {\n console.error('[workflow] request failed', error);\n return fromResponse(json({ error: 'internal error' }, 500), method);\n }\n };\n // A read (the bundle, a preview, a tracked link or pixel) answers straight from the handler:\n // its body can be large, and a step would checkpoint all of it. A write runs in one step,\n // never retried — the caller is waiting, and retries the request itself\n const method = event.requestContext.http.method.toUpperCase();\n if (method === 'GET' || method === 'HEAD') return serve();\n return context.step('http', serve, { retryStrategy: () => ({ shouldRetry: false }) });\n };\n\n /**\n * The sweep as durable steps, one per page of users: an invocation cut short (the function's\n * timeout) is re-invoked, and the re-invocation replays the pages already checkpointed\n * instead of evaluating everyone again. No step retries on its own — a page that failed is\n * evaluated again by the next tick.\n */\n const sweep = async (context: DurableContext): Promise<SweepResult> => {\n const once = { retryStrategy: () => ({ shouldRetry: false }) };\n await context.step(\n 'sweep:maintain',\n async () => {\n const { store, env } = open(context);\n await host.applyOwnBundle(env, bundleVersion());\n await sweepMaintenance(env, store);\n },\n once\n );\n let users = 0;\n const started: string[] = [];\n let after: string | undefined;\n for (let n = 0; ; n++) {\n const page = await context.step(\n `sweep:page:${n}`,\n async () => {\n const { store, env } = open(context);\n return sweepSegmentsPaged(env, store, { after, limit: SWEEP_PAGE_SIZE });\n },\n once\n );\n users += page.users;\n started.push(...page.started);\n if (!page.more || page.lastUserId === undefined) break;\n after = page.lastUserId;\n }\n const sizes = await context.step(\n 'sweep:snapshot',\n async () => {\n const { store } = open(context);\n return (await store.reporting?.snapshotSegments(Date.now())) ?? [];\n },\n once\n );\n return { users, started, sizes };\n };\n\n const durable = withDurableExecution(async (input: unknown, context: DurableContext) => {\n if (isFunctionUrlEvent(input)) return http(input, context);\n if (isRunInput(input)) return run(input, context);\n if (\n typeof input === 'object' &&\n input !== null &&\n (input as { type?: unknown }).type === SWEEP_EVENT_TYPE\n ) {\n return sweep(context);\n }\n throw new Error('journeyLambda: unrecognized event (not a Function URL request, run or sweep)');\n });\n\n const handler = async (\n event: DurableExecutionInvocationInput,\n context: LambdaContext\n ): Promise<DurableExecutionInvocationOutput> => {\n const invocation: Invocation = {};\n try {\n // The durable wrapper reads the whole context Lambda passed, not just the fields above\n return await scope.run(invocation, () =>\n durable(event, context as Parameters<typeof durable>[1])\n );\n } finally {\n // Outside the durable wrapper: a suspended run returns PENDING without unwinding the\n // handler, so a `finally` in there would never release the connection\n await invocation.lease?.close().catch((error: unknown) => {\n console.error('[workflow] closing the store failed', error);\n });\n }\n };\n\n return { handler };\n}\n\nexport { AwsEngineStep, stepRetry } from './engine-step';\nexport { AwsInstances, RUN_EVENT_TYPE, executionName, isRunInput } from './instances';\nexport type { AwsInstancesOptions, RunInput } from './instances';\nexport { sdkLambdaApi } from './lambda-api';\nexport { bearerMatches, timingSafeEqual } from '../host/auth';\nexport type { Authorize } from '../host/auth';\nexport type { ExecutionState, LambdaApi } from './lambda-api';\nexport { fromResponse, isFunctionUrlEvent, toRequest } from './function-url';\nexport type { FunctionUrlEvent, FunctionUrlResult } from './function-url';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAa,mBAAmB;;AAwDhC,SAAS,YAAY,oBAAoC;CACvD,OAAO,mBAAmB,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAC3D;AAEA,MAAM,QAAQ,MAAe,SAAS,QACpC,IAAI,SAAS,KAAK,UAAU,IAAI,GAAG;CAAE;CAAQ,SAAS,EAAE,gBAAgB,mBAAmB;AAAE,CAAC;AAEhG,SAAgB,cACd,SACe;CAEf,MAAM,EACJ,KAAK,SACL,QAAQ,cACR,cACA,aACA,oBACA,GAAG,gBACD;CACJ,MAAM,OAAOA,0BAAAA,kBACX;EAAE,GAAG;EAAa,QAAQ,K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Q,KAAK,GAAG,KAAK,OAAO;GAC5B,IAAI,CAAC,KAAK,QAAQ,KAAK,eAAe,KAAA,GAAW;GACjD,QAAQ,KAAK;EACf;EACA,MAAM,QAAQ,MAAM,QAAQ,KAC1B,kBACA,YAAY;GACV,MAAM,EAAE,UAAU,KAAK,OAAO;GAC9B,OAAQ,MAAM,MAAM,WAAW,iBAAiB,KAAK,IAAI,CAAC,KAAM,CAAC;EACnE,GACA,IACF;EACA,OAAO;GAAE;GAAO;GAAS;EAAM;CACjC;CAEA,MAAM,WAAA,GAAUC,8BAAAA,qBAAAA,CAAqB,OAAO,OAAgB,YAA4B;EACtF,IAAIC,yBAAAA,mBAAmB,KAAK,GAAG,OAAO,KAAK,OAAO,OAAO;EACzD,IAAIC,sBAAAA,WAAW,KAAK,GAAG,OAAO,IAAI,OAAO,OAAO;EAChD,IACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAA,mBAE9B,OAAO,MAAM,OAAO;EAEtB,MAAM,IAAI,MAAM,8EAA8E;CAChG,CAAC;CAED,MAAM,UAAU,OACd,OACA,YAC8C;EAC9C,MAAM,aAAyB,CAAC;EAChC,IAAI;GAEF,OAAO,MAAM,MAAM,IAAI,kBACrB,QAAQ,OAAO,OAAwC,CACzD;EACF,UAAU;GAGR,MAAM,WAAW,OAAO,MAAM,CAAC,CAAC,OAAO,UAAmB;IACxD,QAAQ,MAAM,uCAAuC,KAAK;GAC5D,CAAC;EACH;CACF;CAEA,OAAO,EAAE,QAAQ;AACnB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createJourneyHost","http2Fetch","longestJourneyMs","sdkLambdaApi","AsyncLocalStorage","AwsInstances","readWithRetry","PermanentError","executeJourney","AwsEngineStep","toRequest","fromResponse","sweepMaintenance","sweepSegmentsPaged","withDurableExecution","isFunctionUrlEvent","isRunInput"],"sources":["../../src/aws/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport {\n type DurableContext,\n type DurableExecutionInvocationInput,\n type DurableExecutionInvocationOutput,\n withDurableExecution,\n} from '@aws/durable-execution-sdk-js';\nimport { longestJourneyMs } from '../engine/duration';\nimport type { JourneyOutcome } from '../engine/ports';\nimport { PermanentError } from '../engine/retry';\nimport { executeJourney } from '../host/execute';\nimport { readWithRetry } from '../host/fresh-read';\nimport {\n SWEEP_PAGE_SIZE,\n type SweepResult,\n sweepMaintenance,\n sweepSegmentsPaged,\n} from '../host/ingest';\nimport { type JourneyHostOptions, createJourneyHost } from '../host/journey-host';\nimport type { JourneyEnv } from '../host/platform';\nimport { http2Fetch } from '../http2-client';\nimport type { BundleVersion, ExecutionRegistry, JourneyStore, StoreLease } from '../store/index';\nimport { AwsEngineStep } from './engine-step';\nimport {\n type FunctionUrlEvent,\n type FunctionUrlResult,\n fromResponse,\n isFunctionUrlEvent,\n toRequest,\n} from './function-url';\nimport { AwsInstances, type RunInput, isRunInput } from './instances';\nimport { type LambdaApi, sdkLambdaApi } from './lambda-api';\n\n/**\n * `@shware/workflow/aws` — the journey host as one Lambda durable function behind a Function\n * URL, on Postgres.\n *\n * The one handler tells three inputs apart by the event's top-level shape: a Function URL\n * request (the HTTP API — ingest, identify, devices, tracking, bundle, preview), an internal run\n * (one journey instance: one durable execution, started by an asynchronous invoke of this\n * function's own numbered version), and a scheduled maintenance tick. An HTTP body can never\n * pass for the other two: the Function URL always wraps it.\n *\n * const journeys = journeyLambda({\n * config,\n * env, // parsed from process.env (zod)\n * store: (env, database) => postgresJsStore(env.DATABASE_URL, database),\n * email: (env) => sesEmailTransport({ region: env.AWS_REGION }),\n * });\n * export const handler = journeys.handler;\n */\n\n/** The scheduled tick (EventBridge Scheduler's payload): the segment sweep and maintenance. */\nexport const SWEEP_EVENT_TYPE = '$workflow.sweep';\n\n/** What journeyLambda reads from its env: `JourneyEnv` without the binding it supplies itself. */\nexport type JourneyLambdaEnv = Omit<JourneyEnv, 'JOURNEY' | 'DB' | 'EMAIL'>;\n\nexport interface JourneyLambdaOptions<Env extends JourneyLambdaEnv> extends Omit<\n JourneyHostOptions<Env & JourneyEnv>,\n 'env' | 'store'\n> {\n /** The validated environment (parsed from `process.env` with zod by the app). */\n env: Env;\n /** The Postgres store: AWS needs its execution registry (`postgresJsStore`). */\n store: (env: Env, database: { schema: string }) => JourneyStore | StoreLease;\n /** The Lambda control plane; `@aws-sdk/client-lambda` with the execution role by default. */\n lambda?: LambdaApi;\n /** How long an unconfirmed start is retried (default 12 hours; keep it under the retention). */\n startRetryMs?: number;\n /**\n * How long an erasure waits after stopping an execution before it erases: an invocation\n * running at the stop goes on to its next checkpoint. Set it to at least the function's\n * timeout; 15 minutes (Lambda's maximum) by default.\n */\n stopDrainMs?: number;\n /**\n * The function's `DurableConfig.ExecutionTimeout`, in milliseconds. With it, a workflow that\n * can outlive it (`longestJourneyMs`) fails the handler's creation — a deploy's smoke test —\n * instead of being stopped by the platform midway and recorded as failed.\n */\n executionTimeoutMs?: number;\n}\n\n/**\n * The Lambda invocation context, as far as the handler's signature needs it — declared here so\n * the package's types do not depend on `@types/aws-lambda`. Lambda passes the full object.\n */\nexport interface LambdaContext {\n functionName: string;\n functionVersion: string;\n invokedFunctionArn: string;\n awsRequestId: string;\n getRemainingTimeInMillis(): number;\n}\n\nexport interface JourneyLambda {\n /** Export as the function's handler. */\n handler: (\n event: DurableExecutionInvocationInput,\n context: LambdaContext\n ) => Promise<DurableExecutionInvocationOutput>;\n}\n\ninterface Invocation {\n lease?: Required<StoreLease>;\n}\n\n/** This function's ARN without its qualifier, from the ARN it was invoked under. */\nfunction unqualified(invokedFunctionArn: string): string {\n return invokedFunctionArn.split(':').slice(0, 7).join(':');\n}\n\nconst json = (body: unknown, status = 200) =>\n new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });\n\nexport function journeyLambda<Env extends JourneyLambdaEnv>(\n options: JourneyLambdaOptions<Env>\n): JourneyLambda {\n type HostEnv = Env & JourneyEnv;\n const {\n env: baseEnv,\n lambda: lambdaOption,\n startRetryMs,\n stopDrainMs,\n executionTimeoutMs,\n ...hostOptions\n } = options;\n const host = createJourneyHost<HostEnv>(\n { ...hostOptions, store: (env, database) => options.store(env, database) },\n // Node 24's fetch cannot reach APNs (HTTP/2 only): see http2-client.ts for when this can go\n { apnsFetch: http2Fetch() }\n );\n if (executionTimeoutMs !== undefined) {\n const tooLong = host\n .bundle()\n .workflows.filter((workflow) => longestJourneyMs(workflow) > executionTimeoutMs);\n if (tooLong.length > 0) {\n const days = (ms: number) => `${Math.ceil(ms / 86_400_000)} days`;\n throw new RangeError(\n `${tooLong.map((w) => `'${w.id}' can run ${days(longestJourneyMs(w))}`).join(', ')}, ` +\n `longer than the execution timeout (${days(executionTimeoutMs)}): raise ExecutionTimeout (up to 366 days)`\n );\n }\n }\n const lambda = lambdaOption ?? sdkLambdaApi();\n const ownHashes = new Set(host.bundle().workflows.map((workflow) => workflow.contentHash));\n const scope = new AsyncLocalStorage<Invocation>();\n\n /** The version this code was published as: `$LATEST` while developing. */\n const ownVersion = () => process.env.AWS_LAMBDA_FUNCTION_VERSION ?? '$LATEST';\n /** Numbered versions are ordered: the bundle compiled into a later one goes live by itself. */\n const bundleVersion = (): BundleVersion | undefined => {\n const version = ownVersion();\n return /^\\d+$/.test(version) ? { id: version, createdAt: Number(version) } : undefined;\n };\n\n /** The store and the env (with the instance port) of this invocation, opened on first use. */\n const open = (\n context: DurableContext\n ): { store: JourneyStore; env: HostEnv; executions: ExecutionRegistry } => {\n const invocation = scope.getStore();\n if (invocation === undefined) throw new Error('journeyLambda: outside an invocation');\n const placeholder = { ...baseEnv } as unknown as HostEnv;\n invocation.lease ??= host.lease(placeholder);\n const { store } = invocation.lease;\n const { executions } = store;\n const functionArn = unqualified(context.lambdaContext.invokedFunctionArn);\n const target = async (contentHash: string, version?: string): Promise<string> => {\n // An execution runs the code its IR was compiled with: the version whose bundle put the\n // route there, read in the same row as the hash — never a separately read \"live\" version,\n // which a release between the two reads would make another bundle's\n if (version !== undefined && /^\\d+$/.test(version)) return `${functionArn}:${version}`;\n // A forced deploy records no version: only this code's own workflows can run here\n if (ownHashes.has(contentHash)) return `${functionArn}:${ownVersion()}`;\n throw new Error(`no published version is known to carry workflow IR ${contentHash}`);\n };\n const instances = new AwsInstances({\n store,\n executions,\n lambda,\n target,\n ...(startRetryMs === undefined ? {} : { startRetryMs }),\n ...(stopDrainMs === undefined ? {} : { stopDrainMs }),\n });\n return { store, env: { ...baseEnv, JOURNEY: instances }, executions };\n };\n\n const run = async (input: RunInput, context: DurableContext): Promise<JourneyOutcome> => {\n const { store, env, executions } = open(context);\n const { instanceId, params } = input;\n // Only a start the router recorded may run, byte for byte: the function can be invoked by\n // anything its policy lets through, and an input of this shape would otherwise run any\n // workflow for any user. A stopped execution (an erasure) may not come back either. Outside\n // any step — a step would replay the first invocation's \"not stopped\" on every wake — so the\n // execution fails at once on a refusal; only the read itself is retried, briefly, when the\n // database stumbled.\n const record = await readWithRetry(() => executions.get(instanceId), {\n what: 'run entry',\n instanceId,\n });\n if (\n record === undefined ||\n record.stoppedAt !== undefined ||\n record.input !== JSON.stringify(input)\n ) {\n throw new PermanentError('journeyLambda: run input is not a recorded start');\n }\n // Running is the proof the start got through, whatever became of the invoke's response\n await context.step('$workflow:started', async () => {\n await executions.markSubmitted(\n instanceId,\n context.executionContext.durableExecutionArn,\n Date.now()\n );\n });\n return executeJourney(\n {\n instanceId,\n params,\n enteredAtMs: input.enteredAtMs,\n step: new AwsEngineStep(context, store, executions, lambda, params.userId, instanceId),\n },\n host.runParts(env, store, params)\n );\n };\n\n const http = (event: FunctionUrlEvent, context: DurableContext): Promise<FunctionUrlResult> => {\n const serve = async (): Promise<FunctionUrlResult> => {\n const method = event.requestContext.http.method;\n try {\n const { store, env } = open(context);\n const request = toRequest(event);\n // Only the bundle compiled into a version may route: one is never swapped in by hand\n if (new URL(request.url).pathname === '/deploy') {\n return await fromResponse(\n json(\n {\n error:\n 'deploy by publishing a version (POST /bundle/deploy applies its own bundle)',\n },\n 409\n ),\n method\n );\n }\n await host.applyOwnBundle(env, bundleVersion());\n return await fromResponse(await host.handle(request, env, store), method);\n } catch (error) {\n console.error('[workflow] request failed', error);\n return fromResponse(json({ error: 'internal error' }, 500), method);\n }\n };\n // A read (the bundle, a preview, a tracked link or pixel) answers straight from the handler:\n // its body can be large, and a step would checkpoint all of it. A write runs in one step,\n // never retried — the caller is waiting, and retries the request itself\n const method = event.requestContext.http.method.toUpperCase();\n if (method === 'GET' || method === 'HEAD') return serve();\n return context.step('http', serve, { retryStrategy: () => ({ shouldRetry: false }) });\n };\n\n /**\n * The sweep as durable steps, one per page of users: an invocation cut short (the function's\n * timeout) is re-invoked, and the re-invocation replays the pages already checkpointed\n * instead of evaluating everyone again. No step retries on its own — a page that failed is\n * evaluated again by the next tick.\n */\n const sweep = async (context: DurableContext): Promise<SweepResult> => {\n const once = { retryStrategy: () => ({ shouldRetry: false }) };\n await context.step(\n 'sweep:maintain',\n async () => {\n const { store, env } = open(context);\n await host.applyOwnBundle(env, bundleVersion());\n await sweepMaintenance(env, store);\n },\n once\n );\n let users = 0;\n const started: string[] = [];\n let after: string | undefined;\n for (let n = 0; ; n++) {\n const page = await context.step(\n `sweep:page:${n}`,\n async () => {\n const { store, env } = open(context);\n return sweepSegmentsPaged(env, store, { after, limit: SWEEP_PAGE_SIZE });\n },\n once\n );\n users += page.users;\n started.push(...page.started);\n if (!page.more || page.lastUserId === undefined) break;\n after = page.lastUserId;\n }\n const sizes = await context.step(\n 'sweep:snapshot',\n async () => {\n const { store } = open(context);\n return store.reporting.snapshotSegments(Date.now());\n },\n once\n );\n return { users, started, sizes };\n };\n\n const durable = withDurableExecution(async (input: unknown, context: DurableContext) => {\n if (isFunctionUrlEvent(input)) return http(input, context);\n if (isRunInput(input)) return run(input, context);\n if (\n typeof input === 'object' &&\n input !== null &&\n (input as { type?: unknown }).type === SWEEP_EVENT_TYPE\n ) {\n return sweep(context);\n }\n throw new Error('journeyLambda: unrecognized event (not a Function URL request, run or sweep)');\n });\n\n const handler = async (\n event: DurableExecutionInvocationInput,\n context: LambdaContext\n ): Promise<DurableExecutionInvocationOutput> => {\n const invocation: Invocation = {};\n try {\n // The durable wrapper reads the whole context Lambda passed, not just the fields above\n return await scope.run(invocation, () =>\n durable(event, context as Parameters<typeof durable>[1])\n );\n } finally {\n // Outside the durable wrapper: a suspended run returns PENDING without unwinding the\n // handler, so a `finally` in there would never release the connection\n await invocation.lease?.close().catch((error: unknown) => {\n console.error('[workflow] closing the store failed', error);\n });\n }\n };\n\n return { handler };\n}\n\nexport { AwsEngineStep, stepRetry } from './engine-step';\nexport { AwsInstances, RUN_EVENT_TYPE, executionName, isRunInput } from './instances';\nexport type { AwsInstancesOptions, RunInput } from './instances';\nexport { sdkLambdaApi } from './lambda-api';\nexport { bearerMatches, timingSafeEqual } from '../host/auth';\nexport type { Authorize } from '../host/auth';\nexport type { ExecutionState, LambdaApi } from './lambda-api';\nexport { fromResponse, isFunctionUrlEvent, toRequest } from './function-url';\nexport type { FunctionUrlEvent, FunctionUrlResult } from './function-url';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAa,mBAAmB;;AAwDhC,SAAS,YAAY,oBAAoC;CACvD,OAAO,mBAAmB,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAC3D;AAEA,MAAM,QAAQ,MAAe,SAAS,QACpC,IAAI,SAAS,KAAK,UAAU,IAAI,GAAG;CAAE;CAAQ,SAAS,EAAE,gBAAgB,mBAAmB;AAAE,CAAC;AAEhG,SAAgB,cACd,SACe;CAEf,MAAM,EACJ,KAAK,SACL,QAAQ,cACR,cACA,aACA,oBACA,GAAG,gBACD;CACJ,MAAM,OAAOA,0BAAAA,kBACX;EAAE,GAAG;EAAa,QAAQ,KAAK,aAAa,QAAQ,MAAM,KAAK,QAAQ;CAAE,GAEzE,EAAE,WAAWC,qBAAAA,WAAW,EAAE,CAC5B;CACA,IAAI,uBAAuB,KAAA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,EAAE,UAAU,KAAK,OAAO;GAC9B,OAAO,MAAM,UAAU,iBAAiB,KAAK,IAAI,CAAC;EACpD,GACA,IACF;EACA,OAAO;GAAE;GAAO;GAAS;EAAM;CACjC;CAEA,MAAM,WAAA,GAAUC,8BAAAA,qBAAAA,CAAqB,OAAO,OAAgB,YAA4B;EACtF,IAAIC,yBAAAA,mBAAmB,KAAK,GAAG,OAAO,KAAK,OAAO,OAAO;EACzD,IAAIC,sBAAAA,WAAW,KAAK,GAAG,OAAO,IAAI,OAAO,OAAO;EAChD,IACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAA,mBAE9B,OAAO,MAAM,OAAO;EAEtB,MAAM,IAAI,MAAM,8EAA8E;CAChG,CAAC;CAED,MAAM,UAAU,OACd,OACA,YAC8C;EAC9C,MAAM,aAAyB,CAAC;EAChC,IAAI;GAEF,OAAO,MAAM,MAAM,IAAI,kBACrB,QAAQ,OAAO,OAAwC,CACzD;EACF,UAAU;GAGR,MAAM,WAAW,OAAO,MAAM,CAAC,CAAC,OAAO,UAAmB;IACxD,QAAQ,MAAM,uCAAuC,KAAK;GAC5D,CAAC;EACH;CACF;CAEA,OAAO,EAAE,QAAQ;AACnB"}
|
package/dist/aws/index.d.cts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { JourneyEnv } from "../host/platform.cjs";
|
|
2
1
|
import { JourneyStore, StoreLease } from "../store/index.cjs";
|
|
3
2
|
import { ExecutionState, LambdaApi, sdkLambdaApi } from "./lambda-api.cjs";
|
|
4
3
|
import { AwsEngineStep, stepRetry } from "./engine-step.cjs";
|
|
5
4
|
import { FunctionUrlEvent, FunctionUrlResult, fromResponse, isFunctionUrlEvent, toRequest } from "./function-url.cjs";
|
|
6
5
|
import { Authorize, bearerMatches, timingSafeEqual } from "../host/auth.cjs";
|
|
6
|
+
import { JourneyEnv } from "../host/platform.cjs";
|
|
7
7
|
import { JourneyHostOptions } from "../host/journey-host.cjs";
|
|
8
8
|
import { AwsInstances, AwsInstancesOptions, RUN_EVENT_TYPE, RunInput, executionName, isRunInput } from "./instances.cjs";
|
|
9
9
|
import { DurableExecutionInvocationInput, DurableExecutionInvocationOutput } from "@aws/durable-execution-sdk-js";
|
|
10
|
-
//#region src/aws/index.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* `@shware/workflow/aws` — the journey host as one Lambda durable function behind a Function
|
|
13
12
|
* URL, on Postgres.
|
|
@@ -70,6 +69,5 @@ export interface JourneyLambda {
|
|
|
70
69
|
handler: (event: DurableExecutionInvocationInput, context: LambdaContext) => Promise<DurableExecutionInvocationOutput>;
|
|
71
70
|
}
|
|
72
71
|
export declare function journeyLambda<Env extends JourneyLambdaEnv>(options: JourneyLambdaOptions<Env>): JourneyLambda;
|
|
73
|
-
//#endregion
|
|
74
72
|
export { type Authorize, AwsEngineStep, AwsInstances, type AwsInstancesOptions, type ExecutionState, type FunctionUrlEvent, type FunctionUrlResult, type LambdaApi, RUN_EVENT_TYPE, type RunInput, bearerMatches, executionName, fromResponse, isFunctionUrlEvent, isRunInput, sdkLambdaApi, stepRetry, timingSafeEqual, toRequest };
|
|
75
73
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/aws/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/aws/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/aws/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqDa;;YAGD,mBAAmB,KAAK;iBAEnB,qBAAqB,YAAY,0BAA0B,KAC1E,mBAAmB,MAAM;;EAIzB,KAAK;;EAEL,QAAQ,KAAK,KAAK;IAAY;QAAqB,eAAe;;EAElE,SAAS;;EAET;;;;;;EAMA;;;;;;EAMA;;;;;;iBAOe;EACf;EACA;EACA;EACA;EACA;;iBAGe;;EAEf,UACE,OAAO,iCACP,SAAS,kBACN,QAAQ;;wBAeC,cAAc,YAAY,kBACxC,SAAS,qBAAqB,OAC7B"}
|
package/dist/aws/index.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { JourneyEnv } from "../host/platform.mjs";
|
|
2
1
|
import { JourneyStore, StoreLease } from "../store/index.mjs";
|
|
3
2
|
import { ExecutionState, LambdaApi, sdkLambdaApi } from "./lambda-api.mjs";
|
|
4
3
|
import { AwsEngineStep, stepRetry } from "./engine-step.mjs";
|
|
5
4
|
import { FunctionUrlEvent, FunctionUrlResult, fromResponse, isFunctionUrlEvent, toRequest } from "./function-url.mjs";
|
|
6
5
|
import { Authorize, bearerMatches, timingSafeEqual } from "../host/auth.mjs";
|
|
6
|
+
import { JourneyEnv } from "../host/platform.mjs";
|
|
7
7
|
import { JourneyHostOptions } from "../host/journey-host.mjs";
|
|
8
8
|
import { AwsInstances, AwsInstancesOptions, RUN_EVENT_TYPE, RunInput, executionName, isRunInput } from "./instances.mjs";
|
|
9
9
|
import { DurableExecutionInvocationInput, DurableExecutionInvocationOutput } from "@aws/durable-execution-sdk-js";
|
|
10
|
-
//#region src/aws/index.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* `@shware/workflow/aws` — the journey host as one Lambda durable function behind a Function
|
|
13
12
|
* URL, on Postgres.
|
|
@@ -70,6 +69,5 @@ export interface JourneyLambda {
|
|
|
70
69
|
handler: (event: DurableExecutionInvocationInput, context: LambdaContext) => Promise<DurableExecutionInvocationOutput>;
|
|
71
70
|
}
|
|
72
71
|
export declare function journeyLambda<Env extends JourneyLambdaEnv>(options: JourneyLambdaOptions<Env>): JourneyLambda;
|
|
73
|
-
//#endregion
|
|
74
72
|
export { type Authorize, AwsEngineStep, AwsInstances, type AwsInstancesOptions, type ExecutionState, type FunctionUrlEvent, type FunctionUrlResult, type LambdaApi, RUN_EVENT_TYPE, type RunInput, bearerMatches, executionName, fromResponse, isFunctionUrlEvent, isRunInput, sdkLambdaApi, stepRetry, timingSafeEqual, toRequest };
|
|
75
73
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/aws/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/aws/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/aws/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqDa;;YAGD,mBAAmB,KAAK;iBAEnB,qBAAqB,YAAY,0BAA0B,KAC1E,mBAAmB,MAAM;;EAIzB,KAAK;;EAEL,QAAQ,KAAK,KAAK;IAAY;QAAqB,eAAe;;EAElE,SAAS;;EAET;;;;;;EAMA;;;;;;EAMA;;;;;;iBAOe;EACf;EACA;EACA;EACA;EACA;;iBAGe;;EAEf,UACE,OAAO,iCACP,SAAS,kBACN,QAAQ;;wBAeC,cAAc,YAAY,kBACxC,SAAS,qBAAqB,OAC7B"}
|