@shware/workflow 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -2
  3. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  4. package/dist/apns-relay.cjs +105 -0
  5. package/dist/apns-relay.cjs.map +1 -0
  6. package/dist/apns-relay.d.cts +28 -0
  7. package/dist/apns-relay.d.cts.map +1 -0
  8. package/dist/apns-relay.d.mts +28 -0
  9. package/dist/apns-relay.d.mts.map +1 -0
  10. package/dist/apns-relay.mjs +104 -0
  11. package/dist/apns-relay.mjs.map +1 -0
  12. package/dist/apns.cjs +121 -0
  13. package/dist/apns.cjs.map +1 -0
  14. package/dist/apns.d.cts +63 -0
  15. package/dist/apns.d.cts.map +1 -0
  16. package/dist/apns.d.mts +63 -0
  17. package/dist/apns.d.mts.map +1 -0
  18. package/dist/apns.mjs +116 -0
  19. package/dist/apns.mjs.map +1 -0
  20. package/dist/client.cjs +125 -0
  21. package/dist/client.cjs.map +1 -0
  22. package/dist/client.d.cts +108 -0
  23. package/dist/client.d.cts.map +1 -0
  24. package/dist/client.d.mts +108 -0
  25. package/dist/client.d.mts.map +1 -0
  26. package/dist/client.mjs +122 -0
  27. package/dist/client.mjs.map +1 -0
  28. package/dist/cloudflare/bindings.cjs +28 -0
  29. package/dist/cloudflare/bindings.cjs.map +1 -0
  30. package/dist/cloudflare/bindings.d.cts +144 -0
  31. package/dist/cloudflare/bindings.d.cts.map +1 -0
  32. package/dist/cloudflare/bindings.d.mts +144 -0
  33. package/dist/cloudflare/bindings.d.mts.map +1 -0
  34. package/dist/cloudflare/bindings.mjs +25 -0
  35. package/dist/cloudflare/bindings.mjs.map +1 -0
  36. package/dist/cloudflare/channels.cjs +164 -0
  37. package/dist/cloudflare/channels.cjs.map +1 -0
  38. package/dist/cloudflare/channels.d.cts +29 -0
  39. package/dist/cloudflare/channels.d.cts.map +1 -0
  40. package/dist/cloudflare/channels.d.mts +29 -0
  41. package/dist/cloudflare/channels.d.mts.map +1 -0
  42. package/dist/cloudflare/channels.mjs +161 -0
  43. package/dist/cloudflare/channels.mjs.map +1 -0
  44. package/dist/cloudflare/d1-env.cjs +17 -0
  45. package/dist/cloudflare/d1-env.cjs.map +1 -0
  46. package/dist/cloudflare/d1-env.d.cts +12 -0
  47. package/dist/cloudflare/d1-env.d.cts.map +1 -0
  48. package/dist/cloudflare/d1-env.d.mts +12 -0
  49. package/dist/cloudflare/d1-env.d.mts.map +1 -0
  50. package/dist/cloudflare/d1-env.mjs +16 -0
  51. package/dist/cloudflare/d1-env.mjs.map +1 -0
  52. package/dist/cloudflare/index.cjs +54 -0
  53. package/dist/cloudflare/index.d.cts +19 -0
  54. package/dist/cloudflare/index.d.mts +19 -0
  55. package/dist/cloudflare/index.mjs +16 -0
  56. package/dist/cloudflare/router.cjs +516 -0
  57. package/dist/cloudflare/router.cjs.map +1 -0
  58. package/dist/cloudflare/router.d.cts +157 -0
  59. package/dist/cloudflare/router.d.cts.map +1 -0
  60. package/dist/cloudflare/router.d.mts +157 -0
  61. package/dist/cloudflare/router.d.mts.map +1 -0
  62. package/dist/cloudflare/router.mjs +503 -0
  63. package/dist/cloudflare/router.mjs.map +1 -0
  64. package/dist/cloudflare/runner.cjs +225 -0
  65. package/dist/cloudflare/runner.cjs.map +1 -0
  66. package/dist/cloudflare/runner.d.cts +73 -0
  67. package/dist/cloudflare/runner.d.cts.map +1 -0
  68. package/dist/cloudflare/runner.d.mts +73 -0
  69. package/dist/cloudflare/runner.d.mts.map +1 -0
  70. package/dist/cloudflare/runner.mjs +224 -0
  71. package/dist/cloudflare/runner.mjs.map +1 -0
  72. package/dist/cloudflare/schema.sql +127 -0
  73. package/dist/cloudflare/senders.cjs +114 -0
  74. package/dist/cloudflare/senders.cjs.map +1 -0
  75. package/dist/cloudflare/senders.d.cts +68 -0
  76. package/dist/cloudflare/senders.d.cts.map +1 -0
  77. package/dist/cloudflare/senders.d.mts +68 -0
  78. package/dist/cloudflare/senders.d.mts.map +1 -0
  79. package/dist/cloudflare/senders.mjs +108 -0
  80. package/dist/cloudflare/senders.mjs.map +1 -0
  81. package/dist/cloudflare/worker.cjs +228 -0
  82. package/dist/cloudflare/worker.cjs.map +1 -0
  83. package/dist/cloudflare/worker.d.cts +92 -0
  84. package/dist/cloudflare/worker.d.cts.map +1 -0
  85. package/dist/cloudflare/worker.d.mts +92 -0
  86. package/dist/cloudflare/worker.d.mts.map +1 -0
  87. package/dist/cloudflare/worker.mjs +224 -0
  88. package/dist/cloudflare/worker.mjs.map +1 -0
  89. package/dist/cloudflare/workers.d.cjs +0 -0
  90. package/dist/cloudflare/workers.d.cts +44 -0
  91. package/dist/cloudflare/workers.d.cts.map +1 -0
  92. package/dist/cloudflare/workers.d.mts +44 -0
  93. package/dist/cloudflare/workers.d.mts.map +1 -0
  94. package/dist/config.cjs +151 -0
  95. package/dist/config.cjs.map +1 -0
  96. package/dist/config.d.cts +149 -0
  97. package/dist/config.d.cts.map +1 -0
  98. package/dist/config.d.mts +149 -0
  99. package/dist/config.d.mts.map +1 -0
  100. package/dist/config.mjs +143 -0
  101. package/dist/config.mjs.map +1 -0
  102. package/dist/contract.cjs +212 -0
  103. package/dist/contract.cjs.map +1 -0
  104. package/dist/contract.d.cts +90 -0
  105. package/dist/contract.d.cts.map +1 -0
  106. package/dist/contract.d.mts +90 -0
  107. package/dist/contract.d.mts.map +1 -0
  108. package/dist/contract.mjs +206 -0
  109. package/dist/contract.mjs.map +1 -0
  110. package/dist/dsl/action.cjs +29 -0
  111. package/dist/dsl/action.cjs.map +1 -0
  112. package/dist/dsl/action.d.cts +64 -0
  113. package/dist/dsl/action.d.cts.map +1 -0
  114. package/dist/dsl/action.d.mts +64 -0
  115. package/dist/dsl/action.d.mts.map +1 -0
  116. package/dist/dsl/action.mjs +28 -0
  117. package/dist/dsl/action.mjs.map +1 -0
  118. package/dist/dsl/base.cjs +34 -0
  119. package/dist/dsl/base.cjs.map +1 -0
  120. package/dist/dsl/base.d.cts +45 -0
  121. package/dist/dsl/base.d.cts.map +1 -0
  122. package/dist/dsl/base.d.mts +45 -0
  123. package/dist/dsl/base.d.mts.map +1 -0
  124. package/dist/dsl/base.mjs +30 -0
  125. package/dist/dsl/base.mjs.map +1 -0
  126. package/dist/dsl/bundle.cjs +207 -0
  127. package/dist/dsl/bundle.cjs.map +1 -0
  128. package/dist/dsl/bundle.d.cts +19 -0
  129. package/dist/dsl/bundle.d.cts.map +1 -0
  130. package/dist/dsl/bundle.d.mts +19 -0
  131. package/dist/dsl/bundle.d.mts.map +1 -0
  132. package/dist/dsl/bundle.mjs +206 -0
  133. package/dist/dsl/bundle.mjs.map +1 -0
  134. package/dist/dsl/condition.cjs +177 -0
  135. package/dist/dsl/condition.cjs.map +1 -0
  136. package/dist/dsl/condition.d.cts +140 -0
  137. package/dist/dsl/condition.d.cts.map +1 -0
  138. package/dist/dsl/condition.d.mts +140 -0
  139. package/dist/dsl/condition.d.mts.map +1 -0
  140. package/dist/dsl/condition.mjs +156 -0
  141. package/dist/dsl/condition.mjs.map +1 -0
  142. package/dist/dsl/flow.cjs +228 -0
  143. package/dist/dsl/flow.cjs.map +1 -0
  144. package/dist/dsl/flow.d.cts +223 -0
  145. package/dist/dsl/flow.d.cts.map +1 -0
  146. package/dist/dsl/flow.d.mts +223 -0
  147. package/dist/dsl/flow.d.mts.map +1 -0
  148. package/dist/dsl/flow.mjs +226 -0
  149. package/dist/dsl/flow.mjs.map +1 -0
  150. package/dist/dsl/index.cjs +38 -0
  151. package/dist/dsl/index.d.cts +10 -0
  152. package/dist/dsl/index.d.mts +10 -0
  153. package/dist/dsl/index.mjs +9 -0
  154. package/dist/dsl/refs.cjs +59 -0
  155. package/dist/dsl/refs.cjs.map +1 -0
  156. package/dist/dsl/refs.d.cts +88 -0
  157. package/dist/dsl/refs.d.cts.map +1 -0
  158. package/dist/dsl/refs.d.mts +88 -0
  159. package/dist/dsl/refs.d.mts.map +1 -0
  160. package/dist/dsl/refs.mjs +55 -0
  161. package/dist/dsl/refs.mjs.map +1 -0
  162. package/dist/dsl/template.cjs +65 -0
  163. package/dist/dsl/template.cjs.map +1 -0
  164. package/dist/dsl/template.d.cts +75 -0
  165. package/dist/dsl/template.d.cts.map +1 -0
  166. package/dist/dsl/template.d.mts +75 -0
  167. package/dist/dsl/template.d.mts.map +1 -0
  168. package/dist/dsl/template.mjs +63 -0
  169. package/dist/dsl/template.mjs.map +1 -0
  170. package/dist/dsl/trigger.cjs +40 -0
  171. package/dist/dsl/trigger.cjs.map +1 -0
  172. package/dist/dsl/trigger.d.cts +65 -0
  173. package/dist/dsl/trigger.d.cts.map +1 -0
  174. package/dist/dsl/trigger.d.mts +65 -0
  175. package/dist/dsl/trigger.d.mts.map +1 -0
  176. package/dist/dsl/trigger.mjs +39 -0
  177. package/dist/dsl/trigger.mjs.map +1 -0
  178. package/dist/dsl/workflow.cjs +121 -0
  179. package/dist/dsl/workflow.cjs.map +1 -0
  180. package/dist/dsl/workflow.d.cts +59 -0
  181. package/dist/dsl/workflow.d.cts.map +1 -0
  182. package/dist/dsl/workflow.d.mts +59 -0
  183. package/dist/dsl/workflow.d.mts.map +1 -0
  184. package/dist/dsl/workflow.mjs +120 -0
  185. package/dist/dsl/workflow.mjs.map +1 -0
  186. package/dist/engine/actions.cjs +27 -0
  187. package/dist/engine/actions.cjs.map +1 -0
  188. package/dist/engine/actions.d.cts +40 -0
  189. package/dist/engine/actions.d.cts.map +1 -0
  190. package/dist/engine/actions.d.mts +40 -0
  191. package/dist/engine/actions.d.mts.map +1 -0
  192. package/dist/engine/actions.mjs +26 -0
  193. package/dist/engine/actions.mjs.map +1 -0
  194. package/dist/engine/bucket.cjs +72 -0
  195. package/dist/engine/bucket.cjs.map +1 -0
  196. package/dist/engine/bucket.d.cts +32 -0
  197. package/dist/engine/bucket.d.cts.map +1 -0
  198. package/dist/engine/bucket.d.mts +32 -0
  199. package/dist/engine/bucket.d.mts.map +1 -0
  200. package/dist/engine/bucket.mjs +69 -0
  201. package/dist/engine/bucket.mjs.map +1 -0
  202. package/dist/engine/condition.cjs +166 -0
  203. package/dist/engine/condition.cjs.map +1 -0
  204. package/dist/engine/condition.d.cts +52 -0
  205. package/dist/engine/condition.d.cts.map +1 -0
  206. package/dist/engine/condition.d.mts +52 -0
  207. package/dist/engine/condition.d.mts.map +1 -0
  208. package/dist/engine/condition.mjs +161 -0
  209. package/dist/engine/condition.mjs.map +1 -0
  210. package/dist/engine/index.cjs +20 -0
  211. package/dist/engine/index.d.cts +8 -0
  212. package/dist/engine/index.d.mts +8 -0
  213. package/dist/engine/index.mjs +7 -0
  214. package/dist/engine/interpreter.cjs +428 -0
  215. package/dist/engine/interpreter.cjs.map +1 -0
  216. package/dist/engine/interpreter.d.cts +6 -0
  217. package/dist/engine/interpreter.d.cts.map +1 -0
  218. package/dist/engine/interpreter.d.mts +6 -0
  219. package/dist/engine/interpreter.d.mts.map +1 -0
  220. package/dist/engine/interpreter.mjs +427 -0
  221. package/dist/engine/interpreter.mjs.map +1 -0
  222. package/dist/engine/ports.cjs +0 -0
  223. package/dist/engine/ports.d.cts +252 -0
  224. package/dist/engine/ports.d.cts.map +1 -0
  225. package/dist/engine/ports.d.mts +252 -0
  226. package/dist/engine/ports.d.mts.map +1 -0
  227. package/dist/engine/ports.mjs +1 -0
  228. package/dist/engine/recipient.cjs +23 -0
  229. package/dist/engine/recipient.cjs.map +1 -0
  230. package/dist/engine/recipient.d.cts +13 -0
  231. package/dist/engine/recipient.d.cts.map +1 -0
  232. package/dist/engine/recipient.d.mts +13 -0
  233. package/dist/engine/recipient.d.mts.map +1 -0
  234. package/dist/engine/recipient.mjs +22 -0
  235. package/dist/engine/recipient.mjs.map +1 -0
  236. package/dist/engine/time-scale.cjs +54 -0
  237. package/dist/engine/time-scale.cjs.map +1 -0
  238. package/dist/engine/time-scale.d.cts +31 -0
  239. package/dist/engine/time-scale.d.cts.map +1 -0
  240. package/dist/engine/time-scale.d.mts +31 -0
  241. package/dist/engine/time-scale.d.mts.map +1 -0
  242. package/dist/engine/time-scale.mjs +52 -0
  243. package/dist/engine/time-scale.mjs.map +1 -0
  244. package/dist/engine/time-window.cjs +149 -0
  245. package/dist/engine/time-window.cjs.map +1 -0
  246. package/dist/engine/time-window.d.cts +22 -0
  247. package/dist/engine/time-window.d.cts.map +1 -0
  248. package/dist/engine/time-window.d.mts +22 -0
  249. package/dist/engine/time-window.d.mts.map +1 -0
  250. package/dist/engine/time-window.mjs +147 -0
  251. package/dist/engine/time-window.mjs.map +1 -0
  252. package/dist/fcm.cjs +125 -0
  253. package/dist/fcm.cjs.map +1 -0
  254. package/dist/fcm.d.cts +48 -0
  255. package/dist/fcm.d.cts.map +1 -0
  256. package/dist/fcm.d.mts +48 -0
  257. package/dist/fcm.d.mts.map +1 -0
  258. package/dist/fcm.mjs +121 -0
  259. package/dist/fcm.mjs.map +1 -0
  260. package/dist/hash.cjs +245 -0
  261. package/dist/hash.cjs.map +1 -0
  262. package/dist/hash.d.cts +30 -0
  263. package/dist/hash.d.cts.map +1 -0
  264. package/dist/hash.d.mts +30 -0
  265. package/dist/hash.d.mts.map +1 -0
  266. package/dist/hash.mjs +239 -0
  267. package/dist/hash.mjs.map +1 -0
  268. package/dist/index.cjs +100 -0
  269. package/dist/index.d.cts +18 -0
  270. package/dist/index.d.mts +18 -0
  271. package/dist/index.mjs +17 -0
  272. package/dist/ir.cjs +366 -0
  273. package/dist/ir.cjs.map +1 -0
  274. package/dist/ir.d.cts +486 -0
  275. package/dist/ir.d.cts.map +1 -0
  276. package/dist/ir.d.mts +486 -0
  277. package/dist/ir.d.mts.map +1 -0
  278. package/dist/ir.mjs +344 -0
  279. package/dist/ir.mjs.map +1 -0
  280. package/dist/jwt.cjs +22 -0
  281. package/dist/jwt.cjs.map +1 -0
  282. package/dist/jwt.d.cts +9 -0
  283. package/dist/jwt.d.cts.map +1 -0
  284. package/dist/jwt.d.mts +9 -0
  285. package/dist/jwt.d.mts.map +1 -0
  286. package/dist/jwt.mjs +20 -0
  287. package/dist/jwt.mjs.map +1 -0
  288. package/dist/plan.cjs +223 -0
  289. package/dist/plan.cjs.map +1 -0
  290. package/dist/plan.d.cts +68 -0
  291. package/dist/plan.d.cts.map +1 -0
  292. package/dist/plan.d.mts +68 -0
  293. package/dist/plan.d.mts.map +1 -0
  294. package/dist/plan.mjs +221 -0
  295. package/dist/plan.mjs.map +1 -0
  296. package/dist/postgres-js.cjs +42 -0
  297. package/dist/postgres-js.cjs.map +1 -0
  298. package/dist/postgres-js.d.cts +28 -0
  299. package/dist/postgres-js.d.cts.map +1 -0
  300. package/dist/postgres-js.d.mts +28 -0
  301. package/dist/postgres-js.d.mts.map +1 -0
  302. package/dist/postgres-js.mjs +38 -0
  303. package/dist/postgres-js.mjs.map +1 -0
  304. package/dist/provenance.cjs +67 -0
  305. package/dist/provenance.cjs.map +1 -0
  306. package/dist/provenance.d.cts +41 -0
  307. package/dist/provenance.d.cts.map +1 -0
  308. package/dist/provenance.d.mts +41 -0
  309. package/dist/provenance.d.mts.map +1 -0
  310. package/dist/provenance.mjs +65 -0
  311. package/dist/provenance.mjs.map +1 -0
  312. package/dist/push.cjs +14 -0
  313. package/dist/push.cjs.map +1 -0
  314. package/dist/push.d.cts +16 -0
  315. package/dist/push.d.cts.map +1 -0
  316. package/dist/push.d.mts +16 -0
  317. package/dist/push.d.mts.map +1 -0
  318. package/dist/push.mjs +13 -0
  319. package/dist/push.mjs.map +1 -0
  320. package/dist/react-email.cjs +48 -0
  321. package/dist/react-email.cjs.map +1 -0
  322. package/dist/react-email.d.cts +7 -0
  323. package/dist/react-email.d.cts.map +1 -0
  324. package/dist/react-email.d.mts +7 -0
  325. package/dist/react-email.d.mts.map +1 -0
  326. package/dist/react-email.mjs +47 -0
  327. package/dist/react-email.mjs.map +1 -0
  328. package/dist/reporting/classify.cjs +42 -0
  329. package/dist/reporting/classify.cjs.map +1 -0
  330. package/dist/reporting/classify.d.cts +60 -0
  331. package/dist/reporting/classify.d.cts.map +1 -0
  332. package/dist/reporting/classify.d.mts +60 -0
  333. package/dist/reporting/classify.d.mts.map +1 -0
  334. package/dist/reporting/classify.mjs +38 -0
  335. package/dist/reporting/classify.mjs.map +1 -0
  336. package/dist/reporting/observer.cjs +63 -0
  337. package/dist/reporting/observer.cjs.map +1 -0
  338. package/dist/reporting/observer.d.cts +18 -0
  339. package/dist/reporting/observer.d.cts.map +1 -0
  340. package/dist/reporting/observer.d.mts +18 -0
  341. package/dist/reporting/observer.d.mts.map +1 -0
  342. package/dist/reporting/observer.mjs +62 -0
  343. package/dist/reporting/observer.mjs.map +1 -0
  344. package/dist/reporting/tracking.cjs +153 -0
  345. package/dist/reporting/tracking.cjs.map +1 -0
  346. package/dist/reporting/tracking.d.cts +43 -0
  347. package/dist/reporting/tracking.d.cts.map +1 -0
  348. package/dist/reporting/tracking.d.mts +43 -0
  349. package/dist/reporting/tracking.d.mts.map +1 -0
  350. package/dist/reporting/tracking.mjs +151 -0
  351. package/dist/reporting/tracking.mjs.map +1 -0
  352. package/dist/runtime.cjs +19 -0
  353. package/dist/runtime.cjs.map +1 -0
  354. package/dist/runtime.d.cts +30 -0
  355. package/dist/runtime.d.cts.map +1 -0
  356. package/dist/runtime.d.mts +30 -0
  357. package/dist/runtime.d.mts.map +1 -0
  358. package/dist/runtime.mjs +18 -0
  359. package/dist/runtime.mjs.map +1 -0
  360. package/dist/store/d1.cjs +185 -0
  361. package/dist/store/d1.cjs.map +1 -0
  362. package/dist/store/d1.d.cts +55 -0
  363. package/dist/store/d1.d.cts.map +1 -0
  364. package/dist/store/d1.d.mts +55 -0
  365. package/dist/store/d1.d.mts.map +1 -0
  366. package/dist/store/d1.mjs +184 -0
  367. package/dist/store/d1.mjs.map +1 -0
  368. package/dist/store/facts.cjs +60 -0
  369. package/dist/store/facts.cjs.map +1 -0
  370. package/dist/store/facts.d.cts +38 -0
  371. package/dist/store/facts.d.cts.map +1 -0
  372. package/dist/store/facts.d.mts +38 -0
  373. package/dist/store/facts.d.mts.map +1 -0
  374. package/dist/store/facts.mjs +58 -0
  375. package/dist/store/facts.mjs.map +1 -0
  376. package/dist/store/index.cjs +31 -0
  377. package/dist/store/index.cjs.map +1 -0
  378. package/dist/store/index.d.cts +291 -0
  379. package/dist/store/index.d.cts.map +1 -0
  380. package/dist/store/index.d.mts +291 -0
  381. package/dist/store/index.d.mts.map +1 -0
  382. package/dist/store/index.mjs +22 -0
  383. package/dist/store/index.mjs.map +1 -0
  384. package/dist/store/postgres-reporting.cjs +213 -0
  385. package/dist/store/postgres-reporting.cjs.map +1 -0
  386. package/dist/store/postgres-reporting.d.cts +63 -0
  387. package/dist/store/postgres-reporting.d.cts.map +1 -0
  388. package/dist/store/postgres-reporting.d.mts +63 -0
  389. package/dist/store/postgres-reporting.d.mts.map +1 -0
  390. package/dist/store/postgres-reporting.mjs +212 -0
  391. package/dist/store/postgres-reporting.mjs.map +1 -0
  392. package/dist/store/postgres.cjs +309 -0
  393. package/dist/store/postgres.cjs.map +1 -0
  394. package/dist/store/postgres.d.cts +77 -0
  395. package/dist/store/postgres.d.cts.map +1 -0
  396. package/dist/store/postgres.d.mts +77 -0
  397. package/dist/store/postgres.d.mts.map +1 -0
  398. package/dist/store/postgres.mjs +306 -0
  399. package/dist/store/postgres.mjs.map +1 -0
  400. package/dist/store/sql.cjs +24 -0
  401. package/dist/store/sql.cjs.map +1 -0
  402. package/dist/store/sql.d.cts +25 -0
  403. package/dist/store/sql.d.cts.map +1 -0
  404. package/dist/store/sql.d.mts +25 -0
  405. package/dist/store/sql.d.mts.map +1 -0
  406. package/dist/store/sql.mjs +23 -0
  407. package/dist/store/sql.mjs.map +1 -0
  408. package/dist/store/tables.cjs +404 -0
  409. package/dist/store/tables.cjs.map +1 -0
  410. package/dist/store/tables.d.cts +81 -0
  411. package/dist/store/tables.d.cts.map +1 -0
  412. package/dist/store/tables.d.mts +81 -0
  413. package/dist/store/tables.d.mts.map +1 -0
  414. package/dist/store/tables.mjs +399 -0
  415. package/dist/store/tables.mjs.map +1 -0
  416. package/dist/templates.cjs +247 -0
  417. package/dist/templates.cjs.map +1 -0
  418. package/dist/templates.d.cts +187 -0
  419. package/dist/templates.d.cts.map +1 -0
  420. package/dist/templates.d.mts +187 -0
  421. package/dist/templates.d.mts.map +1 -0
  422. package/dist/templates.mjs +230 -0
  423. package/dist/templates.mjs.map +1 -0
  424. package/dist/webhooks.cjs +96 -0
  425. package/dist/webhooks.cjs.map +1 -0
  426. package/dist/webhooks.d.cts +25 -0
  427. package/dist/webhooks.d.cts.map +1 -0
  428. package/dist/webhooks.d.mts +25 -0
  429. package/dist/webhooks.d.mts.map +1 -0
  430. package/dist/webhooks.mjs +94 -0
  431. package/dist/webhooks.mjs.map +1 -0
  432. package/dist/webpush.cjs +180 -0
  433. package/dist/webpush.cjs.map +1 -0
  434. package/dist/webpush.d.cts +53 -0
  435. package/dist/webpush.d.cts.map +1 -0
  436. package/dist/webpush.d.mts +53 -0
  437. package/dist/webpush.d.mts.map +1 -0
  438. package/dist/webpush.mjs +175 -0
  439. package/dist/webpush.mjs.map +1 -0
  440. package/package.json +189 -3
  441. package/src/cloudflare/schema.sql +127 -0
  442. package/src/cloudflare/workers.d.ts +44 -0
@@ -0,0 +1,225 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_contract = require("../contract.cjs");
3
+ const require_runtime = require("../runtime.cjs");
4
+ const require_cloudflare_bindings = require("./bindings.cjs");
5
+ const require_store_facts = require("../store/facts.cjs");
6
+ const require_cloudflare_d1_env = require("./d1-env.cjs");
7
+ const require_cloudflare_router = require("./router.cjs");
8
+ const require_cloudflare_senders = require("./senders.cjs");
9
+ const require_engine_actions = require("../engine/actions.cjs");
10
+ const require_engine_interpreter = require("../engine/interpreter.cjs");
11
+ const require_engine_time_scale = require("../engine/time-scale.cjs");
12
+ let cloudflare_workers = require("cloudflare:workers");
13
+ let cloudflare_workflows = require("cloudflare:workflows");
14
+ //#region src/cloudflare/runner.ts
15
+ /**
16
+ * Adapts CF's WorkflowStep to EngineStep.
17
+ * subscribe/unsubscribe write the subscription table inside durable steps (the
18
+ * router wakes instances from that table); waitForWake parks on CF's
19
+ * waitForEvent, which signals a timeout by throwing — and so does every other
20
+ * failure in there, so only the clock can tell them apart (see wakeExpired).
21
+ */
22
+ /** Refusals a retry would only repeat: a template's props, an emitted event's payload. */
23
+ const NON_RETRYABLE = /* @__PURE__ */ new Set(["TemplateValidationError", "ContractValidationError"]);
24
+ var CfEngineStep = class {
25
+ step;
26
+ store;
27
+ userId;
28
+ instanceId;
29
+ constructor(step, store, userId, instanceId) {
30
+ this.step = step;
31
+ this.store = store;
32
+ this.userId = userId;
33
+ this.instanceId = instanceId;
34
+ }
35
+ /**
36
+ * A template refusing its props, or the contract refusing an emitted event,
37
+ * is deterministic — a retry hits the same refusal — so it ends the step at
38
+ * once instead of burning the retry budget.
39
+ */
40
+ do(name, fn) {
41
+ return this.step.do(name, async () => {
42
+ try {
43
+ return await fn();
44
+ } catch (error) {
45
+ if (error instanceof Error && NON_RETRYABLE.has(error.name)) throw new cloudflare_workflows.NonRetryableError(error.message, error.name);
46
+ throw error;
47
+ }
48
+ });
49
+ }
50
+ sleep(name, ms) {
51
+ return this.step.sleep(name, ms);
52
+ }
53
+ sleepUntil(name, timestampMs) {
54
+ return this.step.sleepUntil(name, timestampMs);
55
+ }
56
+ subscribe(name, events) {
57
+ return this.step.do(name, () => this.store.subscribe(this.instanceId, this.userId, events, Date.now()));
58
+ }
59
+ unsubscribe(name) {
60
+ return this.step.do(name, () => this.store.unsubscribe(this.instanceId));
61
+ }
62
+ async waitForWake(name, timeoutMs) {
63
+ const startedAt = Date.now();
64
+ try {
65
+ await this.step.waitForEvent(name, {
66
+ type: require_cloudflare_bindings.WAKE_EVENT_TYPE,
67
+ timeout: timeoutMs
68
+ });
69
+ return "event";
70
+ } catch (error) {
71
+ if (await this.step.do(`${name}:timed-out`, async () => require_cloudflare_bindings.wakeExpired(startedAt, timeoutMs, Date.now()))) return "timeout";
72
+ throw error;
73
+ }
74
+ }
75
+ };
76
+ /** Development aid: echo each outbound message before handing it to the real sender. */
77
+ function logging(sender) {
78
+ return { async send(message) {
79
+ console.log(`[journey] ${message.channel} ${message.template} → ${message.recipient ?? message.userId} ${JSON.stringify(message.props)}`);
80
+ return sender.send(message);
81
+ } };
82
+ }
83
+ /**
84
+ * The generic journey executor: one class runs every workflow, because IR is
85
+ * data. It is loaded from the store by the contentHash pinned at entry —
86
+ * content addressing makes it immutable, so reading it outside a step is
87
+ * replay-safe.
88
+ */
89
+ var JourneyRunner = class extends cloudflare_workers.WorkflowEntrypoint {
90
+ /**
91
+ * The data plane. D1 + KV from the env by default; an app on Postgres
92
+ * overrides this (and `closeStore` if its client needs closing):
93
+ *
94
+ * protected override createStore() { return new PostgresJourneyStore(client(this.env)); }
95
+ */
96
+ createStore() {
97
+ return require_cloudflare_d1_env.d1Store(this.env);
98
+ }
99
+ /** Called once `run` is over, success or not — release whatever `createStore` opened. */
100
+ async closeStore(_store) {}
101
+ /**
102
+ * Runtime options for this instance — typed configuration, resolved by the app (typically
103
+ * `resolveRuntime(config.runtime, mode)` over its workflow.config.ts, with the mode coming from
104
+ * an ENVIRONMENT var). The instance params are passed so the decision can also be per user:
105
+ * a tester account in production can run in fast-forward while everyone else runs in real
106
+ * time. Defaults: real time, quiet.
107
+ *
108
+ * protected override runtime({ userId }) {
109
+ * return resolveRuntime(workflowConfig.runtime, isTester(userId) ? 'test' : this.env.ENVIRONMENT);
110
+ * }
111
+ */
112
+ runtime(_params) {
113
+ return require_runtime.resolveRuntime(void 0, "production");
114
+ }
115
+ /**
116
+ * Message outlet; an app overrides this to plug in real channels (say
117
+ * CfEmailSender with a react-email renderer). By default it picks the webhook
118
+ * or logging sender based on the environment.
119
+ */
120
+ createMessageSender() {
121
+ return this.env.MESSAGE_WEBHOOK_URL ? new require_cloudflare_senders.WebhookMessageSender(this.env.MESSAGE_WEBHOOK_URL) : new require_cloudflare_senders.LogMessageSender();
122
+ }
123
+ /**
124
+ * Custom-action registry; an app overrides this returning the same
125
+ * `action(...)` objects its workflows reference (an ActionRef is a
126
+ * RegisteredAction structurally) — the code plane of the dual-plane model:
127
+ *
128
+ * protected override actions() { return [syncCrm, issueCoupon]; }
129
+ */
130
+ actions() {
131
+ return [];
132
+ }
133
+ /**
134
+ * The contract events this journey emits (`.sendEvent()`) are checked
135
+ * against, exactly like ingest; journeyWorker passes its config's.
136
+ */
137
+ contract() {}
138
+ /**
139
+ * Template props check before every send; an app overrides this with
140
+ * `registryValidator({ emails, pushes })` (journeyWorker does it from its
141
+ * registries). By default props go out as resolved.
142
+ */
143
+ createMessageValidator() {}
144
+ /**
145
+ * Reporting hooks: node arrivals, every copy sent, how each instance ended. The host stores
146
+ * what it needs for its dashboards; by default nothing is reported.
147
+ */
148
+ createObserver(_store) {}
149
+ /** Override for a different version policy ('warn' by default) or a fully custom invoker (e.g. webhook degradation for hosted tenants). */
150
+ createActionInvoker() {
151
+ return new require_engine_actions.RegistryActionInvoker(this.actions());
152
+ }
153
+ async run(event, step) {
154
+ const store = this.createStore();
155
+ try {
156
+ return await this.execute(event, step, store);
157
+ } finally {
158
+ await this.closeStore(store);
159
+ }
160
+ }
161
+ async execute(event, step, store) {
162
+ const { workflowId, contentHash, userId } = event.payload;
163
+ const env = this.env;
164
+ const stored = await store.getWorkflowIR(contentHash);
165
+ if (stored === void 0) throw new Error(`WorkflowIR not found: ${workflowId}@${contentHash}`);
166
+ const runtime = require_runtime.resolveRuntime({ current: this.runtime(event.payload) }, "current");
167
+ const ir = require_engine_time_scale.scaleDurations(stored, runtime.timeScale);
168
+ const observer = this.createObserver(store);
169
+ const finished = (status, convertedAt) => observer?.finished?.({
170
+ workflow: workflowId,
171
+ instanceId: event.instanceId,
172
+ userId,
173
+ status,
174
+ at: Date.now(),
175
+ ...convertedAt === void 0 ? {} : { convertedAt }
176
+ });
177
+ const messages = runtime.logMessages ? logging(this.createMessageSender()) : this.createMessageSender();
178
+ const contract = this.contract();
179
+ const events = { emit: async (name, payload, id) => {
180
+ let accepted = payload;
181
+ if (contract !== void 0) {
182
+ const verdict = require_contract.checkEvent(contract, name, payload);
183
+ if (!verdict.ok) throw new require_contract.ContractValidationError(name, verdict.issues);
184
+ accepted = verdict.data;
185
+ }
186
+ await require_cloudflare_router.ingestEvent(env, {
187
+ id,
188
+ userId,
189
+ event: name,
190
+ payload: accepted
191
+ }, store);
192
+ } };
193
+ let outcome;
194
+ try {
195
+ outcome = await require_engine_interpreter.runJourney(ir, {
196
+ userId,
197
+ instanceId: event.instanceId,
198
+ enteredAtMs: event.timestamp.getTime(),
199
+ step: new CfEngineStep(step, store, userId, event.instanceId),
200
+ facts: new require_store_facts.JourneyFactSource(store, userId),
201
+ messages,
202
+ events,
203
+ actions: this.createActionInvoker(),
204
+ validator: this.createMessageValidator(),
205
+ observer
206
+ });
207
+ } catch (error) {
208
+ await step.do("finalize:failed", async () => {
209
+ await store.setEntryStatus(event.instanceId, "failed");
210
+ await finished("failed");
211
+ });
212
+ throw error;
213
+ }
214
+ await step.do("finalize", async () => {
215
+ await store.setEntryStatus(event.instanceId, outcome.status);
216
+ await store.unsubscribe(event.instanceId);
217
+ await finished(outcome.status, outcome.convertedAt);
218
+ });
219
+ return outcome;
220
+ }
221
+ };
222
+ //#endregion
223
+ exports.JourneyRunner = JourneyRunner;
224
+
225
+ //# sourceMappingURL=runner.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.cjs","names":["NonRetryableError","WAKE_EVENT_TYPE","wakeExpired","WorkflowEntrypoint","d1Store","resolveRuntime","WebhookMessageSender","LogMessageSender","RegistryActionInvoker","scaleDurations","checkEvent","ContractValidationError","ingestEvent","runJourney","JourneyFactSource"],"sources":["../../src/cloudflare/runner.ts"],"sourcesContent":["import { WorkflowEntrypoint, type WorkflowEvent, type WorkflowStep } from 'cloudflare:workers';\nimport { NonRetryableError } from 'cloudflare:workflows';\nimport { type Contract, ContractValidationError, checkEvent } from '../contract';\nimport { type RegisteredAction, RegistryActionInvoker } from '../engine/actions';\nimport { runJourney } from '../engine/interpreter';\nimport type {\n ActionInvoker,\n EngineStep,\n EventSink,\n JourneyObserver,\n JourneyOutcome,\n MessageSender,\n MessageValidator,\n} from '../engine/ports';\nimport { scaleDurations } from '../engine/time-scale';\nimport { type JourneyRuntimeOptions, resolveRuntime } from '../runtime';\nimport { JourneyFactSource } from '../store/facts';\nimport type { JourneyStore } from '../store/index';\nimport { type JourneyEnv, type JourneyParams, WAKE_EVENT_TYPE, wakeExpired } from './bindings';\nimport { d1Store } from './d1-env';\nimport { ingestEvent } from './router';\nimport { LogMessageSender, WebhookMessageSender } from './senders';\n\n/**\n * Adapts CF's WorkflowStep to EngineStep.\n * subscribe/unsubscribe write the subscription table inside durable steps (the\n * router wakes instances from that table); waitForWake parks on CF's\n * waitForEvent, which signals a timeout by throwing — and so does every other\n * failure in there, so only the clock can tell them apart (see wakeExpired).\n */\n/** Refusals a retry would only repeat: a template's props, an emitted event's payload. */\nconst NON_RETRYABLE = new Set(['TemplateValidationError', 'ContractValidationError']);\n\nclass CfEngineStep implements EngineStep {\n constructor(\n private readonly step: WorkflowStep,\n private readonly store: JourneyStore,\n private readonly userId: string,\n private readonly instanceId: string\n ) {}\n\n /**\n * A template refusing its props, or the contract refusing an emitted event,\n * is deterministic — a retry hits the same refusal — so it ends the step at\n * once instead of burning the retry budget.\n */\n do<T>(name: string, fn: () => Promise<T>): Promise<T> {\n return this.step.do(name, async () => {\n try {\n return await fn();\n } catch (error) {\n if (error instanceof Error && NON_RETRYABLE.has(error.name)) {\n throw new NonRetryableError(error.message, error.name);\n }\n throw error;\n }\n });\n }\n\n sleep(name: string, ms: number): Promise<void> {\n return this.step.sleep(name, ms);\n }\n\n sleepUntil(name: string, timestampMs: number): Promise<void> {\n return this.step.sleepUntil(name, timestampMs);\n }\n\n subscribe(name: string, events: readonly string[]): Promise<void> {\n // Idempotent in the store: the interpreter re-subscribes on every wait\n // attempt (one-shot-callback contract) and registrations persist here.\n return this.step.do(name, () =>\n this.store.subscribe(this.instanceId, this.userId, events, Date.now())\n );\n }\n\n unsubscribe(name: string): Promise<void> {\n return this.step.do(name, () => this.store.unsubscribe(this.instanceId));\n }\n\n async waitForWake(name: string, timeoutMs: number): Promise<'event' | 'timeout'> {\n const startedAt = Date.now();\n try {\n await this.step.waitForEvent(name, { type: WAKE_EVENT_TYPE, timeout: timeoutMs });\n return 'event';\n } catch (error) {\n /*\n * Only the deadline can tell a real timeout from a failure (see\n * wakeExpired). `startedAt` is not replay-stable, but it is read only\n * inside the step body below, and a step body runs on the live attempt\n * alone — a replay returns the persisted verdict without touching the\n * clock.\n */\n const timedOut = await this.step.do(`${name}:timed-out`, async () =>\n wakeExpired(startedAt, timeoutMs, Date.now())\n );\n if (timedOut) return 'timeout';\n throw error;\n }\n }\n}\n\n/** Development aid: echo each outbound message before handing it to the real sender. */\nfunction logging(sender: MessageSender): MessageSender {\n return {\n async send(message) {\n console.log(\n `[journey] ${message.channel} ${message.template} → ${message.recipient ?? message.userId} ${JSON.stringify(message.props)}`\n );\n return sender.send(message);\n },\n };\n}\n\n/**\n * The generic journey executor: one class runs every workflow, because IR is\n * data. It is loaded from the store by the contentHash pinned at entry —\n * content addressing makes it immutable, so reading it outside a step is\n * replay-safe.\n */\nexport class JourneyRunner extends WorkflowEntrypoint<JourneyEnv, JourneyParams> {\n /**\n * The data plane. D1 + KV from the env by default; an app on Postgres\n * overrides this (and `closeStore` if its client needs closing):\n *\n * protected override createStore() { return new PostgresJourneyStore(client(this.env)); }\n */\n protected createStore(): JourneyStore {\n return d1Store(this.env);\n }\n\n /** Called once `run` is over, success or not — release whatever `createStore` opened. */\n protected async closeStore(_store: JourneyStore): Promise<void> {}\n\n /**\n * Runtime options for this instance — typed configuration, resolved by the app (typically\n * `resolveRuntime(config.runtime, mode)` over its workflow.config.ts, with the mode coming from\n * an ENVIRONMENT var). The instance params are passed so the decision can also be per user:\n * a tester account in production can run in fast-forward while everyone else runs in real\n * time. Defaults: real time, quiet.\n *\n * protected override runtime({ userId }) {\n * return resolveRuntime(workflowConfig.runtime, isTester(userId) ? 'test' : this.env.ENVIRONMENT);\n * }\n */\n protected runtime(_params: JourneyParams): JourneyRuntimeOptions {\n return resolveRuntime(undefined, 'production');\n }\n\n /**\n * Message outlet; an app overrides this to plug in real channels (say\n * CfEmailSender with a react-email renderer). By default it picks the webhook\n * or logging sender based on the environment.\n */\n protected createMessageSender(): MessageSender {\n return this.env.MESSAGE_WEBHOOK_URL\n ? new WebhookMessageSender(this.env.MESSAGE_WEBHOOK_URL)\n : new LogMessageSender();\n }\n\n /**\n * Custom-action registry; an app overrides this returning the same\n * `action(...)` objects its workflows reference (an ActionRef is a\n * RegisteredAction structurally) — the code plane of the dual-plane model:\n *\n * protected override actions() { return [syncCrm, issueCoupon]; }\n */\n protected actions(): readonly RegisteredAction[] {\n return [];\n }\n\n /**\n * The contract events this journey emits (`.sendEvent()`) are checked\n * against, exactly like ingest; journeyWorker passes its config's.\n */\n protected contract(): Contract | undefined {\n return undefined;\n }\n\n /**\n * Template props check before every send; an app overrides this with\n * `registryValidator({ emails, pushes })` (journeyWorker does it from its\n * registries). By default props go out as resolved.\n */\n protected createMessageValidator(): MessageValidator | undefined {\n return undefined;\n }\n\n /**\n * Reporting hooks: node arrivals, every copy sent, how each instance ended. The host stores\n * what it needs for its dashboards; by default nothing is reported.\n */\n protected createObserver(_store: JourneyStore): JourneyObserver | undefined {\n return undefined;\n }\n\n /** Override for a different version policy ('warn' by default) or a fully custom invoker (e.g. webhook degradation for hosted tenants). */\n protected createActionInvoker(): ActionInvoker {\n return new RegistryActionInvoker(this.actions());\n }\n\n async run(event: WorkflowEvent<JourneyParams>, step: WorkflowStep): Promise<JourneyOutcome> {\n const store = this.createStore();\n try {\n return await this.execute(event, step, store);\n } finally {\n await this.closeStore(store);\n }\n }\n\n private async execute(\n event: WorkflowEvent<JourneyParams>,\n step: WorkflowStep,\n store: JourneyStore\n ): Promise<JourneyOutcome> {\n const { workflowId, contentHash, userId } = event.payload;\n const env = this.env;\n\n const stored = await store.getWorkflowIR(contentHash);\n if (stored === undefined) {\n throw new Error(`WorkflowIR not found: ${workflowId}@${contentHash}`);\n }\n const runtime = resolveRuntime({ current: this.runtime(event.payload) }, 'current');\n // Development runs the journey in fast-forward; the pinned hash still names the version.\n const ir = scaleDurations(stored, runtime.timeScale);\n\n const observer = this.createObserver(store);\n const finished = (status: JourneyOutcome['status'] | 'failed', convertedAt?: number) =>\n observer?.finished?.({\n workflow: workflowId,\n instanceId: event.instanceId,\n userId,\n status,\n at: Date.now(),\n ...(convertedAt === undefined ? {} : { convertedAt }),\n });\n\n const messages = runtime.logMessages\n ? logging(this.createMessageSender())\n : this.createMessageSender();\n\n // send_event feeds straight back into the router logic — an in-Worker call\n // forming the event edge between workflows. The step's identity travels as\n // the event id, so a retried emit records the occurrence once.\n // An emitted event passes the same contract check as one arriving over HTTP.\n const contract = this.contract();\n const events: EventSink = {\n emit: async (name, payload, id) => {\n let accepted: Record<string, unknown> = payload;\n if (contract !== undefined) {\n const verdict = checkEvent(contract, name, payload);\n if (!verdict.ok) throw new ContractValidationError(name, verdict.issues);\n accepted = verdict.data;\n }\n await ingestEvent(env, { id, userId, event: name, payload: accepted }, store);\n },\n };\n\n let outcome: JourneyOutcome;\n try {\n outcome = await runJourney(ir, {\n userId,\n instanceId: event.instanceId,\n // Trigger-event creation time: replay-stable, unlike Date.now() here\n enteredAtMs: event.timestamp.getTime(),\n step: new CfEngineStep(step, store, userId, event.instanceId),\n facts: new JourneyFactSource(store, userId),\n messages,\n events,\n actions: this.createActionInvoker(),\n validator: this.createMessageValidator(),\n observer,\n });\n } catch (error) {\n /*\n * An error escaping run() ends the instance, and the ledger is the only\n * place anyone looks afterwards: leaving it at 'running' meant a dead\n * journey stayed indistinguishable from a waiting one, in the dashboard\n * and in the once-policy, forever.\n *\n * Subscriptions are deliberately left in place. They are cleaned up on\n * every ordinary ending, but here the wake rows are the only evidence of\n * what the instance was waiting for, and dropping them would also break\n * the instance if the platform does re-run it.\n */\n await step.do('finalize:failed', async () => {\n await store.setEntryStatus(event.instanceId, 'failed');\n await finished('failed');\n });\n throw error;\n }\n\n await step.do('finalize', async () => {\n await store.setEntryStatus(event.instanceId, outcome.status);\n await store.unsubscribe(event.instanceId);\n await finished(outcome.status, outcome.convertedAt);\n });\n\n return outcome;\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,73 @@
1
+ import { ActionInvoker, JourneyObserver, JourneyOutcome, MessageSender, MessageValidator } from "../engine/ports.cjs";
2
+ import { RegisteredAction } from "../engine/actions.cjs";
3
+ import { Contract } from "../contract.cjs";
4
+ import { JourneyRuntimeOptions } from "../runtime.cjs";
5
+ import { JourneyEnv, JourneyParams } from "./bindings.cjs";
6
+ import { JourneyStore } from "../store/index.cjs";
7
+ import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from "cloudflare:workers";
8
+ //#region src/cloudflare/runner.d.ts
9
+ /**
10
+ * The generic journey executor: one class runs every workflow, because IR is
11
+ * data. It is loaded from the store by the contentHash pinned at entry —
12
+ * content addressing makes it immutable, so reading it outside a step is
13
+ * replay-safe.
14
+ */
15
+ export declare class JourneyRunner extends WorkflowEntrypoint<JourneyEnv, JourneyParams> {
16
+ /**
17
+ * The data plane. D1 + KV from the env by default; an app on Postgres
18
+ * overrides this (and `closeStore` if its client needs closing):
19
+ *
20
+ * protected override createStore() { return new PostgresJourneyStore(client(this.env)); }
21
+ */
22
+ protected createStore(): JourneyStore;
23
+ /** Called once `run` is over, success or not — release whatever `createStore` opened. */
24
+ protected closeStore(_store: JourneyStore): Promise<void>;
25
+ /**
26
+ * Runtime options for this instance — typed configuration, resolved by the app (typically
27
+ * `resolveRuntime(config.runtime, mode)` over its workflow.config.ts, with the mode coming from
28
+ * an ENVIRONMENT var). The instance params are passed so the decision can also be per user:
29
+ * a tester account in production can run in fast-forward while everyone else runs in real
30
+ * time. Defaults: real time, quiet.
31
+ *
32
+ * protected override runtime({ userId }) {
33
+ * return resolveRuntime(workflowConfig.runtime, isTester(userId) ? 'test' : this.env.ENVIRONMENT);
34
+ * }
35
+ */
36
+ protected runtime(_params: JourneyParams): JourneyRuntimeOptions;
37
+ /**
38
+ * Message outlet; an app overrides this to plug in real channels (say
39
+ * CfEmailSender with a react-email renderer). By default it picks the webhook
40
+ * or logging sender based on the environment.
41
+ */
42
+ protected createMessageSender(): MessageSender;
43
+ /**
44
+ * Custom-action registry; an app overrides this returning the same
45
+ * `action(...)` objects its workflows reference (an ActionRef is a
46
+ * RegisteredAction structurally) — the code plane of the dual-plane model:
47
+ *
48
+ * protected override actions() { return [syncCrm, issueCoupon]; }
49
+ */
50
+ protected actions(): readonly RegisteredAction[];
51
+ /**
52
+ * The contract events this journey emits (`.sendEvent()`) are checked
53
+ * against, exactly like ingest; journeyWorker passes its config's.
54
+ */
55
+ protected contract(): Contract | undefined;
56
+ /**
57
+ * Template props check before every send; an app overrides this with
58
+ * `registryValidator({ emails, pushes })` (journeyWorker does it from its
59
+ * registries). By default props go out as resolved.
60
+ */
61
+ protected createMessageValidator(): MessageValidator | undefined;
62
+ /**
63
+ * Reporting hooks: node arrivals, every copy sent, how each instance ended. The host stores
64
+ * what it needs for its dashboards; by default nothing is reported.
65
+ */
66
+ protected createObserver(_store: JourneyStore): JourneyObserver | undefined;
67
+ /** Override for a different version policy ('warn' by default) or a fully custom invoker (e.g. webhook degradation for hosted tenants). */
68
+ protected createActionInvoker(): ActionInvoker;
69
+ run(event: WorkflowEvent<JourneyParams>, step: WorkflowStep): Promise<JourneyOutcome>;
70
+ private execute;
71
+ }
72
+ //#endregion
73
+ //# sourceMappingURL=runner.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.cts","names":[],"sources":["../../src/cloudflare/runner.ts"],"mappings":";;;;;;;;;;;;;;qBAuHa,sBAAsB,mBAAmB,YAAY;;;;;;;YAOtD,eAAe;;YAKT,WAAW,QAAQ,eAAe;;;;;;;;;;;;YAaxC,QAAQ,SAAS,gBAAgB;;;;;;YASjC,uBAAuB;;;;;;;;YAavB,oBAAoB;;;;;YAQpB,YAAY;;;;;;YASZ,0BAA0B;;;;;YAQ1B,eAAe,QAAQ,eAAe;;YAKtC,uBAAuB;EAI3B,IAAI,OAAO,cAAc,gBAAgB,MAAM,eAAe,QAAQ;UAS9D"}
@@ -0,0 +1,73 @@
1
+ import { ActionInvoker, JourneyObserver, JourneyOutcome, MessageSender, MessageValidator } from "../engine/ports.mjs";
2
+ import { RegisteredAction } from "../engine/actions.mjs";
3
+ import { Contract } from "../contract.mjs";
4
+ import { JourneyRuntimeOptions } from "../runtime.mjs";
5
+ import { JourneyEnv, JourneyParams } from "./bindings.mjs";
6
+ import { JourneyStore } from "../store/index.mjs";
7
+ import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from "cloudflare:workers";
8
+ //#region src/cloudflare/runner.d.ts
9
+ /**
10
+ * The generic journey executor: one class runs every workflow, because IR is
11
+ * data. It is loaded from the store by the contentHash pinned at entry —
12
+ * content addressing makes it immutable, so reading it outside a step is
13
+ * replay-safe.
14
+ */
15
+ export declare class JourneyRunner extends WorkflowEntrypoint<JourneyEnv, JourneyParams> {
16
+ /**
17
+ * The data plane. D1 + KV from the env by default; an app on Postgres
18
+ * overrides this (and `closeStore` if its client needs closing):
19
+ *
20
+ * protected override createStore() { return new PostgresJourneyStore(client(this.env)); }
21
+ */
22
+ protected createStore(): JourneyStore;
23
+ /** Called once `run` is over, success or not — release whatever `createStore` opened. */
24
+ protected closeStore(_store: JourneyStore): Promise<void>;
25
+ /**
26
+ * Runtime options for this instance — typed configuration, resolved by the app (typically
27
+ * `resolveRuntime(config.runtime, mode)` over its workflow.config.ts, with the mode coming from
28
+ * an ENVIRONMENT var). The instance params are passed so the decision can also be per user:
29
+ * a tester account in production can run in fast-forward while everyone else runs in real
30
+ * time. Defaults: real time, quiet.
31
+ *
32
+ * protected override runtime({ userId }) {
33
+ * return resolveRuntime(workflowConfig.runtime, isTester(userId) ? 'test' : this.env.ENVIRONMENT);
34
+ * }
35
+ */
36
+ protected runtime(_params: JourneyParams): JourneyRuntimeOptions;
37
+ /**
38
+ * Message outlet; an app overrides this to plug in real channels (say
39
+ * CfEmailSender with a react-email renderer). By default it picks the webhook
40
+ * or logging sender based on the environment.
41
+ */
42
+ protected createMessageSender(): MessageSender;
43
+ /**
44
+ * Custom-action registry; an app overrides this returning the same
45
+ * `action(...)` objects its workflows reference (an ActionRef is a
46
+ * RegisteredAction structurally) — the code plane of the dual-plane model:
47
+ *
48
+ * protected override actions() { return [syncCrm, issueCoupon]; }
49
+ */
50
+ protected actions(): readonly RegisteredAction[];
51
+ /**
52
+ * The contract events this journey emits (`.sendEvent()`) are checked
53
+ * against, exactly like ingest; journeyWorker passes its config's.
54
+ */
55
+ protected contract(): Contract | undefined;
56
+ /**
57
+ * Template props check before every send; an app overrides this with
58
+ * `registryValidator({ emails, pushes })` (journeyWorker does it from its
59
+ * registries). By default props go out as resolved.
60
+ */
61
+ protected createMessageValidator(): MessageValidator | undefined;
62
+ /**
63
+ * Reporting hooks: node arrivals, every copy sent, how each instance ended. The host stores
64
+ * what it needs for its dashboards; by default nothing is reported.
65
+ */
66
+ protected createObserver(_store: JourneyStore): JourneyObserver | undefined;
67
+ /** Override for a different version policy ('warn' by default) or a fully custom invoker (e.g. webhook degradation for hosted tenants). */
68
+ protected createActionInvoker(): ActionInvoker;
69
+ run(event: WorkflowEvent<JourneyParams>, step: WorkflowStep): Promise<JourneyOutcome>;
70
+ private execute;
71
+ }
72
+ //#endregion
73
+ //# sourceMappingURL=runner.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.mts","names":[],"sources":["../../src/cloudflare/runner.ts"],"mappings":";;;;;;;;;;;;;;qBAuHa,sBAAsB,mBAAmB,YAAY;;;;;;;YAOtD,eAAe;;YAKT,WAAW,QAAQ,eAAe;;;;;;;;;;;;YAaxC,QAAQ,SAAS,gBAAgB;;;;;;YASjC,uBAAuB;;;;;;;;YAavB,oBAAoB;;;;;YAQpB,YAAY;;;;;;YASZ,0BAA0B;;;;;YAQ1B,eAAe,QAAQ,eAAe;;YAKtC,uBAAuB;EAI3B,IAAI,OAAO,cAAc,gBAAgB,MAAM,eAAe,QAAQ;UAS9D"}
@@ -0,0 +1,224 @@
1
+ import { ContractValidationError, checkEvent } from "../contract.mjs";
2
+ import { resolveRuntime } from "../runtime.mjs";
3
+ import { WAKE_EVENT_TYPE, wakeExpired } from "./bindings.mjs";
4
+ import { JourneyFactSource } from "../store/facts.mjs";
5
+ import { d1Store } from "./d1-env.mjs";
6
+ import { ingestEvent } from "./router.mjs";
7
+ import { LogMessageSender, WebhookMessageSender } from "./senders.mjs";
8
+ import { RegistryActionInvoker } from "../engine/actions.mjs";
9
+ import { runJourney } from "../engine/interpreter.mjs";
10
+ import { scaleDurations } from "../engine/time-scale.mjs";
11
+ import { WorkflowEntrypoint } from "cloudflare:workers";
12
+ import { NonRetryableError } from "cloudflare:workflows";
13
+ //#region src/cloudflare/runner.ts
14
+ /**
15
+ * Adapts CF's WorkflowStep to EngineStep.
16
+ * subscribe/unsubscribe write the subscription table inside durable steps (the
17
+ * router wakes instances from that table); waitForWake parks on CF's
18
+ * waitForEvent, which signals a timeout by throwing — and so does every other
19
+ * failure in there, so only the clock can tell them apart (see wakeExpired).
20
+ */
21
+ /** Refusals a retry would only repeat: a template's props, an emitted event's payload. */
22
+ const NON_RETRYABLE = /* @__PURE__ */ new Set(["TemplateValidationError", "ContractValidationError"]);
23
+ var CfEngineStep = class {
24
+ step;
25
+ store;
26
+ userId;
27
+ instanceId;
28
+ constructor(step, store, userId, instanceId) {
29
+ this.step = step;
30
+ this.store = store;
31
+ this.userId = userId;
32
+ this.instanceId = instanceId;
33
+ }
34
+ /**
35
+ * A template refusing its props, or the contract refusing an emitted event,
36
+ * is deterministic — a retry hits the same refusal — so it ends the step at
37
+ * once instead of burning the retry budget.
38
+ */
39
+ do(name, fn) {
40
+ return this.step.do(name, async () => {
41
+ try {
42
+ return await fn();
43
+ } catch (error) {
44
+ if (error instanceof Error && NON_RETRYABLE.has(error.name)) throw new NonRetryableError(error.message, error.name);
45
+ throw error;
46
+ }
47
+ });
48
+ }
49
+ sleep(name, ms) {
50
+ return this.step.sleep(name, ms);
51
+ }
52
+ sleepUntil(name, timestampMs) {
53
+ return this.step.sleepUntil(name, timestampMs);
54
+ }
55
+ subscribe(name, events) {
56
+ return this.step.do(name, () => this.store.subscribe(this.instanceId, this.userId, events, Date.now()));
57
+ }
58
+ unsubscribe(name) {
59
+ return this.step.do(name, () => this.store.unsubscribe(this.instanceId));
60
+ }
61
+ async waitForWake(name, timeoutMs) {
62
+ const startedAt = Date.now();
63
+ try {
64
+ await this.step.waitForEvent(name, {
65
+ type: WAKE_EVENT_TYPE,
66
+ timeout: timeoutMs
67
+ });
68
+ return "event";
69
+ } catch (error) {
70
+ if (await this.step.do(`${name}:timed-out`, async () => wakeExpired(startedAt, timeoutMs, Date.now()))) return "timeout";
71
+ throw error;
72
+ }
73
+ }
74
+ };
75
+ /** Development aid: echo each outbound message before handing it to the real sender. */
76
+ function logging(sender) {
77
+ return { async send(message) {
78
+ console.log(`[journey] ${message.channel} ${message.template} → ${message.recipient ?? message.userId} ${JSON.stringify(message.props)}`);
79
+ return sender.send(message);
80
+ } };
81
+ }
82
+ /**
83
+ * The generic journey executor: one class runs every workflow, because IR is
84
+ * data. It is loaded from the store by the contentHash pinned at entry —
85
+ * content addressing makes it immutable, so reading it outside a step is
86
+ * replay-safe.
87
+ */
88
+ var JourneyRunner = class extends WorkflowEntrypoint {
89
+ /**
90
+ * The data plane. D1 + KV from the env by default; an app on Postgres
91
+ * overrides this (and `closeStore` if its client needs closing):
92
+ *
93
+ * protected override createStore() { return new PostgresJourneyStore(client(this.env)); }
94
+ */
95
+ createStore() {
96
+ return d1Store(this.env);
97
+ }
98
+ /** Called once `run` is over, success or not — release whatever `createStore` opened. */
99
+ async closeStore(_store) {}
100
+ /**
101
+ * Runtime options for this instance — typed configuration, resolved by the app (typically
102
+ * `resolveRuntime(config.runtime, mode)` over its workflow.config.ts, with the mode coming from
103
+ * an ENVIRONMENT var). The instance params are passed so the decision can also be per user:
104
+ * a tester account in production can run in fast-forward while everyone else runs in real
105
+ * time. Defaults: real time, quiet.
106
+ *
107
+ * protected override runtime({ userId }) {
108
+ * return resolveRuntime(workflowConfig.runtime, isTester(userId) ? 'test' : this.env.ENVIRONMENT);
109
+ * }
110
+ */
111
+ runtime(_params) {
112
+ return resolveRuntime(void 0, "production");
113
+ }
114
+ /**
115
+ * Message outlet; an app overrides this to plug in real channels (say
116
+ * CfEmailSender with a react-email renderer). By default it picks the webhook
117
+ * or logging sender based on the environment.
118
+ */
119
+ createMessageSender() {
120
+ return this.env.MESSAGE_WEBHOOK_URL ? new WebhookMessageSender(this.env.MESSAGE_WEBHOOK_URL) : new LogMessageSender();
121
+ }
122
+ /**
123
+ * Custom-action registry; an app overrides this returning the same
124
+ * `action(...)` objects its workflows reference (an ActionRef is a
125
+ * RegisteredAction structurally) — the code plane of the dual-plane model:
126
+ *
127
+ * protected override actions() { return [syncCrm, issueCoupon]; }
128
+ */
129
+ actions() {
130
+ return [];
131
+ }
132
+ /**
133
+ * The contract events this journey emits (`.sendEvent()`) are checked
134
+ * against, exactly like ingest; journeyWorker passes its config's.
135
+ */
136
+ contract() {}
137
+ /**
138
+ * Template props check before every send; an app overrides this with
139
+ * `registryValidator({ emails, pushes })` (journeyWorker does it from its
140
+ * registries). By default props go out as resolved.
141
+ */
142
+ createMessageValidator() {}
143
+ /**
144
+ * Reporting hooks: node arrivals, every copy sent, how each instance ended. The host stores
145
+ * what it needs for its dashboards; by default nothing is reported.
146
+ */
147
+ createObserver(_store) {}
148
+ /** Override for a different version policy ('warn' by default) or a fully custom invoker (e.g. webhook degradation for hosted tenants). */
149
+ createActionInvoker() {
150
+ return new RegistryActionInvoker(this.actions());
151
+ }
152
+ async run(event, step) {
153
+ const store = this.createStore();
154
+ try {
155
+ return await this.execute(event, step, store);
156
+ } finally {
157
+ await this.closeStore(store);
158
+ }
159
+ }
160
+ async execute(event, step, store) {
161
+ const { workflowId, contentHash, userId } = event.payload;
162
+ const env = this.env;
163
+ const stored = await store.getWorkflowIR(contentHash);
164
+ if (stored === void 0) throw new Error(`WorkflowIR not found: ${workflowId}@${contentHash}`);
165
+ const runtime = resolveRuntime({ current: this.runtime(event.payload) }, "current");
166
+ const ir = scaleDurations(stored, runtime.timeScale);
167
+ const observer = this.createObserver(store);
168
+ const finished = (status, convertedAt) => observer?.finished?.({
169
+ workflow: workflowId,
170
+ instanceId: event.instanceId,
171
+ userId,
172
+ status,
173
+ at: Date.now(),
174
+ ...convertedAt === void 0 ? {} : { convertedAt }
175
+ });
176
+ const messages = runtime.logMessages ? logging(this.createMessageSender()) : this.createMessageSender();
177
+ const contract = this.contract();
178
+ const events = { emit: async (name, payload, id) => {
179
+ let accepted = payload;
180
+ if (contract !== void 0) {
181
+ const verdict = checkEvent(contract, name, payload);
182
+ if (!verdict.ok) throw new ContractValidationError(name, verdict.issues);
183
+ accepted = verdict.data;
184
+ }
185
+ await ingestEvent(env, {
186
+ id,
187
+ userId,
188
+ event: name,
189
+ payload: accepted
190
+ }, store);
191
+ } };
192
+ let outcome;
193
+ try {
194
+ outcome = await runJourney(ir, {
195
+ userId,
196
+ instanceId: event.instanceId,
197
+ enteredAtMs: event.timestamp.getTime(),
198
+ step: new CfEngineStep(step, store, userId, event.instanceId),
199
+ facts: new JourneyFactSource(store, userId),
200
+ messages,
201
+ events,
202
+ actions: this.createActionInvoker(),
203
+ validator: this.createMessageValidator(),
204
+ observer
205
+ });
206
+ } catch (error) {
207
+ await step.do("finalize:failed", async () => {
208
+ await store.setEntryStatus(event.instanceId, "failed");
209
+ await finished("failed");
210
+ });
211
+ throw error;
212
+ }
213
+ await step.do("finalize", async () => {
214
+ await store.setEntryStatus(event.instanceId, outcome.status);
215
+ await store.unsubscribe(event.instanceId);
216
+ await finished(outcome.status, outcome.convertedAt);
217
+ });
218
+ return outcome;
219
+ }
220
+ };
221
+ //#endregion
222
+ export { JourneyRunner };
223
+
224
+ //# sourceMappingURL=runner.mjs.map