@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.
- package/README.md +3 -2
- package/dist/account-links/__fixtures__/fake-fetch.d.ts +38 -0
- package/dist/account-links/__fixtures__/fake-fetch.d.ts.map +1 -0
- package/dist/account-links/battlenet.d.ts +36 -0
- package/dist/account-links/battlenet.d.ts.map +1 -0
- package/dist/account-links/epic.d.ts +36 -0
- package/dist/account-links/epic.d.ts.map +1 -0
- package/dist/account-links/index.d.ts +7 -0
- package/dist/account-links/index.d.ts.map +1 -0
- package/dist/account-links/riot.d.ts +35 -0
- package/dist/account-links/riot.d.ts.map +1 -0
- package/dist/account-links/steam.d.ts +35 -0
- package/dist/account-links/steam.d.ts.map +1 -0
- package/dist/account-links/twitch.d.ts +38 -0
- package/dist/account-links/twitch.d.ts.map +1 -0
- package/dist/account-links/xbox.d.ts +39 -0
- package/dist/account-links/xbox.d.ts.map +1 -0
- package/dist/app.d.ts +50 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/buckets/bucket-access.d.ts +60 -0
- package/dist/buckets/bucket-access.d.ts.map +1 -0
- package/dist/buckets/bucket-reactions.d.ts +100 -0
- package/dist/buckets/bucket-reactions.d.ts.map +1 -0
- package/dist/buckets/check-membership.d.ts +105 -0
- package/dist/buckets/check-membership.d.ts.map +1 -0
- package/dist/buckets/define-bucket.d.ts +53 -0
- package/dist/buckets/define-bucket.d.ts.map +1 -0
- package/dist/buckets/membership-epoch.d.ts +74 -0
- package/dist/buckets/membership-epoch.d.ts.map +1 -0
- package/dist/buckets/registry-singleton.d.ts +6 -0
- package/dist/buckets/registry-singleton.d.ts.map +1 -0
- package/dist/buckets/registry.d.ts +59 -0
- package/dist/buckets/registry.d.ts.map +1 -0
- package/dist/campaigns/cohort-sql.d.ts +54 -0
- package/dist/campaigns/cohort-sql.d.ts.map +1 -0
- package/dist/campaigns/define-campaign.d.ts +105 -0
- package/dist/campaigns/define-campaign.d.ts.map +1 -0
- package/dist/campaigns/reconcile.d.ts +13 -0
- package/dist/campaigns/reconcile.d.ts.map +1 -0
- package/dist/campaigns/steps.d.ts +29 -0
- package/dist/campaigns/steps.d.ts.map +1 -0
- package/dist/cold-connect/index.d.ts +98 -0
- package/dist/cold-connect/index.d.ts.map +1 -0
- package/dist/cold-connect/page.d.ts +69 -0
- package/dist/cold-connect/page.d.ts.map +1 -0
- package/dist/cold-connect/throttle.d.ts +39 -0
- package/dist/cold-connect/throttle.d.ts.map +1 -0
- package/dist/cold-connect/token.d.ts +57 -0
- package/dist/cold-connect/token.d.ts.map +1 -0
- package/dist/connectors/action-registry-singleton.d.ts +21 -0
- package/dist/connectors/action-registry-singleton.d.ts.map +1 -0
- package/dist/connectors/define-action.d.ts +117 -0
- package/dist/connectors/define-action.d.ts.map +1 -0
- package/dist/connectors/define-connector.d.ts +172 -0
- package/dist/connectors/define-connector.d.ts.map +1 -0
- package/dist/connectors/presets/index.d.ts +17 -0
- package/dist/connectors/presets/index.d.ts.map +1 -0
- package/dist/connectors/registry-singleton.d.ts +34 -0
- package/dist/connectors/registry-singleton.d.ts.map +1 -0
- package/dist/connectors/runtime.d.ts +68 -0
- package/dist/connectors/runtime.d.ts.map +1 -0
- package/dist/container.d.ts +678 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/destinations/define-destination.d.ts +96 -0
- package/dist/destinations/define-destination.d.ts.map +1 -0
- package/dist/destinations/presets/index.d.ts +42 -0
- package/dist/destinations/presets/index.d.ts.map +1 -0
- package/dist/destinations/presets/posthog.d.ts +12 -0
- package/dist/destinations/presets/posthog.d.ts.map +1 -0
- package/dist/destinations/presets/segment.d.ts +15 -0
- package/dist/destinations/presets/segment.d.ts.map +1 -0
- package/dist/destinations/presets/slack.d.ts +10 -0
- package/dist/destinations/presets/slack.d.ts.map +1 -0
- package/dist/destinations/presets/webhook.d.ts +14 -0
- package/dist/destinations/presets/webhook.d.ts.map +1 -0
- package/dist/destinations/registry-singleton.d.ts +44 -0
- package/dist/destinations/registry-singleton.d.ts.map +1 -0
- package/dist/env.d.ts +119 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/flags/reconcile.d.ts +36 -0
- package/dist/flags/reconcile.d.ts.map +1 -0
- package/dist/index.d.ts +210 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/journeys/authoring.d.ts +15 -0
- package/dist/journeys/authoring.d.ts.map +1 -0
- package/dist/journeys/client-defaults-singleton.d.ts +16 -0
- package/dist/journeys/client-defaults-singleton.d.ts.map +1 -0
- package/dist/journeys/constants.d.ts +32 -0
- package/dist/journeys/constants.d.ts.map +1 -0
- package/dist/journeys/define-journey.d.ts +33 -0
- package/dist/journeys/define-journey.d.ts.map +1 -0
- package/dist/journeys/durable-law-harness.d.ts +74 -0
- package/dist/journeys/durable-law-harness.d.ts.map +1 -0
- package/dist/journeys/errors.d.ts +13 -0
- package/dist/journeys/errors.d.ts.map +1 -0
- package/dist/journeys/execute-journey-run.d.ts +160 -0
- package/dist/journeys/execute-journey-run.d.ts.map +1 -0
- package/dist/journeys/graph/build-graph.d.ts +24 -0
- package/dist/journeys/graph/build-graph.d.ts.map +1 -0
- package/dist/journeys/group-scope.d.ts +56 -0
- package/dist/journeys/group-scope.d.ts.map +1 -0
- package/dist/journeys/journey-boundary.d.ts +264 -0
- package/dist/journeys/journey-boundary.d.ts.map +1 -0
- package/dist/journeys/journey-context.d.ts +60 -0
- package/dist/journeys/journey-context.d.ts.map +1 -0
- package/dist/journeys/journey-log.d.ts +42 -0
- package/dist/journeys/journey-log.d.ts.map +1 -0
- package/dist/journeys/journey-source-locations-singleton.d.ts +6 -0
- package/dist/journeys/journey-source-locations-singleton.d.ts.map +1 -0
- package/dist/journeys/journey-sources-singleton.d.ts +5 -0
- package/dist/journeys/journey-sources-singleton.d.ts.map +1 -0
- package/dist/journeys/journey-task-factory.d.ts +11 -0
- package/dist/journeys/journey-task-factory.d.ts.map +1 -0
- package/dist/journeys/journey-task-runtime.d.ts +2 -0
- package/dist/journeys/journey-task-runtime.d.ts.map +1 -0
- package/dist/journeys/journey-version.d.ts +71 -0
- package/dist/journeys/journey-version.d.ts.map +1 -0
- package/dist/journeys/record-once.d.ts +56 -0
- package/dist/journeys/record-once.d.ts.map +1 -0
- package/dist/journeys/registry-singleton.d.ts +6 -0
- package/dist/journeys/registry-singleton.d.ts.map +1 -0
- package/dist/journeys/registry.d.ts +59 -0
- package/dist/journeys/registry.d.ts.map +1 -0
- package/dist/journeys/with-durable-gate.d.ts +97 -0
- package/dist/journeys/with-durable-gate.d.ts.map +1 -0
- package/dist/lib/account-link-emit.d.ts +69 -0
- package/dist/lib/account-link-emit.d.ts.map +1 -0
- package/dist/lib/account-link-events.d.ts +128 -0
- package/dist/lib/account-link-events.d.ts.map +1 -0
- package/dist/lib/account-link-hooks.d.ts +32 -0
- package/dist/lib/account-link-hooks.d.ts.map +1 -0
- package/dist/lib/account-link-ingest.d.ts +78 -0
- package/dist/lib/account-link-ingest.d.ts.map +1 -0
- package/dist/lib/account-link-nonce.d.ts +29 -0
- package/dist/lib/account-link-nonce.d.ts.map +1 -0
- package/dist/lib/account-link-origins.d.ts +37 -0
- package/dist/lib/account-link-origins.d.ts.map +1 -0
- package/dist/lib/account-link-pkce.d.ts +48 -0
- package/dist/lib/account-link-pkce.d.ts.map +1 -0
- package/dist/lib/account-link-provider-registry.d.ts +35 -0
- package/dist/lib/account-link-provider-registry.d.ts.map +1 -0
- package/dist/lib/account-link-throttle.d.ts +76 -0
- package/dist/lib/account-link-throttle.d.ts.map +1 -0
- package/dist/lib/account-link-url.d.ts +41 -0
- package/dist/lib/account-link-url.d.ts.map +1 -0
- package/dist/lib/account-links-from-env.d.ts +62 -0
- package/dist/lib/account-links-from-env.d.ts.map +1 -0
- package/dist/lib/account-links.d.ts +353 -0
- package/dist/lib/account-links.d.ts.map +1 -0
- package/dist/lib/agent/config.d.ts +14 -0
- package/dist/lib/agent/config.d.ts.map +1 -0
- package/dist/lib/agent/proposals.d.ts +52 -0
- package/dist/lib/agent/proposals.d.ts.map +1 -0
- package/dist/lib/agent/provider.d.ts +9 -0
- package/dist/lib/agent/provider.d.ts.map +1 -0
- package/dist/lib/agent/risk.d.ts +24 -0
- package/dist/lib/agent/risk.d.ts.map +1 -0
- package/dist/lib/agent/system-prompt.d.ts +8 -0
- package/dist/lib/agent/system-prompt.d.ts.map +1 -0
- package/dist/lib/agent/tools.d.ts +258 -0
- package/dist/lib/agent/tools.d.ts.map +1 -0
- package/dist/lib/alerting.d.ts +7 -0
- package/dist/lib/alerting.d.ts.map +1 -0
- package/dist/lib/analytics-adapter.d.ts +24 -0
- package/dist/lib/analytics-adapter.d.ts.map +1 -0
- package/dist/lib/analytics-identity.d.ts +60 -0
- package/dist/lib/analytics-identity.d.ts.map +1 -0
- package/dist/lib/analytics-provider-registry.d.ts +20 -0
- package/dist/lib/analytics-provider-registry.d.ts.map +1 -0
- package/dist/lib/analytics-providers-from-env.d.ts +41 -0
- package/dist/lib/analytics-providers-from-env.d.ts.map +1 -0
- package/dist/lib/analytics-singleton.d.ts +10 -0
- package/dist/lib/analytics-singleton.d.ts.map +1 -0
- package/dist/lib/api-key-hash.d.ts +9 -0
- package/dist/lib/api-key-hash.d.ts.map +1 -0
- package/dist/lib/app-secret.d.ts +29 -0
- package/dist/lib/app-secret.d.ts.map +1 -0
- package/dist/lib/attachments.d.ts +53 -0
- package/dist/lib/attachments.d.ts.map +1 -0
- package/dist/lib/attribution-backfill.d.ts +48 -0
- package/dist/lib/attribution-backfill.d.ts.map +1 -0
- package/dist/lib/attribution.d.ts +44 -0
- package/dist/lib/attribution.d.ts.map +1 -0
- package/dist/lib/auth.d.ts +136 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/backfill.d.ts +41 -0
- package/dist/lib/backfill.d.ts.map +1 -0
- package/dist/lib/banner.d.ts +52 -0
- package/dist/lib/banner.d.ts.map +1 -0
- package/dist/lib/blueprint-lock.d.ts +19 -0
- package/dist/lib/blueprint-lock.d.ts.map +1 -0
- package/dist/lib/blueprints.d.ts +573 -0
- package/dist/lib/blueprints.d.ts.map +1 -0
- package/dist/lib/boot-api-key.d.ts +38 -0
- package/dist/lib/boot-api-key.d.ts.map +1 -0
- package/dist/lib/boot.d.ts +23 -0
- package/dist/lib/boot.d.ts.map +1 -0
- package/dist/lib/bootstrap-admin.d.ts +33 -0
- package/dist/lib/bootstrap-admin.d.ts.map +1 -0
- package/dist/lib/bot-prefetch.d.ts +21 -0
- package/dist/lib/bot-prefetch.d.ts.map +1 -0
- package/dist/lib/bucket-emit.d.ts +75 -0
- package/dist/lib/bucket-emit.d.ts.map +1 -0
- package/dist/lib/bucket-posthog-sync.d.ts +29 -0
- package/dist/lib/bucket-posthog-sync.d.ts.map +1 -0
- package/dist/lib/campaign-send-key.d.ts +31 -0
- package/dist/lib/campaign-send-key.d.ts.map +1 -0
- package/dist/lib/connector-actions.d.ts +83 -0
- package/dist/lib/connector-actions.d.ts.map +1 -0
- package/dist/lib/connector-heartbeat.d.ts +35 -0
- package/dist/lib/connector-heartbeat.d.ts.map +1 -0
- package/dist/lib/connector-link-codes.d.ts +105 -0
- package/dist/lib/connector-link-codes.d.ts.map +1 -0
- package/dist/lib/connector-state.d.ts +97 -0
- package/dist/lib/connector-state.d.ts.map +1 -0
- package/dist/lib/contacts.d.ts +622 -0
- package/dist/lib/contacts.d.ts.map +1 -0
- package/dist/lib/conversion-dispatch.d.ts +98 -0
- package/dist/lib/conversion-dispatch.d.ts.map +1 -0
- package/dist/lib/conversions.d.ts +75 -0
- package/dist/lib/conversions.d.ts.map +1 -0
- package/dist/lib/create-admin.d.ts +54 -0
- package/dist/lib/create-admin.d.ts.map +1 -0
- package/dist/lib/crm-deals.d.ts +66 -0
- package/dist/lib/crm-deals.d.ts.map +1 -0
- package/dist/lib/crm-ingest.d.ts +38 -0
- package/dist/lib/crm-ingest.d.ts.map +1 -0
- package/dist/lib/crm-provider-registry.d.ts +20 -0
- package/dist/lib/crm-provider-registry.d.ts.map +1 -0
- package/dist/lib/crm-registry-singleton.d.ts +18 -0
- package/dist/lib/crm-registry-singleton.d.ts.map +1 -0
- package/dist/lib/db.d.ts +3 -0
- package/dist/lib/db.d.ts.map +1 -0
- package/dist/lib/deal-money-events.d.ts +35 -0
- package/dist/lib/deal-money-events.d.ts.map +1 -0
- package/dist/lib/discord-gateway-heartbeat.d.ts +47 -0
- package/dist/lib/discord-gateway-heartbeat.d.ts.map +1 -0
- package/dist/lib/domain-status.d.ts +87 -0
- package/dist/lib/domain-status.d.ts.map +1 -0
- package/dist/lib/email-provider-registry.d.ts +30 -0
- package/dist/lib/email-provider-registry.d.ts.map +1 -0
- package/dist/lib/email-providers-from-env.d.ts +12 -0
- package/dist/lib/email-providers-from-env.d.ts.map +1 -0
- package/dist/lib/email-service-types.d.ts +189 -0
- package/dist/lib/email-service-types.d.ts.map +1 -0
- package/dist/lib/email-stats.d.ts +12 -0
- package/dist/lib/email-stats.d.ts.map +1 -0
- package/dist/lib/email.d.ts +73 -0
- package/dist/lib/email.d.ts.map +1 -0
- package/dist/lib/enrichment-ledger.d.ts +101 -0
- package/dist/lib/enrichment-ledger.d.ts.map +1 -0
- package/dist/lib/enrichment-provider-registry.d.ts +20 -0
- package/dist/lib/enrichment-provider-registry.d.ts.map +1 -0
- package/dist/lib/enrichment-providers-from-env.d.ts +13 -0
- package/dist/lib/enrichment-providers-from-env.d.ts.map +1 -0
- package/dist/lib/enrichment-registry-singleton.d.ts +9 -0
- package/dist/lib/enrichment-registry-singleton.d.ts.map +1 -0
- package/dist/lib/enrollment-guards.d.ts +28 -0
- package/dist/lib/enrollment-guards.d.ts.map +1 -0
- package/dist/lib/enrollment-policy.d.ts +25 -0
- package/dist/lib/enrollment-policy.d.ts.map +1 -0
- package/dist/lib/event-names.d.ts +27 -0
- package/dist/lib/event-names.d.ts.map +1 -0
- package/dist/lib/feed.d.ts +64 -0
- package/dist/lib/feed.d.ts.map +1 -0
- package/dist/lib/flags-registry.d.ts +23 -0
- package/dist/lib/flags-registry.d.ts.map +1 -0
- package/dist/lib/flags.d.ts +143 -0
- package/dist/lib/flags.d.ts.map +1 -0
- package/dist/lib/frequency-cap.d.ts +38 -0
- package/dist/lib/frequency-cap.d.ts.map +1 -0
- package/dist/lib/from-address.d.ts +15 -0
- package/dist/lib/from-address.d.ts.map +1 -0
- package/dist/lib/funnel-progress.d.ts +37 -0
- package/dist/lib/funnel-progress.d.ts.map +1 -0
- package/dist/lib/funnel-registry.d.ts +44 -0
- package/dist/lib/funnel-registry.d.ts.map +1 -0
- package/dist/lib/funnel-transitions.d.ts +63 -0
- package/dist/lib/funnel-transitions.d.ts.map +1 -0
- package/dist/lib/fx.d.ts +118 -0
- package/dist/lib/fx.d.ts.map +1 -0
- package/dist/lib/global-control-readout.d.ts +72 -0
- package/dist/lib/global-control-readout.d.ts.map +1 -0
- package/dist/lib/groups.d.ts +138 -0
- package/dist/lib/groups.d.ts.map +1 -0
- package/dist/lib/hatchet-duration.d.ts +14 -0
- package/dist/lib/hatchet-duration.d.ts.map +1 -0
- package/dist/lib/hatchet.d.ts +3 -0
- package/dist/lib/hatchet.d.ts.map +1 -0
- package/dist/lib/headers.d.ts +8 -0
- package/dist/lib/headers.d.ts.map +1 -0
- package/dist/lib/holdout.d.ts +36 -0
- package/dist/lib/holdout.d.ts.map +1 -0
- package/dist/lib/html.d.ts +5 -0
- package/dist/lib/html.d.ts.map +1 -0
- package/dist/lib/identity-service.d.ts +60 -0
- package/dist/lib/identity-service.d.ts.map +1 -0
- package/dist/lib/identity-token.d.ts +81 -0
- package/dist/lib/identity-token.d.ts.map +1 -0
- package/dist/lib/ingestion.d.ts +218 -0
- package/dist/lib/ingestion.d.ts.map +1 -0
- package/dist/lib/journey-lift.d.ts +56 -0
- package/dist/lib/journey-lift.d.ts.map +1 -0
- package/dist/lib/journey-suppress.d.ts +59 -0
- package/dist/lib/journey-suppress.d.ts.map +1 -0
- package/dist/lib/leader-lease.d.ts +36 -0
- package/dist/lib/leader-lease.d.ts.map +1 -0
- package/dist/lib/lift-stats.d.ts +46 -0
- package/dist/lib/lift-stats.d.ts.map +1 -0
- package/dist/lib/links.d.ts +186 -0
- package/dist/lib/links.d.ts.map +1 -0
- package/dist/lib/load-optional-plugin.d.ts +47 -0
- package/dist/lib/load-optional-plugin.d.ts.map +1 -0
- package/dist/lib/logger.d.ts +4 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/mailer.d.ts +43 -0
- package/dist/lib/mailer.d.ts.map +1 -0
- package/dist/lib/metrics-sql.d.ts +11 -0
- package/dist/lib/metrics-sql.d.ts.map +1 -0
- package/dist/lib/notifications.d.ts +17 -0
- package/dist/lib/notifications.d.ts.map +1 -0
- package/dist/lib/oauth-token-manager.d.ts +74 -0
- package/dist/lib/oauth-token-manager.d.ts.map +1 -0
- package/dist/lib/operator-settings.d.ts +33 -0
- package/dist/lib/operator-settings.d.ts.map +1 -0
- package/dist/lib/operator.d.ts +20 -0
- package/dist/lib/operator.d.ts.map +1 -0
- package/dist/lib/outbound-endpoint-cache.d.ts +25 -0
- package/dist/lib/outbound-endpoint-cache.d.ts.map +1 -0
- package/dist/lib/outbound.d.ts +687 -0
- package/dist/lib/outbound.d.ts.map +1 -0
- package/dist/lib/phone.d.ts +11 -0
- package/dist/lib/phone.d.ts.map +1 -0
- package/dist/lib/posthog-scopes.d.ts +30 -0
- package/dist/lib/posthog-scopes.d.ts.map +1 -0
- package/dist/lib/posthog.d.ts +16 -0
- package/dist/lib/posthog.d.ts.map +1 -0
- package/dist/lib/preferences.d.ts +72 -0
- package/dist/lib/preferences.d.ts.map +1 -0
- package/dist/lib/provider-credentials.d.ts +149 -0
- package/dist/lib/provider-credentials.d.ts.map +1 -0
- package/dist/lib/provision-posthog-loop.d.ts +100 -0
- package/dist/lib/provision-posthog-loop.d.ts.map +1 -0
- package/dist/lib/recipient-preferences.d.ts +29 -0
- package/dist/lib/recipient-preferences.d.ts.map +1 -0
- package/dist/lib/redis.d.ts +33 -0
- package/dist/lib/redis.d.ts.map +1 -0
- package/dist/lib/referral-intent.d.ts +99 -0
- package/dist/lib/referral-intent.d.ts.map +1 -0
- package/dist/lib/referral-link.d.ts +59 -0
- package/dist/lib/referral-link.d.ts.map +1 -0
- package/dist/lib/referral-registry.d.ts +37 -0
- package/dist/lib/referral-registry.d.ts.map +1 -0
- package/dist/lib/referral-report.d.ts +178 -0
- package/dist/lib/referral-report.d.ts.map +1 -0
- package/dist/lib/referral-runtime.d.ts +43 -0
- package/dist/lib/referral-runtime.d.ts.map +1 -0
- package/dist/lib/referrals.d.ts +184 -0
- package/dist/lib/referrals.d.ts.map +1 -0
- package/dist/lib/refine-chain.d.ts +236 -0
- package/dist/lib/refine-chain.d.ts.map +1 -0
- package/dist/lib/refine-traits.d.ts +78 -0
- package/dist/lib/refine-traits.d.ts.map +1 -0
- package/dist/lib/refine.d.ts +35 -0
- package/dist/lib/refine.d.ts.map +1 -0
- package/dist/lib/reset-email.d.ts +38 -0
- package/dist/lib/reset-email.d.ts.map +1 -0
- package/dist/lib/revenue.d.ts +61 -0
- package/dist/lib/revenue.d.ts.map +1 -0
- package/dist/lib/schemas.d.ts +9 -0
- package/dist/lib/schemas.d.ts.map +1 -0
- package/dist/lib/seed-posthog-destination.d.ts +22 -0
- package/dist/lib/seed-posthog-destination.d.ts.map +1 -0
- package/dist/lib/semantic-click.d.ts +58 -0
- package/dist/lib/semantic-click.d.ts.map +1 -0
- package/dist/lib/sending-domain-guidance.d.ts +40 -0
- package/dist/lib/sending-domain-guidance.d.ts.map +1 -0
- package/dist/lib/singleton.d.ts +24 -0
- package/dist/lib/singleton.d.ts.map +1 -0
- package/dist/lib/sms-frequency-cap.d.ts +16 -0
- package/dist/lib/sms-frequency-cap.d.ts.map +1 -0
- package/dist/lib/sms-inbound.d.ts +37 -0
- package/dist/lib/sms-inbound.d.ts.map +1 -0
- package/dist/lib/sms-link-tracking.d.ts +53 -0
- package/dist/lib/sms-link-tracking.d.ts.map +1 -0
- package/dist/lib/sms-mailer.d.ts +12 -0
- package/dist/lib/sms-mailer.d.ts.map +1 -0
- package/dist/lib/sms-provider-registry.d.ts +20 -0
- package/dist/lib/sms-provider-registry.d.ts.map +1 -0
- package/dist/lib/sms-providers-from-env.d.ts +4 -0
- package/dist/lib/sms-providers-from-env.d.ts.map +1 -0
- package/dist/lib/sms-service-types.d.ts +131 -0
- package/dist/lib/sms-service-types.d.ts.map +1 -0
- package/dist/lib/sms-tracked.d.ts +36 -0
- package/dist/lib/sms-tracked.d.ts.map +1 -0
- package/dist/lib/sms.d.ts +58 -0
- package/dist/lib/sms.d.ts.map +1 -0
- package/dist/lib/snippet.d.ts +32 -0
- package/dist/lib/snippet.d.ts.map +1 -0
- package/dist/lib/stable-stringify.d.ts +12 -0
- package/dist/lib/stable-stringify.d.ts.map +1 -0
- package/dist/lib/studio.d.ts +21 -0
- package/dist/lib/studio.d.ts.map +1 -0
- package/dist/lib/survey.d.ts +35 -0
- package/dist/lib/survey.d.ts.map +1 -0
- package/dist/lib/test-mode.d.ts +77 -0
- package/dist/lib/test-mode.d.ts.map +1 -0
- package/dist/lib/timezone.d.ts +55 -0
- package/dist/lib/timezone.d.ts.map +1 -0
- package/dist/lib/tracked.d.ts +95 -0
- package/dist/lib/tracked.d.ts.map +1 -0
- package/dist/lib/tracking-event-names.d.ts +7 -0
- package/dist/lib/tracking-event-names.d.ts.map +1 -0
- package/dist/lib/tracking-events.d.ts +232 -0
- package/dist/lib/tracking-events.d.ts.map +1 -0
- package/dist/lib/tracking.d.ts +47 -0
- package/dist/lib/tracking.d.ts.map +1 -0
- package/dist/lib/unconfigured-email-provider.d.ts +20 -0
- package/dist/lib/unconfigured-email-provider.d.ts.map +1 -0
- package/dist/lib/unique-violation.d.ts +22 -0
- package/dist/lib/unique-violation.d.ts.map +1 -0
- package/dist/lib/user-token.d.ts +44 -0
- package/dist/lib/user-token.d.ts.map +1 -0
- package/dist/lib/variant.d.ts +44 -0
- package/dist/lib/variant.d.ts.map +1 -0
- package/dist/lib/webhook-signing.d.ts +120 -0
- package/dist/lib/webhook-signing.d.ts.map +1 -0
- package/dist/lib/worker-heartbeat.d.ts +18 -0
- package/dist/lib/worker-heartbeat.d.ts.map +1 -0
- package/dist/lists/channels.d.ts +43 -0
- package/dist/lists/channels.d.ts.map +1 -0
- package/dist/lists/define-list.d.ts +76 -0
- package/dist/lists/define-list.d.ts.map +1 -0
- package/dist/lists/registry-singleton.d.ts +8 -0
- package/dist/lists/registry-singleton.d.ts.map +1 -0
- package/dist/lists/registry.d.ts +66 -0
- package/dist/lists/registry.d.ts.map +1 -0
- package/dist/lists/subscription.d.ts +10 -0
- package/dist/lists/subscription.d.ts.map +1 -0
- package/dist/mcp/authoring-guide.d.ts +33 -0
- package/dist/mcp/authoring-guide.d.ts.map +1 -0
- package/dist/mcp/blueprint-tools.d.ts +266 -0
- package/dist/mcp/blueprint-tools.d.ts.map +1 -0
- package/dist/middleware/api-key.d.ts +45 -0
- package/dist/middleware/api-key.d.ts.map +1 -0
- package/dist/middleware/audit.d.ts +3 -0
- package/dist/middleware/audit.d.ts.map +1 -0
- package/dist/middleware/error-handler.d.ts +4 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/publishable-key.d.ts +27 -0
- package/dist/middleware/publishable-key.d.ts.map +1 -0
- package/dist/middleware/rate-limit.d.ts +105 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/request-logger.d.ts +4 -0
- package/dist/middleware/request-logger.d.ts.map +1 -0
- package/dist/middleware/require-admin.d.ts +3 -0
- package/dist/middleware/require-admin.d.ts.map +1 -0
- package/dist/routes/_shared.d.ts +52 -0
- package/dist/routes/_shared.d.ts.map +1 -0
- package/dist/routes/accounts/callback.d.ts +18 -0
- package/dist/routes/accounts/callback.d.ts.map +1 -0
- package/dist/routes/accounts/emit.d.ts +96 -0
- package/dist/routes/accounts/emit.d.ts.map +1 -0
- package/dist/routes/accounts/import-links.d.ts +4 -0
- package/dist/routes/accounts/import-links.d.ts.map +1 -0
- package/dist/routes/accounts/index.d.ts +39 -0
- package/dist/routes/accounts/index.d.ts.map +1 -0
- package/dist/routes/accounts/lookup.d.ts +6 -0
- package/dist/routes/accounts/lookup.d.ts.map +1 -0
- package/dist/routes/accounts/me.d.ts +5 -0
- package/dist/routes/accounts/me.d.ts.map +1 -0
- package/dist/routes/accounts/mint.d.ts +5 -0
- package/dist/routes/accounts/mint.d.ts.map +1 -0
- package/dist/routes/accounts/pages.d.ts +23 -0
- package/dist/routes/accounts/pages.d.ts.map +1 -0
- package/dist/routes/accounts/resolve.d.ts +33 -0
- package/dist/routes/accounts/resolve.d.ts.map +1 -0
- package/dist/routes/accounts/serialize.d.ts +57 -0
- package/dist/routes/accounts/serialize.d.ts.map +1 -0
- package/dist/routes/accounts/shared.d.ts +68 -0
- package/dist/routes/accounts/shared.d.ts.map +1 -0
- package/dist/routes/accounts/start.d.ts +16 -0
- package/dist/routes/accounts/start.d.ts.map +1 -0
- package/dist/routes/accounts/unlink.d.ts +36 -0
- package/dist/routes/accounts/unlink.d.ts.map +1 -0
- package/dist/routes/admin/agent.d.ts +4 -0
- package/dist/routes/admin/agent.d.ts.map +1 -0
- package/dist/routes/admin/alerts.d.ts +190 -0
- package/dist/routes/admin/alerts.d.ts.map +1 -0
- package/dist/routes/admin/analytics.d.ts +137 -0
- package/dist/routes/admin/analytics.d.ts.map +1 -0
- package/dist/routes/admin/api-keys.d.ts +158 -0
- package/dist/routes/admin/api-keys.d.ts.map +1 -0
- package/dist/routes/admin/attribution.d.ts +93 -0
- package/dist/routes/admin/attribution.d.ts.map +1 -0
- package/dist/routes/admin/audit-logs.d.ts +40 -0
- package/dist/routes/admin/audit-logs.d.ts.map +1 -0
- package/dist/routes/admin/blueprints.d.ts +4 -0
- package/dist/routes/admin/blueprints.d.ts.map +1 -0
- package/dist/routes/admin/buckets.d.ts +215 -0
- package/dist/routes/admin/buckets.d.ts.map +1 -0
- package/dist/routes/admin/bulk.d.ts +203 -0
- package/dist/routes/admin/bulk.d.ts.map +1 -0
- package/dist/routes/admin/campaigns.d.ts +198 -0
- package/dist/routes/admin/campaigns.d.ts.map +1 -0
- package/dist/routes/admin/connectors.d.ts +116 -0
- package/dist/routes/admin/connectors.d.ts.map +1 -0
- package/dist/routes/admin/contacts.d.ts +246 -0
- package/dist/routes/admin/contacts.d.ts.map +1 -0
- package/dist/routes/admin/conversions.d.ts +103 -0
- package/dist/routes/admin/conversions.d.ts.map +1 -0
- package/dist/routes/admin/deals.d.ts +136 -0
- package/dist/routes/admin/deals.d.ts.map +1 -0
- package/dist/routes/admin/dlq.d.ts +100 -0
- package/dist/routes/admin/dlq.d.ts.map +1 -0
- package/dist/routes/admin/domain.d.ts +314 -0
- package/dist/routes/admin/domain.d.ts.map +1 -0
- package/dist/routes/admin/emails.d.ts +127 -0
- package/dist/routes/admin/emails.d.ts.map +1 -0
- package/dist/routes/admin/events.d.ts +140 -0
- package/dist/routes/admin/events.d.ts.map +1 -0
- package/dist/routes/admin/flags.d.ts +719 -0
- package/dist/routes/admin/flags.d.ts.map +1 -0
- package/dist/routes/admin/funnels.d.ts +71 -0
- package/dist/routes/admin/funnels.d.ts.map +1 -0
- package/dist/routes/admin/groups.d.ts +169 -0
- package/dist/routes/admin/groups.d.ts.map +1 -0
- package/dist/routes/admin/identity.d.ts +72 -0
- package/dist/routes/admin/identity.d.ts.map +1 -0
- package/dist/routes/admin/impact-schemas.d.ts +48 -0
- package/dist/routes/admin/impact-schemas.d.ts.map +1 -0
- package/dist/routes/admin/impact.d.ts +316 -0
- package/dist/routes/admin/impact.d.ts.map +1 -0
- package/dist/routes/admin/index.d.ts +4 -0
- package/dist/routes/admin/index.d.ts.map +1 -0
- package/dist/routes/admin/journey-impact.d.ts +320 -0
- package/dist/routes/admin/journey-impact.d.ts.map +1 -0
- package/dist/routes/admin/journey-logs.d.ts +57 -0
- package/dist/routes/admin/journey-logs.d.ts.map +1 -0
- package/dist/routes/admin/journeys.d.ts +736 -0
- package/dist/routes/admin/journeys.d.ts.map +1 -0
- package/dist/routes/admin/links.d.ts +382 -0
- package/dist/routes/admin/links.d.ts.map +1 -0
- package/dist/routes/admin/lists.d.ts +22 -0
- package/dist/routes/admin/lists.d.ts.map +1 -0
- package/dist/routes/admin/maintenance.d.ts +72 -0
- package/dist/routes/admin/maintenance.d.ts.map +1 -0
- package/dist/routes/admin/metrics.d.ts +212 -0
- package/dist/routes/admin/metrics.d.ts.map +1 -0
- package/dist/routes/admin/open-editor.d.ts +36 -0
- package/dist/routes/admin/open-editor.d.ts.map +1 -0
- package/dist/routes/admin/preferences.d.ts +109 -0
- package/dist/routes/admin/preferences.d.ts.map +1 -0
- package/dist/routes/admin/provider-credentials.d.ts +108 -0
- package/dist/routes/admin/provider-credentials.d.ts.map +1 -0
- package/dist/routes/admin/readiness.d.ts +24 -0
- package/dist/routes/admin/readiness.d.ts.map +1 -0
- package/dist/routes/admin/referrals.d.ts +230 -0
- package/dist/routes/admin/referrals.d.ts.map +1 -0
- package/dist/routes/admin/reporting.d.ts +149 -0
- package/dist/routes/admin/reporting.d.ts.map +1 -0
- package/dist/routes/admin/settings.d.ts +80 -0
- package/dist/routes/admin/settings.d.ts.map +1 -0
- package/dist/routes/admin/suppressions.d.ts +90 -0
- package/dist/routes/admin/suppressions.d.ts.map +1 -0
- package/dist/routes/admin/targeting.d.ts +58 -0
- package/dist/routes/admin/targeting.d.ts.map +1 -0
- package/dist/routes/admin/templates.d.ts +197 -0
- package/dist/routes/admin/templates.d.ts.map +1 -0
- package/dist/routes/admin/timeline.d.ts +51 -0
- package/dist/routes/admin/timeline.d.ts.map +1 -0
- package/dist/routes/admin/webhooks.d.ts +250 -0
- package/dist/routes/admin/webhooks.d.ts.map +1 -0
- package/dist/routes/campaigns/index.d.ts +239 -0
- package/dist/routes/campaigns/index.d.ts.map +1 -0
- package/dist/routes/connectors/index.d.ts +16 -0
- package/dist/routes/connectors/index.d.ts.map +1 -0
- package/dist/routes/contacts/index.d.ts +187 -0
- package/dist/routes/contacts/index.d.ts.map +1 -0
- package/dist/routes/email/index.d.ts +4 -0
- package/dist/routes/email/index.d.ts.map +1 -0
- package/dist/routes/email/preferences.d.ts +17 -0
- package/dist/routes/email/preferences.d.ts.map +1 -0
- package/dist/routes/email/unsubscribe.d.ts +17 -0
- package/dist/routes/email/unsubscribe.d.ts.map +1 -0
- package/dist/routes/emails/index.d.ts +90 -0
- package/dist/routes/emails/index.d.ts.map +1 -0
- package/dist/routes/events/index.d.ts +116 -0
- package/dist/routes/events/index.d.ts.map +1 -0
- package/dist/routes/feed/index.d.ts +248 -0
- package/dist/routes/feed/index.d.ts.map +1 -0
- package/dist/routes/feed/recipient.d.ts +65 -0
- package/dist/routes/feed/recipient.d.ts.map +1 -0
- package/dist/routes/flags/index.d.ts +94 -0
- package/dist/routes/flags/index.d.ts.map +1 -0
- package/dist/routes/groups/index.d.ts +192 -0
- package/dist/routes/groups/index.d.ts.map +1 -0
- package/dist/routes/health.d.ts +57 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/index.d.ts +8 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/lists/index.d.ts +266 -0
- package/dist/routes/lists/index.d.ts.map +1 -0
- package/dist/routes/referrals/index.d.ts +22 -0
- package/dist/routes/referrals/index.d.ts.map +1 -0
- package/dist/routes/referrals/me.d.ts +4 -0
- package/dist/routes/referrals/me.d.ts.map +1 -0
- package/dist/routes/referrals/report.d.ts +5 -0
- package/dist/routes/referrals/report.d.ts.map +1 -0
- package/dist/routes/referrals/shared.d.ts +16 -0
- package/dist/routes/referrals/shared.d.ts.map +1 -0
- package/dist/routes/referrals/touch.d.ts +5 -0
- package/dist/routes/referrals/touch.d.ts.map +1 -0
- package/dist/routes/snippet.d.ts +12 -0
- package/dist/routes/snippet.d.ts.map +1 -0
- package/dist/routes/tracking/answer.d.ts +56 -0
- package/dist/routes/tracking/answer.d.ts.map +1 -0
- package/dist/routes/tracking/arrive.d.ts +32 -0
- package/dist/routes/tracking/arrive.d.ts.map +1 -0
- package/dist/routes/tracking/click-pipeline.d.ts +213 -0
- package/dist/routes/tracking/click-pipeline.d.ts.map +1 -0
- package/dist/routes/tracking/click.d.ts +26 -0
- package/dist/routes/tracking/click.d.ts.map +1 -0
- package/dist/routes/tracking/identify.d.ts +32 -0
- package/dist/routes/tracking/identify.d.ts.map +1 -0
- package/dist/routes/tracking/index.d.ts +4 -0
- package/dist/routes/tracking/index.d.ts.map +1 -0
- package/dist/routes/tracking/open.d.ts +17 -0
- package/dist/routes/tracking/open.d.ts.map +1 -0
- package/dist/routes/tracking/short.d.ts +17 -0
- package/dist/routes/tracking/short.d.ts.map +1 -0
- package/dist/routes/tracking/vanity.d.ts +17 -0
- package/dist/routes/tracking/vanity.d.ts.map +1 -0
- package/dist/routes/webhooks/crm-provider.d.ts +24 -0
- package/dist/routes/webhooks/crm-provider.d.ts.map +1 -0
- package/dist/routes/webhooks/email-provider.d.ts +21 -0
- package/dist/routes/webhooks/email-provider.d.ts.map +1 -0
- package/dist/routes/webhooks/index.d.ts +8 -0
- package/dist/routes/webhooks/index.d.ts.map +1 -0
- package/dist/routes/webhooks/resend.d.ts +35 -0
- package/dist/routes/webhooks/resend.d.ts.map +1 -0
- package/dist/routes/webhooks/sms-provider.d.ts +23 -0
- package/dist/routes/webhooks/sms-provider.d.ts.map +1 -0
- package/dist/routes/webhooks/sources.d.ts +12 -0
- package/dist/routes/webhooks/sources.d.ts.map +1 -0
- package/dist/sources/define-contact-source.d.ts +114 -0
- package/dist/sources/define-contact-source.d.ts.map +1 -0
- package/dist/sources/registry.d.ts +31 -0
- package/dist/sources/registry.d.ts.map +1 -0
- package/dist/sources/webhook-source.d.ts +53 -0
- package/dist/sources/webhook-source.d.ts.map +1 -0
- package/dist/testing.d.ts +10 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/webhook-sources/define-webhook-source.d.ts +60 -0
- package/dist/webhook-sources/define-webhook-source.d.ts.map +1 -0
- package/dist/webhook-sources/presets/clerk.d.ts +9 -0
- package/dist/webhook-sources/presets/clerk.d.ts.map +1 -0
- package/dist/webhook-sources/presets/index.d.ts +140 -0
- package/dist/webhook-sources/presets/index.d.ts.map +1 -0
- package/dist/webhook-sources/presets/intercom.d.ts +44 -0
- package/dist/webhook-sources/presets/intercom.d.ts.map +1 -0
- package/dist/webhook-sources/presets/segment.d.ts +16 -0
- package/dist/webhook-sources/presets/segment.d.ts.map +1 -0
- package/dist/webhook-sources/presets/stripe.d.ts +20 -0
- package/dist/webhook-sources/presets/stripe.d.ts.map +1 -0
- package/dist/webhook-sources/presets/supabase.d.ts +23 -0
- package/dist/webhook-sources/presets/supabase.d.ts.map +1 -0
- package/dist/webhook-sources/verify.d.ts +48 -0
- package/dist/webhook-sources/verify.d.ts.map +1 -0
- package/dist/worker.d.ts +37 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/workflows/backfill-contact-id.d.ts +202 -0
- package/dist/workflows/backfill-contact-id.d.ts.map +1 -0
- package/dist/workflows/bucket-backfill.d.ts +64 -0
- package/dist/workflows/bucket-backfill.d.ts.map +1 -0
- package/dist/workflows/bucket-reconcile.d.ts +73 -0
- package/dist/workflows/bucket-reconcile.d.ts.map +1 -0
- package/dist/workflows/check-alerts.d.ts +10 -0
- package/dist/workflows/check-alerts.d.ts.map +1 -0
- package/dist/workflows/confirm-semantic-click.d.ts +15 -0
- package/dist/workflows/confirm-semantic-click.d.ts.map +1 -0
- package/dist/workflows/crm-reconcile.d.ts +27 -0
- package/dist/workflows/crm-reconcile.d.ts.map +1 -0
- package/dist/workflows/deliver-webhook.d.ts +88 -0
- package/dist/workflows/deliver-webhook.d.ts.map +1 -0
- package/dist/workflows/dispatch-conversion.d.ts +14 -0
- package/dist/workflows/dispatch-conversion.d.ts.map +1 -0
- package/dist/workflows/identity-alias-backfill.d.ts +96 -0
- package/dist/workflows/identity-alias-backfill.d.ts.map +1 -0
- package/dist/workflows/impact-digest.d.ts +142 -0
- package/dist/workflows/impact-digest.d.ts.map +1 -0
- package/dist/workflows/import-contacts.d.ts +14 -0
- package/dist/workflows/import-contacts.d.ts.map +1 -0
- package/dist/workflows/import-suppressions.d.ts +55 -0
- package/dist/workflows/import-suppressions.d.ts.map +1 -0
- package/dist/workflows/journey-blueprint-interpreter.d.ts +73 -0
- package/dist/workflows/journey-blueprint-interpreter.d.ts.map +1 -0
- package/dist/workflows/send-campaign.d.ts +128 -0
- package/dist/workflows/send-campaign.d.ts.map +1 -0
- package/dist/workflows/send-email.d.ts +15 -0
- package/dist/workflows/send-email.d.ts.map +1 -0
- package/dist/workflows/send-feed.d.ts +37 -0
- package/dist/workflows/send-feed.d.ts.map +1 -0
- package/package.json +60 -22
- package/src/app.ts +9 -1
- package/src/buckets/check-membership.ts +54 -20
- package/src/container.ts +77 -0
- package/src/env.ts +30 -0
- package/src/index.ts +78 -0
- package/src/journeys/journey-log.ts +25 -8
- package/src/lib/contacts.ts +117 -1
- package/src/lib/email-service-types.ts +10 -0
- package/src/lib/ingestion.ts +91 -19
- package/src/lib/links.ts +94 -11
- package/src/lib/mailer-bounce-idempotency.test.ts +7 -2
- package/src/lib/mailer-replied.test.ts +7 -2
- package/src/lib/mailer.ts +1 -0
- package/src/lib/outbound-endpoint-cache.ts +83 -0
- package/src/lib/outbound.ts +150 -37
- package/src/lib/referral-intent.ts +723 -0
- package/src/lib/referral-link.ts +200 -0
- package/src/lib/referral-registry.ts +83 -0
- package/src/lib/referral-report.ts +739 -0
- package/src/lib/referral-runtime.ts +49 -0
- package/src/lib/referrals-no-emit.test.ts +109 -0
- package/src/lib/referrals.ts +712 -0
- package/src/lib/seed-posthog-destination.ts +5 -1
- package/src/lib/tracked.ts +11 -3
- package/src/lib/tracking-events.ts +20 -3
- package/src/lib/webhook-signing.ts +10 -0
- package/src/middleware/api-key.ts +69 -60
- package/src/middleware/publishable-key.ts +11 -23
- package/src/middleware/rate-limit.ts +165 -3
- package/src/routes/admin/api-keys.ts +153 -0
- package/src/routes/admin/index.ts +2 -0
- package/src/routes/admin/links.ts +14 -5
- package/src/routes/admin/referrals.ts +565 -0
- package/src/routes/admin/targeting.ts +6 -1
- package/src/routes/admin/webhooks.ts +4 -0
- package/src/routes/contacts/index.ts +78 -0
- package/src/routes/index.ts +104 -22
- package/src/routes/referrals/index.ts +41 -0
- package/src/routes/referrals/me.ts +123 -0
- package/src/routes/referrals/report.ts +285 -0
- package/src/routes/referrals/shared.ts +34 -0
- package/src/routes/referrals/touch.ts +313 -0
- package/src/routes/tracking/arrive.ts +90 -0
- package/src/routes/tracking/click-pipeline.ts +8 -0
- package/src/workflows/backfill-contact-id.ts +3 -7
- package/src/workflows/bucket-backfill.ts +2 -2
- package/src/workflows/bucket-reconcile.ts +28 -12
- package/src/workflows/check-alerts.ts +3 -9
- package/src/workflows/crm-reconcile.ts +3 -2
- package/src/workflows/deliver-webhook.ts +21 -8
- package/src/workflows/dispatch-conversion.ts +2 -2
- package/src/workflows/identity-alias-backfill.ts +3 -2
- package/src/workflows/impact-digest.ts +2 -2
- package/src/workflows/import-contacts.ts +3 -4
- package/src/workflows/import-suppressions.ts +4 -5
- package/src/workflows/send-campaign.ts +10 -1
package/src/container.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
DefinedConversion,
|
|
11
11
|
DefinedFlag,
|
|
12
12
|
DefinedFunnel,
|
|
13
|
+
DefinedReferral,
|
|
13
14
|
EmailProvider,
|
|
14
15
|
EnrichmentProvider,
|
|
15
16
|
FunnelStageEntry,
|
|
@@ -125,6 +126,8 @@ import {
|
|
|
125
126
|
getOperatorSetting,
|
|
126
127
|
} from "./lib/operator-settings.js";
|
|
127
128
|
import { createRedisSecondaryStorage, getRedis } from "./lib/redis.js";
|
|
129
|
+
import { ReferralRegistry } from "./lib/referral-registry.js";
|
|
130
|
+
import { setReferralRuntime } from "./lib/referral-runtime.js";
|
|
128
131
|
import { sendResetPasswordEmail } from "./lib/reset-email.js";
|
|
129
132
|
import { seedPostHogDestination } from "./lib/seed-posthog-destination.js";
|
|
130
133
|
import { setSmsService } from "./lib/sms.js";
|
|
@@ -236,6 +239,16 @@ export interface HogsendClient {
|
|
|
236
239
|
accountLinkHooks: AccountLinkHooks;
|
|
237
240
|
/** Parsed + validated ACCOUNT_LINK_ALLOWED_ORIGINS. Empty array = none permitted. */
|
|
238
241
|
accountLinkAllowedOrigins: string[];
|
|
242
|
+
/**
|
|
243
|
+
* The container-held registry of referral definitions (`defineReferral`),
|
|
244
|
+
* keyed by id. There is NO env preset and NO single active referral: a
|
|
245
|
+
* referral exists because it was authored in code, and a product may run
|
|
246
|
+
* several at once. EMPTY is the normal state of a deploy that never asked
|
|
247
|
+
* for referrals, and every wired site (the arrive touch, the bind at
|
|
248
|
+
* identity adoption, the qualify evaluation in `ingestEvent`, the conversion
|
|
249
|
+
* tree walk) is INERT while it stays empty.
|
|
250
|
+
*/
|
|
251
|
+
referrals: ReferralRegistry;
|
|
239
252
|
/**
|
|
240
253
|
* The container-held registry of enrichment providers, keyed by `meta.id` —
|
|
241
254
|
* the enrichment sibling of {@link smsProviders}. Empty when no enrichment
|
|
@@ -380,6 +393,13 @@ export interface HogsendClient {
|
|
|
380
393
|
* (frequency cap).
|
|
381
394
|
*/
|
|
382
395
|
defaults: HogsendDefaults;
|
|
396
|
+
/**
|
|
397
|
+
* Resolved browser-readable contact projection (`GET /v1/contacts/me`).
|
|
398
|
+
* `publicProperties` is an operator ALLOWLIST of exact `contacts.properties`
|
|
399
|
+
* keys; `exposeEmail` opts the address in. Both default to closed
|
|
400
|
+
* (`[]` / `false`), so a deploy that configures nothing exposes nothing.
|
|
401
|
+
*/
|
|
402
|
+
contactsConfig: { publicProperties: string[]; exposeEmail: boolean };
|
|
383
403
|
}
|
|
384
404
|
|
|
385
405
|
export interface HogsendClientOptions {
|
|
@@ -486,6 +506,20 @@ export interface HogsendClientOptions {
|
|
|
486
506
|
linkTracking?: boolean;
|
|
487
507
|
linkHost?: string;
|
|
488
508
|
};
|
|
509
|
+
/**
|
|
510
|
+
* What `GET /v1/contacts/me` may hand back to a browser.
|
|
511
|
+
*
|
|
512
|
+
* - `publicProperties` — EXACT `contacts.properties` keys the browser may
|
|
513
|
+
* read. No wildcard, no prefix match. Anything not listed is omitted.
|
|
514
|
+
* - `exposeEmail` — include the contact's email address in the response.
|
|
515
|
+
*
|
|
516
|
+
* Defaults are closed (`[]` / `false`): with no `contacts` option the route
|
|
517
|
+
* answers `{ identified: false, traits: {} }` for everyone.
|
|
518
|
+
*/
|
|
519
|
+
contacts?: {
|
|
520
|
+
publicProperties?: string[];
|
|
521
|
+
exposeEmail?: boolean;
|
|
522
|
+
};
|
|
489
523
|
/**
|
|
490
524
|
* Account linking (Steam, Twitch, or your own `defineAccountLink` provider).
|
|
491
525
|
* The engine owns the stateful flow (state tokens, the link store,
|
|
@@ -506,6 +540,14 @@ export interface HogsendClientOptions {
|
|
|
506
540
|
*/
|
|
507
541
|
allowedOrigins?: string[];
|
|
508
542
|
};
|
|
543
|
+
/**
|
|
544
|
+
* Referral programs, authored with `defineReferral` (PRD 05). Pass the SAME
|
|
545
|
+
* array in BOTH `index.ts` and `worker.ts`: the HTTP side runs the touch and
|
|
546
|
+
* the bind, the worker side runs `getReferralLink` inside journeys.
|
|
547
|
+
* Duplicate ids inside one array warn and last-writer-wins, like every other
|
|
548
|
+
* registry merge. Omitted ⇒ referrals are entirely inert.
|
|
549
|
+
*/
|
|
550
|
+
referrals?: DefinedReferral[];
|
|
509
551
|
/**
|
|
510
552
|
* Enrichment (Refinement) is a first-class provider kind mirroring
|
|
511
553
|
* {@link email}/{@link sms}. The engine owns the cohesive refinement
|
|
@@ -992,6 +1034,21 @@ export function createHogsendClient(
|
|
|
992
1034
|
...(opts.accountLinks?.allowedOrigins ?? []),
|
|
993
1035
|
]);
|
|
994
1036
|
const accountLinkHooks: AccountLinkHooks = opts.accountLinks?.hooks ?? {};
|
|
1037
|
+
// Referrals: code-only, no env preset. Duplicate ids in one array are almost
|
|
1038
|
+
// certainly an authoring mistake, so warn (last-writer-wins, mirroring the
|
|
1039
|
+
// account-link providers merge just above).
|
|
1040
|
+
{
|
|
1041
|
+
const seenReferralIds = new Set<string>();
|
|
1042
|
+
for (const referral of opts.referrals ?? []) {
|
|
1043
|
+
if (seenReferralIds.has(referral.id)) {
|
|
1044
|
+
logger.warn(
|
|
1045
|
+
`referrals contains "${referral.id}" more than once — the last one wins (last-writer-wins on id)`,
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
seenReferralIds.add(referral.id);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
const referrals = new ReferralRegistry(opts.referrals ?? []);
|
|
995
1052
|
if (
|
|
996
1053
|
accountLinkProviders.count() > 0 &&
|
|
997
1054
|
accountLinkAllowedOrigins.length === 0
|
|
@@ -1753,6 +1810,21 @@ export function createHogsendClient(
|
|
|
1753
1810
|
`Destination registry loaded: ${destinationRegistry.count()} destinations`,
|
|
1754
1811
|
);
|
|
1755
1812
|
|
|
1813
|
+
// The referral runtime, for the sites that hold no container: the bind in
|
|
1814
|
+
// `lib/contacts.ts` (post-commit, library code), the qualify + conversion
|
|
1815
|
+
// walk in `lib/ingestion.ts`, and `getReferralLink` inside a durable journey
|
|
1816
|
+
// task. OPTIONAL by design — a deploy with no referrals installs an empty
|
|
1817
|
+
// registry and every one of those sites stays inert.
|
|
1818
|
+
setReferralRuntime({
|
|
1819
|
+
referrals,
|
|
1820
|
+
db,
|
|
1821
|
+
baseUrl: env.API_PUBLIC_URL,
|
|
1822
|
+
hatchet,
|
|
1823
|
+
registry,
|
|
1824
|
+
logger,
|
|
1825
|
+
...(analytics ? { analytics } : {}),
|
|
1826
|
+
});
|
|
1827
|
+
|
|
1756
1828
|
const client: HogsendClient = {
|
|
1757
1829
|
env,
|
|
1758
1830
|
logger,
|
|
@@ -1770,6 +1842,7 @@ export function createHogsendClient(
|
|
|
1770
1842
|
accountLinkProviders,
|
|
1771
1843
|
accountLinkHooks,
|
|
1772
1844
|
accountLinkAllowedOrigins,
|
|
1845
|
+
referrals,
|
|
1773
1846
|
enrichmentProviders,
|
|
1774
1847
|
enrichmentProvider,
|
|
1775
1848
|
crmProviders,
|
|
@@ -1795,6 +1868,10 @@ export function createHogsendClient(
|
|
|
1795
1868
|
hatchet: opts.overrides?.hatchet ?? hatchet,
|
|
1796
1869
|
clientJournal: opts.clientJournal ?? { entries: [] },
|
|
1797
1870
|
defaults,
|
|
1871
|
+
contactsConfig: {
|
|
1872
|
+
publicProperties: opts.contacts?.publicProperties ?? [],
|
|
1873
|
+
exposeEmail: opts.contacts?.exposeEmail ?? false,
|
|
1874
|
+
},
|
|
1798
1875
|
};
|
|
1799
1876
|
|
|
1800
1877
|
// Boot-time reader for `hogsend connect posthog`'s persisted phc_: when no
|
package/src/env.ts
CHANGED
|
@@ -368,6 +368,27 @@ export const env = createEnv({
|
|
|
368
368
|
* HOGSEND_TEST_MODE precedent). Unset ⇒ "false" ⇒ behavior unchanged.
|
|
369
369
|
*/
|
|
370
370
|
HOGSEND_INGEST_SUSPENDED: z.enum(["true", "false"]).default("false"),
|
|
371
|
+
// --- Data-plane rate limits (middleware/rate-limit.ts) ---
|
|
372
|
+
// Sliding-window budgets on the data plane. All optional: unset falls back
|
|
373
|
+
// to the defaults in `middleware/rate-limit.ts`, the single source for the
|
|
374
|
+
// numbers (the OUTBOUND_WEBHOOK_* stance).
|
|
375
|
+
//
|
|
376
|
+
// The browser-reachable ingest routes (everything behind
|
|
377
|
+
// `requirePublishableOrIngest`: `/v1/events`, the `/v1/contacts` upsert,
|
|
378
|
+
// `/v1/contacts/me`, `/v1/lists*`, `/v1/feed*`, `/v1/flags`, and the
|
|
379
|
+
// `/me` reads of accounts and referrals) carry two budgets that share one
|
|
380
|
+
// window:
|
|
381
|
+
// - INGEST_RATE_LIMIT_MAX: per SECRET key (default 3000).
|
|
382
|
+
// - INGEST_PUBLIC_RATE_LIMIT_MAX: per PUBLISHABLE key per client IP
|
|
383
|
+
// (default 1000). A pk_ key is shared by every visitor of a site, so
|
|
384
|
+
// its budget is per visitor, not per key.
|
|
385
|
+
// - INGEST_RATE_LIMIT_WINDOW_MS: the window (default 60000).
|
|
386
|
+
INGEST_RATE_LIMIT_MAX: z.coerce.number().int().positive().optional(),
|
|
387
|
+
INGEST_PUBLIC_RATE_LIMIT_MAX: z.coerce.number().int().positive().optional(),
|
|
388
|
+
INGEST_RATE_LIMIT_WINDOW_MS: z.coerce.number().int().positive().optional(),
|
|
389
|
+
// Per-key budget on `/v1/emails` (transactional sends), separate from the
|
|
390
|
+
// ingest budgets above. Per minute, default 30.
|
|
391
|
+
EMAIL_RATE_LIMIT_MAX: z.coerce.number().int().positive().optional(),
|
|
371
392
|
ENABLED_JOURNEYS: z.string().default("*"),
|
|
372
393
|
// Buckets: same `"*"`-or-csv contract as ENABLED_JOURNEYS (Section 9.3).
|
|
373
394
|
// Evaluated at worker boot — a toggle requires a worker restart; only the
|
|
@@ -400,6 +421,15 @@ export const env = createEnv({
|
|
|
400
421
|
OUTBOUND_WEBHOOK_BASE_DELAY_MS: z.coerce.number().optional(),
|
|
401
422
|
OUTBOUND_WEBHOOK_MAX_DELAY_MS: z.coerce.number().optional(),
|
|
402
423
|
OUTBOUND_WEBHOOK_STUCK_AFTER_MS: z.coerce.number().optional(),
|
|
424
|
+
// How long the outbound spine reuses its list of enabled endpoints before
|
|
425
|
+
// re-reading `webhook_endpoints` (lib/outbound-endpoint-cache.ts). Read raw
|
|
426
|
+
// off process.env at emit time; default 30000, 0 disables the cache. The
|
|
427
|
+
// admin webhook routes clear it on the instance that handled the write.
|
|
428
|
+
OUTBOUND_ENDPOINT_CACHE_TTL_MS: z.coerce
|
|
429
|
+
.number()
|
|
430
|
+
.int()
|
|
431
|
+
.nonnegative()
|
|
432
|
+
.optional(),
|
|
403
433
|
// --- Integration presets (Section 2.2) ---
|
|
404
434
|
// Signature-source secrets. The webhook route resolves a preset's secret via
|
|
405
435
|
// env[source.auth.envKey]; a signature source FAILS CLOSED when its secret is
|
package/src/index.ts
CHANGED
|
@@ -495,6 +495,7 @@ export {
|
|
|
495
495
|
type IdentityKind,
|
|
496
496
|
identifiedContactFilter,
|
|
497
497
|
type MergedLinkUnlink,
|
|
498
|
+
projectPublicContact,
|
|
498
499
|
type ResolvePolicy,
|
|
499
500
|
resolveContactNoCreate,
|
|
500
501
|
resolveOrCreateContact,
|
|
@@ -700,6 +701,7 @@ export {
|
|
|
700
701
|
// internal mechanics behind the /qr endpoint, not semver surface.
|
|
701
702
|
export {
|
|
702
703
|
IdempotencyConflictError,
|
|
704
|
+
LinkOwnershipError,
|
|
703
705
|
type LinkType,
|
|
704
706
|
type MintedLink,
|
|
705
707
|
type MintLinkOptions,
|
|
@@ -765,6 +767,82 @@ export {
|
|
|
765
767
|
getRedis,
|
|
766
768
|
getRedisIfConnected,
|
|
767
769
|
} from "./lib/redis.js";
|
|
770
|
+
// --- Referral intent layer (the ONE place the store is called AND emits) ---
|
|
771
|
+
export {
|
|
772
|
+
type BindReferralInput,
|
|
773
|
+
bindReferral,
|
|
774
|
+
type ConvertReferralInput,
|
|
775
|
+
convertReferral,
|
|
776
|
+
type QualifyReferralInput,
|
|
777
|
+
qualifyReferral,
|
|
778
|
+
qualifyReferralsForEvent,
|
|
779
|
+
REFERRAL_TREE_MAX_DEPTH,
|
|
780
|
+
type ReferralIntentHandles,
|
|
781
|
+
type TouchReferralInput,
|
|
782
|
+
type TouchReferralResult,
|
|
783
|
+
touchReferral,
|
|
784
|
+
} from "./lib/referral-intent.js";
|
|
785
|
+
// --- Referrals: definition wiring + the journey-safe link mint ---
|
|
786
|
+
// `defineReferral` itself lives in `@hogsend/core` (re-exported from the core
|
|
787
|
+
// barrel). Pass definitions to `createHogsendClient({ referrals: [...] })` in
|
|
788
|
+
// BOTH index.ts and worker.ts; `client.referrals` is the resolved registry.
|
|
789
|
+
export {
|
|
790
|
+
type GetReferralLinkOptions,
|
|
791
|
+
getReferralLink,
|
|
792
|
+
type ReferralLink,
|
|
793
|
+
type ReferralLinkContainer,
|
|
794
|
+
} from "./lib/referral-link.js";
|
|
795
|
+
export { ReferralRegistry } from "./lib/referral-registry.js";
|
|
796
|
+
// --- Referral REPORT (report-time model/window/depth/weights, PRD 05 §5.3) ---
|
|
797
|
+
export {
|
|
798
|
+
type CurrencyValue,
|
|
799
|
+
getReferralReport,
|
|
800
|
+
getReferralTree,
|
|
801
|
+
InvalidWindowError,
|
|
802
|
+
NO_CURRENCY,
|
|
803
|
+
parseWindowMs,
|
|
804
|
+
REFERRAL_MODELS,
|
|
805
|
+
REFERRAL_REPORT_MAX_DEPTH,
|
|
806
|
+
type ReferralBeneficiary,
|
|
807
|
+
type ReferralModel,
|
|
808
|
+
type ReferralReport,
|
|
809
|
+
type ReferralTreeLevel,
|
|
810
|
+
type ReferralTreeNode,
|
|
811
|
+
resolveLevelWeights,
|
|
812
|
+
} from "./lib/referral-report.js";
|
|
813
|
+
export {
|
|
814
|
+
getReferralRuntime,
|
|
815
|
+
type ReferralRuntime,
|
|
816
|
+
resetReferralRuntime,
|
|
817
|
+
setReferralRuntime,
|
|
818
|
+
} from "./lib/referral-runtime.js";
|
|
819
|
+
// --- Referral store (the ONE writer of referral_touches; NEVER emits) ---
|
|
820
|
+
// The store returns mutation FACTS; the intent layer emits `referral.*`
|
|
821
|
+
// outbound and re-ingests for journeys, side by side (PRD 05 §6). Pinned by
|
|
822
|
+
// `lib/referrals-no-emit.test.ts`.
|
|
823
|
+
export {
|
|
824
|
+
type BindTouchesInput,
|
|
825
|
+
type BindTouchesResult,
|
|
826
|
+
bindTouches,
|
|
827
|
+
type ListTouchesInput,
|
|
828
|
+
listTouchesForReferee,
|
|
829
|
+
listTouchesForReferrer,
|
|
830
|
+
type QualifyTouchInput,
|
|
831
|
+
type QualifyTouchResult,
|
|
832
|
+
qualifyTouch,
|
|
833
|
+
REFERRAL_IDEMPOTENCY_PROPERTY,
|
|
834
|
+
REFERRAL_VETO_REASON_PROPERTY,
|
|
835
|
+
type RecordTouchInput,
|
|
836
|
+
type RecordTouchResult,
|
|
837
|
+
type ReferralRejectReason,
|
|
838
|
+
type ReferralTouchRecord,
|
|
839
|
+
type ReferralTouchSource,
|
|
840
|
+
type ReferralTouchStatus,
|
|
841
|
+
type RejectTouchInput,
|
|
842
|
+
type RejectTouchResult,
|
|
843
|
+
recordTouch,
|
|
844
|
+
rejectTouch,
|
|
845
|
+
} from "./lib/referrals.js";
|
|
768
846
|
// --- Refinement (`refineContact` — a STANDALONE import, never on `ctx`) ---
|
|
769
847
|
export {
|
|
770
848
|
REFINE_EVENT,
|
|
@@ -45,16 +45,33 @@ export interface LogTransitionArgs {
|
|
|
45
45
|
* Do NOT attempt to dedupe log rows.
|
|
46
46
|
*/
|
|
47
47
|
export function logTransition(args: LogTransitionArgs): void {
|
|
48
|
+
const { db, ...row } = args;
|
|
49
|
+
logTransitions(db, [row]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* `logTransition` for many states at once: one multi-row insert, with the same
|
|
54
|
+
* fire-and-forget, never-throws contract. Used where a single event moves a
|
|
55
|
+
* batch of states (an exit fan-out), so the log costs one statement instead of
|
|
56
|
+
* one per state.
|
|
57
|
+
*/
|
|
58
|
+
export function logTransitions(
|
|
59
|
+
db: Database,
|
|
60
|
+
rows: ReadonlyArray<Omit<LogTransitionArgs, "db">>,
|
|
61
|
+
): void {
|
|
62
|
+
if (rows.length === 0) return;
|
|
48
63
|
try {
|
|
49
|
-
void
|
|
64
|
+
void db
|
|
50
65
|
.insert(journeyLogs)
|
|
51
|
-
.values(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
.values(
|
|
67
|
+
rows.map((row) => ({
|
|
68
|
+
journeyStateId: row.journeyStateId,
|
|
69
|
+
fromNodeId: row.from ?? null,
|
|
70
|
+
toNodeId: row.to ?? null,
|
|
71
|
+
action: row.action,
|
|
72
|
+
detail: row.detail ?? null,
|
|
73
|
+
})),
|
|
74
|
+
)
|
|
58
75
|
.catch(() => {
|
|
59
76
|
// best-effort timeline write — never surface into journey execution
|
|
60
77
|
});
|
package/src/lib/contacts.ts
CHANGED
|
@@ -46,7 +46,7 @@ import { createLogger } from "./logger.js";
|
|
|
46
46
|
* stays logger-free. */
|
|
47
47
|
const logger = createLogger(process.env.LOG_LEVEL);
|
|
48
48
|
|
|
49
|
-
const UUID_REGEX =
|
|
49
|
+
export const UUID_REGEX =
|
|
50
50
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -434,6 +434,38 @@ export function serializeContact(
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
+
/**
|
|
438
|
+
* The BROWSER-safe projection of a contact (`GET /v1/contacts/me`). Applies the
|
|
439
|
+
* operator allowlist: only EXACT `publicProperties` keys survive, and `email`
|
|
440
|
+
* is present only when `exposeEmail` is on. A missing row projects to
|
|
441
|
+
* `{ identified: false, traits: {} }` — the route never 404s, so the absence of
|
|
442
|
+
* a contact is indistinguishable from an empty allowlist.
|
|
443
|
+
*
|
|
444
|
+
* `identified` means the row carries a real identity (`externalId` or `email`);
|
|
445
|
+
* an anonymous-only row reads its own traits but is NOT identified.
|
|
446
|
+
*/
|
|
447
|
+
export function projectPublicContact(
|
|
448
|
+
row: ContactRow | null | undefined,
|
|
449
|
+
config: { publicProperties: string[]; exposeEmail: boolean },
|
|
450
|
+
): {
|
|
451
|
+
identified: boolean;
|
|
452
|
+
traits: Record<string, unknown>;
|
|
453
|
+
email?: string | null;
|
|
454
|
+
} {
|
|
455
|
+
const props = (row?.properties ?? {}) as Record<string, unknown>;
|
|
456
|
+
const traits: Record<string, unknown> = {};
|
|
457
|
+
if (row) {
|
|
458
|
+
for (const key of config.publicProperties) {
|
|
459
|
+
if (Object.hasOwn(props, key)) traits[key] = props[key];
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return {
|
|
463
|
+
identified: Boolean(row && (row.externalId || row.email)),
|
|
464
|
+
traits,
|
|
465
|
+
...(config.exposeEmail ? { email: row?.email ?? null } : {}),
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
437
469
|
export function serializePrefs(row: typeof emailPreferences.$inferSelect) {
|
|
438
470
|
return {
|
|
439
471
|
id: row.id,
|
|
@@ -1500,6 +1532,44 @@ async function resolveContactShared(
|
|
|
1500
1532
|
// Only the singleton-COLLISION soft-unlinks are here. The repoint that moves
|
|
1501
1533
|
// the loser's surviving links to the survivor is deliberately silent — see
|
|
1502
1534
|
// the note on step 4 of `foldLinkedAccounts`.
|
|
1535
|
+
// REFERRAL BIND (PRD 05 stage 3), post-commit for the same reason the
|
|
1536
|
+
// account-link emit above is: `bindReferral` announces `referral.bound` on
|
|
1537
|
+
// both planes, and a resolve that rolled back must never have announced a
|
|
1538
|
+
// bind that never happened. This is the ONE bind site precisely because
|
|
1539
|
+
// `resolveContactShared` is the ONE owner of every `resolveOrCreateContact`
|
|
1540
|
+
// / `resolveContactNoCreate` call.
|
|
1541
|
+
//
|
|
1542
|
+
// The keys scanned are every key this resolve just made this contact's:
|
|
1543
|
+
// the resolved canonical key (which the create arm's `adoptOrphanHistory`
|
|
1544
|
+
// just stamped history under), the anon key supplied by the identify call,
|
|
1545
|
+
// and any key a merge absorbed. `bindTouches` is a no-op for a key with no
|
|
1546
|
+
// unbound touch, so the extra scans cost one indexed lookup on a partial
|
|
1547
|
+
// index built for exactly this query.
|
|
1548
|
+
if (resolved.id !== null) {
|
|
1549
|
+
const boundContactId = resolved.id;
|
|
1550
|
+
const keys = new Set<string>([resolved.resolvedKey]);
|
|
1551
|
+
if (opts.anonymousId) keys.add(opts.anonymousId);
|
|
1552
|
+
for (const key of resolved.mergedKeys ?? []) keys.add(key);
|
|
1553
|
+
// AWAITED, not fire-and-forget: the same ingest that identifies the
|
|
1554
|
+
// referee may ALSO be the qualify event (a `signup` carrying the email),
|
|
1555
|
+
// and `ingestEvent`'s qualify hook runs after this resolve and reads
|
|
1556
|
+
// `status = 'bound'`. A detached bind would lose that race and the touch
|
|
1557
|
+
// would sit at `touched` until the next qualifying event. Errors are still
|
|
1558
|
+
// swallowed with an attributed log: an identify must never fail because a
|
|
1559
|
+
// referral edge could not be stamped.
|
|
1560
|
+
try {
|
|
1561
|
+
const { bindReferral } = await import("./referral-intent.js");
|
|
1562
|
+
for (const refereeKey of keys) {
|
|
1563
|
+
await bindReferral({ db, refereeKey, contactId: boundContactId });
|
|
1564
|
+
}
|
|
1565
|
+
} catch (error: unknown) {
|
|
1566
|
+
logger.warn("referral bind failed", {
|
|
1567
|
+
contactId: boundContactId,
|
|
1568
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1503
1573
|
if (resolved.linkUnlinks && resolved.linkUnlinks.length > 0) {
|
|
1504
1574
|
emitAccountUnlinked(db, resolved.linkUnlinks);
|
|
1505
1575
|
// THE JOURNEY PLANE, beside the outbound one (PRD 08 T5). TWO DIFFERENT
|
|
@@ -2811,12 +2881,23 @@ async function foldEmailPreferences(
|
|
|
2811
2881
|
* pref-fold), stamp-only writes.
|
|
2812
2882
|
*
|
|
2813
2883
|
* Idempotent: a second run finds `contact_id` already set and matches nothing.
|
|
2884
|
+
*
|
|
2885
|
+
* GATED (PRD 09): every warm resolve calls this for the contact's own key,
|
|
2886
|
+
* and almost always there is nothing to adopt. One existence probe
|
|
2887
|
+
* ({@link hasOrphanHistory}) decides first; when it finds no orphan row the
|
|
2888
|
+
* eight statements below are skipped. That is a pure cost cut, not a
|
|
2889
|
+
* behaviour change: each statement below matches only rows with
|
|
2890
|
+
* `user_id = fromKey AND contact_id IS NULL` (the folds' `orphansOnly` loser
|
|
2891
|
+
* scope), so when no such row exists in any of the five tables every one of
|
|
2892
|
+
* them is a no-op.
|
|
2814
2893
|
*/
|
|
2815
2894
|
async function adoptOrphanHistory(
|
|
2816
2895
|
tx: Tx,
|
|
2817
2896
|
fromKey: string,
|
|
2818
2897
|
row: ContactRow,
|
|
2819
2898
|
): Promise<void> {
|
|
2899
|
+
if (!(await hasOrphanHistory(tx, fromKey))) return;
|
|
2900
|
+
|
|
2820
2901
|
const ownKey = contactKey(row);
|
|
2821
2902
|
|
|
2822
2903
|
// user_events + email_sends: no unique constraint involved — plain stamps.
|
|
@@ -2852,6 +2933,41 @@ async function adoptOrphanHistory(
|
|
|
2852
2933
|
// add a test instead if you doubt it.
|
|
2853
2934
|
}
|
|
2854
2935
|
|
|
2936
|
+
/**
|
|
2937
|
+
* The orphan-adoption gate (PRD 09): ONE statement answering "does any of the
|
|
2938
|
+
* five history tables hold a row under `fromKey` that no contact owns?".
|
|
2939
|
+
*
|
|
2940
|
+
* The predicate is exactly the loser scope {@link adoptOrphanHistory}'s
|
|
2941
|
+
* statements use (`user_id = fromKey AND contact_id IS NULL`), deliberately
|
|
2942
|
+
* WITHOUT their `deleted_at` / `status` refinements: the probe only has to be
|
|
2943
|
+
* a superset, so a false positive costs the old eight statements and a false
|
|
2944
|
+
* negative is impossible.
|
|
2945
|
+
*
|
|
2946
|
+
* Every leg is indexed: `user_events` / `email_sends` through their partial
|
|
2947
|
+
* `*_orphan_user_id_idx` (migration 0075, which holds ONLY contactless rows,
|
|
2948
|
+
* so a known contact's probe never walks its history), the other three
|
|
2949
|
+
* through their existing `user_id`-leading indexes. The uncorrelated EXISTS
|
|
2950
|
+
* subqueries are init-plans Postgres evaluates lazily left to right, so the
|
|
2951
|
+
* OR stops at the first leg that finds a row.
|
|
2952
|
+
*/
|
|
2953
|
+
async function hasOrphanHistory(tx: Tx, fromKey: string): Promise<boolean> {
|
|
2954
|
+
const tables = [
|
|
2955
|
+
userEvents,
|
|
2956
|
+
emailSends,
|
|
2957
|
+
journeyStates,
|
|
2958
|
+
bucketMemberships,
|
|
2959
|
+
emailPreferences,
|
|
2960
|
+
] as const;
|
|
2961
|
+
const legs = tables.map(
|
|
2962
|
+
(table) =>
|
|
2963
|
+
sql`exists (select 1 from ${table} where ${table.userId} = ${fromKey} and ${table.contactId} is null)`,
|
|
2964
|
+
);
|
|
2965
|
+
const rows = (await tx.execute(
|
|
2966
|
+
sql`select (${sql.join(legs, sql` or `)}) as "found"`,
|
|
2967
|
+
)) as unknown as Array<{ found: boolean }>;
|
|
2968
|
+
return rows[0]?.found === true;
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2855
2971
|
/** RECORD a contact_aliases row per loser key → survivor (reason 'merge'). */
|
|
2856
2972
|
async function recordMergeAliases(
|
|
2857
2973
|
tx: Tx,
|
|
@@ -52,6 +52,14 @@ export interface SendTrackedEmailOptions<
|
|
|
52
52
|
* transactional sends.
|
|
53
53
|
*/
|
|
54
54
|
campaignId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The recipient's `contacts.id` when the caller already holds it fresh (a
|
|
57
|
+
* campaign resolver that joined `contacts`). The mailer then stamps
|
|
58
|
+
* `email_sends.contact_id` with it instead of resolving `userId` again. Leave
|
|
59
|
+
* it unset unless the id was read in the same unit of work: a journey's
|
|
60
|
+
* enrollment-time id can go stale across a merge.
|
|
61
|
+
*/
|
|
62
|
+
contactId?: string;
|
|
55
63
|
/** Denormalized recipient identity, persisted on the email_sends row for reporting. */
|
|
56
64
|
userId?: string;
|
|
57
65
|
userEmail?: string;
|
|
@@ -183,6 +191,8 @@ export interface EmailServiceSendOptions<
|
|
|
183
191
|
journeyStateId?: string;
|
|
184
192
|
/** Campaign identity for campaign-dispatched sends (see SendTrackedEmailOptions). */
|
|
185
193
|
campaignId?: string;
|
|
194
|
+
/** A fresh `contacts.id` for the recipient (see SendTrackedEmailOptions). */
|
|
195
|
+
contactId?: string;
|
|
186
196
|
/** Denormalized recipient identity, persisted on the email_sends row for reporting. */
|
|
187
197
|
userId?: string;
|
|
188
198
|
userEmail?: string;
|
package/src/lib/ingestion.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { and, eq, inArray, isNull } from "drizzle-orm";
|
|
18
18
|
import { checkBucketMembership } from "../buckets/check-membership.js";
|
|
19
19
|
import { BLUEPRINT_RUN_EVENT } from "../journeys/constants.js";
|
|
20
|
-
import {
|
|
20
|
+
import { logTransitions } from "../journeys/journey-log.js";
|
|
21
21
|
import {
|
|
22
22
|
logResidualTwins,
|
|
23
23
|
mergeAnalyticsIdentities,
|
|
@@ -802,6 +802,38 @@ export async function ingestEvent(opts: {
|
|
|
802
802
|
}
|
|
803
803
|
: null;
|
|
804
804
|
|
|
805
|
+
// (5b-referral) REFERRAL QUALIFY (PRD 05 §6 qualify). Does THIS event
|
|
806
|
+
// promote one of this contact's BOUND touches? Cheap on a miss (one map
|
|
807
|
+
// lookup keyed by `qualify.event`), so it runs on every ingested event, and
|
|
808
|
+
// entirely inert with no referrals registered.
|
|
809
|
+
//
|
|
810
|
+
// Gated on `contactId !== null` for the same reason site 5 is: a touch can
|
|
811
|
+
// only qualify once it is BOUND, and a bound touch by definition has a
|
|
812
|
+
// referee CONTACT — a refused resolve has no contact to look one up for.
|
|
813
|
+
// Best-effort: the event is already durable.
|
|
814
|
+
if (insertedRow && contactId !== null) {
|
|
815
|
+
try {
|
|
816
|
+
const { qualifyReferralsForEvent } = await import("./referral-intent.js");
|
|
817
|
+
await qualifyReferralsForEvent({
|
|
818
|
+
handles: {
|
|
819
|
+
db,
|
|
820
|
+
hatchet,
|
|
821
|
+
registry,
|
|
822
|
+
logger,
|
|
823
|
+
...(opts.analytics ? { analytics: opts.analytics } : {}),
|
|
824
|
+
},
|
|
825
|
+
event: event.event,
|
|
826
|
+
eventProperties: event.eventProperties,
|
|
827
|
+
contactId,
|
|
828
|
+
});
|
|
829
|
+
} catch (err) {
|
|
830
|
+
logger.warn("referral qualify evaluation failed", {
|
|
831
|
+
event: event.event,
|
|
832
|
+
error: err instanceof Error ? err.message : String(err),
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
805
837
|
// (5c) Conversion-point evaluation (plan §5.1) — the unique
|
|
806
838
|
// (definition, event) index makes any replay a no-op.
|
|
807
839
|
//
|
|
@@ -869,6 +901,35 @@ export async function ingestEvent(opts: {
|
|
|
869
901
|
error: err instanceof Error ? err.message : String(err),
|
|
870
902
|
});
|
|
871
903
|
}
|
|
904
|
+
|
|
905
|
+
// THE REFERRAL TREE (PRD 05 §6 convert). Beside the attribution
|
|
906
|
+
// ledger, never inside it: the ledger answers "which touchpoints get
|
|
907
|
+
// credit", the tree answers "which PEOPLE get told". Announces
|
|
908
|
+
// `referral.converted` to the direct referrer and
|
|
909
|
+
// `referral.tree_converted` to each ancestor to depth 5, with `level`
|
|
910
|
+
// as a FACT on the event so a reward journey filters on it. Inert
|
|
911
|
+
// with no referrals registered; isolated so a tree failure can never
|
|
912
|
+
// cost a conversion.
|
|
913
|
+
try {
|
|
914
|
+
const { convertReferral } = await import("./referral-intent.js");
|
|
915
|
+
await convertReferral({
|
|
916
|
+
db,
|
|
917
|
+
hatchet,
|
|
918
|
+
registry,
|
|
919
|
+
logger,
|
|
920
|
+
...(opts.analytics ? { analytics: opts.analytics } : {}),
|
|
921
|
+
contactId,
|
|
922
|
+
conversionId: firedConversion.conversionId,
|
|
923
|
+
value: firedConversion.value ?? null,
|
|
924
|
+
currency: firedConversion.currency ?? null,
|
|
925
|
+
occurredAt: insertedRow.occurredAt,
|
|
926
|
+
});
|
|
927
|
+
} catch (err) {
|
|
928
|
+
logger.warn("referral conversion walk failed", {
|
|
929
|
+
conversionId: firedConversion.conversionId,
|
|
930
|
+
error: err instanceof Error ? err.message : String(err),
|
|
931
|
+
});
|
|
932
|
+
}
|
|
872
933
|
}
|
|
873
934
|
} catch (err) {
|
|
874
935
|
logger.warn("Conversion evaluation failed", {
|
|
@@ -1013,16 +1074,26 @@ async function checkExits(
|
|
|
1013
1074
|
): Promise<ExitResult[]> {
|
|
1014
1075
|
const results: ExitResult[] = [];
|
|
1015
1076
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
)
|
|
1025
|
-
|
|
1077
|
+
// Only the three columns the exit decision and the cancel need: a state row
|
|
1078
|
+
// carries the journey's whole `context` jsonb, and this read runs on every
|
|
1079
|
+
// ingest for every active enrollment the subject has.
|
|
1080
|
+
const activeStates = await db
|
|
1081
|
+
.select({
|
|
1082
|
+
id: journeyStates.id,
|
|
1083
|
+
journeyId: journeyStates.journeyId,
|
|
1084
|
+
hatchetRunId: journeyStates.hatchetRunId,
|
|
1085
|
+
})
|
|
1086
|
+
.from(journeyStates)
|
|
1087
|
+
.where(
|
|
1088
|
+
and(
|
|
1089
|
+
bySubject(journeyStates, {
|
|
1090
|
+
contactId: event.contactId,
|
|
1091
|
+
userKey: event.userId,
|
|
1092
|
+
}),
|
|
1093
|
+
inArray(journeyStates.status, ["active", "waiting"]),
|
|
1094
|
+
isNull(journeyStates.deletedAt),
|
|
1095
|
+
),
|
|
1096
|
+
);
|
|
1026
1097
|
|
|
1027
1098
|
// Blueprint enrollments share journeyStates but are NOT in the code-journey
|
|
1028
1099
|
// registry — their exitOn lives on the journey_blueprints row (spec §4).
|
|
@@ -1095,17 +1166,18 @@ async function checkExits(
|
|
|
1095
1166
|
})
|
|
1096
1167
|
.where(inArray(journeyStates.id, statesToExit));
|
|
1097
1168
|
|
|
1098
|
-
// Fire-and-forget EXIT transition logs
|
|
1099
|
-
// already best-effort around the hatchet
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1169
|
+
// Fire-and-forget EXIT transition logs, one insert for the batch
|
|
1170
|
+
// (best-effort; the exit path is already best-effort around the hatchet
|
|
1171
|
+
// cancel below). Never throws.
|
|
1172
|
+
logTransitions(
|
|
1173
|
+
db,
|
|
1174
|
+
statesToExit.map((id) => ({
|
|
1103
1175
|
journeyStateId: id,
|
|
1104
1176
|
from: null,
|
|
1105
1177
|
to: "end-exited",
|
|
1106
|
-
action: "exited",
|
|
1107
|
-
})
|
|
1108
|
-
|
|
1178
|
+
action: "exited" as const,
|
|
1179
|
+
})),
|
|
1180
|
+
);
|
|
1109
1181
|
|
|
1110
1182
|
// Cancel the live durable runs so a journey suspended in a sleep or
|
|
1111
1183
|
// `waitForEvent` can't resume and fire after it has exited. Best-effort: a
|