@aglyn/aglyn 1.12.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/crm.js +8 -7
  3. package/src/lib/app-utils/crm.js.map +1 -1
  4. package/src/lib/app-utils/docs-help-sections.generated.js +8 -2
  5. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  6. package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
  7. package/src/lib/app-utils/docs-help.generated.js +7 -0
  8. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  9. package/src/lib/app-utils/docs-index.generated.js +48 -34
  10. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  11. package/src/lib/app-utils/dynamic-list-rule.js +9 -5
  12. package/src/lib/app-utils/dynamic-list-rule.js.map +1 -1
  13. package/src/lib/app-utils/host-permissions.d.ts +12 -0
  14. package/src/lib/app-utils/host-permissions.js +26 -1
  15. package/src/lib/app-utils/host-permissions.js.map +1 -1
  16. package/src/lib/app-utils/media-asset-facts.d.ts +2 -2
  17. package/src/lib/app-utils/media-asset-facts.js +4 -3
  18. package/src/lib/app-utils/media-asset-facts.js.map +1 -1
  19. package/src/lib/app-utils/media-cdn-scope.d.ts +19 -4
  20. package/src/lib/app-utils/media-cdn-scope.js +19 -5
  21. package/src/lib/app-utils/media-cdn-scope.js.map +1 -1
  22. package/src/lib/app-utils/media-ref.d.ts +10 -6
  23. package/src/lib/app-utils/media-ref.js +34 -8
  24. package/src/lib/app-utils/media-ref.js.map +1 -1
  25. package/src/lib/app-utils/native-nav.d.ts +2 -2
  26. package/src/lib/app-utils/native-nav.js +2 -2
  27. package/src/lib/app-utils/native-nav.js.map +1 -1
  28. package/src/lib/app-utils/org-permissions.d.ts +7 -0
  29. package/src/lib/app-utils/org-permissions.js +2 -0
  30. package/src/lib/app-utils/org-permissions.js.map +1 -1
  31. package/src/lib/app-utils/org-role-grants.d.ts +7 -0
  32. package/src/lib/app-utils/org-role-grants.js +7 -5
  33. package/src/lib/app-utils/org-role-grants.js.map +1 -1
  34. package/src/lib/app-utils/scope-tokens.d.ts +132 -3
  35. package/src/lib/app-utils/scope-tokens.js +276 -3
  36. package/src/lib/app-utils/scope-tokens.js.map +1 -1
  37. package/src/lib/app-utils/site-placement.d.ts +74 -0
  38. package/src/lib/app-utils/site-placement.js +80 -0
  39. package/src/lib/app-utils/site-placement.js.map +1 -0
  40. package/src/lib/app-utils/transfer-launcher-context.d.ts +17 -1
  41. package/src/lib/app-utils/transfer-launcher-context.js.map +1 -1
  42. package/src/lib/data-transfer/access.d.ts +10 -18
  43. package/src/lib/data-transfer/access.js +21 -25
  44. package/src/lib/data-transfer/access.js.map +1 -1
  45. package/src/lib/data-transfer/resource.d.ts +13 -14
  46. package/src/lib/data-transfer/resource.js +9 -10
  47. package/src/lib/data-transfer/resource.js.map +1 -1
  48. package/src/lib/plugin-manager/first-party-plugins.generated.js +3 -4
  49. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  50. package/src/lib/plugin-manager/plugin-contact-capture.d.ts +10 -0
  51. package/src/lib/plugin-manager/plugin-contact-capture.js +11 -0
  52. package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
  53. package/src/lib/plugin-manager/plugin-entitlements.d.ts +12 -0
  54. package/src/lib/plugin-manager/plugin-entitlements.js +3 -1
  55. package/src/lib/plugin-manager/plugin-entitlements.js.map +1 -1
  56. package/src/lib/plugin-manager/plugin-scope-sharing.d.ts +52 -0
  57. package/src/lib/plugin-manager/plugin-scope-sharing.generated.d.ts +10 -0
  58. package/src/lib/plugin-manager/plugin-scope-sharing.generated.js +82 -0
  59. package/src/lib/plugin-manager/plugin-scope-sharing.generated.js.map +1 -0
  60. package/src/lib/plugin-manager/plugin-scope-sharing.js +85 -0
  61. package/src/lib/plugin-manager/plugin-scope-sharing.js.map +1 -0
  62. package/src/lib/plugin-manager/plugin-transfer-resources.d.ts +56 -1
  63. package/src/lib/plugin-manager/plugin-transfer-resources.js +13 -0
  64. package/src/lib/plugin-manager/plugin-transfer-resources.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-nav.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 * THE NATIVE APPS' NAVIGATION, AS DATA (AGL-3943).\n *\n * One manifest both shells draw (docs/mobile/native-navigation.md): the\n * sidebar for the whole workspace, the sidebar inside one site, and the two\n * settings modes (the workspace's, and the site's, which merges the\n * console's Setup and Admin). Zach chose the site's groups on 2026-10-18:\n * an Analytics row, Starred, Website, Sell, Customers, More, Site settings.\n *\n * Every row names:\n * - the console's word for it (`label`), held to the console by\n * `apps/console/specs/native-nav-manifest.spec.ts`, which reads the\n * console's own tabs, sections and plugin declarations;\n * - one icon per idea, an SF Symbol and a Material Symbol;\n * - the native screen it opens (a plugin's declared screen, a core screen\n * spec, a site platform screen or a `shell.*` destination);\n * - the plugin it belongs to, so it hides when that plugin is off for the\n * workspace or the site.\n *\n * The core's own rows (Home, Analytics, Sites, Pages, Media, the settings\n * modes) are here; a plugin's rows are its own, in\n * `libs/plugins/<plugin>/src/lib/native-nav.ts` (`NATIVE_NAV_ROWS`), placed\n * into a list's group by `order` (docs/PACKAGES.md rule 3: the core never\n * names a plugin). `generate:native-contracts` assembles the two\n * (`assembleNativeNav`) into the manifest the apps read,\n * `ContractValues.nativeNavManifest`.\n *\n * NO IMPORTS, on purpose: the native apps read this through the generated\n * contracts, so it must stay a plain module.\n */\n\n/** A list the shells draw. */\nexport type NativeNavListId = 'workspace' | 'site' | 'workspaceSettings' | 'siteSettings'\n\n/** One icon per idea: the same row draws the same picture in both scopes. */\nexport interface NativeNavIcon {\n /** An SF Symbol name. */\n apple: string\n /** A Material Symbol name, as `AglynIcons.named` takes it. */\n android: string\n}\n\n/**\n * Where a row's console twin lives:\n * - `orgTab` / `hostTab`: a console tab, by its id (`org-nav-tabs.ts`,\n * `host-nav-tabs.ts`);\n * - `orgPluginTab` / `hostPluginTab`: a plugin's `orgNavItems` / `navItems`\n * entry, by its href;\n * - `orgPluginSection` / `hostPluginSection`: a section of a plugin's hub, as\n * `{href}/{sectionId}`;\n * - `setupSection`: a site's Setup section, by its id (`setup-sections.ts`);\n * - `hostAdminSection`, `orgSettingsSection`, `teamSection`,\n * `billingSection`: a section of those hubs, by its `Route` name;\n * - `consoleWidget`: a plugin's card, as `{slot}/{widgetId}`;\n * - `shell`: a place the app's shell owns (Home, Analytics' page, the\n * settings modes), whose console twin is the page named in `id`;\n * - `nativeOnly`: a native screen the console has no page for.\n */\nexport type NativeNavConsoleSurface =\n | 'orgTab'\n | 'hostTab'\n | 'orgPluginTab'\n | 'hostPluginTab'\n | 'orgPluginSection'\n | 'hostPluginSection'\n | 'setupSection'\n | 'hostAdminSection'\n | 'orgSettingsSection'\n | 'teamSection'\n | 'billingSection'\n | 'consoleWidget'\n | 'shell'\n | 'nativeOnly'\n\nexport interface NativeNavConsoleRef {\n surface: NativeNavConsoleSurface\n id: string\n}\n\n/** A section inside a row's area, as the console's section rail lists it. */\nexport interface NativeNavSection {\n id: string\n label: string\n screen: string\n params?: Record<string, string>\n /** Set only when the section belongs to another plugin than its row's. */\n pluginId?: string\n /** The help docs page for it; its row's, unless the console names its own. */\n docs?: string\n console: NativeNavConsoleRef\n}\n\n/** An action the area offers from its title bar (Scan stock, New product). */\nexport interface NativeNavAction {\n id: string\n label: string\n icon: NativeNavIcon\n screen: string\n params?: Record<string, string>\n}\n\nexport interface NativeNavRow {\n /** The idea's id: the same in every list that shows it (`media`). */\n id: string\n /** The console's word. */\n label: string\n /**\n * The console's word when the native label is a decision of its own\n * (a row the apps name differently from the console).\n */\n consoleLabel?: string\n icon: NativeNavIcon\n /** The native screen the row opens. */\n screen: string\n params?: Record<string, string>\n /** The plugin the row belongs to: off for the workspace or site, the row hides. */\n pluginId?: string\n /** Only a site admin sees the row, as only they see the console's Admin tab. */\n requiresHostAdmin?: boolean\n /** A settings row's one line, in the words the screens already use. */\n description?: string\n /** Search words besides the label, so typing \"billing\" finds Plan. */\n keywords?: string[]\n /** Where the row sits in its group, ascending; a plugin's row is placed by it. */\n order?: number\n /**\n * The help docs page for the place, as the console's own help names it\n * (its `docsTopic` and `docsAnchor`, or the page's `help` prop): a docs-site\n * path with its anchor, e.g. `/content-and-data/crm/overview#at-the-organization-level`.\n * The apps open it in the in-app browser, on the docs origin.\n */\n docs?: string\n sections?: NativeNavSection[]\n actions?: NativeNavAction[]\n console: NativeNavConsoleRef\n}\n\nexport interface NativeNavGroup {\n id: string\n /** The heading; absent for a group drawn without one. */\n label?: string\n /** Folded at rest unless it holds the screen in use, remembered per device. */\n foldable: boolean\n /** `starred`: the person's starred items for this scope, drawn by the shell. */\n dynamic?: 'starred'\n rows: NativeNavRow[]\n}\n\nexport interface NativeNavList {\n id: NativeNavListId\n /** The settings mode's title, after its owner's name (\"Juniper Street Co. settings\"). */\n title?: string\n groups: NativeNavGroup[]\n}\n\n/** A console place no row holds, and where the apps put it instead. */\nexport interface NativeNavElsewhere {\n console: NativeNavConsoleRef\n where: string\n}\n\n/** A plugin's row, and the list and group it goes in. */\nexport interface NativeNavContribution {\n list: NativeNavListId\n /** A group of that list, by id. */\n group: string\n row: NativeNavRow\n}\n\n/** Where the Create new menu is offered: the whole workspace, or one site. */\nexport type NativeNavCreateScope = 'workspace' | 'site'\n\n/**\n * One item of the Create new menu (\"+\" on the rail, the center tab on\n * phones): what the console offers to create from that scope, opening the\n * area's own create form.\n */\nexport interface NativeNavCreateItem {\n id: string\n /** The thing made, in the console's words (\"Draft order\", \"Service\"). */\n label: string\n icon: NativeNavIcon\n /** The native screen the item opens, with `params` that open its create form. */\n screen: string\n params?: Record<string, string>\n /** The plugin it belongs to: off for the workspace or site, the item is not offered. */\n pluginId?: string\n /** Only a site admin is offered it. */\n requiresHostAdmin?: boolean\n /** The workspace permission the console's create action asks for (`hosts.create`, `data.manage`). */\n permission?: string\n /** The site roles that may make it, as the rules hold them (`canWriteHostContent`). */\n hostRoles?: string[]\n /** The plan feature it needs; without it the item is shown blocked, with `blockedReason`. */\n planFeature?: string\n /** Why it is blocked when the plan lacks `planFeature`; the default reason otherwise. */\n blockedReason?: string\n /** Where it sits in the menu, ascending. */\n order?: number\n /** Where the console offers the same create action. */\n console: NativeNavConsoleRef\n}\n\n/** One scope's Create new menu. */\nexport interface NativeNavCreateList {\n scope: NativeNavCreateScope\n items: NativeNavCreateItem[]\n}\n\n/** A plugin's Create new item, and the scope that offers it. */\nexport interface NativeNavCreateContribution {\n scope: NativeNavCreateScope\n item: NativeNavCreateItem\n}\n\nexport interface NativeNavManifest {\n lists: NativeNavList[]\n /** The Create new menu per scope (AGL-3943). */\n create?: NativeNavCreateList[]\n /** Destinations the shells own, which no plugin registers. */\n shellScreens: string[]\n elsewhere: NativeNavElsewhere[]\n}\n\n/** The shells' own destinations. */\nexport const NATIVE_NAV_SHELL_SCREENS: readonly string[] = [\n 'shell.home',\n 'shell.analytics',\n 'shell.workspaceSettings',\n 'shell.siteSettings',\n]\n\n/** An icon pair, for the rows here and in the plugins. */\nexport const nativeNavIcon = (apple: string, android: string): NativeNavIcon => ({ apple, android })\n\n/** A console reference, for the rows here and in the plugins. */\nexport const nativeNavRef = (surface: NativeNavConsoleSurface, id: string): NativeNavConsoleRef => ({\n surface,\n id,\n})\n\n/** A section of a plugin hub, at the scope its row stands in. */\nexport function nativeNavHubSection(\n scope: 'org' | 'host',\n href: string,\n id: string,\n label: string,\n screen: string,\n extra: Partial<Pick<NativeNavSection, 'params' | 'pluginId'>> = {},\n): NativeNavSection {\n return {\n id,\n label,\n screen,\n ...extra,\n console: nativeNavRef(scope === 'org' ? 'orgPluginSection' : 'hostPluginSection', `${href}/${id}`),\n }\n}\n\nconst icon = nativeNavIcon\nconst ref = nativeNavRef\n\nconst ICONS = {\n home: icon('house', 'home'),\n overview: icon('chart.bar', 'bar_chart'),\n sites: icon('globe', 'public'),\n pages: icon('doc.text', 'description'),\n media: icon('photo.on.rectangle', 'photo_library'),\n settings: icon('gearshape', 'settings'),\n emails: icon('envelope', 'mail'),\n members: icon('person.2', 'group'),\n roles: icon('person.badge.key', 'admin_panel_settings'),\n activity: icon('clock.arrow.circlepath', 'history'),\n plan: icon('creditcard', 'credit_card'),\n usage: icon('gauge.with.dots.needle.33percent', 'data_usage'),\n invoices: icon('doc.plaintext', 'receipt_long'),\n billingSettings: icon('slider.horizontal.3', 'tune'),\n plugins: icon('puzzlepiece.extension', 'extension'),\n branding: icon('paintbrush', 'brush'),\n sso: icon('key.viewfinder', 'vpn_key'),\n profile: icon('building.2', 'apartment'),\n apiKeys: icon('key', 'key'),\n integrations: icon('point.3.connected.trianglepath.dotted', 'hub'),\n privacy: icon('hand.raised', 'privacy_tip'),\n holds: icon('exclamationmark.triangle', 'warning'),\n importExport: icon('arrow.up.arrow.down', 'sync'),\n ownership: icon('person.crop.circle.badge.checkmark', 'manage_accounts'),\n delete: icon('trash', 'delete_forever'),\n details: icon('info.circle', 'info'),\n business: icon('briefcase', 'business'),\n seo: icon('magnifyingglass', 'travel_explore'),\n tracking: icon('chart.line.uptrend.xyaxis', 'query_stats'),\n theme: icon('paintpalette', 'palette'),\n domain: icon('link', 'domain'),\n security: icon('lock', 'security'),\n errorPages: icon('exclamationmark.circle', 'error_outline'),\n backup: icon('square.and.arrow.down', 'backup'),\n} as const\n\nconst HOME_ROW: NativeNavRow = {\n id: 'home',\n label: 'Home',\n icon: ICONS.home,\n screen: 'shell.home',\n order: 10,\n console: ref('shell', 'home'),\n}\n\nconst WORKSPACE: NativeNavList = {\n id: 'workspace',\n groups: [\n { id: 'top', foldable: false, rows: [HOME_ROW] },\n { id: 'starred', label: 'Starred', foldable: true, dynamic: 'starred', rows: [] },\n {\n id: 'workspace',\n foldable: false,\n rows: [\n {\n id: 'sites',\n label: 'Sites',\n icon: ICONS.sites,\n screen: 'site.sites',\n order: 10,\n docs: '/getting-started/console-tour#the-sites-list',\n console: ref('orgTab', 'nav-tab-org-sites'),\n },\n {\n id: 'media',\n label: 'Media',\n icon: ICONS.media,\n screen: 'site.media',\n order: 90,\n console: ref('orgTab', 'nav-tab-org-media'),\n },\n ],\n },\n ],\n}\n\nconst SITE: NativeNavList = {\n id: 'site',\n groups: [\n {\n id: 'top',\n foldable: false,\n rows: [\n HOME_ROW,\n {\n id: 'overview',\n // \"Analytics\", the console's own word: \"Overview\" read as a second Home (AGL-4011).\n label: 'Analytics',\n consoleLabel: 'Analytics',\n icon: ICONS.overview,\n screen: 'shell.analytics',\n order: 20,\n keywords: ['analytics', 'traffic', 'visitors'],\n console: ref('hostTab', 'nav-tab-analytics'),\n },\n ],\n },\n { id: 'starred', label: 'Starred', foldable: true, dynamic: 'starred', rows: [] },\n {\n id: 'website',\n label: 'Website',\n foldable: true,\n rows: [\n {\n id: 'pages',\n label: 'Pages',\n icon: ICONS.pages,\n screen: 'site.pages',\n order: 10,\n sections: [\n { id: 'pages', label: 'Pages', screen: 'site.pages', console: ref('hostTab', 'nav-tab-screens') },\n { id: 'components', label: 'Components', screen: 'site.components', console: ref('hostTab', 'nav-tab-components') },\n { id: 'layouts', label: 'Layouts', screen: 'site.layouts', console: ref('hostTab', 'nav-tab-layouts') },\n { id: 'templates', label: 'Templates', screen: 'site.templates', console: ref('hostTab', 'nav-tab-templates') },\n { id: 'content', label: 'Content', screen: 'site.content', console: ref('hostTab', 'nav-tab-content') },\n ],\n console: ref('hostTab', 'nav-tab-screens'),\n },\n {\n id: 'media',\n label: 'Media',\n icon: ICONS.media,\n screen: 'site.media',\n order: 20,\n console: ref('hostTab', 'nav-tab-media'),\n },\n ],\n },\n { id: 'sell', label: 'Sell', foldable: true, rows: [] },\n { id: 'customers', label: 'Customers', foldable: true, rows: [] },\n { id: 'more', label: 'More', foldable: true, rows: [] },\n {\n id: 'settings',\n foldable: false,\n rows: [\n {\n id: 'siteSettings',\n label: 'Site settings',\n icon: ICONS.settings,\n screen: 'shell.siteSettings',\n order: 10,\n console: ref('shell', 'siteSettings'),\n },\n ],\n },\n ],\n}\n\n/** Each row's place, in the order written. */\nconst ordered = (rows: NativeNavRow[]): NativeNavRow[] =>\n rows.map((row, index) => ({ ...row, order: row.order ?? (index + 1) * 10 }))\n\n/** The help page each settings hub's `help` prop names, the rows' docs. */\nconst HUB_DOCS: Partial<Record<NativeNavConsoleSurface, string>> = {\n teamSection: '/workspace-and-billing/teams-and-roles/overview#team-page',\n billingSection: '/workspace-and-billing/billing-and-plans/overview#billing-page',\n orgSettingsSection: '/getting-started/console-tour#organization-settings',\n hostAdminSection: '/getting-started/create-a-site#site-admin',\n}\n\nconst setupRow = (\n id: string,\n label: string,\n rowIcon: NativeNavIcon,\n description: string,\n keywords?: string[],\n): NativeNavRow => ({\n id,\n label,\n icon: rowIcon,\n screen: id === 'theme' ? 'site.theme' : 'site.setup',\n ...(id === 'theme' ? {} : { params: { section: id } }),\n description,\n ...(keywords ? { keywords } : {}),\n console: ref('setupSection', id),\n})\n\nconst adminRow = (\n id: string,\n label: string,\n rowIcon: NativeNavIcon,\n screen: string,\n route: string,\n): NativeNavRow => ({\n id,\n label,\n icon: rowIcon,\n screen,\n requiresHostAdmin: true,\n docs: HUB_DOCS.hostAdminSection,\n console: ref('hostAdminSection', route),\n})\n\nconst settingsRow = (\n surface: NativeNavConsoleSurface,\n id: string,\n label: string,\n rowIcon: NativeNavIcon,\n screen: string,\n route: string,\n extra: Partial<Pick<NativeNavRow, 'keywords' | 'order'>> = {},\n): NativeNavRow => ({\n id,\n label,\n icon: rowIcon,\n screen,\n ...extra,\n ...(HUB_DOCS[surface] ? { docs: HUB_DOCS[surface] } : {}),\n console: ref(surface, route),\n})\n\nconst WORKSPACE_SETTINGS: NativeNavList = {\n id: 'workspaceSettings',\n title: 'settings',\n groups: [\n {\n id: 'team',\n label: 'Team',\n foldable: false,\n rows: ordered([\n settingsRow('teamSection', 'members', 'Members', ICONS.members, 'core.team', 'MANAGE_TEAM_MEMBERS', { keywords: ['team', 'invite', 'people'] }),\n settingsRow('teamSection', 'roles', 'Custom roles', ICONS.roles, 'core.team.roles', 'MANAGE_TEAM_ROLES', { keywords: ['permissions'] }),\n settingsRow('teamSection', 'activity', 'Recent activity', ICONS.activity, 'core.team.activity', 'MANAGE_TEAM_ACTIVITY', { keywords: ['audit log'] }),\n ]),\n },\n {\n id: 'billing',\n label: 'Billing',\n foldable: false,\n rows: [\n settingsRow('billingSection', 'plan', 'Plan', ICONS.plan, 'core.billing', 'MANAGE_BILLING', { order: 10, keywords: ['billing', 'upgrade', 'subscription'] }),\n settingsRow('billingSection', 'usage', 'Usage', ICONS.usage, 'core.billing.usage', 'MANAGE_BILLING_USAGE', { order: 20, keywords: ['billing', 'limits'] }),\n settingsRow('billingSection', 'invoices', 'Invoices', ICONS.invoices, 'core.billing.invoices', 'MANAGE_BILLING_INVOICES', { order: 40, keywords: ['billing', 'receipts'] }),\n settingsRow('billingSection', 'billingSettings', 'Settings', ICONS.billingSettings, 'core.billing.settings', 'MANAGE_BILLING_SETTINGS', { order: 50, keywords: ['billing', 'payment method', 'tax'] }),\n ],\n },\n {\n id: 'workspace',\n label: 'Workspace',\n foldable: false,\n rows: ordered([\n settingsRow('orgTab', 'plugins', 'Plugins', ICONS.plugins, 'core.plugins', 'nav-tab-org-plugins'),\n settingsRow('orgSettingsSection', 'branding', 'Branding', ICONS.branding, 'core.settings.branding', 'ORG_SETTINGS_BRANDING', { keywords: ['white label', 'logo', 'colors'] }),\n settingsRow('orgSettingsSection', 'sso', 'Single sign-on', ICONS.sso, 'core.settings.sso', 'ORG_SETTINGS_SSO', { keywords: ['sso', 'saml'] }),\n settingsRow('orgSettingsSection', 'profile', 'Profile', ICONS.profile, 'core.settings.profile', 'ORG_SETTINGS_PROFILE'),\n settingsRow('orgSettingsSection', 'apiKeys', 'API keys', ICONS.apiKeys, 'core.settings.apiKeys', 'ORG_SETTINGS_API_KEYS'),\n settingsRow('orgSettingsSection', 'integrations', 'Integrations', ICONS.integrations, 'core.settings.integrations', 'ORG_SETTINGS_INTEGRATIONS'),\n settingsRow('orgSettingsSection', 'general', 'General', ICONS.settings, 'core.settings.general', 'ORG_SETTINGS_GENERAL', { keywords: ['name', 'address'] }),\n ]),\n },\n {\n id: 'data',\n label: 'Data & compliance',\n foldable: false,\n rows: ordered([\n settingsRow('orgSettingsSection', 'privacy', 'Privacy', ICONS.privacy, 'core.settings.privacy', 'ORG_SETTINGS_PRIVACY', { keywords: ['gdpr', 'erase'] }),\n settingsRow('orgSettingsSection', 'holds', 'Holds & reviews', ICONS.holds, 'core.settings.holds', 'ORG_SETTINGS_HOLDS'),\n settingsRow('orgSettingsSection', 'importExport', 'Import & export', ICONS.importExport, 'core.settings.data', 'ORG_SETTINGS_DATA', { keywords: ['csv', 'export'] }),\n ]),\n },\n {\n id: 'danger',\n label: 'Danger zone',\n foldable: false,\n rows: ordered([\n settingsRow('orgSettingsSection', 'ownership', 'Ownership', ICONS.ownership, 'core.settings.ownership', 'ORG_SETTINGS_OWNERSHIP', { keywords: ['transfer'] }),\n settingsRow('orgSettingsSection', 'delete', 'Delete', ICONS.delete, 'core.settings.delete', 'ORG_SETTINGS_DELETE'),\n ]),\n },\n ],\n}\n\nconst SITE_SETTINGS: NativeNavList = {\n id: 'siteSettings',\n title: 'settings',\n groups: [\n {\n id: 'people',\n foldable: false,\n rows: ordered([\n {\n id: 'users',\n label: 'Users',\n icon: ICONS.members,\n screen: 'core.site.users',\n keywords: ['team', 'collaborators'],\n console: ref('hostTab', 'nav-tab-users'),\n },\n ]),\n },\n {\n id: 'setup',\n label: 'Setup',\n foldable: false,\n rows: ordered([\n setupRow('details', 'Basic details', ICONS.details, 'Logo, business details, layout and languages'),\n setupRow('business', 'Business profile', ICONS.business, 'What the business is, for everything that writes about it'),\n setupRow('seo', 'SEO', ICONS.seo, 'Search title, social image, business profile and verification', ['search']),\n setupRow('tracking', 'Tracking', ICONS.tracking, 'Analytics, ad tags and the consent banner', ['cookies', 'pixels']),\n setupRow('theme', 'Theme', ICONS.theme, 'Colors, font, shape and your saved themes', ['colors', 'fonts']),\n setupRow('emails', 'Emails', ICONS.emails, 'The emails your site sends to customers'),\n setupRow('integrations', 'Integrations', ICONS.integrations, 'Email platforms, Zapier, live chat and the other tools your site connects to'),\n ]),\n },\n {\n id: 'admin',\n label: 'Admin',\n foldable: false,\n rows: ordered([\n adminRow('general', 'General', ICONS.settings, 'core.site.general', 'HOST_ADMIN_GENERAL'),\n adminRow('plugins', 'Plugins', ICONS.plugins, 'core.site.plugins', 'HOST_ADMIN_PLUGINS'),\n adminRow('domain', 'Custom Domain', ICONS.domain, 'core.site.domain', 'HOST_ADMIN_DOMAIN'),\n adminRow('security', 'Security', ICONS.security, 'core.site.security', 'HOST_ADMIN_SECURITY'),\n adminRow('errorPages', 'Error pages', ICONS.errorPages, 'core.site.errorPages', 'HOST_ADMIN_ERROR_PAGES'),\n adminRow('activity', 'Activity', ICONS.activity, 'core.site.activity', 'HOST_ADMIN_ACTIVITY'),\n adminRow('backup', 'Backup & template', ICONS.backup, 'core.site.backup', 'HOST_ADMIN_BACKUP'),\n adminRow('danger', 'Danger zone', ICONS.delete, 'core.site.delete', 'HOST_ADMIN_DANGER'),\n ]),\n },\n ],\n}\n\nconst CREATE: NativeNavCreateList[] = [\n {\n scope: 'workspace',\n items: [\n {\n id: 'site',\n label: 'Site',\n icon: ICONS.sites,\n screen: 'site.sites',\n params: { new: '1' },\n permission: 'hosts.create',\n order: 10,\n console: ref('orgTab', 'nav-tab-org-sites'),\n },\n ],\n },\n {\n scope: 'site',\n items: [\n {\n id: 'page',\n label: 'Page',\n icon: ICONS.pages,\n screen: 'site.pages',\n params: { new: '1' },\n hostRoles: ['admin', 'editor', 'author'],\n order: 10,\n console: ref('hostTab', 'nav-tab-screens'),\n },\n ],\n },\n]\n\n/**\n * The core's half of the manifest: every list and group, and the core's own\n * rows. The manifest the apps read (`ContractValues.nativeNavManifest`) is\n * this with each plugin's `NATIVE_NAV_ROWS` placed by `assembleNativeNav`.\n */\nexport const NATIVE_NAV_MANIFEST: NativeNavManifest = {\n lists: [WORKSPACE, SITE, WORKSPACE_SETTINGS, SITE_SETTINGS],\n create: CREATE,\n shellScreens: [...NATIVE_NAV_SHELL_SCREENS],\n elsewhere: [\n { console: ref('hostTab', 'nav-tab-dashboard'), where: 'Home, inside the site (shell.home)' },\n { console: ref('hostTab', 'nav-tab-setup'), where: 'Site settings → Setup' },\n { console: ref('hostTab', 'nav-tab-admin'), where: 'Site settings → Admin' },\n { console: ref('orgTab', 'nav-tab-org-team'), where: 'Workspace settings → Team' },\n { console: ref('orgTab', 'nav-tab-org-billing'), where: 'Workspace settings → Billing' },\n { console: ref('orgTab', 'nav-tab-org-settings'), where: 'Workspace settings' },\n { console: ref('orgTab', 'nav-tab-org-support'), where: 'Help menu → Contact support (core.support)' },\n ],\n}\n\n/**\n * The manifest with the plugins' rows placed: each into its list's group by\n * `order` (a tie keeps the core's row first, then registration order). A row\n * naming a list or group the core does not have is refused by name, so a\n * plugin cannot quietly invent a group.\n */\nexport function assembleNativeNav(\n core: NativeNavManifest,\n contributions: readonly NativeNavContribution[],\n elsewhere: readonly NativeNavElsewhere[] = [],\n creates: readonly NativeNavCreateContribution[] = [],\n): NativeNavManifest {\n const byOrder = <T extends { order?: number }>(entries: T[]): T[] =>\n entries\n .map((entry, index) => ({ entry, index }))\n .sort((a, b) => (a.entry.order ?? 0) - (b.entry.order ?? 0) || a.index - b.index)\n .map(({ entry }) => entry)\n const lists = core.lists.map((list) => ({\n ...list,\n groups: list.groups.map((group) => ({ ...group, rows: [...group.rows] })),\n }))\n for (const { list: listId, group: groupId, row } of contributions) {\n const group = lists.find((list) => list.id === listId)?.groups.find((entry) => entry.id === groupId)\n if (!group || group.dynamic) {\n throw new Error(`native nav: ${row.id} names ${listId}/${groupId}, which is not a group of rows`)\n }\n if (group.rows.some((entry) => entry.id === row.id)) {\n throw new Error(`native nav: ${listId}/${groupId} holds ${row.id} twice`)\n }\n group.rows.push(row)\n }\n for (const list of lists) {\n for (const group of list.groups) {\n // A section is helped by its row's page unless the console names its own.\n group.rows = byOrder(group.rows).map((row) =>\n row.docs && row.sections\n ? { ...row, sections: row.sections.map((section) => (section.docs ? section : { ...section, docs: row.docs })) }\n : row,\n )\n }\n }\n const create = (core.create ?? []).map((entry) => ({ ...entry, items: [...entry.items] }))\n for (const { scope, item } of creates) {\n const target = create.find((entry) => entry.scope === scope)\n if (!target) throw new Error(`native nav: create item ${item.id} names ${scope}, which has no menu`)\n if (target.items.some((entry) => entry.id === item.id)) {\n throw new Error(`native nav: the ${scope} create menu holds ${item.id} twice`)\n }\n target.items.push(item)\n }\n return {\n ...core,\n lists,\n create: create.map((entry) => ({ ...entry, items: byOrder(entry.items) })),\n elsewhere: [...core.elsewhere, ...elsewhere],\n }\n}\n\n/** What a Create new item that cannot be used says, when its own reason does not apply. */\nexport const NATIVE_CREATE_PERMISSION_REASON =\n \"Your role can't create this here. Ask an owner or admin of the workspace.\"\nexport const NATIVE_CREATE_SITE_ROLE_REASON = \"Your role on this site can't create this. Ask a site admin.\"\nexport const NATIVE_CREATE_PLAN_REASON = \"Your plan doesn't include this. See the plans in Billing.\"\n\n/** A Create new item as one scope offers it. */\nexport interface ResolvedCreateItem extends NativeNavCreateItem {\n /** Shown, but disabled with `reason`: a prerequisite stands between the person and it. */\n blocked: boolean\n reason?: string\n}\n\n/**\n * The Create new menu for the workspace or site in hand. An item of a plugin\n * that is off is not offered, nor an admin-only item to a non-admin. One the\n * person may not use is SHOWN, disabled with its reason (prerequisites are\n * shown, never hidden): a permission or site role they lack, then a plan\n * feature the workspace lacks. `permissions` and `features` are the\n * workspace's resolved answers (an absent key is not held); `hostRole` is\n * the person's role on the site, null at the workspace.\n */\nexport function resolveCreateList(\n manifest: NativeNavManifest,\n scope: NativeNavCreateScope,\n enabledPluginIds: readonly string[],\n permissions: Readonly<Record<string, boolean>>,\n features: Readonly<Record<string, boolean>>,\n hostRole: string | null,\n): ResolvedCreateItem[] {\n const on = new Set(enabledPluginIds)\n const items = manifest.create?.find((entry) => entry.scope === scope)?.items ?? []\n return items\n .filter((item) => (!item.pluginId || on.has(item.pluginId)) && (!item.requiresHostAdmin || hostRole === 'admin'))\n .map((item): ResolvedCreateItem => {\n if (item.permission && permissions[item.permission] !== true) {\n return { ...item, blocked: true, reason: NATIVE_CREATE_PERMISSION_REASON }\n }\n if (item.hostRoles && !item.hostRoles.includes(hostRole ?? '')) {\n return { ...item, blocked: true, reason: NATIVE_CREATE_SITE_ROLE_REASON }\n }\n if (item.planFeature && features[item.planFeature] !== true) {\n return { ...item, blocked: true, reason: item.blockedReason ?? NATIVE_CREATE_PLAN_REASON }\n }\n return { ...item, blocked: false }\n })\n}\n\n/** A list as one scope shows it: rows for plugins that are off, or admin rows for a non-admin, left out. */\nexport interface ResolvedNavList {\n id: NativeNavListId\n title?: string\n groups: NativeNavGroup[]\n}\n\n/**\n * One list for the workspace or site in hand, from the assembled manifest\n * (`ContractValues.nativeNavManifest`). `enabledPluginIds` is the site's\n * effective set (`resolveHostEnabledPlugins`) in site scope and the\n * workspace's (`resolveEnabledPlugins`) otherwise. A section of another\n * plugin than its row's hides with that plugin. A group left with no rows is\n * dropped, except the starred group, which the shell fills.\n */\nexport function resolveNavList(\n manifest: NativeNavManifest,\n listId: NativeNavListId,\n enabledPluginIds: readonly string[],\n hostAdmin: boolean,\n): ResolvedNavList {\n const list = manifest.lists.find((entry) => entry.id === listId)\n if (!list) return { id: listId, groups: [] }\n const on = new Set(enabledPluginIds)\n const shows = (pluginId?: string) => !pluginId || on.has(pluginId)\n const groups: NativeNavGroup[] = []\n for (const group of list.groups) {\n const rows = group.rows\n .filter((row) => shows(row.pluginId) && (hostAdmin || !row.requiresHostAdmin))\n .map((row) =>\n row.sections\n ? { ...row, sections: row.sections.filter((section) => shows(section.pluginId)) }\n : row,\n )\n if (!rows.length && !group.dynamic) continue\n groups.push({ ...group, rows })\n }\n return { id: list.id, ...(list.title ? { title: list.title } : {}), groups }\n}\n\n// ── The phone's Home (AGL-4006) ─────────────────────────────────────────────\n\n/**\n * A group's heading on the phone's Home where it differs from the sidebar's.\n * Nothing on the phone reads \"More\", so the sidebar's More\n * group is headed Tools there.\n */\nexport const PHONE_HOME_GROUP_LABELS: Record<string, string> = { more: 'Tools' }\n\n/** The heading of the phone Home's last group: inside a site, and for the whole workspace. */\nexport const PHONE_HOME_SITE_GROUP_LABEL = 'Site & workspace'\nexport const PHONE_HOME_WORKSPACE_GROUP_LABEL = 'Settings'\n\n/** The Team tile's word: the console's tab for Members, Custom roles and Recent activity. */\nexport const PHONE_HOME_TEAM_LABEL = 'Team'\n\n/** The tile that opens Workspace settings on the phone's Home. */\nexport const WORKSPACE_SETTINGS_ROW: NativeNavRow = {\n id: 'workspaceSettings',\n label: 'Workspace settings',\n icon: ICONS.profile,\n screen: 'shell.workspaceSettings',\n console: ref('shell', 'workspaceSettings'),\n}\n\n/** One group of tiles on the phone's Home. */\nexport interface PhoneHomeGroup {\n id: string\n /** Absent for a group drawn without a heading. */\n label?: string\n rows: NativeNavRow[]\n}\n\n/**\n * The phone's Home: every area of the scope as the same\n * tile, in the sidebar's own groups, then the scope's own places last\n * (Overview and Site settings in a site; Team and Workspace settings\n * everywhere). Nothing is ranked above anything else and nothing sits behind\n * a More.\n *\n * `list` is the scope's everyday list as the app shows it (`resolveNavList`\n * trimmed to the build's screens), `team` the workspace settings' Members row\n * when the person may open it, and `ownerName` heads the whole workspace's\n * areas, whose group has no heading of its own.\n */\nexport function phoneHomeGroups(\n list: ResolvedNavList,\n team: NativeNavRow | null,\n ownerName: string,\n): PhoneHomeGroup[] {\n const inSite = list.id === 'site'\n const own: NativeNavRow[] = []\n const groups: PhoneHomeGroup[] = []\n for (const group of list.groups) {\n if (group.dynamic) continue\n const rows = group.rows.filter((row) => row.screen !== 'shell.home')\n if (group.id === 'top' || group.id === 'settings') {\n own.push(...rows)\n continue\n }\n if (!rows.length) continue\n const label = PHONE_HOME_GROUP_LABELS[group.id] ?? group.label ?? (ownerName || undefined)\n groups.push({ id: group.id, ...(label ? { label } : {}), rows })\n }\n if (team) own.push({ ...team, label: PHONE_HOME_TEAM_LABEL })\n own.push(WORKSPACE_SETTINGS_ROW)\n groups.push({\n id: 'scope',\n label: inSite ? PHONE_HOME_SITE_GROUP_LABEL : PHONE_HOME_WORKSPACE_GROUP_LABEL,\n rows: own,\n })\n return groups\n}\n\n/** Whether a Home tile may go in the tab bar: an area, never Home itself or a settings mode. */\nexport function isTabPinnable(row: Pick<NativeNavRow, 'screen'>): boolean {\n return (\n row.screen !== 'shell.home' &&\n row.screen !== 'shell.workspaceSettings' &&\n row.screen !== 'shell.siteSettings'\n )\n}\n"],"names":["NATIVE_NAV_SHELL_SCREENS","nativeNavIcon","apple","android","nativeNavRef","surface","id","nativeNavHubSection","scope","href","label","screen","extra","console","icon","ref","ICONS","home","overview","sites","pages","media","settings","emails","members","roles","activity","plan","usage","invoices","billingSettings","plugins","branding","sso","profile","apiKeys","integrations","privacy","holds","importExport","ownership","delete","details","business","seo","tracking","theme","domain","security","errorPages","backup","HOME_ROW","order","WORKSPACE","groups","foldable","rows","dynamic","docs","SITE","consoleLabel","keywords","sections","ordered","map","row","index","HUB_DOCS","teamSection","billingSection","orgSettingsSection","hostAdminSection","setupRow","rowIcon","description","params","section","adminRow","route","requiresHostAdmin","settingsRow","WORKSPACE_SETTINGS","title","SITE_SETTINGS","CREATE","items","new","permission","hostRoles","NATIVE_NAV_MANIFEST","lists","create","shellScreens","elsewhere","where","assembleNativeNav","core","contributions","creates","byOrder","entries","entry","sort","a","b","list","group","listId","groupId","find","Error","some","push","item","target","NATIVE_CREATE_PERMISSION_REASON","NATIVE_CREATE_SITE_ROLE_REASON","NATIVE_CREATE_PLAN_REASON","resolveCreateList","manifest","enabledPluginIds","permissions","features","hostRole","on","Set","filter","pluginId","has","blocked","reason","includes","planFeature","blockedReason","resolveNavList","hostAdmin","shows","length","PHONE_HOME_GROUP_LABELS","more","PHONE_HOME_SITE_GROUP_LABEL","PHONE_HOME_WORKSPACE_GROUP_LABEL","PHONE_HOME_TEAM_LABEL","WORKSPACE_SETTINGS_ROW","phoneHomeGroups","team","ownerName","inSite","own","undefined","isTabPinnable"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GAED,4BAA4B;AAiM5B,kCAAkC,GAClC,OAAO,MAAMA,2BAA8C;IACzD;IACA;IACA;IACA;CACD,CAAA;AAED,wDAAwD,GACxD,OAAO,MAAMC,gBAAgB,CAACC,OAAeC,UAAoC,CAAA;QAAED;QAAOC;IAAQ,CAAA,EAAE;AAEpG,+DAA+D,GAC/D,OAAO,MAAMC,eAAe,CAACC,SAAkCC,KAAqC,CAAA;QAClGD;QACAC;IACF,CAAA,EAAE;AAEF,+DAA+D,GAC/D,OAAO,SAASC,oBACdC,KAAqB,EACrBC,IAAY,EACZH,EAAU,EACVI,KAAa,EACbC,MAAc,EACdC,QAAgE,CAAC,CAAC;IAElE,OAAO;QACLN;QACAI;QACAC;OACGC;QACHC,SAAST,aAAaI,UAAU,QAAQ,qBAAqB,qBAAqB,GAAGC,KAAK,CAAC,EAAEH,IAAI;;AAErG;AAEA,MAAMQ,OAAOb;AACb,MAAMc,MAAMX;AAEZ,MAAMY,QAAQ;IACZC,MAAMH,KAAK,SAAS;IACpBI,UAAUJ,KAAK,aAAa;IAC5BK,OAAOL,KAAK,SAAS;IACrBM,OAAON,KAAK,YAAY;IACxBO,OAAOP,KAAK,sBAAsB;IAClCQ,UAAUR,KAAK,aAAa;I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A,oCAAAA,uBAAuB,CAAChC,MAAMpG,EAAE,CAAC,YAAjCoI,oCAAqChC,MAAMhG,KAAK,YAAhDgI,OAAqDQ,aAAaG;QAChF/F,OAAO0D,IAAI,CAAC;YAAE1G,IAAIoG,MAAMpG,EAAE;WAAMI,QAAQ;YAAEA;QAAM,IAAI,CAAC;YAAI8C;;IAC3D;IACA,IAAIyF,MAAMG,IAAIpC,IAAI,CAAC,aAAKiC;QAAMvI,OAAOoI;;IACrCM,IAAIpC,IAAI,CAAC+B;IACTzF,OAAO0D,IAAI,CAAC;QACV1G,IAAI;QACJI,OAAOyI,SAASP,8BAA8BC;QAC9CrF,MAAM4F;IACR;IACA,OAAO9F;AACT;AAEA,8FAA8F,GAC9F,OAAO,SAASgG,cAAcrF,GAAiC;IAC7D,OACEA,IAAItD,MAAM,KAAK,gBACfsD,IAAItD,MAAM,KAAK,6BACfsD,IAAItD,MAAM,KAAK;AAEnB"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-nav.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 * THE NATIVE APPS' NAVIGATION, AS DATA (AGL-3943).\n *\n * One manifest both shells draw (docs/mobile/native-navigation.md): the\n * sidebar for the whole workspace, the sidebar inside one site, and the two\n * settings modes (the workspace's, and the site's, which merges the\n * console's Setup and Admin). Zach chose the site's groups on 2026-10-18:\n * an Analytics row, Starred, Website, Sell, Customers, More, Site settings.\n *\n * Every row names:\n * - the console's word for it (`label`), held to the console by\n * `apps/console/specs/native-nav-manifest.spec.ts`, which reads the\n * console's own tabs, sections and plugin declarations;\n * - one icon per idea, an SF Symbol and a Material Symbol;\n * - the native screen it opens (a plugin's declared screen, a core screen\n * spec, a site platform screen or a `shell.*` destination);\n * - the plugin it belongs to, so it hides when that plugin is off for the\n * workspace or the site.\n *\n * The core's own rows (Home, Analytics, Sites, Pages, Media, the settings\n * modes) are here; a plugin's rows are its own, in\n * `libs/plugins/<plugin>/src/lib/native-nav.ts` (`NATIVE_NAV_ROWS`), placed\n * into a list's group by `order` (docs/PACKAGES.md rule 3: the core never\n * names a plugin). `generate:native-contracts` assembles the two\n * (`assembleNativeNav`) into the manifest the apps read,\n * `ContractValues.nativeNavManifest`.\n *\n * NO IMPORTS, on purpose: the native apps read this through the generated\n * contracts, so it must stay a plain module.\n */\n\n/** A list the shells draw. */\nexport type NativeNavListId = 'workspace' | 'site' | 'workspaceSettings' | 'siteSettings'\n\n/** One icon per idea: the same row draws the same picture in both scopes. */\nexport interface NativeNavIcon {\n /** An SF Symbol name. */\n apple: string\n /** A Material Symbol name, as `AglynIcons.named` takes it. */\n android: string\n}\n\n/**\n * Where a row's console twin lives:\n * - `orgTab` / `hostTab`: a console tab, by its id (`org-nav-tabs.ts`,\n * `host-nav-tabs.ts`);\n * - `orgPluginTab` / `hostPluginTab`: a plugin's `orgNavItems` / `navItems`\n * entry, by its href;\n * - `orgPluginSection` / `hostPluginSection`: a section of a plugin's hub, as\n * `{href}/{sectionId}`;\n * - `setupSection`: a site's Setup section, by its id (`setup-sections.ts`);\n * - `hostAdminSection`, `orgSettingsSection`, `teamSection`,\n * `billingSection`: a section of those hubs, by its `Route` name;\n * - `consoleWidget`: a plugin's card, as `{slot}/{widgetId}`;\n * - `shell`: a place the app's shell owns (Home, Analytics' page, the\n * settings modes), whose console twin is the page named in `id`;\n * - `nativeOnly`: a native screen the console has no page for.\n */\nexport type NativeNavConsoleSurface =\n | 'orgTab'\n | 'hostTab'\n | 'orgPluginTab'\n | 'hostPluginTab'\n | 'orgPluginSection'\n | 'hostPluginSection'\n | 'setupSection'\n | 'hostAdminSection'\n | 'orgSettingsSection'\n | 'teamSection'\n | 'billingSection'\n | 'consoleWidget'\n | 'shell'\n | 'nativeOnly'\n\nexport interface NativeNavConsoleRef {\n surface: NativeNavConsoleSurface\n id: string\n}\n\n/** A section inside a row's area, as the console's section rail lists it. */\nexport interface NativeNavSection {\n id: string\n label: string\n screen: string\n params?: Record<string, string>\n /** Set only when the section belongs to another plugin than its row's. */\n pluginId?: string\n /** The help docs page for it; its row's, unless the console names its own. */\n docs?: string\n console: NativeNavConsoleRef\n}\n\n/** An action the area offers from its title bar (Scan stock, New product). */\nexport interface NativeNavAction {\n id: string\n label: string\n icon: NativeNavIcon\n screen: string\n params?: Record<string, string>\n}\n\nexport interface NativeNavRow {\n /** The idea's id: the same in every list that shows it (`media`). */\n id: string\n /** The console's word. */\n label: string\n /**\n * The console's word when the native label is a decision of its own\n * (a row the apps name differently from the console).\n */\n consoleLabel?: string\n icon: NativeNavIcon\n /** The native screen the row opens. */\n screen: string\n params?: Record<string, string>\n /** The plugin the row belongs to: off for the workspace or site, the row hides. */\n pluginId?: string\n /** Only a site admin sees the row, as only they see the console's Admin tab. */\n requiresHostAdmin?: boolean\n /** A settings row's one line, in the words the screens already use. */\n description?: string\n /** Search words besides the label, so typing \"billing\" finds Plan. */\n keywords?: string[]\n /** Where the row sits in its group, ascending; a plugin's row is placed by it. */\n order?: number\n /**\n * The help docs page for the place, as the console's own help names it\n * (its `docsTopic` and `docsAnchor`, or the page's `help` prop): a docs-site\n * path with its anchor, e.g. `/content-and-data/crm/overview#at-the-organization-level`.\n * The apps open it in the in-app browser, on the docs origin.\n */\n docs?: string\n sections?: NativeNavSection[]\n actions?: NativeNavAction[]\n console: NativeNavConsoleRef\n}\n\nexport interface NativeNavGroup {\n id: string\n /** The heading; absent for a group drawn without one. */\n label?: string\n /** Folded at rest unless it holds the screen in use, remembered per device. */\n foldable: boolean\n /** `starred`: the person's starred items for this scope, drawn by the shell. */\n dynamic?: 'starred'\n rows: NativeNavRow[]\n}\n\nexport interface NativeNavList {\n id: NativeNavListId\n /** The settings mode's title, after its owner's name (\"Juniper Street Co. settings\"). */\n title?: string\n groups: NativeNavGroup[]\n}\n\n/** A console place no row holds, and where the apps put it instead. */\nexport interface NativeNavElsewhere {\n console: NativeNavConsoleRef\n where: string\n}\n\n/** A plugin's row, and the list and group it goes in. */\nexport interface NativeNavContribution {\n list: NativeNavListId\n /** A group of that list, by id. */\n group: string\n row: NativeNavRow\n}\n\n/** Where the Create new menu is offered: the whole workspace, or one site. */\nexport type NativeNavCreateScope = 'workspace' | 'site'\n\n/**\n * One item of the Create new menu (\"+\" on the rail, the center tab on\n * phones): what the console offers to create from that scope, opening the\n * area's own create form.\n */\nexport interface NativeNavCreateItem {\n id: string\n /** The thing made, in the console's words (\"Draft order\", \"Service\"). */\n label: string\n icon: NativeNavIcon\n /** The native screen the item opens, with `params` that open its create form. */\n screen: string\n params?: Record<string, string>\n /** The plugin it belongs to: off for the workspace or site, the item is not offered. */\n pluginId?: string\n /** Only a site admin is offered it. */\n requiresHostAdmin?: boolean\n /** The workspace permission the console's create action asks for (`hosts.create`, `data.manage`). */\n permission?: string\n /** The site roles that may make it, as the rules hold them (`canWriteHostContent`). */\n hostRoles?: string[]\n /** The plan feature it needs; without it the item is shown blocked, with `blockedReason`. */\n planFeature?: string\n /** Why it is blocked when the plan lacks `planFeature`; the default reason otherwise. */\n blockedReason?: string\n /** Where it sits in the menu, ascending. */\n order?: number\n /** Where the console offers the same create action. */\n console: NativeNavConsoleRef\n}\n\n/** One scope's Create new menu. */\nexport interface NativeNavCreateList {\n scope: NativeNavCreateScope\n items: NativeNavCreateItem[]\n}\n\n/** A plugin's Create new item, and the scope that offers it. */\nexport interface NativeNavCreateContribution {\n scope: NativeNavCreateScope\n item: NativeNavCreateItem\n}\n\nexport interface NativeNavManifest {\n lists: NativeNavList[]\n /** The Create new menu per scope (AGL-3943). */\n create?: NativeNavCreateList[]\n /** Destinations the shells own, which no plugin registers. */\n shellScreens: string[]\n elsewhere: NativeNavElsewhere[]\n}\n\n/** The shells' own destinations. */\nexport const NATIVE_NAV_SHELL_SCREENS: readonly string[] = [\n 'shell.home',\n 'shell.analytics',\n 'shell.workspaceSettings',\n 'shell.siteSettings',\n]\n\n/** An icon pair, for the rows here and in the plugins. */\nexport const nativeNavIcon = (apple: string, android: string): NativeNavIcon => ({ apple, android })\n\n/** A console reference, for the rows here and in the plugins. */\nexport const nativeNavRef = (surface: NativeNavConsoleSurface, id: string): NativeNavConsoleRef => ({\n surface,\n id,\n})\n\n/** A section of a plugin hub, at the scope its row stands in. */\nexport function nativeNavHubSection(\n scope: 'org' | 'host',\n href: string,\n id: string,\n label: string,\n screen: string,\n extra: Partial<Pick<NativeNavSection, 'params' | 'pluginId'>> = {},\n): NativeNavSection {\n return {\n id,\n label,\n screen,\n ...extra,\n console: nativeNavRef(scope === 'org' ? 'orgPluginSection' : 'hostPluginSection', `${href}/${id}`),\n }\n}\n\nconst icon = nativeNavIcon\nconst ref = nativeNavRef\n\nconst ICONS = {\n home: icon('house', 'home'),\n overview: icon('chart.bar', 'bar_chart'),\n sites: icon('globe', 'public'),\n pages: icon('doc.text', 'description'),\n media: icon('photo.on.rectangle', 'photo_library'),\n settings: icon('gearshape', 'settings'),\n emails: icon('envelope', 'mail'),\n members: icon('person.2', 'group'),\n roles: icon('person.badge.key', 'admin_panel_settings'),\n activity: icon('clock.arrow.circlepath', 'history'),\n plan: icon('creditcard', 'credit_card'),\n usage: icon('gauge.with.dots.needle.33percent', 'data_usage'),\n invoices: icon('doc.plaintext', 'receipt_long'),\n billingSettings: icon('slider.horizontal.3', 'tune'),\n plugins: icon('puzzlepiece.extension', 'extension'),\n branding: icon('paintbrush', 'brush'),\n sso: icon('key.viewfinder', 'vpn_key'),\n profile: icon('building.2', 'apartment'),\n apiKeys: icon('key', 'key'),\n integrations: icon('point.3.connected.trianglepath.dotted', 'hub'),\n privacy: icon('hand.raised', 'privacy_tip'),\n holds: icon('exclamationmark.triangle', 'warning'),\n importExport: icon('arrow.up.arrow.down', 'sync'),\n ownership: icon('person.crop.circle.badge.checkmark', 'manage_accounts'),\n delete: icon('trash', 'delete_forever'),\n details: icon('info.circle', 'info'),\n business: icon('briefcase', 'business'),\n seo: icon('magnifyingglass', 'travel_explore'),\n tracking: icon('chart.line.uptrend.xyaxis', 'query_stats'),\n theme: icon('paintpalette', 'palette'),\n domain: icon('link', 'domain'),\n security: icon('lock', 'security'),\n errorPages: icon('exclamationmark.circle', 'error_outline'),\n backup: icon('square.and.arrow.down', 'backup'),\n} as const\n\nconst HOME_ROW: NativeNavRow = {\n id: 'home',\n label: 'Home',\n icon: ICONS.home,\n screen: 'shell.home',\n order: 10,\n console: ref('shell', 'home'),\n}\n\nconst WORKSPACE: NativeNavList = {\n id: 'workspace',\n groups: [\n { id: 'top', foldable: false, rows: [HOME_ROW] },\n { id: 'starred', label: 'Starred', foldable: true, dynamic: 'starred', rows: [] },\n {\n id: 'workspace',\n foldable: false,\n rows: [\n {\n id: 'sites',\n label: 'Sites',\n icon: ICONS.sites,\n screen: 'site.sites',\n order: 10,\n docs: '/getting-started/console-tour#the-sites-list',\n console: ref('orgTab', 'nav-tab-org-sites'),\n },\n {\n id: 'media',\n label: 'Media',\n icon: ICONS.media,\n screen: 'site.media',\n order: 90,\n console: ref('orgTab', 'nav-tab-org-media'),\n },\n ],\n },\n ],\n}\n\nconst SITE: NativeNavList = {\n id: 'site',\n groups: [\n {\n id: 'top',\n foldable: false,\n rows: [\n HOME_ROW,\n {\n id: 'overview',\n // \"Analytics\", the console's own word: \"Overview\" read as a second Home (AGL-4011).\n label: 'Analytics',\n consoleLabel: 'Analytics',\n icon: ICONS.overview,\n screen: 'shell.analytics',\n order: 20,\n keywords: ['analytics', 'traffic', 'visitors'],\n console: ref('hostTab', 'nav-tab-analytics'),\n },\n ],\n },\n { id: 'starred', label: 'Starred', foldable: true, dynamic: 'starred', rows: [] },\n {\n id: 'website',\n label: 'Website',\n foldable: true,\n rows: [\n {\n id: 'pages',\n label: 'Pages',\n icon: ICONS.pages,\n screen: 'site.pages',\n order: 10,\n sections: [\n { id: 'pages', label: 'Pages', screen: 'site.pages', console: ref('hostTab', 'nav-tab-screens') },\n { id: 'components', label: 'Components', screen: 'site.components', console: ref('hostTab', 'nav-tab-components') },\n { id: 'layouts', label: 'Layouts', screen: 'site.layouts', console: ref('hostTab', 'nav-tab-layouts') },\n { id: 'templates', label: 'Templates', screen: 'site.templates', console: ref('hostTab', 'nav-tab-templates') },\n { id: 'content', label: 'Content', screen: 'site.content', console: ref('hostTab', 'nav-tab-content') },\n ],\n console: ref('hostTab', 'nav-tab-screens'),\n },\n {\n id: 'media',\n label: 'Media',\n icon: ICONS.media,\n screen: 'site.media',\n order: 20,\n console: ref('hostTab', 'nav-tab-media'),\n },\n ],\n },\n { id: 'sell', label: 'Sell', foldable: true, rows: [] },\n { id: 'customers', label: 'Customers', foldable: true, rows: [] },\n { id: 'more', label: 'More', foldable: true, rows: [] },\n {\n id: 'settings',\n foldable: false,\n rows: [\n {\n id: 'siteSettings',\n label: 'Site settings',\n icon: ICONS.settings,\n screen: 'shell.siteSettings',\n order: 10,\n console: ref('shell', 'siteSettings'),\n },\n ],\n },\n ],\n}\n\n/** Each row's place, in the order written. */\nconst ordered = (rows: NativeNavRow[]): NativeNavRow[] =>\n rows.map((row, index) => ({ ...row, order: row.order ?? (index + 1) * 10 }))\n\n/** The help page each settings hub's `help` prop names, the rows' docs. */\nconst HUB_DOCS: Partial<Record<NativeNavConsoleSurface, string>> = {\n teamSection: '/workspace-and-billing/teams-and-roles/overview#team-page',\n billingSection: '/workspace-and-billing/billing-and-plans/overview#billing-page',\n orgSettingsSection: '/getting-started/console-tour#organization-settings',\n hostAdminSection: '/getting-started/create-a-site#site-admin',\n}\n\nconst setupRow = (\n id: string,\n label: string,\n rowIcon: NativeNavIcon,\n description: string,\n keywords?: string[],\n): NativeNavRow => ({\n id,\n label,\n icon: rowIcon,\n screen: id === 'theme' ? 'site.theme' : 'site.setup',\n ...(id === 'theme' ? {} : { params: { section: id } }),\n description,\n ...(keywords ? { keywords } : {}),\n console: ref('setupSection', id),\n})\n\nconst adminRow = (\n id: string,\n label: string,\n rowIcon: NativeNavIcon,\n screen: string,\n route: string,\n): NativeNavRow => ({\n id,\n label,\n icon: rowIcon,\n screen,\n requiresHostAdmin: true,\n docs: HUB_DOCS.hostAdminSection,\n console: ref('hostAdminSection', route),\n})\n\nconst settingsRow = (\n surface: NativeNavConsoleSurface,\n id: string,\n label: string,\n rowIcon: NativeNavIcon,\n screen: string,\n route: string,\n extra: Partial<Pick<NativeNavRow, 'keywords' | 'order'>> = {},\n): NativeNavRow => ({\n id,\n label,\n icon: rowIcon,\n screen,\n ...extra,\n ...(HUB_DOCS[surface] ? { docs: HUB_DOCS[surface] } : {}),\n console: ref(surface, route),\n})\n\nconst WORKSPACE_SETTINGS: NativeNavList = {\n id: 'workspaceSettings',\n title: 'settings',\n groups: [\n {\n id: 'team',\n label: 'Team',\n foldable: false,\n rows: ordered([\n settingsRow('teamSection', 'members', 'Members', ICONS.members, 'core.team', 'MANAGE_TEAM_MEMBERS', { keywords: ['team', 'invite', 'people'] }),\n settingsRow('teamSection', 'roles', 'Custom roles', ICONS.roles, 'core.team.roles', 'MANAGE_TEAM_ROLES', { keywords: ['permissions'] }),\n settingsRow('teamSection', 'activity', 'Recent activity', ICONS.activity, 'core.team.activity', 'MANAGE_TEAM_ACTIVITY', { keywords: ['audit log'] }),\n ]),\n },\n {\n id: 'billing',\n label: 'Billing',\n foldable: false,\n rows: [\n settingsRow('billingSection', 'plan', 'Plan', ICONS.plan, 'core.billing', 'MANAGE_BILLING', { order: 10, keywords: ['billing', 'upgrade', 'subscription'] }),\n settingsRow('billingSection', 'usage', 'Usage', ICONS.usage, 'core.billing.usage', 'MANAGE_BILLING_USAGE', { order: 20, keywords: ['billing', 'limits'] }),\n settingsRow('billingSection', 'invoices', 'Invoices', ICONS.invoices, 'core.billing.invoices', 'MANAGE_BILLING_INVOICES', { order: 40, keywords: ['billing', 'receipts'] }),\n settingsRow('billingSection', 'billingSettings', 'Settings', ICONS.billingSettings, 'core.billing.settings', 'MANAGE_BILLING_SETTINGS', { order: 50, keywords: ['billing', 'payment method', 'tax'] }),\n ],\n },\n {\n id: 'workspace',\n label: 'Workspace',\n foldable: false,\n rows: ordered([\n settingsRow('orgTab', 'plugins', 'Plugins', ICONS.plugins, 'core.plugins', 'nav-tab-org-plugins'),\n settingsRow('orgSettingsSection', 'branding', 'Branding', ICONS.branding, 'core.settings.branding', 'ORG_SETTINGS_BRANDING', { keywords: ['white label', 'logo', 'colors'] }),\n settingsRow('orgSettingsSection', 'sso', 'Single sign-on', ICONS.sso, 'core.settings.sso', 'ORG_SETTINGS_SSO', { keywords: ['sso', 'saml'] }),\n settingsRow('orgSettingsSection', 'profile', 'Profile', ICONS.profile, 'core.settings.profile', 'ORG_SETTINGS_PROFILE'),\n settingsRow('orgSettingsSection', 'apiKeys', 'API keys', ICONS.apiKeys, 'core.settings.apiKeys', 'ORG_SETTINGS_API_KEYS'),\n settingsRow('orgSettingsSection', 'integrations', 'Integrations', ICONS.integrations, 'core.settings.integrations', 'ORG_SETTINGS_INTEGRATIONS'),\n settingsRow('orgSettingsSection', 'general', 'General', ICONS.settings, 'core.settings.general', 'ORG_SETTINGS_GENERAL', { keywords: ['name', 'address'] }),\n ]),\n },\n {\n id: 'data',\n label: 'Data & compliance',\n foldable: false,\n rows: ordered([\n settingsRow('orgSettingsSection', 'privacy', 'Privacy', ICONS.privacy, 'core.settings.privacy', 'ORG_SETTINGS_PRIVACY', { keywords: ['gdpr', 'erase'] }),\n settingsRow('orgSettingsSection', 'holds', 'Holds & reviews', ICONS.holds, 'core.settings.holds', 'ORG_SETTINGS_HOLDS'),\n settingsRow('orgSettingsSection', 'importExport', 'Import & export', ICONS.importExport, 'core.settings.data', 'ORG_SETTINGS_DATA', { keywords: ['csv', 'export'] }),\n ]),\n },\n {\n id: 'danger',\n label: 'Danger zone',\n foldable: false,\n rows: ordered([\n settingsRow('orgSettingsSection', 'ownership', 'Ownership', ICONS.ownership, 'core.settings.ownership', 'ORG_SETTINGS_OWNERSHIP', { keywords: ['transfer'] }),\n settingsRow('orgSettingsSection', 'delete', 'Delete', ICONS.delete, 'core.settings.delete', 'ORG_SETTINGS_DELETE'),\n ]),\n },\n ],\n}\n\nconst SITE_SETTINGS: NativeNavList = {\n id: 'siteSettings',\n title: 'settings',\n groups: [\n {\n id: 'people',\n foldable: false,\n rows: ordered([\n {\n id: 'users',\n label: 'Users',\n icon: ICONS.members,\n screen: 'core.site.users',\n keywords: ['team', 'collaborators'],\n console: ref('hostTab', 'nav-tab-users'),\n },\n ]),\n },\n {\n id: 'setup',\n label: 'Setup',\n foldable: false,\n rows: ordered([\n setupRow('details', 'Basic details', ICONS.details, 'Logo, business details, layout and languages'),\n setupRow('business', 'Business profile', ICONS.business, 'What the business is, for everything that writes about it'),\n setupRow('seo', 'SEO', ICONS.seo, 'Search title, social image, business profile and verification', ['search']),\n setupRow('tracking', 'Tracking', ICONS.tracking, 'Analytics, ad tags and the consent banner', ['cookies', 'pixels']),\n setupRow('theme', 'Theme', ICONS.theme, 'Colors, font, shape and your saved themes', ['colors', 'fonts']),\n setupRow('emails', 'Emails', ICONS.emails, 'The emails your site sends to customers'),\n setupRow('integrations', 'Integrations', ICONS.integrations, 'Email platforms, Zapier, live chat and the other tools your site connects to'),\n ]),\n },\n {\n id: 'admin',\n label: 'Admin',\n foldable: false,\n rows: ordered([\n adminRow('general', 'General', ICONS.settings, 'core.site.general', 'HOST_ADMIN_GENERAL'),\n adminRow('plugins', 'Plugins', ICONS.plugins, 'core.site.plugins', 'HOST_ADMIN_PLUGINS'),\n adminRow('domain', 'Custom Domain', ICONS.domain, 'core.site.domain', 'HOST_ADMIN_DOMAIN'),\n adminRow('security', 'Security', ICONS.security, 'core.site.security', 'HOST_ADMIN_SECURITY'),\n adminRow('errorPages', 'Error pages', ICONS.errorPages, 'core.site.errorPages', 'HOST_ADMIN_ERROR_PAGES'),\n adminRow('activity', 'Activity', ICONS.activity, 'core.site.activity', 'HOST_ADMIN_ACTIVITY'),\n adminRow('backup', 'Backup & template', ICONS.backup, 'core.site.backup', 'HOST_ADMIN_BACKUP'),\n adminRow('danger', 'Danger zone', ICONS.delete, 'core.site.delete', 'HOST_ADMIN_DANGER'),\n ]),\n },\n ],\n}\n\nconst CREATE: NativeNavCreateList[] = [\n {\n scope: 'workspace',\n items: [\n {\n id: 'site',\n label: 'Site',\n icon: ICONS.sites,\n screen: 'site.sites',\n params: { new: '1' },\n permission: 'hosts.create',\n order: 10,\n console: ref('orgTab', 'nav-tab-org-sites'),\n },\n ],\n },\n {\n scope: 'site',\n items: [\n {\n id: 'page',\n label: 'Page',\n icon: ICONS.pages,\n screen: 'site.pages',\n params: { new: '1' },\n hostRoles: ['admin', 'editor', 'author'],\n order: 10,\n console: ref('hostTab', 'nav-tab-screens'),\n },\n ],\n },\n]\n\n/**\n * The core's half of the manifest: every list and group, and the core's own\n * rows. The manifest the apps read (`ContractValues.nativeNavManifest`) is\n * this with each plugin's `NATIVE_NAV_ROWS` placed by `assembleNativeNav`.\n */\nexport const NATIVE_NAV_MANIFEST: NativeNavManifest = {\n lists: [WORKSPACE, SITE, WORKSPACE_SETTINGS, SITE_SETTINGS],\n create: CREATE,\n shellScreens: [...NATIVE_NAV_SHELL_SCREENS],\n elsewhere: [\n { console: ref('hostTab', 'nav-tab-dashboard'), where: 'Home, inside the site (shell.home)' },\n { console: ref('hostTab', 'nav-tab-setup'), where: 'Site settings → Setup' },\n { console: ref('hostTab', 'nav-tab-admin'), where: 'Site settings → Admin' },\n { console: ref('orgTab', 'nav-tab-org-team'), where: 'Workspace settings → Team' },\n { console: ref('orgTab', 'nav-tab-org-billing'), where: 'Workspace settings → Billing' },\n { console: ref('orgTab', 'nav-tab-org-settings'), where: 'Workspace settings' },\n { console: ref('orgTab', 'nav-tab-org-support'), where: 'Help menu → Contact support (core.support)' },\n ],\n}\n\n/**\n * The manifest with the plugins' rows placed: each into its list's group by\n * `order` (a tie keeps the core's row first, then registration order). A row\n * naming a list or group the core does not have is refused by name, so a\n * plugin cannot quietly invent a group.\n */\nexport function assembleNativeNav(\n core: NativeNavManifest,\n contributions: readonly NativeNavContribution[],\n elsewhere: readonly NativeNavElsewhere[] = [],\n creates: readonly NativeNavCreateContribution[] = [],\n): NativeNavManifest {\n const byOrder = <T extends { order?: number }>(entries: T[]): T[] =>\n entries\n .map((entry, index) => ({ entry, index }))\n .sort((a, b) => (a.entry.order ?? 0) - (b.entry.order ?? 0) || a.index - b.index)\n .map(({ entry }) => entry)\n const lists = core.lists.map((list) => ({\n ...list,\n groups: list.groups.map((group) => ({ ...group, rows: [...group.rows] })),\n }))\n for (const { list: listId, group: groupId, row } of contributions) {\n const group = lists.find((list) => list.id === listId)?.groups.find((entry) => entry.id === groupId)\n if (!group || group.dynamic) {\n throw new Error(`native nav: ${row.id} names ${listId}/${groupId}, which is not a group of rows`)\n }\n if (group.rows.some((entry) => entry.id === row.id)) {\n throw new Error(`native nav: ${listId}/${groupId} holds ${row.id} twice`)\n }\n group.rows.push(row)\n }\n for (const list of lists) {\n for (const group of list.groups) {\n // A section is helped by its row's page unless the console names its own.\n group.rows = byOrder(group.rows).map((row) =>\n row.docs && row.sections\n ? { ...row, sections: row.sections.map((section) => (section.docs ? section : { ...section, docs: row.docs })) }\n : row,\n )\n }\n }\n const create = (core.create ?? []).map((entry) => ({ ...entry, items: [...entry.items] }))\n for (const { scope, item } of creates) {\n const target = create.find((entry) => entry.scope === scope)\n if (!target) throw new Error(`native nav: create item ${item.id} names ${scope}, which has no menu`)\n if (target.items.some((entry) => entry.id === item.id)) {\n throw new Error(`native nav: the ${scope} create menu holds ${item.id} twice`)\n }\n target.items.push(item)\n }\n return {\n ...core,\n lists,\n create: create.map((entry) => ({ ...entry, items: byOrder(entry.items) })),\n elsewhere: [...core.elsewhere, ...elsewhere],\n }\n}\n\n/** What a Create new item that cannot be used says, when its own reason does not apply. */\nexport const NATIVE_CREATE_PERMISSION_REASON =\n 'Your role does not include this permission — ask an organization admin.'\nexport const NATIVE_CREATE_SITE_ROLE_REASON = 'Your access to this site does not include this — ask an organization admin.'\nexport const NATIVE_CREATE_PLAN_REASON = \"Your plan doesn't include this. See the plans in Billing.\"\n\n/** A Create new item as one scope offers it. */\nexport interface ResolvedCreateItem extends NativeNavCreateItem {\n /** Shown, but disabled with `reason`: a prerequisite stands between the person and it. */\n blocked: boolean\n reason?: string\n}\n\n/**\n * The Create new menu for the workspace or site in hand. An item of a plugin\n * that is off is not offered, nor an admin-only item to a non-admin. One the\n * person may not use is SHOWN, disabled with its reason (prerequisites are\n * shown, never hidden): a permission or site role they lack, then a plan\n * feature the workspace lacks. `permissions` and `features` are the\n * workspace's resolved answers (an absent key is not held); `hostRole` is\n * the person's role on the site, null at the workspace.\n */\nexport function resolveCreateList(\n manifest: NativeNavManifest,\n scope: NativeNavCreateScope,\n enabledPluginIds: readonly string[],\n permissions: Readonly<Record<string, boolean>>,\n features: Readonly<Record<string, boolean>>,\n hostRole: string | null,\n): ResolvedCreateItem[] {\n const on = new Set(enabledPluginIds)\n const items = manifest.create?.find((entry) => entry.scope === scope)?.items ?? []\n return items\n .filter((item) => (!item.pluginId || on.has(item.pluginId)) && (!item.requiresHostAdmin || hostRole === 'admin'))\n .map((item): ResolvedCreateItem => {\n if (item.permission && permissions[item.permission] !== true) {\n return { ...item, blocked: true, reason: NATIVE_CREATE_PERMISSION_REASON }\n }\n if (item.hostRoles && !item.hostRoles.includes(hostRole ?? '')) {\n return { ...item, blocked: true, reason: NATIVE_CREATE_SITE_ROLE_REASON }\n }\n if (item.planFeature && features[item.planFeature] !== true) {\n return { ...item, blocked: true, reason: item.blockedReason ?? NATIVE_CREATE_PLAN_REASON }\n }\n return { ...item, blocked: false }\n })\n}\n\n/** A list as one scope shows it: rows for plugins that are off, or admin rows for a non-admin, left out. */\nexport interface ResolvedNavList {\n id: NativeNavListId\n title?: string\n groups: NativeNavGroup[]\n}\n\n/**\n * One list for the workspace or site in hand, from the assembled manifest\n * (`ContractValues.nativeNavManifest`). `enabledPluginIds` is the site's\n * effective set (`resolveHostEnabledPlugins`) in site scope and the\n * workspace's (`resolveEnabledPlugins`) otherwise. A section of another\n * plugin than its row's hides with that plugin. A group left with no rows is\n * dropped, except the starred group, which the shell fills.\n */\nexport function resolveNavList(\n manifest: NativeNavManifest,\n listId: NativeNavListId,\n enabledPluginIds: readonly string[],\n hostAdmin: boolean,\n): ResolvedNavList {\n const list = manifest.lists.find((entry) => entry.id === listId)\n if (!list) return { id: listId, groups: [] }\n const on = new Set(enabledPluginIds)\n const shows = (pluginId?: string) => !pluginId || on.has(pluginId)\n const groups: NativeNavGroup[] = []\n for (const group of list.groups) {\n const rows = group.rows\n .filter((row) => shows(row.pluginId) && (hostAdmin || !row.requiresHostAdmin))\n .map((row) =>\n row.sections\n ? { ...row, sections: row.sections.filter((section) => shows(section.pluginId)) }\n : row,\n )\n if (!rows.length && !group.dynamic) continue\n groups.push({ ...group, rows })\n }\n return { id: list.id, ...(list.title ? { title: list.title } : {}), groups }\n}\n\n// ── The phone's Home (AGL-4006) ─────────────────────────────────────────────\n\n/**\n * A group's heading on the phone's Home where it differs from the sidebar's.\n * Nothing on the phone reads \"More\", so the sidebar's More\n * group is headed Tools there.\n */\nexport const PHONE_HOME_GROUP_LABELS: Record<string, string> = { more: 'Tools' }\n\n/** The heading of the phone Home's last group: inside a site, and for the whole workspace. */\nexport const PHONE_HOME_SITE_GROUP_LABEL = 'Site & workspace'\nexport const PHONE_HOME_WORKSPACE_GROUP_LABEL = 'Settings'\n\n/** The Team tile's word: the console's tab for Members, Custom roles and Recent activity. */\nexport const PHONE_HOME_TEAM_LABEL = 'Team'\n\n/** The tile that opens Workspace settings on the phone's Home. */\nexport const WORKSPACE_SETTINGS_ROW: NativeNavRow = {\n id: 'workspaceSettings',\n label: 'Workspace settings',\n icon: ICONS.profile,\n screen: 'shell.workspaceSettings',\n console: ref('shell', 'workspaceSettings'),\n}\n\n/** One group of tiles on the phone's Home. */\nexport interface PhoneHomeGroup {\n id: string\n /** Absent for a group drawn without a heading. */\n label?: string\n rows: NativeNavRow[]\n}\n\n/**\n * The phone's Home: every area of the scope as the same\n * tile, in the sidebar's own groups, then the scope's own places last\n * (Overview and Site settings in a site; Team and Workspace settings\n * everywhere). Nothing is ranked above anything else and nothing sits behind\n * a More.\n *\n * `list` is the scope's everyday list as the app shows it (`resolveNavList`\n * trimmed to the build's screens), `team` the workspace settings' Members row\n * when the person may open it, and `ownerName` heads the whole workspace's\n * areas, whose group has no heading of its own.\n */\nexport function phoneHomeGroups(\n list: ResolvedNavList,\n team: NativeNavRow | null,\n ownerName: string,\n): PhoneHomeGroup[] {\n const inSite = list.id === 'site'\n const own: NativeNavRow[] = []\n const groups: PhoneHomeGroup[] = []\n for (const group of list.groups) {\n if (group.dynamic) continue\n const rows = group.rows.filter((row) => row.screen !== 'shell.home')\n if (group.id === 'top' || group.id === 'settings') {\n own.push(...rows)\n continue\n }\n if (!rows.length) continue\n const label = PHONE_HOME_GROUP_LABELS[group.id] ?? group.label ?? (ownerName || undefined)\n groups.push({ id: group.id, ...(label ? { label } : {}), rows })\n }\n if (team) own.push({ ...team, label: PHONE_HOME_TEAM_LABEL })\n own.push(WORKSPACE_SETTINGS_ROW)\n groups.push({\n id: 'scope',\n label: inSite ? PHONE_HOME_SITE_GROUP_LABEL : PHONE_HOME_WORKSPACE_GROUP_LABEL,\n rows: own,\n })\n return groups\n}\n\n/** Whether a Home tile may go in the tab bar: an area, never Home itself or a settings mode. */\nexport function isTabPinnable(row: Pick<NativeNavRow, 'screen'>): boolean {\n return (\n row.screen !== 'shell.home' &&\n row.screen !== 'shell.workspaceSettings' &&\n row.screen !== 'shell.siteSettings'\n )\n}\n"],"names":["NATIVE_NAV_SHELL_SCREENS","nativeNavIcon","apple","android","nativeNavRef","surface","id","nativeNavHubSection","scope","href","label","screen","extra","console","icon","ref","ICONS","home","overview","sites","pages","media","settings","emails","members","roles","activity","plan","usage","invoices","billingSettings","plugins","branding","sso","profile","apiKeys","integrations","privacy","holds","importExport","ownership","delete","details","business","seo","tracking","theme","domain","security","errorPages","backup","HOME_ROW","order","WORKSPACE","groups","foldable","rows","dynamic","docs","SITE","consoleLabel","keywords","sections","ordered","map","row","index","HUB_DOCS","teamSection","billingSection","orgSettingsSection","hostAdminSection","setupRow","rowIcon","description","params","section","adminRow","route","requiresHostAdmin","settingsRow","WORKSPACE_SETTINGS","title","SITE_SETTINGS","CREATE","items","new","permission","hostRoles","NATIVE_NAV_MANIFEST","lists","create","shellScreens","elsewhere","where","assembleNativeNav","core","contributions","creates","byOrder","entries","entry","sort","a","b","list","group","listId","groupId","find","Error","some","push","item","target","NATIVE_CREATE_PERMISSION_REASON","NATIVE_CREATE_SITE_ROLE_REASON","NATIVE_CREATE_PLAN_REASON","resolveCreateList","manifest","enabledPluginIds","permissions","features","hostRole","on","Set","filter","pluginId","has","blocked","reason","includes","planFeature","blockedReason","resolveNavList","hostAdmin","shows","length","PHONE_HOME_GROUP_LABELS","more","PHONE_HOME_SITE_GROUP_LABEL","PHONE_HOME_WORKSPACE_GROUP_LABEL","PHONE_HOME_TEAM_LABEL","WORKSPACE_SETTINGS_ROW","phoneHomeGroups","team","ownerName","inSite","own","undefined","isTabPinnable"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GAED,4BAA4B;AAiM5B,kCAAkC,GAClC,OAAO,MAAMA,2BAA8C;IACzD;IACA;IACA;IACA;CACD,CAAA;AAED,wDAAwD,GACxD,OAAO,MAAMC,gBAAgB,CAACC,OAAeC,UAAoC,CAAA;QAAED;QAAOC;IAAQ,CAAA,EAAE;AAEpG,+DAA+D,GAC/D,OAAO,MAAMC,eAAe,CAACC,SAAkCC,KAAqC,CAAA;QAClGD;QACAC;IACF,CAAA,EAAE;AAEF,+DAA+D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B,MAAMC,SAAS1C,KAAKnG,EAAE,KAAK;IAC3B,MAAM8I,MAAsB,EAAE;IAC9B,MAAM9F,SAA2B,EAAE;IACnC,KAAK,MAAMoD,SAASD,KAAKnD,MAAM,CAAE;YAQjBoF,MAAAA;QAPd,IAAIhC,MAAMjD,OAAO,EAAE;QACnB,MAAMD,OAAOkD,MAAMlD,IAAI,CAACsE,MAAM,CAAC,CAAC7D,MAAQA,IAAItD,MAAM,KAAK;QACvD,IAAI+F,MAAMpG,EAAE,KAAK,SAASoG,MAAMpG,EAAE,KAAK,YAAY;YACjD8I,IAAIpC,IAAI,IAAIxD;YACZ;QACF;QACA,IAAI,CAACA,KAAKiF,MAAM,EAAE;QAClB,MAAM/H,SAAQgI,QAAAA,oCAAAA,uBAAuB,CAAChC,MAAMpG,EAAE,CAAC,YAAjCoI,oCAAqChC,MAAMhG,KAAK,YAAhDgI,OAAqDQ,aAAaG;QAChF/F,OAAO0D,IAAI,CAAC;YAAE1G,IAAIoG,MAAMpG,EAAE;WAAMI,QAAQ;YAAEA;QAAM,IAAI,CAAC;YAAI8C;;IAC3D;IACA,IAAIyF,MAAMG,IAAIpC,IAAI,CAAC,aAAKiC;QAAMvI,OAAOoI;;IACrCM,IAAIpC,IAAI,CAAC+B;IACTzF,OAAO0D,IAAI,CAAC;QACV1G,IAAI;QACJI,OAAOyI,SAASP,8BAA8BC;QAC9CrF,MAAM4F;IACR;IACA,OAAO9F;AACT;AAEA,8FAA8F,GAC9F,OAAO,SAASgG,cAAcrF,GAAiC;IAC7D,OACEA,IAAItD,MAAM,KAAK,gBACfsD,IAAItD,MAAM,KAAK,6BACfsD,IAAItD,MAAM,KAAK;AAEnB"}
@@ -85,6 +85,13 @@ export interface OrgPermissionDefinition {
85
85
  * default for it. `narrowPermissionsToSite` applies it. Only a plugin's key.
86
86
  */
87
87
  narrowsPerSite?: Readonly<Record<OrgRole, boolean>>;
88
+ /**
89
+ * A site can raise the key (AGL-4047): wider access to one site than the
90
+ * member's workspace role reads `hostRoleDefaults` there, unless a custom
91
+ * role or their own permissions decide it or the key it follows.
92
+ * `resolveSiteRaisedPermissions` decides it. Only a plugin's key.
93
+ */
94
+ raisesPerSite?: true;
88
95
  /**
89
96
  * The key's preset is the member's role ON THE SITE a request names, for
90
97
  * every member (AGL-4047): `hostRoleDefaults` read for the access they hold
@@ -156,6 +156,8 @@ function replaceEntries(target, entries) {
156
156
  follows: declared.follows
157
157
  } : {}, declared.narrowsPerSite ? {
158
158
  narrowsPerSite: _extends({}, declared.narrowsPerSite)
159
+ } : {}, declared.raisesPerSite ? {
160
+ raisesPerSite: true
159
161
  } : {}, declared.presetFromSiteRole && declared.hostRoleDefaults ? {
160
162
  presetFromSiteRole: true
161
163
  } : {}, declared.presetFromSiteRole && declared.hostRoleDefaults && declared.workspaceMembersOnly ? {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/org-permissions.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AglynOrgMember, OrgRole } from '../foundation'\nimport {\n listPluginCatalogPermissions,\n subscribePluginEntitlements,\n} from '../plugin-manager/plugin-entitlements'\nimport {\n permissionRefinementOf,\n refinePermissionMap,\n subscribePluginPermissions,\n type PermissionRefinement,\n} from '../plugin-manager/plugin-permissions'\nimport { ORG_ROLE_PERMISSION_KEYS } from './org-roles'\nimport {\n CORE_ORG_PERMISSION_ENTRIES,\n CORE_ORG_PERMISSION_GROUPS,\n CORE_ORG_ROLE_GRANTS,\n CORE_SITE_ROLE_PRESETS,\n type OrgPermissionGroup,\n type OrgPermissionScope,\n} from './org-role-grants'\n\nexport type { OrgPermissionGroup, OrgPermissionScope }\n\n/**\n * Granular org permissions (AGL-243) layered on the 4 org roles: each\n * role maps to a default permission set; custom roles\n * (`orgs/{orgId}/roles/{roleId}`) and per-member overrides refine it, so\n * e.g. an editor restricted to one host can also be granted billing\n * visibility — or an admin stripped of it — without inventing new roles.\n * The console hides unpermitted surfaces; the org API routes are the\n * enforcement point.\n */\nexport type CoreOrgPermission =\n | 'org.settings'\n | 'org.auditLog'\n | 'org.apiKeys'\n | 'org.privacy'\n | 'org.holds'\n | 'org.export'\n | 'org.sendingDomains'\n | 'org.businessProfile'\n | 'org.media'\n | 'org.eraseRecords'\n | 'billing.view'\n | 'billing.manage'\n | 'members.manage'\n | 'hosts.create'\n | 'hosts.delete'\n | 'data.manage'\n | 'marketplace.publish'\n | 'plugins.install'\n | 'site.edit'\n | 'site.publish'\n | 'site.sensitive'\n | 'site.manage'\n\n/**\n * A key of the catalog: a core key above, or a key a plugin declares into\n * the catalog through `registerPluginEntitlements` (AGL-2984). A declared key\n * is stored on custom roles and member overrides, layered and resolved\n * exactly like a core key.\n */\nexport type OrgPermission = CoreOrgPermission | (string & {})\n\n/**\n * Legacy boolean permission map derived from the granular `OrgPermission`\n * set (AGL-243). Kept for the console surfaces that predate the granular\n * model; lives here so relocated feature plugins can accept it as a prop\n * (AGL-395).\n */\nexport interface OrgPermissions {\n createHosts: boolean\n editHosts: boolean\n editBilling: boolean\n publishToMarketplace: boolean\n installPlugins: boolean\n manageMembers: boolean\n}\n\nexport interface OrgPermissionDefinition {\n key: OrgPermission\n label: string\n description: string\n /** The plugin that declared the key; absent for a core key. */\n pluginId?: string\n /** The `ORG_PERMISSION_GROUPS` id the role editor files it under (AGL-4047). */\n group: string\n /** Where it is decided: `org`, or `site` for a key a site collaborator holds per site. */\n scope: OrgPermissionScope\n /** Each org role's verdict when nothing refines it (`DEFAULT_ROLE_PERMISSIONS`). */\n roleDefaults: Readonly<Record<OrgRole, boolean>>\n /** Each host role's verdict, for a `site` key. */\n hostRoleDefaults?: Readonly<Record<string, boolean>>\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. Only a plugin's key refines, and only a key the catalog holds.\n */\n refines?: OrgPermission\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. Only a plugin's key follows, and only a key the catalog\n * holds; a key that refines does not also follow.\n */\n follows?: OrgPermission\n /**\n * Present when a site can narrow the key (AGL-4047): where a member who\n * works across the workspace has narrower access to one site than their\n * workspace role, whether the key follows that site role there is a\n * control, set per key on a custom role (`siteNarrowing`) and per member\n * (`AglynOrgMember.siteNarrowing`), and this is each built-in role's\n * default for it. `narrowPermissionsToSite` applies it. Only a plugin's key.\n */\n narrowsPerSite?: Readonly<Record<OrgRole, boolean>>\n /**\n * The key's preset is the member's role ON THE SITE a request names, for\n * every member (AGL-4047): `hostRoleDefaults` read for the access they hold\n * there, then their custom role, their own permissions and that site's\n * toggle. `roleDefaults` is the answer with no site named.\n * `resolveSiteRolePresetPermissions` decides it. The core's site keys\n * (`CORE_SITE_ROLE_PRESETS`) and a plugin's key with `hostRoleDefaults`.\n */\n presetFromSiteRole?: true\n /**\n * With `presetFromSiteRole`: the site role is the preset only for a member\n * of the whole workspace (AGL-4047). A site collaborator's preset is\n * refusal, whatever their site role, and only the site's toggle grants it\n * to them. A plugin's key that replaces a gate asking for an admin of the\n * whole workspace who is also the site's admin.\n */\n workspaceMembersOnly?: true\n}\n\n/**\n * The core keys, in display order for role editors.\n *\n * ⚠️ **EVERY KEY HERE MUST BE ENFORCED SERVER-SIDE.** A permission a customer\n * can tick that changes nothing is worse than its absence, because it implies\n * a control that does not exist — an owner unticks \"delete sites\", hands the\n * role out, and the member deletes sites while the console does not even dim\n * the button. Three of the eleven were in exactly that state (AGL-2444).\n *\n * `marketing.manage` was removed rather than wired, and the reason is worth\n * keeping: announcement bars, popups and campaigns live at\n * `hosts/{hostId}/overlays|campaigns|experiments` and are written\n * client-direct against the security rules, which gate on the HOST role.\n * There is no org-level boundary for it to sit on, and the action it named is\n * not org-scoped at all. Wiring it would have meant inventing one and\n * producing a second permission that looks enforced and is not. If a granular\n * marketing permission is wanted it belongs in the plugin-declared mechanism\n * (AGL-435), scoped to a host — a product decision, not this repair.\n *\n * `apps/console/specs/org-permissions-are-enforced.spec.ts` fails the build if\n * a key here, or a key a plugin declares, gains no server-side consumer.\n */\nconst CORE_ORG_PERMISSIONS: readonly OrgPermissionDefinition[] =\n // One table, shared with the native apps through the contracts (AGL-3950).\n CORE_ORG_PERMISSION_ENTRIES.map((entry) => ({\n ...entry,\n key: entry.key as CoreOrgPermission,\n group: entry.group ?? 'organization',\n scope: entry.scope ?? 'org',\n // A site key's preset is the member's role on the site (AGL-4047).\n ...(CORE_SITE_ROLE_PRESETS[entry.key]\n ? { hostRoleDefaults: { ...CORE_SITE_ROLE_PRESETS[entry.key] }, presetFromSiteRole: true as const }\n : {}),\n roleDefaults: {\n owner: CORE_ORG_ROLE_GRANTS.owner.includes(entry.key),\n admin: CORE_ORG_ROLE_GRANTS.admin.includes(entry.key),\n editor: CORE_ORG_ROLE_GRANTS.editor.includes(entry.key),\n viewer: CORE_ORG_ROLE_GRANTS.viewer.includes(entry.key),\n },\n }))\n\n/** The core keys: a plugin may add keys beside them and never redefine one. */\nconst CORE_ORG_PERMISSION_KEYS: ReadonlySet<string> = new Set(\n CORE_ORG_PERMISSIONS.map((definition) => definition.key),\n)\n\n/** The legacy camelCase projection's keys, which no declaration may take either. */\nconst LEGACY_PERMISSION_KEYS: ReadonlySet<string> = new Set<string>(\n ORG_ROLE_PERMISSION_KEYS,\n)\n\n/** The org roles, in the order `DEFAULT_ROLE_PERMISSIONS` lists them. */\nconst ORG_ROLES: readonly OrgRole[] = ['owner', 'admin', 'editor', 'viewer']\n\n/**\n * Every permission, in display order for role editors: the core keys, then\n * the keys plugins declare through `registerPluginEntitlements`, in the\n * plugins' catalog order (AGL-2984).\n *\n * LIVE, and kept in step in place. A plugin's declarations register at\n * module scope — at boot on the server, before the first paint in the\n * console — which can be after a module holding this binding was evaluated.\n * So this array, the key list, the role defaults and the empty map below are\n * rewritten in place on every registration instead of being computed once\n * when this module loads, and whoever holds the binding reads the declared\n * keys with the core ones.\n */\nexport const ORG_PERMISSIONS: readonly OrgPermissionDefinition[] = []\n\nexport const ORG_PERMISSION_KEYS: readonly OrgPermission[] = []\n\n/**\n * The groups the catalog's keys are filed under, in display order (AGL-4047):\n * the core groups, then one per plugin group a declaration names. Live, like\n * `ORG_PERMISSIONS`; a group with no key is left out.\n */\nexport const ORG_PERMISSION_GROUPS: readonly OrgPermissionGroup[] = []\n\n/**\n * The catalog keys that came through `registerPluginPermissions` (AGL-4047):\n * the keys the per-tier resolver (`resolveRolePermissions`) also answers,\n * which a caller holding a catalog-resolved map lays over that resolver's\n * answer so a custom role reaches them. Live.\n */\nexport const TIER_PERMISSION_KEYS: readonly OrgPermission[] = []\n\n/**\n * Every catalog key that refines a broader one, with that key (AGL-4047),\n * and every key that only follows one, marked `'follows'`. Live, like\n * `ORG_PERMISSIONS`. A resolver lays it over its map with\n * `refinePermissionMap`.\n */\nexport const ORG_PERMISSION_REFINEMENTS: readonly PermissionRefinement[] = []\n\nconst NO_PERMISSIONS = {} as Record<OrgPermission, boolean>\n\n/**\n * Role → default permission set. Owner/admin hold everything (owner-only\n * actions like org deletion stay role-checked, not permission-checked);\n * editors work on content but see no money or roster controls; viewers read\n * only. A declared key's default for each role is the one its declaration\n * names.\n */\nexport const DEFAULT_ROLE_PERMISSIONS: Record<\n OrgRole,\n Record<OrgPermission, boolean>\n> = {\n owner: {} as Record<OrgPermission, boolean>,\n admin: {} as Record<OrgPermission, boolean>,\n editor: {} as Record<OrgPermission, boolean>,\n viewer: {} as Record<OrgPermission, boolean>,\n}\n\n/** Refused declarations already logged, so a refusal is reported once. */\nconst reportedRefusals = new Set<string>()\n\nfunction replaceItems<T>(target: readonly T[], items: readonly T[]): void {\n const list = target as T[]\n list.length = 0\n list.push(...items)\n}\n\nfunction replaceEntries(\n target: Record<string, boolean>,\n entries: Record<string, boolean>,\n): void {\n for (const key of Object.keys(target)) delete target[key]\n Object.assign(target, entries)\n}\n\n/**\n * Rebuilds the live catalog: the core keys, then every key a plugin declared\n * through either declaration API (`listPluginCatalogPermissions`, AGL-4047).\n * A declaration naming a core or legacy key is refused — that key keeps its\n * own meaning and defaults — and logged once.\n */\nfunction syncCatalog(): void {\n const definitions: OrgPermissionDefinition[] = [...CORE_ORG_PERMISSIONS]\n const tierKeys: string[] = []\n const groups: OrgPermissionGroup[] = CORE_ORG_PERMISSION_GROUPS.map((group) => ({ ...group }))\n for (const declared of listPluginCatalogPermissions()) {\n if (\n CORE_ORG_PERMISSION_KEYS.has(declared.key) ||\n LEGACY_PERMISSION_KEYS.has(declared.key)\n ) {\n const refusal = `${declared.pluginId}\\x00${declared.key}`\n if (!reportedRefusals.has(refusal)) {\n reportedRefusals.add(refusal)\n console.error(\n `[plugins] refused catalog permission \"${declared.key}\" to ` +\n `\"${declared.pluginId}\": the key belongs to the core catalog`,\n )\n }\n continue\n }\n definitions.push({\n key: declared.key,\n label: declared.label,\n description: declared.description,\n pluginId: declared.pluginId,\n group: declared.group,\n scope: declared.hostRoleDefaults ? 'site' : 'org',\n roleDefaults: declared.roleDefaults,\n ...(declared.hostRoleDefaults ? { hostRoleDefaults: declared.hostRoleDefaults } : {}),\n ...(declared.refines ? { refines: declared.refines } : {}),\n ...(declared.follows && !declared.refines ? { follows: declared.follows } : {}),\n ...(declared.narrowsPerSite ? { narrowsPerSite: { ...declared.narrowsPerSite } } : {}),\n ...(declared.presetFromSiteRole && declared.hostRoleDefaults ? { presetFromSiteRole: true as const } : {}),\n ...(declared.presetFromSiteRole && declared.hostRoleDefaults && declared.workspaceMembersOnly\n ? { workspaceMembersOnly: true as const }\n : {}),\n })\n if (declared.source === 'tier') tierKeys.push(declared.key)\n if (!groups.some((group) => group.id === declared.group)) {\n groups.push({ id: declared.group, label: declared.groupLabel, pluginId: declared.pluginId })\n }\n }\n const keys = definitions.map((definition) => definition.key)\n const known = new Set<string>(keys)\n // A refinement of a key the catalog does not hold refines nothing, and is\n // dropped from the definition so no editor offers a link to nowhere.\n for (const definition of definitions) {\n if (definition.refines && (!known.has(definition.refines) || definition.refines === definition.key)) {\n delete definition.refines\n }\n if (definition.follows && (!known.has(definition.follows) || definition.follows === definition.key)) {\n delete definition.follows\n }\n }\n replaceItems(\n ORG_PERMISSION_REFINEMENTS,\n definitions.flatMap((definition) => {\n const refinement = permissionRefinementOf(definition)\n return refinement ? [refinement] : []\n }),\n )\n replaceItems(ORG_PERMISSIONS, definitions)\n replaceItems(ORG_PERMISSION_KEYS, keys)\n replaceItems(\n ORG_PERMISSION_GROUPS,\n groups.filter((group) => definitions.some((definition) => definition.group === group.id)),\n )\n replaceItems(TIER_PERMISSION_KEYS, tierKeys)\n replaceEntries(NO_PERMISSIONS, Object.fromEntries(keys.map((key) => [key, false])))\n for (const role of ORG_ROLES) {\n replaceEntries(\n DEFAULT_ROLE_PERMISSIONS[role],\n Object.fromEntries(\n definitions.map((definition) => [definition.key, definition.roleDefaults[role] === true]),\n ),\n )\n }\n CATALOG_AND_LEGACY_KEYS.clear()\n for (const key of [...keys, ...LEGACY_PERMISSION_KEYS]) {\n CATALOG_AND_LEGACY_KEYS.add(key)\n }\n}\n\n/**\n * The `registerPluginPermissions` keys of a catalog-resolved map (AGL-4047).\n *\n * Those keys are answered twice: by the per-tier resolver\n * (`resolveRolePermissions`, the role's tier default and the member's\n * override) and, now that they are catalog keys, by `resolveOrgPermissions`\n * with every layer — the custom role's included. A caller that builds its\n * map from the first spreads this over it, so the custom role a member\n * carries reaches `managePos` the way it reaches `hosts.create`.\n */\nexport function tierPermissionsOf(\n granted: Readonly<Record<string, boolean>> | null | undefined,\n): Record<string, boolean> {\n const picked: Record<string, boolean> = {}\n if (!granted) return picked\n for (const key of TIER_PERMISSION_KEYS) {\n if (typeof granted[key] === 'boolean') picked[key] = granted[key]\n }\n return picked\n}\n\n/** One catalog key by name, or undefined. */\nexport function orgPermissionDefinition(\n permission: OrgPermission,\n): OrgPermissionDefinition | undefined {\n return ORG_PERMISSIONS.find((definition) => definition.key === permission)\n}\n\n/** `orgs/{orgId}/roles/{roleId}` — a named custom permission set. */\nexport interface AglynOrgCustomRole {\n $id?: string\n name?: string\n description?: string\n /** Full permission map; missing keys read as false. */\n permissions?: Partial<Record<OrgPermission, boolean>>\n /**\n * Per key a site can narrow (AGL-4047): `true` follows the site role on a\n * site where the member's access is narrower than their workspace role,\n * `false` keeps the permission there. A key it leaves out follows the\n * built-in role's default (`OrgPermissionDefinition.narrowsPerSite`), and\n * a member's own `siteNarrowing` wins over it.\n */\n siteNarrowing?: Partial<Record<OrgPermission, boolean>>\n}\n\n/**\n * Effective permission map for a member: the org role's defaults, then\n * the custom role's map (when the member has `roleId` and the role doc\n * is supplied), then per-member overrides — later layers win key-by-key.\n */\nexport function resolveOrgPermissions(\n member:\n | (Partial<AglynOrgMember> & {\n roleId?: string\n permissions?: Partial<Record<OrgPermission, boolean>>\n })\n | null\n | undefined,\n customRole?: AglynOrgCustomRole | null,\n): Record<OrgPermission, boolean> {\n if (!member) return NO_PERMISSIONS\n const role = (member.role ?? 'viewer') as OrgRole\n const base = DEFAULT_ROLE_PERMISSIONS[role] ?? NO_PERMISSIONS\n const merged: Record<OrgPermission, boolean> = { ...base }\n if (member.roleId && customRole?.permissions) {\n for (const key of ORG_PERMISSION_KEYS) {\n const value = customRole.permissions[key]\n if (typeof value === 'boolean') merged[key] = value\n }\n }\n if (member.permissions) {\n for (const key of ORG_PERMISSION_KEYS) {\n const value = member.permissions[key]\n if (typeof value === 'boolean') merged[key] = value\n }\n }\n // A key that refines a broader one (AGL-4047) follows it where neither\n // layer set the key, and is never held without it; a key that only follows\n // one takes its verdict where neither layer set the key, and nothing more.\n return refinePermissionMap(merged, ORG_PERMISSION_REFINEMENTS, [\n member.roleId ? customRole?.permissions : undefined,\n member.permissions,\n ])\n}\n\n/**\n * The values a custom role and a per-member override set EXPLICITLY for\n * permission keys outside this catalog — the keys plugins declare through\n * `registerPluginPermissions` (AGL-2974).\n *\n * `resolveOrgPermissions` walks the catalog alone, so a plugin key stored on\n * a custom role or a member document never reached the `resolvedPermissions`\n * stamp the Firestore rules read. A rule gating on one could then honor\n * neither a grant to an editor nor a revocation from an admin. This carries\n * exactly those stored decisions, custom role first and the per-member\n * override over it, which is the precedence the resolver applies.\n *\n * Tier DEFAULTS are deliberately absent. They live in the plugin registry,\n * which is populated per process by whichever plugin bundles that process\n * loaded, and a stamp computed from it would differ by which route happened\n * to write it. A rule supplies the default itself from the member's role,\n * the way `memberResolves` is always conjoined with a role gate.\n *\n * The legacy six camelCase keys are excluded as well: they are the catalog's\n * older projection, not plugin keys, and no rule reads them.\n */\nexport function explicitPluginPermissionValues(\n member:\n | {\n roleId?: string\n permissions?: Partial<Record<string, unknown>> | null\n }\n | null\n | undefined,\n customRole?: { permissions?: Partial<Record<string, unknown>> | null } | null,\n): Record<string, boolean> {\n const values: Record<string, boolean> = {}\n if (!member) return values\n const layers = [\n member.roleId ? customRole?.permissions : undefined,\n member.permissions,\n ]\n for (const layer of layers) {\n for (const [key, value] of Object.entries(layer ?? {})) {\n if (typeof value !== 'boolean') continue\n if (CATALOG_AND_LEGACY_KEYS.has(key)) continue\n values[key] = value\n }\n }\n return values\n}\n\n/**\n * Keys {@link explicitPluginPermissionValues} leaves to the catalog: every\n * catalog key, declared ones included, and the legacy six. Kept in step by\n * `syncCatalog`.\n */\nconst CATALOG_AND_LEGACY_KEYS = new Set<string>()\n\n/**\n * The `resolvedPermissions` map stamped on a member document for the\n * Firestore rules: the catalog verdict with every layer applied, and beside\n * it the plugin keys a custom role or an override set explicitly.\n *\n * One function for every writer of the stamp, so the org-create transaction\n * and `syncOrgAuthProjections` cannot project different maps. The catalog\n * spreads last; the two key spaces do not overlap, and the order keeps it\n * true that nothing but the resolver decides a catalog key.\n */\nexport function projectMemberResolvedPermissions(\n member: Parameters<typeof resolveOrgPermissions>[0],\n customRole?: AglynOrgCustomRole | null,\n): Record<string, boolean> {\n return {\n ...explicitPluginPermissionValues(member, customRole),\n ...resolveOrgPermissions(member, customRole),\n }\n}\n\n/** Single-permission convenience over `resolveOrgPermissions`. */\nexport function hasOrgPermission(\n member: Parameters<typeof resolveOrgPermissions>[0],\n permission: OrgPermission,\n customRole?: AglynOrgCustomRole | null,\n): boolean {\n return resolveOrgPermissions(member, customRole)[permission]\n}\n\n/** The catalog label for a key — the words a refusal names — or the key itself. */\nexport function orgPermissionLabel(permission: OrgPermission): string {\n return (\n ORG_PERMISSIONS.find((definition) => definition.key === permission)?.label ??\n permission\n )\n}\n\n/**\n * The sentence a door answers when a member does not hold a key (AGL-4047):\n * it names the permission by its catalog label and who can change it, never\n * a role.\n */\nexport function permissionRefusalText(permission: OrgPermission): string {\n return `Your role does not include \"${orgPermissionLabel(permission)}\" — ask an organization admin`\n}\n\n/** The keys plugins declared into the catalog, in catalog order. */\nexport function pluginOrgPermissionKeys(): OrgPermission[] {\n return ORG_PERMISSIONS.filter((definition) => definition.pluginId).map(\n (definition) => definition.key,\n )\n}\n\n/** One declared catalog key that moved, and the direction it moved in. */\nexport interface PluginPermissionChange {\n permission: string\n granted: boolean\n}\n\n/**\n * The keys PLUGINS declared into the catalog whose value moved between two\n * maps, in the new map's order — what a member, role or collaborator write\n * raises `org.permissions.changed` for, once per key, so the plugin that owns\n * a key can record who moved it.\n *\n * A key the new map leaves unset is not a change: on a role it defers to the\n * base role, on a site toggle to the host role, and neither is a grant or a\n * revocation of its own. A key set for the first time is a change, because\n * the verdict it produces is no longer the default's. The core keys and the\n * legacy six raise nothing; their writes are recorded by the routes' own\n * activity sentences.\n */\nexport function pluginPermissionChanges(\n before: Partial<Record<string, unknown>> | null | undefined,\n after: Partial<Record<string, unknown>> | null | undefined,\n): PluginPermissionChange[] {\n const changes: PluginPermissionChange[] = []\n for (const [key, next] of Object.entries(after ?? {})) {\n if (typeof next !== 'boolean') continue\n if (CORE_ORG_PERMISSION_KEYS.has(key) || LEGACY_PERMISSION_KEYS.has(key)) continue\n if (before?.[key] === next) continue\n changes.push({ permission: key, granted: next })\n }\n return changes\n}\n\n/**\n * The granular (dotted) set projected onto the legacy boolean map\n * (AGL-2350).\n *\n * ## Why this lives here rather than in the console hook\n *\n * It was a private function in `apps/console/hooks/use-org-permissions.ts`,\n * which meant the CLIENT translated the stored permission model into the\n * legacy flags and the SERVER did not translate at all — it derived the\n * legacy flags straight from the built-in role tier and dropped custom roles\n * and per-member overrides on the floor. The two disagreed exactly on the\n * feature `custom-roles.md` sells, in both directions: a permission granted\n * by a custom role showed in the UI and 403'd on POST, and one revoked by an\n * override was hidden in the UI and still succeeded on POST.\n *\n * One exported copy is what stops them drifting again.\n *\n * ## The key spaces are NOT interchangeable, and that is the trap\n *\n * Two permission vocabularies exist. The stored one is DOTTED\n * (`plugins.install`) — `apps/console/app/api/orgs/roles/route.ts` sanitizes\n * against `ORG_PERMISSION_KEYS` before writing, and `AglynOrgMember`\n * `permissions` is typed to it. The legacy one is camelCase\n * (`installPlugins`).\n *\n * `resolveRolePermissions` in `org-roles.ts` accepts `overrides` and\n * `customRoles` arguments keyed by the CAMELCASE space. Feeding it the real\n * stored documents therefore matches no key and changes nothing — it looks\n * like wiring the feature up while doing precisely nothing. Those two\n * parameters are used by nothing but that module's own spec. Translate\n * through here instead.\n *\n * `editHosts` is derived from the ROLE, not from a dotted key: it has no\n * counterpart in the granular catalog and never had one.\n */\nexport function toLegacyPermissions(\n granted: Record<OrgPermission, boolean>,\n role: OrgRole | null | undefined,\n): OrgPermissions {\n return {\n createHosts: granted['hosts.create'],\n editHosts: role !== 'viewer',\n editBilling: granted['billing.manage'],\n publishToMarketplace: granted['marketplace.publish'],\n installPlugins: granted['plugins.install'],\n manageMembers: granted['members.manage'],\n }\n}\n\nsyncCatalog()\nsubscribePluginEntitlements(syncCatalog)\n// The second declaration API feeds the same catalog (AGL-4047).\nsubscribePluginPermissions(syncCatalog)\n"],"names":["listPluginCatalogPermissions","subscribePluginEntitlements","permissionRefinementOf","refinePermissionMap","subscribePluginPermissions","ORG_ROLE_PERMISSION_KEYS","CORE_ORG_PERMISSION_ENTRIES","CORE_ORG_PERMISSION_GROUPS","CORE_ORG_ROLE_GRANTS","CORE_SITE_ROLE_PRESETS","CORE_ORG_PERMISSIONS","map","entry","key","group","scope","hostRoleDefaults","presetFromSiteRole","roleDefaults","owner","includes","admin","editor","viewer","CORE_ORG_PERMISSION_KEYS","Set","definition","LEGACY_PERMISSION_KEYS","ORG_ROLES","ORG_PERMISSIONS","ORG_PERMISSION_KEYS","ORG_PERMISSION_GROUPS","TIER_PERMISSION_KEYS","ORG_PERMISSION_REFINEMENTS","NO_PERMISSIONS","DEFAULT_ROLE_PERMISSIONS","reportedRefusals","replaceItems","target","items","list","length","push","replaceEntries","entries","Object","keys","assign","syncCatalog","definitions","tierKeys","groups","declared","has","refusal","pluginId","add","console","error","label","description","refines","follows","narrowsPerSite","workspaceMembersOnly","source","some","id","groupLabel","known","flatMap","refinement","filter","fromEntries","role","CATALOG_AND_LEGACY_KEYS","clear","tierPermissionsOf","granted","picked","orgPermissionDefinition","permission","find","resolveOrgPermissions","member","customRole","base","merged","roleId","permissions","value","undefined","explicitPluginPermissionValues","values","layers","layer","projectMemberResolvedPermissions","hasOrgPermission","orgPermissionLabel","permissionRefusalText","pluginOrgPermissionKeys","pluginPermissionChanges","before","after","changes","next","toLegacyPermissions","createHosts","editHosts","editBilling","publishToMarketplace","installPlugins","manageMembers"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,4BAA4B,EAC5BC,2BAA2B,QACtB,2CAAuC;AAC9C,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,0BAA0B,QAErB,0CAAsC;AAC7C,SAASC,wBAAwB,QAAQ,iBAAa;AACtD,SACEC,2BAA2B,EAC3BC,0B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AAO,CAAC2D,gBAAAA,QAAS,CAAC,GAAI;QACrD,IAAI,OAAOE,SAAS,WAAW;QAC/B,IAAIjF,yBAAyB6B,GAAG,CAACxC,QAAQc,uBAAuB0B,GAAG,CAACxC,MAAM;QAC1E,IAAIyF,CAAAA,0BAAAA,MAAQ,CAACzF,IAAI,MAAK4F,MAAM;QAC5BD,QAAQ9D,IAAI,CAAC;YAAEuC,YAAYpE;YAAKiE,SAAS2B;QAAK;IAChD;IACA,OAAOD;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCC,GACD,OAAO,SAASE,oBACd5B,OAAuC,EACvCJ,IAAgC;IAEhC,OAAO;QACLiC,aAAa7B,OAAO,CAAC,eAAe;QACpC8B,WAAWlC,SAAS;QACpBmC,aAAa/B,OAAO,CAAC,iBAAiB;QACtCgC,sBAAsBhC,OAAO,CAAC,sBAAsB;QACpDiC,gBAAgBjC,OAAO,CAAC,kBAAkB;QAC1CkC,eAAelC,OAAO,CAAC,iBAAiB;IAC1C;AACF;AAEA9B;AACA/C,4BAA4B+C;AAC5B,gEAAgE;AAChE5C,2BAA2B4C"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/org-permissions.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AglynOrgMember, OrgRole } from '../foundation'\nimport {\n listPluginCatalogPermissions,\n subscribePluginEntitlements,\n} from '../plugin-manager/plugin-entitlements'\nimport {\n permissionRefinementOf,\n refinePermissionMap,\n subscribePluginPermissions,\n type PermissionRefinement,\n} from '../plugin-manager/plugin-permissions'\nimport { ORG_ROLE_PERMISSION_KEYS } from './org-roles'\nimport {\n CORE_ORG_PERMISSION_ENTRIES,\n CORE_ORG_PERMISSION_GROUPS,\n CORE_ORG_ROLE_GRANTS,\n CORE_SITE_ROLE_PRESETS,\n type OrgPermissionGroup,\n type OrgPermissionScope,\n} from './org-role-grants'\n\nexport type { OrgPermissionGroup, OrgPermissionScope }\n\n/**\n * Granular org permissions (AGL-243) layered on the 4 org roles: each\n * role maps to a default permission set; custom roles\n * (`orgs/{orgId}/roles/{roleId}`) and per-member overrides refine it, so\n * e.g. an editor restricted to one host can also be granted billing\n * visibility — or an admin stripped of it — without inventing new roles.\n * The console hides unpermitted surfaces; the org API routes are the\n * enforcement point.\n */\nexport type CoreOrgPermission =\n | 'org.settings'\n | 'org.auditLog'\n | 'org.apiKeys'\n | 'org.privacy'\n | 'org.holds'\n | 'org.export'\n | 'org.sendingDomains'\n | 'org.businessProfile'\n | 'org.media'\n | 'org.eraseRecords'\n | 'billing.view'\n | 'billing.manage'\n | 'members.manage'\n | 'hosts.create'\n | 'hosts.delete'\n | 'data.manage'\n | 'marketplace.publish'\n | 'plugins.install'\n | 'site.edit'\n | 'site.publish'\n | 'site.sensitive'\n | 'site.manage'\n\n/**\n * A key of the catalog: a core key above, or a key a plugin declares into\n * the catalog through `registerPluginEntitlements` (AGL-2984). A declared key\n * is stored on custom roles and member overrides, layered and resolved\n * exactly like a core key.\n */\nexport type OrgPermission = CoreOrgPermission | (string & {})\n\n/**\n * Legacy boolean permission map derived from the granular `OrgPermission`\n * set (AGL-243). Kept for the console surfaces that predate the granular\n * model; lives here so relocated feature plugins can accept it as a prop\n * (AGL-395).\n */\nexport interface OrgPermissions {\n createHosts: boolean\n editHosts: boolean\n editBilling: boolean\n publishToMarketplace: boolean\n installPlugins: boolean\n manageMembers: boolean\n}\n\nexport interface OrgPermissionDefinition {\n key: OrgPermission\n label: string\n description: string\n /** The plugin that declared the key; absent for a core key. */\n pluginId?: string\n /** The `ORG_PERMISSION_GROUPS` id the role editor files it under (AGL-4047). */\n group: string\n /** Where it is decided: `org`, or `site` for a key a site collaborator holds per site. */\n scope: OrgPermissionScope\n /** Each org role's verdict when nothing refines it (`DEFAULT_ROLE_PERMISSIONS`). */\n roleDefaults: Readonly<Record<OrgRole, boolean>>\n /** Each host role's verdict, for a `site` key. */\n hostRoleDefaults?: Readonly<Record<string, boolean>>\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. Only a plugin's key refines, and only a key the catalog holds.\n */\n refines?: OrgPermission\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. Only a plugin's key follows, and only a key the catalog\n * holds; a key that refines does not also follow.\n */\n follows?: OrgPermission\n /**\n * Present when a site can narrow the key (AGL-4047): where a member who\n * works across the workspace has narrower access to one site than their\n * workspace role, whether the key follows that site role there is a\n * control, set per key on a custom role (`siteNarrowing`) and per member\n * (`AglynOrgMember.siteNarrowing`), and this is each built-in role's\n * default for it. `narrowPermissionsToSite` applies it. Only a plugin's key.\n */\n narrowsPerSite?: Readonly<Record<OrgRole, boolean>>\n /**\n * A site can raise the key (AGL-4047): wider access to one site than the\n * member's workspace role reads `hostRoleDefaults` there, unless a custom\n * role or their own permissions decide it or the key it follows.\n * `resolveSiteRaisedPermissions` decides it. Only a plugin's key.\n */\n raisesPerSite?: true\n /**\n * The key's preset is the member's role ON THE SITE a request names, for\n * every member (AGL-4047): `hostRoleDefaults` read for the access they hold\n * there, then their custom role, their own permissions and that site's\n * toggle. `roleDefaults` is the answer with no site named.\n * `resolveSiteRolePresetPermissions` decides it. The core's site keys\n * (`CORE_SITE_ROLE_PRESETS`) and a plugin's key with `hostRoleDefaults`.\n */\n presetFromSiteRole?: true\n /**\n * With `presetFromSiteRole`: the site role is the preset only for a member\n * of the whole workspace (AGL-4047). A site collaborator's preset is\n * refusal, whatever their site role, and only the site's toggle grants it\n * to them. A plugin's key that replaces a gate asking for an admin of the\n * whole workspace who is also the site's admin.\n */\n workspaceMembersOnly?: true\n}\n\n/**\n * The core keys, in display order for role editors.\n *\n * ⚠️ **EVERY KEY HERE MUST BE ENFORCED SERVER-SIDE.** A permission a customer\n * can tick that changes nothing is worse than its absence, because it implies\n * a control that does not exist — an owner unticks \"delete sites\", hands the\n * role out, and the member deletes sites while the console does not even dim\n * the button. Three of the eleven were in exactly that state (AGL-2444).\n *\n * `marketing.manage` was removed rather than wired, and the reason is worth\n * keeping: announcement bars, popups and campaigns live at\n * `hosts/{hostId}/overlays|campaigns|experiments` and are written\n * client-direct against the security rules, which gate on the HOST role.\n * There is no org-level boundary for it to sit on, and the action it named is\n * not org-scoped at all. Wiring it would have meant inventing one and\n * producing a second permission that looks enforced and is not. If a granular\n * marketing permission is wanted it belongs in the plugin-declared mechanism\n * (AGL-435), scoped to a host — a product decision, not this repair.\n *\n * `apps/console/specs/org-permissions-are-enforced.spec.ts` fails the build if\n * a key here, or a key a plugin declares, gains no server-side consumer.\n */\nconst CORE_ORG_PERMISSIONS: readonly OrgPermissionDefinition[] =\n // One table, shared with the native apps through the contracts (AGL-3950).\n CORE_ORG_PERMISSION_ENTRIES.map((entry) => ({\n ...entry,\n key: entry.key as CoreOrgPermission,\n group: entry.group ?? 'organization',\n scope: entry.scope ?? 'org',\n // A site key's preset is the member's role on the site (AGL-4047).\n ...(CORE_SITE_ROLE_PRESETS[entry.key]\n ? { hostRoleDefaults: { ...CORE_SITE_ROLE_PRESETS[entry.key] }, presetFromSiteRole: true as const }\n : {}),\n roleDefaults: {\n owner: CORE_ORG_ROLE_GRANTS.owner.includes(entry.key),\n admin: CORE_ORG_ROLE_GRANTS.admin.includes(entry.key),\n editor: CORE_ORG_ROLE_GRANTS.editor.includes(entry.key),\n viewer: CORE_ORG_ROLE_GRANTS.viewer.includes(entry.key),\n },\n }))\n\n/** The core keys: a plugin may add keys beside them and never redefine one. */\nconst CORE_ORG_PERMISSION_KEYS: ReadonlySet<string> = new Set(\n CORE_ORG_PERMISSIONS.map((definition) => definition.key),\n)\n\n/** The legacy camelCase projection's keys, which no declaration may take either. */\nconst LEGACY_PERMISSION_KEYS: ReadonlySet<string> = new Set<string>(\n ORG_ROLE_PERMISSION_KEYS,\n)\n\n/** The org roles, in the order `DEFAULT_ROLE_PERMISSIONS` lists them. */\nconst ORG_ROLES: readonly OrgRole[] = ['owner', 'admin', 'editor', 'viewer']\n\n/**\n * Every permission, in display order for role editors: the core keys, then\n * the keys plugins declare through `registerPluginEntitlements`, in the\n * plugins' catalog order (AGL-2984).\n *\n * LIVE, and kept in step in place. A plugin's declarations register at\n * module scope — at boot on the server, before the first paint in the\n * console — which can be after a module holding this binding was evaluated.\n * So this array, the key list, the role defaults and the empty map below are\n * rewritten in place on every registration instead of being computed once\n * when this module loads, and whoever holds the binding reads the declared\n * keys with the core ones.\n */\nexport const ORG_PERMISSIONS: readonly OrgPermissionDefinition[] = []\n\nexport const ORG_PERMISSION_KEYS: readonly OrgPermission[] = []\n\n/**\n * The groups the catalog's keys are filed under, in display order (AGL-4047):\n * the core groups, then one per plugin group a declaration names. Live, like\n * `ORG_PERMISSIONS`; a group with no key is left out.\n */\nexport const ORG_PERMISSION_GROUPS: readonly OrgPermissionGroup[] = []\n\n/**\n * The catalog keys that came through `registerPluginPermissions` (AGL-4047):\n * the keys the per-tier resolver (`resolveRolePermissions`) also answers,\n * which a caller holding a catalog-resolved map lays over that resolver's\n * answer so a custom role reaches them. Live.\n */\nexport const TIER_PERMISSION_KEYS: readonly OrgPermission[] = []\n\n/**\n * Every catalog key that refines a broader one, with that key (AGL-4047),\n * and every key that only follows one, marked `'follows'`. Live, like\n * `ORG_PERMISSIONS`. A resolver lays it over its map with\n * `refinePermissionMap`.\n */\nexport const ORG_PERMISSION_REFINEMENTS: readonly PermissionRefinement[] = []\n\nconst NO_PERMISSIONS = {} as Record<OrgPermission, boolean>\n\n/**\n * Role → default permission set. Owner/admin hold everything (owner-only\n * actions like org deletion stay role-checked, not permission-checked);\n * editors work on content but see no money or roster controls; viewers read\n * only. A declared key's default for each role is the one its declaration\n * names.\n */\nexport const DEFAULT_ROLE_PERMISSIONS: Record<\n OrgRole,\n Record<OrgPermission, boolean>\n> = {\n owner: {} as Record<OrgPermission, boolean>,\n admin: {} as Record<OrgPermission, boolean>,\n editor: {} as Record<OrgPermission, boolean>,\n viewer: {} as Record<OrgPermission, boolean>,\n}\n\n/** Refused declarations already logged, so a refusal is reported once. */\nconst reportedRefusals = new Set<string>()\n\nfunction replaceItems<T>(target: readonly T[], items: readonly T[]): void {\n const list = target as T[]\n list.length = 0\n list.push(...items)\n}\n\nfunction replaceEntries(\n target: Record<string, boolean>,\n entries: Record<string, boolean>,\n): void {\n for (const key of Object.keys(target)) delete target[key]\n Object.assign(target, entries)\n}\n\n/**\n * Rebuilds the live catalog: the core keys, then every key a plugin declared\n * through either declaration API (`listPluginCatalogPermissions`, AGL-4047).\n * A declaration naming a core or legacy key is refused — that key keeps its\n * own meaning and defaults — and logged once.\n */\nfunction syncCatalog(): void {\n const definitions: OrgPermissionDefinition[] = [...CORE_ORG_PERMISSIONS]\n const tierKeys: string[] = []\n const groups: OrgPermissionGroup[] = CORE_ORG_PERMISSION_GROUPS.map((group) => ({ ...group }))\n for (const declared of listPluginCatalogPermissions()) {\n if (\n CORE_ORG_PERMISSION_KEYS.has(declared.key) ||\n LEGACY_PERMISSION_KEYS.has(declared.key)\n ) {\n const refusal = `${declared.pluginId}\\x00${declared.key}`\n if (!reportedRefusals.has(refusal)) {\n reportedRefusals.add(refusal)\n console.error(\n `[plugins] refused catalog permission \"${declared.key}\" to ` +\n `\"${declared.pluginId}\": the key belongs to the core catalog`,\n )\n }\n continue\n }\n definitions.push({\n key: declared.key,\n label: declared.label,\n description: declared.description,\n pluginId: declared.pluginId,\n group: declared.group,\n scope: declared.hostRoleDefaults ? 'site' : 'org',\n roleDefaults: declared.roleDefaults,\n ...(declared.hostRoleDefaults ? { hostRoleDefaults: declared.hostRoleDefaults } : {}),\n ...(declared.refines ? { refines: declared.refines } : {}),\n ...(declared.follows && !declared.refines ? { follows: declared.follows } : {}),\n ...(declared.narrowsPerSite ? { narrowsPerSite: { ...declared.narrowsPerSite } } : {}),\n ...(declared.raisesPerSite ? { raisesPerSite: true as const } : {}),\n ...(declared.presetFromSiteRole && declared.hostRoleDefaults ? { presetFromSiteRole: true as const } : {}),\n ...(declared.presetFromSiteRole && declared.hostRoleDefaults && declared.workspaceMembersOnly\n ? { workspaceMembersOnly: true as const }\n : {}),\n })\n if (declared.source === 'tier') tierKeys.push(declared.key)\n if (!groups.some((group) => group.id === declared.group)) {\n groups.push({ id: declared.group, label: declared.groupLabel, pluginId: declared.pluginId })\n }\n }\n const keys = definitions.map((definition) => definition.key)\n const known = new Set<string>(keys)\n // A refinement of a key the catalog does not hold refines nothing, and is\n // dropped from the definition so no editor offers a link to nowhere.\n for (const definition of definitions) {\n if (definition.refines && (!known.has(definition.refines) || definition.refines === definition.key)) {\n delete definition.refines\n }\n if (definition.follows && (!known.has(definition.follows) || definition.follows === definition.key)) {\n delete definition.follows\n }\n }\n replaceItems(\n ORG_PERMISSION_REFINEMENTS,\n definitions.flatMap((definition) => {\n const refinement = permissionRefinementOf(definition)\n return refinement ? [refinement] : []\n }),\n )\n replaceItems(ORG_PERMISSIONS, definitions)\n replaceItems(ORG_PERMISSION_KEYS, keys)\n replaceItems(\n ORG_PERMISSION_GROUPS,\n groups.filter((group) => definitions.some((definition) => definition.group === group.id)),\n )\n replaceItems(TIER_PERMISSION_KEYS, tierKeys)\n replaceEntries(NO_PERMISSIONS, Object.fromEntries(keys.map((key) => [key, false])))\n for (const role of ORG_ROLES) {\n replaceEntries(\n DEFAULT_ROLE_PERMISSIONS[role],\n Object.fromEntries(\n definitions.map((definition) => [definition.key, definition.roleDefaults[role] === true]),\n ),\n )\n }\n CATALOG_AND_LEGACY_KEYS.clear()\n for (const key of [...keys, ...LEGACY_PERMISSION_KEYS]) {\n CATALOG_AND_LEGACY_KEYS.add(key)\n }\n}\n\n/**\n * The `registerPluginPermissions` keys of a catalog-resolved map (AGL-4047).\n *\n * Those keys are answered twice: by the per-tier resolver\n * (`resolveRolePermissions`, the role's tier default and the member's\n * override) and, now that they are catalog keys, by `resolveOrgPermissions`\n * with every layer — the custom role's included. A caller that builds its\n * map from the first spreads this over it, so the custom role a member\n * carries reaches `managePos` the way it reaches `hosts.create`.\n */\nexport function tierPermissionsOf(\n granted: Readonly<Record<string, boolean>> | null | undefined,\n): Record<string, boolean> {\n const picked: Record<string, boolean> = {}\n if (!granted) return picked\n for (const key of TIER_PERMISSION_KEYS) {\n if (typeof granted[key] === 'boolean') picked[key] = granted[key]\n }\n return picked\n}\n\n/** One catalog key by name, or undefined. */\nexport function orgPermissionDefinition(\n permission: OrgPermission,\n): OrgPermissionDefinition | undefined {\n return ORG_PERMISSIONS.find((definition) => definition.key === permission)\n}\n\n/** `orgs/{orgId}/roles/{roleId}` — a named custom permission set. */\nexport interface AglynOrgCustomRole {\n $id?: string\n name?: string\n description?: string\n /** Full permission map; missing keys read as false. */\n permissions?: Partial<Record<OrgPermission, boolean>>\n /**\n * Per key a site can narrow (AGL-4047): `true` follows the site role on a\n * site where the member's access is narrower than their workspace role,\n * `false` keeps the permission there. A key it leaves out follows the\n * built-in role's default (`OrgPermissionDefinition.narrowsPerSite`), and\n * a member's own `siteNarrowing` wins over it.\n */\n siteNarrowing?: Partial<Record<OrgPermission, boolean>>\n}\n\n/**\n * Effective permission map for a member: the org role's defaults, then\n * the custom role's map (when the member has `roleId` and the role doc\n * is supplied), then per-member overrides — later layers win key-by-key.\n */\nexport function resolveOrgPermissions(\n member:\n | (Partial<AglynOrgMember> & {\n roleId?: string\n permissions?: Partial<Record<OrgPermission, boolean>>\n })\n | null\n | undefined,\n customRole?: AglynOrgCustomRole | null,\n): Record<OrgPermission, boolean> {\n if (!member) return NO_PERMISSIONS\n const role = (member.role ?? 'viewer') as OrgRole\n const base = DEFAULT_ROLE_PERMISSIONS[role] ?? NO_PERMISSIONS\n const merged: Record<OrgPermission, boolean> = { ...base }\n if (member.roleId && customRole?.permissions) {\n for (const key of ORG_PERMISSION_KEYS) {\n const value = customRole.permissions[key]\n if (typeof value === 'boolean') merged[key] = value\n }\n }\n if (member.permissions) {\n for (const key of ORG_PERMISSION_KEYS) {\n const value = member.permissions[key]\n if (typeof value === 'boolean') merged[key] = value\n }\n }\n // A key that refines a broader one (AGL-4047) follows it where neither\n // layer set the key, and is never held without it; a key that only follows\n // one takes its verdict where neither layer set the key, and nothing more.\n return refinePermissionMap(merged, ORG_PERMISSION_REFINEMENTS, [\n member.roleId ? customRole?.permissions : undefined,\n member.permissions,\n ])\n}\n\n/**\n * The values a custom role and a per-member override set EXPLICITLY for\n * permission keys outside this catalog — the keys plugins declare through\n * `registerPluginPermissions` (AGL-2974).\n *\n * `resolveOrgPermissions` walks the catalog alone, so a plugin key stored on\n * a custom role or a member document never reached the `resolvedPermissions`\n * stamp the Firestore rules read. A rule gating on one could then honor\n * neither a grant to an editor nor a revocation from an admin. This carries\n * exactly those stored decisions, custom role first and the per-member\n * override over it, which is the precedence the resolver applies.\n *\n * Tier DEFAULTS are deliberately absent. They live in the plugin registry,\n * which is populated per process by whichever plugin bundles that process\n * loaded, and a stamp computed from it would differ by which route happened\n * to write it. A rule supplies the default itself from the member's role,\n * the way `memberResolves` is always conjoined with a role gate.\n *\n * The legacy six camelCase keys are excluded as well: they are the catalog's\n * older projection, not plugin keys, and no rule reads them.\n */\nexport function explicitPluginPermissionValues(\n member:\n | {\n roleId?: string\n permissions?: Partial<Record<string, unknown>> | null\n }\n | null\n | undefined,\n customRole?: { permissions?: Partial<Record<string, unknown>> | null } | null,\n): Record<string, boolean> {\n const values: Record<string, boolean> = {}\n if (!member) return values\n const layers = [\n member.roleId ? customRole?.permissions : undefined,\n member.permissions,\n ]\n for (const layer of layers) {\n for (const [key, value] of Object.entries(layer ?? {})) {\n if (typeof value !== 'boolean') continue\n if (CATALOG_AND_LEGACY_KEYS.has(key)) continue\n values[key] = value\n }\n }\n return values\n}\n\n/**\n * Keys {@link explicitPluginPermissionValues} leaves to the catalog: every\n * catalog key, declared ones included, and the legacy six. Kept in step by\n * `syncCatalog`.\n */\nconst CATALOG_AND_LEGACY_KEYS = new Set<string>()\n\n/**\n * The `resolvedPermissions` map stamped on a member document for the\n * Firestore rules: the catalog verdict with every layer applied, and beside\n * it the plugin keys a custom role or an override set explicitly.\n *\n * One function for every writer of the stamp, so the org-create transaction\n * and `syncOrgAuthProjections` cannot project different maps. The catalog\n * spreads last; the two key spaces do not overlap, and the order keeps it\n * true that nothing but the resolver decides a catalog key.\n */\nexport function projectMemberResolvedPermissions(\n member: Parameters<typeof resolveOrgPermissions>[0],\n customRole?: AglynOrgCustomRole | null,\n): Record<string, boolean> {\n return {\n ...explicitPluginPermissionValues(member, customRole),\n ...resolveOrgPermissions(member, customRole),\n }\n}\n\n/** Single-permission convenience over `resolveOrgPermissions`. */\nexport function hasOrgPermission(\n member: Parameters<typeof resolveOrgPermissions>[0],\n permission: OrgPermission,\n customRole?: AglynOrgCustomRole | null,\n): boolean {\n return resolveOrgPermissions(member, customRole)[permission]\n}\n\n/** The catalog label for a key — the words a refusal names — or the key itself. */\nexport function orgPermissionLabel(permission: OrgPermission): string {\n return (\n ORG_PERMISSIONS.find((definition) => definition.key === permission)?.label ??\n permission\n )\n}\n\n/**\n * The sentence a door answers when a member does not hold a key (AGL-4047):\n * it names the permission by its catalog label and who can change it, never\n * a role.\n */\nexport function permissionRefusalText(permission: OrgPermission): string {\n return `Your role does not include \"${orgPermissionLabel(permission)}\" — ask an organization admin`\n}\n\n/** The keys plugins declared into the catalog, in catalog order. */\nexport function pluginOrgPermissionKeys(): OrgPermission[] {\n return ORG_PERMISSIONS.filter((definition) => definition.pluginId).map(\n (definition) => definition.key,\n )\n}\n\n/** One declared catalog key that moved, and the direction it moved in. */\nexport interface PluginPermissionChange {\n permission: string\n granted: boolean\n}\n\n/**\n * The keys PLUGINS declared into the catalog whose value moved between two\n * maps, in the new map's order — what a member, role or collaborator write\n * raises `org.permissions.changed` for, once per key, so the plugin that owns\n * a key can record who moved it.\n *\n * A key the new map leaves unset is not a change: on a role it defers to the\n * base role, on a site toggle to the host role, and neither is a grant or a\n * revocation of its own. A key set for the first time is a change, because\n * the verdict it produces is no longer the default's. The core keys and the\n * legacy six raise nothing; their writes are recorded by the routes' own\n * activity sentences.\n */\nexport function pluginPermissionChanges(\n before: Partial<Record<string, unknown>> | null | undefined,\n after: Partial<Record<string, unknown>> | null | undefined,\n): PluginPermissionChange[] {\n const changes: PluginPermissionChange[] = []\n for (const [key, next] of Object.entries(after ?? {})) {\n if (typeof next !== 'boolean') continue\n if (CORE_ORG_PERMISSION_KEYS.has(key) || LEGACY_PERMISSION_KEYS.has(key)) continue\n if (before?.[key] === next) continue\n changes.push({ permission: key, granted: next })\n }\n return changes\n}\n\n/**\n * The granular (dotted) set projected onto the legacy boolean map\n * (AGL-2350).\n *\n * ## Why this lives here rather than in the console hook\n *\n * It was a private function in `apps/console/hooks/use-org-permissions.ts`,\n * which meant the CLIENT translated the stored permission model into the\n * legacy flags and the SERVER did not translate at all — it derived the\n * legacy flags straight from the built-in role tier and dropped custom roles\n * and per-member overrides on the floor. The two disagreed exactly on the\n * feature `custom-roles.md` sells, in both directions: a permission granted\n * by a custom role showed in the UI and 403'd on POST, and one revoked by an\n * override was hidden in the UI and still succeeded on POST.\n *\n * One exported copy is what stops them drifting again.\n *\n * ## The key spaces are NOT interchangeable, and that is the trap\n *\n * Two permission vocabularies exist. The stored one is DOTTED\n * (`plugins.install`) — `apps/console/app/api/orgs/roles/route.ts` sanitizes\n * against `ORG_PERMISSION_KEYS` before writing, and `AglynOrgMember`\n * `permissions` is typed to it. The legacy one is camelCase\n * (`installPlugins`).\n *\n * `resolveRolePermissions` in `org-roles.ts` accepts `overrides` and\n * `customRoles` arguments keyed by the CAMELCASE space. Feeding it the real\n * stored documents therefore matches no key and changes nothing — it looks\n * like wiring the feature up while doing precisely nothing. Those two\n * parameters are used by nothing but that module's own spec. Translate\n * through here instead.\n *\n * `editHosts` is derived from the ROLE, not from a dotted key: it has no\n * counterpart in the granular catalog and never had one.\n */\nexport function toLegacyPermissions(\n granted: Record<OrgPermission, boolean>,\n role: OrgRole | null | undefined,\n): OrgPermissions {\n return {\n createHosts: granted['hosts.create'],\n editHosts: role !== 'viewer',\n editBilling: granted['billing.manage'],\n publishToMarketplace: granted['marketplace.publish'],\n installPlugins: granted['plugins.install'],\n manageMembers: granted['members.manage'],\n }\n}\n\nsyncCatalog()\nsubscribePluginEntitlements(syncCatalog)\n// The second declaration API feeds the same catalog (AGL-4047).\nsubscribePluginPermissions(syncCatalog)\n"],"names":["listPluginCatalogPermissions","subscribePluginEntitlements","permissionRefinementOf","refinePermissionMap","subscribePluginPermissions","ORG_ROLE_PERMISSION_KEYS","CORE_ORG_PERMISSION_ENTRIES","CORE_ORG_PERMISSION_GROUPS","CORE_ORG_ROLE_GRANTS","CORE_SITE_ROLE_PRESETS","CORE_ORG_PERMISSIONS","map","entry","key","group","scope","hostRoleDefaults","presetFromSiteRole","roleDefaults","owner","includes","admin","editor","viewer","CORE_ORG_PERMISSION_KEYS","Set","definition","LEGACY_PERMISSION_KEYS","ORG_ROLES","ORG_PERMISSIONS","ORG_PERMISSION_KEYS","ORG_PERMISSION_GROUPS","TIER_PERMISSION_KEYS","ORG_PERMISSION_REFINEMENTS","NO_PERMISSIONS","DEFAULT_ROLE_PERMISSIONS","reportedRefusals","replaceItems","target","items","list","length","push","replaceEntries","entries","Object","keys","assign","syncCatalog","definitions","tierKeys","groups","declared","has","refusal","pluginId","add","console","error","label","description","refines","follows","narrowsPerSite","raisesPerSite","workspaceMembersOnly","source","some","id","groupLabel","known","flatMap","refinement","filter","fromEntries","role","CATALOG_AND_LEGACY_KEYS","clear","tierPermissionsOf","granted","picked","orgPermissionDefinition","permission","find","resolveOrgPermissions","member","customRole","base","merged","roleId","permissions","value","undefined","explicitPluginPermissionValues","values","layers","layer","projectMemberResolvedPermissions","hasOrgPermission","orgPermissionLabel","permissionRefusalText","pluginOrgPermissionKeys","pluginPermissionChanges","before","after","changes","next","toLegacyPermissions","createHosts","editHosts","editBilling","publishToMarketplace","installPlugins","manageMembers"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,4BAA4B,EAC5BC,2BAA2B,QACtB,2CAAuC;AAC9C,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,0BAA0B,QAErB,0CAAsC;AAC7C,SAASC,wBAAwB,QAAQ,iBAAa;AACtD,SACEC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,oBAAoB,EACpBC,sBAAsB,QAGjB,uBAAmB;AA0H1B;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,MAAMC,uBACJ,2EAA2E;AAC3EJ,4BAA4BK,GAAG,CAAC,CAACC;QAGxBA,cACAA;WAJmC,aACvCA;QACHC,KAAKD,MAAMC,GAAG;QACdC,KAAK,GAAEF,eAAAA,MAAME,KAAK,YAAXF,eAAe;QACtBG,KAAK,GAAEH,eAAAA,MAAMG,KAAK,YAAXH,eAAe;OAElBH,sBAAsB,CAACG,MAAMC,GAAG,CAAC,GACjC;QAAEG,kBAAkB,aAAKP,sBAAsB,CAACG,MAAMC,GAAG,CAAC;QAAII,oBAAoB;IAAc,IAChG,CAAC;QACLC,cAAc;YACZC,OAAOX,qBAAqBW,KAAK,CAACC,QAAQ,CAACR,MAAMC,GAAG;YACpDQ,OAAOb,qBAAqBa,KAAK,CAACD,QAAQ,CAACR,MAAMC,GAAG;YACpDS,QAAQd,qBAAqBc,MAAM,CAACF,QAAQ,CAACR,MAAMC,GAAG;YACtDU,QAAQf,qBAAqBe,MAAM,CAACH,QAAQ,CAACR,MAAMC,GAAG;QACxD;;;AAGJ,6EAA6E,GAC7E,MAAMW,2BAAgD,IAAIC,IACxDf,qBAAqBC,GAAG,CAAC,CAACe,aAAeA,WAAWb,GAAG;AAGzD,kFAAkF,G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narrowable?: boolean;
75
+ /**
76
+ * For a site key, who holds it by the role they have on that site, read
77
+ * where the site has no stamp for them (`hostStampedSitePermission`, AGL-4047).
78
+ * Absent for a key with no such preset, and for one that holds for members of
79
+ * the whole workspace only, which a site's roles alone cannot answer.
80
+ */
81
+ sitePreset?: Record<string, boolean>;
75
82
  }
76
83
  /** A heading the role editor groups keys under. */
77
84
  export interface OrgPermissionGroup {
@@ -207,7 +207,7 @@ export const ORG_ROLE_NAMES = [
207
207
  key: 'data.manage',
208
208
  group: 'datasets',
209
209
  label: 'Manage data',
210
- description: 'Create, edit, and delete organization datasets, the CRM’s records, and marketing lists and topics.'
210
+ description: 'Create and edit organization datasets, add, change and delete their rows, and manage the CRM’s records and marketing lists and topics.'
211
211
  },
212
212
  // Workspace content that asked for the owner, admin or editor role
213
213
  // (AGL-4047), each a key whose default is exactly those roles.
@@ -221,7 +221,7 @@ export const ORG_ROLE_NAMES = [
221
221
  key: 'org.eraseRecords',
222
222
  group: 'datasets',
223
223
  label: 'Delete workspace records',
224
- description: 'Delete records the whole workspace shares, such as dataset rows, contacts and lists.'
224
+ description: 'Delete a whole dataset or list the workspace shares, with everything in it. Deleting one row of a dataset asks “Manage data”.'
225
225
  },
226
226
  {
227
227
  key: 'marketplace.publish',
@@ -319,9 +319,9 @@ const CORE_KEYS = CORE_ORG_PERMISSION_ENTRIES.map((entry)=>entry.key);
319
319
  * `registerPluginPermissions` keys land in one catalog (AGL-4047).
320
320
  */ export function assembleOrgRoleGrants(core, ...declarationLists) {
321
321
  var _core_groups;
322
- const permissions = [
323
- ...core.permissions
324
- ];
322
+ const permissions = core.permissions.map((entry)=>CORE_SITE_ROLE_PRESETS[entry.key] ? _extends({}, entry, {
323
+ sitePreset: _extends({}, CORE_SITE_ROLE_PRESETS[entry.key])
324
+ }) : entry);
325
325
  const groups = [
326
326
  ...(_core_groups = core.groups) != null ? _core_groups : []
327
327
  ];
@@ -354,6 +354,8 @@ const CORE_KEYS = CORE_ORG_PERMISSION_ENTRIES.map((entry)=>entry.key);
354
354
  follows: declaration.follows
355
355
  } : {}, declaration.narrowsPerSite ? {
356
356
  narrowable: true
357
+ } : {}, declaration.hostRoleDefaults && !declaration.workspaceMembersOnly ? {
358
+ sitePreset: _extends({}, declaration.hostRoleDefaults)
357
359
  } : {}));
358
360
  if (group && !groupIds.has(group)) {
359
361
  var _declaration_groupLabel;