@hogsend/engine 0.66.0 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (760) hide show
  1. package/README.md +3 -2
  2. package/dist/account-links/__fixtures__/fake-fetch.d.ts +38 -0
  3. package/dist/account-links/__fixtures__/fake-fetch.d.ts.map +1 -0
  4. package/dist/account-links/battlenet.d.ts +36 -0
  5. package/dist/account-links/battlenet.d.ts.map +1 -0
  6. package/dist/account-links/epic.d.ts +36 -0
  7. package/dist/account-links/epic.d.ts.map +1 -0
  8. package/dist/account-links/index.d.ts +7 -0
  9. package/dist/account-links/index.d.ts.map +1 -0
  10. package/dist/account-links/riot.d.ts +35 -0
  11. package/dist/account-links/riot.d.ts.map +1 -0
  12. package/dist/account-links/steam.d.ts +35 -0
  13. package/dist/account-links/steam.d.ts.map +1 -0
  14. package/dist/account-links/twitch.d.ts +38 -0
  15. package/dist/account-links/twitch.d.ts.map +1 -0
  16. package/dist/account-links/xbox.d.ts +39 -0
  17. package/dist/account-links/xbox.d.ts.map +1 -0
  18. package/dist/app.d.ts +50 -0
  19. package/dist/app.d.ts.map +1 -0
  20. package/dist/buckets/bucket-access.d.ts +60 -0
  21. package/dist/buckets/bucket-access.d.ts.map +1 -0
  22. package/dist/buckets/bucket-reactions.d.ts +100 -0
  23. package/dist/buckets/bucket-reactions.d.ts.map +1 -0
  24. package/dist/buckets/check-membership.d.ts +105 -0
  25. package/dist/buckets/check-membership.d.ts.map +1 -0
  26. package/dist/buckets/define-bucket.d.ts +53 -0
  27. package/dist/buckets/define-bucket.d.ts.map +1 -0
  28. package/dist/buckets/membership-epoch.d.ts +74 -0
  29. package/dist/buckets/membership-epoch.d.ts.map +1 -0
  30. package/dist/buckets/registry-singleton.d.ts +6 -0
  31. package/dist/buckets/registry-singleton.d.ts.map +1 -0
  32. package/dist/buckets/registry.d.ts +59 -0
  33. package/dist/buckets/registry.d.ts.map +1 -0
  34. package/dist/campaigns/cohort-sql.d.ts +54 -0
  35. package/dist/campaigns/cohort-sql.d.ts.map +1 -0
  36. package/dist/campaigns/define-campaign.d.ts +105 -0
  37. package/dist/campaigns/define-campaign.d.ts.map +1 -0
  38. package/dist/campaigns/reconcile.d.ts +13 -0
  39. package/dist/campaigns/reconcile.d.ts.map +1 -0
  40. package/dist/campaigns/steps.d.ts +29 -0
  41. package/dist/campaigns/steps.d.ts.map +1 -0
  42. package/dist/cold-connect/index.d.ts +98 -0
  43. package/dist/cold-connect/index.d.ts.map +1 -0
  44. package/dist/cold-connect/page.d.ts +69 -0
  45. package/dist/cold-connect/page.d.ts.map +1 -0
  46. package/dist/cold-connect/throttle.d.ts +39 -0
  47. package/dist/cold-connect/throttle.d.ts.map +1 -0
  48. package/dist/cold-connect/token.d.ts +57 -0
  49. package/dist/cold-connect/token.d.ts.map +1 -0
  50. package/dist/connectors/action-registry-singleton.d.ts +21 -0
  51. package/dist/connectors/action-registry-singleton.d.ts.map +1 -0
  52. package/dist/connectors/define-action.d.ts +117 -0
  53. package/dist/connectors/define-action.d.ts.map +1 -0
  54. package/dist/connectors/define-connector.d.ts +172 -0
  55. package/dist/connectors/define-connector.d.ts.map +1 -0
  56. package/dist/connectors/presets/index.d.ts +17 -0
  57. package/dist/connectors/presets/index.d.ts.map +1 -0
  58. package/dist/connectors/registry-singleton.d.ts +34 -0
  59. package/dist/connectors/registry-singleton.d.ts.map +1 -0
  60. package/dist/connectors/runtime.d.ts +68 -0
  61. package/dist/connectors/runtime.d.ts.map +1 -0
  62. package/dist/container.d.ts +678 -0
  63. package/dist/container.d.ts.map +1 -0
  64. package/dist/destinations/define-destination.d.ts +96 -0
  65. package/dist/destinations/define-destination.d.ts.map +1 -0
  66. package/dist/destinations/presets/index.d.ts +42 -0
  67. package/dist/destinations/presets/index.d.ts.map +1 -0
  68. package/dist/destinations/presets/posthog.d.ts +12 -0
  69. package/dist/destinations/presets/posthog.d.ts.map +1 -0
  70. package/dist/destinations/presets/segment.d.ts +15 -0
  71. package/dist/destinations/presets/segment.d.ts.map +1 -0
  72. package/dist/destinations/presets/slack.d.ts +10 -0
  73. package/dist/destinations/presets/slack.d.ts.map +1 -0
  74. package/dist/destinations/presets/webhook.d.ts +14 -0
  75. package/dist/destinations/presets/webhook.d.ts.map +1 -0
  76. package/dist/destinations/registry-singleton.d.ts +44 -0
  77. package/dist/destinations/registry-singleton.d.ts.map +1 -0
  78. package/dist/env.d.ts +119 -0
  79. package/dist/env.d.ts.map +1 -0
  80. package/dist/flags/reconcile.d.ts +36 -0
  81. package/dist/flags/reconcile.d.ts.map +1 -0
  82. package/dist/index.d.ts +210 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/journeys/authoring.d.ts +15 -0
  85. package/dist/journeys/authoring.d.ts.map +1 -0
  86. package/dist/journeys/client-defaults-singleton.d.ts +16 -0
  87. package/dist/journeys/client-defaults-singleton.d.ts.map +1 -0
  88. package/dist/journeys/constants.d.ts +32 -0
  89. package/dist/journeys/constants.d.ts.map +1 -0
  90. package/dist/journeys/define-journey.d.ts +33 -0
  91. package/dist/journeys/define-journey.d.ts.map +1 -0
  92. package/dist/journeys/durable-law-harness.d.ts +74 -0
  93. package/dist/journeys/durable-law-harness.d.ts.map +1 -0
  94. package/dist/journeys/errors.d.ts +13 -0
  95. package/dist/journeys/errors.d.ts.map +1 -0
  96. package/dist/journeys/execute-journey-run.d.ts +160 -0
  97. package/dist/journeys/execute-journey-run.d.ts.map +1 -0
  98. package/dist/journeys/graph/build-graph.d.ts +24 -0
  99. package/dist/journeys/graph/build-graph.d.ts.map +1 -0
  100. package/dist/journeys/group-scope.d.ts +56 -0
  101. package/dist/journeys/group-scope.d.ts.map +1 -0
  102. package/dist/journeys/journey-boundary.d.ts +264 -0
  103. package/dist/journeys/journey-boundary.d.ts.map +1 -0
  104. package/dist/journeys/journey-context.d.ts +60 -0
  105. package/dist/journeys/journey-context.d.ts.map +1 -0
  106. package/dist/journeys/journey-log.d.ts +42 -0
  107. package/dist/journeys/journey-log.d.ts.map +1 -0
  108. package/dist/journeys/journey-source-locations-singleton.d.ts +6 -0
  109. package/dist/journeys/journey-source-locations-singleton.d.ts.map +1 -0
  110. package/dist/journeys/journey-sources-singleton.d.ts +5 -0
  111. package/dist/journeys/journey-sources-singleton.d.ts.map +1 -0
  112. package/dist/journeys/journey-task-factory.d.ts +11 -0
  113. package/dist/journeys/journey-task-factory.d.ts.map +1 -0
  114. package/dist/journeys/journey-task-runtime.d.ts +2 -0
  115. package/dist/journeys/journey-task-runtime.d.ts.map +1 -0
  116. package/dist/journeys/journey-version.d.ts +71 -0
  117. package/dist/journeys/journey-version.d.ts.map +1 -0
  118. package/dist/journeys/record-once.d.ts +56 -0
  119. package/dist/journeys/record-once.d.ts.map +1 -0
  120. package/dist/journeys/registry-singleton.d.ts +6 -0
  121. package/dist/journeys/registry-singleton.d.ts.map +1 -0
  122. package/dist/journeys/registry.d.ts +59 -0
  123. package/dist/journeys/registry.d.ts.map +1 -0
  124. package/dist/journeys/with-durable-gate.d.ts +97 -0
  125. package/dist/journeys/with-durable-gate.d.ts.map +1 -0
  126. package/dist/lib/account-link-emit.d.ts +69 -0
  127. package/dist/lib/account-link-emit.d.ts.map +1 -0
  128. package/dist/lib/account-link-events.d.ts +128 -0
  129. package/dist/lib/account-link-events.d.ts.map +1 -0
  130. package/dist/lib/account-link-hooks.d.ts +32 -0
  131. package/dist/lib/account-link-hooks.d.ts.map +1 -0
  132. package/dist/lib/account-link-ingest.d.ts +78 -0
  133. package/dist/lib/account-link-ingest.d.ts.map +1 -0
  134. package/dist/lib/account-link-nonce.d.ts +29 -0
  135. package/dist/lib/account-link-nonce.d.ts.map +1 -0
  136. package/dist/lib/account-link-origins.d.ts +37 -0
  137. package/dist/lib/account-link-origins.d.ts.map +1 -0
  138. package/dist/lib/account-link-pkce.d.ts +48 -0
  139. package/dist/lib/account-link-pkce.d.ts.map +1 -0
  140. package/dist/lib/account-link-provider-registry.d.ts +35 -0
  141. package/dist/lib/account-link-provider-registry.d.ts.map +1 -0
  142. package/dist/lib/account-link-throttle.d.ts +76 -0
  143. package/dist/lib/account-link-throttle.d.ts.map +1 -0
  144. package/dist/lib/account-link-url.d.ts +41 -0
  145. package/dist/lib/account-link-url.d.ts.map +1 -0
  146. package/dist/lib/account-links-from-env.d.ts +62 -0
  147. package/dist/lib/account-links-from-env.d.ts.map +1 -0
  148. package/dist/lib/account-links.d.ts +353 -0
  149. package/dist/lib/account-links.d.ts.map +1 -0
  150. package/dist/lib/agent/config.d.ts +14 -0
  151. package/dist/lib/agent/config.d.ts.map +1 -0
  152. package/dist/lib/agent/proposals.d.ts +52 -0
  153. package/dist/lib/agent/proposals.d.ts.map +1 -0
  154. package/dist/lib/agent/provider.d.ts +9 -0
  155. package/dist/lib/agent/provider.d.ts.map +1 -0
  156. package/dist/lib/agent/risk.d.ts +24 -0
  157. package/dist/lib/agent/risk.d.ts.map +1 -0
  158. package/dist/lib/agent/system-prompt.d.ts +8 -0
  159. package/dist/lib/agent/system-prompt.d.ts.map +1 -0
  160. package/dist/lib/agent/tools.d.ts +258 -0
  161. package/dist/lib/agent/tools.d.ts.map +1 -0
  162. package/dist/lib/alerting.d.ts +7 -0
  163. package/dist/lib/alerting.d.ts.map +1 -0
  164. package/dist/lib/analytics-adapter.d.ts +24 -0
  165. package/dist/lib/analytics-adapter.d.ts.map +1 -0
  166. package/dist/lib/analytics-identity.d.ts +60 -0
  167. package/dist/lib/analytics-identity.d.ts.map +1 -0
  168. package/dist/lib/analytics-provider-registry.d.ts +20 -0
  169. package/dist/lib/analytics-provider-registry.d.ts.map +1 -0
  170. package/dist/lib/analytics-providers-from-env.d.ts +41 -0
  171. package/dist/lib/analytics-providers-from-env.d.ts.map +1 -0
  172. package/dist/lib/analytics-singleton.d.ts +10 -0
  173. package/dist/lib/analytics-singleton.d.ts.map +1 -0
  174. package/dist/lib/api-key-hash.d.ts +9 -0
  175. package/dist/lib/api-key-hash.d.ts.map +1 -0
  176. package/dist/lib/app-secret.d.ts +29 -0
  177. package/dist/lib/app-secret.d.ts.map +1 -0
  178. package/dist/lib/attachments.d.ts +53 -0
  179. package/dist/lib/attachments.d.ts.map +1 -0
  180. package/dist/lib/attribution-backfill.d.ts +48 -0
  181. package/dist/lib/attribution-backfill.d.ts.map +1 -0
  182. package/dist/lib/attribution.d.ts +44 -0
  183. package/dist/lib/attribution.d.ts.map +1 -0
  184. package/dist/lib/auth.d.ts +136 -0
  185. package/dist/lib/auth.d.ts.map +1 -0
  186. package/dist/lib/backfill.d.ts +41 -0
  187. package/dist/lib/backfill.d.ts.map +1 -0
  188. package/dist/lib/banner.d.ts +52 -0
  189. package/dist/lib/banner.d.ts.map +1 -0
  190. package/dist/lib/blueprint-lock.d.ts +19 -0
  191. package/dist/lib/blueprint-lock.d.ts.map +1 -0
  192. package/dist/lib/blueprints.d.ts +573 -0
  193. package/dist/lib/blueprints.d.ts.map +1 -0
  194. package/dist/lib/boot-api-key.d.ts +38 -0
  195. package/dist/lib/boot-api-key.d.ts.map +1 -0
  196. package/dist/lib/boot.d.ts +23 -0
  197. package/dist/lib/boot.d.ts.map +1 -0
  198. package/dist/lib/bootstrap-admin.d.ts +33 -0
  199. package/dist/lib/bootstrap-admin.d.ts.map +1 -0
  200. package/dist/lib/bot-prefetch.d.ts +21 -0
  201. package/dist/lib/bot-prefetch.d.ts.map +1 -0
  202. package/dist/lib/bucket-emit.d.ts +75 -0
  203. package/dist/lib/bucket-emit.d.ts.map +1 -0
  204. package/dist/lib/bucket-posthog-sync.d.ts +29 -0
  205. package/dist/lib/bucket-posthog-sync.d.ts.map +1 -0
  206. package/dist/lib/campaign-send-key.d.ts +31 -0
  207. package/dist/lib/campaign-send-key.d.ts.map +1 -0
  208. package/dist/lib/connector-actions.d.ts +83 -0
  209. package/dist/lib/connector-actions.d.ts.map +1 -0
  210. package/dist/lib/connector-heartbeat.d.ts +35 -0
  211. package/dist/lib/connector-heartbeat.d.ts.map +1 -0
  212. package/dist/lib/connector-link-codes.d.ts +105 -0
  213. package/dist/lib/connector-link-codes.d.ts.map +1 -0
  214. package/dist/lib/connector-state.d.ts +97 -0
  215. package/dist/lib/connector-state.d.ts.map +1 -0
  216. package/dist/lib/contacts.d.ts +622 -0
  217. package/dist/lib/contacts.d.ts.map +1 -0
  218. package/dist/lib/conversion-dispatch.d.ts +98 -0
  219. package/dist/lib/conversion-dispatch.d.ts.map +1 -0
  220. package/dist/lib/conversions.d.ts +75 -0
  221. package/dist/lib/conversions.d.ts.map +1 -0
  222. package/dist/lib/create-admin.d.ts +54 -0
  223. package/dist/lib/create-admin.d.ts.map +1 -0
  224. package/dist/lib/crm-deals.d.ts +66 -0
  225. package/dist/lib/crm-deals.d.ts.map +1 -0
  226. package/dist/lib/crm-ingest.d.ts +38 -0
  227. package/dist/lib/crm-ingest.d.ts.map +1 -0
  228. package/dist/lib/crm-provider-registry.d.ts +20 -0
  229. package/dist/lib/crm-provider-registry.d.ts.map +1 -0
  230. package/dist/lib/crm-registry-singleton.d.ts +18 -0
  231. package/dist/lib/crm-registry-singleton.d.ts.map +1 -0
  232. package/dist/lib/db.d.ts +3 -0
  233. package/dist/lib/db.d.ts.map +1 -0
  234. package/dist/lib/deal-money-events.d.ts +35 -0
  235. package/dist/lib/deal-money-events.d.ts.map +1 -0
  236. package/dist/lib/discord-gateway-heartbeat.d.ts +47 -0
  237. package/dist/lib/discord-gateway-heartbeat.d.ts.map +1 -0
  238. package/dist/lib/domain-status.d.ts +87 -0
  239. package/dist/lib/domain-status.d.ts.map +1 -0
  240. package/dist/lib/email-provider-registry.d.ts +30 -0
  241. package/dist/lib/email-provider-registry.d.ts.map +1 -0
  242. package/dist/lib/email-providers-from-env.d.ts +12 -0
  243. package/dist/lib/email-providers-from-env.d.ts.map +1 -0
  244. package/dist/lib/email-service-types.d.ts +189 -0
  245. package/dist/lib/email-service-types.d.ts.map +1 -0
  246. package/dist/lib/email-stats.d.ts +12 -0
  247. package/dist/lib/email-stats.d.ts.map +1 -0
  248. package/dist/lib/email.d.ts +73 -0
  249. package/dist/lib/email.d.ts.map +1 -0
  250. package/dist/lib/enrichment-ledger.d.ts +101 -0
  251. package/dist/lib/enrichment-ledger.d.ts.map +1 -0
  252. package/dist/lib/enrichment-provider-registry.d.ts +20 -0
  253. package/dist/lib/enrichment-provider-registry.d.ts.map +1 -0
  254. package/dist/lib/enrichment-providers-from-env.d.ts +13 -0
  255. package/dist/lib/enrichment-providers-from-env.d.ts.map +1 -0
  256. package/dist/lib/enrichment-registry-singleton.d.ts +9 -0
  257. package/dist/lib/enrichment-registry-singleton.d.ts.map +1 -0
  258. package/dist/lib/enrollment-guards.d.ts +28 -0
  259. package/dist/lib/enrollment-guards.d.ts.map +1 -0
  260. package/dist/lib/enrollment-policy.d.ts +25 -0
  261. package/dist/lib/enrollment-policy.d.ts.map +1 -0
  262. package/dist/lib/event-names.d.ts +27 -0
  263. package/dist/lib/event-names.d.ts.map +1 -0
  264. package/dist/lib/feed.d.ts +64 -0
  265. package/dist/lib/feed.d.ts.map +1 -0
  266. package/dist/lib/flags-registry.d.ts +23 -0
  267. package/dist/lib/flags-registry.d.ts.map +1 -0
  268. package/dist/lib/flags.d.ts +143 -0
  269. package/dist/lib/flags.d.ts.map +1 -0
  270. package/dist/lib/frequency-cap.d.ts +38 -0
  271. package/dist/lib/frequency-cap.d.ts.map +1 -0
  272. package/dist/lib/from-address.d.ts +15 -0
  273. package/dist/lib/from-address.d.ts.map +1 -0
  274. package/dist/lib/funnel-progress.d.ts +37 -0
  275. package/dist/lib/funnel-progress.d.ts.map +1 -0
  276. package/dist/lib/funnel-registry.d.ts +44 -0
  277. package/dist/lib/funnel-registry.d.ts.map +1 -0
  278. package/dist/lib/funnel-transitions.d.ts +63 -0
  279. package/dist/lib/funnel-transitions.d.ts.map +1 -0
  280. package/dist/lib/fx.d.ts +118 -0
  281. package/dist/lib/fx.d.ts.map +1 -0
  282. package/dist/lib/global-control-readout.d.ts +72 -0
  283. package/dist/lib/global-control-readout.d.ts.map +1 -0
  284. package/dist/lib/groups.d.ts +138 -0
  285. package/dist/lib/groups.d.ts.map +1 -0
  286. package/dist/lib/hatchet-duration.d.ts +14 -0
  287. package/dist/lib/hatchet-duration.d.ts.map +1 -0
  288. package/dist/lib/hatchet.d.ts +3 -0
  289. package/dist/lib/hatchet.d.ts.map +1 -0
  290. package/dist/lib/headers.d.ts +8 -0
  291. package/dist/lib/headers.d.ts.map +1 -0
  292. package/dist/lib/holdout.d.ts +36 -0
  293. package/dist/lib/holdout.d.ts.map +1 -0
  294. package/dist/lib/html.d.ts +5 -0
  295. package/dist/lib/html.d.ts.map +1 -0
  296. package/dist/lib/identity-service.d.ts +60 -0
  297. package/dist/lib/identity-service.d.ts.map +1 -0
  298. package/dist/lib/identity-token.d.ts +81 -0
  299. package/dist/lib/identity-token.d.ts.map +1 -0
  300. package/dist/lib/ingestion.d.ts +218 -0
  301. package/dist/lib/ingestion.d.ts.map +1 -0
  302. package/dist/lib/journey-lift.d.ts +56 -0
  303. package/dist/lib/journey-lift.d.ts.map +1 -0
  304. package/dist/lib/journey-suppress.d.ts +59 -0
  305. package/dist/lib/journey-suppress.d.ts.map +1 -0
  306. package/dist/lib/leader-lease.d.ts +36 -0
  307. package/dist/lib/leader-lease.d.ts.map +1 -0
  308. package/dist/lib/lift-stats.d.ts +46 -0
  309. package/dist/lib/lift-stats.d.ts.map +1 -0
  310. package/dist/lib/links.d.ts +186 -0
  311. package/dist/lib/links.d.ts.map +1 -0
  312. package/dist/lib/load-optional-plugin.d.ts +47 -0
  313. package/dist/lib/load-optional-plugin.d.ts.map +1 -0
  314. package/dist/lib/logger.d.ts +4 -0
  315. package/dist/lib/logger.d.ts.map +1 -0
  316. package/dist/lib/mailer.d.ts +43 -0
  317. package/dist/lib/mailer.d.ts.map +1 -0
  318. package/dist/lib/metrics-sql.d.ts +11 -0
  319. package/dist/lib/metrics-sql.d.ts.map +1 -0
  320. package/dist/lib/notifications.d.ts +17 -0
  321. package/dist/lib/notifications.d.ts.map +1 -0
  322. package/dist/lib/oauth-token-manager.d.ts +74 -0
  323. package/dist/lib/oauth-token-manager.d.ts.map +1 -0
  324. package/dist/lib/operator-settings.d.ts +33 -0
  325. package/dist/lib/operator-settings.d.ts.map +1 -0
  326. package/dist/lib/operator.d.ts +20 -0
  327. package/dist/lib/operator.d.ts.map +1 -0
  328. package/dist/lib/outbound-endpoint-cache.d.ts +25 -0
  329. package/dist/lib/outbound-endpoint-cache.d.ts.map +1 -0
  330. package/dist/lib/outbound.d.ts +687 -0
  331. package/dist/lib/outbound.d.ts.map +1 -0
  332. package/dist/lib/phone.d.ts +11 -0
  333. package/dist/lib/phone.d.ts.map +1 -0
  334. package/dist/lib/posthog-scopes.d.ts +30 -0
  335. package/dist/lib/posthog-scopes.d.ts.map +1 -0
  336. package/dist/lib/posthog.d.ts +16 -0
  337. package/dist/lib/posthog.d.ts.map +1 -0
  338. package/dist/lib/preferences.d.ts +72 -0
  339. package/dist/lib/preferences.d.ts.map +1 -0
  340. package/dist/lib/provider-credentials.d.ts +149 -0
  341. package/dist/lib/provider-credentials.d.ts.map +1 -0
  342. package/dist/lib/provision-posthog-loop.d.ts +100 -0
  343. package/dist/lib/provision-posthog-loop.d.ts.map +1 -0
  344. package/dist/lib/recipient-preferences.d.ts +29 -0
  345. package/dist/lib/recipient-preferences.d.ts.map +1 -0
  346. package/dist/lib/redis.d.ts +33 -0
  347. package/dist/lib/redis.d.ts.map +1 -0
  348. package/dist/lib/referral-intent.d.ts +99 -0
  349. package/dist/lib/referral-intent.d.ts.map +1 -0
  350. package/dist/lib/referral-link.d.ts +59 -0
  351. package/dist/lib/referral-link.d.ts.map +1 -0
  352. package/dist/lib/referral-registry.d.ts +37 -0
  353. package/dist/lib/referral-registry.d.ts.map +1 -0
  354. package/dist/lib/referral-report.d.ts +178 -0
  355. package/dist/lib/referral-report.d.ts.map +1 -0
  356. package/dist/lib/referral-runtime.d.ts +43 -0
  357. package/dist/lib/referral-runtime.d.ts.map +1 -0
  358. package/dist/lib/referrals.d.ts +184 -0
  359. package/dist/lib/referrals.d.ts.map +1 -0
  360. package/dist/lib/refine-chain.d.ts +236 -0
  361. package/dist/lib/refine-chain.d.ts.map +1 -0
  362. package/dist/lib/refine-traits.d.ts +78 -0
  363. package/dist/lib/refine-traits.d.ts.map +1 -0
  364. package/dist/lib/refine.d.ts +35 -0
  365. package/dist/lib/refine.d.ts.map +1 -0
  366. package/dist/lib/reset-email.d.ts +38 -0
  367. package/dist/lib/reset-email.d.ts.map +1 -0
  368. package/dist/lib/revenue.d.ts +61 -0
  369. package/dist/lib/revenue.d.ts.map +1 -0
  370. package/dist/lib/schemas.d.ts +9 -0
  371. package/dist/lib/schemas.d.ts.map +1 -0
  372. package/dist/lib/seed-posthog-destination.d.ts +22 -0
  373. package/dist/lib/seed-posthog-destination.d.ts.map +1 -0
  374. package/dist/lib/semantic-click.d.ts +58 -0
  375. package/dist/lib/semantic-click.d.ts.map +1 -0
  376. package/dist/lib/sending-domain-guidance.d.ts +40 -0
  377. package/dist/lib/sending-domain-guidance.d.ts.map +1 -0
  378. package/dist/lib/singleton.d.ts +24 -0
  379. package/dist/lib/singleton.d.ts.map +1 -0
  380. package/dist/lib/sms-frequency-cap.d.ts +16 -0
  381. package/dist/lib/sms-frequency-cap.d.ts.map +1 -0
  382. package/dist/lib/sms-inbound.d.ts +37 -0
  383. package/dist/lib/sms-inbound.d.ts.map +1 -0
  384. package/dist/lib/sms-link-tracking.d.ts +53 -0
  385. package/dist/lib/sms-link-tracking.d.ts.map +1 -0
  386. package/dist/lib/sms-mailer.d.ts +12 -0
  387. package/dist/lib/sms-mailer.d.ts.map +1 -0
  388. package/dist/lib/sms-provider-registry.d.ts +20 -0
  389. package/dist/lib/sms-provider-registry.d.ts.map +1 -0
  390. package/dist/lib/sms-providers-from-env.d.ts +4 -0
  391. package/dist/lib/sms-providers-from-env.d.ts.map +1 -0
  392. package/dist/lib/sms-service-types.d.ts +131 -0
  393. package/dist/lib/sms-service-types.d.ts.map +1 -0
  394. package/dist/lib/sms-tracked.d.ts +36 -0
  395. package/dist/lib/sms-tracked.d.ts.map +1 -0
  396. package/dist/lib/sms.d.ts +58 -0
  397. package/dist/lib/sms.d.ts.map +1 -0
  398. package/dist/lib/snippet.d.ts +32 -0
  399. package/dist/lib/snippet.d.ts.map +1 -0
  400. package/dist/lib/stable-stringify.d.ts +12 -0
  401. package/dist/lib/stable-stringify.d.ts.map +1 -0
  402. package/dist/lib/studio.d.ts +21 -0
  403. package/dist/lib/studio.d.ts.map +1 -0
  404. package/dist/lib/survey.d.ts +35 -0
  405. package/dist/lib/survey.d.ts.map +1 -0
  406. package/dist/lib/test-mode.d.ts +77 -0
  407. package/dist/lib/test-mode.d.ts.map +1 -0
  408. package/dist/lib/timezone.d.ts +55 -0
  409. package/dist/lib/timezone.d.ts.map +1 -0
  410. package/dist/lib/tracked.d.ts +95 -0
  411. package/dist/lib/tracked.d.ts.map +1 -0
  412. package/dist/lib/tracking-event-names.d.ts +7 -0
  413. package/dist/lib/tracking-event-names.d.ts.map +1 -0
  414. package/dist/lib/tracking-events.d.ts +232 -0
  415. package/dist/lib/tracking-events.d.ts.map +1 -0
  416. package/dist/lib/tracking.d.ts +47 -0
  417. package/dist/lib/tracking.d.ts.map +1 -0
  418. package/dist/lib/unconfigured-email-provider.d.ts +20 -0
  419. package/dist/lib/unconfigured-email-provider.d.ts.map +1 -0
  420. package/dist/lib/unique-violation.d.ts +22 -0
  421. package/dist/lib/unique-violation.d.ts.map +1 -0
  422. package/dist/lib/user-token.d.ts +44 -0
  423. package/dist/lib/user-token.d.ts.map +1 -0
  424. package/dist/lib/variant.d.ts +44 -0
  425. package/dist/lib/variant.d.ts.map +1 -0
  426. package/dist/lib/webhook-signing.d.ts +120 -0
  427. package/dist/lib/webhook-signing.d.ts.map +1 -0
  428. package/dist/lib/worker-heartbeat.d.ts +18 -0
  429. package/dist/lib/worker-heartbeat.d.ts.map +1 -0
  430. package/dist/lists/channels.d.ts +43 -0
  431. package/dist/lists/channels.d.ts.map +1 -0
  432. package/dist/lists/define-list.d.ts +76 -0
  433. package/dist/lists/define-list.d.ts.map +1 -0
  434. package/dist/lists/registry-singleton.d.ts +8 -0
  435. package/dist/lists/registry-singleton.d.ts.map +1 -0
  436. package/dist/lists/registry.d.ts +66 -0
  437. package/dist/lists/registry.d.ts.map +1 -0
  438. package/dist/lists/subscription.d.ts +10 -0
  439. package/dist/lists/subscription.d.ts.map +1 -0
  440. package/dist/mcp/authoring-guide.d.ts +33 -0
  441. package/dist/mcp/authoring-guide.d.ts.map +1 -0
  442. package/dist/mcp/blueprint-tools.d.ts +266 -0
  443. package/dist/mcp/blueprint-tools.d.ts.map +1 -0
  444. package/dist/middleware/api-key.d.ts +45 -0
  445. package/dist/middleware/api-key.d.ts.map +1 -0
  446. package/dist/middleware/audit.d.ts +3 -0
  447. package/dist/middleware/audit.d.ts.map +1 -0
  448. package/dist/middleware/error-handler.d.ts +4 -0
  449. package/dist/middleware/error-handler.d.ts.map +1 -0
  450. package/dist/middleware/publishable-key.d.ts +27 -0
  451. package/dist/middleware/publishable-key.d.ts.map +1 -0
  452. package/dist/middleware/rate-limit.d.ts +105 -0
  453. package/dist/middleware/rate-limit.d.ts.map +1 -0
  454. package/dist/middleware/request-logger.d.ts +4 -0
  455. package/dist/middleware/request-logger.d.ts.map +1 -0
  456. package/dist/middleware/require-admin.d.ts +3 -0
  457. package/dist/middleware/require-admin.d.ts.map +1 -0
  458. package/dist/routes/_shared.d.ts +52 -0
  459. package/dist/routes/_shared.d.ts.map +1 -0
  460. package/dist/routes/accounts/callback.d.ts +18 -0
  461. package/dist/routes/accounts/callback.d.ts.map +1 -0
  462. package/dist/routes/accounts/emit.d.ts +96 -0
  463. package/dist/routes/accounts/emit.d.ts.map +1 -0
  464. package/dist/routes/accounts/import-links.d.ts +4 -0
  465. package/dist/routes/accounts/import-links.d.ts.map +1 -0
  466. package/dist/routes/accounts/index.d.ts +39 -0
  467. package/dist/routes/accounts/index.d.ts.map +1 -0
  468. package/dist/routes/accounts/lookup.d.ts +6 -0
  469. package/dist/routes/accounts/lookup.d.ts.map +1 -0
  470. package/dist/routes/accounts/me.d.ts +5 -0
  471. package/dist/routes/accounts/me.d.ts.map +1 -0
  472. package/dist/routes/accounts/mint.d.ts +5 -0
  473. package/dist/routes/accounts/mint.d.ts.map +1 -0
  474. package/dist/routes/accounts/pages.d.ts +23 -0
  475. package/dist/routes/accounts/pages.d.ts.map +1 -0
  476. package/dist/routes/accounts/resolve.d.ts +33 -0
  477. package/dist/routes/accounts/resolve.d.ts.map +1 -0
  478. package/dist/routes/accounts/serialize.d.ts +57 -0
  479. package/dist/routes/accounts/serialize.d.ts.map +1 -0
  480. package/dist/routes/accounts/shared.d.ts +68 -0
  481. package/dist/routes/accounts/shared.d.ts.map +1 -0
  482. package/dist/routes/accounts/start.d.ts +16 -0
  483. package/dist/routes/accounts/start.d.ts.map +1 -0
  484. package/dist/routes/accounts/unlink.d.ts +36 -0
  485. package/dist/routes/accounts/unlink.d.ts.map +1 -0
  486. package/dist/routes/admin/agent.d.ts +4 -0
  487. package/dist/routes/admin/agent.d.ts.map +1 -0
  488. package/dist/routes/admin/alerts.d.ts +190 -0
  489. package/dist/routes/admin/alerts.d.ts.map +1 -0
  490. package/dist/routes/admin/analytics.d.ts +137 -0
  491. package/dist/routes/admin/analytics.d.ts.map +1 -0
  492. package/dist/routes/admin/api-keys.d.ts +158 -0
  493. package/dist/routes/admin/api-keys.d.ts.map +1 -0
  494. package/dist/routes/admin/attribution.d.ts +93 -0
  495. package/dist/routes/admin/attribution.d.ts.map +1 -0
  496. package/dist/routes/admin/audit-logs.d.ts +40 -0
  497. package/dist/routes/admin/audit-logs.d.ts.map +1 -0
  498. package/dist/routes/admin/blueprints.d.ts +4 -0
  499. package/dist/routes/admin/blueprints.d.ts.map +1 -0
  500. package/dist/routes/admin/buckets.d.ts +215 -0
  501. package/dist/routes/admin/buckets.d.ts.map +1 -0
  502. package/dist/routes/admin/bulk.d.ts +203 -0
  503. package/dist/routes/admin/bulk.d.ts.map +1 -0
  504. package/dist/routes/admin/campaigns.d.ts +198 -0
  505. package/dist/routes/admin/campaigns.d.ts.map +1 -0
  506. package/dist/routes/admin/connectors.d.ts +116 -0
  507. package/dist/routes/admin/connectors.d.ts.map +1 -0
  508. package/dist/routes/admin/contacts.d.ts +246 -0
  509. package/dist/routes/admin/contacts.d.ts.map +1 -0
  510. package/dist/routes/admin/conversions.d.ts +103 -0
  511. package/dist/routes/admin/conversions.d.ts.map +1 -0
  512. package/dist/routes/admin/deals.d.ts +136 -0
  513. package/dist/routes/admin/deals.d.ts.map +1 -0
  514. package/dist/routes/admin/dlq.d.ts +100 -0
  515. package/dist/routes/admin/dlq.d.ts.map +1 -0
  516. package/dist/routes/admin/domain.d.ts +314 -0
  517. package/dist/routes/admin/domain.d.ts.map +1 -0
  518. package/dist/routes/admin/emails.d.ts +127 -0
  519. package/dist/routes/admin/emails.d.ts.map +1 -0
  520. package/dist/routes/admin/events.d.ts +140 -0
  521. package/dist/routes/admin/events.d.ts.map +1 -0
  522. package/dist/routes/admin/flags.d.ts +719 -0
  523. package/dist/routes/admin/flags.d.ts.map +1 -0
  524. package/dist/routes/admin/funnels.d.ts +71 -0
  525. package/dist/routes/admin/funnels.d.ts.map +1 -0
  526. package/dist/routes/admin/groups.d.ts +169 -0
  527. package/dist/routes/admin/groups.d.ts.map +1 -0
  528. package/dist/routes/admin/identity.d.ts +72 -0
  529. package/dist/routes/admin/identity.d.ts.map +1 -0
  530. package/dist/routes/admin/impact-schemas.d.ts +48 -0
  531. package/dist/routes/admin/impact-schemas.d.ts.map +1 -0
  532. package/dist/routes/admin/impact.d.ts +316 -0
  533. package/dist/routes/admin/impact.d.ts.map +1 -0
  534. package/dist/routes/admin/index.d.ts +4 -0
  535. package/dist/routes/admin/index.d.ts.map +1 -0
  536. package/dist/routes/admin/journey-impact.d.ts +320 -0
  537. package/dist/routes/admin/journey-impact.d.ts.map +1 -0
  538. package/dist/routes/admin/journey-logs.d.ts +57 -0
  539. package/dist/routes/admin/journey-logs.d.ts.map +1 -0
  540. package/dist/routes/admin/journeys.d.ts +736 -0
  541. package/dist/routes/admin/journeys.d.ts.map +1 -0
  542. package/dist/routes/admin/links.d.ts +382 -0
  543. package/dist/routes/admin/links.d.ts.map +1 -0
  544. package/dist/routes/admin/lists.d.ts +22 -0
  545. package/dist/routes/admin/lists.d.ts.map +1 -0
  546. package/dist/routes/admin/maintenance.d.ts +72 -0
  547. package/dist/routes/admin/maintenance.d.ts.map +1 -0
  548. package/dist/routes/admin/metrics.d.ts +212 -0
  549. package/dist/routes/admin/metrics.d.ts.map +1 -0
  550. package/dist/routes/admin/open-editor.d.ts +36 -0
  551. package/dist/routes/admin/open-editor.d.ts.map +1 -0
  552. package/dist/routes/admin/preferences.d.ts +109 -0
  553. package/dist/routes/admin/preferences.d.ts.map +1 -0
  554. package/dist/routes/admin/provider-credentials.d.ts +108 -0
  555. package/dist/routes/admin/provider-credentials.d.ts.map +1 -0
  556. package/dist/routes/admin/readiness.d.ts +24 -0
  557. package/dist/routes/admin/readiness.d.ts.map +1 -0
  558. package/dist/routes/admin/referrals.d.ts +230 -0
  559. package/dist/routes/admin/referrals.d.ts.map +1 -0
  560. package/dist/routes/admin/reporting.d.ts +149 -0
  561. package/dist/routes/admin/reporting.d.ts.map +1 -0
  562. package/dist/routes/admin/settings.d.ts +80 -0
  563. package/dist/routes/admin/settings.d.ts.map +1 -0
  564. package/dist/routes/admin/suppressions.d.ts +90 -0
  565. package/dist/routes/admin/suppressions.d.ts.map +1 -0
  566. package/dist/routes/admin/targeting.d.ts +58 -0
  567. package/dist/routes/admin/targeting.d.ts.map +1 -0
  568. package/dist/routes/admin/templates.d.ts +197 -0
  569. package/dist/routes/admin/templates.d.ts.map +1 -0
  570. package/dist/routes/admin/timeline.d.ts +51 -0
  571. package/dist/routes/admin/timeline.d.ts.map +1 -0
  572. package/dist/routes/admin/webhooks.d.ts +250 -0
  573. package/dist/routes/admin/webhooks.d.ts.map +1 -0
  574. package/dist/routes/campaigns/index.d.ts +239 -0
  575. package/dist/routes/campaigns/index.d.ts.map +1 -0
  576. package/dist/routes/connectors/index.d.ts +16 -0
  577. package/dist/routes/connectors/index.d.ts.map +1 -0
  578. package/dist/routes/contacts/index.d.ts +187 -0
  579. package/dist/routes/contacts/index.d.ts.map +1 -0
  580. package/dist/routes/email/index.d.ts +4 -0
  581. package/dist/routes/email/index.d.ts.map +1 -0
  582. package/dist/routes/email/preferences.d.ts +17 -0
  583. package/dist/routes/email/preferences.d.ts.map +1 -0
  584. package/dist/routes/email/unsubscribe.d.ts +17 -0
  585. package/dist/routes/email/unsubscribe.d.ts.map +1 -0
  586. package/dist/routes/emails/index.d.ts +90 -0
  587. package/dist/routes/emails/index.d.ts.map +1 -0
  588. package/dist/routes/events/index.d.ts +116 -0
  589. package/dist/routes/events/index.d.ts.map +1 -0
  590. package/dist/routes/feed/index.d.ts +248 -0
  591. package/dist/routes/feed/index.d.ts.map +1 -0
  592. package/dist/routes/feed/recipient.d.ts +65 -0
  593. package/dist/routes/feed/recipient.d.ts.map +1 -0
  594. package/dist/routes/flags/index.d.ts +94 -0
  595. package/dist/routes/flags/index.d.ts.map +1 -0
  596. package/dist/routes/groups/index.d.ts +192 -0
  597. package/dist/routes/groups/index.d.ts.map +1 -0
  598. package/dist/routes/health.d.ts +57 -0
  599. package/dist/routes/health.d.ts.map +1 -0
  600. package/dist/routes/index.d.ts +8 -0
  601. package/dist/routes/index.d.ts.map +1 -0
  602. package/dist/routes/lists/index.d.ts +266 -0
  603. package/dist/routes/lists/index.d.ts.map +1 -0
  604. package/dist/routes/referrals/index.d.ts +22 -0
  605. package/dist/routes/referrals/index.d.ts.map +1 -0
  606. package/dist/routes/referrals/me.d.ts +4 -0
  607. package/dist/routes/referrals/me.d.ts.map +1 -0
  608. package/dist/routes/referrals/report.d.ts +5 -0
  609. package/dist/routes/referrals/report.d.ts.map +1 -0
  610. package/dist/routes/referrals/shared.d.ts +16 -0
  611. package/dist/routes/referrals/shared.d.ts.map +1 -0
  612. package/dist/routes/referrals/touch.d.ts +5 -0
  613. package/dist/routes/referrals/touch.d.ts.map +1 -0
  614. package/dist/routes/snippet.d.ts +12 -0
  615. package/dist/routes/snippet.d.ts.map +1 -0
  616. package/dist/routes/tracking/answer.d.ts +56 -0
  617. package/dist/routes/tracking/answer.d.ts.map +1 -0
  618. package/dist/routes/tracking/arrive.d.ts +32 -0
  619. package/dist/routes/tracking/arrive.d.ts.map +1 -0
  620. package/dist/routes/tracking/click-pipeline.d.ts +213 -0
  621. package/dist/routes/tracking/click-pipeline.d.ts.map +1 -0
  622. package/dist/routes/tracking/click.d.ts +26 -0
  623. package/dist/routes/tracking/click.d.ts.map +1 -0
  624. package/dist/routes/tracking/identify.d.ts +32 -0
  625. package/dist/routes/tracking/identify.d.ts.map +1 -0
  626. package/dist/routes/tracking/index.d.ts +4 -0
  627. package/dist/routes/tracking/index.d.ts.map +1 -0
  628. package/dist/routes/tracking/open.d.ts +17 -0
  629. package/dist/routes/tracking/open.d.ts.map +1 -0
  630. package/dist/routes/tracking/short.d.ts +17 -0
  631. package/dist/routes/tracking/short.d.ts.map +1 -0
  632. package/dist/routes/tracking/vanity.d.ts +17 -0
  633. package/dist/routes/tracking/vanity.d.ts.map +1 -0
  634. package/dist/routes/webhooks/crm-provider.d.ts +24 -0
  635. package/dist/routes/webhooks/crm-provider.d.ts.map +1 -0
  636. package/dist/routes/webhooks/email-provider.d.ts +21 -0
  637. package/dist/routes/webhooks/email-provider.d.ts.map +1 -0
  638. package/dist/routes/webhooks/index.d.ts +8 -0
  639. package/dist/routes/webhooks/index.d.ts.map +1 -0
  640. package/dist/routes/webhooks/resend.d.ts +35 -0
  641. package/dist/routes/webhooks/resend.d.ts.map +1 -0
  642. package/dist/routes/webhooks/sms-provider.d.ts +23 -0
  643. package/dist/routes/webhooks/sms-provider.d.ts.map +1 -0
  644. package/dist/routes/webhooks/sources.d.ts +12 -0
  645. package/dist/routes/webhooks/sources.d.ts.map +1 -0
  646. package/dist/sources/define-contact-source.d.ts +114 -0
  647. package/dist/sources/define-contact-source.d.ts.map +1 -0
  648. package/dist/sources/registry.d.ts +31 -0
  649. package/dist/sources/registry.d.ts.map +1 -0
  650. package/dist/sources/webhook-source.d.ts +53 -0
  651. package/dist/sources/webhook-source.d.ts.map +1 -0
  652. package/dist/testing.d.ts +10 -0
  653. package/dist/testing.d.ts.map +1 -0
  654. package/dist/webhook-sources/define-webhook-source.d.ts +60 -0
  655. package/dist/webhook-sources/define-webhook-source.d.ts.map +1 -0
  656. package/dist/webhook-sources/presets/clerk.d.ts +9 -0
  657. package/dist/webhook-sources/presets/clerk.d.ts.map +1 -0
  658. package/dist/webhook-sources/presets/index.d.ts +140 -0
  659. package/dist/webhook-sources/presets/index.d.ts.map +1 -0
  660. package/dist/webhook-sources/presets/intercom.d.ts +44 -0
  661. package/dist/webhook-sources/presets/intercom.d.ts.map +1 -0
  662. package/dist/webhook-sources/presets/segment.d.ts +16 -0
  663. package/dist/webhook-sources/presets/segment.d.ts.map +1 -0
  664. package/dist/webhook-sources/presets/stripe.d.ts +20 -0
  665. package/dist/webhook-sources/presets/stripe.d.ts.map +1 -0
  666. package/dist/webhook-sources/presets/supabase.d.ts +23 -0
  667. package/dist/webhook-sources/presets/supabase.d.ts.map +1 -0
  668. package/dist/webhook-sources/verify.d.ts +48 -0
  669. package/dist/webhook-sources/verify.d.ts.map +1 -0
  670. package/dist/worker.d.ts +37 -0
  671. package/dist/worker.d.ts.map +1 -0
  672. package/dist/workflows/backfill-contact-id.d.ts +202 -0
  673. package/dist/workflows/backfill-contact-id.d.ts.map +1 -0
  674. package/dist/workflows/bucket-backfill.d.ts +64 -0
  675. package/dist/workflows/bucket-backfill.d.ts.map +1 -0
  676. package/dist/workflows/bucket-reconcile.d.ts +73 -0
  677. package/dist/workflows/bucket-reconcile.d.ts.map +1 -0
  678. package/dist/workflows/check-alerts.d.ts +10 -0
  679. package/dist/workflows/check-alerts.d.ts.map +1 -0
  680. package/dist/workflows/confirm-semantic-click.d.ts +15 -0
  681. package/dist/workflows/confirm-semantic-click.d.ts.map +1 -0
  682. package/dist/workflows/crm-reconcile.d.ts +27 -0
  683. package/dist/workflows/crm-reconcile.d.ts.map +1 -0
  684. package/dist/workflows/deliver-webhook.d.ts +88 -0
  685. package/dist/workflows/deliver-webhook.d.ts.map +1 -0
  686. package/dist/workflows/dispatch-conversion.d.ts +14 -0
  687. package/dist/workflows/dispatch-conversion.d.ts.map +1 -0
  688. package/dist/workflows/identity-alias-backfill.d.ts +96 -0
  689. package/dist/workflows/identity-alias-backfill.d.ts.map +1 -0
  690. package/dist/workflows/impact-digest.d.ts +142 -0
  691. package/dist/workflows/impact-digest.d.ts.map +1 -0
  692. package/dist/workflows/import-contacts.d.ts +14 -0
  693. package/dist/workflows/import-contacts.d.ts.map +1 -0
  694. package/dist/workflows/import-suppressions.d.ts +55 -0
  695. package/dist/workflows/import-suppressions.d.ts.map +1 -0
  696. package/dist/workflows/journey-blueprint-interpreter.d.ts +73 -0
  697. package/dist/workflows/journey-blueprint-interpreter.d.ts.map +1 -0
  698. package/dist/workflows/send-campaign.d.ts +128 -0
  699. package/dist/workflows/send-campaign.d.ts.map +1 -0
  700. package/dist/workflows/send-email.d.ts +15 -0
  701. package/dist/workflows/send-email.d.ts.map +1 -0
  702. package/dist/workflows/send-feed.d.ts +37 -0
  703. package/dist/workflows/send-feed.d.ts.map +1 -0
  704. package/package.json +60 -22
  705. package/src/app.ts +9 -1
  706. package/src/buckets/check-membership.ts +54 -20
  707. package/src/container.ts +77 -0
  708. package/src/env.ts +30 -0
  709. package/src/index.ts +78 -0
  710. package/src/journeys/journey-log.ts +25 -8
  711. package/src/lib/contacts.ts +117 -1
  712. package/src/lib/email-service-types.ts +10 -0
  713. package/src/lib/ingestion.ts +91 -19
  714. package/src/lib/links.ts +94 -11
  715. package/src/lib/mailer-bounce-idempotency.test.ts +7 -2
  716. package/src/lib/mailer-replied.test.ts +7 -2
  717. package/src/lib/mailer.ts +1 -0
  718. package/src/lib/outbound-endpoint-cache.ts +83 -0
  719. package/src/lib/outbound.ts +150 -37
  720. package/src/lib/referral-intent.ts +723 -0
  721. package/src/lib/referral-link.ts +200 -0
  722. package/src/lib/referral-registry.ts +83 -0
  723. package/src/lib/referral-report.ts +739 -0
  724. package/src/lib/referral-runtime.ts +49 -0
  725. package/src/lib/referrals-no-emit.test.ts +109 -0
  726. package/src/lib/referrals.ts +712 -0
  727. package/src/lib/seed-posthog-destination.ts +5 -1
  728. package/src/lib/tracked.ts +11 -3
  729. package/src/lib/tracking-events.ts +20 -3
  730. package/src/lib/webhook-signing.ts +10 -0
  731. package/src/middleware/api-key.ts +69 -60
  732. package/src/middleware/publishable-key.ts +11 -23
  733. package/src/middleware/rate-limit.ts +165 -3
  734. package/src/routes/admin/api-keys.ts +153 -0
  735. package/src/routes/admin/index.ts +2 -0
  736. package/src/routes/admin/links.ts +14 -5
  737. package/src/routes/admin/referrals.ts +565 -0
  738. package/src/routes/admin/targeting.ts +6 -1
  739. package/src/routes/admin/webhooks.ts +4 -0
  740. package/src/routes/contacts/index.ts +78 -0
  741. package/src/routes/index.ts +104 -22
  742. package/src/routes/referrals/index.ts +41 -0
  743. package/src/routes/referrals/me.ts +123 -0
  744. package/src/routes/referrals/report.ts +285 -0
  745. package/src/routes/referrals/shared.ts +34 -0
  746. package/src/routes/referrals/touch.ts +313 -0
  747. package/src/routes/tracking/arrive.ts +90 -0
  748. package/src/routes/tracking/click-pipeline.ts +8 -0
  749. package/src/workflows/backfill-contact-id.ts +3 -7
  750. package/src/workflows/bucket-backfill.ts +2 -2
  751. package/src/workflows/bucket-reconcile.ts +28 -12
  752. package/src/workflows/check-alerts.ts +3 -9
  753. package/src/workflows/crm-reconcile.ts +3 -2
  754. package/src/workflows/deliver-webhook.ts +21 -8
  755. package/src/workflows/dispatch-conversion.ts +2 -2
  756. package/src/workflows/identity-alias-backfill.ts +3 -2
  757. package/src/workflows/impact-digest.ts +2 -2
  758. package/src/workflows/import-contacts.ts +3 -4
  759. package/src/workflows/import-suppressions.ts +4 -5
  760. package/src/workflows/send-campaign.ts +10 -1
@@ -0,0 +1,105 @@
1
+ import type { HatchetClient } from "@hatchet-dev/typescript-sdk/v1/index.js";
2
+ import { type BucketMeta } from "@hogsend/core";
3
+ import type { JourneyRegistry } from "@hogsend/core/registry";
4
+ import { type Database } from "@hogsend/db";
5
+ import type { Logger } from "../lib/logger.js";
6
+ import { getBucketRegistrySingleton } from "./registry-singleton.js";
7
+ export type BucketTransitionKind = "entered" | "left";
8
+ export interface BucketTransition {
9
+ bucketId: string;
10
+ transition: BucketTransitionKind;
11
+ }
12
+ /**
13
+ * Real-time bucket-membership re-evaluation, invoked from inside `ingestEvent`
14
+ * AFTER the `userEvents` insert / idempotency short-circuit (Section 6.1).
15
+ *
16
+ * For the ingested event it narrows the candidate buckets via the registry's
17
+ * event + property inverted indexes (Section 6.2), evaluates each candidate's
18
+ * criteria against MERGED contact state (Section 6.1 rule #3), diffs the result
19
+ * against the current `bucket_memberships` rows, and performs the atomic
20
+ * RETURNING-gated mutation (partial-unique INSERT for joins, compare-and-swap
21
+ * UPDATE for leaves — Section 6.3). On a real transition it emits
22
+ * `bucket:entered:<id>` / `bucket:left:<id>` back through `ingestEvent`, gated on
23
+ * the entryLimit policy and deferring leaves still inside `minDwell`.
24
+ *
25
+ * Returns the computed transition list so a unit test can assert enter/leave/no-op
26
+ * WITHOUT a live Hatchet (Section 14 — the testing seam). Production callers
27
+ * ignore the return value (the emission has already happened via recursion).
28
+ */
29
+ export declare function checkBucketMembership(opts: {
30
+ db: Database;
31
+ /** The JOURNEY registry — forwarded into the recursive emit ingestEvent. */
32
+ registry: JourneyRegistry;
33
+ hatchet: HatchetClient;
34
+ logger: Logger;
35
+ userId: string;
36
+ userEmail: string | null;
37
+ /**
38
+ * The subject contact's resolved row id (`contacts.id`) — `ingestEvent` has
39
+ * already resolved the contact before calling us, so it threads the id here
40
+ * and we carry it into every `emitBucketTransition` as the ENGINE-INTERNAL
41
+ * provenance pin. Without it, a transition for a contact whose canonical key
42
+ * is its `anonymous_id` re-ingests a bare `userId` and mints a phantom
43
+ * `external_id` twin (issue #608). Optional: a caller without a resolved
44
+ * contact degrades to the pin-less emit.
45
+ */
46
+ contactId?: string;
47
+ /**
48
+ * D1 creation guard, INHERITED from the originating ingest and forwarded into
49
+ * every `emitBucketTransition` (and from there into both of its re-ingests).
50
+ * `ingestEvent` passes `false` exactly when its own resolve REFUSED, i.e.
51
+ * when there is no `contactId` to pin with — because the alternative,
52
+ * degrading the pin to `contactId ?? undefined`, makes the transition
53
+ * re-ingest treat the anon canonical key as an EXTERNAL key and mint an
54
+ * `external_id = <anonId>` phantom twin (issue #608 from the other side).
55
+ * Bucket evaluation itself is UNAFFECTED: `bucket_memberships` is text-keyed
56
+ * with no contact FK, so a contactless subject is still a first-class member.
57
+ */
58
+ allowCreate?: boolean;
59
+ event: string;
60
+ /**
61
+ * D2: the event payload — candidate-narrowing ONLY. It NO LONGER participates
62
+ * in property eval (the raw-payload overlay was the bucket-side conflation).
63
+ */
64
+ eventProperties: Record<string, unknown>;
65
+ /**
66
+ * D2: this-ingest contact-property patch, overlaid on the read contact row so
67
+ * the very first event after a property change evaluates correctly (risk 7).
68
+ */
69
+ contactProperties?: Record<string, unknown>;
70
+ /**
71
+ * Extra property NAMES for candidate-narrowing ONLY — never overlaid on the
72
+ * contact row for value eval. A producer whose write patch omits a key it
73
+ * nonetheless changed (refinement's fill-if-absent drops already-held facts to
74
+ * avoid clobbering first-party data) lists those names here so their fit
75
+ * buckets are still re-checked against live contact state.
76
+ */
77
+ touchProperties?: string[];
78
+ /** Optional override; defaults to the process bucket-registry singleton. */
79
+ bucketRegistry?: ReturnType<typeof getBucketRegistrySingleton>;
80
+ }): Promise<BucketTransition[]>;
81
+ /**
82
+ * The `entryLimit` emit gate, consulted on the JOIN transition only (Section 6.3).
83
+ * Suppressing the emit still wrote the active row and advanced the epoch — only
84
+ * the `bucket:entered` ingestEvent recursion is skipped.
85
+ *
86
+ * The engine now enforces `once_per_period` PRECISELY: it reads the most-recent
87
+ * prior LEAVE (`status:"left"` with `leftAt` set) and emits only once the
88
+ * configured `entryPeriod` has elapsed since that leave. The journey-side
89
+ * entryLimit/entryPeriod is a redundant backstop, no longer the sole gate.
90
+ */
91
+ export declare function shouldEmitJoin(opts: {
92
+ db: Database;
93
+ bucket: BucketMeta;
94
+ userId: string;
95
+ /**
96
+ * The owning contact's `contacts.id`, or `null` when the caller has none.
97
+ * REQUIRED (not optional) on purpose: the prior-cycle lookup below is the
98
+ * cooldown gate, and an optional field a caller forgets silently drops it
99
+ * back onto the mutable text key — which misses the adopted prior cycle and
100
+ * re-emits a `once` join. Pass `null` explicitly for a contactless subject.
101
+ */
102
+ contactId: string | null;
103
+ priorCount: number;
104
+ }): Promise<boolean>;
105
+ //# sourceMappingURL=check-membership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-membership.d.ts","sourceRoot":"","sources":["../../src/buckets/check-membership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EACL,KAAK,UAAU,EAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAO/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,MAAM,CAAC;AAKtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,oBAAoB,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,QAAQ,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,4EAA4E;IAC5E,cAAc,CAAC,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;CAChE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAmQ9B;AAuPD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,OAAO,CAAC,CAuCnB"}
@@ -0,0 +1,53 @@
1
+ import { type CriteriaBuilder } from "@hogsend/core";
2
+ import type { BucketMeta, ConditionEval } from "@hogsend/core/types";
3
+ import type { DefinedJourney } from "../journeys/define-journey.js";
4
+ import type { hatchet } from "../lib/hatchet.js";
5
+ import { type BucketAccessor } from "./bucket-access.js";
6
+ import { type BucketOnHandler, type DwellOptions, type EnterOptions, type LeaveOptions } from "./bucket-reactions.js";
7
+ /**
8
+ * `criteria` may be authored two ways:
9
+ * - declaratively, as a `ConditionEval` data tree, or
10
+ * - with the fluent builder, as `(b) => b.all(b.prop("plan").eq("trial"), ...)`.
11
+ * The builder form runs ONCE here and returns a `ConditionEval`, so everything
12
+ * downstream (registry indexes, schema validation, reconcile cron, Studio) only
13
+ * ever sees the canonical declarative data.
14
+ */
15
+ export type CriteriaInput = ConditionEval | ((b: CriteriaBuilder) => ConditionEval);
16
+ /** `BucketMeta` as authored — `criteria` accepts the builder function too. */
17
+ export type BucketMetaInput<Id extends string = string> = Omit<BucketMeta, "criteria" | "id"> & {
18
+ id: Id;
19
+ criteria?: CriteriaInput;
20
+ };
21
+ export type { DwellOptions };
22
+ export interface DefinedBucket<Id extends string = string> {
23
+ meta: BucketMeta;
24
+ /** Literal-typed transition ref: `"bucket:entered:<id>"`. */
25
+ readonly entered: `bucket:entered:${Id}`;
26
+ /** Literal-typed transition ref: `"bucket:left:<id>"`. */
27
+ readonly left: `bucket:left:${Id}`;
28
+ /**
29
+ * The only task a bucket ever holds is the opt-in per-user fast-expiry timer,
30
+ * which is a DURABLE task (it `ctx.sleepFor`s — Section 6.5), so the type MUST
31
+ * be the durableTask return type, mirroring
32
+ * `DefinedJourney.task = ReturnType<typeof hatchet.durableTask>`
33
+ * (define-journey.ts:34) — NOT `hatchet.task`. The common case is
34
+ * declarative-only (no task), like webhookSources; the engine-wide
35
+ * `bucketReconcileTask` handles time-based leaves regardless.
36
+ */
37
+ task?: ReturnType<typeof hatchet.durableTask>;
38
+ /** Reaction journeys generated by `.on()`. Read by the worker + container. */
39
+ reactions: DefinedJourney[];
40
+ count: BucketAccessor["count"];
41
+ has: BucketAccessor["has"];
42
+ members: BucketAccessor["members"];
43
+ membersIterator: BucketAccessor["membersIterator"];
44
+ on(kind: "enter", handler: BucketOnHandler<"enter">): DefinedBucket<Id>;
45
+ on(kind: "enter", opts: EnterOptions, handler: BucketOnHandler<"enter">): DefinedBucket<Id>;
46
+ on(kind: "leave", handler: BucketOnHandler<"leave">): DefinedBucket<Id>;
47
+ on(kind: "leave", opts: LeaveOptions, handler: BucketOnHandler<"leave">): DefinedBucket<Id>;
48
+ on(kind: "dwell", opts: DwellOptions, handler: BucketOnHandler<"dwell">): DefinedBucket<Id>;
49
+ }
50
+ export declare function defineBucket<const Id extends string>(options: {
51
+ meta: BucketMetaInput<Id>;
52
+ }): DefinedBucket<Id>;
53
+ //# sourceMappingURL=define-bucket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-bucket.d.ts","sourceRoot":"","sources":["../../src/buckets/define-bucket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EAElB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,CAAC,CAAC,CAAC,EAAE,eAAe,KAAK,aAAa,CAAC,CAAC;AAE5C,8EAA8E;AAC9E,MAAM,MAAM,eAAe,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,CAC5D,UAAU,EACV,UAAU,GAAG,IAAI,CAClB,GAAG;IAAE,EAAE,EAAE,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC;AAEzC,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,MAAM,WAAW,aAAa,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM;IACvD,IAAI,EAAE,UAAU,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAAC;IACzC,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,CAAC;IACnC;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,8EAA8E;IAC9E,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/B,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACnD,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IACxE,EAAE,CACA,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAChC,aAAa,CAAC,EAAE,CAAC,CAAC;IACrB,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IACxE,EAAE,CACA,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAChC,aAAa,CAAC,EAAE,CAAC,CAAC;IACrB,EAAE,CACA,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAChC,aAAa,CAAC,EAAE,CAAC,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,OAAO,EAAE;IAC7D,IAAI,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC;CAC3B,GAAG,aAAa,CAAC,EAAE,CAAC,CA6CpB"}
@@ -0,0 +1,74 @@
1
+ import { type BucketMeta, type ConditionEval, type DurationObject, type EventCondition } from "@hogsend/core";
2
+ import { type Database } from "@hogsend/db";
3
+ /**
4
+ * The reserved prefix every bucket transition event carries. Single source of
5
+ * truth shared by the ingest recursion guard (`checkBucketMembership`) and the
6
+ * fast-expiry arming event (`bucket:arm-expiry`).
7
+ */
8
+ export declare const BUCKET_EVENT_PREFIX = "bucket:";
9
+ /**
10
+ * The count of ALL prior memberships (active + left, NO status filter) for a
11
+ * (userId, bucketId) pair. This is the single source for the entryCount-ordinal
12
+ * rule (Section 6.3 / 8.2): the next epoch is `1 + countPriorMemberships(...)`,
13
+ * and the same count drives the entryLimit gate. Both the real-time join path
14
+ * (`handleJoin`) and the reconcile-discovered join path (`reconcileJoinOne`)
15
+ * call this so the ordinal can never drift between the two writers.
16
+ *
17
+ * The predicate MUST stay status-agnostic — narrowing it (e.g. to active-only)
18
+ * would corrupt entryCount and the entryLimit cooldown.
19
+ *
20
+ * `contactId` is REQUIRED (not optional) for the same reason
21
+ * `checkEntryLimit`'s is: an optional field silently defaults a new caller onto
22
+ * the mutable text key, and here that under-counts the epoch — a person whose
23
+ * anon-era memberships were adopted would re-enter at ordinal 1 and slip the
24
+ * `once`/`once_per_period` gate. Pass `null` explicitly for a subject with no
25
+ * contact; that is a permanent, supported state (memberships are text-keyed
26
+ * with no contact FK).
27
+ */
28
+ export declare function countPriorMemberships(db: Database, bucketId: string, userId: string, contactId: string | null): Promise<number>;
29
+ /**
30
+ * Find the first `EventCondition.within` rolling window in a criteria tree
31
+ * (depth-first). Returns null when no event leg carries a window. The single
32
+ * source for the membership-expiry / fastExpiry deadline math — shared so the
33
+ * three membership writers (real-time join, reconcile join, backfill join) can
34
+ * never disagree on which window drives `expiresAt`.
35
+ */
36
+ export declare function firstWithin(criteria: ConditionEval): DurationObject | null;
37
+ /**
38
+ * The persisted membership-expiry / fastExpiry arming deadline. Non-time-based,
39
+ * non-fastExpiry buckets have no deadline (returns null). Time-based / fastExpiry
40
+ * buckets that carry a single `within` window get `now + within`; the reconcile
41
+ * cron and fastExpiry timer own the actual leave.
42
+ *
43
+ * Centralized so the real-time join (check-membership.ts), the reconcile-discovered
44
+ * join (bucket-reconcile.ts), and the backfill join (bucket-backfill.ts) compute
45
+ * the SAME deadline — a divergence here would let a membership-writer arm a window
46
+ * the cron/timer disagrees with.
47
+ */
48
+ export declare function computeExpiresAt(bucket: BucketMeta): Date | null;
49
+ /**
50
+ * The unconditional max-dwell TTL deadline, stamped once on JOIN. null when the
51
+ * bucket has no `maxDwell`; the TTL sweep filters `isNotNull(maxDwellAt)`, so an
52
+ * unset value is never force-left. Shared by all three join writers so the TTL
53
+ * stamp is computed identically.
54
+ */
55
+ export declare function computeMaxDwellAt(bucket: BucketMeta): Date | null;
56
+ /**
57
+ * True when a windowed `count` satisfies the (exists/not_exists/count) event
58
+ * criterion — the POSITIVE "is a member by this windowed count" decision. Shared
59
+ * by the backfill matcher path (selectEventMatchers' positive branch). Behavior is
60
+ * identical to the prior local `matchesCount`: a `count` check with no
61
+ * operator/value (or an unrecognized operator) falls back to `count > 0` / `false`
62
+ * respectively.
63
+ */
64
+ export declare function matchesEventCount(criteria: EventCondition, count: number): boolean;
65
+ /**
66
+ * The SHOULD-LEAVE decision from a windowed count, per criterion shape — a member
67
+ * leaves when the criterion is NO LONGER satisfied. Shared by the reconcile
68
+ * cron's set-based leave path. Behavior is identical to the prior local
69
+ * `shouldLeaveByCount`: it is the per-shape NEGATION of {@link matchesEventCount}
70
+ * for `exists`/`count`, an event-reappeared check for `not_exists`, and preserves
71
+ * the `count` `default → false` for an unrecognized operator.
72
+ */
73
+ export declare function shouldLeaveByCount(criteria: EventCondition, windowedCount: number): boolean;
74
+ //# sourceMappingURL=membership-epoch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"membership-epoch.d.ts","sourceRoot":"","sources":["../../src/buckets/membership-epoch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,aAAa,EAClB,KAAK,cAAc,EAEnB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG/D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,cAAc,GAAG,IAAI,CAW1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAMhE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAIjE;AA8BD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,MAAM,GACZ,OAAO,CAcT;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,cAAc,EACxB,aAAa,EAAE,MAAM,GACpB,OAAO,CAuBT"}
@@ -0,0 +1,6 @@
1
+ import type { BucketRegistry } from "@hogsend/core/registry";
2
+ export declare const setBucketRegistry: (value: BucketRegistry) => void;
3
+ export declare const getBucketRegistrySingleton: () => BucketRegistry;
4
+ /** Reset the singleton — only for test cleanup. */
5
+ export declare const resetBucketRegistry: () => void;
6
+ //# sourceMappingURL=registry-singleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-singleton.d.ts","sourceRoot":"","sources":["../../src/buckets/registry-singleton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK7D,eAAO,MAAM,iBAAiB,iCAAgB,CAAC;AAC/C,eAAO,MAAM,0BAA0B,sBAAgB,CAAC;AACxD,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,YAAkB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { BucketRegistry } from "@hogsend/core/registry";
2
+ import type { DefinedJourney } from "../journeys/define-journey.js";
3
+ import type { DefinedBucket } from "./define-bucket.js";
4
+ /**
5
+ * Build a {@link BucketRegistry} from an injected array of buckets, applying the
6
+ * enabled filter, and install it as the process singleton (so the real-time
7
+ * ingest path and the reconcile cron can resolve it). Returns the registry.
8
+ *
9
+ * `parseEnabledFilter` (journeys/registry.ts) is reused as-is — `ENABLED_BUCKETS`
10
+ * honours the same `"*"`-or-csv contract as `ENABLED_JOURNEYS` (Section 9.3).
11
+ * `BucketRegistry.register()` runs `bucketMetaSchema.parse()` internally, so no
12
+ * separate validation step is needed here.
13
+ */
14
+ export declare function buildBucketRegistry(buckets: DefinedBucket[], enabledFilter?: string): BucketRegistry;
15
+ /**
16
+ * Select the Hatchet durable tasks for the enabled buckets. This is the SINGLE
17
+ * place a bucket's per-user fast-expiry timer task is constructed (Section
18
+ * 4.3/9.4) — task construction happens at worker build, AFTER the registry has
19
+ * validated every meta, never at module-load.
20
+ *
21
+ * Only `meta.fastExpiry` buckets contribute a task; the engine-wide
22
+ * `bucketReconcileTask` (registered separately in `baseWorkflows`) owns
23
+ * time-based leaves regardless. The fast-expiry timer is a single shared
24
+ * `durableTask` keyed on `bucket:arm-expiry` (per-bucket arming is by event
25
+ * payload, not per-bucket task instances), so it is registered once if ANY
26
+ * enabled bucket opts in.
27
+ */
28
+ export declare function selectBucketTasks(buckets: DefinedBucket[], enabledFilter?: string): NonNullable<DefinedBucket["task"]>[];
29
+ /**
30
+ * Select the Hatchet durable tasks for the reaction journeys generated by
31
+ * `bucket.on()` across the ENABLED buckets (Section 9). Reactions are
32
+ * bucket-owned, so they are gated by `ENABLED_BUCKETS` — NOT `ENABLED_JOURNEYS`
33
+ * (their `bucket-<id>-on-<kind>` ids never appear in a consumer's
34
+ * `ENABLED_JOURNEYS` csv, so folding them into the journeys[] array would drop
35
+ * every reaction whenever ENABLED_JOURNEYS is a csv).
36
+ *
37
+ * Asserts no reaction-id collision (a build-time loud failure) before returning.
38
+ */
39
+ export declare function selectBucketReactionTasks(buckets: DefinedBucket[], enabledFilter?: string, userJourneyIds?: Iterable<string>): NonNullable<DefinedBucket["task"]>[];
40
+ /**
41
+ * Collect the reaction `DefinedJourney`s across the ENABLED buckets (Section 9).
42
+ * Bucket-gated by `ENABLED_BUCKETS` for the same reason as
43
+ * {@link selectBucketReactionTasks}. The container registers their metas into the
44
+ * journey registry directly (bypassing the ENABLED_JOURNEYS filter) so the admin
45
+ * `feedsJourneys` and the dwell cron can resolve them.
46
+ */
47
+ export declare function collectBucketReactionJourneys(buckets: DefinedBucket[], enabledFilter?: string): DefinedJourney[];
48
+ /**
49
+ * Reaction tasks register on Hatchet under `journey-${meta.id}`. Two buckets
50
+ * sharing an id, two reactions colliding on a generated id, or a user journey
51
+ * named `bucket-<id>-on-<kind>` collide silently (register-last-wins) or throw on
52
+ * boot. Throw a descriptive build-time error instead (Section 9).
53
+ *
54
+ * @param enabledBuckets the already-enabled buckets to scan.
55
+ * @param userJourneyIds ids of the consumer's hand-written journeys (optional);
56
+ * a reaction id colliding with one of these throws.
57
+ */
58
+ export declare function assertNoReactionIdCollisions(enabledBuckets: DefinedBucket[], userJourneyIds?: Iterable<string>): void;
59
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/buckets/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EAAE,EACxB,aAAa,CAAC,EAAE,MAAM,GACrB,cAAc,CAYhB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,EAAE,EACxB,aAAa,CAAC,EAAE,MAAM,GACrB,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAYtC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,aAAa,EAAE,EACxB,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,GAChC,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAYtC;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,aAAa,EAAE,EACxB,aAAa,CAAC,EAAE,MAAM,GACrB,cAAc,EAAE,CAKlB;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,aAAa,EAAE,EAC/B,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,GAChC,IAAI,CAoBN"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Bulk condition → SQL for the campaign wave runtime. Waves after the first
3
+ * qualify recipients FROM the anchored cohort (`campaign_recipients`) with one
4
+ * indexed query per page — the per-user `evaluateCondition()` path is never
5
+ * used on the wave hot path. Each supported `ConditionEval` compiles to a
6
+ * single [NOT] EXISTS predicate correlated against the outer
7
+ * `campaign_recipients` row; a step's condition array is AND-composed by the
8
+ * caller (OR is deferred — core's `composite` type is the seam, so composites
9
+ * THROW here rather than half-work).
10
+ *
11
+ * v1 supports exactly the cohort-builder vocabulary: `email_engagement`
12
+ * (opened/clicked over THIS campaign's prior sends), `event` (a `user_events`
13
+ * row since the campaign's `startedAt`), and `channel_identity` (a linked
14
+ * connector identity). `property` has no bulk source on this path and throws.
15
+ */
16
+ import { type ConditionEval } from "@hogsend/core";
17
+ import { type SQL } from "drizzle-orm";
18
+ /**
19
+ * Fresh suppression/unsubscribe re-check for a cohort wave — suppression is
20
+ * never snapshotted (GDPR/CAN-SPAM): a member who unsubscribes between waves
21
+ * is excluded from every subsequent wave automatically. Mirrors the bucket
22
+ * resolver's correlated NOT EXISTS exactly (an EXISTS subquery, NOT a JOIN,
23
+ * so an email with two prefs rows is not fanned out; an absent prefs row
24
+ * matches nothing → included, subscribed-by-default). `campaign_recipients.
25
+ * email` is normalized at write, so only the prefs side needs `lower()`. The
26
+ * mailer's per-send category check remains the authoritative backstop.
27
+ *
28
+ * The second NOT EXISTS covers the erasure path the prefs check misses: an
29
+ * admin contact delete (a GDPR erasure) sets ONLY `contacts.deletedAt` and
30
+ * writes nothing to `email_preferences`, so an erased wave-0 recipient would
31
+ * otherwise keep qualifying for every later wave (the mailer's per-send check
32
+ * reads only prefs, too). Matched on the same identity binding the anchor
33
+ * wrote (`userId = externalId ?? contactId` — see channelIdentitySql), and
34
+ * deliberately NOT on email: merge-loser rows are also soft-deleted and share
35
+ * their email with a live survivor, so an email leg would wrongly drop merged
36
+ * members. Failure direction here is under-delivery, never over-delivery.
37
+ */
38
+ export declare function cohortSuppressionSql(): SQL;
39
+ /**
40
+ * Compile one wave `where` condition to its correlated [NOT] EXISTS predicate.
41
+ * `startedAt` is the claimed row's `startedAt` — the anchor `event` conditions
42
+ * scope to ("since the campaign started"), which is why the claim CAS must
43
+ * never reset it.
44
+ *
45
+ * @throws on `composite`/`property` conditions (not supported on the wave
46
+ * path in v1), an `event` count check, or an unknown `channel_identity`
47
+ * connector.
48
+ */
49
+ export declare function waveConditionSql(opts: {
50
+ condition: ConditionEval;
51
+ campaignId: string;
52
+ startedAt: Date;
53
+ }): SQL;
54
+ //# sourceMappingURL=cohort-sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cohort-sql.d.ts","sourceRoot":"","sources":["../../src/campaigns/cohort-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAEL,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AAQvB,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,aAAa,CAAC;AAc5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI,GAAG,CAgB1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CACjB,GAAG,GAAG,CAcN"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Code-defined campaigns (broadcasts) — a scheduled send committed to the
3
+ * repo, mirroring `defineJourney()` / `defineList()`: write a file, deploy,
4
+ * and the worker's boot reconciler schedules it; once sent it is retired
5
+ * (redeploys no-op via the campaign's definition idempotency key).
6
+ *
7
+ * A defined campaign is NOT a new runtime — it reconciles into the same
8
+ * `campaigns` row + durable `send-campaign` task the `POST /v1/campaigns`
9
+ * data-plane uses, so scheduling, cancel, counts, and Studio visibility are
10
+ * identical regardless of how the campaign was created.
11
+ *
12
+ * A campaign is one or more `steps` — email waves separated by durable waits
13
+ * (`step.send` / `step.wait`), each wave a SET operation over the audience,
14
+ * never per-user code (that's `defineJourney`). The legacy single-template
15
+ * form stays supported forever and compiles to one send step.
16
+ */
17
+ import { type CampaignStep } from "@hogsend/core";
18
+ import type { TemplateName } from "@hogsend/email";
19
+ /**
20
+ * The `campaigns.idempotency_key` namespace for code-defined campaigns. A
21
+ * definition's row key is `campaign-def:<id>` — the reconciler resolves the
22
+ * existing row through it, which is what makes a redeploy after `sent` a no-op
23
+ * instead of a second blast.
24
+ */
25
+ export declare const DEFINED_CAMPAIGN_KEY_PREFIX = "campaign-def:";
26
+ /** The audience selector — exactly one of `list` or `bucket` (validated). */
27
+ export type CampaignAudience = {
28
+ list: string;
29
+ } | {
30
+ bucket: string;
31
+ };
32
+ /**
33
+ * The validated, fully-defaulted campaign metadata. `steps` is the canonical
34
+ * form (always populated — the legacy single-template form compiles to one
35
+ * send step); `template`/`props`/`subject`/`from` mirror the FIRST send step
36
+ * so the reconciler and every single-send consumer keep working unchanged.
37
+ * `sendAt` is always a `Date` after `defineCampaign` (authoring input also
38
+ * accepts an ISO string); `enabled` defaults to `true`, `name` to the id.
39
+ */
40
+ export interface CampaignMeta {
41
+ id: string;
42
+ name: string;
43
+ audience: CampaignAudience;
44
+ template: TemplateName;
45
+ props?: Record<string, unknown>;
46
+ subject?: string;
47
+ from?: string;
48
+ steps: CampaignStep[];
49
+ sendAt: Date;
50
+ enabled: boolean;
51
+ }
52
+ /** A defined campaign. `id` is surfaced for literal-typed consumption. */
53
+ export interface DefinedCampaign<Id extends string = string> {
54
+ readonly meta: CampaignMeta;
55
+ readonly id: Id;
56
+ }
57
+ /**
58
+ * Define a campaign (broadcast) in code — a single send, or multi-step waves
59
+ * via `steps: [step.send(…), step.wait(…), …]`. Exactly one of the two forms
60
+ * (top-level `template` fields XOR `steps`) must be provided. Validates the
61
+ * id shape, the audience XOR (exactly one of `list` / `bucket`), that
62
+ * `sendAt` parses to a real instant, and the step sequence: 1–10 steps, the
63
+ * FIRST must be a send (`sendAt` is the timing — a leading wait is redundant;
64
+ * announcement steps are phase 2), the LAST must not be a wait, `where` only
65
+ * on send steps after the first (the cohort must exist before it can be
66
+ * filtered), every wait >= 5 minutes, and every `where` condition is one the
67
+ * wave runtime can compile to bulk SQL — email_engagement, event
68
+ * exists/not_exists, channel_identity targeting `"discord"` (the only
69
+ * linked-identity connector in v1); `property`/`composite`/event-`count`
70
+ * conditions are rejected HERE so they fail at deploy, not mid-campaign.
71
+ * Whether
72
+ * `sendAt` is still in the future is deliberately NOT checked here — that is
73
+ * a deploy-time question the reconciler answers (a definition whose `sendAt`
74
+ * is already stale at first reconcile becomes `expired`, never a surprise
75
+ * blast).
76
+ *
77
+ * @throws if `id` is empty/malformed, both/neither of `template`/`steps` are
78
+ * given, the step sequence breaks any rule above, the audience is not exactly
79
+ * one of list/bucket, or `sendAt` does not parse.
80
+ */
81
+ export declare function defineCampaign<const Id extends string>(meta: {
82
+ id: Id;
83
+ name?: string;
84
+ audience: CampaignAudience;
85
+ sendAt: Date | string;
86
+ enabled?: boolean;
87
+ } & ({
88
+ template: TemplateName;
89
+ props?: Record<string, unknown>;
90
+ subject?: string;
91
+ from?: string;
92
+ steps?: undefined;
93
+ } | {
94
+ steps: CampaignStep[];
95
+ template?: undefined;
96
+ props?: undefined;
97
+ subject?: undefined;
98
+ from?: undefined;
99
+ })): DefinedCampaign<Id>;
100
+ /** Narrowing helper: the audience kind + id as stored on the campaigns row. */
101
+ export declare function audienceOf(meta: CampaignMeta): {
102
+ audienceKind: "list" | "bucket";
103
+ audienceId: string;
104
+ };
105
+ //# sourceMappingURL=define-campaign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-campaign.d.ts","sourceRoot":"","sources":["../../src/campaigns/define-campaign.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAWnD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,kBAAkB,CAAC;AAE3D,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM;IACzD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EACpD,IAAI,EAAE;IACJ,EAAE,EAAE,EAAE,CAAC;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,CACA;IACE,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GACD;IACE,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CACJ,GACA,eAAe,CAAC,EAAE,CAAC,CAqFrB;AAwFD,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG;IAC9C,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB,CAKA"}
@@ -0,0 +1,13 @@
1
+ import type { HogsendClient } from "../container.js";
2
+ import { type DefinedCampaign } from "./define-campaign.js";
3
+ export interface ReconcileResult {
4
+ created: number;
5
+ updated: number;
6
+ expired: number;
7
+ skipped: number;
8
+ }
9
+ export declare function reconcileDefinedCampaigns(opts: {
10
+ client: HogsendClient;
11
+ campaigns: DefinedCampaign[];
12
+ }): Promise<ReconcileResult>;
13
+ //# sourceMappingURL=reconcile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/campaigns/reconcile.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAY9B,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B,GAAG,OAAO,CAAC,eAAe,CAAC,CA+Q3B"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Authoring sugar for campaign steps ({@link defineCampaign} `steps:`).
3
+ * Each helper returns the plain stored POJO ({@link CampaignStep} —
4
+ * `campaigns.steps` blob entries): `step.send` normalizes a `where` builder
5
+ * to `ConditionEval[]` HERE, at authoring time (the same
6
+ * normalize-at-definition pattern as `trigger.where` in `defineJourney`), so
7
+ * the stored form is always introspectable data. Channel steps
8
+ * (`step.discord.post` / `.dm`, …) are phase 2.
9
+ */
10
+ import { type CampaignSendStep, type CampaignWaitStep, type CampaignWhere, type DurationObject } from "@hogsend/core";
11
+ import type { TemplateName } from "@hogsend/email";
12
+ export declare const step: {
13
+ /**
14
+ * A per-recipient email wave. `where` filters the campaign's cohort
15
+ * (builder or declarative conditions — engagement terminals with no
16
+ * template scope to "any prior send of this campaign"); only valid on
17
+ * steps after the first (validated by `defineCampaign`).
18
+ */
19
+ send(opts: {
20
+ template: TemplateName;
21
+ props?: Record<string, unknown>;
22
+ subject?: string;
23
+ from?: string;
24
+ where?: CampaignWhere;
25
+ }): CampaignSendStep;
26
+ /** A durable gap between waves. Minimum 5 minutes (validated). */
27
+ wait(duration: DurationObject): CampaignWaitStep;
28
+ };
29
+ //# sourceMappingURL=steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../src/campaigns/steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,IAAI;IACf;;;;;OAKG;eACQ;QACT,QAAQ,EAAE,YAAY,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,aAAa,CAAC;KACvB,GAAG,gBAAgB;IAYpB,kEAAkE;mBACnD,cAAc,GAAG,gBAAgB;CAGjD,CAAC"}
@@ -0,0 +1,98 @@
1
+ import type { OpenAPIHono } from "@hono/zod-openapi";
2
+ import type { AppEnv } from "../app.js";
3
+ import type { HogsendClient } from "../container.js";
4
+ import { type ColdConnectBranding } from "./page.js";
5
+ import { type ColdConnectThrottleConfig } from "./throttle.js";
6
+ import { type ColdConnectBinding } from "./token.js";
7
+ export type { ColdConnectBranding } from "./page.js";
8
+ export type { ColdConnectThrottleConfig } from "./throttle.js";
9
+ export type { ColdConnectBinding } from "./token.js";
10
+ /**
11
+ * The identity column an `identityKind` resolves a contact on. `userId` and
12
+ * `anonymousId` ride the `external_id`/`anonymous_id` columns under a
13
+ * caller-chosen `platformKey` prefix (e.g. `telegram:`) — there is NO engine-side
14
+ * collision guard there (unlike `discordId`'s dedicated column), so the
15
+ * `platformKey` prefix IS the namespace. `discordId` resolves the dedicated
16
+ * Discord column.
17
+ */
18
+ export type ColdConnectIdentityKind = "userId" | "discordId" | "anonymousId";
19
+ /** Config for {@link createColdConnect}. */
20
+ export interface ColdConnectConfig<S = Record<string, unknown>> {
21
+ /** Stable connector id — seals the token, names the basePath, scopes throttle. */
22
+ connectorId: string;
23
+ /** Which `ingestEvent` identity column the platform key resolves on. */
24
+ identityKind: ColdConnectIdentityKind;
25
+ /** Map a raw platform user id to the namespaced ingest key (e.g. `telegram:<id>`). */
26
+ platformKey: (platformUserId: string) => string;
27
+ /** Event name pushed by the exchange's ingest — what the welcome journey `onEvents` on. */
28
+ linkedEvent: string;
29
+ /** The person-property key the connect page sets in `posthog.identify`. */
30
+ identifyPropKey: string;
31
+ /**
32
+ * Build the ingest payload from the sealed binding. CORRECTION (locked): any
33
+ * property the linked/welcome journey BRANCHES on (`user.properties.<id>`)
34
+ * MUST be a scalar `eventProperties` entry — `contactProperties` never reach
35
+ * the Hatchet payload.
36
+ */
37
+ buildIngest: (binding: ColdConnectBinding<S>) => {
38
+ eventProperties: Record<string, unknown>;
39
+ contactProperties?: Record<string, unknown>;
40
+ };
41
+ /** Connect-page branding (plain-text fields; accentColor regex-validated). */
42
+ branding: ColdConnectBranding;
43
+ /** Confirm-token TTL (seconds). Default 900. */
44
+ ttlSeconds?: number;
45
+ /** Mint-throttle config (Redis-INCR, fail-closed). */
46
+ throttle?: ColdConnectThrottleConfig;
47
+ /**
48
+ * Optional consumer hook run AFTER the bind commits, BEFORE the token is
49
+ * consumed (e.g. Discord `grantVerifiedRole`). AT-LEAST-ONCE: must be
50
+ * idempotent. The token is consumed even if this throws — the bind already
51
+ * committed, so a flaky hook must not keep the token live and re-fire on every
52
+ * click.
53
+ */
54
+ afterBind?: (binding: ColdConnectBinding<S> & {
55
+ contactKey: string;
56
+ }, deps: {
57
+ container: HogsendClient;
58
+ }) => Promise<void>;
59
+ }
60
+ export type MintConfirmResult = {
61
+ ok: true;
62
+ token: string;
63
+ } | {
64
+ ok: false;
65
+ reason: string;
66
+ };
67
+ /** The object returned by {@link createColdConnect}. */
68
+ export interface ColdConnect<S = Record<string, unknown>> {
69
+ /**
70
+ * Mint a confirm token (throttled, fail-closed). Returns `{ ok:false }` when
71
+ * throttled or Redis is unavailable — the caller MUST NOT send a link then.
72
+ */
73
+ mintConfirm(args: {
74
+ platformUserId: string;
75
+ email: string;
76
+ scalars?: S;
77
+ }): Promise<MintConfirmResult>;
78
+ /** Build the connect URL for a minted token on the given API_PUBLIC_URL. */
79
+ confirmUrl(args: {
80
+ apiPublicUrl: string;
81
+ token: string;
82
+ }): string;
83
+ /** Mount `GET /connect/<id>` + `POST /connect/<id>/exchange` on the app. */
84
+ routes(app: OpenAPIHono<AppEnv>): void;
85
+ }
86
+ /**
87
+ * Build a cold-connect flow: chat `/link <email>` → emailed one-click confirm
88
+ * link → click → engine-served connect page → button POST → server-sealed token
89
+ * → `ingestEvent` folds the two contact rows into one + returns the canonical
90
+ * `contactKey` → page runs CLIENT-side `posthog.identify(contactKey)`.
91
+ *
92
+ * Returns `{ mintConfirm, confirmUrl, routes }`. `routes` derives its basePath
93
+ * from `config.connectorId` (never a caller-chosen mount) and the exchange
94
+ * asserts the sealed `binding.connectorId === connectorId` (410 on mismatch),
95
+ * for cross-connector token isolation.
96
+ */
97
+ export declare function createColdConnect<S = Record<string, unknown>>(config: ColdConnectConfig<S>): ColdConnect<S>;
98
+ //# sourceMappingURL=index.d.ts.map