@aglyn/aglyn 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/ai-credit-blocks.d.ts +124 -0
  3. package/src/lib/app-utils/ai-credit-blocks.js +122 -0
  4. package/src/lib/app-utils/ai-credit-blocks.js.map +1 -0
  5. package/src/lib/app-utils/bundle-intent.d.ts +17 -51
  6. package/src/lib/app-utils/bundle-intent.js +30 -74
  7. package/src/lib/app-utils/bundle-intent.js.map +1 -1
  8. package/src/lib/app-utils/contacts.d.ts +4 -1
  9. package/src/lib/app-utils/contacts.js.map +1 -1
  10. package/src/lib/app-utils/docs-help-sections.generated.js +3 -3
  11. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  12. package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
  13. package/src/lib/app-utils/docs-help.generated.js +1 -1
  14. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  15. package/src/lib/app-utils/docs-index.generated.js +97 -97
  16. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  17. package/src/lib/app-utils/error-beacon.d.ts +25 -1
  18. package/src/lib/app-utils/error-beacon.js +55 -4
  19. package/src/lib/app-utils/error-beacon.js.map +1 -1
  20. package/src/lib/app-utils/foreign-script.d.ts +1 -1
  21. package/src/lib/app-utils/foreign-script.js +1 -1
  22. package/src/lib/app-utils/foreign-script.js.map +1 -1
  23. package/src/lib/app-utils/margin-utilization.js +6 -5
  24. package/src/lib/app-utils/margin-utilization.js.map +1 -1
  25. package/src/lib/app-utils/onboarding-deep-link.d.ts +10 -11
  26. package/src/lib/app-utils/onboarding-deep-link.js +37 -32
  27. package/src/lib/app-utils/onboarding-deep-link.js.map +1 -1
  28. package/src/lib/app-utils/operator-alerts.js +17 -0
  29. package/src/lib/app-utils/operator-alerts.js.map +1 -1
  30. package/src/lib/app-utils/plan-entitlements.d.ts +142 -150
  31. package/src/lib/app-utils/plan-entitlements.js +202 -201
  32. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  33. package/src/lib/app-utils/release-flags.d.ts +6 -4
  34. package/src/lib/app-utils/release-flags.js +8 -9
  35. package/src/lib/app-utils/release-flags.js.map +1 -1
  36. package/src/lib/app-utils/server.d.ts +1 -0
  37. package/src/lib/app-utils/server.js +3 -0
  38. package/src/lib/app-utils/server.js.map +1 -1
  39. package/src/lib/app-utils/site-interactions.d.ts +1 -1
  40. package/src/lib/app-utils/site-interactions.js +2 -2
  41. package/src/lib/app-utils/site-interactions.js.map +1 -1
  42. package/src/lib/app-utils/transactional-email-ceiling.d.ts +119 -0
  43. package/src/lib/app-utils/transactional-email-ceiling.js +134 -0
  44. package/src/lib/app-utils/transactional-email-ceiling.js.map +1 -0
  45. package/src/lib/app-utils/upgrade-proposal.d.ts +17 -7
  46. package/src/lib/app-utils/upgrade-proposal.js +20 -13
  47. package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
  48. package/src/lib/foundation/definitions/org-billing.types.d.ts +4 -29
  49. package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
  50. package/src/lib/foundation/definitions/organization.types.d.ts +1 -3
  51. package/src/lib/foundation/definitions/organization.types.js.map +1 -1
  52. package/src/lib/foundation/index.d.ts +1 -1
  53. package/src/lib/foundation/index.js.map +1 -1
  54. package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +0 -6
  55. package/src/lib/plugin-manager/first-party-plugins.generated.js +9 -55
  56. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  57. package/src/lib/plugin-manager/plugin-usage-axes.d.ts +14 -0
  58. package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -1
  59. package/src/lib/plugin-manager/video-embed-provider.d.ts +29 -0
  60. package/src/lib/plugin-manager/video-embed-provider.js +26 -7
  61. package/src/lib/plugin-manager/video-embed-provider.js.map +1 -1
  62. package/src/lib/plugin-manager/video-embed-providers.generated.d.ts +11 -0
  63. package/src/lib/plugin-manager/video-embed-providers.generated.js +161 -0
  64. package/src/lib/plugin-manager/video-embed-providers.generated.js.map +1 -0
@@ -160,6 +160,20 @@ export interface PluginUsageBandDeclaration {
160
160
  outcome: 'stops' | 'bills' | 'continues';
161
161
  reached: string;
162
162
  approach: string;
163
+ /**
164
+ * The band's story on a plan that SELLS what is used past it: the
165
+ * `PlanPricing` rate that prices the excess (`pricedBy`, a key of the
166
+ * platform's price table, never a number), and the two sentences that
167
+ * say so. Where the org's plan carries that rate the alert's outcome is
168
+ * `bills` and these replace `reached` and `approach`; elsewhere the
169
+ * declaration above stands (pricing v4, AGL-4126: runs past the band
170
+ * bill on Pro and stop on Starter).
171
+ */
172
+ overage?: {
173
+ pricedBy: string;
174
+ reached: string;
175
+ approach: string;
176
+ };
163
177
  };
164
178
  /**
165
179
  * The console's quota banner WARNS an organization-wide reader on every
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-usage-axes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT A PLUGIN'S USAGE COSTS, AND HOW MUCH OF ITS BAND IT SPENT (AGL-3080).\n *\n * The platform keeps one cost model (`orgMonthlyCogsUsd`) and one\n * utilization table (`margin-utilization.ts`), and both read the monthly\n * usage rollup. Several of the rollup's meters are a plugin's: the AI\n * plugin's provider spend, the CRM's records, the forms plugin's\n * submissions, the workflows plugin's runs. Core used to name each of them —\n * its rollup field, the unit rate that prices it, the band it is measured\n * against — so a plugin that metered something new could not reach the\n * discount guardrail without a core edit, and core could not be taken\n * without the plugins it named.\n *\n * So a plugin declares its meters, and core composes them:\n *\n * - a COST AXIS names the rollup fields a meter is recorded under and the\n * `ORG_COGS_UNIT_RATES_USD` key that prices one unit, or no key when the\n * field is already dollars. `orgMonthlyCogsUsd` prices it beside core's\n * own axes, and `orgCogsInputFrom` forwards its fields.\n * - a BAND names the rollup fields that measure it and the entitlement that\n * says what the plan includes. The utilization table reads it beside\n * core's own bands. A METERED band is also billed past what the plan\n * includes, at its published billed rate (cost + 30% kept after card\n * fees), beside storage and bandwidth: the invoice sweep, the Billing\n * card's estimate, the monthly summary and the staff usage rows read it\n * from here.\n * - a SPEND LINE names the month document holding what the plugin's usage\n * came to at the rates it bills, the deployment variable naming the month\n * it is first charged for, and the unit a customer sees it in. The usage\n * budget shows it beside the metered figure and counts it once charged.\n * - a METER names what the plugin measures in the monthly usage sweep\n * (`plugin-usage-meters.ts`), so the sweep can refuse to bill a month the\n * registered meter is missing from.\n *\n * ## What core keeps\n *\n * The MONEY. Every unit rate stays in `ORG_COGS_UNIT_RATES_USD`, beside the\n * billed table it is reconciled against (`METERED_UNIT_RATES_USD`, which a\n * metered band names its rate in), and every included figure stays in\n * `PLAN_ENTITLEMENTS`. A declaration names fields and keys; it carries no\n * price. The one number a declaration may carry is a band's unit cost, where\n * the band is sold in a unit OF cost (a credit is a fixed quantity of\n * dollars), and that number is the plugin's own definition of its unit.\n *\n * ## Compiled, never registered\n *\n * The cost model's readers include the staff org page, which prices a rollup\n * in the browser, and the discount guardrail, whose every wrong answer is in\n * the approving direction: a cost axis a registry had not filled would price\n * at nothing and approve a discount the margin cannot carry. So these are\n * compiled from each plugin's `usage-axes` declaration by the manifest\n * generator, like the plan figures, and a rate key core does not have is an\n * error rather than a zero.\n */\n\nimport type { ReleaseFlagKey } from '../app-utils/release-flags'\nimport {\n PLUGIN_COST_AXES_DECLARED,\n PLUGIN_SPEND_LINES_DECLARED,\n PLUGIN_USAGE_BANDS_DECLARED,\n} from './first-party-plugins.generated'\n\n/** A meter a plugin contributes to the platform's cost model. */\nexport interface PluginCostAxisDeclaration {\n /** The breakdown key every staff reader shows it under. */\n id: string\n /** Where it sorts among the cost model's axes; core's own are multiples of 10. */\n order: number\n /** Rollup fields summed for the axis. */\n fields: readonly string[]\n /**\n * Read only when every one of `fields` is absent from a rollup — the\n * narrower field an older rollup recorded the same meter under.\n */\n fallbackFields?: readonly string[]\n /**\n * Rollup fields recorded beside the meter so its sum is legible, forwarded\n * by `orgCogsInputFrom` and never priced.\n */\n recordedFields?: readonly string[]\n /**\n * Rollup fields the plugin's usage sweep writes beside the meter for its\n * staff surfaces to read — served on the staff usage rows, `null` where a\n * rollup never wrote one, and never forwarded to the cost model.\n */\n staffFields?: readonly string[]\n /**\n * The `ORG_COGS_UNIT_RATES_USD` key pricing one unit. Absent when the\n * fields are already dollars, which then enter the model at ×1.\n */\n rate?: string\n /**\n * The month's LIVE reading, when the rollup's figure is a snapshot a meter\n * keeps adding to: `orgs/{orgId}/{collection}/{month}`, the first of\n * `fields` that is a positive number. It replaces the axis's first rollup\n * field wherever a reader fetches it.\n */\n live?: { collection: string; fields: readonly string[] }\n}\n\n/** A band a plugin contributes to the utilization table. */\nexport interface PluginUsageBandDeclaration {\n /** The band's key, and the column the staff table shows it under. */\n id: string\n label: string\n order: number\n /** Rollup fields summed for what the org used. */\n fields: readonly string[]\n fallbackFields?: readonly string[]\n /** The resolved entitlement holding what the plan includes. */\n entitlement: string\n /** The entitlement is per SITE and the org-wide band is it × `hostLimit`. */\n perHost?: boolean\n /**\n * The band is sold in a unit of cost and the rollup records dollars: what\n * was used is `ceil(dollars / unitCostUsd)`, rounded UP so spend already\n * made never reads as less of the band.\n */\n unitCostUsd?: number\n /**\n * The per-site monthly counter the band is measured by:\n * `hosts/{hostId}/counters/{hostCounter}`, field `{month}`, summed over the\n * workspace's sites.\n */\n hostCounter?: string\n /**\n * The WORKSPACE-wide monthly counter the band is enforced against:\n * `orgs/{orgId}/counters/{orgCounter}`, field `{month}` (AGL-3472). Declared\n * by a band whose runtime counts every unit on the org's counter as well as\n * on the site's, in one write, so a workspace-wide band is held to every\n * site's use rather than handed to each site whole. The Billing card meters\n * the band once for the organization from it, where a band without one is\n * metered per site. The usage sweep and alerts still sum `hostCounter`,\n * which the same write moves.\n */\n orgCounter?: string\n /**\n * The workspace is WARNED as it approaches and reaches this band, by the\n * usage-alerts sweep, from its `hostCounter` against what the plan includes\n * of `entitlement`, once per threshold per month. `label` names the band in\n * the title (\"monthly workflow runs\") and `noun` in the opening sentence\n * (\"workflow runs\"); `outcome` is what happens at the band — `stops`,\n * `bills` or `continues` — and `reached` and `approach` are the sentences\n * that say so, at the band and approaching it.\n */\n alert?: {\n label: string\n noun: string\n outcome: 'stops' | 'bills' | 'continues'\n reached: string\n approach: string\n }\n /**\n * The console's quota banner WARNS an organization-wide reader on every\n * console page as the workspace approaches and reaches this band\n * (AGL-2898, AGL-3080). `standing` is a console API path the plugin\n * serves, asked `?orgId=` with the reader's token, that answers the\n * band's standing in its own unit under `member` — `{ used, limit }`,\n * `limit: null` for a plan with no band, which is no row — and\n * `stopsAtBand`: whether reaching it stops the feature (the reading when\n * the route does not say) or bills past it. `approach` is the sentence\n * above 80%; `reached.stops` and `reached.bills` the two at the band.\n * `linksUsage` says the sentences name Billing → Usage, and the banner\n * offers the link.\n *\n * A route, not a counter: a band's meter may be one no client may read,\n * and the route answers in the unit the customer was sold.\n */\n consoleWarning?: {\n standing: string\n member: string\n approach: string\n reached: { stops: string; bills: string }\n linksUsage?: boolean\n }\n /**\n * The band is one of the INFRASTRUCTURE meters (AGL-1280): what the\n * workspace uses past it is billed at its published billed rate (cost +\n * 30% kept after card fees), beside storage and bandwidth, on the same\n * invoice line and the same estimate.\n * A metered band names one rollup field and the `hostCounter` it is\n * measured by.\n */\n metered?: PluginMeteredBand\n}\n\n/** How a metered band is priced, quoted and withheld. */\nexport interface PluginMeteredBand {\n /**\n * The `METERED_UNIT_RATES_USD` key holding our cost per unit — never a\n * number: the rate table is the platform's, beside the markup it is\n * published with.\n */\n rate: string\n /** The count a published price is quoted per: `1000` reads \"per 1,000\". */\n quotedPer: number\n /** The band in running prose, plural and lowercase: \"form submissions\". */\n noun: string\n /**\n * A release flag the overage waits behind: while it is off for the\n * workspace, the units are counted and the charge is recorded as withheld\n * rather than billed — nobody is charged for what they cannot reach\n * (AGL-1604). The rollup records the verdict as `{field}Billed` and what\n * was forgone, at cost, as `{field}OverageWithheldUsd`.\n */\n withheldUntil?: ReleaseFlagKey\n}\n\n/**\n * A line of a workspace's monthly SPEND a plugin contributes to its usage\n * budget (`usage-budget.ts`): what the plugin's usage came to this month, in\n * the dollars it is billed at, shown on the customer's budget card and\n * counted toward the budget from the month the plugin starts charging for it.\n */\nexport interface PluginSpendLineDeclaration {\n /** The line's key. */\n id: string\n /** What the budget card and the budget alert call it. */\n label: string\n /**\n * Where the month's figure is read: `orgs/{orgId}/{collection}/{month}`,\n * field `field`, in dollars.\n */\n live: { collection: string; field: string }\n /**\n * The deployment variable naming the first month (`YYYY-MM`) the line is\n * charged for. Until it names this month or an earlier one — and on any\n * value that is not a month — the line is shown and never counted.\n */\n billedFromEnv: string\n /**\n * The unit the customer is shown the line in, when the stored dollars are\n * not theirs to see: `ceil(dollars / costUsd)` of `label`, and the dollar\n * figure never crosses to the browser.\n */\n unit?: { costUsd: number; label: string }\n}\n\n/**\n * A meter the plugin measures in the platform's monthly usage sweep and\n * registers at runtime (`plugin-usage-meters.ts`). Declared as well as\n * registered so the sweep can refuse to bill a workspace's month without it.\n */\nexport interface PluginUsageMeterDeclaration {\n /** As `registerPluginUsageMeter` names it. */\n id: string\n}\n\nexport type ResolvedPluginCostAxis = PluginCostAxisDeclaration & { pluginId: string }\nexport type ResolvedPluginUsageBand = PluginUsageBandDeclaration & { pluginId: string }\nexport type ResolvedPluginSpendLine = PluginSpendLineDeclaration & { pluginId: string }\nexport type ResolvedPluginUsageMeter = PluginUsageMeterDeclaration & { pluginId: string }\n\n/** What a plugin's `usageAxes` function answers. */\nexport interface PluginUsageAxesDeclaration {\n costAxes?: readonly PluginCostAxisDeclaration[]\n bands?: readonly PluginUsageBandDeclaration[]\n spendLines?: readonly PluginSpendLineDeclaration[]\n meters?: readonly PluginUsageMeterDeclaration[]\n}\n\nexport function pluginCostAxes(): readonly ResolvedPluginCostAxis[] {\n return PLUGIN_COST_AXES_DECLARED\n}\n\nexport function pluginUsageBands(): readonly ResolvedPluginUsageBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED\n}\n\n/** A declared band that is metered, with its one field and its counter. */\nexport type ResolvedPluginMeteredBand = ResolvedPluginUsageBand & {\n metered: PluginMeteredBand\n hostCounter: string\n}\n\n/**\n * Every band billed at cost past what the plan includes, in band order — the\n * infrastructure meters a plugin adds beside storage and bandwidth.\n */\nexport function meteredPluginBands(): readonly ResolvedPluginMeteredBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED.filter(\n (band): band is ResolvedPluginMeteredBand =>\n Boolean(band.metered && band.hostCounter),\n )\n}\n\n/** A declared band measured by a per-site counter and never billed past it. */\nexport type ResolvedPluginCountedBand = ResolvedPluginUsageBand & {\n hostCounter: string\n}\n\n/**\n * Every band measured by a per-site counter and not metered, in band order:\n * the usage sweep sums each across the workspace's sites and records it under\n * the band's first field, and the staff usage rows show the count. A metered\n * band's counter is read with the infrastructure meters instead.\n */\nexport function countedPluginBands(): readonly ResolvedPluginCountedBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED.filter(\n (band): band is ResolvedPluginCountedBand =>\n Boolean(band.hostCounter && !band.metered),\n )\n}\n\n/** A declared band kept on a workspace-wide counter. */\nexport type ResolvedPluginOrgCountedBand = ResolvedPluginUsageBand & {\n orgCounter: string\n}\n\n/**\n * Every band with a workspace-wide counter (`orgCounter`), in band order: the\n * bands the Billing card meters once for the organization, from the counter\n * the band is enforced against.\n */\nexport function orgCountedPluginBands(): readonly ResolvedPluginOrgCountedBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED.filter(\n (band): band is ResolvedPluginOrgCountedBand => Boolean(band.orgCounter),\n )\n}\n\n/** The rollup field a metered band records its count under. */\nexport function meteredBandField(band: ResolvedPluginMeteredBand): string {\n return band.fields[0]!\n}\n\n/**\n * Where the rollup records a withheld band's verdict (`metered.withheldUntil`):\n * whether the month billed the band's overage, and what was forgone, at cost,\n * when it did not. Without the second a withheld month reads as a month that\n * stayed inside the band.\n */\nexport function meteredBandVerdictFields(band: ResolvedPluginMeteredBand): {\n billed: string\n withheldUsd: string\n} {\n const field = meteredBandField(band)\n return { billed: `${field}Billed`, withheldUsd: `${field}OverageWithheldUsd` }\n}\n\nexport function pluginSpendLines(): readonly ResolvedPluginSpendLine[] {\n return PLUGIN_SPEND_LINES_DECLARED\n}\n\n/** A positive finite number, or 0 — the reading every meter is priced from. */\nfunction meterValue(value: unknown): number {\n const parsed = Number(value ?? 0)\n return Number.isFinite(parsed) && parsed > 0 ? parsed : 0\n}\n\n/**\n * What a rollup recorded for a declared meter: `fields` summed, or\n * `fallbackFields` summed when the rollup carries none of `fields` at all.\n *\n * \"Carries none\" is `null` or absent, never zero. A rollup that measured\n * zero has answered, and must not fall back to a figure recorded under an\n * older, narrower basis.\n */\nexport function declaredMeterReading(\n source: Readonly<Record<string, unknown>> | null | undefined,\n declared: {\n fields: readonly string[]\n fallbackFields?: readonly string[]\n },\n): number {\n const present = declared.fields.some((field) => source?.[field] != null)\n const fields =\n !present && declared.fallbackFields?.length\n ? declared.fallbackFields\n : declared.fields\n return fields.reduce((sum, field) => sum + meterValue(source?.[field]), 0)\n}\n\n/**\n * The live reading a cost axis names: the first of its `live.fields` that is\n * a positive number on the month's document, or `undefined` when none is.\n * `undefined` is \"keep the rollup's snapshot\", never zero.\n */\nexport function liveMeterReading(\n document: { get(field: string): unknown } | null | undefined,\n live: { fields: readonly string[] },\n): number | undefined {\n for (const field of live.fields) {\n const value = meterValue(document?.get(field))\n if (value > 0) return value\n }\n return undefined\n}\n\n/** Every rollup field the declared cost axes read or record, in order. */\nexport function pluginCostAxisFields(): string[] {\n const fields: string[] = []\n for (const axis of PLUGIN_COST_AXES_DECLARED) {\n for (const field of [\n ...axis.fields,\n ...(axis.fallbackFields ?? []),\n ...(axis.recordedFields ?? []),\n ]) {\n if (!fields.includes(field)) fields.push(field)\n }\n }\n return fields\n}\n\n/**\n * A month's rollup as a staff reader is served it, one entry per field the\n * declared cost axes read, record or serve to staff (`get` reads one rollup\n * field).\n *\n * A field an axis prices reads zero where the rollup lacks it, as the cost\n * model reads it — except where the axis falls back to an older basis when\n * the rollup carries none of its fields: there absence is the answer that\n * selects the fallback, so it is served as `null`, and a reader pricing the\n * served row reads the month the way the sweep did. A field an axis only\n * records or serves reads `null` when the rollup never wrote it: \"not\n * recorded\" and \"recorded zero\" are different answers, and a projection\n * that collapses them invents history (AGL-2321).\n */\nexport function pluginCostAxisProjection(\n get: (field: string) => unknown,\n): Record<string, number | null> {\n const out: Record<string, number | null> = {}\n for (const axis of PLUGIN_COST_AXES_DECLARED) {\n const absentIsNull = [\n ...(axis.fallbackFields?.length ? axis.fields : []),\n ...(axis.recordedFields ?? []),\n ...(axis.staffFields ?? []),\n ]\n for (const field of [\n ...axis.fields,\n ...(axis.fallbackFields ?? []),\n ...(axis.recordedFields ?? []),\n ...(axis.staffFields ?? []),\n ]) {\n if (field in out) continue\n const value = get(field)\n out[field] =\n value != null ? Number(value) : absentIsNull.includes(field) ? null : 0\n }\n }\n return out\n}\n"],"names":["PLUGIN_COST_AXES_DECLARED","PLUGIN_SPEND_LINES_DECLARED","PLUGIN_USAGE_BANDS_DECLARED","pluginCostAxes","pluginUsageBands","meteredPluginBands","filter","band","Boolean","metered","hostCounter","countedPluginBands","orgCountedPluginBands","orgCounter","meteredBandField","fields","meteredBandVerdictFields","field","billed","withheldUsd","pluginSpendLines","meterValue","value","parsed","Number","isFinite","declaredMeterReading","source","declared","present","some","fallbackFields","length","reduce","sum","liveMeterReading","document","live","get","undefined","pluginCostAxisFields","axis","recordedFields","includes","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D,uBAAuB,EAAE;gBACzBA,oBAAAA,KAAKO,WAAW,YAAhBP,oBAAoB,EAAE;SAC3B;QACD,KAAK,MAAMxB,SAAS;eACfwB,KAAK1B,MAAM;gBACV0B,uBAAAA,KAAKV,cAAc,YAAnBU,uBAAuB,EAAE;gBACzBA,wBAAAA,KAAKC,cAAc,YAAnBD,wBAAuB,EAAE;gBACzBA,qBAAAA,KAAKO,WAAW,YAAhBP,qBAAoB,EAAE;SAC3B,CAAE;YACD,IAAIxB,SAAS6B,KAAK;YAClB,MAAMxB,QAAQgB,IAAIrB;YAClB6B,GAAG,CAAC7B,MAAM,GACRK,SAAS,OAAOE,OAAOF,SAASyB,aAAaJ,QAAQ,CAAC1B,SAAS,OAAO;QAC1E;IACF;IACA,OAAO6B;AACT"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-usage-axes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT A PLUGIN'S USAGE COSTS, AND HOW MUCH OF ITS BAND IT SPENT (AGL-3080).\n *\n * The platform keeps one cost model (`orgMonthlyCogsUsd`) and one\n * utilization table (`margin-utilization.ts`), and both read the monthly\n * usage rollup. Several of the rollup's meters are a plugin's: the AI\n * plugin's provider spend, the CRM's records, the forms plugin's\n * submissions, the workflows plugin's runs. Core used to name each of them —\n * its rollup field, the unit rate that prices it, the band it is measured\n * against — so a plugin that metered something new could not reach the\n * discount guardrail without a core edit, and core could not be taken\n * without the plugins it named.\n *\n * So a plugin declares its meters, and core composes them:\n *\n * - a COST AXIS names the rollup fields a meter is recorded under and the\n * `ORG_COGS_UNIT_RATES_USD` key that prices one unit, or no key when the\n * field is already dollars. `orgMonthlyCogsUsd` prices it beside core's\n * own axes, and `orgCogsInputFrom` forwards its fields.\n * - a BAND names the rollup fields that measure it and the entitlement that\n * says what the plan includes. The utilization table reads it beside\n * core's own bands. A METERED band is also billed past what the plan\n * includes, at its published billed rate (cost + 30% kept after card\n * fees), beside storage and bandwidth: the invoice sweep, the Billing\n * card's estimate, the monthly summary and the staff usage rows read it\n * from here.\n * - a SPEND LINE names the month document holding what the plugin's usage\n * came to at the rates it bills, the deployment variable naming the month\n * it is first charged for, and the unit a customer sees it in. The usage\n * budget shows it beside the metered figure and counts it once charged.\n * - a METER names what the plugin measures in the monthly usage sweep\n * (`plugin-usage-meters.ts`), so the sweep can refuse to bill a month the\n * registered meter is missing from.\n *\n * ## What core keeps\n *\n * The MONEY. Every unit rate stays in `ORG_COGS_UNIT_RATES_USD`, beside the\n * billed table it is reconciled against (`METERED_UNIT_RATES_USD`, which a\n * metered band names its rate in), and every included figure stays in\n * `PLAN_ENTITLEMENTS`. A declaration names fields and keys; it carries no\n * price. The one number a declaration may carry is a band's unit cost, where\n * the band is sold in a unit OF cost (a credit is a fixed quantity of\n * dollars), and that number is the plugin's own definition of its unit.\n *\n * ## Compiled, never registered\n *\n * The cost model's readers include the staff org page, which prices a rollup\n * in the browser, and the discount guardrail, whose every wrong answer is in\n * the approving direction: a cost axis a registry had not filled would price\n * at nothing and approve a discount the margin cannot carry. So these are\n * compiled from each plugin's `usage-axes` declaration by the manifest\n * generator, like the plan figures, and a rate key core does not have is an\n * error rather than a zero.\n */\n\nimport type { ReleaseFlagKey } from '../app-utils/release-flags'\nimport {\n PLUGIN_COST_AXES_DECLARED,\n PLUGIN_SPEND_LINES_DECLARED,\n PLUGIN_USAGE_BANDS_DECLARED,\n} from './first-party-plugins.generated'\n\n/** A meter a plugin contributes to the platform's cost model. */\nexport interface PluginCostAxisDeclaration {\n /** The breakdown key every staff reader shows it under. */\n id: string\n /** Where it sorts among the cost model's axes; core's own are multiples of 10. */\n order: number\n /** Rollup fields summed for the axis. */\n fields: readonly string[]\n /**\n * Read only when every one of `fields` is absent from a rollup — the\n * narrower field an older rollup recorded the same meter under.\n */\n fallbackFields?: readonly string[]\n /**\n * Rollup fields recorded beside the meter so its sum is legible, forwarded\n * by `orgCogsInputFrom` and never priced.\n */\n recordedFields?: readonly string[]\n /**\n * Rollup fields the plugin's usage sweep writes beside the meter for its\n * staff surfaces to read — served on the staff usage rows, `null` where a\n * rollup never wrote one, and never forwarded to the cost model.\n */\n staffFields?: readonly string[]\n /**\n * The `ORG_COGS_UNIT_RATES_USD` key pricing one unit. Absent when the\n * fields are already dollars, which then enter the model at ×1.\n */\n rate?: string\n /**\n * The month's LIVE reading, when the rollup's figure is a snapshot a meter\n * keeps adding to: `orgs/{orgId}/{collection}/{month}`, the first of\n * `fields` that is a positive number. It replaces the axis's first rollup\n * field wherever a reader fetches it.\n */\n live?: { collection: string; fields: readonly string[] }\n}\n\n/** A band a plugin contributes to the utilization table. */\nexport interface PluginUsageBandDeclaration {\n /** The band's key, and the column the staff table shows it under. */\n id: string\n label: string\n order: number\n /** Rollup fields summed for what the org used. */\n fields: readonly string[]\n fallbackFields?: readonly string[]\n /** The resolved entitlement holding what the plan includes. */\n entitlement: string\n /** The entitlement is per SITE and the org-wide band is it × `hostLimit`. */\n perHost?: boolean\n /**\n * The band is sold in a unit of cost and the rollup records dollars: what\n * was used is `ceil(dollars / unitCostUsd)`, rounded UP so spend already\n * made never reads as less of the band.\n */\n unitCostUsd?: number\n /**\n * The per-site monthly counter the band is measured by:\n * `hosts/{hostId}/counters/{hostCounter}`, field `{month}`, summed over the\n * workspace's sites.\n */\n hostCounter?: string\n /**\n * The WORKSPACE-wide monthly counter the band is enforced against:\n * `orgs/{orgId}/counters/{orgCounter}`, field `{month}` (AGL-3472). Declared\n * by a band whose runtime counts every unit on the org's counter as well as\n * on the site's, in one write, so a workspace-wide band is held to every\n * site's use rather than handed to each site whole. The Billing card meters\n * the band once for the organization from it, where a band without one is\n * metered per site. The usage sweep and alerts still sum `hostCounter`,\n * which the same write moves.\n */\n orgCounter?: string\n /**\n * The workspace is WARNED as it approaches and reaches this band, by the\n * usage-alerts sweep, from its `hostCounter` against what the plan includes\n * of `entitlement`, once per threshold per month. `label` names the band in\n * the title (\"monthly workflow runs\") and `noun` in the opening sentence\n * (\"workflow runs\"); `outcome` is what happens at the band — `stops`,\n * `bills` or `continues` — and `reached` and `approach` are the sentences\n * that say so, at the band and approaching it.\n */\n alert?: {\n label: string\n noun: string\n outcome: 'stops' | 'bills' | 'continues'\n reached: string\n approach: string\n /**\n * The band's story on a plan that SELLS what is used past it: the\n * `PlanPricing` rate that prices the excess (`pricedBy`, a key of the\n * platform's price table, never a number), and the two sentences that\n * say so. Where the org's plan carries that rate the alert's outcome is\n * `bills` and these replace `reached` and `approach`; elsewhere the\n * declaration above stands (pricing v4, AGL-4126: runs past the band\n * bill on Pro and stop on Starter).\n */\n overage?: {\n pricedBy: string\n reached: string\n approach: string\n }\n }\n /**\n * The console's quota banner WARNS an organization-wide reader on every\n * console page as the workspace approaches and reaches this band\n * (AGL-2898, AGL-3080). `standing` is a console API path the plugin\n * serves, asked `?orgId=` with the reader's token, that answers the\n * band's standing in its own unit under `member` — `{ used, limit }`,\n * `limit: null` for a plan with no band, which is no row — and\n * `stopsAtBand`: whether reaching it stops the feature (the reading when\n * the route does not say) or bills past it. `approach` is the sentence\n * above 80%; `reached.stops` and `reached.bills` the two at the band.\n * `linksUsage` says the sentences name Billing → Usage, and the banner\n * offers the link.\n *\n * A route, not a counter: a band's meter may be one no client may read,\n * and the route answers in the unit the customer was sold.\n */\n consoleWarning?: {\n standing: string\n member: string\n approach: string\n reached: { stops: string; bills: string }\n linksUsage?: boolean\n }\n /**\n * The band is one of the INFRASTRUCTURE meters (AGL-1280): what the\n * workspace uses past it is billed at its published billed rate (cost +\n * 30% kept after card fees), beside storage and bandwidth, on the same\n * invoice line and the same estimate.\n * A metered band names one rollup field and the `hostCounter` it is\n * measured by.\n */\n metered?: PluginMeteredBand\n}\n\n/** How a metered band is priced, quoted and withheld. */\nexport interface PluginMeteredBand {\n /**\n * The `METERED_UNIT_RATES_USD` key holding our cost per unit — never a\n * number: the rate table is the platform's, beside the markup it is\n * published with.\n */\n rate: string\n /** The count a published price is quoted per: `1000` reads \"per 1,000\". */\n quotedPer: number\n /** The band in running prose, plural and lowercase: \"form submissions\". */\n noun: string\n /**\n * A release flag the overage waits behind: while it is off for the\n * workspace, the units are counted and the charge is recorded as withheld\n * rather than billed — nobody is charged for what they cannot reach\n * (AGL-1604). The rollup records the verdict as `{field}Billed` and what\n * was forgone, at cost, as `{field}OverageWithheldUsd`.\n */\n withheldUntil?: ReleaseFlagKey\n}\n\n/**\n * A line of a workspace's monthly SPEND a plugin contributes to its usage\n * budget (`usage-budget.ts`): what the plugin's usage came to this month, in\n * the dollars it is billed at, shown on the customer's budget card and\n * counted toward the budget from the month the plugin starts charging for it.\n */\nexport interface PluginSpendLineDeclaration {\n /** The line's key. */\n id: string\n /** What the budget card and the budget alert call it. */\n label: string\n /**\n * Where the month's figure is read: `orgs/{orgId}/{collection}/{month}`,\n * field `field`, in dollars.\n */\n live: { collection: string; field: string }\n /**\n * The deployment variable naming the first month (`YYYY-MM`) the line is\n * charged for. Until it names this month or an earlier one — and on any\n * value that is not a month — the line is shown and never counted.\n */\n billedFromEnv: string\n /**\n * The unit the customer is shown the line in, when the stored dollars are\n * not theirs to see: `ceil(dollars / costUsd)` of `label`, and the dollar\n * figure never crosses to the browser.\n */\n unit?: { costUsd: number; label: string }\n}\n\n/**\n * A meter the plugin measures in the platform's monthly usage sweep and\n * registers at runtime (`plugin-usage-meters.ts`). Declared as well as\n * registered so the sweep can refuse to bill a workspace's month without it.\n */\nexport interface PluginUsageMeterDeclaration {\n /** As `registerPluginUsageMeter` names it. */\n id: string\n}\n\nexport type ResolvedPluginCostAxis = PluginCostAxisDeclaration & { pluginId: string }\nexport type ResolvedPluginUsageBand = PluginUsageBandDeclaration & { pluginId: string }\nexport type ResolvedPluginSpendLine = PluginSpendLineDeclaration & { pluginId: string }\nexport type ResolvedPluginUsageMeter = PluginUsageMeterDeclaration & { pluginId: string }\n\n/** What a plugin's `usageAxes` function answers. */\nexport interface PluginUsageAxesDeclaration {\n costAxes?: readonly PluginCostAxisDeclaration[]\n bands?: readonly PluginUsageBandDeclaration[]\n spendLines?: readonly PluginSpendLineDeclaration[]\n meters?: readonly PluginUsageMeterDeclaration[]\n}\n\nexport function pluginCostAxes(): readonly ResolvedPluginCostAxis[] {\n return PLUGIN_COST_AXES_DECLARED\n}\n\nexport function pluginUsageBands(): readonly ResolvedPluginUsageBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED\n}\n\n/** A declared band that is metered, with its one field and its counter. */\nexport type ResolvedPluginMeteredBand = ResolvedPluginUsageBand & {\n metered: PluginMeteredBand\n hostCounter: string\n}\n\n/**\n * Every band billed at cost past what the plan includes, in band order — the\n * infrastructure meters a plugin adds beside storage and bandwidth.\n */\nexport function meteredPluginBands(): readonly ResolvedPluginMeteredBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED.filter(\n (band): band is ResolvedPluginMeteredBand =>\n Boolean(band.metered && band.hostCounter),\n )\n}\n\n/** A declared band measured by a per-site counter and never billed past it. */\nexport type ResolvedPluginCountedBand = ResolvedPluginUsageBand & {\n hostCounter: string\n}\n\n/**\n * Every band measured by a per-site counter and not metered, in band order:\n * the usage sweep sums each across the workspace's sites and records it under\n * the band's first field, and the staff usage rows show the count. A metered\n * band's counter is read with the infrastructure meters instead.\n */\nexport function countedPluginBands(): readonly ResolvedPluginCountedBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED.filter(\n (band): band is ResolvedPluginCountedBand =>\n Boolean(band.hostCounter && !band.metered),\n )\n}\n\n/** A declared band kept on a workspace-wide counter. */\nexport type ResolvedPluginOrgCountedBand = ResolvedPluginUsageBand & {\n orgCounter: string\n}\n\n/**\n * Every band with a workspace-wide counter (`orgCounter`), in band order: the\n * bands the Billing card meters once for the organization, from the counter\n * the band is enforced against.\n */\nexport function orgCountedPluginBands(): readonly ResolvedPluginOrgCountedBand[] {\n return PLUGIN_USAGE_BANDS_DECLARED.filter(\n (band): band is ResolvedPluginOrgCountedBand => Boolean(band.orgCounter),\n )\n}\n\n/** The rollup field a metered band records its count under. */\nexport function meteredBandField(band: ResolvedPluginMeteredBand): string {\n return band.fields[0]!\n}\n\n/**\n * Where the rollup records a withheld band's verdict (`metered.withheldUntil`):\n * whether the month billed the band's overage, and what was forgone, at cost,\n * when it did not. Without the second a withheld month reads as a month that\n * stayed inside the band.\n */\nexport function meteredBandVerdictFields(band: ResolvedPluginMeteredBand): {\n billed: string\n withheldUsd: string\n} {\n const field = meteredBandField(band)\n return { billed: `${field}Billed`, withheldUsd: `${field}OverageWithheldUsd` }\n}\n\nexport function pluginSpendLines(): readonly ResolvedPluginSpendLine[] {\n return PLUGIN_SPEND_LINES_DECLARED\n}\n\n/** A positive finite number, or 0 — the reading every meter is priced from. */\nfunction meterValue(value: unknown): number {\n const parsed = Number(value ?? 0)\n return Number.isFinite(parsed) && parsed > 0 ? parsed : 0\n}\n\n/**\n * What a rollup recorded for a declared meter: `fields` summed, or\n * `fallbackFields` summed when the rollup carries none of `fields` at all.\n *\n * \"Carries none\" is `null` or absent, never zero. A rollup that measured\n * zero has answered, and must not fall back to a figure recorded under an\n * older, narrower basis.\n */\nexport function declaredMeterReading(\n source: Readonly<Record<string, unknown>> | null | undefined,\n declared: {\n fields: readonly string[]\n fallbackFields?: readonly string[]\n },\n): number {\n const present = declared.fields.some((field) => source?.[field] != null)\n const fields =\n !present && declared.fallbackFields?.length\n ? declared.fallbackFields\n : declared.fields\n return fields.reduce((sum, field) => sum + meterValue(source?.[field]), 0)\n}\n\n/**\n * The live reading a cost axis names: the first of its `live.fields` that is\n * a positive number on the month's document, or `undefined` when none is.\n * `undefined` is \"keep the rollup's snapshot\", never zero.\n */\nexport function liveMeterReading(\n document: { get(field: string): unknown } | null | undefined,\n live: { fields: readonly string[] },\n): number | undefined {\n for (const field of live.fields) {\n const value = meterValue(document?.get(field))\n if (value > 0) return value\n }\n return undefined\n}\n\n/** Every rollup field the declared cost axes read or record, in order. */\nexport function pluginCostAxisFields(): string[] {\n const fields: string[] = []\n for (const axis of PLUGIN_COST_AXES_DECLARED) {\n for (const field of [\n ...axis.fields,\n ...(axis.fallbackFields ?? []),\n ...(axis.recordedFields ?? []),\n ]) {\n if (!fields.includes(field)) fields.push(field)\n }\n }\n return fields\n}\n\n/**\n * A month's rollup as a staff reader is served it, one entry per field the\n * declared cost axes read, record or serve to staff (`get` reads one rollup\n * field).\n *\n * A field an axis prices reads zero where the rollup lacks it, as the cost\n * model reads it — except where the axis falls back to an older basis when\n * the rollup carries none of its fields: there absence is the answer that\n * selects the fallback, so it is served as `null`, and a reader pricing the\n * served row reads the month the way the sweep did. A field an axis only\n * records or serves reads `null` when the rollup never wrote it: \"not\n * recorded\" and \"recorded zero\" are different answers, and a projection\n * that collapses them invents history (AGL-2321).\n */\nexport function pluginCostAxisProjection(\n get: (field: string) => unknown,\n): Record<string, number | null> {\n const out: Record<string, number | null> = {}\n for (const axis of PLUGIN_COST_AXES_DECLARED) {\n const absentIsNull = [\n ...(axis.fallbackFields?.length ? axis.fields : []),\n ...(axis.recordedFields ?? []),\n ...(axis.staffFields ?? []),\n ]\n for (const field of [\n ...axis.fields,\n ...(axis.fallbackFields ?? []),\n ...(axis.recordedFields ?? []),\n ...(axis.staffFields ?? []),\n ]) {\n if (field in out) continue\n const value = get(field)\n out[field] =\n value != null ? Number(value) : absentIsNull.includes(field) ? null : 0\n }\n }\n return out\n}\n"],"names":["PLUGIN_COST_AXES_DECLARED","PLUGIN_SPEND_LINES_DECLARED","PLUGIN_USAGE_BANDS_DECLARED","pluginCostAxes","pluginUsageBands","meteredPluginBands","filter","band","Boolean","metered","hostCounter","countedPluginBands","orgCountedPluginBands","orgCounter","meteredBandField","fields","meteredBandVerdictFields","field","billed","withheldUsd","pluginSpendLines","meterValue","value","parsed","Number","isFinite","declaredMeterReading","source","declared","present","some","fallbackFields","length","reduce","sum","liveMeterReading","document","live","get","undefined","pluginCostAxisFields","axis","recordedFields","includes","push","pluginCostAxisProjection","out","absentIsNull","staffFields"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDC,GAGD,SACEA,yBAAyB,EACzBC,2BAA2B,EAC3BC,2BAA2B,QACtB,qCAAiC;AAuNxC,OAAO,SAASC;IACd,OAAOH;AACT;AAEA,OAAO,SAASI;IACd,OAAOF;AACT;AAQA;;;CAGC,GACD,OAAO,SAASG;IACd,OAAOH,4BAA4BI,MAAM,CACvC,CAACC,OACCC,QAAQD,KAAKE,OAAO,IAAIF,KAAKG,WAAW;AAE9C;AAOA;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAAOT,4BAA4BI,MAAM,CACvC,CAACC,OACCC,QAAQD,KAAKG,WAAW,IAAI,CAACH,KAAKE,OAAO;AAE/C;AAOA;;;;CAIC,GACD,OAAO,SAASG;IACd,OAAOV,4BAA4BI,MAAM,CACvC,CAACC,OAA+CC,QAAQD,KAAKM,UAAU;AAE3E;AAEA,6DAA6D,GAC7D,OAAO,SAASC,iBAAiBP,IAA+B;IAC9D,OAAOA,KAAKQ,MAAM,CAAC,EAAE;AACvB;AAEA;;;;;CAKC,GACD,OAAO,SAASC,yBAAyBT,IAA+B;IAItE,MAAMU,QAAQH,iBAAiBP;IAC/B,OAAO;QAAEW,QAAQ,GAAGD,MAAM,MAAM,CAAC;QAAEE,aAAa,GAAGF,MAAM,kBAAkB,CAAC;IAAC;AAC/E;AAEA,OAAO,SAASG;IACd,OAAOnB;AACT;AAEA,6EAA6E,GAC7E,SAASoB,WAAWC,KAAc;IAChC,MAAMC,SAASC,OAAOF,gBAAAA,QAA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mBAIAA,sBACAA,uBACAA;YARAA;QADN,MAAMM,eAAe;eACfN,EAAAA,wBAAAA,KAAKV,cAAc,qBAAnBU,sBAAqBT,MAAM,IAAGS,KAAK1B,MAAM,GAAG,EAAE;gBAC9C0B,uBAAAA,KAAKC,cAAc,YAAnBD,uBAAuB,EAAE;gBACzBA,oBAAAA,KAAKO,WAAW,YAAhBP,oBAAoB,EAAE;SAC3B;QACD,KAAK,MAAMxB,SAAS;eACfwB,KAAK1B,MAAM;gBACV0B,uBAAAA,KAAKV,cAAc,YAAnBU,uBAAuB,EAAE;gBACzBA,wBAAAA,KAAKC,cAAc,YAAnBD,wBAAuB,EAAE;gBACzBA,qBAAAA,KAAKO,WAAW,YAAhBP,qBAAoB,EAAE;SAC3B,CAAE;YACD,IAAIxB,SAAS6B,KAAK;YAClB,MAAMxB,QAAQgB,IAAIrB;YAClB6B,GAAG,CAAC7B,MAAM,GACRK,SAAS,OAAOE,OAAOF,SAASyB,aAAaJ,QAAQ,CAAC1B,SAAS,OAAO;QAC1E;IACF;IACA,OAAO6B;AACT"}
@@ -33,6 +33,11 @@ export type VideoEmbedPlayerOptions = Partial<Record<VideoEmbedPlayerOption, boo
33
33
  * One query parameter of a player address, in the order the declaration
34
34
  * lists them. Either `value`, sent on every address, or an `option` whose
35
35
  * state picks `on` or `off`; a state with no value leaves the parameter out.
36
+ *
37
+ * A value may name the media id as `{id}` (AGL-4140), for a player that
38
+ * repeats it in its query, such as one that loops a single film only as a
39
+ * playlist of itself. The id has passed both patterns by then, so it
40
+ * carries nothing a query could be widened with.
36
41
  */
37
42
  export type VideoEmbedPlayerParam = {
38
43
  param: string;
@@ -43,6 +48,28 @@ export type VideoEmbedPlayerParam = {
43
48
  on?: string;
44
49
  off?: string;
45
50
  };
51
+ /**
52
+ * A link shape {@link VideoEmbedProviderDeclaration.mediaIdPaths} cannot
53
+ * describe (AGL-4140): one that names its media id in the QUERY rather than
54
+ * the path (`/watch?v={id}`), or one only some of the host's domains use (a
55
+ * short-link domain whose whole path is the id, a shape that would misread a
56
+ * page on the host's main domain).
57
+ */
58
+ export interface VideoEmbedMediaIdLink {
59
+ /**
60
+ * A regular expression over the link's PATH, anchored at both ends. Without
61
+ * {@link param}, its first capture group is the media id.
62
+ */
63
+ path: string;
64
+ /** The query parameter that holds the media id, for a path that names none. */
65
+ param?: string;
66
+ /**
67
+ * The declared domains this shape is read on, each matched as
68
+ * {@link VideoEmbedProviderDeclaration.domains} are; every declared domain
69
+ * when absent.
70
+ */
71
+ domains?: readonly string[];
72
+ }
46
73
  export interface VideoEmbedProviderDeclaration {
47
74
  /** Stable id, unique across plugins. */
48
75
  id: string;
@@ -59,6 +86,8 @@ export interface VideoEmbedProviderDeclaration {
59
86
  * against {@link domains}.
60
87
  */
61
88
  mediaIdPaths: readonly string[];
89
+ /** The link shapes the paths cannot describe, tried after them. */
90
+ mediaIdLinks?: readonly VideoEmbedMediaIdLink[];
62
91
  /** A regular expression, anchored at both ends, a media id must match. */
63
92
  mediaIdPattern: string;
64
93
  /** The one origin the host's player is framed from. */
@@ -65,7 +65,7 @@
65
65
  * any other link is. Removing a declaration therefore turns its links back
66
66
  * into plain URLs, which play nothing — so the declaring plugin's spec holds
67
67
  * the declaration to the links it must keep reading.
68
- */ import { FIRST_PARTY_VIDEO_EMBED_PROVIDERS } from "./first-party-plugins.generated.js";
68
+ */ import { FIRST_PARTY_VIDEO_EMBED_PROVIDERS } from "./video-embed-providers.generated.js";
69
69
  export const VIDEO_EMBED_PLAYER_OPTIONS = [
70
70
  'autoPlay',
71
71
  'doNotTrack',
@@ -84,14 +84,27 @@ const compiled = new WeakMap();
84
84
  function compile(provider) {
85
85
  let answer = compiled.get(provider);
86
86
  if (!answer) {
87
+ var _provider_mediaIdLinks;
87
88
  answer = {
88
89
  paths: provider.mediaIdPaths.map((source)=>new RegExp(source)),
90
+ links: ((_provider_mediaIdLinks = provider.mediaIdLinks) != null ? _provider_mediaIdLinks : []).map((link)=>({
91
+ path: new RegExp(link.path),
92
+ param: link.param,
93
+ domains: link.domains
94
+ })),
89
95
  mediaId: new RegExp(provider.mediaIdPattern)
90
96
  };
91
97
  compiled.set(provider, answer);
92
98
  }
93
99
  return answer;
94
100
  }
101
+ /** The media id a link shape reads from this URL, unchecked. */ function linkMediaId(link, url) {
102
+ var _url_searchParams_get;
103
+ if (link.domains && !onDomain(url.hostname, link.domains)) return undefined;
104
+ const match = link.path.exec(url.pathname);
105
+ if (!match) return undefined;
106
+ return link.param ? (_url_searchParams_get = url.searchParams.get(link.param)) != null ? _url_searchParams_get : undefined : match[1];
107
+ }
95
108
  function onDomain(hostname, domains) {
96
109
  return domains.some((domain)=>hostname === domain || hostname.endsWith(`.${domain}`));
97
110
  }
@@ -110,10 +123,15 @@ function onDomain(hostname, domains) {
110
123
  if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined;
111
124
  for (const provider of providers){
112
125
  if (!onDomain(url.hostname, provider.domains)) continue;
113
- const { paths, mediaId } = compile(provider);
114
- for (const pattern of paths){
115
- var _pattern_exec;
116
- const id = (_pattern_exec = pattern.exec(url.pathname)) == null ? void 0 : _pattern_exec[1];
126
+ const { paths, links, mediaId } = compile(provider);
127
+ const candidates = [
128
+ ...paths.map((pattern)=>{
129
+ var _pattern_exec;
130
+ return (_pattern_exec = pattern.exec(url.pathname)) == null ? void 0 : _pattern_exec[1];
131
+ }),
132
+ ...links.map((link)=>linkMediaId(link, url))
133
+ ];
134
+ for (const id of candidates){
117
135
  if (id && mediaId.test(id) && SAFE_MEDIA_ID.test(id)) {
118
136
  return {
119
137
  provider,
@@ -138,14 +156,15 @@ function onDomain(hostname, domains) {
138
156
  const embed = videoEmbedOf(value, providers);
139
157
  if (!embed) return undefined;
140
158
  const params = new URLSearchParams();
159
+ const withId = (value)=>value.split(ID_PLACEHOLDER).join(embed.mediaId);
141
160
  for (const entry of (_embed_provider_playerQuery = embed.provider.playerQuery) != null ? _embed_provider_playerQuery : []){
142
161
  if ('value' in entry) {
143
- params.set(entry.param, entry.value);
162
+ params.set(entry.param, withId(entry.value));
144
163
  continue;
145
164
  }
146
165
  const on = entry.option === 'autoPlay' ? options.autoPlay !== false : Boolean(options[entry.option]);
147
166
  const sent = on ? entry.on : entry.off;
148
- if (sent !== undefined) params.set(entry.param, sent);
167
+ if (sent !== undefined) params.set(entry.param, withId(sent));
149
168
  }
150
169
  const query = params.toString();
151
170
  return query ? `${embed.embedUrl}?${query}` : embed.embedUrl;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/video-embed-provider.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A VIDEO HOST WHOSE OWN PLAYER A VIDEO PLAYS IN (AGL-3080).\n *\n * Some video hosts hand an author a link to a page, not to a file: the film\n * plays only inside the host's player, framed from the host's origin. The\n * Video element recognizes such a link, keeps only the media id it names,\n * and frames the host's player for it. Core never names a host. A plugin\n * DECLARES one — the domains its links live on, where in the path the media\n * id sits, the one origin its player is framed from, and the query that\n * player reads — and core's resolvers answer from the declarations alone.\n *\n * This sits beside `media-delivery-provider.ts` and is not that seam. A\n * delivery provider is where the platform serves ITS OWN copy of a file\n * from; an embed provider is a host whose player the author chose, which the\n * platform never serves a byte of.\n *\n * ## Only the media id survives\n *\n * The string an author pasted never reaches a frame. {@link videoEmbedOf}\n * reads the media id out of it, and every address below is rebuilt from the\n * declaration and that id alone, so a declared player is framed from its\n * declared origin and nowhere else. That closed set is what lets a published\n * page's `frame-src` name the origin for every site\n * ({@link videoEmbedPlayerOrigins}). The id must match the declaration's own\n * pattern AND {@link SAFE_MEDIA_ID}, so no declaration can widen the path it\n * is put into.\n *\n * ## Compiled, and deliberately without a runtime registrar\n *\n * The readers are the published page and its policy: the Video element that\n * plays the link, the `VideoObject` a crawler reads, the built-in entry page\n * that decides whether a featured film can play, and the tenant middleware\n * whose `frame-src` must admit the player. None of them loads a plugin's\n * console code, and the middleware loads no plugin at all. A registry one of\n * them had not filled would render a customer's link as a `<video>` pointed\n * at an HTML page, or refuse the frame, and nothing would go red — the\n * AGL-3025 shape, on the customer's own film. So a first-party plugin\n * declares its hosts under `videoEmbedProviders` in `plugins.config.json`,\n * `tools/scripts/generate-plugin-manifests.mjs` validates and compiles them,\n * and this module reads the compiled list.\n *\n * A marketplace plugin cannot add a host this way, and that is the point\n * rather than a gap: a declaration widens every published page's\n * `frame-src`, which is a platform decision, not one a plugin's own code\n * makes at runtime.\n *\n * ## What \"absent\" means\n *\n * A link no declaration recognizes is an ordinary URL, rendered exactly as\n * any other link is. Removing a declaration therefore turns its links back\n * into plain URLs, which play nothing — so the declaring plugin's spec holds\n * the declaration to the links it must keep reading.\n */\n\nimport { FIRST_PARTY_VIDEO_EMBED_PROVIDERS } from './first-party-plugins.generated'\n\n/**\n * A choice the Video element makes for each player it frames. A declaration\n * says how its player spells each one it supports; one it does not name is\n * never sent.\n *\n * - `autoPlay` — start as soon as the player is ready. ON unless the caller\n * passes exactly `false`: the usual frame is the one a visitor's press\n * loads, and a second play button inside it would ask them twice.\n * - `doNotTrack` — ask the host not to record the viewing session.\n * - `muted` — start without sound.\n * - `loop` — restart at the end.\n */\nexport type VideoEmbedPlayerOption = 'autoPlay' | 'doNotTrack' | 'muted' | 'loop'\n\nexport const VIDEO_EMBED_PLAYER_OPTIONS: readonly VideoEmbedPlayerOption[] = [\n 'autoPlay',\n 'doNotTrack',\n 'muted',\n 'loop',\n]\n\nexport type VideoEmbedPlayerOptions = Partial<\n Record<VideoEmbedPlayerOption, boolean>\n>\n\n/**\n * One query parameter of a player address, in the order the declaration\n * lists them. Either `value`, sent on every address, or an `option` whose\n * state picks `on` or `off`; a state with no value leaves the parameter out.\n */\nexport type VideoEmbedPlayerParam =\n | { param: string; value: string }\n | {\n param: string\n option: VideoEmbedPlayerOption\n on?: string\n off?: string\n }\n\nexport interface VideoEmbedProviderDeclaration {\n /** Stable id, unique across plugins. */\n id: string\n /** The host's name as an author knows it, for labels and help text. */\n label: string\n /**\n * The domains a link's host must equal or end in (after a dot). Exact or\n * dot-anchored only, so a domain that merely contains one is refused.\n */\n domains: readonly string[]\n /**\n * Regular expressions over a link's PATH, anchored at both ends, whose\n * first capture group is the media id. The host is checked separately,\n * against {@link domains}.\n */\n mediaIdPaths: readonly string[]\n /** A regular expression, anchored at both ends, a media id must match. */\n mediaIdPattern: string\n /** The one origin the host's player is framed from. */\n playerOrigin: string\n /** The player page's path on {@link playerOrigin}; `{id}` is the media id. */\n playerPath: string\n /** The query every player address carries, in this order. */\n playerQuery?: readonly VideoEmbedPlayerParam[]\n}\n\n/** A declaration, with the plugin that made it. */\nexport interface ResolvedVideoEmbedProvider\n extends VideoEmbedProviderDeclaration {\n pluginId: string\n}\n\n/** A link a declared host recognized. */\nexport interface VideoEmbed {\n provider: ResolvedVideoEmbedProvider\n /** The media id the link named, and nothing else of it. */\n mediaId: string\n /**\n * The player page with no per-visit options — what a `VideoObject`\n * publishes as `embedUrl`.\n */\n embedUrl: string\n}\n\n/**\n * The floor every media id stands on, whatever a declaration's own pattern\n * admits: no separator, dot, query or fragment can reach the player path.\n */\nconst SAFE_MEDIA_ID = /^[A-Za-z0-9_-]{1,64}$/\n\n/** The placeholder a `playerPath` names the media id with. */\nconst ID_PLACEHOLDER = '{id}'\n\n/** Every host a first-party plugin declares. */\nexport function videoEmbedProviders(): readonly ResolvedVideoEmbedProvider[] {\n return FIRST_PARTY_VIDEO_EMBED_PROVIDERS\n}\n\ninterface CompiledProvider {\n paths: RegExp[]\n mediaId: RegExp\n}\n\nconst compiled = new WeakMap<VideoEmbedProviderDeclaration, CompiledProvider>()\n\nfunction compile(provider: VideoEmbedProviderDeclaration): CompiledProvider {\n let answer = compiled.get(provider)\n if (!answer) {\n answer = {\n paths: provider.mediaIdPaths.map((source) => new RegExp(source)),\n mediaId: new RegExp(provider.mediaIdPattern),\n }\n compiled.set(provider, answer)\n }\n return answer\n}\n\nfunction onDomain(hostname: string, domains: readonly string[]): boolean {\n return domains.some(\n (domain) => hostname === domain || hostname.endsWith(`.${domain}`),\n )\n}\n\n/**\n * The declared host a link belongs to, with the media id it names, or\n * `undefined` for anything else: a value that is not an http(s) URL, a host\n * nothing declares, or a path that names no id the host's pattern accepts.\n */\nexport function videoEmbedOf(\n value: unknown,\n providers: readonly ResolvedVideoEmbedProvider[] = videoEmbedProviders(),\n): VideoEmbed | undefined {\n if (typeof value !== 'string' || !providers.length) return undefined\n let url: URL\n try {\n url = new URL(value.trim())\n } catch {\n return undefined\n }\n if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined\n for (const provider of providers) {\n if (!onDomain(url.hostname, provider.domains)) continue\n const { paths, mediaId } = compile(provider)\n for (const pattern of paths) {\n const id = pattern.exec(url.pathname)?.[1]\n if (id && mediaId.test(id) && SAFE_MEDIA_ID.test(id)) {\n return {\n provider,\n mediaId: id,\n embedUrl: `${provider.playerOrigin}${provider.playerPath.replace(ID_PLACEHOLDER, id)}`,\n }\n }\n }\n }\n return undefined\n}\n\n/** The player page for a declared host's link, with no per-visit options. */\nexport function videoEmbedUrl(\n value: unknown,\n providers?: readonly ResolvedVideoEmbedProvider[],\n): string | undefined {\n return videoEmbedOf(value, providers)?.embedUrl\n}\n\n/**\n * The address of a declared host's player frame for this visit, carrying the\n * declaration's query in its own order. See {@link VideoEmbedPlayerOption}\n * for what each option means and which way it defaults.\n */\nexport function videoEmbedPlayerSrc(\n value: unknown,\n options: VideoEmbedPlayerOptions = {},\n providers?: readonly ResolvedVideoEmbedProvider[],\n): string | undefined {\n const embed = videoEmbedOf(value, providers)\n if (!embed) return undefined\n const params = new URLSearchParams()\n for (const entry of embed.provider.playerQuery ?? []) {\n if ('value' in entry) {\n params.set(entry.param, entry.value)\n continue\n }\n const on =\n entry.option === 'autoPlay'\n ? options.autoPlay !== false\n : Boolean(options[entry.option])\n const sent = on ? entry.on : entry.off\n if (sent !== undefined) params.set(entry.param, sent)\n }\n const query = params.toString()\n return query ? `${embed.embedUrl}?${query}` : embed.embedUrl\n}\n\n/**\n * Every origin a declared player is framed from: what a published page's\n * `frame-src` admits for the Video element.\n */\nexport function videoEmbedPlayerOrigins(\n providers: readonly ResolvedVideoEmbedProvider[] = videoEmbedProviders(),\n): string[] {\n return [...new Set(providers.map((provider) => provider.playerOrigin))]\n}\n\n/** The declared hosts' names, as an author knows them. */\nexport function videoEmbedProviderLabels(\n providers: readonly ResolvedVideoEmbedProvider[] = videoEmbedProviders(),\n): string[] {\n return providers.map((provider) => provider.label)\n}\n"],"names":["FIRST_PARTY_VIDEO_EMBED_PROVIDERS","VIDEO_EMBED_PLAYER_OPTIONS","SAFE_MEDIA_ID","ID_PLACEHOLDER","videoEmbedProviders","compiled","WeakMap","compile","provider","answer","get","paths","mediaIdPaths","map","source","RegExp","mediaId","mediaIdPattern","set","onDomain","hostname","domains","some","domain","endsWith","videoEmbedOf","value","providers","length","undefined","url","URL","trim","protocol","pattern","id","exec","pathname","test","embedUrl","playerOrigin","playerPath","replace","videoEmbedUrl","videoEmbedPlayerSrc","options","embed","params","URLSearchParams","entry","playerQuery","param","on","option","autoPlay","Boolean","sent","off","query","toString","videoEmbedPlayerOrigins","Set","videoEmbedProviderLabels","label"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDC,GAED,SAASA,iCAAiC,QAAQ,qCAAiC;AAgBnF,OAAO,MAAMC,6BAAgE;IAC3E;IACA;IACA;IACA;CACD,CAAA;AAgED;;;CAGC,GACD,MAAMC,gBAAgB;AAEtB,4DAA4D,GA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,SAASsB,yBACdnC,YAAmDvB,qBAAqB;IAExE,OAAOuB,UAAUd,GAAG,CAAC,CAACL,WAAaA,SAASuD,KAAK;AACnD"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/video-embed-provider.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A VIDEO HOST WHOSE OWN PLAYER A VIDEO PLAYS IN (AGL-3080).\n *\n * Some video hosts hand an author a link to a page, not to a file: the film\n * plays only inside the host's player, framed from the host's origin. The\n * Video element recognizes such a link, keeps only the media id it names,\n * and frames the host's player for it. Core never names a host. A plugin\n * DECLARES one — the domains its links live on, where in the path the media\n * id sits, the one origin its player is framed from, and the query that\n * player reads — and core's resolvers answer from the declarations alone.\n *\n * This sits beside `media-delivery-provider.ts` and is not that seam. A\n * delivery provider is where the platform serves ITS OWN copy of a file\n * from; an embed provider is a host whose player the author chose, which the\n * platform never serves a byte of.\n *\n * ## Only the media id survives\n *\n * The string an author pasted never reaches a frame. {@link videoEmbedOf}\n * reads the media id out of it, and every address below is rebuilt from the\n * declaration and that id alone, so a declared player is framed from its\n * declared origin and nowhere else. That closed set is what lets a published\n * page's `frame-src` name the origin for every site\n * ({@link videoEmbedPlayerOrigins}). The id must match the declaration's own\n * pattern AND {@link SAFE_MEDIA_ID}, so no declaration can widen the path it\n * is put into.\n *\n * ## Compiled, and deliberately without a runtime registrar\n *\n * The readers are the published page and its policy: the Video element that\n * plays the link, the `VideoObject` a crawler reads, the built-in entry page\n * that decides whether a featured film can play, and the tenant middleware\n * whose `frame-src` must admit the player. None of them loads a plugin's\n * console code, and the middleware loads no plugin at all. A registry one of\n * them had not filled would render a customer's link as a `<video>` pointed\n * at an HTML page, or refuse the frame, and nothing would go red — the\n * AGL-3025 shape, on the customer's own film. So a first-party plugin\n * declares its hosts under `videoEmbedProviders` in `plugins.config.json`,\n * `tools/scripts/generate-plugin-manifests.mjs` validates and compiles them,\n * and this module reads the compiled list.\n *\n * A marketplace plugin cannot add a host this way, and that is the point\n * rather than a gap: a declaration widens every published page's\n * `frame-src`, which is a platform decision, not one a plugin's own code\n * makes at runtime.\n *\n * ## What \"absent\" means\n *\n * A link no declaration recognizes is an ordinary URL, rendered exactly as\n * any other link is. Removing a declaration therefore turns its links back\n * into plain URLs, which play nothing — so the declaring plugin's spec holds\n * the declaration to the links it must keep reading.\n */\n\nimport { FIRST_PARTY_VIDEO_EMBED_PROVIDERS } from './video-embed-providers.generated'\n\n/**\n * A choice the Video element makes for each player it frames. A declaration\n * says how its player spells each one it supports; one it does not name is\n * never sent.\n *\n * - `autoPlay` — start as soon as the player is ready. ON unless the caller\n * passes exactly `false`: the usual frame is the one a visitor's press\n * loads, and a second play button inside it would ask them twice.\n * - `doNotTrack` — ask the host not to record the viewing session.\n * - `muted` — start without sound.\n * - `loop` — restart at the end.\n */\nexport type VideoEmbedPlayerOption = 'autoPlay' | 'doNotTrack' | 'muted' | 'loop'\n\nexport const VIDEO_EMBED_PLAYER_OPTIONS: readonly VideoEmbedPlayerOption[] = [\n 'autoPlay',\n 'doNotTrack',\n 'muted',\n 'loop',\n]\n\nexport type VideoEmbedPlayerOptions = Partial<\n Record<VideoEmbedPlayerOption, boolean>\n>\n\n/**\n * One query parameter of a player address, in the order the declaration\n * lists them. Either `value`, sent on every address, or an `option` whose\n * state picks `on` or `off`; a state with no value leaves the parameter out.\n *\n * A value may name the media id as `{id}` (AGL-4140), for a player that\n * repeats it in its query, such as one that loops a single film only as a\n * playlist of itself. The id has passed both patterns by then, so it\n * carries nothing a query could be widened with.\n */\nexport type VideoEmbedPlayerParam =\n | { param: string; value: string }\n | {\n param: string\n option: VideoEmbedPlayerOption\n on?: string\n off?: string\n }\n\n/**\n * A link shape {@link VideoEmbedProviderDeclaration.mediaIdPaths} cannot\n * describe (AGL-4140): one that names its media id in the QUERY rather than\n * the path (`/watch?v={id}`), or one only some of the host's domains use (a\n * short-link domain whose whole path is the id, a shape that would misread a\n * page on the host's main domain).\n */\nexport interface VideoEmbedMediaIdLink {\n /**\n * A regular expression over the link's PATH, anchored at both ends. Without\n * {@link param}, its first capture group is the media id.\n */\n path: string\n /** The query parameter that holds the media id, for a path that names none. */\n param?: string\n /**\n * The declared domains this shape is read on, each matched as\n * {@link VideoEmbedProviderDeclaration.domains} are; every declared domain\n * when absent.\n */\n domains?: readonly string[]\n}\n\nexport interface VideoEmbedProviderDeclaration {\n /** Stable id, unique across plugins. */\n id: string\n /** The host's name as an author knows it, for labels and help text. */\n label: string\n /**\n * The domains a link's host must equal or end in (after a dot). Exact or\n * dot-anchored only, so a domain that merely contains one is refused.\n */\n domains: readonly string[]\n /**\n * Regular expressions over a link's PATH, anchored at both ends, whose\n * first capture group is the media id. The host is checked separately,\n * against {@link domains}.\n */\n mediaIdPaths: readonly string[]\n /** The link shapes the paths cannot describe, tried after them. */\n mediaIdLinks?: readonly VideoEmbedMediaIdLink[]\n /** A regular expression, anchored at both ends, a media id must match. */\n mediaIdPattern: string\n /** The one origin the host's player is framed from. */\n playerOrigin: string\n /** The player page's path on {@link playerOrigin}; `{id}` is the media id. */\n playerPath: string\n /** The query every player address carries, in this order. */\n playerQuery?: readonly VideoEmbedPlayerParam[]\n}\n\n/** A declaration, with the plugin that made it. */\nexport interface ResolvedVideoEmbedProvider\n extends VideoEmbedProviderDeclaration {\n pluginId: string\n}\n\n/** A link a declared host recognized. */\nexport interface VideoEmbed {\n provider: ResolvedVideoEmbedProvider\n /** The media id the link named, and nothing else of it. */\n mediaId: string\n /**\n * The player page with no per-visit options — what a `VideoObject`\n * publishes as `embedUrl`.\n */\n embedUrl: string\n}\n\n/**\n * The floor every media id stands on, whatever a declaration's own pattern\n * admits: no separator, dot, query or fragment can reach the player path.\n */\nconst SAFE_MEDIA_ID = /^[A-Za-z0-9_-]{1,64}$/\n\n/** The placeholder a `playerPath` names the media id with. */\nconst ID_PLACEHOLDER = '{id}'\n\n/** Every host a first-party plugin declares. */\nexport function videoEmbedProviders(): readonly ResolvedVideoEmbedProvider[] {\n return FIRST_PARTY_VIDEO_EMBED_PROVIDERS\n}\n\ninterface CompiledLink {\n path: RegExp\n param?: string\n domains?: readonly string[]\n}\n\ninterface CompiledProvider {\n paths: RegExp[]\n links: CompiledLink[]\n mediaId: RegExp\n}\n\nconst compiled = new WeakMap<VideoEmbedProviderDeclaration, CompiledProvider>()\n\nfunction compile(provider: VideoEmbedProviderDeclaration): CompiledProvider {\n let answer = compiled.get(provider)\n if (!answer) {\n answer = {\n paths: provider.mediaIdPaths.map((source) => new RegExp(source)),\n links: (provider.mediaIdLinks ?? []).map((link) => ({\n path: new RegExp(link.path),\n param: link.param,\n domains: link.domains,\n })),\n mediaId: new RegExp(provider.mediaIdPattern),\n }\n compiled.set(provider, answer)\n }\n return answer\n}\n\n/** The media id a link shape reads from this URL, unchecked. */\nfunction linkMediaId(link: CompiledLink, url: URL): string | undefined {\n if (link.domains && !onDomain(url.hostname, link.domains)) return undefined\n const match = link.path.exec(url.pathname)\n if (!match) return undefined\n return link.param ? (url.searchParams.get(link.param) ?? undefined) : match[1]\n}\n\nfunction onDomain(hostname: string, domains: readonly string[]): boolean {\n return domains.some(\n (domain) => hostname === domain || hostname.endsWith(`.${domain}`),\n )\n}\n\n/**\n * The declared host a link belongs to, with the media id it names, or\n * `undefined` for anything else: a value that is not an http(s) URL, a host\n * nothing declares, or a path that names no id the host's pattern accepts.\n */\nexport function videoEmbedOf(\n value: unknown,\n providers: readonly ResolvedVideoEmbedProvider[] = videoEmbedProviders(),\n): VideoEmbed | undefined {\n if (typeof value !== 'string' || !providers.length) return undefined\n let url: URL\n try {\n url = new URL(value.trim())\n } catch {\n return undefined\n }\n if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined\n for (const provider of providers) {\n if (!onDomain(url.hostname, provider.domains)) continue\n const { paths, links, mediaId } = compile(provider)\n const candidates = [\n ...paths.map((pattern) => pattern.exec(url.pathname)?.[1]),\n ...links.map((link) => linkMediaId(link, url)),\n ]\n for (const id of candidates) {\n if (id && mediaId.test(id) && SAFE_MEDIA_ID.test(id)) {\n return {\n provider,\n mediaId: id,\n embedUrl: `${provider.playerOrigin}${provider.playerPath.replace(ID_PLACEHOLDER, id)}`,\n }\n }\n }\n }\n return undefined\n}\n\n/** The player page for a declared host's link, with no per-visit options. */\nexport function videoEmbedUrl(\n value: unknown,\n providers?: readonly ResolvedVideoEmbedProvider[],\n): string | undefined {\n return videoEmbedOf(value, providers)?.embedUrl\n}\n\n/**\n * The address of a declared host's player frame for this visit, carrying the\n * declaration's query in its own order. See {@link VideoEmbedPlayerOption}\n * for what each option means and which way it defaults.\n */\nexport function videoEmbedPlayerSrc(\n value: unknown,\n options: VideoEmbedPlayerOptions = {},\n providers?: readonly ResolvedVideoEmbedProvider[],\n): string | undefined {\n const embed = videoEmbedOf(value, providers)\n if (!embed) return undefined\n const params = new URLSearchParams()\n const withId = (value: string) =>\n value.split(ID_PLACEHOLDER).join(embed.mediaId)\n for (const entry of embed.provider.playerQuery ?? []) {\n if ('value' in entry) {\n params.set(entry.param, withId(entry.value))\n continue\n }\n const on =\n entry.option === 'autoPlay'\n ? options.autoPlay !== false\n : Boolean(options[entry.option])\n const sent = on ? entry.on : entry.off\n if (sent !== undefined) params.set(entry.param, withId(sent))\n }\n const query = params.toString()\n return query ? `${embed.embedUrl}?${query}` : embed.embedUrl\n}\n\n/**\n * Every origin a declared player is framed from: what a published page's\n * `frame-src` admits for the Video element.\n */\nexport function videoEmbedPlayerOrigins(\n providers: readonly ResolvedVideoEmbedProvider[] = videoEmbedProviders(),\n): string[] {\n return [...new Set(providers.map((provider) => provider.playerOrigin))]\n}\n\n/** The declared hosts' names, as an author knows them. */\nexport function videoEmbedProviderLabels(\n providers: readonly ResolvedVideoEmbedProvider[] = videoEmbedProviders(),\n): string[] {\n return providers.map((provider) => provider.label)\n}\n"],"names":["FIRST_PARTY_VIDEO_EMBED_PROVIDERS","VIDEO_EMBED_PLAYER_OPTIONS","SAFE_MEDIA_ID","ID_PLACEHOLDER","videoEmbedProviders","compiled","WeakMap","compile","provider","answer","get","paths","mediaIdPaths","map","source","RegExp","links","mediaIdLinks","link","path","param","domains","mediaId","mediaIdPattern","set","linkMediaId","url","onDomain","hostname","undefined","match","exec","pathname","searchParams","some","domain","endsWith","videoEmbedOf","value","providers","length","URL","trim","protocol","candidates","pattern","id","test","embedUrl","playerOrigin","playerPath","replace","videoEmbedUrl","videoEmbedPlayerSrc","options","embed","params","URLSearchParams","withId","split","join","entry","playerQuery","on","option","autoPlay","Boolean","sent","off","query","toString","videoEmbedPlayerOrigins","Set","videoEmbedProviderLabels","label"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDC,GAED,SAASA,iCAAiC,QAAQ,uCAAmC;AAgBrF,OAAO,MAAMC,6BAAgE;IAC3E;IACA;IACA;IACA;CACD,CAAA;AA8FD;;;CAGC,GACD,MAAMC,gBAAgB;AAEtB,4DAA4D,GAC5D,MAAMC,iBAAiB;AAEvB,8CAA8C,GAC9C,OAAO,SAASC;IACd,OAAOJ;AACT;AAcA,MAAMK,WAAW,IAAIC;AAErB,SAASC,QAAQC,QAAuC;IACtD,IAAIC,SAASJ,SAASK,GAAG,CAACF;IAC1B,IAAI,CAACC,QAAQ;YAGDD;QAFVC,SAAS;YACPE,OAAOH,SAASI,YAAY,CAACC,GAAG,CAAC,CAACC,SAAW,IAAIC,OAAOD;YACxDE,OAAO,EAACR,yBAAAA,SAASS,YAAY,YAArBT,yBAAyB,EAAE,EA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,QACrBC,QAAQZ,OAAO,CAACO,MAAMG,MAAM,CAAC;QACnC,MAAMG,OAAOJ,KAAKF,MAAME,EAAE,GAAGF,MAAMO,GAAG;QACtC,IAAID,SAAStC,WAAW2B,OAAOhC,GAAG,CAACqC,MAAMzC,KAAK,EAAEsC,OAAOS;IACzD;IACA,MAAME,QAAQb,OAAOc,QAAQ;IAC7B,OAAOD,QAAQ,GAAGd,MAAMP,QAAQ,CAAC,CAAC,EAAEqB,OAAO,GAAGd,MAAMP,QAAQ;AAC9D;AAEA;;;CAGC,GACD,OAAO,SAASuB,wBACdhC,YAAmDnC,qBAAqB;IAExE,OAAO;WAAI,IAAIoE,IAAIjC,UAAU1B,GAAG,CAAC,CAACL,WAAaA,SAASyC,YAAY;KAAG;AACzE;AAEA,wDAAwD,GACxD,OAAO,SAASwB,yBACdlC,YAAmDnC,qBAAqB;IAExE,OAAOmC,UAAU1B,GAAG,CAAC,CAACL,WAAaA,SAASkE,KAAK;AACnD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * GENERATED FILE — do not edit. Regenerate with:
3
+ * node tools/scripts/generate-plugin-manifests.mjs
4
+ *
5
+ * Every video host whose own player the Video element frames, declared by
6
+ * the plugin that plays it (AGL-3080). Core names no host. Its own file,
7
+ * not the catalog's, so a published page with no video downloads none of
8
+ * it (AGL-4140).
9
+ */
10
+ import type { ResolvedVideoEmbedProvider } from './video-embed-provider';
11
+ export declare const FIRST_PARTY_VIDEO_EMBED_PROVIDERS: readonly ResolvedVideoEmbedProvider[];
@@ -0,0 +1,161 @@
1
+ /**
2
+ * GENERATED FILE — do not edit. Regenerate with:
3
+ * node tools/scripts/generate-plugin-manifests.mjs
4
+ *
5
+ * Every video host whose own player the Video element frames, declared by
6
+ * the plugin that plays it (AGL-3080). Core names no host. Its own file,
7
+ * not the catalog's, so a published page with no video downloads none of
8
+ * it (AGL-4140).
9
+ */ export const FIRST_PARTY_VIDEO_EMBED_PROVIDERS = [
10
+ {
11
+ "pluginId": "mui",
12
+ "id": "vimeo",
13
+ "label": "Vimeo",
14
+ "domains": [
15
+ "vimeo.com"
16
+ ],
17
+ "mediaIdPaths": [
18
+ "^\\/([0-9]+)\\/?$",
19
+ "^\\/video\\/([0-9]+)\\/?$",
20
+ "^\\/channels\\/[^/]+\\/([0-9]+)\\/?$",
21
+ "^\\/groups\\/[^/]+\\/videos\\/([0-9]+)\\/?$",
22
+ "^\\/showcase\\/[^/]+\\/video\\/([0-9]+)\\/?$",
23
+ "^\\/album\\/[^/]+\\/video\\/([0-9]+)\\/?$",
24
+ "^\\/manage\\/videos\\/([0-9]+)\\/?$"
25
+ ],
26
+ "mediaIdPattern": "^[0-9]{6,12}$",
27
+ "playerOrigin": "https://player.vimeo.com",
28
+ "playerPath": "/video/{id}",
29
+ "playerQuery": [
30
+ {
31
+ "param": "autoplay",
32
+ "option": "autoPlay",
33
+ "on": "1",
34
+ "off": "0"
35
+ },
36
+ {
37
+ "param": "dnt",
38
+ "value": "1"
39
+ },
40
+ {
41
+ "param": "muted",
42
+ "option": "muted",
43
+ "on": "1"
44
+ },
45
+ {
46
+ "param": "loop",
47
+ "option": "loop",
48
+ "on": "1"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "pluginId": "mui",
54
+ "id": "wistia",
55
+ "label": "Wistia",
56
+ "domains": [
57
+ "wistia.com",
58
+ "wistia.net",
59
+ "wi.st"
60
+ ],
61
+ "mediaIdPaths": [
62
+ "^\\/medias\\/([^/]+)(?:\\/manage)?\\/?$",
63
+ "^\\/m\\/([^/]+)\\/?$",
64
+ "^\\/embed\\/iframe\\/([^/]+)\\/?$",
65
+ "^\\/embed\\/medias\\/([^/.]+)(?:\\.jsonp?)?\\/?$"
66
+ ],
67
+ "mediaIdPattern": "^[a-z0-9]{10}$",
68
+ "playerOrigin": "https://fast.wistia.net",
69
+ "playerPath": "/embed/iframe/{id}",
70
+ "playerQuery": [
71
+ {
72
+ "param": "autoPlay",
73
+ "option": "autoPlay",
74
+ "on": "true",
75
+ "off": "false"
76
+ },
77
+ {
78
+ "param": "roundedPlayer",
79
+ "value": "false"
80
+ },
81
+ {
82
+ "param": "doNotTrack",
83
+ "option": "doNotTrack",
84
+ "on": "true"
85
+ },
86
+ {
87
+ "param": "muted",
88
+ "option": "muted",
89
+ "on": "true"
90
+ },
91
+ {
92
+ "param": "endVideoBehavior",
93
+ "option": "loop",
94
+ "on": "loop"
95
+ }
96
+ ]
97
+ },
98
+ {
99
+ "pluginId": "mui",
100
+ "id": "youtube",
101
+ "label": "YouTube",
102
+ "domains": [
103
+ "youtube.com",
104
+ "youtube-nocookie.com",
105
+ "youtu.be"
106
+ ],
107
+ "mediaIdPaths": [
108
+ "^\\/embed\\/([^/]+)\\/?$",
109
+ "^\\/shorts\\/([^/]+)\\/?$",
110
+ "^\\/live\\/([^/]+)\\/?$",
111
+ "^\\/v\\/([^/]+)\\/?$"
112
+ ],
113
+ "mediaIdLinks": [
114
+ {
115
+ "path": "^\\/watch\\/?$",
116
+ "param": "v",
117
+ "domains": [
118
+ "youtube.com"
119
+ ]
120
+ },
121
+ {
122
+ "path": "^\\/([^/]+)\\/?$",
123
+ "domains": [
124
+ "youtu.be"
125
+ ]
126
+ }
127
+ ],
128
+ "mediaIdPattern": "^(?!videoseries$)[A-Za-z0-9_-]{11}$",
129
+ "playerOrigin": "https://www.youtube-nocookie.com",
130
+ "playerPath": "/embed/{id}",
131
+ "playerQuery": [
132
+ {
133
+ "param": "autoplay",
134
+ "option": "autoPlay",
135
+ "on": "1",
136
+ "off": "0"
137
+ },
138
+ {
139
+ "param": "playsinline",
140
+ "value": "1"
141
+ },
142
+ {
143
+ "param": "mute",
144
+ "option": "muted",
145
+ "on": "1"
146
+ },
147
+ {
148
+ "param": "loop",
149
+ "option": "loop",
150
+ "on": "1"
151
+ },
152
+ {
153
+ "param": "playlist",
154
+ "option": "loop",
155
+ "on": "{id}"
156
+ }
157
+ ]
158
+ }
159
+ ];
160
+
161
+ //# sourceMappingURL=video-embed-providers.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/video-embed-providers.generated.ts"],"sourcesContent":["/**\n * GENERATED FILE — do not edit. Regenerate with:\n * node tools/scripts/generate-plugin-manifests.mjs\n *\n * Every video host whose own player the Video element frames, declared by\n * the plugin that plays it (AGL-3080). Core names no host. Its own file,\n * not the catalog's, so a published page with no video downloads none of\n * it (AGL-4140).\n */\n\nimport type { ResolvedVideoEmbedProvider } from './video-embed-provider'\n\nexport const FIRST_PARTY_VIDEO_EMBED_PROVIDERS: readonly ResolvedVideoEmbedProvider[] = [\n {\n \"pluginId\": \"mui\",\n \"id\": \"vimeo\",\n \"label\": \"Vimeo\",\n \"domains\": [\n \"vimeo.com\"\n ],\n \"mediaIdPaths\": [\n \"^\\\\/([0-9]+)\\\\/?$\",\n \"^\\\\/video\\\\/([0-9]+)\\\\/?$\",\n \"^\\\\/channels\\\\/[^/]+\\\\/([0-9]+)\\\\/?$\",\n \"^\\\\/groups\\\\/[^/]+\\\\/videos\\\\/([0-9]+)\\\\/?$\",\n \"^\\\\/showcase\\\\/[^/]+\\\\/video\\\\/([0-9]+)\\\\/?$\",\n \"^\\\\/album\\\\/[^/]+\\\\/video\\\\/([0-9]+)\\\\/?$\",\n \"^\\\\/manage\\\\/videos\\\\/([0-9]+)\\\\/?$\"\n ],\n \"mediaIdPattern\": \"^[0-9]{6,12}$\",\n \"playerOrigin\": \"https://player.vimeo.com\",\n \"playerPath\": \"/video/{id}\",\n \"playerQuery\": [\n {\n \"param\": \"autoplay\",\n \"option\": \"autoPlay\",\n \"on\": \"1\",\n \"off\": \"0\"\n },\n {\n \"param\": \"dnt\",\n \"value\": \"1\"\n },\n {\n \"param\": \"muted\",\n \"option\": \"muted\",\n \"on\": \"1\"\n },\n {\n \"param\": \"loop\",\n \"option\": \"loop\",\n \"on\": \"1\"\n }\n ]\n },\n {\n \"pluginId\": \"mui\",\n \"id\": \"wistia\",\n \"label\": \"Wistia\",\n \"domains\": [\n \"wistia.com\",\n \"wistia.net\",\n \"wi.st\"\n ],\n \"mediaIdPaths\": [\n \"^\\\\/medias\\\\/([^/]+)(?:\\\\/manage)?\\\\/?$\",\n \"^\\\\/m\\\\/([^/]+)\\\\/?$\",\n \"^\\\\/embed\\\\/iframe\\\\/([^/]+)\\\\/?$\",\n \"^\\\\/embed\\\\/medias\\\\/([^/.]+)(?:\\\\.jsonp?)?\\\\/?$\"\n ],\n \"mediaIdPattern\": \"^[a-z0-9]{10}$\",\n \"playerOrigin\": \"https://fast.wistia.net\",\n \"playerPath\": \"/embed/iframe/{id}\",\n \"playerQuery\": [\n {\n \"param\": \"autoPlay\",\n \"option\": \"autoPlay\",\n \"on\": \"true\",\n \"off\": \"false\"\n },\n {\n \"param\": \"roundedPlayer\",\n \"value\": \"false\"\n },\n {\n \"param\": \"doNotTrack\",\n \"option\": \"doNotTrack\",\n \"on\": \"true\"\n },\n {\n \"param\": \"muted\",\n \"option\": \"muted\",\n \"on\": \"true\"\n },\n {\n \"param\": \"endVideoBehavior\",\n \"option\": \"loop\",\n \"on\": \"loop\"\n }\n ]\n },\n {\n \"pluginId\": \"mui\",\n \"id\": \"youtube\",\n \"label\": \"YouTube\",\n \"domains\": [\n \"youtube.com\",\n \"youtube-nocookie.com\",\n \"youtu.be\"\n ],\n \"mediaIdPaths\": [\n \"^\\\\/embed\\\\/([^/]+)\\\\/?$\",\n \"^\\\\/shorts\\\\/([^/]+)\\\\/?$\",\n \"^\\\\/live\\\\/([^/]+)\\\\/?$\",\n \"^\\\\/v\\\\/([^/]+)\\\\/?$\"\n ],\n \"mediaIdLinks\": [\n {\n \"path\": \"^\\\\/watch\\\\/?$\",\n \"param\": \"v\",\n \"domains\": [\n \"youtube.com\"\n ]\n },\n {\n \"path\": \"^\\\\/([^/]+)\\\\/?$\",\n \"domains\": [\n \"youtu.be\"\n ]\n }\n ],\n \"mediaIdPattern\": \"^(?!videoseries$)[A-Za-z0-9_-]{11}$\",\n \"playerOrigin\": \"https://www.youtube-nocookie.com\",\n \"playerPath\": \"/embed/{id}\",\n \"playerQuery\": [\n {\n \"param\": \"autoplay\",\n \"option\": \"autoPlay\",\n \"on\": \"1\",\n \"off\": \"0\"\n },\n {\n \"param\": \"playsinline\",\n \"value\": \"1\"\n },\n {\n \"param\": \"mute\",\n \"option\": \"muted\",\n \"on\": \"1\"\n },\n {\n \"param\": \"loop\",\n \"option\": \"loop\",\n \"on\": \"1\"\n },\n {\n \"param\": \"playlist\",\n \"option\": \"loop\",\n \"on\": \"{id}\"\n }\n ]\n },\n]\n"],"names":["FIRST_PARTY_VIDEO_EMBED_PROVIDERS"],"mappings":"AAAA;;;;;;;;CAQC,GAID,OAAO,MAAMA,oCAA2E;IACtF;QACE,YAAY;QACZ,MAAM;QACN,SAAS;QACT,WAAW;YACT;SACD;QACD,gBAAgB;YACd;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACD,kBAAkB;QAClB,gBAAgB;QAChB,cAAc;QACd,eAAe;YACb;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;gBACN,OAAO;YACT;YACA;gBACE,SAAS;gBACT,SAAS;YACX;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;SACD;IACH;IACA;QACE,YAAY;QACZ,MAAM;QACN,SAAS;QACT,WAAW;YACT;YACA;YACA;SACD;QACD,gBAAgB;YACd;YACA;YACA;YACA;SACD;QACD,kBAAkB;QAClB,gBAAgB;QAChB,cAAc;QACd,eAAe;YACb;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;gBACN,OAAO;YACT;YACA;gBACE,SAAS;gBACT,SAAS;YACX;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;SACD;IACH;IACA;QACE,YAAY;QACZ,MAAM;QACN,SAAS;QACT,WAAW;YACT;YACA;YACA;SACD;QACD,gBAAgB;YACd;YACA;YACA;YACA;SACD;QACD,gBAAgB;YACd;gBACE,QAAQ;gBACR,SAAS;gBACT,WAAW;oBACT;iBACD;YACH;YACA;gBACE,QAAQ;gBACR,WAAW;oBACT;iBACD;YACH;SACD;QACD,kBAAkB;QAClB,gBAAgB;QAChB,cAAc;QACd,eAAe;YACb;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;gBACN,OAAO;YACT;YACA;gBACE,SAAS;gBACT,SAAS;YACX;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;YACA;gBACE,SAAS;gBACT,UAAU;gBACV,MAAM;YACR;SACD;IACH;CACD,CAAA"}