@aglyn/aglyn 1.14.0 → 1.15.1
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/buy-now-pay-later.d.ts +45 -0
- package/src/lib/app-utils/buy-now-pay-later.js +68 -0
- package/src/lib/app-utils/buy-now-pay-later.js.map +1 -0
- package/src/lib/app-utils/contexts.d.ts +1 -0
- package/src/lib/app-utils/contexts.js +1 -0
- package/src/lib/app-utils/contexts.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +6 -3
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +6 -6
- package/src/lib/app-utils/docs-help.generated.js +14 -1
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +20 -20
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/entity-picker-context.d.ts +6 -0
- package/src/lib/app-utils/entity-picker-context.js.map +1 -1
- package/src/lib/app-utils/host-status.js +1 -1
- package/src/lib/app-utils/host-status.js.map +1 -1
- package/src/lib/app-utils/org-role-grants.js +1 -1
- package/src/lib/app-utils/org-role-grants.js.map +1 -1
- package/src/lib/app-utils/page-header-record-context.d.ts +15 -0
- package/src/lib/app-utils/page-header-record-context.js +13 -4
- package/src/lib/app-utils/page-header-record-context.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.d.ts +125 -46
- package/src/lib/app-utils/plan-entitlements.js +118 -49
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/plugin-bundle-checks.d.ts +14 -2
- package/src/lib/app-utils/plugin-bundle-checks.js +82 -7
- package/src/lib/app-utils/plugin-bundle-checks.js.map +1 -1
- package/src/lib/app-utils/plugin-connection-editor.d.ts +48 -0
- package/src/lib/app-utils/plugin-connection-editor.js +46 -0
- package/src/lib/app-utils/plugin-connection-editor.js.map +1 -0
- package/src/lib/app-utils/plugin-connection-record.d.ts +42 -0
- package/src/lib/app-utils/plugin-connection-record.js +48 -0
- package/src/lib/app-utils/plugin-connection-record.js.map +1 -0
- package/src/lib/app-utils/plugin-connection-records-context.d.ts +23 -0
- package/src/lib/app-utils/plugin-connection-records-context.js +29 -0
- package/src/lib/app-utils/plugin-connection-records-context.js.map +1 -0
- package/src/lib/app-utils/plugin-connection-records.d.ts +42 -0
- package/src/lib/app-utils/plugin-connection-records.js +56 -0
- package/src/lib/app-utils/plugin-connection-records.js.map +1 -0
- package/src/lib/app-utils/plugin-connections.d.ts +320 -0
- package/src/lib/app-utils/plugin-connections.js +895 -0
- package/src/lib/app-utils/plugin-connections.js.map +1 -0
- package/src/lib/app-utils/plugin-elements.d.ts +104 -0
- package/src/lib/app-utils/plugin-elements.js +128 -0
- package/src/lib/app-utils/plugin-elements.js.map +1 -0
- package/src/lib/app-utils/plugin-manifest.d.ts +20 -75
- package/src/lib/app-utils/plugin-manifest.js +65 -100
- package/src/lib/app-utils/plugin-manifest.js.map +1 -1
- package/src/lib/app-utils/realm-elements-context.d.ts +16 -0
- package/src/lib/app-utils/realm-elements-context.js +16 -0
- package/src/lib/app-utils/realm-elements-context.js.map +1 -1
- package/src/lib/app-utils/realm-host-surface.generated.js +1 -0
- package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +35 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +1 -0
- package/src/lib/app-utils/server.js +2 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-context.d.ts +9 -0
- package/src/lib/app-utils/site-context.js.map +1 -1
- package/src/lib/app-utils/site-starter.d.ts +6 -0
- package/src/lib/app-utils/site-starter.js +15 -0
- package/src/lib/app-utils/site-starter.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +25 -0
- package/src/lib/plugin-manager/feature-plugins.js +10 -0
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.js +12 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/index.d.ts +1 -0
- package/src/lib/plugin-manager/index.js +1 -0
- package/src/lib/plugin-manager/index.js.map +1 -1
- package/src/lib/plugin-manager/plugin-artifact-inventory.d.ts +5 -0
- package/src/lib/plugin-manager/plugin-artifact-inventory.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-lists.d.ts +18 -0
- package/src/lib/plugin-manager/plugin-record-lists.js +13 -0
- package/src/lib/plugin-manager/plugin-record-lists.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-csp.d.ts +36 -0
- package/src/lib/plugin-manager/plugin-site-csp.js +50 -1
- package/src/lib/plugin-manager/plugin-site-csp.js.map +1 -1
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js +61 -59
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
- package/src/lib/plugin-manager/site-page-enricher-services.d.ts +35 -0
- package/src/lib/plugin-manager/site-page-enricher-services.js +35 -0
- package/src/lib/plugin-manager/site-page-enricher-services.js.map +1 -0
- package/src/lib/plugin-manager/site-page-hooks.js +16 -3
- package/src/lib/plugin-manager/site-page-hooks.js.map +1 -1
- package/src/lib/plugin-manager/video-embed-provider.d.ts +28 -0
- package/src/lib/plugin-manager/video-embed-provider.js +21 -0
- package/src/lib/plugin-manager/video-embed-provider.js.map +1 -1
- package/src/lib/plugin-manager/video-embed-providers.generated.js +3 -1
- package/src/lib/plugin-manager/video-embed-providers.generated.js.map +1 -1
|
@@ -3,6 +3,12 @@ export interface EntityOption {
|
|
|
3
3
|
id: string;
|
|
4
4
|
/** Current display name, resolved at edit time. */
|
|
5
5
|
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* The entity's own name, where `label` says more than it (AGL-4047): two
|
|
8
|
+
* of one name are labelled apart by their owner, and a node that stored the
|
|
9
|
+
* name rather than the id still matches by the name.
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
6
12
|
}
|
|
7
13
|
/**
|
|
8
14
|
* Edit-time option lists for id-based entity pickers in component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/entity-picker-context.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// Same placement rationale as screen-link-context.ts: lives in\n// @aglyn/aglyn without a 'use client' banner so canvas-rendering surfaces\n// share one module graph.\nimport { createContext } from 'react'\n\nexport interface EntityOption {\n /** Stable document id — the persisted reference (AGL-343/344). */\n id: string\n /** Current display name, resolved at edit time. */\n label: string\n}\n\n/**\n * Edit-time option lists for id-based entity pickers in component\n * attributes — every kind a plugin declares (a site's products, its forms,\n * the organization's datasets…). Names are display-only; nodes persist the id, so renames never break references —\n * the same contract as {@link ScreenLinkContext}. Provided by the\n * console's besigner/preview surfaces; absent on the tenant (the tenant\n * only resolves ids, never lists them).\n */\n/**\n * A kind of entity a picker lists, as the plugin that keeps it declares it\n * (`plugin-manager/plugin-entity-pickers`): `products`, `forms`, `datasets`…\n * Open, because the kinds are the plugins' to add (AGL-3080).\n */\nexport type EntityPickerKind = string\n\n/**\n * How much an empty list is worth believing.\n *\n * Every one of these renders as a dropdown with no entries, and an author\n * looking at four identical empty dropdowns cannot tell \"this site has no\n * forms yet\" from \"the read failed\" from \"this editor never lists forms at\n * all\". Only the first of those is a fact about their site; the other two\n * are the picker being broken, and a picker that cannot say which it is\n * sends the author looking for a form they already made.\n *\n * - `unavailable` — no provider is mounted, so nothing on this surface can\n * list entities. The tenant, and any editor outside a host.\n * - `loading` — a read is open or about to be, and no answer has arrived.\n * Also the state of a list nothing has asked for yet: demand is declared\n * on the same commit that would display it, so \"not asked\" and \"asked,\n * unanswered\" are the same beat.\n * - `ready` — the read settled. An empty list here IS the site's answer.\n * - `error` — the read failed. Empty means nothing.\n */\nexport type EntityListState = 'unavailable' | 'loading' | 'ready' | 'error'\n\n/**\n * How many documents a picker BROWSES.\n *\n * A picker is not a catalog viewer. It is a dropdown on a besigner surface\n * where the author is placing one element, and no table in the console offers\n * a page past `TABLE_PAGE_SIZE_OPTIONS` — a dropdown is the smaller surface of\n * the two, not the larger.\n *\n * The middle of that range rather than its floor: a table has a pager under it\n * and a dropdown does not, so the page a reader cannot advance is worth more\n * rows than the one they can.\n *\n * What makes this size SAFE is that browsing is the only job it does. A stored\n * value is named by {@link EntityPickerContextValue.resolve} — one keyed read\n * for the one document, exact at any catalog size — so nothing here has to be\n * wide enough to contain whatever an author picked last month. A window that\n * carried both jobs would have to be, and would still render a bound element\n * as unbound past its own width; widening this cannot fix that, only make it\n * rarer and more expensive.\n */\nexport const ENTITY_PICKER_BROWSE_LIMIT = 25\n\n/**\n * How many documents a server-side name search may return.\n *\n * The same size as the browse window, for the same reason: a reader who has\n * typed a query and still faces 25 rows narrows it further rather than\n * scrolling. Only the kinds in {@link EntityPickerContextValue.searchable}\n * spend this at all.\n */\nexport const ENTITY_PICKER_SEARCH_LIMIT = 25\n\nexport interface EntityPickerContextValue {\n /**\n * Each kind's browse list, id-first: the site's products for a\n * `PRODUCT_SELECT`, its form entities for a `FORM_SELECT`, and every other\n * kind a plugin declares, keyed by the kind.\n */\n options?: Readonly<Partial<Record<EntityPickerKind, EntityOption[]>>>\n /**\n * The fields an entity's documents declare, keyed by kind and then by\n * entity id, in the order the entity declares them: id = the stable field\n * id a node persists, label = its current display name (AGL-556).\n *\n * Only kinds whose documents carry a field model appear. Two surfaces read\n * it: a field picker that maps a value onto one of an entity's fields (a\n * form field's \"Maps to schema field\"), and the insert-token menu inside a\n * repeat, which offers `{{item.<field>}}` for each field of the entity the\n * repeat names (see `RepeatSource.entityKind`).\n */\n entityFields?: Partial<\n Record<EntityPickerKind, Readonly<Record<string, EntityOption[]>>>\n >\n /**\n * Declare that a picker of this kind is on screen (AGL-703).\n *\n * The provider reads these lists from Firestore, and it used to read ALL of\n * them the moment the besigner opened — up to 300 products, 200 catalog\n * collections, 200 categories and 200 datasets, on a site with a real\n * catalog, for pickers most editing sessions never open. Nothing about\n * moving a heading needs the product list.\n *\n * So the lists are demand-driven now, and the demand signal is the thing\n * that would DISPLAY one: a selected node whose schema declares a\n * `PRODUCT_SELECT`, a repeat bound to a dataset. Call this when that is\n * true and read the list on the render after; until then the list is\n * absent, exactly as it is for the beat before any listener syncs.\n *\n * Optional, and absent on the tenant — which resolves ids and never lists\n * them, so nothing there has a picker to ask for.\n */\n request?: (kind: EntityPickerKind) => void\n /**\n * Per-kind read state, so a picker can say WHY it has nothing to offer.\n * A kind the provider omits reads as `loading`; see {@link entityListState}.\n */\n status?: Partial<Record<EntityPickerKind, EntityListState>>\n /**\n * The browse window came back FULL for this kind, so the list above is a\n * page of the site's catalog and not the whole of it.\n *\n * Measured with a probe — the read asks for one document past\n * {@link ENTITY_PICKER_BROWSE_LIMIT} and the extra one is never offered —\n * so this is a fact about the collection rather than a guess from the\n * window being exactly full.\n *\n * A picker owes the reader this sentence for the same reason the inbox's\n * form filter does: \"not in the picker\" and \"does not exist\" are the same\n * empty dropdown, and only one of them is a fact about their site.\n */\n truncated?: Partial<Record<EntityPickerKind, boolean>>\n /**\n * This kind's documents carry the name-search keys, so a typed query\n * reaches the WHOLE collection rather than only the browse window.\n *\n * True for a kind its declaration marks `searchable`, whose documents carry\n * `nameTokens`/`nameLower` from the owner's own write path —\n * `hosts/{host}/resources` deliberately does not stamp them. A picker for a\n * kind that is absent here must say its search covers the window only —\n * claiming otherwise would let an unfound entity read as a nonexistent one.\n */\n searchable?: Partial<Record<EntityPickerKind, boolean>>\n /**\n * Narrow this kind's offered list to what somebody typed.\n *\n * Matching is the provider's, not the dropdown's: it is the only side that\n * can merge the window's own matches with the ones a server query found\n * past it, and it uses `scoreMatch` so a query matches a word ANYWHERE in a\n * name — the same rule the switchers and global search follow.\n *\n * Passing an empty string restores the browse window.\n */\n search?: (kind: EntityPickerKind, text: string) => void\n /**\n * Resolve ONE stored id to its current name, whatever the browse window\n * holds.\n *\n * Deliberately NOT a job for the browse list, though a bulk read could do\n * both. Sharing one read makes the list's width the limit on which stored\n * values can be named, and past that width a picker renders a bound element\n * as UNBOUND rather than as its label — an empty control on an element that\n * is set, which an author repairs by picking again. That is how a correct\n * reference gets replaced with a different one.\n *\n * One keyed `getDoc` for one document instead: exact at any catalog size,\n * and asked for only when a node actually carries a value. Results land in\n * {@link resolved} and are never re-read.\n */\n resolve?: (kind: EntityPickerKind, id: string) => void\n /**\n * What {@link resolve} found, keyed by kind and then by id.\n *\n * Three states, and the picker renders a different label for each: an\n * `EntityOption` is the resolved name, `null` is a settled read that found\n * NO such document, and an absent key is a resolution still in flight.\n * Absent must never render as missing — a picker that flashed \"unavailable\"\n * over every live reference for the beat before its read landed would teach\n * authors to ignore the one warning that matters.\n */\n resolved?: Partial<\n Record<EntityPickerKind, Readonly<Record<string, EntityOption | null>>>\n >\n}\n\n/**\n * What the picker for `kind` should believe about its own emptiness.\n *\n * `request` is the \"a provider is mounted\" signal — it is the one member the\n * contract already says is absent wherever nothing lists entities — so a\n * surface with no provider resolves to `unavailable` rather than passing an\n * empty list off as the site's answer.\n */\nexport function entityListState(\n context: EntityPickerContextValue | undefined,\n kind: EntityPickerKind,\n): EntityListState {\n if (!context?.request) return 'unavailable'\n return context.status?.[kind] ?? 'loading'\n}\n\n/**\n * The id whose label a picker still needs a keyed read to learn, if any.\n *\n * Part of the contract rather than of one screen, because two surfaces ask\n * it — the attributes panel about a node's picker value, and the insert-token\n * menu about the dataset a repeat is bound to — and an answer that differed\n * between them would be a second keyed read for a document one of them\n * already had.\n *\n * Four cases resolve to \"ask nobody\", and each is a read not spent: there is\n * no value; the browse window already carries it, which is the common case on\n * a small site; a resolution has already answered, including the answer that\n * the document is gone; or the browse read has not settled, so the window may\n * be about to supply it for free.\n *\n * The last is the one worth stating. Asking while the listener is still\n * loading would spend a keyed read on nearly every picker on every site,\n * which is the cost splitting these two jobs exists to remove rather than to\n * move.\n */\nexport function entityValueNeedsResolution(\n context: EntityPickerContextValue | undefined,\n kind: EntityPickerKind,\n value: unknown,\n): string | undefined {\n const id = typeof value === 'string' ? value.trim() : ''\n if (!id || !context?.resolve) return undefined\n if ((context.options?.[kind] ?? []).some((entity) => entity.id === id)) return undefined\n if (id in (context.resolved?.[kind] ?? {})) return undefined\n if (entityListState(context, kind) !== 'ready') return undefined\n return id\n}\n\nexport const EntityPickerContext = createContext<EntityPickerContextValue>({})\nEntityPickerContext.displayName = 'EntityPickerContext'\n"],"names":["createContext","ENTITY_PICKER_BROWSE_LIMIT","ENTITY_PICKER_SEARCH_LIMIT","entityListState","context","kind","request","status","entityValueNeedsResolution","value","id","trim","resolve","undefined","options","some","entity","resolved","EntityPickerContext","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,+DAA+D;AAC/D,0EAA0E;AAC1E,0BAA0B;AAC1B,SAASA,aAAa,QAAQ,QAAO;AA6CrC;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,6BAA6B,GAAE;AAE5C;;;;;;;CAOC,GACD,OAAO,MAAMC,6BAA6B,GAAE;AAkH5C;;;;;;;CAOC,GACD,OAAO,SAASC,gBACdC,OAA6C,EAC7CC,IAAsB;;QAGfD;IADP,IAAI,EAACA,2BAAAA,QAASE,OAAO,GAAE,OAAO;IAC9B,gBAAOF,kBAAAA,QAAQG,MAAM,qBAAdH,eAAgB,CAACC,KAAK,mBAAI;AACnC;AAEA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASG,2BACdJ,OAA6C,EAC7CC,IAAsB,EACtBI,KAAc;;QAITL,kBACMA;IAHX,MAAMM,KAAK,OAAOD,UAAU,WAAWA,MAAME,IAAI,KAAK;IACtD,IAAI,CAACD,MAAM,EAACN,2BAAAA,QAASQ,OAAO,GAAE,OAAOC;IACrC,IAAI,UAACT,mBAAAA,QAAQU,OAAO,qBAAfV,gBAAiB,CAACC,KAAK,mBAAI,EAAE,EAAEU,IAAI,CAAC,CAACC,SAAWA,OAAON,EAAE,KAAKA,KAAK,OAAOG;IAC/E,IAAIH,iBAAON,oBAAAA,QAAQa,QAAQ,qBAAhBb,iBAAkB,CAACC,KAAK,oBAAI,CAAC,IAAI,OAAOQ;IACnD,IAAIV,gBAAgBC,SAASC,UAAU,SAAS,OAAOQ;IACvD,OAAOH;AACT;AAEA,OAAO,MAAMQ,sBAAsBlB,cAAwC,CAAC,GAAE;AAC9EkB,oBAAoBC,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/entity-picker-context.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// Same placement rationale as screen-link-context.ts: lives in\n// @aglyn/aglyn without a 'use client' banner so canvas-rendering surfaces\n// share one module graph.\nimport { createContext } from 'react'\n\nexport interface EntityOption {\n /** Stable document id — the persisted reference (AGL-343/344). */\n id: string\n /** Current display name, resolved at edit time. */\n label: string\n /**\n * The entity's own name, where `label` says more than it (AGL-4047): two\n * of one name are labelled apart by their owner, and a node that stored the\n * name rather than the id still matches by the name.\n */\n name?: string\n}\n\n/**\n * Edit-time option lists for id-based entity pickers in component\n * attributes — every kind a plugin declares (a site's products, its forms,\n * the organization's datasets…). Names are display-only; nodes persist the id, so renames never break references —\n * the same contract as {@link ScreenLinkContext}. Provided by the\n * console's besigner/preview surfaces; absent on the tenant (the tenant\n * only resolves ids, never lists them).\n */\n/**\n * A kind of entity a picker lists, as the plugin that keeps it declares it\n * (`plugin-manager/plugin-entity-pickers`): `products`, `forms`, `datasets`…\n * Open, because the kinds are the plugins' to add (AGL-3080).\n */\nexport type EntityPickerKind = string\n\n/**\n * How much an empty list is worth believing.\n *\n * Every one of these renders as a dropdown with no entries, and an author\n * looking at four identical empty dropdowns cannot tell \"this site has no\n * forms yet\" from \"the read failed\" from \"this editor never lists forms at\n * all\". Only the first of those is a fact about their site; the other two\n * are the picker being broken, and a picker that cannot say which it is\n * sends the author looking for a form they already made.\n *\n * - `unavailable` — no provider is mounted, so nothing on this surface can\n * list entities. The tenant, and any editor outside a host.\n * - `loading` — a read is open or about to be, and no answer has arrived.\n * Also the state of a list nothing has asked for yet: demand is declared\n * on the same commit that would display it, so \"not asked\" and \"asked,\n * unanswered\" are the same beat.\n * - `ready` — the read settled. An empty list here IS the site's answer.\n * - `error` — the read failed. Empty means nothing.\n */\nexport type EntityListState = 'unavailable' | 'loading' | 'ready' | 'error'\n\n/**\n * How many documents a picker BROWSES.\n *\n * A picker is not a catalog viewer. It is a dropdown on a besigner surface\n * where the author is placing one element, and no table in the console offers\n * a page past `TABLE_PAGE_SIZE_OPTIONS` — a dropdown is the smaller surface of\n * the two, not the larger.\n *\n * The middle of that range rather than its floor: a table has a pager under it\n * and a dropdown does not, so the page a reader cannot advance is worth more\n * rows than the one they can.\n *\n * What makes this size SAFE is that browsing is the only job it does. A stored\n * value is named by {@link EntityPickerContextValue.resolve} — one keyed read\n * for the one document, exact at any catalog size — so nothing here has to be\n * wide enough to contain whatever an author picked last month. A window that\n * carried both jobs would have to be, and would still render a bound element\n * as unbound past its own width; widening this cannot fix that, only make it\n * rarer and more expensive.\n */\nexport const ENTITY_PICKER_BROWSE_LIMIT = 25\n\n/**\n * How many documents a server-side name search may return.\n *\n * The same size as the browse window, for the same reason: a reader who has\n * typed a query and still faces 25 rows narrows it further rather than\n * scrolling. Only the kinds in {@link EntityPickerContextValue.searchable}\n * spend this at all.\n */\nexport const ENTITY_PICKER_SEARCH_LIMIT = 25\n\nexport interface EntityPickerContextValue {\n /**\n * Each kind's browse list, id-first: the site's products for a\n * `PRODUCT_SELECT`, its form entities for a `FORM_SELECT`, and every other\n * kind a plugin declares, keyed by the kind.\n */\n options?: Readonly<Partial<Record<EntityPickerKind, EntityOption[]>>>\n /**\n * The fields an entity's documents declare, keyed by kind and then by\n * entity id, in the order the entity declares them: id = the stable field\n * id a node persists, label = its current display name (AGL-556).\n *\n * Only kinds whose documents carry a field model appear. Two surfaces read\n * it: a field picker that maps a value onto one of an entity's fields (a\n * form field's \"Maps to schema field\"), and the insert-token menu inside a\n * repeat, which offers `{{item.<field>}}` for each field of the entity the\n * repeat names (see `RepeatSource.entityKind`).\n */\n entityFields?: Partial<\n Record<EntityPickerKind, Readonly<Record<string, EntityOption[]>>>\n >\n /**\n * Declare that a picker of this kind is on screen (AGL-703).\n *\n * The provider reads these lists from Firestore, and it used to read ALL of\n * them the moment the besigner opened — up to 300 products, 200 catalog\n * collections, 200 categories and 200 datasets, on a site with a real\n * catalog, for pickers most editing sessions never open. Nothing about\n * moving a heading needs the product list.\n *\n * So the lists are demand-driven now, and the demand signal is the thing\n * that would DISPLAY one: a selected node whose schema declares a\n * `PRODUCT_SELECT`, a repeat bound to a dataset. Call this when that is\n * true and read the list on the render after; until then the list is\n * absent, exactly as it is for the beat before any listener syncs.\n *\n * Optional, and absent on the tenant — which resolves ids and never lists\n * them, so nothing there has a picker to ask for.\n */\n request?: (kind: EntityPickerKind) => void\n /**\n * Per-kind read state, so a picker can say WHY it has nothing to offer.\n * A kind the provider omits reads as `loading`; see {@link entityListState}.\n */\n status?: Partial<Record<EntityPickerKind, EntityListState>>\n /**\n * The browse window came back FULL for this kind, so the list above is a\n * page of the site's catalog and not the whole of it.\n *\n * Measured with a probe — the read asks for one document past\n * {@link ENTITY_PICKER_BROWSE_LIMIT} and the extra one is never offered —\n * so this is a fact about the collection rather than a guess from the\n * window being exactly full.\n *\n * A picker owes the reader this sentence for the same reason the inbox's\n * form filter does: \"not in the picker\" and \"does not exist\" are the same\n * empty dropdown, and only one of them is a fact about their site.\n */\n truncated?: Partial<Record<EntityPickerKind, boolean>>\n /**\n * This kind's documents carry the name-search keys, so a typed query\n * reaches the WHOLE collection rather than only the browse window.\n *\n * True for a kind its declaration marks `searchable`, whose documents carry\n * `nameTokens`/`nameLower` from the owner's own write path —\n * `hosts/{host}/resources` deliberately does not stamp them. A picker for a\n * kind that is absent here must say its search covers the window only —\n * claiming otherwise would let an unfound entity read as a nonexistent one.\n */\n searchable?: Partial<Record<EntityPickerKind, boolean>>\n /**\n * Narrow this kind's offered list to what somebody typed.\n *\n * Matching is the provider's, not the dropdown's: it is the only side that\n * can merge the window's own matches with the ones a server query found\n * past it, and it uses `scoreMatch` so a query matches a word ANYWHERE in a\n * name — the same rule the switchers and global search follow.\n *\n * Passing an empty string restores the browse window.\n */\n search?: (kind: EntityPickerKind, text: string) => void\n /**\n * Resolve ONE stored id to its current name, whatever the browse window\n * holds.\n *\n * Deliberately NOT a job for the browse list, though a bulk read could do\n * both. Sharing one read makes the list's width the limit on which stored\n * values can be named, and past that width a picker renders a bound element\n * as UNBOUND rather than as its label — an empty control on an element that\n * is set, which an author repairs by picking again. That is how a correct\n * reference gets replaced with a different one.\n *\n * One keyed `getDoc` for one document instead: exact at any catalog size,\n * and asked for only when a node actually carries a value. Results land in\n * {@link resolved} and are never re-read.\n */\n resolve?: (kind: EntityPickerKind, id: string) => void\n /**\n * What {@link resolve} found, keyed by kind and then by id.\n *\n * Three states, and the picker renders a different label for each: an\n * `EntityOption` is the resolved name, `null` is a settled read that found\n * NO such document, and an absent key is a resolution still in flight.\n * Absent must never render as missing — a picker that flashed \"unavailable\"\n * over every live reference for the beat before its read landed would teach\n * authors to ignore the one warning that matters.\n */\n resolved?: Partial<\n Record<EntityPickerKind, Readonly<Record<string, EntityOption | null>>>\n >\n}\n\n/**\n * What the picker for `kind` should believe about its own emptiness.\n *\n * `request` is the \"a provider is mounted\" signal — it is the one member the\n * contract already says is absent wherever nothing lists entities — so a\n * surface with no provider resolves to `unavailable` rather than passing an\n * empty list off as the site's answer.\n */\nexport function entityListState(\n context: EntityPickerContextValue | undefined,\n kind: EntityPickerKind,\n): EntityListState {\n if (!context?.request) return 'unavailable'\n return context.status?.[kind] ?? 'loading'\n}\n\n/**\n * The id whose label a picker still needs a keyed read to learn, if any.\n *\n * Part of the contract rather than of one screen, because two surfaces ask\n * it — the attributes panel about a node's picker value, and the insert-token\n * menu about the dataset a repeat is bound to — and an answer that differed\n * between them would be a second keyed read for a document one of them\n * already had.\n *\n * Four cases resolve to \"ask nobody\", and each is a read not spent: there is\n * no value; the browse window already carries it, which is the common case on\n * a small site; a resolution has already answered, including the answer that\n * the document is gone; or the browse read has not settled, so the window may\n * be about to supply it for free.\n *\n * The last is the one worth stating. Asking while the listener is still\n * loading would spend a keyed read on nearly every picker on every site,\n * which is the cost splitting these two jobs exists to remove rather than to\n * move.\n */\nexport function entityValueNeedsResolution(\n context: EntityPickerContextValue | undefined,\n kind: EntityPickerKind,\n value: unknown,\n): string | undefined {\n const id = typeof value === 'string' ? value.trim() : ''\n if (!id || !context?.resolve) return undefined\n if ((context.options?.[kind] ?? []).some((entity) => entity.id === id)) return undefined\n if (id in (context.resolved?.[kind] ?? {})) return undefined\n if (entityListState(context, kind) !== 'ready') return undefined\n return id\n}\n\nexport const EntityPickerContext = createContext<EntityPickerContextValue>({})\nEntityPickerContext.displayName = 'EntityPickerContext'\n"],"names":["createContext","ENTITY_PICKER_BROWSE_LIMIT","ENTITY_PICKER_SEARCH_LIMIT","entityListState","context","kind","request","status","entityValueNeedsResolution","value","id","trim","resolve","undefined","options","some","entity","resolved","EntityPickerContext","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,+DAA+D;AAC/D,0EAA0E;AAC1E,0BAA0B;AAC1B,SAASA,aAAa,QAAQ,QAAO;AAmDrC;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,6BAA6B,GAAE;AAE5C;;;;;;;CAOC,GACD,OAAO,MAAMC,6BAA6B,GAAE;AAkH5C;;;;;;;CAOC,GACD,OAAO,SAASC,gBACdC,OAA6C,EAC7CC,IAAsB;;QAGfD;IADP,IAAI,EAACA,2BAAAA,QAASE,OAAO,GAAE,OAAO;IAC9B,gBAAOF,kBAAAA,QAAQG,MAAM,qBAAdH,eAAgB,CAACC,KAAK,mBAAI;AACnC;AAEA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASG,2BACdJ,OAA6C,EAC7CC,IAAsB,EACtBI,KAAc;;QAITL,kBACMA;IAHX,MAAMM,KAAK,OAAOD,UAAU,WAAWA,MAAME,IAAI,KAAK;IACtD,IAAI,CAACD,MAAM,EAACN,2BAAAA,QAASQ,OAAO,GAAE,OAAOC;IACrC,IAAI,UAACT,mBAAAA,QAAQU,OAAO,qBAAfV,gBAAiB,CAACC,KAAK,mBAAI,EAAE,EAAEU,IAAI,CAAC,CAACC,SAAWA,OAAON,EAAE,KAAKA,KAAK,OAAOG;IAC/E,IAAIH,iBAAON,oBAAAA,QAAQa,QAAQ,qBAAhBb,iBAAkB,CAACC,KAAK,oBAAI,CAAC,IAAI,OAAOQ;IACnD,IAAIV,gBAAgBC,SAASC,UAAU,SAAS,OAAOQ;IACvD,OAAOH;AACT;AAEA,OAAO,MAAMQ,sBAAsBlB,cAAwC,CAAC,GAAE;AAC9EkB,oBAAoBC,WAAW,GAAG"}
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
return {
|
|
71
71
|
label: 'Maintenance',
|
|
72
72
|
color: 'warning',
|
|
73
|
-
detail: '
|
|
73
|
+
detail: 'Only your team can see this site. Visitors see the 503 page.'
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
// A site in preview (AGL-4086) is not live to its visitors whatever it has
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/host-status.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\nexport interface HostStatus {\n /** `Live`, `Draft`, `In preview`, `Maintenance`, `Suspended`. */\n label: string\n color: 'success' | 'default' | 'warning' | 'error'\n /** Why, in one sentence — the pill's tooltip. */\n detail: string\n}\n\n/**\n * How many pages this site publishes.\n *\n * Read off `host.screens` — the map publishing writes into the host document\n * (`hosts/{hostId}.screens[screenId] = slug`, see `template-screens.ts`) and\n * the tenant reads to route a request. So a site with an entry has at least\n * one page a visitor can reach, and one without has none. That makes this a\n * fact already sitting in a document its readers hold: **no extra read**, on\n * a page that can list a hundred sites.\n *\n * ⚠️ It counts PUBLISHED ROUTES, not authored work. A site with five\n * unpublished drafts counts 0 — the map is written by publishing and by\n * nothing else. Every caller is asking \"what can a visitor reach?\"; a caller\n * that means \"has anyone worked on this?\" is asking a different question and\n * this is the wrong number for it.\n *\n * The placeholder home page a new site is created with (AGL-3408) COUNTS\n * here: it is a page a visitor reaches, so a new site is Live. The first-run\n * offer asks a different question — has the OWNER published anything? — and\n * reads `hostIsBlankSite`, which discounts it.\n */\nexport function publishedScreenCount(\n host: { screens?: Record<string, unknown> } | null | undefined,\n): number {\n return Object.keys(host?.screens ?? {}).length\n}\n\n/**\n * The `Live` / `Draft` pill the console Sites mockup puts on every card\n * (AGL-2166).\n *\n * Derived from {@link publishedScreenCount}: the pill reports what a visitor\n * can reach, placeholder home page included.\n *\n * The staff admin host page has rendered a `published` / `draft` chip since\n * AGL-390 off `host.published`, which is not a field on `AglynHost` and is\n * written by nothing — so that chip has always said `draft`. Deriving from\n * `screens` is what it should have done.\n *\n * Order matters. A suspended site is not \"live\" whatever it has published,\n * and a site in maintenance is serving the 503 screen rather than its\n * pages — reporting either as `Live` would be the console agreeing with a\n * customer who thinks their site is up.\n */\nexport function describeHostStatus(host: {\n screens?: Record<string, unknown>\n maintenance?: boolean\n preview?: boolean\n suspendedAt?: number\n suspendedUntilMs?: number\n}): HostStatus {\n if (host?.suspendedAt) {\n // A timed suspension that has elapsed is over, even though the fields\n // are still on the document — the tenant makes the same check.\n const until = host.suspendedUntilMs\n if (!until || until > Date.now()) {\n return {\n label: 'Suspended',\n color: 'error',\n detail: 'This site is serving a lockdown notice instead of content.',\n }\n }\n }\n if (host?.maintenance) {\n return {\n label: 'Maintenance',\n color: 'warning',\n detail: '
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/host-status.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\nexport interface HostStatus {\n /** `Live`, `Draft`, `In preview`, `Maintenance`, `Suspended`. */\n label: string\n color: 'success' | 'default' | 'warning' | 'error'\n /** Why, in one sentence — the pill's tooltip. */\n detail: string\n}\n\n/**\n * How many pages this site publishes.\n *\n * Read off `host.screens` — the map publishing writes into the host document\n * (`hosts/{hostId}.screens[screenId] = slug`, see `template-screens.ts`) and\n * the tenant reads to route a request. So a site with an entry has at least\n * one page a visitor can reach, and one without has none. That makes this a\n * fact already sitting in a document its readers hold: **no extra read**, on\n * a page that can list a hundred sites.\n *\n * ⚠️ It counts PUBLISHED ROUTES, not authored work. A site with five\n * unpublished drafts counts 0 — the map is written by publishing and by\n * nothing else. Every caller is asking \"what can a visitor reach?\"; a caller\n * that means \"has anyone worked on this?\" is asking a different question and\n * this is the wrong number for it.\n *\n * The placeholder home page a new site is created with (AGL-3408) COUNTS\n * here: it is a page a visitor reaches, so a new site is Live. The first-run\n * offer asks a different question — has the OWNER published anything? — and\n * reads `hostIsBlankSite`, which discounts it.\n */\nexport function publishedScreenCount(\n host: { screens?: Record<string, unknown> } | null | undefined,\n): number {\n return Object.keys(host?.screens ?? {}).length\n}\n\n/**\n * The `Live` / `Draft` pill the console Sites mockup puts on every card\n * (AGL-2166).\n *\n * Derived from {@link publishedScreenCount}: the pill reports what a visitor\n * can reach, placeholder home page included.\n *\n * The staff admin host page has rendered a `published` / `draft` chip since\n * AGL-390 off `host.published`, which is not a field on `AglynHost` and is\n * written by nothing — so that chip has always said `draft`. Deriving from\n * `screens` is what it should have done.\n *\n * Order matters. A suspended site is not \"live\" whatever it has published,\n * and a site in maintenance is serving the 503 screen rather than its\n * pages — reporting either as `Live` would be the console agreeing with a\n * customer who thinks their site is up.\n */\nexport function describeHostStatus(host: {\n screens?: Record<string, unknown>\n maintenance?: boolean\n preview?: boolean\n suspendedAt?: number\n suspendedUntilMs?: number\n}): HostStatus {\n if (host?.suspendedAt) {\n // A timed suspension that has elapsed is over, even though the fields\n // are still on the document — the tenant makes the same check.\n const until = host.suspendedUntilMs\n if (!until || until > Date.now()) {\n return {\n label: 'Suspended',\n color: 'error',\n detail: 'This site is serving a lockdown notice instead of content.',\n }\n }\n }\n if (host?.maintenance) {\n return {\n label: 'Maintenance',\n color: 'warning',\n detail: 'Only your team can see this site. Visitors see the 503 page.',\n }\n }\n // A site in preview (AGL-4086) is not live to its visitors whatever it has\n // published: they get the 503 page or \"Coming soon\", and only the team\n // sees the pages.\n if (host?.preview === true) {\n return {\n label: 'In preview',\n color: 'default',\n detail:\n 'Only your team can see this site. Visitors see the 503 page or \"Coming soon\".',\n }\n }\n const published = publishedScreenCount(host)\n if (published > 0) {\n return {\n label: 'Live',\n color: 'success',\n detail: `${published} published page${published === 1 ? '' : 's'}.`,\n }\n }\n return {\n label: 'Draft',\n color: 'default',\n detail: 'Nothing published yet — visitors see the placeholder.',\n }\n}\n\n/**\n * `6 of 10 sites · Pro plan` — the meta line the Sites mockup puts\n * opposite the section heading.\n *\n * Returns `undefined` rather than a partial line while the org or its plan\n * is still resolving. A count against the FREE limit is what an unresolved\n * org produces, and telling a Pro customer they are at \"1 of 1 sites\"\n * is how a correct page delivers a false upgrade prompt.\n */\nexport function describeSiteAllowance(options: {\n used: number\n limit: number | undefined\n planLabel: string | undefined\n ready: boolean\n}): string | undefined {\n const { used, limit, planLabel, ready } = options\n if (!ready || !planLabel) return undefined\n /*\n * `Number.isFinite`, not `limit < 0` (AGL-2223).\n *\n * `UNLIMITED` is `Number.POSITIVE_INFINITY`, and Enterprise's `hostLimit`\n * is exactly that — so the `< 0` test was never true for the one plan the\n * Unlimited branch existed for, and an Enterprise organization read\n * `4 of Infinity sites · Enterprise plan`. The negative case is kept: an\n * entitlement override can carry a negative sentinel, and reading that as a\n * cap of \"-1 sites\" would be the same class of nonsense.\n */\n const cap =\n limit === undefined || limit === null\n ? undefined\n : !Number.isFinite(limit) || limit < 0\n ? 'Unlimited'\n : String(limit)\n const sites =\n cap === undefined\n ? `${used} site${used === 1 ? '' : 's'}`\n : `${used} of ${cap} site${cap === '1' ? '' : 's'}`\n return `${sites} · ${planLabel} plan`\n}\n"],"names":["publishedScreenCount","host","Object","keys","screens","length","describeHostStatus","suspendedAt","until","suspendedUntilMs","Date","now","label","color","detail","maintenance","preview","published","describeSiteAllowance","options","used","limit","planLabel","ready","undefined","cap","Number","isFinite","String","sites"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAUD;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASA,qBACdC,IAA8D;;IAE9D,OAAOC,OAAOC,IAAI,SAACF,wBAAAA,KAAMG,OAAO,mBAAI,CAAC,GAAGC,MAAM;AAChD;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,mBAAmBL,IAMlC;IACC,IAAIA,wBAAAA,KAAMM,WAAW,EAAE;QACrB,sEAAsE;QACtE,+DAA+D;QAC/D,MAAMC,QAAQP,KAAKQ,gBAAgB;QACnC,IAAI,CAACD,SAASA,QAAQE,KAAKC,GAAG,IAAI;YAChC,OAAO;gBACLC,OAAO;gBACPC,OAAO;gBACPC,QAAQ;YACV;QACF;IACF;IACA,IAAIb,wBAAAA,KAAMc,WAAW,EAAE;QACrB,OAAO;YACLH,OAAO;YACPC,OAAO;YACPC,QAAQ;QACV;IACF;IACA,2EAA2E;IAC3E,uEAAuE;IACvE,kBAAkB;IAClB,IAAIb,CAAAA,wBAAAA,KAAMe,OAAO,MAAK,MAAM;QAC1B,OAAO;YACLJ,OAAO;YACPC,OAAO;YACPC,QACE;QACJ;IACF;IACA,MAAMG,YAAYjB,qBAAqBC;IACvC,IAAIgB,YAAY,GAAG;QACjB,OAAO;YACLL,OAAO;YACPC,OAAO;YACPC,QAAQ,GAAGG,UAAU,eAAe,EAAEA,cAAc,IAAI,KAAK,IAAI,CAAC,CAAC;QACrE;IACF;IACA,OAAO;QACLL,OAAO;QACPC,OAAO;QACPC,QAAQ;IACV;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASI,sBAAsBC,OAKrC;IACC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGJ;IAC1C,IAAI,CAACI,SAAS,CAACD,WAAW,OAAOE;IACjC;;;;;;;;;GASC,GACD,MAAMC,MACJJ,UAAUG,aAAaH,UAAU,OAC7BG,YACA,CAACE,OAAOC,QAAQ,CAACN,UAAUA,QAAQ,IACjC,cACAO,OAAOP;IACf,MAAMQ,QACJJ,QAAQD,YACJ,GAAGJ,KAAK,KAAK,EAAEA,SAAS,IAAI,KAAK,KAAK,GACtC,GAAGA,KAAK,IAAI,EAAEK,IAAI,KAAK,EAAEA,QAAQ,MAAM,KAAK,KAAK;IACvD,OAAO,GAAGI,MAAM,GAAG,EAAEP,UAAU,KAAK,CAAC;AACvC"}
|
|
@@ -194,7 +194,7 @@ export const ORG_ROLE_NAMES = [
|
|
|
194
194
|
group: 'sites',
|
|
195
195
|
scope: 'site',
|
|
196
196
|
label: 'See orders and webhooks',
|
|
197
|
-
description: 'Read a site’s orders, returns and sending address, and set up its webhooks.'
|
|
197
|
+
description: 'Read a site’s orders, returns, subscriptions and sending address, and set up its webhooks.'
|
|
198
198
|
},
|
|
199
199
|
{
|
|
200
200
|
key: 'site.manage',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/org-role-grants.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT EACH ORG ROLE MAY DO, AS DATA (AGL-243, AGL-3950).\n *\n * The core permission catalog and the core keys each org role holds when\n * nothing refines it. `org-permissions.ts` builds the console's live\n * catalog from these (adding the keys plugins declare, with their own role\n * defaults), and the native apps read the same grants through the generated\n * contracts, so a native gate (`hosts.create`, `data.manage`) answers as the\n * console does for a member row that carries no `resolvedPermissions` stamp.\n *\n * `ORG_ROLE_GRANTS` in the contracts is this table with every plugin's\n * declared catalog keys added (`assembleOrgRoleGrants`, run by\n * `generate:native-contracts` over each plugin's declarations), which is\n * exactly the set the console's `DEFAULT_ROLE_PERMISSIONS` holds once the\n * plugins have registered.\n *\n * NO IMPORTS, on purpose: the native apps read it through the generated\n * contracts.\n */\n\n/** The four org roles. */\nexport type OrgRoleName = 'owner' | 'admin' | 'editor' | 'viewer'\n\n/**\n * Where a key is decided (AGL-4047). `org`: by the member's org role, custom\n * role and overrides, the same on every site. `site`: as `org` for a member\n * who reaches the whole workspace, and per site for a site collaborator,\n * from the host role they hold there and that site's toggle.\n */\nexport type OrgPermissionScope = 'org' | 'site'\n\n/** One key of the org permission catalog. */\nexport interface OrgPermissionEntry {\n key: string\n label: string\n description: string\n /** The plugin that declared it; absent for a core key. */\n pluginId?: string\n /** The group the role editor files it under (`ORG_PERMISSION_GROUPS`, or the declaring plugin's id). */\n group?: string\n /** Where it is decided; absent reads as `org`. */\n scope?: OrgPermissionScope\n /**\n * The broader key this one is a finer part of (AGL-4047): never granted\n * without it, and following it where no custom role or override sets this\n * key. Absent for a key that refines nothing.\n */\n refines?: string\n /**\n * The key this one follows where no custom role or override sets it,\n * without needing it (AGL-4047): granted on its own, it holds while that\n * key is refused. Absent for a key that follows nothing, and for one that\n * refines.\n */\n follows?: string\n /**\n * Whether a site can narrow the key (`narrowsPerSite`, AGL-4047), so the\n * role and member editors offer its \"follow the site role\" choice. Absent\n * for a key a site cannot narrow.\n */\n narrowable?: boolean\n /**\n * For a site key, who holds it by the role they have on that site, read\n * where the site has no stamp for them (`hostStampedSitePermission`, AGL-4047).\n * Absent for a key with no such preset, and for one that holds for members of\n * the whole workspace only, which a site's roles alone cannot answer.\n */\n sitePreset?: Record<string, boolean>\n}\n\n/** A heading the role editor groups keys under. */\nexport interface OrgPermissionGroup {\n id: string\n label: string\n /** The plugin whose keys it holds; absent for a core group. */\n pluginId?: string\n}\n\n/** The catalog and each role's default grants. */\nexport interface OrgRoleGrants {\n /** Every key, in the order the role editor lists them. */\n permissions: OrgPermissionEntry[]\n /** The keys each role holds when no custom role or per-member override sets them. */\n grants: Record<OrgRoleName, string[]>\n /** The groups the keys are filed under, in display order; absent in a catalog written before them. */\n groups?: OrgPermissionGroup[]\n}\n\n/**\n * A key a plugin declares into the catalog: `PluginOrgPermissionDeclaration`\n * with org-role defaults, or a `registerPluginPermissions` key (`managePos`),\n * whose `defaults` are per role tier, the owner holding the admin tier's.\n */\nexport interface OrgPermissionDeclaration {\n key: string\n label: string\n description?: string\n roleDefaults?: Record<OrgRoleName, boolean>\n /** The tier defaults of a `registerPluginPermissions` key, used when `roleDefaults` is absent. */\n defaults?: { admin: boolean; editor: boolean; viewer: boolean }\n /** The host-role defaults of a key a site collaborator holds per site. */\n hostRoleDefaults?: Record<string, boolean>\n /** The group it is filed under; absent: a group named by the declaring plugin's id. */\n group?: string\n /** That group's heading, for a group the core does not name. */\n groupLabel?: string\n pluginId?: string\n /** The broader key it refines (AGL-4047). */\n refines?: string\n /** The key it follows without needing it (AGL-4047). */\n follows?: string\n}\n\n/** A custom role (`orgs/{orgId}/roles/{roleId}`) or a member's overrides: explicit verdicts per key. */\nexport interface OrgPermissionLayer {\n permissions?: Record<string, boolean>\n}\n\nexport const ORG_ROLE_NAMES: readonly OrgRoleName[] = ['owner', 'admin', 'editor', 'viewer']\n\n/**\n * The core groups, in display order. A plugin's keys are filed under a group\n * named by the plugin's id unless its declaration names one of these, so no\n * core group id is a plugin id.\n */\nexport const CORE_ORG_PERMISSION_GROUPS: readonly OrgPermissionGroup[] = [\n { id: 'organization', label: 'Organization' },\n { id: 'billing', label: 'Billing' },\n { id: 'team', label: 'Team' },\n { id: 'sites', label: 'Sites' },\n { id: 'datasets', label: 'Data' },\n { id: 'extensions', label: 'Marketplace and plugins' },\n]\n\n/**\n * A declaration's verdict for each org role: its `roleDefaults`, or, for a\n * `registerPluginPermissions` key, its tier `defaults` with the owner on the\n * admin tier (the tier `ORG_ROLE_TIER` resolves the owner onto).\n */\nexport function declarationRoleDefaults(\n declaration: Pick<OrgPermissionDeclaration, 'roleDefaults' | 'defaults'>,\n): Record<OrgRoleName, boolean> {\n if (declaration.roleDefaults) {\n return {\n owner: declaration.roleDefaults.owner === true,\n admin: declaration.roleDefaults.admin === true,\n editor: declaration.roleDefaults.editor === true,\n viewer: declaration.roleDefaults.viewer === true,\n }\n }\n const tiers = declaration.defaults\n return {\n owner: tiers?.admin === true,\n admin: tiers?.admin === true,\n editor: tiers?.editor === true,\n viewer: tiers?.viewer === true,\n }\n}\n\n/**\n * The core keys, in display order for role editors. Every key here is\n * enforced server-side (`apps/console/specs/org-permissions-are-enforced.spec.ts`).\n */\nexport const CORE_ORG_PERMISSION_ENTRIES: readonly OrgPermissionEntry[] = [\n {\n key: 'org.settings',\n group: 'organization',\n label: 'Organization settings',\n description: 'Rename the organization, change its slug, transfer it.',\n },\n {\n key: 'org.auditLog',\n group: 'organization',\n label: 'Activity & audit log',\n description: 'See the organization activity feed.',\n },\n {\n key: 'org.apiKeys',\n group: 'organization',\n label: 'Manage API keys',\n description: 'Create and revoke the workspace’s REST API keys.',\n },\n {\n key: 'org.privacy',\n group: 'organization',\n label: 'Privacy requests',\n description: 'Erase a person from every site in the workspace when they ask.',\n },\n {\n key: 'org.holds',\n group: 'organization',\n label: 'Holds and reviews',\n description: 'See what is held, flagged or locked on the workspace, and request a review.',\n },\n // Workspace acts that asked for the owner or admin role (AGL-4047), each\n // a key of its own whose default is exactly those roles.\n {\n key: 'org.export',\n group: 'organization',\n label: 'Export workspace data',\n description: 'Download a copy of everything the workspace holds.',\n },\n {\n key: 'org.sendingDomains',\n group: 'organization',\n label: 'Sending domains',\n description: 'Add, verify and remove the domains the workspace’s mail is sent from.',\n },\n {\n key: 'org.businessProfile',\n group: 'organization',\n label: 'Business profile',\n description: 'Change the services, audience and tone every site starts from.',\n },\n {\n key: 'billing.view',\n group: 'billing',\n label: 'View billing',\n description: 'See the plan, usage meters, and invoices.',\n },\n {\n key: 'billing.manage',\n group: 'billing',\n label: 'Manage billing',\n description: 'Change plans, buy add-ons, update payment details.',\n },\n {\n key: 'members.manage',\n group: 'team',\n label: 'Manage members',\n description: 'Invite, remove, and re-role organization members.',\n },\n {\n key: 'hosts.create',\n group: 'sites',\n label: 'Create sites',\n description: 'Create new sites in the organization.',\n },\n {\n key: 'hosts.delete',\n group: 'sites',\n label: 'Delete sites',\n description: 'Delete sites the member can access.',\n },\n // The site keys (AGL-4047): each replaced a gate on the member's role on a\n // site, and keeps that role as its preset (`CORE_SITE_ROLE_PRESETS`).\n {\n key: 'site.edit',\n group: 'sites',\n scope: 'site',\n label: 'Edit site content',\n description: 'Create and change pages, content and everything else on a site, without making it live.',\n },\n {\n key: 'site.publish',\n group: 'sites',\n scope: 'site',\n label: 'Publish site content',\n description: 'Make pages and content live, take them down or schedule them, change redirects and change the site’s fonts.',\n },\n {\n key: 'site.sensitive',\n group: 'sites',\n scope: 'site',\n label: 'See orders and webhooks',\n description: 'Read a site’s orders, returns and sending address, and set up its webhooks.',\n },\n {\n key: 'site.manage',\n group: 'sites',\n scope: 'site',\n label: 'Manage site settings',\n description: 'Manage a site’s people, domain, address and plugins, change its plugin settings (live chat, Zapier) and security allow-lists, import, export and delete it.',\n },\n {\n key: 'data.manage',\n group: 'datasets',\n label: 'Manage data',\n description: 'Create and edit organization datasets, add, change and delete their rows, and manage the CRM’s records and marketing lists and topics.',\n },\n // Workspace content that asked for the owner, admin or editor role\n // (AGL-4047), each a key whose default is exactly those roles.\n {\n key: 'org.media',\n group: 'datasets',\n label: 'Edit the workspace media library',\n description: 'Upload, change, move and remove the files in the media library every site shares.',\n },\n {\n key: 'org.eraseRecords',\n group: 'datasets',\n label: 'Delete workspace records',\n description: 'Delete a whole dataset or list the workspace shares, with everything in it. Deleting one row of a dataset asks “Manage data”.',\n },\n {\n key: 'marketplace.publish',\n group: 'extensions',\n label: 'Publish to marketplace',\n description: 'Publish listings under the organization profile.',\n },\n {\n key: 'plugins.install',\n group: 'extensions',\n label: 'Install plugins',\n description: 'Install or remove marketplace plugins.',\n },\n]\n\nconst CORE_KEYS = CORE_ORG_PERMISSION_ENTRIES.map((entry) => entry.key)\n\n/**\n * The core keys whose preset is the member's role ON THE SITE (AGL-4047), and\n * each site role's verdict: the sets the rules' `canWriteHostContent`,\n * `canPublishHostContent`, `canReadHostSensitive` and the site-admin checks\n * asked before they asked these keys. A member's preset on a site is the\n * verdict for the role they hold there (the owner and admins are Admin on\n * every site); a custom role, their own permissions and that site's toggle\n * then grant or refuse it. Each workspace role's default below is the verdict\n * for its own site role, which is the answer with no site named.\n */\nexport const CORE_SITE_ROLE_PRESETS: Readonly<Record<string, Readonly<Record<string, boolean>>>> = {\n 'site.edit': { admin: true, editor: true, author: true, viewer: false },\n 'site.publish': { admin: true, editor: true, author: false, viewer: false },\n 'site.sensitive': { admin: true, editor: true, author: false, viewer: false },\n 'site.manage': { admin: true, editor: false, author: false, viewer: false },\n}\n\n/** The workspace editor's site keys: its own site role's preset. */\nconst EDITOR_SITE_KEYS = Object.keys(CORE_SITE_ROLE_PRESETS).filter((key) => CORE_SITE_ROLE_PRESETS[key].editor)\n\n/**\n * The core keys each org role holds when nothing refines it: owners and\n * admins hold every core key (owner-only acts like deleting the\n * organization stay role-checked, not permission-checked); editors work on\n * content and see no money or roster controls; viewers read only.\n */\nexport const CORE_ORG_ROLE_GRANTS: Readonly<Record<OrgRoleName, readonly string[]>> = {\n owner: CORE_KEYS,\n admin: CORE_KEYS,\n editor: ['data.manage', 'org.media', 'org.eraseRecords', 'marketplace.publish', 'plugins.install', ...EDITOR_SITE_KEYS],\n viewer: [],\n}\n\n/** The core's catalog and grants; the contracts' value adds the plugins' keys. */\nexport const ORG_ROLE_GRANTS: OrgRoleGrants = {\n permissions: CORE_ORG_PERMISSION_ENTRIES.map((entry) => ({ ...entry })),\n groups: CORE_ORG_PERMISSION_GROUPS.map((group) => ({ ...group })),\n grants: {\n owner: [...CORE_ORG_ROLE_GRANTS.owner],\n admin: [...CORE_ORG_ROLE_GRANTS.admin],\n editor: [...CORE_ORG_ROLE_GRANTS.editor],\n viewer: [...CORE_ORG_ROLE_GRANTS.viewer],\n },\n}\n\n/**\n * The catalog with plugins' declared keys after the core ones, each role\n * holding a declared key when its declaration's defaults say so. A\n * declaration naming a key already taken is refused, as the console's\n * catalog refuses it: the first declaration keeps its meaning and defaults.\n * Every declaration list after the first is folded in the same way, so the\n * org catalog keys (`PluginOrgPermissionDeclaration`) and the\n * `registerPluginPermissions` keys land in one catalog (AGL-4047).\n */\nexport function assembleOrgRoleGrants(\n core: OrgRoleGrants,\n ...declarationLists: ReadonlyArray<readonly OrgPermissionDeclaration[]>\n): OrgRoleGrants {\n const permissions = core.permissions.map((entry) =>\n CORE_SITE_ROLE_PRESETS[entry.key] ? { ...entry, sitePreset: { ...CORE_SITE_ROLE_PRESETS[entry.key] } } : entry,\n )\n const groups = [...(core.groups ?? [])]\n const grants = Object.fromEntries(ORG_ROLE_NAMES.map((role) => [role, [...core.grants[role]]])) as Record<\n OrgRoleName,\n string[]\n >\n const taken = new Set(permissions.map((entry) => entry.key))\n const groupIds = new Set(groups.map((group) => group.id))\n for (const declaration of declarationLists.flat()) {\n if (!declaration?.key || taken.has(declaration.key)) continue\n taken.add(declaration.key)\n const group = declaration.group ?? declaration.pluginId\n permissions.push({\n key: declaration.key,\n label: declaration.label,\n description: declaration.description ?? '',\n ...(declaration.pluginId ? { pluginId: declaration.pluginId } : {}),\n ...(group ? { group } : {}),\n scope: declaration.hostRoleDefaults ? 'site' : 'org',\n ...(declaration.refines && declaration.refines !== declaration.key ? { refines: declaration.refines } : {}),\n ...(declaration.follows && declaration.follows !== declaration.key && !declaration.refines\n ? { follows: declaration.follows }\n : {}),\n // A plugin's own declaration carries `narrowsPerSite` (a flag or one per role); only whether it is set matters here.\n ...((declaration as { narrowsPerSite?: unknown }).narrowsPerSite ? { narrowable: true } : {}),\n ...(declaration.hostRoleDefaults && !(declaration as { workspaceMembersOnly?: unknown }).workspaceMembersOnly\n ? { sitePreset: { ...declaration.hostRoleDefaults } }\n : {}),\n })\n if (group && !groupIds.has(group)) {\n groupIds.add(group)\n groups.push({\n id: group,\n label: declaration.groupLabel ?? group,\n ...(declaration.pluginId ? { pluginId: declaration.pluginId } : {}),\n })\n } else if (group && declaration.pluginId) {\n // A plugin's group opened by a declaration that names no plugin (an org\n // catalog declaration, AGL-4047) is still that plugin's: the first of\n // its declarations that names one says so.\n const index = groups.findIndex((entry) => entry.id === group)\n if (index >= 0 && !groups[index].pluginId) groups[index] = { ...groups[index], pluginId: declaration.pluginId }\n }\n const defaults = declarationRoleDefaults(declaration)\n for (const role of ORG_ROLE_NAMES) {\n if (defaults[role]) grants[role].push(declaration.key)\n }\n }\n return { permissions, grants, groups }\n}\n\n/**\n * A member's effective permissions, as the console's `resolveOrgPermissions`\n * answers them: the role's defaults, then the custom role's explicit\n * verdicts (when the member has one), then the member's own overrides,\n * later layers winning key by key, over the catalog's keys only. A missing\n * role reads as viewer; a role the catalog does not know holds nothing.\n */\nexport function rolePermissions(\n catalog: OrgRoleGrants,\n role: string | null | undefined,\n customRole?: OrgPermissionLayer | null,\n overrides?: OrgPermissionLayer | null,\n): Record<string, boolean> {\n const keys = catalog.permissions.map((entry) => entry.key)\n const name = role ?? 'viewer'\n const held = new Set((catalog.grants as Record<string, string[] | undefined>)[name] ?? [])\n const out: Record<string, boolean> = Object.fromEntries(keys.map((key) => [key, held.has(key)]))\n for (const layer of [customRole, overrides]) {\n const values = layer?.permissions\n if (!values) continue\n for (const key of keys) {\n if (typeof values[key] === 'boolean') out[key] = values[key]\n }\n }\n // A key that refines a broader one (AGL-4047) is never held without it, and\n // follows it where neither layer set the key; a key that only follows one\n // takes its verdict where neither layer set the key, and nothing more.\n // Applied broader keys first, so a chain settles in one pass; a refinement\n // that loops is left alone.\n const broader = new Map<string, string>()\n const followsOnly = new Set<string>()\n for (const entry of catalog.permissions) {\n if (entry.refines && entry.refines in out) broader.set(entry.key, entry.refines)\n else if (entry.follows && entry.follows in out) {\n broader.set(entry.key, entry.follows)\n followsOnly.add(entry.key)\n }\n }\n const depth = (key: string): number => {\n const seen = new Set<string>()\n let steps = 0\n let current = key\n while (broader.has(current)) {\n if (seen.has(current)) return -1\n seen.add(current)\n current = broader.get(current) as string\n steps += 1\n }\n return steps\n }\n const ordered = [...broader.keys()]\n .map((key) => ({ key, steps: depth(key) }))\n .filter((entry) => entry.steps > 0)\n .sort((a, b) => a.steps - b.steps)\n for (const { key } of ordered) {\n let stored: boolean | undefined\n for (const layer of [customRole, overrides]) {\n const value = layer?.permissions?.[key]\n if (typeof value === 'boolean') stored = value\n }\n const held = out[broader.get(key) as string] === true\n out[key] = followsOnly.has(key) ? (stored === undefined ? held : stored) : held && (stored === undefined ? true : stored)\n }\n return out\n}\n"],"names":["ORG_ROLE_NAMES","CORE_ORG_PERMISSION_GROUPS","id","label","declarationRoleDefaults","declaration","roleDefaults","owner","admin","editor","viewer","tiers","defaults","CORE_ORG_PERMISSION_ENTRIES","key","group","description","scope","CORE_KEYS","map","entry","CORE_SITE_ROLE_PRESETS","author","EDITOR_SITE_KEYS","Object","keys","filter","CORE_ORG_ROLE_GRANTS","ORG_ROLE_GRANTS","permissions","groups","grants","assembleOrgRoleGrants","core","declarationLists","sitePreset","fromEntries","role","taken","Set","groupIds","flat","has","add","pluginId","push","hostRoleDefaults","refines","follows","narrowsPerSite","narrowable","workspaceMembersOnly","groupLabel","index","findIndex","rolePermissions","catalog","customRole","overrides","name","held","out","layer","values","broader","Map","followsOnly","set","depth","seen","steps","current","get","ordered","sort","a","b","stored","value","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;CAkBC,GAED,wBAAwB;AAkGxB,OAAO,MAAMA,iBAAyC;IAAC;IAAS;IAAS;IAAU;CAAS,CAAA;AAE5F;;;;CAIC,GACD,OAAO,MAAMC,6BAA4D;IACvE;QAAEC,IAAI;QAAgBC,OA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G,CAChCN,GAAG,CAAC,CAACL,MAAS,CAAA;YAAEA;YAAKwD,OAAOF,MAAMtD;QAAK,CAAA,GACvCY,MAAM,CAAC,CAACN,QAAUA,MAAMkD,KAAK,GAAG,GAChCI,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEL,KAAK,GAAGM,EAAEN,KAAK;IACnC,KAAK,MAAM,EAAExD,GAAG,EAAE,IAAI2D,QAAS;QAC7B,IAAII;QACJ,KAAK,MAAMf,SAAS;YAACL;YAAYC;SAAU,CAAE;gBAC7BI;YAAd,MAAMgB,QAAQhB,0BAAAA,qBAAAA,MAAOjC,WAAW,qBAAlBiC,kBAAoB,CAAChD,IAAI;YACvC,IAAI,OAAOgE,UAAU,WAAWD,SAASC;QAC3C;QACA,MAAMlB,OAAOC,GAAG,CAACG,QAAQQ,GAAG,CAAC1D,KAAe,KAAK;QACjD+C,GAAG,CAAC/C,IAAI,GAAGoD,YAAYxB,GAAG,CAAC5B,OAAQ+D,WAAWE,YAAYnB,OAAOiB,SAAUjB,QAASiB,CAAAA,WAAWE,YAAY,OAAOF,MAAK;IACzH;IACA,OAAOhB;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/org-role-grants.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT EACH ORG ROLE MAY DO, AS DATA (AGL-243, AGL-3950).\n *\n * The core permission catalog and the core keys each org role holds when\n * nothing refines it. `org-permissions.ts` builds the console's live\n * catalog from these (adding the keys plugins declare, with their own role\n * defaults), and the native apps read the same grants through the generated\n * contracts, so a native gate (`hosts.create`, `data.manage`) answers as the\n * console does for a member row that carries no `resolvedPermissions` stamp.\n *\n * `ORG_ROLE_GRANTS` in the contracts is this table with every plugin's\n * declared catalog keys added (`assembleOrgRoleGrants`, run by\n * `generate:native-contracts` over each plugin's declarations), which is\n * exactly the set the console's `DEFAULT_ROLE_PERMISSIONS` holds once the\n * plugins have registered.\n *\n * NO IMPORTS, on purpose: the native apps read it through the generated\n * contracts.\n */\n\n/** The four org roles. */\nexport type OrgRoleName = 'owner' | 'admin' | 'editor' | 'viewer'\n\n/**\n * Where a key is decided (AGL-4047). `org`: by the member's org role, custom\n * role and overrides, the same on every site. `site`: as `org` for a member\n * who reaches the whole workspace, and per site for a site collaborator,\n * from the host role they hold there and that site's toggle.\n */\nexport type OrgPermissionScope = 'org' | 'site'\n\n/** One key of the org permission catalog. */\nexport interface OrgPermissionEntry {\n key: string\n label: string\n description: string\n /** The plugin that declared it; absent for a core key. */\n pluginId?: string\n /** The group the role editor files it under (`ORG_PERMISSION_GROUPS`, or the declaring plugin's id). */\n group?: string\n /** Where it is decided; absent reads as `org`. */\n scope?: OrgPermissionScope\n /**\n * The broader key this one is a finer part of (AGL-4047): never granted\n * without it, and following it where no custom role or override sets this\n * key. Absent for a key that refines nothing.\n */\n refines?: string\n /**\n * The key this one follows where no custom role or override sets it,\n * without needing it (AGL-4047): granted on its own, it holds while that\n * key is refused. Absent for a key that follows nothing, and for one that\n * refines.\n */\n follows?: string\n /**\n * Whether a site can narrow the key (`narrowsPerSite`, AGL-4047), so the\n * role and member editors offer its \"follow the site role\" choice. Absent\n * for a key a site cannot narrow.\n */\n narrowable?: boolean\n /**\n * For a site key, who holds it by the role they have on that site, read\n * where the site has no stamp for them (`hostStampedSitePermission`, AGL-4047).\n * Absent for a key with no such preset, and for one that holds for members of\n * the whole workspace only, which a site's roles alone cannot answer.\n */\n sitePreset?: Record<string, boolean>\n}\n\n/** A heading the role editor groups keys under. */\nexport interface OrgPermissionGroup {\n id: string\n label: string\n /** The plugin whose keys it holds; absent for a core group. */\n pluginId?: string\n}\n\n/** The catalog and each role's default grants. */\nexport interface OrgRoleGrants {\n /** Every key, in the order the role editor lists them. */\n permissions: OrgPermissionEntry[]\n /** The keys each role holds when no custom role or per-member override sets them. */\n grants: Record<OrgRoleName, string[]>\n /** The groups the keys are filed under, in display order; absent in a catalog written before them. */\n groups?: OrgPermissionGroup[]\n}\n\n/**\n * A key a plugin declares into the catalog: `PluginOrgPermissionDeclaration`\n * with org-role defaults, or a `registerPluginPermissions` key (`managePos`),\n * whose `defaults` are per role tier, the owner holding the admin tier's.\n */\nexport interface OrgPermissionDeclaration {\n key: string\n label: string\n description?: string\n roleDefaults?: Record<OrgRoleName, boolean>\n /** The tier defaults of a `registerPluginPermissions` key, used when `roleDefaults` is absent. */\n defaults?: { admin: boolean; editor: boolean; viewer: boolean }\n /** The host-role defaults of a key a site collaborator holds per site. */\n hostRoleDefaults?: Record<string, boolean>\n /** The group it is filed under; absent: a group named by the declaring plugin's id. */\n group?: string\n /** That group's heading, for a group the core does not name. */\n groupLabel?: string\n pluginId?: string\n /** The broader key it refines (AGL-4047). */\n refines?: string\n /** The key it follows without needing it (AGL-4047). */\n follows?: string\n}\n\n/** A custom role (`orgs/{orgId}/roles/{roleId}`) or a member's overrides: explicit verdicts per key. */\nexport interface OrgPermissionLayer {\n permissions?: Record<string, boolean>\n}\n\nexport const ORG_ROLE_NAMES: readonly OrgRoleName[] = ['owner', 'admin', 'editor', 'viewer']\n\n/**\n * The core groups, in display order. A plugin's keys are filed under a group\n * named by the plugin's id unless its declaration names one of these, so no\n * core group id is a plugin id.\n */\nexport const CORE_ORG_PERMISSION_GROUPS: readonly OrgPermissionGroup[] = [\n { id: 'organization', label: 'Organization' },\n { id: 'billing', label: 'Billing' },\n { id: 'team', label: 'Team' },\n { id: 'sites', label: 'Sites' },\n { id: 'datasets', label: 'Data' },\n { id: 'extensions', label: 'Marketplace and plugins' },\n]\n\n/**\n * A declaration's verdict for each org role: its `roleDefaults`, or, for a\n * `registerPluginPermissions` key, its tier `defaults` with the owner on the\n * admin tier (the tier `ORG_ROLE_TIER` resolves the owner onto).\n */\nexport function declarationRoleDefaults(\n declaration: Pick<OrgPermissionDeclaration, 'roleDefaults' | 'defaults'>,\n): Record<OrgRoleName, boolean> {\n if (declaration.roleDefaults) {\n return {\n owner: declaration.roleDefaults.owner === true,\n admin: declaration.roleDefaults.admin === true,\n editor: declaration.roleDefaults.editor === true,\n viewer: declaration.roleDefaults.viewer === true,\n }\n }\n const tiers = declaration.defaults\n return {\n owner: tiers?.admin === true,\n admin: tiers?.admin === true,\n editor: tiers?.editor === true,\n viewer: tiers?.viewer === true,\n }\n}\n\n/**\n * The core keys, in display order for role editors. Every key here is\n * enforced server-side (`apps/console/specs/org-permissions-are-enforced.spec.ts`).\n */\nexport const CORE_ORG_PERMISSION_ENTRIES: readonly OrgPermissionEntry[] = [\n {\n key: 'org.settings',\n group: 'organization',\n label: 'Organization settings',\n description: 'Rename the organization, change its slug, transfer it.',\n },\n {\n key: 'org.auditLog',\n group: 'organization',\n label: 'Activity & audit log',\n description: 'See the organization activity feed.',\n },\n {\n key: 'org.apiKeys',\n group: 'organization',\n label: 'Manage API keys',\n description: 'Create and revoke the workspace’s REST API keys.',\n },\n {\n key: 'org.privacy',\n group: 'organization',\n label: 'Privacy requests',\n description: 'Erase a person from every site in the workspace when they ask.',\n },\n {\n key: 'org.holds',\n group: 'organization',\n label: 'Holds and reviews',\n description: 'See what is held, flagged or locked on the workspace, and request a review.',\n },\n // Workspace acts that asked for the owner or admin role (AGL-4047), each\n // a key of its own whose default is exactly those roles.\n {\n key: 'org.export',\n group: 'organization',\n label: 'Export workspace data',\n description: 'Download a copy of everything the workspace holds.',\n },\n {\n key: 'org.sendingDomains',\n group: 'organization',\n label: 'Sending domains',\n description: 'Add, verify and remove the domains the workspace’s mail is sent from.',\n },\n {\n key: 'org.businessProfile',\n group: 'organization',\n label: 'Business profile',\n description: 'Change the services, audience and tone every site starts from.',\n },\n {\n key: 'billing.view',\n group: 'billing',\n label: 'View billing',\n description: 'See the plan, usage meters, and invoices.',\n },\n {\n key: 'billing.manage',\n group: 'billing',\n label: 'Manage billing',\n description: 'Change plans, buy add-ons, update payment details.',\n },\n {\n key: 'members.manage',\n group: 'team',\n label: 'Manage members',\n description: 'Invite, remove, and re-role organization members.',\n },\n {\n key: 'hosts.create',\n group: 'sites',\n label: 'Create sites',\n description: 'Create new sites in the organization.',\n },\n {\n key: 'hosts.delete',\n group: 'sites',\n label: 'Delete sites',\n description: 'Delete sites the member can access.',\n },\n // The site keys (AGL-4047): each replaced a gate on the member's role on a\n // site, and keeps that role as its preset (`CORE_SITE_ROLE_PRESETS`).\n {\n key: 'site.edit',\n group: 'sites',\n scope: 'site',\n label: 'Edit site content',\n description: 'Create and change pages, content and everything else on a site, without making it live.',\n },\n {\n key: 'site.publish',\n group: 'sites',\n scope: 'site',\n label: 'Publish site content',\n description: 'Make pages and content live, take them down or schedule them, change redirects and change the site’s fonts.',\n },\n {\n key: 'site.sensitive',\n group: 'sites',\n scope: 'site',\n label: 'See orders and webhooks',\n description: 'Read a site’s orders, returns, subscriptions and sending address, and set up its webhooks.',\n },\n {\n key: 'site.manage',\n group: 'sites',\n scope: 'site',\n label: 'Manage site settings',\n description: 'Manage a site’s people, domain, address and plugins, change its plugin settings (live chat, Zapier) and security allow-lists, import, export and delete it.',\n },\n {\n key: 'data.manage',\n group: 'datasets',\n label: 'Manage data',\n description: 'Create and edit organization datasets, add, change and delete their rows, and manage the CRM’s records and marketing lists and topics.',\n },\n // Workspace content that asked for the owner, admin or editor role\n // (AGL-4047), each a key whose default is exactly those roles.\n {\n key: 'org.media',\n group: 'datasets',\n label: 'Edit the workspace media library',\n description: 'Upload, change, move and remove the files in the media library every site shares.',\n },\n {\n key: 'org.eraseRecords',\n group: 'datasets',\n label: 'Delete workspace records',\n description: 'Delete a whole dataset or list the workspace shares, with everything in it. Deleting one row of a dataset asks “Manage data”.',\n },\n {\n key: 'marketplace.publish',\n group: 'extensions',\n label: 'Publish to marketplace',\n description: 'Publish listings under the organization profile.',\n },\n {\n key: 'plugins.install',\n group: 'extensions',\n label: 'Install plugins',\n description: 'Install or remove marketplace plugins.',\n },\n]\n\nconst CORE_KEYS = CORE_ORG_PERMISSION_ENTRIES.map((entry) => entry.key)\n\n/**\n * The core keys whose preset is the member's role ON THE SITE (AGL-4047), and\n * each site role's verdict: the sets the rules' `canWriteHostContent`,\n * `canPublishHostContent`, `canReadHostSensitive` and the site-admin checks\n * asked before they asked these keys. A member's preset on a site is the\n * verdict for the role they hold there (the owner and admins are Admin on\n * every site); a custom role, their own permissions and that site's toggle\n * then grant or refuse it. Each workspace role's default below is the verdict\n * for its own site role, which is the answer with no site named.\n */\nexport const CORE_SITE_ROLE_PRESETS: Readonly<Record<string, Readonly<Record<string, boolean>>>> = {\n 'site.edit': { admin: true, editor: true, author: true, viewer: false },\n 'site.publish': { admin: true, editor: true, author: false, viewer: false },\n 'site.sensitive': { admin: true, editor: true, author: false, viewer: false },\n 'site.manage': { admin: true, editor: false, author: false, viewer: false },\n}\n\n/** The workspace editor's site keys: its own site role's preset. */\nconst EDITOR_SITE_KEYS = Object.keys(CORE_SITE_ROLE_PRESETS).filter((key) => CORE_SITE_ROLE_PRESETS[key].editor)\n\n/**\n * The core keys each org role holds when nothing refines it: owners and\n * admins hold every core key (owner-only acts like deleting the\n * organization stay role-checked, not permission-checked); editors work on\n * content and see no money or roster controls; viewers read only.\n */\nexport const CORE_ORG_ROLE_GRANTS: Readonly<Record<OrgRoleName, readonly string[]>> = {\n owner: CORE_KEYS,\n admin: CORE_KEYS,\n editor: ['data.manage', 'org.media', 'org.eraseRecords', 'marketplace.publish', 'plugins.install', ...EDITOR_SITE_KEYS],\n viewer: [],\n}\n\n/** The core's catalog and grants; the contracts' value adds the plugins' keys. */\nexport const ORG_ROLE_GRANTS: OrgRoleGrants = {\n permissions: CORE_ORG_PERMISSION_ENTRIES.map((entry) => ({ ...entry })),\n groups: CORE_ORG_PERMISSION_GROUPS.map((group) => ({ ...group })),\n grants: {\n owner: [...CORE_ORG_ROLE_GRANTS.owner],\n admin: [...CORE_ORG_ROLE_GRANTS.admin],\n editor: [...CORE_ORG_ROLE_GRANTS.editor],\n viewer: [...CORE_ORG_ROLE_GRANTS.viewer],\n },\n}\n\n/**\n * The catalog with plugins' declared keys after the core ones, each role\n * holding a declared key when its declaration's defaults say so. A\n * declaration naming a key already taken is refused, as the console's\n * catalog refuses it: the first declaration keeps its meaning and defaults.\n * Every declaration list after the first is folded in the same way, so the\n * org catalog keys (`PluginOrgPermissionDeclaration`) and the\n * `registerPluginPermissions` keys land in one catalog (AGL-4047).\n */\nexport function assembleOrgRoleGrants(\n core: OrgRoleGrants,\n ...declarationLists: ReadonlyArray<readonly OrgPermissionDeclaration[]>\n): OrgRoleGrants {\n const permissions = core.permissions.map((entry) =>\n CORE_SITE_ROLE_PRESETS[entry.key] ? { ...entry, sitePreset: { ...CORE_SITE_ROLE_PRESETS[entry.key] } } : entry,\n )\n const groups = [...(core.groups ?? [])]\n const grants = Object.fromEntries(ORG_ROLE_NAMES.map((role) => [role, [...core.grants[role]]])) as Record<\n OrgRoleName,\n string[]\n >\n const taken = new Set(permissions.map((entry) => entry.key))\n const groupIds = new Set(groups.map((group) => group.id))\n for (const declaration of declarationLists.flat()) {\n if (!declaration?.key || taken.has(declaration.key)) continue\n taken.add(declaration.key)\n const group = declaration.group ?? declaration.pluginId\n permissions.push({\n key: declaration.key,\n label: declaration.label,\n description: declaration.description ?? '',\n ...(declaration.pluginId ? { pluginId: declaration.pluginId } : {}),\n ...(group ? { group } : {}),\n scope: declaration.hostRoleDefaults ? 'site' : 'org',\n ...(declaration.refines && declaration.refines !== declaration.key ? { refines: declaration.refines } : {}),\n ...(declaration.follows && declaration.follows !== declaration.key && !declaration.refines\n ? { follows: declaration.follows }\n : {}),\n // A plugin's own declaration carries `narrowsPerSite` (a flag or one per role); only whether it is set matters here.\n ...((declaration as { narrowsPerSite?: unknown }).narrowsPerSite ? { narrowable: true } : {}),\n ...(declaration.hostRoleDefaults && !(declaration as { workspaceMembersOnly?: unknown }).workspaceMembersOnly\n ? { sitePreset: { ...declaration.hostRoleDefaults } }\n : {}),\n })\n if (group && !groupIds.has(group)) {\n groupIds.add(group)\n groups.push({\n id: group,\n label: declaration.groupLabel ?? group,\n ...(declaration.pluginId ? { pluginId: declaration.pluginId } : {}),\n })\n } else if (group && declaration.pluginId) {\n // A plugin's group opened by a declaration that names no plugin (an org\n // catalog declaration, AGL-4047) is still that plugin's: the first of\n // its declarations that names one says so.\n const index = groups.findIndex((entry) => entry.id === group)\n if (index >= 0 && !groups[index].pluginId) groups[index] = { ...groups[index], pluginId: declaration.pluginId }\n }\n const defaults = declarationRoleDefaults(declaration)\n for (const role of ORG_ROLE_NAMES) {\n if (defaults[role]) grants[role].push(declaration.key)\n }\n }\n return { permissions, grants, groups }\n}\n\n/**\n * A member's effective permissions, as the console's `resolveOrgPermissions`\n * answers them: the role's defaults, then the custom role's explicit\n * verdicts (when the member has one), then the member's own overrides,\n * later layers winning key by key, over the catalog's keys only. A missing\n * role reads as viewer; a role the catalog does not know holds nothing.\n */\nexport function rolePermissions(\n catalog: OrgRoleGrants,\n role: string | null | undefined,\n customRole?: OrgPermissionLayer | null,\n overrides?: OrgPermissionLayer | null,\n): Record<string, boolean> {\n const keys = catalog.permissions.map((entry) => entry.key)\n const name = role ?? 'viewer'\n const held = new Set((catalog.grants as Record<string, string[] | undefined>)[name] ?? [])\n const out: Record<string, boolean> = Object.fromEntries(keys.map((key) => [key, held.has(key)]))\n for (const layer of [customRole, overrides]) {\n const values = layer?.permissions\n if (!values) continue\n for (const key of keys) {\n if (typeof values[key] === 'boolean') out[key] = values[key]\n }\n }\n // A key that refines a broader one (AGL-4047) is never held without it, and\n // follows it where neither layer set the key; a key that only follows one\n // takes its verdict where neither layer set the key, and nothing more.\n // Applied broader keys first, so a chain settles in one pass; a refinement\n // that loops is left alone.\n const broader = new Map<string, string>()\n const followsOnly = new Set<string>()\n for (const entry of catalog.permissions) {\n if (entry.refines && entry.refines in out) broader.set(entry.key, entry.refines)\n else if (entry.follows && entry.follows in out) {\n broader.set(entry.key, entry.follows)\n followsOnly.add(entry.key)\n }\n }\n const depth = (key: string): number => {\n const seen = new Set<string>()\n let steps = 0\n let current = key\n while (broader.has(current)) {\n if (seen.has(current)) return -1\n seen.add(current)\n current = broader.get(current) as string\n steps += 1\n }\n return steps\n }\n const ordered = [...broader.keys()]\n .map((key) => ({ key, steps: depth(key) }))\n .filter((entry) => entry.steps > 0)\n .sort((a, b) => a.steps - b.steps)\n for (const { key } of ordered) {\n let stored: boolean | undefined\n for (const layer of [customRole, overrides]) {\n const value = layer?.permissions?.[key]\n if (typeof value === 'boolean') stored = value\n }\n const held = out[broader.get(key) as string] === true\n out[key] = followsOnly.has(key) ? (stored === undefined ? held : stored) : held && (stored === undefined ? true : stored)\n }\n return out\n}\n"],"names":["ORG_ROLE_NAMES","CORE_ORG_PERMISSION_GROUPS","id","label","declarationRoleDefaults","declaration","roleDefaults","owner","admin","editor","viewer","tiers","defaults","CORE_ORG_PERMISSION_ENTRIES","key","group","description","scope","CORE_KEYS","map","entry","CORE_SITE_ROLE_PRESETS","author","EDITOR_SITE_KEYS","Object","keys","filter","CORE_ORG_ROLE_GRANTS","ORG_ROLE_GRANTS","permissions","groups","grants","assembleOrgRoleGrants","core","declarationLists","sitePreset","fromEntries","role","taken","Set","groupIds","flat","has","add","pluginId","push","hostRoleDefaults","refines","follows","narrowsPerSite","narrowable","workspaceMembersOnly","groupLabel","index","findIndex","rolePermissions","catalog","customRole","overrides","name","held","out","layer","values","broader","Map","followsOnly","set","depth","seen","steps","current","get","ordered","sort","a","b","stored","value","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;CAkBC,GAED,wBAAwB;AAkGxB,OAAO,MAAMA,iBAAyC;IAAC;IAAS;IAAS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,GAAG,CAACD;YACtBD,SAAS;QACX;QACA,OAAOA;IACT;IACA,MAAMG,UAAU;WAAIT,QAAQvC,IAAI;KAAG,CAChCN,GAAG,CAAC,CAACL,MAAS,CAAA;YAAEA;YAAKwD,OAAOF,MAAMtD;QAAK,CAAA,GACvCY,MAAM,CAAC,CAACN,QAAUA,MAAMkD,KAAK,GAAG,GAChCI,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEL,KAAK,GAAGM,EAAEN,KAAK;IACnC,KAAK,MAAM,EAAExD,GAAG,EAAE,IAAI2D,QAAS;QAC7B,IAAII;QACJ,KAAK,MAAMf,SAAS;YAACL;YAAYC;SAAU,CAAE;gBAC7BI;YAAd,MAAMgB,QAAQhB,0BAAAA,qBAAAA,MAAOjC,WAAW,qBAAlBiC,kBAAoB,CAAChD,IAAI;YACvC,IAAI,OAAOgE,UAAU,WAAWD,SAASC;QAC3C;QACA,MAAMlB,OAAOC,GAAG,CAACG,QAAQQ,GAAG,CAAC1D,KAAe,KAAK;QACjD+C,GAAG,CAAC/C,IAAI,GAAGoD,YAAYxB,GAAG,CAAC5B,OAAQ+D,WAAWE,YAAYnB,OAAOiB,SAAUjB,QAASiB,CAAAA,WAAWE,YAAY,OAAOF,MAAK;IACzH;IACA,OAAOhB;AACT"}
|
|
@@ -35,6 +35,21 @@ export interface PageHeaderRecordValue {
|
|
|
35
35
|
* the route's own heading stands, which already names the surface.
|
|
36
36
|
*/
|
|
37
37
|
title?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Name the record in the trail only, and leave the heading as the route
|
|
40
|
+
* built it (AGL-4047). For a surface whose heading names the place rather
|
|
41
|
+
* than the record — a page of tabs, where the record is the open tab and
|
|
42
|
+
* the heading stays the page's.
|
|
43
|
+
*/
|
|
44
|
+
keepHeading?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The record this one sits inside, as a crumb before it (AGL-4047): a
|
|
47
|
+
* dataset's record names the dataset, linked, then itself. Absent, the
|
|
48
|
+
* record is the trail's only addition, as before.
|
|
49
|
+
*/
|
|
50
|
+
parentTitle?: string;
|
|
51
|
+
/** Where {@link parentTitle} links to. Both or neither. */
|
|
52
|
+
parentHref?: string;
|
|
38
53
|
}
|
|
39
54
|
export interface PageHeaderRecordContextValue {
|
|
40
55
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2026 Aglyn LLC
|
|
@@ -46,16 +47,24 @@ PageHeaderRecordContext.displayName = 'PageHeaderRecordContext';
|
|
|
46
47
|
* standing on is a label rather than a way to get there — so an href here
|
|
47
48
|
* would be an option that silently does nothing.
|
|
48
49
|
*/ export function PageHeaderRecord(props) {
|
|
49
|
-
const { title } = props;
|
|
50
|
+
const { title, keepHeading, parentTitle, parentHref } = props;
|
|
50
51
|
const { setHeaderRecord } = usePageHeaderRecord();
|
|
51
52
|
useEffect(()=>{
|
|
52
|
-
setHeaderRecord == null ? void 0 : setHeaderRecord(title ? {
|
|
53
|
+
setHeaderRecord == null ? void 0 : setHeaderRecord(title ? _extends({
|
|
53
54
|
title
|
|
54
|
-
}
|
|
55
|
+
}, keepHeading ? {
|
|
56
|
+
keepHeading
|
|
57
|
+
} : {}, parentTitle && parentHref ? {
|
|
58
|
+
parentTitle,
|
|
59
|
+
parentHref
|
|
60
|
+
} : {}) : null);
|
|
55
61
|
return ()=>setHeaderRecord == null ? void 0 : setHeaderRecord(null);
|
|
56
62
|
}, [
|
|
57
63
|
setHeaderRecord,
|
|
58
|
-
title
|
|
64
|
+
title,
|
|
65
|
+
keepHeading,
|
|
66
|
+
parentTitle,
|
|
67
|
+
parentHref
|
|
59
68
|
]);
|
|
60
69
|
return null;
|
|
61
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/page-header-record-context.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// Same placement rationale as page-header-actions-context.ts: lives in\n// @aglyn/aglyn without a 'use client' banner so both the console app and\n// relocated feature plugins share one context module.\nimport { createContext, useContext, useEffect } from 'react'\n\n/**\n * Lets a surface name the RECORD it is showing, for the page header and the\n * breadcrumb trail — the sibling of `PageHeaderActions`, which does the same\n * for the header's controls.\n *\n * WHAT A RECORD DETAIL PAGE OWES ITS READER. The heading of a page about one\n * thing names that thing, and the trail ends on it. A detail page whose\n * heading reads `Forms` says only which list the reader came from, which the\n * breadcrumb above it already said, and it reads identically on every row of\n * that list — so two tabs open on two different forms are one string.\n *\n * WHY A CONTEXT AND NOT A PROP, for the same reason the actions seam is one:\n * a route that owns its `DashboardLayout` passes `header` and\n * `breadcrumbItems` directly, and the detail pages that do — Screens,\n * Components, Layouts, Templates, entries — already name their record that\n * way and never touch this. A PLUGIN surface has no such route. The console\n * shell's generic host page owns the layout, builds the heading from the nav\n * item's label and the trail from the surface and section, and renders the\n * surface as a CHILD; a child cannot set its parent's props. So the record\n * arrives here, published by whichever descendant loaded it.\n *\n * WHAT IT REPLACES, precisely: the heading's text and the heading's SECTION\n * suffix, and it appends one crumb. The icon stays the surface's — a form is\n * still a form — and every crumb above it stays exactly as the route built\n * it, so the trail still walks back through the surface and the section the\n * record sits under.\n */\nexport interface PageHeaderRecordValue {\n /**\n * The record's own name, which becomes the page heading and the last crumb.\n *\n * Empty and absent both mean \"not yet\": a surface calls this with whatever\n * it has this render, and a half-loaded name would flash the heading\n * through a wrong string on the way to the right one. Until a name arrives\n * the route's own heading stands, which already names the surface.\n */\n title?: string\n}\n\nexport interface PageHeaderRecordContextValue {\n /**\n * Names the record the page is about; `null` clears it.\n *\n * Absent when no provider is mounted, so a surface rendered outside one —\n * a test harness, a storybook mount — publishes nothing rather than\n * throwing.\n */\n setHeaderRecord?: (record: PageHeaderRecordValue | null) => void\n}\n\nexport const PageHeaderRecordContext =\n createContext<PageHeaderRecordContextValue>({})\nPageHeaderRecordContext.displayName = 'PageHeaderRecordContext'\n\n/** Hook form of {@link PageHeaderRecordContext}. */\nexport function usePageHeaderRecord(): PageHeaderRecordContextValue {\n return useContext(PageHeaderRecordContext)\n}\n\nexport type PageHeaderRecordProps = PageHeaderRecordValue\n\n/**\n * Names the page's record in the header and the trail, and renders nothing\n * where it sits.\n *\n * Written inside the component that LOADED the record, so the heading and the\n * body read one document. A shell that resolved the name a second time to\n * fill its own header would be paying for a second read of a document the\n * page is already holding — and would answer differently while the two were\n * in flight.\n *\n * THE SLOT IS EMPTIED ON UNMOUNT, which is what keeps one record's name off\n * the next page. A list and a detail view are different components, so\n * navigating between them unmounts this publisher and the cleanup runs in the\n * same commit the incoming surface mounts in.\n *\n * Published from a PRIMITIVE rather than an object, deliberately: the effect's\n * dependency is the string itself, so a surface that re-renders while its data\n * settles publishes once per actual change rather than once per render.\n *\n * The record is named, never LINKED. `BreadcrumbsComponent` renders its last\n * crumb as text whatever it is handed, because the level the reader is\n * standing on is a label rather than a way to get there — so an href here\n * would be an option that silently does nothing.\n */\nexport function PageHeaderRecord(props: PageHeaderRecordProps): null {\n const { title } = props\n const { setHeaderRecord } = usePageHeaderRecord()\n useEffect(() => {\n setHeaderRecord?.(title ? {
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/page-header-record-context.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// Same placement rationale as page-header-actions-context.ts: lives in\n// @aglyn/aglyn without a 'use client' banner so both the console app and\n// relocated feature plugins share one context module.\nimport { createContext, useContext, useEffect } from 'react'\n\n/**\n * Lets a surface name the RECORD it is showing, for the page header and the\n * breadcrumb trail — the sibling of `PageHeaderActions`, which does the same\n * for the header's controls.\n *\n * WHAT A RECORD DETAIL PAGE OWES ITS READER. The heading of a page about one\n * thing names that thing, and the trail ends on it. A detail page whose\n * heading reads `Forms` says only which list the reader came from, which the\n * breadcrumb above it already said, and it reads identically on every row of\n * that list — so two tabs open on two different forms are one string.\n *\n * WHY A CONTEXT AND NOT A PROP, for the same reason the actions seam is one:\n * a route that owns its `DashboardLayout` passes `header` and\n * `breadcrumbItems` directly, and the detail pages that do — Screens,\n * Components, Layouts, Templates, entries — already name their record that\n * way and never touch this. A PLUGIN surface has no such route. The console\n * shell's generic host page owns the layout, builds the heading from the nav\n * item's label and the trail from the surface and section, and renders the\n * surface as a CHILD; a child cannot set its parent's props. So the record\n * arrives here, published by whichever descendant loaded it.\n *\n * WHAT IT REPLACES, precisely: the heading's text and the heading's SECTION\n * suffix, and it appends one crumb. The icon stays the surface's — a form is\n * still a form — and every crumb above it stays exactly as the route built\n * it, so the trail still walks back through the surface and the section the\n * record sits under.\n */\nexport interface PageHeaderRecordValue {\n /**\n * The record's own name, which becomes the page heading and the last crumb.\n *\n * Empty and absent both mean \"not yet\": a surface calls this with whatever\n * it has this render, and a half-loaded name would flash the heading\n * through a wrong string on the way to the right one. Until a name arrives\n * the route's own heading stands, which already names the surface.\n */\n title?: string\n /**\n * Name the record in the trail only, and leave the heading as the route\n * built it (AGL-4047). For a surface whose heading names the place rather\n * than the record — a page of tabs, where the record is the open tab and\n * the heading stays the page's.\n */\n keepHeading?: boolean\n /**\n * The record this one sits inside, as a crumb before it (AGL-4047): a\n * dataset's record names the dataset, linked, then itself. Absent, the\n * record is the trail's only addition, as before.\n */\n parentTitle?: string\n /** Where {@link parentTitle} links to. Both or neither. */\n parentHref?: string\n}\n\nexport interface PageHeaderRecordContextValue {\n /**\n * Names the record the page is about; `null` clears it.\n *\n * Absent when no provider is mounted, so a surface rendered outside one —\n * a test harness, a storybook mount — publishes nothing rather than\n * throwing.\n */\n setHeaderRecord?: (record: PageHeaderRecordValue | null) => void\n}\n\nexport const PageHeaderRecordContext =\n createContext<PageHeaderRecordContextValue>({})\nPageHeaderRecordContext.displayName = 'PageHeaderRecordContext'\n\n/** Hook form of {@link PageHeaderRecordContext}. */\nexport function usePageHeaderRecord(): PageHeaderRecordContextValue {\n return useContext(PageHeaderRecordContext)\n}\n\nexport type PageHeaderRecordProps = PageHeaderRecordValue\n\n/**\n * Names the page's record in the header and the trail, and renders nothing\n * where it sits.\n *\n * Written inside the component that LOADED the record, so the heading and the\n * body read one document. A shell that resolved the name a second time to\n * fill its own header would be paying for a second read of a document the\n * page is already holding — and would answer differently while the two were\n * in flight.\n *\n * THE SLOT IS EMPTIED ON UNMOUNT, which is what keeps one record's name off\n * the next page. A list and a detail view are different components, so\n * navigating between them unmounts this publisher and the cleanup runs in the\n * same commit the incoming surface mounts in.\n *\n * Published from a PRIMITIVE rather than an object, deliberately: the effect's\n * dependency is the string itself, so a surface that re-renders while its data\n * settles publishes once per actual change rather than once per render.\n *\n * The record is named, never LINKED. `BreadcrumbsComponent` renders its last\n * crumb as text whatever it is handed, because the level the reader is\n * standing on is a label rather than a way to get there — so an href here\n * would be an option that silently does nothing.\n */\nexport function PageHeaderRecord(props: PageHeaderRecordProps): null {\n const { title, keepHeading, parentTitle, parentHref } = props\n const { setHeaderRecord } = usePageHeaderRecord()\n useEffect(() => {\n setHeaderRecord?.(\n title\n ? {\n title,\n ...(keepHeading ? { keepHeading } : {}),\n ...(parentTitle && parentHref ? { parentTitle, parentHref } : {}),\n }\n : null,\n )\n return () => setHeaderRecord?.(null)\n }, [setHeaderRecord, title, keepHeading, parentTitle, parentHref])\n return null\n}\nPageHeaderRecord.displayName = 'PageHeaderRecord'\n"],"names":["createContext","useContext","useEffect","PageHeaderRecordContext","displayName","usePageHeaderRecord","PageHeaderRecord","props","title","keepHeading","parentTitle","parentHref","setHeaderRecord"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,uEAAuE;AACvE,yEAAyE;AACzE,sDAAsD;AACtD,SAASA,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,QAAO;AAmE5D,OAAO,MAAMC,0BACXH,cAA4C,CAAC,GAAE;AACjDG,wBAAwBC,WAAW,GAAG;AAEtC,kDAAkD,GAClD,OAAO,SAASC;IACd,OAAOJ,WAAWE;AACpB;AAIA;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASG,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,UAAU,EAAE,GAAGJ;IACxD,MAAM,EAAEK,eAAe,EAAE,GAAGP;IAC5BH,UAAU;QACRU,mCAAAA,gBACEJ,QACI;YACEA;WACIC,cAAc;YAAEA;QAAY,IAAI,CAAC,GACjCC,eAAeC,aAAa;YAAED;YAAaC;QAAW,IAAI,CAAC,KAEjE;QAEN,OAAO,IAAMC,mCAAAA,gBAAkB;IACjC,GAAG;QAACA;QAAiBJ;QAAOC;QAAaC;QAAaC;KAAW;IACjE,OAAO;AACT;AACAL,iBAAiBF,WAAW,GAAG"}
|