sendwend 0.0.0-stage → 12.7.3

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 (680) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2082 -2
  3. package/dist/_virtual/_rolldown/runtime.cjs +22 -0
  4. package/dist/apns-relay.cjs +91 -0
  5. package/dist/apns-relay.cjs.map +1 -0
  6. package/dist/apns-relay.d.cts +26 -0
  7. package/dist/apns-relay.d.cts.map +1 -0
  8. package/dist/apns-relay.d.mts +26 -0
  9. package/dist/apns-relay.d.mts.map +1 -0
  10. package/dist/apns-relay.mjs +90 -0
  11. package/dist/apns-relay.mjs.map +1 -0
  12. package/dist/apns.cjs +215 -0
  13. package/dist/apns.cjs.map +1 -0
  14. package/dist/apns.d.cts +110 -0
  15. package/dist/apns.d.cts.map +1 -0
  16. package/dist/apns.d.mts +110 -0
  17. package/dist/apns.d.mts.map +1 -0
  18. package/dist/apns.mjs +207 -0
  19. package/dist/apns.mjs.map +1 -0
  20. package/dist/aws/engine-step.cjs +105 -0
  21. package/dist/aws/engine-step.cjs.map +1 -0
  22. package/dist/aws/engine-step.d.cts +42 -0
  23. package/dist/aws/engine-step.d.cts.map +1 -0
  24. package/dist/aws/engine-step.d.mts +42 -0
  25. package/dist/aws/engine-step.d.mts.map +1 -0
  26. package/dist/aws/engine-step.mjs +103 -0
  27. package/dist/aws/engine-step.mjs.map +1 -0
  28. package/dist/aws/function-url.cjs +53 -0
  29. package/dist/aws/function-url.cjs.map +1 -0
  30. package/dist/aws/function-url.d.cts +36 -0
  31. package/dist/aws/function-url.d.cts.map +1 -0
  32. package/dist/aws/function-url.d.mts +36 -0
  33. package/dist/aws/function-url.d.mts.map +1 -0
  34. package/dist/aws/function-url.mjs +50 -0
  35. package/dist/aws/function-url.mjs.map +1 -0
  36. package/dist/aws/index.cjs +232 -0
  37. package/dist/aws/index.cjs.map +1 -0
  38. package/dist/aws/index.d.cts +73 -0
  39. package/dist/aws/index.d.cts.map +1 -0
  40. package/dist/aws/index.d.mts +73 -0
  41. package/dist/aws/index.d.mts.map +1 -0
  42. package/dist/aws/index.mjs +218 -0
  43. package/dist/aws/index.mjs.map +1 -0
  44. package/dist/aws/instances.cjs +218 -0
  45. package/dist/aws/instances.cjs.map +1 -0
  46. package/dist/aws/instances.d.cts +102 -0
  47. package/dist/aws/instances.d.cts.map +1 -0
  48. package/dist/aws/instances.d.mts +102 -0
  49. package/dist/aws/instances.d.mts.map +1 -0
  50. package/dist/aws/instances.mjs +214 -0
  51. package/dist/aws/instances.mjs.map +1 -0
  52. package/dist/aws/lambda-api.cjs +86 -0
  53. package/dist/aws/lambda-api.cjs.map +1 -0
  54. package/dist/aws/lambda-api.d.cts +41 -0
  55. package/dist/aws/lambda-api.d.cts.map +1 -0
  56. package/dist/aws/lambda-api.d.mts +41 -0
  57. package/dist/aws/lambda-api.d.mts.map +1 -0
  58. package/dist/aws/lambda-api.mjs +85 -0
  59. package/dist/aws/lambda-api.mjs.map +1 -0
  60. package/dist/client.cjs +216 -0
  61. package/dist/client.cjs.map +1 -0
  62. package/dist/client.d.cts +193 -0
  63. package/dist/client.d.cts.map +1 -0
  64. package/dist/client.d.mts +193 -0
  65. package/dist/client.d.mts.map +1 -0
  66. package/dist/client.mjs +212 -0
  67. package/dist/client.mjs.map +1 -0
  68. package/dist/cloudflare/bindings.cjs +49 -0
  69. package/dist/cloudflare/bindings.cjs.map +1 -0
  70. package/dist/cloudflare/bindings.d.cts +31 -0
  71. package/dist/cloudflare/bindings.d.cts.map +1 -0
  72. package/dist/cloudflare/bindings.d.mts +31 -0
  73. package/dist/cloudflare/bindings.d.mts.map +1 -0
  74. package/dist/cloudflare/bindings.mjs +46 -0
  75. package/dist/cloudflare/bindings.mjs.map +1 -0
  76. package/dist/cloudflare/index.cjs +73 -0
  77. package/dist/cloudflare/index.d.cts +25 -0
  78. package/dist/cloudflare/index.d.mts +25 -0
  79. package/dist/cloudflare/index.mjs +20 -0
  80. package/dist/cloudflare/runner.cjs +200 -0
  81. package/dist/cloudflare/runner.cjs.map +1 -0
  82. package/dist/cloudflare/runner.d.cts +83 -0
  83. package/dist/cloudflare/runner.d.cts.map +1 -0
  84. package/dist/cloudflare/runner.d.mts +83 -0
  85. package/dist/cloudflare/runner.d.mts.map +1 -0
  86. package/dist/cloudflare/runner.mjs +199 -0
  87. package/dist/cloudflare/runner.mjs.map +1 -0
  88. package/dist/cloudflare/worker.cjs +106 -0
  89. package/dist/cloudflare/worker.cjs.map +1 -0
  90. package/dist/cloudflare/worker.d.cts +52 -0
  91. package/dist/cloudflare/worker.d.cts.map +1 -0
  92. package/dist/cloudflare/worker.d.mts +52 -0
  93. package/dist/cloudflare/worker.d.mts.map +1 -0
  94. package/dist/cloudflare/worker.mjs +104 -0
  95. package/dist/cloudflare/worker.mjs.map +1 -0
  96. package/dist/cloudflare/workers.d.cjs +0 -0
  97. package/dist/cloudflare/workers.d.cts +42 -0
  98. package/dist/cloudflare/workers.d.cts.map +1 -0
  99. package/dist/cloudflare/workers.d.mts +42 -0
  100. package/dist/cloudflare/workers.d.mts.map +1 -0
  101. package/dist/config.cjs +257 -0
  102. package/dist/config.cjs.map +1 -0
  103. package/dist/config.d.cts +184 -0
  104. package/dist/config.d.cts.map +1 -0
  105. package/dist/config.d.mts +184 -0
  106. package/dist/config.d.mts.map +1 -0
  107. package/dist/config.mjs +246 -0
  108. package/dist/config.mjs.map +1 -0
  109. package/dist/contract.cjs +222 -0
  110. package/dist/contract.cjs.map +1 -0
  111. package/dist/contract.d.cts +110 -0
  112. package/dist/contract.d.cts.map +1 -0
  113. package/dist/contract.d.mts +110 -0
  114. package/dist/contract.d.mts.map +1 -0
  115. package/dist/contract.mjs +216 -0
  116. package/dist/contract.mjs.map +1 -0
  117. package/dist/date-time.cjs +22 -0
  118. package/dist/date-time.cjs.map +1 -0
  119. package/dist/date-time.d.cts +10 -0
  120. package/dist/date-time.d.cts.map +1 -0
  121. package/dist/date-time.d.mts +10 -0
  122. package/dist/date-time.d.mts.map +1 -0
  123. package/dist/date-time.mjs +21 -0
  124. package/dist/date-time.mjs.map +1 -0
  125. package/dist/dsl/action.cjs +25 -0
  126. package/dist/dsl/action.cjs.map +1 -0
  127. package/dist/dsl/action.d.cts +63 -0
  128. package/dist/dsl/action.d.cts.map +1 -0
  129. package/dist/dsl/action.d.mts +63 -0
  130. package/dist/dsl/action.d.mts.map +1 -0
  131. package/dist/dsl/action.mjs +24 -0
  132. package/dist/dsl/action.mjs.map +1 -0
  133. package/dist/dsl/base.cjs +33 -0
  134. package/dist/dsl/base.cjs.map +1 -0
  135. package/dist/dsl/base.d.cts +43 -0
  136. package/dist/dsl/base.d.cts.map +1 -0
  137. package/dist/dsl/base.d.mts +43 -0
  138. package/dist/dsl/base.d.mts.map +1 -0
  139. package/dist/dsl/base.mjs +29 -0
  140. package/dist/dsl/base.mjs.map +1 -0
  141. package/dist/dsl/bundle.cjs +287 -0
  142. package/dist/dsl/bundle.cjs.map +1 -0
  143. package/dist/dsl/bundle.d.cts +33 -0
  144. package/dist/dsl/bundle.d.cts.map +1 -0
  145. package/dist/dsl/bundle.d.mts +33 -0
  146. package/dist/dsl/bundle.d.mts.map +1 -0
  147. package/dist/dsl/bundle.mjs +284 -0
  148. package/dist/dsl/bundle.mjs.map +1 -0
  149. package/dist/dsl/condition.cjs +200 -0
  150. package/dist/dsl/condition.cjs.map +1 -0
  151. package/dist/dsl/condition.d.cts +151 -0
  152. package/dist/dsl/condition.d.cts.map +1 -0
  153. package/dist/dsl/condition.d.mts +151 -0
  154. package/dist/dsl/condition.d.mts.map +1 -0
  155. package/dist/dsl/condition.mjs +178 -0
  156. package/dist/dsl/condition.mjs.map +1 -0
  157. package/dist/dsl/flow.cjs +335 -0
  158. package/dist/dsl/flow.cjs.map +1 -0
  159. package/dist/dsl/flow.d.cts +278 -0
  160. package/dist/dsl/flow.d.cts.map +1 -0
  161. package/dist/dsl/flow.d.mts +278 -0
  162. package/dist/dsl/flow.d.mts.map +1 -0
  163. package/dist/dsl/flow.mjs +331 -0
  164. package/dist/dsl/flow.mjs.map +1 -0
  165. package/dist/dsl/index.cjs +37 -0
  166. package/dist/dsl/index.d.cts +34 -0
  167. package/dist/dsl/index.d.mts +34 -0
  168. package/dist/dsl/index.mjs +9 -0
  169. package/dist/dsl/refs.cjs +101 -0
  170. package/dist/dsl/refs.cjs.map +1 -0
  171. package/dist/dsl/refs.d.cts +127 -0
  172. package/dist/dsl/refs.d.cts.map +1 -0
  173. package/dist/dsl/refs.d.mts +127 -0
  174. package/dist/dsl/refs.d.mts.map +1 -0
  175. package/dist/dsl/refs.mjs +93 -0
  176. package/dist/dsl/refs.mjs.map +1 -0
  177. package/dist/dsl/template.cjs +19 -0
  178. package/dist/dsl/template.cjs.map +1 -0
  179. package/dist/dsl/template.d.cts +30 -0
  180. package/dist/dsl/template.d.cts.map +1 -0
  181. package/dist/dsl/template.d.mts +30 -0
  182. package/dist/dsl/template.d.mts.map +1 -0
  183. package/dist/dsl/template.mjs +18 -0
  184. package/dist/dsl/template.mjs.map +1 -0
  185. package/dist/dsl/trigger.cjs +53 -0
  186. package/dist/dsl/trigger.cjs.map +1 -0
  187. package/dist/dsl/trigger.d.cts +112 -0
  188. package/dist/dsl/trigger.d.cts.map +1 -0
  189. package/dist/dsl/trigger.d.mts +112 -0
  190. package/dist/dsl/trigger.d.mts.map +1 -0
  191. package/dist/dsl/trigger.mjs +52 -0
  192. package/dist/dsl/trigger.mjs.map +1 -0
  193. package/dist/dsl/workflow.cjs +143 -0
  194. package/dist/dsl/workflow.cjs.map +1 -0
  195. package/dist/dsl/workflow.d.cts +88 -0
  196. package/dist/dsl/workflow.d.cts.map +1 -0
  197. package/dist/dsl/workflow.d.mts +88 -0
  198. package/dist/dsl/workflow.d.mts.map +1 -0
  199. package/dist/dsl/workflow.mjs +142 -0
  200. package/dist/dsl/workflow.mjs.map +1 -0
  201. package/dist/email-context.cjs +28 -0
  202. package/dist/email-context.cjs.map +1 -0
  203. package/dist/email-context.d.cts +9 -0
  204. package/dist/email-context.d.cts.map +1 -0
  205. package/dist/email-context.d.mts +9 -0
  206. package/dist/email-context.d.mts.map +1 -0
  207. package/dist/email-context.mjs +26 -0
  208. package/dist/email-context.mjs.map +1 -0
  209. package/dist/email-sender.cjs +93 -0
  210. package/dist/email-sender.cjs.map +1 -0
  211. package/dist/email-sender.d.cts +88 -0
  212. package/dist/email-sender.d.cts.map +1 -0
  213. package/dist/email-sender.d.mts +88 -0
  214. package/dist/email-sender.d.mts.map +1 -0
  215. package/dist/email-sender.mjs +90 -0
  216. package/dist/email-sender.mjs.map +1 -0
  217. package/dist/email.cjs +73 -0
  218. package/dist/email.cjs.map +1 -0
  219. package/dist/email.d.cts +59 -0
  220. package/dist/email.d.cts.map +1 -0
  221. package/dist/email.d.mts +59 -0
  222. package/dist/email.d.mts.map +1 -0
  223. package/dist/email.mjs +68 -0
  224. package/dist/email.mjs.map +1 -0
  225. package/dist/engine/actions.cjs +19 -0
  226. package/dist/engine/actions.cjs.map +1 -0
  227. package/dist/engine/actions.d.cts +27 -0
  228. package/dist/engine/actions.d.cts.map +1 -0
  229. package/dist/engine/actions.d.mts +27 -0
  230. package/dist/engine/actions.d.mts.map +1 -0
  231. package/dist/engine/actions.mjs +18 -0
  232. package/dist/engine/actions.mjs.map +1 -0
  233. package/dist/engine/bucket.cjs +71 -0
  234. package/dist/engine/bucket.cjs.map +1 -0
  235. package/dist/engine/bucket.d.cts +30 -0
  236. package/dist/engine/bucket.d.cts.map +1 -0
  237. package/dist/engine/bucket.d.mts +30 -0
  238. package/dist/engine/bucket.d.mts.map +1 -0
  239. package/dist/engine/bucket.mjs +68 -0
  240. package/dist/engine/bucket.mjs.map +1 -0
  241. package/dist/engine/condition.cjs +199 -0
  242. package/dist/engine/condition.cjs.map +1 -0
  243. package/dist/engine/condition.d.cts +76 -0
  244. package/dist/engine/condition.d.cts.map +1 -0
  245. package/dist/engine/condition.d.mts +76 -0
  246. package/dist/engine/condition.d.mts.map +1 -0
  247. package/dist/engine/condition.mjs +192 -0
  248. package/dist/engine/condition.mjs.map +1 -0
  249. package/dist/engine/duration.cjs +33 -0
  250. package/dist/engine/duration.cjs.map +1 -0
  251. package/dist/engine/duration.d.cts +3 -0
  252. package/dist/engine/duration.d.cts.map +1 -0
  253. package/dist/engine/duration.d.mts +3 -0
  254. package/dist/engine/duration.d.mts.map +1 -0
  255. package/dist/engine/duration.mjs +32 -0
  256. package/dist/engine/duration.mjs.map +1 -0
  257. package/dist/engine/index.cjs +33 -0
  258. package/dist/engine/index.d.cts +10 -0
  259. package/dist/engine/index.d.mts +10 -0
  260. package/dist/engine/index.mjs +9 -0
  261. package/dist/engine/interpreter.cjs +613 -0
  262. package/dist/engine/interpreter.cjs.map +1 -0
  263. package/dist/engine/interpreter.d.cts +4 -0
  264. package/dist/engine/interpreter.d.cts.map +1 -0
  265. package/dist/engine/interpreter.d.mts +4 -0
  266. package/dist/engine/interpreter.d.mts.map +1 -0
  267. package/dist/engine/interpreter.mjs +612 -0
  268. package/dist/engine/interpreter.mjs.map +1 -0
  269. package/dist/engine/ports.cjs +0 -0
  270. package/dist/engine/ports.d.cts +373 -0
  271. package/dist/engine/ports.d.cts.map +1 -0
  272. package/dist/engine/ports.d.mts +373 -0
  273. package/dist/engine/ports.d.mts.map +1 -0
  274. package/dist/engine/ports.mjs +1 -0
  275. package/dist/engine/recipient.cjs +22 -0
  276. package/dist/engine/recipient.cjs.map +1 -0
  277. package/dist/engine/recipient.d.cts +11 -0
  278. package/dist/engine/recipient.d.cts.map +1 -0
  279. package/dist/engine/recipient.d.mts +11 -0
  280. package/dist/engine/recipient.d.mts.map +1 -0
  281. package/dist/engine/recipient.mjs +21 -0
  282. package/dist/engine/recipient.mjs.map +1 -0
  283. package/dist/engine/retry.cjs +106 -0
  284. package/dist/engine/retry.cjs.map +1 -0
  285. package/dist/engine/retry.d.cts +73 -0
  286. package/dist/engine/retry.d.cts.map +1 -0
  287. package/dist/engine/retry.d.mts +73 -0
  288. package/dist/engine/retry.d.mts.map +1 -0
  289. package/dist/engine/retry.mjs +98 -0
  290. package/dist/engine/retry.mjs.map +1 -0
  291. package/dist/engine/time-scale.cjs +153 -0
  292. package/dist/engine/time-scale.cjs.map +1 -0
  293. package/dist/engine/time-scale.d.cts +41 -0
  294. package/dist/engine/time-scale.d.cts.map +1 -0
  295. package/dist/engine/time-scale.d.mts +41 -0
  296. package/dist/engine/time-scale.d.mts.map +1 -0
  297. package/dist/engine/time-scale.mjs +150 -0
  298. package/dist/engine/time-scale.mjs.map +1 -0
  299. package/dist/engine/time-window.cjs +148 -0
  300. package/dist/engine/time-window.cjs.map +1 -0
  301. package/dist/engine/time-window.d.cts +20 -0
  302. package/dist/engine/time-window.d.cts.map +1 -0
  303. package/dist/engine/time-window.d.mts +20 -0
  304. package/dist/engine/time-window.d.mts.map +1 -0
  305. package/dist/engine/time-window.mjs +146 -0
  306. package/dist/engine/time-window.mjs.map +1 -0
  307. package/dist/fcm.cjs +208 -0
  308. package/dist/fcm.cjs.map +1 -0
  309. package/dist/fcm.d.cts +89 -0
  310. package/dist/fcm.d.cts.map +1 -0
  311. package/dist/fcm.d.mts +89 -0
  312. package/dist/fcm.d.mts.map +1 -0
  313. package/dist/fcm.mjs +202 -0
  314. package/dist/fcm.mjs.map +1 -0
  315. package/dist/hash.cjs +244 -0
  316. package/dist/hash.cjs.map +1 -0
  317. package/dist/hash.d.cts +28 -0
  318. package/dist/hash.d.cts.map +1 -0
  319. package/dist/hash.d.mts +28 -0
  320. package/dist/hash.d.mts.map +1 -0
  321. package/dist/hash.mjs +238 -0
  322. package/dist/hash.mjs.map +1 -0
  323. package/dist/host/auth.cjs +48 -0
  324. package/dist/host/auth.cjs.map +1 -0
  325. package/dist/host/auth.d.cts +33 -0
  326. package/dist/host/auth.d.cts.map +1 -0
  327. package/dist/host/auth.d.mts +33 -0
  328. package/dist/host/auth.d.mts.map +1 -0
  329. package/dist/host/auth.mjs +45 -0
  330. package/dist/host/auth.mjs.map +1 -0
  331. package/dist/host/batch.cjs +178 -0
  332. package/dist/host/batch.cjs.map +1 -0
  333. package/dist/host/batch.d.cts +92 -0
  334. package/dist/host/batch.d.cts.map +1 -0
  335. package/dist/host/batch.d.mts +92 -0
  336. package/dist/host/batch.d.mts.map +1 -0
  337. package/dist/host/batch.mjs +169 -0
  338. package/dist/host/batch.mjs.map +1 -0
  339. package/dist/host/channels.cjs +256 -0
  340. package/dist/host/channels.cjs.map +1 -0
  341. package/dist/host/channels.d.cts +66 -0
  342. package/dist/host/channels.d.cts.map +1 -0
  343. package/dist/host/channels.d.mts +66 -0
  344. package/dist/host/channels.d.mts.map +1 -0
  345. package/dist/host/channels.mjs +252 -0
  346. package/dist/host/channels.mjs.map +1 -0
  347. package/dist/host/execute.cjs +102 -0
  348. package/dist/host/execute.cjs.map +1 -0
  349. package/dist/host/execute.d.cts +38 -0
  350. package/dist/host/execute.d.cts.map +1 -0
  351. package/dist/host/execute.d.mts +38 -0
  352. package/dist/host/execute.d.mts.map +1 -0
  353. package/dist/host/execute.mjs +101 -0
  354. package/dist/host/execute.mjs.map +1 -0
  355. package/dist/host/fresh-read.cjs +29 -0
  356. package/dist/host/fresh-read.cjs.map +1 -0
  357. package/dist/host/fresh-read.d.cts +16 -0
  358. package/dist/host/fresh-read.d.cts.map +1 -0
  359. package/dist/host/fresh-read.d.mts +16 -0
  360. package/dist/host/fresh-read.d.mts.map +1 -0
  361. package/dist/host/fresh-read.mjs +28 -0
  362. package/dist/host/fresh-read.mjs.map +1 -0
  363. package/dist/host/http.cjs +393 -0
  364. package/dist/host/http.cjs.map +1 -0
  365. package/dist/host/http.d.cts +61 -0
  366. package/dist/host/http.d.cts.map +1 -0
  367. package/dist/host/http.d.mts +61 -0
  368. package/dist/host/http.d.mts.map +1 -0
  369. package/dist/host/http.mjs +389 -0
  370. package/dist/host/http.mjs.map +1 -0
  371. package/dist/host/ingest.cjs +1210 -0
  372. package/dist/host/ingest.cjs.map +1 -0
  373. package/dist/host/ingest.d.cts +497 -0
  374. package/dist/host/ingest.d.cts.map +1 -0
  375. package/dist/host/ingest.d.mts +497 -0
  376. package/dist/host/ingest.d.mts.map +1 -0
  377. package/dist/host/ingest.mjs +1172 -0
  378. package/dist/host/ingest.mjs.map +1 -0
  379. package/dist/host/journey-host.cjs +223 -0
  380. package/dist/host/journey-host.cjs.map +1 -0
  381. package/dist/host/journey-host.d.cts +118 -0
  382. package/dist/host/journey-host.d.cts.map +1 -0
  383. package/dist/host/journey-host.d.mts +118 -0
  384. package/dist/host/journey-host.d.mts.map +1 -0
  385. package/dist/host/journey-host.mjs +219 -0
  386. package/dist/host/journey-host.mjs.map +1 -0
  387. package/dist/host/platform.cjs +20 -0
  388. package/dist/host/platform.cjs.map +1 -0
  389. package/dist/host/platform.d.cts +120 -0
  390. package/dist/host/platform.d.cts.map +1 -0
  391. package/dist/host/platform.d.mts +120 -0
  392. package/dist/host/platform.d.mts.map +1 -0
  393. package/dist/host/platform.mjs +18 -0
  394. package/dist/host/platform.mjs.map +1 -0
  395. package/dist/host/senders.cjs +71 -0
  396. package/dist/host/senders.cjs.map +1 -0
  397. package/dist/host/senders.d.cts +34 -0
  398. package/dist/host/senders.d.cts.map +1 -0
  399. package/dist/host/senders.d.mts +34 -0
  400. package/dist/host/senders.d.mts.map +1 -0
  401. package/dist/host/senders.mjs +67 -0
  402. package/dist/host/senders.mjs.map +1 -0
  403. package/dist/host/workflow-cache.cjs +47 -0
  404. package/dist/host/workflow-cache.cjs.map +1 -0
  405. package/dist/host/workflow-cache.d.cts +21 -0
  406. package/dist/host/workflow-cache.d.cts.map +1 -0
  407. package/dist/host/workflow-cache.d.mts +21 -0
  408. package/dist/host/workflow-cache.d.mts.map +1 -0
  409. package/dist/host/workflow-cache.mjs +46 -0
  410. package/dist/host/workflow-cache.mjs.map +1 -0
  411. package/dist/http2-client.cjs +89 -0
  412. package/dist/http2-client.cjs.map +1 -0
  413. package/dist/http2-client.d.cts +45 -0
  414. package/dist/http2-client.d.cts.map +1 -0
  415. package/dist/http2-client.d.mts +45 -0
  416. package/dist/http2-client.d.mts.map +1 -0
  417. package/dist/http2-client.mjs +87 -0
  418. package/dist/http2-client.mjs.map +1 -0
  419. package/dist/index.cjs +130 -0
  420. package/dist/index.d.cts +21 -0
  421. package/dist/index.d.mts +21 -0
  422. package/dist/index.mjs +20 -0
  423. package/dist/inflight.cjs +116 -0
  424. package/dist/inflight.cjs.map +1 -0
  425. package/dist/inflight.d.cts +49 -0
  426. package/dist/inflight.d.cts.map +1 -0
  427. package/dist/inflight.d.mts +49 -0
  428. package/dist/inflight.d.mts.map +1 -0
  429. package/dist/inflight.mjs +113 -0
  430. package/dist/inflight.mjs.map +1 -0
  431. package/dist/ir.cjs +429 -0
  432. package/dist/ir.cjs.map +1 -0
  433. package/dist/ir.d.cts +593 -0
  434. package/dist/ir.d.cts.map +1 -0
  435. package/dist/ir.d.mts +593 -0
  436. package/dist/ir.d.mts.map +1 -0
  437. package/dist/ir.mjs +404 -0
  438. package/dist/ir.mjs.map +1 -0
  439. package/dist/jwt.cjs +17 -0
  440. package/dist/jwt.cjs.map +1 -0
  441. package/dist/jwt.d.cts +7 -0
  442. package/dist/jwt.d.cts.map +1 -0
  443. package/dist/jwt.d.mts +7 -0
  444. package/dist/jwt.d.mts.map +1 -0
  445. package/dist/jwt.mjs +15 -0
  446. package/dist/jwt.mjs.map +1 -0
  447. package/dist/node/index.cjs +231 -0
  448. package/dist/node/index.cjs.map +1 -0
  449. package/dist/node/index.d.cts +59 -0
  450. package/dist/node/index.d.cts.map +1 -0
  451. package/dist/node/index.d.mts +59 -0
  452. package/dist/node/index.d.mts.map +1 -0
  453. package/dist/node/index.mjs +225 -0
  454. package/dist/node/index.mjs.map +1 -0
  455. package/dist/node/runs.cjs +222 -0
  456. package/dist/node/runs.cjs.map +1 -0
  457. package/dist/node/runs.d.cts +93 -0
  458. package/dist/node/runs.d.cts.map +1 -0
  459. package/dist/node/runs.d.mts +93 -0
  460. package/dist/node/runs.d.mts.map +1 -0
  461. package/dist/node/runs.mjs +221 -0
  462. package/dist/node/runs.mjs.map +1 -0
  463. package/dist/node/runtime.cjs +351 -0
  464. package/dist/node/runtime.cjs.map +1 -0
  465. package/dist/node/runtime.d.cts +96 -0
  466. package/dist/node/runtime.d.cts.map +1 -0
  467. package/dist/node/runtime.d.mts +96 -0
  468. package/dist/node/runtime.d.mts.map +1 -0
  469. package/dist/node/runtime.mjs +348 -0
  470. package/dist/node/runtime.mjs.map +1 -0
  471. package/dist/plan.cjs +221 -0
  472. package/dist/plan.cjs.map +1 -0
  473. package/dist/plan.d.cts +68 -0
  474. package/dist/plan.d.cts.map +1 -0
  475. package/dist/plan.d.mts +68 -0
  476. package/dist/plan.d.mts.map +1 -0
  477. package/dist/plan.mjs +218 -0
  478. package/dist/plan.mjs.map +1 -0
  479. package/dist/postgres-js.cjs +51 -0
  480. package/dist/postgres-js.cjs.map +1 -0
  481. package/dist/postgres-js.d.cts +32 -0
  482. package/dist/postgres-js.d.cts.map +1 -0
  483. package/dist/postgres-js.d.mts +32 -0
  484. package/dist/postgres-js.d.mts.map +1 -0
  485. package/dist/postgres-js.mjs +46 -0
  486. package/dist/postgres-js.mjs.map +1 -0
  487. package/dist/provenance.cjs +66 -0
  488. package/dist/provenance.cjs.map +1 -0
  489. package/dist/provenance.d.cts +40 -0
  490. package/dist/provenance.d.cts.map +1 -0
  491. package/dist/provenance.d.mts +40 -0
  492. package/dist/provenance.d.mts.map +1 -0
  493. package/dist/provenance.mjs +64 -0
  494. package/dist/provenance.mjs.map +1 -0
  495. package/dist/push.cjs +11 -0
  496. package/dist/push.cjs.map +1 -0
  497. package/dist/push.d.cts +14 -0
  498. package/dist/push.d.cts.map +1 -0
  499. package/dist/push.d.mts +14 -0
  500. package/dist/push.d.mts.map +1 -0
  501. package/dist/push.mjs +10 -0
  502. package/dist/push.mjs.map +1 -0
  503. package/dist/react-email.cjs +56 -0
  504. package/dist/react-email.cjs.map +1 -0
  505. package/dist/react-email.d.cts +5 -0
  506. package/dist/react-email.d.cts.map +1 -0
  507. package/dist/react-email.d.mts +5 -0
  508. package/dist/react-email.d.mts.map +1 -0
  509. package/dist/react-email.mjs +55 -0
  510. package/dist/react-email.mjs.map +1 -0
  511. package/dist/reporting/classify.cjs +46 -0
  512. package/dist/reporting/classify.cjs.map +1 -0
  513. package/dist/reporting/classify.d.cts +65 -0
  514. package/dist/reporting/classify.d.cts.map +1 -0
  515. package/dist/reporting/classify.d.mts +65 -0
  516. package/dist/reporting/classify.d.mts.map +1 -0
  517. package/dist/reporting/classify.mjs +42 -0
  518. package/dist/reporting/classify.mjs.map +1 -0
  519. package/dist/reporting/observer.cjs +137 -0
  520. package/dist/reporting/observer.cjs.map +1 -0
  521. package/dist/reporting/observer.d.cts +31 -0
  522. package/dist/reporting/observer.d.cts.map +1 -0
  523. package/dist/reporting/observer.d.mts +31 -0
  524. package/dist/reporting/observer.d.mts.map +1 -0
  525. package/dist/reporting/observer.mjs +134 -0
  526. package/dist/reporting/observer.mjs.map +1 -0
  527. package/dist/reporting/tracking.cjs +185 -0
  528. package/dist/reporting/tracking.cjs.map +1 -0
  529. package/dist/reporting/tracking.d.cts +63 -0
  530. package/dist/reporting/tracking.d.cts.map +1 -0
  531. package/dist/reporting/tracking.d.mts +63 -0
  532. package/dist/reporting/tracking.d.mts.map +1 -0
  533. package/dist/reporting/tracking.mjs +182 -0
  534. package/dist/reporting/tracking.mjs.map +1 -0
  535. package/dist/runtime.cjs +18 -0
  536. package/dist/runtime.cjs.map +1 -0
  537. package/dist/runtime.d.cts +44 -0
  538. package/dist/runtime.d.cts.map +1 -0
  539. package/dist/runtime.d.mts +44 -0
  540. package/dist/runtime.d.mts.map +1 -0
  541. package/dist/runtime.mjs +17 -0
  542. package/dist/runtime.mjs.map +1 -0
  543. package/dist/store/condition-sql.cjs +145 -0
  544. package/dist/store/condition-sql.cjs.map +1 -0
  545. package/dist/store/condition-sql.d.cts +38 -0
  546. package/dist/store/condition-sql.d.cts.map +1 -0
  547. package/dist/store/condition-sql.d.mts +38 -0
  548. package/dist/store/condition-sql.d.mts.map +1 -0
  549. package/dist/store/condition-sql.mjs +144 -0
  550. package/dist/store/condition-sql.mjs.map +1 -0
  551. package/dist/store/erasure.cjs +21 -0
  552. package/dist/store/erasure.cjs.map +1 -0
  553. package/dist/store/erasure.d.cts +16 -0
  554. package/dist/store/erasure.d.cts.map +1 -0
  555. package/dist/store/erasure.d.mts +16 -0
  556. package/dist/store/erasure.d.mts.map +1 -0
  557. package/dist/store/erasure.mjs +20 -0
  558. package/dist/store/erasure.mjs.map +1 -0
  559. package/dist/store/facts.cjs +79 -0
  560. package/dist/store/facts.cjs.map +1 -0
  561. package/dist/store/facts.d.cts +41 -0
  562. package/dist/store/facts.d.cts.map +1 -0
  563. package/dist/store/facts.d.mts +41 -0
  564. package/dist/store/facts.d.mts.map +1 -0
  565. package/dist/store/facts.mjs +77 -0
  566. package/dist/store/facts.mjs.map +1 -0
  567. package/dist/store/identity.cjs +34 -0
  568. package/dist/store/identity.cjs.map +1 -0
  569. package/dist/store/identity.d.cts +13 -0
  570. package/dist/store/identity.d.cts.map +1 -0
  571. package/dist/store/identity.d.mts +13 -0
  572. package/dist/store/identity.d.mts.map +1 -0
  573. package/dist/store/identity.mjs +30 -0
  574. package/dist/store/identity.mjs.map +1 -0
  575. package/dist/store/index.cjs +35 -0
  576. package/dist/store/index.cjs.map +1 -0
  577. package/dist/store/index.d.cts +766 -0
  578. package/dist/store/index.d.cts.map +1 -0
  579. package/dist/store/index.d.mts +766 -0
  580. package/dist/store/index.d.mts.map +1 -0
  581. package/dist/store/index.mjs +22 -0
  582. package/dist/store/index.mjs.map +1 -0
  583. package/dist/store/postgres-reporting.cjs +327 -0
  584. package/dist/store/postgres-reporting.cjs.map +1 -0
  585. package/dist/store/postgres-reporting.d.cts +95 -0
  586. package/dist/store/postgres-reporting.d.cts.map +1 -0
  587. package/dist/store/postgres-reporting.d.mts +95 -0
  588. package/dist/store/postgres-reporting.d.mts.map +1 -0
  589. package/dist/store/postgres-reporting.mjs +326 -0
  590. package/dist/store/postgres-reporting.mjs.map +1 -0
  591. package/dist/store/postgres.cjs +1173 -0
  592. package/dist/store/postgres.cjs.map +1 -0
  593. package/dist/store/postgres.d.cts +199 -0
  594. package/dist/store/postgres.d.cts.map +1 -0
  595. package/dist/store/postgres.d.mts +199 -0
  596. package/dist/store/postgres.d.mts.map +1 -0
  597. package/dist/store/postgres.mjs +1170 -0
  598. package/dist/store/postgres.mjs.map +1 -0
  599. package/dist/store/sql.cjs +24 -0
  600. package/dist/store/sql.cjs.map +1 -0
  601. package/dist/store/sql.d.cts +26 -0
  602. package/dist/store/sql.d.cts.map +1 -0
  603. package/dist/store/sql.d.mts +26 -0
  604. package/dist/store/sql.d.mts.map +1 -0
  605. package/dist/store/sql.mjs +23 -0
  606. package/dist/store/sql.mjs.map +1 -0
  607. package/dist/store/tables.cjs +660 -0
  608. package/dist/store/tables.cjs.map +1 -0
  609. package/dist/store/tables.d.cts +103 -0
  610. package/dist/store/tables.d.cts.map +1 -0
  611. package/dist/store/tables.d.mts +103 -0
  612. package/dist/store/tables.d.mts.map +1 -0
  613. package/dist/store/tables.mjs +653 -0
  614. package/dist/store/tables.mjs.map +1 -0
  615. package/dist/store/user-lock.cjs +42 -0
  616. package/dist/store/user-lock.cjs.map +1 -0
  617. package/dist/store/user-lock.d.cts +30 -0
  618. package/dist/store/user-lock.d.cts.map +1 -0
  619. package/dist/store/user-lock.d.mts +30 -0
  620. package/dist/store/user-lock.d.mts.map +1 -0
  621. package/dist/store/user-lock.mjs +39 -0
  622. package/dist/store/user-lock.mjs.map +1 -0
  623. package/dist/template-rules.cjs +94 -0
  624. package/dist/template-rules.cjs.map +1 -0
  625. package/dist/template-rules.d.cts +80 -0
  626. package/dist/template-rules.d.cts.map +1 -0
  627. package/dist/template-rules.d.mts +80 -0
  628. package/dist/template-rules.d.mts.map +1 -0
  629. package/dist/template-rules.mjs +86 -0
  630. package/dist/template-rules.mjs.map +1 -0
  631. package/dist/templates.cjs +375 -0
  632. package/dist/templates.cjs.map +1 -0
  633. package/dist/templates.d.cts +358 -0
  634. package/dist/templates.d.cts.map +1 -0
  635. package/dist/templates.d.mts +358 -0
  636. package/dist/templates.d.mts.map +1 -0
  637. package/dist/templates.mjs +353 -0
  638. package/dist/templates.mjs.map +1 -0
  639. package/dist/transports/cloudflare-email.cjs +69 -0
  640. package/dist/transports/cloudflare-email.cjs.map +1 -0
  641. package/dist/transports/cloudflare-email.d.cts +63 -0
  642. package/dist/transports/cloudflare-email.d.cts.map +1 -0
  643. package/dist/transports/cloudflare-email.d.mts +63 -0
  644. package/dist/transports/cloudflare-email.d.mts.map +1 -0
  645. package/dist/transports/cloudflare-email.mjs +67 -0
  646. package/dist/transports/cloudflare-email.mjs.map +1 -0
  647. package/dist/transports/ses.cjs +142 -0
  648. package/dist/transports/ses.cjs.map +1 -0
  649. package/dist/transports/ses.d.cts +49 -0
  650. package/dist/transports/ses.d.cts.map +1 -0
  651. package/dist/transports/ses.d.mts +49 -0
  652. package/dist/transports/ses.d.mts.map +1 -0
  653. package/dist/transports/ses.mjs +139 -0
  654. package/dist/transports/ses.mjs.map +1 -0
  655. package/dist/transports/sigv4.cjs +86 -0
  656. package/dist/transports/sigv4.cjs.map +1 -0
  657. package/dist/transports/sigv4.d.cts +25 -0
  658. package/dist/transports/sigv4.d.cts.map +1 -0
  659. package/dist/transports/sigv4.d.mts +25 -0
  660. package/dist/transports/sigv4.d.mts.map +1 -0
  661. package/dist/transports/sigv4.mjs +85 -0
  662. package/dist/transports/sigv4.mjs.map +1 -0
  663. package/dist/webhooks.cjs +97 -0
  664. package/dist/webhooks.cjs.map +1 -0
  665. package/dist/webhooks.d.cts +23 -0
  666. package/dist/webhooks.d.cts.map +1 -0
  667. package/dist/webhooks.d.mts +23 -0
  668. package/dist/webhooks.d.mts.map +1 -0
  669. package/dist/webhooks.mjs +95 -0
  670. package/dist/webhooks.mjs.map +1 -0
  671. package/dist/webpush.cjs +361 -0
  672. package/dist/webpush.cjs.map +1 -0
  673. package/dist/webpush.d.cts +135 -0
  674. package/dist/webpush.d.cts.map +1 -0
  675. package/dist/webpush.d.mts +135 -0
  676. package/dist/webpush.d.mts.map +1 -0
  677. package/dist/webpush.mjs +350 -0
  678. package/dist/webpush.mjs.map +1 -0
  679. package/package.json +279 -3
  680. package/src/cloudflare/workers.d.ts +44 -0
@@ -0,0 +1,1210 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_engine_bucket = require("../engine/bucket.cjs");
3
+ const require_engine_condition = require("../engine/condition.cjs");
4
+ const require_engine_recipient = require("../engine/recipient.cjs");
5
+ const require_hash = require("../hash.cjs");
6
+ const require_inflight = require("../inflight.cjs");
7
+ const require_ir = require("../ir.cjs");
8
+ const require_reporting_tracking = require("../reporting/tracking.cjs");
9
+ const require_store_facts = require("../store/facts.cjs");
10
+ const require_store_erasure = require("../store/erasure.cjs");
11
+ const require_store_identity = require("../store/identity.cjs");
12
+ const require_store_index = require("../store/index.cjs");
13
+ const require_host_platform = require("./platform.cjs");
14
+ // src/host/ingest.ts
15
+ /**
16
+ * Ingest: what the host does with what comes in, HTTP aside (that is `http.ts`). An incoming
17
+ * event does four things: it is stored, it wakes waiting instances, it is matched against event
18
+ * triggers, and it re-evaluates segment-trigger membership. An identify merges a profile, which
19
+ * wakes the waits on the properties it patched and re-evaluates segment triggers too. Plus
20
+ * devices, subscriptions, erasure, the segment sweep and bundle deploys.
21
+ *
22
+ * Storage goes through a JourneyStore; every entry point takes the one the host opened.
23
+ */
24
+ /**
25
+ * The fast answer for a user with an erasure tombstone (being erased, or erased for good): every
26
+ * ingest-side entry point starts here and does no work for them. The gate itself is the store's
27
+ * conditional write, which throws the same error when the tombstone lands after this check.
28
+ */
29
+ async function refuseIfErased(store, userId) {
30
+ if (await store.erasureState(userId) !== "none") throw new require_store_erasure.UserErasedError(userId);
31
+ }
32
+ /**
33
+ * The largest payload an event may carry, as UTF-8 bytes of its JSON. A triggering event's
34
+ * payload rides in the instance's params for the whole journey (`t.payload.x` reads it there),
35
+ * and the runtimes cap those: Cloudflare Workflows at 1 MiB, and a batch arriving through a
36
+ * queue at 128 KiB a message. Refusing at the door, with the size in the message, replaces an
37
+ * instance that fails to start with an error nobody traces back to one oversized event.
38
+ */
39
+ const MAX_EVENT_PAYLOAD_BYTES = 131072;
40
+ /** What is wrong with a payload's size, or undefined when it fits. */
41
+ function payloadSizeError(event, payload) {
42
+ if (payload === void 0) return void 0;
43
+ const bytes = new TextEncoder().encode(JSON.stringify(payload)).length;
44
+ if (bytes <= 131072) return void 0;
45
+ return `event '${event}': payload is ${bytes} bytes as JSON, over the ${MAX_EVENT_PAYLOAD_BYTES}-byte limit`;
46
+ }
47
+ /** An event whose payload is over `MAX_EVENT_PAYLOAD_BYTES`: the caller's to fix, never retried into fitting. */
48
+ var EventPayloadTooLargeError = class extends Error {
49
+ name = "EventPayloadTooLargeError";
50
+ };
51
+ async function ingestEvent(env, input, store) {
52
+ if (input.event.startsWith("$")) throw new Error(`event name '${input.event}' is reserved ('$' prefix is internal)`);
53
+ const oversized = payloadSizeError(input.event, input.payload);
54
+ if (oversized !== void 0) throw new EventPayloadTooLargeError(oversized);
55
+ await refuseIfErased(store, input.userId);
56
+ let ts = input.ts ?? Date.now();
57
+ let payload = input.payload ?? {};
58
+ const id = input.id ?? crypto.randomUUID();
59
+ const stored = await store.insertEvent({
60
+ id,
61
+ userId: input.userId,
62
+ event: input.event,
63
+ ts,
64
+ payload
65
+ });
66
+ if (!stored) {
67
+ const first = await store.storedEvent(input.userId, id);
68
+ if (first !== void 0 && first.event === input.event) {
69
+ ts = first.ts;
70
+ payload = first.payload;
71
+ }
72
+ }
73
+ const woke = await wakeSubscribers(env, store, input.userId, [input.event]);
74
+ const started = await startTriggeredJourneys(env, store, {
75
+ ...input,
76
+ payload
77
+ }, id, ts);
78
+ started.push(...await refreshSegmentTriggers(env, store, input.userId, Date.now()));
79
+ return {
80
+ id,
81
+ stored,
82
+ woke,
83
+ started
84
+ };
85
+ }
86
+ /**
87
+ * Wake every instance of the user waiting on any of `events`, once each: an instance subscribed
88
+ * to several of them (a wait on two profile properties, patched together) gets one wake-up, and
89
+ * the payload names the first event it matched.
90
+ */
91
+ async function wakeSubscribers(env, store, userId, events) {
92
+ const handles = /* @__PURE__ */ new Map();
93
+ for (const event of events) for (const handle of await store.findWakeHandles(userId, event)) if (!handles.has(handle)) handles.set(handle, event);
94
+ let woke = 0;
95
+ for (const [handle, event] of handles) {
96
+ let instance;
97
+ try {
98
+ instance = await env.JOURNEY.get(handle);
99
+ } catch (error) {
100
+ if (error instanceof require_host_platform.InstanceNotFoundError) await store.unsubscribe(handle);
101
+ else console.warn(`[workflow] looking up ${handle} to wake it failed`, error);
102
+ continue;
103
+ }
104
+ try {
105
+ await instance.sendEvent({
106
+ type: require_host_platform.WAKE_EVENT_TYPE,
107
+ payload: { event }
108
+ });
109
+ woke++;
110
+ } catch (error) {
111
+ const message = error instanceof Error ? error.message : String(error);
112
+ console.warn(`[workflow] waking ${handle} on ${event} failed: ${message}`);
113
+ }
114
+ }
115
+ return woke;
116
+ }
117
+ async function startTriggeredJourneys(env, store, input, occurrence, ts) {
118
+ const started = [];
119
+ for (const route of await store.findTriggers(input.event)) {
120
+ if (require_store_identity.isVisitorSubject(input.userId) && !route.visitors) continue;
121
+ if (route.where !== null && !require_engine_condition.matchesWhere(input.payload, route.where)) continue;
122
+ if (route.filter !== null) {
123
+ const facts = new require_store_facts.JourneyFactSource(store, input.userId);
124
+ if (!await require_engine_condition.evaluateCondition(route.filter, facts, ts)) continue;
125
+ }
126
+ const { instanceId } = await startJourney(env, store, route, input.userId, ts, occurrence, {
127
+ event: input.event,
128
+ payload: input.payload,
129
+ ts
130
+ });
131
+ if (instanceId !== null) started.push(instanceId);
132
+ }
133
+ return started;
134
+ }
135
+ /**
136
+ * Segment-entry triggers, maintained lazily: on each ingest/identify for a
137
+ * user, re-evaluate every trigger-routed segment for that user and act on the
138
+ * membership transition (enter → start journeys, leave → drop membership so a
139
+ * later re-qualification is a new entry attempt under the workflow's re-entry
140
+ * policy). Purely time-driven drift (an inactivity
141
+ * segment turning true by clock alone) has no event to ride on: the scheduled
142
+ * sweep catches it (`sweepSegments`).
143
+ */
144
+ async function refreshSegmentTriggers(env, store, userId, ts) {
145
+ return refreshSegments(env, store, userId, ts, await store.listSegmentTriggers());
146
+ }
147
+ /**
148
+ * Re-evaluate segments for one user — the routed ones only, or with `segments` every one named —
149
+ * and act on each membership transition: entering records the membership and starts the
150
+ * segment's routed workflows, leaving drops it. A segment trigger therefore starts journeys for
151
+ * users who enter after it is deployed; a user already a member is not entered again. Re-entry
152
+ * rides on that edge: one qualification is one occurrence (`$segment:<segment>:<since>`, since
153
+ * when the membership began), so a retried start is the same occurrence and only leaving and
154
+ * matching again makes a new one for the workflow's `reentry` policy to judge.
155
+ *
156
+ * Why the membership writes and the starts are separate store calls, and why that is safe:
157
+ * - Each segment's transition is one store operation. `addSegmentMember` writes the membership
158
+ * and the starts it owes (`segment_start`) in one locked transaction; `removeSegmentMember`
159
+ * drops both in one transaction. No failure leaves a segment half-entered or half-left.
160
+ * - Starts come only from `pendingSegmentStarts`, which exists only once that transaction has
161
+ * committed, so a journey is never started for a membership that was not recorded. A start that
162
+ * fails stays pending and is retried by the next evaluation (the sweep, the user's next event);
163
+ * it is crossed off only once an instance is known to exist (`entryStarted`).
164
+ * - A retried or concurrent start cannot run a journey twice: `startJourney` goes through the
165
+ * entry ledger, which holds one entry per (workflow, user, occurrence), and the membership
166
+ * insert is `ON CONFLICT DO NOTHING`.
167
+ * - Segments are independent memberships. A failure on one leaves the others where they were;
168
+ * every evaluation recomputes each from facts and the stored membership, so the next one
169
+ * converges rather than building on a partial run.
170
+ * Folding every segment's writes into one transaction would add nothing: the starts have to happen
171
+ * after the commit anyway (a workflow instance cannot join a database transaction), which is what
172
+ * the `segment_start` outbox already provides.
173
+ */
174
+ async function refreshSegments(env, store, userId, ts, routes, segments = [], definitions = /* @__PURE__ */ new Map()) {
175
+ if (require_store_identity.isVisitorSubject(userId)) return [];
176
+ const bySegment = new Map(segments.map((name) => [name, []]));
177
+ for (const route of routes) {
178
+ const list = bySegment.get(route.segment) ?? [];
179
+ list.push(route);
180
+ bySegment.set(route.segment, list);
181
+ }
182
+ if (bySegment.size === 0) return [];
183
+ const facts = new require_store_facts.JourneyFactSource(store, userId);
184
+ const started = [];
185
+ const failures = [];
186
+ for (const [segmentId, segmentRoutes] of bySegment) {
187
+ if (!definitions.has(segmentId)) definitions.set(segmentId, await store.getSegmentCondition(segmentId));
188
+ const definition = definitions.get(segmentId);
189
+ if (definition === void 0) continue;
190
+ const matches = await require_engine_condition.evaluateCondition(definition, facts, ts);
191
+ const member = await store.isSegmentMember(segmentId, userId);
192
+ if (matches && !member) {
193
+ const seeding = segmentRoutes.some((route) => route.seeding === true);
194
+ await store.addSegmentMember(segmentId, userId, ts, seeding ? [] : segmentRoutes.map((route) => route.workflow));
195
+ } else if (!matches && member) {
196
+ await store.removeSegmentMember(segmentId, userId);
197
+ continue;
198
+ }
199
+ if (!matches) continue;
200
+ const pending = new Map((await store.pendingSegmentStarts(segmentId, userId)).map((start) => [start.workflow, Math.round(start.since)]));
201
+ for (const route of segmentRoutes) {
202
+ const since = pending.get(route.workflow);
203
+ if (since === void 0) continue;
204
+ try {
205
+ const occurrence = `$segment:${segmentId}:${since}`;
206
+ const { instanceId, outcome } = await startJourney(env, store, route, userId, since, occurrence, {
207
+ event: "$segment_entry",
208
+ payload: { segment: segmentId }
209
+ });
210
+ if (instanceId !== null) started.push(instanceId);
211
+ if (instanceId !== null || outcome === "refused" || await entryStarted(env, store, route.workflow, userId, occurrence)) await store.completeSegmentStart(segmentId, userId, route.workflow);
212
+ } catch (error) {
213
+ failures.push(error);
214
+ }
215
+ }
216
+ }
217
+ if (failures.length > 0) throw failures[0];
218
+ return started;
219
+ }
220
+ /**
221
+ * How long an entry may wait for its runner's admission before maintenance looks for its
222
+ * instance. A create takes well under a second and a queued instance is found by `get`, so this
223
+ * only has to outlast a create still in flight — generously, since a wrong call fails a journey.
224
+ */
225
+ const LOST_START_AFTER_MS = 9e5;
226
+ /** Entries one maintenance run examines, oldest first; the next run takes the rest. */
227
+ const LOST_START_BATCH = 25;
228
+ /**
229
+ * Starts lost between the entry and the platform's create — the Worker cut off there, or a
230
+ * create that failed with its rollback failing too — leave a `running` entry nothing will ever
231
+ * admit, and as a running entry it would block re-entry for good. An instance that
232
+ * ended before admitting itself leaves the same. An entry old enough, unadmitted, whose instance
233
+ * the runtime does not know or reports ended, is marked `failed`: it blocks
234
+ * nothing, and a retry of its occurrence reclaims it. Nothing of such an instance ran, since admission precedes its first effect. Platform-neutral:
235
+ * on AWS a planned start is always known to `get` (its registry row), and reads as ended only once
236
+ * its retries have given up, so only a start with nothing behind it is touched.
237
+ */
238
+ async function failLostStarts(env, store, now) {
239
+ const failed = [];
240
+ for (const entry of await store.unadmittedEntries(now - LOST_START_AFTER_MS, LOST_START_BATCH)) {
241
+ try {
242
+ if (!await hasEnded(await env.JOURNEY.get(entry.instanceId))) continue;
243
+ } catch (error) {
244
+ if (!(error instanceof require_host_platform.InstanceNotFoundError)) continue;
245
+ }
246
+ if (await store.failUnadmittedEntry(entry.instanceId)) {
247
+ failed.push(entry.instanceId);
248
+ console.error(`[workflow] the start of ${entry.instanceId} (${entry.workflow}) was lost before its instance existed: marked failed, the next trigger re-enters`);
249
+ }
250
+ }
251
+ return failed;
252
+ }
253
+ /**
254
+ * How long after its admission an entry is left out of the lost-instance sample. No age proves
255
+ * anything about an admitted instance — it can end a moment after admitting itself, and a long
256
+ * wait runs for weeks — so this is not a judgment, only a filter: the freshest entries are the
257
+ * ones most likely to still be running, and the ones a platform status may not have settled
258
+ * for yet. Correctness rests on the lookup and the conditional update, not on the window.
259
+ */
260
+ const LOST_INSTANCE_AFTER_MS = 9e5;
261
+ /**
262
+ * Admitted entries one maintenance run looks up on the platform: a random sample (see
263
+ * `JourneyStore.admittedEntries`), so every entry is reached eventually however many are
264
+ * running, and the sweep's platform calls stay bounded.
265
+ */
266
+ const LOST_INSTANCE_BATCH = 50;
267
+ /**
268
+ * Instances that ended on the platform without finalizing their entry: terminated from outside
269
+ * (the dashboard, the API), errored for good because a finalize step kept failing, or no longer
270
+ * known to the runtime at all. The entry stays `running`, and as such would block re-entry for
271
+ * good. Only admitted entries are looked at — an unadmitted one is
272
+ * `failLostStarts`' — and only a terminal status, or not found, ends one: an admitted instance
273
+ * did reach the runtime, so not found now means it finished and was evicted (as `stopInstance`
274
+ * reads it). A lookup that fails otherwise proves nothing and leaves the entry alone. The update
275
+ * is conditional on the entry still running under the instance id, so a run that finalized
276
+ * between the read and the lookup keeps its own status.
277
+ *
278
+ * `complete` ends in `failed` too: the run's finalize step is what records the real outcome, and
279
+ * an instance complete with its entry still running went without it, so what the journey would
280
+ * have recorded is unknown. Platform-neutral: on AWS the adapter's own maintenance reconciles
281
+ * these too (both writes are idempotent), and its `status` reads running through a stop's
282
+ * drain, so nothing is failed here that the adapter would still wait for.
283
+ */
284
+ async function failLostInstances(env, store, now) {
285
+ const failed = [];
286
+ for (const entry of await store.admittedEntries(now - LOST_INSTANCE_AFTER_MS, LOST_INSTANCE_BATCH)) {
287
+ let status;
288
+ try {
289
+ const reported = await (await env.JOURNEY.get(entry.instanceId)).status?.();
290
+ if (reported === void 0 || !STOPPED_STATUSES.has(reported.status)) continue;
291
+ status = reported.status;
292
+ } catch (error) {
293
+ if (!(error instanceof require_host_platform.InstanceNotFoundError)) continue;
294
+ status = "not found";
295
+ }
296
+ if (!await store.failAdmittedEntry(entry.instanceId)) continue;
297
+ failed.push(entry.instanceId);
298
+ await store.unsubscribe(entry.instanceId);
299
+ await store.reporting.instanceFinished({
300
+ workflow: entry.workflow,
301
+ instanceId: entry.instanceId,
302
+ userId: entry.userId,
303
+ status: "failed",
304
+ at: now
305
+ });
306
+ console.error(`[workflow] ${entry.instanceId} (${entry.workflow}) ended on the platform (${status}) without finishing: marked failed, the next trigger re-enters`);
307
+ }
308
+ return failed;
309
+ }
310
+ /** How long a visitor who never signs in is kept after they were last heard from. */
311
+ const VISITOR_RETENTION_MS = 7776e6;
312
+ /** Visitors one sweep prunes: the next sweep goes on. */
313
+ const VISITOR_PRUNE_BATCH = 100;
314
+ /** How many users one sweep page evaluates: a unit of resumable work (AWS checkpoints each). */
315
+ const SWEEP_PAGE_SIZE = 500;
316
+ /**
317
+ * What the sweep does before it looks at any user: the runtime's own upkeep (AWS: unconfirmed
318
+ * starts, executions that ended unseen), the entries whose start or instance was lost, and the
319
+ * erasures left unfinished (an instance would not stop). A failure of any is logged, never
320
+ * fatal: the pages still run. Users whose erasure is still pending afterwards are skipped by
321
+ * every page (`sweepSegmentsPaged`).
322
+ */
323
+ async function sweepMaintenance(env, store) {
324
+ try {
325
+ await env.JOURNEY.maintain?.();
326
+ } catch (error) {
327
+ console.error("[workflow] runtime maintenance failed", error);
328
+ }
329
+ try {
330
+ await failLostStarts(env, store, Date.now());
331
+ } catch (error) {
332
+ console.error("[workflow] reclaiming lost starts failed", error);
333
+ }
334
+ try {
335
+ await failLostInstances(env, store, Date.now());
336
+ } catch (error) {
337
+ console.error("[workflow] reclaiming lost instances failed", error);
338
+ }
339
+ try {
340
+ await store.pruneVisitors(Date.now() - VISITOR_RETENTION_MS, VISITOR_PRUNE_BATCH);
341
+ } catch (error) {
342
+ console.error("[workflow] pruning idle visitors failed", error);
343
+ }
344
+ for (const userId of await store.pendingErasures()) try {
345
+ await eraseUser(env, userId, store, Date.now());
346
+ } catch (error) {
347
+ console.error(`[workflow] erasure of ${userId} failed`, error);
348
+ }
349
+ }
350
+ /**
351
+ * One page of the sweep: the next users (ascending, at most `limit`) the store says may have a
352
+ * membership to change, evaluated for those segments only. The pages are what makes the sweep
353
+ * resumable: `sweepSegmentPass` saves its place in the store after each one.
354
+ */
355
+ async function sweepSegmentsPaged(env, store, page) {
356
+ const now = page.now ?? Date.now();
357
+ const limit = page.limit ?? 500;
358
+ const segments = await store.listSegments();
359
+ const routes = await store.listSegmentTriggers();
360
+ const erasing = new Set(await store.pendingErasures());
361
+ const listed = await store.listSegmentCandidates({
362
+ segments,
363
+ now,
364
+ after: page.after,
365
+ limit
366
+ });
367
+ const lastUserId = listed.at(-1)?.userId;
368
+ if (page.after !== void 0 && lastUserId === page.after) throw new Error(`listSegmentCandidates did not advance past ${page.after}: the store ignores 'after'`);
369
+ const candidates = listed.filter(({ userId }) => !erasing.has(userId));
370
+ const started = [];
371
+ const definitions = new Map(segments.map((segment) => [segment.id, segment.condition]));
372
+ for (const { userId, segments: named } of candidates) {
373
+ const owed = routes.filter((route) => named.includes(route.segment));
374
+ try {
375
+ started.push(...await refreshSegments(env, store, userId, now, owed, named, definitions));
376
+ } catch (error) {
377
+ console.error(`[workflow] segment refresh for ${userId} failed`, error);
378
+ }
379
+ }
380
+ return {
381
+ evaluated: candidates.length,
382
+ started,
383
+ lastUserId,
384
+ more: listed.length >= limit
385
+ };
386
+ }
387
+ /** What a journey a date trigger started names as the event that started it. */
388
+ const DATE_TRIGGER_EVENT = "$date";
389
+ /**
390
+ * How long after its time a date trigger may still begin. A send that no sweep picked up for a
391
+ * day (the cron was off, the database down) is no longer the send that was scheduled: a Black
392
+ * Friday email on Sunday is worse than none. One that has begun runs to its end however long
393
+ * that takes.
394
+ */
395
+ const DATE_TRIGGER_GRACE_MS = 864e5;
396
+ /**
397
+ * How long one sweep spends on date triggers before it leaves the rest to the next one. A
398
+ * scheduled handler is not given unlimited time, and the fan-out is resumable by construction,
399
+ * so stopping early costs a sweep interval and running over costs the page in flight.
400
+ */
401
+ const DATE_FANOUT_BUDGET_MS = 3e4;
402
+ /** Journeys started at once within a page: instance creation is the slow part, and rate-limited. */
403
+ const DATE_FANOUT_CONCURRENCY = 8;
404
+ /**
405
+ * One page of the earliest date trigger that is due: the next users its filter may hold for, a
406
+ * journey started for each one it does. Undefined when nothing is due. `except` names the
407
+ * workflows to leave alone — those whose page failed earlier in this sweep, so that one trigger
408
+ * in trouble does not keep the others waiting behind it.
409
+ *
410
+ * The cursor is saved after the page, so a page cut off before that is done again — which starts
411
+ * nothing twice: the occurrence is the trigger's time, and the entry ledger holds one entry per
412
+ * (workflow, user, occurrence). A start that fails leaves the cursor where it was, for the same
413
+ * reason: the next sweep takes the page again and the ledger skips whoever already entered. That
414
+ * is kept up for the grace period; past it, a user whose start still fails is passed over, or
415
+ * one user nobody can start would hold the trigger, and every sweep, forever.
416
+ */
417
+ async function fanOutDatePage(env, store, now = Date.now(), limit = 500, except = []) {
418
+ const run = (await store.dueDateTriggers(now)).find((due) => !except.includes(due.workflow));
419
+ if (run === void 0) return void 0;
420
+ const { workflow, at } = run;
421
+ const overdue = now - at > DATE_TRIGGER_GRACE_MS;
422
+ if (run.after === void 0 && run.entered === 0 && overdue) {
423
+ console.warn(`[workflow] date trigger of '${workflow}' was due ${new Date(at).toISOString()} and no sweep ran it within a day: given up`);
424
+ await store.advanceDateRun(run, {
425
+ skipped: "missed",
426
+ now
427
+ });
428
+ return {
429
+ workflow,
430
+ at,
431
+ started: [],
432
+ finished: true,
433
+ failed: false
434
+ };
435
+ }
436
+ const candidates = await store.listDateCandidates({
437
+ filter: run.filter,
438
+ now,
439
+ after: run.after,
440
+ limit
441
+ });
442
+ const erasing = new Set(await store.pendingErasures());
443
+ const occurrence = `$date:${at}`;
444
+ const started = [];
445
+ let failed = false;
446
+ const enter = async ({ userId, certain }) => {
447
+ if (erasing.has(userId)) return;
448
+ try {
449
+ if (!certain && run.filter !== void 0) {
450
+ const facts = new require_store_facts.JourneyFactSource(store, userId);
451
+ if (!await require_engine_condition.evaluateCondition(run.filter, facts, now)) return;
452
+ }
453
+ const { instanceId } = await startJourney(env, store, run, userId, at, occurrence, {
454
+ event: DATE_TRIGGER_EVENT,
455
+ payload: {},
456
+ ts: at
457
+ });
458
+ if (instanceId !== null) started.push(instanceId);
459
+ } catch (error) {
460
+ if (error instanceof require_store_erasure.UserErasedError) return;
461
+ failed = true;
462
+ console.error(`[workflow] date trigger of '${workflow}': start for ${userId} failed`, error);
463
+ }
464
+ };
465
+ for (let i = 0; i < candidates.length; i += DATE_FANOUT_CONCURRENCY) await Promise.all(candidates.slice(i, i + DATE_FANOUT_CONCURRENCY).map(enter));
466
+ const kept = failed && !overdue;
467
+ if (failed && overdue) console.warn(`[workflow] date trigger of '${workflow}': still failing a day past its time, the users of this page it could not start are passed over`);
468
+ const last = candidates.at(-1)?.userId;
469
+ const finished = !kept && candidates.length < limit;
470
+ await store.advanceDateRun(run, {
471
+ after: kept ? void 0 : last,
472
+ entered: started.length,
473
+ finished,
474
+ now
475
+ });
476
+ if (!kept && !finished && last === run.after) throw new Error(`listDateCandidates did not advance past ${String(run.after)}`);
477
+ return {
478
+ workflow,
479
+ at,
480
+ started,
481
+ finished,
482
+ failed: kept
483
+ };
484
+ }
485
+ /**
486
+ * The date triggers that are due, page after page, until none is left or the budget is spent. A
487
+ * trigger whose page failed is left for the next sweep, and the others go on.
488
+ */
489
+ async function sweepDateTriggers(env, store, now = Date.now(), budgetMs = DATE_FANOUT_BUDGET_MS) {
490
+ const began = Date.now();
491
+ const started = [];
492
+ const byRun = /* @__PURE__ */ new Map();
493
+ const failed = [];
494
+ for (;;) {
495
+ const page = await fanOutDatePage(env, store, now, 500, failed);
496
+ if (page === void 0) break;
497
+ const key = `${page.workflow}@${page.at}`;
498
+ const fanout = byRun.get(key) ?? {
499
+ workflow: page.workflow,
500
+ at: page.at,
501
+ entered: 0,
502
+ finished: false
503
+ };
504
+ fanout.entered += page.started.length;
505
+ fanout.finished = page.finished;
506
+ byRun.set(key, fanout);
507
+ started.push(...page.started);
508
+ if (page.failed) failed.push(page.workflow);
509
+ if (Date.now() - began > budgetMs) break;
510
+ }
511
+ return {
512
+ started,
513
+ dates: [...byRun.values()]
514
+ };
515
+ }
516
+ /**
517
+ * How long one sweep spends on the segments before it leaves the rest of the pass to the next
518
+ * one. As for the date triggers: the handler a schedule calls is not given unlimited time, and
519
+ * the pass is kept in the store, so stopping early costs a sweep interval and nothing else.
520
+ */
521
+ const SWEEP_BUDGET_MS = 3e4;
522
+ /**
523
+ * The pass over the segments, from wherever the store says it is: page after page until every
524
+ * user has been gone through or `budgetMs` is spent (0: one page). The place is saved after each
525
+ * page (`sweep_pass`), so a sweep that is cut off — by the budget, a timeout, a deploy — costs
526
+ * the page in flight, and that page done again changes nothing: whoever it already recorded is
527
+ * no longer a candidate.
528
+ *
529
+ * The pass ends once, however many sweeps it took: the segments that were being seeded when it
530
+ * began are seeded (only a pass that began with them has been through every user for them),
531
+ * and the sizes are recorded. Two sweeps on one pass (an overlap, one called by hand) both do
532
+ * their page; the one whose place was moved under it stops there.
533
+ */
534
+ async function sweepSegmentPass(env, store, now = Date.now(), budgetMs = SWEEP_BUDGET_MS) {
535
+ const began = Date.now();
536
+ const pass = await store.openSweepPass(now);
537
+ let evaluated = 0;
538
+ const started = [];
539
+ for (;;) {
540
+ const page = await sweepSegmentsPaged(env, store, {
541
+ after: pass.after,
542
+ limit: 500,
543
+ now
544
+ });
545
+ evaluated += page.evaluated;
546
+ started.push(...page.started);
547
+ if (!page.more || page.lastUserId === void 0) break;
548
+ const progress = {
549
+ after: page.lastUserId,
550
+ evaluated: page.evaluated
551
+ };
552
+ if (!await store.advanceSweepPass(pass, progress)) return {
553
+ evaluated,
554
+ started,
555
+ sizes: [],
556
+ finished: false,
557
+ more: false
558
+ };
559
+ pass.after = page.lastUserId;
560
+ if (Date.now() - began >= budgetMs) return {
561
+ evaluated,
562
+ started,
563
+ sizes: [],
564
+ finished: false,
565
+ more: true
566
+ };
567
+ }
568
+ await store.finishSeeding(pass.seeding);
569
+ const sizes = await store.reporting.snapshotSegments(now);
570
+ await store.finishSweepPass(pass);
571
+ return {
572
+ evaluated,
573
+ started,
574
+ sizes,
575
+ finished: true,
576
+ more: false
577
+ };
578
+ }
579
+ /**
580
+ * The scheduled sweep: every deployed segment checked against every known user. The store narrows
581
+ * that down in one statement per page (`listSegmentCandidates`), so a sweep with nothing to change
582
+ * costs a few queries however many users there are, and the evaluator a journey's conditions run
583
+ * on decides each remaining case, so a member is exactly who a journey would see in it. Membership
584
+ * follows (joiners keep the time they joined, leavers are removed), segment triggers start the
585
+ * journeys of whoever entered by the clock alone, and the store records each segment's size.
586
+ * Before all that it starts the journeys of the date triggers that are due (`sweepDateTriggers`).
587
+ *
588
+ * One call spends a bounded time (`budgetMs` on the segments, `DATE_FANOUT_BUDGET_MS` on the
589
+ * date triggers) and both keep their place in the store, so an audience too large for one call
590
+ * is gone through by several: `finished` says whether the pass over the segments ended here.
591
+ */
592
+ async function sweepSegments(env, store, now = Date.now(), budgetMs = SWEEP_BUDGET_MS) {
593
+ await sweepMaintenance(env, store);
594
+ const dated = await sweepDateTriggers(env, store, now);
595
+ const pass = await sweepSegmentPass(env, store, now, budgetMs);
596
+ return {
597
+ evaluated: pass.evaluated,
598
+ started: [...dated.started, ...pass.started],
599
+ sizes: pass.sizes,
600
+ finished: pass.finished,
601
+ dates: dated.dates
602
+ };
603
+ }
604
+ /**
605
+ * Whether the occurrence's entry's start is known to have happened: the runner admitted
606
+ * itself, the entry already ended, or the runtime knows its instance and it has not ended. An
607
+ * unadmitted entry whose instance cannot be found, cannot be looked up right now, or ended without
608
+ * admitting itself is not; the caller asks again.
609
+ */
610
+ async function entryStarted(env, store, workflow, userId, occurrence) {
611
+ const entry = await store.getEntry(workflow, userId, occurrence);
612
+ if (entry === void 0 || entry.status === "failed") return false;
613
+ if (entry.admitted || entry.status !== "running") return true;
614
+ try {
615
+ return !await hasEnded(await env.JOURNEY.get(entry.instanceId));
616
+ } catch {
617
+ return false;
618
+ }
619
+ }
620
+ /**
621
+ * Create the instance, idempotently by id, on a runtime that does not record its starts
622
+ * (Cloudflare): a create the platform refuses because the id already exists — a concurrent
623
+ * retry of the same start won the race — is the instance we wanted, not a failure. Rolling the
624
+ * entry back over it would strand a running instance with no ledger row, and it would never be
625
+ * admitted. A create whose instance the runtime cannot find failed, and throws. One refused by
626
+ * an instance that already ended is `ended`: the id stays taken by that corpse for good, which
627
+ * will never admit itself — taking it for the start would leave a running entry nothing ever
628
+ * fails, and no retry of this create can ever succeed either.
629
+ */
630
+ async function createInstance(env, id, params) {
631
+ try {
632
+ await env.JOURNEY.create({
633
+ id,
634
+ params
635
+ });
636
+ return "created";
637
+ } catch (error) {
638
+ let ended;
639
+ try {
640
+ ended = await hasEnded(await env.JOURNEY.get(id));
641
+ } catch {
642
+ throw error;
643
+ }
644
+ return ended ? "ended" : "exists";
645
+ }
646
+ }
647
+ /**
648
+ * The occurrence's instance id is held by an instance that ended (terminated by hand, errored
649
+ * before it finalized its entry). The start is not owed any more: the platform will refuse the
650
+ * id forever, so throwing would fail every redelivery of the event the same way — a permanent
651
+ * 500 for the caller, and for a queue the whole batch retried into the dead letter queue with
652
+ * the events behind this one never stored. The entry records the failure and the caller goes on.
653
+ */
654
+ async function overDeadInstance(store, workflow, instanceId) {
655
+ await store.failUnadmittedEntry(instanceId);
656
+ console.warn(`[workflow] ${workflow}: instance ${instanceId} already ended, its occurrence is not started again`);
657
+ return {
658
+ instanceId: null,
659
+ outcome: "refused"
660
+ };
661
+ }
662
+ /**
663
+ * Create one journey instance behind the entry ledger, as the workflow's re-entry policy (carried
664
+ * on the route) allows. The store's attempt is atomic, so concurrent ingests cannot enter the
665
+ * same occurrence twice nor get past the policy together. An occurrence whose previous instance
666
+ * is recorded as 'failed' is reclaimed rather than lost over one outage.
667
+ */
668
+ async function startJourney(env, store, route, userId, ts, occurrence, trigger) {
669
+ const { workflow, hash, reentry, version } = route;
670
+ const instanceId = buildInstanceId(workflow, hash, userId, ts, occurrence);
671
+ const params = {
672
+ workflowId: workflow,
673
+ contentHash: hash,
674
+ userId,
675
+ trigger
676
+ };
677
+ const execution = await env.JOURNEY.plan?.({
678
+ id: instanceId,
679
+ params,
680
+ ts,
681
+ version
682
+ });
683
+ const outcome = await store.enterJourney({
684
+ workflow,
685
+ userId,
686
+ instanceId,
687
+ hash,
688
+ ts,
689
+ occurrence,
690
+ reentry,
691
+ execution
692
+ });
693
+ if (outcome === "refused") return {
694
+ instanceId: null,
695
+ outcome: "refused"
696
+ };
697
+ if (outcome === "duplicate") {
698
+ if (env.JOURNEY.resume !== void 0) {
699
+ await env.JOURNEY.resume({
700
+ workflow,
701
+ userId
702
+ });
703
+ return {
704
+ instanceId: null,
705
+ outcome: "duplicate"
706
+ };
707
+ }
708
+ const entry = await store.getEntry(workflow, userId, occurrence);
709
+ if (entry?.instanceId !== instanceId || entry.status !== "running" || entry.admitted) return {
710
+ instanceId: null,
711
+ outcome: "duplicate"
712
+ };
713
+ const created = await createInstance(env, instanceId, params);
714
+ if (created === "ended") return overDeadInstance(store, workflow, instanceId);
715
+ return created === "created" ? {
716
+ instanceId,
717
+ outcome: "started"
718
+ } : {
719
+ instanceId: null,
720
+ outcome: "duplicate"
721
+ };
722
+ }
723
+ try {
724
+ if (execution !== void 0) await env.JOURNEY.create({
725
+ id: instanceId,
726
+ params
727
+ });
728
+ else if (await createInstance(env, instanceId, params) === "ended") return await overDeadInstance(store, workflow, instanceId);
729
+ } catch (error) {
730
+ if (execution !== void 0) throw error;
731
+ if (outcome === "reclaimed") await store.setEntryStatus(instanceId, "failed");
732
+ else await store.removeEntry(instanceId);
733
+ throw error;
734
+ }
735
+ return {
736
+ instanceId,
737
+ outcome: "started"
738
+ };
739
+ }
740
+ const utf8 = new TextEncoder();
741
+ /**
742
+ * Instance id: addressable (the host gets it directly to wake it), ≤100
743
+ * chars, legal charset. The murmur3 fingerprints keep ids distinct when the
744
+ * sanitized/truncated userId alone would collide, and tell apart two entries
745
+ * of one user made at the same ts by different occurrences (re-entry). The
746
+ * same occurrence always yields the same id: a retried start is idempotent on
747
+ * the platform too.
748
+ *
749
+ * The workflow id is the author's (`checkout.recovery`, `onboarding/v2`), so it is sanitized
750
+ * like the user id: Cloudflare takes only `^[a-zA-Z0-9_][a-zA-Z0-9-_]*$` and answers anything
751
+ * else `instance.invalid_id` on every start. The hash that follows keeps two workflows whose
752
+ * ids sanitize alike apart.
753
+ */
754
+ function buildInstanceId(workflow, hash, userId, ts, occurrence) {
755
+ const uid = userId.replace(/[^a-zA-Z0-9_-]/g, "-").slice(0, 24);
756
+ const fingerprint = require_engine_bucket.murmur3(utf8.encode(userId)).toString(36);
757
+ const occurrenceFingerprint = require_engine_bucket.murmur3(utf8.encode(occurrence)).toString(36);
758
+ return `${workflow.slice(0, 32).replace(/[^a-zA-Z0-9_-]/g, "-").replace(/^-/, "_")}-${hash.slice(0, 8)}-${uid}-${fingerprint}-${ts.toString(36)}-${occurrenceFingerprint}`;
759
+ }
760
+ /**
761
+ * Merge-patch profile properties (a null removes one), then wake property waits
762
+ * and re-evaluate segment triggers. The merge is one statement in the store, so
763
+ * two identifies landing together cannot lose each other's fields.
764
+ */
765
+ async function identifyUser(env, userId, props, store, at) {
766
+ await refuseIfErased(store, userId);
767
+ const ts = Date.now();
768
+ return {
769
+ ok: true,
770
+ props: await store.mergeProfile(userId, props, at ?? ts),
771
+ woke: await wakeSubscribers(env, store, userId, Object.keys(props).map(require_engine_condition.profileUpdatedEvent)),
772
+ started: await refreshSegmentTriggers(env, store, userId, ts)
773
+ };
774
+ }
775
+ /**
776
+ * The visitor signed in as the user: what the engine knows of them moves to the user, once. Their
777
+ * journeys carry on as the user's (`instanceOwner`), except one the user is already in, which
778
+ * stops. Answers nothing to do when already linked: every signed-in batch names its visitor.
779
+ */
780
+ async function linkVisitor(env, visitorId, userId, store, at = Date.now()) {
781
+ await refuseIfErased(store, userId);
782
+ const linked = await store.linkedUser(visitorId);
783
+ if (linked !== void 0) {
784
+ if (linked !== userId) console.warn(`[workflow] visitor ${visitorId} stays with its first user, not ${userId}`);
785
+ return;
786
+ }
787
+ const merge = await store.linkVisitor(visitorId, userId, at);
788
+ if (merge === null) return;
789
+ for (const instanceId of merge.dropped) await stopInstance(env, instanceId);
790
+ await wakeSubscribers(env, store, userId, [
791
+ require_engine_condition.DEVICES_UPDATED_EVENT,
792
+ ...merge.events,
793
+ ...merge.props.map(require_engine_condition.profileUpdatedEvent)
794
+ ]);
795
+ await refreshSegmentTriggers(env, store, userId, at);
796
+ }
797
+ /**
798
+ * A push token registered for its current owner: the user, or before sign-in the visitor. The
799
+ * device holds only that, so a token moves to whoever registered it last. Wakes the waits that read
800
+ * devices (`reachable('push')` inside `waitUntil`), for the new owner and the previous one.
801
+ */
802
+ async function registerDevice(env, device, store) {
803
+ const { deviceId, userId, visitorId, token, platform } = device;
804
+ if (userId !== void 0 && visitorId !== void 0) await linkVisitor(env, visitorId, userId, store);
805
+ const subject = userId ?? await store.touchVisitor(visitorId ?? "", Date.now());
806
+ await refuseIfErased(store, subject);
807
+ const previous = await store.upsertDevice({
808
+ deviceId,
809
+ userId: require_store_identity.isVisitorSubject(subject) ? null : subject,
810
+ visitorId,
811
+ token,
812
+ platform,
813
+ at: Date.now()
814
+ });
815
+ let woke = await wakeSubscribers(env, store, subject, [require_engine_condition.DEVICES_UPDATED_EVENT]);
816
+ for (const owner of previous) woke += await wakeSubscribers(env, store, owner, [require_engine_condition.DEVICES_UPDATED_EVENT]);
817
+ return {
818
+ ok: true,
819
+ woke
820
+ };
821
+ }
822
+ /** Workflow instance states that will never run another step. */
823
+ const STOPPED_STATUSES = /* @__PURE__ */ new Set([
824
+ "complete",
825
+ "errored",
826
+ "terminated"
827
+ ]);
828
+ /** Whether the instance reports a terminal state. An unreadable status says nothing: false. */
829
+ async function hasEnded(instance) {
830
+ const status = await instance.status?.().catch(() => void 0);
831
+ return status !== void 0 && STOPPED_STATUSES.has(status.status);
832
+ }
833
+ /**
834
+ * Stop one admitted instance for good; true once it is known not to run again: terminated, or
835
+ * already in a terminal state (terminate refuses those). Any other failure is not taken for
836
+ * "already gone": it answers false, and the erasure waits for a retry.
837
+ *
838
+ * An admitted instance the platform no longer knows counts as stopped too — but only an
839
+ * admitted one. Admission is the runner's first act, so an admitted instance did reach the
840
+ * runtime: not found now means it finished and was evicted. An entry that is not admitted is
841
+ * never passed here: for it, not found may just as well mean its `create` is still in flight.
842
+ */
843
+ async function stopInstance(env, instanceId) {
844
+ let instance;
845
+ try {
846
+ instance = await env.JOURNEY.get(instanceId);
847
+ } catch (error) {
848
+ if (error instanceof require_host_platform.InstanceNotFoundError) return true;
849
+ console.warn(`[workflow] looking up ${instanceId} to stop it failed`, error);
850
+ return false;
851
+ }
852
+ if (instance.terminate === void 0) return false;
853
+ try {
854
+ await instance.terminate();
855
+ return true;
856
+ } catch (error) {
857
+ if (await hasEnded(instance)) return true;
858
+ console.warn(`[workflow] terminating ${instanceId} failed`, error);
859
+ return false;
860
+ }
861
+ }
862
+ /**
863
+ * Carry out a recorded erasure: stop every running instance of the user, and only once all are
864
+ * known not to run erase their data. The tombstone is already committed, so no new entry,
865
+ * event, profile or device of theirs lands meanwhile.
866
+ *
867
+ * An entry's runner admits itself before its first effect (`admitInstance`, mutually exclusive
868
+ * with the tombstone's commit), which splits the running instances in two:
869
+ *
870
+ * - not admitted: nothing of it has run, and nothing will — a `create` still in flight, or a
871
+ * runner invoked later, meets the tombstone at admission and exits. No stop is needed, and
872
+ * none would be reliable: the platform may not know the instance yet.
873
+ * - admitted: it did reach the runtime and must be stopped (`stopInstance`), or it would write
874
+ * rows back after the erase. One that will not stop leaves the erasure pending.
875
+ *
876
+ * Erasing nothing until then keeps the entries that name the instances still to stop, so a
877
+ * retry can finish the job. The tombstone outlives the erase (`erased_at`), which is what makes
878
+ * a repeat idempotent and a late write harmless. There is no straggler to come back for: every
879
+ * write about a user runs in the user's locked transaction, the same lock the tombstone takes,
880
+ * so a write either committed before the tombstone — and `forgetUser` deletes it here — or
881
+ * waited for the lock and is refused by the tombstone it then sees.
882
+ */
883
+ async function eraseUser(env, userId, store, now) {
884
+ const pending = [];
885
+ for (const { instanceId, admitted } of await store.runningInstances(userId)) {
886
+ if (!admitted) continue;
887
+ if (!await stopInstance(env, instanceId)) pending.push(instanceId);
888
+ }
889
+ if (pending.length > 0) return {
890
+ erased: false,
891
+ pending
892
+ };
893
+ await store.forgetUser(userId, now);
894
+ return {
895
+ erased: true,
896
+ pending
897
+ };
898
+ }
899
+ /**
900
+ * Forget a user (a deleted account): the tombstone is committed first, then the erasure carried
901
+ * out. `erased: true` means every admitted runner of theirs was confirmed stopped, the entries
902
+ * never admitted can never run, and the data is deleted — for good, with no time window and no
903
+ * second pass: the tombstone commits under the user's lock, which every write about the user
904
+ * also takes, so nothing of theirs can land after it. An admitted instance that will not stop
905
+ * leaves it pending — nothing erased yet — and the scheduled sweep retries it; `erased: false`
906
+ * says so. A user already erased answers `erased: true` again, with nothing to do.
907
+ */
908
+ async function forgetUser(env, userId, store, now = Date.now()) {
909
+ await store.requestErasure(userId, now);
910
+ return {
911
+ ok: true,
912
+ ...await eraseUser(env, userId, store, now)
913
+ };
914
+ }
915
+ /**
916
+ * The user signed out on the device: the token stays registered, bound to nobody, so the next
917
+ * sign-in only has to bind it again. Wakes the former owner's device waits (`reachable('push')`
918
+ * may no longer hold).
919
+ */
920
+ async function unbindDevice(env, token, store) {
921
+ const owner = await store.unbindDevice(token);
922
+ return {
923
+ ok: true,
924
+ woke: owner === void 0 ? 0 : await wakeSubscribers(env, store, owner, [require_engine_condition.DEVICES_UPDATED_EVENT])
925
+ };
926
+ }
927
+ /** A push token forgotten for good (the push service reports it gone); wakes its owner's device waits. */
928
+ async function removeDevice(env, token, store) {
929
+ const owner = await store.removeDevice(token);
930
+ return {
931
+ ok: true,
932
+ woke: owner === void 0 ? 0 : await wakeSubscribers(env, store, owner, [require_engine_condition.DEVICES_UPDATED_EVENT])
933
+ };
934
+ }
935
+ /** A deploy refused because the bundle would break journeys still running: see `problems`. */
936
+ var InFlightError = class extends Error {
937
+ problems;
938
+ name = "InFlightError";
939
+ constructor(problems) {
940
+ const journeys = new Set(problems.map((p) => `${p.workflow}@${p.contentHash}`)).size;
941
+ super(`the bundle would break in-flight journeys on ${journeys} pinned ${journeys === 1 ? "version" : "versions"}: ${require_inflight.describeInFlight(problems).join(" | ")}`);
942
+ this.problems = problems;
943
+ }
944
+ };
945
+ /** A bundle whose declared hashes do not describe its contents — rejected before anything is written. */
946
+ var BundleIntegrityError = class extends Error {
947
+ constructor(message) {
948
+ super(message);
949
+ this.name = "BundleIntegrityError";
950
+ }
951
+ };
952
+ /**
953
+ * Recompute every declared contentHash and refuse the bundle if one disagrees.
954
+ *
955
+ * The contentHash is the address an in-flight journey reads its IR from, so
956
+ * a hash that does not describe its own content is a way to change what a
957
+ * pinned instance executes: submit an edited flow under the old hash and the
958
+ * next replay picks it up. The compiler always computes the hash it ships, so
959
+ * a mismatch means a hand-rolled payload or a stale client — neither should be
960
+ * able to overwrite a version that journeys are running.
961
+ *
962
+ * Each hash is recomputed exactly the way its compiler produced it: a workflow
963
+ * hashes its whole IR (contentHash strips itself), a segment hashes only its
964
+ * condition. Mirroring them is load-bearing — recomputing a segment over the
965
+ * whole record would reject every honest deploy.
966
+ */
967
+ function verifyBundleHashes(parsed) {
968
+ const mismatched = [];
969
+ for (const workflow of parsed.workflows) if (require_hash.semanticHash(workflow) !== workflow.contentHash) mismatched.push(`workflow '${workflow.id}'`);
970
+ for (const segment of parsed.segments) if (require_hash.semanticHash(segment.condition) !== segment.contentHash) mismatched.push(`segment '${segment.id}'`);
971
+ if (mismatched.length > 0) throw new BundleIntegrityError(`contentHash does not match content for ${mismatched.join(", ")} — recompile the bundle instead of editing it by hand`);
972
+ }
973
+ /**
974
+ * Bundle deploy, terraform-apply style: workflow bodies first (content-addressed, so a failed
975
+ * deploy leaves only harmless orphans), then the routing swap. With a `version` the swap happens
976
+ * only over an older live version (`replaceRoutesIfNewer`) — how journeyWorker applies the bundle
977
+ * compiled into it — unless `force` is set: then it happens whatever is live, and the version is
978
+ * recorded as live (`POST /bundle/deploy`). Without a version it is forced and records nothing
979
+ * (`POST /deploy`, a hand-posted bundle).
980
+ *
981
+ * Before any write, the bundle is held against the journeys still running (`checkInFlight`): one
982
+ * that removes a segment or action a pinned IR names, or — with the `config` — a template a pinned
983
+ * message can no longer be sent with, is refused with `InFlightError`, unless `breakInFlight` says
984
+ * to deploy anyway (the refusal is a deploy-time guard; see README "Versioning" for why nothing is
985
+ * pinned beyond the IR). On Cloudflare a published version's code serves at once, and whether a
986
+ * running instance resumes on the version it started on is not documented, so the place to run
987
+ * the same check is before publishing: `sendwend-studio plan`.
988
+ */
989
+ async function deployBundle(env, bundle, store, { version, force = false, config, breakInFlight = false } = {}) {
990
+ const parsed = require_ir.BundleIR.parse(bundle);
991
+ verifyBundleHashes(parsed);
992
+ const problems = await store.checkSchema();
993
+ if (problems.length > 0) throw new require_store_index.SchemaMismatchError(problems);
994
+ const inFlight = require_inflight.checkInFlight(await require_inflight.pinnedWorkflows(store), parsed, config);
995
+ if (inFlight.length > 0 && !breakInFlight) throw new InFlightError(inFlight);
996
+ for (const workflow of parsed.workflows) await store.putWorkflowIR(workflow);
997
+ let applied = true;
998
+ if (version === void 0 || force) await store.replaceRoutes(parsed, version);
999
+ else applied = await store.replaceRoutesIfNewer(parsed, version);
1000
+ const unrouted = parsed.workflows.filter((workflow) => workflow.trigger.type === "webhook").map((workflow) => ({
1001
+ workflow: workflow.id,
1002
+ trigger: workflow.trigger.type
1003
+ }));
1004
+ return {
1005
+ workflows: parsed.workflows.map((w) => `${w.id}@${w.contentHash.slice(0, 8)}`),
1006
+ unrouted,
1007
+ applied,
1008
+ inFlight
1009
+ };
1010
+ }
1011
+ /** The channels a user opts out of per topic: `suppression` rows are keyed by (user, channel, topic). */
1012
+ const SUBSCRIPTION_CHANNELS = ["email", "push"];
1013
+ /**
1014
+ * A subscriptions patch as it arrives over HTTP: untrusted JSON, read field by field and never
1015
+ * cast. Every topic must be one the bundle declares — the engine's list, not the caller's word.
1016
+ */
1017
+ function parseSubscriptionsPatch(body, topics) {
1018
+ const issues = [];
1019
+ const object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1020
+ if (!object(body)) return {
1021
+ ok: false,
1022
+ issues: [{
1023
+ path: "",
1024
+ message: "must be an object"
1025
+ }]
1026
+ };
1027
+ const known = new Set(topics);
1028
+ const patch = {};
1029
+ for (const [channel, value] of Object.entries(body)) {
1030
+ if (!SUBSCRIPTION_CHANNELS.includes(channel)) {
1031
+ issues.push({
1032
+ path: channel,
1033
+ message: "not a subscription channel"
1034
+ });
1035
+ continue;
1036
+ }
1037
+ if (!object(value)) {
1038
+ issues.push({
1039
+ path: channel,
1040
+ message: "must be an object"
1041
+ });
1042
+ continue;
1043
+ }
1044
+ const part = {};
1045
+ for (const [field, setting] of Object.entries(value)) if (field === "all") {
1046
+ if (typeof setting === "boolean") part.all = setting;
1047
+ else issues.push({
1048
+ path: `${channel}.all`,
1049
+ message: "must be a boolean"
1050
+ });
1051
+ } else if (field === "topics") {
1052
+ if (!object(setting)) {
1053
+ issues.push({
1054
+ path: `${channel}.topics`,
1055
+ message: "must be an object"
1056
+ });
1057
+ continue;
1058
+ }
1059
+ const chosen = {};
1060
+ for (const [topic, subscribed] of Object.entries(setting)) if (!known.has(topic)) issues.push({
1061
+ path: `${channel}.topics.${topic}`,
1062
+ message: "not a declared topic"
1063
+ });
1064
+ else if (typeof subscribed !== "boolean") issues.push({
1065
+ path: `${channel}.topics.${topic}`,
1066
+ message: "must be a boolean"
1067
+ });
1068
+ else chosen[topic] = subscribed;
1069
+ part.topics = chosen;
1070
+ } else issues.push({
1071
+ path: `${channel}.${field}`,
1072
+ message: "unknown field"
1073
+ });
1074
+ patch[channel] = part;
1075
+ }
1076
+ return issues.length > 0 ? {
1077
+ ok: false,
1078
+ issues
1079
+ } : {
1080
+ ok: true,
1081
+ patch
1082
+ };
1083
+ }
1084
+ async function readSubscriptions(store, userId, topics) {
1085
+ const read = async (channel) => {
1086
+ const suppressed = new Set(await store.listSuppressions(userId, channel));
1087
+ return {
1088
+ all: !suppressed.has(null),
1089
+ topics: Object.fromEntries(topics.map((topic) => [topic, !suppressed.has(topic)]))
1090
+ };
1091
+ };
1092
+ return {
1093
+ email: await read("email"),
1094
+ push: await read("push")
1095
+ };
1096
+ }
1097
+ /** The user's subscriptions over the declared `topics`; a user with an erasure tombstone is refused. */
1098
+ async function getSubscriptions(store, userId, topics) {
1099
+ await refuseIfErased(store, userId);
1100
+ return readSubscriptions(store, userId, topics);
1101
+ }
1102
+ /**
1103
+ * Apply a patch — each field given sets or clears the matching opt-out, one transaction per
1104
+ * channel — and answer the subscriptions as they now stand. A change of a channel's `all` is a
1105
+ * change of its reachability, so the waits reading it wake, both ways: an
1106
+ * `exitWhen: not(reachable('email'))` fires on the opt-out, and a wait for the channel to become
1107
+ * reachable resumes on the opt-in. Email waits key on the address property, push waits on the
1108
+ * device channel (`reachable('push')` subscribes to device changes).
1109
+ */
1110
+ async function setSubscriptions(env, store, userId, patch, topics, now = Date.now()) {
1111
+ await refuseIfErased(store, userId);
1112
+ for (const channel of SUBSCRIPTION_CHANNELS) {
1113
+ const part = patch[channel];
1114
+ if (part === void 0) continue;
1115
+ const changes = [];
1116
+ if (part.all !== void 0) changes.push({
1117
+ topic: null,
1118
+ suppressed: !part.all
1119
+ });
1120
+ for (const [topic, subscribed] of Object.entries(part.topics ?? {})) if (subscribed !== void 0) changes.push({
1121
+ topic,
1122
+ suppressed: !subscribed
1123
+ });
1124
+ if (changes.length === 0) continue;
1125
+ await store.updateSuppressions(userId, channel, changes, now);
1126
+ if (part.all !== void 0) await wakeSubscribers(env, store, userId, [channel === "push" ? require_engine_condition.DEVICES_UPDATED_EVENT : require_engine_condition.profileUpdatedEvent(require_engine_recipient.RECIPIENT_PROPERTY.email ?? "email")]);
1127
+ }
1128
+ return readSubscriptions(store, userId, topics);
1129
+ }
1130
+ /**
1131
+ * The recipient of a topic copy, by the copy's id. The id is the capability: a UUID nobody can
1132
+ * guess, the same trust `/t/u/<message>` runs on. Undefined — a 404 — for an id that names no
1133
+ * copy (never sent, or erased with its user by `forgetUser`), and for a transactional one, which
1134
+ * has nothing to opt out of; the same rule as `/t/u`. A push copy's `push_<platform>` channel
1135
+ * reads as `push`, the channel its subscriptions are keyed on.
1136
+ */
1137
+ async function resolveMessageOwner(store, messageId) {
1138
+ if (!require_reporting_tracking.isMessageId(messageId)) return void 0;
1139
+ const found = await store.reporting.lookupMessage(messageId);
1140
+ if (found === void 0) return void 0;
1141
+ const { userId, topic } = found;
1142
+ if (topic === null) return void 0;
1143
+ const channel = found.channel === "email" ? "email" : found.channel.startsWith("push") ? "push" : void 0;
1144
+ if (channel === void 0) return void 0;
1145
+ return {
1146
+ userId,
1147
+ message: {
1148
+ channel,
1149
+ topic
1150
+ }
1151
+ };
1152
+ }
1153
+ /** `getSubscriptions` for the copy's recipient, with the copy's channel and topic; undefined when `resolveMessageOwner` is. */
1154
+ async function getSubscriptionsByMessage(store, messageId, topics) {
1155
+ const owner = await resolveMessageOwner(store, messageId);
1156
+ if (owner === void 0) return void 0;
1157
+ return {
1158
+ ...await getSubscriptions(store, owner.userId, topics),
1159
+ message: owner.message
1160
+ };
1161
+ }
1162
+ /** `setSubscriptions` for the copy's recipient, answering as `getSubscriptionsByMessage` does; undefined when `resolveMessageOwner` is. */
1163
+ async function setSubscriptionsByMessage(env, store, messageId, patch, topics, now = Date.now()) {
1164
+ const owner = await resolveMessageOwner(store, messageId);
1165
+ if (owner === void 0) return void 0;
1166
+ return {
1167
+ ...await setSubscriptions(env, store, owner.userId, patch, topics, now),
1168
+ message: owner.message
1169
+ };
1170
+ }
1171
+ exports.BundleIntegrityError = BundleIntegrityError;
1172
+ exports.DATE_FANOUT_BUDGET_MS = DATE_FANOUT_BUDGET_MS;
1173
+ exports.DATE_TRIGGER_EVENT = DATE_TRIGGER_EVENT;
1174
+ exports.DATE_TRIGGER_GRACE_MS = DATE_TRIGGER_GRACE_MS;
1175
+ exports.EventPayloadTooLargeError = EventPayloadTooLargeError;
1176
+ exports.InFlightError = InFlightError;
1177
+ exports.LOST_INSTANCE_AFTER_MS = LOST_INSTANCE_AFTER_MS;
1178
+ exports.LOST_START_AFTER_MS = LOST_START_AFTER_MS;
1179
+ exports.MAX_EVENT_PAYLOAD_BYTES = MAX_EVENT_PAYLOAD_BYTES;
1180
+ exports.SUBSCRIPTION_CHANNELS = SUBSCRIPTION_CHANNELS;
1181
+ exports.SWEEP_BUDGET_MS = SWEEP_BUDGET_MS;
1182
+ exports.SWEEP_PAGE_SIZE = SWEEP_PAGE_SIZE;
1183
+ exports.VISITOR_RETENTION_MS = VISITOR_RETENTION_MS;
1184
+ exports.deployBundle = deployBundle;
1185
+ exports.failLostInstances = failLostInstances;
1186
+ exports.failLostStarts = failLostStarts;
1187
+ exports.fanOutDatePage = fanOutDatePage;
1188
+ exports.forgetUser = forgetUser;
1189
+ exports.getSubscriptions = getSubscriptions;
1190
+ exports.getSubscriptionsByMessage = getSubscriptionsByMessage;
1191
+ exports.identifyUser = identifyUser;
1192
+ exports.ingestEvent = ingestEvent;
1193
+ exports.linkVisitor = linkVisitor;
1194
+ exports.parseSubscriptionsPatch = parseSubscriptionsPatch;
1195
+ exports.payloadSizeError = payloadSizeError;
1196
+ exports.refreshSegmentTriggers = refreshSegmentTriggers;
1197
+ exports.registerDevice = registerDevice;
1198
+ exports.removeDevice = removeDevice;
1199
+ exports.resolveMessageOwner = resolveMessageOwner;
1200
+ exports.setSubscriptions = setSubscriptions;
1201
+ exports.setSubscriptionsByMessage = setSubscriptionsByMessage;
1202
+ exports.sweepDateTriggers = sweepDateTriggers;
1203
+ exports.sweepMaintenance = sweepMaintenance;
1204
+ exports.sweepSegmentPass = sweepSegmentPass;
1205
+ exports.sweepSegments = sweepSegments;
1206
+ exports.sweepSegmentsPaged = sweepSegmentsPaged;
1207
+ exports.unbindDevice = unbindDevice;
1208
+ exports.wakeSubscribers = wakeSubscribers;
1209
+
1210
+ //# sourceMappingURL=ingest.cjs.map