@aglyn/aglyn 1.13.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.
@@ -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,UAAU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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"}
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,EAA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BC,SAAiB;IAEjB,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"}
@@ -16,16 +16,34 @@
16
16
  */
17
17
  import type { AglynOrgMember, HostAccessRole } from '../foundation';
18
18
  import type { AglynOrgCustomRole } from './org-permissions';
19
- /** The one site `visibleTo` places a resource on, or `null` for every site, several, or none. */
20
- export declare function oneSitePlacement(visibleTo: unknown): string | null;
21
19
  /**
22
- * The verdict for a resource placed at `visibleTo`: see above. `site` is asked
20
+ * Where a resource sits: the fields of its document that decide it. A whole
21
+ * document, never `visibleTo` alone, so no caller can answer without the marker.
22
+ */
23
+ export type ScopePlaced = Readonly<{
24
+ visibleTo?: unknown;
25
+ scopeMode?: unknown;
26
+ scopeExcept?: unknown;
27
+ }>;
28
+ /**
29
+ * The one site a resource is placed on, or `null` for every site, several, or
30
+ * none.
31
+ *
32
+ * `null` for a document shared with all sites except some, however few it reaches
33
+ * today. Its list can shrink to one site while it still belongs to the whole
34
+ * workspace, and the next new site joins it, so that one site never comes to
35
+ * answer for it. Read as the rules' `scopePlacement` reads it: either key present
36
+ * is marked, so a stored null or half a marker fails closed.
37
+ */
38
+ export declare function oneSitePlacement(placed: ScopePlaced | null | undefined): string | null;
39
+ /**
40
+ * The verdict for a resource placed as `placed` says: see above. `site` is asked
23
41
  * only when the workspace key did not settle it, so a door pays for reading the
24
42
  * site only then.
25
43
  */
26
44
  export declare function placementVerdict<T extends boolean | Promise<boolean>>(input: {
27
45
  member: Partial<AglynOrgMember> | null | undefined;
28
- visibleTo: unknown;
46
+ placed: ScopePlaced | null | undefined;
29
47
  workspace: boolean;
30
48
  site: (hostId: string) => T;
31
49
  }): boolean | T;
@@ -48,9 +66,9 @@ export declare function stampedPlacementKey(stamps: {
48
66
  export declare function resolvedPlacementKey(member: Partial<AglynOrgMember> | null | undefined, hostId: string, key: string, customRole?: AglynOrgCustomRole | null): boolean;
49
67
  /**
50
68
  * Whether deleting a resource is out of this member's reach whatever they hold:
51
- * they do not reach every site, and it is placed on every site or on several. It
52
- * belongs to the whole workspace.
69
+ * they do not reach every site, and it is placed on every site, on several, or on
70
+ * all sites except some. It belongs to the whole workspace.
53
71
  */
54
- export declare function deleteBeyondReach(member: Partial<AglynOrgMember> | null | undefined, visibleTo: unknown): boolean;
72
+ export declare function deleteBeyondReach(member: Partial<AglynOrgMember> | null | undefined, placed: ScopePlaced | null | undefined): boolean;
55
73
  /** The refusal for it, which names the reach it takes because no permission decides it. */
56
74
  export declare function deleteBeyondReachRefusal(label: string): string;
@@ -15,37 +15,29 @@
15
15
  * limitations under the License.
16
16
  */ import { hostStampedSitePermission, resolveMemberHostPermissions, siteMayNarrow } from "./host-permissions.js";
17
17
  import { hostRoleFor, isOrgWideMember } from "./organizations.js";
18
- /*
19
- * A RESOURCE PLACED ON ONE SITE ANSWERS TO THAT SITE (AGL-4047).
20
- *
21
- * The workspace's shared resources carry `visibleTo`, and one placed on exactly
22
- * one site belongs to it. Where a plugin decides a resource's writes that way,
23
- * its keys come in pairs: a workspace key, and a site key that follows it for a
24
- * member of the whole workspace, which a site can narrow and raise
25
- * (`narrowsPerSite`, `raisesPerSite`), and which a site collaborator holds by
26
- * their site role. The verdict:
27
- *
28
- * - the workspace key admits, unless a site narrows the member on the one site
29
- * the resource sits on;
30
- * - else, on that one site, the site key.
31
- *
32
- * Placed on every site or on several, the workspace key alone: no one site can be
33
- * asked, and a security rule cannot look through a list of them.
18
+ /**
19
+ * The one site a resource is placed on, or `null` for every site, several, or
20
+ * none.
34
21
  *
35
- * The rules ask the same thing in their own words, so these are kept in step with
36
- * them, placement test included.
37
- */ /** The one site `visibleTo` places a resource on, or `null` for every site, several, or none. */ export function oneSitePlacement(visibleTo) {
22
+ * `null` for a document shared with all sites except some, however few it reaches
23
+ * today. Its list can shrink to one site while it still belongs to the whole
24
+ * workspace, and the next new site joins it, so that one site never comes to
25
+ * answer for it. Read as the rules' `scopePlacement` reads it: either key present
26
+ * is marked, so a stored null or half a marker fails closed.
27
+ */ export function oneSitePlacement(placed) {
28
+ if (!placed || placed.scopeMode !== undefined || placed.scopeExcept !== undefined) return null;
29
+ const { visibleTo } = placed;
38
30
  if (!Array.isArray(visibleTo) || visibleTo.length !== 1) return null;
39
31
  const [token] = visibleTo;
40
32
  const match = typeof token === 'string' ? /^host:([^:/]+)$/.exec(token) : null;
41
33
  return match ? match[1] : null;
42
34
  }
43
35
  /**
44
- * The verdict for a resource placed at `visibleTo`: see above. `site` is asked
36
+ * The verdict for a resource placed as `placed` says: see above. `site` is asked
45
37
  * only when the workspace key did not settle it, so a door pays for reading the
46
38
  * site only then.
47
39
  */ export function placementVerdict(input) {
48
- const hostId = oneSitePlacement(input.visibleTo);
40
+ const hostId = oneSitePlacement(input.placed);
49
41
  if (!hostId) return input.workspace;
50
42
  if (input.workspace && !siteMayNarrow(input.member, hostId)) return true;
51
43
  return input.site(hostId);
@@ -76,10 +68,10 @@ import { hostRoleFor, isOrgWideMember } from "./organizations.js";
76
68
  }
77
69
  /**
78
70
  * Whether deleting a resource is out of this member's reach whatever they hold:
79
- * they do not reach every site, and it is placed on every site or on several. It
80
- * belongs to the whole workspace.
81
- */ export function deleteBeyondReach(member, visibleTo) {
82
- return !isOrgWideMember(member) && oneSitePlacement(visibleTo) === null;
71
+ * they do not reach every site, and it is placed on every site, on several, or on
72
+ * all sites except some. It belongs to the whole workspace.
73
+ */ export function deleteBeyondReach(member, placed) {
74
+ return !isOrgWideMember(member) && oneSitePlacement(placed) === null;
83
75
  }
84
76
  /** The refusal for it, which names the reach it takes because no permission decides it. */ export function deleteBeyondReachRefusal(label) {
85
77
  return `This ${label.toLowerCase()} is shared beyond one site, so deleting it takes access to every site in the workspace.`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-placement.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, HostAccessRole } from '../foundation'\nimport { hostStampedSitePermission, resolveMemberHostPermissions, siteMayNarrow } from './host-permissions'\nimport type { AglynOrgCustomRole } from './org-permissions'\nimport { hostRoleFor, isOrgWideMember } from './organizations'\n\n/*\n * A RESOURCE PLACED ON ONE SITE ANSWERS TO THAT SITE (AGL-4047).\n *\n * The workspace's shared resources carry `visibleTo`, and one placed on exactly\n * one site belongs to it. Where a plugin decides a resource's writes that way,\n * its keys come in pairs: a workspace key, and a site key that follows it for a\n * member of the whole workspace, which a site can narrow and raise\n * (`narrowsPerSite`, `raisesPerSite`), and which a site collaborator holds by\n * their site role. The verdict:\n *\n * - the workspace key admits, unless a site narrows the member on the one site\n * the resource sits on;\n * - else, on that one site, the site key.\n *\n * Placed on every site or on several, the workspace key alone: no one site can be\n * asked, and a security rule cannot look through a list of them.\n *\n * The rules ask the same thing in their own words, so these are kept in step with\n * them, placement test included.\n */\n\n/** The one site `visibleTo` places a resource on, or `null` for every site, several, or none. */\nexport function oneSitePlacement(visibleTo: unknown): string | null {\n if (!Array.isArray(visibleTo) || visibleTo.length !== 1) return null\n const [token] = visibleTo as unknown[]\n const match = typeof token === 'string' ? /^host:([^:/]+)$/.exec(token) : null\n return match ? match[1] : null\n}\n\n/**\n * The verdict for a resource placed at `visibleTo`: see above. `site` is asked\n * only when the workspace key did not settle it, so a door pays for reading the\n * site only then.\n */\nexport function placementVerdict<T extends boolean | Promise<boolean>>(input: {\n member: Partial<AglynOrgMember> | null | undefined\n visibleTo: unknown\n workspace: boolean\n site: (hostId: string) => T\n}): boolean | T {\n const hostId = oneSitePlacement(input.visibleTo)\n if (!hostId) return input.workspace\n if (input.workspace && !siteMayNarrow(input.member, hostId)) return true\n return input.site(hostId)\n}\n\n/**\n * The site key as the site's stamp gives it, read as the rules read it:\n * `memberPermissions[uid][key]`, else, on a site the projection has not reached\n * since the key existed, the site role's preset, unless someone decided against\n * this member in a way the stamp would carry: a custom role, or their own\n * workspace key refused. Those wait for the stamp, so nobody refused regains it\n * from `memberRoles`.\n */\nexport function stampedPlacementKey(\n stamps: { memberPermissions?: unknown; memberRoles?: unknown } | null | undefined,\n uid: string,\n key: string,\n preset: Readonly<Partial<Record<HostAccessRole, boolean>>>,\n member: (Partial<AglynOrgMember> & { roleId?: unknown; permissions?: unknown }) | null | undefined,\n workspaceKey: string,\n): boolean {\n const stamp = (stamps?.memberPermissions as Record<string, Record<string, unknown> | undefined> | undefined)?.[uid]?.[key]\n if (typeof stamp === 'boolean') return stamp\n if (member?.roleId != null || (member?.permissions as Record<string, unknown> | undefined)?.[workspaceKey] === false) return false\n return hostStampedSitePermission({ memberRoles: stamps?.memberRoles }, uid, key, preset)\n}\n\n/** The site key from the membership alone, by the function the site's stamp is written from. */\nexport function resolvedPlacementKey(\n member: Partial<AglynOrgMember> | null | undefined,\n hostId: string,\n key: string,\n customRole?: AglynOrgCustomRole | null,\n): boolean {\n if (!member || !hostRoleFor(member, hostId)) return false\n return resolveMemberHostPermissions({ member, customRole: customRole ?? null, hostId })[key] === true\n}\n\n/**\n * Whether deleting a resource is out of this member's reach whatever they hold:\n * they do not reach every site, and it is placed on every site or on several. It\n * belongs to the whole workspace.\n */\nexport function deleteBeyondReach(member: Partial<AglynOrgMember> | null | undefined, visibleTo: unknown): boolean {\n return !isOrgWideMember(member) && oneSitePlacement(visibleTo) === null\n}\n\n/** The refusal for it, which names the reach it takes because no permission decides it. */\nexport function deleteBeyondReachRefusal(label: string): string {\n return `This ${label.toLowerCase()} is shared beyond one site, so deleting it takes access to every site in the workspace.`\n}\n"],"names":["hostStampedSitePermission","resolveMemberHostPermissions","siteMayNarrow","hostRoleFor","isOrgWideMember","oneSitePlacement","visibleTo","Array","isArray","length","token","match","exec","placementVerdict","input","hostId","workspace","member","site","stampedPlacementKey","stamps","uid","key","preset","workspaceKey","stamp","memberPermissions","roleId","permissions","memberRoles","resolvedPlacementKey","customRole","deleteBeyondReach","deleteBeyondReachRefusal","label","toLowerCase"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,yBAAyB,EAAEC,4BAA4B,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,MAAkD,EAClDF,MAAc,EACdO,GAAW,EACXS,UAAsC;IAEtC,IAAI,CAACd,UAAU,CAACd,YAAYc,QAAQF,SAAS,OAAO;IACpD,OAAOd,6BAA6B;QAAEgB;QAAQc,UAAU,EAAEA,qBAAAA,aAAc;QAAMhB;IAAO,EAAE,CAACO,IAAI,KAAK;AACnG;AAEA;;;;CAIC,GACD,OAAO,SAASU,kBAAkBf,MAAkD,EAAEX,SAAkB;IACtG,OAAO,CAACF,gBAAgBa,WAAWZ,iBAAiBC,eAAe;AACrE;AAEA,yFAAyF,GACzF,OAAO,SAAS2B,yBAAyBC,KAAa;IACpD,OAAO,CAAC,KAAK,EAAEA,MAAMC,WAAW,GAAG,uFAAuF,CAAC;AAC7H"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-placement.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, HostAccessRole } from '../foundation'\nimport { hostStampedSitePermission, resolveMemberHostPermissions, siteMayNarrow } from './host-permissions'\nimport type { AglynOrgCustomRole } from './org-permissions'\nimport { hostRoleFor, isOrgWideMember } from './organizations'\n\n/*\n * A RESOURCE PLACED ON ONE SITE ANSWERS TO THAT SITE (AGL-4047).\n *\n * The workspace's shared resources carry `visibleTo`, and one placed on exactly\n * one site belongs to it. Where a plugin decides a resource's writes that way,\n * its keys come in pairs: a workspace key, and a site key that follows it for a\n * member of the whole workspace, which a site can narrow and raise\n * (`narrowsPerSite`, `raisesPerSite`), and which a site collaborator holds by\n * their site role. The verdict:\n *\n * - the workspace key admits, unless a site narrows the member on the one site\n * the resource sits on;\n * - else, on that one site, the site key.\n *\n * Placed on every site, on several, or on all sites except some, the workspace key\n * alone: no one site can be asked, and a security rule cannot look through a list\n * of them.\n *\n * The rules ask the same thing in their own words, so these are kept in step with\n * them, placement test included.\n */\n\n/**\n * Where a resource sits: the fields of its document that decide it. A whole\n * document, never `visibleTo` alone, so no caller can answer without the marker.\n */\nexport type ScopePlaced = Readonly<{ visibleTo?: unknown; scopeMode?: unknown; scopeExcept?: unknown }>\n\n/**\n * The one site a resource is placed on, or `null` for every site, several, or\n * none.\n *\n * `null` for a document shared with all sites except some, however few it reaches\n * today. Its list can shrink to one site while it still belongs to the whole\n * workspace, and the next new site joins it, so that one site never comes to\n * answer for it. Read as the rules' `scopePlacement` reads it: either key present\n * is marked, so a stored null or half a marker fails closed.\n */\nexport function oneSitePlacement(placed: ScopePlaced | null | undefined): string | null {\n if (!placed || placed.scopeMode !== undefined || placed.scopeExcept !== undefined) return null\n const { visibleTo } = placed\n if (!Array.isArray(visibleTo) || visibleTo.length !== 1) return null\n const [token] = visibleTo as unknown[]\n const match = typeof token === 'string' ? /^host:([^:/]+)$/.exec(token) : null\n return match ? match[1] : null\n}\n\n/**\n * The verdict for a resource placed as `placed` says: see above. `site` is asked\n * only when the workspace key did not settle it, so a door pays for reading the\n * site only then.\n */\nexport function placementVerdict<T extends boolean | Promise<boolean>>(input: {\n member: Partial<AglynOrgMember> | null | undefined\n placed: ScopePlaced | null | undefined\n workspace: boolean\n site: (hostId: string) => T\n}): boolean | T {\n const hostId = oneSitePlacement(input.placed)\n if (!hostId) return input.workspace\n if (input.workspace && !siteMayNarrow(input.member, hostId)) return true\n return input.site(hostId)\n}\n\n/**\n * The site key as the site's stamp gives it, read as the rules read it:\n * `memberPermissions[uid][key]`, else, on a site the projection has not reached\n * since the key existed, the site role's preset, unless someone decided against\n * this member in a way the stamp would carry: a custom role, or their own\n * workspace key refused. Those wait for the stamp, so nobody refused regains it\n * from `memberRoles`.\n */\nexport function stampedPlacementKey(\n stamps: { memberPermissions?: unknown; memberRoles?: unknown } | null | undefined,\n uid: string,\n key: string,\n preset: Readonly<Partial<Record<HostAccessRole, boolean>>>,\n member: (Partial<AglynOrgMember> & { roleId?: unknown; permissions?: unknown }) | null | undefined,\n workspaceKey: string,\n): boolean {\n const stamp = (stamps?.memberPermissions as Record<string, Record<string, unknown> | undefined> | undefined)?.[uid]?.[key]\n if (typeof stamp === 'boolean') return stamp\n if (member?.roleId != null || (member?.permissions as Record<string, unknown> | undefined)?.[workspaceKey] === false) return false\n return hostStampedSitePermission({ memberRoles: stamps?.memberRoles }, uid, key, preset)\n}\n\n/** The site key from the membership alone, by the function the site's stamp is written from. */\nexport function resolvedPlacementKey(\n member: Partial<AglynOrgMember> | null | undefined,\n hostId: string,\n key: string,\n customRole?: AglynOrgCustomRole | null,\n): boolean {\n if (!member || !hostRoleFor(member, hostId)) return false\n return resolveMemberHostPermissions({ member, customRole: customRole ?? null, hostId })[key] === true\n}\n\n/**\n * Whether deleting a resource is out of this member's reach whatever they hold:\n * they do not reach every site, and it is placed on every site, on several, or on\n * all sites except some. It belongs to the whole workspace.\n */\nexport function deleteBeyondReach(\n member: Partial<AglynOrgMember> | null | undefined,\n placed: ScopePlaced | null | undefined,\n): boolean {\n return !isOrgWideMember(member) && oneSitePlacement(placed) === null\n}\n\n/** The refusal for it, which names the reach it takes because no permission decides it. */\nexport function deleteBeyondReachRefusal(label: string): string {\n return `This ${label.toLowerCase()} is shared beyond one site, so deleting it takes access to every site in the workspace.`\n}\n"],"names":["hostStampedSitePermission","resolveMemberHostPermissions","siteMayNarrow","hostRoleFor","isOrgWideMember","oneSitePlacement","placed","scopeMode","undefined","scopeExcept","visibleTo","Array","isArray","length","token","match","exec","placementVerdict","input","hostId","workspace","member","site","stampedPlacementKey","stamps","uid","key","preset","workspaceKey","stamp","memberPermissions","roleId","permissions","memberRoles","resolvedPlacementKey","customRole","deleteBeyondReach","deleteBeyondReachRef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AApB,AAACX,mBAA6D,CAACO,aAAa,MAAK,OAAO,OAAO;IAC7H,OAAO5B,0BAA0B;QAAEiC,WAAW,EAAET,0BAAAA,OAAQS,WAAW;IAAC,GAAGR,KAAKC,KAAKC;AACnF;AAEA,8FAA8F,GAC9F,OAAO,SAASO,qBACdb,MAAkD,EAClDF,MAAc,EACdO,GAAW,EACXS,UAAsC;IAEtC,IAAI,CAACd,UAAU,CAAClB,YAAYkB,QAAQF,SAAS,OAAO;IACpD,OAAOlB,6BAA6B;QAAEoB;QAAQc,UAAU,EAAEA,qBAAAA,aAAc;QAAMhB;IAAO,EAAE,CAACO,IAAI,KAAK;AACnG;AAEA;;;;CAIC,GACD,OAAO,SAASU,kBACdf,MAAkD,EAClDf,MAAsC;IAEtC,OAAO,CAACF,gBAAgBiB,WAAWhB,iBAAiBC,YAAY;AAClE;AAEA,yFAAyF,GACzF,OAAO,SAAS+B,yBAAyBC,KAAa;IACpD,OAAO,CAAC,KAAK,EAAEA,MAAMC,WAAW,GAAG,uFAAuF,CAAC;AAC7H"}
@@ -326,6 +326,16 @@ export declare function labelContactSource(source: unknown, fallback?: string):
326
326
  * nothing answers to, without closing the list against a plugin's door.
327
327
  */
328
328
  export declare function isKnownContactSource(source: unknown): boolean;
329
+ /**
330
+ * Whether a capture source is a plugin's word rather than one of the core's.
331
+ *
332
+ * A capture writes its source into the holder's facet, and that is the only place
333
+ * a plugin's word has ever been. A list's sweep still reads the core's words off
334
+ * the top of the row, so reading them from the facet too would change who an
335
+ * existing source-filtered list selects. It asks this to read the facet for the
336
+ * words no existing list could have named.
337
+ */
338
+ export declare function isPluginContactSource(source: string): boolean;
329
339
  /** One source a filter offers: the stored word, and how it reads. */
330
340
  export interface PluginContactSourceOption {
331
341
  value: string;
@@ -117,6 +117,17 @@ export const PLUGIN_CONTACT_SOURCES = definePluginServiceContract('core.contact-
117
117
  if (!word) return false;
118
118
  return Object.hasOwn(CONTACT_SOURCE_LABELS, word) || pluginContactSource(word) !== null;
119
119
  }
120
+ /**
121
+ * Whether a capture source is a plugin's word rather than one of the core's.
122
+ *
123
+ * A capture writes its source into the holder's facet, and that is the only place
124
+ * a plugin's word has ever been. A list's sweep still reads the core's words off
125
+ * the top of the row, so reading them from the facet too would change who an
126
+ * existing source-filtered list selects. It asks this to read the facet for the
127
+ * words no existing list could have named.
128
+ */ export function isPluginContactSource(source) {
129
+ return !Object.hasOwn(CONTACT_SOURCE_LABELS, source);
130
+ }
120
131
  /**
121
132
  * Every source a filter can offer: the core's, then each door a plugin
122
133
  * declared, each reading as {@link labelContactSource} reads it, so a filter's
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-contact-capture.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 { CONTACT_SOURCE_LABELS } from '../app-utils/contacts'\nimport { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport {\n definePluginServiceContract,\n registerPluginService,\n resolvePluginServices,\n} from './plugin-services'\n\n/**\n * A person met on a site, handed to whichever plugin keeps people (AGL-3124).\n *\n * Four silos capture the same thing and none of them is the record system: a\n * form submission, a site member signing up, an order, a booking. Each holds\n * an address, a name and the fact that something happened, and each wants the\n * workspace's person record to know. Today each one imports the writer, which\n * makes the highest-fan-in edge in the repo — thirty files in one plugin alone\n * — and makes the record system's plugin something a storefront cannot take a\n * payment without.\n *\n * So the silo stops importing and starts DECLARING: it registers the capture\n * door it owns, and hands a capture to this seam. The plugin that keeps people\n * registers the writer and does every part of the work that is a record\n * system's to do:\n *\n * - normalizing and keying the address, and deciding whether this is a new\n * person or a visit from one the workspace already holds;\n * - the audience band, the erasure rows, and every other refusal — answered,\n * never thrown, so a capture that is refused never costs the silo the order\n * or the submission it was recording;\n * - what a stage, an owner, a company and a tag mean, and what the arrival\n * of a new person sets off.\n *\n * The silo decides none of that. It reports what it saw.\n *\n * ## Why the profile is opaque\n *\n * `profile` is the owner's own field names with scalar values, not a core\n * type. A person's record shape belongs to the plugin that models it, and a\n * typed core shape would be that model spelled in the platform again — which\n * is the defect this seam exists to retire, not a smaller version of it. A key\n * the owner does not document is the owner's to ignore.\n *\n * `source` is the silo's own word for its door, and it is declared rather than\n * enumerated here for the same reason: core listing `form`, `member`, `order`\n * and `booking` would be core holding the plugin set again. A silo registers\n * its source with {@link registerPluginContactSource}, which is what lets a\n * timeline label an entry and a link point back at the thing that captured the\n * person, without the platform knowing what any of them are.\n *\n * ## One writer; many silos\n *\n * A workspace keeps one set of people, so the writer is a slot: a second\n * plugin's writer is refused naming both, and the incumbent keeps serving. A\n * SOURCE is per silo and there are many, but one source word has one owner —\n * two plugins claiming `order` would make the label and the link ambiguous at\n * the point they are read.\n *\n * ## The caller proves who is asking\n *\n * Like `plugin-record-timeline`, the registry authenticates nobody. A silo has\n * already decided, in its own terms and before it asks, that the capture is\n * the workspace's to record — that the submission was accepted, that the order\n * was paid.\n *\n * Server-side: reached by its own subpath, never through\n * `plugin-manager/index.ts`.\n */\n\n/** The person, as the capturing silo saw them. */\nexport interface PluginContactIdentity {\n /**\n * The address they gave. Raw: the owner normalizes and keys on it, and a\n * silo that normalized first would be keeping a second copy of that rule.\n */\n email: unknown\n name?: string | null\n}\n\n/** What happened, in the capturing silo's own words. */\nexport interface PluginContactInteraction {\n /** The silo's declared source word — see {@link registerPluginContactSource}. */\n source: string\n /** When it happened, epoch ms; the owner uses now when absent. */\n atMs?: number\n /**\n * The document it happened on, in the silo's terms\n * (`formSubmissions/{id}`, `orders/{id}`), so a timeline entry can point\n * back at it. Absent where the door leaves nothing to open.\n */\n refId?: string | null\n /** One line a person reads on the timeline. */\n summary?: string | null\n}\n\nexport interface PluginContactCaptureRequest {\n /**\n * Who caused the capture, when it was not the person captured (AGL-3376) —\n * a member adding someone by hand, an integration's key. A door where the\n * visitor acts for themselves (a form, a purchase) may leave it out.\n */\n actor?: {\n kind: 'member' | 'visitor' | 'apiKey' | 'platform'\n uid?: string | null\n email?: string | null\n apiKeyName?: string | null\n }\n orgId: string\n /** The site the person was met on: the brand whose form or checkout it was. */\n hostId: string\n identity: PluginContactIdentity\n interaction: PluginContactInteraction\n /**\n * An explicit marketing opt-in the capture surface carried, recorded against\n * `hostId`: consent to the MARKETING send purpose (`marketing-consent.ts`),\n * whichever plugin's mail later asks for it. Absent is not consent, and\n * filing a capture under a container is not consent either.\n */\n marketingConsent?: boolean\n /**\n * The disclosure key the capture surface rendered beside that opt-in\n * (`consentGroupDisclosureKey`, AGL-3320), passed through as the surface\n * sent it. The owner records the opt-in for the site's whole consent group\n * only when this is the group's current key, and for `hostId` alone\n * otherwise — so a silo whose surface shows no disclosure sends none.\n */\n disclosedConsentGroup?: string\n /** Tags the silo puts on this capture; the owner adds, never replaces. */\n tags?: readonly string[]\n /**\n * What the capture SURFACE is filed under — the merchant's own act — by\n * container kind (`plugin-containers.ts`): `{ [kind]: ids }`. The owner\n * files the person under the kinds it keeps. Filing is not consent.\n */\n containers?: Readonly<Record<string, readonly string[]>>\n /** Money the capture was worth, in cents, where the silo took some. */\n purchaseCents?: number\n /** The currency {@link purchaseCents} is in, lowercase, when the silo knows. */\n purchaseCurrency?: string\n /**\n * The earliest stage this capture describes, in the OWNER's words. A floor\n * and not a value: the owner fills an empty stage and advances an earlier\n * one, and never moves anybody back, so a repeat customer filling in a\n * contact form is still a customer.\n */\n lifecycleFloor?: string\n /**\n * What kind of door this is, which decides WHICH RECORD the person lands\n * on (AGL-3232) — the owner's rule is Salesforce's: one person is one\n * record, a lead until they are qualified and a contact after.\n *\n * - `lead`: a lead surface — a form whose author routes it to leads, a\n * booking request. The person is filed as a LEAD and nothing else,\n * unless the workspace already holds them as a contact, in which case\n * the capture lands on the contact and no lead is filed.\n * - `relationship`: an act that makes the person a known relationship —\n * a member account, a purchase. The person is filed as a CONTACT, and\n * an open lead the site held for them is stamped converted onto it.\n * - `touch`, the default: everything else — a form without lead routing,\n * a newsletter opt-in. The capture lands on the open lead when the site\n * holds one for the address, and on the contact otherwise.\n */\n surface?: 'lead' | 'relationship' | 'touch'\n /**\n * Profile fields the silo knows, keyed by the owner's own field names.\n * Only the keys given are written, so a silo that knows the phone number\n * does not blank a title somebody typed.\n */\n profile?: Readonly<Record<string, unknown>>\n /**\n * Profile fields written only where the record the person lands on holds\n * none (AGL-3493), keyed as {@link profile} is. For what a door learned\n * in passing — the phone a booking form asked for — and must not put over\n * a value somebody typed on the record or gave the business before.\n * A key also present in `profile` is `profile`'s to write.\n */\n profileFill?: Readonly<Record<string, unknown>>\n /**\n * Facts about THIS CAPTURE that the owner models and the platform does not\n * (AGL-3080) — which form was filled in, which page it was on, where the\n * visitor arrived from.\n *\n * Opaque for the reason {@link profile} is: every one of these is a concept\n * belonging to the plugin that keeps people or to the silo that saw it, and\n * a typed core field for each would be those models spelled out in the\n * platform again. `profile` describes the PERSON and outlives the visit;\n * this describes the visit and does not.\n *\n * A key the owner does not recognize is the owner's to ignore, and a silo\n * that sends nothing here loses nothing: every field is an enrichment of a\n * capture that is already complete without it.\n */\n detail?: Readonly<Record<string, unknown>>\n}\n\n/**\n * The owner's answer. `created: false` is a visit by somebody the workspace\n * already held, which is an interaction and not a new person.\n *\n * A refusal is RETURNED. Every one of these silos has already done the thing\n * it was recording, so a throw here would cost an accepted submission or a\n * paid order for a record it could not keep.\n */\nexport type PluginContactCaptured =\n /** The capture landed on a contact — the record every capture used to make. */\n | { ok: true; record: 'contact'; contactId: string; created: boolean }\n /**\n * The capture landed on a LEAD (AGL-3232): a lead surface met somebody the\n * workspace does not hold as a contact, or a touch reached an open lead.\n * `leadId` is the person key the lead is filed under on `hostId`.\n */\n | {\n ok: true\n record: 'lead'\n leadId: string\n created: boolean\n /**\n * Whether this capture's surface was new on the lead — a new person,\n * or one first met through another door. A form counts its leads by\n * it (AGL-3330): the people it filed, not the times they came back.\n * Absent from a writer that does not say, which a caller reads as\n * `created`.\n */\n sourceAdded?: boolean\n }\n | {\n ok: false\n /**\n * `invalid-email`: nothing usable to key a person on. `band`: the\n * workspace is at the audience it may hold. `erased`: the workspace\n * erased this person and a capture must not quietly rebuild them.\n * `error`: the owner failed, and said so rather than silently.\n */\n reason: 'invalid-email' | 'band' | 'erased' | 'error'\n /** Customer-safe: a caller may show or log it as it stands. */\n error: string\n }\n\nexport interface PluginContactCaptureWriter {\n /** Records one capture; a refusal is returned, never thrown. */\n capture(\n request: PluginContactCaptureRequest,\n ): Promise<PluginContactCaptured>\n}\n\n/** A capture door a silo owns. */\nexport interface PluginContactSourceDeclaration {\n /** The silo's word for the door, as its captures carry it. */\n source: string\n /** What a timeline entry from this door says: `Form submission`. */\n label: string\n /**\n * What a link from that entry says when there is something to open —\n * `Open submission`. Absent where the door leaves nothing to open, which\n * is the honest answer for an import or a by-hand add.\n */\n openLabel?: string\n /**\n * The record kind the silo's own document is, for\n * `plugin-record-routes` to address it with. Absent where the door has no\n * record of its own to open.\n */\n recordKind?: string\n}\n\n/** A source declaration with the silo that made it. */\nexport type ResolvedPluginContactSource = PluginContactSourceDeclaration & {\n pluginId: string\n}\n\nexport const PLUGIN_CONTACT_CAPTURE =\n definePluginServiceContract<PluginContactCaptureWriter>(\n 'core.contact-capture',\n { multiple: false },\n )\n\nexport const PLUGIN_CONTACT_SOURCES =\n definePluginServiceContract<PluginContactSourceDeclaration>(\n 'core.contact-capture-sources',\n { multiple: true },\n )\n\n/**\n * Registers the plugin that keeps people. The owner is the loader's marker\n * when a register fn is running, else `options.pluginId`; with neither the\n * registration throws, and a second plugin's writer is refused naming both —\n * the incumbent keeps serving.\n */\nexport function registerPluginContactCaptureWriter(\n writer: PluginContactCaptureWriter,\n options?: { pluginId?: string },\n): void {\n registerPluginService(PLUGIN_CONTACT_CAPTURE, writer, {\n ...(options?.pluginId ? { pluginId: options.pluginId } : {}),\n })\n}\n\n/** Declares a capture door. One source word has one owner. */\nexport function registerPluginContactSource(\n declaration: PluginContactSourceDeclaration,\n options?: { pluginId?: string },\n): void {\n const key = declaration.source?.trim() ?? ''\n if (!key) throw new Error('a contact capture source needs a source word')\n if (!declaration.label?.trim()) {\n throw new Error(`contact capture source \"${key}\" needs a label`)\n }\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n const incumbent = resolvePluginServices(PLUGIN_CONTACT_SOURCES).find(\n (entry) => entry.key === key,\n )\n if (incumbent && pluginId && incumbent.pluginId !== pluginId) {\n throw new Error(\n `contact capture source \"${key}\" is already declared by ` +\n `\"${incumbent.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n registerPluginService(\n PLUGIN_CONTACT_SOURCES,\n { ...declaration, source: key },\n {\n ...(options?.pluginId ? { pluginId: options.pluginId } : {}),\n key,\n },\n )\n}\n\nexport interface ResolvedPluginContactCaptureWriter {\n /** The plugin that keeps people. */\n pluginId: string\n writer: PluginContactCaptureWriter\n}\n\n/** The writer with its owner, or `null` when no plugin keeps people here. */\nexport function pluginContactCaptureWriter(): ResolvedPluginContactCaptureWriter | null {\n const entry = resolvePluginServices(PLUGIN_CONTACT_CAPTURE)[0]\n return entry ? { pluginId: entry.pluginId, writer: entry.impl } : null\n}\n\n/**\n * Hands one capture to the plugin that keeps people, or answers `null` when\n * no plugin does.\n *\n * `null` and a refusal are different answers and a silo treats them\n * differently: `null` is a workspace with no record system, where there is\n * nothing to record and nothing has gone wrong; a refusal is a record system\n * that considered this person and declined.\n */\nexport async function capturePluginContact(\n request: PluginContactCaptureRequest,\n): Promise<PluginContactCaptured | null> {\n const found = pluginContactCaptureWriter()\n if (!found) return null\n return found.writer.capture(request)\n}\n\n/** Every declared capture door, with its silo, in registration order. */\nexport function listPluginContactSources(): ResolvedPluginContactSource[] {\n return resolvePluginServices(PLUGIN_CONTACT_SOURCES).map((entry) => ({\n ...entry.impl,\n pluginId: entry.pluginId,\n }))\n}\n\n/** One declared capture door by its source word, or `null`. */\nexport function pluginContactSource(\n source: string,\n): ResolvedPluginContactSource | null {\n const key = source.trim()\n const entry = resolvePluginServices(PLUGIN_CONTACT_SOURCES).find(\n (one) => one.key === key,\n )\n return entry ? { ...entry.impl, pluginId: entry.pluginId } : null\n}\n\n/**\n * How a contact's source word reads on screen, wherever it came from: the\n * core's own words from {@link CONTACT_SOURCE_LABELS}, then the label a\n * plugin declared for its door with {@link registerPluginContactSource},\n * then `fallback` when one is given, else the word itself.\n *\n * The core's map is a closed `Record<ContactSource, string>`, and a plugin's\n * door is an open string by design, so a list, a chip or a report that read\n * the map alone showed a plugin's raw word (`waiver` rather than its label).\n * This is the one place both are asked, in that order, so a plugin cannot\n * relabel a core source. It answers from what is registered in THIS process:\n * a plugin that declares its door from its `declarations` entry is known in\n * the console's browser and on both servers before a page renders.\n */\nexport function labelContactSource(source: unknown, fallback?: string): string {\n const word = typeof source === 'string' ? source.trim() : ''\n if (!word) return fallback ?? ''\n if (Object.hasOwn(CONTACT_SOURCE_LABELS, word)) {\n return CONTACT_SOURCE_LABELS[word as keyof typeof CONTACT_SOURCE_LABELS]\n }\n return pluginContactSource(word)?.label || (fallback ?? word)\n}\n\n/**\n * Whether a word is a source this process can name: one of the core's, or a\n * door a plugin declared. What keeps a saved filter from carrying a word\n * nothing answers to, without closing the list against a plugin's door.\n */\nexport function isKnownContactSource(source: unknown): boolean {\n const word = typeof source === 'string' ? source.trim() : ''\n if (!word) return false\n return Object.hasOwn(CONTACT_SOURCE_LABELS, word) || pluginContactSource(word) !== null\n}\n\n/** One source a filter offers: the stored word, and how it reads. */\nexport interface PluginContactSourceOption {\n value: string\n label: string\n}\n\n/**\n * Every source a filter can offer: the core's, then each door a plugin\n * declared, each reading as {@link labelContactSource} reads it, so a filter's\n * choice and a row's chip cannot disagree. A plugin that declares a core word\n * adds no second entry and does not change its label.\n */\nexport function listContactSourceOptions(): PluginContactSourceOption[] {\n const words = new Set([\n ...Object.keys(CONTACT_SOURCE_LABELS),\n ...listPluginContactSources().map((door) => door.source),\n ])\n return [...words].map((value) => ({ value, label: labelContactSource(value) }))\n}\n"],"names":["CONTACT_SOURCE_LABELS","getRegisteringPluginId","definePluginServiceContract","registerPluginService","resolvePluginServices","PLUGIN_CONTACT_CAPTURE","multiple","PLUGIN_CONTACT_SOURCES","registerPluginContactCaptureWriter","writer","options","pluginId","registerPluginContactSource","declaration","key","source","trim","Error","label","incumbent","find","entry","pluginContactCaptureWriter","impl","capturePluginContact","request","found","capture","listPluginContactSources","map","pluginContactSource","one","labelContactSource","fallback","word","Object","hasOwn","isKnownContactSource","listContactSourceOptions","words","Set","keys","door","value"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,QAAQ,2BAAuB;AAC7D,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,QAChB,uBAAmB;AAuQ1B,OAAO,MAAMC,yBACXH,4BACE,wBACA;IAAEI,UAAU;AAAM,GACnB;AAEH,OAAO,MAAMC,yBACXL,4BACE,gCACA;IAAEI,UAAU;AAAK,GAClB;AAEH;;;;;CAKC,GACD,OAAO,SAASE,mCACdC,MAAkC,EAClCC,OAA+B;IAE/BP,sBAAsBE,wBAAwBI,QAAQ,aAChDC,CAAAA,2BAAAA,QAASC,QAAQ,IAAG;QAAEA,UAAUD,QAAQC,QAAQ;IAAC,IAAI,CAAC;AAE9D;AAEA,4DAA4D,GAC5D,OAAO,SAASC,4BACdC,WAA2C,EAC3CH,OAA+B;cAObT,OAAAA;QALNY,qBAEPA;IAFL,MAAMC,eAAMD,sBAAAA,YAAYE,MAAM,qBAAlBF,oBAAoBG,IAAI,qBAAM;IAC1C,IAAI,CAACF,KAAK,MAAM,IAAIG,MAAM;IAC1B,IAAI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,MAAMD,MAAMC,OAAOC,IAAI;IACvB,MAAMK,QAAQjB,sBAAsBG,wBAAwBa,IAAI,CAC9D,CAACW,MAAQA,IAAIjB,GAAG,KAAKA;IAEvB,OAAOO,QAAQ,aAAKA,MAAME,IAAI;QAAEZ,UAAUU,MAAMV,QAAQ;SAAK;AAC/D;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASqB,mBAAmBjB,MAAe,EAAEkB,QAAiB;QAM5DH;IALP,MAAMI,OAAO,OAAOnB,WAAW,WAAWA,OAAOC,IAAI,KAAK;IAC1D,IAAI,CAACkB,MAAM,OAAOD,mBAAAA,WAAY;IAC9B,IAAIE,OAAOC,MAAM,CAACpC,uBAAuBkC,OAAO;QAC9C,OAAOlC,qBAAqB,CAACkC,KAA2C;IAC1E;IACA,OAAOJ,EAAAA,uBAAAA,oBAAoBI,0BAApBJ,qBAA2BZ,KAAK,MAAKe,mBAAAA,WAAYC;AAC1D;AAEA;;;;CAIC,GACD,OAAO,SAASG,qBAAqBtB,MAAe;IAClD,MAAMmB,OAAO,OAAOnB,WAAW,WAAWA,OAAOC,IAAI,KAAK;IAC1D,IAAI,CAACkB,MAAM,OAAO;IAClB,OAAOC,OAAOC,MAAM,CAACpC,uBAAuBkC,SAASJ,oBAAoBI,UAAU;AACrF;AAQA;;;;;CAKC,GACD,OAAO,SAASI;IACd,MAAMC,QAAQ,IAAIC,IAAI;WACjBL,OAAOM,IAAI,CAACzC;WACZ4B,2BAA2BC,GAAG,CAAC,CAACa,OAASA,KAAK3B,MAAM;KACxD;IACD,OAAO;WAAIwB;KAAM,CAACV,GAAG,CAAC,CAACc,QAAW,CAAA;YAAEA;YAAOzB,OAAOc,mBAAmBW;QAAO,CAAA;AAC9E"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-contact-capture.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 { CONTACT_SOURCE_LABELS } from '../app-utils/contacts'\nimport { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport {\n definePluginServiceContract,\n registerPluginService,\n resolvePluginServices,\n} from './plugin-services'\n\n/**\n * A person met on a site, handed to whichever plugin keeps people (AGL-3124).\n *\n * Four silos capture the same thing and none of them is the record system: a\n * form submission, a site member signing up, an order, a booking. Each holds\n * an address, a name and the fact that something happened, and each wants the\n * workspace's person record to know. Today each one imports the writer, which\n * makes the highest-fan-in edge in the repo — thirty files in one plugin alone\n * — and makes the record system's plugin something a storefront cannot take a\n * payment without.\n *\n * So the silo stops importing and starts DECLARING: it registers the capture\n * door it owns, and hands a capture to this seam. The plugin that keeps people\n * registers the writer and does every part of the work that is a record\n * system's to do:\n *\n * - normalizing and keying the address, and deciding whether this is a new\n * person or a visit from one the workspace already holds;\n * - the audience band, the erasure rows, and every other refusal — answered,\n * never thrown, so a capture that is refused never costs the silo the order\n * or the submission it was recording;\n * - what a stage, an owner, a company and a tag mean, and what the arrival\n * of a new person sets off.\n *\n * The silo decides none of that. It reports what it saw.\n *\n * ## Why the profile is opaque\n *\n * `profile` is the owner's own field names with scalar values, not a core\n * type. A person's record shape belongs to the plugin that models it, and a\n * typed core shape would be that model spelled in the platform again — which\n * is the defect this seam exists to retire, not a smaller version of it. A key\n * the owner does not document is the owner's to ignore.\n *\n * `source` is the silo's own word for its door, and it is declared rather than\n * enumerated here for the same reason: core listing `form`, `member`, `order`\n * and `booking` would be core holding the plugin set again. A silo registers\n * its source with {@link registerPluginContactSource}, which is what lets a\n * timeline label an entry and a link point back at the thing that captured the\n * person, without the platform knowing what any of them are.\n *\n * ## One writer; many silos\n *\n * A workspace keeps one set of people, so the writer is a slot: a second\n * plugin's writer is refused naming both, and the incumbent keeps serving. A\n * SOURCE is per silo and there are many, but one source word has one owner —\n * two plugins claiming `order` would make the label and the link ambiguous at\n * the point they are read.\n *\n * ## The caller proves who is asking\n *\n * Like `plugin-record-timeline`, the registry authenticates nobody. A silo has\n * already decided, in its own terms and before it asks, that the capture is\n * the workspace's to record — that the submission was accepted, that the order\n * was paid.\n *\n * Server-side: reached by its own subpath, never through\n * `plugin-manager/index.ts`.\n */\n\n/** The person, as the capturing silo saw them. */\nexport interface PluginContactIdentity {\n /**\n * The address they gave. Raw: the owner normalizes and keys on it, and a\n * silo that normalized first would be keeping a second copy of that rule.\n */\n email: unknown\n name?: string | null\n}\n\n/** What happened, in the capturing silo's own words. */\nexport interface PluginContactInteraction {\n /** The silo's declared source word — see {@link registerPluginContactSource}. */\n source: string\n /** When it happened, epoch ms; the owner uses now when absent. */\n atMs?: number\n /**\n * The document it happened on, in the silo's terms\n * (`formSubmissions/{id}`, `orders/{id}`), so a timeline entry can point\n * back at it. Absent where the door leaves nothing to open.\n */\n refId?: string | null\n /** One line a person reads on the timeline. */\n summary?: string | null\n}\n\nexport interface PluginContactCaptureRequest {\n /**\n * Who caused the capture, when it was not the person captured (AGL-3376) —\n * a member adding someone by hand, an integration's key. A door where the\n * visitor acts for themselves (a form, a purchase) may leave it out.\n */\n actor?: {\n kind: 'member' | 'visitor' | 'apiKey' | 'platform'\n uid?: string | null\n email?: string | null\n apiKeyName?: string | null\n }\n orgId: string\n /** The site the person was met on: the brand whose form or checkout it was. */\n hostId: string\n identity: PluginContactIdentity\n interaction: PluginContactInteraction\n /**\n * An explicit marketing opt-in the capture surface carried, recorded against\n * `hostId`: consent to the MARKETING send purpose (`marketing-consent.ts`),\n * whichever plugin's mail later asks for it. Absent is not consent, and\n * filing a capture under a container is not consent either.\n */\n marketingConsent?: boolean\n /**\n * The disclosure key the capture surface rendered beside that opt-in\n * (`consentGroupDisclosureKey`, AGL-3320), passed through as the surface\n * sent it. The owner records the opt-in for the site's whole consent group\n * only when this is the group's current key, and for `hostId` alone\n * otherwise — so a silo whose surface shows no disclosure sends none.\n */\n disclosedConsentGroup?: string\n /** Tags the silo puts on this capture; the owner adds, never replaces. */\n tags?: readonly string[]\n /**\n * What the capture SURFACE is filed under — the merchant's own act — by\n * container kind (`plugin-containers.ts`): `{ [kind]: ids }`. The owner\n * files the person under the kinds it keeps. Filing is not consent.\n */\n containers?: Readonly<Record<string, readonly string[]>>\n /** Money the capture was worth, in cents, where the silo took some. */\n purchaseCents?: number\n /** The currency {@link purchaseCents} is in, lowercase, when the silo knows. */\n purchaseCurrency?: string\n /**\n * The earliest stage this capture describes, in the OWNER's words. A floor\n * and not a value: the owner fills an empty stage and advances an earlier\n * one, and never moves anybody back, so a repeat customer filling in a\n * contact form is still a customer.\n */\n lifecycleFloor?: string\n /**\n * What kind of door this is, which decides WHICH RECORD the person lands\n * on (AGL-3232) — the owner's rule is Salesforce's: one person is one\n * record, a lead until they are qualified and a contact after.\n *\n * - `lead`: a lead surface — a form whose author routes it to leads, a\n * booking request. The person is filed as a LEAD and nothing else,\n * unless the workspace already holds them as a contact, in which case\n * the capture lands on the contact and no lead is filed.\n * - `relationship`: an act that makes the person a known relationship —\n * a member account, a purchase. The person is filed as a CONTACT, and\n * an open lead the site held for them is stamped converted onto it.\n * - `touch`, the default: everything else — a form without lead routing,\n * a newsletter opt-in. The capture lands on the open lead when the site\n * holds one for the address, and on the contact otherwise.\n */\n surface?: 'lead' | 'relationship' | 'touch'\n /**\n * Profile fields the silo knows, keyed by the owner's own field names.\n * Only the keys given are written, so a silo that knows the phone number\n * does not blank a title somebody typed.\n */\n profile?: Readonly<Record<string, unknown>>\n /**\n * Profile fields written only where the record the person lands on holds\n * none (AGL-3493), keyed as {@link profile} is. For what a door learned\n * in passing — the phone a booking form asked for — and must not put over\n * a value somebody typed on the record or gave the business before.\n * A key also present in `profile` is `profile`'s to write.\n */\n profileFill?: Readonly<Record<string, unknown>>\n /**\n * Facts about THIS CAPTURE that the owner models and the platform does not\n * (AGL-3080) — which form was filled in, which page it was on, where the\n * visitor arrived from.\n *\n * Opaque for the reason {@link profile} is: every one of these is a concept\n * belonging to the plugin that keeps people or to the silo that saw it, and\n * a typed core field for each would be those models spelled out in the\n * platform again. `profile` describes the PERSON and outlives the visit;\n * this describes the visit and does not.\n *\n * A key the owner does not recognize is the owner's to ignore, and a silo\n * that sends nothing here loses nothing: every field is an enrichment of a\n * capture that is already complete without it.\n */\n detail?: Readonly<Record<string, unknown>>\n}\n\n/**\n * The owner's answer. `created: false` is a visit by somebody the workspace\n * already held, which is an interaction and not a new person.\n *\n * A refusal is RETURNED. Every one of these silos has already done the thing\n * it was recording, so a throw here would cost an accepted submission or a\n * paid order for a record it could not keep.\n */\nexport type PluginContactCaptured =\n /** The capture landed on a contact — the record every capture used to make. */\n | { ok: true; record: 'contact'; contactId: string; created: boolean }\n /**\n * The capture landed on a LEAD (AGL-3232): a lead surface met somebody the\n * workspace does not hold as a contact, or a touch reached an open lead.\n * `leadId` is the person key the lead is filed under on `hostId`.\n */\n | {\n ok: true\n record: 'lead'\n leadId: string\n created: boolean\n /**\n * Whether this capture's surface was new on the lead — a new person,\n * or one first met through another door. A form counts its leads by\n * it (AGL-3330): the people it filed, not the times they came back.\n * Absent from a writer that does not say, which a caller reads as\n * `created`.\n */\n sourceAdded?: boolean\n }\n | {\n ok: false\n /**\n * `invalid-email`: nothing usable to key a person on. `band`: the\n * workspace is at the audience it may hold. `erased`: the workspace\n * erased this person and a capture must not quietly rebuild them.\n * `error`: the owner failed, and said so rather than silently.\n */\n reason: 'invalid-email' | 'band' | 'erased' | 'error'\n /** Customer-safe: a caller may show or log it as it stands. */\n error: string\n }\n\nexport interface PluginContactCaptureWriter {\n /** Records one capture; a refusal is returned, never thrown. */\n capture(\n request: PluginContactCaptureRequest,\n ): Promise<PluginContactCaptured>\n}\n\n/** A capture door a silo owns. */\nexport interface PluginContactSourceDeclaration {\n /** The silo's word for the door, as its captures carry it. */\n source: string\n /** What a timeline entry from this door says: `Form submission`. */\n label: string\n /**\n * What a link from that entry says when there is something to open —\n * `Open submission`. Absent where the door leaves nothing to open, which\n * is the honest answer for an import or a by-hand add.\n */\n openLabel?: string\n /**\n * The record kind the silo's own document is, for\n * `plugin-record-routes` to address it with. Absent where the door has no\n * record of its own to open.\n */\n recordKind?: string\n}\n\n/** A source declaration with the silo that made it. */\nexport type ResolvedPluginContactSource = PluginContactSourceDeclaration & {\n pluginId: string\n}\n\nexport const PLUGIN_CONTACT_CAPTURE =\n definePluginServiceContract<PluginContactCaptureWriter>(\n 'core.contact-capture',\n { multiple: false },\n )\n\nexport const PLUGIN_CONTACT_SOURCES =\n definePluginServiceContract<PluginContactSourceDeclaration>(\n 'core.contact-capture-sources',\n { multiple: true },\n )\n\n/**\n * Registers the plugin that keeps people. The owner is the loader's marker\n * when a register fn is running, else `options.pluginId`; with neither the\n * registration throws, and a second plugin's writer is refused naming both —\n * the incumbent keeps serving.\n */\nexport function registerPluginContactCaptureWriter(\n writer: PluginContactCaptureWriter,\n options?: { pluginId?: string },\n): void {\n registerPluginService(PLUGIN_CONTACT_CAPTURE, writer, {\n ...(options?.pluginId ? { pluginId: options.pluginId } : {}),\n })\n}\n\n/** Declares a capture door. One source word has one owner. */\nexport function registerPluginContactSource(\n declaration: PluginContactSourceDeclaration,\n options?: { pluginId?: string },\n): void {\n const key = declaration.source?.trim() ?? ''\n if (!key) throw new Error('a contact capture source needs a source word')\n if (!declaration.label?.trim()) {\n throw new Error(`contact capture source \"${key}\" needs a label`)\n }\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n const incumbent = resolvePluginServices(PLUGIN_CONTACT_SOURCES).find(\n (entry) => entry.key === key,\n )\n if (incumbent && pluginId && incumbent.pluginId !== pluginId) {\n throw new Error(\n `contact capture source \"${key}\" is already declared by ` +\n `\"${incumbent.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n registerPluginService(\n PLUGIN_CONTACT_SOURCES,\n { ...declaration, source: key },\n {\n ...(options?.pluginId ? { pluginId: options.pluginId } : {}),\n key,\n },\n )\n}\n\nexport interface ResolvedPluginContactCaptureWriter {\n /** The plugin that keeps people. */\n pluginId: string\n writer: PluginContactCaptureWriter\n}\n\n/** The writer with its owner, or `null` when no plugin keeps people here. */\nexport function pluginContactCaptureWriter(): ResolvedPluginContactCaptureWriter | null {\n const entry = resolvePluginServices(PLUGIN_CONTACT_CAPTURE)[0]\n return entry ? { pluginId: entry.pluginId, writer: entry.impl } : null\n}\n\n/**\n * Hands one capture to the plugin that keeps people, or answers `null` when\n * no plugin does.\n *\n * `null` and a refusal are different answers and a silo treats them\n * differently: `null` is a workspace with no record system, where there is\n * nothing to record and nothing has gone wrong; a refusal is a record system\n * that considered this person and declined.\n */\nexport async function capturePluginContact(\n request: PluginContactCaptureRequest,\n): Promise<PluginContactCaptured | null> {\n const found = pluginContactCaptureWriter()\n if (!found) return null\n return found.writer.capture(request)\n}\n\n/** Every declared capture door, with its silo, in registration order. */\nexport function listPluginContactSources(): ResolvedPluginContactSource[] {\n return resolvePluginServices(PLUGIN_CONTACT_SOURCES).map((entry) => ({\n ...entry.impl,\n pluginId: entry.pluginId,\n }))\n}\n\n/** One declared capture door by its source word, or `null`. */\nexport function pluginContactSource(\n source: string,\n): ResolvedPluginContactSource | null {\n const key = source.trim()\n const entry = resolvePluginServices(PLUGIN_CONTACT_SOURCES).find(\n (one) => one.key === key,\n )\n return entry ? { ...entry.impl, pluginId: entry.pluginId } : null\n}\n\n/**\n * How a contact's source word reads on screen, wherever it came from: the\n * core's own words from {@link CONTACT_SOURCE_LABELS}, then the label a\n * plugin declared for its door with {@link registerPluginContactSource},\n * then `fallback` when one is given, else the word itself.\n *\n * The core's map is a closed `Record<ContactSource, string>`, and a plugin's\n * door is an open string by design, so a list, a chip or a report that read\n * the map alone showed a plugin's raw word (`waiver` rather than its label).\n * This is the one place both are asked, in that order, so a plugin cannot\n * relabel a core source. It answers from what is registered in THIS process:\n * a plugin that declares its door from its `declarations` entry is known in\n * the console's browser and on both servers before a page renders.\n */\nexport function labelContactSource(source: unknown, fallback?: string): string {\n const word = typeof source === 'string' ? source.trim() : ''\n if (!word) return fallback ?? ''\n if (Object.hasOwn(CONTACT_SOURCE_LABELS, word)) {\n return CONTACT_SOURCE_LABELS[word as keyof typeof CONTACT_SOURCE_LABELS]\n }\n return pluginContactSource(word)?.label || (fallback ?? word)\n}\n\n/**\n * Whether a word is a source this process can name: one of the core's, or a\n * door a plugin declared. What keeps a saved filter from carrying a word\n * nothing answers to, without closing the list against a plugin's door.\n */\nexport function isKnownContactSource(source: unknown): boolean {\n const word = typeof source === 'string' ? source.trim() : ''\n if (!word) return false\n return Object.hasOwn(CONTACT_SOURCE_LABELS, word) || pluginContactSource(word) !== null\n}\n\n/**\n * Whether a capture source is a plugin's word rather than one of the core's.\n *\n * A capture writes its source into the holder's facet, and that is the only place\n * a plugin's word has ever been. A list's sweep still reads the core's words off\n * the top of the row, so reading them from the facet too would change who an\n * existing source-filtered list selects. It asks this to read the facet for the\n * words no existing list could have named.\n */\nexport function isPluginContactSource(source: string): boolean {\n return !Object.hasOwn(CONTACT_SOURCE_LABELS, source)\n}\n\n/** One source a filter offers: the stored word, and how it reads. */\nexport interface PluginContactSourceOption {\n value: string\n label: string\n}\n\n/**\n * Every source a filter can offer: the core's, then each door a plugin\n * declared, each reading as {@link labelContactSource} reads it, so a filter's\n * choice and a row's chip cannot disagree. A plugin that declares a core word\n * adds no second entry and does not change its label.\n */\nexport function listContactSourceOptions(): PluginContactSourceOption[] {\n const words = new Set([\n ...Object.keys(CONTACT_SOURCE_LABELS),\n ...listPluginContactSources().map((door) => door.source),\n ])\n return [...words].map((value) => ({ value, label: labelContactSource(value) }))\n}\n"],"names":["CONTACT_SOURCE_LABELS","getRegisteringPluginId","definePluginServiceContract","registerPluginService","resolvePluginServices","PLUGIN_CONTACT_CAPTURE","multiple","PLUGIN_CONTACT_SOURCES","registerPluginContactCaptureWriter","writer","options","pluginId","registerPluginContactSource","declaration","key","source","trim","Error","label","incumbent","find","entry","pluginContactCaptureWriter","impl","capturePluginContact","request","found","capture","listPluginContactSources","map","pluginContactSource","one","labelContactSource","fallback","word","Object","hasOwn","isKnownContactSource","isPluginContactSource","listContactSourceOptions","words","Set","keys","door","value"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,QAAQ,2BAAuB;AAC7D,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,QAChB,uBAAmB;AAuQ1B,OAAO,MAAMC,yBACXH,4BACE,wBACA;IAAEI,UAAU;AAAM,GACnB;AAEH,OAAO,MAAMC,yBACXL,4BACE,gCACA;IAAEI,UAAU;AAAK,GAClB;AAEH;;;;;CAKC,GACD,OAAO,SAASE,mCACdC,MAAkC,EAClCC,OAA+B;IAE/BP,sBAAsBE,wBAAwBI,QAAQ,aAChDC,CAAAA,2BAAAA,QAASC,QAAQ,IAAG;QAAEA,UAAUD,QAAQC,QAAQ;IAAC,IAAI,CAAC;AAE9D;AAEA,4DAA4D,GAC5D,OAAO,SAASC,4BACdC,WAA2C,EAC3CH,OAA+B;cAObT,OAAAA;QALNY,qBAEPA;IAFL,MAAMC,eAAMD,sBAAAA,YAAYE,MAAM,qBAAlBF,oBAAoBG,IAAI,qBAAM;IAC1C,IAAI,CAACF,KAAK,MAAM,IAAIG,MAAM;IAC1B,IAAI,GAACJ,qBAAAA,YAAYK,KAAK,qBAAjBL,mBAAmBG,IAAI,KAAI;QAC9B,MAAM,IAAIC,MAAM,CAAC,wBAAwB,EAAEH,IAAI,eAAe,CAAC;IACjE;IACA,MAAMH,WAAW,EAACV,SAAAA,0BAAAA,oCAAAA,0BAA4BS,2BAAAA,QAASC,QAAQ,YAA7CV,QAAiD,IAAIe,IAAI;IAC3E,MAAMG,YAAYf,sBAAsBG,wBA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