@aglyn/aglyn 1.17.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/lib/app-utils/compose-reusable-components.js +7 -3
- package/src/lib/app-utils/compose-reusable-components.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
- package/src/lib/app-utils/docs-help.generated.js +1 -0
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +18 -4
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/element-motion.js +6 -5
- package/src/lib/app-utils/element-motion.js.map +1 -1
- package/src/lib/app-utils/expand-repeatables.d.ts +23 -3
- package/src/lib/app-utils/expand-repeatables.js +61 -7
- package/src/lib/app-utils/expand-repeatables.js.map +1 -1
- package/src/lib/app-utils/plugin-connection-editor.d.ts +22 -0
- package/src/lib/app-utils/plugin-connection-editor.js.map +1 -1
- package/src/lib/app-utils/plugin-connection-repeat.d.ts +82 -0
- package/src/lib/app-utils/plugin-connection-repeat.js +162 -0
- package/src/lib/app-utils/plugin-connection-repeat.js.map +1 -0
- package/src/lib/app-utils/release-flags.js +2 -2
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/repeat-sources.d.ts +33 -1
- package/src/lib/app-utils/repeat-sources.js +27 -3
- package/src/lib/app-utils/repeat-sources.js.map +1 -1
- package/src/lib/app-utils/seo-page-facts.js +3 -6
- package/src/lib/app-utils/seo-page-facts.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +6 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +8 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/repeat-rows.d.ts +20 -2
- package/src/lib/plugin-manager/repeat-rows.js +42 -16
- package/src/lib/plugin-manager/repeat-rows.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-connection-editor.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 { createContext } from 'react'\nimport type { PluginConnectionRecordsPageData, PluginConnectionSiteRecord } from './plugin-connection-records'\n\n/*\n * DECLARED CONNECTIONS IN THE EDITOR (AGL-4196).\n *\n * A published page hands each signed element its connection's record with\n * the page (`plugin-connection-records.ts`), and binds each record's summary\n * fields as `{{var:<listingId>__<connectionId>-<field>}}`. The Besigner and\n * Preview render in the console, where there is no page render to ride, so\n * the plugin that runs the connections (the marketplace) provides THIS\n * context to every editor surface instead: which listing a component id's\n * namespace belongs to, each listing's records, and the variables the\n * records give the site. The surfaces turn it into the same\n * `PluginConnectionRecordsContext` value the published page provides, so an\n * element reads its record through the same hook, and the binding picker\n * lists the variables by name.\n *\n * Core declares the seam and never names the plugin that fills it. Absent,\n * every element reads `null` and the picker lists nothing extra: the same\n * answer as a site that has not connected.\n */\n\n/** One `{{var:…}}` a connection's record gives the site, as the binding picker lists it. */\nexport interface EditorConnectionVariable {\n /** The variable id (`pluginConnectionVariableId`): what the token carries. */\n id: string\n /** What a person reads: the connection's label and the field's name, never the id. */\n label: string\n /** The value the last sync wrote, as the published page would print it, or `null` before one. */\n value: string | null\n}\n\n/** What the editor knows of the site's declared connections. */\nexport interface EditorPluginConnections {\n /** The listing whose namespace `componentId` is in (`<identity>.<role>`), or `null`. */\n listingFor(componentId: string): string | null\n /** Listing id → connection id → the record its last sync wrote. */\n records: Readonly<Record<string, Readonly<Record<string, PluginConnectionSiteRecord>>>>\n /** Every summary field of every declared connection, as site variables. */\n variables: readonly EditorConnectionVariable[]\n}\n\nexport const EditorPluginConnectionsContext = createContext<EditorPluginConnections | undefined>(undefined)\nEditorPluginConnectionsContext.displayName = 'EditorPluginConnectionsContext'\n\n/** An editor node, as far as attributing it to a listing needs. */\nexport interface EditorConnectionNode {\n $id?: unknown\n componentId?: unknown\n}\n\n/**\n * The `PluginConnectionRecordsContext` value for `nodes` (a page's, or one\n * element's), attributed the way the published page's enricher attributes\n * them: a node whose component id is in a listing's namespace, and only when\n * that listing holds a record. `undefined` when none is.\n */\nexport function editorConnectionRecordsPageData(\n connections: EditorPluginConnections | undefined,\n nodes: Iterable<EditorConnectionNode | null | undefined>,\n): PluginConnectionRecordsPageData | undefined {\n if (!connections) return undefined\n const attributed: Record<string, string> = {}\n const records: PluginConnectionRecordsPageData['records'] = {}\n for (const node of nodes) {\n const nodeId = node?.$id\n const componentId = node?.componentId\n if (typeof nodeId !== 'string' || !nodeId || typeof componentId !== 'string' || !componentId.includes('.')) continue\n const listingId = connections.listingFor(componentId)\n if (!listingId) continue\n const held = connections.records[listingId]\n if (!held || !Object.keys(held).length) continue\n attributed[nodeId] = listingId\n records[listingId] = { ...held }\n }\n return Object.keys(attributed).length ? { nodes: attributed, records } : undefined\n}\n"],"names":["createContext","EditorPluginConnectionsContext","undefined","displayName","editorConnectionRecordsPageData","connections","nodes","attributed","records","node","nodeId","$id","componentId","includes","listingId","listingFor","held","Object","keys","length"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,QAAO;
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-connection-editor.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 { createContext } from 'react'\nimport type { PluginConnectionRecordsPageData, PluginConnectionSiteRecord } from './plugin-connection-records'\nimport type { PluginConnectionFieldTypes } from './plugin-connection-repeat'\n\n/*\n * DECLARED CONNECTIONS IN THE EDITOR (AGL-4196).\n *\n * A published page hands each signed element its connection's record with\n * the page (`plugin-connection-records.ts`), and binds each record's summary\n * fields as `{{var:<listingId>__<connectionId>-<field>}}`. The Besigner and\n * Preview render in the console, where there is no page render to ride, so\n * the plugin that runs the connections (the marketplace) provides THIS\n * context to every editor surface instead: which listing a component id's\n * namespace belongs to, each listing's records, and the variables the\n * records give the site. The surfaces turn it into the same\n * `PluginConnectionRecordsContext` value the published page provides, so an\n * element reads its record through the same hook, and the binding picker\n * lists the variables by name.\n *\n * Core declares the seam and never names the plugin that fills it. Absent,\n * every element reads `null` and the picker lists nothing extra: the same\n * answer as a site that has not connected.\n */\n\n/** One `{{var:…}}` a connection's record gives the site, as the binding picker lists it. */\nexport interface EditorConnectionVariable {\n /** The variable id (`pluginConnectionVariableId`): what the token carries. */\n id: string\n /** What a person reads: the connection's label and the field's name, never the id. */\n label: string\n /** The value the last sync wrote, as the published page would print it, or `null` before one. */\n value: string | null\n}\n\n/**\n * One declared connection an element can repeat over (AGL-4212): what the\n * Attributes panel's picker lists, what a `repeatConnection` value's\n * identity resolves to, and the fields its `{{item.*}}` tokens can name.\n */\nexport interface EditorConnectionRepeatable {\n /** `<publisher handle>.<manifest id>`: what a `repeatConnection` value names. */\n identity: string\n listingId: string\n connectionId: string\n /** The connection's own label, as the site's connections card shows it. */\n label: string\n /** The declared type of each summary field and each item field. */\n types: PluginConnectionFieldTypes\n}\n\n/** What the editor knows of the site's declared connections. */\nexport interface EditorPluginConnections {\n /** The listing whose namespace `componentId` is in (`<identity>.<role>`), or `null`. */\n listingFor(componentId: string): string | null\n /** Listing id → connection id → the record its last sync wrote. */\n records: Readonly<Record<string, Readonly<Record<string, PluginConnectionSiteRecord>>>>\n /** Every summary field of every declared connection, as site variables. */\n variables: readonly EditorConnectionVariable[]\n /**\n * Every declared connection of a namespaced install that writes a record,\n * for a repeat over it (AGL-4212). Absent from a provider that predates it,\n * which offers no such repeat.\n */\n repeatables?: readonly EditorConnectionRepeatable[]\n}\n\nexport const EditorPluginConnectionsContext = createContext<EditorPluginConnections | undefined>(undefined)\nEditorPluginConnectionsContext.displayName = 'EditorPluginConnectionsContext'\n\n/** An editor node, as far as attributing it to a listing needs. */\nexport interface EditorConnectionNode {\n $id?: unknown\n componentId?: unknown\n}\n\n/**\n * The `PluginConnectionRecordsContext` value for `nodes` (a page's, or one\n * element's), attributed the way the published page's enricher attributes\n * them: a node whose component id is in a listing's namespace, and only when\n * that listing holds a record. `undefined` when none is.\n */\nexport function editorConnectionRecordsPageData(\n connections: EditorPluginConnections | undefined,\n nodes: Iterable<EditorConnectionNode | null | undefined>,\n): PluginConnectionRecordsPageData | undefined {\n if (!connections) return undefined\n const attributed: Record<string, string> = {}\n const records: PluginConnectionRecordsPageData['records'] = {}\n for (const node of nodes) {\n const nodeId = node?.$id\n const componentId = node?.componentId\n if (typeof nodeId !== 'string' || !nodeId || typeof componentId !== 'string' || !componentId.includes('.')) continue\n const listingId = connections.listingFor(componentId)\n if (!listingId) continue\n const held = connections.records[listingId]\n if (!held || !Object.keys(held).length) continue\n attributed[nodeId] = listingId\n records[listingId] = { ...held }\n }\n return Object.keys(attributed).length ? { nodes: attributed, records } : undefined\n}\n"],"names":["createContext","EditorPluginConnectionsContext","undefined","displayName","editorConnectionRecordsPageData","connections","nodes","attributed","records","node","nodeId","$id","componentId","includes","listingId","listingFor","held","Object","keys","length"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,QAAO;AAkErC,OAAO,MAAMC,iCAAiCD,cAAmDE,WAAU;AAC3GD,+BAA+BE,WAAW,GAAG;AAQ7C;;;;;CAKC,GACD,OAAO,SAASC,gCACdC,WAAgD,EAChDC,KAAwD;IAExD,IAAI,CAACD,aAAa,OAAOH;IACzB,MAAMK,aAAqC,CAAC;IAC5C,MAAMC,UAAsD,CAAC;IAC7D,KAAK,MAAMC,QAAQH,MAAO;QACxB,MAAMI,SAASD,wBAAAA,KAAME,GAAG;QACxB,MAAMC,cAAcH,wBAAAA,KAAMG,WAAW;QACrC,IAAI,OAAOF,WAAW,YAAY,CAACA,UAAU,OAAOE,gBAAgB,YAAY,CAACA,YAAYC,QAAQ,CAAC,MAAM;QAC5G,MAAMC,YAAYT,YAAYU,UAAU,CAACH;QACzC,IAAI,CAACE,WAAW;QAChB,MAAME,OAAOX,YAAYG,OAAO,CAACM,UAAU;QAC3C,IAAI,CAACE,QAAQ,CAACC,OAAOC,IAAI,CAACF,MAAMG,MAAM,EAAE;QACxCZ,UAAU,CAACG,OAAO,GAAGI;QACrBN,OAAO,CAACM,UAAU,GAAG,aAAKE;IAC5B;IACA,OAAOC,OAAOC,IAAI,CAACX,YAAYY,MAAM,GAAG;QAAEb,OAAOC;QAAYC;IAAQ,IAAIN;AAC3E"}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
import { type RepeatableDataset } from './expand-repeatables';
|
|
18
|
+
import type { PluginConnectionSiteRecord } from './plugin-connection-records';
|
|
19
|
+
import { type PluginConnectionDeclaration, type PluginConnectionFieldType } from './plugin-connections';
|
|
20
|
+
/** Which part of a record a repeat reads: its list, or its summary fields. */
|
|
21
|
+
export type PluginConnectionRepeatPart = 'items' | 'fields';
|
|
22
|
+
/** What a `repeatConnection` value names. */
|
|
23
|
+
export interface PluginConnectionRepeatTarget {
|
|
24
|
+
/** `<publisher handle>.<manifest id>`, as the plugin's bundle knows itself. */
|
|
25
|
+
identity: string;
|
|
26
|
+
connectionId: string;
|
|
27
|
+
part: PluginConnectionRepeatPart;
|
|
28
|
+
}
|
|
29
|
+
/** The last segment that turns a value into the summary row. */
|
|
30
|
+
export declare const PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT = "fields";
|
|
31
|
+
/**
|
|
32
|
+
* The target a `repeatConnection` value (or the `connection:` key
|
|
33
|
+
* `repeatKey` makes of it) names, or `null` when it names none.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parsePluginConnectionRepeat(value: unknown): PluginConnectionRepeatTarget | null;
|
|
36
|
+
/** The `repeatConnection` value that names `target`. */
|
|
37
|
+
export declare function pluginConnectionRepeatValue(target: PluginConnectionRepeatTarget): string;
|
|
38
|
+
/** The declared type of each field of a connection's record. */
|
|
39
|
+
export interface PluginConnectionFieldTypes {
|
|
40
|
+
/** The summary fields (`sync.record.fields`). */
|
|
41
|
+
fields: Readonly<Record<string, PluginConnectionFieldType>>;
|
|
42
|
+
/** Each item's fields (`sync.record.items.fields`). */
|
|
43
|
+
items: Readonly<Record<string, PluginConnectionFieldType>>;
|
|
44
|
+
}
|
|
45
|
+
/** The field types a connection's declaration gives its record. */
|
|
46
|
+
export declare function pluginConnectionFieldTypes(connection: Pick<PluginConnectionDeclaration, 'sync'> | null | undefined): PluginConnectionFieldTypes;
|
|
47
|
+
/** What a `datetime` field's readable sibling is suffixed with. */
|
|
48
|
+
export declare const PLUGIN_CONNECTION_ISO_SUFFIX = "Iso";
|
|
49
|
+
/**
|
|
50
|
+
* A stored `datetime` (epoch ms) as a reader reads it, `Nov 3, 2026`, and as
|
|
51
|
+
* ISO, or `null` for a value that is no instant.
|
|
52
|
+
*
|
|
53
|
+
* The same words `toLocaleDateString('en-US', { month: 'short', day:
|
|
54
|
+
* 'numeric', year: 'numeric', timeZone: 'UTC' })` prints, spelled out here
|
|
55
|
+
* so the server and the editor's browser cannot print them differently.
|
|
56
|
+
*/
|
|
57
|
+
export declare function pluginConnectionDate(value: unknown): {
|
|
58
|
+
text: string;
|
|
59
|
+
iso: string;
|
|
60
|
+
} | null;
|
|
61
|
+
/**
|
|
62
|
+
* One row's values: each declared field the record holds, as it is held —
|
|
63
|
+
* numbers stay numbers, yes/no stays yes/no — except a `datetime`, which
|
|
64
|
+
* becomes its readable date with `<field>Iso` beside it. A field the record
|
|
65
|
+
* leaves empty is absent, so its token prints nothing and an element bound to
|
|
66
|
+
* it alone is left out of that copy.
|
|
67
|
+
*/
|
|
68
|
+
export declare function pluginConnectionRepeatRow(values: Readonly<Record<string, unknown>> | null | undefined, types: Readonly<Record<string, PluginConnectionFieldType>>): Record<string, unknown>;
|
|
69
|
+
/**
|
|
70
|
+
* The rows a repeat over `part` of `record` renders, in the record's order.
|
|
71
|
+
*
|
|
72
|
+
* - `items` — one row per item, each with `$id` its position, which is all
|
|
73
|
+
* the expansion's copy ids need (the list is rewritten whole by each sync).
|
|
74
|
+
* - `fields` — exactly one row, `$id` `fields`; NONE when the site has no
|
|
75
|
+
* record yet, so a summary block draws nothing before the first sync.
|
|
76
|
+
*/
|
|
77
|
+
export declare function pluginConnectionRepeatRows(record: Pick<PluginConnectionSiteRecord, 'fields' | 'items'> | null | undefined, types: PluginConnectionFieldTypes, part: PluginConnectionRepeatPart): RepeatableDataset;
|
|
78
|
+
/**
|
|
79
|
+
* Every `{{item.<field>}}` a repeat over `part` can name, in declared order,
|
|
80
|
+
* each `datetime` followed by its `Iso` sibling.
|
|
81
|
+
*/
|
|
82
|
+
export declare function pluginConnectionRepeatFieldNames(types: PluginConnectionFieldTypes, part: PluginConnectionRepeatPart): string[];
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { REPEAT_CONNECTION_KEY_PREFIX } from "./expand-repeatables.js";
|
|
18
|
+
import { PLUGIN_CONNECTION_ID_PATTERN } from "./plugin-connections.js";
|
|
19
|
+
/** The last segment that turns a value into the summary row. */ export const PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT = 'fields';
|
|
20
|
+
/** A publisher handle and a manifest id, dot-joined: no slash, no space. */ const IDENTITY_PATTERN = /^[A-Za-z0-9][\w-]*(?:\.[A-Za-z0-9][\w-]*)+$/;
|
|
21
|
+
/**
|
|
22
|
+
* The target a `repeatConnection` value (or the `connection:` key
|
|
23
|
+
* `repeatKey` makes of it) names, or `null` when it names none.
|
|
24
|
+
*/ export function parsePluginConnectionRepeat(value) {
|
|
25
|
+
if (typeof value !== 'string') return null;
|
|
26
|
+
let text = value.trim();
|
|
27
|
+
if (text.startsWith(REPEAT_CONNECTION_KEY_PREFIX)) {
|
|
28
|
+
text = text.slice(REPEAT_CONNECTION_KEY_PREFIX.length).trim();
|
|
29
|
+
}
|
|
30
|
+
const [identity, connectionId, part, ...rest] = text.split('/');
|
|
31
|
+
if (rest.length || !identity || !connectionId) return null;
|
|
32
|
+
if (!IDENTITY_PATTERN.test(identity)) return null;
|
|
33
|
+
if (!PLUGIN_CONNECTION_ID_PATTERN.test(connectionId)) return null;
|
|
34
|
+
if (part !== undefined && part !== PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
identity,
|
|
39
|
+
connectionId,
|
|
40
|
+
part: part ? 'fields' : 'items'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The `repeatConnection` value that names `target`. */ export function pluginConnectionRepeatValue(target) {
|
|
44
|
+
const base = `${target.identity}/${target.connectionId}`;
|
|
45
|
+
return target.part === 'fields' ? `${base}/${PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT}` : base;
|
|
46
|
+
}
|
|
47
|
+
/** The field types a connection's declaration gives its record. */ export function pluginConnectionFieldTypes(connection) {
|
|
48
|
+
var _connection_sync, _record_items;
|
|
49
|
+
const record = connection == null ? void 0 : (_connection_sync = connection.sync) == null ? void 0 : _connection_sync.record;
|
|
50
|
+
const typesOf = (declared)=>{
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const [field, declaration] of Object.entries(declared != null ? declared : {})){
|
|
53
|
+
out[field] = declaration.type;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
fields: typesOf(record == null ? void 0 : record.fields),
|
|
59
|
+
items: typesOf(record == null ? void 0 : (_record_items = record.items) == null ? void 0 : _record_items.fields)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** What a `datetime` field's readable sibling is suffixed with. */ export const PLUGIN_CONNECTION_ISO_SUFFIX = 'Iso';
|
|
63
|
+
const MONTHS = [
|
|
64
|
+
'Jan',
|
|
65
|
+
'Feb',
|
|
66
|
+
'Mar',
|
|
67
|
+
'Apr',
|
|
68
|
+
'May',
|
|
69
|
+
'Jun',
|
|
70
|
+
'Jul',
|
|
71
|
+
'Aug',
|
|
72
|
+
'Sep',
|
|
73
|
+
'Oct',
|
|
74
|
+
'Nov',
|
|
75
|
+
'Dec'
|
|
76
|
+
];
|
|
77
|
+
/**
|
|
78
|
+
* A stored `datetime` (epoch ms) as a reader reads it, `Nov 3, 2026`, and as
|
|
79
|
+
* ISO, or `null` for a value that is no instant.
|
|
80
|
+
*
|
|
81
|
+
* The same words `toLocaleDateString('en-US', { month: 'short', day:
|
|
82
|
+
* 'numeric', year: 'numeric', timeZone: 'UTC' })` prints, spelled out here
|
|
83
|
+
* so the server and the editor's browser cannot print them differently.
|
|
84
|
+
*/ export function pluginConnectionDate(value) {
|
|
85
|
+
const ms = typeof value === 'number' ? value : typeof value === 'string' && value.trim() ? Date.parse(value) : Number.NaN;
|
|
86
|
+
if (!Number.isFinite(ms)) return null;
|
|
87
|
+
const date = new Date(ms);
|
|
88
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
89
|
+
return {
|
|
90
|
+
text: `${MONTHS[date.getUTCMonth()]} ${date.getUTCDate()}, ${date.getUTCFullYear()}`,
|
|
91
|
+
iso: date.toISOString()
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* One row's values: each declared field the record holds, as it is held —
|
|
96
|
+
* numbers stay numbers, yes/no stays yes/no — except a `datetime`, which
|
|
97
|
+
* becomes its readable date with `<field>Iso` beside it. A field the record
|
|
98
|
+
* leaves empty is absent, so its token prints nothing and an element bound to
|
|
99
|
+
* it alone is left out of that copy.
|
|
100
|
+
*/ export function pluginConnectionRepeatRow(values, types) {
|
|
101
|
+
const row = {};
|
|
102
|
+
if (!values) return row;
|
|
103
|
+
for (const [field, type] of Object.entries(types)){
|
|
104
|
+
const value = values[field];
|
|
105
|
+
if (value === null || value === undefined || value === '') continue;
|
|
106
|
+
if (type === 'datetime') {
|
|
107
|
+
const date = pluginConnectionDate(value);
|
|
108
|
+
if (!date) continue;
|
|
109
|
+
row[field] = date.text;
|
|
110
|
+
const iso = `${field}${PLUGIN_CONNECTION_ISO_SUFFIX}`;
|
|
111
|
+
// A field the plugin declared under that name is its own.
|
|
112
|
+
if (!(iso in types)) row[iso] = date.iso;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === 'number' && !Number.isFinite(value)) continue;
|
|
116
|
+
if (typeof value === 'object') continue;
|
|
117
|
+
row[field] = value;
|
|
118
|
+
}
|
|
119
|
+
return row;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The rows a repeat over `part` of `record` renders, in the record's order.
|
|
123
|
+
*
|
|
124
|
+
* - `items` — one row per item, each with `$id` its position, which is all
|
|
125
|
+
* the expansion's copy ids need (the list is rewritten whole by each sync).
|
|
126
|
+
* - `fields` — exactly one row, `$id` `fields`; NONE when the site has no
|
|
127
|
+
* record yet, so a summary block draws nothing before the first sync.
|
|
128
|
+
*/ export function pluginConnectionRepeatRows(record, types, part) {
|
|
129
|
+
if (!record) return {
|
|
130
|
+
records: []
|
|
131
|
+
};
|
|
132
|
+
if (part === 'fields') {
|
|
133
|
+
return {
|
|
134
|
+
records: [
|
|
135
|
+
_extends({}, pluginConnectionRepeatRow(record.fields, types.fields), {
|
|
136
|
+
$id: PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const items = Array.isArray(record.items) ? record.items : [];
|
|
142
|
+
return {
|
|
143
|
+
records: items.map((item, index)=>_extends({}, pluginConnectionRepeatRow(item, types.items), {
|
|
144
|
+
$id: String(index)
|
|
145
|
+
}))
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Every `{{item.<field>}}` a repeat over `part` can name, in declared order,
|
|
150
|
+
* each `datetime` followed by its `Iso` sibling.
|
|
151
|
+
*/ export function pluginConnectionRepeatFieldNames(types, part) {
|
|
152
|
+
const declared = part === 'fields' ? types.fields : types.items;
|
|
153
|
+
const names = [];
|
|
154
|
+
for (const [field, type] of Object.entries(declared)){
|
|
155
|
+
names.push(field);
|
|
156
|
+
const iso = `${field}${PLUGIN_CONNECTION_ISO_SUFFIX}`;
|
|
157
|
+
if (type === 'datetime' && !(iso in declared)) names.push(iso);
|
|
158
|
+
}
|
|
159
|
+
return names;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=plugin-connection-repeat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-connection-repeat.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n REPEAT_CONNECTION_KEY_PREFIX,\n type RepeatableDataset,\n} from './expand-repeatables'\nimport type { PluginConnectionSiteRecord } from './plugin-connection-records'\nimport {\n PLUGIN_CONNECTION_ID_PATTERN,\n type PluginConnectionDeclaration,\n type PluginConnectionFieldType,\n} from './plugin-connections'\n\n/*\n * REPEATING AN ELEMENT OVER A PLUGIN CONNECTION'S RECORD (AGL-4212).\n *\n * A marketplace plugin that declares a connection gets, per site, the small\n * public record its sync last wrote (`plugin-connection-records.ts`): summary\n * `fields` and a list of `items`. Any element can repeat over that record the\n * way it repeats over a dataset, so an author builds the display from\n * ordinary elements instead of styling one closed block. The node names it\n * under `repeatConnection` (`expand-repeatables.ts`):\n *\n * - `<pluginIdentity>/<connectionId>` — one row per item;\n * - `<pluginIdentity>/<connectionId>/fields` — ONE row of the summary\n * fields, or none before the first sync.\n *\n * `pluginIdentity` is the namespace a bundle publishes under\n * (`<publisher handle>.<manifest id>`), the one name a preset can know.\n *\n * Everything here is pure, and it is the ONE place a record becomes rows: the\n * marketplace's server reader answers the published page with it, and its\n * editor source draws the canvas with it, so the two cannot disagree about a\n * date or a missing field. Reached by path: a published page's own download\n * never asks how rows are made.\n */\n\n/** Which part of a record a repeat reads: its list, or its summary fields. */\nexport type PluginConnectionRepeatPart = 'items' | 'fields'\n\n/** What a `repeatConnection` value names. */\nexport interface PluginConnectionRepeatTarget {\n /** `<publisher handle>.<manifest id>`, as the plugin's bundle knows itself. */\n identity: string\n connectionId: string\n part: PluginConnectionRepeatPart\n}\n\n/** The last segment that turns a value into the summary row. */\nexport const PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT = 'fields'\n\n/** A publisher handle and a manifest id, dot-joined: no slash, no space. */\nconst IDENTITY_PATTERN = /^[A-Za-z0-9][\\w-]*(?:\\.[A-Za-z0-9][\\w-]*)+$/\n\n/**\n * The target a `repeatConnection` value (or the `connection:` key\n * `repeatKey` makes of it) names, or `null` when it names none.\n */\nexport function parsePluginConnectionRepeat(\n value: unknown,\n): PluginConnectionRepeatTarget | null {\n if (typeof value !== 'string') return null\n let text = value.trim()\n if (text.startsWith(REPEAT_CONNECTION_KEY_PREFIX)) {\n text = text.slice(REPEAT_CONNECTION_KEY_PREFIX.length).trim()\n }\n const [identity, connectionId, part, ...rest] = text.split('/')\n if (rest.length || !identity || !connectionId) return null\n if (!IDENTITY_PATTERN.test(identity)) return null\n if (!PLUGIN_CONNECTION_ID_PATTERN.test(connectionId)) return null\n if (part !== undefined && part !== PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT) {\n return null\n }\n return { identity, connectionId, part: part ? 'fields' : 'items' }\n}\n\n/** The `repeatConnection` value that names `target`. */\nexport function pluginConnectionRepeatValue(\n target: PluginConnectionRepeatTarget,\n): string {\n const base = `${target.identity}/${target.connectionId}`\n return target.part === 'fields'\n ? `${base}/${PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT}`\n : base\n}\n\n/** The declared type of each field of a connection's record. */\nexport interface PluginConnectionFieldTypes {\n /** The summary fields (`sync.record.fields`). */\n fields: Readonly<Record<string, PluginConnectionFieldType>>\n /** Each item's fields (`sync.record.items.fields`). */\n items: Readonly<Record<string, PluginConnectionFieldType>>\n}\n\n/** The field types a connection's declaration gives its record. */\nexport function pluginConnectionFieldTypes(\n connection: Pick<PluginConnectionDeclaration, 'sync'> | null | undefined,\n): PluginConnectionFieldTypes {\n const record = connection?.sync?.record\n const typesOf = (\n declared: Readonly<Record<string, { type: PluginConnectionFieldType }>> | undefined,\n ) => {\n const out: Record<string, PluginConnectionFieldType> = {}\n for (const [field, declaration] of Object.entries(declared ?? {})) {\n out[field] = declaration.type\n }\n return out\n }\n return {\n fields: typesOf(record?.fields),\n items: typesOf(record?.items?.fields),\n }\n}\n\n/** What a `datetime` field's readable sibling is suffixed with. */\nexport const PLUGIN_CONNECTION_ISO_SUFFIX = 'Iso'\n\nconst MONTHS = [\n 'Jan',\n 'Feb',\n 'Mar',\n 'Apr',\n 'May',\n 'Jun',\n 'Jul',\n 'Aug',\n 'Sep',\n 'Oct',\n 'Nov',\n 'Dec',\n] as const\n\n/**\n * A stored `datetime` (epoch ms) as a reader reads it, `Nov 3, 2026`, and as\n * ISO, or `null` for a value that is no instant.\n *\n * The same words `toLocaleDateString('en-US', { month: 'short', day:\n * 'numeric', year: 'numeric', timeZone: 'UTC' })` prints, spelled out here\n * so the server and the editor's browser cannot print them differently.\n */\nexport function pluginConnectionDate(\n value: unknown,\n): { text: string; iso: string } | null {\n const ms =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim()\n ? Date.parse(value)\n : Number.NaN\n if (!Number.isFinite(ms)) return null\n const date = new Date(ms)\n if (Number.isNaN(date.getTime())) return null\n return {\n text: `${MONTHS[date.getUTCMonth()]} ${date.getUTCDate()}, ${date.getUTCFullYear()}`,\n iso: date.toISOString(),\n }\n}\n\n/**\n * One row's values: each declared field the record holds, as it is held —\n * numbers stay numbers, yes/no stays yes/no — except a `datetime`, which\n * becomes its readable date with `<field>Iso` beside it. A field the record\n * leaves empty is absent, so its token prints nothing and an element bound to\n * it alone is left out of that copy.\n */\nexport function pluginConnectionRepeatRow(\n values: Readonly<Record<string, unknown>> | null | undefined,\n types: Readonly<Record<string, PluginConnectionFieldType>>,\n): Record<string, unknown> {\n const row: Record<string, unknown> = {}\n if (!values) return row\n for (const [field, type] of Object.entries(types)) {\n const value = values[field]\n if (value === null || value === undefined || value === '') continue\n if (type === 'datetime') {\n const date = pluginConnectionDate(value)\n if (!date) continue\n row[field] = date.text\n const iso = `${field}${PLUGIN_CONNECTION_ISO_SUFFIX}`\n // A field the plugin declared under that name is its own.\n if (!(iso in types)) row[iso] = date.iso\n continue\n }\n if (typeof value === 'number' && !Number.isFinite(value)) continue\n if (typeof value === 'object') continue\n row[field] = value\n }\n return row\n}\n\n/**\n * The rows a repeat over `part` of `record` renders, in the record's order.\n *\n * - `items` — one row per item, each with `$id` its position, which is all\n * the expansion's copy ids need (the list is rewritten whole by each sync).\n * - `fields` — exactly one row, `$id` `fields`; NONE when the site has no\n * record yet, so a summary block draws nothing before the first sync.\n */\nexport function pluginConnectionRepeatRows(\n record: Pick<PluginConnectionSiteRecord, 'fields' | 'items'> | null | undefined,\n types: PluginConnectionFieldTypes,\n part: PluginConnectionRepeatPart,\n): RepeatableDataset {\n if (!record) return { records: [] }\n if (part === 'fields') {\n return {\n records: [\n {\n ...pluginConnectionRepeatRow(record.fields, types.fields),\n $id: PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT,\n },\n ],\n }\n }\n const items = Array.isArray(record.items) ? record.items : []\n return {\n records: items.map((item, index) => ({\n ...pluginConnectionRepeatRow(item, types.items),\n $id: String(index),\n })),\n }\n}\n\n/**\n * Every `{{item.<field>}}` a repeat over `part` can name, in declared order,\n * each `datetime` followed by its `Iso` sibling.\n */\nexport function pluginConnectionRepeatFieldNames(\n types: PluginConnectionFieldTypes,\n part: PluginConnectionRepeatPart,\n): string[] {\n const declared = part === 'fields' ? types.fields : types.items\n const names: string[] = []\n for (const [field, type] of Object.entries(declared)) {\n names.push(field)\n const iso = `${field}${PLUGIN_CONNECTION_ISO_SUFFIX}`\n if (type === 'datetime' && !(iso in declared)) names.push(iso)\n }\n return names\n}\n"],"names":["REPEAT_CONNECTION_KEY_PREFIX","PLUGIN_CONNECTION_ID_PATTERN","PLUGIN_CONNECTION_REPEAT_FIELDS_SEGMENT","IDENTITY_PATTERN","parsePluginConnectionRepeat","value","text","trim","startsWith","slice","length","identity","connectionId","part","rest","split","test","undefined","pluginConnectionRepeatValue","target","base","pluginConnectionFieldTypes","connection","record","sync","typesOf","declared","out","field","declaration","Object","entries","type","fields","items","PLUGIN_CONNECTION_ISO_SUFFIX","MONTHS","pluginConnectionDate","ms","Date","parse","Number","NaN","isFinite","date","isNaN","getTime","getUTCMonth","getUTCDate","getUTCFullYear","iso","toISOString","pluginConnectionRepeatRow","values","types","row","pluginConnectionRepeatRows","records","$id","Array","isArray","map","item","index","String","pluginConnectionRepeatFieldNames","names","push"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,4BAA4B,QAEvB,0BAAsB;AAE7B,SACEC,4BAA4B,QAGvB,0BAAsB;AAqC7B,8DAA8D,GAC9D,OAAO,MAAMC,0CAA0C,SAAQ;AAE/D,0EAA0E,GAC1E,MAAMC,mBAAmB;AAEzB;;;CAGC,GACD,OAAO,SAASC,4BACdC,KAAc;IAEd,IAAI,OAAOA,UAAU,UAAU,OAAO;IACtC,IAAIC,OAAOD,MAAME,IAAI;IACrB,IAAID,KAAKE,UAAU,CAACR,+BAA+B;QACjDM,OAAOA,KAAKG,KAAK,CAACT,6BAA6BU,MAAM,EAAEH,IA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A;;;;;;;CAOC,GACD,OAAO,SAASC,2BACdjC,MAA+E,EAC/E+B,KAAiC,EACjCzC,IAAgC;IAEhC,IAAI,CAACU,QAAQ,OAAO;QAAEkC,SAAS,EAAE;IAAC;IAClC,IAAI5C,SAAS,UAAU;QACrB,OAAO;YACL4C,SAAS;gBACP,aACKL,0BAA0B7B,OAAOU,MAAM,EAAEqB,MAAMrB,MAAM;oBACxDyB,KAAKxD;;aAER;QACH;IACF;IACA,MAAMgC,QAAQyB,MAAMC,OAAO,CAACrC,OAAOW,KAAK,IAAIX,OAAOW,KAAK,GAAG,EAAE;IAC7D,OAAO;QACLuB,SAASvB,MAAM2B,GAAG,CAAC,CAACC,MAAMC,QAAW,aAChCX,0BAA0BU,MAAMR,MAAMpB,KAAK;gBAC9CwB,KAAKM,OAAOD;;IAEhB;AACF;AAEA;;;CAGC,GACD,OAAO,SAASE,iCACdX,KAAiC,EACjCzC,IAAgC;IAEhC,MAAMa,WAAWb,SAAS,WAAWyC,MAAMrB,MAAM,GAAGqB,MAAMpB,KAAK;IAC/D,MAAMgC,QAAkB,EAAE;IAC1B,KAAK,MAAM,CAACtC,OAAOI,KAAK,IAAIF,OAAOC,OAAO,CAACL,UAAW;QACpDwC,MAAMC,IAAI,CAACvC;QACX,MAAMsB,MAAM,GAAGtB,QAAQO,8BAA8B;QACrD,IAAIH,SAAS,cAAc,CAAEkB,CAAAA,OAAOxB,QAAO,GAAIwC,MAAMC,IAAI,CAACjB;IAC5D;IACA,OAAOgB;AACT"}
|
|
@@ -61,7 +61,7 @@ export function isReleaseFlagStage(value) {
|
|
|
61
61
|
description: 'Storefront shoppers pay on the merchant\u2019s own site: the Payment ' + 'Element, email, shipping address and method, and a live total with ' + 'tax open in place under the Buy or Checkout button, styled with the ' + 'site theme, instead of a redirect to checkout.stripe.com (AGL-1944). ' + 'Released to every workspace 2026-10-06 (AGL-3606). The webhook is ' + 'still the only thing that fulfils. Also gated on ' + 'NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY, so a deployment without one keeps ' + 'the redirect; turning this off returns every storefront to the redirect.',
|
|
62
62
|
defaultEnabled: true
|
|
63
63
|
},
|
|
64
|
-
// Released to every store 2026-11-06, after the Terms (v24) named a site's
|
|
64
|
+
// Released to every store 2026-11-06, after the Terms (v24, v25) named a site's
|
|
65
65
|
// own Stripe account as the seller of record. On, a store that sets up
|
|
66
66
|
// payments gets a full Stripe account of its own and its sales, online and
|
|
67
67
|
// in person, become direct charges on it. It stays the kill switch: off,
|
|
@@ -70,7 +70,7 @@ export function isReleaseFlagStage(value) {
|
|
|
70
70
|
{
|
|
71
71
|
key: 'release_direct_charges',
|
|
72
72
|
label: 'Sellers get their own Stripe account',
|
|
73
|
-
description: 'When a store sets up payments it gets a full Stripe account of its own ' + '(Stripe bills it, Stripe Dashboard included), and its site sales, ' + 'quotes, invoices and
|
|
73
|
+
description: 'When a store sets up payments it gets a full Stripe account of its own ' + '(Stripe bills it, Stripe Dashboard included), and its site sales, ' + 'quotes, invoices, bookings and in-person card sales (the register and ' + 'Tap to Pay) are charged directly on that account: the store is the ' + 'seller of record, owns refunds, disputes and sales tax, and the ' + 'platform keeps only its plan take as an application fee. Plugin ' + 'marketplace sales stay on the platform account. Off: new stores get ' + 'the platform-managed account ' + 'and destination charges, as before. Accounts already created keep ' + 'whichever shape they were created with.',
|
|
74
74
|
defaultEnabled: true
|
|
75
75
|
},
|
|
76
76
|
// Released to every site 2026-09-16 (AGL-3041). Still the whole surface's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/release-flags.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 * Release flags (AGL-227): platform-level \"is this feature launched\"\n * gating backed by Firebase Remote Config. A separate axis from plan\n * entitlements (`plan-entitlements.ts`) — entitlements ask whether the\n * tenant's PLAN includes a feature, release flags ask whether the feature\n * is released to the public at all (or partially, via percentage rollout).\n * Staff bypass release flags everywhere but see a flagged warning.\n */\n\n/** Remote Config parameter keys for release-gated features. */\nimport type { OrgPlan } from '../foundation'\nimport { PLAN_LABELS, PLAN_LADDER } from './plan-entitlements'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\nimport {\n PLUGIN_RELEASE_FLAGS,\n type PluginReleaseFlagKey,\n} from './plugin-release-flags.generated'\n\n/**\n * Every release flag: the ones plugins declare (compiled from\n * plugins.config.json, AGL-3080) and the platform's own below.\n */\nexport type ReleaseFlagKey =\n | PluginReleaseFlagKey\n | 'release_addon_store'\n | 'release_native_checkout'\n | 'release_direct_charges'\n | 'release_edit_bar'\n | 'release_assist'\n | 'release_video_uploads'\n | 'release_video_delivery'\n | 'release_ai_generative'\n | 'release_ai_site_import'\n | 'release_ai_site_import_generative'\n | 'release_crm_assist_whole_record'\n | 'release_ai_site_inspiration'\n | 'release_ad_audience_sync'\n | 'release_site_starters'\n | 'release_video_embed_posters'\n\nexport interface ReleaseFlagDefinition {\n key: ReleaseFlagKey\n label: string\n description: string\n /**\n * Fallback verdict when Remote Config is unreachable (offline, blocked,\n * first paint before activate). MUST match the seeded value in\n * cloud/firebase-remoteconfig.template.json so environments without a\n * published template behave like the template intends.\n */\n defaultEnabled: boolean\n /** Host dashboard tab id (host-nav-tabs.ts) this flag hides, if any. */\n navTabId?: string\n /**\n * Where a RELEASED feature stands, when it is still changing. Absent means\n * generally available, which is what every feature without a stage is.\n *\n * Data only. A stage never gates anything, and it says nothing while the\n * flag is off: an off feature is rolling out, whatever its stage reads. The\n * console labels an on, `beta`-staged feature Beta beside its nav tab and\n * its hub header, and the docs open its pages with a `:::note Beta`\n * admonition, which `docs-release-flags.spec.ts` holds to this field.\n */\n stage?: ReleaseFlagStage\n}\n\n/**\n * The stages a released feature can be in short of general availability.\n * One today. A stage is per feature, never platform-wide: features keep\n * arriving in beta for as long as the product grows.\n */\nexport const RELEASE_FLAG_STAGES = ['beta'] as const\n\nexport type ReleaseFlagStage = (typeof RELEASE_FLAG_STAGES)[number]\n\nexport function isReleaseFlagStage(value: unknown): value is ReleaseFlagStage {\n return (RELEASE_FLAG_STAGES as readonly unknown[]).includes(value)\n}\n\n/** A release flag a plugin declares, as the generator compiles it. */\nexport type PluginReleaseFlagDefinition = ReleaseFlagDefinition & {\n key: PluginReleaseFlagKey\n}\n\n/**\n * The platform's own release flags: features no plugin owns.\n *\n * Every first-party plugin is release-flagged too (AGL-422) — the flag feeds\n * the plugin LOADER (console, published sites, API dispatch), not just nav\n * visibility, so staff can kill-switch a whole plugin platform-wide from the\n * Feature Flags page. Those flags are the plugins' own: each is defined by\n * its catalog row's `releaseFlagDefinition` in plugins.config.json and\n * compiled into `PLUGIN_RELEASE_FLAGS`, so adding a plugin edits nothing\n * here.\n */\nconst PLATFORM_RELEASE_FLAGS: readonly ReleaseFlagDefinition[] = [\n {\n key: 'release_addon_store',\n label: 'Add-on store',\n description:\n 'Self-serve add-on purchases on the Billing page: seats, datasets, ' +\n 'extra sites, POS registers, Event Calendar (AGL-524..531).',\n defaultEnabled: true,\n },\n // Released to every workspace 2026-10-06 (AGL-3606). Storefront-only since\n // the console's plan checkout stopped rendering Stripe Checkout at all. Still\n // the surface's kill switch, globally or per org: off, both storefront\n // checkout routes return the hosted redirect again.\n {\n key: 'release_native_checkout',\n label: 'In-page checkout',\n description:\n 'Storefront shoppers pay on the merchant\\u2019s own site: the Payment ' +\n 'Element, email, shipping address and method, and a live total with ' +\n 'tax open in place under the Buy or Checkout button, styled with the ' +\n 'site theme, instead of a redirect to checkout.stripe.com (AGL-1944). ' +\n 'Released to every workspace 2026-10-06 (AGL-3606). The webhook is ' +\n 'still the only thing that fulfils. Also gated on ' +\n 'NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY, so a deployment without one keeps ' +\n 'the redirect; turning this off returns every storefront to the redirect.',\n defaultEnabled: true,\n },\n // Released to every store 2026-11-06, after the Terms (v24) named a site's\n // own Stripe account as the seller of record. On, a store that sets up\n // payments gets a full Stripe account of its own and its sales, online and\n // in person, become direct charges on it. It stays the kill switch: off,\n // new setups get the platform-managed account again. Neither state changes\n // an account already created: the account itself decides how it charges.\n {\n key: 'release_direct_charges',\n label: 'Sellers get their own Stripe account',\n description:\n 'When a store sets up payments it gets a full Stripe account of its own ' +\n '(Stripe bills it, Stripe Dashboard included), and its site sales, ' +\n 'quotes, invoices and bookings are charged directly on that account: ' +\n 'the store is the seller of record, owns refunds, disputes and sales ' +\n 'tax, and the platform keeps only its plan take as an application fee. The ' +\n 'register, Tap to Pay and plugin marketplace sales stay on the ' +\n 'platform account. Off: new stores get the platform-managed account ' +\n 'and destination charges, as before. Accounts already created keep ' +\n 'whichever shape they were created with.',\n defaultEnabled: true,\n },\n // Released to every site 2026-09-16 (AGL-3041). Still the whole surface's\n // kill switch, globally or for one org by override: off, the tenant slot\n // renders nothing, both token mints refuse, and `/api/edit-context` turns\n // away every token already issued.\n {\n key: 'release_edit_bar',\n label: 'Site admin bar',\n description:\n 'Admin bar on published sites: a signed-in editor jumps from a live ' +\n 'page straight into the Besigner to edit it. Released ' +\n '2026-09-16 (AGL-3041) for every site; turning it off hides the bar ' +\n 'and revokes every outstanding edit token at the verify site.',\n defaultEnabled: true,\n },\n {\n key: 'release_assist',\n label: `${PLATFORM_BRAND_NAME} Assist`,\n // Released to every workspace and still changing: what it answers, what\n // it can build from a message and how it cites the docs.\n stage: 'beta',\n description:\n 'The in-console AI chat helper on every page (AGL-1860): docs-' +\n 'grounded answers with deep links, page-context guidance on Pro+. ' +\n 'ON in production, and gated on TWO published legal artifacts ' +\n '(AGL-1909), neither of which is a repo file — both are live besigner ' +\n 'pages, so publication is what satisfies them: (1) the privacy-policy ' +\n 'disclosure for stored Q&A, because the data loop records every ' +\n 'exchange org-scoped under orgs/{orgId}/assistExchanges; and (2) the ' +\n 'Anthropic row on /legal/subprocessors, which was deliberately ' +\n 'REMOVED on 2026-08-13 (subprocessorsV2a-20260813) on the premise ' +\n 'that no production key existed — so the page is not merely ' +\n 'incomplete without it, it is affirmatively wrong. NOTE the real ' +\n 'trigger is ANTHROPIC_API_KEY, not this flag: /api/ai/assist (the ' +\n 'besigner copy assistant, AGL-89/130/169) carries no release flag at ' +\n 'all and sends customer site content to Anthropic on the key plus a ' +\n 'Pro entitlement alone. Setting the key in production therefore makes ' +\n 'Anthropic a subprocessor whether or not this flag is ever flipped.',\n defaultEnabled: true,\n },\n // Ingress only, and with no staff preview on the server: a video a staff\n // session uploads into a customer's library serves on that customer's pages\n // like any other, so a grant goes to the org through its override.\n // `apps/console/utils/server/video-uploads.ts` holds the gate.\n {\n key: 'release_video_uploads',\n label: 'Video uploads',\n description:\n 'New video in the media library, on every upload path (AGL-2830). ' +\n 'Off: refused with 403 video_uploads_paused, as DAM video delivery is ' +\n 'not yet metered or bounded per org (AGL-2810, AGL-2812). Images, ' +\n 'documents and stored videos are unaffected.',\n defaultEnabled: false,\n },\n // Delivery, not ingress: this flag decides whether a video already in the\n // library is COPIED to the configured delivery provider and served from it\n // through a short-lived signed redirect (AGL-2824). Per org, with no staff\n // preview on the server — a copy is customer data at the provider, so a\n // grant goes to the org through its override. Off, or with no provider\n // configured, every video serves from this platform exactly as before.\n // `media-delivery.ts` in `tenant-data-admin` holds the gate.\n {\n key: 'release_video_delivery',\n label: 'Video delivery',\n description:\n 'Serves library video from a configured delivery provider through ' +\n 'short-lived signed redirects, and copies each video to it (AGL-2824). ' +\n 'OFF by default: video serves from this platform as before. Also ' +\n \"needs the provider's settings.\",\n defaultEnabled: false,\n },\n // The generative doors share one runtime with Assist (AGL-2903) but not\n // its flag: `release_assist` answers questions, this builds things, and\n // the two are sold, metered and disclosed separately. The server-side\n // gate lives in `aiGateLadder` (404 when off, staff preview).\n // Labeled for what it switches — the generative doors — and not with the\n // add-on's own name, which is sold and live whether or not the doors are\n // released: the docs name the add-on, and a flag wearing the same words\n // reads as documented when it is not.\n {\n key: 'release_ai_generative',\n label: `${PLATFORM_BRAND_NAME} AI generation`,\n // Released to every workspace and still changing: the guided start, page\n // and section generation and the other generative doors.\n stage: 'beta',\n description:\n 'Generative building and automation behind the AI add-on ' +\n '(AGL-2903): sections, pages and workflows written by a model from ' +\n 'a brief, on the shared Anthropic runtime. ON for every workspace ' +\n 'since 2026-09-29; every generative route answers 404 while it is ' +\n 'off. On, it sends customer briefs and site content to Anthropic ' +\n 'on the same ANTHROPIC_API_KEY and under the same subprocessor ' +\n 'disclosure as Assist (AGL-1909).',\n defaultEnabled: true,\n },\n // \"Bring my site\" (AGL-3973): proving a workspace owns a website, and the\n // crawl that reads it once it has. OFF by default so a code change can\n // never be what releases it; the doors answer 404 while it is off, with a\n // staff preview. Its own flag rather than `release_ai_generative`, because\n // reading someone's website is a different thing to disclose than\n // writing from a brief.\n {\n key: 'release_ai_site_import',\n label: 'Bring my site',\n // Released on every paid plan and still changing: how pages are read,\n // rewritten in the new design and brought in wave by wave.\n stage: 'beta',\n description:\n 'Bring an existing website into a workspace on a paid plan (AGL-3973): ' +\n 'the workspace proves it owns the domain (a DNS record, a home page ' +\n 'meta tag, or a code emailed to an address at the domain), then ' +\n 'AglynBot reads the site within robots.txt, same-origin only, under ' +\n 'page, byte and time budgets. ON since 2026-10-25 (beta.282, after the ' +\n 'Legal v18 import clause and the blocked-page reason, AGL-4029); turned ' +\n 'off, the ownership and crawl doors answer 404.',\n defaultEnabled: true,\n },\n // Improve it, generative (AGL-4152): under Bring my site's Improve it, the\n // site is planned before anything is built, its menu and design drawn to it,\n // and with new copy on a page is redesigned from a ledger of what the source\n // holds, with new sections. Off by default and off everywhere in production\n // until its paid eval and the owner's read pass; a test organization gets it\n // with the per-org override, `orgs/{orgId}.releaseFlags`. Off, Improve it is\n // exactly what `release_ai_site_import` ships today.\n {\n key: 'release_ai_site_import_generative',\n label: 'Bring my site: generative Improve it',\n description:\n 'Under Improve it, the site is planned before anything is built: its ' +\n 'menu, footer, design and one proposed page. With new copy on, each main ' +\n 'page is redesigned from what the source holds: sections added, new copy ' +\n 'written and checked so that it invents no name, number, price or ' +\n 'credential (AGL-4152). OFF by default; on for one organization by its per-org ' +\n 'override while it is evaluated. Off, Improve it is unchanged.',\n defaultEnabled: false,\n },\n // What CRM assistance hands the model provider, not whether it runs:\n // `release_ai_generative` opens the doors, this widens what a record sends\n // through them. Per org, with no staff preview — the data is the customer's,\n // and a staff session reading a customer's record must send what the\n // published pages promise. The CRM's record-facts readers hold the gate.\n {\n key: 'release_crm_assist_whole_record',\n label: 'CRM assistance: whole record',\n description:\n 'What AI assistance in the CRM (a record summary, next step or ' +\n 'email draft) sends the model provider (AGL-3520). OFF: the ' +\n 'disclosed fields, with addresses and numbers in typed text ' +\n 'replaced. ON: the whole record, contact details and custom fields ' +\n 'included. ON since 2026-10-05, after Privacy Policy section 2 and ' +\n 'the Subprocessors row were republished; see ' +\n 'docs/drafts/agl-3520-crm-assistance-whole-record-disclosure.md.',\n defaultEnabled: true,\n },\n // Per org, with no staff preview on the server: the site job reads the\n // sites a person names only where the org's verdict is on, and the guided\n // start asks for them by the same verdict. `model/ai-site-inspiration.ts`\n // in the AI plugin holds the key.\n {\n key: 'release_ai_site_inspiration',\n label: 'AI site start: sites you like',\n description:\n 'The guided AI site start asks for sites the person likes (AGL-3975): ' +\n 'one on Free, three on a paid plan. The site job reads each home page ' +\n 'and two of its stylesheets through the SSRF-guarded fetch and keeps ' +\n 'signals only (section order, spacing, header, colors, type mood, ' +\n 'button and card shape, motion, and on a paid plan the features it ' +\n 'offers), never its words, images or logos. ON since 2026-10-28, ' +\n 'after its live eval re-run passed; turned off, no field is shown ' +\n 'and no site is read.',\n defaultEnabled: true,\n },\n // Platform-wide, never per org: the nightly job reads only the platform\n // value, because it is the operator's own marketing and no workspace's\n // feature. `apps/console/app/api/admin/ad-audience-sync/route.ts` holds the\n // gate; a dry run reports the counts whichever way it is set.\n {\n key: 'release_ad_audience_sync',\n label: 'Account-holder ad audiences',\n description:\n 'Nightly sync of United States account holders, as SHA-256 hashed ' +\n 'email addresses, to the operator\\u2019s own Meta, Google and LinkedIn ' +\n 'customer-list audiences (AGL-3780). OFF by default: nothing is sent ' +\n 'until the Privacy Policy that discloses it is published.',\n defaultEnabled: false,\n },\n // Per org (AGL-4049): \"Create site\" is to offer the starter picker only\n // where the org's verdict is on. Nothing reads the flag yet, and off it\n // creates the default site as it always has.\n {\n key: 'release_site_starters',\n label: 'Site starters from the marketplace',\n description:\n 'Create site asks the person to choose a starter (AGL-4049): every ' +\n `option, ${PLATFORM_BRAND_NAME}\\u2019s own included, is a marketplace listing any ` +\n 'publisher may list and price, for a base start or an AI start. OFF ' +\n 'by default: Create site makes the default site as it always has.',\n defaultEnabled: false,\n },\n // Per org (AGL-4140): the tenant loader reads it for the site's workspace\n // into `SiteContextValue.videoEmbedPosters`, the lockdown verdict reads it\n // for the middleware's `img-src`, and a site import stamps it on each wave\n // as the wave starts. Off, a poster-less YouTube film asks for a poster,\n // as it always has.\n {\n key: 'release_video_embed_posters',\n label: 'YouTube thumbnails as video posters',\n description:\n 'A YouTube film placed or imported with no poster shows YouTube\\u2019s ' +\n 'own thumbnail (AGL-4140), which each visitor\\u2019s browser loads from ' +\n 'i.ytimg.com with the page. OFF by default: nothing is requested from ' +\n 'Google until the Subprocessors page that discloses it is published.',\n defaultEnabled: false,\n },\n]\n\n/**\n * The registry: one entry per gated feature, the plugins' first. Adding a\n * platform flag = add it above, seed it in the Remote Config template, and\n * (optionally) wrap the page in `<FeatureGate>` — the staff admin editor and\n * nav filtering pick it up from this list.\n */\nexport const RELEASE_FLAGS: readonly ReleaseFlagDefinition[] = [\n ...PLUGIN_RELEASE_FLAGS,\n ...PLATFORM_RELEASE_FLAGS,\n]\n\nexport const RELEASE_FLAG_KEYS = RELEASE_FLAGS.map(\n (definition) => definition.key,\n) as readonly ReleaseFlagKey[]\n\nexport function isReleaseFlagKey(value: string): value is ReleaseFlagKey {\n return (RELEASE_FLAG_KEYS as readonly string[]).includes(value)\n}\n\nexport function getReleaseFlagDefinition(\n key: ReleaseFlagKey,\n): ReleaseFlagDefinition {\n const definition = RELEASE_FLAGS.find((entry) => entry.key === key)\n if (!definition) throw new Error(`Unknown release flag: ${key}`)\n return definition\n}\n\n/**\n * The stage a flag's definition declares, or `undefined` for a generally\n * available feature (and for a key the registry does not know, so a retired\n * key can never label anything).\n */\nexport function releaseFlagStage(\n key: ReleaseFlagKey | null | undefined,\n): ReleaseFlagStage | undefined {\n if (!key) return undefined\n return RELEASE_FLAGS.find((entry) => entry.key === key)?.stage\n}\n\n/** Whether a flag's definition declares the `beta` stage. */\nexport function isBetaStaged(key: ReleaseFlagKey | null | undefined): boolean {\n return releaseFlagStage(key) === 'beta'\n}\n\n/**\n * Whether a surface wears the Beta label: its feature is RELEASED for this\n * viewer's workspace and its flag is staged `beta`.\n *\n * `released` is the rollout verdict without the staff bypass. A staff member\n * looking at a workspace whose flag is off is previewing a feature that is\n * still rolling out, which the staff preview marker already says; calling it\n * Beta there would describe a feature the workspace does not have.\n */\nexport function showsBetaStage(\n key: ReleaseFlagKey | null | undefined,\n released: boolean | null | undefined,\n): boolean {\n return released === true && isBetaStaged(key)\n}\n\n/**\n * The stage a console surface wears, from the release flags that govern it:\n * a hub's own flag and its open section's, either of which may be absent.\n * `beta` when any of them is released for this workspace and staged beta.\n *\n * `flags` is the console's verdict map, read for `released` (the rollout\n * verdict without the staff bypass) for the reason {@link showsBetaStage}\n * gives.\n */\nexport function releaseStageOfSurface(\n keys: readonly (ReleaseFlagKey | null | undefined)[],\n flags: Partial<Record<ReleaseFlagKey, { released?: boolean } | undefined>>,\n): ReleaseFlagStage | undefined {\n return keys.some((key) => key && showsBetaStage(key, flags[key]?.released))\n ? 'beta'\n : undefined\n}\n\n/** Every flag staged `beta`, in registry order. */\nexport const BETA_STAGED_RELEASE_FLAG_KEYS: readonly ReleaseFlagKey[] =\n RELEASE_FLAGS.filter((definition) => definition.stage === 'beta').map(\n (definition) => definition.key,\n )\n\n/**\n * The JSON payload stored in each Remote Config parameter. `enabled: true`\n * turns the feature on for everyone; `enabled: false` with a positive\n * `rolloutPercent` enables it for that percentage of subjects (stable\n * per-tenant bucketing, GrowthBook-style); `plans` narrows either of those\n * to a set of tiers (AGL-2486).\n */\nexport interface ReleaseFlagValue {\n enabled: boolean\n /** 0–100; only consulted while `enabled` is false. */\n rolloutPercent?: number\n /**\n * Plan/tier targeting (AGL-2486). The tiers this flag is being rolled out\n * to, or ABSENT for \"every tier\".\n *\n * ABSENT AND EMPTY BOTH MEAN EVERY TIER, and that is load-bearing: every\n * flag stored before this field existed parses to `undefined` here, and an\n * operator who unticks every box has plainly not asked for a flag that\n * reaches nobody. Reading an empty list as \"no tiers\" would dark-launch\n * nothing while the console still said the flag was on — the inverted\n * reading of this field is the whole hazard, so it is closed in the parser\n * rather than left to each call site.\n */\n plans?: OrgPlan[]\n /** Free-form staff note (\"waiting on AGL-199\", owner, etc.). */\n note?: string\n}\n\nconst clampPercent = (value: unknown): number => {\n const percent = typeof value === 'number' && Number.isFinite(value) ? value : 0\n return Math.min(100, Math.max(0, Math.round(percent)))\n}\n\n/**\n * Every plan a flag may target, cheapest first — `PLAN_LADDER`: the\n * self-serve plans, the plans pricing v4 retired (AGL-4126) in their old\n * place, then `enterprise`. Derived, never re-typed: pricing v3 inserted\n * `scale` mid-ladder and added `agency`, and a second hand-written tier list\n * here would have missed both. The retired plans stay targetable because a\n * workspace can still be ON one, and a flag aimed at \"Pro and above\" must\n * reach it; a stored list naming one must not lose it on the next save.\n */\nexport const RELEASE_FLAG_PLAN_LADDER: readonly OrgPlan[] = PLAN_LADDER\n\nconst isOrgPlan = (value: unknown): value is OrgPlan =>\n typeof value === 'string' &&\n Object.prototype.hasOwnProperty.call(PLAN_LABELS, value)\n\n/**\n * The tiers on the ladder at or above `plan` — what the console's \"Pro and\n * above\" shortcut expands to before it is STORED as an explicit list.\n *\n * Deliberately a UI convenience and not a stored \"minimum plan\" mode: a\n * stored threshold would silently re-aim every live flag the day a tier is\n * inserted into the middle of the ladder (pricing v3 did exactly that with\n * `scale`). An explicit list means the audience of a published flag only\n * ever changes because a human changed it.\n */\nexport function releaseFlagPlansAtOrAbove(plan: OrgPlan): OrgPlan[] {\n const index = RELEASE_FLAG_PLAN_LADDER.indexOf(plan)\n return index < 0 ? [] : RELEASE_FLAG_PLAN_LADDER.slice(index)\n}\n\n/**\n * Sanitises whatever is stored at `plans`, in ladder order.\n *\n * Returns `undefined` — not `[]` — for \"no targeting declared\", so the\n * absence survives a round trip through the staff editor and cannot be\n * written back as a list that means something else. Unknown tier names are\n * dropped for the same reason `parseOrgReleaseFlagOverrides` drops unknown\n * keys: a renamed or retired tier must never gate anything. A list that\n * names ONLY unknown tiers collapses to `undefined` (every tier) rather than\n * to an empty list, because a typo must inherit, never silently target.\n */\nexport function parseReleaseFlagPlans(raw: unknown): OrgPlan[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const named = new Set(raw.filter(isOrgPlan))\n if (named.size === 0) return undefined\n return RELEASE_FLAG_PLAN_LADDER.filter((plan) => named.has(plan))\n}\n\n/**\n * Parses a Remote Config parameter string into a `ReleaseFlagValue`.\n * Tolerant by design — the template is hand-editable in the Firebase\n * console, so plain \"true\"/\"false\" strings and malformed JSON must not\n * crash gating: anything unreadable falls back to the registry default.\n */\nexport function parseReleaseFlagValue(\n raw: string | null | undefined,\n fallbackEnabled: boolean,\n): ReleaseFlagValue {\n const text = raw?.trim()\n if (!text) return { enabled: fallbackEnabled }\n if (text === 'true') return { enabled: true }\n if (text === 'false') return { enabled: false }\n try {\n const parsed = JSON.parse(text)\n if (typeof parsed === 'boolean') return { enabled: parsed }\n if (parsed && typeof parsed === 'object') {\n const plans = parseReleaseFlagPlans(parsed.plans)\n return {\n enabled: parsed.enabled === true,\n rolloutPercent: clampPercent(parsed.rolloutPercent),\n // Spread, so a flag stored before AGL-2486 has NO `plans` key at all\n // rather than an explicit `undefined`. `JSON.stringify` drops both,\n // but the two are not the same to `'plans' in value`, which is what\n // the staff PUT uses to tell \"the operator cleared the targeting\"\n // apart from \"this client never sent the field\".\n ...(plans ? { plans } : {}),\n note: typeof parsed.note === 'string' ? parsed.note : undefined,\n }\n }\n } catch {\n // fall through to the registry default\n }\n return { enabled: fallbackEnabled }\n}\n\n/**\n * The longest parameter description Remote Config will publish (AGL-3048).\n *\n * One description past it refuses the WHOLE publish with\n * `DESCRIPTION_EXCEEDS_MAXIMUM_SIZE`, which the staff flags route answered as\n * a 500. Registry descriptions are written for the staff flags page, and\n * several run far past the limit, so what the page shows and what a\n * parameter carries cannot always be the same text.\n *\n * Counted in UTF-8 BYTES. Remote Config states the limit in characters\n * without saying how it counts them, and a UTF-8 byte count is never smaller\n * than the code-point or UTF-16 count, so text within 256 bytes is within the\n * limit on every reading. The cost is a few characters of headroom on text\n * with typographic punctuation.\n */\nexport const REMOTE_CONFIG_DESCRIPTION_MAX_BYTES = 256\n\nfunction utf8ByteLength(text: string): number {\n let bytes = 0\n for (const character of text) {\n const codePoint = character.codePointAt(0) ?? 0\n bytes +=\n codePoint < 0x80 ? 1 : codePoint < 0x800 ? 2 : codePoint < 0x10000 ? 3 : 4\n }\n return bytes\n}\n\n/** Whether Remote Config accepts `text` as a parameter description. */\nexport function fitsRemoteConfigDescription(text: string): boolean {\n return utf8ByteLength(text) <= REMOTE_CONFIG_DESCRIPTION_MAX_BYTES\n}\n\nconst DESCRIPTION_ELLIPSIS = '…'\n\n/**\n * `text` cut to a length Remote Config accepts, at a word boundary, with an\n * ellipsis marking the cut. Text that already fits comes back unchanged.\n *\n * The cut takes whole code points, so a multi-byte character is never split.\n * It backs up to the last space when it lands inside a word (only a single\n * word longer than the whole budget is cut hard), and punctuation left\n * dangling before the ellipsis is dropped.\n */\nexport function clampRemoteConfigDescription(text: string): string {\n if (fitsRemoteConfigDescription(text)) return text\n const budget =\n REMOTE_CONFIG_DESCRIPTION_MAX_BYTES - utf8ByteLength(DESCRIPTION_ELLIPSIS)\n let kept = ''\n let bytes = 0\n for (const character of text) {\n const size = utf8ByteLength(character)\n if (bytes + size > budget) break\n kept += character\n bytes += size\n }\n const next = text.charAt(kept.length)\n if (next && !/\\s/.test(next)) {\n const lastSpace = kept.search(/\\s\\S*$/)\n if (lastSpace > 0) kept = kept.slice(0, lastSpace)\n }\n return `${kept.replace(/[\\s.,;:(–—-]+$/, '')}${DESCRIPTION_ELLIPSIS}`\n}\n\n/**\n * The description to publish with a release flag's Remote Config parameter\n * (AGL-3048). Always one Remote Config accepts:\n *\n * 1. The registry description, when it fits, so the flags page and the\n * parameter say the same thing.\n * 2. Otherwise the LIVE parameter's description, when it has one that fits.\n * Remote Config has already accepted exactly that text, and someone chose\n * it for the Firebase console. The first 250 characters of a longer\n * paragraph would drop whatever the paragraph says last: for\n * `release_assist`, the `/legal/subprocessors` precondition that its\n * AGL-1909 suite wants in front of whoever reads the flag there. The full\n * registry text stays on the staff flags page either way.\n * 3. Otherwise, as on a first publish with nothing live to keep, the\n * registry description clamped at a word boundary.\n */\nexport function releaseFlagParameterDescription(\n registryDescription: string,\n liveDescription: string | null | undefined,\n): string {\n if (fitsRemoteConfigDescription(registryDescription)) {\n return registryDescription\n }\n if (\n typeof liveDescription === 'string' &&\n liveDescription.trim().length > 0 &&\n fitsRemoteConfigDescription(liveDescription)\n ) {\n return liveDescription\n }\n return clampRemoteConfigDescription(registryDescription)\n}\n\n/**\n * FNV-1a 32-bit hash → 0–99 bucket. Deterministic so a subject keeps the\n * same rollout verdict across sessions and surfaces, and seeded with the\n * flag key so a subject doesn't land in the same bucket for every flag.\n */\nexport function releaseFlagBucket(flagKey: string, subjectId: string): number {\n let hash = 0x811c9dc5\n const seed = `${flagKey}:${subjectId}`\n for (let index = 0; index < seed.length; index += 1) {\n hash ^= seed.charCodeAt(index)\n hash = Math.imul(hash, 0x01000193)\n }\n return (hash >>> 0) % 100\n}\n\n/**\n * The gating verdict for one subject.\n *\n * `subjectId` is the ORG ID, or nothing. A rollout is a cohort of\n * workspaces, so a whole workspace has to land on one side of the\n * percentage: every surface that asks about an org must ask with the same\n * string, or they answer differently about the same customer.\n *\n * This docstring used to sanction falling back to the uid, and the server\n * gates fell back to a hostId. Since a hostId, a uid and an orgId hash to\n * three different buckets, a mid-rollout flag could be on in the console\n * and off on the published site for one workspace — stable per subject, so\n * it never flickered, it just stayed wrong (AGL-1656).\n *\n * An empty subject only passes fully-enabled flags. That is the deliberate\n * cost: a request with no resolvable org never joins a partial rollout,\n * which is the conservative answer rather than a confidently wrong one.\n */\nexport function isReleaseFlagOn(\n flagKey: ReleaseFlagKey,\n value: ReleaseFlagValue,\n subjectId: string | null | undefined,\n /**\n * The subject org's plan, when the caller knows it (AGL-2486). Optional so\n * every pre-existing call site compiles and answers unchanged: a flag that\n * declares no tier targeting never reads this.\n */\n plan?: OrgPlan | null,\n): boolean {\n if (!releaseFlagTargetsPlan(value, plan)) return false\n if (value.enabled) return true\n const percent = clampPercent(value.rolloutPercent)\n if (percent <= 0 || !subjectId) return false\n if (percent >= 100) return true\n return releaseFlagBucket(flagKey, subjectId) < percent\n}\n\n/**\n * Does this flag's tier targeting admit `plan`? (AGL-2486)\n *\n * THE SEMANTICS, because an operator who cannot predict the audience will\n * not stage a rollout at all:\n *\n * - The tier list is a FILTER, applied before and independently of the\n * percentage. The percentage then picks a cohort WITHIN the admitted\n * tiers. \"Pro and above at 50%\" is therefore both \"half of the Pro+\n * workspaces\" and \"the global 50% cohort, restricted to Pro+\" — the two\n * readings name the same set, and they do so because\n * {@link releaseFlagBucket} hashes `flagKey:orgId` and NOTHING ELSE.\n * - Which is also why the bucket is stable. Adding, removing or reordering\n * tiers cannot reshuffle the bucket, so an org already inside a 50%\n * rollout keeps the feature when an unrelated tier joins the list. Had\n * the plan been mixed into the hash — the obvious way to write this — a\n * tier edit would have re-drawn the cohort under every customer already\n * in it, and a plan change would have re-rolled the dice for one.\n * - The filter binds the FULLY-ENABLED path too, not just the rollout.\n * \"On, Enterprise + Agency\" is how a launch to the top of the ladder is\n * expressed, and it is what was actually asked for. Untargeted flags are\n * unaffected: no list means every tier, so `enabled` still means everyone.\n * - An UNKNOWN plan fails a declared list. Same conservatism as a missing\n * subject on a percentage rollout: a caller that cannot say which\n * workspace it is asking about gets the safe answer rather than a\n * confidently wrong one. A per-org staff override still wins over all of\n * it — see {@link isReleaseFlagOnForOrg} — so a targeted flag can still be\n * handed to one org off-ladder.\n */\nexport function releaseFlagTargetsPlan(\n value: ReleaseFlagValue,\n plan: OrgPlan | null | undefined,\n): boolean {\n const plans = value.plans\n // `!plans` would be the idiom here, but `strictNullChecks` is off repo-wide\n // and an empty array is truthy — both \"absent\" and \"empty\" have to be named\n // for the every-tier reading to actually hold.\n if (plans == null || plans.length === 0) return true\n if (!plan) return false\n return plans.includes(plan)\n}\n\n/**\n * Per-org release-flag overrides (AGL-1635), stored on the org doc at\n * `releaseFlags`. A present key is a staff DECISION about one organization\n * and wins over both the Remote Config value and the rollout bucket; an\n * absent key inherits.\n *\n * A separate field from `entitlements.features` on purpose: those ask\n * whether the org's PLAN includes a feature, these ask whether a\n * not-yet-released feature is switched on for this one customer. Folding\n * them together would make \"granted by the deal\" and \"previewing an\n * unreleased build\" indistinguishable at the point a support question is\n * asked.\n *\n * Why the org doc and not a Remote Config condition: RC conditions are\n * template-global and would need one published condition per org, with a\n * template publish (a manual, separate deploy) for every grant.\n */\nexport type OrgReleaseFlagOverrides = Partial<Record<ReleaseFlagKey, boolean>>\n\n/**\n * Sanitises whatever is actually stored at `org.releaseFlags`.\n *\n * Tolerant for the same reason `parseReleaseFlagValue` is: this map is\n * hand-editable in the Firebase console and survives registry renames, so a\n * retired flag key or a non-boolean must be dropped rather than allowed to\n * gate anything. Unknown keys are discarded — a stale key can never grant a\n * flag that no longer exists, and a typo silently inherits instead of\n * silently forcing.\n */\nexport function parseOrgReleaseFlagOverrides(\n raw: unknown,\n): OrgReleaseFlagOverrides {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {}\n const overrides: OrgReleaseFlagOverrides = {}\n for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {\n if (typeof value === 'boolean' && isReleaseFlagKey(key)) {\n overrides[key] = value\n }\n }\n return overrides\n}\n\n/**\n * The gating verdict with a per-org override applied on top of\n * `isReleaseFlagOn`.\n *\n * The override is checked FIRST and short-circuits, so a forced-off flag\n * stays off for an org even while the flag is globally enabled — the\n * per-org kill switch is half the point, not just the per-org grant. Every\n * release-flag gate resolves through here so the console, the tenant\n * runtime and the API dispatchers cannot disagree about one org.\n */\nexport function isReleaseFlagOnForOrg(\n flagKey: ReleaseFlagKey,\n value: ReleaseFlagValue,\n subjectId: string | null | undefined,\n overrides: OrgReleaseFlagOverrides | null | undefined,\n /**\n * The org's plan, for tier targeting (AGL-2486). Checked only AFTER the\n * override: a staff grant is a decision about one named customer and\n * outranks the tier filter exactly as it already outranks the rollout\n * bucket. That ordering is what lets a Free org preview a\n * Business-targeted flag without widening the flag for every Free org.\n *\n * REQUIRED, and `null` has to be typed out. It was optional for one\n * release and that cost a silent revenue bug: `report-usage` held the org\n * document, dropped the argument, and every `plans`-declaring flag read\n * OFF — so the contacts overage went uninvoiced for exactly the orgs\n * entitled to reach the feature, with nothing thrown and nothing logged.\n * An unknown tier still refuses, which is the correct conservatism; what\n * cannot be allowed is a caller MANUFACTURING an unknown out of a tier it\n * already has in hand. Spelling `null` makes that a statement rather than\n * an omission, and makes the next call site that forgets fail to compile\n * instead of failing to bill. `getOrgReleaseFlagTargeting` returns the\n * plan beside the overrides from ONE document read precisely so that\n * passing it costs nothing.\n */\n plan: OrgPlan | null,\n): boolean {\n const override = overrides?.[flagKey]\n if (typeof override === 'boolean') return override\n return isReleaseFlagOn(flagKey, value, subjectId, plan)\n}\n"],"names":["PLAN_LABELS","PLAN_LADDER","PLATFORM_BRAND_NAME","PLUGIN_RELEASE_FLAGS","RELEASE_FLAG_STAGES","isReleaseFlagStage","value","includes","PLATFORM_RELEASE_FLAGS","key","label","description","defaultEnabled","stage","RELEASE_FLAGS","RELEASE_FLAG_KEYS","map","definition","isReleaseFlagKey","getReleaseFlagDefinition","find","entry","Error","releaseFlagStage","undefined","isBetaStaged","showsBetaStage","released","releaseStageOfSurface","keys","flags","some","BETA_STAGED_RELEASE_FLAG_KEYS","filter","clampPercent","percent","Number","isFinite","Math","min","max","round","RELEASE_FLAG_PLAN_LADDER","isOrgPlan","Object","prototype","hasOwnProperty","call","releaseFlagPlansAtOrAbove","plan","index","indexOf","slice","parseReleaseFlagPlans","raw","Array","isArray","named","Set","size","has","parseReleaseFlagValue","fallbackEnabled","text","trim","enabled","parsed","JSON","parse","plans","rolloutPercent","note","REMOTE_CONFIG_DESCRIPTION_MAX_BYTES","utf8ByteLength","bytes","character","codePoint","codePointAt","fitsRemoteConfigDescription","DESCRIPTION_ELLIPSIS","clampRemoteConfigDescription","budget","kept","next","charAt","length","test","lastSpace","search","replace","releaseFlagParameterDescription","registryDescription","liveDescription","releaseFlagBucket","flagKey","subjectId","hash","seed","charCodeAt","imul","isReleaseFlagOn","releaseFlagTargetsPlan","parseOrgReleaseFlagOverrides","overrides","entries","isReleaseFlagOnForOrg","override"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC,GAED,6DAA6D;AAE7D,SAASA,WAAW,EAAEC,WAAW,QAAQ,yBAAqB;AAC9D,SAASC,mBAAmB,QAAQ,sBAAkB;AACtD,SACEC,oBAAoB,QAEf,sCAAkC;AAkDzC;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB;IAAC;CAAO,CAAS;AAIpD,OAAO,SAASC,mBAAmBC,KAAc;IAC/C,OAAO,AAACF,oBAA2CG,QAAQ,CAACD;AAC9D;AAOA;;;;;;;;;;CAUC,GACD,MAAME,yBAA2D;IAC/D;QACEC,KAAK;QACLC,OAAO;QACPC,aACE,uEACA;QACFC,gBAAgB;IAClB;IACA,2EAA2E;IAC3E,8EAA8E;IAC9E,uEAAuE;IACvE,oDAAoD;IACpD;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,0EACA,wEACA,yEACA,0EACA,uEACA,sDACA,2EACA;QACFC,gBAAgB;IAClB;IACA,2EAA2E;IAC3E,uEAAuE;IACvE,2EAA2E;IAC3E,yEAAyE;IACzE,2EAA2E;IAC3E,yEAAyE;IACzE;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,4EACA,uEACA,yEACA,yEACA,+EACA,mEACA,wEACA,uEACA;QACFC,gBAAgB;IAClB;IACA,0EAA0E;IAC1E,yEAAyE;IACzE,0EAA0E;IAC1E,mCAAmC;IACnC;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,wEACA,0DACA,wEACA;QACFC,gBAAgB;IAClB;IACA;QACEH,KAAK;QACLC,OAAO,GAAGR,oBAAoB,OAAO,CAAC;QACtC,wEAAwE;QACxE,yDAAyD;QACzDW,OAAO;QACPF,aACE,kEACA,sEACA,kEACA,0EACA,0EACA,oEACA,yEACA,mEACA,sEACA,gEACA,qEACA,sEACA,yEACA,wEACA,0EACA;QACFC,gBAAgB;IAClB;IACA,yEAAyE;IACzE,4EAA4E;IAC5E,mEAAmE;IACnE,+DAA+D;IAC/D;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,sEACA,0EACA,sEACA;QACFC,gBAAgB;IAClB;IACA,0EAA0E;IAC1E,2EAA2E;IAC3E,2EAA2E;IAC3E,wEAAwE;IACxE,uEAAuE;IACvE,uEAAuE;IACvE,6DAA6D;IAC7D;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,sEACA,2EACA,qEACA;QACFC,gBAAgB;IAClB;IACA,wEAAwE;IACxE,wEAAwE;IACxE,sEAAsE;IACtE,8DAA8D;IAC9D,yEAAyE;IACzE,yEAAyE;IACzE,wEAAwE;IACxE,sCAAsC;IACtC;QACEH,KAAK;QACL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;CA4BC,GACD,OAAO,SAASkE,uBACd/F,KAAuB,EACvB2C,IAAgC;IAEhC,MAAMoB,QAAQ/D,MAAM+D,KAAK;IACzB,4EAA4E;IAC5E,4EAA4E;IAC5E,+CAA+C;IAC/C,IAAIA,SAAS,QAAQA,MAAMgB,MAAM,KAAK,GAAG,OAAO;IAChD,IAAI,CAACpC,MAAM,OAAO;IAClB,OAAOoB,MAAM9D,QAAQ,CAAC0C;AACxB;AAqBA;;;;;;;;;CASC,GACD,OAAO,SAASqD,6BACdhD,GAAY;IAEZ,IAAI,CAACA,OAAO,OAAOA,QAAQ,YAAYC,MAAMC,OAAO,CAACF,MAAM,OAAO,CAAC;IACnE,MAAMiD,YAAqC,CAAC;IAC5C,KAAK,MAAM,CAAC9F,KAAKH,MAAM,IAAIsC,OAAO4D,OAAO,CAAClD,KAAiC;QACzE,IAAI,OAAOhD,UAAU,aAAaY,iBAAiBT,MAAM;YACvD8F,SAAS,CAAC9F,IAAI,GAAGH;QACnB;IACF;IACA,OAAOiG;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASE,sBACdX,OAAuB,EACvBxF,KAAuB,EACvByF,SAAoC,EACpCQ,SAAqD,EACrD;;;;;;;;;;;;;;;;;;;GAmBC,GACDtD,IAAoB;IAEpB,MAAMyD,WAAWH,6BAAAA,SAAW,CAACT,QAAQ;IACrC,IAAI,OAAOY,aAAa,WAAW,OAAOA;IAC1C,OAAON,gBAAgBN,SAASxF,OAAOyF,WAAW9C;AACpD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/release-flags.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 * Release flags (AGL-227): platform-level \"is this feature launched\"\n * gating backed by Firebase Remote Config. A separate axis from plan\n * entitlements (`plan-entitlements.ts`) — entitlements ask whether the\n * tenant's PLAN includes a feature, release flags ask whether the feature\n * is released to the public at all (or partially, via percentage rollout).\n * Staff bypass release flags everywhere but see a flagged warning.\n */\n\n/** Remote Config parameter keys for release-gated features. */\nimport type { OrgPlan } from '../foundation'\nimport { PLAN_LABELS, PLAN_LADDER } from './plan-entitlements'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\nimport {\n PLUGIN_RELEASE_FLAGS,\n type PluginReleaseFlagKey,\n} from './plugin-release-flags.generated'\n\n/**\n * Every release flag: the ones plugins declare (compiled from\n * plugins.config.json, AGL-3080) and the platform's own below.\n */\nexport type ReleaseFlagKey =\n | PluginReleaseFlagKey\n | 'release_addon_store'\n | 'release_native_checkout'\n | 'release_direct_charges'\n | 'release_edit_bar'\n | 'release_assist'\n | 'release_video_uploads'\n | 'release_video_delivery'\n | 'release_ai_generative'\n | 'release_ai_site_import'\n | 'release_ai_site_import_generative'\n | 'release_crm_assist_whole_record'\n | 'release_ai_site_inspiration'\n | 'release_ad_audience_sync'\n | 'release_site_starters'\n | 'release_video_embed_posters'\n\nexport interface ReleaseFlagDefinition {\n key: ReleaseFlagKey\n label: string\n description: string\n /**\n * Fallback verdict when Remote Config is unreachable (offline, blocked,\n * first paint before activate). MUST match the seeded value in\n * cloud/firebase-remoteconfig.template.json so environments without a\n * published template behave like the template intends.\n */\n defaultEnabled: boolean\n /** Host dashboard tab id (host-nav-tabs.ts) this flag hides, if any. */\n navTabId?: string\n /**\n * Where a RELEASED feature stands, when it is still changing. Absent means\n * generally available, which is what every feature without a stage is.\n *\n * Data only. A stage never gates anything, and it says nothing while the\n * flag is off: an off feature is rolling out, whatever its stage reads. The\n * console labels an on, `beta`-staged feature Beta beside its nav tab and\n * its hub header, and the docs open its pages with a `:::note Beta`\n * admonition, which `docs-release-flags.spec.ts` holds to this field.\n */\n stage?: ReleaseFlagStage\n}\n\n/**\n * The stages a released feature can be in short of general availability.\n * One today. A stage is per feature, never platform-wide: features keep\n * arriving in beta for as long as the product grows.\n */\nexport const RELEASE_FLAG_STAGES = ['beta'] as const\n\nexport type ReleaseFlagStage = (typeof RELEASE_FLAG_STAGES)[number]\n\nexport function isReleaseFlagStage(value: unknown): value is ReleaseFlagStage {\n return (RELEASE_FLAG_STAGES as readonly unknown[]).includes(value)\n}\n\n/** A release flag a plugin declares, as the generator compiles it. */\nexport type PluginReleaseFlagDefinition = ReleaseFlagDefinition & {\n key: PluginReleaseFlagKey\n}\n\n/**\n * The platform's own release flags: features no plugin owns.\n *\n * Every first-party plugin is release-flagged too (AGL-422) — the flag feeds\n * the plugin LOADER (console, published sites, API dispatch), not just nav\n * visibility, so staff can kill-switch a whole plugin platform-wide from the\n * Feature Flags page. Those flags are the plugins' own: each is defined by\n * its catalog row's `releaseFlagDefinition` in plugins.config.json and\n * compiled into `PLUGIN_RELEASE_FLAGS`, so adding a plugin edits nothing\n * here.\n */\nconst PLATFORM_RELEASE_FLAGS: readonly ReleaseFlagDefinition[] = [\n {\n key: 'release_addon_store',\n label: 'Add-on store',\n description:\n 'Self-serve add-on purchases on the Billing page: seats, datasets, ' +\n 'extra sites, POS registers, Event Calendar (AGL-524..531).',\n defaultEnabled: true,\n },\n // Released to every workspace 2026-10-06 (AGL-3606). Storefront-only since\n // the console's plan checkout stopped rendering Stripe Checkout at all. Still\n // the surface's kill switch, globally or per org: off, both storefront\n // checkout routes return the hosted redirect again.\n {\n key: 'release_native_checkout',\n label: 'In-page checkout',\n description:\n 'Storefront shoppers pay on the merchant\\u2019s own site: the Payment ' +\n 'Element, email, shipping address and method, and a live total with ' +\n 'tax open in place under the Buy or Checkout button, styled with the ' +\n 'site theme, instead of a redirect to checkout.stripe.com (AGL-1944). ' +\n 'Released to every workspace 2026-10-06 (AGL-3606). The webhook is ' +\n 'still the only thing that fulfils. Also gated on ' +\n 'NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY, so a deployment without one keeps ' +\n 'the redirect; turning this off returns every storefront to the redirect.',\n defaultEnabled: true,\n },\n // Released to every store 2026-11-06, after the Terms (v24, v25) named a site's\n // own Stripe account as the seller of record. On, a store that sets up\n // payments gets a full Stripe account of its own and its sales, online and\n // in person, become direct charges on it. It stays the kill switch: off,\n // new setups get the platform-managed account again. Neither state changes\n // an account already created: the account itself decides how it charges.\n {\n key: 'release_direct_charges',\n label: 'Sellers get their own Stripe account',\n description:\n 'When a store sets up payments it gets a full Stripe account of its own ' +\n '(Stripe bills it, Stripe Dashboard included), and its site sales, ' +\n 'quotes, invoices, bookings and in-person card sales (the register and ' +\n 'Tap to Pay) are charged directly on that account: the store is the ' +\n 'seller of record, owns refunds, disputes and sales tax, and the ' +\n 'platform keeps only its plan take as an application fee. Plugin ' +\n 'marketplace sales stay on the platform account. Off: new stores get ' +\n 'the platform-managed account ' +\n 'and destination charges, as before. Accounts already created keep ' +\n 'whichever shape they were created with.',\n defaultEnabled: true,\n },\n // Released to every site 2026-09-16 (AGL-3041). Still the whole surface's\n // kill switch, globally or for one org by override: off, the tenant slot\n // renders nothing, both token mints refuse, and `/api/edit-context` turns\n // away every token already issued.\n {\n key: 'release_edit_bar',\n label: 'Site admin bar',\n description:\n 'Admin bar on published sites: a signed-in editor jumps from a live ' +\n 'page straight into the Besigner to edit it. Released ' +\n '2026-09-16 (AGL-3041) for every site; turning it off hides the bar ' +\n 'and revokes every outstanding edit token at the verify site.',\n defaultEnabled: true,\n },\n {\n key: 'release_assist',\n label: `${PLATFORM_BRAND_NAME} Assist`,\n // Released to every workspace and still changing: what it answers, what\n // it can build from a message and how it cites the docs.\n stage: 'beta',\n description:\n 'The in-console AI chat helper on every page (AGL-1860): docs-' +\n 'grounded answers with deep links, page-context guidance on Pro+. ' +\n 'ON in production, and gated on TWO published legal artifacts ' +\n '(AGL-1909), neither of which is a repo file — both are live besigner ' +\n 'pages, so publication is what satisfies them: (1) the privacy-policy ' +\n 'disclosure for stored Q&A, because the data loop records every ' +\n 'exchange org-scoped under orgs/{orgId}/assistExchanges; and (2) the ' +\n 'Anthropic row on /legal/subprocessors, which was deliberately ' +\n 'REMOVED on 2026-08-13 (subprocessorsV2a-20260813) on the premise ' +\n 'that no production key existed — so the page is not merely ' +\n 'incomplete without it, it is affirmatively wrong. NOTE the real ' +\n 'trigger is ANTHROPIC_API_KEY, not this flag: /api/ai/assist (the ' +\n 'besigner copy assistant, AGL-89/130/169) carries no release flag at ' +\n 'all and sends customer site content to Anthropic on the key plus a ' +\n 'Pro entitlement alone. Setting the key in production therefore makes ' +\n 'Anthropic a subprocessor whether or not this flag is ever flipped.',\n defaultEnabled: true,\n },\n // Ingress only, and with no staff preview on the server: a video a staff\n // session uploads into a customer's library serves on that customer's pages\n // like any other, so a grant goes to the org through its override.\n // `apps/console/utils/server/video-uploads.ts` holds the gate.\n {\n key: 'release_video_uploads',\n label: 'Video uploads',\n description:\n 'New video in the media library, on every upload path (AGL-2830). ' +\n 'Off: refused with 403 video_uploads_paused, as DAM video delivery is ' +\n 'not yet metered or bounded per org (AGL-2810, AGL-2812). Images, ' +\n 'documents and stored videos are unaffected.',\n defaultEnabled: false,\n },\n // Delivery, not ingress: this flag decides whether a video already in the\n // library is COPIED to the configured delivery provider and served from it\n // through a short-lived signed redirect (AGL-2824). Per org, with no staff\n // preview on the server — a copy is customer data at the provider, so a\n // grant goes to the org through its override. Off, or with no provider\n // configured, every video serves from this platform exactly as before.\n // `media-delivery.ts` in `tenant-data-admin` holds the gate.\n {\n key: 'release_video_delivery',\n label: 'Video delivery',\n description:\n 'Serves library video from a configured delivery provider through ' +\n 'short-lived signed redirects, and copies each video to it (AGL-2824). ' +\n 'OFF by default: video serves from this platform as before. Also ' +\n \"needs the provider's settings.\",\n defaultEnabled: false,\n },\n // The generative doors share one runtime with Assist (AGL-2903) but not\n // its flag: `release_assist` answers questions, this builds things, and\n // the two are sold, metered and disclosed separately. The server-side\n // gate lives in `aiGateLadder` (404 when off, staff preview).\n // Labeled for what it switches — the generative doors — and not with the\n // add-on's own name, which is sold and live whether or not the doors are\n // released: the docs name the add-on, and a flag wearing the same words\n // reads as documented when it is not.\n {\n key: 'release_ai_generative',\n label: `${PLATFORM_BRAND_NAME} AI generation`,\n // Released to every workspace and still changing: the guided start, page\n // and section generation and the other generative doors.\n stage: 'beta',\n description:\n 'Generative building and automation behind the AI add-on ' +\n '(AGL-2903): sections, pages and workflows written by a model from ' +\n 'a brief, on the shared Anthropic runtime. ON for every workspace ' +\n 'since 2026-09-29; every generative route answers 404 while it is ' +\n 'off. On, it sends customer briefs and site content to Anthropic ' +\n 'on the same ANTHROPIC_API_KEY and under the same subprocessor ' +\n 'disclosure as Assist (AGL-1909).',\n defaultEnabled: true,\n },\n // \"Bring my site\" (AGL-3973): proving a workspace owns a website, and the\n // crawl that reads it once it has. OFF by default so a code change can\n // never be what releases it; the doors answer 404 while it is off, with a\n // staff preview. Its own flag rather than `release_ai_generative`, because\n // reading someone's website is a different thing to disclose than\n // writing from a brief.\n {\n key: 'release_ai_site_import',\n label: 'Bring my site',\n // Released on every paid plan and still changing: how pages are read,\n // rewritten in the new design and brought in wave by wave.\n stage: 'beta',\n description:\n 'Bring an existing website into a workspace on a paid plan (AGL-3973): ' +\n 'the workspace proves it owns the domain (a DNS record, a home page ' +\n 'meta tag, or a code emailed to an address at the domain), then ' +\n 'AglynBot reads the site within robots.txt, same-origin only, under ' +\n 'page, byte and time budgets. ON since 2026-10-25 (beta.282, after the ' +\n 'Legal v18 import clause and the blocked-page reason, AGL-4029); turned ' +\n 'off, the ownership and crawl doors answer 404.',\n defaultEnabled: true,\n },\n // Improve it, generative (AGL-4152): under Bring my site's Improve it, the\n // site is planned before anything is built, its menu and design drawn to it,\n // and with new copy on a page is redesigned from a ledger of what the source\n // holds, with new sections. Off by default and off everywhere in production\n // until its paid eval and the owner's read pass; a test organization gets it\n // with the per-org override, `orgs/{orgId}.releaseFlags`. Off, Improve it is\n // exactly what `release_ai_site_import` ships today.\n {\n key: 'release_ai_site_import_generative',\n label: 'Bring my site: generative Improve it',\n description:\n 'Under Improve it, the site is planned before anything is built: its ' +\n 'menu, footer, design and one proposed page. With new copy on, each main ' +\n 'page is redesigned from what the source holds: sections added, new copy ' +\n 'written and checked so that it invents no name, number, price or ' +\n 'credential (AGL-4152). OFF by default; on for one organization by its per-org ' +\n 'override while it is evaluated. Off, Improve it is unchanged.',\n defaultEnabled: false,\n },\n // What CRM assistance hands the model provider, not whether it runs:\n // `release_ai_generative` opens the doors, this widens what a record sends\n // through them. Per org, with no staff preview — the data is the customer's,\n // and a staff session reading a customer's record must send what the\n // published pages promise. The CRM's record-facts readers hold the gate.\n {\n key: 'release_crm_assist_whole_record',\n label: 'CRM assistance: whole record',\n description:\n 'What AI assistance in the CRM (a record summary, next step or ' +\n 'email draft) sends the model provider (AGL-3520). OFF: the ' +\n 'disclosed fields, with addresses and numbers in typed text ' +\n 'replaced. ON: the whole record, contact details and custom fields ' +\n 'included. ON since 2026-10-05, after Privacy Policy section 2 and ' +\n 'the Subprocessors row were republished; see ' +\n 'docs/drafts/agl-3520-crm-assistance-whole-record-disclosure.md.',\n defaultEnabled: true,\n },\n // Per org, with no staff preview on the server: the site job reads the\n // sites a person names only where the org's verdict is on, and the guided\n // start asks for them by the same verdict. `model/ai-site-inspiration.ts`\n // in the AI plugin holds the key.\n {\n key: 'release_ai_site_inspiration',\n label: 'AI site start: sites you like',\n description:\n 'The guided AI site start asks for sites the person likes (AGL-3975): ' +\n 'one on Free, three on a paid plan. The site job reads each home page ' +\n 'and two of its stylesheets through the SSRF-guarded fetch and keeps ' +\n 'signals only (section order, spacing, header, colors, type mood, ' +\n 'button and card shape, motion, and on a paid plan the features it ' +\n 'offers), never its words, images or logos. ON since 2026-10-28, ' +\n 'after its live eval re-run passed; turned off, no field is shown ' +\n 'and no site is read.',\n defaultEnabled: true,\n },\n // Platform-wide, never per org: the nightly job reads only the platform\n // value, because it is the operator's own marketing and no workspace's\n // feature. `apps/console/app/api/admin/ad-audience-sync/route.ts` holds the\n // gate; a dry run reports the counts whichever way it is set.\n {\n key: 'release_ad_audience_sync',\n label: 'Account-holder ad audiences',\n description:\n 'Nightly sync of United States account holders, as SHA-256 hashed ' +\n 'email addresses, to the operator\\u2019s own Meta, Google and LinkedIn ' +\n 'customer-list audiences (AGL-3780). OFF by default: nothing is sent ' +\n 'until the Privacy Policy that discloses it is published.',\n defaultEnabled: false,\n },\n // Per org (AGL-4049): \"Create site\" is to offer the starter picker only\n // where the org's verdict is on. Nothing reads the flag yet, and off it\n // creates the default site as it always has.\n {\n key: 'release_site_starters',\n label: 'Site starters from the marketplace',\n description:\n 'Create site asks the person to choose a starter (AGL-4049): every ' +\n `option, ${PLATFORM_BRAND_NAME}\\u2019s own included, is a marketplace listing any ` +\n 'publisher may list and price, for a base start or an AI start. OFF ' +\n 'by default: Create site makes the default site as it always has.',\n defaultEnabled: false,\n },\n // Per org (AGL-4140): the tenant loader reads it for the site's workspace\n // into `SiteContextValue.videoEmbedPosters`, the lockdown verdict reads it\n // for the middleware's `img-src`, and a site import stamps it on each wave\n // as the wave starts. Off, a poster-less YouTube film asks for a poster,\n // as it always has.\n {\n key: 'release_video_embed_posters',\n label: 'YouTube thumbnails as video posters',\n description:\n 'A YouTube film placed or imported with no poster shows YouTube\\u2019s ' +\n 'own thumbnail (AGL-4140), which each visitor\\u2019s browser loads from ' +\n 'i.ytimg.com with the page. OFF by default: nothing is requested from ' +\n 'Google until the Subprocessors page that discloses it is published.',\n defaultEnabled: false,\n },\n]\n\n/**\n * The registry: one entry per gated feature, the plugins' first. Adding a\n * platform flag = add it above, seed it in the Remote Config template, and\n * (optionally) wrap the page in `<FeatureGate>` — the staff admin editor and\n * nav filtering pick it up from this list.\n */\nexport const RELEASE_FLAGS: readonly ReleaseFlagDefinition[] = [\n ...PLUGIN_RELEASE_FLAGS,\n ...PLATFORM_RELEASE_FLAGS,\n]\n\nexport const RELEASE_FLAG_KEYS = RELEASE_FLAGS.map(\n (definition) => definition.key,\n) as readonly ReleaseFlagKey[]\n\nexport function isReleaseFlagKey(value: string): value is ReleaseFlagKey {\n return (RELEASE_FLAG_KEYS as readonly string[]).includes(value)\n}\n\nexport function getReleaseFlagDefinition(\n key: ReleaseFlagKey,\n): ReleaseFlagDefinition {\n const definition = RELEASE_FLAGS.find((entry) => entry.key === key)\n if (!definition) throw new Error(`Unknown release flag: ${key}`)\n return definition\n}\n\n/**\n * The stage a flag's definition declares, or `undefined` for a generally\n * available feature (and for a key the registry does not know, so a retired\n * key can never label anything).\n */\nexport function releaseFlagStage(\n key: ReleaseFlagKey | null | undefined,\n): ReleaseFlagStage | undefined {\n if (!key) return undefined\n return RELEASE_FLAGS.find((entry) => entry.key === key)?.stage\n}\n\n/** Whether a flag's definition declares the `beta` stage. */\nexport function isBetaStaged(key: ReleaseFlagKey | null | undefined): boolean {\n return releaseFlagStage(key) === 'beta'\n}\n\n/**\n * Whether a surface wears the Beta label: its feature is RELEASED for this\n * viewer's workspace and its flag is staged `beta`.\n *\n * `released` is the rollout verdict without the staff bypass. A staff member\n * looking at a workspace whose flag is off is previewing a feature that is\n * still rolling out, which the staff preview marker already says; calling it\n * Beta there would describe a feature the workspace does not have.\n */\nexport function showsBetaStage(\n key: ReleaseFlagKey | null | undefined,\n released: boolean | null | undefined,\n): boolean {\n return released === true && isBetaStaged(key)\n}\n\n/**\n * The stage a console surface wears, from the release flags that govern it:\n * a hub's own flag and its open section's, either of which may be absent.\n * `beta` when any of them is released for this workspace and staged beta.\n *\n * `flags` is the console's verdict map, read for `released` (the rollout\n * verdict without the staff bypass) for the reason {@link showsBetaStage}\n * gives.\n */\nexport function releaseStageOfSurface(\n keys: readonly (ReleaseFlagKey | null | undefined)[],\n flags: Partial<Record<ReleaseFlagKey, { released?: boolean } | undefined>>,\n): ReleaseFlagStage | undefined {\n return keys.some((key) => key && showsBetaStage(key, flags[key]?.released))\n ? 'beta'\n : undefined\n}\n\n/** Every flag staged `beta`, in registry order. */\nexport const BETA_STAGED_RELEASE_FLAG_KEYS: readonly ReleaseFlagKey[] =\n RELEASE_FLAGS.filter((definition) => definition.stage === 'beta').map(\n (definition) => definition.key,\n )\n\n/**\n * The JSON payload stored in each Remote Config parameter. `enabled: true`\n * turns the feature on for everyone; `enabled: false` with a positive\n * `rolloutPercent` enables it for that percentage of subjects (stable\n * per-tenant bucketing, GrowthBook-style); `plans` narrows either of those\n * to a set of tiers (AGL-2486).\n */\nexport interface ReleaseFlagValue {\n enabled: boolean\n /** 0–100; only consulted while `enabled` is false. */\n rolloutPercent?: number\n /**\n * Plan/tier targeting (AGL-2486). The tiers this flag is being rolled out\n * to, or ABSENT for \"every tier\".\n *\n * ABSENT AND EMPTY BOTH MEAN EVERY TIER, and that is load-bearing: every\n * flag stored before this field existed parses to `undefined` here, and an\n * operator who unticks every box has plainly not asked for a flag that\n * reaches nobody. Reading an empty list as \"no tiers\" would dark-launch\n * nothing while the console still said the flag was on — the inverted\n * reading of this field is the whole hazard, so it is closed in the parser\n * rather than left to each call site.\n */\n plans?: OrgPlan[]\n /** Free-form staff note (\"waiting on AGL-199\", owner, etc.). */\n note?: string\n}\n\nconst clampPercent = (value: unknown): number => {\n const percent = typeof value === 'number' && Number.isFinite(value) ? value : 0\n return Math.min(100, Math.max(0, Math.round(percent)))\n}\n\n/**\n * Every plan a flag may target, cheapest first — `PLAN_LADDER`: the\n * self-serve plans, the plans pricing v4 retired (AGL-4126) in their old\n * place, then `enterprise`. Derived, never re-typed: pricing v3 inserted\n * `scale` mid-ladder and added `agency`, and a second hand-written tier list\n * here would have missed both. The retired plans stay targetable because a\n * workspace can still be ON one, and a flag aimed at \"Pro and above\" must\n * reach it; a stored list naming one must not lose it on the next save.\n */\nexport const RELEASE_FLAG_PLAN_LADDER: readonly OrgPlan[] = PLAN_LADDER\n\nconst isOrgPlan = (value: unknown): value is OrgPlan =>\n typeof value === 'string' &&\n Object.prototype.hasOwnProperty.call(PLAN_LABELS, value)\n\n/**\n * The tiers on the ladder at or above `plan` — what the console's \"Pro and\n * above\" shortcut expands to before it is STORED as an explicit list.\n *\n * Deliberately a UI convenience and not a stored \"minimum plan\" mode: a\n * stored threshold would silently re-aim every live flag the day a tier is\n * inserted into the middle of the ladder (pricing v3 did exactly that with\n * `scale`). An explicit list means the audience of a published flag only\n * ever changes because a human changed it.\n */\nexport function releaseFlagPlansAtOrAbove(plan: OrgPlan): OrgPlan[] {\n const index = RELEASE_FLAG_PLAN_LADDER.indexOf(plan)\n return index < 0 ? [] : RELEASE_FLAG_PLAN_LADDER.slice(index)\n}\n\n/**\n * Sanitises whatever is stored at `plans`, in ladder order.\n *\n * Returns `undefined` — not `[]` — for \"no targeting declared\", so the\n * absence survives a round trip through the staff editor and cannot be\n * written back as a list that means something else. Unknown tier names are\n * dropped for the same reason `parseOrgReleaseFlagOverrides` drops unknown\n * keys: a renamed or retired tier must never gate anything. A list that\n * names ONLY unknown tiers collapses to `undefined` (every tier) rather than\n * to an empty list, because a typo must inherit, never silently target.\n */\nexport function parseReleaseFlagPlans(raw: unknown): OrgPlan[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const named = new Set(raw.filter(isOrgPlan))\n if (named.size === 0) return undefined\n return RELEASE_FLAG_PLAN_LADDER.filter((plan) => named.has(plan))\n}\n\n/**\n * Parses a Remote Config parameter string into a `ReleaseFlagValue`.\n * Tolerant by design — the template is hand-editable in the Firebase\n * console, so plain \"true\"/\"false\" strings and malformed JSON must not\n * crash gating: anything unreadable falls back to the registry default.\n */\nexport function parseReleaseFlagValue(\n raw: string | null | undefined,\n fallbackEnabled: boolean,\n): ReleaseFlagValue {\n const text = raw?.trim()\n if (!text) return { enabled: fallbackEnabled }\n if (text === 'true') return { enabled: true }\n if (text === 'false') return { enabled: false }\n try {\n const parsed = JSON.parse(text)\n if (typeof parsed === 'boolean') return { enabled: parsed }\n if (parsed && typeof parsed === 'object') {\n const plans = parseReleaseFlagPlans(parsed.plans)\n return {\n enabled: parsed.enabled === true,\n rolloutPercent: clampPercent(parsed.rolloutPercent),\n // Spread, so a flag stored before AGL-2486 has NO `plans` key at all\n // rather than an explicit `undefined`. `JSON.stringify` drops both,\n // but the two are not the same to `'plans' in value`, which is what\n // the staff PUT uses to tell \"the operator cleared the targeting\"\n // apart from \"this client never sent the field\".\n ...(plans ? { plans } : {}),\n note: typeof parsed.note === 'string' ? parsed.note : undefined,\n }\n }\n } catch {\n // fall through to the registry default\n }\n return { enabled: fallbackEnabled }\n}\n\n/**\n * The longest parameter description Remote Config will publish (AGL-3048).\n *\n * One description past it refuses the WHOLE publish with\n * `DESCRIPTION_EXCEEDS_MAXIMUM_SIZE`, which the staff flags route answered as\n * a 500. Registry descriptions are written for the staff flags page, and\n * several run far past the limit, so what the page shows and what a\n * parameter carries cannot always be the same text.\n *\n * Counted in UTF-8 BYTES. Remote Config states the limit in characters\n * without saying how it counts them, and a UTF-8 byte count is never smaller\n * than the code-point or UTF-16 count, so text within 256 bytes is within the\n * limit on every reading. The cost is a few characters of headroom on text\n * with typographic punctuation.\n */\nexport const REMOTE_CONFIG_DESCRIPTION_MAX_BYTES = 256\n\nfunction utf8ByteLength(text: string): number {\n let bytes = 0\n for (const character of text) {\n const codePoint = character.codePointAt(0) ?? 0\n bytes +=\n codePoint < 0x80 ? 1 : codePoint < 0x800 ? 2 : codePoint < 0x10000 ? 3 : 4\n }\n return bytes\n}\n\n/** Whether Remote Config accepts `text` as a parameter description. */\nexport function fitsRemoteConfigDescription(text: string): boolean {\n return utf8ByteLength(text) <= REMOTE_CONFIG_DESCRIPTION_MAX_BYTES\n}\n\nconst DESCRIPTION_ELLIPSIS = '…'\n\n/**\n * `text` cut to a length Remote Config accepts, at a word boundary, with an\n * ellipsis marking the cut. Text that already fits comes back unchanged.\n *\n * The cut takes whole code points, so a multi-byte character is never split.\n * It backs up to the last space when it lands inside a word (only a single\n * word longer than the whole budget is cut hard), and punctuation left\n * dangling before the ellipsis is dropped.\n */\nexport function clampRemoteConfigDescription(text: string): string {\n if (fitsRemoteConfigDescription(text)) return text\n const budget =\n REMOTE_CONFIG_DESCRIPTION_MAX_BYTES - utf8ByteLength(DESCRIPTION_ELLIPSIS)\n let kept = ''\n let bytes = 0\n for (const character of text) {\n const size = utf8ByteLength(character)\n if (bytes + size > budget) break\n kept += character\n bytes += size\n }\n const next = text.charAt(kept.length)\n if (next && !/\\s/.test(next)) {\n const lastSpace = kept.search(/\\s\\S*$/)\n if (lastSpace > 0) kept = kept.slice(0, lastSpace)\n }\n return `${kept.replace(/[\\s.,;:(–—-]+$/, '')}${DESCRIPTION_ELLIPSIS}`\n}\n\n/**\n * The description to publish with a release flag's Remote Config parameter\n * (AGL-3048). Always one Remote Config accepts:\n *\n * 1. The registry description, when it fits, so the flags page and the\n * parameter say the same thing.\n * 2. Otherwise the LIVE parameter's description, when it has one that fits.\n * Remote Config has already accepted exactly that text, and someone chose\n * it for the Firebase console. The first 250 characters of a longer\n * paragraph would drop whatever the paragraph says last: for\n * `release_assist`, the `/legal/subprocessors` precondition that its\n * AGL-1909 suite wants in front of whoever reads the flag there. The full\n * registry text stays on the staff flags page either way.\n * 3. Otherwise, as on a first publish with nothing live to keep, the\n * registry description clamped at a word boundary.\n */\nexport function releaseFlagParameterDescription(\n registryDescription: string,\n liveDescription: string | null | undefined,\n): string {\n if (fitsRemoteConfigDescription(registryDescription)) {\n return registryDescription\n }\n if (\n typeof liveDescription === 'string' &&\n liveDescription.trim().length > 0 &&\n fitsRemoteConfigDescription(liveDescription)\n ) {\n return liveDescription\n }\n return clampRemoteConfigDescription(registryDescription)\n}\n\n/**\n * FNV-1a 32-bit hash → 0–99 bucket. Deterministic so a subject keeps the\n * same rollout verdict across sessions and surfaces, and seeded with the\n * flag key so a subject doesn't land in the same bucket for every flag.\n */\nexport function releaseFlagBucket(flagKey: string, subjectId: string): number {\n let hash = 0x811c9dc5\n const seed = `${flagKey}:${subjectId}`\n for (let index = 0; index < seed.length; index += 1) {\n hash ^= seed.charCodeAt(index)\n hash = Math.imul(hash, 0x01000193)\n }\n return (hash >>> 0) % 100\n}\n\n/**\n * The gating verdict for one subject.\n *\n * `subjectId` is the ORG ID, or nothing. A rollout is a cohort of\n * workspaces, so a whole workspace has to land on one side of the\n * percentage: every surface that asks about an org must ask with the same\n * string, or they answer differently about the same customer.\n *\n * This docstring used to sanction falling back to the uid, and the server\n * gates fell back to a hostId. Since a hostId, a uid and an orgId hash to\n * three different buckets, a mid-rollout flag could be on in the console\n * and off on the published site for one workspace — stable per subject, so\n * it never flickered, it just stayed wrong (AGL-1656).\n *\n * An empty subject only passes fully-enabled flags. That is the deliberate\n * cost: a request with no resolvable org never joins a partial rollout,\n * which is the conservative answer rather than a confidently wrong one.\n */\nexport function isReleaseFlagOn(\n flagKey: ReleaseFlagKey,\n value: ReleaseFlagValue,\n subjectId: string | null | undefined,\n /**\n * The subject org's plan, when the caller knows it (AGL-2486). Optional so\n * every pre-existing call site compiles and answers unchanged: a flag that\n * declares no tier targeting never reads this.\n */\n plan?: OrgPlan | null,\n): boolean {\n if (!releaseFlagTargetsPlan(value, plan)) return false\n if (value.enabled) return true\n const percent = clampPercent(value.rolloutPercent)\n if (percent <= 0 || !subjectId) return false\n if (percent >= 100) return true\n return releaseFlagBucket(flagKey, subjectId) < percent\n}\n\n/**\n * Does this flag's tier targeting admit `plan`? (AGL-2486)\n *\n * THE SEMANTICS, because an operator who cannot predict the audience will\n * not stage a rollout at all:\n *\n * - The tier list is a FILTER, applied before and independently of the\n * percentage. The percentage then picks a cohort WITHIN the admitted\n * tiers. \"Pro and above at 50%\" is therefore both \"half of the Pro+\n * workspaces\" and \"the global 50% cohort, restricted to Pro+\" — the two\n * readings name the same set, and they do so because\n * {@link releaseFlagBucket} hashes `flagKey:orgId` and NOTHING ELSE.\n * - Which is also why the bucket is stable. Adding, removing or reordering\n * tiers cannot reshuffle the bucket, so an org already inside a 50%\n * rollout keeps the feature when an unrelated tier joins the list. Had\n * the plan been mixed into the hash — the obvious way to write this — a\n * tier edit would have re-drawn the cohort under every customer already\n * in it, and a plan change would have re-rolled the dice for one.\n * - The filter binds the FULLY-ENABLED path too, not just the rollout.\n * \"On, Enterprise + Agency\" is how a launch to the top of the ladder is\n * expressed, and it is what was actually asked for. Untargeted flags are\n * unaffected: no list means every tier, so `enabled` still means everyone.\n * - An UNKNOWN plan fails a declared list. Same conservatism as a missing\n * subject on a percentage rollout: a caller that cannot say which\n * workspace it is asking about gets the safe answer rather than a\n * confidently wrong one. A per-org staff override still wins over all of\n * it — see {@link isReleaseFlagOnForOrg} — so a targeted flag can still be\n * handed to one org off-ladder.\n */\nexport function releaseFlagTargetsPlan(\n value: ReleaseFlagValue,\n plan: OrgPlan | null | undefined,\n): boolean {\n const plans = value.plans\n // `!plans` would be the idiom here, but `strictNullChecks` is off repo-wide\n // and an empty array is truthy — both \"absent\" and \"empty\" have to be named\n // for the every-tier reading to actually hold.\n if (plans == null || plans.length === 0) return true\n if (!plan) return false\n return plans.includes(plan)\n}\n\n/**\n * Per-org release-flag overrides (AGL-1635), stored on the org doc at\n * `releaseFlags`. A present key is a staff DECISION about one organization\n * and wins over both the Remote Config value and the rollout bucket; an\n * absent key inherits.\n *\n * A separate field from `entitlements.features` on purpose: those ask\n * whether the org's PLAN includes a feature, these ask whether a\n * not-yet-released feature is switched on for this one customer. Folding\n * them together would make \"granted by the deal\" and \"previewing an\n * unreleased build\" indistinguishable at the point a support question is\n * asked.\n *\n * Why the org doc and not a Remote Config condition: RC conditions are\n * template-global and would need one published condition per org, with a\n * template publish (a manual, separate deploy) for every grant.\n */\nexport type OrgReleaseFlagOverrides = Partial<Record<ReleaseFlagKey, boolean>>\n\n/**\n * Sanitises whatever is actually stored at `org.releaseFlags`.\n *\n * Tolerant for the same reason `parseReleaseFlagValue` is: this map is\n * hand-editable in the Firebase console and survives registry renames, so a\n * retired flag key or a non-boolean must be dropped rather than allowed to\n * gate anything. Unknown keys are discarded — a stale key can never grant a\n * flag that no longer exists, and a typo silently inherits instead of\n * silently forcing.\n */\nexport function parseOrgReleaseFlagOverrides(\n raw: unknown,\n): OrgReleaseFlagOverrides {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {}\n const overrides: OrgReleaseFlagOverrides = {}\n for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {\n if (typeof value === 'boolean' && isReleaseFlagKey(key)) {\n overrides[key] = value\n }\n }\n return overrides\n}\n\n/**\n * The gating verdict with a per-org override applied on top of\n * `isReleaseFlagOn`.\n *\n * The override is checked FIRST and short-circuits, so a forced-off flag\n * stays off for an org even while the flag is globally enabled — the\n * per-org kill switch is half the point, not just the per-org grant. Every\n * release-flag gate resolves through here so the console, the tenant\n * runtime and the API dispatchers cannot disagree about one org.\n */\nexport function isReleaseFlagOnForOrg(\n flagKey: ReleaseFlagKey,\n value: ReleaseFlagValue,\n subjectId: string | null | undefined,\n overrides: OrgReleaseFlagOverrides | null | undefined,\n /**\n * The org's plan, for tier targeting (AGL-2486). Checked only AFTER the\n * override: a staff grant is a decision about one named customer and\n * outranks the tier filter exactly as it already outranks the rollout\n * bucket. That ordering is what lets a Free org preview a\n * Business-targeted flag without widening the flag for every Free org.\n *\n * REQUIRED, and `null` has to be typed out. It was optional for one\n * release and that cost a silent revenue bug: `report-usage` held the org\n * document, dropped the argument, and every `plans`-declaring flag read\n * OFF — so the contacts overage went uninvoiced for exactly the orgs\n * entitled to reach the feature, with nothing thrown and nothing logged.\n * An unknown tier still refuses, which is the correct conservatism; what\n * cannot be allowed is a caller MANUFACTURING an unknown out of a tier it\n * already has in hand. Spelling `null` makes that a statement rather than\n * an omission, and makes the next call site that forgets fail to compile\n * instead of failing to bill. `getOrgReleaseFlagTargeting` returns the\n * plan beside the overrides from ONE document read precisely so that\n * passing it costs nothing.\n */\n plan: OrgPlan | null,\n): boolean {\n const override = overrides?.[flagKey]\n if (typeof override === 'boolean') return override\n return isReleaseFlagOn(flagKey, value, subjectId, plan)\n}\n"],"names":["PLAN_LABELS","PLAN_LADDER","PLATFORM_BRAND_NAME","PLUGIN_RELEASE_FLAGS","RELEASE_FLAG_STAGES","isReleaseFlagStage","value","includes","PLATFORM_RELEASE_FLAGS","key","label","description","defaultEnabled","stage","RELEASE_FLAGS","RELEASE_FLAG_KEYS","map","definition","isReleaseFlagKey","getReleaseFlagDefinition","find","entry","Error","releaseFlagStage","undefined","isBetaStaged","showsBetaStage","released","releaseStageOfSurface","keys","flags","some","BETA_STAGED_RELEASE_FLAG_KEYS","filter","clampPercent","percent","Number","isFinite","Math","min","max","round","RELEASE_FLAG_PLAN_LADDER","isOrgPlan","Object","prototype","hasOwnProperty","call","releaseFlagPlansAtOrAbove","plan","index","indexOf","slice","parseReleaseFlagPlans","raw","Array","isArray","named","Set","size","has","parseReleaseFlagValue","fallbackEnabled","text","trim","enabled","parsed","JSON","parse","plans","rolloutPercent","note","REMOTE_CONFIG_DESCRIPTION_MAX_BYTES","utf8ByteLength","bytes","character","codePoint","codePointAt","fitsRemoteConfigDescription","DESCRIPTION_ELLIPSIS","clampRemoteConfigDescription","budget","kept","next","charAt","length","test","lastSpace","search","replace","releaseFlagParameterDescription","registryDescription","liveDescription","releaseFlagBucket","flagKey","subjectId","hash","seed","charCodeAt","imul","isReleaseFlagOn","releaseFlagTargetsPlan","parseOrgReleaseFlagOverrides","overrides","entries","isReleaseFlagOnForOrg","override"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC,GAED,6DAA6D;AAE7D,SAASA,WAAW,EAAEC,WAAW,QAAQ,yBAAqB;AAC9D,SAASC,mBAAmB,QAAQ,sBAAkB;AACtD,SACEC,oBAAoB,QAEf,sCAAkC;AAkDzC;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB;IAAC;CAAO,CAAS;AAIpD,OAAO,SAASC,mBAAmBC,KAAc;IAC/C,OAAO,AAACF,oBAA2CG,QAAQ,CAACD;AAC9D;AAOA;;;;;;;;;;CAUC,GACD,MAAME,yBAA2D;IAC/D;QACEC,KAAK;QACLC,OAAO;QACPC,aACE,uEACA;QACFC,gBAAgB;IAClB;IACA,2EAA2E;IAC3E,8EAA8E;IAC9E,uEAAuE;IACvE,oDAAoD;IACpD;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,0EACA,wEACA,yEACA,0EACA,uEACA,sDACA,2EACA;QACFC,gBAAgB;IAClB;IACA,gFAAgF;IAChF,uEAAuE;IACvE,2EAA2E;IAC3E,yEAAyE;IACzE,2EAA2E;IAC3E,yEAAyE;IACzE;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,4EACA,uEACA,2EACA,wEACA,qEACA,qEACA,yEACA,kCACA,uEACA;QACFC,gBAAgB;IAClB;IACA,0EAA0E;IAC1E,yEAAyE;IACzE,0EAA0E;IAC1E,mCAAmC;IACnC;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,wEACA,0DACA,wEACA;QACFC,gBAAgB;IAClB;IACA;QACEH,KAAK;QACLC,OAAO,GAAGR,oBAAoB,OAAO,CAAC;QACtC,wEAAwE;QACxE,yDAAyD;QACzDW,OAAO;QACPF,aACE,kEACA,sEACA,kEACA,0EACA,0EACA,oEACA,yEACA,mEACA,sEACA,gEACA,qEACA,sEACA,yEACA,wEACA,0EACA;QACFC,gBAAgB;IAClB;IACA,yEAAyE;IACzE,4EAA4E;IAC5E,mEAAmE;IACnE,+DAA+D;IAC/D;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,sEACA,0EACA,sEACA;QACFC,gBAAgB;IAClB;IACA,0EAA0E;IAC1E,2EAA2E;IAC3E,2EAA2E;IAC3E,wEAAwE;IACxE,uEAAuE;IACvE,uEAAuE;IACvE,6DAA6D;IAC7D;QACEH,KAAK;QACLC,OAAO;QACPC,aACE,sEACA,2EACA,qEACA;QACFC,gBAAgB;IAClB;IACA,wEAAwE;IACxE,wEAAwE;IACxE,sEAAsE;IACtE,8DAA8D;IAC9D,yEAAyE;IACzE,yEAAyE;IACzE,wEAAwE;IACxE,sCAAs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