sendwend 0.0.1 → 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 (684) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2065 -22
  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 +270 -31
  680. package/src/cloudflare/workers.d.ts +44 -0
  681. package/index.cjs +0 -18
  682. package/index.d.cts +0 -4
  683. package/index.d.mts +0 -4
  684. package/index.mjs +0 -1
@@ -0,0 +1,150 @@
1
+ // src/engine/time-scale.ts
2
+ /**
3
+ * Debug time scale: divide every duration in a workflow's IR by a factor so a
4
+ * journey written in days plays out in seconds — with a factor of 3600, a
5
+ * `delay('2 days')` sleeps 48 s, a `waitUntil(..., { timeout: '3 days' })`
6
+ * gives up after 72 s, and a goal `within: '30 days'` closes after 12 min.
7
+ *
8
+ * Everything that is a Duration scales together (delays, random delays, wait
9
+ * timeouts, goal and `performed(... within)` windows inside the workflow), so
10
+ * the journey keeps its shape, just faster. Wall-clock `timeWindow`s cannot
11
+ * scale (they are times of day, not durations), so a scaled flow drops them:
12
+ * a rehearsal reaching a 09:00 window at night would otherwise sleep real hours
13
+ * in a journey that runs in seconds. The other nodes keep their ids, so step
14
+ * names stay put. Segment definitions
15
+ * and trigger routes live in the store rather than the workflow body;
16
+ * `scaleSegmentWindows` scales them as they are read — one segment for an
17
+ * event-driven evaluation, all of them for the scheduled sweep, a route's
18
+ * profile gate at ingest — so a segment's `within` keeps pace everywhere.
19
+ *
20
+ * The walk follows the IR's own structure — the fields that hold a Duration
21
+ * are known — so a message prop or an event payload that happens to look like
22
+ * one (`{ value, ms }`) is left alone. The source text is kept so the studio
23
+ * still shows what was written.
24
+ */
25
+ function scaleDurations(ir, factor) {
26
+ if (!(factor > 0) || factor === 1) return ir;
27
+ return {
28
+ ...ir,
29
+ trigger: ir.trigger.type === "event" ? {
30
+ ...ir.trigger,
31
+ ...ir.trigger.filter === void 0 ? {} : { filter: scaleCondition(ir.trigger.filter, factor) }
32
+ } : ir.trigger,
33
+ ...ir.goal === void 0 ? {} : { goal: {
34
+ ...ir.goal,
35
+ condition: scaleCondition(ir.goal.condition, factor),
36
+ ...ir.goal.within === void 0 ? {} : { within: scale(ir.goal.within, factor) }
37
+ } },
38
+ ...ir.exitWhen === void 0 ? {} : { exitWhen: scaleCondition(ir.exitWhen, factor) },
39
+ flow: scaleFlow(ir.flow, factor)
40
+ };
41
+ }
42
+ /** A condition with its `performed(... within)` windows divided by `factor`. */
43
+ function scaleCondition(condition, factor) {
44
+ if (!(factor > 0) || factor === 1) return condition;
45
+ switch (condition.type) {
46
+ case "and":
47
+ case "or": return {
48
+ ...condition,
49
+ conditions: condition.conditions.map((child) => scaleCondition(child, factor))
50
+ };
51
+ case "not": return {
52
+ ...condition,
53
+ condition: scaleCondition(condition.condition, factor)
54
+ };
55
+ case "performed": return condition.within === void 0 ? condition : {
56
+ ...condition,
57
+ within: scale(condition.within, factor)
58
+ };
59
+ default: return condition;
60
+ }
61
+ }
62
+ function scaleFlow(nodes, factor) {
63
+ return nodes.flatMap((node) => node.type === "time_window" ? [] : [scaleNode(node, factor)]);
64
+ }
65
+ function scaleNode(node, factor) {
66
+ switch (node.type) {
67
+ case "delay": return {
68
+ ...node,
69
+ duration: scale(node.duration, factor)
70
+ };
71
+ case "random_delay": return {
72
+ ...node,
73
+ min: scale(node.min, factor),
74
+ max: scale(node.max, factor)
75
+ };
76
+ case "wait_until": return {
77
+ ...node,
78
+ condition: scaleCondition(node.condition, factor),
79
+ timeout: scale(node.timeout, factor),
80
+ onTimeout: Array.isArray(node.onTimeout) ? scaleFlow(node.onTimeout, factor) : node.onTimeout
81
+ };
82
+ case "branch": return {
83
+ ...node,
84
+ cases: node.cases.map((branch) => ({
85
+ ...branch,
86
+ condition: scaleCondition(branch.condition, factor),
87
+ flow: scaleFlow(branch.flow, factor)
88
+ })),
89
+ ...node.otherwise === void 0 ? {} : { otherwise: scaleFlow(node.otherwise, factor) }
90
+ };
91
+ case "filter": return {
92
+ ...node,
93
+ condition: scaleCondition(node.condition, factor)
94
+ };
95
+ case "cohort": return {
96
+ ...node,
97
+ arms: node.arms.map((arm) => ({
98
+ ...arm,
99
+ flow: scaleFlow(arm.flow, factor)
100
+ }))
101
+ };
102
+ default: return node;
103
+ }
104
+ }
105
+ function scale(duration, factor) {
106
+ return {
107
+ value: duration.value,
108
+ ms: Math.max(0, Math.round(duration.ms / factor))
109
+ };
110
+ }
111
+ /**
112
+ * A store whose segment definitions come back scaled by `factor` — what the journey host leases
113
+ * in fast-forward, so a segment's windows (`performed(e.login, { within: '7 days' })`) shrink
114
+ * with the journeys that reference it, and with the segment triggers it routes. Every read that
115
+ * hands out a stored condition is scaled: `getSegmentCondition` (event-driven evaluation),
116
+ * `listSegments` (the scheduled sweep, which narrows candidates in SQL and evaluates with those
117
+ * definitions) and `findTriggers` (the profile gate an event trigger checks before it starts a
118
+ * journey, which `scaleDurations` scales inside the journey too). Every other method is the
119
+ * store's own.
120
+ */
121
+ function scaleSegmentWindows(store, factor) {
122
+ if (!(factor > 0) || factor === 1) return store;
123
+ return new Proxy(store, { get(target, property) {
124
+ const value = Reflect.get(target, property, target);
125
+ if (typeof value !== "function") return value;
126
+ switch (property) {
127
+ case "getSegmentCondition": return async (name) => {
128
+ const condition = await target.getSegmentCondition(name);
129
+ return condition === void 0 ? void 0 : scaleCondition(condition, factor);
130
+ };
131
+ case "listSegments": return async () => {
132
+ return (await value.call(target)).map(({ id, condition }) => ({
133
+ id,
134
+ condition: scaleCondition(condition, factor)
135
+ }));
136
+ };
137
+ case "findTriggers": return async (event) => {
138
+ const scaled = (route) => ({
139
+ ...route,
140
+ filter: route.filter === null ? null : scaleCondition(route.filter, factor)
141
+ });
142
+ return (await value.call(target, event)).map(scaled);
143
+ };
144
+ default: return value.bind(target);
145
+ }
146
+ } });
147
+ }
148
+ export { scaleCondition, scaleDurations, scaleSegmentWindows };
149
+
150
+ //# sourceMappingURL=time-scale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-scale.mjs","names":[],"sources":["../../src/engine/time-scale.ts"],"sourcesContent":["import type { ConditionIR, DurationIR, NodeIR, WorkflowIR } from '../ir';\n\n/**\n * Debug time scale: divide every duration in a workflow's IR by a factor so a\n * journey written in days plays out in seconds — with a factor of 3600, a\n * `delay('2 days')` sleeps 48 s, a `waitUntil(..., { timeout: '3 days' })`\n * gives up after 72 s, and a goal `within: '30 days'` closes after 12 min.\n *\n * Everything that is a Duration scales together (delays, random delays, wait\n * timeouts, goal and `performed(... within)` windows inside the workflow), so\n * the journey keeps its shape, just faster. Wall-clock `timeWindow`s cannot\n * scale (they are times of day, not durations), so a scaled flow drops them:\n * a rehearsal reaching a 09:00 window at night would otherwise sleep real hours\n * in a journey that runs in seconds. The other nodes keep their ids, so step\n * names stay put. Segment definitions\n * and trigger routes live in the store rather than the workflow body;\n * `scaleSegmentWindows` scales them as they are read — one segment for an\n * event-driven evaluation, all of them for the scheduled sweep, a route's\n * profile gate at ingest — so a segment's `within` keeps pace everywhere.\n *\n * The walk follows the IR's own structure — the fields that hold a Duration\n * are known — so a message prop or an event payload that happens to look like\n * one (`{ value, ms }`) is left alone. The source text is kept so the studio\n * still shows what was written.\n */\nexport function scaleDurations(ir: WorkflowIR, factor: number): WorkflowIR {\n if (!(factor > 0) || factor === 1) return ir;\n return {\n ...ir,\n trigger:\n ir.trigger.type === 'event'\n ? {\n ...ir.trigger,\n ...(ir.trigger.filter === undefined\n ? {}\n : { filter: scaleCondition(ir.trigger.filter, factor) }),\n }\n : ir.trigger,\n ...(ir.goal === undefined\n ? {}\n : {\n goal: {\n ...ir.goal,\n condition: scaleCondition(ir.goal.condition, factor),\n ...(ir.goal.within === undefined ? {} : { within: scale(ir.goal.within, factor) }),\n },\n }),\n ...(ir.exitWhen === undefined ? {} : { exitWhen: scaleCondition(ir.exitWhen, factor) }),\n flow: scaleFlow(ir.flow, factor),\n };\n}\n\n/** A condition with its `performed(... within)` windows divided by `factor`. */\nexport function scaleCondition(condition: ConditionIR, factor: number): ConditionIR {\n if (!(factor > 0) || factor === 1) return condition;\n switch (condition.type) {\n case 'and':\n case 'or':\n return {\n ...condition,\n conditions: condition.conditions.map((child) => scaleCondition(child, factor)),\n };\n case 'not':\n return { ...condition, condition: scaleCondition(condition.condition, factor) };\n case 'performed':\n return condition.within === undefined\n ? condition\n : { ...condition, within: scale(condition.within, factor) };\n default:\n return condition;\n }\n}\n\nfunction scaleFlow(nodes: readonly NodeIR[], factor: number): NodeIR[] {\n return nodes.flatMap((node) => (node.type === 'time_window' ? [] : [scaleNode(node, factor)]));\n}\n\nfunction scaleNode(node: NodeIR, factor: number): NodeIR {\n switch (node.type) {\n case 'delay':\n return { ...node, duration: scale(node.duration, factor) };\n case 'random_delay':\n return { ...node, min: scale(node.min, factor), max: scale(node.max, factor) };\n case 'wait_until':\n return {\n ...node,\n condition: scaleCondition(node.condition, factor),\n timeout: scale(node.timeout, factor),\n onTimeout: Array.isArray(node.onTimeout)\n ? scaleFlow(node.onTimeout, factor)\n : node.onTimeout,\n };\n case 'branch':\n return {\n ...node,\n cases: node.cases.map((branch) => ({\n ...branch,\n condition: scaleCondition(branch.condition, factor),\n flow: scaleFlow(branch.flow, factor),\n })),\n ...(node.otherwise === undefined ? {} : { otherwise: scaleFlow(node.otherwise, factor) }),\n };\n case 'filter':\n return { ...node, condition: scaleCondition(node.condition, factor) };\n case 'cohort':\n return {\n ...node,\n arms: node.arms.map((arm) => ({ ...arm, flow: scaleFlow(arm.flow, factor) })),\n };\n default:\n return node;\n }\n}\n\nfunction scale(duration: DurationIR, factor: number): DurationIR {\n return { value: duration.value, ms: Math.max(0, Math.round(duration.ms / factor)) };\n}\n\n/**\n * A store whose segment definitions come back scaled by `factor` — what the journey host leases\n * in fast-forward, so a segment's windows (`performed(e.login, { within: '7 days' })`) shrink\n * with the journeys that reference it, and with the segment triggers it routes. Every read that\n * hands out a stored condition is scaled: `getSegmentCondition` (event-driven evaluation),\n * `listSegments` (the scheduled sweep, which narrows candidates in SQL and evaluates with those\n * definitions) and `findTriggers` (the profile gate an event trigger checks before it starts a\n * journey, which `scaleDurations` scales inside the journey too). Every other method is the\n * store's own.\n */\nexport function scaleSegmentWindows<\n S extends { getSegmentCondition(name: string): Promise<ConditionIR | undefined> },\n>(store: S, factor: number): S {\n if (!(factor > 0) || factor === 1) return store;\n return new Proxy(store, {\n get(target, property) {\n const value: unknown = Reflect.get(target, property, target);\n if (typeof value !== 'function') return value;\n switch (property) {\n case 'getSegmentCondition':\n return async (name: string) => {\n const condition = await target.getSegmentCondition(name);\n return condition === undefined ? undefined : scaleCondition(condition, factor);\n };\n case 'listSegments':\n return async () => {\n const segments = (await value.call(target)) as { id: string; condition: ConditionIR }[];\n return segments.map(({ id, condition }) => ({\n id,\n condition: scaleCondition(condition, factor),\n }));\n };\n case 'findTriggers':\n return async (event: string) => {\n // Only the profile gate: `where` is payload-only, so it holds no window to scale\n const scaled = (route: { filter: ConditionIR | null }) => ({\n ...route,\n filter: route.filter === null ? null : scaleCondition(route.filter, factor),\n });\n return ((await value.call(target, event)) as { filter: ConditionIR | null }[]).map(\n scaled\n );\n };\n default:\n return value.bind(target);\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,eAAe,IAAgB,QAA4B;CACzE,IAAI,EAAE,SAAS,MAAM,WAAW,GAAG,OAAO;CAC1C,OAAO;EACL,GAAG;EACH,SACE,GAAG,QAAQ,SAAS,UAChB;GACE,GAAG,GAAG;GACN,GAAI,GAAG,QAAQ,WAAW,KAAA,IACtB,CAAC,IACD,EAAE,QAAQ,eAAe,GAAG,QAAQ,QAAQ,MAAM,EAAE;EAC1D,IACA,GAAG;EACT,GAAI,GAAG,SAAS,KAAA,IACZ,CAAC,IACD,EACE,MAAM;GACJ,GAAG,GAAG;GACN,WAAW,eAAe,GAAG,KAAK,WAAW,MAAM;GACnD,GAAI,GAAG,KAAK,WAAW,K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UAAkB;IAE9B,MAAM,UAAU,WAA2C;KACzD,GAAG;KACH,QAAQ,MAAM,WAAW,OAAO,OAAO,eAAe,MAAM,QAAQ,MAAM;IAC5E;IACA,QAAS,MAAM,MAAM,KAAK,QAAQ,KAAK,EAAA,CAAwC,IAC7E,MACF;GACF;GACF,SACE,OAAO,MAAM,KAAK,MAAM;EAC5B;CACF,EACF,CAAC;AACH"}
@@ -0,0 +1,148 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ // src/engine/time-window.ts
3
+ /**
4
+ * Time-window scheduling — when does the next send window open?
5
+ *
6
+ * Pure functions of (nowMs, days, between, tz): the interpreter calls them
7
+ * inside a durable step, so the answer is checkpointed and replay-safe.
8
+ * Timezone math goes through Intl.DateTimeFormat (available in Node, workerd
9
+ * and browsers alike) — no tz database dependency. An unknown timezone falls
10
+ * back to UTC rather than failing the journey.
11
+ */
12
+ const DAY_MS = 864e5;
13
+ /** Indexed by Date#getUTCDay, matching WeekdayIR's lowercase three-letter form. */
14
+ const WEEKDAYS = [
15
+ "sun",
16
+ "mon",
17
+ "tue",
18
+ "wed",
19
+ "thu",
20
+ "fri",
21
+ "sat"
22
+ ];
23
+ const formatters = /* @__PURE__ */ new Map();
24
+ /** Cached per-timezone formatter; throws on an invalid timezone id. */
25
+ function formatterFor(tz) {
26
+ let dtf = formatters.get(tz);
27
+ if (dtf === void 0) {
28
+ dtf = new Intl.DateTimeFormat("en-US", {
29
+ timeZone: tz,
30
+ hourCycle: "h23",
31
+ year: "numeric",
32
+ month: "numeric",
33
+ day: "numeric",
34
+ hour: "numeric",
35
+ minute: "numeric"
36
+ });
37
+ formatters.set(tz, dtf);
38
+ }
39
+ return dtf;
40
+ }
41
+ /** Validate a timezone id, falling back to UTC — a bad profile value must not wedge the journey. */
42
+ function resolveTimeZone(tz) {
43
+ try {
44
+ formatterFor(tz);
45
+ return tz;
46
+ } catch {
47
+ return "UTC";
48
+ }
49
+ }
50
+ function localParts(ms, tz) {
51
+ const parts = {};
52
+ for (const part of formatterFor(tz).formatToParts(new Date(ms))) parts[part.type] = part.value;
53
+ return {
54
+ year: Number(parts.year),
55
+ month: Number(parts.month),
56
+ day: Number(parts.day),
57
+ hour: Number(parts.hour),
58
+ minute: Number(parts.minute)
59
+ };
60
+ }
61
+ /** The zone's UTC offset at an instant, as (wall clock read as if it were UTC) − instant. */
62
+ function offsetMsAt(ts, tz) {
63
+ const p = localParts(ts, tz);
64
+ return Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute) - ts;
65
+ }
66
+ /**
67
+ * The first instant at or after `before` whose offset differs from the one
68
+ * there — i.e. the DST transition separating the two bounds. Bisects on the
69
+ * minute grid, the finest granularity any tz rule uses, so the loop lands on
70
+ * the transition itself rather than merely near it.
71
+ */
72
+ function transitionBetween(before, after, tz) {
73
+ const startOffset = offsetMsAt(before, tz);
74
+ let lo = before;
75
+ let hi = after;
76
+ while (hi - lo > 6e4) {
77
+ const mid = lo + Math.floor((hi - lo) / 12e4) * 6e4;
78
+ if (offsetMsAt(mid, tz) === startOffset) lo = mid;
79
+ else hi = mid;
80
+ }
81
+ return hi;
82
+ }
83
+ /**
84
+ * The UTC instant at which the wall clock in `tz` reads y-m-d hh:mm.
85
+ *
86
+ * Guess the UTC value from the offset at the guess, read it back through the
87
+ * timezone and correct by the difference; a second pass settles every wall
88
+ * time that exists, and picks the earlier of the two when a fall-back repeats
89
+ * an hour.
90
+ *
91
+ * A wall time inside a spring-forward gap exists on no clock, so the two
92
+ * corrections straddle the transition and neither reads back as asked. The
93
+ * convention here is the usual one: move forward to the first instant that
94
+ * does exist, i.e. the transition itself — 02:30 on a US spring-forward day
95
+ * resolves to 03:00. Without that branch the correction bottoms out on the low
96
+ * side and the window opens an hour *before* its configured start.
97
+ */
98
+ function zonedInstant(year, month, day, hour, minute, tz) {
99
+ const target = Date.UTC(year, month - 1, day, hour, minute);
100
+ const first = target - offsetMsAt(target, tz);
101
+ if (offsetMsAt(first, tz) === target - first) return first;
102
+ const second = target - offsetMsAt(first, tz);
103
+ if (offsetMsAt(second, tz) === target - second) return second;
104
+ return transitionBetween(Math.min(first, second), Math.max(first, second), tz);
105
+ }
106
+ const TIME = /^(\d{1,2}):(\d{2})$/;
107
+ function parseTime(value) {
108
+ const match = TIME.exec(value);
109
+ if (!match) return null;
110
+ const hh = Number(match[1]);
111
+ const mm = Number(match[2]);
112
+ if (hh > 23 || mm > 59) return null;
113
+ return {
114
+ hh,
115
+ mm
116
+ };
117
+ }
118
+ /**
119
+ * The instant the next [start, end) window opens in `tz`, or null when nowMs
120
+ * is already inside a window. Scans nine calendar days so every weekday is
121
+ * reachable. Malformed times (the DSL validates its own input, but IR may come
122
+ * from elsewhere) disable the window — better to send now than to hold a user
123
+ * forever on a config typo.
124
+ */
125
+ function nextWindowStart(nowMs, days, between, tz) {
126
+ const start = parseTime(between[0]);
127
+ const end = parseTime(between[1]);
128
+ if (start === null || end === null) return null;
129
+ const zone = resolveTimeZone(tz);
130
+ const today = localParts(nowMs, zone);
131
+ const firstDay = Date.UTC(today.year, today.month - 1, today.day);
132
+ for (let offset = 0; offset < 9; offset++) {
133
+ const date = new Date(firstDay + offset * DAY_MS);
134
+ if (!days.includes(WEEKDAYS[date.getUTCDay()])) continue;
135
+ const year = date.getUTCFullYear();
136
+ const month = date.getUTCMonth() + 1;
137
+ const day = date.getUTCDate();
138
+ const opensAt = zonedInstant(year, month, day, start.hh, start.mm, zone);
139
+ const closesAt = zonedInstant(year, month, day, end.hh, end.mm, zone);
140
+ if (nowMs < opensAt) return opensAt;
141
+ if (nowMs < closesAt) return null;
142
+ }
143
+ return null;
144
+ }
145
+ exports.nextWindowStart = nextWindowStart;
146
+ exports.resolveTimeZone = resolveTimeZone;
147
+
148
+ //# sourceMappingURL=time-window.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-window.cjs","names":[],"sources":["../../src/engine/time-window.ts"],"sourcesContent":["/**\n * Time-window scheduling — when does the next send window open?\n *\n * Pure functions of (nowMs, days, between, tz): the interpreter calls them\n * inside a durable step, so the answer is checkpointed and replay-safe.\n * Timezone math goes through Intl.DateTimeFormat (available in Node, workerd\n * and browsers alike) — no tz database dependency. An unknown timezone falls\n * back to UTC rather than failing the journey.\n */\n\nconst DAY_MS = 86_400_000;\n\n/** Indexed by Date#getUTCDay, matching WeekdayIR's lowercase three-letter form. */\nconst WEEKDAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];\n\ninterface LocalParts {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n}\n\nconst formatters = new Map<string, Intl.DateTimeFormat>();\n\n/** Cached per-timezone formatter; throws on an invalid timezone id. */\nfunction formatterFor(tz: string): Intl.DateTimeFormat {\n let dtf = formatters.get(tz);\n if (dtf === undefined) {\n dtf = new Intl.DateTimeFormat('en-US', {\n timeZone: tz,\n hourCycle: 'h23',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n });\n formatters.set(tz, dtf);\n }\n return dtf;\n}\n\n/** Validate a timezone id, falling back to UTC — a bad profile value must not wedge the journey. */\nexport function resolveTimeZone(tz: string): string {\n try {\n formatterFor(tz);\n return tz;\n } catch {\n return 'UTC';\n }\n}\n\nfunction localParts(ms: number, tz: string): LocalParts {\n const parts: Partial<Record<string, string>> = {};\n for (const part of formatterFor(tz).formatToParts(new Date(ms))) {\n parts[part.type] = part.value;\n }\n return {\n year: Number(parts.year),\n month: Number(parts.month),\n day: Number(parts.day),\n hour: Number(parts.hour),\n minute: Number(parts.minute),\n };\n}\n\n/** The zone's UTC offset at an instant, as (wall clock read as if it were UTC) − instant. */\nfunction offsetMsAt(ts: number, tz: string): number {\n const p = localParts(ts, tz);\n return Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute) - ts;\n}\n\n/**\n * The first instant at or after `before` whose offset differs from the one\n * there — i.e. the DST transition separating the two bounds. Bisects on the\n * minute grid, the finest granularity any tz rule uses, so the loop lands on\n * the transition itself rather than merely near it.\n */\nfunction transitionBetween(before: number, after: number, tz: string): number {\n const startOffset = offsetMsAt(before, tz);\n let lo = before;\n let hi = after;\n while (hi - lo > 60_000) {\n // Halve on whole minutes: both bounds stay minute-aligned, so mid is\n // strictly inside (lo, hi) and the loop cannot stall.\n const mid = lo + Math.floor((hi - lo) / 120_000) * 60_000;\n if (offsetMsAt(mid, tz) === startOffset) lo = mid;\n else hi = mid;\n }\n return hi;\n}\n\n/**\n * The UTC instant at which the wall clock in `tz` reads y-m-d hh:mm.\n *\n * Guess the UTC value from the offset at the guess, read it back through the\n * timezone and correct by the difference; a second pass settles every wall\n * time that exists, and picks the earlier of the two when a fall-back repeats\n * an hour.\n *\n * A wall time inside a spring-forward gap exists on no clock, so the two\n * corrections straddle the transition and neither reads back as asked. The\n * convention here is the usual one: move forward to the first instant that\n * does exist, i.e. the transition itself — 02:30 on a US spring-forward day\n * resolves to 03:00. Without that branch the correction bottoms out on the low\n * side and the window opens an hour *before* its configured start.\n */\nfunction zonedInstant(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n tz: string\n): number {\n const target = Date.UTC(year, month - 1, day, hour, minute);\n const first = target - offsetMsAt(target, tz);\n if (offsetMsAt(first, tz) === target - first) return first;\n const second = target - offsetMsAt(first, tz);\n if (offsetMsAt(second, tz) === target - second) return second;\n return transitionBetween(Math.min(first, second), Math.max(first, second), tz);\n}\n\nconst TIME = /^(\\d{1,2}):(\\d{2})$/;\n\nfunction parseTime(value: string): { hh: number; mm: number } | null {\n const match = TIME.exec(value);\n if (!match) return null;\n const hh = Number(match[1]);\n const mm = Number(match[2]);\n if (hh > 23 || mm > 59) return null;\n return { hh, mm };\n}\n\n/**\n * The instant the next [start, end) window opens in `tz`, or null when nowMs\n * is already inside a window. Scans nine calendar days so every weekday is\n * reachable. Malformed times (the DSL validates its own input, but IR may come\n * from elsewhere) disable the window — better to send now than to hold a user\n * forever on a config typo.\n */\nexport function nextWindowStart(\n nowMs: number,\n days: readonly string[],\n between: readonly [string, string],\n tz: string\n): number | null {\n const start = parseTime(between[0]);\n const end = parseTime(between[1]);\n if (start === null || end === null) return null;\n const zone = resolveTimeZone(tz);\n\n // Step the local *calendar*, not the absolute clock: a spring-forward day is\n // 23 hours long, so nowMs + n·24h crosses two local midnights and skips that\n // date entirely — the send would be held until the weekday came round again.\n // Date.UTC arithmetic over the civil date has no DST to trip on, and\n // getUTCDay names the same weekday the zone does.\n const today = localParts(nowMs, zone);\n const firstDay = Date.UTC(today.year, today.month - 1, today.day);\n\n for (let offset = 0; offset < 9; offset++) {\n const date = new Date(firstDay + offset * DAY_MS);\n if (!days.includes(WEEKDAYS[date.getUTCDay()])) continue;\n const year = date.getUTCFullYear();\n const month = date.getUTCMonth() + 1;\n const day = date.getUTCDate();\n const opensAt = zonedInstant(year, month, day, start.hh, start.mm, zone);\n const closesAt = zonedInstant(year, month, day, end.hh, end.mm, zone);\n if (nowMs < opensAt) return opensAt;\n if (nowMs < closesAt) return null;\n // Past this day's window (e.g. 23:00 against 09:00–17:00) → keep scanning forward\n }\n return null; // no allowed day in range (an empty days list) → do not wait\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS;;AAGf,MAAM,WAAW;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK;AAUjE,MAAM,6BAAa,IAAI,IAAiC;;AAGxD,SAAS,aAAa,IAAiC;CACrD,IAAI,MAAM,WAAW,IAAI,EAAE;CAC3B,IAAI,QAAQ,KAAA,GAAW;EACrB,MAAM,IAAI,KAAK,eAAe,SAAS;GACrC,UAAU;GACV,WAAW;GACX,MAAM;GACN,OAAO;GACP,KAAK;GACL,MAAM;GACN,QAAQ;EACV,CAAC;EACD,WAAW,IAAI,IAAI,GAAG;CACxB;CACA,OAAO;AACT;;AAGA,SAAgB,gBAAgB,IAAoB;CAClD,IAAI;EACF,aAAa,EAAE;EACf,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,WAAW,IAAY,IAAw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b,SAAS,UAAU,OAAkD;CACnE,MAAM,QAAQ,KAAK,KAAK,KAAK;CAC7B,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,KAAK,OAAO,MAAM,EAAE;CAC1B,MAAM,KAAK,OAAO,MAAM,EAAE;CAC1B,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO;CAC/B,OAAO;EAAE;EAAI;CAAG;AAClB;;;;;;;;AASA,SAAgB,gBACd,OACA,MACA,SACA,IACe;CACf,MAAM,QAAQ,UAAU,QAAQ,EAAE;CAClC,MAAM,MAAM,UAAU,QAAQ,EAAE;CAChC,IAAI,UAAU,QAAQ,QAAQ,MAAM,OAAO;CAC3C,MAAM,OAAO,gBAAgB,EAAE;CAO/B,MAAM,QAAQ,WAAW,OAAO,IAAI;CACpC,MAAM,WAAW,KAAK,IAAI,MAAM,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;CAEhE,KAAK,IAAI,SAAS,GAAG,SAAS,GAAG,UAAU;EACzC,MAAM,OAAO,IAAI,KAAK,WAAW,SAAS,MAAM;EAChD,IAAI,CAAC,KAAK,SAAS,SAAS,KAAK,UAAU,EAAE,GAAG;EAChD,MAAM,OAAO,KAAK,eAAe;EACjC,MAAM,QAAQ,KAAK,YAAY,IAAI;EACnC,MAAM,MAAM,KAAK,WAAW;EAC5B,MAAM,UAAU,aAAa,MAAM,OAAO,KAAK,MAAM,IAAI,MAAM,IAAI,IAAI;EACvE,MAAM,WAAW,aAAa,MAAM,OAAO,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI;EACpE,IAAI,QAAQ,SAAS,OAAO;EAC5B,IAAI,QAAQ,UAAU,OAAO;CAE/B;CACA,OAAO;AACT"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Time-window scheduling — when does the next send window open?
3
+ *
4
+ * Pure functions of (nowMs, days, between, tz): the interpreter calls them
5
+ * inside a durable step, so the answer is checkpointed and replay-safe.
6
+ * Timezone math goes through Intl.DateTimeFormat (available in Node, workerd
7
+ * and browsers alike) — no tz database dependency. An unknown timezone falls
8
+ * back to UTC rather than failing the journey.
9
+ */
10
+ /** Validate a timezone id, falling back to UTC — a bad profile value must not wedge the journey. */
11
+ export declare function resolveTimeZone(tz: string): string;
12
+ /**
13
+ * The instant the next [start, end) window opens in `tz`, or null when nowMs
14
+ * is already inside a window. Scans nine calendar days so every weekday is
15
+ * reachable. Malformed times (the DSL validates its own input, but IR may come
16
+ * from elsewhere) disable the window — better to send now than to hold a user
17
+ * forever on a config typo.
18
+ */
19
+ export declare function nextWindowStart(nowMs: number, days: readonly string[], between: readonly [string, string], tz: string): number | null;
20
+ //# sourceMappingURL=time-window.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-window.d.cts","names":[],"sources":["../../src/engine/time-window.ts"],"mappings":";;;;;;;;;;wBA4CgB,gBAAgB;;;;;;;;wBAkGhB,gBACd,eACA,yBACA,oCACA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Time-window scheduling — when does the next send window open?
3
+ *
4
+ * Pure functions of (nowMs, days, between, tz): the interpreter calls them
5
+ * inside a durable step, so the answer is checkpointed and replay-safe.
6
+ * Timezone math goes through Intl.DateTimeFormat (available in Node, workerd
7
+ * and browsers alike) — no tz database dependency. An unknown timezone falls
8
+ * back to UTC rather than failing the journey.
9
+ */
10
+ /** Validate a timezone id, falling back to UTC — a bad profile value must not wedge the journey. */
11
+ export declare function resolveTimeZone(tz: string): string;
12
+ /**
13
+ * The instant the next [start, end) window opens in `tz`, or null when nowMs
14
+ * is already inside a window. Scans nine calendar days so every weekday is
15
+ * reachable. Malformed times (the DSL validates its own input, but IR may come
16
+ * from elsewhere) disable the window — better to send now than to hold a user
17
+ * forever on a config typo.
18
+ */
19
+ export declare function nextWindowStart(nowMs: number, days: readonly string[], between: readonly [string, string], tz: string): number | null;
20
+ //# sourceMappingURL=time-window.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-window.d.mts","names":[],"sources":["../../src/engine/time-window.ts"],"mappings":";;;;;;;;;;wBA4CgB,gBAAgB;;;;;;;;wBAkGhB,gBACd,eACA,yBACA,oCACA"}
@@ -0,0 +1,146 @@
1
+ // src/engine/time-window.ts
2
+ /**
3
+ * Time-window scheduling — when does the next send window open?
4
+ *
5
+ * Pure functions of (nowMs, days, between, tz): the interpreter calls them
6
+ * inside a durable step, so the answer is checkpointed and replay-safe.
7
+ * Timezone math goes through Intl.DateTimeFormat (available in Node, workerd
8
+ * and browsers alike) — no tz database dependency. An unknown timezone falls
9
+ * back to UTC rather than failing the journey.
10
+ */
11
+ const DAY_MS = 864e5;
12
+ /** Indexed by Date#getUTCDay, matching WeekdayIR's lowercase three-letter form. */
13
+ const WEEKDAYS = [
14
+ "sun",
15
+ "mon",
16
+ "tue",
17
+ "wed",
18
+ "thu",
19
+ "fri",
20
+ "sat"
21
+ ];
22
+ const formatters = /* @__PURE__ */ new Map();
23
+ /** Cached per-timezone formatter; throws on an invalid timezone id. */
24
+ function formatterFor(tz) {
25
+ let dtf = formatters.get(tz);
26
+ if (dtf === void 0) {
27
+ dtf = new Intl.DateTimeFormat("en-US", {
28
+ timeZone: tz,
29
+ hourCycle: "h23",
30
+ year: "numeric",
31
+ month: "numeric",
32
+ day: "numeric",
33
+ hour: "numeric",
34
+ minute: "numeric"
35
+ });
36
+ formatters.set(tz, dtf);
37
+ }
38
+ return dtf;
39
+ }
40
+ /** Validate a timezone id, falling back to UTC — a bad profile value must not wedge the journey. */
41
+ function resolveTimeZone(tz) {
42
+ try {
43
+ formatterFor(tz);
44
+ return tz;
45
+ } catch {
46
+ return "UTC";
47
+ }
48
+ }
49
+ function localParts(ms, tz) {
50
+ const parts = {};
51
+ for (const part of formatterFor(tz).formatToParts(new Date(ms))) parts[part.type] = part.value;
52
+ return {
53
+ year: Number(parts.year),
54
+ month: Number(parts.month),
55
+ day: Number(parts.day),
56
+ hour: Number(parts.hour),
57
+ minute: Number(parts.minute)
58
+ };
59
+ }
60
+ /** The zone's UTC offset at an instant, as (wall clock read as if it were UTC) − instant. */
61
+ function offsetMsAt(ts, tz) {
62
+ const p = localParts(ts, tz);
63
+ return Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute) - ts;
64
+ }
65
+ /**
66
+ * The first instant at or after `before` whose offset differs from the one
67
+ * there — i.e. the DST transition separating the two bounds. Bisects on the
68
+ * minute grid, the finest granularity any tz rule uses, so the loop lands on
69
+ * the transition itself rather than merely near it.
70
+ */
71
+ function transitionBetween(before, after, tz) {
72
+ const startOffset = offsetMsAt(before, tz);
73
+ let lo = before;
74
+ let hi = after;
75
+ while (hi - lo > 6e4) {
76
+ const mid = lo + Math.floor((hi - lo) / 12e4) * 6e4;
77
+ if (offsetMsAt(mid, tz) === startOffset) lo = mid;
78
+ else hi = mid;
79
+ }
80
+ return hi;
81
+ }
82
+ /**
83
+ * The UTC instant at which the wall clock in `tz` reads y-m-d hh:mm.
84
+ *
85
+ * Guess the UTC value from the offset at the guess, read it back through the
86
+ * timezone and correct by the difference; a second pass settles every wall
87
+ * time that exists, and picks the earlier of the two when a fall-back repeats
88
+ * an hour.
89
+ *
90
+ * A wall time inside a spring-forward gap exists on no clock, so the two
91
+ * corrections straddle the transition and neither reads back as asked. The
92
+ * convention here is the usual one: move forward to the first instant that
93
+ * does exist, i.e. the transition itself — 02:30 on a US spring-forward day
94
+ * resolves to 03:00. Without that branch the correction bottoms out on the low
95
+ * side and the window opens an hour *before* its configured start.
96
+ */
97
+ function zonedInstant(year, month, day, hour, minute, tz) {
98
+ const target = Date.UTC(year, month - 1, day, hour, minute);
99
+ const first = target - offsetMsAt(target, tz);
100
+ if (offsetMsAt(first, tz) === target - first) return first;
101
+ const second = target - offsetMsAt(first, tz);
102
+ if (offsetMsAt(second, tz) === target - second) return second;
103
+ return transitionBetween(Math.min(first, second), Math.max(first, second), tz);
104
+ }
105
+ const TIME = /^(\d{1,2}):(\d{2})$/;
106
+ function parseTime(value) {
107
+ const match = TIME.exec(value);
108
+ if (!match) return null;
109
+ const hh = Number(match[1]);
110
+ const mm = Number(match[2]);
111
+ if (hh > 23 || mm > 59) return null;
112
+ return {
113
+ hh,
114
+ mm
115
+ };
116
+ }
117
+ /**
118
+ * The instant the next [start, end) window opens in `tz`, or null when nowMs
119
+ * is already inside a window. Scans nine calendar days so every weekday is
120
+ * reachable. Malformed times (the DSL validates its own input, but IR may come
121
+ * from elsewhere) disable the window — better to send now than to hold a user
122
+ * forever on a config typo.
123
+ */
124
+ function nextWindowStart(nowMs, days, between, tz) {
125
+ const start = parseTime(between[0]);
126
+ const end = parseTime(between[1]);
127
+ if (start === null || end === null) return null;
128
+ const zone = resolveTimeZone(tz);
129
+ const today = localParts(nowMs, zone);
130
+ const firstDay = Date.UTC(today.year, today.month - 1, today.day);
131
+ for (let offset = 0; offset < 9; offset++) {
132
+ const date = new Date(firstDay + offset * DAY_MS);
133
+ if (!days.includes(WEEKDAYS[date.getUTCDay()])) continue;
134
+ const year = date.getUTCFullYear();
135
+ const month = date.getUTCMonth() + 1;
136
+ const day = date.getUTCDate();
137
+ const opensAt = zonedInstant(year, month, day, start.hh, start.mm, zone);
138
+ const closesAt = zonedInstant(year, month, day, end.hh, end.mm, zone);
139
+ if (nowMs < opensAt) return opensAt;
140
+ if (nowMs < closesAt) return null;
141
+ }
142
+ return null;
143
+ }
144
+ export { nextWindowStart, resolveTimeZone };
145
+
146
+ //# sourceMappingURL=time-window.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-window.mjs","names":[],"sources":["../../src/engine/time-window.ts"],"sourcesContent":["/**\n * Time-window scheduling — when does the next send window open?\n *\n * Pure functions of (nowMs, days, between, tz): the interpreter calls them\n * inside a durable step, so the answer is checkpointed and replay-safe.\n * Timezone math goes through Intl.DateTimeFormat (available in Node, workerd\n * and browsers alike) — no tz database dependency. An unknown timezone falls\n * back to UTC rather than failing the journey.\n */\n\nconst DAY_MS = 86_400_000;\n\n/** Indexed by Date#getUTCDay, matching WeekdayIR's lowercase three-letter form. */\nconst WEEKDAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];\n\ninterface LocalParts {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n}\n\nconst formatters = new Map<string, Intl.DateTimeFormat>();\n\n/** Cached per-timezone formatter; throws on an invalid timezone id. */\nfunction formatterFor(tz: string): Intl.DateTimeFormat {\n let dtf = formatters.get(tz);\n if (dtf === undefined) {\n dtf = new Intl.DateTimeFormat('en-US', {\n timeZone: tz,\n hourCycle: 'h23',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n });\n formatters.set(tz, dtf);\n }\n return dtf;\n}\n\n/** Validate a timezone id, falling back to UTC — a bad profile value must not wedge the journey. */\nexport function resolveTimeZone(tz: string): string {\n try {\n formatterFor(tz);\n return tz;\n } catch {\n return 'UTC';\n }\n}\n\nfunction localParts(ms: number, tz: string): LocalParts {\n const parts: Partial<Record<string, string>> = {};\n for (const part of formatterFor(tz).formatToParts(new Date(ms))) {\n parts[part.type] = part.value;\n }\n return {\n year: Number(parts.year),\n month: Number(parts.month),\n day: Number(parts.day),\n hour: Number(parts.hour),\n minute: Number(parts.minute),\n };\n}\n\n/** The zone's UTC offset at an instant, as (wall clock read as if it were UTC) − instant. */\nfunction offsetMsAt(ts: number, tz: string): number {\n const p = localParts(ts, tz);\n return Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute) - ts;\n}\n\n/**\n * The first instant at or after `before` whose offset differs from the one\n * there — i.e. the DST transition separating the two bounds. Bisects on the\n * minute grid, the finest granularity any tz rule uses, so the loop lands on\n * the transition itself rather than merely near it.\n */\nfunction transitionBetween(before: number, after: number, tz: string): number {\n const startOffset = offsetMsAt(before, tz);\n let lo = before;\n let hi = after;\n while (hi - lo > 60_000) {\n // Halve on whole minutes: both bounds stay minute-aligned, so mid is\n // strictly inside (lo, hi) and the loop cannot stall.\n const mid = lo + Math.floor((hi - lo) / 120_000) * 60_000;\n if (offsetMsAt(mid, tz) === startOffset) lo = mid;\n else hi = mid;\n }\n return hi;\n}\n\n/**\n * The UTC instant at which the wall clock in `tz` reads y-m-d hh:mm.\n *\n * Guess the UTC value from the offset at the guess, read it back through the\n * timezone and correct by the difference; a second pass settles every wall\n * time that exists, and picks the earlier of the two when a fall-back repeats\n * an hour.\n *\n * A wall time inside a spring-forward gap exists on no clock, so the two\n * corrections straddle the transition and neither reads back as asked. The\n * convention here is the usual one: move forward to the first instant that\n * does exist, i.e. the transition itself — 02:30 on a US spring-forward day\n * resolves to 03:00. Without that branch the correction bottoms out on the low\n * side and the window opens an hour *before* its configured start.\n */\nfunction zonedInstant(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n tz: string\n): number {\n const target = Date.UTC(year, month - 1, day, hour, minute);\n const first = target - offsetMsAt(target, tz);\n if (offsetMsAt(first, tz) === target - first) return first;\n const second = target - offsetMsAt(first, tz);\n if (offsetMsAt(second, tz) === target - second) return second;\n return transitionBetween(Math.min(first, second), Math.max(first, second), tz);\n}\n\nconst TIME = /^(\\d{1,2}):(\\d{2})$/;\n\nfunction parseTime(value: string): { hh: number; mm: number } | null {\n const match = TIME.exec(value);\n if (!match) return null;\n const hh = Number(match[1]);\n const mm = Number(match[2]);\n if (hh > 23 || mm > 59) return null;\n return { hh, mm };\n}\n\n/**\n * The instant the next [start, end) window opens in `tz`, or null when nowMs\n * is already inside a window. Scans nine calendar days so every weekday is\n * reachable. Malformed times (the DSL validates its own input, but IR may come\n * from elsewhere) disable the window — better to send now than to hold a user\n * forever on a config typo.\n */\nexport function nextWindowStart(\n nowMs: number,\n days: readonly string[],\n between: readonly [string, string],\n tz: string\n): number | null {\n const start = parseTime(between[0]);\n const end = parseTime(between[1]);\n if (start === null || end === null) return null;\n const zone = resolveTimeZone(tz);\n\n // Step the local *calendar*, not the absolute clock: a spring-forward day is\n // 23 hours long, so nowMs + n·24h crosses two local midnights and skips that\n // date entirely — the send would be held until the weekday came round again.\n // Date.UTC arithmetic over the civil date has no DST to trip on, and\n // getUTCDay names the same weekday the zone does.\n const today = localParts(nowMs, zone);\n const firstDay = Date.UTC(today.year, today.month - 1, today.day);\n\n for (let offset = 0; offset < 9; offset++) {\n const date = new Date(firstDay + offset * DAY_MS);\n if (!days.includes(WEEKDAYS[date.getUTCDay()])) continue;\n const year = date.getUTCFullYear();\n const month = date.getUTCMonth() + 1;\n const day = date.getUTCDate();\n const opensAt = zonedInstant(year, month, day, start.hh, start.mm, zone);\n const closesAt = zonedInstant(year, month, day, end.hh, end.mm, zone);\n if (nowMs < opensAt) return opensAt;\n if (nowMs < closesAt) return null;\n // Past this day's window (e.g. 23:00 against 09:00–17:00) → keep scanning forward\n }\n return null; // no allowed day in range (an empty days list) → do not wait\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,SAAS;;AAGf,MAAM,WAAW;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK;AAUjE,MAAM,6BAAa,IAAI,IAAiC;;AAGxD,SAAS,aAAa,IAAiC;CACrD,IAAI,MAAM,WAAW,IAAI,EAAE;CAC3B,IAAI,QAAQ,KAAA,GAAW;EACrB,MAAM,IAAI,KAAK,eAAe,SAAS;GACrC,UAAU;GACV,WAAW;GACX,MAAM;GACN,OAAO;GACP,KAAK;GACL,MAAM;GACN,QAAQ;EACV,CAAC;EACD,WAAW,IAAI,IAAI,GAAG;CACxB;CACA,OAAO;AACT;;AAGA,SAAgB,gBAAgB,IAAoB;CAClD,IAAI;EACF,aAAa,EAAE;EACf,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,WAAW,IAAY,IAAwB;CACtD,MAAM,QAAyC,CAAC;CAChD,KAAK,MAAM,QAAQ,aAAa,EAAE,CAAC,CAAC,cAAc,IAAI,KAAK,EAAE,CAAC,GAC5D,MAAM,KAAK,QAAQ,KAAK;CAE1B,OAAO;EACL,MAAM,OAAO,MAAM,IAAI;EACvB,OAAO,OAAO,MAAM,KAAK;EACzB,KAAK,OAAO,MAAM,GAAG;EACrB,M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