@shware/workflow 5.0.0 → 6.0.0
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 +165 -42
- 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 +2 -3
- package/dist/aws/index.d.cts +0 -2
- package/dist/aws/index.d.cts.map +1 -1
- package/dist/aws/index.d.mts +0 -2
- package/dist/aws/index.d.mts.map +1 -1
- package/dist/aws/index.mjs +2 -3
- package/dist/aws/instances.cjs +1 -2
- package/dist/aws/instances.d.cts +0 -2
- package/dist/aws/instances.d.cts.map +1 -1
- package/dist/aws/instances.d.mts +0 -2
- package/dist/aws/instances.d.mts.map +1 -1
- package/dist/aws/instances.mjs +1 -2
- 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 +46 -6
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -5
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts +25 -5
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +46 -6
- package/dist/client.mjs.map +1 -1
- package/dist/cloudflare/bindings.cjs +1 -2
- package/dist/cloudflare/bindings.d.cts +0 -2
- package/dist/cloudflare/bindings.d.cts.map +1 -1
- package/dist/cloudflare/bindings.d.mts +0 -2
- package/dist/cloudflare/bindings.d.mts.map +1 -1
- package/dist/cloudflare/bindings.mjs +1 -2
- package/dist/cloudflare/index.cjs +2 -2
- package/dist/cloudflare/index.mjs +2 -2
- package/dist/cloudflare/runner.cjs +2 -3
- package/dist/cloudflare/runner.d.cts +1 -3
- package/dist/cloudflare/runner.d.cts.map +1 -1
- package/dist/cloudflare/runner.d.mts +1 -3
- package/dist/cloudflare/runner.d.mts.map +1 -1
- package/dist/cloudflare/runner.mjs +2 -3
- 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 +25 -5
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +15 -11
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +15 -11
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +26 -6
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +12 -2
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +28 -9
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +28 -9
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs +12 -2
- package/dist/contract.mjs.map +1 -1
- 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 +5 -5
- package/dist/dsl/bundle.cjs.map +1 -1
- package/dist/dsl/bundle.d.cts +5 -3
- package/dist/dsl/bundle.d.cts.map +1 -1
- package/dist/dsl/bundle.d.mts +5 -3
- package/dist/dsl/bundle.d.mts.map +1 -1
- package/dist/dsl/bundle.mjs +5 -5
- package/dist/dsl/bundle.mjs.map +1 -1
- 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 +3 -3
- package/dist/dsl/flow.cjs.map +1 -1
- package/dist/dsl/flow.d.cts +1 -3
- package/dist/dsl/flow.d.cts.map +1 -1
- package/dist/dsl/flow.d.mts +1 -3
- package/dist/dsl/flow.d.mts.map +1 -1
- package/dist/dsl/flow.mjs +3 -3
- package/dist/dsl/flow.mjs.map +1 -1
- 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 +3 -4
- 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 +3 -4
- 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 +2 -3
- package/dist/email-sender.cjs.map +1 -1
- package/dist/email-sender.d.cts +1 -3
- package/dist/email-sender.d.cts.map +1 -1
- package/dist/email-sender.d.mts +1 -3
- package/dist/email-sender.d.mts.map +1 -1
- package/dist/email-sender.mjs +2 -3
- package/dist/email-sender.mjs.map +1 -1
- package/dist/email.cjs +33 -7
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +38 -11
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +38 -11
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +33 -8
- package/dist/email.mjs.map +1 -1
- 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 +1 -2
- package/dist/engine/condition.cjs.map +1 -1
- package/dist/engine/condition.d.cts +0 -2
- package/dist/engine/condition.d.cts.map +1 -1
- package/dist/engine/condition.d.mts +0 -2
- package/dist/engine/condition.d.mts.map +1 -1
- package/dist/engine/condition.mjs +1 -2
- 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/index.cjs +1 -1
- package/dist/engine/index.mjs +1 -1
- package/dist/engine/interpreter.cjs +22 -6
- package/dist/engine/interpreter.cjs.map +1 -1
- 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 +22 -6
- package/dist/engine/interpreter.mjs.map +1 -1
- package/dist/engine/ports.d.cts +8 -4
- package/dist/engine/ports.d.cts.map +1 -1
- package/dist/engine/ports.d.mts +8 -4
- 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 +2 -3
- package/dist/host/channels.d.cts +0 -2
- package/dist/host/channels.d.cts.map +1 -1
- package/dist/host/channels.d.mts +0 -2
- package/dist/host/channels.d.mts.map +1 -1
- package/dist/host/channels.mjs +2 -3
- package/dist/host/execute.cjs +3 -4
- 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 +3 -4
- 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 +39 -5
- 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 +40 -6
- package/dist/host/http.mjs.map +1 -1
- package/dist/host/ingest.cjs +129 -6
- package/dist/host/ingest.cjs.map +1 -1
- package/dist/host/ingest.d.cts +71 -2
- package/dist/host/ingest.d.cts.map +1 -1
- package/dist/host/ingest.d.mts +71 -2
- package/dist/host/ingest.d.mts.map +1 -1
- package/dist/host/ingest.mjs +126 -7
- package/dist/host/ingest.mjs.map +1 -1
- package/dist/host/journey-host.cjs +11 -10
- package/dist/host/journey-host.cjs.map +1 -1
- package/dist/host/journey-host.d.cts +0 -2
- package/dist/host/journey-host.d.cts.map +1 -1
- package/dist/host/journey-host.d.mts +0 -2
- package/dist/host/journey-host.d.mts.map +1 -1
- package/dist/host/journey-host.mjs +11 -10
- package/dist/host/journey-host.mjs.map +1 -1
- package/dist/host/platform.cjs +1 -2
- package/dist/host/platform.d.cts +0 -2
- package/dist/host/platform.d.cts.map +1 -1
- package/dist/host/platform.d.mts +0 -2
- package/dist/host/platform.d.mts.map +1 -1
- package/dist/host/platform.mjs +1 -2
- 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/index.cjs +5 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +5 -5
- package/dist/ir.cjs +12 -4
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +17 -2
- package/dist/ir.d.cts.map +1 -1
- package/dist/ir.d.mts +17 -2
- package/dist/ir.d.mts.map +1 -1
- package/dist/ir.mjs +12 -5
- package/dist/ir.mjs.map +1 -1
- 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 +2 -2
- package/dist/reporting/observer.cjs.map +1 -1
- 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 +2 -2
- package/dist/reporting/observer.mjs.map +1 -1
- package/dist/reporting/tracking.cjs +29 -12
- package/dist/reporting/tracking.cjs.map +1 -1
- package/dist/reporting/tracking.d.cts +13 -8
- package/dist/reporting/tracking.d.cts.map +1 -1
- package/dist/reporting/tracking.d.mts +13 -8
- package/dist/reporting/tracking.d.mts.map +1 -1
- package/dist/reporting/tracking.mjs +29 -12
- package/dist/reporting/tracking.mjs.map +1 -1
- 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 +4 -5
- package/dist/store/facts.cjs.map +1 -1
- package/dist/store/facts.d.cts +2 -4
- package/dist/store/facts.d.cts.map +1 -1
- package/dist/store/facts.d.mts +2 -4
- package/dist/store/facts.d.mts.map +1 -1
- package/dist/store/facts.mjs +4 -5
- package/dist/store/facts.mjs.map +1 -1
- package/dist/store/index.cjs +2 -3
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +44 -15
- package/dist/store/index.d.cts.map +1 -1
- package/dist/store/index.d.mts +44 -15
- package/dist/store/index.d.mts.map +1 -1
- package/dist/store/index.mjs +2 -3
- package/dist/store/index.mjs.map +1 -1
- package/dist/store/postgres-reporting.cjs +31 -12
- package/dist/store/postgres-reporting.cjs.map +1 -1
- package/dist/store/postgres-reporting.d.cts +4 -4
- package/dist/store/postgres-reporting.d.cts.map +1 -1
- package/dist/store/postgres-reporting.d.mts +4 -4
- package/dist/store/postgres-reporting.d.mts.map +1 -1
- package/dist/store/postgres-reporting.mjs +31 -12
- package/dist/store/postgres-reporting.mjs.map +1 -1
- package/dist/store/postgres.cjs +40 -5
- package/dist/store/postgres.cjs.map +1 -1
- package/dist/store/postgres.d.cts +4 -4
- package/dist/store/postgres.d.cts.map +1 -1
- package/dist/store/postgres.d.mts +4 -4
- package/dist/store/postgres.d.mts.map +1 -1
- package/dist/store/postgres.mjs +41 -6
- 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 +76 -13
- package/dist/store/tables.cjs.map +1 -1
- package/dist/store/tables.d.cts +17 -3
- package/dist/store/tables.d.cts.map +1 -1
- package/dist/store/tables.d.mts +17 -3
- package/dist/store/tables.d.mts.map +1 -1
- package/dist/store/tables.mjs +75 -14
- package/dist/store/tables.mjs.map +1 -1
- 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 +61 -9
- package/dist/templates.cjs.map +1 -1
- package/dist/templates.d.cts +101 -15
- package/dist/templates.d.cts.map +1 -1
- package/dist/templates.d.mts +101 -15
- package/dist/templates.d.mts.map +1 -1
- package/dist/templates.mjs +62 -11
- package/dist/templates.mjs.map +1 -1
- package/dist/transports/cloudflare-email.cjs +1 -2
- package/dist/transports/cloudflare-email.d.cts +0 -2
- package/dist/transports/cloudflare-email.d.cts.map +1 -1
- package/dist/transports/cloudflare-email.d.mts +0 -2
- 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 -5
|
@@ -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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_http2_client = require("../http2-client.cjs");
|
|
3
3
|
const require_engine_retry = require("../engine/retry.cjs");
|
|
4
|
+
const require_host_ingest = require("../host/ingest.cjs");
|
|
4
5
|
const require_aws_engine_step = require("./engine-step.cjs");
|
|
5
6
|
const require_aws_function_url = require("./function-url.cjs");
|
|
6
7
|
const require_engine_duration = require("../engine/duration.cjs");
|
|
7
8
|
const require_host_fresh_read = require("../host/fresh-read.cjs");
|
|
8
|
-
const require_host_ingest = require("../host/ingest.cjs");
|
|
9
9
|
const require_host_execute = require("../host/execute.cjs");
|
|
10
10
|
const require_host_auth = require("../host/auth.cjs");
|
|
11
11
|
const require_host_journey_host = require("../host/journey-host.cjs");
|
|
@@ -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.
|
|
@@ -192,7 +192,6 @@ function journeyLambda(options) {
|
|
|
192
192
|
};
|
|
193
193
|
return { handler };
|
|
194
194
|
}
|
|
195
|
-
//#endregion
|
|
196
195
|
exports.AwsEngineStep = require_aws_engine_step.AwsEngineStep;
|
|
197
196
|
exports.AwsInstances = require_aws_instances.AwsInstances;
|
|
198
197
|
exports.RUN_EVENT_TYPE = require_aws_instances.RUN_EVENT_TYPE;
|
package/dist/aws/index.d.cts
CHANGED
|
@@ -7,7 +7,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
|
@@ -7,7 +7,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"}
|
package/dist/aws/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { http2Fetch } from "../http2-client.mjs";
|
|
2
2
|
import { PermanentError } from "../engine/retry.mjs";
|
|
3
|
+
import { sweepMaintenance, sweepSegmentsPaged } from "../host/ingest.mjs";
|
|
3
4
|
import { AwsEngineStep, stepRetry } from "./engine-step.mjs";
|
|
4
5
|
import { fromResponse, isFunctionUrlEvent, toRequest } from "./function-url.mjs";
|
|
5
6
|
import { longestJourneyMs } from "../engine/duration.mjs";
|
|
6
7
|
import { readWithRetry } from "../host/fresh-read.mjs";
|
|
7
|
-
import { sweepMaintenance, sweepSegmentsPaged } from "../host/ingest.mjs";
|
|
8
8
|
import { executeJourney } from "../host/execute.mjs";
|
|
9
9
|
import { bearerMatches, timingSafeEqual } from "../host/auth.mjs";
|
|
10
10
|
import { createJourneyHost } from "../host/journey-host.mjs";
|
|
@@ -12,7 +12,7 @@ import { AwsInstances, RUN_EVENT_TYPE, executionName, isRunInput } from "./insta
|
|
|
12
12
|
import { sdkLambdaApi } from "./lambda-api.mjs";
|
|
13
13
|
import { withDurableExecution } from "@aws/durable-execution-sdk-js";
|
|
14
14
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
15
|
-
|
|
15
|
+
// src/aws/index.ts
|
|
16
16
|
/**
|
|
17
17
|
* `@shware/workflow/aws` — the journey host as one Lambda durable function behind a Function
|
|
18
18
|
* URL, on Postgres.
|
|
@@ -191,7 +191,6 @@ function journeyLambda(options) {
|
|
|
191
191
|
};
|
|
192
192
|
return { handler };
|
|
193
193
|
}
|
|
194
|
-
//#endregion
|
|
195
194
|
export { AwsEngineStep, AwsInstances, RUN_EVENT_TYPE, SWEEP_EVENT_TYPE, bearerMatches, executionName, fromResponse, isFunctionUrlEvent, isRunInput, journeyLambda, sdkLambdaApi, stepRetry, timingSafeEqual, toRequest };
|
|
196
195
|
|
|
197
196
|
//# sourceMappingURL=index.mjs.map
|
package/dist/aws/instances.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_engine_bucket = require("../engine/bucket.cjs");
|
|
3
3
|
const require_host_platform = require("../host/platform.cjs");
|
|
4
|
-
|
|
4
|
+
// src/aws/instances.ts
|
|
5
5
|
/**
|
|
6
6
|
* The router's instance port over Lambda durable executions: an instance is one execution of
|
|
7
7
|
* this same function, started by an asynchronous self-invoke under a stable execution name;
|
|
@@ -210,7 +210,6 @@ var AwsInstances = class {
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
-
//#endregion
|
|
214
213
|
exports.AwsInstances = AwsInstances;
|
|
215
214
|
exports.RUN_EVENT_TYPE = RUN_EVENT_TYPE;
|
|
216
215
|
exports.executionName = executionName;
|
package/dist/aws/instances.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExecutionRegistry, ExecutionStart, JourneyStore } from "../store/index.cjs";
|
|
2
2
|
import { LambdaApi } from "./lambda-api.cjs";
|
|
3
3
|
import { JourneyParams, WorkflowBindingLike, WorkflowInstanceLike } from "../host/platform.cjs";
|
|
4
|
-
//#region src/aws/instances.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* The router's instance port over Lambda durable executions: an instance is one execution of
|
|
7
6
|
* this same function, started by an asynchronous self-invoke under a stable execution name;
|
|
@@ -100,5 +99,4 @@ export declare class AwsInstances implements WorkflowBindingLike {
|
|
|
100
99
|
private reconcile;
|
|
101
100
|
private instance;
|
|
102
101
|
}
|
|
103
|
-
//#endregion
|
|
104
102
|
//# sourceMappingURL=instances.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.d.cts","names":[],"sources":["../../src/aws/instances.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"instances.d.cts","names":[],"sources":["../../src/aws/instances.ts"],"mappings":";;;;;;;;;qBAsBa;iBAEI;EACf,aAAa;EACb;EACA,QAAQ;;EAER;;wBAGc,WAAW,iBAAiB,SAAS;;;;;;wBA0BrC,cAAc,oBAAoB;iBAQjC;EACf,OAAO;EACP,YAAY;EACZ,QAAQ;;;;;EAKR,OAAO,qBAAqB,mBAAmB;;;;;;EAM/C;;EAEA;;;;;;EAMA;EACA;;qBAKW,wBAAwB;mBAMN;mBALZ;mBACA;mBACA;mBACA;EAEjB,YAA6B,SAAS;;;;;;EAYhC,KAAK;IACT;IACA,QAAQ;IACR;IACA;MACE,QAAQ;EAeN,OAAO;IAAW;IAAY;MAAoB,QAAQ;EAS1D,IAAI,aAAa,QAAQ;EAQzB,OAAO;IAAS;IAAkB;MAAmB;EAMrD,YAAY;UA4BJ;;UAUA;UASA;;;;;UAWN;;UAKA;;;;;;;;;;UAaM;UAKA;UA0CN"}
|
package/dist/aws/instances.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExecutionRegistry, ExecutionStart, JourneyStore } from "../store/index.mjs";
|
|
2
2
|
import { LambdaApi } from "./lambda-api.mjs";
|
|
3
3
|
import { JourneyParams, WorkflowBindingLike, WorkflowInstanceLike } from "../host/platform.mjs";
|
|
4
|
-
//#region src/aws/instances.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* The router's instance port over Lambda durable executions: an instance is one execution of
|
|
7
6
|
* this same function, started by an asynchronous self-invoke under a stable execution name;
|
|
@@ -100,5 +99,4 @@ export declare class AwsInstances implements WorkflowBindingLike {
|
|
|
100
99
|
private reconcile;
|
|
101
100
|
private instance;
|
|
102
101
|
}
|
|
103
|
-
//#endregion
|
|
104
102
|
//# sourceMappingURL=instances.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.d.mts","names":[],"sources":["../../src/aws/instances.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"instances.d.mts","names":[],"sources":["../../src/aws/instances.ts"],"mappings":";;;;;;;;;qBAsBa;iBAEI;EACf,aAAa;EACb;EACA,QAAQ;;EAER;;wBAGc,WAAW,iBAAiB,SAAS;;;;;;wBA0BrC,cAAc,oBAAoB;iBAQjC;EACf,OAAO;EACP,YAAY;EACZ,QAAQ;;;;;EAKR,OAAO,qBAAqB,mBAAmB;;;;;;EAM/C;;EAEA;;;;;;EAMA;EACA;;qBAKW,wBAAwB;mBAMN;mBALZ;mBACA;mBACA;mBACA;EAEjB,YAA6B,SAAS;;;;;;EAYhC,KAAK;IACT;IACA,QAAQ;IACR;IACA;MACE,QAAQ;EAeN,OAAO;IAAW;IAAY;MAAoB,QAAQ;EAS1D,IAAI,aAAa,QAAQ;EAQzB,OAAO;IAAS;IAAkB;MAAmB;EAMrD,YAAY;UA4BJ;;UAUA;UASA;;;;;UAWN;;UAKA;;;;;;;;;;UAaM;UAKA;UA0CN"}
|
package/dist/aws/instances.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { murmur3 } from "../engine/bucket.mjs";
|
|
2
2
|
import { InstanceNotFoundError } from "../host/platform.mjs";
|
|
3
|
-
|
|
3
|
+
// src/aws/instances.ts
|
|
4
4
|
/**
|
|
5
5
|
* The router's instance port over Lambda durable executions: an instance is one execution of
|
|
6
6
|
* this same function, started by an asynchronous self-invoke under a stable execution name;
|
|
@@ -209,7 +209,6 @@ var AwsInstances = class {
|
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
|
-
//#endregion
|
|
213
212
|
export { AwsInstances, RUN_EVENT_TYPE, executionName, isRunInput };
|
|
214
213
|
|
|
215
214
|
//# sourceMappingURL=instances.mjs.map
|
package/dist/aws/lambda-api.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/aws/lambda-api.ts
|
|
3
3
|
const STATES = {
|
|
4
4
|
RUNNING: "running",
|
|
5
5
|
SUCCEEDED: "succeeded",
|
|
@@ -83,7 +83,6 @@ function sdkLambdaApi(options = {}) {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
//#endregion
|
|
87
86
|
exports.sdkLambdaApi = sdkLambdaApi;
|
|
88
87
|
|
|
89
88
|
//# sourceMappingURL=lambda-api.cjs.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as LambdaSdk from "@aws-sdk/client-lambda";
|
|
2
|
-
//#region src/aws/lambda-api.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The Lambda control-plane calls the adapter makes, as a port: starting an execution of this
|
|
5
4
|
* function, completing a wake callback, and looking at or stopping an execution. The default
|
|
@@ -38,6 +37,5 @@ export declare function sdkLambdaApi(options?: {
|
|
|
38
37
|
/** A configured client (endpoint, retries) instead of the default one. */
|
|
39
38
|
client?: Pick<InstanceType<Sdk['LambdaClient']>, 'send'>;
|
|
40
39
|
}): LambdaApi;
|
|
41
|
-
//#endregion
|
|
42
40
|
export {};
|
|
43
41
|
//# sourceMappingURL=lambda-api.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-api.d.cts","names":[],"sources":["../../src/aws/lambda-api.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambda-api.d.cts","names":[],"sources":["../../src/aws/lambda-api.ts"],"mappings":";;;;;;;YASY;iBAEK;;;;;EAKf,eAAe;IACb;IACA;IACA;MACE;IAAU;;;;;;EAKd,iBAAiB,oBAAoB,iBAAiB;;EAEtD,eAAe,cAAc,QAAQ;;EAErC,cAAc,gBAAgB,eAAe;;EAE7C,cAAc,cAAc;;KAoBzB,aAAa;;wBAGF,aACd;EACE;;EAEA,SAAS,KAAK,aAAa;IAE5B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as LambdaSdk from "@aws-sdk/client-lambda";
|
|
2
|
-
//#region src/aws/lambda-api.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The Lambda control-plane calls the adapter makes, as a port: starting an execution of this
|
|
5
4
|
* function, completing a wake callback, and looking at or stopping an execution. The default
|
|
@@ -38,6 +37,5 @@ export declare function sdkLambdaApi(options?: {
|
|
|
38
37
|
/** A configured client (endpoint, retries) instead of the default one. */
|
|
39
38
|
client?: Pick<InstanceType<Sdk['LambdaClient']>, 'send'>;
|
|
40
39
|
}): LambdaApi;
|
|
41
|
-
//#endregion
|
|
42
40
|
export {};
|
|
43
41
|
//# sourceMappingURL=lambda-api.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-api.d.mts","names":[],"sources":["../../src/aws/lambda-api.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambda-api.d.mts","names":[],"sources":["../../src/aws/lambda-api.ts"],"mappings":";;;;;;;YASY;iBAEK;;;;;EAKf,eAAe;IACb;IACA;IACA;MACE;IAAU;;;;;;EAKd,iBAAiB,oBAAoB,iBAAiB;;EAEtD,eAAe,cAAc,QAAQ;;EAErC,cAAc,gBAAgB,eAAe;;EAE7C,cAAc,cAAc;;KAoBzB,aAAa;;wBAGF,aACd;EACE;;EAEA,SAAS,KAAK,aAAa;IAE5B"}
|
package/dist/aws/lambda-api.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/aws/lambda-api.ts
|
|
2
2
|
const STATES = {
|
|
3
3
|
RUNNING: "running",
|
|
4
4
|
SUCCEEDED: "succeeded",
|
|
@@ -82,7 +82,6 @@ function sdkLambdaApi(options = {}) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
//#endregion
|
|
86
85
|
export { sdkLambdaApi };
|
|
87
86
|
|
|
88
87
|
//# sourceMappingURL=lambda-api.mjs.map
|
package/dist/client.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
const require_host_ingest = require("./host/ingest.cjs");
|
|
3
|
+
// src/client.ts
|
|
3
4
|
var JourneyClientError = class extends Error {
|
|
4
5
|
path;
|
|
5
6
|
status;
|
|
@@ -104,23 +105,62 @@ var JourneyClient = class {
|
|
|
104
105
|
removeDevice(token) {
|
|
105
106
|
return this.post("/devices/remove", { token });
|
|
106
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Where the user stands, topic × channel: for `email` and for `push`, `all` (false once they
|
|
110
|
+
* opted out of the whole channel) and each declared topic (false once they opted out of it on
|
|
111
|
+
* that channel) — the engine's record, which a preference page shows as it is. The two are
|
|
112
|
+
* independent flags: a topic answers its own opt-out even while `all` is false, so `all: false`
|
|
113
|
+
* masks every topic however they read (nothing is sent on the channel until it is true again).
|
|
114
|
+
* Rejects with a 410 for an erased user.
|
|
115
|
+
*/
|
|
116
|
+
getSubscriptions(userId) {
|
|
117
|
+
return this.request("GET", subscriptionsPath(userId));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set subscriptions: only what the patch names changes, per channel (`{ email: { topics: {
|
|
121
|
+
* newsletter: false } } }` opts out of one topic's emails, `{ push: { all: false } }` of every
|
|
122
|
+
* push — the in-app opt-out App Store Review Guideline 4.5.4 asks for). `all: true` clears the
|
|
123
|
+
* channel-wide opt-out only: a topic opted out on its own stays off until the patch names it,
|
|
124
|
+
* so a preference page's "subscribe to all" sends `all: true` plus every topic `true`. Answers
|
|
125
|
+
* the subscriptions as they now stand. With a contract, a topic it does not declare is refused
|
|
126
|
+
* here, before the request; the engine refuses it too.
|
|
127
|
+
*/
|
|
128
|
+
setSubscriptions(userId, patch) {
|
|
129
|
+
const contract = this.options.contract;
|
|
130
|
+
if (contract !== void 0) {
|
|
131
|
+
const issues = [];
|
|
132
|
+
for (const channel of require_host_ingest.SUBSCRIPTION_CHANNELS) for (const topic of Object.keys(patch[channel]?.topics ?? {})) {
|
|
133
|
+
if (contract.topics.includes(topic)) continue;
|
|
134
|
+
issues.push({
|
|
135
|
+
path: `${channel}.topics.${topic}`,
|
|
136
|
+
message: "not a declared topic"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (issues.length > 0) return Promise.reject(new JourneyValidationError("/subscriptions", void 0, issues));
|
|
140
|
+
}
|
|
141
|
+
return this.request("PUT", subscriptionsPath(userId), patch);
|
|
142
|
+
}
|
|
107
143
|
/** Deploy a compiled bundle (BundleIR). */
|
|
108
144
|
deploy(bundle) {
|
|
109
145
|
return this.post("/deploy", bundle);
|
|
110
146
|
}
|
|
111
|
-
|
|
112
|
-
|
|
147
|
+
post(path, body) {
|
|
148
|
+
return this.request("POST", path, body);
|
|
149
|
+
}
|
|
150
|
+
async request(method, path, body) {
|
|
151
|
+
const headers = {};
|
|
152
|
+
if (body !== void 0) headers["content-type"] = "application/json";
|
|
113
153
|
if (this.options.token !== void 0) headers.authorization = `Bearer ${this.options.token}`;
|
|
114
154
|
const response = await (this.options.fetch ?? fetch)(`${this.options.origin.replace(/\/$/, "")}${path}`, {
|
|
115
|
-
method
|
|
155
|
+
method,
|
|
116
156
|
headers,
|
|
117
|
-
body: JSON.stringify(body)
|
|
157
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
118
158
|
});
|
|
119
159
|
if (!response.ok) throw new JourneyClientError(path, response.status, await response.text());
|
|
120
160
|
return await response.json();
|
|
121
161
|
}
|
|
122
162
|
};
|
|
123
|
-
|
|
163
|
+
const subscriptionsPath = (userId) => `/subscriptions/${encodeURIComponent(userId)}`;
|
|
124
164
|
exports.JourneyClient = JourneyClient;
|
|
125
165
|
exports.JourneyClientError = JourneyClientError;
|
|
126
166
|
exports.JourneyValidationError = JourneyValidationError;
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type * as core from 'zod/v4/core';\nimport type { Contract, ContractIssue, ProfilePatch } from './contract';\nimport type { DeployResult, IdentifyResult, IngestResult } from './host/ingest';\nimport type { ProfileProps } from './store';\n\n/**\n * `@shware/workflow/client` — the producer side of the ingest API, for the\n * service that knows what users do (an api server, a webhook handler). Plain\n * fetch, no dependencies; errors carry the status and body so a caller can\n * log them without failing the request that triggered the report.\n */\n\nexport interface JourneyClientOptions<C extends Contract | undefined = undefined> {\n /**\n * The shared `defineContract(...)`: types `track` (the event name picks the\n * payload type) and `identify`, and checks both before anything is sent.\n */\n contract?: C;\n /** The journey Worker's origin, e.g. `https://workflow.example.com`. */\n origin: string;\n /** Its API_TOKEN, sent as a bearer; omit against an open local instance. */\n token?: string;\n /** Fetch implementation (defaults to the global one). */\n fetch?: typeof fetch;\n}\n\nexport class JourneyClientError extends Error {\n constructor(\n readonly path: string,\n readonly status: number,\n readonly body: string\n ) {\n super(`journey ${path} failed: ${status} ${body}`);\n this.name = 'JourneyClientError';\n }\n}\n\n/** A payload or profile patch the contract refuses — raised before the request, with the field paths. */\nexport class JourneyValidationError extends Error {\n constructor(\n readonly path: string,\n readonly event: string | undefined,\n readonly issues: ContractIssue[]\n ) {\n super(\n `journey ${path}${event === undefined ? '' : ` '${event}'`} refused by the contract: ${issues\n .map((i) => `${i.path || '(root)'} ${i.message}`)\n .join('; ')}`\n );\n this.name = 'JourneyValidationError';\n }\n}\n\ntype EventsOf<C> = C extends Contract<infer E> ? E : never;\n/** Event names: the contract's, or any string without one. */\nexport type ClientEventName<C> = [C] extends [undefined] ? string : keyof EventsOf<C> & string;\ntype TrackArgs<C, K> = [C] extends [undefined]\n ? [payload?: Record<string, unknown>, options?: TrackOptions]\n : K extends keyof EventsOf<C>\n ? [payload: core.input<EventsOf<C>[K]>, options?: TrackOptions]\n : never;\ntype IdentifyProps<C> = [C] extends [undefined]\n ? ProfileProps\n : C extends Contract<Record<string, core.$ZodObject>, infer P>\n ? ProfilePatch<P>\n : never;\n\nexport interface TrackOptions {\n /** The occurrence's identity: a retry with the same id is recorded once. */\n id?: string;\n /** When it happened (epoch ms); the Worker's clock when omitted. */\n ts?: number;\n}\n\nexport class JourneyClient<C extends Contract | undefined = undefined> {\n constructor(private readonly options: JourneyClientOptions<C>) {}\n\n /** Merge profile properties (`null` clears one). Every property a journey reads must be identified before the event that starts it. */\n identify(userId: string, props: IdentifyProps<C>): Promise<IdentifyResult> {\n const contract = this.options.contract;\n if (contract !== undefined) {\n const result = contract.parseProfilePatch(props);\n if (!result.ok)\n return Promise.reject(new JourneyValidationError('/identify', undefined, result.issues));\n }\n return this.post<IdentifyResult>('/identify', { userId, props });\n }\n\n /**\n * Record an event; the Worker starts every journey whose trigger matches it\n * and wakes waits on it. A caller that retries should pass the same `id`\n * each time: the Worker stores one occurrence per id, so a retry after a\n * timeout cannot double-count the event. `ts` defaults to the Worker's clock.\n */\n track<K extends ClientEventName<C>>(\n userId: string,\n event: K,\n ...args: TrackArgs<C, K>\n ): Promise<IngestResult> {\n const [payload = {}, options = {}] = args as [Record<string, unknown>?, TrackOptions?];\n const contract = this.options.contract;\n if (contract !== undefined) {\n const result = contract.parseEvent(event, payload);\n if (!result.ok)\n return Promise.reject(new JourneyValidationError('/events', event, result.issues));\n }\n return this.post<IngestResult>('/events', {\n userId,\n event,\n payload,\n ...(options.id === undefined ? {} : { id: options.id }),\n ...(options.ts === undefined ? {} : { ts: options.ts }),\n });\n }\n\n /**\n * A push token the app registered for the user (call it on every registration: a token moves\n * to the latest user). The engine keeps devices itself — pushes go to them, a token APNs / FCM\n * reports as gone is dropped — and journeys waiting on `reachable('push')` wake.\n */\n registerDevice(\n userId: string,\n device: { token: string; platform: 'ios' | 'android' | 'web'; ts?: number }\n ): Promise<{ ok: true; woke: number }> {\n const { token, platform, ts } = device;\n return this.post('/devices', {\n userId,\n token,\n platform,\n ...(ts === undefined ? {} : { ts }),\n });\n }\n\n /**\n * A journey push tapped open: the `message_id` the push carried, reported for the user who\n * tapped it. Recorded as a human open on the copy (an email's opens are tracked by the Worker).\n */\n messageOpened(userId: string, messageId: string): Promise<{ ok: true; recorded: boolean }> {\n return this.post('/messages/opened', { userId, messageId });\n }\n\n /**\n * A deleted account: the engine records the erasure, stops the user's running journeys, then\n * erases everything it keeps about them (profile, devices, events, reporting). Once this\n * resolves the request is durable: `erased: false` means an instance would not stop yet, and\n * the Worker's scheduled sweep finishes the job.\n */\n forgetUser(userId: string): Promise<{ ok: true; erased: boolean; pending: string[] }> {\n return this.post('/users/forget', { userId });\n }\n\n /** The user signed out on that device: the token stays registered, bound to nobody. */\n unbindDevice(token: string): Promise<{ ok: true; woke: number }> {\n return this.post('/devices/unbind', { token });\n }\n\n /** Forget a push token for good (an uninstall the app learned of, a token it replaced). */\n removeDevice(token: string): Promise<{ ok: true; woke: number }> {\n return this.post('/devices/remove', { token });\n }\n\n /** Deploy a compiled bundle (BundleIR). */\n deploy(bundle: unknown): Promise<DeployResult> {\n return this.post<DeployResult>('/deploy', bundle);\n }\n\n private async post<T>(path: string, body: unknown): Promise<T> {\n const headers: Record<string, string> = { 'content-type': 'application/json' };\n if (this.options.token !== undefined) headers.authorization = `Bearer ${this.options.token}`;\n const doFetch = this.options.fetch ?? fetch;\n const response = await doFetch(`${this.options.origin.replace(/\\/$/, '')}${path}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n });\n if (!response.ok) throw new JourneyClientError(path, response.status, await response.text());\n return (await response.json()) as T;\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["SUBSCRIPTION_CHANNELS"],"sources":["../src/client.ts"],"sourcesContent":["import type * as core from 'zod/v4/core';\nimport type { Contract, ContractIssue, ProfilePatch, Topic } from './contract';\nimport {\n type DeployResult,\n type IdentifyResult,\n type IngestResult,\n SUBSCRIPTION_CHANNELS,\n type Subscriptions,\n type SubscriptionsPatch,\n} from './host/ingest';\nimport type { ProfileProps } from './store';\n\n/**\n * `@shware/workflow/client` — the producer side of the ingest API, for the\n * service that knows what users do (an api server, a webhook handler). Plain\n * fetch, no dependencies; errors carry the status and body so a caller can\n * log them without failing the request that triggered the report.\n */\n\nexport interface JourneyClientOptions<C extends Contract | undefined = undefined> {\n /**\n * The shared `defineContract(...)`: types `track` (the event name picks the\n * payload type) and `identify`, and checks both before anything is sent.\n */\n contract?: C;\n /** The journey Worker's origin, e.g. `https://workflow.example.com`. */\n origin: string;\n /** Its API_TOKEN, sent as a bearer; omit against an open local instance. */\n token?: string;\n /** Fetch implementation (defaults to the global one). */\n fetch?: typeof fetch;\n}\n\nexport class JourneyClientError extends Error {\n constructor(\n readonly path: string,\n readonly status: number,\n readonly body: string\n ) {\n super(`journey ${path} failed: ${status} ${body}`);\n this.name = 'JourneyClientError';\n }\n}\n\n/** A payload or profile patch the contract refuses — raised before the request, with the field paths. */\nexport class JourneyValidationError extends Error {\n constructor(\n readonly path: string,\n readonly event: string | undefined,\n readonly issues: ContractIssue[]\n ) {\n super(\n `journey ${path}${event === undefined ? '' : ` '${event}'`} refused by the contract: ${issues\n .map((i) => `${i.path || '(root)'} ${i.message}`)\n .join('; ')}`\n );\n this.name = 'JourneyValidationError';\n }\n}\n\ntype EventsOf<C> = C extends Contract<infer E> ? E : never;\n/** Event names: the contract's, or any string without one. */\nexport type ClientEventName<C> = [C] extends [undefined] ? string : keyof EventsOf<C> & string;\ntype TrackArgs<C, K> = [C] extends [undefined]\n ? [payload?: Record<string, unknown>, options?: TrackOptions]\n : K extends keyof EventsOf<C>\n ? [payload: core.input<EventsOf<C>[K]>, options?: TrackOptions]\n : never;\ntype IdentifyProps<C> = [C] extends [undefined]\n ? ProfileProps\n : C extends Contract<Record<string, core.$ZodObject>, infer P>\n ? ProfilePatch<P>\n : never;\n\n/** The topics the client's contract declares; any string without a contract. */\nexport type ClientTopic<C> = [C] extends [undefined] ? string : Topic<C>;\n\nexport type {\n ChannelSubscriptions,\n ChannelSubscriptionsPatch,\n SubscriptionChannel,\n Subscriptions,\n SubscriptionsPatch,\n} from './host/ingest';\n\nexport interface TrackOptions {\n /** The occurrence's identity: a retry with the same id is recorded once. */\n id?: string;\n /** When it happened (epoch ms); the Worker's clock when omitted. */\n ts?: number;\n}\n\nexport class JourneyClient<C extends Contract | undefined = undefined> {\n constructor(private readonly options: JourneyClientOptions<C>) {}\n\n /** Merge profile properties (`null` clears one). Every property a journey reads must be identified before the event that starts it. */\n identify(userId: string, props: IdentifyProps<C>): Promise<IdentifyResult> {\n const contract = this.options.contract;\n if (contract !== undefined) {\n const result = contract.parseProfilePatch(props);\n if (!result.ok)\n return Promise.reject(new JourneyValidationError('/identify', undefined, result.issues));\n }\n return this.post<IdentifyResult>('/identify', { userId, props });\n }\n\n /**\n * Record an event; the Worker starts every journey whose trigger matches it\n * and wakes waits on it. A caller that retries should pass the same `id`\n * each time: the Worker stores one occurrence per id, so a retry after a\n * timeout cannot double-count the event. `ts` defaults to the Worker's clock.\n */\n track<K extends ClientEventName<C>>(\n userId: string,\n event: K,\n ...args: TrackArgs<C, K>\n ): Promise<IngestResult> {\n const [payload = {}, options = {}] = args as [Record<string, unknown>?, TrackOptions?];\n const contract = this.options.contract;\n if (contract !== undefined) {\n const result = contract.parseEvent(event, payload);\n if (!result.ok)\n return Promise.reject(new JourneyValidationError('/events', event, result.issues));\n }\n return this.post<IngestResult>('/events', {\n userId,\n event,\n payload,\n ...(options.id === undefined ? {} : { id: options.id }),\n ...(options.ts === undefined ? {} : { ts: options.ts }),\n });\n }\n\n /**\n * A push token the app registered for the user (call it on every registration: a token moves\n * to the latest user). The engine keeps devices itself — pushes go to them, a token APNs / FCM\n * reports as gone is dropped — and journeys waiting on `reachable('push')` wake.\n */\n registerDevice(\n userId: string,\n device: { token: string; platform: 'ios' | 'android' | 'web'; ts?: number }\n ): Promise<{ ok: true; woke: number }> {\n const { token, platform, ts } = device;\n return this.post('/devices', {\n userId,\n token,\n platform,\n ...(ts === undefined ? {} : { ts }),\n });\n }\n\n /**\n * A journey push tapped open: the `message_id` the push carried, reported for the user who\n * tapped it. Recorded as a human open on the copy (an email's opens are tracked by the Worker).\n */\n messageOpened(userId: string, messageId: string): Promise<{ ok: true; recorded: boolean }> {\n return this.post('/messages/opened', { userId, messageId });\n }\n\n /**\n * A deleted account: the engine records the erasure, stops the user's running journeys, then\n * erases everything it keeps about them (profile, devices, events, reporting). Once this\n * resolves the request is durable: `erased: false` means an instance would not stop yet, and\n * the Worker's scheduled sweep finishes the job.\n */\n forgetUser(userId: string): Promise<{ ok: true; erased: boolean; pending: string[] }> {\n return this.post('/users/forget', { userId });\n }\n\n /** The user signed out on that device: the token stays registered, bound to nobody. */\n unbindDevice(token: string): Promise<{ ok: true; woke: number }> {\n return this.post('/devices/unbind', { token });\n }\n\n /** Forget a push token for good (an uninstall the app learned of, a token it replaced). */\n removeDevice(token: string): Promise<{ ok: true; woke: number }> {\n return this.post('/devices/remove', { token });\n }\n\n /**\n * Where the user stands, topic × channel: for `email` and for `push`, `all` (false once they\n * opted out of the whole channel) and each declared topic (false once they opted out of it on\n * that channel) — the engine's record, which a preference page shows as it is. The two are\n * independent flags: a topic answers its own opt-out even while `all` is false, so `all: false`\n * masks every topic however they read (nothing is sent on the channel until it is true again).\n * Rejects with a 410 for an erased user.\n */\n getSubscriptions(userId: string): Promise<Subscriptions<ClientTopic<C>>> {\n return this.request('GET', subscriptionsPath(userId));\n }\n\n /**\n * Set subscriptions: only what the patch names changes, per channel (`{ email: { topics: {\n * newsletter: false } } }` opts out of one topic's emails, `{ push: { all: false } }` of every\n * push — the in-app opt-out App Store Review Guideline 4.5.4 asks for). `all: true` clears the\n * channel-wide opt-out only: a topic opted out on its own stays off until the patch names it,\n * so a preference page's \"subscribe to all\" sends `all: true` plus every topic `true`. Answers\n * the subscriptions as they now stand. With a contract, a topic it does not declare is refused\n * here, before the request; the engine refuses it too.\n */\n setSubscriptions(\n userId: string,\n patch: SubscriptionsPatch<ClientTopic<C>>\n ): Promise<Subscriptions<ClientTopic<C>>> {\n const contract = this.options.contract;\n if (contract !== undefined) {\n const issues: ContractIssue[] = [];\n for (const channel of SUBSCRIPTION_CHANNELS) {\n for (const topic of Object.keys(patch[channel]?.topics ?? {})) {\n // `includes`, not the predicate: narrowing `string` by a `topic is string` leaves `never`\n if (contract.topics.includes(topic)) continue;\n issues.push({ path: `${channel}.topics.${topic}`, message: 'not a declared topic' });\n }\n }\n if (issues.length > 0) {\n return Promise.reject(new JourneyValidationError('/subscriptions', undefined, issues));\n }\n }\n return this.request('PUT', subscriptionsPath(userId), patch);\n }\n\n /** Deploy a compiled bundle (BundleIR). */\n deploy(bundle: unknown): Promise<DeployResult> {\n return this.post<DeployResult>('/deploy', bundle);\n }\n\n private post<T>(path: string, body: unknown): Promise<T> {\n return this.request<T>('POST', path, body);\n }\n\n private async request<T>(\n method: 'GET' | 'POST' | 'PUT',\n path: string,\n body?: unknown\n ): Promise<T> {\n const headers: Record<string, string> = {};\n if (body !== undefined) headers['content-type'] = 'application/json';\n if (this.options.token !== undefined) headers.authorization = `Bearer ${this.options.token}`;\n const doFetch = this.options.fetch ?? fetch;\n const response = await doFetch(`${this.options.origin.replace(/\\/$/, '')}${path}`, {\n method,\n headers,\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n });\n if (!response.ok) throw new JourneyClientError(path, response.status, await response.text());\n return (await response.json()) as T;\n }\n}\n\nconst subscriptionsPath = (userId: string) => `/subscriptions/${encodeURIComponent(userId)}`;\n"],"mappings":"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"}
|
package/dist/client.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { Contract, ContractIssue, ProfilePatch, Topic } from "./contract.cjs";
|
|
1
2
|
import { ProfileProps } from "./store/index.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import { DeployResult, IdentifyResult, IngestResult } from "./host/ingest.cjs";
|
|
3
|
+
import { ChannelSubscriptions, ChannelSubscriptionsPatch, DeployResult, IdentifyResult, IngestResult, SubscriptionChannel, Subscriptions, SubscriptionsPatch } from "./host/ingest.cjs";
|
|
4
4
|
import * as core from "zod/v4/core";
|
|
5
|
-
//#region src/client.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* `@shware/workflow/client` — the producer side of the ingest API, for the
|
|
8
7
|
* service that knows what users do (an api server, a webhook handler). Plain
|
|
@@ -40,6 +39,8 @@ type EventsOf<C> = C extends Contract<infer E> ? E : never;
|
|
|
40
39
|
export type ClientEventName<C> = [C] extends [undefined] ? string : keyof EventsOf<C> & string;
|
|
41
40
|
type TrackArgs<C, K> = [C] extends [undefined] ? [payload?: Record<string, unknown>, options?: TrackOptions] : K extends keyof EventsOf<C> ? [payload: core.input<EventsOf<C>[K]>, options?: TrackOptions] : never;
|
|
42
41
|
type IdentifyProps<C> = [C] extends [undefined] ? ProfileProps : C extends Contract<Record<string, core.$ZodObject>, infer P> ? ProfilePatch<P> : never;
|
|
42
|
+
/** The topics the client's contract declares; any string without a contract. */
|
|
43
|
+
export type ClientTopic<C> = [C] extends [undefined] ? string : Topic<C>;
|
|
43
44
|
export interface TrackOptions {
|
|
44
45
|
/** The occurrence's identity: a retry with the same id is recorded once. */
|
|
45
46
|
id?: string;
|
|
@@ -100,10 +101,29 @@ export declare class JourneyClient<C extends Contract | undefined = undefined> {
|
|
|
100
101
|
ok: true;
|
|
101
102
|
woke: number;
|
|
102
103
|
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Where the user stands, topic × channel: for `email` and for `push`, `all` (false once they
|
|
106
|
+
* opted out of the whole channel) and each declared topic (false once they opted out of it on
|
|
107
|
+
* that channel) — the engine's record, which a preference page shows as it is. The two are
|
|
108
|
+
* independent flags: a topic answers its own opt-out even while `all` is false, so `all: false`
|
|
109
|
+
* masks every topic however they read (nothing is sent on the channel until it is true again).
|
|
110
|
+
* Rejects with a 410 for an erased user.
|
|
111
|
+
*/
|
|
112
|
+
getSubscriptions(userId: string): Promise<Subscriptions<ClientTopic<C>>>;
|
|
113
|
+
/**
|
|
114
|
+
* Set subscriptions: only what the patch names changes, per channel (`{ email: { topics: {
|
|
115
|
+
* newsletter: false } } }` opts out of one topic's emails, `{ push: { all: false } }` of every
|
|
116
|
+
* push — the in-app opt-out App Store Review Guideline 4.5.4 asks for). `all: true` clears the
|
|
117
|
+
* channel-wide opt-out only: a topic opted out on its own stays off until the patch names it,
|
|
118
|
+
* so a preference page's "subscribe to all" sends `all: true` plus every topic `true`. Answers
|
|
119
|
+
* the subscriptions as they now stand. With a contract, a topic it does not declare is refused
|
|
120
|
+
* here, before the request; the engine refuses it too.
|
|
121
|
+
*/
|
|
122
|
+
setSubscriptions(userId: string, patch: SubscriptionsPatch<ClientTopic<C>>): Promise<Subscriptions<ClientTopic<C>>>;
|
|
103
123
|
/** Deploy a compiled bundle (BundleIR). */
|
|
104
124
|
deploy(bundle: unknown): Promise<DeployResult>;
|
|
105
125
|
private post;
|
|
126
|
+
private request;
|
|
106
127
|
}
|
|
107
|
-
|
|
108
|
-
export {};
|
|
128
|
+
export type { ChannelSubscriptions, ChannelSubscriptionsPatch, SubscriptionChannel, Subscriptions, SubscriptionsPatch };
|
|
109
129
|
//# sourceMappingURL=client.d.cts.map
|
package/dist/client.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;iBAmBiB,qBAAqB,UAAU;;;;;EAK9C,WAAW;;EAEX;;EAEA;;EAEA,eAAe;;qBAGJ,2BAA2B;WAE3B;WACA;WACA;EAHX,YACW,cACA,gBACA;;;qBAQA,+BAA+B;WAE/B;WACA;WACA,QAAQ;EAHnB,YACW,cACA,2BACA,QAAQ;;KAWhB,SAAS,KAAK,UAAU,eAAe,KAAK;;YAErC,gBAAgB,MAAM,wCAAwC,SAAS;KAC9E,UAAU,GAAG,MAAM,0BACnB,UAAU,yBAAyB,UAAU,gBAC9C,gBAAgB,SAAS,MACtB,SAAS,KAAK,MAAM,SAAS,GAAG,KAAK,UAAU;KAEjD,cAAc,MAAM,yBACrB,eACA,UAAU,SAAS,eAAe,KAAK,mBAAmB,KACxD,aAAa;;YAIP,YAAY,MAAM,kCAAkC,MAAM;iBAUrD;;EAEf;;EAEA;;qBAGW,cAAc,UAAU;mBACN;EAA7B,YAA6B,SAAS,qBAAqB;;EAG3D,SAAS,gBAAgB,OAAO,cAAc,KAAK,QAAQ;;;;;;;EAgB3D,MAAM,UAAU,gBAAgB,IAC9B,gBACA,OAAO,MACJ,MAAM,UAAU,GAAG,KACrB,QAAQ;;;;;;EAsBX,eACE,gBACA;IAAU;IAAe;IAAqC;MAC7D;IAAU;IAAU;;;;;;EAcvB,cAAc,gBAAgB,oBAAoB;IAAU;IAAU;;;;;;;;EAUtE,WAAW,iBAAiB;IAAU;IAAU;IAAiB;;;EAKjE,aAAa,gBAAgB;IAAU;IAAU;;;EAKjD,aAAa,gBAAgB;IAAU;IAAU;;;;;;;;;;EAYjD,iBAAiB,iBAAiB,QAAQ,cAAc,YAAY;;;;;;;;;;EAapE,iBACE,gBACA,OAAO,mBAAmB,YAAY,MACrC,QAAQ,cAAc,YAAY;;EAmBrC,OAAO,kBAAkB,QAAQ;UAIzB;UAIM"}
|
package/dist/client.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { Contract, ContractIssue, ProfilePatch, Topic } from "./contract.mjs";
|
|
1
2
|
import { ProfileProps } from "./store/index.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { DeployResult, IdentifyResult, IngestResult } from "./host/ingest.mjs";
|
|
3
|
+
import { ChannelSubscriptions, ChannelSubscriptionsPatch, DeployResult, IdentifyResult, IngestResult, SubscriptionChannel, Subscriptions, SubscriptionsPatch } from "./host/ingest.mjs";
|
|
4
4
|
import * as core from "zod/v4/core";
|
|
5
|
-
//#region src/client.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* `@shware/workflow/client` — the producer side of the ingest API, for the
|
|
8
7
|
* service that knows what users do (an api server, a webhook handler). Plain
|
|
@@ -40,6 +39,8 @@ type EventsOf<C> = C extends Contract<infer E> ? E : never;
|
|
|
40
39
|
export type ClientEventName<C> = [C] extends [undefined] ? string : keyof EventsOf<C> & string;
|
|
41
40
|
type TrackArgs<C, K> = [C] extends [undefined] ? [payload?: Record<string, unknown>, options?: TrackOptions] : K extends keyof EventsOf<C> ? [payload: core.input<EventsOf<C>[K]>, options?: TrackOptions] : never;
|
|
42
41
|
type IdentifyProps<C> = [C] extends [undefined] ? ProfileProps : C extends Contract<Record<string, core.$ZodObject>, infer P> ? ProfilePatch<P> : never;
|
|
42
|
+
/** The topics the client's contract declares; any string without a contract. */
|
|
43
|
+
export type ClientTopic<C> = [C] extends [undefined] ? string : Topic<C>;
|
|
43
44
|
export interface TrackOptions {
|
|
44
45
|
/** The occurrence's identity: a retry with the same id is recorded once. */
|
|
45
46
|
id?: string;
|
|
@@ -100,10 +101,29 @@ export declare class JourneyClient<C extends Contract | undefined = undefined> {
|
|
|
100
101
|
ok: true;
|
|
101
102
|
woke: number;
|
|
102
103
|
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Where the user stands, topic × channel: for `email` and for `push`, `all` (false once they
|
|
106
|
+
* opted out of the whole channel) and each declared topic (false once they opted out of it on
|
|
107
|
+
* that channel) — the engine's record, which a preference page shows as it is. The two are
|
|
108
|
+
* independent flags: a topic answers its own opt-out even while `all` is false, so `all: false`
|
|
109
|
+
* masks every topic however they read (nothing is sent on the channel until it is true again).
|
|
110
|
+
* Rejects with a 410 for an erased user.
|
|
111
|
+
*/
|
|
112
|
+
getSubscriptions(userId: string): Promise<Subscriptions<ClientTopic<C>>>;
|
|
113
|
+
/**
|
|
114
|
+
* Set subscriptions: only what the patch names changes, per channel (`{ email: { topics: {
|
|
115
|
+
* newsletter: false } } }` opts out of one topic's emails, `{ push: { all: false } }` of every
|
|
116
|
+
* push — the in-app opt-out App Store Review Guideline 4.5.4 asks for). `all: true` clears the
|
|
117
|
+
* channel-wide opt-out only: a topic opted out on its own stays off until the patch names it,
|
|
118
|
+
* so a preference page's "subscribe to all" sends `all: true` plus every topic `true`. Answers
|
|
119
|
+
* the subscriptions as they now stand. With a contract, a topic it does not declare is refused
|
|
120
|
+
* here, before the request; the engine refuses it too.
|
|
121
|
+
*/
|
|
122
|
+
setSubscriptions(userId: string, patch: SubscriptionsPatch<ClientTopic<C>>): Promise<Subscriptions<ClientTopic<C>>>;
|
|
103
123
|
/** Deploy a compiled bundle (BundleIR). */
|
|
104
124
|
deploy(bundle: unknown): Promise<DeployResult>;
|
|
105
125
|
private post;
|
|
126
|
+
private request;
|
|
106
127
|
}
|
|
107
|
-
|
|
108
|
-
export {};
|
|
128
|
+
export type { ChannelSubscriptions, ChannelSubscriptionsPatch, SubscriptionChannel, Subscriptions, SubscriptionsPatch };
|
|
109
129
|
//# sourceMappingURL=client.d.mts.map
|
package/dist/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;iBAmBiB,qBAAqB,UAAU;;;;;EAK9C,WAAW;;EAEX;;EAEA;;EAEA,eAAe;;qBAGJ,2BAA2B;WAE3B;WACA;WACA;EAHX,YACW,cACA,gBACA;;;qBAQA,+BAA+B;WAE/B;WACA;WACA,QAAQ;EAHnB,YACW,cACA,2BACA,QAAQ;;KAWhB,SAAS,KAAK,UAAU,eAAe,KAAK;;YAErC,gBAAgB,MAAM,wCAAwC,SAAS;KAC9E,UAAU,GAAG,MAAM,0BACnB,UAAU,yBAAyB,UAAU,gBAC9C,gBAAgB,SAAS,MACtB,SAAS,KAAK,MAAM,SAAS,GAAG,KAAK,UAAU;KAEjD,cAAc,MAAM,yBACrB,eACA,UAAU,SAAS,eAAe,KAAK,mBAAmB,KACxD,aAAa;;YAIP,YAAY,MAAM,kCAAkC,MAAM;iBAUrD;;EAEf;;EAEA;;qBAGW,cAAc,UAAU;mBACN;EAA7B,YAA6B,SAAS,qBAAqB;;EAG3D,SAAS,gBAAgB,OAAO,cAAc,KAAK,QAAQ;;;;;;;EAgB3D,MAAM,UAAU,gBAAgB,IAC9B,gBACA,OAAO,MACJ,MAAM,UAAU,GAAG,KACrB,QAAQ;;;;;;EAsBX,eACE,gBACA;IAAU;IAAe;IAAqC;MAC7D;IAAU;IAAU;;;;;;EAcvB,cAAc,gBAAgB,oBAAoB;IAAU;IAAU;;;;;;;;EAUtE,WAAW,iBAAiB;IAAU;IAAU;IAAiB;;;EAKjE,aAAa,gBAAgB;IAAU;IAAU;;;EAKjD,aAAa,gBAAgB;IAAU;IAAU;;;;;;;;;;EAYjD,iBAAiB,iBAAiB,QAAQ,cAAc,YAAY;;;;;;;;;;EAapE,iBACE,gBACA,OAAO,mBAAmB,YAAY,MACrC,QAAQ,cAAc,YAAY;;EAmBrC,OAAO,kBAAkB,QAAQ;UAIzB;UAIM"}
|
package/dist/client.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { SUBSCRIPTION_CHANNELS } from "./host/ingest.mjs";
|
|
2
|
+
// src/client.ts
|
|
2
3
|
var JourneyClientError = class extends Error {
|
|
3
4
|
path;
|
|
4
5
|
status;
|
|
@@ -103,23 +104,62 @@ var JourneyClient = class {
|
|
|
103
104
|
removeDevice(token) {
|
|
104
105
|
return this.post("/devices/remove", { token });
|
|
105
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Where the user stands, topic × channel: for `email` and for `push`, `all` (false once they
|
|
109
|
+
* opted out of the whole channel) and each declared topic (false once they opted out of it on
|
|
110
|
+
* that channel) — the engine's record, which a preference page shows as it is. The two are
|
|
111
|
+
* independent flags: a topic answers its own opt-out even while `all` is false, so `all: false`
|
|
112
|
+
* masks every topic however they read (nothing is sent on the channel until it is true again).
|
|
113
|
+
* Rejects with a 410 for an erased user.
|
|
114
|
+
*/
|
|
115
|
+
getSubscriptions(userId) {
|
|
116
|
+
return this.request("GET", subscriptionsPath(userId));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set subscriptions: only what the patch names changes, per channel (`{ email: { topics: {
|
|
120
|
+
* newsletter: false } } }` opts out of one topic's emails, `{ push: { all: false } }` of every
|
|
121
|
+
* push — the in-app opt-out App Store Review Guideline 4.5.4 asks for). `all: true` clears the
|
|
122
|
+
* channel-wide opt-out only: a topic opted out on its own stays off until the patch names it,
|
|
123
|
+
* so a preference page's "subscribe to all" sends `all: true` plus every topic `true`. Answers
|
|
124
|
+
* the subscriptions as they now stand. With a contract, a topic it does not declare is refused
|
|
125
|
+
* here, before the request; the engine refuses it too.
|
|
126
|
+
*/
|
|
127
|
+
setSubscriptions(userId, patch) {
|
|
128
|
+
const contract = this.options.contract;
|
|
129
|
+
if (contract !== void 0) {
|
|
130
|
+
const issues = [];
|
|
131
|
+
for (const channel of SUBSCRIPTION_CHANNELS) for (const topic of Object.keys(patch[channel]?.topics ?? {})) {
|
|
132
|
+
if (contract.topics.includes(topic)) continue;
|
|
133
|
+
issues.push({
|
|
134
|
+
path: `${channel}.topics.${topic}`,
|
|
135
|
+
message: "not a declared topic"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (issues.length > 0) return Promise.reject(new JourneyValidationError("/subscriptions", void 0, issues));
|
|
139
|
+
}
|
|
140
|
+
return this.request("PUT", subscriptionsPath(userId), patch);
|
|
141
|
+
}
|
|
106
142
|
/** Deploy a compiled bundle (BundleIR). */
|
|
107
143
|
deploy(bundle) {
|
|
108
144
|
return this.post("/deploy", bundle);
|
|
109
145
|
}
|
|
110
|
-
|
|
111
|
-
|
|
146
|
+
post(path, body) {
|
|
147
|
+
return this.request("POST", path, body);
|
|
148
|
+
}
|
|
149
|
+
async request(method, path, body) {
|
|
150
|
+
const headers = {};
|
|
151
|
+
if (body !== void 0) headers["content-type"] = "application/json";
|
|
112
152
|
if (this.options.token !== void 0) headers.authorization = `Bearer ${this.options.token}`;
|
|
113
153
|
const response = await (this.options.fetch ?? fetch)(`${this.options.origin.replace(/\/$/, "")}${path}`, {
|
|
114
|
-
method
|
|
154
|
+
method,
|
|
115
155
|
headers,
|
|
116
|
-
body: JSON.stringify(body)
|
|
156
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
117
157
|
});
|
|
118
158
|
if (!response.ok) throw new JourneyClientError(path, response.status, await response.text());
|
|
119
159
|
return await response.json();
|
|
120
160
|
}
|
|
121
161
|
};
|
|
122
|
-
|
|
162
|
+
const subscriptionsPath = (userId) => `/subscriptions/${encodeURIComponent(userId)}`;
|
|
123
163
|
export { JourneyClient, JourneyClientError, JourneyValidationError };
|
|
124
164
|
|
|
125
165
|
//# sourceMappingURL=client.mjs.map
|