@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,160 @@
1
+ import type { Conditions } from "@hatchet-dev/typescript-sdk/v1/index.js";
2
+ import type { JsonValue } from "@hatchet-dev/typescript-sdk/v1/types.js";
3
+ import { type DurationObject } from "@hogsend/core";
4
+ import type { JourneyMeta, JourneyRunFn } from "@hogsend/core/types";
5
+ import { type Database, journeyStates } from "@hogsend/db";
6
+ /** The event payload a journey durable task receives from `hatchet.events.push`. */
7
+ export interface EventPayloadInput {
8
+ userId: JsonValue;
9
+ userEmail: JsonValue;
10
+ properties: JsonValue;
11
+ /** The event's groupType→groupKey association map (`ingestEvent` pushes it
12
+ * on every event) — a group-scoped wait's trigger-association scope input. */
13
+ groups?: Record<string, string>;
14
+ /** The resolved subject contact row id (`ingestEvent` pushes it) — group
15
+ * membership auto-resolution input. */
16
+ contactId?: string;
17
+ [key: string]: JsonValue;
18
+ }
19
+ /**
20
+ * The structural slice of Hatchet's `DurableContext` the journey run lifecycle
21
+ * needs. The real SDK context satisfies it; tests pass a stub. Mirrors the
22
+ * shape `createJourneyContext` documents (sleepFor/waitFor normalization,
23
+ * memoized `now`), plus the run-id anchor and the abort signal the
24
+ * shutdown-release path reads.
25
+ */
26
+ export interface JourneyDurableCtx {
27
+ /** Replay-stable id of THIS logical durable run (see runAnchor below). */
28
+ workflowRunId: () => string;
29
+ sleepFor: (duration: DurationObject | number | `${number}s`) => Promise<unknown>;
30
+ waitFor: (conditions: Conditions | Conditions[]) => Promise<Record<string, unknown>>;
31
+ /** Replay-memoized clock (SDK >= 1.22.3); optional so stubs fall back live. */
32
+ now?: () => Promise<Date>;
33
+ /** Aborted when the worker releases the run (graceful shutdown). */
34
+ abortController?: {
35
+ signal?: {
36
+ aborted?: boolean;
37
+ };
38
+ };
39
+ }
40
+ /** The `journey_states` row an enrollment insert returns. */
41
+ export type JourneyStateRow = typeof journeyStates.$inferSelect;
42
+ /**
43
+ * Insert the enrollment row, tolerating the partial-unique-index race.
44
+ *
45
+ * The active-state read guard in the run lifecycle (a `findFirst` over the live
46
+ * statuses) is NOT atomic with this insert: two near-simultaneous FIRST events
47
+ * for the same (user, journey) — a burst, which is the digest primitive's whole
48
+ * target workload — can BOTH clear that guard and race here. The loser would
49
+ * otherwise hit the `uq_user_journey_active` partial unique index with a raw
50
+ * 23505 that escapes the task fn (durable tasks run with `retries: 0`) and
51
+ * surfaces as a FAILED Hatchet run. `onConflictDoNothing` against that index
52
+ * absorbs the loser, returning `undefined` (0 rows) — the SAME outcome the read
53
+ * guard produces, so the caller maps it to the `already_active` skip.
54
+ *
55
+ * DRIZZLE GOTCHA (from prior prod debugging in this repo — mirrors
56
+ * campaigns/reconcile.ts): for a PARTIAL unique index the arbiter predicate goes
57
+ * in `where`, NOT `targetWhere`. A `targetWhere` is silently ignored and
58
+ * Postgres then throws 42P10 ("no unique or exclusion constraint matching the ON
59
+ * CONFLICT specification") at runtime. The `where` reproduces the index
60
+ * predicate (`status IN ('active','waiting')`) EXACTLY — see
61
+ * journey-states.ts:uq_user_journey_active.
62
+ *
63
+ * PRD 05 T3 — the arbiter deliberately STAYS on the string key. The second live
64
+ * index, `uq_contact_journey_active`, cannot be an arbiter here: drizzle's
65
+ * `target` accepts columns only (no expression), and a bare
66
+ * `(contact_id, journey_id)` target would never fire for a NULL `contact_id` —
67
+ * i.e. for every anonymous visitor, a permanent supported state — so an
68
+ * anonymous re-trigger of a live journey would insert a second row and die on
69
+ * the string index. Instead its 23505 is caught below and mapped to the SAME
70
+ * zero-rows outcome, which the caller reads as `already_active`. That is the
71
+ * correct answer: the contact IS already live in this journey, under a different
72
+ * string key that adoption has since folded onto the same contact.
73
+ */
74
+ export declare function insertEnrollment(opts: {
75
+ db: Database;
76
+ userId: string;
77
+ userEmail: string;
78
+ journeyId: string;
79
+ context: Record<string, unknown>;
80
+ hatchetRunId?: string;
81
+ /**
82
+ * Blueprint runs serialize this insert against a concurrent GRAPH EDIT via a
83
+ * transaction-scoped advisory lock — `updateBlueprint` takes the SAME lock
84
+ * ({@link blueprintGraphLock}) around its in-flight count + guarded update,
85
+ * so an enrollment cannot become active/waiting in the window between that
86
+ * count and update. Code journeys have no mutable graph, so they insert
87
+ * lock-free (the default).
88
+ */
89
+ serializeWithGraphLock?: boolean;
90
+ /**
91
+ * Content fingerprint + label of the definition this enrollment enters
92
+ * under (meta.versionHash / meta.version). Stamped once here; never
93
+ * updated — no UPDATE path in the engine ever touches the version
94
+ * columns. Optional for API back-compat (dogfood tests call this
95
+ * directly); executeJourneyRun always passes them.
96
+ */
97
+ journeyVersionHash?: string | null;
98
+ journeyVersionLabel?: string | null;
99
+ /**
100
+ * PRD 04 dual-write: the `contacts.id` owning `userId`, stamped alongside the
101
+ * canonical string key. OPTIONAL and defaulting to NULL — this is public API
102
+ * (index.ts) and bookkeeping, so a caller that omits it (dogfood tests, any
103
+ * pre-PRD-04 consumer) behaves exactly as before. The RESOLVE lives in the
104
+ * caller, never here: `executeJourneyRun` already holds the pushed
105
+ * `input.contactId` and only pays for a lookup when it doesn't.
106
+ */
107
+ contactId?: string | null;
108
+ }): Promise<JourneyStateRow | undefined>;
109
+ export interface ExecuteJourneyRunOptions {
110
+ /**
111
+ * The journey's resolved meta. For a code journey this is `defineJourney`'s
112
+ * normalized `JourneyMeta`; for a blueprint it is built from the
113
+ * `journey_blueprints` row (same shape — that is the whole point: the
114
+ * enrollment guards below receive it verbatim, spec §6).
115
+ */
116
+ meta: JourneyMeta;
117
+ /** The run body — a code journey's `run` or the blueprint tree-walk. */
118
+ run: JourneyRunFn;
119
+ /** The Hatchet event payload the durable task received. */
120
+ input: EventPayloadInput;
121
+ /** The Hatchet `DurableContext` (or a structural stub in tests). */
122
+ hatchetCtx: JourneyDurableCtx;
123
+ /**
124
+ * Extra keys merged into the enrollment row's `context` jsonb on FIRST entry
125
+ * (a replay recovers the existing row and never re-writes it). The blueprint
126
+ * interpreter pins `__blueprintVersion` here (spec §12).
127
+ */
128
+ extraContext?: Record<string, unknown>;
129
+ /**
130
+ * Serialize the enrollment insert against a concurrent blueprint graph edit
131
+ * with a transaction-scoped advisory lock (spec §12). Set by the blueprint
132
+ * interpreter — the blueprint id IS the journeyId, so the lock key matches
133
+ * `updateBlueprint`'s. Code journeys leave it unset (no mutable graph).
134
+ */
135
+ serializeEnrollment?: boolean;
136
+ /**
137
+ * Serialize a run failure into `journeyStates.errorMessage`. Defaults to the
138
+ * error's message; the blueprint interpreter writes the structured
139
+ * `{ blueprintId, nodeId, message }` JSON instead (spec §6.1).
140
+ */
141
+ serializeError?: (err: unknown) => string;
142
+ }
143
+ export type ExecuteJourneyRunResult = {
144
+ status: "skipped";
145
+ reason: string;
146
+ } | {
147
+ stateId: string;
148
+ status: "completed" | "exited";
149
+ };
150
+ /**
151
+ * The full journey durable-run lifecycle, shared VERBATIM by `defineJourney`
152
+ * tasks and the blueprint interpreter: replay recovery by run id → enrollment
153
+ * guards (entry only) → enrollment insert → timezone resolve → journey context
154
+ * + replay-safety boundary → `run()` → terminal transitions (completed /
155
+ * exited / released / failed). Extracted from `defineJourney` so the blueprint
156
+ * interpreter executes through the IDENTICAL machinery instead of a parallel
157
+ * reimplementation (spec §6) — behavior for code journeys is unchanged.
158
+ */
159
+ export declare function executeJourneyRun(options: ExecuteJourneyRunOptions): Promise<ExecuteJourneyRunResult>;
160
+ //# sourceMappingURL=execute-journey-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-journey-run.d.ts","sourceRoot":"","sources":["../../src/journeys/execute-journey-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAa,KAAK,cAAc,EAAgB,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEb,MAAM,qBAAqB,CAAC;AAC7B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M,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAmDvC;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB,wEAAwE;IACxE,GAAG,EAAE,YAAY,CAAC;IAClB,2DAA2D;IAC3D,KAAK,EAAE,iBAAiB,CAAC;IACzB,oEAAoE;IACpE,UAAU,EAAE,iBAAiB,CAAC;IAC9B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC;CAC3C;AAED,MAAM,MAAM,uBAAuB,GAC/B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAA;CAAE,CAAC;AAExD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA6pBlC"}
@@ -0,0 +1,24 @@
1
+ import type { JourneyGraph, JourneyMeta } from "@hogsend/core";
2
+ /**
3
+ * The consumer's `Templates`/`Events` `as const` maps (`CONST_NAME -> "value"`),
4
+ * threaded through so `Templates.X` / `Events.X` member expressions in a
5
+ * journey's source resolve to their REAL runtime values. This is what makes the
6
+ * derived node ids deterministic (stable `wait-event:${value}` / `digest:${value}`
7
+ * ids that join to `journeyStates.currentNodeId`) and populates `meta.template` /
8
+ * `meta.event` for exact previews — with NO other extraction changes.
9
+ */
10
+ export interface JourneyGraphConsts {
11
+ templates?: Record<string, string>;
12
+ events?: Record<string, string>;
13
+ }
14
+ export declare function buildJourneyGraph({ runSource, meta, consts, }: {
15
+ runSource?: string;
16
+ meta: JourneyMeta;
17
+ consts?: JourneyGraphConsts;
18
+ }): JourneyGraph;
19
+ /**
20
+ * The meta-only fallback graph: `start → end-completed`, `degraded: true`. Used
21
+ * when the source is missing or extraction throws.
22
+ */
23
+ export declare function degradedGraphFromMeta(meta: JourneyMeta): JourneyGraph;
24
+ //# sourceMappingURL=build-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-graph.d.ts","sourceRoot":"","sources":["../../../src/journeys/graph/build-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,YAAY,EACZ,WAAW,EASZ,MAAM,eAAe,CAAC;AAuHvB;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,IAAI,EACJ,MAAM,GACP,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B,GAAG,YAAY,CAOf;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,CAerE"}
@@ -0,0 +1,56 @@
1
+ import { type Database } from "@hogsend/db";
2
+ /**
3
+ * Thrown when a group-scoped primitive cannot pin its scope to a single group
4
+ * key: the enrolled contact has no live membership of the requested type, has
5
+ * more than one (ambiguous), or no contact was resolvable at all. A loud throw
6
+ * (not a silent skip) — an unresolvable scope is an authoring/data problem the
7
+ * journey must surface, exactly like an intra-run key collision.
8
+ */
9
+ export declare class GroupScopeUnresolvableError extends Error {
10
+ readonly journeyId: string;
11
+ readonly groupType: string;
12
+ constructor(opts: {
13
+ journeyId: string;
14
+ groupType: string;
15
+ detail: string;
16
+ });
17
+ }
18
+ /** The `group` option as authored: a bare type (auto-resolve the key) or an
19
+ * explicit `{ type, key }` pin. */
20
+ export type GroupScopeOption = string | {
21
+ type: string;
22
+ key?: string;
23
+ };
24
+ /**
25
+ * Resolve a `group` option to a concrete replay-stable `{ type, key }` scope.
26
+ * Resolution order (DECISIONS §3.3) — EXACTLY this sequence:
27
+ *
28
+ * 1. **Explicit key** (`{ type, key }`): returned verbatim, NEVER recorded —
29
+ * it wins even over a recorded `__groupKeys__[type]`, and two same-type
30
+ * call sites with different explicit keys stay independent.
31
+ * 2. **Trigger association** (`triggerGroups[type]`): returned, NOT recorded —
32
+ * it rides the task input, so it is replay-stable by construction.
33
+ * 3. **Recorded** `journey_states.context.__groupKeys__[type]`: returned
34
+ * verbatim (only ever holds membership-resolved keys).
35
+ * 4. **Sole live membership**: exactly one live membership of `type` → its
36
+ * key, RECORDED under `__groupKeys__[type]` via `recordOnce` (read-back
37
+ * semantics converge concurrent racers — the committed value is returned,
38
+ * never the locally computed one). 0 or ≥2 rows → throw
39
+ * {@link GroupScopeUnresolvableError}.
40
+ *
41
+ * `record: false` (future ctx.history use) keeps the order identical but step
42
+ * 4 resolves WITHOUT writing.
43
+ */
44
+ export declare function resolveGroupScope(opts: {
45
+ db: Database;
46
+ stateId: string;
47
+ journeyId: string;
48
+ contactId: string | undefined;
49
+ triggerGroups: Record<string, string> | undefined;
50
+ option: GroupScopeOption;
51
+ record?: boolean;
52
+ }): Promise<{
53
+ type: string;
54
+ key: string;
55
+ }>;
56
+ //# sourceMappingURL=group-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-scope.d.ts","sourceRoot":"","sources":["../../src/journeys/group-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,aAAa,CAAC;AAItE;;;;;;GAMG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAS3E;AAED;mCACmC;AACnC,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAoDvE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,EAAE,EAAE,QAAQ,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAClD,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CA4CzC"}
@@ -0,0 +1,264 @@
1
+ import type { EmailAttachment } from "@hogsend/core";
2
+ /**
3
+ * The minimal slice of Hatchet's `DurableContext` the boundary needs for its
4
+ * Layer-1 fast path. The real context structurally satisfies this; tests pass a
5
+ * stub. `memo(fn, deps)` is TS-`private` on the SDK class (1.22.3,
6
+ * context.d.ts:457) so it can only be reached via an `as any` cast at the call
7
+ * site — we model it here as optional so a probe (`typeof … === "function"`)
8
+ * gates it. `supportsEviction` (engineVersion >= v0.80.0) is the public getter
9
+ * that decides whether `memo` is actually durable: when false, the SDK's `memo`
10
+ * returns a bare `fn()` with ZERO durability, so we must NOT rely on it.
11
+ */
12
+ export interface HatchetMemoCtx {
13
+ memo?: <T>(fn: () => Promise<T> | T, deps: unknown[]) => Promise<T>;
14
+ supportsEviction?: boolean;
15
+ }
16
+ export interface JourneyEmailEffect {
17
+ to: string;
18
+ userId: string;
19
+ template: string;
20
+ subject?: string;
21
+ props: Record<string, unknown>;
22
+ category: string;
23
+ journeyName?: string;
24
+ journeyStateId?: string;
25
+ idempotencyKey?: string;
26
+ /**
27
+ * Neutral attachments (PRD 17), carried so a scoped `services.email`
28
+ * override observes the files a send would carry rather than silently
29
+ * dropping them. Deliberately NOT part of any derived idempotency key —
30
+ * the key stays `kind:anchor:site:template`.
31
+ */
32
+ attachments?: EmailAttachment[];
33
+ }
34
+ export interface JourneySmsEffect {
35
+ to: string;
36
+ userId: string;
37
+ template: string;
38
+ props: Record<string, unknown>;
39
+ category: string;
40
+ journeyName?: string;
41
+ journeyStateId?: string;
42
+ idempotencyKey?: string;
43
+ }
44
+ export interface JourneyConnectorEffect {
45
+ connectorId: string;
46
+ action: string;
47
+ args?: unknown;
48
+ idempotencyKey?: string;
49
+ }
50
+ export interface JourneyFeedEffect {
51
+ recipient: {
52
+ userId?: string;
53
+ email?: string;
54
+ anonymousId?: string;
55
+ };
56
+ type: string;
57
+ title?: string;
58
+ body?: string;
59
+ blocks?: unknown[];
60
+ actionUrl?: string;
61
+ metadata?: Record<string, unknown>;
62
+ category: string;
63
+ templateKey?: string;
64
+ journeyStateId?: string;
65
+ idempotencyKey?: string;
66
+ }
67
+ /** Scoped service replacements, primarily for deterministic journey tests. */
68
+ export interface JourneyServiceOverrides {
69
+ email?: (effect: JourneyEmailEffect) => Promise<{
70
+ emailSendId: string;
71
+ sentAt: string;
72
+ }>;
73
+ sms?: (effect: JourneySmsEffect) => Promise<{
74
+ smsSendId: string;
75
+ status: "sent" | "suppressed" | "unsubscribed" | "no_consent" | "skipped";
76
+ reason?: string;
77
+ sentAt?: string;
78
+ }>;
79
+ connector?: (effect: JourneyConnectorEffect) => Promise<unknown>;
80
+ /** Required with `connector`; validates an action before scoped capture. */
81
+ connectorActionExists?: (connectorId: string, action: string) => boolean;
82
+ feed?: (effect: JourneyFeedEffect) => Promise<{
83
+ feedItemId: string | null;
84
+ recipientKey: string | null;
85
+ suppressed: boolean;
86
+ createdAt: string | null;
87
+ }>;
88
+ }
89
+ /**
90
+ * Per-enrollment, per-run state threaded through `AsyncLocalStorage` so the
91
+ * standalone `sendEmail` / `ctx.trigger` side-effect helpers can be made
92
+ * EXACTLY-ONCE across a durable replay WITHOUT any change to journey-authoring
93
+ * signatures. The boundary is established once in `define-journey` around the
94
+ * `run()` call; a replay-from-top re-enters that scope from the top, so the
95
+ * boundary is re-derived deterministically each time.
96
+ */
97
+ export interface JourneyBoundary {
98
+ /** The `journeyStates.id` — used for FK/observability and as the key anchor
99
+ * fallback when no replay-stable run id is available (tests, outside a durable
100
+ * run). NOT the primary key anchor — see {@link runAnchor}. */
101
+ stateId: string;
102
+ /**
103
+ * The replay-stable per-enrollment anchor every derived key uses: the Hatchet
104
+ * `workflowRunId()`. Unlike `stateId` (a fresh `defaultRandom()` uuid that can
105
+ * differ if a replay-from-top mints a new `journey_states` row for a terminal
106
+ * prior enrollment), the run id is preserved across replays of the SAME logical
107
+ * durable run — so both dedup layers' keys collide as intended on a replay.
108
+ * Falls back to `stateId` when absent (a non-durable test/harness context).
109
+ */
110
+ runAnchor: string;
111
+ /**
112
+ * The nearest authored wait/checkpoint label, captured as side effects run so
113
+ * a same-template send inherits the label of the `ctx.sleep`/`waitForEvent`/
114
+ * `checkpoint` that immediately preceded it. This is the "site" discriminant
115
+ * that lets two sends of the SAME template on different branches derive
116
+ * distinct keys for free, without an explicit authoring label.
117
+ */
118
+ currentLabel: string | undefined;
119
+ /**
120
+ * Every derived key seen so far in THIS run. A second side effect that derives
121
+ * an already-seen key would silently over-dedup (the second email/trigger
122
+ * would be suppressed), so {@link registerKey} throws loudly instead — the
123
+ * footgun is a fail-fast dev error, never a silently-dropped message.
124
+ */
125
+ seenKeys: Set<string>;
126
+ /**
127
+ * Every `ctx.digest`/`ctx.throttle` SITE label seen so far in THIS run. Unlike
128
+ * {@link seenKeys} (auto-derived send/trigger keys), these are the authored
129
+ * site labels the primitives use to anchor their durable record. Reusing one
130
+ * label for two distinct sites would make them share a record and silently
131
+ * over-collapse, so {@link registerRecordLabel} throws loudly on a collision.
132
+ */
133
+ seenRecordLabels: Set<string>;
134
+ /**
135
+ * Layer-1 fast path: run `fn` through Hatchet's durable `memo` keyed by
136
+ * `deps` when (and only when) the engine supports eviction; otherwise fall
137
+ * through to a bare `fn()`. Belt-and-suspenders over the Layer-2 DB key — when
138
+ * eviction is live the provider/ingest call is skipped before the DB is even
139
+ * touched; when it isn't, Layer 2 still guarantees exactly-once.
140
+ */
141
+ memoize<T>(deps: unknown[], fn: () => Promise<T> | T): Promise<T>;
142
+ /**
143
+ * The enclosing journey's id (`meta.id`), threaded onto the boundary so the
144
+ * tracked mailer can enforce `meta.suppress` at send time WITHOUT the send
145
+ * call sites having to pass it. Optional so non-journey boundaries (tests,
146
+ * harness contexts) compile unchanged. Undefined ⇒ the suppress guard is inert.
147
+ */
148
+ journeyId?: string;
149
+ /**
150
+ * The enclosing journey's `meta.suppress` resolved to milliseconds
151
+ * (`durationToMs`). > 0 arms the tracked mailer's per-recipient min-gap
152
+ * suppress guard for this journey's sends; 0 (the `{}`/zero-duration default)
153
+ * disables it. Optional for the same reason as {@link journeyId}.
154
+ */
155
+ suppressMs?: number;
156
+ /**
157
+ * The enclosing journey's `meta.category` — the email-preference category
158
+ * stamped on this journey's `sendEmail` sends, overriding the template's own
159
+ * category (the standalone `sendEmail` has no journey reference of its own, so
160
+ * the boundary is the only conduit for it). Undefined ⇒ the send falls back to
161
+ * the built-in `journey` default. Optional so non-journey boundaries (tests,
162
+ * harness contexts) compile unchanged.
163
+ */
164
+ category?: string;
165
+ /** Async-scope-local effects used before process singletons or databases. */
166
+ services?: JourneyServiceOverrides;
167
+ /**
168
+ * Scope-local wall clock for synchronous side-effect metadata such as
169
+ * unsubscribe-token expiry. Production supplies the real clock; deterministic
170
+ * harnesses can supply their virtual clock without installing process-global
171
+ * fake timers. Optional so existing non-production boundary fixtures keep the
172
+ * historical real-time fallback.
173
+ */
174
+ now?: () => Date;
175
+ }
176
+ /**
177
+ * The active journey boundary, or `undefined` when not inside a journey `run()`
178
+ * (e.g. an admin bulk send or a `POST /v1/emails` call). Standalone helpers read
179
+ * this to decide whether to auto-key + memoize their side effect.
180
+ */
181
+ export declare function getJourneyBoundary(): JourneyBoundary | undefined;
182
+ /** Run `fn` with `boundary` installed as the active journey boundary. */
183
+ export declare function runWithJourneyBoundary<T>(boundary: JourneyBoundary, fn: () => Promise<T>): Promise<T>;
184
+ /**
185
+ * Build the {@link JourneyBoundary.memoize} closure for a given Hatchet context.
186
+ * Probes `memo`/`supportsEviction` at call time (not construction time) so a
187
+ * degraded engine cleanly falls through to `fn()`. Accepts `unknown` and casts
188
+ * to {@link HatchetMemoCtx} internally: the SDK's `memo` is TS-`private`, so the
189
+ * real `DurableContext` is not assignable to a public-`memo` type — keeping the
190
+ * cast HERE contains the one brittle SDK-private access to this single helper.
191
+ */
192
+ export declare function createMemoize(hatchetCtx: unknown): JourneyBoundary["memoize"];
193
+ /**
194
+ * Read `supportsEviction` off a Hatchet context for boot-time logging, tolerating
195
+ * the same private-member assignability gap as {@link createMemoize}.
196
+ */
197
+ export declare function supportsEviction(hatchetCtx: unknown): boolean;
198
+ /** The kind of side effect a key is derived for — keeps the namespaces apart. */
199
+ export type JourneyKeyKind = "send" | "smsSend" | "trigger" | "connector" | "refine";
200
+ /**
201
+ * Derive the deterministic, branch-stable idempotency key shared by BOTH defense
202
+ * layers. Content/site-derived (NEVER a positional counter), so a replay that
203
+ * reaches a given logical side effect re-derives the SAME key and a genuinely
204
+ * different side effect derives a DIFFERENT key — in both branch directions.
205
+ *
206
+ * send → `journeySend:<anchor>:<site>:<discriminant>`
207
+ * trigger → `journeyTrigger:<anchor>:<site>:<discriminant>`
208
+ * connector → `journeyConnector:<anchor>:<site>:<discriminant>`
209
+ *
210
+ * `anchor` is the REPLAY-STABLE per-enrollment id (`boundary.runAnchor`, the
211
+ * Hatchet `workflowRunId()`), NOT the freshly-minted `journeyStates.id`: a
212
+ * replay-from-top that mints a new state row for a terminal prior enrollment
213
+ * would otherwise derive a NON-colliding key and re-deliver. `site` is the
214
+ * explicit `idempotencyLabel` ?? the nearest authored wait label ?? the
215
+ * discriminant itself (templateKey for sends, event name for triggers). The key
216
+ * contains NO wall-clock and NO live-DB-read result, so it is stable across the
217
+ * clock/branch divergence a replay can introduce.
218
+ */
219
+ export declare function deriveJourneyKey(opts: {
220
+ kind: JourneyKeyKind;
221
+ /** The replay-stable per-enrollment anchor (`boundary.runAnchor`). */
222
+ anchor: string;
223
+ site: string;
224
+ discriminant: string;
225
+ }): string;
226
+ /**
227
+ * Recover the `<site>` discriminant embedded in a journey SEND idempotency key
228
+ * (`journeySend:<anchor>:<site>:<discriminant>`), given the replay-stable
229
+ * `anchor` (`boundary.runAnchor`) and the `discriminant` (the send's
230
+ * templateKey). Returns undefined when `key` is absent or is not a `journeySend:`
231
+ * key with the expected anchor/discriminant framing.
232
+ *
233
+ * This is how the SEND transition log recovers the EXACT `site` the mailer used
234
+ * when it derived the key via {@link deriveJourneyKey} — the SAME value
235
+ * `buildJourneyGraph` uses for the send node id (`send:<site>`) — so the log row
236
+ * joins the graph node WITHOUT recomputing the site (a recompute of
237
+ * `currentLabel ?? templateKey` would miss an explicit `idempotencyLabel`). Site
238
+ * strings may themselves contain `:` (e.g. `wait-event:foo`), so we strip the
239
+ * exact prefix/suffix rather than split on `:`.
240
+ */
241
+ export declare function parseJourneySendSite(opts: {
242
+ key: string | null | undefined;
243
+ anchor: string;
244
+ discriminant: string;
245
+ }): string | undefined;
246
+ /**
247
+ * Record `key` as used in this run, throwing loudly if it collides with a key an
248
+ * earlier side effect in the same run already derived. A collision means two
249
+ * genuinely-different sends/triggers resolved to the same key (e.g. the SAME
250
+ * template sent twice under the SAME nearest label) — under the unique index the
251
+ * second would be silently suppressed, so we fail fast at dev time instead. The
252
+ * fix is to pass a distinct `idempotencyLabel` to one of them.
253
+ */
254
+ export declare function registerKey(boundary: JourneyBoundary, key: string): void;
255
+ /**
256
+ * Record a `ctx.digest`/`ctx.throttle` SITE label as used in this run, throwing
257
+ * loudly if it collides with a label an earlier primitive call in the same run
258
+ * already used. Two sites sharing a label would share one durable record and
259
+ * silently over-collapse (a second digest folding into the first's window, a
260
+ * throttle verdict bleeding across sites), so we fail fast at dev time instead.
261
+ * No-op when `boundary` is undefined (a unit-test context outside a durable run).
262
+ */
263
+ export declare function registerRecordLabel(boundary: JourneyBoundary | undefined, label: string): void;
264
+ //# sourceMappingURL=journey-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-boundary.d.ts","sourceRoot":"","sources":["../../src/journeys/journey-boundary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OA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AAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAET;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,GAAG,SAAS,CAYrB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CASxE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,KAAK,EAAE,MAAM,GACZ,IAAI,CAUN"}
@@ -0,0 +1,60 @@
1
+ import type { Conditions, HatchetClient } from "@hatchet-dev/typescript-sdk/v1/index.js";
2
+ import type { DurationObject } from "@hogsend/core";
3
+ import type { JourneyRegistry } from "@hogsend/core/registry";
4
+ import { type SendWindow } from "@hogsend/core/schedule";
5
+ import type { JourneyContext, PropertyCondition } from "@hogsend/core/types";
6
+ import { type Database } from "@hogsend/db";
7
+ import type { Logger } from "../lib/logger.js";
8
+ /** Journey statuses that are terminal — a journey in any of these must never be
9
+ * resurrected back to "active" by a wait resuming. Exported so the durable task
10
+ * runner can avoid clobbering a terminal row to "failed" on a cancel. */
11
+ export declare const TERMINAL_STATUSES: readonly ["completed", "failed", "exited"];
12
+ /**
13
+ * CEL filter for a group-scoped wait: matches an event whose pushed payload
14
+ * carries the group association `groups[type] == key`. Membership is tested
15
+ * before indexing so an event with no `groups` map (an older producer) can
16
+ * never error the expression; both literals go through `celStringLiteral` so
17
+ * an externally-supplied type/key cannot break out of the filter.
18
+ */
19
+ export declare function buildGroupEventFilter(type: string, key: string): string;
20
+ interface JourneyContextConfig {
21
+ db: Database;
22
+ hatchet: HatchetClient;
23
+ hatchetCtx: {
24
+ sleepFor: (duration: DurationObject | number | `${number}s`) => Promise<unknown>;
25
+ waitFor: (conditions: Conditions | Conditions[]) => Promise<Record<string, unknown>>;
26
+ now?: () => Promise<Date>;
27
+ };
28
+ registry: JourneyRegistry;
29
+ logger: Logger;
30
+ stateId: string;
31
+ userId: string;
32
+ userEmail: string;
33
+ journeyContext: Record<string, unknown>;
34
+ /** The user's resolved IANA timezone, bound into `ctx.when`. */
35
+ resolvedTimezone: string;
36
+ /** The client default send window, auto-applied by `ctx.when`. */
37
+ defaultSendWindow?: SendWindow;
38
+ /** The journey's trigger event — `ctx.digest`'s default `event`. */
39
+ triggerEvent?: string;
40
+ /** The journey's already-normalized `trigger.where` — `ctx.digest` applies it
41
+ * when digesting the trigger event with no explicit `where` (honors the
42
+ * trigger contract). */
43
+ triggerWhere?: PropertyCondition[];
44
+ /** The journey id — keys the digest definition-interplay warn-once. */
45
+ journeyId?: string;
46
+ /** The journey's entry limit — drives `ctx.digest` interplay warnings. */
47
+ entryLimit?: "once" | "once_per_period" | "unlimited";
48
+ /** The journey's entry period (for `once_per_period`). */
49
+ entryPeriod?: DurationObject;
50
+ /** The trigger event's groupType→groupKey association map (rides the task
51
+ * input, so replay-stable) — group-scope resolution leg 2. */
52
+ triggerGroups?: Record<string, string>;
53
+ /** The enrolled contact's row id — group membership auto-resolution
54
+ * (leg 4). Undefined defers to the resolver's no-contact throw, which
55
+ * only fires when that leg is actually reached. */
56
+ contactId?: string;
57
+ }
58
+ export declare function createJourneyContext(config: JourneyContextConfig): JourneyContext;
59
+ export {};
60
+ //# sourceMappingURL=journey-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-context.d.ts","sourceRoot":"","sources":["../../src/journeys/journey-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACd,MAAM,yCAAyC,CAAC;AAMjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAA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AC,EAAE,iBAAiB,EAAE,CAAC;IACnC,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,WAAW,CAAC;IACtD,0DAA0D;IAC1D,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;kEAC8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC;;uDAEmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CAy3ChB"}
@@ -0,0 +1,42 @@
1
+ import { type Database } from "@hogsend/db";
2
+ /**
3
+ * The transition-log action vocabulary. These strings are written verbatim to
4
+ * `journey_logs.action` (a free-text column) and read by the Studio instance
5
+ * drawer timeline + the Phase-3 per-node *reached* funnel. Keep them in lockstep
6
+ * with the graph extractor's node semantics.
7
+ */
8
+ export type JourneyLogAction = "entered" | "sleep" | "wait" | "resume" | "checkpoint" | "send" | "trigger" | "completed" | "failed" | "exited";
9
+ export interface LogTransitionArgs {
10
+ db: Database;
11
+ journeyStateId: string;
12
+ /** Source node id (best-effort; null/undefined when unknown or not tracked). */
13
+ from?: string | null;
14
+ /** Destination node id (the node reached by this transition). */
15
+ to?: string | null;
16
+ action: JourneyLogAction;
17
+ detail?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Best-effort, STRICTLY fire-and-forget transition log. Inserts one
21
+ * `journey_logs` row for observability.
22
+ *
23
+ * SAFETY: this runs on the replay-safe journey hot path, so it must NEVER reject
24
+ * into or alter journey execution / replay-safety. Any failure — a synchronous
25
+ * build/dispatch throw OR a rejected insert — is swallowed to a silent no-op. It
26
+ * returns `void`; callers must NOT `await` it in a way that could throw, and no
27
+ * existing side effect may be reordered or gated on it.
28
+ *
29
+ * REPLAY: a journey is a Hatchet durable task that replays-from-top on eviction,
30
+ * so a replay RE-LOGS (duplicate rows). That is acceptable for a timeline — the
31
+ * Phase-3 reach-counts use `count(DISTINCT journey_state_id)` per `to_node_id`.
32
+ * Do NOT attempt to dedupe log rows.
33
+ */
34
+ export declare function logTransition(args: LogTransitionArgs): void;
35
+ /**
36
+ * `logTransition` for many states at once: one multi-row insert, with the same
37
+ * fire-and-forget, never-throws contract. Used where a single event moves a
38
+ * batch of states (an exit fan-out), so the log costs one statement instead of
39
+ * one per state.
40
+ */
41
+ export declare function logTransitions(db: Database, rows: ReadonlyArray<Omit<LogTransitionArgs, "db">>): void;
42
+ //# sourceMappingURL=journey-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-log.d.ts","sourceRoot":"","sources":["../../src/journeys/journey-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAe,MAAM,aAAa,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,OAAO,GACP,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,MAAM,GACN,SAAS,GACT,WAAW,GACX,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,iEAAiE;IACjE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAG3D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,GACjD,IAAI,CAoBN"}
@@ -0,0 +1,6 @@
1
+ import type { JourneySourceLocation } from "@hogsend/core";
2
+ export declare const setJourneySourceLocations: (value: Map<string, JourneySourceLocation>) => void;
3
+ export declare const getJourneySourceLocations: () => Map<string, JourneySourceLocation>;
4
+ /** Reset the singleton — only for test cleanup. */
5
+ export declare const resetJourneySourceLocations: () => void;
6
+ //# sourceMappingURL=journey-source-locations-singleton.d.ts.map