@shware/workflow 4.1.1 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/README.md +16 -38
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -2
  3. package/dist/apns-relay.cjs +1 -2
  4. package/dist/apns-relay.d.cts +0 -2
  5. package/dist/apns-relay.d.cts.map +1 -1
  6. package/dist/apns-relay.d.mts +0 -2
  7. package/dist/apns-relay.d.mts.map +1 -1
  8. package/dist/apns-relay.mjs +1 -2
  9. package/dist/apns.cjs +1 -2
  10. package/dist/apns.d.cts +0 -2
  11. package/dist/apns.d.cts.map +1 -1
  12. package/dist/apns.d.mts +0 -2
  13. package/dist/apns.d.mts.map +1 -1
  14. package/dist/apns.mjs +1 -2
  15. package/dist/aws/engine-step.cjs +1 -2
  16. package/dist/aws/engine-step.d.cts +0 -2
  17. package/dist/aws/engine-step.d.cts.map +1 -1
  18. package/dist/aws/engine-step.d.mts +0 -2
  19. package/dist/aws/engine-step.d.mts.map +1 -1
  20. package/dist/aws/engine-step.mjs +1 -2
  21. package/dist/aws/function-url.cjs +1 -2
  22. package/dist/aws/function-url.d.cts +0 -2
  23. package/dist/aws/function-url.d.cts.map +1 -1
  24. package/dist/aws/function-url.d.mts +0 -2
  25. package/dist/aws/function-url.d.mts.map +1 -1
  26. package/dist/aws/function-url.mjs +1 -2
  27. package/dist/aws/index.cjs +3 -5
  28. package/dist/aws/index.cjs.map +1 -1
  29. package/dist/aws/index.d.cts +1 -3
  30. package/dist/aws/index.d.cts.map +1 -1
  31. package/dist/aws/index.d.mts +1 -3
  32. package/dist/aws/index.d.mts.map +1 -1
  33. package/dist/aws/index.mjs +3 -5
  34. package/dist/aws/index.mjs.map +1 -1
  35. package/dist/aws/instances.cjs +2 -3
  36. package/dist/aws/instances.cjs.map +1 -1
  37. package/dist/aws/instances.d.cts +1 -3
  38. package/dist/aws/instances.d.cts.map +1 -1
  39. package/dist/aws/instances.d.mts +1 -3
  40. package/dist/aws/instances.d.mts.map +1 -1
  41. package/dist/aws/instances.mjs +2 -3
  42. package/dist/aws/instances.mjs.map +1 -1
  43. package/dist/aws/lambda-api.cjs +1 -2
  44. package/dist/aws/lambda-api.d.cts +0 -2
  45. package/dist/aws/lambda-api.d.cts.map +1 -1
  46. package/dist/aws/lambda-api.d.mts +0 -2
  47. package/dist/aws/lambda-api.d.mts.map +1 -1
  48. package/dist/aws/lambda-api.mjs +1 -2
  49. package/dist/client.cjs +1 -2
  50. package/dist/client.d.cts +0 -2
  51. package/dist/client.d.cts.map +1 -1
  52. package/dist/client.d.mts +0 -2
  53. package/dist/client.d.mts.map +1 -1
  54. package/dist/client.mjs +1 -2
  55. package/dist/cloudflare/bindings.cjs +1 -2
  56. package/dist/cloudflare/bindings.cjs.map +1 -1
  57. package/dist/cloudflare/bindings.d.cts +0 -21
  58. package/dist/cloudflare/bindings.d.cts.map +1 -1
  59. package/dist/cloudflare/bindings.d.mts +0 -21
  60. package/dist/cloudflare/bindings.d.mts.map +1 -1
  61. package/dist/cloudflare/bindings.mjs +1 -2
  62. package/dist/cloudflare/bindings.mjs.map +1 -1
  63. package/dist/cloudflare/index.cjs +0 -5
  64. package/dist/cloudflare/index.d.cts +4 -6
  65. package/dist/cloudflare/index.d.mts +4 -6
  66. package/dist/cloudflare/index.mjs +2 -4
  67. package/dist/cloudflare/runner.cjs +4 -6
  68. package/dist/cloudflare/runner.cjs.map +1 -1
  69. package/dist/cloudflare/runner.d.cts +3 -5
  70. package/dist/cloudflare/runner.d.cts.map +1 -1
  71. package/dist/cloudflare/runner.d.mts +3 -5
  72. package/dist/cloudflare/runner.d.mts.map +1 -1
  73. package/dist/cloudflare/runner.mjs +4 -6
  74. package/dist/cloudflare/runner.mjs.map +1 -1
  75. package/dist/cloudflare/worker.cjs +1 -2
  76. package/dist/cloudflare/worker.d.cts +0 -2
  77. package/dist/cloudflare/worker.d.cts.map +1 -1
  78. package/dist/cloudflare/worker.d.mts +0 -2
  79. package/dist/cloudflare/worker.d.mts.map +1 -1
  80. package/dist/cloudflare/worker.mjs +1 -2
  81. package/dist/cloudflare/workers.d.cts +0 -2
  82. package/dist/cloudflare/workers.d.cts.map +1 -1
  83. package/dist/cloudflare/workers.d.mts +0 -2
  84. package/dist/cloudflare/workers.d.mts.map +1 -1
  85. package/dist/config.cjs +1 -2
  86. package/dist/config.cjs.map +1 -1
  87. package/dist/config.d.cts +1 -3
  88. package/dist/config.d.cts.map +1 -1
  89. package/dist/config.d.mts +1 -3
  90. package/dist/config.d.mts.map +1 -1
  91. package/dist/config.mjs +1 -2
  92. package/dist/config.mjs.map +1 -1
  93. package/dist/contract.cjs +1 -2
  94. package/dist/contract.d.cts +0 -2
  95. package/dist/contract.d.cts.map +1 -1
  96. package/dist/contract.d.mts +0 -2
  97. package/dist/contract.d.mts.map +1 -1
  98. package/dist/contract.mjs +1 -2
  99. package/dist/dsl/action.cjs +1 -2
  100. package/dist/dsl/action.d.cts +0 -2
  101. package/dist/dsl/action.d.cts.map +1 -1
  102. package/dist/dsl/action.d.mts +0 -2
  103. package/dist/dsl/action.d.mts.map +1 -1
  104. package/dist/dsl/action.mjs +1 -2
  105. package/dist/dsl/base.cjs +1 -2
  106. package/dist/dsl/base.d.cts +0 -2
  107. package/dist/dsl/base.d.cts.map +1 -1
  108. package/dist/dsl/base.d.mts +0 -2
  109. package/dist/dsl/base.d.mts.map +1 -1
  110. package/dist/dsl/base.mjs +1 -2
  111. package/dist/dsl/bundle.cjs +1 -2
  112. package/dist/dsl/bundle.d.cts +0 -2
  113. package/dist/dsl/bundle.d.cts.map +1 -1
  114. package/dist/dsl/bundle.d.mts +0 -2
  115. package/dist/dsl/bundle.d.mts.map +1 -1
  116. package/dist/dsl/bundle.mjs +1 -2
  117. package/dist/dsl/condition.cjs +1 -2
  118. package/dist/dsl/condition.d.cts +0 -2
  119. package/dist/dsl/condition.d.cts.map +1 -1
  120. package/dist/dsl/condition.d.mts +0 -2
  121. package/dist/dsl/condition.d.mts.map +1 -1
  122. package/dist/dsl/condition.mjs +1 -2
  123. package/dist/dsl/flow.cjs +1 -2
  124. package/dist/dsl/flow.d.cts +0 -2
  125. package/dist/dsl/flow.d.cts.map +1 -1
  126. package/dist/dsl/flow.d.mts +0 -2
  127. package/dist/dsl/flow.d.mts.map +1 -1
  128. package/dist/dsl/flow.mjs +1 -2
  129. package/dist/dsl/refs.cjs +1 -2
  130. package/dist/dsl/refs.d.cts +0 -2
  131. package/dist/dsl/refs.d.cts.map +1 -1
  132. package/dist/dsl/refs.d.mts +0 -2
  133. package/dist/dsl/refs.d.mts.map +1 -1
  134. package/dist/dsl/refs.mjs +1 -2
  135. package/dist/dsl/template.cjs +1 -2
  136. package/dist/dsl/template.d.cts +0 -2
  137. package/dist/dsl/template.d.cts.map +1 -1
  138. package/dist/dsl/template.d.mts +0 -2
  139. package/dist/dsl/template.d.mts.map +1 -1
  140. package/dist/dsl/template.mjs +1 -2
  141. package/dist/dsl/trigger.cjs +1 -2
  142. package/dist/dsl/trigger.d.cts +0 -2
  143. package/dist/dsl/trigger.d.cts.map +1 -1
  144. package/dist/dsl/trigger.d.mts +0 -2
  145. package/dist/dsl/trigger.d.mts.map +1 -1
  146. package/dist/dsl/trigger.mjs +1 -2
  147. package/dist/dsl/workflow.cjs +1 -2
  148. package/dist/dsl/workflow.d.cts +0 -2
  149. package/dist/dsl/workflow.d.cts.map +1 -1
  150. package/dist/dsl/workflow.d.mts +0 -2
  151. package/dist/dsl/workflow.d.mts.map +1 -1
  152. package/dist/dsl/workflow.mjs +1 -2
  153. package/dist/email-context.cjs +1 -2
  154. package/dist/email-context.d.cts +0 -2
  155. package/dist/email-context.d.cts.map +1 -1
  156. package/dist/email-context.d.mts +0 -2
  157. package/dist/email-context.d.mts.map +1 -1
  158. package/dist/email-context.mjs +1 -2
  159. package/dist/email-sender.cjs +1 -2
  160. package/dist/email-sender.d.cts +0 -2
  161. package/dist/email-sender.d.cts.map +1 -1
  162. package/dist/email-sender.d.mts +0 -2
  163. package/dist/email-sender.d.mts.map +1 -1
  164. package/dist/email-sender.mjs +1 -2
  165. package/dist/email.cjs +1 -2
  166. package/dist/email.d.cts +0 -2
  167. package/dist/email.d.cts.map +1 -1
  168. package/dist/email.d.mts +0 -2
  169. package/dist/email.d.mts.map +1 -1
  170. package/dist/email.mjs +1 -2
  171. package/dist/engine/actions.cjs +1 -2
  172. package/dist/engine/actions.d.cts +0 -2
  173. package/dist/engine/actions.d.cts.map +1 -1
  174. package/dist/engine/actions.d.mts +0 -2
  175. package/dist/engine/actions.d.mts.map +1 -1
  176. package/dist/engine/actions.mjs +1 -2
  177. package/dist/engine/bucket.cjs +1 -2
  178. package/dist/engine/bucket.d.cts +0 -2
  179. package/dist/engine/bucket.d.cts.map +1 -1
  180. package/dist/engine/bucket.d.mts +0 -2
  181. package/dist/engine/bucket.d.mts.map +1 -1
  182. package/dist/engine/bucket.mjs +1 -2
  183. package/dist/engine/condition.cjs +3 -4
  184. package/dist/engine/condition.cjs.map +1 -1
  185. package/dist/engine/condition.d.cts +1 -3
  186. package/dist/engine/condition.d.cts.map +1 -1
  187. package/dist/engine/condition.d.mts +1 -3
  188. package/dist/engine/condition.d.mts.map +1 -1
  189. package/dist/engine/condition.mjs +3 -4
  190. package/dist/engine/condition.mjs.map +1 -1
  191. package/dist/engine/duration.cjs +1 -2
  192. package/dist/engine/duration.d.cts +0 -2
  193. package/dist/engine/duration.d.cts.map +1 -1
  194. package/dist/engine/duration.d.mts +0 -2
  195. package/dist/engine/duration.d.mts.map +1 -1
  196. package/dist/engine/duration.mjs +1 -2
  197. package/dist/engine/interpreter.cjs +1 -2
  198. package/dist/engine/interpreter.d.cts +0 -2
  199. package/dist/engine/interpreter.d.cts.map +1 -1
  200. package/dist/engine/interpreter.d.mts +0 -2
  201. package/dist/engine/interpreter.d.mts.map +1 -1
  202. package/dist/engine/interpreter.mjs +1 -2
  203. package/dist/engine/ports.d.cts +1 -3
  204. package/dist/engine/ports.d.cts.map +1 -1
  205. package/dist/engine/ports.d.mts +1 -3
  206. package/dist/engine/ports.d.mts.map +1 -1
  207. package/dist/engine/recipient.cjs +1 -2
  208. package/dist/engine/recipient.d.cts +0 -2
  209. package/dist/engine/recipient.d.cts.map +1 -1
  210. package/dist/engine/recipient.d.mts +0 -2
  211. package/dist/engine/recipient.d.mts.map +1 -1
  212. package/dist/engine/recipient.mjs +1 -2
  213. package/dist/engine/retry.cjs +1 -2
  214. package/dist/engine/retry.d.cts +0 -2
  215. package/dist/engine/retry.d.cts.map +1 -1
  216. package/dist/engine/retry.d.mts +0 -2
  217. package/dist/engine/retry.d.mts.map +1 -1
  218. package/dist/engine/retry.mjs +1 -2
  219. package/dist/engine/time-scale.cjs +1 -2
  220. package/dist/engine/time-scale.d.cts +0 -2
  221. package/dist/engine/time-scale.d.cts.map +1 -1
  222. package/dist/engine/time-scale.d.mts +0 -2
  223. package/dist/engine/time-scale.d.mts.map +1 -1
  224. package/dist/engine/time-scale.mjs +1 -2
  225. package/dist/engine/time-window.cjs +1 -2
  226. package/dist/engine/time-window.d.cts +0 -2
  227. package/dist/engine/time-window.d.cts.map +1 -1
  228. package/dist/engine/time-window.d.mts +0 -2
  229. package/dist/engine/time-window.d.mts.map +1 -1
  230. package/dist/engine/time-window.mjs +1 -2
  231. package/dist/fcm.cjs +1 -2
  232. package/dist/fcm.d.cts +0 -2
  233. package/dist/fcm.d.cts.map +1 -1
  234. package/dist/fcm.d.mts +0 -2
  235. package/dist/fcm.d.mts.map +1 -1
  236. package/dist/fcm.mjs +1 -2
  237. package/dist/hash.cjs +1 -2
  238. package/dist/hash.d.cts +0 -2
  239. package/dist/hash.d.cts.map +1 -1
  240. package/dist/hash.d.mts +0 -2
  241. package/dist/hash.d.mts.map +1 -1
  242. package/dist/hash.mjs +1 -2
  243. package/dist/host/auth.cjs +1 -2
  244. package/dist/host/auth.d.cts +0 -2
  245. package/dist/host/auth.d.cts.map +1 -1
  246. package/dist/host/auth.d.mts +0 -2
  247. package/dist/host/auth.d.mts.map +1 -1
  248. package/dist/host/auth.mjs +1 -2
  249. package/dist/host/channels.cjs +1 -2
  250. package/dist/host/channels.d.cts +1 -3
  251. package/dist/host/channels.d.cts.map +1 -1
  252. package/dist/host/channels.d.mts +1 -3
  253. package/dist/host/channels.d.mts.map +1 -1
  254. package/dist/host/channels.mjs +1 -2
  255. package/dist/host/execute.cjs +1 -2
  256. package/dist/host/execute.d.cts +1 -3
  257. package/dist/host/execute.d.cts.map +1 -1
  258. package/dist/host/execute.d.mts +1 -3
  259. package/dist/host/execute.d.mts.map +1 -1
  260. package/dist/host/execute.mjs +1 -2
  261. package/dist/host/fresh-read.cjs +1 -2
  262. package/dist/host/fresh-read.d.cts +0 -2
  263. package/dist/host/fresh-read.d.cts.map +1 -1
  264. package/dist/host/fresh-read.d.mts +0 -2
  265. package/dist/host/fresh-read.d.mts.map +1 -1
  266. package/dist/host/fresh-read.mjs +1 -2
  267. package/dist/host/http.cjs +4 -6
  268. package/dist/host/http.cjs.map +1 -1
  269. package/dist/host/http.d.cts +2 -4
  270. package/dist/host/http.d.cts.map +1 -1
  271. package/dist/host/http.d.mts +2 -4
  272. package/dist/host/http.d.mts.map +1 -1
  273. package/dist/host/http.mjs +4 -6
  274. package/dist/host/http.mjs.map +1 -1
  275. package/dist/host/ingest.cjs +12 -24
  276. package/dist/host/ingest.cjs.map +1 -1
  277. package/dist/host/ingest.d.cts +8 -15
  278. package/dist/host/ingest.d.cts.map +1 -1
  279. package/dist/host/ingest.d.mts +8 -15
  280. package/dist/host/ingest.d.mts.map +1 -1
  281. package/dist/host/ingest.mjs +13 -24
  282. package/dist/host/ingest.mjs.map +1 -1
  283. package/dist/host/journey-host.cjs +3 -6
  284. package/dist/host/journey-host.cjs.map +1 -1
  285. package/dist/host/journey-host.d.cts +6 -8
  286. package/dist/host/journey-host.d.cts.map +1 -1
  287. package/dist/host/journey-host.d.mts +6 -8
  288. package/dist/host/journey-host.d.mts.map +1 -1
  289. package/dist/host/journey-host.mjs +3 -6
  290. package/dist/host/journey-host.mjs.map +1 -1
  291. package/dist/host/platform.cjs +1 -2
  292. package/dist/host/platform.cjs.map +1 -1
  293. package/dist/host/platform.d.cts +1 -9
  294. package/dist/host/platform.d.cts.map +1 -1
  295. package/dist/host/platform.d.mts +1 -9
  296. package/dist/host/platform.d.mts.map +1 -1
  297. package/dist/host/platform.mjs +1 -2
  298. package/dist/host/platform.mjs.map +1 -1
  299. package/dist/host/senders.cjs +1 -2
  300. package/dist/host/senders.d.cts +0 -2
  301. package/dist/host/senders.d.cts.map +1 -1
  302. package/dist/host/senders.d.mts +0 -2
  303. package/dist/host/senders.d.mts.map +1 -1
  304. package/dist/host/senders.mjs +1 -2
  305. package/dist/http2-client.cjs +1 -2
  306. package/dist/http2-client.d.cts +0 -2
  307. package/dist/http2-client.d.cts.map +1 -1
  308. package/dist/http2-client.d.mts +0 -2
  309. package/dist/http2-client.d.mts.map +1 -1
  310. package/dist/http2-client.mjs +1 -2
  311. package/dist/ir.cjs +1 -2
  312. package/dist/ir.d.cts +0 -2
  313. package/dist/ir.d.cts.map +1 -1
  314. package/dist/ir.d.mts +0 -2
  315. package/dist/ir.d.mts.map +1 -1
  316. package/dist/ir.mjs +1 -2
  317. package/dist/jwt.cjs +1 -2
  318. package/dist/jwt.d.cts +0 -2
  319. package/dist/jwt.d.cts.map +1 -1
  320. package/dist/jwt.d.mts +0 -2
  321. package/dist/jwt.d.mts.map +1 -1
  322. package/dist/jwt.mjs +1 -2
  323. package/dist/plan.cjs +1 -2
  324. package/dist/plan.d.cts +0 -2
  325. package/dist/plan.d.cts.map +1 -1
  326. package/dist/plan.d.mts +0 -2
  327. package/dist/plan.d.mts.map +1 -1
  328. package/dist/plan.mjs +1 -2
  329. package/dist/postgres-js.cjs +1 -2
  330. package/dist/postgres-js.d.cts +0 -2
  331. package/dist/postgres-js.d.cts.map +1 -1
  332. package/dist/postgres-js.d.mts +0 -2
  333. package/dist/postgres-js.d.mts.map +1 -1
  334. package/dist/postgres-js.mjs +1 -2
  335. package/dist/provenance.cjs +1 -2
  336. package/dist/provenance.d.cts +0 -2
  337. package/dist/provenance.d.cts.map +1 -1
  338. package/dist/provenance.d.mts +0 -2
  339. package/dist/provenance.d.mts.map +1 -1
  340. package/dist/provenance.mjs +1 -2
  341. package/dist/push.cjs +1 -2
  342. package/dist/push.d.cts +0 -2
  343. package/dist/push.d.cts.map +1 -1
  344. package/dist/push.d.mts +0 -2
  345. package/dist/push.d.mts.map +1 -1
  346. package/dist/push.mjs +1 -2
  347. package/dist/react-email.cjs +1 -2
  348. package/dist/react-email.d.cts +0 -2
  349. package/dist/react-email.d.cts.map +1 -1
  350. package/dist/react-email.d.mts +0 -2
  351. package/dist/react-email.d.mts.map +1 -1
  352. package/dist/react-email.mjs +1 -2
  353. package/dist/reporting/classify.cjs +1 -2
  354. package/dist/reporting/classify.d.cts +0 -2
  355. package/dist/reporting/classify.d.cts.map +1 -1
  356. package/dist/reporting/classify.d.mts +0 -2
  357. package/dist/reporting/classify.d.mts.map +1 -1
  358. package/dist/reporting/classify.mjs +1 -2
  359. package/dist/reporting/observer.cjs +1 -2
  360. package/dist/reporting/observer.d.cts +0 -2
  361. package/dist/reporting/observer.d.cts.map +1 -1
  362. package/dist/reporting/observer.d.mts +0 -2
  363. package/dist/reporting/observer.d.mts.map +1 -1
  364. package/dist/reporting/observer.mjs +1 -2
  365. package/dist/reporting/tracking.cjs +1 -2
  366. package/dist/reporting/tracking.d.cts +0 -2
  367. package/dist/reporting/tracking.d.cts.map +1 -1
  368. package/dist/reporting/tracking.d.mts +0 -2
  369. package/dist/reporting/tracking.d.mts.map +1 -1
  370. package/dist/reporting/tracking.mjs +1 -2
  371. package/dist/runtime.cjs +1 -2
  372. package/dist/runtime.d.cts +0 -2
  373. package/dist/runtime.d.cts.map +1 -1
  374. package/dist/runtime.d.mts +0 -2
  375. package/dist/runtime.d.mts.map +1 -1
  376. package/dist/runtime.mjs +1 -2
  377. package/dist/store/erasure.cjs +1 -2
  378. package/dist/store/erasure.d.cts +0 -2
  379. package/dist/store/erasure.d.cts.map +1 -1
  380. package/dist/store/erasure.d.mts +0 -2
  381. package/dist/store/erasure.d.mts.map +1 -1
  382. package/dist/store/erasure.mjs +1 -2
  383. package/dist/store/facts.cjs +2 -3
  384. package/dist/store/facts.cjs.map +1 -1
  385. package/dist/store/facts.d.cts +0 -2
  386. package/dist/store/facts.d.cts.map +1 -1
  387. package/dist/store/facts.d.mts +0 -2
  388. package/dist/store/facts.d.mts.map +1 -1
  389. package/dist/store/facts.mjs +2 -3
  390. package/dist/store/facts.mjs.map +1 -1
  391. package/dist/store/index.cjs +1 -4
  392. package/dist/store/index.cjs.map +1 -1
  393. package/dist/store/index.d.cts +21 -28
  394. package/dist/store/index.d.cts.map +1 -1
  395. package/dist/store/index.d.mts +21 -28
  396. package/dist/store/index.d.mts.map +1 -1
  397. package/dist/store/index.mjs +2 -4
  398. package/dist/store/index.mjs.map +1 -1
  399. package/dist/store/postgres-reporting.cjs +1 -2
  400. package/dist/store/postgres-reporting.d.cts +0 -2
  401. package/dist/store/postgres-reporting.d.cts.map +1 -1
  402. package/dist/store/postgres-reporting.d.mts +0 -2
  403. package/dist/store/postgres-reporting.d.mts.map +1 -1
  404. package/dist/store/postgres-reporting.mjs +1 -2
  405. package/dist/store/postgres.cjs +3 -5
  406. package/dist/store/postgres.cjs.map +1 -1
  407. package/dist/store/postgres.d.cts +2 -5
  408. package/dist/store/postgres.d.cts.map +1 -1
  409. package/dist/store/postgres.d.mts +2 -5
  410. package/dist/store/postgres.d.mts.map +1 -1
  411. package/dist/store/postgres.mjs +3 -5
  412. package/dist/store/postgres.mjs.map +1 -1
  413. package/dist/store/sql.cjs +1 -2
  414. package/dist/store/sql.d.cts +0 -2
  415. package/dist/store/sql.d.cts.map +1 -1
  416. package/dist/store/sql.d.mts +0 -2
  417. package/dist/store/sql.d.mts.map +1 -1
  418. package/dist/store/sql.mjs +1 -2
  419. package/dist/store/tables.cjs +1 -2
  420. package/dist/store/tables.d.cts +0 -2
  421. package/dist/store/tables.d.cts.map +1 -1
  422. package/dist/store/tables.d.mts +0 -2
  423. package/dist/store/tables.d.mts.map +1 -1
  424. package/dist/store/tables.mjs +1 -2
  425. package/dist/store/user-lock.cjs +1 -2
  426. package/dist/store/user-lock.d.cts +0 -2
  427. package/dist/store/user-lock.d.cts.map +1 -1
  428. package/dist/store/user-lock.d.mts +0 -2
  429. package/dist/store/user-lock.d.mts.map +1 -1
  430. package/dist/store/user-lock.mjs +1 -2
  431. package/dist/templates.cjs +1 -2
  432. package/dist/templates.d.cts +0 -2
  433. package/dist/templates.d.cts.map +1 -1
  434. package/dist/templates.d.mts +0 -2
  435. package/dist/templates.d.mts.map +1 -1
  436. package/dist/templates.mjs +1 -2
  437. package/dist/transports/cloudflare-email.cjs +1 -2
  438. package/dist/transports/cloudflare-email.d.cts +1 -3
  439. package/dist/transports/cloudflare-email.d.cts.map +1 -1
  440. package/dist/transports/cloudflare-email.d.mts +1 -3
  441. package/dist/transports/cloudflare-email.d.mts.map +1 -1
  442. package/dist/transports/cloudflare-email.mjs +1 -2
  443. package/dist/transports/ses.cjs +1 -2
  444. package/dist/transports/ses.d.cts +0 -2
  445. package/dist/transports/ses.d.cts.map +1 -1
  446. package/dist/transports/ses.d.mts +0 -2
  447. package/dist/transports/ses.d.mts.map +1 -1
  448. package/dist/transports/ses.mjs +1 -2
  449. package/dist/transports/sigv4.cjs +1 -2
  450. package/dist/transports/sigv4.d.cts +0 -2
  451. package/dist/transports/sigv4.d.cts.map +1 -1
  452. package/dist/transports/sigv4.d.mts +0 -2
  453. package/dist/transports/sigv4.d.mts.map +1 -1
  454. package/dist/transports/sigv4.mjs +1 -2
  455. package/dist/webhooks.cjs +1 -2
  456. package/dist/webhooks.d.cts +0 -2
  457. package/dist/webhooks.d.cts.map +1 -1
  458. package/dist/webhooks.d.mts +0 -2
  459. package/dist/webhooks.d.mts.map +1 -1
  460. package/dist/webhooks.mjs +1 -2
  461. package/dist/webpush.cjs +1 -2
  462. package/dist/webpush.d.cts +0 -2
  463. package/dist/webpush.d.cts.map +1 -1
  464. package/dist/webpush.d.mts +0 -2
  465. package/dist/webpush.d.mts.map +1 -1
  466. package/dist/webpush.mjs +1 -2
  467. package/package.json +5 -7
  468. package/dist/cloudflare/d1-env.cjs +0 -17
  469. package/dist/cloudflare/d1-env.cjs.map +0 -1
  470. package/dist/cloudflare/d1-env.d.cts +0 -12
  471. package/dist/cloudflare/d1-env.d.cts.map +0 -1
  472. package/dist/cloudflare/d1-env.d.mts +0 -12
  473. package/dist/cloudflare/d1-env.d.mts.map +0 -1
  474. package/dist/cloudflare/d1-env.mjs +0 -16
  475. package/dist/cloudflare/d1-env.mjs.map +0 -1
  476. package/dist/cloudflare/schema.sql +0 -148
  477. package/dist/store/d1.cjs +0 -245
  478. package/dist/store/d1.cjs.map +0 -1
  479. package/dist/store/d1.d.cts +0 -73
  480. package/dist/store/d1.d.cts.map +0 -1
  481. package/dist/store/d1.d.mts +0 -73
  482. package/dist/store/d1.d.mts.map +0 -1
  483. package/dist/store/d1.mjs +0 -244
  484. package/dist/store/d1.mjs.map +0 -1
  485. package/src/cloudflare/schema.sql +0 -148
@@ -1,7 +1,6 @@
1
1
  import { ScalarIR } from "./ir.cjs";
2
2
  import { MessageSender, MessageTracking, OutboundMessage } from "./engine/ports.cjs";
3
3
  import { EmailAddress, ResolvedEmail } from "./email.cjs";
4
- //#region src/email-sender.d.ts
5
4
  /**
6
5
  * The email channel, split where the runtime stops mattering: `EmailSender` renders a copy,
7
6
  * applies its tracking and commits the tracked links — the same on every host — and hands the
@@ -84,5 +83,4 @@ export declare function unsubscribeHeaders(unsubscribeUrl: string | undefined, o
84
83
  * end when there is none.
85
84
  */
86
85
  export declare function trackEmail(html: string, tracking: MessageTracking, unsubscribeUrl?: string): string;
87
- //#endregion
88
86
  //# sourceMappingURL=email-sender.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-sender.d.cts","names":[],"sources":["../src/email-sender.ts"],"mappings":";;;;;;;;;;;iBAYiB,sBAAsB;EACrC;EACA;;;;;;;;;YAUU,iBACV,kBACA,OAAO,eAAe,0BACnB,QAAQ;;iBAGI;EACf,MAAM;EACN;EACA,UAAU;EACV;EACA;;;;;EAKA,UAAU,SAAS;;;;;;EAMnB;;;;;;iBAOe;EACf,KAAK,SAAS,eAAe;IAAU;;;iBAGxB;EACf,WAAW;EACX,QAAQ;;;;;;;qBAQG,uBAAuB;mBACL;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB;;;;;;;;;;;;;;wBAuCxB,mBACd,oCACA,+BACC;;;;;;;;wBAsBa,WACd,cACA,UAAU,iBACV"}
1
+ {"version":3,"file":"email-sender.d.cts","names":[],"sources":["../src/email-sender.ts"],"mappings":";;;;;;;;;;iBAYiB,sBAAsB;EACrC;EACA;;;;;;;;;YAUU,iBACV,kBACA,OAAO,eAAe,0BACnB,QAAQ;;iBAGI;EACf,MAAM;EACN;EACA,UAAU;EACV;EACA;;;;;EAKA,UAAU,SAAS;;;;;;EAMnB;;;;;;iBAOe;EACf,KAAK,SAAS,eAAe;IAAU;;;iBAGxB;EACf,WAAW;EACX,QAAQ;;;;;;;qBAQG,uBAAuB;mBACL;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB;;;;;;;;;;;;;;wBAuCxB,mBACd,oCACA,+BACC;;;;;;;;wBAsBa,WACd,cACA,UAAU,iBACV"}
@@ -1,7 +1,6 @@
1
1
  import { ScalarIR } from "./ir.mjs";
2
2
  import { MessageSender, MessageTracking, OutboundMessage } from "./engine/ports.mjs";
3
3
  import { EmailAddress, ResolvedEmail } from "./email.mjs";
4
- //#region src/email-sender.d.ts
5
4
  /**
6
5
  * The email channel, split where the runtime stops mattering: `EmailSender` renders a copy,
7
6
  * applies its tracking and commits the tracked links — the same on every host — and hands the
@@ -84,5 +83,4 @@ export declare function unsubscribeHeaders(unsubscribeUrl: string | undefined, o
84
83
  * end when there is none.
85
84
  */
86
85
  export declare function trackEmail(html: string, tracking: MessageTracking, unsubscribeUrl?: string): string;
87
- //#endregion
88
86
  //# sourceMappingURL=email-sender.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-sender.d.mts","names":[],"sources":["../src/email-sender.ts"],"mappings":";;;;;;;;;;;iBAYiB,sBAAsB;EACrC;EACA;;;;;;;;;YAUU,iBACV,kBACA,OAAO,eAAe,0BACnB,QAAQ;;iBAGI;EACf,MAAM;EACN;EACA,UAAU;EACV;EACA;;;;;EAKA,UAAU,SAAS;;;;;;EAMnB;;;;;;iBAOe;EACf,KAAK,SAAS,eAAe;IAAU;;;iBAGxB;EACf,WAAW;EACX,QAAQ;;;;;;;qBAQG,uBAAuB;mBACL;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB;;;;;;;;;;;;;;wBAuCxB,mBACd,oCACA,+BACC;;;;;;;;wBAsBa,WACd,cACA,UAAU,iBACV"}
1
+ {"version":3,"file":"email-sender.d.mts","names":[],"sources":["../src/email-sender.ts"],"mappings":";;;;;;;;;;iBAYiB,sBAAsB;EACrC;EACA;;;;;;;;;YAUU,iBACV,kBACA,OAAO,eAAe,0BACnB,QAAQ;;iBAGI;EACf,MAAM;EACN;EACA,UAAU;EACV;EACA;;;;;EAKA,UAAU,SAAS;;;;;;EAMnB;;;;;;iBAOe;EACf,KAAK,SAAS,eAAe;IAAU;;;iBAGxB;EACf,WAAW;EACX,QAAQ;;;;;;;qBAQG,uBAAuB;mBACL;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB;;;;;;;;;;;;;;wBAuCxB,mBACd,oCACA,+BACC;;;;;;;;wBAsBa,WACd,cACA,UAAU,iBACV"}
@@ -1,5 +1,5 @@
1
1
  import { isUnsubscribeLink } from "./email.mjs";
2
- //#region src/email-sender.ts
2
+ // src/email-sender.ts
3
3
  /**
4
4
  * The email channel over any transport: render → tracking applied to the HTML → the tracked
5
5
  * links committed → the transport. The links resolve before the email exists anywhere a
@@ -77,7 +77,6 @@ function unescapeAttribute(value) {
77
77
  function escapeAttribute(value) {
78
78
  return value.replaceAll("&", "&").replaceAll("\"", """);
79
79
  }
80
- //#endregion
81
80
  export { EmailSender, trackEmail, unsubscribeHeaders };
82
81
 
83
82
  //# sourceMappingURL=email-sender.mjs.map
package/dist/email.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/email.ts
2
+ // src/email.ts
3
3
  /** `Name <email>`, or the bare address. */
4
4
  function formatEmailAddress(address) {
5
5
  if (typeof address === "string") return address;
@@ -80,7 +80,6 @@ function isUnsubscribeLink(url, unsubscribeUrl) {
80
80
  return false;
81
81
  }
82
82
  }
83
- //#endregion
84
83
  exports.assertEmailAddress = assertEmailAddress;
85
84
  exports.assertEmailConfig = assertEmailConfig;
86
85
  exports.assertEmailMetadata = assertEmailMetadata;
package/dist/email.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { EmailTemplate } from "./templates.cjs";
2
- //#region src/email.d.ts
3
2
  /**
4
3
  * Email metadata: who a template's email comes from, where replies go, and the unsubscribe link
5
4
  * its layout carries. Each `emailTemplate` declares its own `from` (and `replyTo`, if replies should
@@ -65,5 +64,4 @@ export declare function assertEmailMetadata(template: {
65
64
  }, where: string): void;
66
65
  /** The unsubscribe link may carry its own query (a token, a list): the path names it. */
67
66
  export declare function isUnsubscribeLink(url: string, unsubscribeUrl: string | undefined): boolean;
68
- //#endregion
69
67
  //# sourceMappingURL=email.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.cts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;;;;;;;YAYY;EAA0B;EAAe;;;wBAGrC,mBAAmB,SAAS;;;;;;wBAa5B,YAAY,SAAS;;iBAepB;;;;;;EAMf;;EAEA;;;;;;IAME;;;;iBAKa;EACf,MAAM;;EAEN,UAAU;;EAEV;;;wBAIc,aACd,UAAU,KAAK,uDACf,SAAS,cACR;;wBAYa,mBAAmB,kBAAkB;;wBAkBrC,qBAAqB,cAAc;;wBAanC,kBACd;EAAU,QAAQ;GAClB,WAAW,SAAS;;wBA0BN,oBACd;EAAY;EAAgB;EAAmB;GAC/C;;wBAUc,kBAAkB,aAAa"}
1
+ {"version":3,"file":"email.d.cts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;;;;;;YAYY;EAA0B;EAAe;;;wBAGrC,mBAAmB,SAAS;;;;;;wBAa5B,YAAY,SAAS;;iBAepB;;;;;;EAMf;;EAEA;;;;;;IAME;;;;iBAKa;EACf,MAAM;;EAEN,UAAU;;EAEV;;;wBAIc,aACd,UAAU,KAAK,uDACf,SAAS,cACR;;wBAYa,mBAAmB,kBAAkB;;wBAkBrC,qBAAqB,cAAc;;wBAanC,kBACd;EAAU,QAAQ;GAClB,WAAW,SAAS;;wBA0BN,oBACd;EAAY;EAAgB;EAAmB;GAC/C;;wBAUc,kBAAkB,aAAa"}
package/dist/email.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { EmailTemplate } from "./templates.mjs";
2
- //#region src/email.d.ts
3
2
  /**
4
3
  * Email metadata: who a template's email comes from, where replies go, and the unsubscribe link
5
4
  * its layout carries. Each `emailTemplate` declares its own `from` (and `replyTo`, if replies should
@@ -65,5 +64,4 @@ export declare function assertEmailMetadata(template: {
65
64
  }, where: string): void;
66
65
  /** The unsubscribe link may carry its own query (a token, a list): the path names it. */
67
66
  export declare function isUnsubscribeLink(url: string, unsubscribeUrl: string | undefined): boolean;
68
- //#endregion
69
67
  //# sourceMappingURL=email.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.mts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;;;;;;;YAYY;EAA0B;EAAe;;;wBAGrC,mBAAmB,SAAS;;;;;;wBAa5B,YAAY,SAAS;;iBAepB;;;;;;EAMf;;EAEA;;;;;;IAME;;;;iBAKa;EACf,MAAM;;EAEN,UAAU;;EAEV;;;wBAIc,aACd,UAAU,KAAK,uDACf,SAAS,cACR;;wBAYa,mBAAmB,kBAAkB;;wBAkBrC,qBAAqB,cAAc;;wBAanC,kBACd;EAAU,QAAQ;GAClB,WAAW,SAAS;;wBA0BN,oBACd;EAAY;EAAgB;EAAmB;GAC/C;;wBAUc,kBAAkB,aAAa"}
1
+ {"version":3,"file":"email.d.mts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;;;;;;YAYY;EAA0B;EAAe;;;wBAGrC,mBAAmB,SAAS;;;;;;wBAa5B,YAAY,SAAS;;iBAepB;;;;;;EAMf;;EAEA;;;;;;IAME;;;;iBAKa;EACf,MAAM;;EAEN,UAAU;;EAEV;;;wBAIc,aACd,UAAU,KAAK,uDACf,SAAS,cACR;;wBAYa,mBAAmB,kBAAkB;;wBAkBrC,qBAAqB,cAAc;;wBAanC,kBACd;EAAU,QAAQ;GAClB,WAAW,SAAS;;wBA0BN,oBACd;EAAY;EAAgB;EAAmB;GAC/C;;wBAUc,kBAAkB,aAAa"}
package/dist/email.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/email.ts
1
+ // src/email.ts
2
2
  /** `Name <email>`, or the bare address. */
3
3
  function formatEmailAddress(address) {
4
4
  if (typeof address === "string") return address;
@@ -79,7 +79,6 @@ function isUnsubscribeLink(url, unsubscribeUrl) {
79
79
  return false;
80
80
  }
81
81
  }
82
- //#endregion
83
82
  export { assertEmailAddress, assertEmailConfig, assertEmailMetadata, assertUnsubscribeUrl, formatEmailAddress, isUnsubscribeLink, mimeAddress, resolveEmail };
84
83
 
85
84
  //# sourceMappingURL=email.mjs.map
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/engine/actions.ts
2
+ // src/engine/actions.ts
3
3
  var RegistryActionInvoker = class {
4
4
  registry;
5
5
  constructor(actions) {
@@ -14,7 +14,6 @@ var RegistryActionInvoker = class {
14
14
  });
15
15
  }
16
16
  };
17
- //#endregion
18
17
  exports.RegistryActionInvoker = RegistryActionInvoker;
19
18
 
20
19
  //# sourceMappingURL=actions.cjs.map
@@ -1,6 +1,5 @@
1
1
  import { ScalarIR } from "../ir.cjs";
2
2
  import { ActionInvocation, ActionInvoker } from "./ports.cjs";
3
- //#region src/engine/actions.d.ts
4
3
  /**
5
4
  * The default ActionInvoker: a name → handler registry (the runtime half of
6
5
  * the dual-plane model — IR carries identity, the deployed bundle carries
@@ -25,5 +24,4 @@ export declare class RegistryActionInvoker implements ActionInvoker {
25
24
  constructor(actions: readonly RegisteredAction[]);
26
25
  invoke(invocation: ActionInvocation): Promise<void>;
27
26
  }
28
- //#endregion
29
27
  //# sourceMappingURL=actions.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.cts","names":[],"sources":["../../src/engine/actions.ts"],"mappings":";;;;;;;;;;;;;;iBAeiB;WACN;;EAET,QACE,MAAM,eAAe,uBACrB;IAAO;IAAgB;MACtB;;qBAGQ,iCAAiC;mBAC3B;EAEjB,YAAY,kBAAkB;EAIxB,OAAO,YAAY,mBAAmB"}
1
+ {"version":3,"file":"actions.d.cts","names":[],"sources":["../../src/engine/actions.ts"],"mappings":";;;;;;;;;;;;;iBAeiB;WACN;;EAET,QACE,MAAM,eAAe,uBACrB;IAAO;IAAgB;MACtB;;qBAGQ,iCAAiC;mBAC3B;EAEjB,YAAY,kBAAkB;EAIxB,OAAO,YAAY,mBAAmB"}
@@ -1,6 +1,5 @@
1
1
  import { ScalarIR } from "../ir.mjs";
2
2
  import { ActionInvocation, ActionInvoker } from "./ports.mjs";
3
- //#region src/engine/actions.d.ts
4
3
  /**
5
4
  * The default ActionInvoker: a name → handler registry (the runtime half of
6
5
  * the dual-plane model — IR carries identity, the deployed bundle carries
@@ -25,5 +24,4 @@ export declare class RegistryActionInvoker implements ActionInvoker {
25
24
  constructor(actions: readonly RegisteredAction[]);
26
25
  invoke(invocation: ActionInvocation): Promise<void>;
27
26
  }
28
- //#endregion
29
27
  //# sourceMappingURL=actions.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.mts","names":[],"sources":["../../src/engine/actions.ts"],"mappings":";;;;;;;;;;;;;;iBAeiB;WACN;;EAET,QACE,MAAM,eAAe,uBACrB;IAAO;IAAgB;MACtB;;qBAGQ,iCAAiC;mBAC3B;EAEjB,YAAY,kBAAkB;EAIxB,OAAO,YAAY,mBAAmB"}
1
+ {"version":3,"file":"actions.d.mts","names":[],"sources":["../../src/engine/actions.ts"],"mappings":";;;;;;;;;;;;;iBAeiB;WACN;;EAET,QACE,MAAM,eAAe,uBACrB;IAAO;IAAgB;MACtB;;qBAGQ,iCAAiC;mBAC3B;EAEjB,YAAY,kBAAkB;EAIxB,OAAO,YAAY,mBAAmB"}
@@ -1,4 +1,4 @@
1
- //#region src/engine/actions.ts
1
+ // src/engine/actions.ts
2
2
  var RegistryActionInvoker = class {
3
3
  registry;
4
4
  constructor(actions) {
@@ -13,7 +13,6 @@ var RegistryActionInvoker = class {
13
13
  });
14
14
  }
15
15
  };
16
- //#endregion
17
16
  export { RegistryActionInvoker };
18
17
 
19
18
  //# sourceMappingURL=actions.mjs.map
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/engine/bucket.ts
2
+ // src/engine/bucket.ts
3
3
  /**
4
4
  * Cohort bucketing — deterministic assignment of a user to an A/B arm.
5
5
  *
@@ -64,7 +64,6 @@ const BUCKET_RESOLUTION = 1e4;
64
64
  function hashToBucket(input) {
65
65
  return murmur3(utf8.encode(input)) % BUCKET_RESOLUTION;
66
66
  }
67
- //#endregion
68
67
  exports.BUCKET_RESOLUTION = BUCKET_RESOLUTION;
69
68
  exports.hashToBucket = hashToBucket;
70
69
  exports.murmur3 = murmur3;
@@ -1,4 +1,3 @@
1
- //#region src/engine/bucket.d.ts
2
1
  /**
3
2
  * Cohort bucketing — deterministic assignment of a user to an A/B arm.
4
3
  *
@@ -28,5 +27,4 @@ export declare const BUCKET_RESOLUTION = 10000;
28
27
  * regardless of the user id's alphabet.
29
28
  */
30
29
  export declare function hashToBucket(input: string): number;
31
- //#endregion
32
30
  //# sourceMappingURL=bucket.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bucket.d.cts","names":[],"sources":["../../src/engine/bucket.ts"],"mappings":";;;;;;;;;;;;;;;;wBAgBgB,QAAQ,OAAO,YAAY;;;;;;;qBA6C9B;;;;;;wBAOG,aAAa"}
1
+ {"version":3,"file":"bucket.d.cts","names":[],"sources":["../../src/engine/bucket.ts"],"mappings":";;;;;;;;;;;;;;;wBAgBgB,QAAQ,OAAO,YAAY;;;;;;;qBA6C9B;;;;;;wBAOG,aAAa"}
@@ -1,4 +1,3 @@
1
- //#region src/engine/bucket.d.ts
2
1
  /**
3
2
  * Cohort bucketing — deterministic assignment of a user to an A/B arm.
4
3
  *
@@ -28,5 +27,4 @@ export declare const BUCKET_RESOLUTION = 10000;
28
27
  * regardless of the user id's alphabet.
29
28
  */
30
29
  export declare function hashToBucket(input: string): number;
31
- //#endregion
32
30
  //# sourceMappingURL=bucket.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bucket.d.mts","names":[],"sources":["../../src/engine/bucket.ts"],"mappings":";;;;;;;;;;;;;;;;wBAgBgB,QAAQ,OAAO,YAAY;;;;;;;qBA6C9B;;;;;;wBAOG,aAAa"}
1
+ {"version":3,"file":"bucket.d.mts","names":[],"sources":["../../src/engine/bucket.ts"],"mappings":";;;;;;;;;;;;;;;wBAgBgB,QAAQ,OAAO,YAAY;;;;;;;qBA6C9B;;;;;;wBAOG,aAAa"}
@@ -1,4 +1,4 @@
1
- //#region src/engine/bucket.ts
1
+ // src/engine/bucket.ts
2
2
  /**
3
3
  * Cohort bucketing — deterministic assignment of a user to an A/B arm.
4
4
  *
@@ -63,7 +63,6 @@ const BUCKET_RESOLUTION = 1e4;
63
63
  function hashToBucket(input) {
64
64
  return murmur3(utf8.encode(input)) % BUCKET_RESOLUTION;
65
65
  }
66
- //#endregion
67
66
  export { BUCKET_RESOLUTION, hashToBucket, murmur3 };
68
67
 
69
68
  //# sourceMappingURL=bucket.mjs.map
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_engine_recipient = require("./recipient.cjs");
3
- //#region src/engine/condition.ts
3
+ // src/engine/condition.ts
4
4
  /**
5
5
  * ConditionIR evaluation: pure logic, with facts injected through FactSource,
6
- * so the D1 implementation and the in-memory test one share a single set of
6
+ * so the store-backed implementation and the in-memory test one share a single set of
7
7
  * semantics and cannot drift into two evaluators.
8
8
  */
9
9
  async function evaluateCondition(condition, facts, nowMs, opts) {
@@ -12,7 +12,7 @@ async function evaluateCondition(condition, facts, nowMs, opts) {
12
12
  /**
13
13
  * `enclosing` is the chain of segment names currently being expanded. A
14
14
  * segment that reaches itself has no truth value to converge on, and left
15
- * unchecked the recursion runs until memory gives out, one D1 round trip per
15
+ * unchecked the recursion runs until memory gives out, one store round trip per
16
16
  * level — inside a step, so Workflows retries it and the instance never gets
17
17
  * out. Failing immediately keeps it bounded, and the message names the cycle
18
18
  * because only a deployed bundle can fix it. Only the *path* is tracked, so a
@@ -175,7 +175,6 @@ async function relevantEvents(condition, facts) {
175
175
  await walk(condition);
176
176
  return [...found];
177
177
  }
178
- //#endregion
179
178
  exports.DEVICES_UPDATED_EVENT = DEVICES_UPDATED_EVENT;
180
179
  exports.PROFILE_UPDATED_EVENT = PROFILE_UPDATED_EVENT;
181
180
  exports.evaluateCondition = evaluateCondition;
@@ -1 +1 @@
1
- {"version":3,"file":"condition.cjs","names":["RECIPIENT_PROPERTY"],"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 * The wake-up channel for one profile property: `$profile_updated:<path>`. A property predicate\n * subscribes to its own property's channel, and `/identify` fires one per property it patched —\n * so an identify that touches `plan` does not wake a wait on `email`.\n */\nexport function profileUpdatedEvent(path: string): string {\n return `${PROFILE_UPDATED_EVENT}:${path}`;\n}\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 its property's channel (`profileUpdatedEvent(path)`, so an\n * /identify touching that property wakes the wait and one touching another\n * does not); `reachable` contributes the recipient property's channel, or the\n * device channel for push (in_app, slack and discord have no address to wait\n * on). Segment references are expanded, which is why a FactSource is needed to\n * resolve 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(profileUpdatedEvent(c.path));\n break;\n case 'reachable': {\n if (c.channel === 'push') {\n found.add(DEVICES_UPDATED_EVENT);\n break;\n }\n const path = RECIPIENT_PROPERTY[c.channel];\n if (path !== undefined) found.add(profileUpdatedEvent(path));\n break;\n }\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,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AM,2BAAW,IAAI,IAAY;CACjC,eAAe,KAAK,GAA+B;EACjD,QAAQ,EAAE,MAAV;GACE,KAAK;GACL,KAAK;IACH,KAAK,MAAM,SAAS,EAAE,YAAY,MAAM,KAAK,KAAK;IAClD;GACF,KAAK;IACH,MAAM,KAAK,EAAE,SAAS;IACtB;GACF,KAAK;IACH,MAAM,IAAI,EAAE,KAAK;IACjB;GACF,KAAK,WAAW;IACd,IAAI,SAAS,IAAI,EAAE,OAAO,GAAG;IAC7B,SAAS,IAAI,EAAE,OAAO;IACtB,MAAM,MAAM,MAAM,MAAM,oBAAoB,EAAE,OAAO;IACrD,IAAI,KAAK,MAAM,KAAK,GAAG;IACvB;GACF;GACA,KAAK;IACH,MAAM,IAAI,oBAAoB,EAAE,IAAI,CAAC;IACrC;GACF,KAAK,aAAa;IAChB,IAAI,EAAE,YAAY,QAAQ;KACxB,MAAM,IAAI,qBAAqB;KAC/B;IACF;IACA,MAAM,OAAOA,yBAAAA,mBAAmB,EAAE;IAClC,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,oBAAoB,IAAI,CAAC;IAC3D;GACF;EAGF;CACF;CACA,MAAM,KAAK,SAAS;CACpB,OAAO,CAAC,GAAG,KAAK;AAClB"}
1
+ {"version":3,"file":"condition.cjs","names":["RECIPIENT_PROPERTY"],"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 store-backed 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 store 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 * The wake-up channel for one profile property: `$profile_updated:<path>`. A property predicate\n * subscribes to its own property's channel, and `/identify` fires one per property it patched —\n * so an identify that touches `plan` does not wake a wait on `email`.\n */\nexport function profileUpdatedEvent(path: string): string {\n return `${PROFILE_UPDATED_EVENT}:${path}`;\n}\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 its property's channel (`profileUpdatedEvent(path)`, so an\n * /identify touching that property wakes the wait and one touching another\n * does not); `reachable` contributes the recipient property's channel, or the\n * device channel for push (in_app, slack and discord have no address to wait\n * on). Segment references are expanded, which is why a FactSource is needed to\n * resolve 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 store 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(profileUpdatedEvent(c.path));\n break;\n case 'reachable': {\n if (c.channel === 'push') {\n found.add(DEVICES_UPDATED_EVENT);\n break;\n }\n const path = RECIPIENT_PROPERTY[c.channel];\n if (path !== undefined) found.add(profileUpdatedEvent(path));\n break;\n }\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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,EAAE,SAAS;IACtB;GACF,KAAK;IACH,MAAM,IAAI,EAAE,KAAK;IACjB;GACF,KAAK,WAAW;IACd,IAAI,SAAS,IAAI,EAAE,OAAO,GAAG;IAC7B,SAAS,IAAI,EAAE,OAAO;IACtB,MAAM,MAAM,MAAM,MAAM,oBAAoB,EAAE,OAAO;IACrD,IAAI,KAAK,MAAM,KAAK,GAAG;IACvB;GACF;GACA,KAAK;IACH,MAAM,IAAI,oBAAoB,EAAE,IAAI,CAAC;IACrC;GACF,KAAK,aAAa;IAChB,IAAI,EAAE,YAAY,QAAQ;KACxB,MAAM,IAAI,qBAAqB;KAC/B;IACF;IACA,MAAM,OAAOA,yBAAAA,mBAAmB,EAAE;IAClC,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,oBAAoB,IAAI,CAAC;IAC3D;GACF;EAGF;CACF;CACA,MAAM,KAAK,SAAS;CACpB,OAAO,CAAC,GAAG,KAAK;AAClB"}
@@ -1,6 +1,5 @@
1
1
  import { ConditionIR } from "../ir.cjs";
2
2
  import { FactSource } from "./ports.cjs";
3
- //#region src/engine/condition.d.ts
4
3
  /**
5
4
  * Evaluation options.
6
5
  * - anchorMs: the earliest instant `performed` counts events from — the goal
@@ -17,7 +16,7 @@ export interface EvaluateOptions {
17
16
  }
18
17
  /**
19
18
  * 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
19
+ * so the store-backed implementation and the in-memory test one share a single set of
21
20
  * semantics and cannot drift into two evaluators.
22
21
  */
23
22
  export declare function evaluateCondition(condition: ConditionIR, facts: FactSource, nowMs: number, opts?: EvaluateOptions): Promise<boolean>;
@@ -57,5 +56,4 @@ export declare const DEVICES_UPDATED_EVENT = "$devices_updated";
57
56
  * resolve their definitions.
58
57
  */
59
58
  export declare function relevantEvents(condition: ConditionIR, facts: FactSource): Promise<string[]>;
60
- //#endregion
61
59
  //# sourceMappingURL=condition.d.cts.map
@@ -1 +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;;;;;;wBAOG,oBAAoB;;;;;qBAQvB;;;;;;;;;;;wBAYS,eAAe,WAAW,aAAa,OAAO,aAAa"}
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;;;;;;wBAOG,oBAAoB;;;;;qBAQvB;;;;;;;;;;;wBAYS,eAAe,WAAW,aAAa,OAAO,aAAa"}
@@ -1,6 +1,5 @@
1
1
  import { ConditionIR } from "../ir.mjs";
2
2
  import { FactSource } from "./ports.mjs";
3
- //#region src/engine/condition.d.ts
4
3
  /**
5
4
  * Evaluation options.
6
5
  * - anchorMs: the earliest instant `performed` counts events from — the goal
@@ -17,7 +16,7 @@ export interface EvaluateOptions {
17
16
  }
18
17
  /**
19
18
  * 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
19
+ * so the store-backed implementation and the in-memory test one share a single set of
21
20
  * semantics and cannot drift into two evaluators.
22
21
  */
23
22
  export declare function evaluateCondition(condition: ConditionIR, facts: FactSource, nowMs: number, opts?: EvaluateOptions): Promise<boolean>;
@@ -57,5 +56,4 @@ export declare const DEVICES_UPDATED_EVENT = "$devices_updated";
57
56
  * resolve their definitions.
58
57
  */
59
58
  export declare function relevantEvents(condition: ConditionIR, facts: FactSource): Promise<string[]>;
60
- //#endregion
61
59
  //# sourceMappingURL=condition.d.mts.map
@@ -1 +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;;;;;;wBAOG,oBAAoB;;;;;qBAQvB;;;;;;;;;;;wBAYS,eAAe,WAAW,aAAa,OAAO,aAAa"}
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;;;;;;wBAOG,oBAAoB;;;;;qBAQvB;;;;;;;;;;;wBAYS,eAAe,WAAW,aAAa,OAAO,aAAa"}
@@ -1,8 +1,8 @@
1
1
  import { RECIPIENT_PROPERTY } from "./recipient.mjs";
2
- //#region src/engine/condition.ts
2
+ // src/engine/condition.ts
3
3
  /**
4
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
5
+ * so the store-backed implementation and the in-memory test one share a single set of
6
6
  * semantics and cannot drift into two evaluators.
7
7
  */
8
8
  async function evaluateCondition(condition, facts, nowMs, opts) {
@@ -11,7 +11,7 @@ async function evaluateCondition(condition, facts, nowMs, opts) {
11
11
  /**
12
12
  * `enclosing` is the chain of segment names currently being expanded. A
13
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
14
+ * unchecked the recursion runs until memory gives out, one store round trip per
15
15
  * level — inside a step, so Workflows retries it and the instance never gets
16
16
  * out. Failing immediately keeps it bounded, and the message names the cycle
17
17
  * because only a deployed bundle can fix it. Only the *path* is tracked, so a
@@ -174,7 +174,6 @@ async function relevantEvents(condition, facts) {
174
174
  await walk(condition);
175
175
  return [...found];
176
176
  }
177
- //#endregion
178
177
  export { DEVICES_UPDATED_EVENT, PROFILE_UPDATED_EVENT, evaluateCondition, matchesWhere, profileUpdatedEvent, relevantEvents };
179
178
 
180
179
  //# sourceMappingURL=condition.mjs.map
@@ -1 +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 * The wake-up channel for one profile property: `$profile_updated:<path>`. A property predicate\n * subscribes to its own property's channel, and `/identify` fires one per property it patched —\n * so an identify that touches `plan` does not wake a wait on `email`.\n */\nexport function profileUpdatedEvent(path: string): string {\n return `${PROFILE_UPDATED_EVENT}:${path}`;\n}\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 its property's channel (`profileUpdatedEvent(path)`, so an\n * /identify touching that property wakes the wait and one touching another\n * does not); `reachable` contributes the recipient property's channel, or the\n * device channel for push (in_app, slack and discord have no address to wait\n * on). Segment references are expanded, which is why a FactSource is needed to\n * resolve 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(profileUpdatedEvent(c.path));\n break;\n case 'reachable': {\n if (c.channel === 'push') {\n found.add(DEVICES_UPDATED_EVENT);\n break;\n }\n const path = RECIPIENT_PROPERTY[c.channel];\n if (path !== undefined) found.add(profileUpdatedEvent(path));\n break;\n }\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,OAAO,MAAM,CAAC,GAAG,WAAW,UAAU,OAAO,CAAC;EAC5E;EACA,KAAK,aAAa;GAChB,MAAM,SAAmB,CAAC;GAC1B,IAAI,UAAU,WAAW,KAAA,GAAW,OAAO,KAAK,QAAQ,UAAU,OAAO,EAAE;GAC3E,IAAI,MAAM,aAAa,KAAA,GAAW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KAAK;CAC7F;AACF;AAEA,SAAS,UAAU,QAA8B,QAAyC;CACxF,IAAI,WAAW,KAAA,KAAa,WAAW,KAAA,KAAa,OAAO,SAAS,GAAG,OAAO;CAC9E,MAAM,CAAC,KAAK,OAAO;CACnB,OAAO,UAAU,OAAO,UAAU;AACpC;;;;;;;AAQA,MAAa,wBAAwB;;;;;;AAOrC,SAAgB,oBAAoB,MAAsB;CACxD,OAAO,GAAG,sBAAsB,GAAG;AACrC;;;;;AAMA,MAAa,wBAAwB;;;;;;;;;;;AAYrC,eAAsB,eAAe,WAAwB,OAAsC;CACjG,MAAM,wBAAQ,IAAI,IAAY;CAI9B,MAAM,2BAAW,IAAI,IAAY;CACjC,eAAe,KAAK,GAA+B;EACjD,QAAQ,EAAE,MAAV;GACE,KAAK;GACL,KAAK;IACH,KAAK,MAAM,SAAS,EAAE,YAAY,MAAM,KAAK,KAAK;IAClD;GACF,KAAK;IACH,MAAM,KAAK,EAAE,SAAS;IACtB;GACF,KAAK;IACH,MAAM,IAAI,EAAE,KAAK;IACjB;GACF,KAAK,WAAW;IACd,IAAI,SAAS,IAAI,EAAE,OAAO,GAAG;IAC7B,SAAS,IAAI,EAAE,OAAO;IACtB,MAAM,MAAM,MAAM,MAAM,oBAAoB,EAAE,OAAO;IACrD,IAAI,KAAK,MAAM,KAAK,GAAG;IACvB;GACF;GACA,KAAK;IACH,MAAM,IAAI,oBAAoB,EAAE,IAAI,CAAC;IACrC;GACF,KAAK,aAAa;IAChB,IAAI,EAAE,YAAY,QAAQ;KACxB,MAAM,IAAI,qBAAqB;KAC/B;IACF;IACA,MAAM,OAAO,mBAAmB,EAAE;IAClC,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,oBAAoB,IAAI,CAAC;IAC3D;GACF;EAGF;CACF;CACA,MAAM,KAAK,SAAS;CACpB,OAAO,CAAC,GAAG,KAAK;AAClB"}
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 store-backed 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 store 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 * The wake-up channel for one profile property: `$profile_updated:<path>`. A property predicate\n * subscribes to its own property's channel, and `/identify` fires one per property it patched —\n * so an identify that touches `plan` does not wake a wait on `email`.\n */\nexport function profileUpdatedEvent(path: string): string {\n return `${PROFILE_UPDATED_EVENT}:${path}`;\n}\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 its property's channel (`profileUpdatedEvent(path)`, so an\n * /identify touching that property wakes the wait and one touching another\n * does not); `reachable` contributes the recipient property's channel, or the\n * device channel for push (in_app, slack and discord have no address to wait\n * on). Segment references are expanded, which is why a FactSource is needed to\n * resolve 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 store 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(profileUpdatedEvent(c.path));\n break;\n case 'reachable': {\n if (c.channel === 'push') {\n found.add(DEVICES_UPDATED_EVENT);\n break;\n }\n const path = RECIPIENT_PROPERTY[c.channel];\n if (path !== undefined) found.add(profileUpdatedEvent(path));\n break;\n }\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,WAC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;;;;AAOrC,SAAgB,oBAAoB,MAAsB;CACxD,OAAO,GAAG,sBAAsB,GAAG;AACrC;;;;;AAMA,MAAa,wBAAwB;;;;;;;;;;;AAYrC,eAAsB,eAAe,WAAwB,OAAsC;CACjG,MAAM,wBAAQ,IAAI,IAAY;CAI9B,MAAM,2BAAW,IAAI,IAAY;CACjC,eAAe,KAAK,GAA+B;EACjD,QAAQ,EAAE,MAAV;GACE,KAAK;GACL,KAAK;IACH,KAAK,MAAM,SAAS,EAAE,YAAY,MAAM,KAAK,KAAK;IAClD;GACF,KAAK;IACH,MAAM,KAAK,EAAE,SAAS;IACtB;GACF,KAAK;IACH,MAAM,IAAI,EAAE,KAAK;IACjB;GACF,KAAK,WAAW;IACd,IAAI,SAAS,IAAI,EAAE,OAAO,GAAG;IAC7B,SAAS,IAAI,EAAE,OAAO;IACtB,MAAM,MAAM,MAAM,MAAM,oBAAoB,EAAE,OAAO;IACrD,IAAI,KAAK,MAAM,KAAK,GAAG;IACvB;GACF;GACA,KAAK;IACH,MAAM,IAAI,oBAAoB,EAAE,IAAI,CAAC;IACrC;GACF,KAAK,aAAa;IAChB,IAAI,EAAE,YAAY,QAAQ;KACxB,MAAM,IAAI,qBAAqB;KAC/B;IACF;IACA,MAAM,OAAO,mBAAmB,EAAE;IAClC,IAAI,SAAS,KAAA,GAAW,MAAM,IAAI,oBAAoB,IAAI,CAAC;IAC3D;GACF;EAGF;CACF;CACA,MAAM,KAAK,SAAS;CACpB,OAAO,CAAC,GAAG,KAAK;AAClB"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/engine/duration.ts
2
+ // src/engine/duration.ts
3
3
  /**
4
4
  * The longest an instance of a workflow can live, from its IR: every delay at its longest, every
5
5
  * wait to its timeout, a time window as a full week (the furthest the next allowed slot can be),
@@ -28,7 +28,6 @@ function nodeMs(node) {
28
28
  function longestJourneyMs(ir) {
29
29
  return Math.max(flowMs(ir.flow), ir.goal?.within?.ms ?? 0);
30
30
  }
31
- //#endregion
32
31
  exports.longestJourneyMs = longestJourneyMs;
33
32
 
34
33
  //# sourceMappingURL=duration.cjs.map
@@ -1,5 +1,3 @@
1
1
  import { WorkflowIR } from "../ir.cjs";
2
- //#region src/engine/duration.d.ts
3
2
  export declare function longestJourneyMs(ir: Pick<WorkflowIR, 'flow' | 'goal'>): number;
4
- //#endregion
5
3
  //# sourceMappingURL=duration.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"duration.d.cts","names":[],"sources":["../../src/engine/duration.ts"],"mappings":";;wBAyCgB,iBAAiB,IAAI,KAAK"}
1
+ {"version":3,"file":"duration.d.cts","names":[],"sources":["../../src/engine/duration.ts"],"mappings":";wBAyCgB,iBAAiB,IAAI,KAAK"}
@@ -1,5 +1,3 @@
1
1
  import { WorkflowIR } from "../ir.mjs";
2
- //#region src/engine/duration.d.ts
3
2
  export declare function longestJourneyMs(ir: Pick<WorkflowIR, 'flow' | 'goal'>): number;
4
- //#endregion
5
3
  //# sourceMappingURL=duration.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"duration.d.mts","names":[],"sources":["../../src/engine/duration.ts"],"mappings":";;wBAyCgB,iBAAiB,IAAI,KAAK"}
1
+ {"version":3,"file":"duration.d.mts","names":[],"sources":["../../src/engine/duration.ts"],"mappings":";wBAyCgB,iBAAiB,IAAI,KAAK"}
@@ -1,4 +1,4 @@
1
- //#region src/engine/duration.ts
1
+ // src/engine/duration.ts
2
2
  /**
3
3
  * The longest an instance of a workflow can live, from its IR: every delay at its longest, every
4
4
  * wait to its timeout, a time window as a full week (the furthest the next allowed slot can be),
@@ -27,7 +27,6 @@ function nodeMs(node) {
27
27
  function longestJourneyMs(ir) {
28
28
  return Math.max(flowMs(ir.flow), ir.goal?.within?.ms ?? 0);
29
29
  }
30
- //#endregion
31
30
  export { longestJourneyMs };
32
31
 
33
32
  //# sourceMappingURL=duration.mjs.map
@@ -3,7 +3,7 @@ const require_engine_bucket = require("./bucket.cjs");
3
3
  const require_engine_recipient = require("./recipient.cjs");
4
4
  const require_engine_condition = require("./condition.cjs");
5
5
  const require_engine_time_window = require("./time-window.cjs");
6
- //#region src/engine/interpreter.ts
6
+ // src/engine/interpreter.ts
7
7
  /**
8
8
  * IR interpreter: the execution core for one user's journey instance.
9
9
  *
@@ -429,7 +429,6 @@ async function resolveValues(values, facts) {
429
429
  for (const [key, value] of Object.entries(values)) resolved[key] = typeof value === "object" ? await facts.getProperty(value.path) : value;
430
430
  return resolved;
431
431
  }
432
- //#endregion
433
432
  exports.runJourney = runJourney;
434
433
 
435
434
  //# sourceMappingURL=interpreter.cjs.map
@@ -1,6 +1,4 @@
1
1
  import { WorkflowIR } from "../ir.cjs";
2
2
  import { JourneyContext, JourneyOutcome } from "./ports.cjs";
3
- //#region src/engine/interpreter.d.ts
4
3
  export declare function runJourney(ir: WorkflowIR, ctx: JourneyContext): Promise<JourneyOutcome>;
5
- //#endregion
6
4
  //# sourceMappingURL=interpreter.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interpreter.d.cts","names":[],"sources":["../../src/engine/interpreter.ts"],"mappings":";;;wBAiGsB,WAAW,IAAI,YAAY,KAAK,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"interpreter.d.cts","names":[],"sources":["../../src/engine/interpreter.ts"],"mappings":";;wBAiGsB,WAAW,IAAI,YAAY,KAAK,iBAAiB,QAAQ"}