@aglyn/plugins-outreach 1.0.0-beta.220 → 1.0.0-beta.222
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/package.json +14 -14
- package/src/lib/components/do-not-contact-domains.d.ts +6 -2
- package/src/lib/components/do-not-contact-domains.js +73 -11
- package/src/lib/components/do-not-contact-domains.js.map +1 -1
- package/src/lib/components/enrollments-table.d.ts +6 -0
- package/src/lib/components/enrollments-table.js +77 -4
- package/src/lib/components/enrollments-table.js.map +1 -1
- package/src/lib/components/sequence-detail.js +3 -1
- package/src/lib/components/sequence-detail.js.map +1 -1
- package/src/lib/components/sequence-report-card.js +7 -3
- package/src/lib/components/sequence-report-card.js.map +1 -1
- package/src/lib/components/use-outreach-crm.d.ts +18 -15
- package/src/lib/components/use-outreach-crm.js +118 -87
- package/src/lib/components/use-outreach-crm.js.map +1 -1
- package/src/lib/components/use-outreach-data.d.ts +2 -2
- package/src/lib/components/use-outreach-data.js.map +1 -1
- package/src/lib/constants/transfer-resources.d.ts +33 -0
- package/src/lib/constants/transfer-resources.js +38 -0
- package/src/lib/constants/transfer-resources.js.map +1 -0
- package/src/lib/declarations.console-server.d.ts +7 -1
- package/src/lib/declarations.console-server.js +66 -1
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/engine/click-tracking.js +1 -1
- package/src/lib/engine/click-tracking.js.map +1 -1
- package/src/lib/engine/ip-range.d.ts +26 -0
- package/src/lib/engine/ip-range.js +78 -0
- package/src/lib/engine/ip-range.js.map +1 -0
- package/src/lib/engine/open-source.d.ts +24 -0
- package/src/lib/engine/open-source.js +130 -0
- package/src/lib/engine/open-source.js.map +1 -0
- package/src/lib/engine/open-tracking.d.ts +15 -2
- package/src/lib/engine/open-tracking.js +59 -16
- package/src/lib/engine/open-tracking.js.map +1 -1
- package/src/lib/engine/outreach-access.d.ts +47 -0
- package/src/lib/engine/outreach-access.js +56 -0
- package/src/lib/engine/outreach-access.js.map +1 -0
- package/src/lib/enrollment/enroll-people.d.ts +10 -10
- package/src/lib/enrollment/enroll-people.js +30 -25
- package/src/lib/enrollment/enroll-people.js.map +1 -1
- package/src/lib/enrollment/gate-lookups.js +30 -15
- package/src/lib/enrollment/gate-lookups.js.map +1 -1
- package/src/lib/enrollment/message-templates.d.ts +24 -0
- package/src/lib/enrollment/message-templates.js +35 -0
- package/src/lib/enrollment/message-templates.js.map +1 -0
- package/src/lib/model/enrollment-engagement.d.ts +16 -0
- package/src/lib/model/enrollment-engagement.js +16 -0
- package/src/lib/model/enrollment-engagement.js.map +1 -1
- package/src/lib/model/enrollment-history.d.ts +8 -1
- package/src/lib/model/enrollment-history.js +17 -5
- package/src/lib/model/enrollment-history.js.map +1 -1
- package/src/lib/model/enrollment-timeline.d.ts +3 -0
- package/src/lib/model/enrollment-timeline.js +15 -4
- package/src/lib/model/enrollment-timeline.js.map +1 -1
- package/src/lib/model/outreach.types.d.ts +12 -3
- package/src/lib/model/outreach.types.js +12 -1
- package/src/lib/model/outreach.types.js.map +1 -1
- package/src/lib/model/sequence-report.d.ts +14 -7
- package/src/lib/model/sequence-report.js +12 -8
- package/src/lib/model/sequence-report.js.map +1 -1
- package/src/lib/plugin.js +18 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/routes/curate-routes.js +4 -6
- package/src/lib/routes/curate-routes.js.map +1 -1
- package/src/lib/routes/enroll-routes.d.ts +0 -12
- package/src/lib/routes/enroll-routes.js +52 -92
- package/src/lib/routes/enroll-routes.js.map +1 -1
- package/src/lib/routes/platform-deps.d.ts +4 -16
- package/src/lib/routes/platform-deps.js +5 -25
- package/src/lib/routes/platform-deps.js.map +1 -1
- package/src/lib/routes/preview-routes.js +25 -13
- package/src/lib/routes/preview-routes.js.map +1 -1
- package/src/lib/routes/register-routes.js +7 -5
- package/src/lib/routes/register-routes.js.map +1 -1
- package/src/lib/routes/route-gate.js +6 -17
- package/src/lib/routes/route-gate.js.map +1 -1
- package/src/lib/routes/sequence-routes.d.ts +46 -0
- package/src/lib/routes/sequence-routes.js +155 -63
- package/src/lib/routes/sequence-routes.js.map +1 -1
- package/src/lib/runtime/click-events.js +8 -8
- package/src/lib/runtime/click-events.js.map +1 -1
- package/src/lib/runtime/click-route.js +5 -2
- package/src/lib/runtime/click-route.js.map +1 -1
- package/src/lib/runtime/lead-records.d.ts +18 -10
- package/src/lib/runtime/lead-records.js +14 -60
- package/src/lib/runtime/lead-records.js.map +1 -1
- package/src/lib/runtime/open-events.d.ts +8 -0
- package/src/lib/runtime/open-events.js +10 -3
- package/src/lib/runtime/open-events.js.map +1 -1
- package/src/lib/runtime/platform-runtime-deps.d.ts +9 -5
- package/src/lib/runtime/platform-runtime-deps.js +31 -24
- package/src/lib/runtime/platform-runtime-deps.js.map +1 -1
- package/src/lib/runtime/send-job.js +20 -17
- package/src/lib/runtime/send-job.js.map +1 -1
- package/src/lib/runtime/sync-job.js +10 -5
- package/src/lib/runtime/sync-job.js.map +1 -1
- package/src/lib/storage/do-not-contact-store.d.ts +8 -0
- package/src/lib/storage/do-not-contact-store.js +13 -0
- package/src/lib/storage/do-not-contact-store.js.map +1 -1
- package/src/lib/testing/stand-in-record-system.d.ts +54 -0
- package/src/lib/testing/stand-in-record-system.js +243 -0
- package/src/lib/testing/stand-in-record-system.js.map +1 -0
- package/src/lib/transfer/do-not-contact-transfer.d.ts +129 -0
- package/src/lib/transfer/do-not-contact-transfer.js +801 -0
- package/src/lib/transfer/do-not-contact-transfer.js.map +1 -0
- package/src/lib/transfer/plan-gate.d.ts +25 -0
- package/src/lib/transfer/plan-gate.js +35 -0
- package/src/lib/transfer/plan-gate.js.map +1 -0
- package/src/lib/transfer/platform-transfer-deps.d.ts +24 -0
- package/src/lib/transfer/platform-transfer-deps.js +39 -0
- package/src/lib/transfer/platform-transfer-deps.js.map +1 -0
- package/src/lib/transfer/sequences-package.d.ts +48 -0
- package/src/lib/transfer/sequences-package.js +93 -0
- package/src/lib/transfer/sequences-package.js.map +1 -0
- package/src/lib/transfer/sequences-package.server.d.ts +31 -0
- package/src/lib/transfer/sequences-package.server.js +207 -0
- package/src/lib/transfer/sequences-package.server.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/model/outreach.types.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * THE OUTREACH DOCUMENT MODEL (AGL-2974).\n *\n * One file both halves import — the console reads these documents, the server\n * routes write them — so a field is spelled once. Client-safe: types and\n * constants only, nothing that reaches Firestore.\n *\n * EVERY DOCUMENT HERE IS SERVER-WRITTEN. The Firestore rules let an\n * org-wide member holding `outreach.use` READ the org collections on a\n * workspace that carries `features.outreach`, and refuse every client write,\n * because these documents are the sending engine's state: a client that\n * could write a mailbox could lift its daily cap, and one that could write\n * an enrollment could send a step twice. The credential collection is closed\n * to clients entirely.\n *\n * Lean on purpose. Each type carries what the mailbox and sequence work is\n * known to need and nothing speculative; a field is added where the code\n * that reads it lands. Times are epoch milliseconds throughout, the unit\n * `nextDueAtMs` has to be compared in.\n */\n\nimport type { OutreachClickMachineReason } from '../engine/click-tracking'\nimport type { OutreachOpenMachineReason } from '../engine/open-tracking'\nimport type { OutreachGatewayDayCounts, OutreachMailGateway } from '../engine/mail-gateway'\n\n/**\n * Where Outreach keeps its records.\n *\n * Eight collections under the organization, and two at the top level. The\n * org-scoped ones are erased with the org, whose erasure deletes the whole\n * `orgs/{orgId}` tree. The top-level ones — credentials, and the short\n * tracking links (AGL-3297) — are keyed by an `orgId` FIELD that a\n * path-scoped delete of `orgs/{orgId}` cannot see: the org erasure sweeps\n * them by that field\n * (`libs/tenant/data/admin/src/lib/server/erase.ts` names it as a literal,\n * which the boundary forces, and `outreach.types.spec.ts` holds the two\n * spellings together, along with the rules').\n */\nexport const OUTREACH_COLLECTIONS = {\n /** `orgs/{orgId}/outreachMailboxes/{mailboxId}` — a connected mailbox. */\n mailboxes: 'outreachMailboxes',\n /** `orgs/{orgId}/outreachSequences/{sequenceId}` — the steps to send. */\n sequences: 'outreachSequences',\n /** `orgs/{orgId}/outreachEnrollments/{enrollmentId}` — one person in one sequence. */\n enrollments: 'outreachEnrollments',\n /**\n * `orgs/{orgId}/outreachSettings/{settingsId}` — the organization's own\n * Outreach settings, one document per concern. `compliance` holds who\n * every email says sent it and the countries Outreach may send to.\n */\n settings: 'outreachSettings',\n /**\n * `orgs/{orgId}/outreachDoNotContact/{key}` — the addresses Outreach never\n * emails for this organization, keyed by `outreachDoNotContactKey`.\n */\n doNotContact: 'outreachDoNotContact',\n /**\n * `orgs/{orgId}/outreachDoNotContactDomains/{domain}` — the domains\n * Outreach never emails for this organization (AGL-3244), keyed by the\n * domain itself: a domain names a company, not a person.\n */\n doNotContactDomains: 'outreachDoNotContactDomains',\n /**\n * `orgs/{orgId}/outreachDomainIntel/{domain}` — a recipient domain's MX\n * as this organization first cached it (AGL-3326). Neither read nor\n * written any more: the platform-wide `mailDomains` cache replaced it\n * (AGL-3328), and it is retired with its rule once that has shipped.\n */\n domainIntel: 'outreachDomainIntel',\n /**\n * `orgs/{orgId}/outreachGatewayStats/{gateway}` — the organization's\n * ledger per mail gateway as first written (AGL-3326), with no sending\n * domain. READ THROUGH, never written: its last thirty days are summed\n * into the sending-domain ledger's standing\n * (`orgs/{orgId}/mailGatewayLedger`, AGL-3328) until they age out, and it\n * is retired with its rule after that.\n */\n gatewayStats: 'outreachGatewayStats',\n /**\n * `outreachMailboxCredentials/{mailboxId}` — the provider grant behind a\n * mailbox. TOP-LEVEL and closed to every client, staff included, so the\n * token material never shares a readable path with the mailbox it serves.\n */\n mailboxCredentials: 'outreachMailboxCredentials',\n /**\n * `outreachLinks/{linkId}` — what one short tracking link in a sent email\n * points at (AGL-3297): the organization, the enrollment, the step, the\n * link's index and the destination. TOP-LEVEL so the link's id alone\n * resolves it with one read, keyed by an `orgId` FIELD that the org\n * erasure sweeps, and closed to every client.\n */\n links: 'outreachLinks',\n} as const\n\n/** The org-scoped collections, by their {@link OUTREACH_COLLECTIONS} key. */\nexport type OutreachOrgCollection = Exclude<\n keyof typeof OUTREACH_COLLECTIONS,\n 'mailboxCredentials' | 'links'\n>\n\n/** `orgs/{orgId}/<collection>` for one of the org-scoped collections. */\nexport function outreachOrgCollectionPath(\n orgId: string,\n collection: OutreachOrgCollection,\n): string {\n return `orgs/${orgId}/${OUTREACH_COLLECTIONS[collection]}`\n}\n\n/** Stamped by the server on every write. */\nexport interface OutreachTimestamps {\n createdAtMs: number\n updatedAtMs: number\n}\n\n/** The mail providers a mailbox can be connected through. */\nexport const OUTREACH_MAILBOX_PROVIDERS = ['google'] as const\nexport type OutreachMailboxProvider =\n (typeof OUTREACH_MAILBOX_PROVIDERS)[number]\n\n/**\n * Where a mailbox stands.\n *\n * - `connected` — the grant works and the mailbox may send.\n * - `paused` — a member stopped it; enrollments on it wait.\n * - `reconnect_required` — the provider refused the grant (revoked, expired,\n * password changed); nothing sends until the rep connects it again.\n * - `disconnected` — a member removed it; its credential is gone.\n */\nexport const OUTREACH_MAILBOX_STATUSES = [\n 'connected',\n 'paused',\n 'reconnect_required',\n 'disconnected',\n] as const\nexport type OutreachMailboxStatus = (typeof OUTREACH_MAILBOX_STATUSES)[number]\n\n/**\n * The hours a mailbox sends in, in its own {@link OutreachMailbox.timezone}.\n * A step that comes due outside the window waits for the next opening.\n */\nexport interface OutreachSendWindow {\n /** Days of the week it sends on, `0` Sunday through `6` Saturday. */\n days: number[]\n /** Minutes after local midnight the window opens, inclusive. */\n startMinute: number\n /** Minutes after local midnight the window closes, exclusive. */\n endMinute: number\n}\n\n/**\n * One mailbox-local day's sending, as the health panel sums it (AGL-2978).\n */\nexport interface OutreachMailboxDailyHealth {\n sent: number\n bounces: number\n replies: number\n /**\n * Tests of a sequence step sent to a member (AGL-3325). Counted apart from\n * `sent`: a test is a real Gmail send, so it spends the account's own\n * limits, but it is not a person emailed and never moves the daily cap.\n */\n tests?: number\n}\n\n/**\n * The counters a mailbox's sending is judged by.\n *\n * `sentToday` is what `dailyCap` refuses against, and it belongs to one\n * mailbox-local day — `sentOnDay` — so a counter from yesterday is read as\n * zero rather than as today's spend.\n */\nexport interface OutreachMailboxHealth {\n sentToday: number\n /** The local day (`YYYY-MM-DD` in the mailbox's timezone) `sentToday` counts. */\n sentOnDay: string | null\n /** Hard bounces on mail this mailbox sent. */\n bounces: number\n /** Replies detected on Outreach threads. */\n replies: number\n lastSentAtMs: number | null\n /** The last provider error, kept until a later send succeeds. */\n lastErrorAtMs: number | null\n lastErrorCode: string | null\n /**\n * Per mailbox-local day (`YYYY-MM-DD`), the sends, bounces and replies\n * counted on it (AGL-2978). The Mailboxes panel shows the last seven days\n * summed; the sending runtime increments the day it counts on and may drop\n * days older than a week. Absent, or empty, until the first send.\n */\n daily?: Record<string, OutreachMailboxDailyHealth>\n /**\n * The mailbox's most recent sends, newest last, at most\n * `OUTREACH_BOUNCE_RATE_WINDOW_SENDS` of them, each marked when a hard\n * bounce came back for it (AGL-2981): the window the bounce-rate pause is\n * judged over. A send is named by a digest of its `Message-ID`, never by\n * its recipient.\n */\n recentSends?: OutreachRecentSend[]\n /** When a reply last called this mailbox's email spam (AGL-2981). */\n lastComplaintAtMs?: number | null\n}\n\n/** One send in {@link OutreachMailboxHealth.recentSends}. */\nexport interface OutreachRecentSend {\n /** A digest of the send's `Message-ID`: what a bounce is matched to. */\n id: string\n atMs: number\n bounced: boolean\n}\n\n/** Why a mailbox paused itself (AGL-2981): the engine's health decision, kept. */\nexport interface OutreachMailboxAutoPause {\n /**\n * `bounce_rate` is what the window rule wrote before AGL-3326 changed it\n * from a percentage to a count; a stored pause keeps the reason it was\n * written with, and the card shows `message` either way.\n */\n reason: 'bounces_today' | 'bounces_in_window' | 'bounce_rate' | 'complaint'\n /** The sentence the mailbox's card shows. */\n message: string\n atMs: number\n /** For a complaint, when resuming stops being premature; `null` otherwise. */\n untilMs: number | null\n}\n\n/** Where a mailbox's reply and bounce sync has read to (AGL-2981). */\nexport interface OutreachMailboxSync {\n /** Everything received before this was read by an earlier run, epoch ms. */\n throughMs: number\n /** Gmail ids of messages outside any enrollment's thread already handled. */\n handledMessageIds: string[]\n}\n\n/**\n * An address a connected Google account may send as, which Gmail has\n * verified — its own address, or an alias whose ownership Gmail confirmed\n * (AGL-2978). Only these are offered as a mailbox's `sendAs`.\n */\nexport interface OutreachSendAsAddress {\n email: string\n /** The name Gmail holds for the address, `''` when it holds none. */\n displayName: string\n /** The account's own address. */\n isPrimary: boolean\n /** The address Gmail sends as by default. */\n isDefault: boolean\n}\n\n/**\n * A rep's own mailbox, connected to send Outreach mail\n * (`orgs/{orgId}/outreachMailboxes/{id}`).\n *\n * Its grant lives in {@link OutreachMailboxCredentials} under the same id.\n */\nexport interface OutreachMailbox extends OutreachTimestamps {\n id: string\n provider: OutreachMailboxProvider\n /** The account's own address. */\n email: string\n /** The address mail goes out as: the account's, or an alias it may send as. */\n sendAs: string\n /**\n * The verified addresses `sendAs` may be, as Gmail listed them at the last\n * connect (AGL-2978). A changed alias shows up here on the next reconnect.\n */\n sendAsOptions: OutreachSendAsAddress[]\n /** The From name recipients see. */\n displayName: string\n status: OutreachMailboxStatus\n /** The most mail it sends in one local day, ramp included. */\n dailyCap: number\n window: OutreachSendWindow\n /** IANA zone the window and the day boundary are read in. */\n timezone: string\n /**\n * When the warm-up ramp began, or `null` for a mailbox sending at its full\n * cap. The ramp is measured from here, not from connection, so a paused\n * mailbox can restart it.\n */\n rampStartedAtMs: number | null\n health: OutreachMailboxHealth\n /** The member who connected it, and whose mail it is. */\n connectedByUid: string\n /** When the grant behind it was last connected (AGL-2978). */\n connectedAtMs: number\n /**\n * Set when the mailbox paused ITSELF on its health (AGL-2981), and cleared\n * when a member pauses or resumes it; absent otherwise.\n */\n autoPause?: OutreachMailboxAutoPause | null\n /** The reply and bounce sync's place in the mailbox (AGL-2981). */\n sync?: OutreachMailboxSync | null\n}\n\n/**\n * The provider grant behind one mailbox\n * (`outreachMailboxCredentials/{mailboxId}`).\n *\n * Only the fields every reader relies on are declared here; the token\n * material is added by the code that stores it. `orgId` is REQUIRED, not\n * decorative: the org erasure finds these documents by it, and a credential\n * written without one would outlive its workspace.\n *\n * NAME EVERY SEALED FIELD WITH A SECRET WORD — `refreshToken`,\n * `tokenCiphertext`. The personal-data export discloses these documents with\n * secrets redacted, and its redaction reads field names first: a name\n * carrying `token`, `secret` or `credential` is withheld whatever its value,\n * while a neutral name such as `ciphertext` is judged by the value's shape\n * alone and can be disclosed.\n */\nexport interface OutreachMailboxCredentials extends OutreachTimestamps {\n /** The mailbox id, which is also this document's id. */\n id: string\n orgId: string\n mailboxId: string\n provider: OutreachMailboxProvider\n}\n\n/** A sequence's lifecycle. Only an `active` sequence advances its enrollments. */\nexport const OUTREACH_SEQUENCE_STATUSES = [\n 'draft',\n 'active',\n 'paused',\n 'archived',\n] as const\nexport type OutreachSequenceStatus =\n (typeof OUTREACH_SEQUENCE_STATUSES)[number]\n\n/*==========================================\n * SEQUENCES (AGL-2979).\n *\n * The limits are the outbound playbook's: a person gets at most four emails\n * from one sequence, spaced by business days, and the tasks between them are\n * the rep's own touches — a LinkedIn note, a call. The engine\n * (`../engine/sequence-validation.ts`) holds a stored sequence to them.\n *==========================================*/\n\n/** The most steps one sequence holds, emails and tasks together. */\nexport const OUTREACH_MAX_STEPS = 8\n\n/** The most of those steps that send an email. */\nexport const OUTREACH_MAX_EMAIL_STEPS = 4\n\n/** The longest wait one step may carry, in business days. */\nexport const OUTREACH_MAX_STEP_DELAY_BUSINESS_DAYS = 30\n\n/**\n * The shortest wait before an email that follows an earlier email. The first\n * email may wait `0` — \"the next opening of the window\", or the same day as\n * a task before it — and so may a task, but each later email waits at least\n * this long after the step before it.\n */\nexport const OUTREACH_MIN_EMAIL_FOLLOW_UP_BUSINESS_DAYS = 1\n\n/**\n * One email step.\n *\n * Steps are a union on `kind`, so a later kind joins without reshaping the\n * ones already stored.\n */\nexport interface OutreachEmailStep {\n /** Stable within the sequence, so an edit that reorders steps is traceable. */\n id: string\n kind: 'email'\n /**\n * Business days to wait after the previous step, counted in the mailbox's\n * zone — after enrollment for the first step, where `0` means the next\n * opening of the sending window.\n */\n delayBusinessDays: number\n /**\n * The subject, merge fields allowed. Required on the first email and on\n * any email that starts a new thread; an in-thread email is sent as `Re:`\n * the thread's own subject, so its field is not read.\n */\n subject: string\n /**\n * Whether the email goes out as a reply in the thread the earlier emails\n * started. True by default for every email after the first; the first\n * email always starts the thread, whatever this says.\n */\n replyInThread: boolean\n /** Plain text with merge fields, as its author wrote it; `''` when `templateId` is set. */\n body: string\n /**\n * A CRM email template (`orgs/{orgId}/crmEmailTemplates/{id}`) whose body\n * is sent instead of `body`, or `null`. Only the body is taken from it: the\n * step's own subject is the one that is sent.\n */\n templateId: string | null\n}\n\n/** The rep's own touches a task step asks for. */\nexport const OUTREACH_TASK_KINDS = ['linkedin', 'call', 'todo'] as const\nexport type OutreachTaskKind = (typeof OUTREACH_TASK_KINDS)[number]\n\nexport const OUTREACH_TASK_KIND_LABELS: Record<OutreachTaskKind, string> = {\n linkedin: 'LinkedIn',\n call: 'Call',\n todo: 'To-do',\n}\n\n/** One task step: a CRM task for the rep, created when the step comes due. */\nexport interface OutreachTaskStep {\n id: string\n kind: 'task'\n taskKind: OutreachTaskKind\n /** What the task says, e.g. \"Connect on LinkedIn\". */\n title: string\n /** Business days after the previous step; `0` is the same day. */\n delayBusinessDays: number\n}\n\nexport type OutreachSequenceStep = OutreachEmailStep | OutreachTaskStep\n\n/** The countries a new sequence sends to: the United States alone. */\nexport const OUTREACH_DEFAULT_ALLOWED_COUNTRIES: readonly string[] = ['US']\n\n/** Behavior a sequence applies to every enrollment in it. */\nexport interface OutreachSequenceSettings {\n /**\n * The hours this sequence sends in, replacing its mailbox's own window;\n * `null` sends in the mailbox's. Read in the mailbox's zone either way.\n */\n window: OutreachSendWindow | null\n /**\n * ISO-3166-1 alpha-2 codes a recipient may be in, uppercase. Default\n * {@link OUTREACH_DEFAULT_ALLOWED_COUNTRIES}: Canada, the United Kingdom\n * and most of the EU need a consent basis a cold email does not have.\n */\n allowedCountries: string[]\n /** Whether a contact who is already a customer may be enrolled. Default `false`. */\n allowCustomers: boolean\n /**\n * Whether the links in this sequence's emails are rewritten so clicks are\n * counted (AGL-3239). Default `false`, and `false` on every sequence\n * written before the setting existed: turning it on changes what the\n * recipient sees in the body, which is not a change to make on anyone's\n * behalf.\n *\n * It buys the one engagement number a plain-text sequence can honestly\n * report. It costs a visible link: the destination in the body becomes a\n * short link of ours that forwards to it. Opens are the separate\n * {@link countOpens}, because a pixel needs an HTML part.\n */\n trackClicks: boolean\n /**\n * Whether this sequence's emails carry an HTML part with a tracking image,\n * so opens are counted (AGL-3395). Default `false`, and `false` on every\n * sequence written before the setting existed.\n *\n * On, each email goes out as `multipart/alternative`: the plain-text part\n * exactly as it would have been, and beside it the same words as HTML with\n * a 1×1 image on the short-link host. It costs the plain-text one-to-one\n * look, and some gateways score an HTML part with a remote image — see\n * `../engine/open-tracking.ts`. Off, nothing about the email changes and\n * the report says opens are not measured.\n */\n countOpens: boolean\n /**\n * Whether this sequence's emails carry `List-Unsubscribe` and\n * `List-Unsubscribe-Post` (RFC 8058) (AGL-3296). Default `false`, and\n * `false` on every sequence written before the setting existed.\n *\n * On, mail clients draw their own unsubscribe button — Apple Mail as \"This\n * message is from a mailing list\" — which is the easiest way out for the\n * recipient and makes a one-to-one email read as bulk. Off, the footer's\n * \"reply 'no'\" line is the way out; the footer and its postal address are\n * mandatory either way, and the reply classifier stops on a \"no\". The\n * Gmail/Yahoo one-click requirement binds bulk senders (5,000 a day), not a\n * mailbox sending a sequence.\n */\n listUnsubscribe: boolean\n}\n\n/*==========================================\n * WHAT A SEQUENCE MEASURED (AGL-3239).\n *\n * Counters on the sequence document, incremented by the sending runtime and\n * by the click route. They are NOT derived from the enrollments on read: the\n * console lists enrollments a page at a time, so a rollup taken over what is\n * loaded would report the first page's numbers as the sequence's.\n *\n * Every field is optional and every absence means \"not recorded\", never\n * zero. The distinction is the whole of `campaign-report.ts`'s honesty and\n * it is kept here for the same reason: a sequence that ran before this\n * existed has no counters, and reporting its click rate as 0% would publish\n * a fact about our schema as a fact about its recipients.\n *=========================================*/\n\n/**\n * The per-destination click rollup under one sequence:\n * `orgs/{orgId}/outreachSequences/{id}/reports/links`.\n *\n * One document per sequence, holding a bounded map — the campaign rollup's\n * own shape and its own cap, so \"a link\" means the same thing in a rep's\n * report and a marketer's. Here rather than beside the writer, because the\n * console's listener is a browser module and the writer is not.\n */\nexport const OUTREACH_LINK_ROLLUP_PATH = ['reports', 'links'] as const\n\n/** The counters one sequence is judged by. */\nexport interface OutreachSequenceStats {\n /** Email steps that left. One person getting four emails counts four. */\n sent?: number\n /**\n * Distinct enrollments that have had at least one email — the denominator\n * of every engagement rate, and the thing `sent` is not.\n */\n people?: number\n /**\n * At least one email of this sequence went out with its links rewritten.\n *\n * Absent is NOT false; it is \"never recorded\", which is what every\n * sequence sent before the setting existed reads as. Either way the report\n * withholds the click rate rather than showing 0% — see\n * {@link OutreachSequenceStats} above.\n */\n clickTracked?: boolean\n /** Click EVENTS judged a person's. One reader clicking twice counts two. */\n clicks?: number\n /** Enrollments whose FIRST human click was seen: the rate's numerator. */\n uniqueClicks?: number\n /**\n * Clicks a link scanner or a security gateway made, counted apart and\n * never in the rate (`../engine/click-tracking.ts`). Shown, not hidden:\n * a large number here is the reader's evidence that the small number\n * beside it is the real one.\n */\n machineClicks?: number\n /** When a person last followed a link. */\n lastClickAtMs?: number | null\n /**\n * At least one email of this sequence went out with a tracking image\n * (AGL-3395). Absent is \"never recorded\", and the report says opens are\n * not measured rather than showing 0%.\n */\n openTracked?: boolean\n /**\n * Distinct enrollments that have had at least one email carrying the\n * image — the open rate's denominator. Not `people`: a sequence that turned\n * the setting on halfway through emailed some people no image at all, and\n * they could never have been counted as opening.\n */\n openPeople?: number\n /** Opens judged a person's. One reader opening twice counts two. */\n opens?: number\n /** Enrollments whose FIRST human open was seen: the open rate's numerator. */\n uniqueOpens?: number\n /**\n * Fetches of the image a machine made — a mail privacy proxy prefetching\n * it, a gateway scanning the message — counted apart and never in the\n * rate (`../engine/open-tracking.ts`).\n */\n machineOpens?: number\n /** Of {@link machineOpens}, the ones a mail provider's image proxy made. */\n proxyOpens?: number\n /** When a person last opened one of this sequence's emails. */\n lastOpenAtMs?: number | null\n}\n\n/** What one enrollment did with the links it was sent (AGL-3239). */\nexport interface OutreachEnrollmentEngagement {\n /** Click events judged this person's, machines excluded. */\n clicks: number\n /** The first, which is what makes them one of the sequence's `uniqueClicks`. */\n firstClickAtMs: number | null\n lastClickAtMs: number | null\n /** The destination they followed last, as `campaignLinkKey` reduces it. */\n lastClickUrl: string | null\n /** Clicks on this person's links that were a machine's. */\n machineClicks: number\n /**\n * Every distinct destination this person followed since the per-click\n * history began (AGL-3332), as `campaignLinkKey` reduces it, oldest first\n * and at most {@link OUTREACH_ENGAGEMENT_LINKS_MAX}. What the table counts\n * as \"links\" and filters \"followed this link\" by, without a read of the\n * history. A click from before the history kept only `lastClickUrl`.\n */\n links?: string[]\n /**\n * How many of `clicks` and `machineClicks` have a row of their own in the\n * enrollment's history (AGL-3332). The rest were counted as totals only —\n * before the history began, or past {@link OUTREACH_ENROLLMENT_HISTORY_MAX}.\n */\n loggedClicks?: number\n loggedMachineClicks?: number\n /** Opens judged this person's, machines excluded (AGL-3395). */\n opens?: number\n /** The first, which is what makes them one of the sequence's `uniqueOpens`. */\n firstOpenAtMs?: number | null\n lastOpenAtMs?: number | null\n /** Fetches of this person's tracking image that were a machine's. */\n machineOpens?: number\n /** How many of `opens` and `machineOpens` have a row in the history. */\n loggedOpens?: number\n}\n\n/**\n * The most distinct destinations {@link OutreachEnrollmentEngagement.links}\n * holds. The enrollment is what the enrollments table listens to, so the\n * list is bounded; a sequence's emails carry a link or two each, and nobody\n * follows twenty different ones.\n */\nexport const OUTREACH_ENGAGEMENT_LINKS_MAX = 20\n\n/*==========================================\n * ONE PERSON'S HISTORY (AGL-3332).\n *\n * `orgs/{orgId}/outreachEnrollments/{id}/history/{entryId}`: a row for each\n * visit to a tracking link in this person's emails — which link, from which\n * step, when, and whether a person or a scanner made it — for each fetch\n * of the tracking image in a sequence that counts opens (AGL-3395), and for\n * each pause, resume, stop and do-not-contact a member applied. The enrollment\n * keeps totals; this keeps the events, and is read only when somebody opens\n * the person, so the table's listener never carries it.\n *\n * Server-written, read-only to members, and erased with the enrollment.\n *==========================================*/\n\n/** The history's subcollection under an enrollment. */\nexport const OUTREACH_ENROLLMENT_HISTORY = 'history'\n\n/**\n * The most rows one enrollment's history holds. Past it a click is still\n * counted on the engagement, and the detail view says how many went\n * unlisted — a scanner fetching the same links for a month must not grow a\n * person's history without end.\n */\nexport const OUTREACH_ENROLLMENT_HISTORY_MAX = 500\n\n/** A member's act on one enrollment, as its history records it. */\nexport type OutreachHistoryAction = 'pause' | 'resume' | 'stop' | 'do_not_contact'\n\n/** One visit to a tracking link. */\nexport interface OutreachClickHistoryEntry {\n id: string\n kind: 'click'\n atMs: number\n /** The destination as `campaignLinkKey` reduces it — the link rollup's key; `null` when unreadable. */\n url: string | null\n /** The step whose email carried the link. */\n stepIndex: number\n /** Whether it counts: a person's click, not a scanner's. */\n human: boolean\n /** Why it was read as a scanner's; `null` for a person's. */\n machineReason: OutreachClickMachineReason | null\n}\n\n/** One member's act on the enrollment. */\nexport interface OutreachActionHistoryEntry {\n id: string\n kind: 'action'\n atMs: number\n action: OutreachHistoryAction\n byUid: string\n /** The reason the member typed, if any. */\n detail: string | null\n}\n\n/** One fetch of the tracking image in this person's email (AGL-3395). */\nexport interface OutreachOpenHistoryEntry {\n id: string\n kind: 'open'\n atMs: number\n /** The step whose email carried the image. */\n stepIndex: number\n /** Whether it counts: a person's open, not a proxy's or a scanner's. */\n human: boolean\n /** Why it was read as a machine's; `null` for a person's. */\n machineReason: OutreachOpenMachineReason | null\n}\n\nexport type OutreachEnrollmentHistoryEntry =\n | OutreachClickHistoryEntry\n | OutreachOpenHistoryEntry\n | OutreachActionHistoryEntry\n\n/** An ordered set of steps sent from one mailbox (`orgs/{orgId}/outreachSequences/{id}`). */\nexport interface OutreachSequence extends OutreachTimestamps {\n id: string\n name: string\n /** The site whose CRM the enrolled people are records of. */\n hostId: string\n /**\n * The mailbox every email step is sent from. A setting of the sequence,\n * kept beside `settings` rather than inside it because enrollments and a\n * mailbox's own screens select sequences by it.\n */\n mailboxId: string\n steps: OutreachSequenceStep[]\n settings: OutreachSequenceSettings\n status: OutreachSequenceStatus\n /**\n * The campaigns the sequence is in (AGL-3254): container ids from the\n * org's `emailCampaigns`, under the field every campaign member carries\n * (`containerMembershipField('campaign')`). Everyone enrolled gains them on their\n * own record at enroll time, and what the sequence produces is credited\n * to them. Absent on a sequence saved before it could join one.\n */\n campaignIds?: string[]\n /**\n * What it measured (AGL-3239). Absent until the first email leaves, and\n * absent forever on a sequence that finished before the counters existed.\n */\n stats?: OutreachSequenceStats\n}\n\n/*==========================================\n * ENROLLMENTS (AGL-2979).\n *==========================================*/\n\n/**\n * Where one person's run through a sequence stands.\n *\n * `active` sends and `paused` waits. The rest end the sending, and each says\n * why: `finished` sent every step, `replied` heard back, `bounced` reached a\n * mailbox that does not exist, `opted_out` was asked to stop, `stopped` was\n * ended by a member or a gate, `failed` could not be sent. The transitions\n * between them are the engine's (`../engine/enrollment-state.ts`).\n */\nexport const OUTREACH_ENROLLMENT_STATUSES = [\n 'active',\n 'paused',\n 'finished',\n 'replied',\n 'bounced',\n 'opted_out',\n 'stopped',\n 'failed',\n] as const\nexport type OutreachEnrollmentStatus =\n (typeof OUTREACH_ENROLLMENT_STATUSES)[number]\n\n/**\n * Why an enrollment is not `active`, recorded beside the status. `finished`\n * needs none; each other status allows the reasons\n * `OUTREACH_STOP_REASONS_BY_STATUS` names.\n */\nexport const OUTREACH_STOP_REASONS = [\n /** A person wrote back in the thread. */\n 'reply',\n /** The recipient's server refused the address for good. */\n 'hard_bounce',\n /** A reply asked not to be emailed again. */\n 'opt_out_reply',\n /** The unsubscribe link or header was used. */\n 'unsubscribe',\n /** The address is on the organization's do-not-contact list. */\n 'do_not_contact',\n /** A gate refused the next send — the person became a customer, say. */\n 'gate',\n /** A member paused or stopped it. */\n 'manual',\n /**\n * The engine held the next send (AGL-3326): the recipient's mail gateway\n * refused this organization's sender twice in the last thirty days and\n * delivered nothing. A member resumes it to send anyway.\n */\n 'gateway_blocked_here',\n /** The sequence was archived with the person still in it. */\n 'sequence_archived',\n /** The provider refused the send for good, or the email could not be composed. */\n 'send_failed',\n] as const\nexport type OutreachStopReason = (typeof OUTREACH_STOP_REASONS)[number]\n\n/** The statuses a stop reason is recorded with, and the reasons each allows. */\nexport const OUTREACH_STOP_REASONS_BY_STATUS: Readonly<\n Record<\n Exclude<OutreachEnrollmentStatus, 'active' | 'finished'>,\n readonly OutreachStopReason[]\n >\n> = {\n paused: ['manual', 'gateway_blocked_here'],\n replied: ['reply'],\n bounced: ['hard_bounce'],\n opted_out: ['opt_out_reply', 'unsubscribe', 'do_not_contact'],\n stopped: ['manual', 'gate', 'sequence_archived'],\n failed: ['send_failed'],\n}\n\n/**\n * What a rep confirms before a COLD contact is enrolled — one with no\n * inbound capture behind them — each recorded with who confirmed it and\n * when, because each is a fact only the rep can know:\n *\n * - `us_business_address`: the address is a business address in the US;\n * - `published_or_given`: they or their company published it, or they gave\n * it to us — never guessed from a name or bought on a list;\n * - `verified_deliverable`: a verifier said it accepts mail.\n */\nexport const OUTREACH_ATTESTATION_KINDS = [\n 'us_business_address',\n 'published_or_given',\n 'verified_deliverable',\n] as const\nexport type OutreachAttestationKind = (typeof OUTREACH_ATTESTATION_KINDS)[number]\n\n/** The sentence a rep ticks for each attestation. */\nexport const OUTREACH_ATTESTATION_LABELS: Record<OutreachAttestationKind, string> = {\n us_business_address: 'This is a US business address',\n published_or_given:\n 'They or their company published this address, or they gave it to us',\n verified_deliverable: 'This address was verified as deliverable',\n}\n\n/** One confirmation, as stored. */\nexport interface OutreachAttestation {\n /** The member who confirmed it. */\n uid: string\n atMs: number\n}\n\n/** The confirmations an enrollment carries, by kind. */\nexport type OutreachAttestations = Partial<\n Record<OutreachAttestationKind, OutreachAttestation>\n>\n\n/** The longest personal line an enrollment keeps: one sentence, not a letter. */\nexport const OUTREACH_PERSONAL_LINE_MAX = 300\n\n/*==========================================\n * CURATED STEPS (AGL-3324).\n *\n * A step is one template for everyone, plus the personal line. Curating\n * rewrites ONE person's copy of a step — drafted by the workspace's AI from\n * their record and the step's own body as the skeleton, or written by the\n * member — and keeps it on the enrollment, never on the sequence. The send\n * job reads the override in place of the step's subject and body; the\n * tokens, the footer, the click tracking and the plain-text rules still\n * apply to it exactly as they apply to the step.\n *\n * Nothing is stored that a member has not read: a draft lands on the\n * enrollment only when the member confirms it, with who and when.\n *==========================================*/\n\n/** Who wrote the override: the AI, or the member by hand. */\nexport const OUTREACH_STEP_OVERRIDE_SOURCES = ['ai', 'member'] as const\nexport type OutreachStepOverrideSource = (typeof OUTREACH_STEP_OVERRIDE_SOURCES)[number]\n\n/** One person's own copy of one step. */\nexport interface OutreachStepOverride {\n /** The subject, merge fields allowed; absent keeps the step's own. Not read on an in-thread email. */\n subject?: string\n /** The plain-text body, merge fields allowed; absent keeps the step's own (or its template's). */\n body?: string\n source: OutreachStepOverrideSource\n /** When the member confirmed it — the moment it was stored, never before. */\n draftedAtMs: number\n /** The member who confirmed it. */\n draftedByUid?: string\n /** An AI draft the member changed before confirming it. */\n edited?: boolean\n /** The prompt the AI was given, for the audit log; absent on a member's own words. */\n prompt?: string\n /** The model that drafted it, for the audit log. */\n model?: string\n}\n\n/** The overrides an enrollment carries, keyed by the step's index as text. */\nexport type OutreachStepOverrides = Record<string, OutreachStepOverride>\n\n/** The sentence a member ticks before a curated draft is stored — a fourth attestation. */\nexport const OUTREACH_CURATION_CONFIRMATION_LABEL =\n \"I've read this draft, and it goes out to this person as written\"\n\n/**\n * Which CRM record an enrollment names (AGL-3234). A person is a LEAD until\n * somebody qualifies them and a CONTACT after, and a sequence works either:\n * an enrollment made on a lead follows the lead to the contact it becomes,\n * so the thread and the steps carry on as one enrollment.\n */\nexport const OUTREACH_ENROLLMENT_TARGETS = ['contact', 'lead'] as const\nexport type OutreachEnrollmentTarget = (typeof OUTREACH_ENROLLMENT_TARGETS)[number]\n\n/** One person in one sequence (`orgs/{orgId}/outreachEnrollments/{id}`). */\nexport interface OutreachEnrollment extends OutreachTimestamps {\n id: string\n sequenceId: string\n /**\n * The record the person is (AGL-3234): `contact` for a CRM contact,\n * `lead` for a lead the sequence's site holds. A stored enrollment with\n * no target is a contact's — every enrollment was, before leads could be\n * sequenced.\n */\n target: OutreachEnrollmentTarget\n /**\n * The CRM contact the person is — `''` while the enrollment targets a\n * lead that has not converted. Filled in, beside `target: 'contact'`, the\n * moment the lead becomes a contact.\n */\n contactId: string\n /**\n * `hosts/{hostId}/leads/{leadId}` — the person key — for an enrollment\n * made on a lead; kept once the lead converts, so the lead's page still\n * lists the sequence. `null` for an enrollment made on a contact.\n */\n leadId: string | null\n /**\n * The person's name as the sending site knew it at enrollment, `''` when\n * it had none — what the enrollments table shows beside the address,\n * without a read of every record on the page (AGL-2980).\n */\n contactName: string\n /** The address the steps go to, normalized, captured at enrollment. */\n email: string\n /**\n * What the enrollments table's search box reads (AGL-3321): every prefix\n * of the name and of the address and its parts\n * (`outreachEnrollmentSearchTokens`), stamped by the enroll route beside\n * the two it is made of, which nothing rewrites afterwards.\n */\n searchTokens?: string[]\n hostId: string\n mailboxId: string\n /** The index into `steps` of the NEXT step to run. */\n stepIndex: number\n /**\n * The step the enrollment began at (AGL-3228), when it was not the first:\n * the member enrolled someone who already had the earlier steps by hand.\n * Absent on an enrollment that began at step 1. The first email sent from\n * here starts the enrollment's thread, whatever `replyInThread` says —\n * there is no earlier email of ours for it to answer.\n */\n startStepIndex?: number\n /**\n * The steps before {@link startStepIndex}, marked skipped at enrollment\n * and never run (AGL-3228). Absent when none were.\n */\n skippedSteps?: OutreachSkippedStep[]\n /** When that step comes due, or `null` when nothing is waiting. */\n nextDueAtMs: number | null\n status: OutreachEnrollmentStatus\n /** Why the status is not `active`; `null` while active and once finished. */\n stopReason: OutreachStopReason | null\n /** Plain-language detail: the gate's reason, the bounce's diagnostic. */\n stopDetail: string | null\n stoppedAtMs: number | null\n /** The member who paused or stopped it; `null` when the engine did. */\n stoppedByUid: string | null\n /**\n * The rep's signal sentence — why this person, now — merged into the\n * steps as `{{enrollment.personalLine}}`. Required for a cold contact.\n */\n personalLine: string\n /** Whether the contact was cold (no inbound capture) when enrolled. */\n cold: boolean\n attestations: OutreachAttestations\n /** The member who enrolled the person. */\n enrolledByUid: string\n /** The provider thread the next in-thread email is sent into, once one exists. */\n gmailThreadId: string | null\n /** Every provider thread this enrollment has sent into, oldest first — what reply sync watches. */\n gmailThreadIds: string[]\n /** The subject the current thread was started with, as sent. */\n threadSubject: string | null\n /**\n * The `Message-ID`s of the emails sent into the current thread, oldest\n * first, angle brackets included: the next in-thread email answers the\n * last and names them all in `References`.\n */\n messageIds: string[]\n /** When the last step ran. */\n lastSentAtMs: number | null\n /**\n * A sending run's hold on the step it is running (AGL-2981): taken in a\n * transaction before the step runs, cleared when it is recorded. Absent\n * or `null` while no run holds one.\n */\n sendClaim?: OutreachSendClaim | null\n /** Every step the runtime ran, oldest first (AGL-2981). */\n stepRecords?: OutreachStepRecord[]\n /** Gmail ids of this enrollment's thread messages the sync has handled, the last hundred. */\n syncedMessageIds?: string[]\n /**\n * What this person did with the links they were sent (AGL-3239). Absent\n * until their first click, which is why the table reads an absence as\n * \"no clicks\" only for a sequence that tracks them at all.\n */\n engagement?: OutreachEnrollmentEngagement\n /**\n * Whether the person clicked a link (AGL-3332): what the enrollments\n * table's \"Clicked\" filter asks Firestore. `false` from enrollment, set\n * by the click route on a person's click, never a scanner's.\n */\n clicked?: boolean\n /**\n * The sequence's campaigns as they stood when the person was enrolled\n * (AGL-3254): what every outcome of this enrollment is credited to. A\n * campaign the sequence joins later does not claim the people already\n * in it, and one it leaves keeps what it was credited with.\n */\n campaignIds?: string[]\n /**\n * This person's own copies of steps (AGL-3324), by step index. Absent on\n * an enrollment nobody curated, which sends the sequence's steps as\n * written; a step without an entry sends the same.\n */\n stepOverrides?: OutreachStepOverrides\n /**\n * The gateway hold (AGL-3326), once one applied: which gateway, when the\n * engine held the send, and the member who released it — by resuming the\n * held enrollment, or by ticking the person past the red chip when they\n * enrolled them. A released hold is not taken again; a send that the\n * engine held and nobody released waits.\n */\n gatewayHold?: OutreachGatewayHold | null\n /**\n * How many of this enrollment's email steps the sync has credited to the\n * gateway ledger as delivered (AGL-3326): a send with no bounce a day\n * later. The sync credits the next ones from here.\n */\n gatewayDeliveredSteps?: number\n}\n\n/** A gateway hold on one enrollment (AGL-3326) — see {@link OutreachEnrollment.gatewayHold}. */\nexport interface OutreachGatewayHold {\n gateway: OutreachMailGateway\n /** When the engine held a send; `null` when a member released it before one was. */\n heldAtMs: number | null\n releasedByUid: string | null\n releasedAtMs: number | null\n}\n\n\n/**\n * The organization's ledger for one mail gateway as first written\n * (`orgs/{orgId}/outreachGatewayStats/{gateway}`, AGL-3326): totals, and the\n * same counts by UTC day. Read through, never written — see\n * `OUTREACH_COLLECTIONS.gatewayStats`.\n */\nexport interface OutreachGatewayStats {\n gateway: OutreachMailGateway\n sent: number\n delivered: number\n blocked: number\n lastBlockedAtMs: number | null\n /** `YYYY-MM-DD` (UTC) → that day's counts, the last thirty days kept. */\n days: Record<string, OutreachGatewayDayCounts>\n updatedAtMs: number\n}\n\n/** A sending run's claim on one enrollment's step (AGL-2981). */\nexport interface OutreachSendClaim {\n /** The run that holds it. */\n token: string\n atMs: number\n stepIndex: number\n /**\n * The `Message-ID` an email step goes out with, minted before the send, so\n * a claim a run died holding is settled by looking for the message rather\n * than by sending it again. `null` for a task step.\n */\n messageId: string | null\n}\n\n/**\n * One step an enrollment skipped because it began past it (AGL-3228): the\n * person already had it by hand, so the runtime never runs it. Kept apart\n * from {@link OutreachStepRecord}, which every reader counts as a send.\n */\nexport interface OutreachSkippedStep {\n stepIndex: number\n stepId: string\n kind: 'email' | 'task'\n /** When it was marked skipped: the enrollment. */\n atMs: number\n}\n\n/** One step the runtime ran for an enrollment (AGL-2981). */\nexport interface OutreachStepRecord {\n stepIndex: number\n stepId: string\n kind: 'email' | 'task'\n atMs: number\n /** Gmail's id for the sent message. */\n gmailMessageId?: string\n /** Gmail's thread the message went into. */\n gmailThreadId?: string\n /** The `Message-ID` it went out with, angle brackets included. */\n messageId?: string\n /** The subject as sent. */\n subject?: string\n /** The record system's task for a task step; `null` when none could be filed. */\n taskId?: string | null\n /**\n * The destinations this email's links were rewritten to point at, in the\n * order a click token indexes them (AGL-3239). Absent on a step that\n * carried no links, and on every step sent before tracking existed.\n *\n * Kept so the console can say WHICH link a person followed without the\n * token having to carry the URL back to us, and so a rewritten body can be\n * read afterwards for what it actually offered them.\n */\n links?: string[]\n /**\n * The email carried a tracking image (AGL-3395). Absent on every email\n * sent without one — which is every email of a sequence that does not\n * count opens.\n */\n openTracked?: boolean\n /**\n * The email went out as this person's curated copy (AGL-3324), and who\n * wrote it. Absent on a step sent as the sequence wrote it.\n */\n curated?: OutreachStepOverrideSource\n}\n\n/*==========================================\n * ORGANIZATION SETTINGS (AGL-2979).\n *==========================================*/\n\n/**\n * What every Outreach email's footer says about who sent it — the\n * identification and the postal address CAN-SPAM requires on commercial\n * mail. The composer refuses to write an email without a legal name and a\n * postal address, and a sequence cannot be activated without them.\n */\nexport interface OutreachOrgSettings {\n /** The organization's legal name, as the footer prints it: \"Example Co LLC\". */\n legalName: string\n /**\n * The name the solicitation sentence uses when it is not the legal name:\n * \"This is a sales email from Example Co.\" `''` uses the legal\n * name.\n */\n brandName: string\n /**\n * A valid physical postal address: a street address, a USPS PO box, or a\n * private mailbox registered with the USPS. Line breaks are printed as\n * commas.\n */\n postalAddress: string\n}\n\n/** The id of the compliance document in the `settings` collection. */\nexport const OUTREACH_COMPLIANCE_SETTINGS_ID = 'compliance'\n\n/**\n * The organization's Outreach compliance settings\n * (`orgs/{orgId}/outreachSettings/compliance`): the footer's sender identity,\n * and the countries Outreach may send to at all.\n *\n * `allowedCountries` is a CEILING over every sequence's own list — a\n * sequence sends only to the countries both name — so narrowing it here\n * narrows every sequence at once, without editing any of them. Default\n * {@link OUTREACH_DEFAULT_ALLOWED_COUNTRIES}.\n */\nexport interface OutreachComplianceSettings extends OutreachOrgSettings {\n /** ISO-3166-1 alpha-2 codes, uppercase, in the order they were chosen. */\n allowedCountries: string[]\n}\n\n/** The compliance settings as stored, with who changed them last. */\nexport interface OutreachComplianceSettingsDocument\n extends OutreachComplianceSettings {\n /** `0` until the organization first saves them. */\n updatedAtMs: number\n updatedByUid: string | null\n}\n\n/*==========================================\n * DO NOT CONTACT (AGL-2980).\n *\n * The organization's own list of addresses Outreach never emails, whoever\n * enrolls them and from whichever site. A member adds one by hand; the\n * sending runtime adds one when a reply asks to be left alone, when the\n * unsubscribe link is used, and when an address bounces for good.\n *\n * AN ENTRY CARRIES NO ADDRESS. Its id is `outreachDoNotContactKey(email)` —\n * the same hash the platform's suppression lists key by — and that is all a\n * lookup needs, since every caller holds the address it is about to use.\n * So the list keeps working after a person is erased from the workspace,\n * which is exactly when a promise not to email them must still hold, while\n * holding nothing that identifies them.\n *==========================================*/\n\n/** Why an address is on the list. */\nexport const OUTREACH_DO_NOT_CONTACT_REASONS = [\n /** A member put it there. */\n 'manual',\n /** A reply asked not to be emailed again. */\n 'opt_out_reply',\n /** The unsubscribe link or header was used. */\n 'unsubscribe',\n /** Mail to it bounced for good. */\n 'hard_bounce',\n /**\n * The recipient organization's mail gateway refused the sender outright\n * (AGL-3244) — a Barracuda, Proofpoint or Mimecast policy block — which is\n * a verdict on the whole domain, and is filed against it.\n */\n 'gateway_block',\n] as const\nexport type OutreachDoNotContactReason =\n (typeof OUTREACH_DO_NOT_CONTACT_REASONS)[number]\n\n/** What put an address on the list: a member, or the sending runtime. */\nexport const OUTREACH_DO_NOT_CONTACT_SOURCES = ['member', 'runtime'] as const\nexport type OutreachDoNotContactSource =\n (typeof OUTREACH_DO_NOT_CONTACT_SOURCES)[number]\n\n/** One address on the list (`orgs/{orgId}/outreachDoNotContact/{key}`). */\nexport interface OutreachDoNotContactEntry {\n /** `outreachDoNotContactKey` of the address, which is also the document id. */\n key: string\n reason: OutreachDoNotContactReason\n source: OutreachDoNotContactSource\n /** The member who added it; `null` when the runtime did. */\n addedByUid: string | null\n addedAtMs: number\n /** The enrollment that led here, when one did. */\n enrollmentId: string | null\n /** That enrollment's sequence. */\n sequenceId: string | null\n /** Plain-language detail: why the member added it, the bounce's diagnostic. */\n detail: string | null\n}\n\n/**\n * One domain on the list (`orgs/{orgId}/outreachDoNotContactDomains/{domain}`)\n * (AGL-3244): no address at it is emailed, whoever enrolls them.\n *\n * Unlike an address entry it CARRIES THE DOMAIN, in clear, because the\n * Compliance page lists it and a member takes it off by name; a domain is a\n * company's, not a person's, and a person erasure leaves it alone. A member\n * adds one by hand; the sending runtime adds one when a hard bounce reads\n * as the domain's mail gateway refusing the sender rather than one address\n * being unknown.\n */\nexport interface OutreachDoNotContactDomainEntry {\n /** The domain, lower-cased, which is also the document id. */\n domain: string\n reason: OutreachDoNotContactReason\n source: OutreachDoNotContactSource\n /** The member who added it; `null` when the runtime did. */\n addedByUid: string | null\n addedAtMs: number\n /** The enrollment whose bounce led here, when one did. */\n enrollmentId: string | null\n /** That enrollment's sequence. */\n sequenceId: string | null\n /** Plain-language detail: the member's note, or the bounce's diagnostic. */\n detail: string | null\n /**\n * What the domains list's search box reads (AGL-3321):\n * `outreachDomainSearchTokens`, stamped by the one writer that adds it.\n */\n searchTokens?: string[]\n}\n"],"names":["OUTREACH_COLLECTIONS","mailboxes","sequences","enrollments","settings","doNotContact","doNotContactDomains","domainIntel","gatewayStats","mailboxCredentials","links","outreachOrgCollectionPath","orgId","collection","OUTREACH_MAILBOX_PROVIDERS","OUTREACH_MAILBOX_STATUSES","OUTREACH_SEQUENCE_STATUSES","OUTREACH_MAX_STEPS","OUTREACH_MAX_EMAIL_STEPS","OUTREACH_MAX_STEP_DELAY_BUSINESS_DAYS","OUTREACH_MIN_EMAIL_FOLLOW_UP_BUSINESS_DAYS","OUTREACH_TASK_KINDS","OUTREACH_TASK_KIND_LABELS","linkedin","call","todo","OUTREACH_DEFAULT_ALLOWED_COUNTRIES","OUTREACH_LINK_ROLLUP_PATH","OUTREACH_ENGAGEMENT_LINKS_MAX","OUTREACH_ENROLLMENT_HISTORY","OUTREACH_ENROLLMENT_HISTORY_MAX","OUTREACH_ENROLLMENT_STATUSES","OUTREACH_STOP_REASONS","OUTREACH_STOP_REASONS_BY_STATUS","paused","replied","bounced","opted_out","stopped","failed","OUTREACH_ATTESTATION_KINDS","OUTREACH_ATTESTATION_LABELS","us_business_address","published_or_given","verified_deliverable","OUTREACH_PERSONAL_LINE_MAX","OUTREACH_STEP_OVERRIDE_SOURCES","OUTREACH_CURATION_CONFIRMATION_LABEL","OUTREACH_ENROLLMENT_TARGETS","OUTREACH_COMPLIANCE_SETTINGS_ID","OUTREACH_DO_NOT_CONTACT_REASONS","OUTREACH_DO_NOT_CONTACT_SOURCES"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;CAmBC,GAMD;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMA,uBAAuB;IAClC,wEAAwE,GACxEC,WAAW;IACX,uEAAuE,GACvEC,WAAW;IACX,oFAAoF,GACpFC,aAAa;IACb;;;;GAIC,GACDC,UAAU;IACV;;;GAGC,GACDC,cAAc;IACd;;;;GAIC,GACDC,qBAAqB;IACrB;;;;;GAKC,GACDC,aAAa;IACb;;;;;;;GAOC,GACDC,cAAc;IACd;;;;GAIC,GACDC,oBAAoB;IACpB;;;;;;GAMC,GACDC,OAAO;AACT,EAAU;AAQV,uEAAuE,GACvE,OAAO,SAASC,0BACdC,KAAa,EACbC,UAAiC;IAEjC,OAAO,CAAC,KAAK,EAAED,MAAM,CAAC,EAAEZ,oBAAoB,CAACa,WAAW,EAAE;AAC5D;AAQA,2DAA2D,GAC3D,OAAO,MAAMC,6BAA6B;IAAC;CAAS,CAAS;AAI7D;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B;IACvC;IACA;IACA;IACA;CACD,CAAS;AAyLV,gFAAgF,GAChF,OAAO,MAAMC,6BAA6B;IACxC;IACA;IACA;IACA;CACD,CAAS;AAIV;;;;;;;4CAO4C,GAE5C,kEAAkE,GAClE,OAAO,MAAMC,qBAAqB,EAAC;AAEnC,gDAAgD,GAChD,OAAO,MAAMC,2BAA2B,EAAC;AAEzC,2DAA2D,GAC3D,OAAO,MAAMC,wCAAwC,GAAE;AAEvD;;;;;CAKC,GACD,OAAO,MAAMC,6CAA6C,EAAC;AAwC3D,gDAAgD,GAChD,OAAO,MAAMC,sBAAsB;IAAC;IAAY;IAAQ;CAAO,CAAS;AAGxE,OAAO,MAAMC,4BAA8D;IACzEC,UAAU;IACVC,MAAM;IACNC,MAAM;AACR,EAAC;AAeD,oEAAoE,GACpE,OAAO,MAAMC,qCAAwD;IAAC;CAAK,CAAA;AA2D3E;;;;;;;;;;;;;2CAa2C,GAE3C;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B;IAAC;IAAW;CAAQ,CAAS;AAmGtE;;;;;CAKC,GACD,OAAO,MAAMC,gCAAgC,GAAE;AAE/C;;;;;;;;;;;;4CAY4C,GAE5C,qDAAqD,GACrD,OAAO,MAAMC,8BAA8B,UAAS;AAEpD;;;;;CAKC,GACD,OAAO,MAAMC,kCAAkC,IAAG;AA+ElD;;4CAE4C,GAE5C;;;;;;;;CAQC,GACD,OAAO,MAAMC,+BAA+B;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAIV;;;;CAIC,GACD,OAAO,MAAMC,wBAAwB;IACnC,uCAAuC,GACvC;IACA,yDAAyD,GACzD;IACA,2CAA2C,GAC3C;IACA,6CAA6C,GAC7C;IACA,8DAA8D,GAC9D;IACA,sEAAsE,GACtE;IACA,mCAAmC,GACnC;IACA;;;;GAIC,GACD;IACA,2DAA2D,GAC3D;IACA,gFAAgF,GAChF;CACD,CAAS;AAGV,8EAA8E,GAC9E,OAAO,MAAMC,kCAKT;IACFC,QAAQ;QAAC;QAAU;KAAuB;IAC1CC,SAAS;QAAC;KAAQ;IAClBC,SAAS;QAAC;KAAc;IACxBC,WAAW;QAAC;QAAiB;QAAe;KAAiB;IAC7DC,SAAS;QAAC;QAAU;QAAQ;KAAoB;IAChDC,QAAQ;QAAC;KAAc;AACzB,EAAC;AAED;;;;;;;;;CASC,GACD,OAAO,MAAMC,6BAA6B;IACxC;IACA;IACA;CACD,CAAS;AAGV,mDAAmD,GACnD,OAAO,MAAMC,8BAAuE;IAClFC,qBAAqB;IACrBC,oBACE;IACFC,sBAAsB;AACxB,EAAC;AAcD,+EAA+E,GAC/E,OAAO,MAAMC,6BAA6B,IAAG;AAE7C;;;;;;;;;;;;;4CAa4C,GAE5C,2DAA2D,GAC3D,OAAO,MAAMC,iCAAiC;IAAC;IAAM;CAAS,CAAS;AAyBvE,yFAAyF,GACzF,OAAO,MAAMC,uCACX,kEAAiE;AAEnE;;;;;CAKC,GACD,OAAO,MAAMC,8BAA8B;IAAC;IAAW;CAAO,CAAS;AAuQvE,oEAAoE,GACpE,OAAO,MAAMC,kCAAkC,aAAY;AAyB3D;;;;;;;;;;;;;;4CAc4C,GAE5C,mCAAmC,GACnC,OAAO,MAAMC,kCAAkC;IAC7C,2BAA2B,GAC3B;IACA,2CAA2C,GAC3C;IACA,6CAA6C,GAC7C;IACA,iCAAiC,GACjC;IACA;;;;GAIC,GACD;CACD,CAAS;AAIV,uEAAuE,GACvE,OAAO,MAAMC,kCAAkC;IAAC;IAAU;CAAU,CAAS"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/model/outreach.types.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * THE OUTREACH DOCUMENT MODEL (AGL-2974).\n *\n * One file both halves import — the console reads these documents, the server\n * routes write them — so a field is spelled once. Client-safe: types and\n * constants only, nothing that reaches Firestore.\n *\n * EVERY DOCUMENT HERE IS SERVER-WRITTEN. The Firestore rules let an\n * org-wide member holding `outreach.use` READ the org collections on a\n * workspace that carries `features.outreach`, and refuse every client write,\n * because these documents are the sending engine's state: a client that\n * could write a mailbox could lift its daily cap, and one that could write\n * an enrollment could send a step twice. The credential collection is closed\n * to clients entirely.\n *\n * Lean on purpose. Each type carries what the mailbox and sequence work is\n * known to need and nothing speculative; a field is added where the code\n * that reads it lands. Times are epoch milliseconds throughout, the unit\n * `nextDueAtMs` has to be compared in.\n */\n\nimport type { OutreachClickMachineReason } from '../engine/click-tracking'\nimport type { OutreachOpenMachineReason } from '../engine/open-tracking'\nimport type { OutreachOpenSource } from '../engine/open-source'\nimport type { OutreachGatewayDayCounts, OutreachMailGateway } from '../engine/mail-gateway'\n\n/**\n * Where Outreach keeps its records.\n *\n * Eight collections under the organization, and two at the top level. The\n * org-scoped ones are erased with the org, whose erasure deletes the whole\n * `orgs/{orgId}` tree. The top-level ones — credentials, and the short\n * tracking links (AGL-3297) — are keyed by an `orgId` FIELD that a\n * path-scoped delete of `orgs/{orgId}` cannot see: the org erasure sweeps\n * them by that field\n * (`libs/tenant/data/admin/src/lib/server/erase.ts` names it as a literal,\n * which the boundary forces, and `outreach.types.spec.ts` holds the two\n * spellings together, along with the rules').\n */\nexport const OUTREACH_COLLECTIONS = {\n /** `orgs/{orgId}/outreachMailboxes/{mailboxId}` — a connected mailbox. */\n mailboxes: 'outreachMailboxes',\n /** `orgs/{orgId}/outreachSequences/{sequenceId}` — the steps to send. */\n sequences: 'outreachSequences',\n /** `orgs/{orgId}/outreachEnrollments/{enrollmentId}` — one person in one sequence. */\n enrollments: 'outreachEnrollments',\n /**\n * `orgs/{orgId}/outreachSettings/{settingsId}` — the organization's own\n * Outreach settings, one document per concern. `compliance` holds who\n * every email says sent it and the countries Outreach may send to.\n */\n settings: 'outreachSettings',\n /**\n * `orgs/{orgId}/outreachDoNotContact/{key}` — the addresses Outreach never\n * emails for this organization, keyed by `outreachDoNotContactKey`.\n */\n doNotContact: 'outreachDoNotContact',\n /**\n * `orgs/{orgId}/outreachDoNotContactDomains/{domain}` — the domains\n * Outreach never emails for this organization (AGL-3244), keyed by the\n * domain itself: a domain names a company, not a person.\n */\n doNotContactDomains: 'outreachDoNotContactDomains',\n /**\n * `orgs/{orgId}/outreachDomainIntel/{domain}` — a recipient domain's MX\n * as this organization first cached it (AGL-3326). Neither read nor\n * written any more: the platform-wide `mailDomains` cache replaced it\n * (AGL-3328), and it is retired with its rule once that has shipped.\n */\n domainIntel: 'outreachDomainIntel',\n /**\n * `orgs/{orgId}/outreachGatewayStats/{gateway}` — the organization's\n * ledger per mail gateway as first written (AGL-3326), with no sending\n * domain. READ THROUGH, never written: its last thirty days are summed\n * into the sending-domain ledger's standing\n * (`orgs/{orgId}/mailGatewayLedger`, AGL-3328) until they age out, and it\n * is retired with its rule after that.\n */\n gatewayStats: 'outreachGatewayStats',\n /**\n * `outreachMailboxCredentials/{mailboxId}` — the provider grant behind a\n * mailbox. TOP-LEVEL and closed to every client, staff included, so the\n * token material never shares a readable path with the mailbox it serves.\n */\n mailboxCredentials: 'outreachMailboxCredentials',\n /**\n * `outreachLinks/{linkId}` — what one short tracking link in a sent email\n * points at (AGL-3297): the organization, the enrollment, the step, the\n * link's index and the destination. TOP-LEVEL so the link's id alone\n * resolves it with one read, keyed by an `orgId` FIELD that the org\n * erasure sweeps, and closed to every client.\n */\n links: 'outreachLinks',\n} as const\n\n/** The org-scoped collections, by their {@link OUTREACH_COLLECTIONS} key. */\nexport type OutreachOrgCollection = Exclude<\n keyof typeof OUTREACH_COLLECTIONS,\n 'mailboxCredentials' | 'links'\n>\n\n/** `orgs/{orgId}/<collection>` for one of the org-scoped collections. */\nexport function outreachOrgCollectionPath(\n orgId: string,\n collection: OutreachOrgCollection,\n): string {\n return `orgs/${orgId}/${OUTREACH_COLLECTIONS[collection]}`\n}\n\n/** Stamped by the server on every write. */\nexport interface OutreachTimestamps {\n createdAtMs: number\n updatedAtMs: number\n}\n\n/** The mail providers a mailbox can be connected through. */\nexport const OUTREACH_MAILBOX_PROVIDERS = ['google'] as const\nexport type OutreachMailboxProvider =\n (typeof OUTREACH_MAILBOX_PROVIDERS)[number]\n\n/**\n * Where a mailbox stands.\n *\n * - `connected` — the grant works and the mailbox may send.\n * - `paused` — a member stopped it; enrollments on it wait.\n * - `reconnect_required` — the provider refused the grant (revoked, expired,\n * password changed); nothing sends until the rep connects it again.\n * - `disconnected` — a member removed it; its credential is gone.\n */\nexport const OUTREACH_MAILBOX_STATUSES = [\n 'connected',\n 'paused',\n 'reconnect_required',\n 'disconnected',\n] as const\nexport type OutreachMailboxStatus = (typeof OUTREACH_MAILBOX_STATUSES)[number]\n\n/**\n * The hours a mailbox sends in, in its own {@link OutreachMailbox.timezone}.\n * A step that comes due outside the window waits for the next opening.\n */\nexport interface OutreachSendWindow {\n /** Days of the week it sends on, `0` Sunday through `6` Saturday. */\n days: number[]\n /** Minutes after local midnight the window opens, inclusive. */\n startMinute: number\n /** Minutes after local midnight the window closes, exclusive. */\n endMinute: number\n}\n\n/**\n * One mailbox-local day's sending, as the health panel sums it (AGL-2978).\n */\nexport interface OutreachMailboxDailyHealth {\n sent: number\n bounces: number\n replies: number\n /**\n * Tests of a sequence step sent to a member (AGL-3325). Counted apart from\n * `sent`: a test is a real Gmail send, so it spends the account's own\n * limits, but it is not a person emailed and never moves the daily cap.\n */\n tests?: number\n}\n\n/**\n * The counters a mailbox's sending is judged by.\n *\n * `sentToday` is what `dailyCap` refuses against, and it belongs to one\n * mailbox-local day — `sentOnDay` — so a counter from yesterday is read as\n * zero rather than as today's spend.\n */\nexport interface OutreachMailboxHealth {\n sentToday: number\n /** The local day (`YYYY-MM-DD` in the mailbox's timezone) `sentToday` counts. */\n sentOnDay: string | null\n /** Hard bounces on mail this mailbox sent. */\n bounces: number\n /** Replies detected on Outreach threads. */\n replies: number\n lastSentAtMs: number | null\n /** The last provider error, kept until a later send succeeds. */\n lastErrorAtMs: number | null\n lastErrorCode: string | null\n /**\n * Per mailbox-local day (`YYYY-MM-DD`), the sends, bounces and replies\n * counted on it (AGL-2978). The Mailboxes panel shows the last seven days\n * summed; the sending runtime increments the day it counts on and may drop\n * days older than a week. Absent, or empty, until the first send.\n */\n daily?: Record<string, OutreachMailboxDailyHealth>\n /**\n * The mailbox's most recent sends, newest last, at most\n * `OUTREACH_BOUNCE_RATE_WINDOW_SENDS` of them, each marked when a hard\n * bounce came back for it (AGL-2981): the window the bounce-rate pause is\n * judged over. A send is named by a digest of its `Message-ID`, never by\n * its recipient.\n */\n recentSends?: OutreachRecentSend[]\n /** When a reply last called this mailbox's email spam (AGL-2981). */\n lastComplaintAtMs?: number | null\n}\n\n/** One send in {@link OutreachMailboxHealth.recentSends}. */\nexport interface OutreachRecentSend {\n /** A digest of the send's `Message-ID`: what a bounce is matched to. */\n id: string\n atMs: number\n bounced: boolean\n}\n\n/** Why a mailbox paused itself (AGL-2981): the engine's health decision, kept. */\nexport interface OutreachMailboxAutoPause {\n /**\n * `bounce_rate` is what the window rule wrote before AGL-3326 changed it\n * from a percentage to a count; a stored pause keeps the reason it was\n * written with, and the card shows `message` either way.\n */\n reason: 'bounces_today' | 'bounces_in_window' | 'bounce_rate' | 'complaint'\n /** The sentence the mailbox's card shows. */\n message: string\n atMs: number\n /** For a complaint, when resuming stops being premature; `null` otherwise. */\n untilMs: number | null\n}\n\n/** Where a mailbox's reply and bounce sync has read to (AGL-2981). */\nexport interface OutreachMailboxSync {\n /** Everything received before this was read by an earlier run, epoch ms. */\n throughMs: number\n /** Gmail ids of messages outside any enrollment's thread already handled. */\n handledMessageIds: string[]\n}\n\n/**\n * An address a connected Google account may send as, which Gmail has\n * verified — its own address, or an alias whose ownership Gmail confirmed\n * (AGL-2978). Only these are offered as a mailbox's `sendAs`.\n */\nexport interface OutreachSendAsAddress {\n email: string\n /** The name Gmail holds for the address, `''` when it holds none. */\n displayName: string\n /** The account's own address. */\n isPrimary: boolean\n /** The address Gmail sends as by default. */\n isDefault: boolean\n}\n\n/**\n * A rep's own mailbox, connected to send Outreach mail\n * (`orgs/{orgId}/outreachMailboxes/{id}`).\n *\n * Its grant lives in {@link OutreachMailboxCredentials} under the same id.\n */\nexport interface OutreachMailbox extends OutreachTimestamps {\n id: string\n provider: OutreachMailboxProvider\n /** The account's own address. */\n email: string\n /** The address mail goes out as: the account's, or an alias it may send as. */\n sendAs: string\n /**\n * The verified addresses `sendAs` may be, as Gmail listed them at the last\n * connect (AGL-2978). A changed alias shows up here on the next reconnect.\n */\n sendAsOptions: OutreachSendAsAddress[]\n /** The From name recipients see. */\n displayName: string\n status: OutreachMailboxStatus\n /** The most mail it sends in one local day, ramp included. */\n dailyCap: number\n window: OutreachSendWindow\n /** IANA zone the window and the day boundary are read in. */\n timezone: string\n /**\n * When the warm-up ramp began, or `null` for a mailbox sending at its full\n * cap. The ramp is measured from here, not from connection, so a paused\n * mailbox can restart it.\n */\n rampStartedAtMs: number | null\n health: OutreachMailboxHealth\n /** The member who connected it, and whose mail it is. */\n connectedByUid: string\n /** When the grant behind it was last connected (AGL-2978). */\n connectedAtMs: number\n /**\n * Set when the mailbox paused ITSELF on its health (AGL-2981), and cleared\n * when a member pauses or resumes it; absent otherwise.\n */\n autoPause?: OutreachMailboxAutoPause | null\n /** The reply and bounce sync's place in the mailbox (AGL-2981). */\n sync?: OutreachMailboxSync | null\n}\n\n/**\n * The provider grant behind one mailbox\n * (`outreachMailboxCredentials/{mailboxId}`).\n *\n * Only the fields every reader relies on are declared here; the token\n * material is added by the code that stores it. `orgId` is REQUIRED, not\n * decorative: the org erasure finds these documents by it, and a credential\n * written without one would outlive its workspace.\n *\n * NAME EVERY SEALED FIELD WITH A SECRET WORD — `refreshToken`,\n * `tokenCiphertext`. The personal-data export discloses these documents with\n * secrets redacted, and its redaction reads field names first: a name\n * carrying `token`, `secret` or `credential` is withheld whatever its value,\n * while a neutral name such as `ciphertext` is judged by the value's shape\n * alone and can be disclosed.\n */\nexport interface OutreachMailboxCredentials extends OutreachTimestamps {\n /** The mailbox id, which is also this document's id. */\n id: string\n orgId: string\n mailboxId: string\n provider: OutreachMailboxProvider\n}\n\n/** A sequence's lifecycle. Only an `active` sequence advances its enrollments. */\nexport const OUTREACH_SEQUENCE_STATUSES = [\n 'draft',\n 'active',\n 'paused',\n 'archived',\n] as const\nexport type OutreachSequenceStatus =\n (typeof OUTREACH_SEQUENCE_STATUSES)[number]\n\n/*==========================================\n * SEQUENCES (AGL-2979).\n *\n * The limits are the outbound playbook's: a person gets at most four emails\n * from one sequence, spaced by business days, and the tasks between them are\n * the rep's own touches — a LinkedIn note, a call. The engine\n * (`../engine/sequence-validation.ts`) holds a stored sequence to them.\n *==========================================*/\n\n/** The most steps one sequence holds, emails and tasks together. */\nexport const OUTREACH_MAX_STEPS = 8\n\n/** The most of those steps that send an email. */\nexport const OUTREACH_MAX_EMAIL_STEPS = 4\n\n/** The longest wait one step may carry, in business days. */\nexport const OUTREACH_MAX_STEP_DELAY_BUSINESS_DAYS = 30\n\n/**\n * The shortest wait before an email that follows an earlier email. The first\n * email may wait `0` — \"the next opening of the window\", or the same day as\n * a task before it — and so may a task, but each later email waits at least\n * this long after the step before it.\n */\nexport const OUTREACH_MIN_EMAIL_FOLLOW_UP_BUSINESS_DAYS = 1\n\n/**\n * One email step.\n *\n * Steps are a union on `kind`, so a later kind joins without reshaping the\n * ones already stored.\n */\nexport interface OutreachEmailStep {\n /** Stable within the sequence, so an edit that reorders steps is traceable. */\n id: string\n kind: 'email'\n /**\n * Business days to wait after the previous step, counted in the mailbox's\n * zone — after enrollment for the first step, where `0` means the next\n * opening of the sending window.\n */\n delayBusinessDays: number\n /**\n * The subject, merge fields allowed. Required on the first email and on\n * any email that starts a new thread; an in-thread email is sent as `Re:`\n * the thread's own subject, so its field is not read.\n */\n subject: string\n /**\n * Whether the email goes out as a reply in the thread the earlier emails\n * started. True by default for every email after the first; the first\n * email always starts the thread, whatever this says.\n */\n replyInThread: boolean\n /** Plain text with merge fields, as its author wrote it; `''` when `templateId` is set. */\n body: string\n /**\n * A CRM email template (`orgs/{orgId}/crmEmailTemplates/{id}`) whose body\n * is sent instead of `body`, or `null`. Only the body is taken from it: the\n * step's own subject is the one that is sent.\n */\n templateId: string | null\n}\n\n/** The rep's own touches a task step asks for. */\nexport const OUTREACH_TASK_KINDS = ['linkedin', 'call', 'todo'] as const\nexport type OutreachTaskKind = (typeof OUTREACH_TASK_KINDS)[number]\n\nexport const OUTREACH_TASK_KIND_LABELS: Record<OutreachTaskKind, string> = {\n linkedin: 'LinkedIn',\n call: 'Call',\n todo: 'To-do',\n}\n\n/** One task step: a CRM task for the rep, created when the step comes due. */\nexport interface OutreachTaskStep {\n id: string\n kind: 'task'\n taskKind: OutreachTaskKind\n /** What the task says, e.g. \"Connect on LinkedIn\". */\n title: string\n /** Business days after the previous step; `0` is the same day. */\n delayBusinessDays: number\n}\n\nexport type OutreachSequenceStep = OutreachEmailStep | OutreachTaskStep\n\n/** The countries a new sequence sends to: the United States alone. */\nexport const OUTREACH_DEFAULT_ALLOWED_COUNTRIES: readonly string[] = ['US']\n\n/** Behavior a sequence applies to every enrollment in it. */\nexport interface OutreachSequenceSettings {\n /**\n * The hours this sequence sends in, replacing its mailbox's own window;\n * `null` sends in the mailbox's. Read in the mailbox's zone either way.\n */\n window: OutreachSendWindow | null\n /**\n * ISO-3166-1 alpha-2 codes a recipient may be in, uppercase. Default\n * {@link OUTREACH_DEFAULT_ALLOWED_COUNTRIES}: Canada, the United Kingdom\n * and most of the EU need a consent basis a cold email does not have.\n */\n allowedCountries: string[]\n /** Whether a contact who is already a customer may be enrolled. Default `false`. */\n allowCustomers: boolean\n /**\n * Whether the links in this sequence's emails are rewritten so clicks are\n * counted (AGL-3239). Default `false`, and `false` on every sequence\n * written before the setting existed: turning it on changes what the\n * recipient sees in the body, which is not a change to make on anyone's\n * behalf.\n *\n * It buys the one engagement number a plain-text sequence can honestly\n * report. It costs a visible link: the destination in the body becomes a\n * short link of ours that forwards to it. Opens are the separate\n * {@link countOpens}, because a pixel needs an HTML part.\n */\n trackClicks: boolean\n /**\n * Whether this sequence's emails carry an HTML part with a tracking image,\n * so opens are counted (AGL-3395). Default `false`, and `false` on every\n * sequence written before the setting existed.\n *\n * On, each email goes out as `multipart/alternative`: the plain-text part\n * exactly as it would have been, and beside it the same words as HTML with\n * a 1×1 image on the short-link host. It costs the plain-text one-to-one\n * look, and some gateways score an HTML part with a remote image — see\n * `../engine/open-tracking.ts`. Off, nothing about the email changes and\n * the report says opens are not measured.\n */\n countOpens: boolean\n /**\n * Whether this sequence's emails carry `List-Unsubscribe` and\n * `List-Unsubscribe-Post` (RFC 8058) (AGL-3296). Default `false`, and\n * `false` on every sequence written before the setting existed.\n *\n * On, mail clients draw their own unsubscribe button — Apple Mail as \"This\n * message is from a mailing list\" — which is the easiest way out for the\n * recipient and makes a one-to-one email read as bulk. Off, the footer's\n * \"reply 'no'\" line is the way out; the footer and its postal address are\n * mandatory either way, and the reply classifier stops on a \"no\". The\n * Gmail/Yahoo one-click requirement binds bulk senders (5,000 a day), not a\n * mailbox sending a sequence.\n */\n listUnsubscribe: boolean\n}\n\n/*==========================================\n * WHAT A SEQUENCE MEASURED (AGL-3239).\n *\n * Counters on the sequence document, incremented by the sending runtime and\n * by the click route. They are NOT derived from the enrollments on read: the\n * console lists enrollments a page at a time, so a rollup taken over what is\n * loaded would report the first page's numbers as the sequence's.\n *\n * Every field is optional and every absence means \"not recorded\", never\n * zero. The distinction is the whole of `send-report.ts`'s honesty and\n * it is kept here for the same reason: a sequence that ran before this\n * existed has no counters, and reporting its click rate as 0% would publish\n * a fact about our schema as a fact about its recipients.\n *=========================================*/\n\n/**\n * The per-destination click rollup under one sequence:\n * `orgs/{orgId}/outreachSequences/{id}/reports/links`.\n *\n * One document per sequence, holding a bounded map — the campaign rollup's\n * own shape and its own cap, so \"a link\" means the same thing in a rep's\n * report and a marketer's. Here rather than beside the writer, because the\n * console's listener is a browser module and the writer is not.\n */\nexport const OUTREACH_LINK_ROLLUP_PATH = ['reports', 'links'] as const\n\n/** The counters one sequence is judged by. */\nexport interface OutreachSequenceStats {\n /** Email steps that left. One person getting four emails counts four. */\n sent?: number\n /**\n * Distinct enrollments that have had at least one email — the denominator\n * of every engagement rate, and the thing `sent` is not.\n */\n people?: number\n /**\n * At least one email of this sequence went out with its links rewritten.\n *\n * Absent is NOT false; it is \"never recorded\", which is what every\n * sequence sent before the setting existed reads as. Either way the report\n * withholds the click rate rather than showing 0% — see\n * {@link OutreachSequenceStats} above.\n */\n clickTracked?: boolean\n /** Click EVENTS judged a person's. One reader clicking twice counts two. */\n clicks?: number\n /** Enrollments whose FIRST human click was seen: the rate's numerator. */\n uniqueClicks?: number\n /**\n * Clicks a link scanner or a security gateway made, counted apart and\n * never in the rate (`../engine/click-tracking.ts`). Shown, not hidden:\n * a large number here is the reader's evidence that the small number\n * beside it is the real one.\n */\n machineClicks?: number\n /** When a person last followed a link. */\n lastClickAtMs?: number | null\n /**\n * At least one email of this sequence went out with a tracking image\n * (AGL-3395). Absent is \"never recorded\", and the report says opens are\n * not measured rather than showing 0%.\n */\n openTracked?: boolean\n /**\n * Distinct enrollments that have had at least one email carrying the\n * image — the open rate's denominator. Not `people`: a sequence that turned\n * the setting on halfway through emailed some people no image at all, and\n * they could never have been counted as opening.\n */\n openPeople?: number\n /** Opens judged a person's. One reader opening twice counts two. */\n opens?: number\n /** Enrollments whose FIRST human open was seen: the open rate's numerator. */\n uniqueOpens?: number\n /**\n * Fetches of the image a machine made — a mail privacy proxy prefetching\n * it, a gateway scanning the message — counted apart and never in the\n * rate (`../engine/open-tracking.ts`).\n */\n machineOpens?: number\n /** Of {@link machineOpens}, the ones a mail provider's image proxy made. */\n proxyOpens?: number\n /** When a person last opened one of this sequence's emails. */\n lastOpenAtMs?: number | null\n}\n\n/** What one enrollment did with the links it was sent (AGL-3239). */\nexport interface OutreachEnrollmentEngagement {\n /** Click events judged this person's, machines excluded. */\n clicks: number\n /** The first, which is what makes them one of the sequence's `uniqueClicks`. */\n firstClickAtMs: number | null\n lastClickAtMs: number | null\n /** The destination they followed last, as `sendLinkKey` reduces it. */\n lastClickUrl: string | null\n /** Clicks on this person's links that were a machine's. */\n machineClicks: number\n /**\n * Every distinct destination this person followed since the per-click\n * history began (AGL-3332), as `sendLinkKey` reduces it, oldest first\n * and at most {@link OUTREACH_ENGAGEMENT_LINKS_MAX}. What the table counts\n * as \"links\" and filters \"followed this link\" by, without a read of the\n * history. A click from before the history kept only `lastClickUrl`.\n */\n links?: string[]\n /**\n * How many of `clicks` and `machineClicks` have a row of their own in the\n * enrollment's history (AGL-3332). The rest were counted as totals only —\n * before the history began, or past {@link OUTREACH_ENROLLMENT_HISTORY_MAX}.\n */\n loggedClicks?: number\n loggedMachineClicks?: number\n /** Opens judged this person's, machines excluded (AGL-3395). */\n opens?: number\n /** The first, which is what makes them one of the sequence's `uniqueOpens`. */\n firstOpenAtMs?: number | null\n lastOpenAtMs?: number | null\n /** Fetches of this person's tracking image that were a machine's. */\n machineOpens?: number\n /** How many of `opens` and `machineOpens` have a row in the history. */\n loggedOpens?: number\n}\n\n/**\n * The most distinct destinations {@link OutreachEnrollmentEngagement.links}\n * holds. The enrollment is what the enrollments table listens to, so the\n * list is bounded; a sequence's emails carry a link or two each, and nobody\n * follows twenty different ones.\n */\nexport const OUTREACH_ENGAGEMENT_LINKS_MAX = 20\n\n/*==========================================\n * ONE PERSON'S HISTORY (AGL-3332).\n *\n * `orgs/{orgId}/outreachEnrollments/{id}/history/{entryId}`: a row for each\n * visit to a tracking link in this person's emails — which link, from which\n * step, when, and whether a person or a scanner made it — for each fetch\n * of the tracking image in a sequence that counts opens (AGL-3395), and for\n * each pause, resume, stop and do-not-contact a member applied. The enrollment\n * keeps totals; this keeps the events, and is read only when somebody opens\n * the person, so the table's listener never carries it.\n *\n * Server-written, read-only to members, and erased with the enrollment.\n *==========================================*/\n\n/** The history's subcollection under an enrollment. */\nexport const OUTREACH_ENROLLMENT_HISTORY = 'history'\n\n/**\n * The most rows one enrollment's history holds. Past it a click is still\n * counted on the engagement, and the detail view says how many went\n * unlisted — a scanner fetching the same links for a month must not grow a\n * person's history without end.\n */\nexport const OUTREACH_ENROLLMENT_HISTORY_MAX = 500\n\n/** A member's act on one enrollment, as its history records it. */\nexport type OutreachHistoryAction = 'pause' | 'resume' | 'stop' | 'do_not_contact'\n\n/** One visit to a tracking link. */\nexport interface OutreachClickHistoryEntry {\n id: string\n kind: 'click'\n atMs: number\n /** The destination as `sendLinkKey` reduces it — the link rollup's key; `null` when unreadable. */\n url: string | null\n /** The step whose email carried the link. */\n stepIndex: number\n /** Whether it counts: a person's click, not a scanner's. */\n human: boolean\n /** Why it was read as a scanner's; `null` for a person's. */\n machineReason: OutreachClickMachineReason | null\n}\n\n/** One member's act on the enrollment. */\nexport interface OutreachActionHistoryEntry {\n id: string\n kind: 'action'\n atMs: number\n action: OutreachHistoryAction\n byUid: string\n /** The reason the member typed, if any. */\n detail: string | null\n}\n\n/** One fetch of the tracking image in this person's email (AGL-3395). */\nexport interface OutreachOpenHistoryEntry {\n id: string\n kind: 'open'\n atMs: number\n /** The step whose email carried the image. */\n stepIndex: number\n /** Whether it counts: a person's open, not a proxy's or a scanner's. */\n human: boolean\n /** Why it was read as a machine's; `null` for a person's. */\n machineReason: OutreachOpenMachineReason | null\n /** The agent the fetch sent (AGL-3488); `null` on rows from before it was kept. */\n userAgent?: string | null\n /** The network the fetch came from (AGL-3488); `null` when unknown or not kept. */\n source?: OutreachOpenSource | null\n}\n\nexport type OutreachEnrollmentHistoryEntry =\n | OutreachClickHistoryEntry\n | OutreachOpenHistoryEntry\n | OutreachActionHistoryEntry\n\n/** An ordered set of steps sent from one mailbox (`orgs/{orgId}/outreachSequences/{id}`). */\nexport interface OutreachSequence extends OutreachTimestamps {\n id: string\n name: string\n /** The site whose CRM the enrolled people are records of. */\n hostId: string\n /**\n * The mailbox every email step is sent from. A setting of the sequence,\n * kept beside `settings` rather than inside it because enrollments and a\n * mailbox's own screens select sequences by it.\n */\n mailboxId: string\n steps: OutreachSequenceStep[]\n settings: OutreachSequenceSettings\n status: OutreachSequenceStatus\n /**\n * The campaigns the sequence is in (AGL-3254): container ids from the\n * org's `emailCampaigns`, under the field every campaign member carries\n * (`containerMembershipField('campaign')`). Everyone enrolled gains them on their\n * own record at enroll time, and what the sequence produces is credited\n * to them. Absent on a sequence saved before it could join one.\n */\n campaignIds?: string[]\n /**\n * What it measured (AGL-3239). Absent until the first email leaves, and\n * absent forever on a sequence that finished before the counters existed.\n */\n stats?: OutreachSequenceStats\n}\n\n/*==========================================\n * ENROLLMENTS (AGL-2979).\n *==========================================*/\n\n/**\n * Where one person's run through a sequence stands.\n *\n * `active` sends and `paused` waits. The rest end the sending, and each says\n * why: `finished` sent every step, `replied` heard back, `bounced` reached a\n * mailbox that does not exist, `opted_out` was asked to stop, `stopped` was\n * ended by a member or a gate, `failed` could not be sent. The transitions\n * between them are the engine's (`../engine/enrollment-state.ts`).\n */\nexport const OUTREACH_ENROLLMENT_STATUSES = [\n 'active',\n 'paused',\n 'finished',\n 'replied',\n 'bounced',\n 'opted_out',\n 'stopped',\n 'failed',\n] as const\nexport type OutreachEnrollmentStatus =\n (typeof OUTREACH_ENROLLMENT_STATUSES)[number]\n\n/**\n * Why an enrollment is not `active`, recorded beside the status. `finished`\n * needs none; each other status allows the reasons\n * `OUTREACH_STOP_REASONS_BY_STATUS` names.\n */\nexport const OUTREACH_STOP_REASONS = [\n /** A person wrote back in the thread. */\n 'reply',\n /** The recipient's server refused the address for good. */\n 'hard_bounce',\n /** A reply asked not to be emailed again. */\n 'opt_out_reply',\n /** The unsubscribe link or header was used. */\n 'unsubscribe',\n /** The address is on the organization's do-not-contact list. */\n 'do_not_contact',\n /** A gate refused the next send — the person became a customer, say. */\n 'gate',\n /** A member paused or stopped it. */\n 'manual',\n /**\n * The engine held the next send (AGL-3326): the recipient's mail gateway\n * refused this organization's sender twice in the last thirty days and\n * delivered nothing. A member resumes it to send anyway.\n */\n 'gateway_blocked_here',\n /** The sequence was archived with the person still in it. */\n 'sequence_archived',\n /** The provider refused the send for good, or the email could not be composed. */\n 'send_failed',\n] as const\nexport type OutreachStopReason = (typeof OUTREACH_STOP_REASONS)[number]\n\n/** The statuses a stop reason is recorded with, and the reasons each allows. */\nexport const OUTREACH_STOP_REASONS_BY_STATUS: Readonly<\n Record<\n Exclude<OutreachEnrollmentStatus, 'active' | 'finished'>,\n readonly OutreachStopReason[]\n >\n> = {\n paused: ['manual', 'gateway_blocked_here'],\n replied: ['reply'],\n bounced: ['hard_bounce'],\n opted_out: ['opt_out_reply', 'unsubscribe', 'do_not_contact'],\n stopped: ['manual', 'gate', 'sequence_archived'],\n failed: ['send_failed'],\n}\n\n/**\n * What a rep confirms before a COLD contact is enrolled — one with no\n * inbound capture behind them — each recorded with who confirmed it and\n * when, because each is a fact only the rep can know:\n *\n * - `us_business_address`: the address is a business address in the US;\n * - `published_or_given`: they or their company published it, or they gave\n * it to us — never guessed from a name or bought on a list;\n * - `verified_deliverable`: a verifier said it accepts mail.\n */\nexport const OUTREACH_ATTESTATION_KINDS = [\n 'us_business_address',\n 'published_or_given',\n 'verified_deliverable',\n] as const\nexport type OutreachAttestationKind = (typeof OUTREACH_ATTESTATION_KINDS)[number]\n\n/** The sentence a rep ticks for each attestation. */\nexport const OUTREACH_ATTESTATION_LABELS: Record<OutreachAttestationKind, string> = {\n us_business_address: 'This is a US business address',\n published_or_given:\n 'They or their company published this address, or they gave it to us',\n verified_deliverable: 'This address was verified as deliverable',\n}\n\n/** One confirmation, as stored. */\nexport interface OutreachAttestation {\n /** The member who confirmed it. */\n uid: string\n atMs: number\n}\n\n/** The confirmations an enrollment carries, by kind. */\nexport type OutreachAttestations = Partial<\n Record<OutreachAttestationKind, OutreachAttestation>\n>\n\n/** The longest personal line an enrollment keeps: one sentence, not a letter. */\nexport const OUTREACH_PERSONAL_LINE_MAX = 300\n\n/*==========================================\n * CURATED STEPS (AGL-3324).\n *\n * A step is one template for everyone, plus the personal line. Curating\n * rewrites ONE person's copy of a step — drafted by the workspace's AI from\n * their record and the step's own body as the skeleton, or written by the\n * member — and keeps it on the enrollment, never on the sequence. The send\n * job reads the override in place of the step's subject and body; the\n * tokens, the footer, the click tracking and the plain-text rules still\n * apply to it exactly as they apply to the step.\n *\n * Nothing is stored that a member has not read: a draft lands on the\n * enrollment only when the member confirms it, with who and when.\n *==========================================*/\n\n/** Who wrote the override: the AI, or the member by hand. */\nexport const OUTREACH_STEP_OVERRIDE_SOURCES = ['ai', 'member'] as const\nexport type OutreachStepOverrideSource = (typeof OUTREACH_STEP_OVERRIDE_SOURCES)[number]\n\n/** One person's own copy of one step. */\nexport interface OutreachStepOverride {\n /** The subject, merge fields allowed; absent keeps the step's own. Not read on an in-thread email. */\n subject?: string\n /** The plain-text body, merge fields allowed; absent keeps the step's own (or its template's). */\n body?: string\n source: OutreachStepOverrideSource\n /** When the member confirmed it — the moment it was stored, never before. */\n draftedAtMs: number\n /** The member who confirmed it. */\n draftedByUid?: string\n /** An AI draft the member changed before confirming it. */\n edited?: boolean\n /** The prompt the AI was given, for the audit log; absent on a member's own words. */\n prompt?: string\n /** The model that drafted it, for the audit log. */\n model?: string\n}\n\n/** The overrides an enrollment carries, keyed by the step's index as text. */\nexport type OutreachStepOverrides = Record<string, OutreachStepOverride>\n\n/** The sentence a member ticks before a curated draft is stored — a fourth attestation. */\nexport const OUTREACH_CURATION_CONFIRMATION_LABEL =\n \"I've read this draft, and it goes out to this person as written\"\n\n/**\n * Which CRM record an enrollment names (AGL-3234). A person is a LEAD until\n * somebody qualifies them and a CONTACT after, and a sequence works either:\n * an enrollment made on a lead follows the lead to the contact it becomes,\n * so the thread and the steps carry on as one enrollment.\n */\nexport const OUTREACH_ENROLLMENT_TARGETS = ['contact', 'lead'] as const\nexport type OutreachEnrollmentTarget = (typeof OUTREACH_ENROLLMENT_TARGETS)[number]\n\n/** One person in one sequence (`orgs/{orgId}/outreachEnrollments/{id}`). */\nexport interface OutreachEnrollment extends OutreachTimestamps {\n id: string\n sequenceId: string\n /**\n * The record the person is (AGL-3234): `contact` for a CRM contact,\n * `lead` for a lead the sequence's site holds. A stored enrollment with\n * no target is a contact's — every enrollment was, before leads could be\n * sequenced.\n */\n target: OutreachEnrollmentTarget\n /**\n * The CRM contact the person is — `''` while the enrollment targets a\n * lead that has not converted. Filled in, beside `target: 'contact'`, the\n * moment the lead becomes a contact.\n */\n contactId: string\n /**\n * `hosts/{hostId}/leads/{leadId}` — the person key — for an enrollment\n * made on a lead; kept once the lead converts, so the lead's page still\n * lists the sequence. `null` for an enrollment made on a contact.\n */\n leadId: string | null\n /**\n * The person's name as the sending site knew it at enrollment, `''` when\n * it had none — what the enrollments table shows beside the address,\n * without a read of every record on the page (AGL-2980).\n */\n contactName: string\n /** The address the steps go to, normalized, captured at enrollment. */\n email: string\n /**\n * What the enrollments table's search box reads (AGL-3321): every prefix\n * of the name and of the address and its parts\n * (`outreachEnrollmentSearchTokens`), stamped by the enroll route beside\n * the two it is made of, which nothing rewrites afterwards.\n */\n searchTokens?: string[]\n hostId: string\n mailboxId: string\n /** The index into `steps` of the NEXT step to run. */\n stepIndex: number\n /**\n * The step the enrollment began at (AGL-3228), when it was not the first:\n * the member enrolled someone who already had the earlier steps by hand.\n * Absent on an enrollment that began at step 1. The first email sent from\n * here starts the enrollment's thread, whatever `replyInThread` says —\n * there is no earlier email of ours for it to answer.\n */\n startStepIndex?: number\n /**\n * The steps before {@link startStepIndex}, marked skipped at enrollment\n * and never run (AGL-3228). Absent when none were.\n */\n skippedSteps?: OutreachSkippedStep[]\n /** When that step comes due, or `null` when nothing is waiting. */\n nextDueAtMs: number | null\n status: OutreachEnrollmentStatus\n /** Why the status is not `active`; `null` while active and once finished. */\n stopReason: OutreachStopReason | null\n /** Plain-language detail: the gate's reason, the bounce's diagnostic. */\n stopDetail: string | null\n stoppedAtMs: number | null\n /** The member who paused or stopped it; `null` when the engine did. */\n stoppedByUid: string | null\n /**\n * The rep's signal sentence — why this person, now — merged into the\n * steps as `{{enrollment.personalLine}}`. Required for a cold contact.\n */\n personalLine: string\n /** Whether the contact was cold (no inbound capture) when enrolled. */\n cold: boolean\n attestations: OutreachAttestations\n /** The member who enrolled the person. */\n enrolledByUid: string\n /** The provider thread the next in-thread email is sent into, once one exists. */\n gmailThreadId: string | null\n /** Every provider thread this enrollment has sent into, oldest first — what reply sync watches. */\n gmailThreadIds: string[]\n /** The subject the current thread was started with, as sent. */\n threadSubject: string | null\n /**\n * The `Message-ID`s of the emails sent into the current thread, oldest\n * first, angle brackets included: the next in-thread email answers the\n * last and names them all in `References`.\n */\n messageIds: string[]\n /** When the last step ran. */\n lastSentAtMs: number | null\n /**\n * A sending run's hold on the step it is running (AGL-2981): taken in a\n * transaction before the step runs, cleared when it is recorded. Absent\n * or `null` while no run holds one.\n */\n sendClaim?: OutreachSendClaim | null\n /** Every step the runtime ran, oldest first (AGL-2981). */\n stepRecords?: OutreachStepRecord[]\n /** Gmail ids of this enrollment's thread messages the sync has handled, the last hundred. */\n syncedMessageIds?: string[]\n /**\n * What this person did with the links they were sent (AGL-3239). Absent\n * until their first click, which is why the table reads an absence as\n * \"no clicks\" only for a sequence that tracks them at all.\n */\n engagement?: OutreachEnrollmentEngagement\n /**\n * Whether the person clicked a link (AGL-3332): what the enrollments\n * table's \"Clicked\" filter asks Firestore. `false` from enrollment, set\n * by the click route on a person's click, never a scanner's.\n */\n clicked?: boolean\n /**\n * The sequence's campaigns as they stood when the person was enrolled\n * (AGL-3254): what every outcome of this enrollment is credited to. A\n * campaign the sequence joins later does not claim the people already\n * in it, and one it leaves keeps what it was credited with.\n */\n campaignIds?: string[]\n /**\n * This person's own copies of steps (AGL-3324), by step index. Absent on\n * an enrollment nobody curated, which sends the sequence's steps as\n * written; a step without an entry sends the same.\n */\n stepOverrides?: OutreachStepOverrides\n /**\n * The gateway hold (AGL-3326), once one applied: which gateway, when the\n * engine held the send, and the member who released it — by resuming the\n * held enrollment, or by ticking the person past the red chip when they\n * enrolled them. A released hold is not taken again; a send that the\n * engine held and nobody released waits.\n */\n gatewayHold?: OutreachGatewayHold | null\n /**\n * How many of this enrollment's email steps the sync has credited to the\n * gateway ledger as delivered (AGL-3326): a send with no bounce a day\n * later. The sync credits the next ones from here.\n */\n gatewayDeliveredSteps?: number\n}\n\n/** A gateway hold on one enrollment (AGL-3326) — see {@link OutreachEnrollment.gatewayHold}. */\nexport interface OutreachGatewayHold {\n gateway: OutreachMailGateway\n /** When the engine held a send; `null` when a member released it before one was. */\n heldAtMs: number | null\n releasedByUid: string | null\n releasedAtMs: number | null\n}\n\n\n/**\n * The organization's ledger for one mail gateway as first written\n * (`orgs/{orgId}/outreachGatewayStats/{gateway}`, AGL-3326): totals, and the\n * same counts by UTC day. Read through, never written — see\n * `OUTREACH_COLLECTIONS.gatewayStats`.\n */\nexport interface OutreachGatewayStats {\n gateway: OutreachMailGateway\n sent: number\n delivered: number\n blocked: number\n lastBlockedAtMs: number | null\n /** `YYYY-MM-DD` (UTC) → that day's counts, the last thirty days kept. */\n days: Record<string, OutreachGatewayDayCounts>\n updatedAtMs: number\n}\n\n/** A sending run's claim on one enrollment's step (AGL-2981). */\nexport interface OutreachSendClaim {\n /** The run that holds it. */\n token: string\n atMs: number\n stepIndex: number\n /**\n * The `Message-ID` an email step goes out with, minted before the send, so\n * a claim a run died holding is settled by looking for the message rather\n * than by sending it again. `null` for a task step.\n */\n messageId: string | null\n}\n\n/**\n * One step an enrollment skipped because it began past it (AGL-3228): the\n * person already had it by hand, so the runtime never runs it. Kept apart\n * from {@link OutreachStepRecord}, which every reader counts as a send.\n */\nexport interface OutreachSkippedStep {\n stepIndex: number\n stepId: string\n kind: 'email' | 'task'\n /** When it was marked skipped: the enrollment. */\n atMs: number\n}\n\n/** One step the runtime ran for an enrollment (AGL-2981). */\nexport interface OutreachStepRecord {\n stepIndex: number\n stepId: string\n kind: 'email' | 'task'\n atMs: number\n /** Gmail's id for the sent message. */\n gmailMessageId?: string\n /** Gmail's thread the message went into. */\n gmailThreadId?: string\n /** The `Message-ID` it went out with, angle brackets included. */\n messageId?: string\n /** The subject as sent. */\n subject?: string\n /** The record system's task for a task step; `null` when none could be filed. */\n taskId?: string | null\n /**\n * The destinations this email's links were rewritten to point at, in the\n * order a click token indexes them (AGL-3239). Absent on a step that\n * carried no links, and on every step sent before tracking existed.\n *\n * Kept so the console can say WHICH link a person followed without the\n * token having to carry the URL back to us, and so a rewritten body can be\n * read afterwards for what it actually offered them.\n */\n links?: string[]\n /**\n * The email carried a tracking image (AGL-3395). Absent on every email\n * sent without one — which is every email of a sequence that does not\n * count opens.\n */\n openTracked?: boolean\n /**\n * The email went out as this person's curated copy (AGL-3324), and who\n * wrote it. Absent on a step sent as the sequence wrote it.\n */\n curated?: OutreachStepOverrideSource\n}\n\n/*==========================================\n * ORGANIZATION SETTINGS (AGL-2979).\n *==========================================*/\n\n/**\n * What every Outreach email's footer says about who sent it — the\n * identification and the postal address CAN-SPAM requires on commercial\n * mail. The composer refuses to write an email without a legal name and a\n * postal address, and a sequence cannot be activated without them.\n */\nexport interface OutreachOrgSettings {\n /** The organization's legal name, as the footer prints it: \"Example Co LLC\". */\n legalName: string\n /**\n * The name the solicitation sentence uses when it is not the legal name:\n * \"This is a sales email from Example Co.\" `''` uses the legal\n * name.\n */\n brandName: string\n /**\n * A valid physical postal address: a street address, a USPS PO box, or a\n * private mailbox registered with the USPS. Line breaks are printed as\n * commas.\n */\n postalAddress: string\n}\n\n/** The id of the compliance document in the `settings` collection. */\nexport const OUTREACH_COMPLIANCE_SETTINGS_ID = 'compliance'\n\n/**\n * The organization's Outreach compliance settings\n * (`orgs/{orgId}/outreachSettings/compliance`): the footer's sender identity,\n * and the countries Outreach may send to at all.\n *\n * `allowedCountries` is a CEILING over every sequence's own list — a\n * sequence sends only to the countries both name — so narrowing it here\n * narrows every sequence at once, without editing any of them. Default\n * {@link OUTREACH_DEFAULT_ALLOWED_COUNTRIES}.\n */\nexport interface OutreachComplianceSettings extends OutreachOrgSettings {\n /** ISO-3166-1 alpha-2 codes, uppercase, in the order they were chosen. */\n allowedCountries: string[]\n}\n\n/** The compliance settings as stored, with who changed them last. */\nexport interface OutreachComplianceSettingsDocument\n extends OutreachComplianceSettings {\n /** `0` until the organization first saves them. */\n updatedAtMs: number\n updatedByUid: string | null\n}\n\n/*==========================================\n * DO NOT CONTACT (AGL-2980).\n *\n * The organization's own list of addresses Outreach never emails, whoever\n * enrolls them and from whichever site. A member adds one by hand; the\n * sending runtime adds one when a reply asks to be left alone, when the\n * unsubscribe link is used, and when an address bounces for good.\n *\n * AN ENTRY CARRIES NO ADDRESS. Its id is `outreachDoNotContactKey(email)` —\n * the same hash the platform's suppression lists key by — and that is all a\n * lookup needs, since every caller holds the address it is about to use.\n * So the list keeps working after a person is erased from the workspace,\n * which is exactly when a promise not to email them must still hold, while\n * holding nothing that identifies them.\n *==========================================*/\n\n/** Why an address is on the list. */\nexport const OUTREACH_DO_NOT_CONTACT_REASONS = [\n /** A member put it there. */\n 'manual',\n /** A reply asked not to be emailed again. */\n 'opt_out_reply',\n /** The unsubscribe link or header was used. */\n 'unsubscribe',\n /** Mail to it bounced for good. */\n 'hard_bounce',\n /**\n * The recipient organization's mail gateway refused the sender outright\n * (AGL-3244) — a Barracuda, Proofpoint or Mimecast policy block — which is\n * a verdict on the whole domain, and is filed against it.\n */\n 'gateway_block',\n] as const\nexport type OutreachDoNotContactReason =\n (typeof OUTREACH_DO_NOT_CONTACT_REASONS)[number]\n\n/** Why an entry is on the list, as the Compliance page and an export say it. */\nexport const OUTREACH_DO_NOT_CONTACT_REASON_LABELS: Record<OutreachDoNotContactReason, string> = {\n manual: 'Added by a member',\n opt_out_reply: 'A reply asked not to be emailed',\n unsubscribe: 'Unsubscribed',\n hard_bounce: 'Mail bounced',\n gateway_block: 'Its mail gateway blocked the sender',\n}\n\n/** What put an address on the list: a member, or the sending runtime. */\nexport const OUTREACH_DO_NOT_CONTACT_SOURCES = ['member', 'runtime'] as const\nexport type OutreachDoNotContactSource =\n (typeof OUTREACH_DO_NOT_CONTACT_SOURCES)[number]\n\n/** Who added an entry, as an export says it. */\nexport const OUTREACH_DO_NOT_CONTACT_SOURCE_LABELS: Record<OutreachDoNotContactSource, string> = {\n member: 'A member',\n runtime: 'Sequences, automatically',\n}\n\n/** One address on the list (`orgs/{orgId}/outreachDoNotContact/{key}`). */\nexport interface OutreachDoNotContactEntry {\n /** `outreachDoNotContactKey` of the address, which is also the document id. */\n key: string\n reason: OutreachDoNotContactReason\n source: OutreachDoNotContactSource\n /** The member who added it; `null` when the runtime did. */\n addedByUid: string | null\n addedAtMs: number\n /** The enrollment that led here, when one did. */\n enrollmentId: string | null\n /** That enrollment's sequence. */\n sequenceId: string | null\n /** Plain-language detail: why the member added it, the bounce's diagnostic. */\n detail: string | null\n}\n\n/**\n * One domain on the list (`orgs/{orgId}/outreachDoNotContactDomains/{domain}`)\n * (AGL-3244): no address at it is emailed, whoever enrolls them.\n *\n * Unlike an address entry it CARRIES THE DOMAIN, in clear, because the\n * Compliance page lists it and a member takes it off by name; a domain is a\n * company's, not a person's, and a person erasure leaves it alone. A member\n * adds one by hand; the sending runtime adds one when a hard bounce reads\n * as the domain's mail gateway refusing the sender rather than one address\n * being unknown.\n */\nexport interface OutreachDoNotContactDomainEntry {\n /** The domain, lower-cased, which is also the document id. */\n domain: string\n reason: OutreachDoNotContactReason\n source: OutreachDoNotContactSource\n /** The member who added it; `null` when the runtime did. */\n addedByUid: string | null\n addedAtMs: number\n /** The enrollment whose bounce led here, when one did. */\n enrollmentId: string | null\n /** That enrollment's sequence. */\n sequenceId: string | null\n /** Plain-language detail: the member's note, or the bounce's diagnostic. */\n detail: string | null\n /**\n * What the domains list's search box reads (AGL-3321):\n * `outreachDomainSearchTokens`, stamped by the one writer that adds it.\n */\n searchTokens?: string[]\n}\n"],"names":["OUTREACH_COLLECTIONS","mailboxes","sequences","enrollments","settings","doNotContact","doNotContactDomains","domainIntel","gatewayStats","mailboxCredentials","links","outreachOrgCollectionPath","orgId","collection","OUTREACH_MAILBOX_PROVIDERS","OUTREACH_MAILBOX_STATUSES","OUTREACH_SEQUENCE_STATUSES","OUTREACH_MAX_STEPS","OUTREACH_MAX_EMAIL_STEPS","OUTREACH_MAX_STEP_DELAY_BUSINESS_DAYS","OUTREACH_MIN_EMAIL_FOLLOW_UP_BUSINESS_DAYS","OUTREACH_TASK_KINDS","OUTREACH_TASK_KIND_LABELS","linkedin","call","todo","OUTREACH_DEFAULT_ALLOWED_COUNTRIES","OUTREACH_LINK_ROLLUP_PATH","OUTREACH_ENGAGEMENT_LINKS_MAX","OUTREACH_ENROLLMENT_HISTORY","OUTREACH_ENROLLMENT_HISTORY_MAX","OUTREACH_ENROLLMENT_STATUSES","OUTREACH_STOP_REASONS","OUTREACH_STOP_REASONS_BY_STATUS","paused","replied","bounced","opted_out","stopped","failed","OUTREACH_ATTESTATION_KINDS","OUTREACH_ATTESTATION_LABELS","us_business_address","published_or_given","verified_deliverable","OUTREACH_PERSONAL_LINE_MAX","OUTREACH_STEP_OVERRIDE_SOURCES","OUTREACH_CURATION_CONFIRMATION_LABEL","OUTREACH_ENROLLMENT_TARGETS","OUTREACH_COMPLIANCE_SETTINGS_ID","OUTREACH_DO_NOT_CONTACT_REASONS","OUTREACH_DO_NOT_CONTACT_REASON_LABELS","manual","opt_out_reply","unsubscribe","hard_bounce","gateway_block","OUTREACH_DO_NOT_CONTACT_SOURCES","OUTREACH_DO_NOT_CONTACT_SOURCE_LABELS","member","runtime"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;CAmBC,GAOD;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMA,uBAAuB;IAClC,wEAAwE,GACxEC,WAAW;IACX,uEAAuE,GACvEC,WAAW;IACX,oFAAoF,GACpFC,aAAa;IACb;;;;GAIC,GACDC,UAAU;IACV;;;GAGC,GACDC,cAAc;IACd;;;;GAIC,GACDC,qBAAqB;IACrB;;;;;GAKC,GACDC,aAAa;IACb;;;;;;;GAOC,GACDC,cAAc;IACd;;;;GAIC,GACDC,oBAAoB;IACpB;;;;;;GAMC,GACDC,OAAO;AACT,EAAU;AAQV,uEAAuE,GACvE,OAAO,SAASC,0BACdC,KAAa,EACbC,UAAiC;IAEjC,OAAO,CAAC,KAAK,EAAED,MAAM,CAAC,EAAEZ,oBAAoB,CAACa,WAAW,EAAE;AAC5D;AAQA,2DAA2D,GAC3D,OAAO,MAAMC,6BAA6B;IAAC;CAAS,CAAS;AAI7D;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B;IACvC;IACA;IACA;IACA;CACD,CAAS;AAyLV,gFAAgF,GAChF,OAAO,MAAMC,6BAA6B;IACxC;IACA;IACA;IACA;CACD,CAAS;AAIV;;;;;;;4CAO4C,GAE5C,kEAAkE,GAClE,OAAO,MAAMC,qBAAqB,EAAC;AAEnC,gDAAgD,GAChD,OAAO,MAAMC,2BAA2B,EAAC;AAEzC,2DAA2D,GAC3D,OAAO,MAAMC,wCAAwC,GAAE;AAEvD;;;;;CAKC,GACD,OAAO,MAAMC,6CAA6C,EAAC;AAwC3D,gDAAgD,GAChD,OAAO,MAAMC,sBAAsB;IAAC;IAAY;IAAQ;CAAO,CAAS;AAGxE,OAAO,MAAMC,4BAA8D;IACzEC,UAAU;IACVC,MAAM;IACNC,MAAM;AACR,EAAC;AAeD,oEAAoE,GACpE,OAAO,MAAMC,qCAAwD;IAAC;CAAK,CAAA;AA2D3E;;;;;;;;;;;;;2CAa2C,GAE3C;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B;IAAC;IAAW;CAAQ,CAAS;AAmGtE;;;;;CAKC,GACD,OAAO,MAAMC,gCAAgC,GAAE;AAE/C;;;;;;;;;;;;4CAY4C,GAE5C,qDAAqD,GACrD,OAAO,MAAMC,8BAA8B,UAAS;AAEpD;;;;;CAKC,GACD,OAAO,MAAMC,kCAAkC,IAAG;AAmFlD;;4CAE4C,GAE5C;;;;;;;;CAQC,GACD,OAAO,MAAMC,+BAA+B;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAIV;;;;CAIC,GACD,OAAO,MAAMC,wBAAwB;IACnC,uCAAuC,GACvC;IACA,yDAAyD,GACzD;IACA,2CAA2C,GAC3C;IACA,6CAA6C,GAC7C;IACA,8DAA8D,GAC9D;IACA,sEAAsE,GACtE;IACA,mCAAmC,GACnC;IACA;;;;GAIC,GACD;IACA,2DAA2D,GAC3D;IACA,gFAAgF,GAChF;CACD,CAAS;AAGV,8EAA8E,GAC9E,OAAO,MAAMC,kCAKT;IACFC,QAAQ;QAAC;QAAU;KAAuB;IAC1CC,SAAS;QAAC;KAAQ;IAClBC,SAAS;QAAC;KAAc;IACxBC,WAAW;QAAC;QAAiB;QAAe;KAAiB;IAC7DC,SAAS;QAAC;QAAU;QAAQ;KAAoB;IAChDC,QAAQ;QAAC;KAAc;AACzB,EAAC;AAED;;;;;;;;;CASC,GACD,OAAO,MAAMC,6BAA6B;IACxC;IACA;IACA;CACD,CAAS;AAGV,mDAAmD,GACnD,OAAO,MAAMC,8BAAuE;IAClFC,qBAAqB;IACrBC,oBACE;IACFC,sBAAsB;AACxB,EAAC;AAcD,+EAA+E,GAC/E,OAAO,MAAMC,6BAA6B,IAAG;AAE7C;;;;;;;;;;;;;4CAa4C,GAE5C,2DAA2D,GAC3D,OAAO,MAAMC,iCAAiC;IAAC;IAAM;CAAS,CAAS;AAyBvE,yFAAyF,GACzF,OAAO,MAAMC,uCACX,kEAAiE;AAEnE;;;;;CAKC,GACD,OAAO,MAAMC,8BAA8B;IAAC;IAAW;CAAO,CAAS;AAuQvE,oEAAoE,GACpE,OAAO,MAAMC,kCAAkC,aAAY;AAyB3D;;;;;;;;;;;;;;4CAc4C,GAE5C,mCAAmC,GACnC,OAAO,MAAMC,kCAAkC;IAC7C,2BAA2B,GAC3B;IACA,2CAA2C,GAC3C;IACA,6CAA6C,GAC7C;IACA,iCAAiC,GACjC;IACA;;;;GAIC,GACD;CACD,CAAS;AAIV,8EAA8E,GAC9E,OAAO,MAAMC,wCAAoF;IAC/FC,QAAQ;IACRC,eAAe;IACfC,aAAa;IACbC,aAAa;IACbC,eAAe;AACjB,EAAC;AAED,uEAAuE,GACvE,OAAO,MAAMC,kCAAkC;IAAC;IAAU;CAAU,CAAS;AAI7E,8CAA8C,GAC9C,OAAO,MAAMC,wCAAoF;IAC/FC,QAAQ;IACRC,SAAS;AACX,EAAC"}
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { type
|
|
17
|
+
import { type SendLinkReport, type SendLinkRollup, type SendRate } from '@aglyn/shared-ui-email-campaigns/model/send-report';
|
|
18
18
|
import type { OutreachSequenceStats } from './outreach.types';
|
|
19
19
|
/** Why a number a reader expects is missing, or must not be read the obvious way. */
|
|
20
20
|
export interface OutreachReportCaveat {
|
|
21
21
|
/** Stable id, so a spec asserts on the caveat and not on its prose. */
|
|
22
|
-
id: 'opens-not-measured' | 'opens-unrecorded' | 'opens-counted' | 'opens-stopped' | 'clicks-not-tracked' | 'clicks-unrecorded' | 'machine-clicks-excluded';
|
|
22
|
+
id: 'opens-not-measured' | 'opens-unrecorded' | 'opens-counted' | 'opens-stopped' | 'opens-all-machine' | 'clicks-not-tracked' | 'clicks-unrecorded' | 'machine-clicks-excluded';
|
|
23
23
|
message: string;
|
|
24
24
|
}
|
|
25
25
|
/** Everything the sequence's report card renders. */
|
|
@@ -52,6 +52,13 @@ export interface OutreachSequenceReport {
|
|
|
52
52
|
proxyOpens: number;
|
|
53
53
|
/** When a person last opened one of the emails. */
|
|
54
54
|
lastOpenAtMs: number | null;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the image was fetched and EVERY fetch was a machine's
|
|
57
|
+
* (AGL-3488): the open rate is then unmeasured rather than nought — the
|
|
58
|
+
* scanners in front of these inboxes answered for everyone, and whether
|
|
59
|
+
* a person read the mail behind them cannot be told from here.
|
|
60
|
+
*/
|
|
61
|
+
opensUnmeasured: boolean;
|
|
55
62
|
rates: {
|
|
56
63
|
/**
|
|
57
64
|
* Distinct people who clicked, over the people emailed.
|
|
@@ -59,14 +66,14 @@ export interface OutreachSequenceReport {
|
|
|
59
66
|
* `null` when the sequence never sent a tracked link, when nobody has
|
|
60
67
|
* been emailed yet, and when the counters predate the feature.
|
|
61
68
|
*/
|
|
62
|
-
click:
|
|
69
|
+
click: SendRate | null;
|
|
63
70
|
/**
|
|
64
71
|
* Distinct people who opened, over the people sent the image.
|
|
65
72
|
*
|
|
66
|
-
* `null` when no email carried the image,
|
|
67
|
-
* one yet.
|
|
73
|
+
* `null` when no email carried the image, when nobody has been sent
|
|
74
|
+
* one yet, and when only machines fetched it (`opensUnmeasured`).
|
|
68
75
|
*/
|
|
69
|
-
open:
|
|
76
|
+
open: SendRate | null;
|
|
70
77
|
};
|
|
71
78
|
caveats: OutreachReportCaveat[];
|
|
72
79
|
}
|
|
@@ -88,4 +95,4 @@ export declare function outreachSequenceReport(stats: OutreachSequenceStats | un
|
|
|
88
95
|
* key derivation is the campaign one, and the table a rep reads should be
|
|
89
96
|
* the same table a marketer reads.
|
|
90
97
|
*/
|
|
91
|
-
export declare function outreachSequenceLinkReport(rollup:
|
|
98
|
+
export declare function outreachSequenceLinkReport(rollup: SendLinkRollup | undefined): SendLinkReport;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/ /*==========================================
|
|
17
17
|
* WHAT A SEQUENCE MEASURED, AND WHAT IT DID NOT (AGL-3239).
|
|
18
18
|
*
|
|
19
|
-
* The rules are `
|
|
19
|
+
* The rules are `send-report.ts`'s, applied to a channel that can
|
|
20
20
|
* measure less, and the sameness is deliberate: a rate called "click rate"
|
|
21
21
|
* on the Sequences screen and a rate called "click rate" on a campaign's
|
|
22
22
|
* report are taken over comparably named denominators, and each says which
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* Three refusals carry over unchanged:
|
|
26
26
|
*
|
|
27
27
|
* 1. **A rate over a zero or unknown denominator is `null`**, never 0%. The
|
|
28
|
-
* rate helper itself is `
|
|
28
|
+
* rate helper itself is `sendRate`, imported rather than rewritten,
|
|
29
29
|
* so the two reports cannot drift into two definitions of a percentage.
|
|
30
30
|
* 2. **An absent counter is "not recorded", not nought.** A sequence that
|
|
31
31
|
* ran before the counters existed reports nothing rather than zeroes.
|
|
@@ -43,11 +43,12 @@
|
|
|
43
43
|
* that counts them (AGL-3395) gets an open rate over the people who were
|
|
44
44
|
* sent the image, never over everyone it emailed, with the machine
|
|
45
45
|
* fetches set apart and shown.
|
|
46
|
-
*=========================================*/ import {
|
|
46
|
+
*=========================================*/ import { sendLinkReport, sendRate } from "@aglyn/shared-ui-email-campaigns/model/send-report";
|
|
47
47
|
/** The sentence each caveat is shown as. */ const CAVEATS = {
|
|
48
48
|
'opens-not-measured': 'Opens aren’t measured. A sequence email is plain text, the way a one-to-one email is, and counting an open needs a tracking image in an HTML email. Clicks are measured instead.',
|
|
49
49
|
'opens-unrecorded': 'Opens are counted for this sequence, and no email with the tracking image has gone out yet. Emails sent from now on carry it.',
|
|
50
|
-
'opens-counted': 'Opens are counted from a tracking image in an HTML copy of each email, and the open rate is taken over the people sent one. Gmail readers’ opens count. Fetches
|
|
50
|
+
'opens-counted': 'Opens are counted from a tracking image in an HTML copy of each email, and the open rate is taken over the people sent one. Gmail readers’ opens count. Fetches made whether or not anyone reads the email — by Apple Mail as it arrives, by Yahoo’s image proxy, and by Google’s, Microsoft’s and other security scanners — are counted separately and left out of the rate.',
|
|
51
|
+
'opens-all-machine': 'Every fetch of the tracking image so far was made by a machine — a mail provider’s proxy or a security scanner fetching it for the recipient — so whether anyone read these emails can’t be told from opens, and no open rate is shown. That is common when the people emailed are behind company mail security.',
|
|
51
52
|
'opens-stopped': 'Opens were counted while this sequence’s emails carried a tracking image. It’s turned off now, so the figures cover only the emails sent while it was on.',
|
|
52
53
|
'clicks-not-tracked': 'Clicks aren’t being counted for this sequence. Turn on link tracking in its settings, and the emails sent after that have their links counted.',
|
|
53
54
|
'clicks-unrecorded': 'No click has been counted for this sequence yet: either its emails carry no links, or they went out before link tracking was turned on. Emails sent from now on are counted.',
|
|
@@ -74,7 +75,7 @@ const caveat = (id)=>({
|
|
|
74
75
|
};
|
|
75
76
|
const sent = count(source.sent);
|
|
76
77
|
/*
|
|
77
|
-
* ABSENT, not zero — the distinction `
|
|
78
|
+
* ABSENT, not zero — the distinction `send-report.ts` makes about
|
|
78
79
|
* `delivered` and for the same reason. `people` is the denominator of the
|
|
79
80
|
* click rate, and `?? 0` here would turn "we never counted" into "nobody
|
|
80
81
|
* was emailed" and render that beside a non-zero send count.
|
|
@@ -87,6 +88,7 @@ const caveat = (id)=>({
|
|
|
87
88
|
const openPeople = source.openPeople === undefined ? null : count(source.openPeople);
|
|
88
89
|
const uniqueOpens = count(source.uniqueOpens);
|
|
89
90
|
const machineOpens = count(source.machineOpens);
|
|
91
|
+
const opensUnmeasured = openTracked && uniqueOpens === 0 && machineOpens > 0;
|
|
90
92
|
/*
|
|
91
93
|
* Opens (AGL-3395). A sequence that never carried the image says opens
|
|
92
94
|
* are not measured — the sentence every sequence showed before the
|
|
@@ -96,6 +98,7 @@ const caveat = (id)=>({
|
|
|
96
98
|
*/ const caveats = [];
|
|
97
99
|
if (!openTracked) caveats.push(caveat(countOpens ? 'opens-unrecorded' : 'opens-not-measured'));
|
|
98
100
|
else caveats.push(caveat(countOpens ? 'opens-counted' : 'opens-stopped'));
|
|
101
|
+
if (opensUnmeasured) caveats.push(caveat('opens-all-machine'));
|
|
99
102
|
if (!clickTracked) {
|
|
100
103
|
/*
|
|
101
104
|
* Two ways to have no click figures, and they are not the same
|
|
@@ -124,9 +127,10 @@ const caveat = (id)=>({
|
|
|
124
127
|
machineOpens,
|
|
125
128
|
proxyOpens: Math.min(count(source.proxyOpens), machineOpens),
|
|
126
129
|
lastOpenAtMs: typeof source.lastOpenAtMs === 'number' && Number.isFinite(source.lastOpenAtMs) ? source.lastOpenAtMs : null,
|
|
130
|
+
opensUnmeasured,
|
|
127
131
|
rates: {
|
|
128
|
-
click: clickTracked ?
|
|
129
|
-
open: openTracked ?
|
|
132
|
+
click: clickTracked ? sendRate(uniqueClicks, people != null ? people : undefined, 'people emailed') : null,
|
|
133
|
+
open: openTracked && !opensUnmeasured ? sendRate(uniqueOpens, openPeople != null ? openPeople : undefined, 'people sent a tracked email') : null
|
|
130
134
|
},
|
|
131
135
|
caveats
|
|
132
136
|
};
|
|
@@ -138,7 +142,7 @@ const caveat = (id)=>({
|
|
|
138
142
|
* key derivation is the campaign one, and the table a rep reads should be
|
|
139
143
|
* the same table a marketer reads.
|
|
140
144
|
*/ export function outreachSequenceLinkReport(rollup) {
|
|
141
|
-
return
|
|
145
|
+
return sendLinkReport(rollup);
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
//# sourceMappingURL=sequence-report.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/model/sequence-report.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * WHAT A SEQUENCE MEASURED, AND WHAT IT DID NOT (AGL-3239).\n *\n * The rules are `campaign-report.ts`'s, applied to a channel that can\n * measure less, and the sameness is deliberate: a rate called \"click rate\"\n * on the Sequences screen and a rate called \"click rate\" on a campaign's\n * report are taken over comparably named denominators, and each says which\n * one on screen.\n *\n * Three refusals carry over unchanged:\n *\n * 1. **A rate over a zero or unknown denominator is `null`**, never 0%. The\n * rate helper itself is `campaignRate`, imported rather than rewritten,\n * so the two reports cannot drift into two definitions of a percentage.\n * 2. **An absent counter is \"not recorded\", not nought.** A sequence that\n * ran before the counters existed reports nothing rather than zeroes.\n * 3. **A structural zero is withheld with its reason named.** A sequence\n * that never sent a tracked link could only ever have counted zero\n * clicks, so its click rate measures our sending code and is not shown.\n *\n * And one is this channel's own:\n *\n * 4. **Opens are not measured unless the sequence asked for them.** A\n * sequence email is plain text by decision and a pixel needs an HTML\n * part, so for a sequence with \"Count opens\" off the report SAYS opens\n * are not measured, in the place a reader looks for an open rate — nobody\n * concludes from a missing number that nobody read the mail. A sequence\n * that counts them (AGL-3395) gets an open rate over the people who were\n * sent the image, never over everyone it emailed, with the machine\n * fetches set apart and shown.\n *=========================================*/\n\nimport {\n campaignLinkReport,\n campaignRate,\n type CampaignLinkReport,\n type CampaignLinkRollup,\n type CampaignRate,\n} from '@aglyn/shared-ui-email-campaigns/model'\nimport type { OutreachSequenceStats } from './outreach.types'\n\n/** Why a number a reader expects is missing, or must not be read the obvious way. */\nexport interface OutreachReportCaveat {\n /** Stable id, so a spec asserts on the caveat and not on its prose. */\n id:\n | 'opens-not-measured'\n | 'opens-unrecorded'\n | 'opens-counted'\n | 'opens-stopped'\n | 'clicks-not-tracked'\n | 'clicks-unrecorded'\n | 'machine-clicks-excluded'\n message: string\n}\n\n/** Everything the sequence's report card renders. */\nexport interface OutreachSequenceReport {\n /** Email steps that left. One person getting four emails counts four. */\n sent: number\n /** Distinct people who have had at least one, or `null` when unrecorded. */\n people: number | null\n /** Click events judged a person's. */\n clicks: number\n /** Distinct people who clicked — the rate's numerator. */\n uniqueClicks: number\n /** Clicks a scanner made, counted apart and never in the rate. */\n machineClicks: number\n /** When a person last followed a link. */\n lastClickAtMs: number | null\n /** Whether any email of this sequence went out with its links rewritten. */\n clickTracked: boolean\n /** Whether any email of this sequence carried a tracking image (AGL-3395). */\n openTracked: boolean\n /** Distinct people sent at least one email with the image, or `null` when unrecorded. */\n openPeople: number | null\n /** Opens judged a person's. */\n opens: number\n /** Distinct people who opened — the open rate's numerator. */\n uniqueOpens: number\n /** Fetches of the image a machine made, never in the rate. */\n machineOpens: number\n /** Of `machineOpens`, the ones a mail provider's image proxy made. */\n proxyOpens: number\n /** When a person last opened one of the emails. */\n lastOpenAtMs: number | null\n rates: {\n /**\n * Distinct people who clicked, over the people emailed.\n *\n * `null` when the sequence never sent a tracked link, when nobody has\n * been emailed yet, and when the counters predate the feature.\n */\n click: CampaignRate | null\n /**\n * Distinct people who opened, over the people sent the image.\n *\n * `null` when no email carried the image, and when nobody has been sent\n * one yet.\n */\n open: CampaignRate | null\n }\n caveats: OutreachReportCaveat[]\n}\n\n/** The sentence each caveat is shown as. */\nconst CAVEATS: Record<OutreachReportCaveat['id'], string> = {\n 'opens-not-measured':\n 'Opens aren’t measured. A sequence email is plain text, the way a one-to-one email is, and counting an open needs a tracking image in an HTML email. Clicks are measured instead.',\n 'opens-unrecorded':\n 'Opens are counted for this sequence, and no email with the tracking image has gone out yet. Emails sent from now on carry it.',\n 'opens-counted':\n 'Opens are counted from a tracking image in an HTML copy of each email, and the open rate is taken over the people sent one. Gmail readers’ opens count. Fetches Apple Mail makes as the email arrives, whether or not anyone reads it, and those by Yahoo’s image proxy and security scanners, are counted separately and left out of the rate.',\n 'opens-stopped':\n 'Opens were counted while this sequence’s emails carried a tracking image. It’s turned off now, so the figures cover only the emails sent while it was on.',\n 'clicks-not-tracked':\n 'Clicks aren’t being counted for this sequence. Turn on link tracking in its settings, and the emails sent after that have their links counted.',\n 'clicks-unrecorded':\n 'No click has been counted for this sequence yet: either its emails carry no links, or they went out before link tracking was turned on. Emails sent from now on are counted.',\n 'machine-clicks-excluded':\n 'Some clicks came from security scanners that open every link in an email before the recipient sees it. They’re counted separately and left out of the click rate.',\n}\n\nconst caveat = (id: OutreachReportCaveat['id']): OutreachReportCaveat => ({\n id,\n message: CAVEATS[id],\n})\n\n/**\n * Turns a sequence's stored counters into its report.\n *\n * @param stats The sequence's `stats`, or `undefined` for one that has none.\n * @param trackClicks Whether the sequence is SET to track clicks now — which\n * is a different question from whether it ever has, and the two together\n * are what separate \"nothing to report yet\" from \"this will never report\".\n * @param countOpens Whether the sequence is SET to count opens now\n * (AGL-3395), read beside `stats.openTracked` the same way.\n */\nexport function outreachSequenceReport(\n stats: OutreachSequenceStats | undefined,\n trackClicks: boolean,\n countOpens = false,\n): OutreachSequenceReport {\n const source = stats ?? {}\n const count = (value: unknown): number => {\n const parsed = Number(value ?? 0)\n return Number.isFinite(parsed) && parsed > 0 ? parsed : 0\n }\n const sent = count(source.sent)\n /*\n * ABSENT, not zero — the distinction `campaign-report.ts` makes about\n * `delivered` and for the same reason. `people` is the denominator of the\n * click rate, and `?? 0` here would turn \"we never counted\" into \"nobody\n * was emailed\" and render that beside a non-zero send count.\n */\n const people = source.people === undefined ? null : count(source.people)\n const clicks = count(source.clicks)\n const uniqueClicks = count(source.uniqueClicks)\n const machineClicks = count(source.machineClicks)\n const clickTracked = source.clickTracked === true\n const openTracked = source.openTracked === true\n const openPeople = source.openPeople === undefined ? null : count(source.openPeople)\n const uniqueOpens = count(source.uniqueOpens)\n const machineOpens = count(source.machineOpens)\n\n /*\n * Opens (AGL-3395). A sequence that never carried the image says opens\n * are not measured — the sentence every sequence showed before the\n * setting existed, and still true of every one with it off. One that has\n * carried it explains what the rate counts, and one that stopped says\n * the figures stop where the setting did.\n */\n const caveats: OutreachReportCaveat[] = []\n if (!openTracked) caveats.push(caveat(countOpens ? 'opens-unrecorded' : 'opens-not-measured'))\n else caveats.push(caveat(countOpens ? 'opens-counted' : 'opens-stopped'))\n if (!clickTracked) {\n /*\n * Two ways to have no click figures, and they are not the same\n * situation: one is a setting nobody turned on, the other is a sequence\n * that finished its sending before the counters existed. The first has\n * something to do about it and the second does not, so they are named\n * apart — and a sequence that has sent NOTHING yet gets neither, because\n * there is nothing missing about a report for a sequence that has not\n * run.\n */\n if (sent > 0) caveats.push(caveat(trackClicks ? 'clicks-unrecorded' : 'clicks-not-tracked'))\n else if (!trackClicks) caveats.push(caveat('clicks-not-tracked'))\n }\n if (machineClicks > 0) caveats.push(caveat('machine-clicks-excluded'))\n\n return {\n sent,\n people,\n clicks,\n uniqueClicks,\n machineClicks,\n lastClickAtMs:\n typeof source.lastClickAtMs === 'number' && Number.isFinite(source.lastClickAtMs)\n ? source.lastClickAtMs\n : null,\n clickTracked,\n openTracked,\n openPeople,\n opens: count(source.opens),\n uniqueOpens,\n machineOpens,\n proxyOpens: Math.min(count(source.proxyOpens), machineOpens),\n lastOpenAtMs:\n typeof source.lastOpenAtMs === 'number' && Number.isFinite(source.lastOpenAtMs)\n ? source.lastOpenAtMs\n : null,\n rates: {\n click: clickTracked\n ? campaignRate(uniqueClicks, people ?? undefined, 'people emailed')\n : null,\n open: openTracked\n ? campaignRate(uniqueOpens, openPeople ?? undefined, 'people sent a tracked email')\n : null,\n },\n caveats,\n }\n}\n\n/**\n * The sequence's link table, on the campaign rollup's own reader.\n *\n * Re-exported rather than wrapped: the stored shape is the campaign one, the\n * key derivation is the campaign one, and the table a rep reads should be\n * the same table a marketer reads.\n */\nexport function outreachSequenceLinkReport(\n rollup: CampaignLinkRollup | undefined,\n): CampaignLinkReport {\n return campaignLinkReport(rollup)\n}\n"],"names":["campaignLinkReport","campaignRate","CAVEATS","caveat","id","message","outreachSequenceReport","stats","trackClicks","countOpens","source","count","value","parsed","Number","isFinite","sent","people","undefined","clicks","uniqueClicks","machineClicks","clickTracked","openTracked","openPeople","uniqueOpens","machineOpens","caveats","push","lastClickAtMs","opens","proxyOpens","Math","min","lastOpenAtMs","rates","click","open","outreachSequenceLinkReport","rollup"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA8B2C,GAE3C,SACEA,kBAAkB,EAClBC,YAAY,QAIP,yCAAwC;AAkE/C,0CAA0C,GAC1C,MAAMC,UAAsD;IAC1D,sBACE;IACF,oBACE;IACF,iBACE;IACF,iBACE;IACF,sBACE;IACF,qBACE;IACF,2BACE;AACJ;AAEA,MAAMC,SAAS,CAACC,KAA0D,CAAA;QACxEA;QACAC,SAASH,OAAO,CAACE,GAAG;IACtB,CAAA;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASE,uBACdC,KAAwC,EACxCC,WAAoB,EACpBC,aAAa,KAAK;IAElB,MAAMC,SAASH,gBAAAA,QAAS,CAAC;IACzB,MAAMI,QAAQ,CAACC;QACb,MAAMC,SAASC,OAAOF,gBAAAA,QAAS;QAC/B,OAAOE,OAAOC,QAAQ,CAACF,WAAWA,SAAS,IAAIA,SAAS;IAC1D;IACA,MAAMG,OAAOL,MAAMD,OAAOM,IAAI;IAC9B;;;;;GAKC,GACD,MAAMC,SAASP,OAAOO,MAAM,KAAKC,YAAY,OAAOP,MAAMD,OAAOO,MAAM;IACvE,MAAME,SAASR,MAAMD,OAAOS,MAAM;IAClC,MAAMC,eAAeT,MAAMD,OAAOU,YAAY;IAC9C,MAAMC,gBAAgBV,MAAMD,OAAOW,aAAa;IAChD,MAAMC,eAAeZ,OAAOY,YAAY,KAAK;IAC7C,MAAMC,cAAcb,OAAOa,WAAW,KAAK;IAC3C,MAAMC,aAAad,OAAOc,UAAU,KAAKN,YAAY,OAAOP,MAAMD,OAAOc,UAAU;IACnF,MAAMC,cAAcd,MAAMD,OAAOe,WAAW;IAC5C,MAAMC,eAAef,MAAMD,OAAOgB,YAAY;IAE9C;;;;;;GAMC,GACD,MAAMC,UAAkC,EAAE;IAC1C,IAAI,CAACJ,aAAaI,QAAQC,IAAI,CAACzB,OAAOM,aAAa,qBAAqB;SACnEkB,QAAQC,IAAI,CAACzB,OAAOM,aAAa,kBAAkB;IACxD,IAAI,CAACa,cAAc;QACjB;;;;;;;;KAQC,GACD,IAAIN,OAAO,GAAGW,QAAQC,IAAI,CAACzB,OAAOK,cAAc,sBAAsB;aACjE,IAAI,CAACA,aAAamB,QAAQC,IAAI,CAACzB,OAAO;IAC7C;IACA,IAAIkB,gBAAgB,GAAGM,QAAQC,IAAI,CAACzB,OAAO;IAE3C,OAAO;QACLa;QACAC;QACAE;QACAC;QACAC;QACAQ,eACE,OAAOnB,OAAOmB,aAAa,KAAK,YAAYf,OAAOC,QAAQ,CAACL,OAAOmB,aAAa,IAC5EnB,OAAOmB,aAAa,GACpB;QACNP;QACAC;QACAC;QACAM,OAAOnB,MAAMD,OAAOoB,KAAK;QACzBL;QACAC;QACAK,YAAYC,KAAKC,GAAG,CAACtB,MAAMD,OAAOqB,UAAU,GAAGL;QAC/CQ,cACE,OAAOxB,OAAOwB,YAAY,KAAK,YAAYpB,OAAOC,QAAQ,CAACL,OAAOwB,YAAY,IAC1ExB,OAAOwB,YAAY,GACnB;QACNC,OAAO;YACLC,OAAOd,eACHrB,aAAamB,cAAcH,iBAAAA,SAAUC,WAAW,oBAChD;YACJmB,MAAMd,cACFtB,aAAawB,aAAaD,qBAAAA,aAAcN,WAAW,iCACnD;QACN;QACAS;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASW,2BACdC,MAAsC;IAEtC,OAAOvC,mBAAmBuC;AAC5B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/model/sequence-report.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * WHAT A SEQUENCE MEASURED, AND WHAT IT DID NOT (AGL-3239).\n *\n * The rules are `send-report.ts`'s, applied to a channel that can\n * measure less, and the sameness is deliberate: a rate called \"click rate\"\n * on the Sequences screen and a rate called \"click rate\" on a campaign's\n * report are taken over comparably named denominators, and each says which\n * one on screen.\n *\n * Three refusals carry over unchanged:\n *\n * 1. **A rate over a zero or unknown denominator is `null`**, never 0%. The\n * rate helper itself is `sendRate`, imported rather than rewritten,\n * so the two reports cannot drift into two definitions of a percentage.\n * 2. **An absent counter is \"not recorded\", not nought.** A sequence that\n * ran before the counters existed reports nothing rather than zeroes.\n * 3. **A structural zero is withheld with its reason named.** A sequence\n * that never sent a tracked link could only ever have counted zero\n * clicks, so its click rate measures our sending code and is not shown.\n *\n * And one is this channel's own:\n *\n * 4. **Opens are not measured unless the sequence asked for them.** A\n * sequence email is plain text by decision and a pixel needs an HTML\n * part, so for a sequence with \"Count opens\" off the report SAYS opens\n * are not measured, in the place a reader looks for an open rate — nobody\n * concludes from a missing number that nobody read the mail. A sequence\n * that counts them (AGL-3395) gets an open rate over the people who were\n * sent the image, never over everyone it emailed, with the machine\n * fetches set apart and shown.\n *=========================================*/\n\nimport {\n sendLinkReport,\n sendRate,\n type SendLinkReport,\n type SendLinkRollup,\n type SendRate,\n} from '@aglyn/shared-ui-email-campaigns/model/send-report'\nimport type { OutreachSequenceStats } from './outreach.types'\n\n/** Why a number a reader expects is missing, or must not be read the obvious way. */\nexport interface OutreachReportCaveat {\n /** Stable id, so a spec asserts on the caveat and not on its prose. */\n id:\n | 'opens-not-measured'\n | 'opens-unrecorded'\n | 'opens-counted'\n | 'opens-stopped'\n | 'opens-all-machine'\n | 'clicks-not-tracked'\n | 'clicks-unrecorded'\n | 'machine-clicks-excluded'\n message: string\n}\n\n/** Everything the sequence's report card renders. */\nexport interface OutreachSequenceReport {\n /** Email steps that left. One person getting four emails counts four. */\n sent: number\n /** Distinct people who have had at least one, or `null` when unrecorded. */\n people: number | null\n /** Click events judged a person's. */\n clicks: number\n /** Distinct people who clicked — the rate's numerator. */\n uniqueClicks: number\n /** Clicks a scanner made, counted apart and never in the rate. */\n machineClicks: number\n /** When a person last followed a link. */\n lastClickAtMs: number | null\n /** Whether any email of this sequence went out with its links rewritten. */\n clickTracked: boolean\n /** Whether any email of this sequence carried a tracking image (AGL-3395). */\n openTracked: boolean\n /** Distinct people sent at least one email with the image, or `null` when unrecorded. */\n openPeople: number | null\n /** Opens judged a person's. */\n opens: number\n /** Distinct people who opened — the open rate's numerator. */\n uniqueOpens: number\n /** Fetches of the image a machine made, never in the rate. */\n machineOpens: number\n /** Of `machineOpens`, the ones a mail provider's image proxy made. */\n proxyOpens: number\n /** When a person last opened one of the emails. */\n lastOpenAtMs: number | null\n /**\n * Whether the image was fetched and EVERY fetch was a machine's\n * (AGL-3488): the open rate is then unmeasured rather than nought — the\n * scanners in front of these inboxes answered for everyone, and whether\n * a person read the mail behind them cannot be told from here.\n */\n opensUnmeasured: boolean\n rates: {\n /**\n * Distinct people who clicked, over the people emailed.\n *\n * `null` when the sequence never sent a tracked link, when nobody has\n * been emailed yet, and when the counters predate the feature.\n */\n click: SendRate | null\n /**\n * Distinct people who opened, over the people sent the image.\n *\n * `null` when no email carried the image, when nobody has been sent\n * one yet, and when only machines fetched it (`opensUnmeasured`).\n */\n open: SendRate | null\n }\n caveats: OutreachReportCaveat[]\n}\n\n/** The sentence each caveat is shown as. */\nconst CAVEATS: Record<OutreachReportCaveat['id'], string> = {\n 'opens-not-measured':\n 'Opens aren’t measured. A sequence email is plain text, the way a one-to-one email is, and counting an open needs a tracking image in an HTML email. Clicks are measured instead.',\n 'opens-unrecorded':\n 'Opens are counted for this sequence, and no email with the tracking image has gone out yet. Emails sent from now on carry it.',\n 'opens-counted':\n 'Opens are counted from a tracking image in an HTML copy of each email, and the open rate is taken over the people sent one. Gmail readers’ opens count. Fetches made whether or not anyone reads the email — by Apple Mail as it arrives, by Yahoo’s image proxy, and by Google’s, Microsoft’s and other security scanners — are counted separately and left out of the rate.',\n 'opens-all-machine':\n 'Every fetch of the tracking image so far was made by a machine — a mail provider’s proxy or a security scanner fetching it for the recipient — so whether anyone read these emails can’t be told from opens, and no open rate is shown. That is common when the people emailed are behind company mail security.',\n 'opens-stopped':\n 'Opens were counted while this sequence’s emails carried a tracking image. It’s turned off now, so the figures cover only the emails sent while it was on.',\n 'clicks-not-tracked':\n 'Clicks aren’t being counted for this sequence. Turn on link tracking in its settings, and the emails sent after that have their links counted.',\n 'clicks-unrecorded':\n 'No click has been counted for this sequence yet: either its emails carry no links, or they went out before link tracking was turned on. Emails sent from now on are counted.',\n 'machine-clicks-excluded':\n 'Some clicks came from security scanners that open every link in an email before the recipient sees it. They’re counted separately and left out of the click rate.',\n}\n\nconst caveat = (id: OutreachReportCaveat['id']): OutreachReportCaveat => ({\n id,\n message: CAVEATS[id],\n})\n\n/**\n * Turns a sequence's stored counters into its report.\n *\n * @param stats The sequence's `stats`, or `undefined` for one that has none.\n * @param trackClicks Whether the sequence is SET to track clicks now — which\n * is a different question from whether it ever has, and the two together\n * are what separate \"nothing to report yet\" from \"this will never report\".\n * @param countOpens Whether the sequence is SET to count opens now\n * (AGL-3395), read beside `stats.openTracked` the same way.\n */\nexport function outreachSequenceReport(\n stats: OutreachSequenceStats | undefined,\n trackClicks: boolean,\n countOpens = false,\n): OutreachSequenceReport {\n const source = stats ?? {}\n const count = (value: unknown): number => {\n const parsed = Number(value ?? 0)\n return Number.isFinite(parsed) && parsed > 0 ? parsed : 0\n }\n const sent = count(source.sent)\n /*\n * ABSENT, not zero — the distinction `send-report.ts` makes about\n * `delivered` and for the same reason. `people` is the denominator of the\n * click rate, and `?? 0` here would turn \"we never counted\" into \"nobody\n * was emailed\" and render that beside a non-zero send count.\n */\n const people = source.people === undefined ? null : count(source.people)\n const clicks = count(source.clicks)\n const uniqueClicks = count(source.uniqueClicks)\n const machineClicks = count(source.machineClicks)\n const clickTracked = source.clickTracked === true\n const openTracked = source.openTracked === true\n const openPeople = source.openPeople === undefined ? null : count(source.openPeople)\n const uniqueOpens = count(source.uniqueOpens)\n const machineOpens = count(source.machineOpens)\n const opensUnmeasured = openTracked && uniqueOpens === 0 && machineOpens > 0\n\n /*\n * Opens (AGL-3395). A sequence that never carried the image says opens\n * are not measured — the sentence every sequence showed before the\n * setting existed, and still true of every one with it off. One that has\n * carried it explains what the rate counts, and one that stopped says\n * the figures stop where the setting did.\n */\n const caveats: OutreachReportCaveat[] = []\n if (!openTracked) caveats.push(caveat(countOpens ? 'opens-unrecorded' : 'opens-not-measured'))\n else caveats.push(caveat(countOpens ? 'opens-counted' : 'opens-stopped'))\n if (opensUnmeasured) caveats.push(caveat('opens-all-machine'))\n if (!clickTracked) {\n /*\n * Two ways to have no click figures, and they are not the same\n * situation: one is a setting nobody turned on, the other is a sequence\n * that finished its sending before the counters existed. The first has\n * something to do about it and the second does not, so they are named\n * apart — and a sequence that has sent NOTHING yet gets neither, because\n * there is nothing missing about a report for a sequence that has not\n * run.\n */\n if (sent > 0) caveats.push(caveat(trackClicks ? 'clicks-unrecorded' : 'clicks-not-tracked'))\n else if (!trackClicks) caveats.push(caveat('clicks-not-tracked'))\n }\n if (machineClicks > 0) caveats.push(caveat('machine-clicks-excluded'))\n\n return {\n sent,\n people,\n clicks,\n uniqueClicks,\n machineClicks,\n lastClickAtMs:\n typeof source.lastClickAtMs === 'number' && Number.isFinite(source.lastClickAtMs)\n ? source.lastClickAtMs\n : null,\n clickTracked,\n openTracked,\n openPeople,\n opens: count(source.opens),\n uniqueOpens,\n machineOpens,\n proxyOpens: Math.min(count(source.proxyOpens), machineOpens),\n lastOpenAtMs:\n typeof source.lastOpenAtMs === 'number' && Number.isFinite(source.lastOpenAtMs)\n ? source.lastOpenAtMs\n : null,\n opensUnmeasured,\n rates: {\n click: clickTracked\n ? sendRate(uniqueClicks, people ?? undefined, 'people emailed')\n : null,\n open: openTracked && !opensUnmeasured\n ? sendRate(uniqueOpens, openPeople ?? undefined, 'people sent a tracked email')\n : null,\n },\n caveats,\n }\n}\n\n/**\n * The sequence's link table, on the campaign rollup's own reader.\n *\n * Re-exported rather than wrapped: the stored shape is the campaign one, the\n * key derivation is the campaign one, and the table a rep reads should be\n * the same table a marketer reads.\n */\nexport function outreachSequenceLinkReport(\n rollup: SendLinkRollup | undefined,\n): SendLinkReport {\n return sendLinkReport(rollup)\n}\n"],"names":["sendLinkReport","sendRate","CAVEATS","caveat","id","message","outreachSequenceReport","stats","trackClicks","countOpens","source","count","value","parsed","Number","isFinite","sent","people","undefined","clicks","uniqueClicks","machineClicks","clickTracked","openTracked","openPeople","uniqueOpens","machineOpens","opensUnmeasured","caveats","push","lastClickAtMs","opens","proxyOpens","Math","min","lastOpenAtMs","rates","click","open","outreachSequenceLinkReport","rollup"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA8B2C,GAE3C,SACEA,cAAc,EACdC,QAAQ,QAIH,qDAAoD;AA0E3D,0CAA0C,GAC1C,MAAMC,UAAsD;IAC1D,sBACE;IACF,oBACE;IACF,iBACE;IACF,qBACE;IACF,iBACE;IACF,sBACE;IACF,qBACE;IACF,2BACE;AACJ;AAEA,MAAMC,SAAS,CAACC,KAA0D,CAAA;QACxEA;QACAC,SAASH,OAAO,CAACE,GAAG;IACtB,CAAA;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASE,uBACdC,KAAwC,EACxCC,WAAoB,EACpBC,aAAa,KAAK;IAElB,MAAMC,SAASH,gBAAAA,QAAS,CAAC;IACzB,MAAMI,QAAQ,CAACC;QACb,MAAMC,SAASC,OAAOF,gBAAAA,QAAS;QAC/B,OAAOE,OAAOC,QAAQ,CAACF,WAAWA,SAAS,IAAIA,SAAS;IAC1D;IACA,MAAMG,OAAOL,MAAMD,OAAOM,IAAI;IAC9B;;;;;GAKC,GACD,MAAMC,SAASP,OAAOO,MAAM,KAAKC,YAAY,OAAOP,MAAMD,OAAOO,MAAM;IACvE,MAAME,SAASR,MAAMD,OAAOS,MAAM;IAClC,MAAMC,eAAeT,MAAMD,OAAOU,YAAY;IAC9C,MAAMC,gBAAgBV,MAAMD,OAAOW,aAAa;IAChD,MAAMC,eAAeZ,OAAOY,YAAY,KAAK;IAC7C,MAAMC,cAAcb,OAAOa,WAAW,KAAK;IAC3C,MAAMC,aAAad,OAAOc,UAAU,KAAKN,YAAY,OAAOP,MAAMD,OAAOc,UAAU;IACnF,MAAMC,cAAcd,MAAMD,OAAOe,WAAW;IAC5C,MAAMC,eAAef,MAAMD,OAAOgB,YAAY;IAC9C,MAAMC,kBAAkBJ,eAAeE,gBAAgB,KAAKC,eAAe;IAE3E;;;;;;GAMC,GACD,MAAME,UAAkC,EAAE;IAC1C,IAAI,CAACL,aAAaK,QAAQC,IAAI,CAAC1B,OAAOM,aAAa,qBAAqB;SACnEmB,QAAQC,IAAI,CAAC1B,OAAOM,aAAa,kBAAkB;IACxD,IAAIkB,iBAAiBC,QAAQC,IAAI,CAAC1B,OAAO;IACzC,IAAI,CAACmB,cAAc;QACjB;;;;;;;;KAQC,GACD,IAAIN,OAAO,GAAGY,QAAQC,IAAI,CAAC1B,OAAOK,cAAc,sBAAsB;aACjE,IAAI,CAACA,aAAaoB,QAAQC,IAAI,CAAC1B,OAAO;IAC7C;IACA,IAAIkB,gBAAgB,GAAGO,QAAQC,IAAI,CAAC1B,OAAO;IAE3C,OAAO;QACLa;QACAC;QACAE;QACAC;QACAC;QACAS,eACE,OAAOpB,OAAOoB,aAAa,KAAK,YAAYhB,OAAOC,QAAQ,CAACL,OAAOoB,aAAa,IAC5EpB,OAAOoB,aAAa,GACpB;QACNR;QACAC;QACAC;QACAO,OAAOpB,MAAMD,OAAOqB,KAAK;QACzBN;QACAC;QACAM,YAAYC,KAAKC,GAAG,CAACvB,MAAMD,OAAOsB,UAAU,GAAGN;QAC/CS,cACE,OAAOzB,OAAOyB,YAAY,KAAK,YAAYrB,OAAOC,QAAQ,CAACL,OAAOyB,YAAY,IAC1EzB,OAAOyB,YAAY,GACnB;QACNR;QACAS,OAAO;YACLC,OAAOf,eACHrB,SAASmB,cAAcH,iBAAAA,SAAUC,WAAW,oBAC5C;YACJoB,MAAMf,eAAe,CAACI,kBAClB1B,SAASwB,aAAaD,qBAAAA,aAAcN,WAAW,iCAC/C;QACN;QACAU;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASW,2BACdC,MAAkC;IAElC,OAAOxC,eAAewC;AACxB"}
|
package/src/lib/plugin.js
CHANGED
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ import { registerConsoleExtension, registerPluginPermissions } from "@aglyn/aglyn";
|
|
17
|
+
import { registerPluginTransferResourceUi } from "@aglyn/aglyn/plugin-manager/plugin-transfer-resources";
|
|
17
18
|
import { mdiEmailFastOutline } from "@aglyn/shared-data-mdi";
|
|
18
19
|
import { lazy } from "react";
|
|
19
20
|
import { OUTREACH_CONSOLE_SECTIONS } from "./components/outreach-console-sections.js";
|
|
20
21
|
import { OUTREACH_PERMISSIONS, OUTREACH_PLUGIN_ID, OUTREACH_USE_PERMISSION } from "./constants/bundle-common.js";
|
|
22
|
+
import { OUTREACH_DO_NOT_CONTACT_TRANSFER_KEY, OUTREACH_DO_NOT_CONTACT_TRANSFER_LABEL } from "./constants/transfer-resources.js";
|
|
21
23
|
/** Code-split: the hub only loads when opened. */ const OutreachConsolePage = lazy(()=>import("./components/outreach-console-page.js"));
|
|
22
24
|
/**
|
|
23
25
|
* The console half of this plugin (AGL-2974), named in `plugins.config.json`
|
|
@@ -49,6 +51,15 @@ import { OUTREACH_PERMISSIONS, OUTREACH_PLUGIN_ID, OUTREACH_USE_PERMISSION } fro
|
|
|
49
51
|
* calls a feature no plan carries "a paid add-on", which this is not.
|
|
50
52
|
*/ export function registerOutreachConsole() {
|
|
51
53
|
registerPluginPermissions(OUTREACH_PERMISSIONS);
|
|
54
|
+
// How the Import & export hub names sequences in a workspace package (AGL-3535).
|
|
55
|
+
registerPluginTransferResourceUi('outreach.sequences', {
|
|
56
|
+
label: 'Sequences',
|
|
57
|
+
icon: {
|
|
58
|
+
path: mdiEmailFastOutline.path
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
pluginId: OUTREACH_PLUGIN_ID
|
|
62
|
+
});
|
|
52
63
|
registerConsoleExtension({
|
|
53
64
|
pluginId: OUTREACH_PLUGIN_ID,
|
|
54
65
|
displayName: 'Sequences',
|
|
@@ -81,6 +92,13 @@ import { OUTREACH_PERMISSIONS, OUTREACH_PLUGIN_ID, OUTREACH_USE_PERMISSION } fro
|
|
|
81
92
|
}
|
|
82
93
|
]
|
|
83
94
|
});
|
|
95
|
+
// The do-not-contact list's Import and Export, opened from the
|
|
96
|
+
// Compliance section's do-not-contact card.
|
|
97
|
+
registerPluginTransferResourceUi(OUTREACH_DO_NOT_CONTACT_TRANSFER_KEY, {
|
|
98
|
+
label: OUTREACH_DO_NOT_CONTACT_TRANSFER_LABEL
|
|
99
|
+
}, {
|
|
100
|
+
pluginId: OUTREACH_PLUGIN_ID
|
|
101
|
+
});
|
|
84
102
|
}
|
|
85
103
|
|
|
86
104
|
//# sourceMappingURL=plugin.js.map
|
package/src/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/outreach/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n registerConsoleExtension,\n registerPluginPermissions,\n} from '@aglyn/aglyn'\nimport { mdiEmailFastOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport { OUTREACH_CONSOLE_SECTIONS } from './components/outreach-console-sections'\nimport {\n OUTREACH_PERMISSIONS,\n OUTREACH_PLUGIN_ID,\n OUTREACH_USE_PERMISSION,\n} from './constants/bundle-common'\n\n/** Code-split: the hub only loads when opened. */\nconst OutreachConsolePage = lazy(\n () => import('./components/outreach-console-page'),\n)\n\n/**\n * The console half of this plugin (AGL-2974), named in `plugins.config.json`\n * as `console`. Console and console API only, like the CRM: a sequence has no\n * canvas element, so there is no site bundle and no tenant half.\n *\n * THE NAME PEOPLE READ IS \"SEQUENCES\" (AGL-3199); the plugin id, the lib, the\n * package, the flag, the entitlement, the permission, the collections and the\n * API prefix all stay `outreach`. Renaming those would move stored data and\n * break the unsubscribe links already sent, and no reader sees them.\n *\n * ONE ORGANIZATION-LEVEL SURFACE. Sequences are a rep's work across every site\n * the organization sells for, sent from that rep's own mailbox, so they live\n * beside the organization's other tabs rather than under a site. It is\n * declared in `orgNavItems`, which the console serves at\n * `/[orgSlug]/outreach/<section>` through its generic org route.\n *\n * THREE GATES, each answered by the shell, never by this page:\n *\n * - the RELEASE flag `release_outreach`, reached through the nav item's\n * `navTabId` — off by default, so only staff preview it;\n * - the ENTITLEMENT `features.outreach`, which no plan carries, so an\n * organization has it only through its per-org override;\n * - the PERMISSION `outreach.use`, which owners and admins hold by default.\n *\n * The org tab strip hides the tab unless all three hold. A deep link is\n * answered by the route with the refusal that applies, and the words for the\n * entitlement one are this extension's own: the shell's derived sentence\n * calls a feature no plan carries \"a paid add-on\", which this is not.\n */\nexport function registerOutreachConsole(): void {\n registerPluginPermissions(OUTREACH_PERMISSIONS)\n registerConsoleExtension({\n pluginId: OUTREACH_PLUGIN_ID,\n displayName: 'Sequences',\n permission: OUTREACH_USE_PERMISSION,\n featureFlag: 'outreach',\n upgradeNotice: {\n message: \"Sequences isn't available to this workspace yet.\",\n },\n orgNavItems: [\n {\n label: 'Sequences',\n // The URL slug stays `outreach`: it is the plugin id the console\n // resolves the surface by, and this label is the name its tab carries.\n href: '/outreach',\n sections: OUTREACH_CONSOLE_SECTIONS,\n // The release flag's tab id: `release_outreach` names it, and the org\n // strip hides the tab from customers while the flag is off.\n navTabId: 'nav-tab-org-outreach',\n icon: { path: mdiEmailFastOutline.path },\n header: {\n title: 'Sequences',\n icon: { path: mdiEmailFastOutline.path },\n docsTopic: 'sequences',\n },\n Component: OutreachConsolePage,\n },\n ],\n })\n}\n"],"names":["registerConsoleExtension","registerPluginPermissions","mdiEmailFastOutline","lazy","OUTREACH_CONSOLE_SECTIONS","OUTREACH_PERMISSIONS","OUTREACH_PLUGIN_ID","OUTREACH_USE_PERMISSION","OutreachConsolePage","registerOutreachConsole","pluginId","displayName","permission","featureFlag","upgradeNotice","message","orgNavItems","
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/outreach/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n registerConsoleExtension,\n registerPluginPermissions,\n} from '@aglyn/aglyn'\nimport { registerPluginTransferResourceUi } from '@aglyn/aglyn/plugin-manager/plugin-transfer-resources'\nimport { mdiEmailFastOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport { OUTREACH_CONSOLE_SECTIONS } from './components/outreach-console-sections'\nimport {\n OUTREACH_PERMISSIONS,\n OUTREACH_PLUGIN_ID,\n OUTREACH_USE_PERMISSION,\n} from './constants/bundle-common'\nimport {\n OUTREACH_DO_NOT_CONTACT_TRANSFER_KEY,\n OUTREACH_DO_NOT_CONTACT_TRANSFER_LABEL,\n} from './constants/transfer-resources'\n\n/** Code-split: the hub only loads when opened. */\nconst OutreachConsolePage = lazy(\n () => import('./components/outreach-console-page'),\n)\n\n/**\n * The console half of this plugin (AGL-2974), named in `plugins.config.json`\n * as `console`. Console and console API only, like the CRM: a sequence has no\n * canvas element, so there is no site bundle and no tenant half.\n *\n * THE NAME PEOPLE READ IS \"SEQUENCES\" (AGL-3199); the plugin id, the lib, the\n * package, the flag, the entitlement, the permission, the collections and the\n * API prefix all stay `outreach`. Renaming those would move stored data and\n * break the unsubscribe links already sent, and no reader sees them.\n *\n * ONE ORGANIZATION-LEVEL SURFACE. Sequences are a rep's work across every site\n * the organization sells for, sent from that rep's own mailbox, so they live\n * beside the organization's other tabs rather than under a site. It is\n * declared in `orgNavItems`, which the console serves at\n * `/[orgSlug]/outreach/<section>` through its generic org route.\n *\n * THREE GATES, each answered by the shell, never by this page:\n *\n * - the RELEASE flag `release_outreach`, reached through the nav item's\n * `navTabId` — off by default, so only staff preview it;\n * - the ENTITLEMENT `features.outreach`, which no plan carries, so an\n * organization has it only through its per-org override;\n * - the PERMISSION `outreach.use`, which owners and admins hold by default.\n *\n * The org tab strip hides the tab unless all three hold. A deep link is\n * answered by the route with the refusal that applies, and the words for the\n * entitlement one are this extension's own: the shell's derived sentence\n * calls a feature no plan carries \"a paid add-on\", which this is not.\n */\nexport function registerOutreachConsole(): void {\n registerPluginPermissions(OUTREACH_PERMISSIONS)\n // How the Import & export hub names sequences in a workspace package (AGL-3535).\n registerPluginTransferResourceUi(\n 'outreach.sequences',\n { label: 'Sequences', icon: { path: mdiEmailFastOutline.path } },\n { pluginId: OUTREACH_PLUGIN_ID },\n )\n registerConsoleExtension({\n pluginId: OUTREACH_PLUGIN_ID,\n displayName: 'Sequences',\n permission: OUTREACH_USE_PERMISSION,\n featureFlag: 'outreach',\n upgradeNotice: {\n message: \"Sequences isn't available to this workspace yet.\",\n },\n orgNavItems: [\n {\n label: 'Sequences',\n // The URL slug stays `outreach`: it is the plugin id the console\n // resolves the surface by, and this label is the name its tab carries.\n href: '/outreach',\n sections: OUTREACH_CONSOLE_SECTIONS,\n // The release flag's tab id: `release_outreach` names it, and the org\n // strip hides the tab from customers while the flag is off.\n navTabId: 'nav-tab-org-outreach',\n icon: { path: mdiEmailFastOutline.path },\n header: {\n title: 'Sequences',\n icon: { path: mdiEmailFastOutline.path },\n docsTopic: 'sequences',\n },\n Component: OutreachConsolePage,\n },\n ],\n })\n // The do-not-contact list's Import and Export, opened from the\n // Compliance section's do-not-contact card.\n registerPluginTransferResourceUi(\n OUTREACH_DO_NOT_CONTACT_TRANSFER_KEY,\n { label: OUTREACH_DO_NOT_CONTACT_TRANSFER_LABEL },\n { pluginId: OUTREACH_PLUGIN_ID },\n )\n}\n"],"names":["registerConsoleExtension","registerPluginPermissions","registerPluginTransferResourceUi","mdiEmailFastOutline","lazy","OUTREACH_CONSOLE_SECTIONS","OUTREACH_PERMISSIONS","OUTREACH_PLUGIN_ID","OUTREACH_USE_PERMISSION","OUTREACH_DO_NOT_CONTACT_TRANSFER_KEY","OUTREACH_DO_NOT_CONTACT_TRANSFER_LABEL","OutreachConsolePage","registerOutreachConsole","label","icon","path","pluginId","displayName","permission","featureFlag","upgradeNotice","message","orgNavItems","href","sections","navTabId","header","title","docsTopic","Component"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,wBAAwB,EACxBC,yBAAyB,QACpB,eAAc;AACrB,SAASC,gCAAgC,QAAQ,wDAAuD;AACxG,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,SAASC,IAAI,QAAQ,QAAO;AAC5B,SAASC,yBAAyB,QAAQ,4CAAwC;AAClF,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB,QAClB,+BAA2B;AAClC,SACEC,oCAAoC,EACpCC,sCAAsC,QACjC,oCAAgC;AAEvC,gDAAgD,GAChD,MAAMC,sBAAsBP,KAC1B,IAAM,MAAM,CAAC;AAGf;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,SAASQ;IACdX,0BAA0BK;IAC1B,iFAAiF;IACjFJ,iCACE,sBACA;QAAEW,OAAO;QAAaC,MAAM;YAAEC,MAAMZ,oBAAoBY,IAAI;QAAC;IAAE,GAC/D;QAAEC,UAAUT;IAAmB;IAEjCP,yBAAyB;QACvBgB,UAAUT;QACVU,aAAa;QACbC,YAAYV;QACZW,aAAa;QACbC,eAAe;YACbC,SAAS;QACX;QACAC,aAAa;YACX;gBACET,OAAO;gBACP,iEAAiE;gBACjE,uEAAuE;gBACvEU,MAAM;gBACNC,UAAUnB;gBACV,sEAAsE;gBACtE,4DAA4D;gBAC5DoB,UAAU;gBACVX,MAAM;oBAAEC,MAAMZ,oBAAoBY,IAAI;gBAAC;gBACvCW,QAAQ;oBACNC,OAAO;oBACPb,MAAM;wBAAEC,MAAMZ,oBAAoBY,IAAI;oBAAC;oBACvCa,WAAW;gBACb;gBACAC,WAAWlB;YACb;SACD;IACH;IACA,+DAA+D;IAC/D,4CAA4C;IAC5CT,iCACEO,sCACA;QAAEI,OAAOH;IAAuC,GAChD;QAAEM,UAAUT;IAAmB;AAEnC"}
|