@shware/workflow 3.2.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/README.md +100 -29
  2. package/dist/apns.cjs +113 -26
  3. package/dist/apns.cjs.map +1 -1
  4. package/dist/apns.d.cts +52 -6
  5. package/dist/apns.d.cts.map +1 -1
  6. package/dist/apns.d.mts +52 -6
  7. package/dist/apns.d.mts.map +1 -1
  8. package/dist/apns.mjs +111 -27
  9. package/dist/apns.mjs.map +1 -1
  10. package/dist/aws/engine-step.cjs +5 -5
  11. package/dist/aws/engine-step.cjs.map +1 -1
  12. package/dist/aws/engine-step.d.cts +8 -2
  13. package/dist/aws/engine-step.d.cts.map +1 -1
  14. package/dist/aws/engine-step.d.mts +8 -2
  15. package/dist/aws/engine-step.d.mts.map +1 -1
  16. package/dist/aws/engine-step.mjs +5 -5
  17. package/dist/aws/engine-step.mjs.map +1 -1
  18. package/dist/aws/index.cjs +47 -6
  19. package/dist/aws/index.cjs.map +1 -1
  20. package/dist/aws/index.d.cts +2 -2
  21. package/dist/aws/index.d.cts.map +1 -1
  22. package/dist/aws/index.d.mts +2 -2
  23. package/dist/aws/index.d.mts.map +1 -1
  24. package/dist/aws/index.mjs +47 -6
  25. package/dist/aws/index.mjs.map +1 -1
  26. package/dist/aws/instances.cjs +29 -6
  27. package/dist/aws/instances.cjs.map +1 -1
  28. package/dist/aws/instances.d.cts +11 -1
  29. package/dist/aws/instances.d.cts.map +1 -1
  30. package/dist/aws/instances.d.mts +11 -1
  31. package/dist/aws/instances.d.mts.map +1 -1
  32. package/dist/aws/instances.mjs +27 -4
  33. package/dist/aws/instances.mjs.map +1 -1
  34. package/dist/client.cjs +4 -1
  35. package/dist/client.cjs.map +1 -1
  36. package/dist/client.d.cts +2 -2
  37. package/dist/client.d.cts.map +1 -1
  38. package/dist/client.d.mts +2 -2
  39. package/dist/client.d.mts.map +1 -1
  40. package/dist/client.mjs +4 -1
  41. package/dist/client.mjs.map +1 -1
  42. package/dist/cloudflare/bindings.cjs +28 -25
  43. package/dist/cloudflare/bindings.cjs.map +1 -1
  44. package/dist/cloudflare/bindings.d.cts +17 -129
  45. package/dist/cloudflare/bindings.d.cts.map +1 -1
  46. package/dist/cloudflare/bindings.d.mts +17 -129
  47. package/dist/cloudflare/bindings.d.mts.map +1 -1
  48. package/dist/cloudflare/bindings.mjs +28 -23
  49. package/dist/cloudflare/bindings.mjs.map +1 -1
  50. package/dist/cloudflare/d1-env.cjs +6 -6
  51. package/dist/cloudflare/d1-env.cjs.map +1 -1
  52. package/dist/cloudflare/d1-env.d.cts +5 -5
  53. package/dist/cloudflare/d1-env.d.mts +5 -5
  54. package/dist/cloudflare/d1-env.mjs +6 -6
  55. package/dist/cloudflare/d1-env.mjs.map +1 -1
  56. package/dist/cloudflare/index.cjs +28 -18
  57. package/dist/cloudflare/index.d.cts +8 -4
  58. package/dist/cloudflare/index.d.mts +8 -4
  59. package/dist/cloudflare/index.mjs +9 -5
  60. package/dist/cloudflare/runner.cjs +29 -14
  61. package/dist/cloudflare/runner.cjs.map +1 -1
  62. package/dist/cloudflare/runner.d.cts +9 -2
  63. package/dist/cloudflare/runner.d.cts.map +1 -1
  64. package/dist/cloudflare/runner.d.mts +9 -2
  65. package/dist/cloudflare/runner.d.mts.map +1 -1
  66. package/dist/cloudflare/runner.mjs +28 -13
  67. package/dist/cloudflare/runner.mjs.map +1 -1
  68. package/dist/cloudflare/schema.sql +27 -6
  69. package/dist/cloudflare/worker.cjs +19 -9
  70. package/dist/cloudflare/worker.cjs.map +1 -1
  71. package/dist/cloudflare/worker.d.cts +2 -2
  72. package/dist/cloudflare/worker.d.cts.map +1 -1
  73. package/dist/cloudflare/worker.d.mts +2 -2
  74. package/dist/cloudflare/worker.d.mts.map +1 -1
  75. package/dist/cloudflare/worker.mjs +19 -9
  76. package/dist/cloudflare/worker.mjs.map +1 -1
  77. package/dist/config.cjs +21 -5
  78. package/dist/config.cjs.map +1 -1
  79. package/dist/config.mjs +21 -5
  80. package/dist/config.mjs.map +1 -1
  81. package/dist/dsl/action.cjs +3 -6
  82. package/dist/dsl/action.cjs.map +1 -1
  83. package/dist/dsl/action.d.cts +12 -11
  84. package/dist/dsl/action.d.cts.map +1 -1
  85. package/dist/dsl/action.d.mts +12 -11
  86. package/dist/dsl/action.d.mts.map +1 -1
  87. package/dist/dsl/action.mjs +3 -6
  88. package/dist/dsl/action.mjs.map +1 -1
  89. package/dist/dsl/bundle.cjs +35 -31
  90. package/dist/dsl/bundle.cjs.map +1 -1
  91. package/dist/dsl/bundle.d.cts.map +1 -1
  92. package/dist/dsl/bundle.d.mts.map +1 -1
  93. package/dist/dsl/bundle.mjs +35 -31
  94. package/dist/dsl/bundle.mjs.map +1 -1
  95. package/dist/dsl/condition.cjs +13 -1
  96. package/dist/dsl/condition.cjs.map +1 -1
  97. package/dist/dsl/condition.d.cts +9 -1
  98. package/dist/dsl/condition.d.cts.map +1 -1
  99. package/dist/dsl/condition.d.mts +9 -1
  100. package/dist/dsl/condition.d.mts.map +1 -1
  101. package/dist/dsl/condition.mjs +13 -2
  102. package/dist/dsl/condition.mjs.map +1 -1
  103. package/dist/dsl/flow.cjs +33 -11
  104. package/dist/dsl/flow.cjs.map +1 -1
  105. package/dist/dsl/flow.d.cts +9 -1
  106. package/dist/dsl/flow.d.cts.map +1 -1
  107. package/dist/dsl/flow.d.mts +9 -1
  108. package/dist/dsl/flow.d.mts.map +1 -1
  109. package/dist/dsl/flow.mjs +34 -13
  110. package/dist/dsl/flow.mjs.map +1 -1
  111. package/dist/dsl/workflow.cjs +2 -3
  112. package/dist/dsl/workflow.cjs.map +1 -1
  113. package/dist/dsl/workflow.d.cts.map +1 -1
  114. package/dist/dsl/workflow.d.mts.map +1 -1
  115. package/dist/dsl/workflow.mjs +3 -4
  116. package/dist/dsl/workflow.mjs.map +1 -1
  117. package/dist/email-sender.cjs +24 -0
  118. package/dist/email-sender.cjs.map +1 -1
  119. package/dist/email-sender.d.cts +18 -0
  120. package/dist/email-sender.d.cts.map +1 -1
  121. package/dist/email-sender.d.mts +18 -0
  122. package/dist/email-sender.d.mts.map +1 -1
  123. package/dist/email-sender.mjs +24 -1
  124. package/dist/email-sender.mjs.map +1 -1
  125. package/dist/engine/actions.cjs +1 -8
  126. package/dist/engine/actions.cjs.map +1 -1
  127. package/dist/engine/actions.d.cts +1 -12
  128. package/dist/engine/actions.d.cts.map +1 -1
  129. package/dist/engine/actions.d.mts +1 -12
  130. package/dist/engine/actions.d.mts.map +1 -1
  131. package/dist/engine/actions.mjs +1 -8
  132. package/dist/engine/actions.mjs.map +1 -1
  133. package/dist/engine/condition.cjs +25 -5
  134. package/dist/engine/condition.cjs.map +1 -1
  135. package/dist/engine/condition.d.cts +12 -3
  136. package/dist/engine/condition.d.cts.map +1 -1
  137. package/dist/engine/condition.d.mts +12 -3
  138. package/dist/engine/condition.d.mts.map +1 -1
  139. package/dist/engine/condition.mjs +25 -6
  140. package/dist/engine/condition.mjs.map +1 -1
  141. package/dist/engine/index.cjs +3 -0
  142. package/dist/engine/index.d.cts +5 -5
  143. package/dist/engine/index.d.mts +5 -5
  144. package/dist/engine/index.mjs +4 -4
  145. package/dist/engine/interpreter.cjs +27 -20
  146. package/dist/engine/interpreter.cjs.map +1 -1
  147. package/dist/engine/interpreter.d.cts.map +1 -1
  148. package/dist/engine/interpreter.d.mts.map +1 -1
  149. package/dist/engine/interpreter.mjs +27 -20
  150. package/dist/engine/interpreter.mjs.map +1 -1
  151. package/dist/engine/ports.d.cts +21 -6
  152. package/dist/engine/ports.d.cts.map +1 -1
  153. package/dist/engine/ports.d.mts +21 -6
  154. package/dist/engine/ports.d.mts.map +1 -1
  155. package/dist/engine/retry.cjs +13 -0
  156. package/dist/engine/retry.cjs.map +1 -1
  157. package/dist/engine/retry.d.cts +12 -0
  158. package/dist/engine/retry.d.cts.map +1 -1
  159. package/dist/engine/retry.d.mts +12 -0
  160. package/dist/engine/retry.d.mts.map +1 -1
  161. package/dist/engine/retry.mjs +13 -1
  162. package/dist/engine/retry.mjs.map +1 -1
  163. package/dist/engine/time-scale.cjs +90 -15
  164. package/dist/engine/time-scale.cjs.map +1 -1
  165. package/dist/engine/time-scale.d.cts +9 -6
  166. package/dist/engine/time-scale.d.cts.map +1 -1
  167. package/dist/engine/time-scale.d.mts +9 -6
  168. package/dist/engine/time-scale.d.mts.map +1 -1
  169. package/dist/engine/time-scale.mjs +90 -16
  170. package/dist/engine/time-scale.mjs.map +1 -1
  171. package/dist/fcm.cjs +111 -38
  172. package/dist/fcm.cjs.map +1 -1
  173. package/dist/fcm.d.cts +45 -5
  174. package/dist/fcm.d.cts.map +1 -1
  175. package/dist/fcm.d.mts +45 -5
  176. package/dist/fcm.d.mts.map +1 -1
  177. package/dist/fcm.mjs +110 -39
  178. package/dist/fcm.mjs.map +1 -1
  179. package/dist/hash.cjs +6 -6
  180. package/dist/hash.cjs.map +1 -1
  181. package/dist/hash.mjs +6 -6
  182. package/dist/hash.mjs.map +1 -1
  183. package/dist/host/auth.cjs +49 -0
  184. package/dist/host/auth.cjs.map +1 -0
  185. package/dist/host/auth.d.cts +21 -0
  186. package/dist/host/auth.d.cts.map +1 -0
  187. package/dist/host/auth.d.mts +21 -0
  188. package/dist/host/auth.d.mts.map +1 -0
  189. package/dist/host/auth.mjs +47 -0
  190. package/dist/host/auth.mjs.map +1 -0
  191. package/dist/host/channels.cjs +118 -40
  192. package/dist/host/channels.cjs.map +1 -1
  193. package/dist/host/channels.d.cts +27 -1
  194. package/dist/host/channels.d.cts.map +1 -1
  195. package/dist/host/channels.d.mts +27 -1
  196. package/dist/host/channels.d.mts.map +1 -1
  197. package/dist/host/channels.mjs +121 -44
  198. package/dist/host/channels.mjs.map +1 -1
  199. package/dist/host/execute.cjs +14 -2
  200. package/dist/host/execute.cjs.map +1 -1
  201. package/dist/host/execute.d.cts +4 -4
  202. package/dist/host/execute.d.cts.map +1 -1
  203. package/dist/host/execute.d.mts +4 -4
  204. package/dist/host/execute.d.mts.map +1 -1
  205. package/dist/host/execute.mjs +13 -1
  206. package/dist/host/execute.mjs.map +1 -1
  207. package/dist/host/fresh-read.cjs +30 -0
  208. package/dist/host/fresh-read.cjs.map +1 -0
  209. package/dist/host/fresh-read.d.cts +18 -0
  210. package/dist/host/fresh-read.d.cts.map +1 -0
  211. package/dist/host/fresh-read.d.mts +18 -0
  212. package/dist/host/fresh-read.d.mts.map +1 -0
  213. package/dist/host/fresh-read.mjs +29 -0
  214. package/dist/host/fresh-read.mjs.map +1 -0
  215. package/dist/host/http.cjs +321 -0
  216. package/dist/host/http.cjs.map +1 -0
  217. package/dist/host/http.d.cts +54 -0
  218. package/dist/host/http.d.cts.map +1 -0
  219. package/dist/host/http.d.mts +54 -0
  220. package/dist/host/http.d.mts.map +1 -0
  221. package/dist/host/http.mjs +317 -0
  222. package/dist/host/http.mjs.map +1 -0
  223. package/dist/host/{router.cjs → ingest.cjs} +147 -175
  224. package/dist/host/ingest.cjs.map +1 -0
  225. package/dist/host/{router.d.cts → ingest.d.cts} +48 -30
  226. package/dist/host/ingest.d.cts.map +1 -0
  227. package/dist/host/{router.d.mts → ingest.d.mts} +48 -30
  228. package/dist/host/ingest.d.mts.map +1 -0
  229. package/dist/host/{router.mjs → ingest.mjs} +144 -173
  230. package/dist/host/ingest.mjs.map +1 -0
  231. package/dist/host/journey-host.cjs +65 -93
  232. package/dist/host/journey-host.cjs.map +1 -1
  233. package/dist/host/journey-host.d.cts +19 -26
  234. package/dist/host/journey-host.d.cts.map +1 -1
  235. package/dist/host/journey-host.d.mts +19 -26
  236. package/dist/host/journey-host.d.mts.map +1 -1
  237. package/dist/host/journey-host.mjs +65 -93
  238. package/dist/host/journey-host.mjs.map +1 -1
  239. package/dist/host/platform.cjs +21 -0
  240. package/dist/host/platform.cjs.map +1 -0
  241. package/dist/host/platform.d.cts +126 -0
  242. package/dist/host/platform.d.cts.map +1 -0
  243. package/dist/host/platform.d.mts +126 -0
  244. package/dist/host/platform.d.mts.map +1 -0
  245. package/dist/host/platform.mjs +19 -0
  246. package/dist/host/platform.mjs.map +1 -0
  247. package/dist/host/senders.cjs +18 -9
  248. package/dist/host/senders.cjs.map +1 -1
  249. package/dist/host/senders.d.cts +9 -4
  250. package/dist/host/senders.d.cts.map +1 -1
  251. package/dist/host/senders.d.mts +9 -4
  252. package/dist/host/senders.d.mts.map +1 -1
  253. package/dist/host/senders.mjs +18 -9
  254. package/dist/host/senders.mjs.map +1 -1
  255. package/dist/index.cjs +1 -1
  256. package/dist/index.mjs +1 -1
  257. package/dist/ir.cjs +5 -7
  258. package/dist/ir.cjs.map +1 -1
  259. package/dist/ir.d.cts +3 -12
  260. package/dist/ir.d.cts.map +1 -1
  261. package/dist/ir.d.mts +3 -12
  262. package/dist/ir.d.mts.map +1 -1
  263. package/dist/ir.mjs +5 -7
  264. package/dist/ir.mjs.map +1 -1
  265. package/dist/plan.cjs +27 -33
  266. package/dist/plan.cjs.map +1 -1
  267. package/dist/plan.d.cts +1 -1
  268. package/dist/plan.d.cts.map +1 -1
  269. package/dist/plan.d.mts +1 -1
  270. package/dist/plan.d.mts.map +1 -1
  271. package/dist/plan.mjs +27 -33
  272. package/dist/plan.mjs.map +1 -1
  273. package/dist/reporting/observer.cjs +1 -0
  274. package/dist/reporting/observer.cjs.map +1 -1
  275. package/dist/reporting/observer.mjs +1 -0
  276. package/dist/reporting/observer.mjs.map +1 -1
  277. package/dist/reporting/tracking.cjs +19 -4
  278. package/dist/reporting/tracking.cjs.map +1 -1
  279. package/dist/reporting/tracking.d.cts +13 -11
  280. package/dist/reporting/tracking.d.cts.map +1 -1
  281. package/dist/reporting/tracking.d.mts +13 -11
  282. package/dist/reporting/tracking.d.mts.map +1 -1
  283. package/dist/reporting/tracking.mjs +19 -4
  284. package/dist/reporting/tracking.mjs.map +1 -1
  285. package/dist/store/d1.cjs +88 -29
  286. package/dist/store/d1.cjs.map +1 -1
  287. package/dist/store/d1.d.cts +29 -11
  288. package/dist/store/d1.d.cts.map +1 -1
  289. package/dist/store/d1.d.mts +29 -11
  290. package/dist/store/d1.d.mts.map +1 -1
  291. package/dist/store/d1.mjs +88 -29
  292. package/dist/store/d1.mjs.map +1 -1
  293. package/dist/store/erasure.cjs +22 -0
  294. package/dist/store/erasure.cjs.map +1 -0
  295. package/dist/store/erasure.d.cts +18 -0
  296. package/dist/store/erasure.d.cts.map +1 -0
  297. package/dist/store/erasure.d.mts +18 -0
  298. package/dist/store/erasure.d.mts.map +1 -0
  299. package/dist/store/erasure.mjs +21 -0
  300. package/dist/store/erasure.mjs.map +1 -0
  301. package/dist/store/index.cjs +2 -0
  302. package/dist/store/index.cjs.map +1 -1
  303. package/dist/store/index.d.cts +67 -13
  304. package/dist/store/index.d.cts.map +1 -1
  305. package/dist/store/index.d.mts +67 -13
  306. package/dist/store/index.d.mts.map +1 -1
  307. package/dist/store/index.mjs +2 -1
  308. package/dist/store/index.mjs.map +1 -1
  309. package/dist/store/postgres-reporting.cjs +125 -62
  310. package/dist/store/postgres-reporting.cjs.map +1 -1
  311. package/dist/store/postgres-reporting.d.cts +30 -2
  312. package/dist/store/postgres-reporting.d.cts.map +1 -1
  313. package/dist/store/postgres-reporting.d.mts +30 -2
  314. package/dist/store/postgres-reporting.d.mts.map +1 -1
  315. package/dist/store/postgres-reporting.mjs +125 -62
  316. package/dist/store/postgres-reporting.mjs.map +1 -1
  317. package/dist/store/postgres.cjs +179 -60
  318. package/dist/store/postgres.cjs.map +1 -1
  319. package/dist/store/postgres.d.cts +44 -7
  320. package/dist/store/postgres.d.cts.map +1 -1
  321. package/dist/store/postgres.d.mts +44 -7
  322. package/dist/store/postgres.d.mts.map +1 -1
  323. package/dist/store/postgres.mjs +179 -60
  324. package/dist/store/postgres.mjs.map +1 -1
  325. package/dist/store/tables.cjs +7 -5
  326. package/dist/store/tables.cjs.map +1 -1
  327. package/dist/store/tables.d.cts.map +1 -1
  328. package/dist/store/tables.d.mts.map +1 -1
  329. package/dist/store/tables.mjs +7 -5
  330. package/dist/store/tables.mjs.map +1 -1
  331. package/dist/store/user-lock.cjs +43 -0
  332. package/dist/store/user-lock.cjs.map +1 -0
  333. package/dist/store/user-lock.d.cts +32 -0
  334. package/dist/store/user-lock.d.cts.map +1 -0
  335. package/dist/store/user-lock.d.mts +32 -0
  336. package/dist/store/user-lock.d.mts.map +1 -0
  337. package/dist/store/user-lock.mjs +40 -0
  338. package/dist/store/user-lock.mjs.map +1 -0
  339. package/dist/transports/cloudflare-email.cjs +3 -2
  340. package/dist/transports/cloudflare-email.cjs.map +1 -1
  341. package/dist/transports/cloudflare-email.mjs +3 -2
  342. package/dist/transports/cloudflare-email.mjs.map +1 -1
  343. package/dist/transports/ses.cjs +52 -7
  344. package/dist/transports/ses.cjs.map +1 -1
  345. package/dist/transports/ses.d.cts +9 -1
  346. package/dist/transports/ses.d.cts.map +1 -1
  347. package/dist/transports/ses.d.mts +9 -1
  348. package/dist/transports/ses.d.mts.map +1 -1
  349. package/dist/transports/ses.mjs +52 -8
  350. package/dist/transports/ses.mjs.map +1 -1
  351. package/dist/webpush.cjs +133 -47
  352. package/dist/webpush.cjs.map +1 -1
  353. package/dist/webpush.d.cts +49 -8
  354. package/dist/webpush.d.cts.map +1 -1
  355. package/dist/webpush.d.mts +49 -8
  356. package/dist/webpush.d.mts.map +1 -1
  357. package/dist/webpush.mjs +130 -47
  358. package/dist/webpush.mjs.map +1 -1
  359. package/package.json +1 -1
  360. package/src/cloudflare/schema.sql +27 -6
  361. package/dist/host/router.cjs.map +0 -1
  362. package/dist/host/router.d.cts.map +0 -1
  363. package/dist/host/router.d.mts.map +0 -1
  364. package/dist/host/router.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { EmailAddress } from "../email.mjs";
2
- import { ExecutionStart } from "../store/index.mjs";
2
+ import { WorkflowBindingLike } from "../host/platform.mjs";
3
3
  //#region src/cloudflare/bindings.d.ts
4
4
  /**
5
5
  * A minimal structural interface over the Cloudflare bindings.
@@ -9,10 +9,6 @@ import { ExecutionStart } from "../store/index.mjs";
9
9
  * subset plus the ambient cloudflare:workers declaration is enough to compile,
10
10
  * and the real bindings satisfy it structurally at runtime.
11
11
  */
12
- export interface KVNamespaceLike {
13
- get(key: string): Promise<string | null>;
14
- put(key: string, value: string): Promise<void>;
15
- }
16
12
  /** Structural subset of D1Result: `meta.changes` is how INSERT OR IGNORE reports whether it inserted. */
17
13
  export interface D1RunResultLike {
18
14
  meta?: {
@@ -32,53 +28,6 @@ export interface D1DatabaseLike {
32
28
  /** Statements run in order inside one transaction (real D1 semantics) — deploy relies on the atomicity. */
33
29
  batch(statements: D1PreparedStatementLike[]): Promise<unknown>;
34
30
  }
35
- export interface WorkflowInstanceLike {
36
- id: string;
37
- sendEvent(event: {
38
- type: string;
39
- payload?: unknown;
40
- }): Promise<void>;
41
- /** Stop the instance for good (Cloudflare Workflows' `terminate`). */
42
- terminate?(): Promise<void>;
43
- /** Where it stands (`complete`, `errored`, `terminated`, `running`, …). */
44
- status?(): Promise<{
45
- status: string;
46
- }>;
47
- }
48
- /**
49
- * How the router starts, wakes and stops instances: Cloudflare's workflow binding, or the AWS
50
- * adapter's equivalent over durable executions.
51
- */
52
- export interface WorkflowBindingLike {
53
- create(options: {
54
- id: string;
55
- params: unknown;
56
- }): Promise<WorkflowInstanceLike>;
57
- get(id: string): Promise<WorkflowInstanceLike>;
58
- /**
59
- * For a runtime whose start is a submit that can be lost in flight (AWS): the start to record
60
- * with the entry, in one transaction. A failed `create` then keeps the entry — its recorded
61
- * start is retried by the next ingest for the pair (`resume`) or by maintenance, never rolled
62
- * back and re-entered as a second execution.
63
- */
64
- plan?(options: {
65
- id: string;
66
- params: JourneyParams;
67
- ts: number;
68
- /** The code version whose routes named `params.contentHash` (absent after a forced deploy). */
69
- version?: string | undefined;
70
- }): Promise<ExecutionStart>;
71
- /** Retry the recorded, unconfirmed start of the (workflow, user) entry still running, if any. */
72
- resume?(entry: {
73
- workflow: string;
74
- userId: string;
75
- }): Promise<void>;
76
- /**
77
- * Maintenance the sweep runs first: old unconfirmed starts retried (or given up on), and
78
- * executions the platform ended on its own (timeout, stop, crash) reconciled into the ledger.
79
- */
80
- maintain?(): Promise<void>;
81
- }
82
31
  /**
83
32
  * Cloudflare Email Service's send_email binding (structural subset).
84
33
  *
@@ -96,84 +45,20 @@ export interface EmailBindingLike {
96
45
  replyTo?: EmailAddress;
97
46
  subject: string;
98
47
  html: string;
48
+ /** List-Unsubscribe and List-Unsubscribe-Post, when the email has an unsubscribe link. */
49
+ headers?: Readonly<Record<string, string>>;
99
50
  /** `${instanceId}:${nodeId}`: stable across replays and retries — drop a send whose key was already delivered. */
100
51
  idempotencyKey: string;
101
52
  }): Promise<unknown>;
102
53
  }
103
- /** Every binding the journey engine needs (names match the wrangler config). */
104
- export interface JourneyEnv {
105
- /**
106
- * BundleIR storage for the default D1 store (`wf:${contentHash}` → WorkflowIR JSON). Optional:
107
- * a Worker on another JourneyStore (Postgres, say) does not declare it.
108
- */
109
- WORKFLOW_KV?: KVNamespaceLike;
110
- /** Tables of the default D1 store (events / profiles / segments / triggers / entries / subscriptions). Optional, as above. */
111
- DB?: D1DatabaseLike;
112
- /** JourneyRunner's workflow binding (creating instances and waking them). */
113
- JOURNEY: WorkflowBindingLike;
114
- /** Optional message-delivery webhook (defaults to the console logging sender). */
115
- MESSAGE_WEBHOOK_URL?: string;
116
- /**
117
- * Bearer token required on every mutating HTTP endpoint (`Authorization:
118
- * Bearer <token>`). Unset = open — acceptable only for local dev; /deploy in
119
- * particular rewrites the whole routing table, so production must set this.
120
- */
121
- API_TOKEN?: string;
122
- /**
123
- * This Worker's public origin. With a store that keeps reporting (Postgres), journey emails'
124
- * links and open pixel point at its `/t/...` routes; without it emails go out untracked.
125
- */
126
- WORKFLOW_ORIGIN?: string;
127
- /** Which `workflow.config.ts` entry applies (`development`, `production`, …); production when unset. */
128
- ENVIRONMENT?: string;
129
- /** Cloudflare Email Sending, when the config has `emails`. */
130
- EMAIL?: EmailBindingLike;
131
- /** The APNs auth key (`.p8`, base64) named by the config's `apns.keyId`. */
132
- APNS_PRIVATE_KEY_BASE64?: string;
133
- /** The Firebase service account (base64 JSON) the config's `fcm` sends with. */
134
- GOOGLE_APPLICATION_CREDENTIALS_BASE64?: string;
135
- /** The VAPID key pair web pushes are signed with (`generateVapidKeys`); the config's `webPush` turns the channel on. */
136
- VAPID_PUBLIC_KEY?: string;
137
- VAPID_PRIVATE_KEY?: string;
138
- /**
139
- * Cloudflare's version metadata binding (wrangler `"version_metadata": { "binding":
140
- * "CF_VERSION_METADATA" }`). With it, and a store that records the live version (Postgres),
141
- * journeyWorker makes the bundle compiled into each new version live by itself: `wrangler
142
- * deploy` is the whole deploy.
143
- */
144
- CF_VERSION_METADATA?: {
145
- id: string;
146
- tag?: string;
147
- timestamp: string;
148
- };
149
- /** Development only: the HTTP/2 relay `wrangler dev` sends APNs requests through (see `@shware/workflow/apns-relay`). */
150
- APNS_RELAY_ORIGIN?: string;
151
- }
152
- /** The runtime does not know the instance: the only failure that lets the router drop its wakes. */
153
- export declare class InstanceNotFoundError extends Error {
154
- readonly instanceId: string;
155
- readonly name = "InstanceNotFoundError";
156
- constructor(instanceId: string);
157
- }
54
+ /** Cloudflare's Workflow binding, as far as the host uses it. */
55
+ export type CfWorkflowBinding = Pick<WorkflowBindingLike, 'create' | 'get'>;
158
56
  /**
159
- * Does this lookup failure say the instance is gone, rather than that the lookup failed?
160
- * Cloudflare reports an unknown id as `instance.not_found`.
57
+ * The Workflow binding as the host's runtime port: `get` answers an unknown id with
58
+ * `InstanceNotFoundError`, as the port promises, instead of Cloudflare's own error. Everything
59
+ * else is forwarded as is.
161
60
  */
162
- export declare function isInstanceNotFound(error: unknown): boolean;
163
- /** The event type the router uses to wake waiting instances (sendEvent's `type`). */
164
- export declare const WAKE_EVENT_TYPE = "wake";
165
- /** Journey instance parameters, passed by the ingest router when it creates one. */
166
- export interface JourneyParams {
167
- workflowId: string;
168
- /** The IR version pinned at entry. */
169
- contentHash: string;
170
- userId: string;
171
- trigger: {
172
- event: string;
173
- payload: Record<string, unknown>;
174
- };
175
- [key: string]: unknown;
176
- }
61
+ export declare function cloudflareJourneyBinding(binding: CfWorkflowBinding): WorkflowBindingLike;
177
62
  /**
178
63
  * Slack on the deadline when deciding whether a thrown wait was a timeout: the
179
64
  * platform may surface the expiry a moment early, and a wait shorter than this
@@ -184,11 +69,14 @@ export declare const WAKE_TIMEOUT_TOLERANCE_MS = 5000;
184
69
  * Did a wait that threw actually reach its deadline?
185
70
  *
186
71
  * CF signals a wait timeout by throwing, and so does every other failure in
187
- * there — a broken binding, an evicted instance, a malformed timeout. The
188
- * adapter used to read them all as timeouts, which made an infrastructure
189
- * fault indistinguishable from "the user never did it": the journey took its
190
- * onTimeout branch, early and silently. Only the clock can tell them apart.
72
+ * there — a broken binding, an evicted instance, a malformed timeout. Reading
73
+ * them all as timeouts would make an infrastructure fault indistinguishable
74
+ * from "the user never did it" (the journey would take its onTimeout branch,
75
+ * early and silently). Only the clock can tell them apart, and only against
76
+ * the absolute deadline: measured from when the wait was parked, a replay
77
+ * after an eviction would start the measure over and read a
78
+ * genuine expiry as a failure.
191
79
  */
192
- export declare function wakeExpired(startedAt: number, timeoutMs: number, now: number): boolean;
80
+ export declare function wakeExpired(deadlineMs: number, now: number): boolean;
193
81
  //#endregion
194
82
  //# sourceMappingURL=bindings.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindings.d.mts","names":[],"sources":["../../src/cloudflare/bindings.ts"],"mappings":";;;;;;;;;;;iBAYiB;EACf,IAAI,cAAc;EAClB,IAAI,aAAa,gBAAgB;;;iBAIlB;EACf;IAAS;;;iBAGM;EACf,QAAQ,oBAAoB;EAC5B,MAAM,IAAI,4BAA4B,QAAQ;EAC9C,IAAI,IAAI,4BAA4B;IAAU,SAAS;;EACvD,OAAO,QAAQ;;iBAGA;EACf,QAAQ,cAAc;;EAEtB,MAAM,YAAY,4BAA4B;;iBAG/B;EACf;EACA,UAAU;IAAS;IAAc;MAAsB;;EAEvD,cAAc;;EAEd,WAAW;IAAU;;;;;;;iBAON;EACf,OAAO;IAAW;IAAY;MAAoB,QAAQ;EAC1D,IAAI,aAAa,QAAQ;;;;;;;EAOzB,MAAM;IACJ;IACA,QAAQ;IACR;;IAEA;MACE,QAAQ;;EAEZ,QAAQ;IAAS;IAAkB;MAAmB;;;;;EAKtD,aAAa;;;;;;;;;;;;iBAaE;EACf,KAAK;IACH,MAAM;IACN,IAAI;IACJ,UAAU;IACV;IACA;;IAEA;MACE;;;iBAIW;;;;;EAKf,cAAc;;EAEd,KAAK;;EAEL,SAAS;;EAET;;;;;;EAMA;;;;;EAKA;;EAEA;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;EACA;;;;;;;EAOA;IAAwB;IAAY;IAAc;;;EAElD;;;qBAIW,8BAA8B;WAEpB;WADH;EAClB,YAAqB;;;;;;wBASP,mBAAmB;;qBAMtB;;iBAGI;EACf;;EAEA;EACA;EACA;IAAW;IAAe,SAAS;;GAClC;;;;;;;qBAQU;;;;;;;;;;wBAWG,YAAY,mBAAmB,mBAAmB"}
1
+ {"version":3,"file":"bindings.d.mts","names":[],"sources":["../../src/cloudflare/bindings.ts"],"mappings":";;;;;;;;;;;;iBAaiB;EACf;IAAS;;;iBAGM;EACf,QAAQ,oBAAoB;EAC5B,MAAM,IAAI,4BAA4B,QAAQ;EAC9C,IAAI,IAAI,4BAA4B;IAAU,SAAS;;EACvD,OAAO,QAAQ;;iBAGA;EACf,QAAQ,cAAc;;EAEtB,MAAM,YAAY,4BAA4B;;;;;;;;;;;;iBAa/B;EACf,KAAK;IACH,MAAM;IACN,IAAI;IACJ,UAAU;IACV;IACA;;IAEA,UAAU,SAAS;;IAEnB;MACE;;;YAIM,oBAAoB,KAAK;;;;;;wBAUrB,yBAAyB,SAAS,oBAAoB;;;;;;qBAqBzD;;;;;;;;;;;;;wBAcG,YAAY,oBAAoB"}
@@ -1,23 +1,25 @@
1
+ import { InstanceNotFoundError } from "../host/platform.mjs";
1
2
  //#region src/cloudflare/bindings.ts
2
- /** The runtime does not know the instance: the only failure that lets the router drop its wakes. */
3
- var InstanceNotFoundError = class extends Error {
4
- instanceId;
5
- name = "InstanceNotFoundError";
6
- constructor(instanceId) {
7
- super(`no such instance: ${instanceId}`);
8
- this.instanceId = instanceId;
9
- }
10
- };
3
+ /** How Cloudflare's `get` reports an unknown instance id. */
4
+ const CF_NOT_FOUND = "instance.not_found";
11
5
  /**
12
- * Does this lookup failure say the instance is gone, rather than that the lookup failed?
13
- * Cloudflare reports an unknown id as `instance.not_found`.
6
+ * The Workflow binding as the host's runtime port: `get` answers an unknown id with
7
+ * `InstanceNotFoundError`, as the port promises, instead of Cloudflare's own error. Everything
8
+ * else is forwarded as is.
14
9
  */
15
- function isInstanceNotFound(error) {
16
- if (error instanceof InstanceNotFoundError) return true;
17
- return /not[_ ]found|no such instance/i.test(String(error));
10
+ function cloudflareJourneyBinding(binding) {
11
+ return {
12
+ create: (options) => binding.create(options),
13
+ async get(id) {
14
+ try {
15
+ return await binding.get(id);
16
+ } catch (error) {
17
+ if (String(error).includes(CF_NOT_FOUND)) throw new InstanceNotFoundError(id, { cause: error });
18
+ throw error;
19
+ }
20
+ }
21
+ };
18
22
  }
19
- /** The event type the router uses to wake waiting instances (sendEvent's `type`). */
20
- const WAKE_EVENT_TYPE = "wake";
21
23
  /**
22
24
  * Slack on the deadline when deciding whether a thrown wait was a timeout: the
23
25
  * platform may surface the expiry a moment early, and a wait shorter than this
@@ -28,15 +30,18 @@ const WAKE_TIMEOUT_TOLERANCE_MS = 5e3;
28
30
  * Did a wait that threw actually reach its deadline?
29
31
  *
30
32
  * CF signals a wait timeout by throwing, and so does every other failure in
31
- * there — a broken binding, an evicted instance, a malformed timeout. The
32
- * adapter used to read them all as timeouts, which made an infrastructure
33
- * fault indistinguishable from "the user never did it": the journey took its
34
- * onTimeout branch, early and silently. Only the clock can tell them apart.
33
+ * there — a broken binding, an evicted instance, a malformed timeout. Reading
34
+ * them all as timeouts would make an infrastructure fault indistinguishable
35
+ * from "the user never did it" (the journey would take its onTimeout branch,
36
+ * early and silently). Only the clock can tell them apart, and only against
37
+ * the absolute deadline: measured from when the wait was parked, a replay
38
+ * after an eviction would start the measure over and read a
39
+ * genuine expiry as a failure.
35
40
  */
36
- function wakeExpired(startedAt, timeoutMs, now) {
37
- return now - startedAt >= Math.max(0, timeoutMs - WAKE_TIMEOUT_TOLERANCE_MS);
41
+ function wakeExpired(deadlineMs, now) {
42
+ return now >= deadlineMs - WAKE_TIMEOUT_TOLERANCE_MS;
38
43
  }
39
44
  //#endregion
40
- export { InstanceNotFoundError, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, isInstanceNotFound, wakeExpired };
45
+ export { WAKE_TIMEOUT_TOLERANCE_MS, cloudflareJourneyBinding, wakeExpired };
41
46
 
42
47
  //# sourceMappingURL=bindings.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindings.mjs","names":[],"sources":["../../src/cloudflare/bindings.ts"],"sourcesContent":["import type { EmailAddress } from '../email';\nimport type { ExecutionStart } from '../store/index';\n\n/**\n * A minimal structural interface over the Cloudflare bindings.\n *\n * @cloudflare/workers-types is deliberately not used: the global types it\n * injects clash with the DOM lib this package's react side needs. A structural\n * subset plus the ambient cloudflare:workers declaration is enough to compile,\n * and the real bindings satisfy it structurally at runtime.\n */\n\nexport interface KVNamespaceLike {\n get(key: string): Promise<string | null>;\n put(key: string, value: string): Promise<void>;\n}\n\n/** Structural subset of D1Result: `meta.changes` is how INSERT OR IGNORE reports whether it inserted. */\nexport interface D1RunResultLike {\n meta?: { changes?: number };\n}\n\nexport interface D1PreparedStatementLike {\n bind(...values: unknown[]): D1PreparedStatementLike;\n first<T = Record<string, unknown>>(): Promise<T | null>;\n all<T = Record<string, unknown>>(): Promise<{ results: T[] }>;\n run(): Promise<D1RunResultLike>;\n}\n\nexport interface D1DatabaseLike {\n prepare(sql: string): D1PreparedStatementLike;\n /** Statements run in order inside one transaction (real D1 semantics) — deploy relies on the atomicity. */\n batch(statements: D1PreparedStatementLike[]): Promise<unknown>;\n}\n\nexport interface WorkflowInstanceLike {\n id: string;\n sendEvent(event: { type: string; payload?: unknown }): Promise<void>;\n /** Stop the instance for good (Cloudflare Workflows' `terminate`). */\n terminate?(): Promise<void>;\n /** Where it stands (`complete`, `errored`, `terminated`, `running`, …). */\n status?(): Promise<{ status: string }>;\n}\n\n/**\n * How the router starts, wakes and stops instances: Cloudflare's workflow binding, or the AWS\n * adapter's equivalent over durable executions.\n */\nexport interface WorkflowBindingLike {\n create(options: { id: string; params: unknown }): Promise<WorkflowInstanceLike>;\n get(id: string): Promise<WorkflowInstanceLike>;\n /**\n * For a runtime whose start is a submit that can be lost in flight (AWS): the start to record\n * with the entry, in one transaction. A failed `create` then keeps the entry — its recorded\n * start is retried by the next ingest for the pair (`resume`) or by maintenance, never rolled\n * back and re-entered as a second execution.\n */\n plan?(options: {\n id: string;\n params: JourneyParams;\n ts: number;\n /** The code version whose routes named `params.contentHash` (absent after a forced deploy). */\n version?: string | undefined;\n }): Promise<ExecutionStart>;\n /** Retry the recorded, unconfirmed start of the (workflow, user) entry still running, if any. */\n resume?(entry: { workflow: string; userId: string }): Promise<void>;\n /**\n * Maintenance the sweep runs first: old unconfirmed starts retried (or given up on), and\n * executions the platform ended on its own (timeout, stop, crash) reconciled into the ledger.\n */\n maintain?(): Promise<void>;\n}\n\n/**\n * Cloudflare Email Service's send_email binding (structural subset).\n *\n * `idempotencyKey` is part of the call because the send happens inside a\n * `step.do`: a step body re-runs after its fn resolved but before the\n * checkpoint committed, so a binding that drops the key mails the user twice.\n * The binding is app-supplied glue (nothing here can de-duplicate — there is\n * no state between two runs of the same step), which is why the port makes the\n * key impossible to miss rather than merely available.\n */\nexport interface EmailBindingLike {\n send(message: {\n from: EmailAddress;\n to: EmailAddress;\n replyTo?: EmailAddress;\n subject: string;\n html: string;\n /** `${instanceId}:${nodeId}`: stable across replays and retries — drop a send whose key was already delivered. */\n idempotencyKey: string;\n }): Promise<unknown>;\n}\n\n/** Every binding the journey engine needs (names match the wrangler config). */\nexport interface JourneyEnv {\n /**\n * BundleIR storage for the default D1 store (`wf:${contentHash}` → WorkflowIR JSON). Optional:\n * a Worker on another JourneyStore (Postgres, say) does not declare it.\n */\n WORKFLOW_KV?: KVNamespaceLike;\n /** Tables of the default D1 store (events / profiles / segments / triggers / entries / subscriptions). Optional, as above. */\n DB?: D1DatabaseLike;\n /** JourneyRunner's workflow binding (creating instances and waking them). */\n JOURNEY: WorkflowBindingLike;\n /** Optional message-delivery webhook (defaults to the console logging sender). */\n MESSAGE_WEBHOOK_URL?: string;\n /**\n * Bearer token required on every mutating HTTP endpoint (`Authorization:\n * Bearer <token>`). Unset = open — acceptable only for local dev; /deploy in\n * particular rewrites the whole routing table, so production must set this.\n */\n API_TOKEN?: string;\n /**\n * This Worker's public origin. With a store that keeps reporting (Postgres), journey emails'\n * links and open pixel point at its `/t/...` routes; without it emails go out untracked.\n */\n WORKFLOW_ORIGIN?: string;\n /** Which `workflow.config.ts` entry applies (`development`, `production`, …); production when unset. */\n ENVIRONMENT?: string;\n /** Cloudflare Email Sending, when the config has `emails`. */\n EMAIL?: EmailBindingLike;\n /** The APNs auth key (`.p8`, base64) named by the config's `apns.keyId`. */\n APNS_PRIVATE_KEY_BASE64?: string;\n /** The Firebase service account (base64 JSON) the config's `fcm` sends with. */\n GOOGLE_APPLICATION_CREDENTIALS_BASE64?: string;\n /** The VAPID key pair web pushes are signed with (`generateVapidKeys`); the config's `webPush` turns the channel on. */\n VAPID_PUBLIC_KEY?: string;\n VAPID_PRIVATE_KEY?: string;\n /**\n * Cloudflare's version metadata binding (wrangler `\"version_metadata\": { \"binding\":\n * \"CF_VERSION_METADATA\" }`). With it, and a store that records the live version (Postgres),\n * journeyWorker makes the bundle compiled into each new version live by itself: `wrangler\n * deploy` is the whole deploy.\n */\n CF_VERSION_METADATA?: { id: string; tag?: string; timestamp: string };\n /** Development only: the HTTP/2 relay `wrangler dev` sends APNs requests through (see `@shware/workflow/apns-relay`). */\n APNS_RELAY_ORIGIN?: string;\n}\n\n/** The runtime does not know the instance: the only failure that lets the router drop its wakes. */\nexport class InstanceNotFoundError extends Error {\n override readonly name = 'InstanceNotFoundError';\n constructor(readonly instanceId: string) {\n super(`no such instance: ${instanceId}`);\n }\n}\n\n/**\n * Does this lookup failure say the instance is gone, rather than that the lookup failed?\n * Cloudflare reports an unknown id as `instance.not_found`.\n */\nexport function isInstanceNotFound(error: unknown): boolean {\n if (error instanceof InstanceNotFoundError) return true;\n return /not[_ ]found|no such instance/i.test(String(error));\n}\n\n/** The event type the router uses to wake waiting instances (sendEvent's `type`). */\nexport const WAKE_EVENT_TYPE = 'wake';\n\n/** Journey instance parameters, passed by the ingest router when it creates one. */\nexport interface JourneyParams {\n workflowId: string;\n /** The IR version pinned at entry. */\n contentHash: string;\n userId: string;\n trigger: { event: string; payload: Record<string, unknown> };\n [key: string]: unknown;\n}\n\n/**\n * Slack on the deadline when deciding whether a thrown wait was a timeout: the\n * platform may surface the expiry a moment early, and a wait shorter than this\n * has no room to tell the two apart anyway.\n */\nexport const WAKE_TIMEOUT_TOLERANCE_MS = 5_000;\n\n/**\n * Did a wait that threw actually reach its deadline?\n *\n * CF signals a wait timeout by throwing, and so does every other failure in\n * there — a broken binding, an evicted instance, a malformed timeout. The\n * adapter used to read them all as timeouts, which made an infrastructure\n * fault indistinguishable from \"the user never did it\": the journey took its\n * onTimeout branch, early and silently. Only the clock can tell them apart.\n */\nexport function wakeExpired(startedAt: number, timeoutMs: number, now: number): boolean {\n return now - startedAt >= Math.max(0, timeoutMs - WAKE_TIMEOUT_TOLERANCE_MS);\n}\n"],"mappings":";;AA8IA,IAAa,wBAAb,cAA2C,MAAM;CAE1B;CADrB,OAAyB;CACzB,YAAY,YAA6B;EACvC,MAAM,qBAAqB,YAAY;EADpB,KAAA,aAAA;CAErB;AACF;;;;;AAMA,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,iBAAiB,uBAAuB,OAAO;CACnD,OAAO,iCAAiC,KAAK,OAAO,KAAK,CAAC;AAC5D;;AAGA,MAAa,kBAAkB;;;;;;AAiB/B,MAAa,4BAA4B;;;;;;;;;;AAWzC,SAAgB,YAAY,WAAmB,WAAmB,KAAsB;CACtF,OAAO,MAAM,aAAa,KAAK,IAAI,GAAG,YAAY,yBAAyB;AAC7E"}
1
+ {"version":3,"file":"bindings.mjs","names":[],"sources":["../../src/cloudflare/bindings.ts"],"sourcesContent":["import type { EmailAddress } from '../email';\nimport { InstanceNotFoundError, type WorkflowBindingLike } from '../host/platform';\n\n/**\n * A minimal structural interface over the Cloudflare bindings.\n *\n * @cloudflare/workers-types is deliberately not used: the global types it\n * injects clash with the DOM lib this package's react side needs. A structural\n * subset plus the ambient cloudflare:workers declaration is enough to compile,\n * and the real bindings satisfy it structurally at runtime.\n */\n\n/** Structural subset of D1Result: `meta.changes` is how INSERT OR IGNORE reports whether it inserted. */\nexport interface D1RunResultLike {\n meta?: { changes?: number };\n}\n\nexport interface D1PreparedStatementLike {\n bind(...values: unknown[]): D1PreparedStatementLike;\n first<T = Record<string, unknown>>(): Promise<T | null>;\n all<T = Record<string, unknown>>(): Promise<{ results: T[] }>;\n run(): Promise<D1RunResultLike>;\n}\n\nexport interface D1DatabaseLike {\n prepare(sql: string): D1PreparedStatementLike;\n /** Statements run in order inside one transaction (real D1 semantics) — deploy relies on the atomicity. */\n batch(statements: D1PreparedStatementLike[]): Promise<unknown>;\n}\n\n/**\n * Cloudflare Email Service's send_email binding (structural subset).\n *\n * `idempotencyKey` is part of the call because the send happens inside a\n * `step.do`: a step body re-runs after its fn resolved but before the\n * checkpoint committed, so a binding that drops the key mails the user twice.\n * The binding is app-supplied glue (nothing here can de-duplicate — there is\n * no state between two runs of the same step), which is why the port makes the\n * key impossible to miss rather than merely available.\n */\nexport interface EmailBindingLike {\n send(message: {\n from: EmailAddress;\n to: EmailAddress;\n replyTo?: EmailAddress;\n subject: string;\n html: string;\n /** List-Unsubscribe and List-Unsubscribe-Post, when the email has an unsubscribe link. */\n headers?: Readonly<Record<string, string>>;\n /** `${instanceId}:${nodeId}`: stable across replays and retries — drop a send whose key was already delivered. */\n idempotencyKey: string;\n }): Promise<unknown>;\n}\n\n/** Cloudflare's Workflow binding, as far as the host uses it. */\nexport type CfWorkflowBinding = Pick<WorkflowBindingLike, 'create' | 'get'>;\n\n/** How Cloudflare's `get` reports an unknown instance id. */\nconst CF_NOT_FOUND = 'instance.not_found';\n\n/**\n * The Workflow binding as the host's runtime port: `get` answers an unknown id with\n * `InstanceNotFoundError`, as the port promises, instead of Cloudflare's own error. Everything\n * else is forwarded as is.\n */\nexport function cloudflareJourneyBinding(binding: CfWorkflowBinding): WorkflowBindingLike {\n return {\n create: (options) => binding.create(options),\n async get(id) {\n try {\n return await binding.get(id);\n } catch (error) {\n if (String(error).includes(CF_NOT_FOUND)) {\n throw new InstanceNotFoundError(id, { cause: error });\n }\n throw error;\n }\n },\n };\n}\n\n/**\n * Slack on the deadline when deciding whether a thrown wait was a timeout: the\n * platform may surface the expiry a moment early, and a wait shorter than this\n * has no room to tell the two apart anyway.\n */\nexport const WAKE_TIMEOUT_TOLERANCE_MS = 5_000;\n\n/**\n * Did a wait that threw actually reach its deadline?\n *\n * CF signals a wait timeout by throwing, and so does every other failure in\n * there — a broken binding, an evicted instance, a malformed timeout. Reading\n * them all as timeouts would make an infrastructure fault indistinguishable\n * from \"the user never did it\" (the journey would take its onTimeout branch,\n * early and silently). Only the clock can tell them apart, and only against\n * the absolute deadline: measured from when the wait was parked, a replay\n * after an eviction would start the measure over and read a\n * genuine expiry as a failure.\n */\nexport function wakeExpired(deadlineMs: number, now: number): boolean {\n return now >= deadlineMs - WAKE_TIMEOUT_TOLERANCE_MS;\n}\n"],"mappings":";;;AA0DA,MAAM,eAAe;;;;;;AAOrB,SAAgB,yBAAyB,SAAiD;CACxF,OAAO;EACL,SAAS,YAAY,QAAQ,OAAO,OAAO;EAC3C,MAAM,IAAI,IAAI;GACZ,IAAI;IACF,OAAO,MAAM,QAAQ,IAAI,EAAE;GAC7B,SAAS,OAAO;IACd,IAAI,OAAO,KAAK,CAAC,CAAC,SAAS,YAAY,GACrC,MAAM,IAAI,sBAAsB,IAAI,EAAE,OAAO,MAAM,CAAC;IAEtD,MAAM;GACR;EACF;CACF;AACF;;;;;;AAOA,MAAa,4BAA4B;;;;;;;;;;;;;AAczC,SAAgB,YAAY,YAAoB,KAAsB;CACpE,OAAO,OAAO,aAAa;AAC7B"}
@@ -2,14 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_store_d1 = require("../store/d1.cjs");
3
3
  //#region src/cloudflare/d1-env.ts
4
4
  /**
5
- * The default store: D1 + KV from the env's bindings. Every router function
6
- * and the runner fall back to it when no store is passed, so a Worker that
7
- * declares `DB` and `WORKFLOW_KV` needs no wiring; one on another store (say
8
- * PostgresJourneyStore) passes its own and may omit those bindings entirely.
5
+ * The default store: D1 from the env's `DB` binding — tables and workflow bodies alike (see
6
+ * ../cloudflare/schema.sql). Every router function and the runner fall back to it when no store
7
+ * is passed, so a Worker that declares `DB` needs no wiring; one on another store (say
8
+ * PostgresJourneyStore) passes its own and may omit the binding entirely.
9
9
  */
10
10
  function d1Store(env) {
11
- if (env.DB === void 0 || env.WORKFLOW_KV === void 0) throw new Error("JourneyStore not configured: declare the DB and WORKFLOW_KV bindings for the default D1 store, or pass a store explicitly");
12
- return new require_store_d1.D1JourneyStore(env.DB, env.WORKFLOW_KV);
11
+ if (env.DB === void 0) throw new Error("JourneyStore not configured: declare the DB binding for the default D1 store, or pass a store explicitly");
12
+ return new require_store_d1.D1JourneyStore(env.DB);
13
13
  }
14
14
  //#endregion
15
15
  exports.d1Store = d1Store;
@@ -1 +1 @@
1
- {"version":3,"file":"d1-env.cjs","names":["D1JourneyStore"],"sources":["../../src/cloudflare/d1-env.ts"],"sourcesContent":["import { D1JourneyStore } from '../store/d1';\nimport type { JourneyStore } from '../store/index';\nimport type { JourneyEnv } from './bindings';\n\n/**\n * The default store: D1 + KV from the env's bindings. Every router function\n * and the runner fall back to it when no store is passed, so a Worker that\n * declares `DB` and `WORKFLOW_KV` needs no wiring; one on another store (say\n * PostgresJourneyStore) passes its own and may omit those bindings entirely.\n */\nexport function d1Store(env: JourneyEnv): JourneyStore {\n if (env.DB === undefined || env.WORKFLOW_KV === undefined) {\n throw new Error(\n 'JourneyStore not configured: declare the DB and WORKFLOW_KV bindings for the default D1 store, or pass a store explicitly'\n );\n }\n return new D1JourneyStore(env.DB, env.WORKFLOW_KV);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,QAAQ,KAA+B;CACrD,IAAI,IAAI,OAAO,KAAA,KAAa,IAAI,gBAAgB,KAAA,GAC9C,MAAM,IAAI,MACR,2HACF;CAEF,OAAO,IAAIA,iBAAAA,eAAe,IAAI,IAAI,IAAI,WAAW;AACnD"}
1
+ {"version":3,"file":"d1-env.cjs","names":["D1JourneyStore"],"sources":["../../src/cloudflare/d1-env.ts"],"sourcesContent":["import type { JourneyEnv } from '../host/platform';\nimport { D1JourneyStore } from '../store/d1';\nimport type { JourneyStore } from '../store/index';\n\n/**\n * The default store: D1 from the env's `DB` binding — tables and workflow bodies alike (see\n * ../cloudflare/schema.sql). Every router function and the runner fall back to it when no store\n * is passed, so a Worker that declares `DB` needs no wiring; one on another store (say\n * PostgresJourneyStore) passes its own and may omit the binding entirely.\n */\nexport function d1Store(env: JourneyEnv): JourneyStore {\n if (env.DB === undefined) {\n throw new Error(\n 'JourneyStore not configured: declare the DB binding for the default D1 store, or pass a store explicitly'\n );\n }\n return new D1JourneyStore(env.DB);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,QAAQ,KAA+B;CACrD,IAAI,IAAI,OAAO,KAAA,GACb,MAAM,IAAI,MACR,0GACF;CAEF,OAAO,IAAIA,iBAAAA,eAAe,IAAI,EAAE;AAClC"}
@@ -1,11 +1,11 @@
1
- import { JourneyEnv } from "./bindings.cjs";
1
+ import { JourneyEnv } from "../host/platform.cjs";
2
2
  import { JourneyStore } from "../store/index.cjs";
3
3
  //#region src/cloudflare/d1-env.d.ts
4
4
  /**
5
- * The default store: D1 + KV from the env's bindings. Every router function
6
- * and the runner fall back to it when no store is passed, so a Worker that
7
- * declares `DB` and `WORKFLOW_KV` needs no wiring; one on another store (say
8
- * PostgresJourneyStore) passes its own and may omit those bindings entirely.
5
+ * The default store: D1 from the env's `DB` binding — tables and workflow bodies alike (see
6
+ * ../cloudflare/schema.sql). Every router function and the runner fall back to it when no store
7
+ * is passed, so a Worker that declares `DB` needs no wiring; one on another store (say
8
+ * PostgresJourneyStore) passes its own and may omit the binding entirely.
9
9
  */
10
10
  export declare function d1Store(env: JourneyEnv): JourneyStore;
11
11
  //#endregion
@@ -1,11 +1,11 @@
1
- import { JourneyEnv } from "./bindings.mjs";
1
+ import { JourneyEnv } from "../host/platform.mjs";
2
2
  import { JourneyStore } from "../store/index.mjs";
3
3
  //#region src/cloudflare/d1-env.d.ts
4
4
  /**
5
- * The default store: D1 + KV from the env's bindings. Every router function
6
- * and the runner fall back to it when no store is passed, so a Worker that
7
- * declares `DB` and `WORKFLOW_KV` needs no wiring; one on another store (say
8
- * PostgresJourneyStore) passes its own and may omit those bindings entirely.
5
+ * The default store: D1 from the env's `DB` binding — tables and workflow bodies alike (see
6
+ * ../cloudflare/schema.sql). Every router function and the runner fall back to it when no store
7
+ * is passed, so a Worker that declares `DB` needs no wiring; one on another store (say
8
+ * PostgresJourneyStore) passes its own and may omit the binding entirely.
9
9
  */
10
10
  export declare function d1Store(env: JourneyEnv): JourneyStore;
11
11
  //#endregion
@@ -1,14 +1,14 @@
1
1
  import { D1JourneyStore } from "../store/d1.mjs";
2
2
  //#region src/cloudflare/d1-env.ts
3
3
  /**
4
- * The default store: D1 + KV from the env's bindings. Every router function
5
- * and the runner fall back to it when no store is passed, so a Worker that
6
- * declares `DB` and `WORKFLOW_KV` needs no wiring; one on another store (say
7
- * PostgresJourneyStore) passes its own and may omit those bindings entirely.
4
+ * The default store: D1 from the env's `DB` binding — tables and workflow bodies alike (see
5
+ * ../cloudflare/schema.sql). Every router function and the runner fall back to it when no store
6
+ * is passed, so a Worker that declares `DB` needs no wiring; one on another store (say
7
+ * PostgresJourneyStore) passes its own and may omit the binding entirely.
8
8
  */
9
9
  function d1Store(env) {
10
- if (env.DB === void 0 || env.WORKFLOW_KV === void 0) throw new Error("JourneyStore not configured: declare the DB and WORKFLOW_KV bindings for the default D1 store, or pass a store explicitly");
11
- return new D1JourneyStore(env.DB, env.WORKFLOW_KV);
10
+ if (env.DB === void 0) throw new Error("JourneyStore not configured: declare the DB binding for the default D1 store, or pass a store explicitly");
11
+ return new D1JourneyStore(env.DB);
12
12
  }
13
13
  //#endregion
14
14
  export { d1Store };
@@ -1 +1 @@
1
- {"version":3,"file":"d1-env.mjs","names":[],"sources":["../../src/cloudflare/d1-env.ts"],"sourcesContent":["import { D1JourneyStore } from '../store/d1';\nimport type { JourneyStore } from '../store/index';\nimport type { JourneyEnv } from './bindings';\n\n/**\n * The default store: D1 + KV from the env's bindings. Every router function\n * and the runner fall back to it when no store is passed, so a Worker that\n * declares `DB` and `WORKFLOW_KV` needs no wiring; one on another store (say\n * PostgresJourneyStore) passes its own and may omit those bindings entirely.\n */\nexport function d1Store(env: JourneyEnv): JourneyStore {\n if (env.DB === undefined || env.WORKFLOW_KV === undefined) {\n throw new Error(\n 'JourneyStore not configured: declare the DB and WORKFLOW_KV bindings for the default D1 store, or pass a store explicitly'\n );\n }\n return new D1JourneyStore(env.DB, env.WORKFLOW_KV);\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,QAAQ,KAA+B;CACrD,IAAI,IAAI,OAAO,KAAA,KAAa,IAAI,gBAAgB,KAAA,GAC9C,MAAM,IAAI,MACR,2HACF;CAEF,OAAO,IAAI,eAAe,IAAI,IAAI,IAAI,WAAW;AACnD"}
1
+ {"version":3,"file":"d1-env.mjs","names":[],"sources":["../../src/cloudflare/d1-env.ts"],"sourcesContent":["import type { JourneyEnv } from '../host/platform';\nimport { D1JourneyStore } from '../store/d1';\nimport type { JourneyStore } from '../store/index';\n\n/**\n * The default store: D1 from the env's `DB` binding — tables and workflow bodies alike (see\n * ../cloudflare/schema.sql). Every router function and the runner fall back to it when no store\n * is passed, so a Worker that declares `DB` needs no wiring; one on another store (say\n * PostgresJourneyStore) passes its own and may omit the binding entirely.\n */\nexport function d1Store(env: JourneyEnv): JourneyStore {\n if (env.DB === undefined) {\n throw new Error(\n 'JourneyStore not configured: declare the DB binding for the default D1 store, or pass a store explicitly'\n );\n }\n return new D1JourneyStore(env.DB);\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,QAAQ,KAA+B;CACrD,IAAI,IAAI,OAAO,KAAA,GACb,MAAM,IAAI,MACR,0GACF;CAEF,OAAO,IAAI,eAAe,IAAI,EAAE;AAClC"}
@@ -1,59 +1,69 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_email_sender = require("../email-sender.cjs");
3
+ const require_store_erasure = require("../store/erasure.cjs");
3
4
  const require_store_postgres_reporting = require("../store/postgres-reporting.cjs");
4
5
  const require_store_postgres = require("../store/postgres.cjs");
5
6
  const require_store_facts = require("../store/facts.cjs");
6
- const require_cloudflare_bindings = require("./bindings.cjs");
7
7
  const require_store_d1 = require("../store/d1.cjs");
8
8
  const require_cloudflare_d1_env = require("./d1-env.cjs");
9
- const require_reporting_classify = require("../reporting/classify.cjs");
10
- const require_reporting_tracking = require("../reporting/tracking.cjs");
11
9
  const require_store_index = require("../store/index.cjs");
12
- const require_host_router = require("../host/router.cjs");
10
+ const require_host_platform = require("../host/platform.cjs");
11
+ const require_host_ingest = require("../host/ingest.cjs");
13
12
  const require_reporting_observer = require("../reporting/observer.cjs");
14
13
  const require_host_senders = require("../host/senders.cjs");
15
14
  const require_host_channels = require("../host/channels.cjs");
15
+ const require_reporting_classify = require("../reporting/classify.cjs");
16
+ const require_reporting_tracking = require("../reporting/tracking.cjs");
17
+ const require_host_auth = require("../host/auth.cjs");
18
+ const require_host_http = require("../host/http.cjs");
16
19
  const require_host_journey_host = require("../host/journey-host.cjs");
20
+ const require_cloudflare_bindings = require("./bindings.cjs");
17
21
  const require_cloudflare_runner = require("./runner.cjs");
18
22
  const require_cloudflare_worker = require("./worker.cjs");
19
23
  exports.BURST_WINDOW_MS = require_reporting_classify.BURST_WINDOW_MS;
20
- exports.BundleIntegrityError = require_host_router.BundleIntegrityError;
24
+ exports.BundleIntegrityError = require_host_ingest.BundleIntegrityError;
21
25
  exports.D1JourneyStore = require_store_d1.D1JourneyStore;
22
26
  exports.DEFAULT_QUICK_MS = require_reporting_classify.DEFAULT_QUICK_MS;
23
27
  exports.EmailSender = require_email_sender.EmailSender;
24
28
  exports.EnvValidationError = require_host_journey_host.EnvValidationError;
25
- exports.InstanceNotFoundError = require_cloudflare_bindings.InstanceNotFoundError;
29
+ exports.InstanceNotFoundError = require_host_platform.InstanceNotFoundError;
26
30
  exports.JourneyFactSource = require_store_facts.JourneyFactSource;
27
31
  exports.JourneyRunner = require_cloudflare_runner.JourneyRunner;
28
32
  exports.LogMessageSender = require_host_senders.LogMessageSender;
29
33
  exports.PostgresJourneyStore = require_store_postgres.PostgresJourneyStore;
30
34
  exports.PostgresReporting = require_store_postgres_reporting.PostgresReporting;
35
+ exports.SWEEP_PAGE_SIZE = require_host_ingest.SWEEP_PAGE_SIZE;
31
36
  exports.SchemaMismatchError = require_store_index.SchemaMismatchError;
32
- exports.UnversionedStoreError = require_host_router.UnversionedStoreError;
33
- exports.WAKE_EVENT_TYPE = require_cloudflare_bindings.WAKE_EVENT_TYPE;
37
+ exports.UnversionedStoreError = require_host_ingest.UnversionedStoreError;
38
+ exports.UserErasedError = require_store_erasure.UserErasedError;
39
+ exports.WAKE_EVENT_TYPE = require_host_platform.WAKE_EVENT_TYPE;
34
40
  exports.WAKE_TIMEOUT_TOLERANCE_MS = require_cloudflare_bindings.WAKE_TIMEOUT_TOLERANCE_MS;
35
41
  exports.WebhookMessageSender = require_host_senders.WebhookMessageSender;
42
+ exports.authorized = require_host_auth.authorized;
43
+ exports.bearerMatches = require_host_auth.bearerMatches;
36
44
  exports.channelsFromConfig = require_host_channels.channelsFromConfig;
37
45
  exports.classifyClick = require_reporting_classify.classifyClick;
38
46
  exports.classifyOpen = require_reporting_classify.classifyOpen;
47
+ exports.cloudflareJourneyBinding = require_cloudflare_bindings.cloudflareJourneyBinding;
39
48
  exports.d1Store = require_cloudflare_d1_env.d1Store;
40
- exports.deployBundle = require_host_router.deployBundle;
41
- exports.forgetUser = require_host_router.forgetUser;
42
- exports.handleRequest = require_host_router.handleRequest;
49
+ exports.deployBundle = require_host_ingest.deployBundle;
50
+ exports.forgetUser = require_host_ingest.forgetUser;
51
+ exports.handleRequest = require_host_http.handleRequest;
43
52
  exports.handleTracking = require_reporting_tracking.handleTracking;
44
- exports.identifyUser = require_host_router.identifyUser;
45
- exports.ingestEvent = require_host_router.ingestEvent;
46
- exports.isInstanceNotFound = require_cloudflare_bindings.isInstanceNotFound;
53
+ exports.identifyUser = require_host_ingest.identifyUser;
54
+ exports.ingestEvent = require_host_ingest.ingestEvent;
47
55
  exports.journeyMode = require_host_channels.journeyMode;
48
56
  exports.journeyWorker = require_cloudflare_worker.journeyWorker;
49
57
  exports.recordPushOpen = require_reporting_tracking.recordPushOpen;
50
- exports.registerDevice = require_host_router.registerDevice;
51
- exports.removeDevice = require_host_router.removeDevice;
58
+ exports.registerDevice = require_host_ingest.registerDevice;
59
+ exports.removeDevice = require_host_ingest.removeDevice;
52
60
  exports.reportingObserver = require_reporting_observer.reportingObserver;
53
61
  exports.routeByChannel = require_host_senders.routeByChannel;
54
62
  exports.routeByPlatform = require_host_senders.routeByPlatform;
55
63
  exports.runtimeFromConfig = require_host_channels.runtimeFromConfig;
56
- exports.sweepSegments = require_host_router.sweepSegments;
64
+ exports.sweepMaintenance = require_host_ingest.sweepMaintenance;
65
+ exports.sweepSegments = require_host_ingest.sweepSegments;
66
+ exports.sweepSegmentsPaged = require_host_ingest.sweepSegmentsPaged;
57
67
  exports.trackEmail = require_email_sender.trackEmail;
58
- exports.unbindDevice = require_host_router.unbindDevice;
68
+ exports.unbindDevice = require_host_ingest.unbindDevice;
59
69
  exports.wakeExpired = require_cloudflare_bindings.wakeExpired;
@@ -1,6 +1,8 @@
1
1
  import { JourneyObserver, LinkPurpose, MessageTracking, OutboundMessage, PushDevice, SendResult } from "../engine/ports.cjs";
2
2
  import { EmailAddress } from "../email.cjs";
3
- import { D1DatabaseLike, EmailBindingLike, InstanceNotFoundError, JourneyEnv, JourneyParams, KVNamespaceLike, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WorkflowBindingLike, WorkflowInstanceLike, isInstanceNotFound, wakeExpired } from "./bindings.cjs";
3
+ import { UserErasedError } from "../store/erasure.cjs";
4
+ import { InstanceNotFoundError, JourneyEnv, JourneyParams, WAKE_EVENT_TYPE, WorkflowBindingLike, WorkflowInstanceLike } from "../host/platform.cjs";
5
+ import { D1DatabaseLike, EmailBindingLike, WAKE_TIMEOUT_TOLERANCE_MS, cloudflareJourneyBinding, wakeExpired } from "./bindings.cjs";
4
6
  import { D1JourneyStore } from "../store/d1.cjs";
5
7
  import { JourneyFactSource } from "../store/facts.cjs";
6
8
  import { SqlClientLike } from "../store/sql.cjs";
@@ -8,14 +10,16 @@ import { PostgresJourneyStore, PostgresJourneyStoreOptions } from "../store/post
8
10
  import { PostgresReporting } from "../store/postgres-reporting.cjs";
9
11
  import { BundleVersion, Engagement, EntryInput, EntryOutcome, EventInput, JourneyReporting, JourneyStore, MessageRecord, ProfileProps, SchemaMismatchError, SegmentTriggerRoute, StoreLease, TriggerRoute } from "../store/index.cjs";
10
12
  import { EmailMessage, EmailRenderer, EmailSender, EmailSenderOptions, EmailTransport, RenderedEmail, trackEmail } from "../email-sender.cjs";
11
- import { BundleIntegrityError, DeployResult, DeviceRegistration, IdentifyResult, IngestInput, IngestResult, SweepResult, UnversionedStoreError, deployBundle, forgetUser, handleRequest, identifyUser, ingestEvent, registerDevice, removeDevice, sweepSegments, unbindDevice } from "../host/router.cjs";
13
+ import { BundleIntegrityError, DeployResult, DeviceRegistration, IdentifyResult, IngestInput, IngestResult, SWEEP_PAGE_SIZE, SweepPage, SweepResult, UnversionedStoreError, deployBundle, forgetUser, identifyUser, ingestEvent, registerDevice, removeDevice, sweepMaintenance, sweepSegments, sweepSegmentsPaged, unbindDevice } from "../host/ingest.cjs";
12
14
  import { EnvValidationError } from "../host/journey-host.cjs";
13
15
  import { d1Store } from "./d1-env.cjs";
16
+ import { TrackingOptions, handleTracking, recordPushOpen } from "../reporting/tracking.cjs";
17
+ import { IngestValidation, handleRequest } from "../host/http.cjs";
18
+ import { authorized, bearerMatches } from "../host/auth.cjs";
14
19
  import { JourneyRunner } from "./runner.cjs";
15
20
  import { LogMessageSender, WebhookMessageSender, routeByChannel, routeByPlatform } from "../host/senders.cjs";
16
21
  import { ChannelsConfig, channelsFromConfig, journeyMode, runtimeFromConfig } from "../host/channels.cjs";
17
22
  import { reportingObserver } from "../reporting/observer.cjs";
18
- import { TrackingOptions, handleTracking, recordPushOpen } from "../reporting/tracking.cjs";
19
23
  import { BURST_WINDOW_MS, ClassifyOptions, ClickFacts, DEFAULT_QUICK_MS, RequestFacts, Verdict, classifyClick, classifyOpen } from "../reporting/classify.cjs";
20
24
  import { ExecutionContextLike, JourneyWorker, JourneyWorkerOptions, journeyWorker } from "./worker.cjs";
21
- export { BURST_WINDOW_MS, BundleIntegrityError, type BundleVersion, type ChannelsConfig, type ClassifyOptions, type ClickFacts, type D1DatabaseLike, D1JourneyStore, DEFAULT_QUICK_MS, type DeployResult, type DeviceRegistration, type EmailAddress, type EmailBindingLike, type EmailMessage, type EmailRenderer, EmailSender, type EmailSenderOptions, type EmailTransport, type Engagement, type EntryInput, type EntryOutcome, EnvValidationError, type EventInput, type ExecutionContextLike, type IdentifyResult, type IngestInput, type IngestResult, InstanceNotFoundError, type JourneyEnv, JourneyFactSource, type JourneyObserver, type JourneyParams, type JourneyReporting, JourneyRunner, type JourneyStore, type JourneyWorker, type JourneyWorkerOptions, type KVNamespaceLike, type LinkPurpose, LogMessageSender, type MessageRecord, type MessageTracking, type OutboundMessage, PostgresJourneyStore, type PostgresJourneyStoreOptions, PostgresReporting, type ProfileProps, type PushDevice, type RenderedEmail, type RequestFacts, SchemaMismatchError, type SegmentTriggerRoute, type SendResult, type SqlClientLike, type StoreLease, type SweepResult, type TrackingOptions, type TriggerRoute, UnversionedStoreError, type Verdict, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WebhookMessageSender, type WorkflowBindingLike, type WorkflowInstanceLike, channelsFromConfig, classifyClick, classifyOpen, d1Store, deployBundle, forgetUser, handleRequest, handleTracking, identifyUser, ingestEvent, isInstanceNotFound, journeyMode, journeyWorker, recordPushOpen, registerDevice, removeDevice, reportingObserver, routeByChannel, routeByPlatform, runtimeFromConfig, sweepSegments, trackEmail, unbindDevice, wakeExpired };
25
+ export { BURST_WINDOW_MS, BundleIntegrityError, type BundleVersion, type ChannelsConfig, type ClassifyOptions, type ClickFacts, type D1DatabaseLike, D1JourneyStore, DEFAULT_QUICK_MS, type DeployResult, type DeviceRegistration, type EmailAddress, type EmailBindingLike, type EmailMessage, type EmailRenderer, EmailSender, type EmailSenderOptions, type EmailTransport, type Engagement, type EntryInput, type EntryOutcome, EnvValidationError, type EventInput, type ExecutionContextLike, type IdentifyResult, type IngestInput, type IngestResult, type IngestValidation, InstanceNotFoundError, type JourneyEnv, JourneyFactSource, type JourneyObserver, type JourneyParams, type JourneyReporting, JourneyRunner, type JourneyStore, type JourneyWorker, type JourneyWorkerOptions, type LinkPurpose, LogMessageSender, type MessageRecord, type MessageTracking, type OutboundMessage, PostgresJourneyStore, type PostgresJourneyStoreOptions, PostgresReporting, type ProfileProps, type PushDevice, type RenderedEmail, type RequestFacts, SWEEP_PAGE_SIZE, SchemaMismatchError, type SegmentTriggerRoute, type SendResult, type SqlClientLike, type StoreLease, type SweepPage, type SweepResult, type TrackingOptions, type TriggerRoute, UnversionedStoreError, UserErasedError, type Verdict, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WebhookMessageSender, type WorkflowBindingLike, type WorkflowInstanceLike, authorized, bearerMatches, channelsFromConfig, classifyClick, classifyOpen, cloudflareJourneyBinding, d1Store, deployBundle, forgetUser, handleRequest, handleTracking, identifyUser, ingestEvent, journeyMode, journeyWorker, recordPushOpen, registerDevice, removeDevice, reportingObserver, routeByChannel, routeByPlatform, runtimeFromConfig, sweepMaintenance, sweepSegments, sweepSegmentsPaged, trackEmail, unbindDevice, wakeExpired };
@@ -1,6 +1,8 @@
1
1
  import { JourneyObserver, LinkPurpose, MessageTracking, OutboundMessage, PushDevice, SendResult } from "../engine/ports.mjs";
2
2
  import { EmailAddress } from "../email.mjs";
3
- import { D1DatabaseLike, EmailBindingLike, InstanceNotFoundError, JourneyEnv, JourneyParams, KVNamespaceLike, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WorkflowBindingLike, WorkflowInstanceLike, isInstanceNotFound, wakeExpired } from "./bindings.mjs";
3
+ import { UserErasedError } from "../store/erasure.mjs";
4
+ import { InstanceNotFoundError, JourneyEnv, JourneyParams, WAKE_EVENT_TYPE, WorkflowBindingLike, WorkflowInstanceLike } from "../host/platform.mjs";
5
+ import { D1DatabaseLike, EmailBindingLike, WAKE_TIMEOUT_TOLERANCE_MS, cloudflareJourneyBinding, wakeExpired } from "./bindings.mjs";
4
6
  import { D1JourneyStore } from "../store/d1.mjs";
5
7
  import { JourneyFactSource } from "../store/facts.mjs";
6
8
  import { SqlClientLike } from "../store/sql.mjs";
@@ -8,14 +10,16 @@ import { PostgresJourneyStore, PostgresJourneyStoreOptions } from "../store/post
8
10
  import { PostgresReporting } from "../store/postgres-reporting.mjs";
9
11
  import { BundleVersion, Engagement, EntryInput, EntryOutcome, EventInput, JourneyReporting, JourneyStore, MessageRecord, ProfileProps, SchemaMismatchError, SegmentTriggerRoute, StoreLease, TriggerRoute } from "../store/index.mjs";
10
12
  import { EmailMessage, EmailRenderer, EmailSender, EmailSenderOptions, EmailTransport, RenderedEmail, trackEmail } from "../email-sender.mjs";
11
- import { BundleIntegrityError, DeployResult, DeviceRegistration, IdentifyResult, IngestInput, IngestResult, SweepResult, UnversionedStoreError, deployBundle, forgetUser, handleRequest, identifyUser, ingestEvent, registerDevice, removeDevice, sweepSegments, unbindDevice } from "../host/router.mjs";
13
+ import { BundleIntegrityError, DeployResult, DeviceRegistration, IdentifyResult, IngestInput, IngestResult, SWEEP_PAGE_SIZE, SweepPage, SweepResult, UnversionedStoreError, deployBundle, forgetUser, identifyUser, ingestEvent, registerDevice, removeDevice, sweepMaintenance, sweepSegments, sweepSegmentsPaged, unbindDevice } from "../host/ingest.mjs";
12
14
  import { EnvValidationError } from "../host/journey-host.mjs";
13
15
  import { d1Store } from "./d1-env.mjs";
16
+ import { TrackingOptions, handleTracking, recordPushOpen } from "../reporting/tracking.mjs";
17
+ import { IngestValidation, handleRequest } from "../host/http.mjs";
18
+ import { authorized, bearerMatches } from "../host/auth.mjs";
14
19
  import { JourneyRunner } from "./runner.mjs";
15
20
  import { LogMessageSender, WebhookMessageSender, routeByChannel, routeByPlatform } from "../host/senders.mjs";
16
21
  import { ChannelsConfig, channelsFromConfig, journeyMode, runtimeFromConfig } from "../host/channels.mjs";
17
22
  import { reportingObserver } from "../reporting/observer.mjs";
18
- import { TrackingOptions, handleTracking, recordPushOpen } from "../reporting/tracking.mjs";
19
23
  import { BURST_WINDOW_MS, ClassifyOptions, ClickFacts, DEFAULT_QUICK_MS, RequestFacts, Verdict, classifyClick, classifyOpen } from "../reporting/classify.mjs";
20
24
  import { ExecutionContextLike, JourneyWorker, JourneyWorkerOptions, journeyWorker } from "./worker.mjs";
21
- export { BURST_WINDOW_MS, BundleIntegrityError, type BundleVersion, type ChannelsConfig, type ClassifyOptions, type ClickFacts, type D1DatabaseLike, D1JourneyStore, DEFAULT_QUICK_MS, type DeployResult, type DeviceRegistration, type EmailAddress, type EmailBindingLike, type EmailMessage, type EmailRenderer, EmailSender, type EmailSenderOptions, type EmailTransport, type Engagement, type EntryInput, type EntryOutcome, EnvValidationError, type EventInput, type ExecutionContextLike, type IdentifyResult, type IngestInput, type IngestResult, InstanceNotFoundError, type JourneyEnv, JourneyFactSource, type JourneyObserver, type JourneyParams, type JourneyReporting, JourneyRunner, type JourneyStore, type JourneyWorker, type JourneyWorkerOptions, type KVNamespaceLike, type LinkPurpose, LogMessageSender, type MessageRecord, type MessageTracking, type OutboundMessage, PostgresJourneyStore, type PostgresJourneyStoreOptions, PostgresReporting, type ProfileProps, type PushDevice, type RenderedEmail, type RequestFacts, SchemaMismatchError, type SegmentTriggerRoute, type SendResult, type SqlClientLike, type StoreLease, type SweepResult, type TrackingOptions, type TriggerRoute, UnversionedStoreError, type Verdict, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WebhookMessageSender, type WorkflowBindingLike, type WorkflowInstanceLike, channelsFromConfig, classifyClick, classifyOpen, d1Store, deployBundle, forgetUser, handleRequest, handleTracking, identifyUser, ingestEvent, isInstanceNotFound, journeyMode, journeyWorker, recordPushOpen, registerDevice, removeDevice, reportingObserver, routeByChannel, routeByPlatform, runtimeFromConfig, sweepSegments, trackEmail, unbindDevice, wakeExpired };
25
+ export { BURST_WINDOW_MS, BundleIntegrityError, type BundleVersion, type ChannelsConfig, type ClassifyOptions, type ClickFacts, type D1DatabaseLike, D1JourneyStore, DEFAULT_QUICK_MS, type DeployResult, type DeviceRegistration, type EmailAddress, type EmailBindingLike, type EmailMessage, type EmailRenderer, EmailSender, type EmailSenderOptions, type EmailTransport, type Engagement, type EntryInput, type EntryOutcome, EnvValidationError, type EventInput, type ExecutionContextLike, type IdentifyResult, type IngestInput, type IngestResult, type IngestValidation, InstanceNotFoundError, type JourneyEnv, JourneyFactSource, type JourneyObserver, type JourneyParams, type JourneyReporting, JourneyRunner, type JourneyStore, type JourneyWorker, type JourneyWorkerOptions, type LinkPurpose, LogMessageSender, type MessageRecord, type MessageTracking, type OutboundMessage, PostgresJourneyStore, type PostgresJourneyStoreOptions, PostgresReporting, type ProfileProps, type PushDevice, type RenderedEmail, type RequestFacts, SWEEP_PAGE_SIZE, SchemaMismatchError, type SegmentTriggerRoute, type SendResult, type SqlClientLike, type StoreLease, type SweepPage, type SweepResult, type TrackingOptions, type TriggerRoute, UnversionedStoreError, UserErasedError, type Verdict, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WebhookMessageSender, type WorkflowBindingLike, type WorkflowInstanceLike, authorized, bearerMatches, channelsFromConfig, classifyClick, classifyOpen, cloudflareJourneyBinding, d1Store, deployBundle, forgetUser, handleRequest, handleTracking, identifyUser, ingestEvent, journeyMode, journeyWorker, recordPushOpen, registerDevice, removeDevice, reportingObserver, routeByChannel, routeByPlatform, runtimeFromConfig, sweepMaintenance, sweepSegments, sweepSegmentsPaged, trackEmail, unbindDevice, wakeExpired };
@@ -1,18 +1,22 @@
1
1
  import { EmailSender, trackEmail } from "../email-sender.mjs";
2
+ import { UserErasedError } from "../store/erasure.mjs";
2
3
  import { PostgresReporting } from "../store/postgres-reporting.mjs";
3
4
  import { PostgresJourneyStore } from "../store/postgres.mjs";
4
5
  import { JourneyFactSource } from "../store/facts.mjs";
5
- import { InstanceNotFoundError, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, isInstanceNotFound, wakeExpired } from "./bindings.mjs";
6
6
  import { D1JourneyStore } from "../store/d1.mjs";
7
7
  import { d1Store } from "./d1-env.mjs";
8
- import { BURST_WINDOW_MS, DEFAULT_QUICK_MS, classifyClick, classifyOpen } from "../reporting/classify.mjs";
9
- import { handleTracking, recordPushOpen } from "../reporting/tracking.mjs";
10
8
  import { SchemaMismatchError } from "../store/index.mjs";
11
- import { BundleIntegrityError, UnversionedStoreError, deployBundle, forgetUser, handleRequest, identifyUser, ingestEvent, registerDevice, removeDevice, sweepSegments, unbindDevice } from "../host/router.mjs";
9
+ import { InstanceNotFoundError, WAKE_EVENT_TYPE } from "../host/platform.mjs";
10
+ import { BundleIntegrityError, SWEEP_PAGE_SIZE, UnversionedStoreError, deployBundle, forgetUser, identifyUser, ingestEvent, registerDevice, removeDevice, sweepMaintenance, sweepSegments, sweepSegmentsPaged, unbindDevice } from "../host/ingest.mjs";
12
11
  import { reportingObserver } from "../reporting/observer.mjs";
13
12
  import { LogMessageSender, WebhookMessageSender, routeByChannel, routeByPlatform } from "../host/senders.mjs";
14
13
  import { channelsFromConfig, journeyMode, runtimeFromConfig } from "../host/channels.mjs";
14
+ import { BURST_WINDOW_MS, DEFAULT_QUICK_MS, classifyClick, classifyOpen } from "../reporting/classify.mjs";
15
+ import { handleTracking, recordPushOpen } from "../reporting/tracking.mjs";
16
+ import { authorized, bearerMatches } from "../host/auth.mjs";
17
+ import { handleRequest } from "../host/http.mjs";
15
18
  import { EnvValidationError } from "../host/journey-host.mjs";
19
+ import { WAKE_TIMEOUT_TOLERANCE_MS, cloudflareJourneyBinding, wakeExpired } from "./bindings.mjs";
16
20
  import { JourneyRunner } from "./runner.mjs";
17
21
  import { journeyWorker } from "./worker.mjs";
18
- export { BURST_WINDOW_MS, BundleIntegrityError, D1JourneyStore, DEFAULT_QUICK_MS, EmailSender, EnvValidationError, InstanceNotFoundError, JourneyFactSource, JourneyRunner, LogMessageSender, PostgresJourneyStore, PostgresReporting, SchemaMismatchError, UnversionedStoreError, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WebhookMessageSender, channelsFromConfig, classifyClick, classifyOpen, d1Store, deployBundle, forgetUser, handleRequest, handleTracking, identifyUser, ingestEvent, isInstanceNotFound, journeyMode, journeyWorker, recordPushOpen, registerDevice, removeDevice, reportingObserver, routeByChannel, routeByPlatform, runtimeFromConfig, sweepSegments, trackEmail, unbindDevice, wakeExpired };
22
+ export { BURST_WINDOW_MS, BundleIntegrityError, D1JourneyStore, DEFAULT_QUICK_MS, EmailSender, EnvValidationError, InstanceNotFoundError, JourneyFactSource, JourneyRunner, LogMessageSender, PostgresJourneyStore, PostgresReporting, SWEEP_PAGE_SIZE, SchemaMismatchError, UnversionedStoreError, UserErasedError, WAKE_EVENT_TYPE, WAKE_TIMEOUT_TOLERANCE_MS, WebhookMessageSender, authorized, bearerMatches, channelsFromConfig, classifyClick, classifyOpen, cloudflareJourneyBinding, d1Store, deployBundle, forgetUser, handleRequest, handleTracking, identifyUser, ingestEvent, journeyMode, journeyWorker, recordPushOpen, registerDevice, removeDevice, reportingObserver, routeByChannel, routeByPlatform, runtimeFromConfig, sweepMaintenance, sweepSegments, sweepSegmentsPaged, trackEmail, unbindDevice, wakeExpired };