@shware/workflow 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +154 -2
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/apns-relay.cjs +105 -0
- package/dist/apns-relay.cjs.map +1 -0
- package/dist/apns-relay.d.cts +28 -0
- package/dist/apns-relay.d.cts.map +1 -0
- package/dist/apns-relay.d.mts +28 -0
- package/dist/apns-relay.d.mts.map +1 -0
- package/dist/apns-relay.mjs +104 -0
- package/dist/apns-relay.mjs.map +1 -0
- package/dist/apns.cjs +121 -0
- package/dist/apns.cjs.map +1 -0
- package/dist/apns.d.cts +63 -0
- package/dist/apns.d.cts.map +1 -0
- package/dist/apns.d.mts +63 -0
- package/dist/apns.d.mts.map +1 -0
- package/dist/apns.mjs +116 -0
- package/dist/apns.mjs.map +1 -0
- package/dist/client.cjs +125 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +108 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +108 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +122 -0
- package/dist/client.mjs.map +1 -0
- package/dist/cloudflare/bindings.cjs +28 -0
- package/dist/cloudflare/bindings.cjs.map +1 -0
- package/dist/cloudflare/bindings.d.cts +144 -0
- package/dist/cloudflare/bindings.d.cts.map +1 -0
- package/dist/cloudflare/bindings.d.mts +144 -0
- package/dist/cloudflare/bindings.d.mts.map +1 -0
- package/dist/cloudflare/bindings.mjs +25 -0
- package/dist/cloudflare/bindings.mjs.map +1 -0
- package/dist/cloudflare/channels.cjs +164 -0
- package/dist/cloudflare/channels.cjs.map +1 -0
- package/dist/cloudflare/channels.d.cts +29 -0
- package/dist/cloudflare/channels.d.cts.map +1 -0
- package/dist/cloudflare/channels.d.mts +29 -0
- package/dist/cloudflare/channels.d.mts.map +1 -0
- package/dist/cloudflare/channels.mjs +161 -0
- package/dist/cloudflare/channels.mjs.map +1 -0
- package/dist/cloudflare/d1-env.cjs +17 -0
- package/dist/cloudflare/d1-env.cjs.map +1 -0
- package/dist/cloudflare/d1-env.d.cts +12 -0
- package/dist/cloudflare/d1-env.d.cts.map +1 -0
- package/dist/cloudflare/d1-env.d.mts +12 -0
- package/dist/cloudflare/d1-env.d.mts.map +1 -0
- package/dist/cloudflare/d1-env.mjs +16 -0
- package/dist/cloudflare/d1-env.mjs.map +1 -0
- package/dist/cloudflare/index.cjs +54 -0
- package/dist/cloudflare/index.d.cts +19 -0
- package/dist/cloudflare/index.d.mts +19 -0
- package/dist/cloudflare/index.mjs +16 -0
- package/dist/cloudflare/router.cjs +516 -0
- package/dist/cloudflare/router.cjs.map +1 -0
- package/dist/cloudflare/router.d.cts +157 -0
- package/dist/cloudflare/router.d.cts.map +1 -0
- package/dist/cloudflare/router.d.mts +157 -0
- package/dist/cloudflare/router.d.mts.map +1 -0
- package/dist/cloudflare/router.mjs +503 -0
- package/dist/cloudflare/router.mjs.map +1 -0
- package/dist/cloudflare/runner.cjs +225 -0
- package/dist/cloudflare/runner.cjs.map +1 -0
- package/dist/cloudflare/runner.d.cts +73 -0
- package/dist/cloudflare/runner.d.cts.map +1 -0
- package/dist/cloudflare/runner.d.mts +73 -0
- package/dist/cloudflare/runner.d.mts.map +1 -0
- package/dist/cloudflare/runner.mjs +224 -0
- package/dist/cloudflare/runner.mjs.map +1 -0
- package/dist/cloudflare/schema.sql +127 -0
- package/dist/cloudflare/senders.cjs +114 -0
- package/dist/cloudflare/senders.cjs.map +1 -0
- package/dist/cloudflare/senders.d.cts +68 -0
- package/dist/cloudflare/senders.d.cts.map +1 -0
- package/dist/cloudflare/senders.d.mts +68 -0
- package/dist/cloudflare/senders.d.mts.map +1 -0
- package/dist/cloudflare/senders.mjs +108 -0
- package/dist/cloudflare/senders.mjs.map +1 -0
- package/dist/cloudflare/worker.cjs +228 -0
- package/dist/cloudflare/worker.cjs.map +1 -0
- package/dist/cloudflare/worker.d.cts +92 -0
- package/dist/cloudflare/worker.d.cts.map +1 -0
- package/dist/cloudflare/worker.d.mts +92 -0
- package/dist/cloudflare/worker.d.mts.map +1 -0
- package/dist/cloudflare/worker.mjs +224 -0
- package/dist/cloudflare/worker.mjs.map +1 -0
- package/dist/cloudflare/workers.d.cjs +0 -0
- package/dist/cloudflare/workers.d.cts +44 -0
- package/dist/cloudflare/workers.d.cts.map +1 -0
- package/dist/cloudflare/workers.d.mts +44 -0
- package/dist/cloudflare/workers.d.mts.map +1 -0
- package/dist/config.cjs +151 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +149 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +149 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +143 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract.cjs +212 -0
- package/dist/contract.cjs.map +1 -0
- package/dist/contract.d.cts +90 -0
- package/dist/contract.d.cts.map +1 -0
- package/dist/contract.d.mts +90 -0
- package/dist/contract.d.mts.map +1 -0
- package/dist/contract.mjs +206 -0
- package/dist/contract.mjs.map +1 -0
- package/dist/dsl/action.cjs +29 -0
- package/dist/dsl/action.cjs.map +1 -0
- package/dist/dsl/action.d.cts +64 -0
- package/dist/dsl/action.d.cts.map +1 -0
- package/dist/dsl/action.d.mts +64 -0
- package/dist/dsl/action.d.mts.map +1 -0
- package/dist/dsl/action.mjs +28 -0
- package/dist/dsl/action.mjs.map +1 -0
- package/dist/dsl/base.cjs +34 -0
- package/dist/dsl/base.cjs.map +1 -0
- package/dist/dsl/base.d.cts +45 -0
- package/dist/dsl/base.d.cts.map +1 -0
- package/dist/dsl/base.d.mts +45 -0
- package/dist/dsl/base.d.mts.map +1 -0
- package/dist/dsl/base.mjs +30 -0
- package/dist/dsl/base.mjs.map +1 -0
- package/dist/dsl/bundle.cjs +207 -0
- package/dist/dsl/bundle.cjs.map +1 -0
- package/dist/dsl/bundle.d.cts +19 -0
- package/dist/dsl/bundle.d.cts.map +1 -0
- package/dist/dsl/bundle.d.mts +19 -0
- package/dist/dsl/bundle.d.mts.map +1 -0
- package/dist/dsl/bundle.mjs +206 -0
- package/dist/dsl/bundle.mjs.map +1 -0
- package/dist/dsl/condition.cjs +177 -0
- package/dist/dsl/condition.cjs.map +1 -0
- package/dist/dsl/condition.d.cts +140 -0
- package/dist/dsl/condition.d.cts.map +1 -0
- package/dist/dsl/condition.d.mts +140 -0
- package/dist/dsl/condition.d.mts.map +1 -0
- package/dist/dsl/condition.mjs +156 -0
- package/dist/dsl/condition.mjs.map +1 -0
- package/dist/dsl/flow.cjs +228 -0
- package/dist/dsl/flow.cjs.map +1 -0
- package/dist/dsl/flow.d.cts +223 -0
- package/dist/dsl/flow.d.cts.map +1 -0
- package/dist/dsl/flow.d.mts +223 -0
- package/dist/dsl/flow.d.mts.map +1 -0
- package/dist/dsl/flow.mjs +226 -0
- package/dist/dsl/flow.mjs.map +1 -0
- package/dist/dsl/index.cjs +38 -0
- package/dist/dsl/index.d.cts +10 -0
- package/dist/dsl/index.d.mts +10 -0
- package/dist/dsl/index.mjs +9 -0
- package/dist/dsl/refs.cjs +59 -0
- package/dist/dsl/refs.cjs.map +1 -0
- package/dist/dsl/refs.d.cts +88 -0
- package/dist/dsl/refs.d.cts.map +1 -0
- package/dist/dsl/refs.d.mts +88 -0
- package/dist/dsl/refs.d.mts.map +1 -0
- package/dist/dsl/refs.mjs +55 -0
- package/dist/dsl/refs.mjs.map +1 -0
- package/dist/dsl/template.cjs +65 -0
- package/dist/dsl/template.cjs.map +1 -0
- package/dist/dsl/template.d.cts +75 -0
- package/dist/dsl/template.d.cts.map +1 -0
- package/dist/dsl/template.d.mts +75 -0
- package/dist/dsl/template.d.mts.map +1 -0
- package/dist/dsl/template.mjs +63 -0
- package/dist/dsl/template.mjs.map +1 -0
- package/dist/dsl/trigger.cjs +40 -0
- package/dist/dsl/trigger.cjs.map +1 -0
- package/dist/dsl/trigger.d.cts +65 -0
- package/dist/dsl/trigger.d.cts.map +1 -0
- package/dist/dsl/trigger.d.mts +65 -0
- package/dist/dsl/trigger.d.mts.map +1 -0
- package/dist/dsl/trigger.mjs +39 -0
- package/dist/dsl/trigger.mjs.map +1 -0
- package/dist/dsl/workflow.cjs +121 -0
- package/dist/dsl/workflow.cjs.map +1 -0
- package/dist/dsl/workflow.d.cts +59 -0
- package/dist/dsl/workflow.d.cts.map +1 -0
- package/dist/dsl/workflow.d.mts +59 -0
- package/dist/dsl/workflow.d.mts.map +1 -0
- package/dist/dsl/workflow.mjs +120 -0
- package/dist/dsl/workflow.mjs.map +1 -0
- package/dist/engine/actions.cjs +27 -0
- package/dist/engine/actions.cjs.map +1 -0
- package/dist/engine/actions.d.cts +40 -0
- package/dist/engine/actions.d.cts.map +1 -0
- package/dist/engine/actions.d.mts +40 -0
- package/dist/engine/actions.d.mts.map +1 -0
- package/dist/engine/actions.mjs +26 -0
- package/dist/engine/actions.mjs.map +1 -0
- package/dist/engine/bucket.cjs +72 -0
- package/dist/engine/bucket.cjs.map +1 -0
- package/dist/engine/bucket.d.cts +32 -0
- package/dist/engine/bucket.d.cts.map +1 -0
- package/dist/engine/bucket.d.mts +32 -0
- package/dist/engine/bucket.d.mts.map +1 -0
- package/dist/engine/bucket.mjs +69 -0
- package/dist/engine/bucket.mjs.map +1 -0
- package/dist/engine/condition.cjs +166 -0
- package/dist/engine/condition.cjs.map +1 -0
- package/dist/engine/condition.d.cts +52 -0
- package/dist/engine/condition.d.cts.map +1 -0
- package/dist/engine/condition.d.mts +52 -0
- package/dist/engine/condition.d.mts.map +1 -0
- package/dist/engine/condition.mjs +161 -0
- package/dist/engine/condition.mjs.map +1 -0
- package/dist/engine/index.cjs +20 -0
- package/dist/engine/index.d.cts +8 -0
- package/dist/engine/index.d.mts +8 -0
- package/dist/engine/index.mjs +7 -0
- package/dist/engine/interpreter.cjs +428 -0
- package/dist/engine/interpreter.cjs.map +1 -0
- package/dist/engine/interpreter.d.cts +6 -0
- package/dist/engine/interpreter.d.cts.map +1 -0
- package/dist/engine/interpreter.d.mts +6 -0
- package/dist/engine/interpreter.d.mts.map +1 -0
- package/dist/engine/interpreter.mjs +427 -0
- package/dist/engine/interpreter.mjs.map +1 -0
- package/dist/engine/ports.cjs +0 -0
- package/dist/engine/ports.d.cts +252 -0
- package/dist/engine/ports.d.cts.map +1 -0
- package/dist/engine/ports.d.mts +252 -0
- package/dist/engine/ports.d.mts.map +1 -0
- package/dist/engine/ports.mjs +1 -0
- package/dist/engine/recipient.cjs +23 -0
- package/dist/engine/recipient.cjs.map +1 -0
- package/dist/engine/recipient.d.cts +13 -0
- package/dist/engine/recipient.d.cts.map +1 -0
- package/dist/engine/recipient.d.mts +13 -0
- package/dist/engine/recipient.d.mts.map +1 -0
- package/dist/engine/recipient.mjs +22 -0
- package/dist/engine/recipient.mjs.map +1 -0
- package/dist/engine/time-scale.cjs +54 -0
- package/dist/engine/time-scale.cjs.map +1 -0
- package/dist/engine/time-scale.d.cts +31 -0
- package/dist/engine/time-scale.d.cts.map +1 -0
- package/dist/engine/time-scale.d.mts +31 -0
- package/dist/engine/time-scale.d.mts.map +1 -0
- package/dist/engine/time-scale.mjs +52 -0
- package/dist/engine/time-scale.mjs.map +1 -0
- package/dist/engine/time-window.cjs +149 -0
- package/dist/engine/time-window.cjs.map +1 -0
- package/dist/engine/time-window.d.cts +22 -0
- package/dist/engine/time-window.d.cts.map +1 -0
- package/dist/engine/time-window.d.mts +22 -0
- package/dist/engine/time-window.d.mts.map +1 -0
- package/dist/engine/time-window.mjs +147 -0
- package/dist/engine/time-window.mjs.map +1 -0
- package/dist/fcm.cjs +125 -0
- package/dist/fcm.cjs.map +1 -0
- package/dist/fcm.d.cts +48 -0
- package/dist/fcm.d.cts.map +1 -0
- package/dist/fcm.d.mts +48 -0
- package/dist/fcm.d.mts.map +1 -0
- package/dist/fcm.mjs +121 -0
- package/dist/fcm.mjs.map +1 -0
- package/dist/hash.cjs +245 -0
- package/dist/hash.cjs.map +1 -0
- package/dist/hash.d.cts +30 -0
- package/dist/hash.d.cts.map +1 -0
- package/dist/hash.d.mts +30 -0
- package/dist/hash.d.mts.map +1 -0
- package/dist/hash.mjs +239 -0
- package/dist/hash.mjs.map +1 -0
- package/dist/index.cjs +100 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +17 -0
- package/dist/ir.cjs +366 -0
- package/dist/ir.cjs.map +1 -0
- package/dist/ir.d.cts +486 -0
- package/dist/ir.d.cts.map +1 -0
- package/dist/ir.d.mts +486 -0
- package/dist/ir.d.mts.map +1 -0
- package/dist/ir.mjs +344 -0
- package/dist/ir.mjs.map +1 -0
- package/dist/jwt.cjs +22 -0
- package/dist/jwt.cjs.map +1 -0
- package/dist/jwt.d.cts +9 -0
- package/dist/jwt.d.cts.map +1 -0
- package/dist/jwt.d.mts +9 -0
- package/dist/jwt.d.mts.map +1 -0
- package/dist/jwt.mjs +20 -0
- package/dist/jwt.mjs.map +1 -0
- package/dist/plan.cjs +223 -0
- package/dist/plan.cjs.map +1 -0
- package/dist/plan.d.cts +68 -0
- package/dist/plan.d.cts.map +1 -0
- package/dist/plan.d.mts +68 -0
- package/dist/plan.d.mts.map +1 -0
- package/dist/plan.mjs +221 -0
- package/dist/plan.mjs.map +1 -0
- package/dist/postgres-js.cjs +42 -0
- package/dist/postgres-js.cjs.map +1 -0
- package/dist/postgres-js.d.cts +28 -0
- package/dist/postgres-js.d.cts.map +1 -0
- package/dist/postgres-js.d.mts +28 -0
- package/dist/postgres-js.d.mts.map +1 -0
- package/dist/postgres-js.mjs +38 -0
- package/dist/postgres-js.mjs.map +1 -0
- package/dist/provenance.cjs +67 -0
- package/dist/provenance.cjs.map +1 -0
- package/dist/provenance.d.cts +41 -0
- package/dist/provenance.d.cts.map +1 -0
- package/dist/provenance.d.mts +41 -0
- package/dist/provenance.d.mts.map +1 -0
- package/dist/provenance.mjs +65 -0
- package/dist/provenance.mjs.map +1 -0
- package/dist/push.cjs +14 -0
- package/dist/push.cjs.map +1 -0
- package/dist/push.d.cts +16 -0
- package/dist/push.d.cts.map +1 -0
- package/dist/push.d.mts +16 -0
- package/dist/push.d.mts.map +1 -0
- package/dist/push.mjs +13 -0
- package/dist/push.mjs.map +1 -0
- package/dist/react-email.cjs +48 -0
- package/dist/react-email.cjs.map +1 -0
- package/dist/react-email.d.cts +7 -0
- package/dist/react-email.d.cts.map +1 -0
- package/dist/react-email.d.mts +7 -0
- package/dist/react-email.d.mts.map +1 -0
- package/dist/react-email.mjs +47 -0
- package/dist/react-email.mjs.map +1 -0
- package/dist/reporting/classify.cjs +42 -0
- package/dist/reporting/classify.cjs.map +1 -0
- package/dist/reporting/classify.d.cts +60 -0
- package/dist/reporting/classify.d.cts.map +1 -0
- package/dist/reporting/classify.d.mts +60 -0
- package/dist/reporting/classify.d.mts.map +1 -0
- package/dist/reporting/classify.mjs +38 -0
- package/dist/reporting/classify.mjs.map +1 -0
- package/dist/reporting/observer.cjs +63 -0
- package/dist/reporting/observer.cjs.map +1 -0
- package/dist/reporting/observer.d.cts +18 -0
- package/dist/reporting/observer.d.cts.map +1 -0
- package/dist/reporting/observer.d.mts +18 -0
- package/dist/reporting/observer.d.mts.map +1 -0
- package/dist/reporting/observer.mjs +62 -0
- package/dist/reporting/observer.mjs.map +1 -0
- package/dist/reporting/tracking.cjs +153 -0
- package/dist/reporting/tracking.cjs.map +1 -0
- package/dist/reporting/tracking.d.cts +43 -0
- package/dist/reporting/tracking.d.cts.map +1 -0
- package/dist/reporting/tracking.d.mts +43 -0
- package/dist/reporting/tracking.d.mts.map +1 -0
- package/dist/reporting/tracking.mjs +151 -0
- package/dist/reporting/tracking.mjs.map +1 -0
- package/dist/runtime.cjs +19 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +30 -0
- package/dist/runtime.d.cts.map +1 -0
- package/dist/runtime.d.mts +30 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +18 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/store/d1.cjs +185 -0
- package/dist/store/d1.cjs.map +1 -0
- package/dist/store/d1.d.cts +55 -0
- package/dist/store/d1.d.cts.map +1 -0
- package/dist/store/d1.d.mts +55 -0
- package/dist/store/d1.d.mts.map +1 -0
- package/dist/store/d1.mjs +184 -0
- package/dist/store/d1.mjs.map +1 -0
- package/dist/store/facts.cjs +60 -0
- package/dist/store/facts.cjs.map +1 -0
- package/dist/store/facts.d.cts +38 -0
- package/dist/store/facts.d.cts.map +1 -0
- package/dist/store/facts.d.mts +38 -0
- package/dist/store/facts.d.mts.map +1 -0
- package/dist/store/facts.mjs +58 -0
- package/dist/store/facts.mjs.map +1 -0
- package/dist/store/index.cjs +31 -0
- package/dist/store/index.cjs.map +1 -0
- package/dist/store/index.d.cts +291 -0
- package/dist/store/index.d.cts.map +1 -0
- package/dist/store/index.d.mts +291 -0
- package/dist/store/index.d.mts.map +1 -0
- package/dist/store/index.mjs +22 -0
- package/dist/store/index.mjs.map +1 -0
- package/dist/store/postgres-reporting.cjs +213 -0
- package/dist/store/postgres-reporting.cjs.map +1 -0
- package/dist/store/postgres-reporting.d.cts +63 -0
- package/dist/store/postgres-reporting.d.cts.map +1 -0
- package/dist/store/postgres-reporting.d.mts +63 -0
- package/dist/store/postgres-reporting.d.mts.map +1 -0
- package/dist/store/postgres-reporting.mjs +212 -0
- package/dist/store/postgres-reporting.mjs.map +1 -0
- package/dist/store/postgres.cjs +309 -0
- package/dist/store/postgres.cjs.map +1 -0
- package/dist/store/postgres.d.cts +77 -0
- package/dist/store/postgres.d.cts.map +1 -0
- package/dist/store/postgres.d.mts +77 -0
- package/dist/store/postgres.d.mts.map +1 -0
- package/dist/store/postgres.mjs +306 -0
- package/dist/store/postgres.mjs.map +1 -0
- package/dist/store/sql.cjs +24 -0
- package/dist/store/sql.cjs.map +1 -0
- package/dist/store/sql.d.cts +25 -0
- package/dist/store/sql.d.cts.map +1 -0
- package/dist/store/sql.d.mts +25 -0
- package/dist/store/sql.d.mts.map +1 -0
- package/dist/store/sql.mjs +23 -0
- package/dist/store/sql.mjs.map +1 -0
- package/dist/store/tables.cjs +404 -0
- package/dist/store/tables.cjs.map +1 -0
- package/dist/store/tables.d.cts +81 -0
- package/dist/store/tables.d.cts.map +1 -0
- package/dist/store/tables.d.mts +81 -0
- package/dist/store/tables.d.mts.map +1 -0
- package/dist/store/tables.mjs +399 -0
- package/dist/store/tables.mjs.map +1 -0
- package/dist/templates.cjs +247 -0
- package/dist/templates.cjs.map +1 -0
- package/dist/templates.d.cts +187 -0
- package/dist/templates.d.cts.map +1 -0
- package/dist/templates.d.mts +187 -0
- package/dist/templates.d.mts.map +1 -0
- package/dist/templates.mjs +230 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/webhooks.cjs +96 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +25 -0
- package/dist/webhooks.d.cts.map +1 -0
- package/dist/webhooks.d.mts +25 -0
- package/dist/webhooks.d.mts.map +1 -0
- package/dist/webhooks.mjs +94 -0
- package/dist/webhooks.mjs.map +1 -0
- package/dist/webpush.cjs +180 -0
- package/dist/webpush.cjs.map +1 -0
- package/dist/webpush.d.cts +53 -0
- package/dist/webpush.d.cts.map +1 -0
- package/dist/webpush.d.mts +53 -0
- package/dist/webpush.d.mts.map +1 -0
- package/dist/webpush.mjs +175 -0
- package/dist/webpush.mjs.map +1 -0
- package/package.json +189 -3
- package/src/cloudflare/schema.sql +127 -0
- package/src/cloudflare/workers.d.ts +44 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ConditionIR } from "../ir.cjs";
|
|
2
|
+
import { FactSource } from "./ports.cjs";
|
|
3
|
+
//#region src/engine/condition.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Evaluation options.
|
|
6
|
+
* - anchorMs: the earliest instant `performed` counts events from — the goal
|
|
7
|
+
* guard anchors at workflow entry (a conversion must happen *after* entry),
|
|
8
|
+
* waitUntil at the moment the wait began (a wake must not be satisfied by
|
|
9
|
+
* pre-existing history). Combined with `within` by taking the later bound.
|
|
10
|
+
* - untilMs: the latest instant `performed` counts events up to — the goal's
|
|
11
|
+
* attribution window ends there, so an event after it is no conversion even
|
|
12
|
+
* when the check runs later (a resumed instance, a delayed wake).
|
|
13
|
+
*/
|
|
14
|
+
export interface EvaluateOptions {
|
|
15
|
+
anchorMs?: number;
|
|
16
|
+
untilMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ConditionIR evaluation: pure logic, with facts injected through FactSource,
|
|
20
|
+
* so the D1 implementation and the in-memory test one share a single set of
|
|
21
|
+
* semantics and cannot drift into two evaluators.
|
|
22
|
+
*/
|
|
23
|
+
export declare function evaluateCondition(condition: ConditionIR, facts: FactSource, nowMs: number, opts?: EvaluateOptions): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate a where tree against one event's payload. Shared by performed
|
|
26
|
+
* counting (FactSource implementations) and the ingest router's trigger gate.
|
|
27
|
+
* Dotted paths descend nested objects; a missing or non-scalar leaf behaves
|
|
28
|
+
* like a missing property (exists sees objects, comparisons do not).
|
|
29
|
+
*/
|
|
30
|
+
export declare function matchesWhere(payload: unknown, where: ConditionIR): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Wake-up channel for profile changes: a property predicate has no event name
|
|
33
|
+
* of its own, so subscriptions use this reserved name and the ingest router
|
|
34
|
+
* fires it on every /identify. The '$' prefix marks internal names — real
|
|
35
|
+
* events may never use it (the router rejects them).
|
|
36
|
+
*/
|
|
37
|
+
export declare const PROFILE_UPDATED_EVENT = "$profile_updated";
|
|
38
|
+
/**
|
|
39
|
+
* Wake-up channel for device changes: a device registered for the user, moved to another account
|
|
40
|
+
* or was unbound or removed (`POST /devices`, `/devices/unbind`, `/devices/remove`). `reachable('push')` subscribes to it.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DEVICES_UPDATED_EVENT = "$devices_updated";
|
|
43
|
+
/**
|
|
44
|
+
* The set of event names a condition cares about — what wait_until subscribes
|
|
45
|
+
* to for wake-ups. `performed` contributes its event; a property predicate
|
|
46
|
+
* contributes PROFILE_UPDATED_EVENT (so /identify wakes the wait). Segment
|
|
47
|
+
* references are expanded, which is why a FactSource is needed to resolve
|
|
48
|
+
* their definitions.
|
|
49
|
+
*/
|
|
50
|
+
export declare function relevantEvents(condition: ConditionIR, facts: FactSource): Promise<string[]>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//# sourceMappingURL=condition.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.d.cts","names":[],"sources":["../../src/engine/condition.ts"],"mappings":";;;;;;;;;;;;;iBAciB;EACf;EACA;;;;;;;wBAQoB,kBACpB,WAAW,aACX,OAAO,YACP,eACA,OAAO,kBACN;;;;;;;wBAqFa,aAAa,kBAAkB,OAAO;;;;;;;qBAuFzC;;;;;qBAMA;;;;;;;;wBASS,eAAe,WAAW,aAAa,OAAO,aAAa"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ConditionIR } from "../ir.mjs";
|
|
2
|
+
import { FactSource } from "./ports.mjs";
|
|
3
|
+
//#region src/engine/condition.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Evaluation options.
|
|
6
|
+
* - anchorMs: the earliest instant `performed` counts events from — the goal
|
|
7
|
+
* guard anchors at workflow entry (a conversion must happen *after* entry),
|
|
8
|
+
* waitUntil at the moment the wait began (a wake must not be satisfied by
|
|
9
|
+
* pre-existing history). Combined with `within` by taking the later bound.
|
|
10
|
+
* - untilMs: the latest instant `performed` counts events up to — the goal's
|
|
11
|
+
* attribution window ends there, so an event after it is no conversion even
|
|
12
|
+
* when the check runs later (a resumed instance, a delayed wake).
|
|
13
|
+
*/
|
|
14
|
+
export interface EvaluateOptions {
|
|
15
|
+
anchorMs?: number;
|
|
16
|
+
untilMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ConditionIR evaluation: pure logic, with facts injected through FactSource,
|
|
20
|
+
* so the D1 implementation and the in-memory test one share a single set of
|
|
21
|
+
* semantics and cannot drift into two evaluators.
|
|
22
|
+
*/
|
|
23
|
+
export declare function evaluateCondition(condition: ConditionIR, facts: FactSource, nowMs: number, opts?: EvaluateOptions): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate a where tree against one event's payload. Shared by performed
|
|
26
|
+
* counting (FactSource implementations) and the ingest router's trigger gate.
|
|
27
|
+
* Dotted paths descend nested objects; a missing or non-scalar leaf behaves
|
|
28
|
+
* like a missing property (exists sees objects, comparisons do not).
|
|
29
|
+
*/
|
|
30
|
+
export declare function matchesWhere(payload: unknown, where: ConditionIR): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Wake-up channel for profile changes: a property predicate has no event name
|
|
33
|
+
* of its own, so subscriptions use this reserved name and the ingest router
|
|
34
|
+
* fires it on every /identify. The '$' prefix marks internal names — real
|
|
35
|
+
* events may never use it (the router rejects them).
|
|
36
|
+
*/
|
|
37
|
+
export declare const PROFILE_UPDATED_EVENT = "$profile_updated";
|
|
38
|
+
/**
|
|
39
|
+
* Wake-up channel for device changes: a device registered for the user, moved to another account
|
|
40
|
+
* or was unbound or removed (`POST /devices`, `/devices/unbind`, `/devices/remove`). `reachable('push')` subscribes to it.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DEVICES_UPDATED_EVENT = "$devices_updated";
|
|
43
|
+
/**
|
|
44
|
+
* The set of event names a condition cares about — what wait_until subscribes
|
|
45
|
+
* to for wake-ups. `performed` contributes its event; a property predicate
|
|
46
|
+
* contributes PROFILE_UPDATED_EVENT (so /identify wakes the wait). Segment
|
|
47
|
+
* references are expanded, which is why a FactSource is needed to resolve
|
|
48
|
+
* their definitions.
|
|
49
|
+
*/
|
|
50
|
+
export declare function relevantEvents(condition: ConditionIR, facts: FactSource): Promise<string[]>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//# sourceMappingURL=condition.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.d.mts","names":[],"sources":["../../src/engine/condition.ts"],"mappings":";;;;;;;;;;;;;iBAciB;EACf;EACA;;;;;;;wBAQoB,kBACpB,WAAW,aACX,OAAO,YACP,eACA,OAAO,kBACN;;;;;;;wBAqFa,aAAa,kBAAkB,OAAO;;;;;;;qBAuFzC;;;;;qBAMA;;;;;;;;wBASS,eAAe,WAAW,aAAa,OAAO,aAAa"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { RECIPIENT_PROPERTY } from "./recipient.mjs";
|
|
2
|
+
//#region src/engine/condition.ts
|
|
3
|
+
/**
|
|
4
|
+
* ConditionIR evaluation: pure logic, with facts injected through FactSource,
|
|
5
|
+
* so the D1 implementation and the in-memory test one share a single set of
|
|
6
|
+
* semantics and cannot drift into two evaluators.
|
|
7
|
+
*/
|
|
8
|
+
async function evaluateCondition(condition, facts, nowMs, opts) {
|
|
9
|
+
return evaluate(condition, facts, nowMs, opts, []);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `enclosing` is the chain of segment names currently being expanded. A
|
|
13
|
+
* segment that reaches itself has no truth value to converge on, and left
|
|
14
|
+
* unchecked the recursion runs until memory gives out, one D1 round trip per
|
|
15
|
+
* level — inside a step, so Workflows retries it and the instance never gets
|
|
16
|
+
* out. Failing immediately keeps it bounded, and the message names the cycle
|
|
17
|
+
* because only a deployed bundle can fix it. Only the *path* is tracked, so a
|
|
18
|
+
* diamond (two branches referencing one segment) still evaluates twice.
|
|
19
|
+
*/
|
|
20
|
+
async function evaluate(condition, facts, nowMs, opts, enclosing) {
|
|
21
|
+
switch (condition.type) {
|
|
22
|
+
case "and":
|
|
23
|
+
for (const child of condition.conditions) if (!await evaluate(child, facts, nowMs, opts, enclosing)) return false;
|
|
24
|
+
return true;
|
|
25
|
+
case "or":
|
|
26
|
+
for (const child of condition.conditions) if (await evaluate(child, facts, nowMs, opts, enclosing)) return true;
|
|
27
|
+
return false;
|
|
28
|
+
case "not": return !await evaluate(condition.condition, facts, nowMs, opts, enclosing);
|
|
29
|
+
case "segment": {
|
|
30
|
+
if (enclosing.includes(condition.segment)) throw new Error(`segment '${condition.segment}' references itself: ${[...enclosing, condition.segment].join(" -> ")}`);
|
|
31
|
+
const def = await facts.getSegmentCondition(condition.segment);
|
|
32
|
+
if (def === void 0) throw new Error(`Unknown segment: '${condition.segment}' (bundle not deployed?)`);
|
|
33
|
+
return evaluate(def, facts, nowMs, opts, [...enclosing, condition.segment]);
|
|
34
|
+
}
|
|
35
|
+
case "performed": {
|
|
36
|
+
const bounds = [];
|
|
37
|
+
if (condition.within !== void 0) bounds.push(nowMs - condition.within.ms);
|
|
38
|
+
if (opts?.anchorMs !== void 0) bounds.push(opts.anchorMs);
|
|
39
|
+
const sinceMs = bounds.length > 0 ? Math.max(...bounds) : void 0;
|
|
40
|
+
return await facts.countEvents(condition.event, {
|
|
41
|
+
...sinceMs !== void 0 ? { sinceMs } : {},
|
|
42
|
+
...opts?.untilMs !== void 0 ? { untilMs: opts.untilMs } : {},
|
|
43
|
+
...condition.where !== void 0 ? { where: condition.where } : {}
|
|
44
|
+
}) >= (condition.count ?? 1);
|
|
45
|
+
}
|
|
46
|
+
case "property": return compareProperty(condition, await facts.getProperty(condition.path));
|
|
47
|
+
case "reachable": {
|
|
48
|
+
if (await facts.isSuppressed?.(condition.channel)) return false;
|
|
49
|
+
if (condition.channel === "push") return (await facts.listDevices()).length > 0;
|
|
50
|
+
const path = RECIPIENT_PROPERTY[condition.channel];
|
|
51
|
+
return path === void 0 || await facts.getProperty(path) !== void 0;
|
|
52
|
+
}
|
|
53
|
+
case "payload": throw new Error("payload conditions are only valid inside performed({ where }) or a trigger where clause");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Evaluate a where tree against one event's payload. Shared by performed
|
|
58
|
+
* counting (FactSource implementations) and the ingest router's trigger gate.
|
|
59
|
+
* Dotted paths descend nested objects; a missing or non-scalar leaf behaves
|
|
60
|
+
* like a missing property (exists sees objects, comparisons do not).
|
|
61
|
+
*/
|
|
62
|
+
function matchesWhere(payload, where) {
|
|
63
|
+
switch (where.type) {
|
|
64
|
+
case "and": return where.conditions.every((child) => matchesWhere(payload, child));
|
|
65
|
+
case "or": return where.conditions.some((child) => matchesWhere(payload, child));
|
|
66
|
+
case "not": return !matchesWhere(payload, where.condition);
|
|
67
|
+
case "payload": {
|
|
68
|
+
const raw = valueAtPath(payload, where.path);
|
|
69
|
+
if (where.op === "exists") return raw !== void 0 && raw !== null;
|
|
70
|
+
if (where.op === "not_exists") return raw === void 0 || raw === null;
|
|
71
|
+
return compareProperty(where, typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean" ? raw : void 0);
|
|
72
|
+
}
|
|
73
|
+
default: throw new Error(`where clause may not contain a '${where.type}' condition`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function valueAtPath(payload, path) {
|
|
77
|
+
let current = payload;
|
|
78
|
+
for (const key of path.split(".")) {
|
|
79
|
+
if (current === null || typeof current !== "object") return void 0;
|
|
80
|
+
current = current[key];
|
|
81
|
+
}
|
|
82
|
+
return current;
|
|
83
|
+
}
|
|
84
|
+
function compareProperty(condition, actual) {
|
|
85
|
+
const { op, value, values } = condition;
|
|
86
|
+
switch (op) {
|
|
87
|
+
case "exists": return actual !== void 0;
|
|
88
|
+
case "not_exists": return actual === void 0;
|
|
89
|
+
case "eq": return actual === value;
|
|
90
|
+
case "ne": return actual !== value;
|
|
91
|
+
case "gt": return actual !== void 0 && value !== void 0 && actual > value;
|
|
92
|
+
case "gte": return actual !== void 0 && value !== void 0 && actual >= value;
|
|
93
|
+
case "lt": return actual !== void 0 && value !== void 0 && actual < value;
|
|
94
|
+
case "lte": return actual !== void 0 && value !== void 0 && actual <= value;
|
|
95
|
+
case "between": return isBetween(actual, values);
|
|
96
|
+
case "not_between": return !isBetween(actual, values);
|
|
97
|
+
case "in_array": return actual !== void 0 && (values ?? []).includes(actual);
|
|
98
|
+
case "not_in_array": return actual === void 0 || !(values ?? []).includes(actual);
|
|
99
|
+
case "contains": return typeof actual === "string" && typeof value === "string" && actual.includes(value);
|
|
100
|
+
case "not_contains": return !(typeof actual === "string" && typeof value === "string" && actual.includes(value));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function isBetween(actual, values) {
|
|
104
|
+
if (actual === void 0 || values === void 0 || values.length < 2) return false;
|
|
105
|
+
const [min, max] = values;
|
|
106
|
+
return actual >= min && actual <= max;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Wake-up channel for profile changes: a property predicate has no event name
|
|
110
|
+
* of its own, so subscriptions use this reserved name and the ingest router
|
|
111
|
+
* fires it on every /identify. The '$' prefix marks internal names — real
|
|
112
|
+
* events may never use it (the router rejects them).
|
|
113
|
+
*/
|
|
114
|
+
const PROFILE_UPDATED_EVENT = "$profile_updated";
|
|
115
|
+
/**
|
|
116
|
+
* Wake-up channel for device changes: a device registered for the user, moved to another account
|
|
117
|
+
* or was unbound or removed (`POST /devices`, `/devices/unbind`, `/devices/remove`). `reachable('push')` subscribes to it.
|
|
118
|
+
*/
|
|
119
|
+
const DEVICES_UPDATED_EVENT = "$devices_updated";
|
|
120
|
+
/**
|
|
121
|
+
* The set of event names a condition cares about — what wait_until subscribes
|
|
122
|
+
* to for wake-ups. `performed` contributes its event; a property predicate
|
|
123
|
+
* contributes PROFILE_UPDATED_EVENT (so /identify wakes the wait). Segment
|
|
124
|
+
* references are expanded, which is why a FactSource is needed to resolve
|
|
125
|
+
* their definitions.
|
|
126
|
+
*/
|
|
127
|
+
async function relevantEvents(condition, facts) {
|
|
128
|
+
const found = /* @__PURE__ */ new Set();
|
|
129
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
130
|
+
async function walk(c) {
|
|
131
|
+
switch (c.type) {
|
|
132
|
+
case "and":
|
|
133
|
+
case "or":
|
|
134
|
+
for (const child of c.conditions) await walk(child);
|
|
135
|
+
break;
|
|
136
|
+
case "not":
|
|
137
|
+
await walk(c.condition);
|
|
138
|
+
break;
|
|
139
|
+
case "performed":
|
|
140
|
+
found.add(c.event);
|
|
141
|
+
break;
|
|
142
|
+
case "segment": {
|
|
143
|
+
if (expanded.has(c.segment)) break;
|
|
144
|
+
expanded.add(c.segment);
|
|
145
|
+
const def = await facts.getSegmentCondition(c.segment);
|
|
146
|
+
if (def) await walk(def);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case "property":
|
|
150
|
+
found.add(PROFILE_UPDATED_EVENT);
|
|
151
|
+
break;
|
|
152
|
+
case "reachable": found.add(c.channel === "push" ? DEVICES_UPDATED_EVENT : PROFILE_UPDATED_EVENT);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
await walk(condition);
|
|
156
|
+
return [...found];
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { DEVICES_UPDATED_EVENT, PROFILE_UPDATED_EVENT, evaluateCondition, matchesWhere, relevantEvents };
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=condition.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.mjs","names":[],"sources":["../../src/engine/condition.ts"],"sourcesContent":["import type { ConditionIR, PropertyOperatorIR, ScalarIR } from '../ir';\nimport type { FactSource } from './ports';\nimport { RECIPIENT_PROPERTY } from './recipient';\n\n/**\n * Evaluation options.\n * - anchorMs: the earliest instant `performed` counts events from — the goal\n * guard anchors at workflow entry (a conversion must happen *after* entry),\n * waitUntil at the moment the wait began (a wake must not be satisfied by\n * pre-existing history). Combined with `within` by taking the later bound.\n * - untilMs: the latest instant `performed` counts events up to — the goal's\n * attribution window ends there, so an event after it is no conversion even\n * when the check runs later (a resumed instance, a delayed wake).\n */\nexport interface EvaluateOptions {\n anchorMs?: number;\n untilMs?: number;\n}\n\n/**\n * ConditionIR evaluation: pure logic, with facts injected through FactSource,\n * so the D1 implementation and the in-memory test one share a single set of\n * semantics and cannot drift into two evaluators.\n */\nexport async function evaluateCondition(\n condition: ConditionIR,\n facts: FactSource,\n nowMs: number,\n opts?: EvaluateOptions\n): Promise<boolean> {\n return evaluate(condition, facts, nowMs, opts, []);\n}\n\n/**\n * `enclosing` is the chain of segment names currently being expanded. A\n * segment that reaches itself has no truth value to converge on, and left\n * unchecked the recursion runs until memory gives out, one D1 round trip per\n * level — inside a step, so Workflows retries it and the instance never gets\n * out. Failing immediately keeps it bounded, and the message names the cycle\n * because only a deployed bundle can fix it. Only the *path* is tracked, so a\n * diamond (two branches referencing one segment) still evaluates twice.\n */\nasync function evaluate(\n condition: ConditionIR,\n facts: FactSource,\n nowMs: number,\n opts: EvaluateOptions | undefined,\n enclosing: readonly string[]\n): Promise<boolean> {\n switch (condition.type) {\n case 'and': {\n for (const child of condition.conditions) {\n if (!(await evaluate(child, facts, nowMs, opts, enclosing))) return false;\n }\n return true;\n }\n case 'or': {\n for (const child of condition.conditions) {\n if (await evaluate(child, facts, nowMs, opts, enclosing)) return true;\n }\n return false;\n }\n case 'not':\n return !(await evaluate(condition.condition, facts, nowMs, opts, enclosing));\n case 'segment': {\n if (enclosing.includes(condition.segment)) {\n throw new Error(\n `segment '${condition.segment}' references itself: ${[...enclosing, condition.segment].join(' -> ')}`\n );\n }\n const def = await facts.getSegmentCondition(condition.segment);\n if (def === undefined) {\n throw new Error(`Unknown segment: '${condition.segment}' (bundle not deployed?)`);\n }\n return evaluate(def, facts, nowMs, opts, [...enclosing, condition.segment]);\n }\n case 'performed': {\n const bounds: number[] = [];\n if (condition.within !== undefined) bounds.push(nowMs - condition.within.ms);\n if (opts?.anchorMs !== undefined) bounds.push(opts.anchorMs);\n const sinceMs = bounds.length > 0 ? Math.max(...bounds) : undefined;\n const count = await facts.countEvents(condition.event, {\n ...(sinceMs !== undefined ? { sinceMs } : {}),\n ...(opts?.untilMs !== undefined ? { untilMs: opts.untilMs } : {}),\n ...(condition.where !== undefined ? { where: condition.where } : {}),\n });\n return count >= (condition.count ?? 1);\n }\n case 'property': {\n const actual = await facts.getProperty(condition.path);\n return compareProperty(condition, actual);\n }\n case 'reachable': {\n if (await facts.isSuppressed?.(condition.channel)) return false;\n if (condition.channel === 'push') return (await facts.listDevices()).length > 0;\n const path = RECIPIENT_PROPERTY[condition.channel];\n // in_app, slack and discord need no address: a signed-in user is reachable in the app, and\n // the webhook channels post to a team channel, not to the user\n return path === undefined || (await facts.getProperty(path)) !== undefined;\n }\n case 'payload':\n // Placement is validated at compile; reaching here means hand-built IR\n throw new Error(\n 'payload conditions are only valid inside performed({ where }) or a trigger where clause'\n );\n }\n}\n\n/**\n * Evaluate a where tree against one event's payload. Shared by performed\n * counting (FactSource implementations) and the ingest router's trigger gate.\n * Dotted paths descend nested objects; a missing or non-scalar leaf behaves\n * like a missing property (exists sees objects, comparisons do not).\n */\nexport function matchesWhere(payload: unknown, where: ConditionIR): boolean {\n switch (where.type) {\n case 'and':\n return where.conditions.every((child) => matchesWhere(payload, child));\n case 'or':\n return where.conditions.some((child) => matchesWhere(payload, child));\n case 'not':\n return !matchesWhere(payload, where.condition);\n case 'payload': {\n const raw = valueAtPath(payload, where.path);\n if (where.op === 'exists') return raw !== undefined && raw !== null;\n if (where.op === 'not_exists') return raw === undefined || raw === null;\n const actual =\n typeof raw === 'string' || typeof raw === 'number' || typeof raw === 'boolean'\n ? raw\n : undefined;\n return compareProperty(where, actual);\n }\n default:\n // compileBundle rejects these; defend against hand-built IR\n throw new Error(`where clause may not contain a '${where.type}' condition`);\n }\n}\n\nfunction valueAtPath(payload: unknown, path: string): unknown {\n let current: unknown = payload;\n for (const key of path.split('.')) {\n if (current === null || typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[key];\n }\n return current;\n}\n\nfunction compareProperty(\n condition: {\n op: PropertyOperatorIR;\n value?: ScalarIR | undefined;\n values?: ScalarIR[] | undefined;\n },\n actual: ScalarIR | undefined\n): boolean {\n const { op, value, values } = condition;\n switch (op) {\n case 'exists':\n return actual !== undefined;\n case 'not_exists':\n return actual === undefined;\n case 'eq':\n return actual === value;\n case 'ne':\n return actual !== value;\n case 'gt':\n return actual !== undefined && value !== undefined && actual > value;\n case 'gte':\n return actual !== undefined && value !== undefined && actual >= value;\n case 'lt':\n return actual !== undefined && value !== undefined && actual < value;\n case 'lte':\n return actual !== undefined && value !== undefined && actual <= value;\n case 'between':\n return isBetween(actual, values);\n case 'not_between':\n // A missing property is outside any range, mirroring not_in_array.\n return !isBetween(actual, values);\n case 'in_array':\n return actual !== undefined && (values ?? []).includes(actual);\n case 'not_in_array':\n return actual === undefined || !(values ?? []).includes(actual);\n case 'contains':\n return typeof actual === 'string' && typeof value === 'string' && actual.includes(value);\n case 'not_contains':\n return !(typeof actual === 'string' && typeof value === 'string' && actual.includes(value));\n }\n}\n\nfunction isBetween(actual: ScalarIR | undefined, values: ScalarIR[] | undefined): boolean {\n if (actual === undefined || values === undefined || values.length < 2) return false;\n const [min, max] = values;\n return actual >= min && actual <= max;\n}\n\n/**\n * Wake-up channel for profile changes: a property predicate has no event name\n * of its own, so subscriptions use this reserved name and the ingest router\n * fires it on every /identify. The '$' prefix marks internal names — real\n * events may never use it (the router rejects them).\n */\nexport const PROFILE_UPDATED_EVENT = '$profile_updated';\n\n/**\n * Wake-up channel for device changes: a device registered for the user, moved to another account\n * or was unbound or removed (`POST /devices`, `/devices/unbind`, `/devices/remove`). `reachable('push')` subscribes to it.\n */\nexport const DEVICES_UPDATED_EVENT = '$devices_updated';\n\n/**\n * The set of event names a condition cares about — what wait_until subscribes\n * to for wake-ups. `performed` contributes its event; a property predicate\n * contributes PROFILE_UPDATED_EVENT (so /identify wakes the wait). Segment\n * references are expanded, which is why a FactSource is needed to resolve\n * their definitions.\n */\nexport async function relevantEvents(condition: ConditionIR, facts: FactSource): Promise<string[]> {\n const found = new Set<string>();\n // Names already expanded. The result is a union, so re-walking a segment can\n // only add what is already there — and a segment that reaches itself would\n // otherwise recurse until the stack blows, taking a D1 read per level.\n const expanded = new Set<string>();\n async function walk(c: ConditionIR): Promise<void> {\n switch (c.type) {\n case 'and':\n case 'or':\n for (const child of c.conditions) await walk(child);\n break;\n case 'not':\n await walk(c.condition);\n break;\n case 'performed':\n found.add(c.event);\n break;\n case 'segment': {\n if (expanded.has(c.segment)) break;\n expanded.add(c.segment);\n const def = await facts.getSegmentCondition(c.segment);\n if (def) await walk(def);\n break;\n }\n case 'property':\n found.add(PROFILE_UPDATED_EVENT);\n break;\n case 'reachable':\n found.add(c.channel === 'push' ? DEVICES_UPDATED_EVENT : PROFILE_UPDATED_EVENT);\n break;\n case 'payload':\n break; // only appears inside performed.where, which is not walked\n }\n }\n await walk(condition);\n return [...found];\n}\n"],"mappings":";;;;;;;AAwBA,eAAsB,kBACpB,WACA,OACA,OACA,MACkB;CAClB,OAAO,SAAS,WAAW,OAAO,OAAO,MAAM,CAAC,CAAC;AACnD;;;;;;;;;;AAWA,eAAe,SACb,WACA,OACA,OACA,MACA,WACkB;CAClB,QAAQ,UAAU,MAAlB;EACE,KAAK;GACH,KAAK,MAAM,SAAS,UAAU,YAC5B,IAAI,CAAE,MAAM,SAAS,OAAO,OAAO,OAAO,MAAM,SAAS,GAAI,OAAO;GAEtE,OAAO;EAET,KAAK;GACH,KAAK,MAAM,SAAS,UAAU,YAC5B,IAAI,MAAM,SAAS,OAAO,OAAO,OAAO,MAAM,SAAS,GAAG,OAAO;GAEnE,OAAO;EAET,KAAK,OACH,OAAO,CAAE,MAAM,SAAS,UAAU,WAAW,OAAO,OAAO,MAAM,SAAS;EAC5E,KAAK,WAAW;GACd,IAAI,UAAU,SAAS,UAAU,OAAO,GACtC,MAAM,IAAI,MACR,YAAY,UAAU,QAAQ,uBAAuB,CAAC,GAAG,WAAW,UAAU,OAAO,CAAC,CAAC,KAAK,MAAM,GACpG;GAEF,MAAM,MAAM,MAAM,MAAM,oBAAoB,UAAU,OAAO;GAC7D,IAAI,QAAQ,KAAA,GACV,MAAM,IAAI,MAAM,qBAAqB,UAAU,QAAQ,yBAAyB;GAElF,OAAO,SAAS,KAAK,OAAO,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|
+
const require_engine_bucket = require("./bucket.cjs");
|
|
3
|
+
const require_engine_condition = require("./condition.cjs");
|
|
4
|
+
const require_engine_actions = require("./actions.cjs");
|
|
5
|
+
const require_engine_time_window = require("./time-window.cjs");
|
|
6
|
+
const require_engine_interpreter = require("./interpreter.cjs");
|
|
7
|
+
const require_engine_time_scale = require("./time-scale.cjs");
|
|
8
|
+
exports.DEVICES_UPDATED_EVENT = require_engine_condition.DEVICES_UPDATED_EVENT;
|
|
9
|
+
exports.PROFILE_UPDATED_EVENT = require_engine_condition.PROFILE_UPDATED_EVENT;
|
|
10
|
+
exports.RegistryActionInvoker = require_engine_actions.RegistryActionInvoker;
|
|
11
|
+
exports.evaluateCondition = require_engine_condition.evaluateCondition;
|
|
12
|
+
exports.hashToBucket = require_engine_bucket.hashToBucket;
|
|
13
|
+
exports.matchesWhere = require_engine_condition.matchesWhere;
|
|
14
|
+
exports.murmur3 = require_engine_bucket.murmur3;
|
|
15
|
+
exports.nextWindowStart = require_engine_time_window.nextWindowStart;
|
|
16
|
+
exports.relevantEvents = require_engine_condition.relevantEvents;
|
|
17
|
+
exports.resolveTimeZone = require_engine_time_window.resolveTimeZone;
|
|
18
|
+
exports.runJourney = require_engine_interpreter.runJourney;
|
|
19
|
+
exports.scaleDurations = require_engine_time_scale.scaleDurations;
|
|
20
|
+
exports.scaleSegmentWindows = require_engine_time_scale.scaleSegmentWindows;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInvocation, ActionInvoker, EngineStep, EventSink, FactSource, JourneyContext, JourneyObserver, JourneyOutcome, MessageSender, MessageTracking, OutboundMessage, PushDevice, SendResult } from "./ports.cjs";
|
|
2
|
+
import { ActionVersionPolicy, RegisteredAction, RegistryActionInvoker } from "./actions.cjs";
|
|
3
|
+
import { hashToBucket, murmur3 } from "./bucket.cjs";
|
|
4
|
+
import { DEVICES_UPDATED_EVENT, EvaluateOptions, PROFILE_UPDATED_EVENT, evaluateCondition, matchesWhere, relevantEvents } from "./condition.cjs";
|
|
5
|
+
import { runJourney } from "./interpreter.cjs";
|
|
6
|
+
import { scaleDurations, scaleSegmentWindows } from "./time-scale.cjs";
|
|
7
|
+
import { nextWindowStart, resolveTimeZone } from "./time-window.cjs";
|
|
8
|
+
export { type ActionInvocation, type ActionInvoker, type ActionVersionPolicy, DEVICES_UPDATED_EVENT, type EngineStep, type EvaluateOptions, type EventSink, type FactSource, type JourneyContext, type JourneyObserver, type JourneyOutcome, type MessageSender, type MessageTracking, type OutboundMessage, PROFILE_UPDATED_EVENT, type PushDevice, type RegisteredAction, RegistryActionInvoker, type SendResult, evaluateCondition, hashToBucket, matchesWhere, murmur3, nextWindowStart, relevantEvents, resolveTimeZone, runJourney, scaleDurations, scaleSegmentWindows };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInvocation, ActionInvoker, EngineStep, EventSink, FactSource, JourneyContext, JourneyObserver, JourneyOutcome, MessageSender, MessageTracking, OutboundMessage, PushDevice, SendResult } from "./ports.mjs";
|
|
2
|
+
import { ActionVersionPolicy, RegisteredAction, RegistryActionInvoker } from "./actions.mjs";
|
|
3
|
+
import { hashToBucket, murmur3 } from "./bucket.mjs";
|
|
4
|
+
import { DEVICES_UPDATED_EVENT, EvaluateOptions, PROFILE_UPDATED_EVENT, evaluateCondition, matchesWhere, relevantEvents } from "./condition.mjs";
|
|
5
|
+
import { runJourney } from "./interpreter.mjs";
|
|
6
|
+
import { scaleDurations, scaleSegmentWindows } from "./time-scale.mjs";
|
|
7
|
+
import { nextWindowStart, resolveTimeZone } from "./time-window.mjs";
|
|
8
|
+
export { type ActionInvocation, type ActionInvoker, type ActionVersionPolicy, DEVICES_UPDATED_EVENT, type EngineStep, type EvaluateOptions, type EventSink, type FactSource, type JourneyContext, type JourneyObserver, type JourneyOutcome, type MessageSender, type MessageTracking, type OutboundMessage, PROFILE_UPDATED_EVENT, type PushDevice, type RegisteredAction, RegistryActionInvoker, type SendResult, evaluateCondition, hashToBucket, matchesWhere, murmur3, nextWindowStart, relevantEvents, resolveTimeZone, runJourney, scaleDurations, scaleSegmentWindows };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { hashToBucket, murmur3 } from "./bucket.mjs";
|
|
2
|
+
import { DEVICES_UPDATED_EVENT, PROFILE_UPDATED_EVENT, evaluateCondition, matchesWhere, relevantEvents } from "./condition.mjs";
|
|
3
|
+
import { RegistryActionInvoker } from "./actions.mjs";
|
|
4
|
+
import { nextWindowStart, resolveTimeZone } from "./time-window.mjs";
|
|
5
|
+
import { runJourney } from "./interpreter.mjs";
|
|
6
|
+
import { scaleDurations, scaleSegmentWindows } from "./time-scale.mjs";
|
|
7
|
+
export { DEVICES_UPDATED_EVENT, PROFILE_UPDATED_EVENT, RegistryActionInvoker, evaluateCondition, hashToBucket, matchesWhere, murmur3, nextWindowStart, relevantEvents, resolveTimeZone, runJourney, scaleDurations, scaleSegmentWindows };
|