@aglyn/aglyn 1.0.0-beta.270 → 1.0.0-beta.272
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 +11 -11
- package/src/lib/app-utils/account-preferences.d.ts +50 -0
- package/src/lib/app-utils/account-preferences.js +96 -0
- package/src/lib/app-utils/account-preferences.js.map +1 -1
- package/src/lib/app-utils/activity-labels.js +2 -0
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +16 -2
- package/src/lib/app-utils/analytics-events.js +2 -0
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/append-only-history.d.ts +94 -0
- package/src/lib/app-utils/append-only-history.js +73 -0
- package/src/lib/app-utils/append-only-history.js.map +1 -0
- package/src/lib/app-utils/bundle-intent.d.ts +186 -0
- package/src/lib/app-utils/bundle-intent.js +386 -0
- package/src/lib/app-utils/bundle-intent.js.map +1 -0
- package/src/lib/app-utils/client-build.d.ts +207 -0
- package/src/lib/app-utils/client-build.js +237 -0
- package/src/lib/app-utils/client-build.js.map +1 -0
- package/src/lib/app-utils/console-routes.d.ts +4 -0
- package/src/lib/app-utils/console-routes.js +2 -0
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +13 -6
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +11 -5
- package/src/lib/app-utils/docs-help.generated.js +31 -2
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +105 -35
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/margin-utilization.js +6 -4
- package/src/lib/app-utils/margin-utilization.js.map +1 -1
- package/src/lib/app-utils/media-filter.d.ts +26 -0
- package/src/lib/app-utils/media-filter.js +32 -0
- package/src/lib/app-utils/media-filter.js.map +1 -1
- package/src/lib/app-utils/onboarding-deep-link.d.ts +36 -2
- package/src/lib/app-utils/onboarding-deep-link.js +48 -5
- package/src/lib/app-utils/onboarding-deep-link.js.map +1 -1
- package/src/lib/app-utils/operator-alerts.js +21 -0
- package/src/lib/app-utils/operator-alerts.js.map +1 -1
- package/src/lib/app-utils/owner-approval-record.d.ts +102 -0
- package/src/lib/app-utils/owner-approval-record.js +148 -0
- package/src/lib/app-utils/owner-approval-record.js.map +1 -0
- package/src/lib/app-utils/plan-card-meters.d.ts +96 -0
- package/src/lib/app-utils/plan-card-meters.js +197 -0
- package/src/lib/app-utils/plan-card-meters.js.map +1 -0
- package/src/lib/app-utils/plan-entitlements.d.ts +183 -67
- package/src/lib/app-utils/plan-entitlements.js +213 -58
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +22 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +4 -0
- package/src/lib/app-utils/server.js +7 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-care-project.d.ts +227 -0
- package/src/lib/app-utils/site-care-project.js +423 -0
- package/src/lib/app-utils/site-care-project.js.map +1 -0
- package/src/lib/app-utils/site-care.d.ts +291 -0
- package/src/lib/app-utils/site-care.js +310 -0
- package/src/lib/app-utils/site-care.js.map +1 -0
- package/src/lib/app-utils/upgrade-proposal.d.ts +29 -4
- package/src/lib/app-utils/upgrade-proposal.js +60 -9
- package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
- package/src/lib/foundation/definitions/org-billing.types.d.ts +40 -10
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +3 -1
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +20 -0
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +48 -0
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.js +16 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-ai-capabilities.d.ts +19 -0
- package/src/lib/plugin-manager/plugin-ai-capabilities.js.map +1 -1
- package/src/lib/plugin-manager/plugin-domain-search.d.ts +81 -0
- package/src/lib/plugin-manager/plugin-domain-search.js +63 -0
- package/src/lib/plugin-manager/plugin-domain-search.js.map +1 -0
- package/src/lib/plugin-manager/plugin-entitlements.d.ts +23 -5
- package/src/lib/plugin-manager/plugin-entitlements.js +10 -0
- package/src/lib/plugin-manager/plugin-entitlements.js.map +1 -1
- package/src/lib/plugin-manager/plugin-media-ingest.d.ts +18 -1
- package/src/lib/plugin-manager/plugin-media-ingest.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-resources.d.ts +74 -0
- package/src/lib/plugin-manager/plugin-site-resources.js +135 -0
- package/src/lib/plugin-manager/plugin-site-resources.js.map +1 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.d.ts +61 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.js +102 -0
- package/src/lib/plugin-manager/purchase-gate-preclearance.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/onboarding-deep-link.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 type { OrgPlan } from '../foundation/definitions/org-billing.types'\nimport { isCustomPricedPlan } from './plan-entitlements'\n\n/**\n * The marketing → console onboarding deep link (AGL-1117).\n *\n * `app.aglyn.com/signup?plan=pro&interval=year`, optionally `&ai=1` for the\n * Aglyn AI add-on (AGL-2897).\n *\n * This is a CONTRACT with a site we do not control and cannot deploy in\n * lockstep with. So it is parsed defensively and in one place: the pricing\n * page will eventually be edited by someone who has never read this file, and\n * a typo in a CTA must degrade to ordinary signup rather than break it or —\n * far worse — silently start someone on the wrong plan.\n */\nexport type OnboardingInterval = 'month' | 'year'\n\nexport interface OnboardingPlanIntent {\n plan: OrgPlan\n interval: OnboardingInterval\n /**\n * Whether the link ACTUALLY said an interval, as opposed to `interval`\n * being the safe default below (AGL-1535).\n *\n * Some CTAs carry a plan and deliberately no interval — the /pricing scale\n * strip quotes monthly and annual side by side and commits to neither. The\n * billing page honours that (it only lets a *stated* interval move the\n * toggle, so an annual org is not silently flipped to monthly on arrival),\n * but every hop between the CTA and that page used to re-serialize the\n * intent with `&interval=month` appended — which made the omission\n * unrecoverable one redirect after it was made. Carrying the distinction is\n * what keeps \"no interval stated\" a thing the last reader can still see.\n */\n intervalStated: boolean\n /**\n * Enterprise is quoted, not bought. The CTA still carries `plan=enterprise`\n * because that is what the visitor clicked, and the console has to route\n * them to contact-sales rather than to a checkout that cannot price it\n * (AGL-1110).\n */\n contactSales: boolean\n /**\n * The Aglyn AI add-on, asked for alongside the plan (AGL-2897):\n * `?plan=pro&interval=month&ai=1`.\n *\n * Present only when the link said so, and only ever `true` — the add-on\n * rides the plan checkout as a second subscription item, so a flag that\n * was never stated must not be told apart from one that was set to false\n * by every hop that re-serializes the intent. Enterprise never carries it:\n * the add-on is quoted with the deal, not bought through a checkout.\n */\n ai?: true\n}\n\nconst SELF_SERVE_PLANS: readonly OrgPlan[] = [\n 'starter',\n 'pro',\n 'business',\n 'scale',\n 'advanced',\n 'agency',\n]\n\n/**\n * Read a plan intent off the URL, or null when there isn't a usable one.\n *\n * Null for `free` on purpose: it is a real plan but not a purchase, so there\n * is nothing to carry into checkout and a new org already starts there.\n * Returning an intent for it would send someone to a billing page to buy\n * what they already have.\n */\nexport function parseOnboardingPlanIntent(\n params:\n | URLSearchParams\n | Record<string, string | string[] | undefined>\n | null\n | undefined,\n): OnboardingPlanIntent | null {\n if (!params) return null\n const read = (key: string): string => {\n const raw =\n params instanceof URLSearchParams ? params.get(key) : params[key]\n // Next gives `string[]` for a repeated param. Take the first rather than\n // joining, so `?plan=pro&plan=free` cannot become the string \"pro,free\"\n // and fall through to null — the first is what the CTA meant.\n return String((Array.isArray(raw) ? raw[0] : raw) ?? '')\n .trim()\n .toLowerCase()\n }\n const plan = read('plan')\n if (!plan) return null\n if (isCustomPricedPlan(plan as OrgPlan)) {\n return {\n plan: plan as OrgPlan,\n interval: 'month',\n intervalStated: false,\n contactSales: true,\n }\n }\n if (!SELF_SERVE_PLANS.includes(plan as OrgPlan)) return null\n const interval = read('interval')\n const known = interval === 'year' || interval === 'annual' || interval === 'month'\n // The add-on is opt-in by an explicit affirmative. Anything else — absent,\n // empty, `0`, `false`, a typo — is \"not asked for\": a checkout that adds a\n // paid item off a malformed link is the expensive direction to be wrong in.\n const ai = read('ai')\n const aiStated = ai === '1' || ai === 'true' || ai === 'yes'\n return {\n plan: plan as OrgPlan,\n // Anything unrecognized falls to monthly, never to yearly: guessing the\n // longer commitment from a malformed link is the expensive direction to\n // be wrong in.\n interval: interval === 'year' || interval === 'annual' ? 'year' : 'month',\n // A junk interval is not a stated one: `?interval=decade` means the link\n // is broken, and the reader should fall back to what it knows about the\n // org rather than be told \"monthly\" with a straight face.\n intervalStated: known,\n contactSales: false,\n ...(aiStated ? { ai: true } : {}),\n }\n}\n\n/**\n * The intent as query params — the one place the wire form is written\n * (AGL-1535).\n *\n * Every hop that re-serializes an intent (the signup landing, the auth-bounce\n * `continue`, the home jump) used to build this string by hand and append\n * `&interval=` unconditionally, which turned the parser's monthly DEFAULT into\n * a statement the next reader could not tell from the real thing.\n */\nexport function onboardingPlanQuery(intent: OnboardingPlanIntent): string {\n return (\n `plan=${encodeURIComponent(intent.plan)}` +\n (intent.intervalStated ? `&interval=${intent.interval}` : '') +\n (intent.ai ? '&ai=1' : '')\n )\n}\n\n/**\n * The signup URL a marketing CTA should carry — the WRITER half of the\n * contract above (AGL-1989).\n *\n * The contract had a parser and a re-serializer but nothing that produced a\n * link in the first place, so every published CTA was hand-typed. That is how\n * `/pricing` came to have six CTAs carrying `interval=` and three carrying\n * none: the \"Need more scale?\" strip quotes Scale, Advanced and Agency at both\n * cadences and its CHOOSE links say only `?plan=scale`, so a visitor who had\n * just picked Annual arrived pre-selected for a MONTHLY plan and silently lost\n * the annual discount they were shown. Nothing could have caught it, because\n * the string that should have been published existed nowhere a check could\n * read it.\n *\n * `interval: null` is a real and different thing from `'month'`: it means the\n * CTA does not commit to a cadence, which the billing page honours by leaving\n * an annual org on annual (`intervalStated`). Callers with a cadence to state\n * must state it.\n *\n * The marketing site is authored content, not code, so this does not publish\n * anything — it is what the authoring input quotes, so the person clicking the\n * link into the besigner pastes a string this contract's own parser agrees\n * with rather than one they typed.\n */\nexport function onboardingSignupHref(\n signupUrl: string,\n plan: OrgPlan,\n interval: OnboardingInterval | null,\n options: { ai?: boolean } = {},\n): string {\n const contactSales = isCustomPricedPlan(plan)\n // A custom-priced plan is quoted, not bought, so `parseOnboardingPlanIntent`\n // reports `intervalStated: false` for it HOWEVER the link is written. Writing\n // `?plan=enterprise&interval=year` anyway puts a claim on the wire that no\n // reader honours — and before AGL-1864 fixed the reader, that exact link\n // flipped an annual org to monthly on arrival. Drop it at the source, which\n // is the last place it can be dropped before it is published.\n const stated = interval != null && contactSales === false\n return `${signupUrl}?${onboardingPlanQuery({\n plan,\n interval: stated ? interval : 'month',\n intervalStated: stated,\n contactSales,\n // The add-on CTA (AGL-2897). Dropped for a custom-priced plan for the\n // same reason the interval is: the parser refuses it there, so writing\n // it would publish a claim no reader honors.\n ...(options.ai && !contactSales ? { ai: true } : {}),\n })}`\n}\n\n/**\n * Where a freshly provisioned workspace should land, given the plan the\n * visitor picked on the marketing site.\n *\n * Deliberately returns a path rather than pushing: signup owns the\n * navigation, and a pure function is the half worth testing.\n */\nexport function onboardingDestination(\n orgSlug: string,\n intent: OnboardingPlanIntent | null,\n): string {\n if (!orgSlug) return '/'\n if (!intent) return `/${orgSlug}`\n // Enterprise is a conversation, not a checkout (AGL-1110).\n if (intent.contactSales) return `/${orgSlug}/support?topic=enterprise`\n return `/${orgSlug}/billing?${onboardingPlanQuery(intent)}`\n}\n"],"names":["isCustomPricedPlan","SELF_SERVE_PLANS","parseOnboardingPlanIntent","params","read","key","Array","raw","URLSearchParams","get","String","isArray","trim","toLowerCase","plan","interval","intervalStated","contactSales","includes","known","ai","aiStated","onboardingPlanQuery","intent","encodeURIComponent","onboardingSignupHref","signupUrl","options","stated","onboardingDestination","orgSlug"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,yBAAqB;AAqDxD,MAAMC,mBAAuC;IAC3C;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;;CAOC,GACD,OAAO,SAASC,0BACdC,MAIa;IAEb,IAAI,CAACA,QAAQ,OAAO;IACpB,MAAMC,OAAO,CAACC;YAMGC;QALf,MAAMC,MACJJ,kBAAkBK,kBAAkBL,OAAOM,GAAG,CAACJ,OAAOF,MAAM,CAACE,IAAI;QACnE,yEAAyE;QACzE,wEAAwE;QACxE,8DAA8D;QAC9D,OAAOK,QAAQJ,OAAAA,MAAMK,OAAO,CAACJ,OAAOA,GAAG,CAAC,EAAE,GAAGA,eAA9BD,OAAsC,IAClDM,IAAI,GACJC,WAAW;IAChB;IACA,MAAMC,OAAOV,KAAK;IAClB,IAAI,CAACU,MAAM,OAAO;IAClB,IAAId,mBAAmBc,OAAkB;QACvC,OAAO;YACLA,MAAMA;YACNC,UAAU;YACVC,gBAAgB;YAChBC,cAAc;QAChB;IACF;IACA,IAAI,CAAChB,iBAAiBiB,QAAQ,CAACJ,OAAkB,OAAO;IACxD,MAAMC,WAAWX,KAAK;IACtB,MAAMe,QAAQJ,aAAa,UAAUA,aAAa,YAAYA,aAAa;IAC3E,2EAA2E;IAC3E,2EAA2E;IAC3E,4EAA4E;IAC5E,MAAMK,KAAKhB,KAAK;IAChB,MAAMiB,WAAWD,OAAO,OAAOA,OAAO,UAAUA,OAAO;IACvD,OAAO;QACLN,MAAMA;QACN,wEAAwE;QACxE,wEAAwE;QACxE,eAAe;QACfC,UAAUA,aAAa,UAAUA,aAAa,WAAW,SAAS;QAClE,yEAAyE;QACzE,wEAAwE;QACxE,0DAA0D;QAC1DC,gBAAgBG;QAChBF,cAAc;OACVI,WAAW;QAAED,IAAI;IAAK,IAAI,CAAC;AAEnC;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,oBAAoBC,MAA4B;IAC9D,OACE,CAAC,KAAK,EAAEC,mBAAmBD,OAAOT,IAAI,GAAG,GACxCS,CAAAA,OAAOP,cAAc,GAAG,CAAC,UAAU,EAAEO,OAAOR,QAAQ,EAAE,GAAG,EAAC,IAC1DQ,CAAAA,OAAOH,EAAE,GAAG,UAAU,EAAC;AAE5B;AAEA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASK,qBACdC,SAAiB,EACjBZ,IAAa,EACbC,QAAmC,EACnCY,UAA4B,CAAC,CAAC;IAE9B,MAAMV,eAAejB,mBAAmBc;IACxC,6EAA6E;IAC7E,8EAA8E;IAC9E,2EAA2E;IAC3E,yEAAyE;IACzE,4EAA4E;IAC5E,8DAA8D;IAC9D,MAAMc,SAASb,YAAY,QAAQE,iBAAiB;IACpD,OAAO,GAAGS,UAAU,CAAC,EAAEJ,oBAAoB;QACzCR;QACAC,UAAUa,SAASb,WAAW;QAC9BC,gBAAgBY;QAChBX;OAIIU,QAAQP,EAAE,IAAI,CAACH,eAAe;QAAEG,IAAI;IAAK,IAAI,CAAC,KAChD;AACN;AAEA;;;;;;CAMC,GACD,OAAO,SAASS,sBACdC,OAAe,EACfP,MAAmC;IAEnC,IAAI,CAACO,SAAS,OAAO;IACrB,IAAI,CAACP,QAAQ,OAAO,CAAC,CAAC,EAAEO,SAAS;IACjC,2DAA2D;IAC3D,IAAIP,OAAON,YAAY,EAAE,OAAO,CAAC,CAAC,EAAEa,QAAQ,yBAAyB,CAAC;IACtE,OAAO,CAAC,CAAC,EAAEA,QAAQ,SAAS,EAAER,oBAAoBC,SAAS;AAC7D"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/onboarding-deep-link.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 type { AiTierId, OrgPlan } from '../foundation/definitions/org-billing.types'\nimport {\n bundleAddonsParam,\n hasBundleAddons,\n normalizeBundleCoupon,\n parseBundleAddons,\n type BundleAddons,\n} from './bundle-intent'\nimport { isAiTierId, isCustomPricedPlan } from './plan-entitlements'\n\n/**\n * The marketing → console onboarding deep link (AGL-1117).\n *\n * `app.aglyn.com/signup?plan=pro&interval=year`, optionally `&ai=1` for the\n * Aglyn AI add-on (AGL-2897), or `&ai=<tier>` (`&ai=boost`) for a named\n * Aglyn AI tier (AGL-3965). The bundle checkout link (AGL-3955) adds\n * `&addons=siteCare,ai:boost,extraHost:2` for any add-on the plan sells and\n * `&coupon=<code>` for a promotion code to apply at checkout.\n *\n * This is a CONTRACT with a site we do not control and cannot deploy in\n * lockstep with. So it is parsed defensively and in one place: the pricing\n * page will eventually be edited by someone who has never read this file, and\n * a typo in a CTA must degrade to ordinary signup rather than break it or —\n * far worse — silently start someone on the wrong plan.\n */\nexport type OnboardingInterval = 'month' | 'year'\n\nexport interface OnboardingPlanIntent {\n plan: OrgPlan\n interval: OnboardingInterval\n /**\n * Whether the link ACTUALLY said an interval, as opposed to `interval`\n * being the safe default below (AGL-1535).\n *\n * Some CTAs carry a plan and deliberately no interval — the /pricing scale\n * strip quotes monthly and annual side by side and commits to neither. The\n * billing page honours that (it only lets a *stated* interval move the\n * toggle, so an annual org is not silently flipped to monthly on arrival),\n * but every hop between the CTA and that page used to re-serialize the\n * intent with `&interval=month` appended — which made the omission\n * unrecoverable one redirect after it was made. Carrying the distinction is\n * what keeps \"no interval stated\" a thing the last reader can still see.\n */\n intervalStated: boolean\n /**\n * Enterprise is quoted, not bought. The CTA still carries `plan=enterprise`\n * because that is what the visitor clicked, and the console has to route\n * them to contact-sales rather than to a checkout that cannot price it\n * (AGL-1110).\n */\n contactSales: boolean\n /**\n * The Aglyn AI add-on, asked for alongside the plan (AGL-2897):\n * `?plan=pro&interval=month&ai=1`.\n *\n * Present only when the link said so, and only ever `true` — the add-on\n * rides the plan checkout as a second subscription item, so a flag that\n * was never stated must not be told apart from one that was set to false\n * by every hop that re-serializes the intent. Enterprise never carries it:\n * the add-on is quoted with the deal, not bought through a checkout.\n */\n ai?: true\n /**\n * The Aglyn AI tier the link named (AGL-3965): `?ai=boost`, or an\n * `ai:boost` token in `addons=` (AGL-3955). Present only with `ai`; absent,\n * `ai=1` means the tier with the plan's old price and band\n * (`defaultAiTierForPlan`), which is what checkout sells.\n */\n aiTier?: AiTierId\n /**\n * Every add-on the `addons=` param preselects (AGL-3955), parsed by the\n * shared `parseBundleAddons`. Absent when it named none. `ai=1` stays the\n * `ai` flag above; an `ai` token here sets that flag too, so a reader that\n * wants the whole set reads both (`intentAddons`).\n * Whether the plan sells each one is the reader's question\n * (`fitBundleAddonsToPlan`), because the owner can pick another plan.\n */\n addons?: BundleAddons\n /**\n * A promotion code to apply at checkout (AGL-3955). Applied only: codes are\n * minted on the staff Coupons page. An invalid or expired one is dropped by\n * the Billing page with a notice, never an error page.\n */\n coupon?: string\n /**\n * Add-on tokens the link named that nothing understood, as written, so the\n * page can say in one line that they were left off.\n */\n droppedAddons?: string[]\n}\n\nconst SELF_SERVE_PLANS: readonly OrgPlan[] = [\n 'starter',\n 'pro',\n 'business',\n 'scale',\n 'advanced',\n 'agency',\n]\n\n/**\n * Read a plan intent off the URL, or null when there isn't a usable one.\n *\n * Null for `free` on purpose: it is a real plan but not a purchase, so there\n * is nothing to carry into checkout and a new org already starts there.\n * Returning an intent for it would send someone to a billing page to buy\n * what they already have.\n */\nexport function parseOnboardingPlanIntent(\n params:\n | URLSearchParams\n | Record<string, string | string[] | undefined>\n | null\n | undefined,\n): OnboardingPlanIntent | null {\n if (!params) return null\n const read = (key: string): string => {\n const raw =\n params instanceof URLSearchParams ? params.get(key) : params[key]\n // Next gives `string[]` for a repeated param. Take the first rather than\n // joining, so `?plan=pro&plan=free` cannot become the string \"pro,free\"\n // and fall through to null — the first is what the CTA meant.\n return String((Array.isArray(raw) ? raw[0] : raw) ?? '')\n .trim()\n .toLowerCase()\n }\n const plan = read('plan')\n if (!plan) return null\n if (isCustomPricedPlan(plan as OrgPlan)) {\n return {\n plan: plan as OrgPlan,\n interval: 'month',\n intervalStated: false,\n contactSales: true,\n }\n }\n if (!SELF_SERVE_PLANS.includes(plan as OrgPlan)) return null\n const interval = read('interval')\n const known = interval === 'year' || interval === 'annual' || interval === 'month'\n // The add-on is opt-in by an explicit affirmative. Anything else — absent,\n // empty, `0`, `false`, a typo — is \"not asked for\": a checkout that adds a\n // paid item off a malformed link is the expensive direction to be wrong in.\n const ai = read('ai')\n // The bundle (AGL-3955). Read case-preserving: a coupon code is typed the\n // way Stripe stores it, and `read` lower-cases.\n const rawParam = (key: string): string => {\n const raw = params instanceof URLSearchParams ? params.get(key) : params[key]\n return String((Array.isArray(raw) ? raw[0] : raw) ?? '').trim()\n }\n const parsedAddons = parseBundleAddons(rawParam('addons'))\n const addons: BundleAddons = { ...parsedAddons.addons }\n const coupon = normalizeBundleCoupon(rawParam('coupon'))\n // `?ai=<tier>` names the tier outright; otherwise an `ai:<tier>` token in\n // `addons=` does (AGL-3965).\n const aiTier = isAiTierId(ai) ? ai : (parsedAddons.aiTier ?? null)\n const aiStated = ai === '1' || ai === 'true' || ai === 'yes' || aiTier !== null\n return {\n plan: plan as OrgPlan,\n // Anything unrecognized falls to monthly, never to yearly: guessing the\n // longer commitment from a malformed link is the expensive direction to\n // be wrong in.\n interval: interval === 'year' || interval === 'annual' ? 'year' : 'month',\n // A junk interval is not a stated one: `?interval=decade` means the link\n // is broken, and the reader should fall back to what it knows about the\n // org rather than be told \"monthly\" with a straight face.\n intervalStated: known,\n contactSales: false,\n ...(aiStated || addons.aiAddon ? { ai: true } : {}),\n ...(aiTier ? { aiTier } : {}),\n ...(hasBundleAddons(addons) ? { addons } : {}),\n ...(coupon ? { coupon } : {}),\n ...(parsedAddons.dropped.length ? { droppedAddons: parsedAddons.dropped } : {}),\n }\n}\n\n/** The whole add-on set an intent asks for: `addons=` and the `ai` flag together. */\nexport function intentAddons(intent: Pick<OnboardingPlanIntent, 'ai' | 'addons'> | null | undefined): BundleAddons {\n return { ...(intent?.addons ?? {}), ...(intent?.ai ? { aiAddon: 1 } : {}) }\n}\n\n/**\n * The intent as query params — the one place the wire form is written\n * (AGL-1535).\n *\n * Every hop that re-serializes an intent (the signup landing, the auth-bounce\n * `continue`, the home jump) used to build this string by hand and append\n * `&interval=` unconditionally, which turned the parser's monthly DEFAULT into\n * a statement the next reader could not tell from the real thing.\n */\nexport function onboardingPlanQuery(intent: OnboardingPlanIntent): string {\n // `ai=1` stays the spelling when Aglyn AI is the only add-on, so the\n // published pricing CTAs and every hop between them read unchanged. Any\n // other add-on writes the whole set as `addons=` (AGL-3955), Aglyn AI with it.\n const addons: BundleAddons = { ...(intent.addons ?? {}) }\n if (intent.ai) addons.aiAddon = 1\n const others = Object.keys(addons).some(\n (kind) => kind !== 'aiAddon' && (addons[kind as keyof BundleAddons] ?? 0) > 0,\n )\n const coupon = normalizeBundleCoupon(intent.coupon)\n return (\n `plan=${encodeURIComponent(intent.plan)}` +\n (intent.intervalStated ? `&interval=${intent.interval}` : '') +\n (others\n ? // Fixed tokens, letters, digits, `:` and `,` only, so the link stays\n // readable when it is read aloud or typed off a QR's caption.\n `&addons=${bundleAddonsParam(addons, intent.aiTier)}`\n : addons.aiAddon\n ? `&ai=${intent.aiTier ?? '1'}`\n : '') +\n (coupon ? `&coupon=${encodeURIComponent(coupon)}` : '')\n )\n}\n\n/**\n * The signup URL a marketing CTA should carry — the WRITER half of the\n * contract above (AGL-1989).\n *\n * The contract had a parser and a re-serializer but nothing that produced a\n * link in the first place, so every published CTA was hand-typed. That is how\n * `/pricing` came to have six CTAs carrying `interval=` and three carrying\n * none: the \"Need more scale?\" strip quotes Scale, Advanced and Agency at both\n * cadences and its CHOOSE links say only `?plan=scale`, so a visitor who had\n * just picked Annual arrived pre-selected for a MONTHLY plan and silently lost\n * the annual discount they were shown. Nothing could have caught it, because\n * the string that should have been published existed nowhere a check could\n * read it.\n *\n * `interval: null` is a real and different thing from `'month'`: it means the\n * CTA does not commit to a cadence, which the billing page honours by leaving\n * an annual org on annual (`intervalStated`). Callers with a cadence to state\n * must state it.\n *\n * The marketing site is authored content, not code, so this does not publish\n * anything — it is what the authoring input quotes, so the person clicking the\n * link into the besigner pastes a string this contract's own parser agrees\n * with rather than one they typed.\n */\nexport function onboardingSignupHref(\n signupUrl: string,\n plan: OrgPlan,\n interval: OnboardingInterval | null,\n options: { ai?: boolean; aiTier?: AiTierId } = {},\n): string {\n const contactSales = isCustomPricedPlan(plan)\n // A custom-priced plan is quoted, not bought, so `parseOnboardingPlanIntent`\n // reports `intervalStated: false` for it HOWEVER the link is written. Writing\n // `?plan=enterprise&interval=year` anyway puts a claim on the wire that no\n // reader honours — and before AGL-1864 fixed the reader, that exact link\n // flipped an annual org to monthly on arrival. Drop it at the source, which\n // is the last place it can be dropped before it is published.\n const stated = interval != null && contactSales === false\n return `${signupUrl}?${onboardingPlanQuery({\n plan,\n interval: stated ? interval : 'month',\n intervalStated: stated,\n contactSales,\n // The add-on CTA (AGL-2897). Dropped for a custom-priced plan for the\n // same reason the interval is: the parser refuses it there, so writing\n // it would publish a claim no reader honors.\n ...((options.ai || options.aiTier) && !contactSales ? { ai: true } : {}),\n ...(options.aiTier && !contactSales ? { aiTier: options.aiTier } : {}),\n })}`\n}\n\n/**\n * Where a freshly provisioned workspace should land, given the plan the\n * visitor picked on the marketing site.\n *\n * Deliberately returns a path rather than pushing: signup owns the\n * navigation, and a pure function is the half worth testing.\n */\nexport function onboardingDestination(\n orgSlug: string,\n intent: OnboardingPlanIntent | null,\n): string {\n if (!orgSlug) return '/'\n if (!intent) return `/${orgSlug}`\n // Enterprise is a conversation, not a checkout (AGL-1110).\n if (intent.contactSales) return `/${orgSlug}/support?topic=enterprise`\n return `/${orgSlug}/billing?${onboardingPlanQuery(intent)}`\n}\n"],"names":["bundleAddonsParam","hasBundleAddons","normalizeBundleCoupon","parseBundleAddons","isAiTierId","isCustomPricedPlan","SELF_SERVE_PLANS","parseOnboardingPlanIntent","params","parsedAddons","read","key","Array","raw","URLSearchParams","get","String","isArray","trim","toLowerCase","plan","interval","intervalStated","contactSales","includes","known","ai","rawParam","addons","coupon","aiTier","aiStated","aiAddon","dropped","length","droppedAddons","intentAddons","intent","onboardingPlanQuery","others","Object","keys","some","kind","encodeURIComponent","onboardingSignupHref","signupUrl","options","stated","onboardingDestination","orgSlug"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,iBAAiB,EACjBC,eAAe,EACfC,qBAAqB,EACrBC,iBAAiB,QAEZ,qBAAiB;AACxB,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,yBAAqB;AAmFpE,MAAMC,mBAAuC;IAC3C;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;;CAOC,GACD,OAAO,SAASC,0BACdC,MAIa;QAyCyBC;IAvCtC,IAAI,CAACD,QAAQ,OAAO;IACpB,MAAME,OAAO,CAACC;YAMGC;QALf,MAAMC,MACJL,kBAAkBM,kBAAkBN,OAAOO,GAAG,CAACJ,OAAOH,MAAM,CAACG,IAAI;QACnE,yEAAyE;QACzE,wEAAwE;QACxE,8DAA8D;QAC9D,OAAOK,QAAQJ,OAAAA,MAAMK,OAAO,CAACJ,OAAOA,GAAG,CAAC,EAAE,GAAGA,eAA9BD,OAAsC,IAClDM,IAAI,GACJC,WAAW;IAChB;IACA,MAAMC,OAAOV,KAAK;IAClB,IAAI,CAACU,MAAM,OAAO;IAClB,IAAIf,mBAAmBe,OAAkB;QACvC,OAAO;YACLA,MAAMA;YACNC,UAAU;YACVC,gBAAgB;YAChBC,cAAc;QAChB;IACF;IACA,IAAI,CAACjB,iBAAiBkB,QAAQ,CAACJ,OAAkB,OAAO;IACxD,MAAMC,WAAWX,KAAK;IACtB,MAAMe,QAAQJ,aAAa,UAAUA,aAAa,YAAYA,aAAa;IAC3E,2EAA2E;IAC3E,2EAA2E;IAC3E,4EAA4E;IAC5E,MAAMK,KAAKhB,KAAK;IAChB,0EAA0E;IAC1E,gDAAgD;IAChD,MAAMiB,WAAW,CAAChB;YAEDC;QADf,MAAMC,MAAML,kBAAkBM,kBAAkBN,OAAOO,GAAG,CAACJ,OAAOH,MAAM,CAACG,IAAI;QAC7E,OAAOK,QAAQJ,OAAAA,MAAMK,OAAO,CAACJ,OAAOA,GAAG,CAAC,EAAE,GAAGA,eAA9BD,OAAsC,IAAIM,IAAI;IAC/D;IACA,MAAMT,eAAeN,kBAAkBwB,SAAS;IAChD,MAAMC,SAAuB,aAAKnB,aAAamB,MAAM;IACrD,MAAMC,SAAS3B,sBAAsByB,SAAS;IAC9C,0EAA0E;IAC1E,6BAA6B;IAC7B,MAAMG,SAAS1B,WAAWsB,MAAMA,MAAMjB,uBAAAA,aAAaqB,MAAM,YAAnBrB,uBAAuB;IAC7D,MAAMsB,WAAWL,OAAO,OAAOA,OAAO,UAAUA,OAAO,SAASI,WAAW;IAC3E,OAAO;QACLV,MAAMA;QACN,wEAAwE;QACxE,wEAAwE;QACxE,eAAe;QACfC,UAAUA,aAAa,UAAUA,aAAa,WAAW,SAAS;QAClE,yEAAyE;QACzE,wEAAwE;QACxE,0DAA0D;QAC1DC,gBAAgBG;QAChBF,cAAc;OACVQ,YAAYH,OAAOI,OAAO,GAAG;QAAEN,IAAI;IAAK,IAAI,CAAC,GAC7CI,SAAS;QAAEA;IAAO,IAAI,CAAC,GACvB7B,gBAAgB2B,UAAU;QAAEA;IAAO,IAAI,CAAC,GACxCC,SAAS;QAAEA;IAAO,IAAI,CAAC,GACvBpB,aAAawB,OAAO,CAACC,MAAM,GAAG;QAAEC,eAAe1B,aAAawB,OAAO;IAAC,IAAI,CAAC;AAEjF;AAEA,mFAAmF,GACnF,OAAO,SAASG,aAAaC,MAAsE;;IACjG,OAAO,qBAAMA,0BAAAA,OAAQT,MAAM,mBAAI,CAAC,GAAQS,CAAAA,0BAAAA,OAAQX,EAAE,IAAG;QAAEM,SAAS;IAAE,IAAI,CAAC;AACzE;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASM,oBAAoBD,MAA4B;QAI3BA,gBAcpBA;IAjBf,qEAAqE;IACrE,wEAAwE;IACxE,+EAA+E;IAC/E,MAAMT,SAAuB,cAAMS,iBAAAA,OAAOT,MAAM,YAAbS,iBAAiB,CAAC;IACrD,IAAIA,OAAOX,EAAE,EAAEE,OAAOI,OAAO,GAAG;IAChC,MAAMO,SAASC,OAAOC,IAAI,CAACb,QAAQc,IAAI,CACrC,CAACC;YAAgCf;eAAvBe,SAAS,aAAa,EAACf,eAAAA,MAAM,CAACe,KAA2B,YAAlCf,eAAsC,KAAK;;IAE9E,MAAMC,SAAS3B,sBAAsBmC,OAAOR,MAAM;IAClD,OACE,CAAC,KAAK,EAAEe,mBAAmBP,OAAOjB,IAAI,GAAG,GACxCiB,CAAAA,OAAOf,cAAc,GAAG,CAAC,UAAU,EAAEe,OAAOhB,QAAQ,EAAE,GAAG,EAAC,IAC1DkB,CAAAA,SAEG,8DAA8D;IAC9D,CAAC,QAAQ,EAAEvC,kBAAkB4B,QAAQS,OAAOP,MAAM,GAAG,GACrDF,OAAOI,OAAO,GACZ,CAAC,IAAI,GAAEK,iBAAAA,OAAOP,MAAM,YAAbO,iBAAiB,KAAK,GAC7B,EAAC,IACNR,CAAAA,SAAS,CAAC,QAAQ,EAAEe,mBAAmBf,SAAS,GAAG,EAAC;AAEzD;AAEA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASgB,qBACdC,SAAiB,EACjB1B,IAAa,EACbC,QAAmC,EACnC0B,UAA+C,CAAC,CAAC;IAEjD,MAAMxB,eAAelB,mBAAmBe;IACxC,6EAA6E;IAC7E,8EAA8E;IAC9E,2EAA2E;IAC3E,yEAAyE;IACzE,4EAA4E;IAC5E,8DAA8D;IAC9D,MAAM4B,SAAS3B,YAAY,QAAQE,iBAAiB;IACpD,OAAO,GAAGuB,UAAU,CAAC,EAAER,oBAAoB;QACzClB;QACAC,UAAU2B,SAAS3B,WAAW;QAC9BC,gBAAgB0B;QAChBzB;OAII,AAACwB,CAAAA,QAAQrB,EAAE,IAAIqB,QAAQjB,MAAM,AAAD,KAAM,CAACP,eAAe;QAAEG,IAAI;IAAK,IAAI,CAAC,GAClEqB,QAAQjB,MAAM,IAAI,CAACP,eAAe;QAAEO,QAAQiB,QAAQjB,MAAM;IAAC,IAAI,CAAC,KAClE;AACN;AAEA;;;;;;CAMC,GACD,OAAO,SAASmB,sBACdC,OAAe,EACfb,MAAmC;IAEnC,IAAI,CAACa,SAAS,OAAO;IACrB,IAAI,CAACb,QAAQ,OAAO,CAAC,CAAC,EAAEa,SAAS;IACjC,2DAA2D;IAC3D,IAAIb,OAAOd,YAAY,EAAE,OAAO,CAAC,CAAC,EAAE2B,QAAQ,yBAAyB,CAAC;IACtE,OAAO,CAAC,CAAC,EAAEA,QAAQ,SAAS,EAAEZ,oBAAoBD,SAAS;AAC7D"}
|
|
@@ -172,6 +172,27 @@ const DAY = 24 * 60;
|
|
|
172
172
|
dedupeWindowMinutes: 7 * DAY,
|
|
173
173
|
defaultEnabled: true
|
|
174
174
|
},
|
|
175
|
+
{
|
|
176
|
+
// The scheduled reconciliation of Site Care extra time (AGL-3959): a
|
|
177
|
+
// request's billed hours and the Stripe invoice item that carries them
|
|
178
|
+
// disagree, or one exists without the other. Should know, not must:
|
|
179
|
+
// nothing is lost yet, the next invoice has not gone, and the fix is on
|
|
180
|
+
// the request. The same check compares a flat-quoted project's
|
|
181
|
+
// invoices (AGL-3970), whose findings arrive with `month` "projects".
|
|
182
|
+
type: 'billing.siteCareReconciliation',
|
|
183
|
+
label: 'Site Care billing does not match Stripe',
|
|
184
|
+
description: 'A Site Care request’s billed hours, amount or line description disagree with its Stripe invoice item, a Stripe item has no request row behind it, a month’s total disagrees with its statement, or a project invoice’s status or amount disagrees with Stripe (or exists in Stripe with no project row). Open the workspace’s staff page and correct it from the request or the project — never by hand in Stripe.',
|
|
185
|
+
tier: 'should',
|
|
186
|
+
category: 'billing',
|
|
187
|
+
title: 'Site Care billing mismatch on {{orgName}} ({{month}})',
|
|
188
|
+
body: '{{count}} Site Care finding(s) on workspace {{orgName}} ({{orgId}}) for {{month}}: {{findings}} Fix it from the request on the staff organization page.',
|
|
189
|
+
link: '/admin/orgs/{{orgId}}#site-care',
|
|
190
|
+
delivery: 'immediate',
|
|
191
|
+
// One alert a day per workspace and month: the same finding re-checked
|
|
192
|
+
// tomorrow is the same news.
|
|
193
|
+
dedupeWindowMinutes: DAY,
|
|
194
|
+
defaultEnabled: true
|
|
195
|
+
},
|
|
175
196
|
{
|
|
176
197
|
type: 'billing.webhookSignatureRejected',
|
|
177
198
|
label: 'Billing webhook failing its signature check',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/operator-alerts.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 type { AglynNotificationType, NotificationLevel } from './notifications'\n\n/**\n * OPERATOR ALERTS (AGL-3377): the events whoever runs an install must hear\n * about, as one typed catalog.\n *\n * Every alert is an entry here (or a plugin's entry in the same shape,\n * registered through `@aglyn/aglyn/plugin-manager/operator-alerts`) and is\n * raised through ONE server entry point, `raiseOperatorAlert` in\n * `@aglyn/tenant-data-admin/server/operator-alerts`. That entry point writes\n * the staff console notification, dedupes a flapping condition, honours the\n * per-type switches staff set on Staff → Operator alerts, and delivers by\n * email (the `operator-alert` system email) and the optional out-of-band\n * webhook. No call site composes or sends its own mail.\n *\n * The catalog holds nothing install-specific: no address, no domain, no\n * host. Recipients come from `resolveStaffAlertRecipients()` and the webhook\n * from `OPERATOR_ALERT_WEBHOOK_URL`, so an entry reads the same on aglyn.com,\n * on a self-hosted install and in an OSS consumer's deployment.\n *\n * Copy is written against merge tokens (`{{orgId}}`), filled from the\n * `context` the call site passes. A token the call site did not supply is\n * blanked, so every sentence must still read when its optional tokens are\n * empty. Never put a data subject's address or other personal data into a\n * context: the alert travels to an inbox and a webhook, not only the console.\n */\n\n/**\n * How much an alert matters.\n *\n * - `must` — money moving with nobody looking, a legal duty unmet, data not\n * protected or not erased. On and immediate unless staff change it.\n * - `should` — a fault an operator wants to know about today.\n * - `low` — routine review work; on, and batched into the daily digest.\n */\nexport type OperatorAlertTier = 'must' | 'should' | 'low'\n\nexport type OperatorAlertCategory =\n | 'billing'\n | 'payments'\n | 'legal'\n | 'data'\n | 'ops'\n | 'deliverability'\n | 'security'\n | 'support'\n\n/** `digest` batches the alert into the once-a-day operator digest. */\nexport type OperatorAlertDelivery = 'immediate' | 'digest'\n\nexport interface OperatorAlertDefinition {\n /**\n * Stable id, also the key of its settings row. Never rename: staff\n * switches are stored under it. A plugin's types start with its plugin id\n * and a dot (`commerce.taxNotReversed`).\n */\n type: string\n /** The settings row's name. */\n label: string\n /** What it means and the first thing to do, for the settings page. */\n description: string\n tier: OperatorAlertTier\n category: OperatorAlertCategory\n /** The notification title and email subject, with `{{tokens}}`. */\n title: string\n /** What happened and what to do, with `{{tokens}}`. */\n body: string\n /** Console path the alert opens, with `{{tokens}}`; the call may override. */\n link?: string\n /** The coded default; staff may change it. */\n delivery: OperatorAlertDelivery\n /**\n * How long one `dedupeKey` stays quiet after it fired, in minutes. A\n * condition that flaps inside the window is told once. `0` never dedupes.\n * A call without a `dedupeKey` is never deduped.\n */\n dedupeWindowMinutes: number\n /**\n * Fire only once the same `dedupeKey` has been raised this many times\n * inside the window — for an endpoint any stranger can hit, where one\n * refused request is noise and several are a broken secret. Default 1.\n */\n minOccurrences?: number\n /** The coded default; staff may change it. */\n defaultEnabled: boolean\n /**\n * The console notification's type. Absent is the generic\n * `system.operatorAlert`; a type that already had its own notification\n * keeps it, so its icon, label and everyone's mutes are unchanged.\n */\n notificationType?: AglynNotificationType\n /**\n * How loud its console notification is drawn (AGL-3437). Absent, the\n * tier answers — see {@link operatorAlertLevel}. Set where the tone and\n * the importance part ways: a recovery is worth hearing about and is good\n * news, and a degraded check is a must-know that is not yet an outage.\n */\n level?: NotificationLevel\n /** The plugin that contributed it; absent for core's own. */\n pluginId?: string\n}\n\n/** Values a call site passes for an alert's `{{tokens}}`. */\nexport type OperatorAlertContext = Readonly<\n Record<string, string | number | boolean | null | undefined>\n>\n\n/** The notification type an alert without its own writes under. */\nexport const OPERATOR_ALERT_DEFAULT_NOTIFICATION_TYPE: AglynNotificationType =\n 'system.operatorAlert'\n\nexport const OPERATOR_ALERT_TIER_LABELS: Record<OperatorAlertTier, string> = {\n must: 'Must know',\n should: 'Should know',\n low: 'Routine',\n}\n\n/**\n * The level an alert's notification is drawn at when its entry names none:\n * a must-know is red, a should-know amber, routine review work informational.\n */\nexport const OPERATOR_ALERT_TIER_LEVELS: Record<\n OperatorAlertTier,\n NotificationLevel\n> = {\n must: 'critical',\n should: 'warning',\n low: 'info',\n}\n\n/** The level an alert's console notification carries (AGL-3437). */\nexport function operatorAlertLevel(\n definition: Pick<OperatorAlertDefinition, 'tier' | 'level'>,\n): NotificationLevel {\n return definition.level ?? OPERATOR_ALERT_TIER_LEVELS[definition.tier]\n}\n\nexport const OPERATOR_ALERT_CATEGORY_LABELS: Record<\n OperatorAlertCategory,\n string\n> = {\n billing: 'Billing',\n payments: 'Payments & payouts',\n legal: 'Legal',\n data: 'Data protection',\n ops: 'Operations',\n deliverability: 'Email deliverability',\n security: 'Security',\n support: 'Support',\n}\n\nconst DAY = 24 * 60\n\n/**\n * Core's alerts. Plugins contribute theirs through the plugin-manager\n * registry; nothing plugin-specific belongs in this list.\n */\nexport const CORE_OPERATOR_ALERTS: readonly OperatorAlertDefinition[] = [\n // ── Fraud, risk and legal duties already alerting before AGL-3377 ──────\n {\n type: 'system.abuseReportUrgent',\n label: 'Urgent abuse, fraud or risk alert',\n description:\n 'Phishing, malware or CSAM reported on a site, card testing, a flagged or disputed payment, a held phishing email, a seller under review. Review it on Staff → Abuse reports.',\n tier: 'must',\n category: 'security',\n title: '{{title}}',\n body: '{{body}}',\n link: '/admin/abuse-reports',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.abuseReportUrgent',\n },\n {\n // The one lock no person placed (AGL-3450): staff confirm it before the\n // customer's appeal arrives, and re-place it as `abuse` or lift it.\n type: 'security.pageSecurityHold',\n label: 'Automatic security hold on a new workspace',\n description:\n 'The page screen held a phishing page from a workspace in its first two weeks and locked the workspace, the site and the publishing account as security. Confirm it on Staff → Abuse reports, then re-place it as abuse on Staff → Lockdown, or lift it there if it is a false positive.',\n tier: 'must',\n category: 'security',\n title: 'Security hold placed on {{orgName}}',\n body:\n '{{page}} on {{siteName}} ({{hostId}}) was held for review: {{signal}} Locked as security, pending your review: {{locks}}. The abuse row is {{reference}}. Lift the hold, or re-place it as abuse, on Staff → Lockdown (/admin/lockdown).',\n link: '/admin/abuse-reports?report={{reviewId}}',\n delivery: 'immediate',\n // One hold per workspace; a repeat inside the day is the same event.\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n notificationType: 'system.abuseReportUrgent',\n },\n {\n type: 'security.paymentFraudHold',\n label: 'Automatic security hold for payment fraud',\n description:\n 'Stripe flagged a workspace\\'s own subscription payment as fraud — a Radar block at highest risk, a Stripe fraud report, three or more cards failing within 30 minutes, an early fraud warning or a Radar review. A new workspace that never paid is locked as security (takedown) with its subscriptions canceled; an older or paying one is not locked and needs a decision. Confirm it on Staff → Abuse reports, then re-place it as abuse on Staff → Lockdown, or lift it there.',\n tier: 'must',\n category: 'security',\n title: '{{action}}: {{orgName}}',\n body:\n '{{trigger}} on {{orgName}} ({{orgId}}). Charges: {{charges}}; cards: {{cards}}, issued in {{cardCountries}}. Locked: {{locks}}. The abuse row is {{reference}}. Lift it, or re-place it as abuse, on Staff → Lockdown (/admin/lockdown).',\n link: '/admin/abuse-reports?report={{reviewId}}',\n delivery: 'immediate',\n // One per workspace per window: every further card in the burst is the\n // same event, and the abuse row carries all of them.\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n notificationType: 'system.abuseReportUrgent',\n },\n {\n type: 'system.disputeUnattributed',\n label: 'Card dispute with no owner',\n description:\n 'A chargeback arrived that no subscription, order or marketplace purchase claimed, so nothing is answering it. Find the charge in Stripe and respond before the evidence deadline.',\n tier: 'must',\n category: 'billing',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.disputeUnattributed',\n },\n {\n type: 'system.dmcaCounterNotice',\n label: 'DMCA counter-notice',\n description:\n 'A customer contested a takedown. The statutory clock is already running; forward it to the complainant and restore on time unless they file suit.',\n tier: 'must',\n category: 'legal',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.dmcaCounterNotice',\n },\n {\n type: 'system.billingWebhookHalfApplied',\n label: 'Billing webhook half applied',\n description:\n 'A Stripe event threw after its handlers began, so its effects may be partly applied and Stripe will not retry it. Reconcile the event by hand.',\n tier: 'must',\n category: 'billing',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.billingWebhookHalfApplied',\n },\n\n // ── MUST: billing ───────────────────────────────────────────────────────\n {\n type: 'billing.platformDisputeLost',\n label: 'Subscription dispute lost',\n description:\n 'A card dispute on a workspace subscription closed as lost: the money has been taken back. Decide whether the workspace keeps its plan.',\n tier: 'must',\n category: 'billing',\n title: 'Subscription dispute lost on workspace {{orgId}}',\n body:\n 'The card dispute {{disputeId}} on invoice {{invoiceId}} for workspace {{orgName}} ({{orgId}}) closed as lost ({{reason}}), and {{amount}} was taken back. The workspace keeps its plan until somebody decides otherwise.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 30 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.orphanedSubscription',\n label: 'Stripe is billing a workspace that does not exist',\n description:\n 'A subscription names a workspace that was deleted or erased, so the customer keeps being charged for nothing. Cancel or refund it in Stripe.',\n tier: 'must',\n category: 'billing',\n title: 'Subscription bills a missing workspace',\n body:\n 'Stripe subscription {{subscriptionId}} (customer {{customerId}}, plan {{plan}}) names workspace {{orgId}}, which {{reason}}. The {{eventType}} event changed nothing. Cancel or refund it in Stripe.',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.usageNotReported',\n label: 'Metered usage not reported to Stripe',\n description:\n 'A closed month measured billable usage and it reached no invoice. Report it to Stripe by hand or the revenue is lost.',\n tier: 'must',\n category: 'billing',\n title: 'Usage for {{month}} not billed on {{orgId}}',\n body:\n 'The closed month {{month}} measured {{amount}} of billable usage on workspace {{orgName}} ({{orgId}}), and it was not reported to Stripe ({{reason}}). Nothing will invoice it until somebody does.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 7 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.webhookSignatureRejected',\n label: 'Billing webhook failing its signature check',\n description:\n 'Repeated deliveries to the billing webhook were refused because their signature did not match. Usually a rolled signing secret: until it is fixed, Stripe cannot tell the install about money.',\n tier: 'must',\n category: 'billing',\n title: 'Billing webhook is refusing deliveries',\n body:\n 'The billing webhook refused several signed deliveries within six hours because their Stripe signature matched none of the configured secrets. If Stripe is the sender, its signing secret no longer matches this install’s, and no billing event is being applied.',\n link: '/admin/health',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n minOccurrences: 3,\n defaultEnabled: true,\n },\n {\n type: 'billing.webhookInert',\n label: 'Billing webhook delivery moved nothing',\n description:\n 'Stripe delivered an event this install subscribed to, and no handler did anything with it. Usually a handler that stopped being registered.',\n tier: 'must',\n category: 'billing',\n title: 'A {{eventType}} delivery changed nothing',\n body:\n 'Stripe event {{eventId}} ({{eventType}}) was accepted and no handler acted on it. Check which handler stopped being registered, then replay the event.',\n link: '/admin/health',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n\n // ── MUST: data protection and records ───────────────────────────────────\n {\n type: 'data.personErasureFailed',\n label: 'Personal data erasure failed',\n description:\n 'A data subject’s erasure request failed. It will be retried, but the legal deadline keeps running: read the error and fix the cause.',\n tier: 'must',\n category: 'data',\n title: 'Erasure request {{requestId}} failed',\n body:\n 'The erasure request {{requestId}} on workspace {{orgName}} ({{orgId}}) failed (attempt {{attempt}}): {{error}}. The statutory deadline keeps running while it retries.',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'data.orgErasureFailed',\n label: 'Workspace erasure failed',\n description:\n 'A workspace scheduled for erasure could not be erased. Its data is still held after the date it was promised gone.',\n tier: 'must',\n category: 'data',\n title: 'Workspace {{orgId}} could not be erased',\n body:\n 'The scheduled erasure of workspace {{orgName}} ({{orgId}}) did not complete: {{reason}}. It will be retried on the next run; its data is held until it succeeds.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'data.backupExportFailed',\n label: 'Database export failed',\n description:\n 'The scheduled database export did not start. A stale export means the worst day has nothing to restore from.',\n tier: 'must',\n category: 'data',\n title: 'Database export failed',\n body:\n 'The scheduled database export did not start ({{reason}}). The last good export is getting older; check the service account’s export permission and the bucket.',\n link: '/admin/health',\n delivery: 'immediate',\n dedupeWindowMinutes: 12 * 60,\n defaultEnabled: true,\n },\n\n // ── MUST: legal ─────────────────────────────────────────────────────────\n {\n type: 'legal.abuseReportHigh',\n label: 'Takedown, impersonation or illegal-content report',\n description:\n 'A DMCA takedown, impersonation or illegal-content report. Each carries a response duty; review it on Staff → Abuse reports.',\n tier: 'must',\n category: 'legal',\n title: '{{category}} report on {{site}}',\n body:\n '{{site}} was reported for {{category}}. Reference {{reference}}. Review it and respond within the policy’s window.',\n link: '/admin/abuse-reports',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n },\n\n // ── MUST/SHOULD: health ─────────────────────────────────────────────────\n {\n type: 'system.healthDegraded',\n label: 'Health check degraded',\n description:\n 'A health check went from healthy to degraded: scheduled jobs silent, backups stale, billing deliveries failing, sign-ups refused, server errors, a site not rendering. Told once per incident.',\n tier: 'must',\n category: 'ops',\n title: '{{check}} is degraded',\n body: '{{check}} went from healthy to degraded. {{detail}}',\n link: '/admin/health',\n delivery: 'immediate',\n // Must-know, and still amber rather than red: degraded is not down.\n level: 'warning',\n // A check flapping across the line is told once an hour, not on\n // every swing.\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n },\n {\n // The reminder the edge alert never sends (AGL-3860): raised by the\n // operator alerts tick at 1 h and every 2 h after while a check stays\n // degraded. The tick raises it as Must know from 2 h, so its level\n // follows the tier it was raised at rather than one coded here.\n type: 'system.healthStillDegraded',\n label: 'Health check still degraded',\n description:\n 'A health check has stayed degraded for an hour or more. Told at 1 h and again every 2 h until it recovers; Should know for the first reminder, Must know from 2 h on. Open the failing endpoint, read the failing check’s code and fix the cause, or the check when the check is what is wrong.',\n tier: 'should',\n category: 'ops',\n title: '{{check}} is still degraded after {{duration}}',\n body: '{{check}} is still degraded after {{duration}}. {{detail}}',\n link: '/admin/health',\n delivery: 'immediate',\n // The tick dedupes each reminder per check per step on the check's own\n // state; the window only stops a retried tick from telling one twice.\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n },\n {\n // The post-deploy production canary (AGL-3567), raised from GitHub\n // Actions through `/api/admin/operator-alerts/canary`. Red because a\n // deploy that stops rendering pages is every published site down.\n type: 'ops.productionCanaryRed',\n label: 'Production canary failed after a deploy',\n description:\n 'Right after a tenant or console production deploy, uncached pages stopped rendering. The canary rolls the deploy back by itself when the failure holds across sites; after any rollback the next release must be promoted by hand.',\n tier: 'must',\n category: 'ops',\n title: '{{project}} production canary: {{outcome}}',\n body: '{{detail}}',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'critical',\n // The caller dedupes per deployment and verdict; this only stops a\n // re-run of the same red run from telling it twice.\n dedupeWindowMinutes: 30,\n defaultEnabled: true,\n },\n {\n type: 'system.healthRecovered',\n label: 'Health check recovered',\n description: 'A degraded health check is healthy again.',\n tier: 'should',\n category: 'ops',\n title: '{{check}} recovered',\n body: '{{check}} is healthy again after {{duration}}.',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'success',\n // A check flapping across the line is told once an hour, not on\n // every swing.\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n },\n {\n // The render monitor (AGL-3568): a published site fetched over HTTP, on\n // pages no cache can answer, failed several runs in a row. Red, not the\n // amber of a degraded check: every visitor without a cached copy is\n // getting an error page or a timeout right now.\n type: 'system.siteRenderFailing',\n label: 'Published site not rendering pages',\n description:\n 'The render monitor asked a published site for pages no cache can answer, several runs in a row, and got no complete page back. Visitors to cached pages may still see them, so the site can look up while every other page fails. Check the latest site runtime deployment first and roll it back if it just shipped.',\n tier: 'must',\n category: 'ops',\n title: 'Pages are not rendering on {{site}}',\n body:\n '{{site}} failed {{failures}} render checks in a row, over {{since}}. {{detail}} Cached pages may still load, so the site can look up while new renders fail.',\n link: '/admin/health',\n delivery: 'immediate',\n // Told once per outage: the monitor raises it on the edge, and the\n // window only covers a site flapping across the line.\n dedupeWindowMinutes: 30,\n defaultEnabled: true,\n },\n {\n type: 'system.siteRenderRecovered',\n label: 'Published site rendering again',\n description:\n 'A published site the render monitor had reported as not rendering serves fresh pages again.',\n tier: 'should',\n category: 'ops',\n title: '{{site}} is rendering pages again',\n body: 'Fresh page renders on {{site}} pass again after {{duration}}.',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'success',\n dedupeWindowMinutes: 30,\n defaultEnabled: true,\n },\n {\n // The render monitor could not see the site (AGL-3580): bot protection\n // answered every probe it made, so it knows nothing about whether pages\n // render. Not an outage, and never worded as one — on 2026-10-05 a\n // missing probe token read as \"pages are not rendering\" for three hours\n // while the site served pages. Amber: detection is off until it is fixed.\n type: 'system.renderMonitorBlind',\n label: 'Render monitor cannot see a site',\n description:\n 'Bot protection answered the render monitor instead of a published site, several runs in a row, so nothing is checking whether that site renders pages. The site itself may be fine. Check AGLYN_PROBE_TOKEN on the console and the \"CI and uptime probe bypass\" firewall rule on the site runtime.',\n tier: 'must',\n category: 'ops',\n title: 'The render monitor cannot see {{site}}',\n body:\n 'Bot protection answered instead of {{site}} for {{runs}} runs in a row, so nothing is checking its pages. {{detail}} This is not a verdict on the site.',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'warning',\n dedupeWindowMinutes: 360,\n defaultEnabled: true,\n },\n\n // ── SHOULD: billing ─────────────────────────────────────────────────────\n {\n type: 'billing.autoLocked',\n label: 'Workspace billing locked automatically',\n description:\n 'A workspace crossed its spend guard and the platform locked its billable activity. Check it is not a false positive before the customer notices.',\n tier: 'should',\n category: 'billing',\n title: 'Billing locked on {{orgName}}',\n body:\n 'Workspace {{orgName}} ({{orgId}}) was locked automatically: {{reason}}.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.platformInvoiceUncollectible',\n label: 'Subscription invoice voided or uncollectible',\n description:\n 'A workspace invoice was voided or marked uncollectible: revenue the books expected is not coming.',\n tier: 'should',\n category: 'billing',\n title: 'Invoice {{status}} on {{orgId}}',\n body:\n 'Invoice {{invoiceId}} for {{amount}} on workspace {{orgName}} ({{orgId}}) was marked {{status}}, so Stripe has stopped collecting it.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 30 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.connectPayoutFailed',\n label: 'Connected account payout or transfer failed',\n description:\n 'Money due to a merchant or seller did not arrive. Stripe retries on its own schedule; a human decides what happens next.',\n tier: 'should',\n category: 'billing',\n title: 'A {{kind}} to {{account}} failed',\n body:\n 'A {{amount}} Stripe {{kind}} ({{stripeId}}) to connected account {{account}} ({{merchant}}) failed: {{reason}}. The merchant’s funds are not where the ledger says.',\n delivery: 'immediate',\n dedupeWindowMinutes: 30 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'staff.paymentFailed',\n label: 'Workspace payment failed',\n description:\n 'A paying workspace’s renewal failed. Stripe is retrying; the customer has been told.',\n tier: 'should',\n category: 'billing',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'staff.paymentFailed',\n },\n\n // ── SHOULD: security ────────────────────────────────────────────────────\n {\n type: 'security.staffGranted',\n label: 'Staff access granted or raised',\n description:\n 'Somebody was made staff, or a staff role was raised. If nobody on the team did it, revoke it and rotate credentials.',\n tier: 'should',\n category: 'security',\n title: '{{target}} is now {{role}} staff',\n body: '{{actor}} granted {{target}} the {{role}} staff role (was {{previous}}).',\n link: '/admin/users',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n },\n\n // ── SHOULD: support ─────────────────────────────────────────────────────\n {\n type: 'support.slaBreached',\n label: 'Support ticket past its response time',\n description:\n 'A support ticket passed its promised response time without a staff reply.',\n tier: 'should',\n category: 'support',\n title: 'Ticket past its response time: {{subject}}',\n body:\n 'The {{tier}} ticket “{{subject}}” from workspace {{orgName}} ({{orgId}}) was due a first response {{overdue}} ago and has none.',\n // The ticket itself: the support page opens `?ticketId=` on load.\n link: '/admin/support?ticketId={{ticketId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'support.ticketOpened',\n label: 'New support ticket',\n description: 'A subscriber opened a support ticket.',\n tier: 'should',\n category: 'support',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'support.ticketOpened',\n // A customer asking for help, not a fault.\n level: 'info',\n },\n {\n type: 'support.ticketReply',\n label: 'Support ticket reply',\n description: 'A subscriber replied on a support ticket.',\n tier: 'should',\n category: 'support',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'support.ticketReply',\n level: 'info',\n },\n\n // ── SHOULD: deliverability ──────────────────────────────────────────────\n {\n type: 'deliverability.sendRateSaturated',\n label: 'Email send-rate governor saturated',\n description:\n 'The platform’s email send-rate budget is exhausted, so sends are being deferred. Raise the budget or find the sender filling it.',\n tier: 'should',\n category: 'deliverability',\n title: 'Email sending is being throttled',\n body:\n 'The {{scope}} send-rate budget is full ({{detail}}), so sends are being deferred.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n type: 'deliverability.sendRateUnavailable',\n label: 'Email send-rate governor unavailable',\n description:\n 'The send-rate governor could not read its counters, so mail is going out unmetered: nothing is holding the shared domains under their hourly ceiling.',\n tier: 'should',\n category: 'deliverability',\n title: 'Email send-rate governor unavailable',\n body:\n 'The send-rate governor could not read its counters ({{error}}), so sends are being allowed unmetered until it can.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n type: 'deliverability.gatewayBlocking',\n label: 'A recipient gateway is blocking the shared domain',\n description:\n 'A mail gateway is refusing mail from the shared sending domain, so everyone behind that gateway stops receiving it.',\n tier: 'should',\n category: 'deliverability',\n title: '{{gateway}} is blocking {{domain}}',\n body:\n 'Mail from {{domain}} is being refused by {{gateway}} ({{detail}}). Recipients behind that gateway are not receiving it.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'deliverability.providerCredentialsRejected',\n label: 'Email provider rejected the credentials',\n description:\n 'The email provider refused the API key, or a sending pool is unhealthy: invites, password resets and receipts are not leaving. The webhook channel is the one that still reaches you.',\n tier: 'should',\n category: 'deliverability',\n title: 'Email delivery is failing: {{problem}}',\n body: '{{detail}}',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n // A purchasing ceiling, not a job failure: the provisioning sweep ran\n // and every site keeps sending, so the copy must not read as an outage.\n type: 'deliverability.sendingDomainCapacityFull',\n label: 'Sending-domain allowance full',\n description:\n 'Every dedicated sending domain the provider allowance covers is in use, so new sites that ask for one stay on the shared pool. No mail is lost; raise the allowance or move merchants onto domains they own.',\n tier: 'should',\n category: 'deliverability',\n title: 'Sending-domain allowance full ({{held}}/{{capacity}})',\n body:\n 'The sending-domain allowance is full ({{held}} of {{capacity}} in use), so sites that asked for a dedicated domain keep sending on the shared pool. No mail is lost: what they go without is the isolation a domain of their own buys, and their campaigns are held to the pool’s stricter reputation limits. Raise AGLYN_SENDING_DOMAIN_CAPACITY once the provider allowance covers it, or move merchants onto domains they own.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n\n // ── SHOULD: operations ──────────────────────────────────────────────────\n {\n type: 'ops.reaperStuck',\n label: 'A reaper is stuck or failing',\n description:\n 'A cleanup job (sending domains, unverified workspaces) could not finish, so what it removes keeps accumulating.',\n tier: 'should',\n category: 'ops',\n title: '{{job}} is stuck',\n body: '{{job}} could not finish: {{detail}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'ops.pluginJobFailed',\n label: 'A plugin job failed',\n description:\n 'A plugin’s scheduled job threw: consent-group changes, the publish outbox, sending-domain provisioning, a plugin cron.',\n tier: 'should',\n category: 'ops',\n // `job` is a noun phrase that reads as a subject on its own (\"The\n // publish outbox drain\", \"The scheduled job acme-mail-send\"), so the\n // title and the body open with the same words.\n title: '{{job}} failed',\n body: '{{job}} failed: {{error}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n // Nightly, so once a day per provider is every run it could report.\n type: 'ops.adAudienceSyncFailed',\n label: 'Ad audience sync failed',\n description:\n 'The nightly account-holder audience sync (AGL-3780) could not update a Meta, Google or LinkedIn audience, or held a run whose audience would have shrunk by more than half. The audience keeps what it last had; check the provider credentials, or run the sync with force once the drop is confirmed.',\n tier: 'should',\n category: 'ops',\n title: 'Ad audience sync: {{provider}} not updated',\n body: 'The {{provider}} account-holder audience was not updated: {{detail}}. It keeps what it was last sent, and the next nightly run tries again.',\n link: '/admin/flags',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'system.pluginVerifierRegression',\n label: 'Plugin verifier regression',\n description:\n 'A live plugin version stopped passing the static verifier.',\n tier: 'should',\n category: 'security',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.pluginVerifierRegression',\n },\n {\n type: 'system.bandwidthCeilingTripped',\n label: 'Bandwidth ceiling reached',\n description:\n 'A site crossed the per-month bandwidth abuse ceiling.',\n tier: 'should',\n category: 'ops',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.bandwidthCeilingTripped',\n },\n\n // ── LOW ─────────────────────────────────────────────────────────────────\n {\n type: 'marketplace.review',\n label: 'Plugin listing waiting for review',\n description: 'A plugin listing or version was submitted for review.',\n tier: 'low',\n category: 'security',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'marketplace.review',\n },\n {\n type: 'system.scopeDrift',\n label: 'Resources missing a sharing scope',\n description:\n 'The weekly sweep found documents invisible to every site-scoped read: a creation path forgot the field.',\n tier: 'low',\n category: 'data',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.scopeDrift',\n },\n]\n\n/** An amount in minor units, as an alert prints it: `$12.40`. */\nexport function formatOperatorAlertAmount(\n cents: number,\n currency = 'usd',\n): string {\n const value = Number(cents) / 100\n if (!Number.isFinite(value)) return ''\n try {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: String(currency || 'usd').toUpperCase(),\n }).format(value)\n } catch {\n return `${value.toFixed(2)} ${String(currency).toUpperCase()}`\n }\n}\n\n/** Replaces each `{{token}}` with its context value, or nothing. */\nexport function renderOperatorAlertTemplate(\n template: string,\n context: OperatorAlertContext | undefined,\n): string {\n return String(template ?? '')\n .replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (_match, name: string) => {\n const value = context?.[name]\n return value === null || value === undefined ? '' : String(value)\n })\n .replace(/\\(\\s*\\)/g, '')\n .replace(/[ \\t]{2,}/g, ' ')\n .replace(/ ([.,;:])/g, '$1')\n .trim()\n}\n\n/** A staff member's answer for one type; an absent key keeps the default. */\nexport interface OperatorAlertTypeSetting {\n enabled?: boolean\n delivery?: OperatorAlertDelivery\n}\n\n/** `platformSettings/operatorAlerts`, keyed by alert type. */\nexport interface OperatorAlertSettings {\n types?: Record<string, OperatorAlertTypeSetting>\n}\n\n/** Whether a type is on, and how it is delivered, after staff's answers. */\nexport function effectiveOperatorAlertSetting(\n definition: Pick<OperatorAlertDefinition, 'type' | 'delivery' | 'defaultEnabled'>,\n settings: OperatorAlertSettings | null | undefined,\n): { enabled: boolean; delivery: OperatorAlertDelivery } {\n const answer = settings?.types?.[definition.type]\n return {\n enabled:\n typeof answer?.enabled === 'boolean'\n ? answer.enabled\n : definition.defaultEnabled,\n delivery:\n answer?.delivery === 'immediate' || answer?.delivery === 'digest'\n ? answer.delivery\n : definition.delivery,\n }\n}\n\n/**\n * Staff notification types whose alert emails the operator on a coded\n * default of immediate (AGL-3375), derived from the catalog so there is one\n * list.\n */\nexport const OPERATOR_ALERT_NOTIFICATION_TYPES: ReadonlySet<string> = new Set(\n CORE_OPERATOR_ALERTS.flatMap((definition) =>\n definition.notificationType ? [definition.notificationType] : [],\n ),\n)\n"],"names":["OPERATOR_ALERT_DEFAULT_NOTIFICATION_TYPE","OPERATOR_ALERT_TIER_LABELS","must","should","low","OPERATOR_ALERT_TIER_LEVELS","operatorAlertLevel","definition","level","tier","OPERATOR_ALERT_CATEGORY_LABELS","billing","payments","legal","data","ops","deliverability","security","support","DAY","CORE_OPERATOR_ALERTS","type","label","description","category","title","body","link","delivery","dedupeWindowMinutes","defaultEnabled","notificationType","minOccurrences","formatOperatorAlertAmount","cents","currency","value","Number","isFinite","Intl","NumberFormat","style","String","toUpperCase","format","toFixed","renderOperatorAlertTemplate","template","context","replace","_match","name","undefined","trim","effectiveOperatorAlertSetting","settings","answer","types","enabled","OPERATOR_ALERT_NOTIFICATION_TYPES","Set","flatMap"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GA6GD,iEAAiE,GACjE,OAAO,MAAMA,2CACX,uBAAsB;AAExB,OAAO,MAAMC,6BAAgE;IAC3EC,MAAM;IACNC,QAAQ;IACRC,KAAK;AACP,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMC,6BAGT;IACFH,MAAM;IACNC,QAAQ;IACRC,KAAK;AACP,EAAC;AAED,kEAAkE,GAClE,OAAO,SAASE,mBACdC,UAA2D;QAEpDA;IAAP,QAAOA,oBAAAA,WAAWC,KAAK,YAAhBD,oBAAoBF,0BAA0B,CAACE,WAAWE,IAAI,CAAC;AACxE;AAEA,OAAO,MAAMC,iCAGT;IACFC,SAAS;IACTC,UAAU;IACVC,OAAO;IACPC,MAAM;IACNC,KAAK;IACLC,gBAAgB;IAChBC,UAAU;IACVC,SAAS;AACX,EAAC;AAED,MAAMC,MAAM,KAAK;AAEjB;;;CAGC,GACD,OAAO,MAAMC,uBAA2D;IACtE,0EAA0E;IAC1E;QACEC,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACE,wEAAwE;QACxE,oEAAoE;QACpEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,qEAAqE;QACrEC,qBAAqBV;QACrBW,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,uEAAuE;QACvE,qDAAqD;QACrDC,qBAAqBV;QACrBW,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IAEA,2EAA2E;IAC3E;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,KAAKV;QAC1BW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFE,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAIV;QACzBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBG,gBAAgB;QAChBF,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFE,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,KAAK;QAC1BC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACV,oEAAoE;QACpEpB,OAAO;QACP,gEAAgE;QAChE,eAAe;QACfqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,oEAAoE;QACpE,sEAAsE;QACtE,mEAAmE;QACnE,gEAAgE;QAChET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACV,uEAAuE;QACvE,sEAAsE;QACtEC,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,mEAAmE;QACnE,qEAAqE;QACrE,kEAAkE;QAClET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACP,mEAAmE;QACnE,oDAAoD;QACpDqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACP,gEAAgE;QAChE,eAAe;QACfqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,wEAAwE;QACxE,wEAAwE;QACxE,oEAAoE;QACpE,gDAAgD;QAChDT,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,mEAAmE;QACnE,sDAAsD;QACtDC,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACPqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,uEAAuE;QACvE,wEAAwE;QACxE,mEAAmE;QACnE,wEAAwE;QACxE,0EAA0E;QAC1ET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACPqB,qBAAqB;QACrBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,KAAKV;QAC1BW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFE,UAAU;QACVC,qBAAqB,KAAKV;QAC1BW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IAEA,2EAA2E;IAC3E;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACF,kEAAkE;QAClEC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;QAClB,2CAA2C;QAC3CvB,OAAO;IACT;IACA;QACEa,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;QAClBvB,OAAO;IACT;IAEA,2EAA2E;IAC3E;QACEa,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACE,sEAAsE;QACtE,wEAAwE;QACxET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACV,kEAAkE;QAClE,qEAAqE;QACrE,+CAA+C;QAC/CC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACE,oEAAoE;QACpET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IAEA,2EAA2E;IAC3E;QACEV,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;CACD,CAAA;AAED,+DAA+D,GAC/D,OAAO,SAASE,0BACdC,KAAa,EACbC,WAAW,KAAK;IAEhB,MAAMC,QAAQC,OAAOH,SAAS;IAC9B,IAAI,CAACG,OAAOC,QAAQ,CAACF,QAAQ,OAAO;IACpC,IAAI;QACF,OAAO,IAAIG,KAAKC,YAAY,CAAC,SAAS;YACpCC,OAAO;YACPN,UAAUO,OAAOP,YAAY,OAAOQ,WAAW;QACjD,GAAGC,MAAM,CAACR;IACZ,EAAE,eAAM;QACN,OAAO,GAAGA,MAAMS,OAAO,CAAC,GAAG,CAAC,EAAEH,OAAOP,UAAUQ,WAAW,IAAI;IAChE;AACF;AAEA,kEAAkE,GAClE,OAAO,SAASG,4BACdC,QAAgB,EAChBC,OAAyC;IAEzC,OAAON,OAAOK,mBAAAA,WAAY,IACvBE,OAAO,CAAC,2BAA2B,CAACC,QAAQC;QAC3C,MAAMf,QAAQY,2BAAAA,OAAS,CAACG,KAAK;QAC7B,OAAOf,UAAU,QAAQA,UAAUgB,YAAY,KAAKV,OAAON;IAC7D,GACCa,OAAO,CAAC,YAAY,IACpBA,OAAO,CAAC,cAAc,KACtBA,OAAO,CAAC,cAAc,MACtBI,IAAI;AACT;AAaA,0EAA0E,GAC1E,OAAO,SAASC,8BACd/C,UAAiF,EACjFgD,QAAkD;QAEnCA;IAAf,MAAMC,SAASD,6BAAAA,kBAAAA,SAAUE,KAAK,qBAAfF,eAAiB,CAAChD,WAAWc,IAAI,CAAC;IACjD,OAAO;QACLqC,SACE,QAAOF,0BAAAA,OAAQE,OAAO,MAAK,YACvBF,OAAOE,OAAO,GACdnD,WAAWuB,cAAc;QAC/BF,UACE4B,CAAAA,0BAAAA,OAAQ5B,QAAQ,MAAK,eAAe4B,CAAAA,0BAAAA,OAAQ5B,QAAQ,MAAK,WACrD4B,OAAO5B,QAAQ,GACfrB,WAAWqB,QAAQ;IAC3B;AACF;AAEA;;;;CAIC,GACD,OAAO,MAAM+B,oCAAyD,IAAIC,IACxExC,qBAAqByC,OAAO,CAAC,CAACtD,aAC5BA,WAAWwB,gBAAgB,GAAG;QAACxB,WAAWwB,gBAAgB;KAAC,GAAG,EAAE,GAEnE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/operator-alerts.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 type { AglynNotificationType, NotificationLevel } from './notifications'\n\n/**\n * OPERATOR ALERTS (AGL-3377): the events whoever runs an install must hear\n * about, as one typed catalog.\n *\n * Every alert is an entry here (or a plugin's entry in the same shape,\n * registered through `@aglyn/aglyn/plugin-manager/operator-alerts`) and is\n * raised through ONE server entry point, `raiseOperatorAlert` in\n * `@aglyn/tenant-data-admin/server/operator-alerts`. That entry point writes\n * the staff console notification, dedupes a flapping condition, honours the\n * per-type switches staff set on Staff → Operator alerts, and delivers by\n * email (the `operator-alert` system email) and the optional out-of-band\n * webhook. No call site composes or sends its own mail.\n *\n * The catalog holds nothing install-specific: no address, no domain, no\n * host. Recipients come from `resolveStaffAlertRecipients()` and the webhook\n * from `OPERATOR_ALERT_WEBHOOK_URL`, so an entry reads the same on aglyn.com,\n * on a self-hosted install and in an OSS consumer's deployment.\n *\n * Copy is written against merge tokens (`{{orgId}}`), filled from the\n * `context` the call site passes. A token the call site did not supply is\n * blanked, so every sentence must still read when its optional tokens are\n * empty. Never put a data subject's address or other personal data into a\n * context: the alert travels to an inbox and a webhook, not only the console.\n */\n\n/**\n * How much an alert matters.\n *\n * - `must` — money moving with nobody looking, a legal duty unmet, data not\n * protected or not erased. On and immediate unless staff change it.\n * - `should` — a fault an operator wants to know about today.\n * - `low` — routine review work; on, and batched into the daily digest.\n */\nexport type OperatorAlertTier = 'must' | 'should' | 'low'\n\nexport type OperatorAlertCategory =\n | 'billing'\n | 'payments'\n | 'legal'\n | 'data'\n | 'ops'\n | 'deliverability'\n | 'security'\n | 'support'\n\n/** `digest` batches the alert into the once-a-day operator digest. */\nexport type OperatorAlertDelivery = 'immediate' | 'digest'\n\nexport interface OperatorAlertDefinition {\n /**\n * Stable id, also the key of its settings row. Never rename: staff\n * switches are stored under it. A plugin's types start with its plugin id\n * and a dot (`commerce.taxNotReversed`).\n */\n type: string\n /** The settings row's name. */\n label: string\n /** What it means and the first thing to do, for the settings page. */\n description: string\n tier: OperatorAlertTier\n category: OperatorAlertCategory\n /** The notification title and email subject, with `{{tokens}}`. */\n title: string\n /** What happened and what to do, with `{{tokens}}`. */\n body: string\n /** Console path the alert opens, with `{{tokens}}`; the call may override. */\n link?: string\n /** The coded default; staff may change it. */\n delivery: OperatorAlertDelivery\n /**\n * How long one `dedupeKey` stays quiet after it fired, in minutes. A\n * condition that flaps inside the window is told once. `0` never dedupes.\n * A call without a `dedupeKey` is never deduped.\n */\n dedupeWindowMinutes: number\n /**\n * Fire only once the same `dedupeKey` has been raised this many times\n * inside the window — for an endpoint any stranger can hit, where one\n * refused request is noise and several are a broken secret. Default 1.\n */\n minOccurrences?: number\n /** The coded default; staff may change it. */\n defaultEnabled: boolean\n /**\n * The console notification's type. Absent is the generic\n * `system.operatorAlert`; a type that already had its own notification\n * keeps it, so its icon, label and everyone's mutes are unchanged.\n */\n notificationType?: AglynNotificationType\n /**\n * How loud its console notification is drawn (AGL-3437). Absent, the\n * tier answers — see {@link operatorAlertLevel}. Set where the tone and\n * the importance part ways: a recovery is worth hearing about and is good\n * news, and a degraded check is a must-know that is not yet an outage.\n */\n level?: NotificationLevel\n /** The plugin that contributed it; absent for core's own. */\n pluginId?: string\n}\n\n/** Values a call site passes for an alert's `{{tokens}}`. */\nexport type OperatorAlertContext = Readonly<\n Record<string, string | number | boolean | null | undefined>\n>\n\n/** The notification type an alert without its own writes under. */\nexport const OPERATOR_ALERT_DEFAULT_NOTIFICATION_TYPE: AglynNotificationType =\n 'system.operatorAlert'\n\nexport const OPERATOR_ALERT_TIER_LABELS: Record<OperatorAlertTier, string> = {\n must: 'Must know',\n should: 'Should know',\n low: 'Routine',\n}\n\n/**\n * The level an alert's notification is drawn at when its entry names none:\n * a must-know is red, a should-know amber, routine review work informational.\n */\nexport const OPERATOR_ALERT_TIER_LEVELS: Record<\n OperatorAlertTier,\n NotificationLevel\n> = {\n must: 'critical',\n should: 'warning',\n low: 'info',\n}\n\n/** The level an alert's console notification carries (AGL-3437). */\nexport function operatorAlertLevel(\n definition: Pick<OperatorAlertDefinition, 'tier' | 'level'>,\n): NotificationLevel {\n return definition.level ?? OPERATOR_ALERT_TIER_LEVELS[definition.tier]\n}\n\nexport const OPERATOR_ALERT_CATEGORY_LABELS: Record<\n OperatorAlertCategory,\n string\n> = {\n billing: 'Billing',\n payments: 'Payments & payouts',\n legal: 'Legal',\n data: 'Data protection',\n ops: 'Operations',\n deliverability: 'Email deliverability',\n security: 'Security',\n support: 'Support',\n}\n\nconst DAY = 24 * 60\n\n/**\n * Core's alerts. Plugins contribute theirs through the plugin-manager\n * registry; nothing plugin-specific belongs in this list.\n */\nexport const CORE_OPERATOR_ALERTS: readonly OperatorAlertDefinition[] = [\n // ── Fraud, risk and legal duties already alerting before AGL-3377 ──────\n {\n type: 'system.abuseReportUrgent',\n label: 'Urgent abuse, fraud or risk alert',\n description:\n 'Phishing, malware or CSAM reported on a site, card testing, a flagged or disputed payment, a held phishing email, a seller under review. Review it on Staff → Abuse reports.',\n tier: 'must',\n category: 'security',\n title: '{{title}}',\n body: '{{body}}',\n link: '/admin/abuse-reports',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.abuseReportUrgent',\n },\n {\n // The one lock no person placed (AGL-3450): staff confirm it before the\n // customer's appeal arrives, and re-place it as `abuse` or lift it.\n type: 'security.pageSecurityHold',\n label: 'Automatic security hold on a new workspace',\n description:\n 'The page screen held a phishing page from a workspace in its first two weeks and locked the workspace, the site and the publishing account as security. Confirm it on Staff → Abuse reports, then re-place it as abuse on Staff → Lockdown, or lift it there if it is a false positive.',\n tier: 'must',\n category: 'security',\n title: 'Security hold placed on {{orgName}}',\n body:\n '{{page}} on {{siteName}} ({{hostId}}) was held for review: {{signal}} Locked as security, pending your review: {{locks}}. The abuse row is {{reference}}. Lift the hold, or re-place it as abuse, on Staff → Lockdown (/admin/lockdown).',\n link: '/admin/abuse-reports?report={{reviewId}}',\n delivery: 'immediate',\n // One hold per workspace; a repeat inside the day is the same event.\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n notificationType: 'system.abuseReportUrgent',\n },\n {\n type: 'security.paymentFraudHold',\n label: 'Automatic security hold for payment fraud',\n description:\n 'Stripe flagged a workspace\\'s own subscription payment as fraud — a Radar block at highest risk, a Stripe fraud report, three or more cards failing within 30 minutes, an early fraud warning or a Radar review. A new workspace that never paid is locked as security (takedown) with its subscriptions canceled; an older or paying one is not locked and needs a decision. Confirm it on Staff → Abuse reports, then re-place it as abuse on Staff → Lockdown, or lift it there.',\n tier: 'must',\n category: 'security',\n title: '{{action}}: {{orgName}}',\n body:\n '{{trigger}} on {{orgName}} ({{orgId}}). Charges: {{charges}}; cards: {{cards}}, issued in {{cardCountries}}. Locked: {{locks}}. The abuse row is {{reference}}. Lift it, or re-place it as abuse, on Staff → Lockdown (/admin/lockdown).',\n link: '/admin/abuse-reports?report={{reviewId}}',\n delivery: 'immediate',\n // One per workspace per window: every further card in the burst is the\n // same event, and the abuse row carries all of them.\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n notificationType: 'system.abuseReportUrgent',\n },\n {\n type: 'system.disputeUnattributed',\n label: 'Card dispute with no owner',\n description:\n 'A chargeback arrived that no subscription, order or marketplace purchase claimed, so nothing is answering it. Find the charge in Stripe and respond before the evidence deadline.',\n tier: 'must',\n category: 'billing',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.disputeUnattributed',\n },\n {\n type: 'system.dmcaCounterNotice',\n label: 'DMCA counter-notice',\n description:\n 'A customer contested a takedown. The statutory clock is already running; forward it to the complainant and restore on time unless they file suit.',\n tier: 'must',\n category: 'legal',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.dmcaCounterNotice',\n },\n {\n type: 'system.billingWebhookHalfApplied',\n label: 'Billing webhook half applied',\n description:\n 'A Stripe event threw after its handlers began, so its effects may be partly applied and Stripe will not retry it. Reconcile the event by hand.',\n tier: 'must',\n category: 'billing',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.billingWebhookHalfApplied',\n },\n\n // ── MUST: billing ───────────────────────────────────────────────────────\n {\n type: 'billing.platformDisputeLost',\n label: 'Subscription dispute lost',\n description:\n 'A card dispute on a workspace subscription closed as lost: the money has been taken back. Decide whether the workspace keeps its plan.',\n tier: 'must',\n category: 'billing',\n title: 'Subscription dispute lost on workspace {{orgId}}',\n body:\n 'The card dispute {{disputeId}} on invoice {{invoiceId}} for workspace {{orgName}} ({{orgId}}) closed as lost ({{reason}}), and {{amount}} was taken back. The workspace keeps its plan until somebody decides otherwise.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 30 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.orphanedSubscription',\n label: 'Stripe is billing a workspace that does not exist',\n description:\n 'A subscription names a workspace that was deleted or erased, so the customer keeps being charged for nothing. Cancel or refund it in Stripe.',\n tier: 'must',\n category: 'billing',\n title: 'Subscription bills a missing workspace',\n body:\n 'Stripe subscription {{subscriptionId}} (customer {{customerId}}, plan {{plan}}) names workspace {{orgId}}, which {{reason}}. The {{eventType}} event changed nothing. Cancel or refund it in Stripe.',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.usageNotReported',\n label: 'Metered usage not reported to Stripe',\n description:\n 'A closed month measured billable usage and it reached no invoice. Report it to Stripe by hand or the revenue is lost.',\n tier: 'must',\n category: 'billing',\n title: 'Usage for {{month}} not billed on {{orgId}}',\n body:\n 'The closed month {{month}} measured {{amount}} of billable usage on workspace {{orgName}} ({{orgId}}), and it was not reported to Stripe ({{reason}}). Nothing will invoice it until somebody does.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 7 * DAY,\n defaultEnabled: true,\n },\n {\n // The scheduled reconciliation of Site Care extra time (AGL-3959): a\n // request's billed hours and the Stripe invoice item that carries them\n // disagree, or one exists without the other. Should know, not must:\n // nothing is lost yet, the next invoice has not gone, and the fix is on\n // the request. The same check compares a flat-quoted project's\n // invoices (AGL-3970), whose findings arrive with `month` \"projects\".\n type: 'billing.siteCareReconciliation',\n label: 'Site Care billing does not match Stripe',\n description:\n 'A Site Care request’s billed hours, amount or line description disagree with its Stripe invoice item, a Stripe item has no request row behind it, a month’s total disagrees with its statement, or a project invoice’s status or amount disagrees with Stripe (or exists in Stripe with no project row). Open the workspace’s staff page and correct it from the request or the project — never by hand in Stripe.',\n tier: 'should',\n category: 'billing',\n title: 'Site Care billing mismatch on {{orgName}} ({{month}})',\n body:\n '{{count}} Site Care finding(s) on workspace {{orgName}} ({{orgId}}) for {{month}}: {{findings}} Fix it from the request on the staff organization page.',\n link: '/admin/orgs/{{orgId}}#site-care',\n delivery: 'immediate',\n // One alert a day per workspace and month: the same finding re-checked\n // tomorrow is the same news.\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.webhookSignatureRejected',\n label: 'Billing webhook failing its signature check',\n description:\n 'Repeated deliveries to the billing webhook were refused because their signature did not match. Usually a rolled signing secret: until it is fixed, Stripe cannot tell the install about money.',\n tier: 'must',\n category: 'billing',\n title: 'Billing webhook is refusing deliveries',\n body:\n 'The billing webhook refused several signed deliveries within six hours because their Stripe signature matched none of the configured secrets. If Stripe is the sender, its signing secret no longer matches this install’s, and no billing event is being applied.',\n link: '/admin/health',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n minOccurrences: 3,\n defaultEnabled: true,\n },\n {\n type: 'billing.webhookInert',\n label: 'Billing webhook delivery moved nothing',\n description:\n 'Stripe delivered an event this install subscribed to, and no handler did anything with it. Usually a handler that stopped being registered.',\n tier: 'must',\n category: 'billing',\n title: 'A {{eventType}} delivery changed nothing',\n body:\n 'Stripe event {{eventId}} ({{eventType}}) was accepted and no handler acted on it. Check which handler stopped being registered, then replay the event.',\n link: '/admin/health',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n\n // ── MUST: data protection and records ───────────────────────────────────\n {\n type: 'data.personErasureFailed',\n label: 'Personal data erasure failed',\n description:\n 'A data subject’s erasure request failed. It will be retried, but the legal deadline keeps running: read the error and fix the cause.',\n tier: 'must',\n category: 'data',\n title: 'Erasure request {{requestId}} failed',\n body:\n 'The erasure request {{requestId}} on workspace {{orgName}} ({{orgId}}) failed (attempt {{attempt}}): {{error}}. The statutory deadline keeps running while it retries.',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'data.orgErasureFailed',\n label: 'Workspace erasure failed',\n description:\n 'A workspace scheduled for erasure could not be erased. Its data is still held after the date it was promised gone.',\n tier: 'must',\n category: 'data',\n title: 'Workspace {{orgId}} could not be erased',\n body:\n 'The scheduled erasure of workspace {{orgName}} ({{orgId}}) did not complete: {{reason}}. It will be retried on the next run; its data is held until it succeeds.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'data.backupExportFailed',\n label: 'Database export failed',\n description:\n 'The scheduled database export did not start. A stale export means the worst day has nothing to restore from.',\n tier: 'must',\n category: 'data',\n title: 'Database export failed',\n body:\n 'The scheduled database export did not start ({{reason}}). The last good export is getting older; check the service account’s export permission and the bucket.',\n link: '/admin/health',\n delivery: 'immediate',\n dedupeWindowMinutes: 12 * 60,\n defaultEnabled: true,\n },\n\n // ── MUST: legal ─────────────────────────────────────────────────────────\n {\n type: 'legal.abuseReportHigh',\n label: 'Takedown, impersonation or illegal-content report',\n description:\n 'A DMCA takedown, impersonation or illegal-content report. Each carries a response duty; review it on Staff → Abuse reports.',\n tier: 'must',\n category: 'legal',\n title: '{{category}} report on {{site}}',\n body:\n '{{site}} was reported for {{category}}. Reference {{reference}}. Review it and respond within the policy’s window.',\n link: '/admin/abuse-reports',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n },\n\n // ── MUST/SHOULD: health ─────────────────────────────────────────────────\n {\n type: 'system.healthDegraded',\n label: 'Health check degraded',\n description:\n 'A health check went from healthy to degraded: scheduled jobs silent, backups stale, billing deliveries failing, sign-ups refused, server errors, a site not rendering. Told once per incident.',\n tier: 'must',\n category: 'ops',\n title: '{{check}} is degraded',\n body: '{{check}} went from healthy to degraded. {{detail}}',\n link: '/admin/health',\n delivery: 'immediate',\n // Must-know, and still amber rather than red: degraded is not down.\n level: 'warning',\n // A check flapping across the line is told once an hour, not on\n // every swing.\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n },\n {\n // The reminder the edge alert never sends (AGL-3860): raised by the\n // operator alerts tick at 1 h and every 2 h after while a check stays\n // degraded. The tick raises it as Must know from 2 h, so its level\n // follows the tier it was raised at rather than one coded here.\n type: 'system.healthStillDegraded',\n label: 'Health check still degraded',\n description:\n 'A health check has stayed degraded for an hour or more. Told at 1 h and again every 2 h until it recovers; Should know for the first reminder, Must know from 2 h on. Open the failing endpoint, read the failing check’s code and fix the cause, or the check when the check is what is wrong.',\n tier: 'should',\n category: 'ops',\n title: '{{check}} is still degraded after {{duration}}',\n body: '{{check}} is still degraded after {{duration}}. {{detail}}',\n link: '/admin/health',\n delivery: 'immediate',\n // The tick dedupes each reminder per check per step on the check's own\n // state; the window only stops a retried tick from telling one twice.\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n },\n {\n // The post-deploy production canary (AGL-3567), raised from GitHub\n // Actions through `/api/admin/operator-alerts/canary`. Red because a\n // deploy that stops rendering pages is every published site down.\n type: 'ops.productionCanaryRed',\n label: 'Production canary failed after a deploy',\n description:\n 'Right after a tenant or console production deploy, uncached pages stopped rendering. The canary rolls the deploy back by itself when the failure holds across sites; after any rollback the next release must be promoted by hand.',\n tier: 'must',\n category: 'ops',\n title: '{{project}} production canary: {{outcome}}',\n body: '{{detail}}',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'critical',\n // The caller dedupes per deployment and verdict; this only stops a\n // re-run of the same red run from telling it twice.\n dedupeWindowMinutes: 30,\n defaultEnabled: true,\n },\n {\n type: 'system.healthRecovered',\n label: 'Health check recovered',\n description: 'A degraded health check is healthy again.',\n tier: 'should',\n category: 'ops',\n title: '{{check}} recovered',\n body: '{{check}} is healthy again after {{duration}}.',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'success',\n // A check flapping across the line is told once an hour, not on\n // every swing.\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n },\n {\n // The render monitor (AGL-3568): a published site fetched over HTTP, on\n // pages no cache can answer, failed several runs in a row. Red, not the\n // amber of a degraded check: every visitor without a cached copy is\n // getting an error page or a timeout right now.\n type: 'system.siteRenderFailing',\n label: 'Published site not rendering pages',\n description:\n 'The render monitor asked a published site for pages no cache can answer, several runs in a row, and got no complete page back. Visitors to cached pages may still see them, so the site can look up while every other page fails. Check the latest site runtime deployment first and roll it back if it just shipped.',\n tier: 'must',\n category: 'ops',\n title: 'Pages are not rendering on {{site}}',\n body:\n '{{site}} failed {{failures}} render checks in a row, over {{since}}. {{detail}} Cached pages may still load, so the site can look up while new renders fail.',\n link: '/admin/health',\n delivery: 'immediate',\n // Told once per outage: the monitor raises it on the edge, and the\n // window only covers a site flapping across the line.\n dedupeWindowMinutes: 30,\n defaultEnabled: true,\n },\n {\n type: 'system.siteRenderRecovered',\n label: 'Published site rendering again',\n description:\n 'A published site the render monitor had reported as not rendering serves fresh pages again.',\n tier: 'should',\n category: 'ops',\n title: '{{site}} is rendering pages again',\n body: 'Fresh page renders on {{site}} pass again after {{duration}}.',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'success',\n dedupeWindowMinutes: 30,\n defaultEnabled: true,\n },\n {\n // The render monitor could not see the site (AGL-3580): bot protection\n // answered every probe it made, so it knows nothing about whether pages\n // render. Not an outage, and never worded as one — on 2026-10-05 a\n // missing probe token read as \"pages are not rendering\" for three hours\n // while the site served pages. Amber: detection is off until it is fixed.\n type: 'system.renderMonitorBlind',\n label: 'Render monitor cannot see a site',\n description:\n 'Bot protection answered the render monitor instead of a published site, several runs in a row, so nothing is checking whether that site renders pages. The site itself may be fine. Check AGLYN_PROBE_TOKEN on the console and the \"CI and uptime probe bypass\" firewall rule on the site runtime.',\n tier: 'must',\n category: 'ops',\n title: 'The render monitor cannot see {{site}}',\n body:\n 'Bot protection answered instead of {{site}} for {{runs}} runs in a row, so nothing is checking its pages. {{detail}} This is not a verdict on the site.',\n link: '/admin/health',\n delivery: 'immediate',\n level: 'warning',\n dedupeWindowMinutes: 360,\n defaultEnabled: true,\n },\n\n // ── SHOULD: billing ─────────────────────────────────────────────────────\n {\n type: 'billing.autoLocked',\n label: 'Workspace billing locked automatically',\n description:\n 'A workspace crossed its spend guard and the platform locked its billable activity. Check it is not a false positive before the customer notices.',\n tier: 'should',\n category: 'billing',\n title: 'Billing locked on {{orgName}}',\n body:\n 'Workspace {{orgName}} ({{orgId}}) was locked automatically: {{reason}}.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.platformInvoiceUncollectible',\n label: 'Subscription invoice voided or uncollectible',\n description:\n 'A workspace invoice was voided or marked uncollectible: revenue the books expected is not coming.',\n tier: 'should',\n category: 'billing',\n title: 'Invoice {{status}} on {{orgId}}',\n body:\n 'Invoice {{invoiceId}} for {{amount}} on workspace {{orgName}} ({{orgId}}) was marked {{status}}, so Stripe has stopped collecting it.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 30 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'billing.connectPayoutFailed',\n label: 'Connected account payout or transfer failed',\n description:\n 'Money due to a merchant or seller did not arrive. Stripe retries on its own schedule; a human decides what happens next.',\n tier: 'should',\n category: 'billing',\n title: 'A {{kind}} to {{account}} failed',\n body:\n 'A {{amount}} Stripe {{kind}} ({{stripeId}}) to connected account {{account}} ({{merchant}}) failed: {{reason}}. The merchant’s funds are not where the ledger says.',\n delivery: 'immediate',\n dedupeWindowMinutes: 30 * DAY,\n defaultEnabled: true,\n },\n {\n type: 'staff.paymentFailed',\n label: 'Workspace payment failed',\n description:\n 'A paying workspace’s renewal failed. Stripe is retrying; the customer has been told.',\n tier: 'should',\n category: 'billing',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'staff.paymentFailed',\n },\n\n // ── SHOULD: security ────────────────────────────────────────────────────\n {\n type: 'security.staffGranted',\n label: 'Staff access granted or raised',\n description:\n 'Somebody was made staff, or a staff role was raised. If nobody on the team did it, revoke it and rotate credentials.',\n tier: 'should',\n category: 'security',\n title: '{{target}} is now {{role}} staff',\n body: '{{actor}} granted {{target}} the {{role}} staff role (was {{previous}}).',\n link: '/admin/users',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n },\n\n // ── SHOULD: support ─────────────────────────────────────────────────────\n {\n type: 'support.slaBreached',\n label: 'Support ticket past its response time',\n description:\n 'A support ticket passed its promised response time without a staff reply.',\n tier: 'should',\n category: 'support',\n title: 'Ticket past its response time: {{subject}}',\n body:\n 'The {{tier}} ticket “{{subject}}” from workspace {{orgName}} ({{orgId}}) was due a first response {{overdue}} ago and has none.',\n // The ticket itself: the support page opens `?ticketId=` on load.\n link: '/admin/support?ticketId={{ticketId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'support.ticketOpened',\n label: 'New support ticket',\n description: 'A subscriber opened a support ticket.',\n tier: 'should',\n category: 'support',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'support.ticketOpened',\n // A customer asking for help, not a fault.\n level: 'info',\n },\n {\n type: 'support.ticketReply',\n label: 'Support ticket reply',\n description: 'A subscriber replied on a support ticket.',\n tier: 'should',\n category: 'support',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'support.ticketReply',\n level: 'info',\n },\n\n // ── SHOULD: deliverability ──────────────────────────────────────────────\n {\n type: 'deliverability.sendRateSaturated',\n label: 'Email send-rate governor saturated',\n description:\n 'The platform’s email send-rate budget is exhausted, so sends are being deferred. Raise the budget or find the sender filling it.',\n tier: 'should',\n category: 'deliverability',\n title: 'Email sending is being throttled',\n body:\n 'The {{scope}} send-rate budget is full ({{detail}}), so sends are being deferred.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n type: 'deliverability.sendRateUnavailable',\n label: 'Email send-rate governor unavailable',\n description:\n 'The send-rate governor could not read its counters, so mail is going out unmetered: nothing is holding the shared domains under their hourly ceiling.',\n tier: 'should',\n category: 'deliverability',\n title: 'Email send-rate governor unavailable',\n body:\n 'The send-rate governor could not read its counters ({{error}}), so sends are being allowed unmetered until it can.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n type: 'deliverability.gatewayBlocking',\n label: 'A recipient gateway is blocking the shared domain',\n description:\n 'A mail gateway is refusing mail from the shared sending domain, so everyone behind that gateway stops receiving it.',\n tier: 'should',\n category: 'deliverability',\n title: '{{gateway}} is blocking {{domain}}',\n body:\n 'Mail from {{domain}} is being refused by {{gateway}} ({{detail}}). Recipients behind that gateway are not receiving it.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'deliverability.providerCredentialsRejected',\n label: 'Email provider rejected the credentials',\n description:\n 'The email provider refused the API key, or a sending pool is unhealthy: invites, password resets and receipts are not leaving. The webhook channel is the one that still reaches you.',\n tier: 'should',\n category: 'deliverability',\n title: 'Email delivery is failing: {{problem}}',\n body: '{{detail}}',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n // A purchasing ceiling, not a job failure: the provisioning sweep ran\n // and every site keeps sending, so the copy must not read as an outage.\n type: 'deliverability.sendingDomainCapacityFull',\n label: 'Sending-domain allowance full',\n description:\n 'Every dedicated sending domain the provider allowance covers is in use, so new sites that ask for one stay on the shared pool. No mail is lost; raise the allowance or move merchants onto domains they own.',\n tier: 'should',\n category: 'deliverability',\n title: 'Sending-domain allowance full ({{held}}/{{capacity}})',\n body:\n 'The sending-domain allowance is full ({{held}} of {{capacity}} in use), so sites that asked for a dedicated domain keep sending on the shared pool. No mail is lost: what they go without is the isolation a domain of their own buys, and their campaigns are held to the pool’s stricter reputation limits. Raise AGLYN_SENDING_DOMAIN_CAPACITY once the provider allowance covers it, or move merchants onto domains they own.',\n link: '/admin/emails',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n\n // ── SHOULD: operations ──────────────────────────────────────────────────\n {\n type: 'ops.reaperStuck',\n label: 'A reaper is stuck or failing',\n description:\n 'A cleanup job (sending domains, unverified workspaces) could not finish, so what it removes keeps accumulating.',\n tier: 'should',\n category: 'ops',\n title: '{{job}} is stuck',\n body: '{{job}} could not finish: {{detail}}',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'ops.pluginJobFailed',\n label: 'A plugin job failed',\n description:\n 'A plugin’s scheduled job threw: consent-group changes, the publish outbox, sending-domain provisioning, a plugin cron.',\n tier: 'should',\n category: 'ops',\n // `job` is a noun phrase that reads as a subject on its own (\"The\n // publish outbox drain\", \"The scheduled job acme-mail-send\"), so the\n // title and the body open with the same words.\n title: '{{job}} failed',\n body: '{{job}} failed: {{error}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n },\n {\n // Nightly, so once a day per provider is every run it could report.\n type: 'ops.adAudienceSyncFailed',\n label: 'Ad audience sync failed',\n description:\n 'The nightly account-holder audience sync (AGL-3780) could not update a Meta, Google or LinkedIn audience, or held a run whose audience would have shrunk by more than half. The audience keeps what it last had; check the provider credentials, or run the sync with force once the drop is confirmed.',\n tier: 'should',\n category: 'ops',\n title: 'Ad audience sync: {{provider}} not updated',\n body: 'The {{provider}} account-holder audience was not updated: {{detail}}. It keeps what it was last sent, and the next nightly run tries again.',\n link: '/admin/flags',\n delivery: 'immediate',\n dedupeWindowMinutes: DAY,\n defaultEnabled: true,\n },\n {\n type: 'system.pluginVerifierRegression',\n label: 'Plugin verifier regression',\n description:\n 'A live plugin version stopped passing the static verifier.',\n tier: 'should',\n category: 'security',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.pluginVerifierRegression',\n },\n {\n type: 'system.bandwidthCeilingTripped',\n label: 'Bandwidth ceiling reached',\n description:\n 'A site crossed the per-month bandwidth abuse ceiling.',\n tier: 'should',\n category: 'ops',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.bandwidthCeilingTripped',\n },\n\n // ── LOW ─────────────────────────────────────────────────────────────────\n {\n type: 'marketplace.review',\n label: 'Plugin listing waiting for review',\n description: 'A plugin listing or version was submitted for review.',\n tier: 'low',\n category: 'security',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'marketplace.review',\n },\n {\n type: 'system.scopeDrift',\n label: 'Resources missing a sharing scope',\n description:\n 'The weekly sweep found documents invisible to every site-scoped read: a creation path forgot the field.',\n tier: 'low',\n category: 'data',\n title: '{{title}}',\n body: '{{body}}',\n delivery: 'digest',\n dedupeWindowMinutes: 0,\n defaultEnabled: true,\n notificationType: 'system.scopeDrift',\n },\n]\n\n/** An amount in minor units, as an alert prints it: `$12.40`. */\nexport function formatOperatorAlertAmount(\n cents: number,\n currency = 'usd',\n): string {\n const value = Number(cents) / 100\n if (!Number.isFinite(value)) return ''\n try {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: String(currency || 'usd').toUpperCase(),\n }).format(value)\n } catch {\n return `${value.toFixed(2)} ${String(currency).toUpperCase()}`\n }\n}\n\n/** Replaces each `{{token}}` with its context value, or nothing. */\nexport function renderOperatorAlertTemplate(\n template: string,\n context: OperatorAlertContext | undefined,\n): string {\n return String(template ?? '')\n .replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (_match, name: string) => {\n const value = context?.[name]\n return value === null || value === undefined ? '' : String(value)\n })\n .replace(/\\(\\s*\\)/g, '')\n .replace(/[ \\t]{2,}/g, ' ')\n .replace(/ ([.,;:])/g, '$1')\n .trim()\n}\n\n/** A staff member's answer for one type; an absent key keeps the default. */\nexport interface OperatorAlertTypeSetting {\n enabled?: boolean\n delivery?: OperatorAlertDelivery\n}\n\n/** `platformSettings/operatorAlerts`, keyed by alert type. */\nexport interface OperatorAlertSettings {\n types?: Record<string, OperatorAlertTypeSetting>\n}\n\n/** Whether a type is on, and how it is delivered, after staff's answers. */\nexport function effectiveOperatorAlertSetting(\n definition: Pick<OperatorAlertDefinition, 'type' | 'delivery' | 'defaultEnabled'>,\n settings: OperatorAlertSettings | null | undefined,\n): { enabled: boolean; delivery: OperatorAlertDelivery } {\n const answer = settings?.types?.[definition.type]\n return {\n enabled:\n typeof answer?.enabled === 'boolean'\n ? answer.enabled\n : definition.defaultEnabled,\n delivery:\n answer?.delivery === 'immediate' || answer?.delivery === 'digest'\n ? answer.delivery\n : definition.delivery,\n }\n}\n\n/**\n * Staff notification types whose alert emails the operator on a coded\n * default of immediate (AGL-3375), derived from the catalog so there is one\n * list.\n */\nexport const OPERATOR_ALERT_NOTIFICATION_TYPES: ReadonlySet<string> = new Set(\n CORE_OPERATOR_ALERTS.flatMap((definition) =>\n definition.notificationType ? [definition.notificationType] : [],\n ),\n)\n"],"names":["OPERATOR_ALERT_DEFAULT_NOTIFICATION_TYPE","OPERATOR_ALERT_TIER_LABELS","must","should","low","OPERATOR_ALERT_TIER_LEVELS","operatorAlertLevel","definition","level","tier","OPERATOR_ALERT_CATEGORY_LABELS","billing","payments","legal","data","ops","deliverability","security","support","DAY","CORE_OPERATOR_ALERTS","type","label","description","category","title","body","link","delivery","dedupeWindowMinutes","defaultEnabled","notificationType","minOccurrences","formatOperatorAlertAmount","cents","currency","value","Number","isFinite","Intl","NumberFormat","style","String","toUpperCase","format","toFixed","renderOperatorAlertTemplate","template","context","replace","_match","name","undefined","trim","effectiveOperatorAlertSetting","settings","answer","types","enabled","OPERATOR_ALERT_NOTIFICATION_TYPES","Set","flatMap"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GA6GD,iEAAiE,GACjE,OAAO,MAAMA,2CACX,uBAAsB;AAExB,OAAO,MAAMC,6BAAgE;IAC3EC,MAAM;IACNC,QAAQ;IACRC,KAAK;AACP,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMC,6BAGT;IACFH,MAAM;IACNC,QAAQ;IACRC,KAAK;AACP,EAAC;AAED,kEAAkE,GAClE,OAAO,SAASE,mBACdC,UAA2D;QAEpDA;IAAP,QAAOA,oBAAAA,WAAWC,KAAK,YAAhBD,oBAAoBF,0BAA0B,CAACE,WAAWE,IAAI,CAAC;AACxE;AAEA,OAAO,MAAMC,iCAGT;IACFC,SAAS;IACTC,UAAU;IACVC,OAAO;IACPC,MAAM;IACNC,KAAK;IACLC,gBAAgB;IAChBC,UAAU;IACVC,SAAS;AACX,EAAC;AAED,MAAMC,MAAM,KAAK;AAEjB;;;CAGC,GACD,OAAO,MAAMC,uBAA2D;IACtE,0EAA0E;IAC1E;QACEC,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACE,wEAAwE;QACxE,oEAAoE;QACpEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,qEAAqE;QACrEC,qBAAqBV;QACrBW,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,uEAAuE;QACvE,qDAAqD;QACrDC,qBAAqBV;QACrBW,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IAEA,2EAA2E;IAC3E;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,KAAKV;QAC1BW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFE,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAIV;QACzBW,gBAAgB;IAClB;IACA;QACE,qEAAqE;QACrE,uEAAuE;QACvE,oEAAoE;QACpE,wEAAwE;QACxE,+DAA+D;QAC/D,sEAAsE;QACtET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,uEAAuE;QACvE,6BAA6B;QAC7BC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBG,gBAAgB;QAChBF,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFE,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,KAAK;QAC1BC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACV,oEAAoE;QACpEpB,OAAO;QACP,gEAAgE;QAChE,eAAe;QACfqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,oEAAoE;QACpE,sEAAsE;QACtE,mEAAmE;QACnE,gEAAgE;QAChET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACV,uEAAuE;QACvE,sEAAsE;QACtEC,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,mEAAmE;QACnE,qEAAqE;QACrE,kEAAkE;QAClET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACP,mEAAmE;QACnE,oDAAoD;QACpDqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACP,gEAAgE;QAChE,eAAe;QACfqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,wEAAwE;QACxE,wEAAwE;QACxE,oEAAoE;QACpE,gDAAgD;QAChDT,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACV,mEAAmE;QACnE,sDAAsD;QACtDC,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACPqB,qBAAqB;QACrBC,gBAAgB;IAClB;IACA;QACE,uEAAuE;QACvE,wEAAwE;QACxE,mEAAmE;QACnE,wEAAwE;QACxE,0EAA0E;QAC1ET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVpB,OAAO;QACPqB,qBAAqB;QACrBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,KAAKV;QAC1BW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFE,UAAU;QACVC,qBAAqB,KAAKV;QAC1BW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IAEA,2EAA2E;IAC3E;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACF,kEAAkE;QAClEC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;QAClB,2CAA2C;QAC3CvB,OAAO;IACT;IACA;QACEa,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;QAClBvB,OAAO;IACT;IAEA,2EAA2E;IAC3E;QACEa,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACE,sEAAsE;QACtE,wEAAwE;QACxET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MACE;QACFC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IAEA,2EAA2E;IAC3E;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACV,kEAAkE;QAClE,qEAAqE;QACrE,+CAA+C;QAC/CC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB,IAAI;QACzBC,gBAAgB;IAClB;IACA;QACE,oEAAoE;QACpET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNC,MAAM;QACNC,UAAU;QACVC,qBAAqBV;QACrBW,gBAAgB;IAClB;IACA;QACET,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IAEA,2EAA2E;IAC3E;QACEV,MAAM;QACNC,OAAO;QACPC,aAAa;QACbd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;IACA;QACEV,MAAM;QACNC,OAAO;QACPC,aACE;QACFd,MAAM;QACNe,UAAU;QACVC,OAAO;QACPC,MAAM;QACNE,UAAU;QACVC,qBAAqB;QACrBC,gBAAgB;QAChBC,kBAAkB;IACpB;CACD,CAAA;AAED,+DAA+D,GAC/D,OAAO,SAASE,0BACdC,KAAa,EACbC,WAAW,KAAK;IAEhB,MAAMC,QAAQC,OAAOH,SAAS;IAC9B,IAAI,CAACG,OAAOC,QAAQ,CAACF,QAAQ,OAAO;IACpC,IAAI;QACF,OAAO,IAAIG,KAAKC,YAAY,CAAC,SAAS;YACpCC,OAAO;YACPN,UAAUO,OAAOP,YAAY,OAAOQ,WAAW;QACjD,GAAGC,MAAM,CAACR;IACZ,EAAE,eAAM;QACN,OAAO,GAAGA,MAAMS,OAAO,CAAC,GAAG,CAAC,EAAEH,OAAOP,UAAUQ,WAAW,IAAI;IAChE;AACF;AAEA,kEAAkE,GAClE,OAAO,SAASG,4BACdC,QAAgB,EAChBC,OAAyC;IAEzC,OAAON,OAAOK,mBAAAA,WAAY,IACvBE,OAAO,CAAC,2BAA2B,CAACC,QAAQC;QAC3C,MAAMf,QAAQY,2BAAAA,OAAS,CAACG,KAAK;QAC7B,OAAOf,UAAU,QAAQA,UAAUgB,YAAY,KAAKV,OAAON;IAC7D,GACCa,OAAO,CAAC,YAAY,IACpBA,OAAO,CAAC,cAAc,KACtBA,OAAO,CAAC,cAAc,MACtBI,IAAI;AACT;AAaA,0EAA0E,GAC1E,OAAO,SAASC,8BACd/C,UAAiF,EACjFgD,QAAkD;QAEnCA;IAAf,MAAMC,SAASD,6BAAAA,kBAAAA,SAAUE,KAAK,qBAAfF,eAAiB,CAAChD,WAAWc,IAAI,CAAC;IACjD,OAAO;QACLqC,SACE,QAAOF,0BAAAA,OAAQE,OAAO,MAAK,YACvBF,OAAOE,OAAO,GACdnD,WAAWuB,cAAc;QAC/BF,UACE4B,CAAAA,0BAAAA,OAAQ5B,QAAQ,MAAK,eAAe4B,CAAAA,0BAAAA,OAAQ5B,QAAQ,MAAK,WACrD4B,OAAO5B,QAAQ,GACfrB,WAAWqB,QAAQ;IAC3B;AACF;AAEA;;;;CAIC,GACD,OAAO,MAAM+B,oCAAyD,IAAIC,IACxExC,qBAAqByC,OAAO,CAAC,CAACtD,aAC5BA,WAAWwB,gBAAgB,GAAG;QAACxB,WAAWwB,gBAAgB;KAAC,GAAG,EAAE,GAEnE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* THE OWNER'S RECORDED YES (AGL-3959).
|
|
19
|
+
*
|
|
20
|
+
* Paid work beyond what a subscription includes is billed only after the
|
|
21
|
+
* owner agreed to it, and the owner never clicks anything in the console to
|
|
22
|
+
* agree: they say yes to a person — at the booth, on the phone, by text or by
|
|
23
|
+
* email — and STAFF record how and when. Saving the record emails the owner a
|
|
24
|
+
* confirmation, and that email is the written record.
|
|
25
|
+
*
|
|
26
|
+
* This module is the record's shape and its rules, with no Firestore and no
|
|
27
|
+
* product in it, so any staff surface that bills by an approval reads it the
|
|
28
|
+
* same way: Site Care's extra time first, and the flat-quoted project invoice
|
|
29
|
+
* (AGL-3970) after it. A correction never edits a record in place: it is a
|
|
30
|
+
* new record with `version` one higher, `corrected: true` and the reason, and
|
|
31
|
+
* the old one stays in the request's history.
|
|
32
|
+
*/
|
|
33
|
+
/** How the owner said yes. */
|
|
34
|
+
export declare const OWNER_APPROVAL_CHANNELS: readonly ["in-person", "phone", "text", "email"];
|
|
35
|
+
export type OwnerApprovalChannel = (typeof OWNER_APPROVAL_CHANNELS)[number];
|
|
36
|
+
/** The channel as a sentence reads it: "by phone", "in person". */
|
|
37
|
+
export declare const OWNER_APPROVAL_CHANNEL_WORDS: Readonly<Record<OwnerApprovalChannel, string>>;
|
|
38
|
+
/** The channel as a picker labels it. */
|
|
39
|
+
export declare const OWNER_APPROVAL_CHANNEL_LABELS: Readonly<Record<OwnerApprovalChannel, string>>;
|
|
40
|
+
/** The longest approval an hourly record may carry, in hours. */
|
|
41
|
+
export declare const OWNER_APPROVAL_MAX_HOURS = 40;
|
|
42
|
+
/** The longest note or reason a record keeps. */
|
|
43
|
+
export declare const OWNER_APPROVAL_NOTE_MAX = 500;
|
|
44
|
+
/** One recorded yes. Written by staff, read by the close and the emails. */
|
|
45
|
+
export interface OwnerApprovalRecord {
|
|
46
|
+
/** Whole hours the owner agreed to, at most. */
|
|
47
|
+
hours: number;
|
|
48
|
+
/** The published hourly rate the owner agreed to, in whole dollars. */
|
|
49
|
+
rateUsd: number;
|
|
50
|
+
channel: OwnerApprovalChannel;
|
|
51
|
+
/** When the owner said yes, epoch ms. */
|
|
52
|
+
approvedAtMs: number;
|
|
53
|
+
/** When staff recorded it, epoch ms. */
|
|
54
|
+
recordedAtMs: number;
|
|
55
|
+
recordedByUid: string;
|
|
56
|
+
recordedByEmail: string | null;
|
|
57
|
+
/** What the owner said yes to, in staff's words; optional. */
|
|
58
|
+
note: string | null;
|
|
59
|
+
/** 1 for the first record; each correction is one higher. */
|
|
60
|
+
version: number;
|
|
61
|
+
/** True on every record after the first. */
|
|
62
|
+
corrected: boolean;
|
|
63
|
+
/** Why it was corrected; required when `corrected`. */
|
|
64
|
+
correctionReason: string | null;
|
|
65
|
+
}
|
|
66
|
+
export type OwnerApprovalInputResult = {
|
|
67
|
+
ok: true;
|
|
68
|
+
record: OwnerApprovalRecord;
|
|
69
|
+
} | {
|
|
70
|
+
ok: false;
|
|
71
|
+
error: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Reads what staff typed into a record, refusing anything the record cannot
|
|
75
|
+
* honestly say. `previous` is the record it corrects, when there is one: a
|
|
76
|
+
* correction needs a reason, and the reason is what the history and the
|
|
77
|
+
* re-sent confirmation say changed.
|
|
78
|
+
*/
|
|
79
|
+
export declare function readOwnerApprovalInput(raw: Readonly<Record<string, unknown>> | null | undefined, context: {
|
|
80
|
+
rateUsd: number;
|
|
81
|
+
nowMs: number;
|
|
82
|
+
by: {
|
|
83
|
+
uid: string;
|
|
84
|
+
email: string | null;
|
|
85
|
+
};
|
|
86
|
+
previous?: OwnerApprovalRecord | null;
|
|
87
|
+
/**
|
|
88
|
+
* The most hours the record may carry; `OWNER_APPROVAL_MAX_HOURS` unless
|
|
89
|
+
* the surface says otherwise. A flat-quoted project (AGL-3970) records
|
|
90
|
+
* the quote's own whole hours, which a redesign can take past a week.
|
|
91
|
+
*/
|
|
92
|
+
maxHours?: number;
|
|
93
|
+
}): OwnerApprovalInputResult;
|
|
94
|
+
/** A stored record read back defensively, or null when it is not one. */
|
|
95
|
+
export declare function readOwnerApprovalRecord(value: unknown): OwnerApprovalRecord | null;
|
|
96
|
+
/** "2 hours", "1 hour". */
|
|
97
|
+
export declare function describeHours(hours: number): string;
|
|
98
|
+
/**
|
|
99
|
+
* The confirmation's one sentence, in the owner's words: what they agreed
|
|
100
|
+
* to, how and when.
|
|
101
|
+
*/
|
|
102
|
+
export declare function ownerApprovalSentence(record: Pick<OwnerApprovalRecord, 'hours' | 'rateUsd' | 'channel' | 'approvedAtMs'>, what: string, formatDate: (ms: number) => string): string;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* THE OWNER'S RECORDED YES (AGL-3959).
|
|
18
|
+
*
|
|
19
|
+
* Paid work beyond what a subscription includes is billed only after the
|
|
20
|
+
* owner agreed to it, and the owner never clicks anything in the console to
|
|
21
|
+
* agree: they say yes to a person — at the booth, on the phone, by text or by
|
|
22
|
+
* email — and STAFF record how and when. Saving the record emails the owner a
|
|
23
|
+
* confirmation, and that email is the written record.
|
|
24
|
+
*
|
|
25
|
+
* This module is the record's shape and its rules, with no Firestore and no
|
|
26
|
+
* product in it, so any staff surface that bills by an approval reads it the
|
|
27
|
+
* same way: Site Care's extra time first, and the flat-quoted project invoice
|
|
28
|
+
* (AGL-3970) after it. A correction never edits a record in place: it is a
|
|
29
|
+
* new record with `version` one higher, `corrected: true` and the reason, and
|
|
30
|
+
* the old one stays in the request's history.
|
|
31
|
+
*/ /** How the owner said yes. */ export const OWNER_APPROVAL_CHANNELS = [
|
|
32
|
+
'in-person',
|
|
33
|
+
'phone',
|
|
34
|
+
'text',
|
|
35
|
+
'email'
|
|
36
|
+
];
|
|
37
|
+
/** The channel as a sentence reads it: "by phone", "in person". */ export const OWNER_APPROVAL_CHANNEL_WORDS = {
|
|
38
|
+
'in-person': 'in person',
|
|
39
|
+
phone: 'by phone',
|
|
40
|
+
text: 'by text message',
|
|
41
|
+
email: 'by email'
|
|
42
|
+
};
|
|
43
|
+
/** The channel as a picker labels it. */ export const OWNER_APPROVAL_CHANNEL_LABELS = {
|
|
44
|
+
'in-person': 'In person',
|
|
45
|
+
phone: 'Phone call',
|
|
46
|
+
text: 'Text message',
|
|
47
|
+
email: 'Email'
|
|
48
|
+
};
|
|
49
|
+
/** The longest approval an hourly record may carry, in hours. */ export const OWNER_APPROVAL_MAX_HOURS = 40;
|
|
50
|
+
/** The longest note or reason a record keeps. */ export const OWNER_APPROVAL_NOTE_MAX = 500;
|
|
51
|
+
/** A trimmed, bounded string, or null when blank. */ function cleanText(value, max) {
|
|
52
|
+
const text = typeof value === 'string' ? value.trim().slice(0, max) : '';
|
|
53
|
+
return text ? text : null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads what staff typed into a record, refusing anything the record cannot
|
|
57
|
+
* honestly say. `previous` is the record it corrects, when there is one: a
|
|
58
|
+
* correction needs a reason, and the reason is what the history and the
|
|
59
|
+
* re-sent confirmation say changed.
|
|
60
|
+
*/ export function readOwnerApprovalInput(raw, context) {
|
|
61
|
+
var _context_maxHours, _ref, _context_previous;
|
|
62
|
+
const hours = Number(raw == null ? void 0 : raw['hours']);
|
|
63
|
+
const maxHours = (_context_maxHours = context.maxHours) != null ? _context_maxHours : OWNER_APPROVAL_MAX_HOURS;
|
|
64
|
+
if (!Number.isInteger(hours) || hours < 1 || hours > maxHours) {
|
|
65
|
+
return {
|
|
66
|
+
ok: false,
|
|
67
|
+
error: `Enter the hours the owner approved, a whole number from 1 to ${maxHours}.`
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const channel = String((_ref = raw == null ? void 0 : raw['channel']) != null ? _ref : '');
|
|
71
|
+
if (!OWNER_APPROVAL_CHANNELS.includes(channel)) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: 'Choose how the owner said yes.'
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const approvedAtMs = Number(raw == null ? void 0 : raw['approvedAtMs']);
|
|
78
|
+
if (!Number.isFinite(approvedAtMs) || approvedAtMs <= 0) {
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
error: 'Enter when the owner said yes.'
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// A minute of clock skew is allowed; a yes recorded for tomorrow is not one
|
|
85
|
+
// anybody has heard yet.
|
|
86
|
+
if (approvedAtMs > context.nowMs + 60000) {
|
|
87
|
+
return {
|
|
88
|
+
ok: false,
|
|
89
|
+
error: 'The owner’s yes cannot be in the future.'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const previous = (_context_previous = context.previous) != null ? _context_previous : null;
|
|
93
|
+
const correctionReason = cleanText(raw == null ? void 0 : raw['reason'], OWNER_APPROVAL_NOTE_MAX);
|
|
94
|
+
if (previous && !correctionReason) {
|
|
95
|
+
return {
|
|
96
|
+
ok: false,
|
|
97
|
+
error: 'Say why the approval is being corrected.'
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
ok: true,
|
|
102
|
+
record: {
|
|
103
|
+
hours,
|
|
104
|
+
rateUsd: context.rateUsd,
|
|
105
|
+
channel,
|
|
106
|
+
approvedAtMs: Math.floor(approvedAtMs),
|
|
107
|
+
recordedAtMs: context.nowMs,
|
|
108
|
+
recordedByUid: context.by.uid,
|
|
109
|
+
recordedByEmail: context.by.email,
|
|
110
|
+
note: cleanText(raw == null ? void 0 : raw['note'], OWNER_APPROVAL_NOTE_MAX),
|
|
111
|
+
version: previous ? Math.max(1, Number(previous.version) || 1) + 1 : 1,
|
|
112
|
+
corrected: Boolean(previous),
|
|
113
|
+
correctionReason: previous ? correctionReason : null
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** A stored record read back defensively, or null when it is not one. */ export function readOwnerApprovalRecord(value) {
|
|
118
|
+
var _record_recordedByUid, _record_recordedByEmail, _record_note, _record_correctionReason;
|
|
119
|
+
if (!value || typeof value !== 'object') return null;
|
|
120
|
+
const record = value;
|
|
121
|
+
const hours = Number(record.hours);
|
|
122
|
+
if (!Number.isInteger(hours) || hours < 1) return null;
|
|
123
|
+
if (!OWNER_APPROVAL_CHANNELS.includes(record.channel)) return null;
|
|
124
|
+
return {
|
|
125
|
+
hours,
|
|
126
|
+
rateUsd: Number(record.rateUsd) || 0,
|
|
127
|
+
channel: record.channel,
|
|
128
|
+
approvedAtMs: Number(record.approvedAtMs) || 0,
|
|
129
|
+
recordedAtMs: Number(record.recordedAtMs) || 0,
|
|
130
|
+
recordedByUid: String((_record_recordedByUid = record.recordedByUid) != null ? _record_recordedByUid : ''),
|
|
131
|
+
recordedByEmail: (_record_recordedByEmail = record.recordedByEmail) != null ? _record_recordedByEmail : null,
|
|
132
|
+
note: (_record_note = record.note) != null ? _record_note : null,
|
|
133
|
+
version: Number(record.version) || 1,
|
|
134
|
+
corrected: record.corrected === true,
|
|
135
|
+
correctionReason: (_record_correctionReason = record.correctionReason) != null ? _record_correctionReason : null
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** "2 hours", "1 hour". */ export function describeHours(hours) {
|
|
139
|
+
return `${hours} ${hours === 1 ? 'hour' : 'hours'}`;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The confirmation's one sentence, in the owner's words: what they agreed
|
|
143
|
+
* to, how and when.
|
|
144
|
+
*/ export function ownerApprovalSentence(record, what, formatDate) {
|
|
145
|
+
return `You approved up to ${describeHours(record.hours)} of extra time at ` + `$${record.rateUsd} an hour for “${what}”, ` + `${OWNER_APPROVAL_CHANNEL_WORDS[record.channel]} on ${formatDate(record.approvedAtMs)}.`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=owner-approval-record.js.map
|