@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,687 @@
1
+ import type { HatchetClient } from "@hatchet-dev/typescript-sdk/v1/index.js";
2
+ import { type Database } from "@hogsend/db";
3
+ import type { SerializedContact } from "./contacts.js";
4
+ import type { Logger } from "./logger.js";
5
+ import { type WebhookEventType } from "./webhook-signing.js";
6
+ export { type EmailSendContextByMessageId,
7
+ /**
8
+ * @deprecated Kept for one minor; use {@link EmailSendContextByMessageId}.
9
+ */
10
+ type ResendEmailSendContext, resolveEmailSendContextByMessageId,
11
+ /**
12
+ * @deprecated Kept for one minor; use
13
+ * {@link resolveEmailSendContextByMessageId}.
14
+ */
15
+ resolveEmailSendContextByResendId, } from "./tracking-events.js";
16
+ /**
17
+ * The outbound event catalog re-exported for the emit spine. Identical to the
18
+ * signing lib's {@link WEBHOOK_EVENT_TYPES} — the single source of truth.
19
+ */
20
+ export declare const OUTBOUND_EVENTS: readonly ["contact.created", "contact.updated", "contact.deleted", "contact.unsubscribed", "contact.subscribed", "contact.control_group", "contact.refined", "email.sent", "email.delivered", "email.opened", "email.clicked", "email.action", "email.bounced", "email.complained", "email.replied", "sms.sent", "sms.delivered", "sms.failed", "sms.clicked", "journey.completed", "journey.heldout", "bucket.entered", "bucket.left", "link.clicked", "link.arrived", "funnel.stage_changed", "deal.quoted", "deal.sold", "group.identified", "group.member_added", "group.member_removed", "account.linked", "account.unlinked", "account.link_failed", "referral.touched", "referral.bound", "referral.qualified", "referral.converted", "referral.tree_converted", "referral.rejected", "impact.digest"];
21
+ export type OutboundEventName = WebhookEventType;
22
+ interface EmailEventPayload {
23
+ emailSendId: string;
24
+ messageId: string | null;
25
+ templateKey: string | null;
26
+ userId: string | null;
27
+ to: string;
28
+ at: string;
29
+ category?: string;
30
+ subject?: string;
31
+ }
32
+ interface BucketEventPayload {
33
+ bucketId: string;
34
+ bucketName: string;
35
+ userId: string;
36
+ userEmail: string | null;
37
+ transition: "entered" | "left";
38
+ entryCount: number;
39
+ source: string;
40
+ }
41
+ /**
42
+ * The serialized group shape carried on `group.identified` — mirrors
43
+ * {@link SerializedContact}: the internal columns (`organizationId`,
44
+ * `deletedAt`) are omitted and timestamps are ISO strings. Structurally
45
+ * identical to the `/v1/groups` route's `serializeGroup` output so the emit
46
+ * reuses that one serializer without a layering inversion (lib → routes).
47
+ */
48
+ export interface SerializedGroup {
49
+ id: string;
50
+ groupType: string;
51
+ groupKey: string;
52
+ displayName: string | null;
53
+ properties: Record<string, unknown> | null;
54
+ firstSeenAt: string;
55
+ lastSeenAt: string;
56
+ createdAt: string;
57
+ updatedAt: string;
58
+ }
59
+ /**
60
+ * The typed per-event payload map. `data` in each delivered envelope is exactly
61
+ * `OutboundPayloads[E]` for the emitted event `E`. Producers (the 12 hook
62
+ * points) construct these; subscribers receive them under `envelope.data`.
63
+ */
64
+ export interface OutboundPayloads {
65
+ "contact.created": SerializedContact;
66
+ "contact.updated": SerializedContact;
67
+ "contact.deleted": {
68
+ id: string;
69
+ externalId: string | null;
70
+ email: string | null;
71
+ };
72
+ "contact.unsubscribed": {
73
+ externalId: string | null;
74
+ email: string | null;
75
+ category: string | null;
76
+ scope: "all" | "category";
77
+ };
78
+ /**
79
+ * A genuine opt-IN (resubscribe-all or a category/channel grant) — the
80
+ * mirror of `contact.unsubscribed`, emitted from the same preference-write
81
+ * choke. `source` is the grant provenance: `"api"` (default),
82
+ * `"preference_center"`, `"started_keyword"`, `"import"`.
83
+ */
84
+ "contact.subscribed": {
85
+ externalId: string | null;
86
+ email: string | null;
87
+ category: string | null;
88
+ scope: "all" | "category";
89
+ source: string;
90
+ };
91
+ /**
92
+ * A refinement landed vendor traits on a contact (`refineContact`). Emitted
93
+ * ONLY on a genuine `status: "refined"` — never on `cached`, `not_found` or
94
+ * `skipped`, because a cache hit is a spend decision, not a change.
95
+ *
96
+ * `traits` carries the canonical trait KEY NAMES only — `["title",
97
+ * "company_domain"]` — never their values. That is deliberate: the
98
+ * payload says WHAT CHANGED, and a subscriber that wants the values reads
99
+ * the contact (`GET /v1/contacts`). So vendor-licensed person data never
100
+ * leaves the building inside a webhook body, and the envelope stays a fixed
101
+ * size whatever the provider returned.
102
+ *
103
+ * `userId` is the canonical contact key (`external_id ?? anonymous_id ??
104
+ * id`); `email` / `contactId` ride alongside so a subscriber can look the
105
+ * contact up by whichever key it holds.
106
+ */
107
+ "contact.refined": {
108
+ userId: string | null;
109
+ email: string | null;
110
+ contactId: string | null;
111
+ /** The enrichment provider id that answered. */
112
+ provider: string;
113
+ /** Mapped trait key NAMES, sorted. Values are deliberately absent. */
114
+ traits: string[];
115
+ /** ISO — the lookup instant (the same value as `enrichment.at`). */
116
+ at: string;
117
+ };
118
+ "email.sent": {
119
+ emailSendId: string;
120
+ messageId: string;
121
+ templateKey: string | null;
122
+ to: string;
123
+ userId: string | null;
124
+ category: string | null;
125
+ journeyStateId: string | null;
126
+ subject: string;
127
+ sentAt: string;
128
+ };
129
+ "email.delivered": EmailEventPayload;
130
+ "email.opened": EmailEventPayload;
131
+ "email.clicked": EmailEventPayload & {
132
+ linkUrl?: string;
133
+ linkId?: string;
134
+ };
135
+ /**
136
+ * A NON-email tracked link was clicked (Discord/referral/ad-hoc
137
+ * `createTrackedLink`). The deliberate counterpart to `email.clicked` — a
138
+ * non-email click has no `email_sends` row, so it carries `emailSendId: null`
139
+ * and `messageId: null` and never masquerades as an email click
140
+ * (MF-missing #3). `userId` is the link's stitch subject (`distinct_id`) when
141
+ * the link is identity-bearing, else null for a broadcast link.
142
+ */
143
+ "link.clicked": {
144
+ linkId: string;
145
+ source: string | null;
146
+ userId: string | null;
147
+ emailSendId: null;
148
+ messageId: null;
149
+ linkUrl: string;
150
+ at: string;
151
+ };
152
+ /**
153
+ * A visitor CONFIRMED landing from a tracked hit (opt-in `hs_ref` +
154
+ * POST /v1/t/arrive). Subset of `link.clicked` — fires only when the link
155
+ * opts in AND the landing page reports back. Unlike `link.clicked`, `linkId`
156
+ * here is the MANAGED `links.id` (`trackedLinkId` rides separately — no
157
+ * legacy split), and the identity fields are the VISITOR's: `userId` only
158
+ * when token-verified, `anonymousId` for a clamped anon arrival.
159
+ */
160
+ "link.arrived": {
161
+ linkId: string;
162
+ trackedLinkId: string;
163
+ ref: string;
164
+ source: string | null;
165
+ campaign: string | null;
166
+ userId: string | null;
167
+ anonymousId: string | null;
168
+ visitorKind: "token" | "anon";
169
+ linkUrl: string | null;
170
+ at: string;
171
+ };
172
+ /**
173
+ * A SEMANTIC link answered — the in-email action event (consumer-named, e.g.
174
+ * "nps.submitted"). Emitted at most once per (send, event name): first
175
+ * answer wins, scanner bursts are suppressed. `event`/`properties` carry the
176
+ * consumer semantics; the rest is send context.
177
+ */
178
+ "email.action": {
179
+ event: string;
180
+ properties: Record<string, unknown> | null;
181
+ emailSendId: string;
182
+ templateKey: string | null;
183
+ userId: string | null;
184
+ to: string;
185
+ at: string;
186
+ linkId: string;
187
+ linkUrl: string;
188
+ };
189
+ "email.bounced": EmailEventPayload & {
190
+ bounceType?: string;
191
+ bounceReason?: string;
192
+ };
193
+ "email.complained": EmailEventPayload & {
194
+ complaintType?: string;
195
+ reason?: string;
196
+ };
197
+ /**
198
+ * A HUMAN REPLIED (PRD 16). The one email event that reports a message
199
+ * coming BACK, so its shape is deliberately NOT `EmailEventPayload`: every
200
+ * send-context field is NULLABLE because a reply that could not be
201
+ * correlated to an `email_sends` row is still delivered here rather than
202
+ * dropped, exactly as the uncorrelated-reply EARS requires.
203
+ *
204
+ * `messageId` is the RECEIVED message's id; `inReplyTo` is the id of OUR
205
+ * send it answers, and it is present only when the relay PROVED that send
206
+ * belongs to this instance. A subscriber may key on `inReplyTo`; it must
207
+ * never key on anything else here, because every other field came out of a
208
+ * message a stranger composed.
209
+ */
210
+ "email.replied": {
211
+ /** The inbound message's own id — never the id of the send it answers. */
212
+ messageId: string;
213
+ /** OUR send's message id, proven. Null on an uncorrelated reply. */
214
+ inReplyTo: string | null;
215
+ correlated: boolean;
216
+ /** Send context, all null when uncorrelated. */
217
+ emailSendId: string | null;
218
+ templateKey: string | null;
219
+ userId: string | null;
220
+ /** The address WE sent to — not the reply's sender. Null uncorrelated. */
221
+ to: string | null;
222
+ /** The reply's sender, as parsed. Attacker-supplied; display only. */
223
+ from: string | null;
224
+ subject: string | null;
225
+ /** Bounded plain text. Never HTML. */
226
+ text: string | null;
227
+ textTruncated: boolean;
228
+ /** The address the reply arrived at (`hello@reply.acme.com`). */
229
+ recipient: string;
230
+ at: string;
231
+ };
232
+ "sms.sent": {
233
+ smsSendId: string;
234
+ messageId: string;
235
+ templateKey: string | null;
236
+ to: string;
237
+ userId: string | null;
238
+ category: string | null;
239
+ journeyStateId: string | null;
240
+ segments: number | null;
241
+ sentAt: string;
242
+ };
243
+ "sms.delivered": {
244
+ smsSendId: string;
245
+ messageId: string;
246
+ templateKey: string | null;
247
+ userId: string | null;
248
+ to: string;
249
+ at: string;
250
+ };
251
+ "sms.failed": {
252
+ smsSendId: string;
253
+ messageId: string;
254
+ templateKey: string | null;
255
+ userId: string | null;
256
+ to: string;
257
+ at: string;
258
+ errorCode?: string;
259
+ errorReason?: string;
260
+ };
261
+ /**
262
+ * A tracked SMS short link was clicked (first-party, PER-HIT — the SMS
263
+ * sibling of `email.clicked`). `linkId` is the `tracked_links.id`,
264
+ * `linkUrl` the original destination. `userId` is null for a raw send with
265
+ * no resolvable contact.
266
+ */
267
+ "sms.clicked": {
268
+ smsSendId: string;
269
+ messageId: string | null;
270
+ templateKey: string | null;
271
+ userId: string | null;
272
+ to: string;
273
+ at: string;
274
+ linkUrl: string;
275
+ linkId: string;
276
+ };
277
+ "journey.completed": {
278
+ journeyId: string;
279
+ journeyName: string;
280
+ stateId: string;
281
+ userId: string;
282
+ userEmail: string;
283
+ completedAt: string;
284
+ };
285
+ /**
286
+ * Global control group membership (impact plan §4.3) — emitted once per
287
+ * contact key (per-endpoint dedupe) on the first withheld send. `userId`
288
+ * is null for identity-less sends; `email` null on the SMS leg.
289
+ */
290
+ "contact.control_group": {
291
+ userId: string | null;
292
+ email: string | null;
293
+ at: string;
294
+ };
295
+ /** Holdout diversion (impact plan §4.1) — the counterfactual as data. */
296
+ "journey.heldout": {
297
+ journeyId: string;
298
+ journeyName: string;
299
+ stateId: string;
300
+ userId: string;
301
+ userEmail: string;
302
+ heldOutAt: string;
303
+ };
304
+ /**
305
+ * A referral EDGE reached its first end: someone clicked a `shared` link and
306
+ * landed. `refereeContactId` is NULL on the (normal) cold path — the referee
307
+ * is a browser id, not yet a person — which is exactly why this event names
308
+ * only the REFERRER as its subject and mints no contact.
309
+ */
310
+ "referral.touched": ReferralTouchPayload;
311
+ /**
312
+ * The edge gained its second end: the referee identified and
313
+ * `adoptOrphanHistory` stamped the touch. Delivered ONCE per touch (one
314
+ * dedupe key), and re-ingested onto the journey bus for BOTH ends.
315
+ */
316
+ "referral.bound": ReferralTouchPayload & {
317
+ boundAt: string;
318
+ side: string;
319
+ };
320
+ /**
321
+ * A bound referee did the thing the program asked for (`qualify.event`, with
322
+ * optional `where`). Exactly once per touch — the store's
323
+ * `qualified_at IS NULL` predicate is the guard.
324
+ */
325
+ "referral.qualified": ReferralTouchPayload & {
326
+ event: string | null;
327
+ conversionId: string | null;
328
+ qualifiedAt: string;
329
+ side: string;
330
+ };
331
+ /** A referee converted; the DIRECT referrer is told (`level` is always 1). */
332
+ "referral.converted": ReferralConversionPayload;
333
+ /**
334
+ * An ANCESTOR above the direct referrer is told about the same conversion,
335
+ * one delivery per hop to depth 5. `level` is a FACT on the event: a reward
336
+ * journey filters with `trigger.where: (b) => b.prop("level").eq(1)`, and
337
+ * that is the only place levels appear in code. Depth and weights stay
338
+ * report-time parameters.
339
+ */
340
+ "referral.tree_converted": ReferralConversionPayload;
341
+ /**
342
+ * An edge was refused — `self` (the referee turned out to BE the referrer,
343
+ * which falls out of the identity merge rather than a fraud heuristic),
344
+ * `window` (the touch was older than `bindWindow` at identify),
345
+ * `duplicate`, or `veto` (a `before*` hook said no; its free text rides
346
+ * `detail`).
347
+ */
348
+ "referral.rejected": ReferralTouchPayload & {
349
+ reason: string | null;
350
+ detail?: string | null;
351
+ };
352
+ /**
353
+ * Weekly impact digest (impact experiments D5) — facts-only rollup of
354
+ * shipped journey changes and holdout-lift threshold crossings, emitted
355
+ * by the engine-owned cron. Shipped entries are structurally
356
+ * observational (the type carries no lift fields); lift entries are
357
+ * holdout-backed causal. The ONE self-referential catalog event: the
358
+ * cron derives its watermark from its own delivery rows.
359
+ */
360
+ "impact.digest": {
361
+ /** UTC YYYY-MM-DD of the emit — also the dedupeKey day. */
362
+ periodKey: string;
363
+ /** ISO — watermark (last digest delivery, clamped to 30 days back). */
364
+ since: string;
365
+ /** ISO — this run's snapshot instant. */
366
+ until: string;
367
+ /**
368
+ * Lift first (desc |winProbability − 0.5|), then shipped (desc
369
+ * firstSeenAt); capped at 50.
370
+ */
371
+ entries: ImpactDigestEntry[];
372
+ truncated: boolean;
373
+ };
374
+ "bucket.entered": BucketEventPayload;
375
+ "bucket.left": BucketEventPayload & {
376
+ reason?: string;
377
+ };
378
+ /**
379
+ * A CRM pipeline change landed on the spine (webhook or reconciliation
380
+ * poll). Native identifiers — the canonical stage may be null when the
381
+ * per-provider stage map has no entry (surfaced, never dropped).
382
+ */
383
+ "funnel.stage_changed": CrmDealEventPayload & {
384
+ stageId: string;
385
+ stageName: string | null;
386
+ status: string | null;
387
+ };
388
+ /** A deal FIRST reached canonical `quoted`. Value = quote value. */
389
+ "deal.quoted": CrmDealEventPayload;
390
+ /** A deal FIRST reached canonical `sold`. Value = deal value. */
391
+ "deal.sold": CrmDealEventPayload;
392
+ /**
393
+ * A group was identified (upserted) via `POST /v1/groups` — the serialized
394
+ * group with its merged property bag. Fires on every successful identify
395
+ * (intent-layer only, never the pageview-driven ingest association path).
396
+ */
397
+ "group.identified": SerializedGroup;
398
+ /**
399
+ * A contact was added to a group via `POST /v1/groups/.../members` — emitted
400
+ * ONLY when THIS call inserted the membership (a re-add is a no-op).
401
+ */
402
+ "group.member_added": {
403
+ groupType: string;
404
+ groupKey: string;
405
+ groupId: string;
406
+ contactId: string;
407
+ role: string | null;
408
+ };
409
+ /**
410
+ * A contact was removed from a group via
411
+ * `DELETE /v1/groups/.../members/{contactId}` — emitted ONLY when THIS call
412
+ * actually deleted a membership row.
413
+ */
414
+ "group.member_removed": {
415
+ groupType: string;
416
+ groupKey: string;
417
+ groupId: string;
418
+ contactId: string;
419
+ };
420
+ /**
421
+ * A third-party platform account (`defineAccountLink`: Steam, Twitch, …) was
422
+ * bound to a contact. Emitted from the intent layer only — the callback
423
+ * handler and the data-plane import — never from the ingest path.
424
+ *
425
+ * FULL CURRENT STATE, never a delta (DECISIONS §5.2). A relink is TWO
426
+ * deliveries — `account.unlinked` for the displaced owner at the LOWER
427
+ * version, then `account.linked` at the higher one — and those retry
428
+ * independently, so they can arrive out of order, duplicated, or a day late.
429
+ * The customer rule that makes all three cases a no-op, verbatim from
430
+ * DECISIONS §5.3: *upsert keyed on `(provider, providerUserId)`; apply only
431
+ * when `incoming.version > stored.version`; otherwise discard.*
432
+ */
433
+ "account.linked": {
434
+ state: "linked";
435
+ /** The `AccountLinkProvider` meta.id (`"steam"`, `"twitch"`, …). */
436
+ provider: string;
437
+ providerUserId: string;
438
+ contactId: string;
439
+ /** The canonical contact key: `external_id ?? anonymous_id ?? id`. */
440
+ userId: string | null;
441
+ /**
442
+ * The CONTACT's email, never the provider-reported one. A
443
+ * provider-reported address is at most a display property (DECISIONS §6.3
444
+ * / §6.4) and must never become a resolution key downstream.
445
+ */
446
+ email: string | null;
447
+ /** The provider's display name for the account. */
448
+ username: string | null;
449
+ method: "oauth" | "import";
450
+ /** True when this link displaced a different live owner. */
451
+ relink: boolean;
452
+ /**
453
+ * A decimal STRING, never a JSON number. `linked_accounts.version` is a
454
+ * Postgres `bigint` (DECISIONS §5.1), which exceeds
455
+ * `Number.MAX_SAFE_INTEGER`, so a JSON number silently loses integer
456
+ * fidelity and breaks the `>` guard above in exactly the case that guard
457
+ * exists for. Serialize with `String(row.version)`; compare with
458
+ * `BigInt()` or a numeric column, never `parseInt`.
459
+ */
460
+ version: string;
461
+ /** ISO 8601. */
462
+ at: string;
463
+ };
464
+ /**
465
+ * A platform account was released from a contact — by the player, by the
466
+ * API/erasure path, or because a relink moved it elsewhere. Emitted from the
467
+ * intent layer only, never from the ingest path.
468
+ *
469
+ * FULL CURRENT STATE, never a delta (DECISIONS §5.2), and it shares the
470
+ * `(provider, providerUserId)` version sequence with `account.linked`, so
471
+ * the same rule applies verbatim from DECISIONS §5.3: *upsert keyed on
472
+ * `(provider, providerUserId)`; apply only when `incoming.version >
473
+ * stored.version`; otherwise discard.*
474
+ */
475
+ "account.unlinked": {
476
+ state: "unlinked";
477
+ provider: string;
478
+ providerUserId: string;
479
+ contactId: string;
480
+ /** The canonical contact key: `external_id ?? anonymous_id ?? id`. */
481
+ userId: string | null;
482
+ /** The CONTACT's email, never the provider-reported one. */
483
+ email: string | null;
484
+ reason: "player" | "api" | "relinked";
485
+ /**
486
+ * A decimal STRING, never a JSON number — `linked_accounts.version` is a
487
+ * Postgres `bigint` (DECISIONS §5.1) and a JSON number loses fidelity past
488
+ * `Number.MAX_SAFE_INTEGER`. Serialize with `String(row.version)`.
489
+ */
490
+ version: string;
491
+ /** ISO 8601. */
492
+ at: string;
493
+ };
494
+ /**
495
+ * A link flow ended without binding anything. Deliberately carries NO
496
+ * `version` and NO `state`: nothing mutated, so there is no current state to
497
+ * report and nothing for the `incoming.version > stored.version` guard to
498
+ * compare — a subscriber records this as an attempt, never as ownership.
499
+ *
500
+ * `contactId` is null whenever the flow failed before a trustworthy contact
501
+ * was in hand (a state token that did not verify carries nothing). This
502
+ * event NEVER mints a contact (DECISIONS §8).
503
+ */
504
+ "account.link_failed": {
505
+ provider: string;
506
+ reason: "denied" | "vetoed" | "exchange_failed" | "state_invalid";
507
+ contactId: string | null;
508
+ /** ISO 8601. */
509
+ at: string;
510
+ };
511
+ }
512
+ /** Shared payload for the `crm.*` outbound family. */
513
+ export interface CrmDealEventPayload {
514
+ provider: string;
515
+ dealId: string;
516
+ pipelineId: string | null;
517
+ /**
518
+ * The code-defined funnel claiming this deal's pipeline (defineFunnel).
519
+ * The emit site always sent it; the type lagged behind (impact plan §2
520
+ * seam 5) — now part of the contract.
521
+ */
522
+ funnelId: string | null;
523
+ canonicalStage: string | null;
524
+ value: number | null;
525
+ currency: string | null;
526
+ userId: string | null;
527
+ at: string;
528
+ }
529
+ /**
530
+ * One journey-version cohort inside an impact digest entry. Exposure-window
531
+ * metadata rides along because current vs previous cohorts have DIFFERENT
532
+ * exposure (a 3-day-old version vs a 60-day-old one is not a fair rate
533
+ * comparison) — subscribers MUST normalize or caveat against these.
534
+ */
535
+ export interface ImpactVersionCohort {
536
+ versionHash: string;
537
+ versionLabel: string | null;
538
+ /**
539
+ * All-time distinct treated users for this version — deliberately NOT
540
+ * windowed by `days` (named to say so; the /impact route's version rows
541
+ * ARE windowed).
542
+ */
543
+ enrollmentsAllTime: number;
544
+ converters: number;
545
+ /** converters / enrollmentsAllTime; 0 when the cohort is empty. */
546
+ conversionRate: number;
547
+ /** ISO min(created_at) of this hash's rows. */
548
+ firstSeenAt: string;
549
+ /** Whole days between firstSeenAt and the digest's `until`. */
550
+ exposureDays: number;
551
+ }
552
+ /**
553
+ * "You shipped a change" — OBSERVATIONAL by construction: the type carries
554
+ * no liftPercent/winProbability, so causal language is structurally
555
+ * impossible (the causal-language law, routes/admin/funnels.ts:16).
556
+ */
557
+ export interface ImpactDigestShippedEntry {
558
+ kind: "shipped";
559
+ causal: false;
560
+ journeyId: string;
561
+ /** null for blueprint/unregistered journeys. */
562
+ journeyName: string | null;
563
+ versionHash: string;
564
+ versionLabel: string | null;
565
+ change: "new_journey" | "new_version" | "new_label";
566
+ /** Set for new_label (the label that was current before the window). */
567
+ previousVersionLabel: string | null;
568
+ firstSeenAt: string;
569
+ goalDefinitionId: string | null;
570
+ current: ImpactVersionCohort;
571
+ /** null for new_journey / new_label. */
572
+ previous: ImpactVersionCohort | null;
573
+ }
574
+ /**
575
+ * "This is working / hurting" — a holdout-backed win-probability CROSSING
576
+ * (not level: no weekly re-nag). Suppressed verdicts never produce an
577
+ * entry, so winProbability is never null here; smallSample rides verbatim.
578
+ */
579
+ export interface ImpactDigestLiftEntry {
580
+ kind: "lift";
581
+ causal: true;
582
+ journeyId: string;
583
+ journeyName: string | null;
584
+ goalDefinitionId: string | null;
585
+ /** The lift window in days (90 — mirrors the lift route default). */
586
+ windowDays: number;
587
+ direction: "up" | "down";
588
+ treatment: {
589
+ contacts: number;
590
+ converters: number;
591
+ rate: number;
592
+ };
593
+ control: {
594
+ contacts: number;
595
+ converters: number;
596
+ rate: number;
597
+ };
598
+ liftPercent: number | null;
599
+ winProbability: number;
600
+ /**
601
+ * Last digest's as-REPORTED value when available (frozen-payload
602
+ * override), else the live recompute at the previous watermark; null
603
+ * when neither produced a probability.
604
+ */
605
+ previousWinProbability: number | null;
606
+ smallSample: boolean;
607
+ }
608
+ /**
609
+ * The shared shape of every touch-scoped referral event. Scalars only: these
610
+ * payloads double as the journey-bus `eventProperties`, and `ingestEvent`
611
+ * filters the Hatchet push down to `string | number | boolean | null`, so a
612
+ * nested field would be silently dropped between `user_events` and the journey
613
+ * (and a `where` clause naming it would never match).
614
+ */
615
+ export type ReferralTouchPayload = {
616
+ referralId: string;
617
+ touchId: string;
618
+ referrerContactId: string;
619
+ /** NULL until the edge binds. */
620
+ refereeContactId: string | null;
621
+ /** The canonical key at touch time — an ANONYMOUS id on a cold touch. */
622
+ refereeKey: string;
623
+ source: string;
624
+ linkId: string | null;
625
+ clickId: string | null;
626
+ status: string;
627
+ /** ISO 8601. */
628
+ touchedAt: string;
629
+ };
630
+ /** `referral.converted` / `referral.tree_converted`. */
631
+ export type ReferralConversionPayload = {
632
+ referralId: string;
633
+ touchId: string;
634
+ /** 1 = the direct referrer; 2+ = an ancestor. Capped at 5. */
635
+ level: number;
636
+ /** The contact being TOLD (who earns at this level). */
637
+ beneficiaryContactId: string;
638
+ /** The contact who actually converted. */
639
+ refereeContactId: string;
640
+ /** The next hop toward the referee — "your friend's friend". */
641
+ viaContactId: string;
642
+ conversionId: string;
643
+ /**
644
+ * The converted amount. NOT named `value`: this payload doubles verbatim as
645
+ * the journey-bus `eventProperties`, and a `value` there would fire the
646
+ * built-in wildcard `revenue` conversion (trigger `*` + `value > 0`) FOR THE
647
+ * BENEFICIARY - minting a phantom conversion on every ancestor and
648
+ * re-entering `convertReferral` up the whole chain.
649
+ */
650
+ conversionValue: number | null;
651
+ currency: string | null;
652
+ /** ISO 8601. */
653
+ at: string;
654
+ };
655
+ export type ImpactDigestEntry = ImpactDigestShippedEntry | ImpactDigestLiftEntry;
656
+ /**
657
+ * THE fire-and-forget emit spine. It does NOT deliver — it selects the active,
658
+ * subscribed endpoints for `event`, inserts one `webhook_deliveries` row per
659
+ * endpoint (all sharing ONE `webhookId` = the `Webhook-Id` header), and enqueues
660
+ * the durable {@link deliverWebhookTask} per inserted row.
661
+ *
662
+ * Idempotency: when `dedupeKey` is provided, the unique
663
+ * `(endpointId, dedupeKey)` index makes a re-emit (e.g. a Hatchet retry of the
664
+ * producing task) a no-op via `onConflictDoNothing` — no duplicate row, no
665
+ * second enqueue. Events without a `dedupeKey` are never deduped (NULL keys are
666
+ * distinct in Postgres), which is correct for non-retryable emit points.
667
+ *
668
+ * NEVER throws to callers. Internal failures (endpoint select, insert, enqueue)
669
+ * are logged via `logger.warn` and swallowed so a transient outbound error can
670
+ * never fail a contact upsert / email send / journey step. Callers MUST STILL
671
+ * wrap the call as `void emitOutbound(...).catch(logger.warn)` — the `.catch` is
672
+ * defence-in-depth against a programming error that escapes this guard.
673
+ *
674
+ * Single-tenant: only endpoints with `organizationId IS NULL` are selected and
675
+ * the delivery rows are written with `organizationId ?? null`. Multi-tenant
676
+ * scoping is a later non-breaking change.
677
+ */
678
+ export declare function emitOutbound<E extends OutboundEventName>(opts: {
679
+ db: Database;
680
+ hatchet: HatchetClient;
681
+ logger: Logger;
682
+ event: E;
683
+ payload: OutboundPayloads[E];
684
+ dedupeKey?: string;
685
+ organizationId?: string | null;
686
+ }): Promise<void>;
687
+ //# sourceMappingURL=outbound.d.ts.map