@getvitops/utils 8.3.0-alpha.1 → 8.3.0-alpha.2
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/CHANGELOG.md +32 -0
- package/dist/notify/index.d.mts +8 -0
- package/dist/notify/index.d.mts.map +1 -1
- package/dist/notify/index.mjs +11 -1
- package/dist/notify/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @getvitops/utils
|
|
2
2
|
|
|
3
|
+
## 8.3.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0a47856: Build correctness and gaps from the second upstream round.
|
|
8
|
+
|
|
9
|
+
- **`@getvitops/emdash`: fixes a circular import that emptied the plugin block map in the static build.** `Section.astro` and `WidgetArea.astro` imported `emdash/ui` statically, which imports `virtual:emdash/block-components`, which is `@getvitops/emdash/astro` again. Depending on import order, every `vitops_*` block inside a section body was dropped from prerendered pages with only a `PortableText [components.type] is missing …` warning. Both now import it lazily, and a test fails if any renderer imports `emdash/ui` statically. No code change needed in sites.
|
|
10
|
+
- **`@getvitops/cli`: `vitops emdash build`** runs `astro build` and then `check-prerender`, and fails when the build reports a block type with no component (reported once per type). The template's `build`, `deploy` and `deploy:dev` scripts use it; existing sites replace `astro build && vitops emdash check-prerender` with `vitops emdash build`. `check-prerender` also warns (fails with `--strict`) on a page without exactly one `<h1>`.
|
|
11
|
+
- **`@getvitops/emdash`: `vitops_hero` and `vitops_section` heading level** accepts `h1`–`h6` and `p` (a heading that is styled but not in the outline). The hero defaults to `h1`; set the level to `2` on a page whose layout already renders an `h1` (the template's seed does).
|
|
12
|
+
- **`@getvitops/emdash`: `vitops_logos`** shows an entry's name as text (`.logos__name`) when it has no image. `@getvitops/core` adds the rule (all formats).
|
|
13
|
+
- **`@getvitops/emdash`: an empty content widget** (no text, no blocks) no longer renders its title, and an area whose widgets are all empty renders nothing.
|
|
14
|
+
- **`@getvitops/create`:** the template's `pages` collection gets `urlPattern: "/{slug}"` (the sitemap listed `/pages/<slug>`, which 404s; existing sites change it under Content Types), and `.gitignore` ignores only `src/styles/tailwind.css` and `tokens.json`, so site CSS kept in `src/styles/` is committed.
|
|
15
|
+
- **`@getvitops/emdash`: per-item colour.** The rows of `vitops_cards`, `vitops_stats`, `vitops_steps` and the hero's `cards` take their own `tone` / `color` (blank inherits the block's), so one block can hold a pine item and an amber one. Hero cards also take an `eyebrow` and a button (`ctaLabel` / `ctaHref`; with a button the card is no longer a stretched link).
|
|
16
|
+
- **`@getvitops/generator` / `@getvitops/emdash`: solid fills read.** The generator emits `--color-<hue>-<step>-on` for every step of every hue, the foreground for a fill at that step picked by the same APCA rule as `text-on-<role>` (css and tailwind formats, a plain `:root`, not `@theme`). A block fill chosen by `color` (hue and step) uses it instead of a fixed white..
|
|
17
|
+
- **`@getvitops/core`: `.counter__value.sr-only`** hides itself, so a build that never emitted the `.sr-only` utility no longer shows a counting figure twice (all formats).
|
|
18
|
+
- **`@getvitops/astro` / `@getvitops/core`: `SiteFooter` groups.** A top-level item of the `footer-sitemap` menu with children becomes a column (its label is the heading, its children the links, one level only); childless items stay in the flat list. Each column is a named `<nav>`.
|
|
19
|
+
- **`@getvitops/astro`: planned links and header buttons.** A menu item with `draft` in its CSS classes stays in the menu but is not rendered (at every level, in the header and the footer). `<SiteNav>` has an `actions` slot for header buttons that are not menu items, and an item with `cta` in its CSS classes renders as a button.
|
|
20
|
+
- **`@getvitops/cli`: `check-prerender` warnings** (fail with `--strict`): links to pages the build did not produce, a form with no delivery address (no `site.notifications.email`, location `email` or `site.crm`), and form fields missing from every `site.templates` form entry (the generated privacy policy reads those). It reads `./site.json`, or `--site=<path>`. `vitops setup … --dry-run` is accepted as `--dry`.
|
|
21
|
+
- **`@getvitops/emdash` / `@getvitops/astro`: "tick any number" form field** (`vitops_form` field kind `checkboxes`): a fieldset of checkboxes sharing one name. The conversion route joins repeated values (`IT, Marketing`) instead of keeping the last. The "required" toggle is not applied to the group (HTML cannot require one of several).
|
|
22
|
+
- **`@getvitops/core`: size hooks.** `.steps__title`, `.stats__figure` and `.card__title` read `--steps-title-size` (default one step below `heading`), `--stats-figure-size` and `--card-title-size`, set on the block through its `style` field. They set the `--heading-fs` / `--display-fs` properties the type-role utilities already read, so no extra class or prop is needed (all formats).
|
|
23
|
+
- **`@getvitops/create`:** the template's `site.json` lists its contact form under `site.templates`, so the privacy policy inventory and the new check agree.
|
|
24
|
+
- **`@getvitops/emdash`: `theme` on every block, on widget areas and on your own markup.** A `theme` select (`<role>` tinted, `<role>:solid` filled, populated from the site's roles by a new `themes/list` route) is a common field on every `vitops_*` block, applied to the block's own root with the role's computed readable text. `<VitopsWidgetArea theme="…">` takes the same, and `themeAttrs('surface')` gives `{ class, style }` for a layout `<body>`. `vitops_section`'s existing `theme` now goes through the same path.
|
|
25
|
+
- **`@getvitops/cli` / `@getvitops/emdash`: pages with a dropped block fail the build.** `vitops_section` and widget areas emit an invisible `<template data-vitops-unrendered="…">` for any body block with no renderer, and `check-prerender` fails the page naming the types (nested bodies only; `vitops emdash build` also scans the build log, which covers top-level bodies). A regression test imports the plugin entry first with a mock of the real virtual module, so the old import cycle fails it.
|
|
26
|
+
- **`@getvitops/emdash`: `formTemplateFromBlock(block)`** turns a saved `vitops_form` value into a `site.templates` form entry (names as submitted, a `checkboxes` field as a `checkbox` with options), to paste into `site.json` so the generated privacy policy lists what the form collects. The build cannot read the CMS database, so this is run by hand; `check-prerender` warns when fields are missing.
|
|
27
|
+
- **`@getvitops/utils`: `hasFormDelivery`** (`@getvitops/utils/notify`): the one test for "has this form anywhere to go", used by `check-prerender`.
|
|
28
|
+
- **`@getvitops/emdash`:** a `color` hue tint now flips with the colour scheme (`light-dark()`); hero option cards sit at `h2` under an `h1` hero; menu items also accept `hidden: true` (same as the `draft` class); `vitops docs blocks` documents `theme`, the per-row colours, the `--<role>-fs` type-size hook and the form checks.
|
|
29
|
+
- **`@getvitops/create`:** the template redirects `/home` to `/`, and the guides use `vp exec` instead of `vpx`.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- @getvitops/config@8.3.0-alpha.2
|
|
34
|
+
|
|
3
35
|
## 8.3.0-alpha.1
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/dist/notify/index.d.mts
CHANGED
|
@@ -109,6 +109,14 @@ export declare function resolveSender(channel: EmailChannelConfig, ctx: NotifyCo
|
|
|
109
109
|
* report the misconfiguration instead of reporting success over a no-op.
|
|
110
110
|
*/
|
|
111
111
|
export declare function planNotifications(ctx: NotifyContext): NotificationPlan;
|
|
112
|
+
/**
|
|
113
|
+
* Whether a form post has anywhere to go: a `notifications.email` channel, a location e-mail,
|
|
114
|
+
* or a CRM. With none of the three the emdash template's `/api/track` refuses the post (it
|
|
115
|
+
* would otherwise accept it and lose the message), so `vitops emdash check-prerender` asks the
|
|
116
|
+
* same question of the config before the first visitor finds out. One function so the build
|
|
117
|
+
* check and the route cannot disagree.
|
|
118
|
+
*/
|
|
119
|
+
export declare function hasFormDelivery(ctx: Pick<NotifyContext, 'notifications' | 'locationEmails'>, crm?: unknown): boolean;
|
|
112
120
|
/** One section: a heading and its lines. Empty sections are dropped by the caller. */
|
|
113
121
|
interface Section {
|
|
114
122
|
heading: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/notify/types.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/email.ts","../../src/notify/google-ads.ts","../../src/notify/index.ts"],"mappings":";;;;;;;;;;;;;;;;;UAeiB;EACf;EACA;EACA;;KAQU,qBAAqB,QAAQ,YAAY;;UAGpC;EACf,gBAAgB;;EAEhB;;EAEA;;;;;EAKA;;;UAIe;EACf;;EAEA;;UAGe,kBAAkB;EACjC;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;;EAEP;;UAGe;EACf;EACA;;EAEA;;EAEA;;;;;;;;;;UAWe;EACf,KAAK;IACH;IACA;MAAiB;MAAe;;IAChC;IACA;IACA;IACA;MACE;;;qBCvEO;;wBAGG,sBACd,gBAAgB,iCACf;;;;;;;;wBAYa,iBACd,SAAS,oBACT,KAAK;;;;;;;;wBAaS,cAAc,SAAS,oBAAoB,KAAK;;;;;;;wBAmBhD,kBAAkB,KAAK,gBAAgB;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/notify/types.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/email.ts","../../src/notify/google-ads.ts","../../src/notify/index.ts"],"mappings":";;;;;;;;;;;;;;;;;UAeiB;EACf;EACA;EACA;;KAQU,qBAAqB,QAAQ,YAAY;;UAGpC;EACf,gBAAgB;;EAEhB;;EAEA;;;;;EAKA;;;UAIe;EACf;;EAEA;;UAGe,kBAAkB;EACjC;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;;EAEP;;UAGe;EACf;EACA;;EAEA;;EAEA;;;;;;;;;;UAWe;EACf,KAAK;IACH;IACA;MAAiB;MAAe;;IAChC;IACA;IACA;IACA;MACE;;;qBCvEO;;wBAGG,sBACd,gBAAgB,iCACf;;;;;;;;wBAYa,iBACd,SAAS,oBACT,KAAK;;;;;;;;wBAaS,cAAc,SAAS,oBAAoB,KAAK;;;;;;;wBAmBhD,kBAAkB,KAAK,gBAAgB;;;;;;;;wBA6DvC,gBACd,KAAK,KAAK,oDACV;;UC5FQ;EACR;EACA;;;;;;;;wBAyDc,cAAc,OAAO;EAAoB;EAAiB,UAAU;;;wBA4DpE,YACd,OAAO,iBACP;EAAS;EAA8B;IACtC;UCxHc;;EAEf;;;;;;;;;;;;;EAaA;;EAEA,SAAS,eAAe;;;;;;;;;;wBA0CJ,UACpB,MAAM,WACN,SAAS,iBACT,SAAS,cACT,UAAS,mBACR,QAAQ;;;;;;;;wBAkDK,SACd,MAAM,WACN,SAAS,iBACT,OAAM,wBACL;UC9Hc;;;EAGf;EACA,OAAO;;;;EAIP;;UAGe;;;EAGf;;;EAGA;;EAEA;IAAW;IAAe;;;;EAG1B;EACA;EACA;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;wBAUc,6BACd,oBACA;;;;wBASc,2BAA2B;;;;;;;;;;;wBA4BrB,sBACpB,OAAO,sBACP,aAAa,sBACb,mBAAkB,QACjB,QAAQ;;;wBA6EK,+BACd,QAAQ;iBC9JO;;;;;EAKf,QAAQ;;iBAGO;EACf,SAAS;;EAET;;;;;;;;;wBAUoB,OACpB,OAAO,iBACP,KAAK,eACL,OAAM,YACN;EAAS;IACR,QAAQ"}
|
package/dist/notify/index.mjs
CHANGED
|
@@ -208,6 +208,16 @@ function planEmail(ctx) {
|
|
|
208
208
|
enabled: true
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether a form post has anywhere to go: a `notifications.email` channel, a location e-mail,
|
|
213
|
+
* or a CRM. With none of the three the emdash template's `/api/track` refuses the post (it
|
|
214
|
+
* would otherwise accept it and lose the message), so `vitops emdash check-prerender` asks the
|
|
215
|
+
* same question of the config before the first visitor finds out. One function so the build
|
|
216
|
+
* check and the route cannot disagree.
|
|
217
|
+
*/
|
|
218
|
+
function hasFormDelivery(ctx, crm) {
|
|
219
|
+
return Boolean(ctx.notifications?.email || ctx.locationEmails?.length || crm);
|
|
220
|
+
}
|
|
211
221
|
|
|
212
222
|
// src/notify/render.ts
|
|
213
223
|
/**
|
|
@@ -522,5 +532,5 @@ async function notify(event, ctx, deps = {}, extra = {}) {
|
|
|
522
532
|
};
|
|
523
533
|
}
|
|
524
534
|
|
|
525
|
-
export { DEFAULT_EMAIL_BINDING, conversionActionResourceName, describeEvent, describeGoogleAdsOfflineResult, logEmail, normalizeEmailChannel, notify, planNotifications, renderEmail, resolveRecipient, resolveSender, sendEmail, toGoogleConversionDateTime, uploadClickConversion };
|
|
535
|
+
export { DEFAULT_EMAIL_BINDING, conversionActionResourceName, describeEvent, describeGoogleAdsOfflineResult, hasFormDelivery, logEmail, normalizeEmailChannel, notify, planNotifications, renderEmail, resolveRecipient, resolveSender, sendEmail, toGoogleConversionDateTime, uploadClickConversion };
|
|
526
536
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/notify/email.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/google-ads.ts","../../src/notify/index.ts"],"sourcesContent":["/**\n * The e-mail channel — Cloudflare Email Sending.\n *\n * I/O only: it executes an `EmailPlan` and decides nothing. Whether to send, to\n * whom, and from where were all settled in `plan.ts`.\n *\n * **The binding is passed in, never imported.** `@getvitops/utils` does not depend\n * on `cloudflare:workers`, so this module runs in Node and in a test with a stub,\n * and the Astro package gains no Cloudflare coupling. The consumer's route hands\n * over `env.EMAIL`.\n *\n * Uses the current Email Sending binding — a structured `send({ to, from,\n * subject, html, text })` — not the legacy `EmailMessage` + hand-built MIME path.\n * The domain in `from` must have been onboarded (`wrangler email sending enable\n * <domain>`); nothing here can check that, which is why `E_SENDER_NOT_VERIFIED`\n * is surfaced verbatim rather than collapsed into \"send failed\".\n */\nimport type { RenderedMessage } from './types.ts';\nimport type { ChannelResult, EmailBinding, EmailPlan } from './types.ts';\n\n/**\n * Provider errors worth retrying.\n *\n * Everything else is a configuration fault — an unverified sender, a malformed\n * payload, a suppressed recipient — where a retry is pure latency and the send\n * will fail identically. Retrying those also burns the daily quota.\n */\nconst RETRYABLE = new Set([\n 'E_RATE_LIMIT_EXCEEDED',\n 'E_DELIVERY_FAILED',\n 'E_INTERNAL_SERVER_ERROR',\n]);\n\nfunction codeOf(error: unknown): string | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport interface SendEmailOptions {\n /** Attempts for a retryable failure (default 3). */\n attempts?: number;\n /**\n * Per-attempt ceiling in milliseconds (default 10000; `0` disables).\n *\n * `binding.send()` is a network call with no deadline of its own, so without\n * this one hung attempt hangs the request that produced it — forever, in the\n * one module otherwise built on always saying why. A conversion endpoint\n * cannot be the thing that makes a form submission time out, so the bound\n * belongs here rather than in every consumer's wrapper.\n *\n * A timeout is treated as retryable: it is a transient condition by\n * definition, unlike `E_SENDER_NOT_VERIFIED` and friends.\n */\n timeoutMs?: number;\n /** Injected for tests; real callers let it default to a real delay. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nconst wait = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));\n\n/** Marker for a send that exceeded its deadline, so the retry rule can see it. */\nconst TIMEOUT_CODE = 'E_SEND_TIMEOUT';\n\n/**\n * Race a send against its deadline.\n *\n * The timer is always cleared — a pending `setTimeout` keeps a Worker's event\n * loop alive past the response, which turns a bounded send into an unbounded\n * invocation and bills for the difference.\n */\nasync function withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {\n if (ms <= 0) return work;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n work,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const err = new Error(`Email send exceeded ${ms}ms.`) as Error & { code: string };\n err.code = TIMEOUT_CODE;\n reject(err);\n }, ms);\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\n/**\n * Send one rendered message according to a plan.\n *\n * Never throws: a failed notification must not take down the request that\n * produced it. The visitor has already submitted their form, and failing their\n * response because our mail didn't go out would turn a lost notification into a\n * lost conversion. The failure is returned instead, for the caller to log.\n */\nexport async function sendEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n binding: EmailBinding,\n options: SendEmailOptions = {},\n): Promise<ChannelResult> {\n if (!plan.enabled || !plan.to || !plan.from) {\n return { channel: 'email', sent: false, reason: plan.skip ?? 'Channel not enabled.' };\n }\n\n const attempts = Math.max(1, options.attempts ?? 3);\n const sleep = options.sleep ?? wait;\n const timeoutMs = options.timeoutMs ?? 10_000;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n await withTimeout(\n binding.send({\n to: plan.to,\n from: plan.fromName ? { email: plan.from, name: plan.fromName } : { email: plan.from },\n subject: message.subject,\n text: message.text,\n html: message.html,\n ...(plan.replyTo ? { replyTo: plan.replyTo } : {}),\n }),\n timeoutMs,\n );\n return { channel: 'email', sent: true };\n } catch (error) {\n const code = codeOf(error);\n if (attempt === attempts || !code || !(RETRYABLE.has(code) || code === TIMEOUT_CODE)) {\n return {\n channel: 'email',\n sent: false,\n reason: messageOf(error),\n ...(code ? { code } : {}),\n };\n }\n // Exponential backoff. Cloudflare's rate limit is per-account, so a burst\n // of conversions retrying in lockstep would keep colliding.\n await sleep(2 ** (attempt - 1) * 250);\n }\n }\n\n /* c8 ignore next -- the loop always returns; this satisfies the type checker. */\n return { channel: 'email', sent: false, reason: 'Exhausted attempts.' };\n}\n\n/**\n * Print the message instead of sending it.\n *\n * The dev path, for a machine with no binding. Explicit rather than a silent\n * no-op, because \"I never saw the notification\" is the symptom of both a broken\n * integration and a working one nobody could observe.\n */\nexport function logEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n log: (line: string) => void = console.log,\n): ChannelResult {\n log(\n [\n '\\n========== NOTIFICATION EMAIL (not sent — no binding) ==========',\n `To: ${plan.to ?? '(unresolved)'}`,\n `From: ${plan.from ?? '(unresolved)'}`,\n `Subject: ${message.subject}`,\n '---',\n message.text,\n '================================================================\\n',\n ].join('\\n'),\n );\n return { channel: 'email', sent: false, reason: 'No binding — logged to the console.' };\n}\n","/**\n * Every decision a notification makes, as one pure function.\n *\n * Pure in the load-bearing sense: no `fetch`, no binding, no clock. Whether a\n * channel fires, who it reaches, and *why* it was skipped are all decided here and\n * asserted in `plan.test.ts`; the senders beside this file do what they are told\n * and decide nothing. That is the same split `indexing/plan.ts` makes against\n * `gsc.ts`, and `@getvitops/core`'s consent store makes against its DOM wiring,\n * for the same reason: the consequential logic has to be testable without the\n * environment it runs in.\n *\n * The practical payoff is that a misconfigured site can be told exactly what will\n * and won't happen without sending anything — a silently unsent conversion\n * notification is indistinguishable from no conversion.\n */\nimport type { EmailChannelConfig, EmailPlan, NotificationPlan, NotifyContext } from './types.ts';\n\n/** Default Workers binding name for Cloudflare Email Sending. */\nexport const DEFAULT_EMAIL_BINDING = 'EMAIL';\n\n/** Normalise the `email` shorthand: a bare address means a Cloudflare send to it. */\nexport function normalizeEmailChannel(\n input: string | EmailChannelConfig | undefined,\n): EmailChannelConfig | undefined {\n if (input === undefined) return undefined;\n return typeof input === 'string' ? { provider: 'cloudflare', to: input } : input;\n}\n\n/**\n * Who the notification reaches.\n *\n * An explicit recipient wins; otherwise it falls to the site's own contact\n * addresses, primary first. This cascade is why a site that has already said\n * where it receives mail doesn't have to say it twice.\n */\nexport function resolveRecipient(\n channel: EmailChannelConfig,\n ctx: NotifyContext,\n): string | undefined {\n if (channel.to) return channel.to;\n return ctx.locationEmails?.find((e) => !!e);\n}\n\n/**\n * The From address.\n *\n * `noreply@<canonical>` by default, because the sending domain has to be one the\n * site controls — Cloudflare rejects anything else with `E_SENDER_NOT_VERIFIED`,\n * and guessing from the recipient's domain would send that failure every time.\n */\nexport function resolveSender(channel: EmailChannelConfig, ctx: NotifyContext): string | undefined {\n if (channel.from) return channel.from;\n if (!ctx.canonical) return undefined;\n let host: string;\n try {\n host = new URL(ctx.canonical).hostname;\n } catch {\n // A bare hostname is a legitimate way to write `domains.canonical`.\n host = ctx.canonical.replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '');\n }\n return host ? `noreply@${host}` : undefined;\n}\n\n/**\n * Decide what will be sent, and say why anything won't be.\n *\n * Every \"off\" carries a reason rather than being an absence, so a caller can\n * report the misconfiguration instead of reporting success over a no-op.\n */\nexport function planNotifications(ctx: NotifyContext): NotificationPlan {\n const email = planEmail(ctx);\n return { email, empty: !email.enabled };\n}\n\nfunction planEmail(ctx: NotifyContext): EmailPlan {\n const channel = normalizeEmailChannel(ctx.notifications?.email);\n const binding = channel?.binding ?? DEFAULT_EMAIL_BINDING;\n\n if (!channel) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip: 'No `notifications.email` configured.',\n };\n }\n\n const to = resolveRecipient(channel, ctx);\n if (!to) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip:\n 'No recipient: set `notifications.email.to`, or give a location an `email` ' +\n 'so the notification has somewhere to go.',\n };\n }\n\n const from = resolveSender(channel, ctx);\n if (!from) {\n return {\n provider: 'cloudflare',\n binding,\n to,\n enabled: false,\n skip:\n 'No sender: set `notifications.email.from`, or `domains.canonical` so ' +\n '`noreply@<host>` can be derived. Cloudflare only sends from a domain you have onboarded.',\n };\n }\n\n return {\n provider: 'cloudflare',\n binding,\n to,\n from,\n fromName: channel.fromName ?? ctx.organizationName,\n replyTo: channel.replyTo,\n enabled: true,\n };\n}\n","/**\n * Turning a `ConversionEvent` into something a person reads.\n *\n * Pure, and separate from both the plan and the sender, because rendering is the\n * part that differs per channel: an SMS channel will render the same event in 160\n * characters, a portal log as a row. The event stays the fact; only this file has\n * an opinion about prose.\n *\n * The layout is three sections — who got in touch, which ad sent them, and what\n * the request looked like — because that is the order the reader needs them in.\n * The contact details are the point; attribution is why it matters; the visitor\n * context is for when something looks wrong.\n */\nimport { identifySubmitter } from '../tracking/identity.ts';\nimport { getPrimaryClickId, identifyPlatform } from '../tracking/platform.ts';\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport type { RenderedMessage } from './types.ts';\n\n/**\n * Fields never worth putting in a notification.\n *\n * A honeypot is not visitor-supplied — it is bait, and reporting it as something\n * they submitted is untrue. The same rule `legal/derive.ts` applies when deriving\n * `piiCollected`, and for the same reason. Callers may strip more.\n */\nconst OMIT_FIELDS = new Set(['website', '_honeypot', 'honeypot', 'cf-turnstile-response']);\n\nfunction label(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1).replace(/[_-]/g, ' ');\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\n/** One section: a heading and its lines. Empty sections are dropped by the caller. */\ninterface Section {\n heading: string;\n lines: [string, string][];\n}\n\n/**\n * One line, already rendered both ways — a plain fact (`html` is just the\n * escaped `text`) or a link (`html` an anchor, `text` the bare href). Built at\n * the point each line is known rather than carried as a union and branched on\n * later: `describeEvent`'s lines are always plain `[label, value]` pairs (see\n * `Section` above, which `render.test.ts` destructures as such), and the one\n * line shape `renderEmail` adds itself — the \"Actions\" link — is turned into\n * this same rendered shape immediately, so the two renderers below share one\n * line format instead of branching on what kind of line each one is.\n */\ninterface RenderedLine {\n label: string;\n text: string;\n html: string;\n}\n\n/** A section as `renderEmail` assembles it — `describeEvent`'s output plus its own additions. */\ninterface RenderSection {\n heading: string;\n lines: RenderedLine[];\n}\n\nfunction factLine([label, value]: readonly [string, string]): RenderedLine {\n return { label, text: value, html: escapeHtml(value) };\n}\n\nfunction linkLine(label: string, href: string): RenderedLine {\n return { label, text: href, html: `<a href=\"${escapeHtml(href)}\">${escapeHtml(href)}</a>` };\n}\n\nfunction toRenderSection(section: Section): RenderSection {\n return { heading: section.heading, lines: section.lines.map(factLine) };\n}\n\n/**\n * Who submitted the form, for the subject line.\n *\n * `formData['name']` alone is the shape a form has when someone writes it that\n * way, and most don't: a downstream site had `first_name`/`last_name` on five of\n * six forms, so every notification read \"from Unknown\" and the renderer could\n * not be adopted at all. The cascade is ordered most-specific first, and falls\n * back to the email rather than to nothing — an address identifies the person\n * even when no name field exists.\n */\nfunction submitterName(formData: Record<string, string>): string {\n return identifySubmitter(formData).fullName;\n}\n\n/**\n * The event as sections — the shared structure behind both renderings.\n *\n * Extracted so the text and HTML versions cannot disagree about content. They\n * differ only in markup; a field added here appears in both.\n */\nexport function describeEvent(event: ConversionEvent): { subject: string; sections: Section[] } {\n const t = event.tracking;\n const platform = t ? identifyPlatform(t) : null;\n const clickId = t ? getPrimaryClickId(t) : null;\n\n const contact: [string, string][] = [];\n let subject: string;\n\n if (event.type === 'form' && event.formData) {\n const name = submitterName(event.formData);\n subject = `[Contact Form] New submission from ${name}`;\n for (const [key, value] of Object.entries(event.formData)) {\n if (!OMIT_FIELDS.has(key) && value) contact.push([label(key), value]);\n }\n } else if (event.type === 'email') {\n const email = event.email ?? 'unknown';\n subject = `[Email Click] Visitor emailing ${email}`;\n contact.push(['Email', email]);\n } else {\n const phone = event.phone ?? 'unknown';\n subject = `[Phone Call] Visitor calling ${phone}`;\n contact.push(['Phone', phone]);\n }\n\n const attribution: [string, string][] = [];\n if (t) {\n if (platform) attribution.push(['Platform', platform]);\n if (clickId) attribution.push([`Click ID (${clickId.param})`, clickId.value]);\n for (const key of ['utm_campaign', 'utm_source', 'utm_medium', 'utm_content', 'utm_term']) {\n const value = t[key];\n if (value) attribution.push([label(key.replace('utm_', '')), String(value)]);\n }\n if (t.ab_variant) attribution.push(['A/B variant', t.ab_variant]);\n }\n\n const context: [string, string][] = [];\n if (t?.landingPage) context.push(['Landing page', t.landingPage]);\n if (t?.referrer) context.push(['Referrer', t.referrer]);\n if (t?.ts) context.push(['First visit', new Date(t.ts).toISOString()]);\n context.push(['Received', new Date(event.at).toISOString()]);\n if (event.userAgent) context.push(['User agent', event.userAgent]);\n if (event.ip) context.push(['IP', event.ip]);\n\n const sections: Section[] = [\n { heading: 'Contact details', lines: contact },\n // Stated rather than omitted: \"we don't know where this came from\" is a\n // useful answer, and a silently missing section reads as a bug in the tool.\n {\n heading: 'Ad attribution',\n lines: attribution.length\n ? attribution\n : [['Source', 'None — visitor arrived without ad tracking']],\n },\n { heading: 'Visitor context', lines: context },\n ];\n\n return { subject, sections: sections.filter((s) => s.lines.length) };\n}\n\n/** Render for e-mail. Both halves, always — see `RenderedMessage`. */\nexport function renderEmail(\n event: ConversionEvent,\n extra: { notes?: string[] | undefined; actionUrl?: string | undefined } = {},\n): RenderedMessage {\n const { subject, sections: eventSections } = describeEvent(event);\n\n // `{clickId}` is the only placeholder — an event has no durable id nothing\n // in this toolchain could look back up (there's no store), so interpolating\n // one would be decorative. Omitted entirely when there's no click ID to\n // interpolate, rather than emailing a link with a literal `{clickId}` in it.\n const clickId = event.tracking ? getPrimaryClickId(event.tracking) : null;\n const actionSection: RenderSection | null =\n extra.actionUrl && clickId\n ? {\n heading: 'Actions',\n lines: [\n linkLine(\n 'View in ad platform',\n extra.actionUrl.replace(/\\{clickId\\}/g, encodeURIComponent(clickId.value)),\n ),\n ],\n }\n : null;\n\n // Deliberately a channel-neutral `string[]` rather than a typed CRM result —\n // this module gains no dependency on `crm`, and the seam serves any future\n // sink the same way.\n const sections: RenderSection[] = [\n ...eventSections.map(toRenderSection),\n ...(actionSection ? [actionSection] : []),\n ...(extra.notes && extra.notes.length\n ? [{ heading: 'Delivery', lines: extra.notes.map((n) => factLine(['CRM', n])) }]\n : []),\n ];\n\n const text = sections\n .map((s) => [`--- ${s.heading} ---`, ...s.lines.map((l) => `${l.label}: ${l.text}`)].join('\\n'))\n .join('\\n\\n');\n\n const html = sections\n .map(\n (s) =>\n `<h2 style=\"font:600 14px system-ui;margin:24px 0 8px\">${escapeHtml(s.heading)}</h2>` +\n `<table style=\"font:14px system-ui;border-collapse:collapse\">${s.lines\n .map(\n (l) =>\n `<tr><td style=\"padding:2px 12px 2px 0;color:#666;vertical-align:top\">${escapeHtml(l.label)}</td>` +\n `<td style=\"padding:2px 0\">${l.html}</td></tr>`,\n )\n .join('')}</table>`,\n )\n .join('');\n\n return { subject, text, html };\n}\n","/**\n * Google Ads offline conversion upload — the server-side counterpart to the\n * client-side `gtag('event', 'conversion', …)` call `gtagBootstrap`\n * (`@getvitops/utils/ads`) wires up. Reads `site.ads.google.reporting: 'server'`\n * and a matching `conversionActionId` (see that field's own docblock for why\n * it is a different identifier from `conversionLabel`, not an alternate\n * spelling of it) and calls `ConversionUploadService.UploadClickConversions`\n * instead of relying on a visitor's browser to fire the tag.\n *\n * Same reasoning as `@getvitops/utils/crm`'s executors: credentials are a\n * structurally-typed shape the consumer's route supplies from env vars, never\n * config, and a failed upload is a `GoogleAdsUploadResult` to log or fold into\n * the notification email — never an exception, and never something that fails\n * the conversion request it's attached to. A lost ad report is not a lost\n * lead; the visitor has already submitted.\n *\n * **Structurally typed against Google's documented REST shape, not verified\n * against a live Ads account** — no developer-token/MCC access exists\n * anywhere in this toolchain's own setup to test against (the same blocker\n * `vitops ads provision` is waiting on). Same caveat, and the same reason, as\n * `@getvitops/utils/crm`'s Jobber executor: wrapped so a wrong guess about the\n * exact request/response shape degrades to a stated failure reason rather\n * than breaking. Re-verify against `googleads.googleapis.com`'s current API\n * version and `ClickConversion` message shape before depending on this in\n * production, and update this docblock with what was found.\n */\nimport { errorDetail, googleAccessToken, googleHeaders } from '../google/token.ts';\nimport type { GoogleOAuth } from '../google/token.ts';\n\n/** Bumped independently of everything else here — the Ads API deprecates\n * versions on its own rolling schedule. Last checked against Google's public\n * docs at the time this file was written; not re-verified since. */\nconst API_VERSION = 'v17';\n\nexport interface GoogleAdsCredentials {\n /** Issued against a Google Ads manager (MCC) account — a Google review, not\n * a self-service toggle. Never config. */\n developerToken: string;\n oauth: GoogleOAuth;\n /** The MCC's own (dashes-or-not) customer id — required when `customerId`\n * in the upload input is a client account managed under it, which is the\n * common case for an agency running this on a client's behalf. */\n loginCustomerId?: string | undefined;\n}\n\nexport interface GoogleAdsUploadInput {\n /** Google Ads customer id, as shown in the UI (`\"123-456-7890\"`) or bare\n * digits — either works, dashes are stripped before the call. */\n customerId: string;\n /** A numeric conversion action id, or a full\n * `customers/…/conversionActions/…` resource name. */\n conversionActionId: string;\n /** The click id captured on `_ac` — `getPrimaryClickId()`'s result. */\n clickId: { param: string; value: string };\n /** Epoch ms — converted to the Ads API's own\n * `\"yyyy-MM-dd HH:mm:ss+00:00\"` format. */\n at: number;\n conversionValue?: number | undefined;\n currencyCode?: string | undefined;\n orderId?: string | undefined;\n}\n\n/** Never thrown — an Ads API outage or a malformed request both come back as\n * `ok: false`, the same \"structured result, not an exception\" rule every\n * other executor in this toolchain follows. */\nexport interface GoogleAdsUploadResult {\n ok: boolean;\n reason?: string | undefined;\n code?: string | undefined;\n}\n\nfunction digitsOnly(id: string): string {\n return id.replace(/\\D/g, '');\n}\n\n/** A bare numeric id becomes a full resource name under `customerId`; a value\n * already shaped like one (the escape hatch, matching `txtRecord`'s `=`\n * check in `@getvitops/utils/ads`) passes through unchanged. */\nexport function conversionActionResourceName(\n customerId: string,\n conversionActionId: string,\n): string {\n if (conversionActionId.includes('customers/')) return conversionActionId;\n return `customers/${digitsOnly(customerId)}/conversionActions/${conversionActionId}`;\n}\n\n/** The Ads API's documented click-conversion datetime format, always\n * rendered in UTC — there is no per-account timezone lookup here to do\n * better, and UTC is unambiguous. */\nexport function toGoogleConversionDateTime(atMs: number): string {\n const d = new Date(atMs);\n const pad = (n: number): string => String(n).padStart(2, '0');\n return (\n `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ` +\n `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}+00:00`\n );\n}\n\n/** The request field a click id param maps to — the API takes `gclid`/\n * `gbraid`/`wbraid` as distinct fields, not one generic \"click id\" field.\n * Anything else this toolchain's `PLATFORM_PARAMS` maps to Google (today,\n * only these three) falls back to `gclid`. */\nfunction clickIdField(param: string): 'gclid' | 'gbraid' | 'wbraid' {\n if (param === 'gbraid' || param === 'wbraid') return param;\n return 'gclid';\n}\n\n/**\n * Upload one click conversion via `ConversionUploadService.UploadClickConversions`.\n *\n * `partialFailure: true` is always sent, and a 200 response carrying\n * `partialFailureError` is treated as a failure, not a success — a single-\n * conversion batch makes \"partial\" and \"total\" failure the same case, and\n * Google Ads API responses are 200 for a partial failure by design (silently\n * treating that as success is exactly the trap `@getvitops/utils/crm`'s\n * Jobber executor documents for its own GraphQL transport).\n */\nexport async function uploadClickConversion(\n input: GoogleAdsUploadInput,\n credentials: GoogleAdsCredentials,\n fetchImpl: typeof fetch = fetch,\n): Promise<GoogleAdsUploadResult> {\n let token: string;\n try {\n token = await googleAccessToken({ kind: 'oauth', oauth: credentials.oauth }, fetchImpl);\n } catch (err) {\n return {\n ok: false,\n reason: `Google Ads token exchange failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n\n const customerId = digitsOnly(input.customerId);\n const url = `https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}:uploadClickConversions`;\n\n const body = {\n conversions: [\n {\n conversionAction: conversionActionResourceName(customerId, input.conversionActionId),\n [clickIdField(input.clickId.param)]: input.clickId.value,\n conversionDateTime: toGoogleConversionDateTime(input.at),\n ...(input.conversionValue != null ? { conversionValue: input.conversionValue } : {}),\n ...(input.currencyCode ? { currencyCode: input.currencyCode } : {}),\n ...(input.orderId ? { orderId: input.orderId } : {}),\n },\n ],\n partialFailure: true,\n };\n\n let res: Response;\n try {\n res = await fetchImpl(url, {\n method: 'POST',\n headers: googleHeaders(token, {\n 'developer-token': credentials.developerToken,\n 'content-type': 'application/json',\n ...(credentials.loginCustomerId\n ? { 'login-customer-id': digitsOnly(credentials.loginCustomerId) }\n : {}),\n }),\n body: JSON.stringify(body),\n });\n } catch (err) {\n return {\n ok: false,\n reason: `Google Ads request failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n\n if (!res.ok) {\n return {\n ok: false,\n code: String(res.status),\n reason: await errorDetail(res, (status) =>\n status === 401\n ? 'Google Ads rejected the access token.'\n : status === 403\n ? 'Google Ads refused the request — check the developer token is approved and `login-customer-id` is set for an MCC-managed account.'\n : undefined,\n ),\n };\n }\n\n const json = (await res.json().catch(() => ({}))) as {\n partialFailureError?: { message?: string };\n };\n if (json.partialFailureError) {\n return {\n ok: false,\n reason: `Google Ads rejected the conversion: ${json.partialFailureError.message ?? 'no detail given'}`,\n };\n }\n\n return { ok: true };\n}\n\n/** A one-line delivery note, matching `describeCrmResult`'s shape — what\n * `conversion.ts` folds into the notification email's \"Delivery\" section. */\nexport function describeGoogleAdsOfflineResult(\n result: GoogleAdsUploadResult | null,\n): string | null {\n if (!result) return null;\n if (result.ok) return 'Reported to Google Ads (server-side)';\n return `⚠ Not reported to Google Ads: ${result.reason ?? 'unknown reason'}`;\n}\n","/**\n * Conversion notifications — plan, render, dispatch.\n *\n * The seam between \"a conversion happened\" and \"someone found out about it\".\n * A `ConversionEvent` from `@getvitops/utils/tracking` goes in; where it goes and\n * how it reads are config, not code at the call site.\n *\n * Three files, three jobs, matching `indexing/`:\n * - `plan.ts` decides everything, purely — which channels, which recipients,\n * and why anything is off.\n * - `render.ts` turns the event into prose, purely.\n * - `email.ts` executes, and decides nothing.\n *\n * `google-ads.ts` is a fourth file, added later, that does **not** follow the\n * three-file shape above: it isn't a `NotificationsConfig` channel `notify()`\n * plans and dispatches, it's a separate delivery keyed to `site.ads.google`,\n * wired in by `createConversionRoute`'s own `googleAdsOffline` option and\n * folded into the email's \"Delivery\" section exactly like `@getvitops/utils/\n * crm`'s `CrmResult` — see that module's `describeCrmResult` for the\n * precedent this follows (`describeGoogleAdsOfflineResult` here).\n *\n * ---\n *\n * **TODO — further channels.** Only `email` is implemented. The seam is\n * `NotificationsConfig` + a sender with `sendEmail`'s signature `(plan, message,\n * transport) => ChannelResult`; adding one should mean a new sender file, a new\n * branch in `planNotifications`, and a schema variant — touching neither\n * `ConversionEvent` nor the recipient cascade. Planned:\n * - `sms` — the same event rendered short. `render.ts` already separates\n * `describeEvent` from `renderEmail` for exactly this.\n * - `persist` — append to a store (D1, a portal log) the client reviews.\n * The generic `email`/`text`/`persist` helpers taking content + provider config\n * belong at that point, not before: one implemented channel is not enough to know\n * what the abstraction should be.\n */\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport { logEmail, sendEmail } from './email.ts';\nimport { planNotifications } from './plan.ts';\nimport { renderEmail } from './render.ts';\nimport type { ChannelResult, EmailBinding, NotifyContext } from './types.ts';\n\nexport interface NotifyDeps {\n /**\n * The Workers `send_email` binding (`env.EMAIL`). Omit it and the notification\n * is printed instead — the dev path.\n */\n email?: EmailBinding | undefined;\n}\n\nexport interface NotifyResult {\n results: ChannelResult[];\n /** True when at least one channel delivered. */\n delivered: boolean;\n}\n\n/**\n * Notify every configured channel about a conversion.\n *\n * Channels are independent: one failing must not stop the others, and none of\n * them may throw into the request that produced the event. Every outcome —\n * delivered, skipped, failed — comes back as data for the caller to log.\n */\nexport async function notify(\n event: ConversionEvent,\n ctx: NotifyContext,\n deps: NotifyDeps = {},\n extra: { notes?: string[] | undefined } = {},\n): Promise<NotifyResult> {\n const plan = planNotifications(ctx);\n const results: ChannelResult[] = [];\n\n if (plan.email.enabled) {\n const message = renderEmail(event, { ...extra, actionUrl: ctx.notifications?.actionUrl });\n results.push(\n deps.email ? await sendEmail(plan.email, message, deps.email) : logEmail(plan.email, message),\n );\n } else {\n results.push({ channel: 'email', sent: false, reason: plan.email.skip ?? 'Not configured.' });\n }\n\n return { results, delivered: results.some((r) => r.sent) };\n}\n\nexport {\n DEFAULT_EMAIL_BINDING,\n normalizeEmailChannel,\n planNotifications,\n resolveRecipient,\n resolveSender,\n} from './plan.ts';\nexport { describeEvent, renderEmail } from './render.ts';\nexport { logEmail, sendEmail } from './email.ts';\nexport {\n conversionActionResourceName,\n describeGoogleAdsOfflineResult,\n toGoogleConversionDateTime,\n uploadClickConversion,\n} from './google-ads.ts';\nexport type {\n GoogleAdsCredentials,\n GoogleAdsUploadInput,\n GoogleAdsUploadResult,\n} from './google-ads.ts';\nexport type {\n ChannelPlan,\n ChannelResult,\n EmailBinding,\n EmailChannelConfig,\n EmailPlan,\n NotificationPlan,\n NotificationsConfig,\n NotifyContext,\n RenderedMessage,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;AACF,CAAC;AAED,SAAS,OAAO,OAAoC;CAClD,MAAM,OAAQ,OAAqC;CACnD,OAAO,OAAO,SAAS,WAAW,OAAO;AAC3C;AAEA,SAAS,UAAU,OAAwB;CACzC,OAAO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AM;EACvB,QAAQ,MAAM,YAAY,MAAM,WAC9B,WAAW,MACP,0CACA,WAAW,MACT,sIACA,MACR;CACF;CAGF,MAAM,OAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE;CAG/C,IAAI,KAAK,qBACP,OAAO;EACL,IAAI;EACJ,QAAQ,uCAAuC,KAAK,oBAAoB,WAAW;CACrF;CAGF,OAAO,EAAE,IAAI,KAAK;AACpB;;;AAIA,SAAgB,+BACd,QACe;CACf,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,IAAI,OAAO;CACtB,OAAO,iCAAiC,OAAO,UAAU;AAC3D;;;;;;;;;;AC9IA,eAAsB,OACpB,OACA,KACA,OAAmB,CAAC,GACpB,QAA0C,CAAC,GACpB;CACvB,MAAM,OAAO,kBAAkB,GAAG;CAClC,MAAM,UAA2B,CAAC;CAElC,IAAI,KAAK,MAAM,SAAS;EACtB,MAAM,UAAU,YAAY,OAAO;GAAE,GAAG;GAAO,WAAW,IAAI,eAAe;EAAU,CAAC;EACxF,QAAQ,KACN,KAAK,QAAQ,MAAM,UAAU,KAAK,OAAO,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,OAAO,OAAO,CAC9F;CACF,OACE,QAAQ,KAAK;EAAE,SAAS;EAAS,MAAM;EAAO,QAAQ,KAAK,MAAM,QAAQ;CAAkB,CAAC;CAG9F,OAAO;EAAE;EAAS,WAAW,QAAQ,MAAM,MAAM,EAAE,IAAI;CAAE;AAC3D"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/notify/email.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/google-ads.ts","../../src/notify/index.ts"],"sourcesContent":["/**\n * The e-mail channel — Cloudflare Email Sending.\n *\n * I/O only: it executes an `EmailPlan` and decides nothing. Whether to send, to\n * whom, and from where were all settled in `plan.ts`.\n *\n * **The binding is passed in, never imported.** `@getvitops/utils` does not depend\n * on `cloudflare:workers`, so this module runs in Node and in a test with a stub,\n * and the Astro package gains no Cloudflare coupling. The consumer's route hands\n * over `env.EMAIL`.\n *\n * Uses the current Email Sending binding — a structured `send({ to, from,\n * subject, html, text })` — not the legacy `EmailMessage` + hand-built MIME path.\n * The domain in `from` must have been onboarded (`wrangler email sending enable\n * <domain>`); nothing here can check that, which is why `E_SENDER_NOT_VERIFIED`\n * is surfaced verbatim rather than collapsed into \"send failed\".\n */\nimport type { RenderedMessage } from './types.ts';\nimport type { ChannelResult, EmailBinding, EmailPlan } from './types.ts';\n\n/**\n * Provider errors worth retrying.\n *\n * Everything else is a configuration fault — an unverified sender, a malformed\n * payload, a suppressed recipient — where a retry is pure latency and the send\n * will fail identically. Retrying those also burns the daily quota.\n */\nconst RETRYABLE = new Set([\n 'E_RATE_LIMIT_EXCEEDED',\n 'E_DELIVERY_FAILED',\n 'E_INTERNAL_SERVER_ERROR',\n]);\n\nfunction codeOf(error: unknown): string | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport interface SendEmailOptions {\n /** Attempts for a retryable failure (default 3). */\n attempts?: number;\n /**\n * Per-attempt ceiling in milliseconds (default 10000; `0` disables).\n *\n * `binding.send()` is a network call with no deadline of its own, so without\n * this one hung attempt hangs the request that produced it — forever, in the\n * one module otherwise built on always saying why. A conversion endpoint\n * cannot be the thing that makes a form submission time out, so the bound\n * belongs here rather than in every consumer's wrapper.\n *\n * A timeout is treated as retryable: it is a transient condition by\n * definition, unlike `E_SENDER_NOT_VERIFIED` and friends.\n */\n timeoutMs?: number;\n /** Injected for tests; real callers let it default to a real delay. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nconst wait = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));\n\n/** Marker for a send that exceeded its deadline, so the retry rule can see it. */\nconst TIMEOUT_CODE = 'E_SEND_TIMEOUT';\n\n/**\n * Race a send against its deadline.\n *\n * The timer is always cleared — a pending `setTimeout` keeps a Worker's event\n * loop alive past the response, which turns a bounded send into an unbounded\n * invocation and bills for the difference.\n */\nasync function withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {\n if (ms <= 0) return work;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n work,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const err = new Error(`Email send exceeded ${ms}ms.`) as Error & { code: string };\n err.code = TIMEOUT_CODE;\n reject(err);\n }, ms);\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\n/**\n * Send one rendered message according to a plan.\n *\n * Never throws: a failed notification must not take down the request that\n * produced it. The visitor has already submitted their form, and failing their\n * response because our mail didn't go out would turn a lost notification into a\n * lost conversion. The failure is returned instead, for the caller to log.\n */\nexport async function sendEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n binding: EmailBinding,\n options: SendEmailOptions = {},\n): Promise<ChannelResult> {\n if (!plan.enabled || !plan.to || !plan.from) {\n return { channel: 'email', sent: false, reason: plan.skip ?? 'Channel not enabled.' };\n }\n\n const attempts = Math.max(1, options.attempts ?? 3);\n const sleep = options.sleep ?? wait;\n const timeoutMs = options.timeoutMs ?? 10_000;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n await withTimeout(\n binding.send({\n to: plan.to,\n from: plan.fromName ? { email: plan.from, name: plan.fromName } : { email: plan.from },\n subject: message.subject,\n text: message.text,\n html: message.html,\n ...(plan.replyTo ? { replyTo: plan.replyTo } : {}),\n }),\n timeoutMs,\n );\n return { channel: 'email', sent: true };\n } catch (error) {\n const code = codeOf(error);\n if (attempt === attempts || !code || !(RETRYABLE.has(code) || code === TIMEOUT_CODE)) {\n return {\n channel: 'email',\n sent: false,\n reason: messageOf(error),\n ...(code ? { code } : {}),\n };\n }\n // Exponential backoff. Cloudflare's rate limit is per-account, so a burst\n // of conversions retrying in lockstep would keep colliding.\n await sleep(2 ** (attempt - 1) * 250);\n }\n }\n\n /* c8 ignore next -- the loop always returns; this satisfies the type checker. */\n return { channel: 'email', sent: false, reason: 'Exhausted attempts.' };\n}\n\n/**\n * Print the message instead of sending it.\n *\n * The dev path, for a machine with no binding. Explicit rather than a silent\n * no-op, because \"I never saw the notification\" is the symptom of both a broken\n * integration and a working one nobody could observe.\n */\nexport function logEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n log: (line: string) => void = console.log,\n): ChannelResult {\n log(\n [\n '\\n========== NOTIFICATION EMAIL (not sent — no binding) ==========',\n `To: ${plan.to ?? '(unresolved)'}`,\n `From: ${plan.from ?? '(unresolved)'}`,\n `Subject: ${message.subject}`,\n '---',\n message.text,\n '================================================================\\n',\n ].join('\\n'),\n );\n return { channel: 'email', sent: false, reason: 'No binding — logged to the console.' };\n}\n","/**\n * Every decision a notification makes, as one pure function.\n *\n * Pure in the load-bearing sense: no `fetch`, no binding, no clock. Whether a\n * channel fires, who it reaches, and *why* it was skipped are all decided here and\n * asserted in `plan.test.ts`; the senders beside this file do what they are told\n * and decide nothing. That is the same split `indexing/plan.ts` makes against\n * `gsc.ts`, and `@getvitops/core`'s consent store makes against its DOM wiring,\n * for the same reason: the consequential logic has to be testable without the\n * environment it runs in.\n *\n * The practical payoff is that a misconfigured site can be told exactly what will\n * and won't happen without sending anything — a silently unsent conversion\n * notification is indistinguishable from no conversion.\n */\nimport type { EmailChannelConfig, EmailPlan, NotificationPlan, NotifyContext } from './types.ts';\n\n/** Default Workers binding name for Cloudflare Email Sending. */\nexport const DEFAULT_EMAIL_BINDING = 'EMAIL';\n\n/** Normalise the `email` shorthand: a bare address means a Cloudflare send to it. */\nexport function normalizeEmailChannel(\n input: string | EmailChannelConfig | undefined,\n): EmailChannelConfig | undefined {\n if (input === undefined) return undefined;\n return typeof input === 'string' ? { provider: 'cloudflare', to: input } : input;\n}\n\n/**\n * Who the notification reaches.\n *\n * An explicit recipient wins; otherwise it falls to the site's own contact\n * addresses, primary first. This cascade is why a site that has already said\n * where it receives mail doesn't have to say it twice.\n */\nexport function resolveRecipient(\n channel: EmailChannelConfig,\n ctx: NotifyContext,\n): string | undefined {\n if (channel.to) return channel.to;\n return ctx.locationEmails?.find((e) => !!e);\n}\n\n/**\n * The From address.\n *\n * `noreply@<canonical>` by default, because the sending domain has to be one the\n * site controls — Cloudflare rejects anything else with `E_SENDER_NOT_VERIFIED`,\n * and guessing from the recipient's domain would send that failure every time.\n */\nexport function resolveSender(channel: EmailChannelConfig, ctx: NotifyContext): string | undefined {\n if (channel.from) return channel.from;\n if (!ctx.canonical) return undefined;\n let host: string;\n try {\n host = new URL(ctx.canonical).hostname;\n } catch {\n // A bare hostname is a legitimate way to write `domains.canonical`.\n host = ctx.canonical.replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '');\n }\n return host ? `noreply@${host}` : undefined;\n}\n\n/**\n * Decide what will be sent, and say why anything won't be.\n *\n * Every \"off\" carries a reason rather than being an absence, so a caller can\n * report the misconfiguration instead of reporting success over a no-op.\n */\nexport function planNotifications(ctx: NotifyContext): NotificationPlan {\n const email = planEmail(ctx);\n return { email, empty: !email.enabled };\n}\n\nfunction planEmail(ctx: NotifyContext): EmailPlan {\n const channel = normalizeEmailChannel(ctx.notifications?.email);\n const binding = channel?.binding ?? DEFAULT_EMAIL_BINDING;\n\n if (!channel) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip: 'No `notifications.email` configured.',\n };\n }\n\n const to = resolveRecipient(channel, ctx);\n if (!to) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip:\n 'No recipient: set `notifications.email.to`, or give a location an `email` ' +\n 'so the notification has somewhere to go.',\n };\n }\n\n const from = resolveSender(channel, ctx);\n if (!from) {\n return {\n provider: 'cloudflare',\n binding,\n to,\n enabled: false,\n skip:\n 'No sender: set `notifications.email.from`, or `domains.canonical` so ' +\n '`noreply@<host>` can be derived. Cloudflare only sends from a domain you have onboarded.',\n };\n }\n\n return {\n provider: 'cloudflare',\n binding,\n to,\n from,\n fromName: channel.fromName ?? ctx.organizationName,\n replyTo: channel.replyTo,\n enabled: true,\n };\n}\n\n/**\n * Whether a form post has anywhere to go: a `notifications.email` channel, a location e-mail,\n * or a CRM. With none of the three the emdash template's `/api/track` refuses the post (it\n * would otherwise accept it and lose the message), so `vitops emdash check-prerender` asks the\n * same question of the config before the first visitor finds out. One function so the build\n * check and the route cannot disagree.\n */\nexport function hasFormDelivery(\n ctx: Pick<NotifyContext, 'notifications' | 'locationEmails'>,\n crm?: unknown,\n): boolean {\n return Boolean(ctx.notifications?.email || ctx.locationEmails?.length || crm);\n}\n","/**\n * Turning a `ConversionEvent` into something a person reads.\n *\n * Pure, and separate from both the plan and the sender, because rendering is the\n * part that differs per channel: an SMS channel will render the same event in 160\n * characters, a portal log as a row. The event stays the fact; only this file has\n * an opinion about prose.\n *\n * The layout is three sections — who got in touch, which ad sent them, and what\n * the request looked like — because that is the order the reader needs them in.\n * The contact details are the point; attribution is why it matters; the visitor\n * context is for when something looks wrong.\n */\nimport { identifySubmitter } from '../tracking/identity.ts';\nimport { getPrimaryClickId, identifyPlatform } from '../tracking/platform.ts';\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport type { RenderedMessage } from './types.ts';\n\n/**\n * Fields never worth putting in a notification.\n *\n * A honeypot is not visitor-supplied — it is bait, and reporting it as something\n * they submitted is untrue. The same rule `legal/derive.ts` applies when deriving\n * `piiCollected`, and for the same reason. Callers may strip more.\n */\nconst OMIT_FIELDS = new Set(['website', '_honeypot', 'honeypot', 'cf-turnstile-response']);\n\nfunction label(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1).replace(/[_-]/g, ' ');\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"');\n}\n\n/** One section: a heading and its lines. Empty sections are dropped by the caller. */\ninterface Section {\n heading: string;\n lines: [string, string][];\n}\n\n/**\n * One line, already rendered both ways — a plain fact (`html` is just the\n * escaped `text`) or a link (`html` an anchor, `text` the bare href). Built at\n * the point each line is known rather than carried as a union and branched on\n * later: `describeEvent`'s lines are always plain `[label, value]` pairs (see\n * `Section` above, which `render.test.ts` destructures as such), and the one\n * line shape `renderEmail` adds itself — the \"Actions\" link — is turned into\n * this same rendered shape immediately, so the two renderers below share one\n * line format instead of branching on what kind of line each one is.\n */\ninterface RenderedLine {\n label: string;\n text: string;\n html: string;\n}\n\n/** A section as `renderEmail` assembles it — `describeEvent`'s output plus its own additions. */\ninterface RenderSection {\n heading: string;\n lines: RenderedLine[];\n}\n\nfunction factLine([label, value]: readonly [string, string]): RenderedLine {\n return { label, text: value, html: escapeHtml(value) };\n}\n\nfunction linkLine(label: string, href: string): RenderedLine {\n return { label, text: href, html: `<a href=\"${escapeHtml(href)}\">${escapeHtml(href)}</a>` };\n}\n\nfunction toRenderSection(section: Section): RenderSection {\n return { heading: section.heading, lines: section.lines.map(factLine) };\n}\n\n/**\n * Who submitted the form, for the subject line.\n *\n * `formData['name']` alone is the shape a form has when someone writes it that\n * way, and most don't: a downstream site had `first_name`/`last_name` on five of\n * six forms, so every notification read \"from Unknown\" and the renderer could\n * not be adopted at all. The cascade is ordered most-specific first, and falls\n * back to the email rather than to nothing — an address identifies the person\n * even when no name field exists.\n */\nfunction submitterName(formData: Record<string, string>): string {\n return identifySubmitter(formData).fullName;\n}\n\n/**\n * The event as sections — the shared structure behind both renderings.\n *\n * Extracted so the text and HTML versions cannot disagree about content. They\n * differ only in markup; a field added here appears in both.\n */\nexport function describeEvent(event: ConversionEvent): { subject: string; sections: Section[] } {\n const t = event.tracking;\n const platform = t ? identifyPlatform(t) : null;\n const clickId = t ? getPrimaryClickId(t) : null;\n\n const contact: [string, string][] = [];\n let subject: string;\n\n if (event.type === 'form' && event.formData) {\n const name = submitterName(event.formData);\n subject = `[Contact Form] New submission from ${name}`;\n for (const [key, value] of Object.entries(event.formData)) {\n if (!OMIT_FIELDS.has(key) && value) contact.push([label(key), value]);\n }\n } else if (event.type === 'email') {\n const email = event.email ?? 'unknown';\n subject = `[Email Click] Visitor emailing ${email}`;\n contact.push(['Email', email]);\n } else {\n const phone = event.phone ?? 'unknown';\n subject = `[Phone Call] Visitor calling ${phone}`;\n contact.push(['Phone', phone]);\n }\n\n const attribution: [string, string][] = [];\n if (t) {\n if (platform) attribution.push(['Platform', platform]);\n if (clickId) attribution.push([`Click ID (${clickId.param})`, clickId.value]);\n for (const key of ['utm_campaign', 'utm_source', 'utm_medium', 'utm_content', 'utm_term']) {\n const value = t[key];\n if (value) attribution.push([label(key.replace('utm_', '')), String(value)]);\n }\n if (t.ab_variant) attribution.push(['A/B variant', t.ab_variant]);\n }\n\n const context: [string, string][] = [];\n if (t?.landingPage) context.push(['Landing page', t.landingPage]);\n if (t?.referrer) context.push(['Referrer', t.referrer]);\n if (t?.ts) context.push(['First visit', new Date(t.ts).toISOString()]);\n context.push(['Received', new Date(event.at).toISOString()]);\n if (event.userAgent) context.push(['User agent', event.userAgent]);\n if (event.ip) context.push(['IP', event.ip]);\n\n const sections: Section[] = [\n { heading: 'Contact details', lines: contact },\n // Stated rather than omitted: \"we don't know where this came from\" is a\n // useful answer, and a silently missing section reads as a bug in the tool.\n {\n heading: 'Ad attribution',\n lines: attribution.length\n ? attribution\n : [['Source', 'None — visitor arrived without ad tracking']],\n },\n { heading: 'Visitor context', lines: context },\n ];\n\n return { subject, sections: sections.filter((s) => s.lines.length) };\n}\n\n/** Render for e-mail. Both halves, always — see `RenderedMessage`. */\nexport function renderEmail(\n event: ConversionEvent,\n extra: { notes?: string[] | undefined; actionUrl?: string | undefined } = {},\n): RenderedMessage {\n const { subject, sections: eventSections } = describeEvent(event);\n\n // `{clickId}` is the only placeholder — an event has no durable id nothing\n // in this toolchain could look back up (there's no store), so interpolating\n // one would be decorative. Omitted entirely when there's no click ID to\n // interpolate, rather than emailing a link with a literal `{clickId}` in it.\n const clickId = event.tracking ? getPrimaryClickId(event.tracking) : null;\n const actionSection: RenderSection | null =\n extra.actionUrl && clickId\n ? {\n heading: 'Actions',\n lines: [\n linkLine(\n 'View in ad platform',\n extra.actionUrl.replace(/\\{clickId\\}/g, encodeURIComponent(clickId.value)),\n ),\n ],\n }\n : null;\n\n // Deliberately a channel-neutral `string[]` rather than a typed CRM result —\n // this module gains no dependency on `crm`, and the seam serves any future\n // sink the same way.\n const sections: RenderSection[] = [\n ...eventSections.map(toRenderSection),\n ...(actionSection ? [actionSection] : []),\n ...(extra.notes && extra.notes.length\n ? [{ heading: 'Delivery', lines: extra.notes.map((n) => factLine(['CRM', n])) }]\n : []),\n ];\n\n const text = sections\n .map((s) => [`--- ${s.heading} ---`, ...s.lines.map((l) => `${l.label}: ${l.text}`)].join('\\n'))\n .join('\\n\\n');\n\n const html = sections\n .map(\n (s) =>\n `<h2 style=\"font:600 14px system-ui;margin:24px 0 8px\">${escapeHtml(s.heading)}</h2>` +\n `<table style=\"font:14px system-ui;border-collapse:collapse\">${s.lines\n .map(\n (l) =>\n `<tr><td style=\"padding:2px 12px 2px 0;color:#666;vertical-align:top\">${escapeHtml(l.label)}</td>` +\n `<td style=\"padding:2px 0\">${l.html}</td></tr>`,\n )\n .join('')}</table>`,\n )\n .join('');\n\n return { subject, text, html };\n}\n","/**\n * Google Ads offline conversion upload — the server-side counterpart to the\n * client-side `gtag('event', 'conversion', …)` call `gtagBootstrap`\n * (`@getvitops/utils/ads`) wires up. Reads `site.ads.google.reporting: 'server'`\n * and a matching `conversionActionId` (see that field's own docblock for why\n * it is a different identifier from `conversionLabel`, not an alternate\n * spelling of it) and calls `ConversionUploadService.UploadClickConversions`\n * instead of relying on a visitor's browser to fire the tag.\n *\n * Same reasoning as `@getvitops/utils/crm`'s executors: credentials are a\n * structurally-typed shape the consumer's route supplies from env vars, never\n * config, and a failed upload is a `GoogleAdsUploadResult` to log or fold into\n * the notification email — never an exception, and never something that fails\n * the conversion request it's attached to. A lost ad report is not a lost\n * lead; the visitor has already submitted.\n *\n * **Structurally typed against Google's documented REST shape, not verified\n * against a live Ads account** — no developer-token/MCC access exists\n * anywhere in this toolchain's own setup to test against (the same blocker\n * `vitops ads provision` is waiting on). Same caveat, and the same reason, as\n * `@getvitops/utils/crm`'s Jobber executor: wrapped so a wrong guess about the\n * exact request/response shape degrades to a stated failure reason rather\n * than breaking. Re-verify against `googleads.googleapis.com`'s current API\n * version and `ClickConversion` message shape before depending on this in\n * production, and update this docblock with what was found.\n */\nimport { errorDetail, googleAccessToken, googleHeaders } from '../google/token.ts';\nimport type { GoogleOAuth } from '../google/token.ts';\n\n/** Bumped independently of everything else here — the Ads API deprecates\n * versions on its own rolling schedule. Last checked against Google's public\n * docs at the time this file was written; not re-verified since. */\nconst API_VERSION = 'v17';\n\nexport interface GoogleAdsCredentials {\n /** Issued against a Google Ads manager (MCC) account — a Google review, not\n * a self-service toggle. Never config. */\n developerToken: string;\n oauth: GoogleOAuth;\n /** The MCC's own (dashes-or-not) customer id — required when `customerId`\n * in the upload input is a client account managed under it, which is the\n * common case for an agency running this on a client's behalf. */\n loginCustomerId?: string | undefined;\n}\n\nexport interface GoogleAdsUploadInput {\n /** Google Ads customer id, as shown in the UI (`\"123-456-7890\"`) or bare\n * digits — either works, dashes are stripped before the call. */\n customerId: string;\n /** A numeric conversion action id, or a full\n * `customers/…/conversionActions/…` resource name. */\n conversionActionId: string;\n /** The click id captured on `_ac` — `getPrimaryClickId()`'s result. */\n clickId: { param: string; value: string };\n /** Epoch ms — converted to the Ads API's own\n * `\"yyyy-MM-dd HH:mm:ss+00:00\"` format. */\n at: number;\n conversionValue?: number | undefined;\n currencyCode?: string | undefined;\n orderId?: string | undefined;\n}\n\n/** Never thrown — an Ads API outage or a malformed request both come back as\n * `ok: false`, the same \"structured result, not an exception\" rule every\n * other executor in this toolchain follows. */\nexport interface GoogleAdsUploadResult {\n ok: boolean;\n reason?: string | undefined;\n code?: string | undefined;\n}\n\nfunction digitsOnly(id: string): string {\n return id.replace(/\\D/g, '');\n}\n\n/** A bare numeric id becomes a full resource name under `customerId`; a value\n * already shaped like one (the escape hatch, matching `txtRecord`'s `=`\n * check in `@getvitops/utils/ads`) passes through unchanged. */\nexport function conversionActionResourceName(\n customerId: string,\n conversionActionId: string,\n): string {\n if (conversionActionId.includes('customers/')) return conversionActionId;\n return `customers/${digitsOnly(customerId)}/conversionActions/${conversionActionId}`;\n}\n\n/** The Ads API's documented click-conversion datetime format, always\n * rendered in UTC — there is no per-account timezone lookup here to do\n * better, and UTC is unambiguous. */\nexport function toGoogleConversionDateTime(atMs: number): string {\n const d = new Date(atMs);\n const pad = (n: number): string => String(n).padStart(2, '0');\n return (\n `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ` +\n `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}+00:00`\n );\n}\n\n/** The request field a click id param maps to — the API takes `gclid`/\n * `gbraid`/`wbraid` as distinct fields, not one generic \"click id\" field.\n * Anything else this toolchain's `PLATFORM_PARAMS` maps to Google (today,\n * only these three) falls back to `gclid`. */\nfunction clickIdField(param: string): 'gclid' | 'gbraid' | 'wbraid' {\n if (param === 'gbraid' || param === 'wbraid') return param;\n return 'gclid';\n}\n\n/**\n * Upload one click conversion via `ConversionUploadService.UploadClickConversions`.\n *\n * `partialFailure: true` is always sent, and a 200 response carrying\n * `partialFailureError` is treated as a failure, not a success — a single-\n * conversion batch makes \"partial\" and \"total\" failure the same case, and\n * Google Ads API responses are 200 for a partial failure by design (silently\n * treating that as success is exactly the trap `@getvitops/utils/crm`'s\n * Jobber executor documents for its own GraphQL transport).\n */\nexport async function uploadClickConversion(\n input: GoogleAdsUploadInput,\n credentials: GoogleAdsCredentials,\n fetchImpl: typeof fetch = fetch,\n): Promise<GoogleAdsUploadResult> {\n let token: string;\n try {\n token = await googleAccessToken({ kind: 'oauth', oauth: credentials.oauth }, fetchImpl);\n } catch (err) {\n return {\n ok: false,\n reason: `Google Ads token exchange failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n\n const customerId = digitsOnly(input.customerId);\n const url = `https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}:uploadClickConversions`;\n\n const body = {\n conversions: [\n {\n conversionAction: conversionActionResourceName(customerId, input.conversionActionId),\n [clickIdField(input.clickId.param)]: input.clickId.value,\n conversionDateTime: toGoogleConversionDateTime(input.at),\n ...(input.conversionValue != null ? { conversionValue: input.conversionValue } : {}),\n ...(input.currencyCode ? { currencyCode: input.currencyCode } : {}),\n ...(input.orderId ? { orderId: input.orderId } : {}),\n },\n ],\n partialFailure: true,\n };\n\n let res: Response;\n try {\n res = await fetchImpl(url, {\n method: 'POST',\n headers: googleHeaders(token, {\n 'developer-token': credentials.developerToken,\n 'content-type': 'application/json',\n ...(credentials.loginCustomerId\n ? { 'login-customer-id': digitsOnly(credentials.loginCustomerId) }\n : {}),\n }),\n body: JSON.stringify(body),\n });\n } catch (err) {\n return {\n ok: false,\n reason: `Google Ads request failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n\n if (!res.ok) {\n return {\n ok: false,\n code: String(res.status),\n reason: await errorDetail(res, (status) =>\n status === 401\n ? 'Google Ads rejected the access token.'\n : status === 403\n ? 'Google Ads refused the request — check the developer token is approved and `login-customer-id` is set for an MCC-managed account.'\n : undefined,\n ),\n };\n }\n\n const json = (await res.json().catch(() => ({}))) as {\n partialFailureError?: { message?: string };\n };\n if (json.partialFailureError) {\n return {\n ok: false,\n reason: `Google Ads rejected the conversion: ${json.partialFailureError.message ?? 'no detail given'}`,\n };\n }\n\n return { ok: true };\n}\n\n/** A one-line delivery note, matching `describeCrmResult`'s shape — what\n * `conversion.ts` folds into the notification email's \"Delivery\" section. */\nexport function describeGoogleAdsOfflineResult(\n result: GoogleAdsUploadResult | null,\n): string | null {\n if (!result) return null;\n if (result.ok) return 'Reported to Google Ads (server-side)';\n return `⚠ Not reported to Google Ads: ${result.reason ?? 'unknown reason'}`;\n}\n","/**\n * Conversion notifications — plan, render, dispatch.\n *\n * The seam between \"a conversion happened\" and \"someone found out about it\".\n * A `ConversionEvent` from `@getvitops/utils/tracking` goes in; where it goes and\n * how it reads are config, not code at the call site.\n *\n * Three files, three jobs, matching `indexing/`:\n * - `plan.ts` decides everything, purely — which channels, which recipients,\n * and why anything is off.\n * - `render.ts` turns the event into prose, purely.\n * - `email.ts` executes, and decides nothing.\n *\n * `google-ads.ts` is a fourth file, added later, that does **not** follow the\n * three-file shape above: it isn't a `NotificationsConfig` channel `notify()`\n * plans and dispatches, it's a separate delivery keyed to `site.ads.google`,\n * wired in by `createConversionRoute`'s own `googleAdsOffline` option and\n * folded into the email's \"Delivery\" section exactly like `@getvitops/utils/\n * crm`'s `CrmResult` — see that module's `describeCrmResult` for the\n * precedent this follows (`describeGoogleAdsOfflineResult` here).\n *\n * ---\n *\n * **TODO — further channels.** Only `email` is implemented. The seam is\n * `NotificationsConfig` + a sender with `sendEmail`'s signature `(plan, message,\n * transport) => ChannelResult`; adding one should mean a new sender file, a new\n * branch in `planNotifications`, and a schema variant — touching neither\n * `ConversionEvent` nor the recipient cascade. Planned:\n * - `sms` — the same event rendered short. `render.ts` already separates\n * `describeEvent` from `renderEmail` for exactly this.\n * - `persist` — append to a store (D1, a portal log) the client reviews.\n * The generic `email`/`text`/`persist` helpers taking content + provider config\n * belong at that point, not before: one implemented channel is not enough to know\n * what the abstraction should be.\n */\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport { logEmail, sendEmail } from './email.ts';\nimport { planNotifications } from './plan.ts';\nimport { renderEmail } from './render.ts';\nimport type { ChannelResult, EmailBinding, NotifyContext } from './types.ts';\n\nexport interface NotifyDeps {\n /**\n * The Workers `send_email` binding (`env.EMAIL`). Omit it and the notification\n * is printed instead — the dev path.\n */\n email?: EmailBinding | undefined;\n}\n\nexport interface NotifyResult {\n results: ChannelResult[];\n /** True when at least one channel delivered. */\n delivered: boolean;\n}\n\n/**\n * Notify every configured channel about a conversion.\n *\n * Channels are independent: one failing must not stop the others, and none of\n * them may throw into the request that produced the event. Every outcome —\n * delivered, skipped, failed — comes back as data for the caller to log.\n */\nexport async function notify(\n event: ConversionEvent,\n ctx: NotifyContext,\n deps: NotifyDeps = {},\n extra: { notes?: string[] | undefined } = {},\n): Promise<NotifyResult> {\n const plan = planNotifications(ctx);\n const results: ChannelResult[] = [];\n\n if (plan.email.enabled) {\n const message = renderEmail(event, { ...extra, actionUrl: ctx.notifications?.actionUrl });\n results.push(\n deps.email ? await sendEmail(plan.email, message, deps.email) : logEmail(plan.email, message),\n );\n } else {\n results.push({ channel: 'email', sent: false, reason: plan.email.skip ?? 'Not configured.' });\n }\n\n return { results, delivered: results.some((r) => r.sent) };\n}\n\nexport {\n DEFAULT_EMAIL_BINDING,\n hasFormDelivery,\n normalizeEmailChannel,\n planNotifications,\n resolveRecipient,\n resolveSender,\n} from './plan.ts';\nexport { describeEvent, renderEmail } from './render.ts';\nexport { logEmail, sendEmail } from './email.ts';\nexport {\n conversionActionResourceName,\n describeGoogleAdsOfflineResult,\n toGoogleConversionDateTime,\n uploadClickConversion,\n} from './google-ads.ts';\nexport type {\n GoogleAdsCredentials,\n GoogleAdsUploadInput,\n GoogleAdsUploadResult,\n} from './google-ads.ts';\nexport type {\n ChannelPlan,\n ChannelResult,\n EmailBinding,\n EmailChannelConfig,\n EmailPlan,\n NotificationPlan,\n NotificationsConfig,\n NotifyContext,\n RenderedMessage,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;AACF,CAAC;AAED,SAAS,OAAO,OAAoC;CAClD,MAAM,OAAQ,OAAqC;CACnD,OAAO,OAAO,SAAS,WAAW,OAAO;AAC3C;AAEA,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAsBA,MAAM,QAAQ,OAA8B,IAAI,SAAS,MAAM,WAAW,GAAG,EAAE,CAAC;;AAGhF,MAAM,eAAe;;;;;;;;AASrB,eAAe,YA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CACA,WAAW,MACT,sIACA,MACR;CACF;CAGF,MAAM,OAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE;CAG/C,IAAI,KAAK,qBACP,OAAO;EACL,IAAI;EACJ,QAAQ,uCAAuC,KAAK,oBAAoB,WAAW;CACrF;CAGF,OAAO,EAAE,IAAI,KAAK;AACpB;;;AAIA,SAAgB,+BACd,QACe;CACf,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,IAAI,OAAO;CACtB,OAAO,iCAAiC,OAAO,UAAU;AAC3D;;;;;;;;;;AC9IA,eAAsB,OACpB,OACA,KACA,OAAmB,CAAC,GACpB,QAA0C,CAAC,GACpB;CACvB,MAAM,OAAO,kBAAkB,GAAG;CAClC,MAAM,UAA2B,CAAC;CAElC,IAAI,KAAK,MAAM,SAAS;EACtB,MAAM,UAAU,YAAY,OAAO;GAAE,GAAG;GAAO,WAAW,IAAI,eAAe;EAAU,CAAC;EACxF,QAAQ,KACN,KAAK,QAAQ,MAAM,UAAU,KAAK,OAAO,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,OAAO,OAAO,CAC9F;CACF,OACE,QAAQ,KAAK;EAAE,SAAS;EAAS,MAAM;EAAO,QAAQ,KAAK,MAAM,QAAQ;CAAkB,CAAC;CAG9F,OAAO;EAAE;EAAS,WAAW,QAAQ,MAAM,MAAM,EAAE,IAAI;CAAE;AAC3D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getvitops/utils",
|
|
3
|
-
"version": "8.3.0-alpha.
|
|
3
|
+
"version": "8.3.0-alpha.2",
|
|
4
4
|
"description": "Shared build-time utilities for the Vitops toolchain — favicon generation and friends.",
|
|
5
5
|
"homepage": "https://docs.vitops.ca",
|
|
6
6
|
"bugs": "https://github.com/getvitops/design-system/issues",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"access": "public"
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"@getvitops/config": "8.3.0-alpha.
|
|
110
|
+
"@getvitops/config": "8.3.0-alpha.2",
|
|
111
111
|
"colorjs.io": "^0.5.2",
|
|
112
112
|
"parse5": "^7.3.0",
|
|
113
113
|
"png-to-ico": "^3.0.2",
|