@hogsend/engine 0.67.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 (738) 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/env.ts +30 -0
  708. package/src/journeys/journey-log.ts +25 -8
  709. package/src/lib/contacts.ts +47 -1
  710. package/src/lib/email-service-types.ts +10 -0
  711. package/src/lib/ingestion.ts +30 -19
  712. package/src/lib/mailer-bounce-idempotency.test.ts +7 -2
  713. package/src/lib/mailer-replied.test.ts +7 -2
  714. package/src/lib/mailer.ts +1 -0
  715. package/src/lib/outbound-endpoint-cache.ts +83 -0
  716. package/src/lib/outbound.ts +56 -37
  717. package/src/lib/seed-posthog-destination.ts +5 -1
  718. package/src/lib/tracked.ts +11 -3
  719. package/src/lib/tracking-events.ts +20 -3
  720. package/src/middleware/api-key.ts +69 -60
  721. package/src/middleware/publishable-key.ts +11 -23
  722. package/src/middleware/rate-limit.ts +165 -3
  723. package/src/routes/admin/api-keys.ts +148 -0
  724. package/src/routes/admin/targeting.ts +6 -1
  725. package/src/routes/admin/webhooks.ts +4 -0
  726. package/src/routes/index.ts +67 -24
  727. package/src/workflows/backfill-contact-id.ts +3 -7
  728. package/src/workflows/bucket-backfill.ts +2 -2
  729. package/src/workflows/bucket-reconcile.ts +28 -12
  730. package/src/workflows/check-alerts.ts +3 -9
  731. package/src/workflows/crm-reconcile.ts +3 -2
  732. package/src/workflows/deliver-webhook.ts +21 -8
  733. package/src/workflows/dispatch-conversion.ts +2 -2
  734. package/src/workflows/identity-alias-backfill.ts +3 -2
  735. package/src/workflows/impact-digest.ts +2 -2
  736. package/src/workflows/import-contacts.ts +3 -4
  737. package/src/workflows/import-suppressions.ts +4 -5
  738. package/src/workflows/send-campaign.ts +10 -1
@@ -0,0 +1,678 @@
1
+ import type { HatchetClient } from "@hatchet-dev/typescript-sdk/v1/index.js";
2
+ import type { AccountLinkHooks, AccountLinkProvider, AnalyticsEventMirrorConfig, AnalyticsProvider, ConversionDestination, CrmProvider, CrmStageMap, DefinedConversion, DefinedFlag, DefinedFunnel, DefinedReferral, EmailProvider, EnrichmentProvider, FunnelStageEntry, FxRateProvider, JourneySourceLocation, PostHogService, SmsProvider, TimeZone } from "@hogsend/core";
3
+ import type { BucketRegistry, JourneyRegistry } from "@hogsend/core/registry";
4
+ import type { SendWindow } from "@hogsend/core/schedule";
5
+ import { type Database, type DatabaseClient, type JournalShape } from "@hogsend/db";
6
+ import type { TemplateRegistry } from "@hogsend/email";
7
+ import type { SmsTemplateRegistry } from "@hogsend/sms";
8
+ import type { DefinedBucket } from "./buckets/define-bucket.js";
9
+ import type { DefinedCampaign } from "./campaigns/define-campaign.js";
10
+ import { ConnectorActionRegistry } from "./connectors/action-registry-singleton.js";
11
+ import type { DefinedConnectorAction } from "./connectors/define-action.js";
12
+ import type { DefinedConnector } from "./connectors/define-connector.js";
13
+ import { ConnectorRegistry } from "./connectors/registry-singleton.js";
14
+ import type { DefinedDestination } from "./destinations/define-destination.js";
15
+ import { env } from "./env.js";
16
+ import type { DefinedJourney } from "./journeys/define-journey.js";
17
+ import { AccountLinkProviderRegistry } from "./lib/account-link-provider-registry.js";
18
+ import { AnalyticsProviderRegistry } from "./lib/analytics-provider-registry.js";
19
+ import { type Auth } from "./lib/auth.js";
20
+ import { CrmProviderRegistry } from "./lib/crm-provider-registry.js";
21
+ import { type DomainStatusService } from "./lib/domain-status.js";
22
+ import { EmailProviderRegistry } from "./lib/email-provider-registry.js";
23
+ import type { EmailService, FrequencyCapConfig } from "./lib/email-service-types.js";
24
+ import { EnrichmentProviderRegistry } from "./lib/enrichment-provider-registry.js";
25
+ import { FlagRegistry } from "./lib/flags-registry.js";
26
+ import { FunnelRegistry } from "./lib/funnel-registry.js";
27
+ import { type FxLens } from "./lib/fx.js";
28
+ import { type IdentityService } from "./lib/identity-service.js";
29
+ import { type Logger } from "./lib/logger.js";
30
+ import { ReferralRegistry } from "./lib/referral-registry.js";
31
+ import { SmsProviderRegistry } from "./lib/sms-provider-registry.js";
32
+ import type { SmsService } from "./lib/sms-service-types.js";
33
+ import { type DefinedList } from "./lists/define-list.js";
34
+ import { type ListRegistry } from "./lists/registry.js";
35
+ import { type DefinedContactSource } from "./sources/define-contact-source.js";
36
+ import { type ContactSourceRegistry } from "./sources/registry.js";
37
+ import { type DefinedWebhookSource } from "./webhook-sources/define-webhook-source.js";
38
+ export interface HogsendDefaults {
39
+ /** Global fallback IANA timezone for scheduling. Defaults to "UTC". */
40
+ timezone: TimeZone;
41
+ /** Default quiet-hours / send window auto-applied by `ctx.when`. */
42
+ sendWindow?: SendWindow;
43
+ /** Optional per-recipient frequency cap enforced in the mailer. */
44
+ frequencyCap?: FrequencyCapConfig;
45
+ }
46
+ export interface HogsendClient {
47
+ env: typeof env;
48
+ logger: Logger;
49
+ db: Database;
50
+ dbClient: DatabaseClient;
51
+ auth: Auth;
52
+ emailService: EmailService;
53
+ /**
54
+ * The container-held registry of email providers, keyed by `meta.id`. The
55
+ * `POST /v1/webhooks/email/:providerId` route resolves the verifying provider
56
+ * out of this. Holds at least the resolved active provider.
57
+ */
58
+ emailProviders: EmailProviderRegistry;
59
+ /**
60
+ * The single resolved active email provider (the one the mailer sends
61
+ * through). Resolved from `opts.email.defaultProvider` / `EMAIL_PROVIDER`,
62
+ * defaulting to the env-built Resend provider for byte-for-byte parity.
63
+ */
64
+ emailProvider: EmailProvider;
65
+ /**
66
+ * Cached sending-domain status for the ACTIVE provider. Consumed by the
67
+ * mailer's test-mode check (F3 — sync `testModeCached()` per send), the
68
+ * `GET/POST /v1/admin/domain` routes, and (via HTTP) the CLI
69
+ * (`hogsend domain`) + Studio Setup view. In-memory cache only; the per-send
70
+ * path never awaits a provider call.
71
+ */
72
+ domainStatus: DomainStatusService;
73
+ /**
74
+ * The app's template registry (key → component + subject + category +
75
+ * optional preview/examples). Same object threaded into the engine mailer;
76
+ * exposed here so admin preview/catalog routes can enumerate keys and render
77
+ * templates without going through a send. Empty when no templates are wired.
78
+ */
79
+ templates: TemplateRegistry;
80
+ /**
81
+ * The engine-owned tracked SMS sender (the SMS sibling of {@link emailService}).
82
+ * When no SMS provider is configured this is an inert stub whose `send` throws
83
+ * an actionable error — so an existing deploy without Twilio creds boots clean.
84
+ */
85
+ smsService: SmsService;
86
+ /**
87
+ * The container-held registry of SMS providers, keyed by `meta.id`. The
88
+ * `POST /v1/webhooks/sms/:providerId` route resolves the verifying provider
89
+ * out of this. Empty when no SMS provider is configured.
90
+ */
91
+ smsProviders: SmsProviderRegistry;
92
+ /**
93
+ * The single resolved active SMS provider the tracked sender delivers through.
94
+ * Undefined when no SMS provider is configured.
95
+ */
96
+ smsProvider?: SmsProvider;
97
+ /**
98
+ * The container-held registry of account-link providers (Steam, Twitch, or
99
+ * consumer-authored via `defineAccountLink`), keyed by `meta.id`. The
100
+ * `/v1/accounts/:provider/*` routes resolve providers out of this and 404 an
101
+ * unknown id. Unlike email/SMS/analytics there is NO single active provider:
102
+ * the player picks one per link, so there is no `accountLinkProvider` field,
103
+ * no `ACCOUNT_LINK_PROVIDER` env, and no "not registered" boot throw — the
104
+ * missing symmetry is deliberate. Empty when none configured (an
105
+ * unconfigured provider is ABSENT, never present-but-disabled).
106
+ */
107
+ accountLinkProviders: AccountLinkProviderRegistry;
108
+ /**
109
+ * The consumer's account-link hooks, held VERBATIM — no wrapping, no
110
+ * per-hook defaulting. The container only holds them: `beforeLink` is
111
+ * invoked by the hosted callback (PRD 07) and `afterLink`/`afterUnlink` by
112
+ * the link store (PRD 03), and by nothing else (DECISIONS §15.4). `{}` when
113
+ * none supplied.
114
+ */
115
+ accountLinkHooks: AccountLinkHooks;
116
+ /** Parsed + validated ACCOUNT_LINK_ALLOWED_ORIGINS. Empty array = none permitted. */
117
+ accountLinkAllowedOrigins: string[];
118
+ /**
119
+ * The container-held registry of referral definitions (`defineReferral`),
120
+ * keyed by id. There is NO env preset and NO single active referral: a
121
+ * referral exists because it was authored in code, and a product may run
122
+ * several at once. EMPTY is the normal state of a deploy that never asked
123
+ * for referrals, and every wired site (the arrive touch, the bind at
124
+ * identity adoption, the qualify evaluation in `ingestEvent`, the conversion
125
+ * tree walk) is INERT while it stays empty.
126
+ */
127
+ referrals: ReferralRegistry;
128
+ /**
129
+ * The container-held registry of enrichment providers, keyed by `meta.id` —
130
+ * the enrichment sibling of {@link smsProviders}. Empty when no enrichment
131
+ * provider is configured.
132
+ */
133
+ enrichmentProviders: EnrichmentProviderRegistry;
134
+ /**
135
+ * The single resolved active enrichment provider `refineContact()` looks up
136
+ * through. Undefined when no enrichment provider is configured — a deploy
137
+ * with no enrichment is a valid deploy (refinement stays inert).
138
+ */
139
+ enrichmentProvider?: EnrichmentProvider;
140
+ /**
141
+ * The container-held registry of CRM providers, keyed by `meta.id`. The
142
+ * `POST /v1/webhooks/crm/:providerId` route resolves the verifying provider
143
+ * out of this and the reconciliation poll walks it. Unlike email/SMS there
144
+ * is no single "active" CRM — many sync concurrently; `pushLead` callers
145
+ * name the provider. Empty when none configured.
146
+ */
147
+ crmProviders: CrmProviderRegistry;
148
+ /**
149
+ * The funnel registry (§5b.4): every `defineFunnel` plus the synthesized
150
+ * `"default"` carrying the crm sugar. Routes stage events by
151
+ * (provider, pipeline) claim; admin stats/Studio render per funnel.
152
+ */
153
+ funnels: FunnelRegistry;
154
+ /**
155
+ * The registry of code-defined feature flags (`defineFlag`), keyed by
156
+ * `meta.key`. Built from `opts.flags`; the boot reconciler + Studio read it.
157
+ * Empty when no flags are defined in code (DB/Studio flags still evaluate).
158
+ */
159
+ flagRegistry: FlagRegistry;
160
+ /**
161
+ * The container-held registry of analytics providers, keyed by `meta.id` —
162
+ * the analytics sibling of {@link emailProviders}. Built from env presets
163
+ * (`analyticsProvidersFromEnv`) merged consumer-last.
164
+ */
165
+ analyticsProviders: AnalyticsProviderRegistry;
166
+ /**
167
+ * The single resolved ACTIVE analytics provider (identity PULL + person
168
+ * writes + capture). Undefined when nothing is configured — every consumer
169
+ * treats that as a silent no-op.
170
+ */
171
+ analytics?: AnalyticsProvider;
172
+ /**
173
+ * Identity-attach helper that resolves/merges a contact AND propagates the
174
+ * analytics merge (§5.3) in one call, for identity-attach OUTSIDE the
175
+ * `/v1/events` ingest path. Discord `/link` (§7) wires its `resolveContact`
176
+ * callback to `client.identity.linkContact` so a successful contact-merge
177
+ * folds the discord-keyed person into the canonical one through the SAME
178
+ * engine emission ingest uses — never bespoke per-consumer plumbing.
179
+ */
180
+ identity: IdentityService;
181
+ /**
182
+ * The OPTIONAL base-currency FX lens (docs/groups.md §Base-currency lens):
183
+ * `getBaseCurrency()` resolves the effective reporting currency PER CALL
184
+ * (code pin → Studio operator setting → env `BASE_CURRENCY`; null = lens
185
+ * off) and `getRatesToBase()` is the fail-soft quote→base sheet the admin
186
+ * group revenue views convert through. The per-currency revenue LAW is
187
+ * untouched; this only serves an opt-in converted view on top of it.
188
+ */
189
+ fx: FxLens;
190
+ registry: JourneyRegistry;
191
+ /**
192
+ * Map of enabled journey id → its captured `run` source string. Populated by
193
+ * `buildJourneyRegistry` (skips journeys whose source failed to serialize).
194
+ * Consumed by the Studio journey-graph route, which parses the source lazily
195
+ * with acorn to derive a visual workflow. Empty when no journeys are wired.
196
+ */
197
+ journeySources: Map<string, string>;
198
+ /**
199
+ * The consumer's `Templates`/`Events` `as const` maps, normalized to always
200
+ * be present (`{ templates: {}, events: {} }` when unwired). Consumed by the
201
+ * Studio journey-graph route to resolve `Templates.X` / `Events.X` member
202
+ * expressions to their real values, for exact previews + stable node ids.
203
+ */
204
+ journeyConstants: {
205
+ templates: Record<string, string>;
206
+ events: Record<string, string>;
207
+ };
208
+ /**
209
+ * Map of enabled journey id → its `defineJourney` call-site `{ path, line }`.
210
+ * Populated by `buildJourneyRegistry`. Consumed by the Studio journey-graph
211
+ * route to build an "open in editor" deep link. Absent ids had no capturable
212
+ * call-site (e.g. bucket-generated reaction journeys).
213
+ */
214
+ journeySourceLocations: Map<string, JourneySourceLocation>;
215
+ /**
216
+ * The bucket registry (id map + event/property inverted indexes for candidate
217
+ * narrowing). Built and installed as the process singleton at client build;
218
+ * the real-time ingest path reads it via `getBucketRegistrySingleton()`.
219
+ * Empty when no buckets are wired.
220
+ */
221
+ bucketRegistry: BucketRegistry;
222
+ /**
223
+ * The email-list registry (D3): code-defined subscription categories layered
224
+ * on `email_preferences.categories`, with the LOCKED polarity rule that is the
225
+ * single source of truth for the mailer's suppression check AND the preference
226
+ * center. Built and installed as the process singleton at client build (read
227
+ * elsewhere via `getListRegistry()`). Empty when no lists are wired.
228
+ */
229
+ listRegistry: ListRegistry;
230
+ /**
231
+ * Code-defined one-shot campaigns (broadcasts), verbatim from
232
+ * `opts.campaigns`. The worker's boot reconciler turns them into scheduled
233
+ * `campaigns` rows; empty when none are wired.
234
+ */
235
+ campaigns: DefinedCampaign[];
236
+ /**
237
+ * The unified inbound CONNECTOR registry, keyed by `meta.id`. Holds every
238
+ * transport: webhook (the `:sourceId` dispatch + legacy webhookSources),
239
+ * gateway, and poll. Installed as the process singleton in BOTH the API and
240
+ * worker. The webhook route reads `getByTransport("webhook")`; the generic
241
+ * `/v1/connectors/:id/*` routes read `get(id).handlers`.
242
+ */
243
+ connectorRegistry: ConnectorRegistry;
244
+ /**
245
+ * The contact-source registry (Clay/Attio/generic-webhook origins), keyed by
246
+ * `meta.id`. `isProspectSource()` classifies a contact's `contacts.source` as
247
+ * a cold prospect origin; the cold posture + write-back travel with each
248
+ * entry. Installed as the process singleton in BOTH the API and worker.
249
+ */
250
+ contactSourceRegistry: ContactSourceRegistry;
251
+ /**
252
+ * The connector OUTBOUND ACTION registry, keyed by `${connectorId}:${name}`.
253
+ * Holds the journey-callable imperative actions (Discord post / broadcast /
254
+ * mention / DM) the standalone `sendConnectorAction()` resolves. Socket-free —
255
+ * independent of any inbound gateway runtime. Empty when none are wired.
256
+ */
257
+ connectorActionRegistry: ConnectorActionRegistry;
258
+ hatchet: HatchetClient;
259
+ /**
260
+ * The client repo's migration journal (`migrations/meta/_journal.json`),
261
+ * powering the `schema.client` block of `GET /v1/health`. Defaults to an
262
+ * empty journal — a client that injects none has a trivially-in-sync client
263
+ * track. The CLIENT track never gates boot (client-owned); engine does.
264
+ */
265
+ clientJournal: JournalShape;
266
+ /**
267
+ * Resolved scheduling + frequency-cap defaults. `timezone` always has a value
268
+ * ("UTC" when unset). Read by the journey context (tz/window) and the mailer
269
+ * (frequency cap).
270
+ */
271
+ defaults: HogsendDefaults;
272
+ /**
273
+ * Resolved browser-readable contact projection (`GET /v1/contacts/me`).
274
+ * `publicProperties` is an operator ALLOWLIST of exact `contacts.properties`
275
+ * keys; `exposeEmail` opts the address in. Both default to closed
276
+ * (`[]` / `false`), so a deploy that configures nothing exposes nothing.
277
+ */
278
+ contactsConfig: {
279
+ publicProperties: string[];
280
+ exposeEmail: boolean;
281
+ };
282
+ }
283
+ export interface HogsendClientOptions {
284
+ /** Journeys to register in the {@link JourneyRegistry}. Defaults to none. */
285
+ journeys?: DefinedJourney[];
286
+ /**
287
+ * The consumer's `Templates`/`Events` `as const` maps (each a
288
+ * `CONST_NAME -> "value"` record). Threaded into the Studio journey-graph
289
+ * route so `Templates.X` / `Events.X` member expressions in a journey's `run`
290
+ * source resolve to their real runtime values — yielding exact email-template
291
+ * previews and stable, join-safe `wait-event:${value}` / `digest:${value}`
292
+ * node ids (instead of positional `unstable` synthetics). Defaults to none.
293
+ */
294
+ journeyConstants?: {
295
+ templates?: Record<string, string>;
296
+ events?: Record<string, string>;
297
+ };
298
+ /** Buckets to register in the {@link BucketRegistry}. Defaults to none. */
299
+ buckets?: DefinedBucket[];
300
+ /**
301
+ * Email lists (D3) to register in the {@link ListRegistry}. Each is a
302
+ * `defineList()` subscription category (id + name + `defaultOptIn`). The
303
+ * registry drives the mailer's list-aware suppression check and the
304
+ * preference center. Defaults to none (empty registry ⇒ legacy opt-in).
305
+ */
306
+ lists?: DefinedList[];
307
+ /**
308
+ * Code-defined one-shot campaigns (broadcasts) — `defineCampaign()` files.
309
+ * Carried on the client so the worker's boot reconciler can schedule them
310
+ * (see `reconcileDefinedCampaigns`); the API process only stores them.
311
+ * Defaults to none.
312
+ */
313
+ campaigns?: DefinedCampaign[];
314
+ /**
315
+ * Email is a first-class channel. Its config is grouped here rather than
316
+ * spread across top-level args — the engine owns the cohesive email pipeline
317
+ * (templates → render → preference checks → tracking → `email_sends` write),
318
+ * and the {@link EmailProvider} is only the swappable wire under it.
319
+ *
320
+ * - `provider` — a single swappable email provider (Resend, Postmark, SES…),
321
+ * the back-compat one-provider seam. MERGED LAST (after env presets and
322
+ * `providers`), so it wins on id collision. Tracking/rendering/preferences
323
+ * come along for free regardless of which provider you supply.
324
+ * - `providers` — register MANY providers into the {@link EmailProviderRegistry}
325
+ * (e.g. Resend + Postmark) so the `POST /v1/webhooks/email/:providerId`
326
+ * route can verify each one's webhooks. Merged AFTER the env presets and
327
+ * BEFORE `provider`.
328
+ * - `defaultProvider` — the active provider id the mailer sends through.
329
+ * Resolves as `defaultProvider ?? EMAIL_PROVIDER ?? "resend"`. If it names a
330
+ * provider that isn't registered, the container throws at boot with the list
331
+ * of registered ids.
332
+ * - `templates` — the app's template registry (key → component + subject +
333
+ * category), threaded into the engine mailer and onward to
334
+ * `getTemplate(..., { registry })`. The engine bakes in no business
335
+ * templates; clients own their `.tsx` files + registry. Defaults to an
336
+ * empty registry (no sendable template keys).
337
+ *
338
+ * Other channels (SMS, push, Slack) are NOT configured here — they're plain
339
+ * functions a journey imports and calls.
340
+ */
341
+ email?: {
342
+ provider?: EmailProvider;
343
+ providers?: EmailProvider[];
344
+ defaultProvider?: string;
345
+ templates?: TemplateRegistry;
346
+ };
347
+ /**
348
+ * SMS is a first-class channel (the SMS sibling of {@link email}). Its config
349
+ * is grouped here; the engine owns the cohesive SMS pipeline (templates →
350
+ * render → preference/suppression checks → `sms_sends` write → STOP handling),
351
+ * and the {@link SmsProvider} (Twilio, …) is only the swappable wire.
352
+ *
353
+ * - `provider` — a single SMS provider. Merged LAST (after env presets and
354
+ * `providers`), so it wins on id collision.
355
+ * - `providers` — register MANY providers into the {@link SmsProviderRegistry}
356
+ * so `POST /v1/webhooks/sms/:providerId` can verify each one's webhooks.
357
+ * - `defaultProvider` — the active provider id the tracked sender delivers
358
+ * through. Resolves as `defaultProvider ?? SMS_PROVIDER ?? "twilio"`. If it
359
+ * names an unregistered provider, the container throws at boot.
360
+ * - `templates` — the app's SMS template registry (key → component +
361
+ * category), threaded into the tracked SMS sender.
362
+ * - `from` — the E.164 default sender (overrides env `SMS_FROM`).
363
+ * - `stopFooter` — the compliance footer appended to non-transactional
364
+ * bodies; `false` disables it, a string overrides the default text.
365
+ * - `optOutReplies` — send STOP/START/HELP confirmation replies (default off;
366
+ * the carrier already replies and a post-STOP send is blocked).
367
+ * - `linkTracking` — rewrite bare URLs in rendered bodies to first-party
368
+ * short tracked links (`/s/:code`). Default true (overrides env
369
+ * `SMS_LINK_TRACKING`).
370
+ * - `linkHost` — the full origin short links are minted under (overrides
371
+ * env `SMS_LINK_HOST`; falls back to `API_PUBLIC_URL`).
372
+ *
373
+ * Omitting `sms` entirely (or configuring no provider) installs an inert stub
374
+ * SMS service — an existing deploy without Twilio creds boots unchanged.
375
+ */
376
+ sms?: {
377
+ provider?: SmsProvider;
378
+ providers?: SmsProvider[];
379
+ defaultProvider?: string;
380
+ templates?: SmsTemplateRegistry;
381
+ from?: string;
382
+ stopFooter?: string | false;
383
+ optOutReplies?: boolean;
384
+ linkTracking?: boolean;
385
+ linkHost?: string;
386
+ };
387
+ /**
388
+ * What `GET /v1/contacts/me` may hand back to a browser.
389
+ *
390
+ * - `publicProperties` — EXACT `contacts.properties` keys the browser may
391
+ * read. No wildcard, no prefix match. Anything not listed is omitted.
392
+ * - `exposeEmail` — include the contact's email address in the response.
393
+ *
394
+ * Defaults are closed (`[]` / `false`): with no `contacts` option the route
395
+ * answers `{ identified: false, traits: {} }` for everyone.
396
+ */
397
+ contacts?: {
398
+ publicProperties?: string[];
399
+ exposeEmail?: boolean;
400
+ };
401
+ /**
402
+ * Account linking (Steam, Twitch, or your own `defineAccountLink` provider).
403
+ * The engine owns the stateful flow (state tokens, the link store,
404
+ * versioning, hooks, outbound events); a provider is only the two proof
405
+ * wires (authorize URL + callback → proven identity).
406
+ */
407
+ accountLinks?: {
408
+ /** Register MANY providers. Merged AFTER env presets, so a same-id provider wins. */
409
+ providers?: AccountLinkProvider[];
410
+ /** In-process hooks. beforeLink is fail-closed; afterLink/afterUnlink fail-open (DECISIONS §9). */
411
+ hooks?: AccountLinkHooks;
412
+ /**
413
+ * Extra allowed origins, concatenated AFTER ACCOUNT_LINK_ALLOWED_ORIGINS and
414
+ * parsed by the same rule. A malformed entry THROWS at boot. This is the ONE
415
+ * allowlist: PRD 07 checks `returnTo` against it, PRD 10 uses it as the
416
+ * `postMessage` targetOrigin set, and PRD 10 validates its `resultRedirect`
417
+ * against it. PRD 10 CONSUMES this field and does not redeclare it.
418
+ */
419
+ allowedOrigins?: string[];
420
+ };
421
+ /**
422
+ * Referral programs, authored with `defineReferral` (PRD 05). Pass the SAME
423
+ * array in BOTH `index.ts` and `worker.ts`: the HTTP side runs the touch and
424
+ * the bind, the worker side runs `getReferralLink` inside journeys.
425
+ * Duplicate ids inside one array warn and last-writer-wins, like every other
426
+ * registry merge. Omitted ⇒ referrals are entirely inert.
427
+ */
428
+ referrals?: DefinedReferral[];
429
+ /**
430
+ * Enrichment (Refinement) is a first-class provider kind mirroring
431
+ * {@link email}/{@link sms}. The engine owns the cohesive refinement
432
+ * pipeline (ledger → TTL/negative cache → budget cap → ingest write), and
433
+ * the {@link EnrichmentProvider} (Apollo, Clay, …) is only the swappable
434
+ * vendor wire under it.
435
+ *
436
+ * - `provider` — a single enrichment provider. Merged LAST (after env
437
+ * presets and `providers`), so it wins on id collision.
438
+ * - `providers` — register MANY providers into the
439
+ * {@link EnrichmentProviderRegistry}.
440
+ * - `defaultProvider` — the active provider id `refineContact()` looks up
441
+ * through. Resolves as `defaultProvider ?? ENRICHMENT_PROVIDER ?? "apollo"`.
442
+ * If it names an unregistered provider, the container throws at boot.
443
+ * When nothing is explicitly requested and exactly ONE provider is
444
+ * registered, that one is used (the SMS DX rule).
445
+ *
446
+ * Omitting `enrichment` entirely (or configuring no provider) leaves
447
+ * refinement inert — a deploy with no enrichment is a valid deploy.
448
+ */
449
+ enrichment?: {
450
+ provider?: EnrichmentProvider;
451
+ providers?: EnrichmentProvider[];
452
+ defaultProvider?: string;
453
+ };
454
+ /**
455
+ * The OPTIONAL base-currency FX lens (docs/groups.md §Base-currency lens).
456
+ * OFF unless a base currency resolves — with no `fx.baseCurrency` pin, no
457
+ * Studio operator setting, and no env `BASE_CURRENCY`, nothing anywhere
458
+ * converts.
459
+ *
460
+ * - `provider` — a BYO {@link FxRateProvider} rate source. WINS over the env
461
+ * presets entirely (the same consumer-over-env spirit as `analytics`,
462
+ * minus the registry — exactly one FX source resolves at boot; multiple
463
+ * simultaneous rate sources have no use case). Without it, env resolves:
464
+ * `FX_PROVIDER=frankfurter` → the ECB preset, else a set `FX_RATES` → the
465
+ * sovereign static preset, else no source (lens stays off).
466
+ * - `baseCurrency` — the code-level PIN: wins over BOTH the Studio operator
467
+ * setting and env `BASE_CURRENCY` (the `defaults.timezone` pattern; also
468
+ * the test seam, since `env` is a process singleton). Without it the base
469
+ * resolves per call: Studio setting (explicit null there = lens OFF,
470
+ * beating env) → env `BASE_CURRENCY`.
471
+ */
472
+ fx?: {
473
+ provider?: FxRateProvider;
474
+ baseCurrency?: string;
475
+ };
476
+ /**
477
+ * Code-first conversion-point definitions (plan §5.1) — `defineConversion`
478
+ * results. Evaluated inside `ingestEvent` after every fresh event insert;
479
+ * fired instances land in the `conversions` table. Every journey
480
+ * `meta.goal` is boot-validated against this set (plus the seeded
481
+ * "revenue" definition when active) — an unknown goal throws here.
482
+ */
483
+ conversions?: DefinedConversion[];
484
+ /**
485
+ * Code-first feature-flag definitions (`defineFlag()` results). Reconciled
486
+ * into `flags` rows at boot (create-if-absent, disabled + rollout 0; contract
487
+ * drift synced on code-origin rows; operator state never clobbered — see
488
+ * `reconcileDefinedFlags`). Only the CONTRACT is expressed here; targeting /
489
+ * rollout / enabling are DB/operator-owned. Wire in BOTH `index.ts` and
490
+ * `worker.ts` so both processes reconcile. Defaults to none.
491
+ */
492
+ flags?: DefinedFlag[];
493
+ /**
494
+ * Conversion DESTINATIONS (plan §5.2) — ad-platform feedback providers
495
+ * (`defineConversionDestination`; Meta CAPI is the reference). Referenced
496
+ * by id from `defineConversion({ destinations })`.
497
+ */
498
+ conversionDestinations?: ConversionDestination[];
499
+ /**
500
+ * CRM sync providers — the pluggable
501
+ * layer that pushes leads INTO client CRMs and lands pipeline stage changes
502
+ * + deal values back on the event spine as `funnel.stage_changed`. Register
503
+ * one (`provider`) or many (`providers`); each is webhook-served at
504
+ * `POST /v1/webhooks/crm/:providerId` and polled for reconciliation where
505
+ * it implements `poll`. No "active" selection — many CRMs sync at once.
506
+ */
507
+ crm?: {
508
+ provider?: CrmProvider;
509
+ providers?: CrmProvider[];
510
+ /**
511
+ * Per-provider stage maps: native `(pipelineId|'*') → stageId → canonical
512
+ * stage` — the one-CRM-no-funnels 3-liner. Desugars into `crmPipeline`
513
+ * bindings on the synthesized `"default"` funnel. Unmapped stages record
514
+ * native ids and warn (the provider's won/lost status hint still resolves
515
+ * sold/lost). Every mapped value must be a ladder stage or `"lost"` —
516
+ * validated at boot.
517
+ */
518
+ stageMaps?: Record<string, CrmStageMap>;
519
+ /**
520
+ * YOUR canonical funnel's stages, in rank order — replaces the built-in
521
+ * `lead → contacted → survey_booked → quoted → sold`. Same entries as
522
+ * `defineFunnel`: plain strings, or objects carrying `milestone` (and
523
+ * `on` event triggers). All-string arrays get the legacy money defaults
524
+ * (soldStage = last stage, quotedStage = a stage literally named
525
+ * "quoted"); any object entry makes milestones explicit-only. `"lost"`
526
+ * stays the implicit terminal. Zero migration: only new stage events
527
+ * re-rank.
528
+ */
529
+ stages?: FunnelStageEntry[];
530
+ };
531
+ /**
532
+ * Funnels as code-first primitives (§5b.4) — `defineFunnel` results. Each
533
+ * claims CRM traffic via its `bindings` (provider, pipeline) pairs;
534
+ * overlapping claims throw at boot. The `crm.{stages,stageMaps}` group
535
+ * above is sugar for a single `"default"` funnel and composes with these.
536
+ */
537
+ funnels?: DefinedFunnel[];
538
+ /**
539
+ * The analytics provider(s) — provider-neutral since the
540
+ * `AnalyticsProvider` contract (the analytics sibling of `EmailProvider`;
541
+ * PostHog is the reference implementation, not the architecture). Its role
542
+ * is deliberately NARROW — it is NOT the outbound-catalog firing path (the
543
+ * email/contact/journey/bucket lifecycle fans out durably via DESTINATIONS
544
+ * on the webhook spine). The ACTIVE provider serves:
545
+ *
546
+ * 1. The identity PULL — `getPersonProperties` for per-user timezone
547
+ * resolution at journey enrollment (`define-journey` / `lib/timezone.ts`).
548
+ * On PostHog this needs `POSTHOG_PERSONAL_API_KEY` (the phc_ project key
549
+ * is write-only by design); reads soft-fail to contact-property
550
+ * fallbacks without it.
551
+ * 2. Person WRITES — `setPersonProperties` (the opt-in `bucket.syncToPostHog`
552
+ * mirror, and trait propagation). Rides the capture pipeline; no extra
553
+ * credential.
554
+ *
555
+ * Accepted shapes (mirrors `email`):
556
+ * - a group: `{ provider?, providers?, defaultProvider? }` — register one or
557
+ * many `AnalyticsProvider`s; env presets (`analyticsProvidersFromEnv` —
558
+ * PostHog when `POSTHOG_API_KEY` is set) merge consumer-LAST;
559
+ * `defaultProvider` / env `ANALYTICS_PROVIDER` picks the active id
560
+ * (default `"posthog"`).
561
+ * - a bare `AnalyticsProvider` — registered and made active.
562
+ * - @deprecated a legacy `PostHogService` — wrapped via
563
+ * `wrapLegacyAnalyticsService` and made active.
564
+ *
565
+ * Lives at the top level (not under `email`) because the engine itself uses
566
+ * it for the PULL.
567
+ */
568
+ analytics?: PostHogService | AnalyticsProvider | {
569
+ provider?: AnalyticsProvider;
570
+ providers?: AnalyticsProvider[];
571
+ defaultProvider?: string;
572
+ eventMirror?: AnalyticsEventMirrorConfig;
573
+ };
574
+ /**
575
+ * Code-defined outbound DESTINATIONS (Phase 3). Each is a
576
+ * `defineDestination()` delivery-time transform keyed by its `meta.id`, which
577
+ * the delivery task resolves by `webhook_endpoints.kind`. They are MERGED with
578
+ * the env-enabled presets ({@link destinationsFromEnv}): a consumer
579
+ * destination WINS over a preset of the same id (so you can override the
580
+ * shipped `posthog`/`segment`/`slack` shapes). The `webhook` + `posthog`
581
+ * presets are always present, so the no-regression signed-POST path can never
582
+ * be turned off here. Installed as the process registry the self-booting
583
+ * delivery task reads — and `createHogsendClient` runs in BOTH the API and
584
+ * worker, so it is wired in both. Defaults to none (presets only).
585
+ */
586
+ destinations?: DefinedDestination[];
587
+ /**
588
+ * Code-defined inbound CONNECTORS (the unified umbrella). Each is a
589
+ * `defineConnector()` of any transport. MERGED with `connectorsFromEnv` env
590
+ * presets (consumer LAST ⇒ wins on id collision, mirroring destinations). The
591
+ * legacy `webhookSources` array is folded in here as `transport:"webhook"`
592
+ * connectors. Defaults to none.
593
+ */
594
+ connectors?: DefinedConnector[];
595
+ /**
596
+ * Connector OUTBOUND ACTIONS (e.g. `discordActions` from `@hogsend/plugin-discord`)
597
+ * — journey-callable imperative actions registered into the
598
+ * {@link ConnectorActionRegistry} and invoked via the standalone
599
+ * `sendConnectorAction()`. Socket-free; independent of any inbound gateway
600
+ * runtime. Defaults to none.
601
+ */
602
+ connectorActions?: DefinedConnectorAction[];
603
+ /**
604
+ * @deprecated pass `connectors` instead. Back-compat array of
605
+ * `defineWebhookSource()` sources; converted to webhook-transport connectors.
606
+ * Still also accepted by `createApp({ webhookSources })`.
607
+ */
608
+ webhookSources?: DefinedWebhookSource[];
609
+ /**
610
+ * Code-defined CONTACT SOURCES (`defineContactSource()`) — Clay/Attio/generic
611
+ * webhook origins of cold "prospects". Each is lifted onto the webhook-source
612
+ * umbrella (served at `POST /v1/webhooks/:sourceId`, provenance-stamped from
613
+ * `meta.id`) AND registered in the {@link ContactSourceRegistry} so the engine
614
+ * can classify sourced contacts + resolve their cold posture / write-back.
615
+ * Wire in BOTH `index.ts` and `worker.ts`. Defaults to none.
616
+ */
617
+ contactSources?: DefinedContactSource[];
618
+ /**
619
+ * Auto-register the shipped webhook-source PRESETS (Clerk, Supabase, Stripe,
620
+ * Segment) for every preset whose env secret is configured (gated further by
621
+ * `ENABLED_WEBHOOK_PRESETS`). Set `false` to suppress env presets entirely.
622
+ * Default `true`. (Mirrors — and is also honored from — the deprecated
623
+ * `createApp({ enablePresets })` flag, which strips preset ids back out of the
624
+ * registry when set there.)
625
+ */
626
+ enablePresets?: boolean;
627
+ /**
628
+ * Comma-separated ids (or `*`) controlling which journeys load. Defaults to
629
+ * `env.ENABLED_JOURNEYS`.
630
+ */
631
+ enabledJourneys?: string;
632
+ /**
633
+ * Comma-separated ids (or `*`) controlling which buckets load. Defaults to
634
+ * `env.ENABLED_BUCKETS`.
635
+ */
636
+ enabledBuckets?: string;
637
+ /**
638
+ * Comma-separated ids (or `*`) controlling which lists load. Defaults to
639
+ * `env.ENABLED_LISTS`.
640
+ */
641
+ enabledLists?: string;
642
+ /**
643
+ * The client repo's migration journal for the `schema.client` health block.
644
+ * Defaults to `{ entries: [] }` (empty client track ⇒ trivially in sync).
645
+ */
646
+ clientJournal?: JournalShape;
647
+ /**
648
+ * Declarative scheduling + delivery defaults.
649
+ *
650
+ * - `timezone` — global fallback IANA tz (e.g. "UTC"), the terminal step of
651
+ * the per-user tz resolution chain.
652
+ * - `sendWindow` — quiet-hours window ("HH:mm".."HH:mm") auto-applied by
653
+ * `ctx.when` so scheduled instants land inside the window. Enforced ONLY at
654
+ * the scheduling layer; immediate transactional sends bypass it.
655
+ * - `frequencyCap` — per-recipient send cap enforced in the mailer choke
656
+ * point. Opt-in; "transactional" is exempt by default.
657
+ */
658
+ defaults?: {
659
+ timezone?: TimeZone;
660
+ sendWindow?: SendWindow;
661
+ frequencyCap?: FrequencyCapConfig;
662
+ };
663
+ /**
664
+ * Genuinely advanced / test-only seams. You probably don't need these —
665
+ * prefer the first-class `email` / `analytics` args above.
666
+ * `mailer` replaces the engine-built {@link EmailService} wholesale (used by
667
+ * tests to inject a mock); `auth`, `hatchet`, and `db` swap their respective
668
+ * infrastructure singletons.
669
+ */
670
+ overrides?: {
671
+ mailer?: EmailService;
672
+ auth?: Auth;
673
+ hatchet?: HatchetClient;
674
+ db?: Database;
675
+ };
676
+ }
677
+ export declare function createHogsendClient(opts?: HogsendClientOptions): HogsendClient;
678
+ //# sourceMappingURL=container.d.ts.map