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,151 @@
1
+ import { ConditionIR, DurationIR, SourceLocIR } from "../ir.cjs";
2
+ import { Duration } from "./base.cjs";
3
+ import { EventRef, PayloadRef, PayloadRefs, TriggerPayloadRef, UserPropertyRef } from "./refs.cjs";
4
+ import { Channel } from "./template.cjs";
5
+ /**
6
+ * Conditions — drizzle-style predicate expressions: free functions (eq/gt/…)
7
+ * composed with and/or/not, plus `segment` for naming an expression as a
8
+ * top-level asset. A condition is an opaque handle wrapping its ConditionIR.
9
+ *
10
+ * Type techniques:
11
+ * - Types flow in from the reference's phantom type; operator applicability is
12
+ * a signature constraint (gt only takes string|number refs, contains only
13
+ * string ones), mirroring customer.io's condition panel.
14
+ * - Value parameters are always NoInfer: types come from the reference only,
15
+ * which stops eq(ref, 'typo') from widening T to include the bad value.
16
+ *
17
+ * TODO: JSON array 'where at least one'、JSON object 'has the property'。
18
+ */
19
+ /** Opaque condition handle — what predicates, combinators and segments all produce. */
20
+ export interface Condition {
21
+ readonly __condition: true;
22
+ }
23
+ /** @internal unwrap a condition to its IR — used by flow/trigger/workflow builders */
24
+ export declare const condIR: (c: Condition) => ConditionIR;
25
+ /**
26
+ * Predicates accept three kinds of reference: a user property (profile
27
+ * condition), an event payload field (only valid inside a `where`) or a field
28
+ * of the triggering event's payload (`t.payload.x`, only valid in the workflow
29
+ * that event triggers). All produce `Condition`, so the bundle compiler
30
+ * enforces the placement.
31
+ */
32
+ type CondRef<T> = UserPropertyRef<T> | PayloadRef<T> | TriggerPayloadRef<T>;
33
+ export declare function eq<T>(ref: CondRef<T>, value: NoInfer<T>): Condition;
34
+ export declare function ne<T>(ref: CondRef<T>, value: NoInfer<T>): Condition;
35
+ export declare function gt<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
36
+ export declare function gte<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
37
+ export declare function lt<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
38
+ export declare function lte<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
39
+ export declare function between<T extends string | number>(ref: CondRef<T>, min: NoInfer<T>, max: NoInfer<T>): Condition;
40
+ export declare function notBetween<T extends string | number>(ref: CondRef<T>, min: NoInfer<T>, max: NoInfer<T>): Condition;
41
+ export declare function inArray<T>(ref: CondRef<T>, values: readonly NoInfer<T>[]): Condition;
42
+ export declare function notInArray<T>(ref: CondRef<T>, values: readonly NoInfer<T>[]): Condition;
43
+ export declare function exists(ref: CondRef<unknown>): Condition;
44
+ export declare function notExists(ref: CondRef<unknown>): Condition;
45
+ export declare function contains<T extends string>(ref: CondRef<T>, value: string): Condition;
46
+ export declare function notContains<T extends string>(ref: CondRef<T>, value: string): Condition;
47
+ export interface PerformedOptions {
48
+ /** Only occurrences this recent count; must be a positive duration. */
49
+ within?: Duration;
50
+ /** At least this many occurrences; a positive integer (1 is the default). */
51
+ count?: number;
52
+ }
53
+ /**
54
+ * @internal A duration that has to elapse — a wait's timeout, a goal's window, a performed
55
+ * window. Zero parses as a valid duration but means "never" or "always" depending on the node,
56
+ * and either way it is not what the author meant.
57
+ */
58
+ export declare function positiveDurationIR(value: Duration, what: string): DurationIR;
59
+ /** A payload where clause: an arrow taking the typed payload-ref table. Runs once at construction — the result is a serializable condition tree in IR, never a closure. */
60
+ export type PayloadWhere<P> = (p: PayloadRefs<P>) => Condition;
61
+ /**
62
+ * Event predicate: performed an event (optionally within a window / at least N
63
+ * times). "Did not perform" is `not(performed(...))` — expressed by the
64
+ * combinator, so there is no separate notPerformed.
65
+ *
66
+ * The optional second argument narrows which events count by their payload —
67
+ * an arrow receiving a typed payload reference table, with the ordinary
68
+ * predicates applying. It compiles to a `where` subtree in IR (data the UI
69
+ * renders), not a runtime closure:
70
+ *
71
+ * performed(e.login)
72
+ * performed(e.login, (p) => and(eq(p.platform, 'web'), eq(p.tags.utm_source, 'meta')))
73
+ * performed(e.purchase, (p) => gt(p.value, 100), { within: '30 days', count: 2 })
74
+ * performed(e.purchase, { within: '30 days' }) // options without a where
75
+ *
76
+ * Time anchoring: evaluated inside a `goal` the count starts at workflow
77
+ * entry, inside `waitUntil` at the moment the wait began (the engine anchors
78
+ * them — a conversion or a wake must not be satisfied by pre-existing
79
+ * history). Everywhere else (branch/filter/exitWhen/segments) it looks over
80
+ * full history, bounded only by `within`.
81
+ */
82
+ export declare function performed<P>(event: EventRef<P>, opts?: PerformedOptions): Condition;
83
+ export declare function performed<P>(event: EventRef<P>, where: PayloadWhere<P>, opts?: PerformedOptions): Condition;
84
+ /**
85
+ * The user can be reached on a channel right now. For push it asks the host's
86
+ * device directory (at least one device listed) — the engine keeps no device
87
+ * state, so this is the way to branch on "has the app on a device that allowed
88
+ * notifications"; for the other channels it checks the recipient property
89
+ * (`email`, `phone`, …). Inside `waitUntil` it wakes on device changes
90
+ * (`POST /devices/changed`) or profile updates respectively.
91
+ *
92
+ * .branch([reachable('push'), (w) => w.push(tip)], (w) => w.email(tip))
93
+ *
94
+ * (`.prefer([push.tip, email.tip], props)` is this branch for one push and one email.)
95
+ */
96
+ export declare function reachable(channel: Channel): Condition;
97
+ /** Condition combinators: nest freely. */
98
+ export declare function and(...conditions: readonly Condition[]): Condition;
99
+ export declare function or(...conditions: readonly Condition[]): Condition;
100
+ export declare function not(condition: Condition): Condition;
101
+ /**
102
+ * Segment: a named condition expression and a top-level asset — it shows up in
103
+ * the UI sidebar, is reusable across workflows, is referenced by id in IR,
104
+ * and has a continuously materialized membership count (the prerequisite for
105
+ * segment triggers). Anonymous reuse is just a const expression; a one-off
106
+ * check is an inline expression at the use site.
107
+ * TODO, to match customer.io's panel: form / page / device / screen /
108
+ * opt-out / message data(email opened、sms clicked、webhook …)
109
+ */
110
+ export interface SegmentRef extends Condition {
111
+ readonly __segment: true;
112
+ /** Wire identity: segment references and the membership store are keyed on it (`SegmentIR.id`). */
113
+ readonly id: string;
114
+ }
115
+ /** @internal the compiled shape behind a SegmentRef — compileBundle reads definition/loc off it */
116
+ export interface SegmentInternal extends SegmentRef {
117
+ readonly ir: ConditionIR;
118
+ /** Human label / description; metadata, so never part of the hash. */
119
+ readonly meta: SegmentMeta | undefined;
120
+ /** The segment's own definition (SegmentIR.condition), as opposed to a reference by id. */
121
+ readonly definition: ConditionIR;
122
+ /** Callsite of the segment() call (provenance; lands in SegmentIR.meta.loc). */
123
+ readonly loc: SourceLocIR | undefined;
124
+ }
125
+ /** Labels for a segment: what the studio shows instead of the wire key. */
126
+ export interface SegmentMeta {
127
+ name?: string;
128
+ description?: string;
129
+ }
130
+ export interface SegmentDefinition extends SegmentMeta {
131
+ /**
132
+ * Wire identity — by-name references and the membership store are keyed on
133
+ * it, so it is not something to rename for readability.
134
+ */
135
+ id: string;
136
+ /** Who is in the segment; the predicates already checked its types. */
137
+ condition: Condition;
138
+ }
139
+ /**
140
+ * Segment definition. `name` and `description` are optional labels: metadata,
141
+ * dropped before hashing, and what the studio shows.
142
+ *
143
+ * export const purchaser = segment({
144
+ * id: 'purchaser',
145
+ * name: 'Purchased (last 30d)',
146
+ * condition: performed(e.purchase, { within: '30 days' }),
147
+ * });
148
+ */
149
+ export declare function segment({ id, condition, name, description }: SegmentDefinition): SegmentRef;
150
+ export {};
151
+ //# sourceMappingURL=condition.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.d.cts","names":[],"sources":["../../src/dsl/condition.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBA+BiB;WACN;;;qBAgBE,SAAM,GAAO,cAAY;;;;;;;;K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AAY;;;;;;;;;;iBAa1B,mBAAmB;WACzB;;WAEA;;;iBAIM,wBAAwB;WAC9B,IAAI;;WAEJ,MAAM;;WAEN,YAAY;;WAEZ,KAAK;;;iBAIC;EACf;EACA;;iBAGe,0BAA0B;;;;;EAKzC;;EAEA,WAAW;;;;;;;;;;;;wBAaG,UAAU,IAAI,WAAW,MAAM,eAAe,oBAAoB"}
@@ -0,0 +1,151 @@
1
+ import { ConditionIR, DurationIR, SourceLocIR } from "../ir.mjs";
2
+ import { Duration } from "./base.mjs";
3
+ import { EventRef, PayloadRef, PayloadRefs, TriggerPayloadRef, UserPropertyRef } from "./refs.mjs";
4
+ import { Channel } from "./template.mjs";
5
+ /**
6
+ * Conditions — drizzle-style predicate expressions: free functions (eq/gt/…)
7
+ * composed with and/or/not, plus `segment` for naming an expression as a
8
+ * top-level asset. A condition is an opaque handle wrapping its ConditionIR.
9
+ *
10
+ * Type techniques:
11
+ * - Types flow in from the reference's phantom type; operator applicability is
12
+ * a signature constraint (gt only takes string|number refs, contains only
13
+ * string ones), mirroring customer.io's condition panel.
14
+ * - Value parameters are always NoInfer: types come from the reference only,
15
+ * which stops eq(ref, 'typo') from widening T to include the bad value.
16
+ *
17
+ * TODO: JSON array 'where at least one'、JSON object 'has the property'。
18
+ */
19
+ /** Opaque condition handle — what predicates, combinators and segments all produce. */
20
+ export interface Condition {
21
+ readonly __condition: true;
22
+ }
23
+ /** @internal unwrap a condition to its IR — used by flow/trigger/workflow builders */
24
+ export declare const condIR: (c: Condition) => ConditionIR;
25
+ /**
26
+ * Predicates accept three kinds of reference: a user property (profile
27
+ * condition), an event payload field (only valid inside a `where`) or a field
28
+ * of the triggering event's payload (`t.payload.x`, only valid in the workflow
29
+ * that event triggers). All produce `Condition`, so the bundle compiler
30
+ * enforces the placement.
31
+ */
32
+ type CondRef<T> = UserPropertyRef<T> | PayloadRef<T> | TriggerPayloadRef<T>;
33
+ export declare function eq<T>(ref: CondRef<T>, value: NoInfer<T>): Condition;
34
+ export declare function ne<T>(ref: CondRef<T>, value: NoInfer<T>): Condition;
35
+ export declare function gt<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
36
+ export declare function gte<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
37
+ export declare function lt<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
38
+ export declare function lte<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition;
39
+ export declare function between<T extends string | number>(ref: CondRef<T>, min: NoInfer<T>, max: NoInfer<T>): Condition;
40
+ export declare function notBetween<T extends string | number>(ref: CondRef<T>, min: NoInfer<T>, max: NoInfer<T>): Condition;
41
+ export declare function inArray<T>(ref: CondRef<T>, values: readonly NoInfer<T>[]): Condition;
42
+ export declare function notInArray<T>(ref: CondRef<T>, values: readonly NoInfer<T>[]): Condition;
43
+ export declare function exists(ref: CondRef<unknown>): Condition;
44
+ export declare function notExists(ref: CondRef<unknown>): Condition;
45
+ export declare function contains<T extends string>(ref: CondRef<T>, value: string): Condition;
46
+ export declare function notContains<T extends string>(ref: CondRef<T>, value: string): Condition;
47
+ export interface PerformedOptions {
48
+ /** Only occurrences this recent count; must be a positive duration. */
49
+ within?: Duration;
50
+ /** At least this many occurrences; a positive integer (1 is the default). */
51
+ count?: number;
52
+ }
53
+ /**
54
+ * @internal A duration that has to elapse — a wait's timeout, a goal's window, a performed
55
+ * window. Zero parses as a valid duration but means "never" or "always" depending on the node,
56
+ * and either way it is not what the author meant.
57
+ */
58
+ export declare function positiveDurationIR(value: Duration, what: string): DurationIR;
59
+ /** A payload where clause: an arrow taking the typed payload-ref table. Runs once at construction — the result is a serializable condition tree in IR, never a closure. */
60
+ export type PayloadWhere<P> = (p: PayloadRefs<P>) => Condition;
61
+ /**
62
+ * Event predicate: performed an event (optionally within a window / at least N
63
+ * times). "Did not perform" is `not(performed(...))` — expressed by the
64
+ * combinator, so there is no separate notPerformed.
65
+ *
66
+ * The optional second argument narrows which events count by their payload —
67
+ * an arrow receiving a typed payload reference table, with the ordinary
68
+ * predicates applying. It compiles to a `where` subtree in IR (data the UI
69
+ * renders), not a runtime closure:
70
+ *
71
+ * performed(e.login)
72
+ * performed(e.login, (p) => and(eq(p.platform, 'web'), eq(p.tags.utm_source, 'meta')))
73
+ * performed(e.purchase, (p) => gt(p.value, 100), { within: '30 days', count: 2 })
74
+ * performed(e.purchase, { within: '30 days' }) // options without a where
75
+ *
76
+ * Time anchoring: evaluated inside a `goal` the count starts at workflow
77
+ * entry, inside `waitUntil` at the moment the wait began (the engine anchors
78
+ * them — a conversion or a wake must not be satisfied by pre-existing
79
+ * history). Everywhere else (branch/filter/exitWhen/segments) it looks over
80
+ * full history, bounded only by `within`.
81
+ */
82
+ export declare function performed<P>(event: EventRef<P>, opts?: PerformedOptions): Condition;
83
+ export declare function performed<P>(event: EventRef<P>, where: PayloadWhere<P>, opts?: PerformedOptions): Condition;
84
+ /**
85
+ * The user can be reached on a channel right now. For push it asks the host's
86
+ * device directory (at least one device listed) — the engine keeps no device
87
+ * state, so this is the way to branch on "has the app on a device that allowed
88
+ * notifications"; for the other channels it checks the recipient property
89
+ * (`email`, `phone`, …). Inside `waitUntil` it wakes on device changes
90
+ * (`POST /devices/changed`) or profile updates respectively.
91
+ *
92
+ * .branch([reachable('push'), (w) => w.push(tip)], (w) => w.email(tip))
93
+ *
94
+ * (`.prefer([push.tip, email.tip], props)` is this branch for one push and one email.)
95
+ */
96
+ export declare function reachable(channel: Channel): Condition;
97
+ /** Condition combinators: nest freely. */
98
+ export declare function and(...conditions: readonly Condition[]): Condition;
99
+ export declare function or(...conditions: readonly Condition[]): Condition;
100
+ export declare function not(condition: Condition): Condition;
101
+ /**
102
+ * Segment: a named condition expression and a top-level asset — it shows up in
103
+ * the UI sidebar, is reusable across workflows, is referenced by id in IR,
104
+ * and has a continuously materialized membership count (the prerequisite for
105
+ * segment triggers). Anonymous reuse is just a const expression; a one-off
106
+ * check is an inline expression at the use site.
107
+ * TODO, to match customer.io's panel: form / page / device / screen /
108
+ * opt-out / message data(email opened、sms clicked、webhook …)
109
+ */
110
+ export interface SegmentRef extends Condition {
111
+ readonly __segment: true;
112
+ /** Wire identity: segment references and the membership store are keyed on it (`SegmentIR.id`). */
113
+ readonly id: string;
114
+ }
115
+ /** @internal the compiled shape behind a SegmentRef — compileBundle reads definition/loc off it */
116
+ export interface SegmentInternal extends SegmentRef {
117
+ readonly ir: ConditionIR;
118
+ /** Human label / description; metadata, so never part of the hash. */
119
+ readonly meta: SegmentMeta | undefined;
120
+ /** The segment's own definition (SegmentIR.condition), as opposed to a reference by id. */
121
+ readonly definition: ConditionIR;
122
+ /** Callsite of the segment() call (provenance; lands in SegmentIR.meta.loc). */
123
+ readonly loc: SourceLocIR | undefined;
124
+ }
125
+ /** Labels for a segment: what the studio shows instead of the wire key. */
126
+ export interface SegmentMeta {
127
+ name?: string;
128
+ description?: string;
129
+ }
130
+ export interface SegmentDefinition extends SegmentMeta {
131
+ /**
132
+ * Wire identity — by-name references and the membership store are keyed on
133
+ * it, so it is not something to rename for readability.
134
+ */
135
+ id: string;
136
+ /** Who is in the segment; the predicates already checked its types. */
137
+ condition: Condition;
138
+ }
139
+ /**
140
+ * Segment definition. `name` and `description` are optional labels: metadata,
141
+ * dropped before hashing, and what the studio shows.
142
+ *
143
+ * export const purchaser = segment({
144
+ * id: 'purchaser',
145
+ * name: 'Purchased (last 30d)',
146
+ * condition: performed(e.purchase, { within: '30 days' }),
147
+ * });
148
+ */
149
+ export declare function segment({ id, condition, name, description }: SegmentDefinition): SegmentRef;
150
+ export {};
151
+ //# sourceMappingURL=condition.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.d.mts","names":[],"sources":["../../src/dsl/condition.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBA+BiB;WACN;;;qBAgBE,SAAM,GAAO,cAAY;;;;;;;;KAsBjC,QAAQ,KAAK,gBAAgB,KAAK,WAAW,KAAK,kBAAkB;wBAuDzD,GAAG,GAAG,KAAK,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,MAAM;;WAEN,YAAY;;WAEZ,KAAK;;;iBAIC;EACf;EACA;;iBAGe,0BAA0B;;;;;EAKzC;;EAEA,WAAW;;;;;;;;;;;;wBAaG,UAAU,IAAI,WAAW,MAAM,eAAe,oBAAoB"}
@@ -0,0 +1,178 @@
1
+ import { captureLoc } from "../provenance.mjs";
2
+ import { durationIR } from "./base.mjs";
3
+ import { PAYLOAD_PATH, payloadRefs, triggerRefOf } from "./refs.mjs";
4
+ // src/dsl/condition.ts
5
+ const cond = (ir, loc) => {
6
+ return {
7
+ __condition: true,
8
+ ir: loc === void 0 ? ir : {
9
+ ...ir,
10
+ meta: { loc }
11
+ }
12
+ };
13
+ };
14
+ /** @internal unwrap a condition to its IR — used by flow/trigger/workflow builders */
15
+ const condIR = (c) => {
16
+ const ir = c.ir;
17
+ if (ir === void 0) throw new Error("Condition was not created by this DSL — use the predicates (eq/gt/…), combinators (and/or/not) or segment()");
18
+ return ir;
19
+ };
20
+ /**
21
+ * A payload ref identifies itself by a symbol key, and a user-property ref by
22
+ * the absence of one. Nothing here reads a *string* key off the reference: a
23
+ * payload ref hands out sub-refs for every string key, so a field named `type`
24
+ * or `path` would otherwise answer in place of the ref itself.
25
+ */
26
+ const payloadPathOf = (ref) => ref[PAYLOAD_PATH];
27
+ function prop(ref, op, value, values, loc) {
28
+ const operands = {
29
+ op,
30
+ ...value !== void 0 ? { value } : {},
31
+ ...values !== void 0 ? { values: [...values] } : {}
32
+ };
33
+ const triggerRef = triggerRefOf(ref);
34
+ if (triggerRef !== void 0) return cond({
35
+ type: "trigger_payload",
36
+ event: triggerRef.event,
37
+ path: triggerRef.path,
38
+ ...operands
39
+ }, loc);
40
+ const payloadPath = payloadPathOf(ref);
41
+ return cond({
42
+ type: payloadPath !== void 0 ? "payload" : "property",
43
+ path: payloadPath ?? ref.path,
44
+ ...operands
45
+ }, loc);
46
+ }
47
+ function eq(ref, value) {
48
+ return prop(ref, "eq", value, void 0, captureLoc(eq));
49
+ }
50
+ function ne(ref, value) {
51
+ return prop(ref, "ne", value, void 0, captureLoc(ne));
52
+ }
53
+ function gt(ref, value) {
54
+ return prop(ref, "gt", value, void 0, captureLoc(gt));
55
+ }
56
+ function gte(ref, value) {
57
+ return prop(ref, "gte", value, void 0, captureLoc(gte));
58
+ }
59
+ function lt(ref, value) {
60
+ return prop(ref, "lt", value, void 0, captureLoc(lt));
61
+ }
62
+ function lte(ref, value) {
63
+ return prop(ref, "lte", value, void 0, captureLoc(lte));
64
+ }
65
+ function between(ref, min, max) {
66
+ return prop(ref, "between", void 0, [min, max], captureLoc(between));
67
+ }
68
+ function notBetween(ref, min, max) {
69
+ return prop(ref, "not_between", void 0, [min, max], captureLoc(notBetween));
70
+ }
71
+ function inArray(ref, values) {
72
+ return prop(ref, "in_array", void 0, values, captureLoc(inArray));
73
+ }
74
+ function notInArray(ref, values) {
75
+ return prop(ref, "not_in_array", void 0, values, captureLoc(notInArray));
76
+ }
77
+ function exists(ref) {
78
+ return prop(ref, "exists", void 0, void 0, captureLoc(exists));
79
+ }
80
+ function notExists(ref) {
81
+ return prop(ref, "not_exists", void 0, void 0, captureLoc(notExists));
82
+ }
83
+ function contains(ref, value) {
84
+ return prop(ref, "contains", value, void 0, captureLoc(contains));
85
+ }
86
+ function notContains(ref, value) {
87
+ return prop(ref, "not_contains", value, void 0, captureLoc(notContains));
88
+ }
89
+ /**
90
+ * @internal A duration that has to elapse — a wait's timeout, a goal's window, a performed
91
+ * window. Zero parses as a valid duration but means "never" or "always" depending on the node,
92
+ * and either way it is not what the author meant.
93
+ */
94
+ function positiveDurationIR(value, what) {
95
+ const ir = durationIR(value);
96
+ if (ir.ms <= 0) throw new Error(`${what} must be positive, got '${value}'`);
97
+ return ir;
98
+ }
99
+ function performed(event, whereOrOpts, maybeOpts) {
100
+ const where = typeof whereOrOpts === "function" ? whereOrOpts : void 0;
101
+ const opts = typeof whereOrOpts === "function" ? maybeOpts : whereOrOpts;
102
+ if (opts?.count !== void 0 && (!Number.isInteger(opts.count) || opts.count < 1)) throw new Error(`performed(): count must be a positive integer, got ${String(opts.count)}`);
103
+ return cond({
104
+ type: "performed",
105
+ event: event.name,
106
+ ...where !== void 0 ? { where: condIR(where(payloadRefs())) } : {},
107
+ ...opts?.within !== void 0 ? { within: positiveDurationIR(opts.within, "performed(): within") } : {},
108
+ ...opts?.count !== void 0 ? { count: opts.count } : {}
109
+ }, captureLoc(performed));
110
+ }
111
+ /**
112
+ * The user can be reached on a channel right now. For push it asks the host's
113
+ * device directory (at least one device listed) — the engine keeps no device
114
+ * state, so this is the way to branch on "has the app on a device that allowed
115
+ * notifications"; for the other channels it checks the recipient property
116
+ * (`email`, `phone`, …). Inside `waitUntil` it wakes on device changes
117
+ * (`POST /devices/changed`) or profile updates respectively.
118
+ *
119
+ * .branch([reachable('push'), (w) => w.push(tip)], (w) => w.email(tip))
120
+ *
121
+ * (`.prefer([push.tip, email.tip], props)` is this branch for one push and one email.)
122
+ */
123
+ function reachable(channel) {
124
+ return cond({
125
+ type: "reachable",
126
+ channel
127
+ }, captureLoc(reachable));
128
+ }
129
+ /** Condition combinators: nest freely. */
130
+ function and(...conditions) {
131
+ return cond({
132
+ type: "and",
133
+ conditions: conditions.map(condIR)
134
+ }, captureLoc(and));
135
+ }
136
+ function or(...conditions) {
137
+ return cond({
138
+ type: "or",
139
+ conditions: conditions.map(condIR)
140
+ }, captureLoc(or));
141
+ }
142
+ function not(condition) {
143
+ return cond({
144
+ type: "not",
145
+ condition: condIR(condition)
146
+ }, captureLoc(not));
147
+ }
148
+ /**
149
+ * Segment definition. `name` and `description` are optional labels: metadata,
150
+ * dropped before hashing, and what the studio shows.
151
+ *
152
+ * export const purchaser = segment({
153
+ * id: 'purchaser',
154
+ * name: 'Purchased (last 30d)',
155
+ * condition: performed(e.purchase, { within: '30 days' }),
156
+ * });
157
+ */
158
+ function segment({ id, condition, name, description }) {
159
+ const meta = {
160
+ ...name === void 0 ? {} : { name },
161
+ ...description === void 0 ? {} : { description }
162
+ };
163
+ return {
164
+ __condition: true,
165
+ __segment: true,
166
+ id,
167
+ ir: {
168
+ type: "segment",
169
+ segment: id
170
+ },
171
+ definition: condIR(condition),
172
+ loc: captureLoc(segment),
173
+ meta: Object.keys(meta).length === 0 ? void 0 : meta
174
+ };
175
+ }
176
+ export { and, between, condIR, contains, eq, exists, gt, gte, inArray, lt, lte, ne, not, notBetween, notContains, notExists, notInArray, or, performed, positiveDurationIR, reachable, segment };
177
+
178
+ //# sourceMappingURL=condition.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.mjs","names":[],"sources":["../../src/dsl/condition.ts"],"sourcesContent":["import type { ConditionIR, DurationIR, SourceLocIR } from '../ir';\nimport { captureLoc } from '../provenance';\nimport { type Duration, durationIR } from './base';\nimport {\n type EventRef,\n PAYLOAD_PATH,\n type PayloadRef,\n type PayloadRefs,\n type TriggerPayloadRef,\n type UserPropertyRef,\n payloadRefs,\n triggerRefOf,\n} from './refs';\nimport type { Channel } from './template';\n\n/**\n * Conditions — drizzle-style predicate expressions: free functions (eq/gt/…)\n * composed with and/or/not, plus `segment` for naming an expression as a\n * top-level asset. A condition is an opaque handle wrapping its ConditionIR.\n *\n * Type techniques:\n * - Types flow in from the reference's phantom type; operator applicability is\n * a signature constraint (gt only takes string|number refs, contains only\n * string ones), mirroring customer.io's condition panel.\n * - Value parameters are always NoInfer: types come from the reference only,\n * which stops eq(ref, 'typo') from widening T to include the bad value.\n *\n * TODO: JSON array 'where at least one'、JSON object 'has the property'。\n */\n\n/** Opaque condition handle — what predicates, combinators and segments all produce. */\nexport interface Condition {\n readonly __condition: true;\n}\n\ninterface ConditionInternal extends Condition {\n readonly ir: ConditionIR;\n}\n\nconst cond = (ir: ConditionIR, loc?: SourceLocIR): Condition => {\n const impl: ConditionInternal = {\n __condition: true,\n ir: loc === undefined ? ir : { ...ir, meta: { loc } },\n };\n return impl;\n};\n\n/** @internal unwrap a condition to its IR — used by flow/trigger/workflow builders */\nexport const condIR = (c: Condition): ConditionIR => {\n // Partial: the cast is unsound for hand-rolled objects — exactly what this checks\n const ir = (c as Partial<ConditionInternal>).ir;\n if (ir === undefined) {\n // A hand-rolled `{ __condition: true }` would otherwise surface as a\n // baffling zod error at toIR() time, far away from the actual mistake.\n throw new Error(\n 'Condition was not created by this DSL — use the predicates (eq/gt/…), combinators (and/or/not) or segment()'\n );\n }\n return ir;\n};\n\ntype Scalar = string | number | boolean;\n\n/**\n * Predicates accept three kinds of reference: a user property (profile\n * condition), an event payload field (only valid inside a `where`) or a field\n * of the triggering event's payload (`t.payload.x`, only valid in the workflow\n * that event triggers). All produce `Condition`, so the bundle compiler\n * enforces the placement.\n */\ntype CondRef<T> = UserPropertyRef<T> | PayloadRef<T> | TriggerPayloadRef<T>;\n\n/**\n * A payload ref identifies itself by a symbol key, and a user-property ref by\n * the absence of one. Nothing here reads a *string* key off the reference: a\n * payload ref hands out sub-refs for every string key, so a field named `type`\n * or `path` would otherwise answer in place of the ref itself.\n */\nconst payloadPathOf = (ref: CondRef<unknown>): string | undefined =>\n (ref as Partial<PayloadRef<unknown>>)[PAYLOAD_PATH];\n\nfunction prop(\n ref: CondRef<unknown>,\n op:\n | 'eq'\n | 'ne'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'between'\n | 'not_between'\n | 'in_array'\n | 'not_in_array'\n | 'exists'\n | 'not_exists'\n | 'contains'\n | 'not_contains',\n value?: Scalar,\n values?: readonly Scalar[],\n loc?: SourceLocIR\n): Condition {\n const operands = {\n op,\n ...(value !== undefined ? { value } : {}),\n ...(values !== undefined ? { values: [...values] } : {}),\n };\n const triggerRef = triggerRefOf(ref);\n if (triggerRef !== undefined) {\n return cond(\n { type: 'trigger_payload', event: triggerRef.event, path: triggerRef.path, ...operands },\n loc\n );\n }\n const payloadPath = payloadPathOf(ref);\n return cond(\n {\n type: payloadPath !== undefined ? 'payload' : 'property',\n path: payloadPath ?? (ref as UserPropertyRef<unknown>).path,\n ...operands,\n },\n loc\n );\n}\n\nexport function eq<T>(ref: CondRef<T>, value: NoInfer<T>): Condition {\n return prop(ref, 'eq', value as Scalar, undefined, captureLoc(eq));\n}\nexport function ne<T>(ref: CondRef<T>, value: NoInfer<T>): Condition {\n return prop(ref, 'ne', value as Scalar, undefined, captureLoc(ne));\n}\nexport function gt<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition {\n return prop(ref, 'gt', value, undefined, captureLoc(gt));\n}\nexport function gte<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition {\n return prop(ref, 'gte', value, undefined, captureLoc(gte));\n}\nexport function lt<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition {\n return prop(ref, 'lt', value, undefined, captureLoc(lt));\n}\nexport function lte<T extends string | number>(ref: CondRef<T>, value: NoInfer<T>): Condition {\n return prop(ref, 'lte', value, undefined, captureLoc(lte));\n}\nexport function between<T extends string | number>(\n ref: CondRef<T>,\n min: NoInfer<T>,\n max: NoInfer<T>\n): Condition {\n return prop(ref, 'between', undefined, [min, max], captureLoc(between));\n}\nexport function notBetween<T extends string | number>(\n ref: CondRef<T>,\n min: NoInfer<T>,\n max: NoInfer<T>\n): Condition {\n return prop(ref, 'not_between', undefined, [min, max], captureLoc(notBetween));\n}\nexport function inArray<T>(ref: CondRef<T>, values: readonly NoInfer<T>[]): Condition {\n return prop(ref, 'in_array', undefined, values as readonly Scalar[], captureLoc(inArray));\n}\nexport function notInArray<T>(ref: CondRef<T>, values: readonly NoInfer<T>[]): Condition {\n return prop(ref, 'not_in_array', undefined, values as readonly Scalar[], captureLoc(notInArray));\n}\nexport function exists(ref: CondRef<unknown>): Condition {\n return prop(ref, 'exists', undefined, undefined, captureLoc(exists));\n}\nexport function notExists(ref: CondRef<unknown>): Condition {\n return prop(ref, 'not_exists', undefined, undefined, captureLoc(notExists));\n}\nexport function contains<T extends string>(ref: CondRef<T>, value: string): Condition {\n return prop(ref, 'contains', value, undefined, captureLoc(contains));\n}\nexport function notContains<T extends string>(ref: CondRef<T>, value: string): Condition {\n return prop(ref, 'not_contains', value, undefined, captureLoc(notContains));\n}\n\nexport interface PerformedOptions {\n /** Only occurrences this recent count; must be a positive duration. */\n within?: Duration;\n /** At least this many occurrences; a positive integer (1 is the default). */\n count?: number;\n}\n\n/**\n * @internal A duration that has to elapse — a wait's timeout, a goal's window, a performed\n * window. Zero parses as a valid duration but means \"never\" or \"always\" depending on the node,\n * and either way it is not what the author meant.\n */\nexport function positiveDurationIR(value: Duration, what: string): DurationIR {\n const ir = durationIR(value);\n if (ir.ms <= 0) throw new Error(`${what} must be positive, got '${value}'`);\n return ir;\n}\n\n/** A payload where clause: an arrow taking the typed payload-ref table. Runs once at construction — the result is a serializable condition tree in IR, never a closure. */\nexport type PayloadWhere<P> = (p: PayloadRefs<P>) => Condition;\n\n/**\n * Event predicate: performed an event (optionally within a window / at least N\n * times). \"Did not perform\" is `not(performed(...))` — expressed by the\n * combinator, so there is no separate notPerformed.\n *\n * The optional second argument narrows which events count by their payload —\n * an arrow receiving a typed payload reference table, with the ordinary\n * predicates applying. It compiles to a `where` subtree in IR (data the UI\n * renders), not a runtime closure:\n *\n * performed(e.login)\n * performed(e.login, (p) => and(eq(p.platform, 'web'), eq(p.tags.utm_source, 'meta')))\n * performed(e.purchase, (p) => gt(p.value, 100), { within: '30 days', count: 2 })\n * performed(e.purchase, { within: '30 days' }) // options without a where\n *\n * Time anchoring: evaluated inside a `goal` the count starts at workflow\n * entry, inside `waitUntil` at the moment the wait began (the engine anchors\n * them — a conversion or a wake must not be satisfied by pre-existing\n * history). Everywhere else (branch/filter/exitWhen/segments) it looks over\n * full history, bounded only by `within`.\n */\nexport function performed<P>(event: EventRef<P>, opts?: PerformedOptions): Condition;\nexport function performed<P>(\n event: EventRef<P>,\n where: PayloadWhere<P>,\n opts?: PerformedOptions\n): Condition;\nexport function performed<P>(\n event: EventRef<P>,\n whereOrOpts?: PayloadWhere<P> | PerformedOptions,\n maybeOpts?: PerformedOptions\n): Condition {\n const where = typeof whereOrOpts === 'function' ? whereOrOpts : undefined;\n const opts = typeof whereOrOpts === 'function' ? maybeOpts : whereOrOpts;\n // count: 0 is satisfied by nobody having done anything, and a fraction is never reached\n if (opts?.count !== undefined && (!Number.isInteger(opts.count) || opts.count < 1)) {\n throw new Error(`performed(): count must be a positive integer, got ${String(opts.count)}`);\n }\n return cond(\n {\n type: 'performed',\n event: event.name,\n ...(where !== undefined ? { where: condIR(where(payloadRefs<P>())) } : {}),\n ...(opts?.within !== undefined\n ? { within: positiveDurationIR(opts.within, 'performed(): within') }\n : {}),\n ...(opts?.count !== undefined ? { count: opts.count } : {}),\n },\n captureLoc(performed)\n );\n}\n\n/**\n * The user can be reached on a channel right now. For push it asks the host's\n * device directory (at least one device listed) — the engine keeps no device\n * state, so this is the way to branch on \"has the app on a device that allowed\n * notifications\"; for the other channels it checks the recipient property\n * (`email`, `phone`, …). Inside `waitUntil` it wakes on device changes\n * (`POST /devices/changed`) or profile updates respectively.\n *\n * .branch([reachable('push'), (w) => w.push(tip)], (w) => w.email(tip))\n *\n * (`.prefer([push.tip, email.tip], props)` is this branch for one push and one email.)\n */\nexport function reachable(channel: Channel): Condition {\n return cond({ type: 'reachable', channel }, captureLoc(reachable));\n}\n\n/** Condition combinators: nest freely. */\nexport function and(...conditions: readonly Condition[]): Condition {\n return cond({ type: 'and', conditions: conditions.map(condIR) }, captureLoc(and));\n}\nexport function or(...conditions: readonly Condition[]): Condition {\n return cond({ type: 'or', conditions: conditions.map(condIR) }, captureLoc(or));\n}\nexport function not(condition: Condition): Condition {\n return cond({ type: 'not', condition: condIR(condition) }, captureLoc(not));\n}\n\n/**\n * Segment: a named condition expression and a top-level asset — it shows up in\n * the UI sidebar, is reusable across workflows, is referenced by id in IR,\n * and has a continuously materialized membership count (the prerequisite for\n * segment triggers). Anonymous reuse is just a const expression; a one-off\n * check is an inline expression at the use site.\n * TODO, to match customer.io's panel: form / page / device / screen /\n * opt-out / message data(email opened、sms clicked、webhook …)\n */\nexport interface SegmentRef extends Condition {\n readonly __segment: true;\n /** Wire identity: segment references and the membership store are keyed on it (`SegmentIR.id`). */\n readonly id: string;\n}\n\n/** @internal the compiled shape behind a SegmentRef — compileBundle reads definition/loc off it */\nexport interface SegmentInternal extends SegmentRef {\n readonly ir: ConditionIR;\n /** Human label / description; metadata, so never part of the hash. */\n readonly meta: SegmentMeta | undefined;\n /** The segment's own definition (SegmentIR.condition), as opposed to a reference by id. */\n readonly definition: ConditionIR;\n /** Callsite of the segment() call (provenance; lands in SegmentIR.meta.loc). */\n readonly loc: SourceLocIR | undefined;\n}\n\n/** Labels for a segment: what the studio shows instead of the wire key. */\nexport interface SegmentMeta {\n name?: string;\n description?: string;\n}\n\nexport interface SegmentDefinition extends SegmentMeta {\n /**\n * Wire identity — by-name references and the membership store are keyed on\n * it, so it is not something to rename for readability.\n */\n id: string;\n /** Who is in the segment; the predicates already checked its types. */\n condition: Condition;\n}\n\n/**\n * Segment definition. `name` and `description` are optional labels: metadata,\n * dropped before hashing, and what the studio shows.\n *\n * export const purchaser = segment({\n * id: 'purchaser',\n * name: 'Purchased (last 30d)',\n * condition: performed(e.purchase, { within: '30 days' }),\n * });\n */\nexport function segment({ id, condition, name, description }: SegmentDefinition): SegmentRef {\n const meta: SegmentMeta = {\n ...(name === undefined ? {} : { name }),\n ...(description === undefined ? {} : { description }),\n };\n const impl: SegmentInternal = {\n __condition: true,\n __segment: true,\n id,\n ir: { type: 'segment', segment: id },\n definition: condIR(condition),\n loc: captureLoc(segment),\n meta: Object.keys(meta).length === 0 ? undefined : meta,\n };\n return impl;\n}\n"],"mappings":";;;;AAuCA,MAAM,QAAQ,IAAiB,QAAiC;CAK9D,OAAO;EAHL,aAAa;EACb,IAAI,QAAQ,KAAA,IAAY,KAAK;GAAE,GAAG;GAAI,MAAM,EAAE,IAAI;EAAE;CAE5C;AACZ;;AAGA,MAAa,UAAU,MAA8B;CAEnD,MAAM,KAAM,EAAiC;CAC7C,IAAI,OAAO,KAAA,GAGT,MAAM,IAAI,MACR,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