@aglyn/aglyn 1.23.1 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/lib/app-utils/activity-labels.js +4 -1
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/activity-presenter.d.ts +11 -0
- package/src/lib/app-utils/activity-presenter.js +9 -0
- package/src/lib/app-utils/activity-presenter.js.map +1 -1
- package/src/lib/app-utils/activity-search.d.ts +1 -0
- package/src/lib/app-utils/activity-search.js +1 -0
- package/src/lib/app-utils/activity-search.js.map +1 -1
- package/src/lib/app-utils/agent-api-catalog.d.ts +18 -0
- package/src/lib/app-utils/agent-api-catalog.js +8 -1
- package/src/lib/app-utils/agent-api-catalog.js.map +1 -1
- package/src/lib/app-utils/binding-token-catalog.d.ts +15 -0
- package/src/lib/app-utils/binding-token-catalog.js +16 -0
- package/src/lib/app-utils/binding-token-catalog.js.map +1 -1
- package/src/lib/app-utils/business-details.d.ts +5 -0
- package/src/lib/app-utils/business-details.js +4 -0
- package/src/lib/app-utils/business-details.js.map +1 -1
- package/src/lib/app-utils/connector-discovery.d.ts +80 -0
- package/src/lib/app-utils/connector-discovery.js +107 -0
- package/src/lib/app-utils/connector-discovery.js.map +1 -0
- package/src/lib/app-utils/crm.d.ts +17 -30
- package/src/lib/app-utils/crm.js +139 -3
- package/src/lib/app-utils/crm.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +5 -1
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +5 -5
- package/src/lib/app-utils/docs-help.generated.js +12 -3
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +149 -9
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/entity-picker-context.d.ts +6 -0
- package/src/lib/app-utils/entity-picker-context.js.map +1 -1
- package/src/lib/app-utils/expand-repeatables.js +25 -2
- package/src/lib/app-utils/expand-repeatables.js.map +1 -1
- package/src/lib/app-utils/host-tokens.d.ts +17 -0
- package/src/lib/app-utils/host-tokens.js +18 -0
- package/src/lib/app-utils/host-tokens.js.map +1 -1
- package/src/lib/app-utils/native-app-association.d.ts +9 -5
- package/src/lib/app-utils/native-app-association.js +10 -5
- package/src/lib/app-utils/native-app-association.js.map +1 -1
- package/src/lib/app-utils/native-nav.js +1 -1
- package/src/lib/app-utils/native-nav.js.map +1 -1
- package/src/lib/app-utils/organizations.js +4 -2
- package/src/lib/app-utils/organizations.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.d.ts +227 -36
- package/src/lib/app-utils/plan-entitlements.js +335 -43
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/plugin-release-flags.generated.js +2 -2
- package/src/lib/app-utils/plugin-release-flags.generated.js.map +1 -1
- package/src/lib/app-utils/reusable-component-keys.d.ts +9 -0
- package/src/lib/app-utils/reusable-component-keys.js +9 -0
- package/src/lib/app-utils/reusable-component-keys.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +1 -0
- package/src/lib/app-utils/server.js +1 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/sign-in-visibility.d.ts +78 -0
- package/src/lib/app-utils/sign-in-visibility.js +79 -0
- package/src/lib/app-utils/sign-in-visibility.js.map +1 -0
- package/src/lib/app-utils/site-live-url.d.ts +4 -1
- package/src/lib/app-utils/site-live-url.js +17 -3
- package/src/lib/app-utils/site-live-url.js.map +1 -1
- package/src/lib/app-utils/usage-level.d.ts +50 -0
- package/src/lib/app-utils/usage-level.js +94 -0
- package/src/lib/app-utils/usage-level.js.map +1 -0
- package/src/lib/foundation/definitions/org-billing.types.d.ts +24 -2
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/plugin-manager/plugin-contact-capture.d.ts +2 -0
- package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/binding-token-catalog.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 * Browsable data-placeholder catalogs for the designer's insert picker\n * (AGL-583). Hand-typing `{{entry.title}}` stays the advanced path; these\n * catalogs give every token a friendly label + description so editors can\n * browse and insert instead of memorizing the grammar.\n *\n * The token STRINGS are owned elsewhere — `collectionEntryTokens`\n * (collection-entries.ts) and the tenant compose pipeline resolve them —\n * this module only names them for pickers. The spec cross-checks the entry\n * catalog against the resolver so the two can never drift.\n */\nexport interface BindingTokenCatalogEntry {\n /** The literal token inserted into the prop, e.g. `{{entry.title}}`. */\n token: string\n /** Friendly picker label, e.g. `Title`. */\n label: string\n /** One-line description shown as the option's secondary text. */\n description?: string\n}\n\n/**\n * `{{entry.*}}` tokens (AGL-105/551/582) — resolve per entry inside a\n * Collection entries block and page-wide on entry-template screens.\n * Mirrors {@link collectionEntryTokens}; the spec enforces the mirror.\n */\nexport const ENTRY_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[] = [\n { token: '{{entry.title}}', label: 'Title', description: 'The entry headline.' },\n {\n token: '{{entry.excerpt}}',\n label: 'Excerpt',\n description: 'Short summary text.',\n },\n {\n token: '{{entry.body}}',\n label: 'Body',\n description: 'The full entry body.',\n },\n {\n token: '{{entry.url}}',\n label: 'Link URL',\n description: 'Auto-route to the entry page.',\n },\n {\n token: '{{entry.date}}',\n label: 'Published date',\n description: 'Formatted publish date.',\n },\n /*\n Beside the readable date on purpose: a designer reaching for \"the date\" in\n a Video element's Publication date field has to see that the readable one\n is the wrong pick there, and why.\n */\n {\n token: '{{entry.publishedAt}}',\n label: 'Publish timestamp',\n description:\n 'The publish date and time in ISO 8601, for a field that needs a ' +\n 'machine-readable date, such as a Video element’s publication date.',\n },\n {\n token: '{{entry.author}}',\n label: 'Author',\n description: 'The byline set on the entry.',\n },\n {\n token: '{{entry.authorBio}}',\n label: 'Author bio',\n description: 'Blurb from the author’s record.',\n },\n {\n token: '{{entry.authorImage}}',\n label: 'Author portrait',\n description: 'Portrait or logo from the author’s record.',\n },\n {\n token: '{{entry.authorUrl}}',\n label: 'Author link',\n description: 'The author’s own page.',\n },\n {\n token: '{{entry.authorPageUrl}}',\n label: 'Author page',\n description:\n 'This author’s page on this site — everything they wrote, across every ' +\n 'collection. Separate from Author link, which is their own site.',\n },\n {\n token: '{{entry.slug}}',\n label: 'Slug',\n description: 'URL-safe entry identifier.',\n },\n /*\n Named \"Its collection…\" rather than \"Collection…\", which is what these\n describe and also exactly what the `{{collection.*}}` entries below are\n called. The picker groups options by heading, so the two sets sit apart —\n but a designer scanning it reads the LABEL, and two options reading\n \"Collection name\" three lines apart is a choice made by guessing. The\n pronoun is doing real work: on the one page where both resolve, they mean\n different collections.\n */\n {\n token: '{{entry.collection}}',\n label: 'Its collection',\n description:\n 'Which section this entry belongs to. Worth binding on a listing that ' +\n 'MIXES collections — an author page — where a card otherwise cannot ' +\n 'tell a release note from an essay.',\n },\n {\n token: '{{entry.collectionSlug}}',\n label: 'Its collection slug',\n description: 'That collection’s URL segment.',\n },\n {\n token: '{{entry.collectionUrl}}',\n label: 'Its collection link',\n description: 'The listing this entry belongs to.',\n },\n {\n token: '{{entry.coverImage}}',\n label: 'Cover image',\n description: 'Cover image URL.',\n },\n {\n token: '{{entry.coverVideo}}',\n label: 'Featured video',\n description:\n 'The featured video’s source — a library film, a video file link or ' +\n 'a video host’s link — for a Video element.',\n },\n {\n token: '{{entry.coverVideoDuration}}',\n label: 'Featured video length',\n description:\n 'How long the featured video runs, in seconds, for a Video element’s ' +\n 'duration field. Blank when the entry does not say.',\n },\n {\n token: '{{entry.category}}',\n label: 'Category',\n description: 'The entry category.',\n },\n {\n token: '{{entry.tags}}',\n label: 'Tags',\n description: 'Tags, comma separated.',\n },\n {\n token: '{{entry.seoTitle}}',\n label: 'SEO title',\n description: 'Search title; falls back to Title.',\n },\n {\n token: '{{entry.seoDescription}}',\n label: 'SEO description',\n description: 'Meta description; falls back to Excerpt.',\n },\n]\n\n/**\n * `{{collection.*}}` and `{{pagination.*}}` tokens (AGL-551/1321/1386) —\n * resolve on collection list/entry template screens (see the tenant compose\n * pipeline's collection tokens).\n *\n * The category and pagination tokens all resolve to the empty string where\n * they do not apply, so they are safe to bind unconditionally: ONE list\n * screen serves the bare listing, every `/page/{n}` and every\n * `/category/{slug}`, and a template has no runtime conditional to vary\n * itself with.\n */\nexport const COLLECTION_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[] = [\n {\n token: '{{collection.name}}',\n label: 'Collection name',\n description: 'Display name of the routed collection.',\n },\n {\n token: '{{collection.slug}}',\n label: 'Collection slug',\n description: 'URL slug of the routed collection.',\n },\n {\n token: '{{collection.category}}',\n label: 'Filtered category',\n description: 'Category the URL filtered on; empty when unfiltered.',\n },\n {\n token: '{{collection.categorySlug}}',\n label: 'Filtered category slug',\n description: 'That category’s URL segment; empty when unfiltered.',\n },\n {\n token: '{{pagination.page}}',\n label: 'Current page',\n description: 'Page number this URL is showing.',\n },\n {\n token: '{{pagination.totalPages}}',\n label: 'Total pages',\n // A listing bigger than one read cannot be counted honestly (AGL-3219):\n // the count and the entries were read at two different moments, and the\n // pager built from them disagreed with itself at the page boundary. It\n // still resolves, so a template binding it keeps rendering.\n description:\n 'Pages in the listing, after any category filter. Empty on a listing too large to count — bind the next link instead.',\n },\n {\n token: '{{pagination.prevUrl}}',\n label: 'Previous page link',\n description: 'Keeps the category; empty on the first page.',\n },\n {\n token: '{{pagination.nextUrl}}',\n label: 'Next page link',\n // The reliable \"is there more\" (AGL-3219): it is set from a read that\n // asked for one entry more than the page needed, so empty means there was\n // no such entry rather than that a total said so.\n description:\n 'Keeps the category; empty when there is nothing older to show.',\n },\n]\n\n/**\n * `{{author.*}}` tokens (AGL-2518) — resolve on an author's own page,\n * `/author/{slug}`.\n *\n * Empty everywhere else, like the category tokens above and for the same\n * reason: a template has no runtime conditional, so the tokens have to be the\n * thing that varies. A heading bound to `{{author.name}}` prints a name on an\n * author page and nothing anywhere else.\n *\n * The `{{pagination.*}}` tokens resolve HERE TOO, over this author's own\n * archive — deliberately the same four names a collection listing uses, so a\n * pager built once works on both.\n */\nexport const AUTHOR_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[] = [\n {\n token: '{{author.name}}',\n label: 'Name',\n description: 'The byline this page collects.',\n },\n {\n token: '{{author.bio}}',\n label: 'Bio',\n description: 'Their blurb, from the author record.',\n },\n {\n token: '{{author.image}}',\n label: 'Portrait',\n description: 'Their portrait or logo, from the author record.',\n },\n {\n token: '{{author.jobTitle}}',\n label: 'Role',\n description: 'Their job title; empty for an Organization author.',\n },\n {\n token: '{{author.worksFor}}',\n label: 'Organization',\n description: 'Who they write for; empty for an Organization author.',\n },\n {\n token: '{{author.url}}',\n label: 'Their own site',\n description:\n 'The url on their record — a personal site, not this page. Empty when ' +\n 'they have none.',\n },\n {\n token: '{{author.pageUrl}}',\n label: 'This page',\n description: 'The canonical address of the page you are designing.',\n },\n {\n token: '{{author.entryCount}}',\n label: 'Post count',\n description: 'How many entries they have published, across every collection.',\n },\n {\n token: '{{author.entryCountLabel}}',\n label: 'Post count, worded',\n description:\n '\"1 post\" or \"12 posts\" — pluralized for you, because a template has no ' +\n 'conditional to do it with.',\n },\n]\n\n/**\n * The `{{item.*}}` token for one field of the record a repeat is rendering,\n * optionally hopping one reference to a field of the referenced record\n * (AGL-180). Always takes the stable field id — display names are labels\n * only, so renaming a field never breaks a binding (AGL-578).\n */\nexport function repeatItemToken(\n fieldId: string,\n targetFieldId?: string,\n): string {\n return targetFieldId\n ? `{{item.${fieldId}.${targetFieldId}}}`\n : `{{item.${fieldId}}}`\n}\n"],"names":["ENTRY_TOKEN_CATALOG","token","label","description","COLLECTION_TOKEN_CATALOG","AUTHOR_TOKEN_CATALOG","repeatItemToken","fieldId","targetFieldId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,GAUD;;;;CAIC,GACD,OAAO,MAAMA,sBAA2D;IACtE;QAAEC,OAAO;QAAmBC,OAAO;QAASC,aAAa;IAAsB;IAC/E;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;;;;EAIA,GACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,qEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,2EACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;;;;;;;;EAQA,GACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,0EACA,wEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,wEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,yEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;CACD,CAAA;AAED;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,2BAAgE;IAC3E;QACEH,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACP,wEAAwE;QACxE,wEAAwE;QACxE,uEAAuE;QACvE,4DAA4D;QAC5DC,aACE;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACP,sEAAsE;QACtE,0EAA0E;QAC1E,kDAAkD;QAClDC,aACE;IACJ;CACD,CAAA;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,MAAME,uBAA4D;IACvE;QACEJ,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,0EACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,4EACA;IACJ;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,SAASG,gBACdC,OAAe,EACfC,aAAsB;IAEtB,OAAOA,gBACH,CAAC,OAAO,EAAED,QAAQ,CAAC,EAAEC,cAAc,EAAE,CAAC,GACtC,CAAC,OAAO,EAAED,QAAQ,EAAE,CAAC;AAC3B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/binding-token-catalog.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 * Browsable data-placeholder catalogs for the designer's insert picker\n * (AGL-583). Hand-typing `{{entry.title}}` stays the advanced path; these\n * catalogs give every token a friendly label + description so editors can\n * browse and insert instead of memorizing the grammar.\n *\n * The token STRINGS are owned elsewhere — `collectionEntryTokens`\n * (collection-entries.ts) and the tenant compose pipeline resolve them —\n * this module only names them for pickers. The spec cross-checks the entry\n * catalog against the resolver so the two can never drift.\n */\nexport interface BindingTokenCatalogEntry {\n /** The literal token inserted into the prop, e.g. `{{entry.title}}`. */\n token: string\n /** Friendly picker label, e.g. `Title`. */\n label: string\n /** One-line description shown as the option's secondary text. */\n description?: string\n}\n\n/**\n * `{{entry.*}}` tokens (AGL-105/551/582) — resolve per entry inside a\n * Collection entries block and page-wide on entry-template screens.\n * Mirrors {@link collectionEntryTokens}; the spec enforces the mirror.\n */\nexport const ENTRY_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[] = [\n { token: '{{entry.title}}', label: 'Title', description: 'The entry headline.' },\n {\n token: '{{entry.excerpt}}',\n label: 'Excerpt',\n description: 'Short summary text.',\n },\n {\n token: '{{entry.body}}',\n label: 'Body',\n description: 'The full entry body.',\n },\n {\n token: '{{entry.url}}',\n label: 'Link URL',\n description: 'Auto-route to the entry page.',\n },\n {\n token: '{{entry.date}}',\n label: 'Published date',\n description: 'Formatted publish date.',\n },\n /*\n Beside the readable date on purpose: a designer reaching for \"the date\" in\n a Video element's Publication date field has to see that the readable one\n is the wrong pick there, and why.\n */\n {\n token: '{{entry.publishedAt}}',\n label: 'Publish timestamp',\n description:\n 'The publish date and time in ISO 8601, for a field that needs a ' +\n 'machine-readable date, such as a Video element’s publication date.',\n },\n {\n token: '{{entry.author}}',\n label: 'Author',\n description: 'The byline set on the entry.',\n },\n {\n token: '{{entry.authorBio}}',\n label: 'Author bio',\n description: 'Blurb from the author’s record.',\n },\n {\n token: '{{entry.authorImage}}',\n label: 'Author portrait',\n description: 'Portrait or logo from the author’s record.',\n },\n {\n token: '{{entry.authorUrl}}',\n label: 'Author link',\n description: 'The author’s own page.',\n },\n {\n token: '{{entry.authorPageUrl}}',\n label: 'Author page',\n description:\n 'This author’s page on this site — everything they wrote, across every ' +\n 'collection. Separate from Author link, which is their own site.',\n },\n {\n token: '{{entry.slug}}',\n label: 'Slug',\n description: 'URL-safe entry identifier.',\n },\n /*\n Named \"Its collection…\" rather than \"Collection…\", which is what these\n describe and also exactly what the `{{collection.*}}` entries below are\n called. The picker groups options by heading, so the two sets sit apart —\n but a designer scanning it reads the LABEL, and two options reading\n \"Collection name\" three lines apart is a choice made by guessing. The\n pronoun is doing real work: on the one page where both resolve, they mean\n different collections.\n */\n {\n token: '{{entry.collection}}',\n label: 'Its collection',\n description:\n 'Which section this entry belongs to. Worth binding on a listing that ' +\n 'MIXES collections — an author page — where a card otherwise cannot ' +\n 'tell a release note from an essay.',\n },\n {\n token: '{{entry.collectionSlug}}',\n label: 'Its collection slug',\n description: 'That collection’s URL segment.',\n },\n {\n token: '{{entry.collectionUrl}}',\n label: 'Its collection link',\n description: 'The listing this entry belongs to.',\n },\n {\n token: '{{entry.coverImage}}',\n label: 'Cover image',\n description: 'Cover image URL.',\n },\n {\n token: '{{entry.coverVideo}}',\n label: 'Featured video',\n description:\n 'The featured video’s source — a library film, a video file link or ' +\n 'a video host’s link — for a Video element.',\n },\n {\n token: '{{entry.coverVideoDuration}}',\n label: 'Featured video length',\n description:\n 'How long the featured video runs, in seconds, for a Video element’s ' +\n 'duration field. Blank when the entry does not say.',\n },\n {\n token: '{{entry.category}}',\n label: 'Category',\n description: 'The entry category.',\n },\n {\n token: '{{entry.tags}}',\n label: 'Tags',\n description: 'Tags, comma separated.',\n },\n {\n token: '{{entry.seoTitle}}',\n label: 'SEO title',\n description: 'Search title; falls back to Title.',\n },\n {\n token: '{{entry.seoDescription}}',\n label: 'SEO description',\n description: 'Meta description; falls back to Excerpt.',\n },\n]\n\n/**\n * `{{collection.*}}` and `{{pagination.*}}` tokens (AGL-551/1321/1386) —\n * resolve on collection list/entry template screens (see the tenant compose\n * pipeline's collection tokens).\n *\n * The category and pagination tokens all resolve to the empty string where\n * they do not apply, so they are safe to bind unconditionally: ONE list\n * screen serves the bare listing, every `/page/{n}` and every\n * `/category/{slug}`, and a template has no runtime conditional to vary\n * itself with.\n */\nexport const COLLECTION_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[] = [\n {\n token: '{{collection.name}}',\n label: 'Collection name',\n description: 'Display name of the routed collection.',\n },\n {\n token: '{{collection.slug}}',\n label: 'Collection slug',\n description: 'URL slug of the routed collection.',\n },\n {\n token: '{{collection.category}}',\n label: 'Filtered category',\n description: 'Category the URL filtered on; empty when unfiltered.',\n },\n {\n token: '{{collection.categorySlug}}',\n label: 'Filtered category slug',\n description: 'That category’s URL segment; empty when unfiltered.',\n },\n {\n token: '{{pagination.page}}',\n label: 'Current page',\n description: 'Page number this URL is showing.',\n },\n {\n token: '{{pagination.totalPages}}',\n label: 'Total pages',\n // A listing bigger than one read cannot be counted honestly (AGL-3219):\n // the count and the entries were read at two different moments, and the\n // pager built from them disagreed with itself at the page boundary. It\n // still resolves, so a template binding it keeps rendering.\n description:\n 'Pages in the listing, after any category filter. Empty on a listing too large to count — bind the next link instead.',\n },\n {\n token: '{{pagination.prevUrl}}',\n label: 'Previous page link',\n description: 'Keeps the category; empty on the first page.',\n },\n {\n token: '{{pagination.nextUrl}}',\n label: 'Next page link',\n // The reliable \"is there more\" (AGL-3219): it is set from a read that\n // asked for one entry more than the page needed, so empty means there was\n // no such entry rather than that a total said so.\n description:\n 'Keeps the category; empty when there is nothing older to show.',\n },\n]\n\n/**\n * `{{author.*}}` tokens (AGL-2518) — resolve on an author's own page,\n * `/author/{slug}`.\n *\n * Empty everywhere else, like the category tokens above and for the same\n * reason: a template has no runtime conditional, so the tokens have to be the\n * thing that varies. A heading bound to `{{author.name}}` prints a name on an\n * author page and nothing anywhere else.\n *\n * The `{{pagination.*}}` tokens resolve HERE TOO, over this author's own\n * archive — deliberately the same four names a collection listing uses, so a\n * pager built once works on both.\n */\nexport const AUTHOR_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[] = [\n {\n token: '{{author.name}}',\n label: 'Name',\n description: 'The byline this page collects.',\n },\n {\n token: '{{author.bio}}',\n label: 'Bio',\n description: 'Their blurb, from the author record.',\n },\n {\n token: '{{author.image}}',\n label: 'Portrait',\n description: 'Their portrait or logo, from the author record.',\n },\n {\n token: '{{author.jobTitle}}',\n label: 'Role',\n description: 'Their job title; empty for an Organization author.',\n },\n {\n token: '{{author.worksFor}}',\n label: 'Organization',\n description: 'Who they write for; empty for an Organization author.',\n },\n {\n token: '{{author.url}}',\n label: 'Their own site',\n description:\n 'The url on their record — a personal site, not this page. Empty when ' +\n 'they have none.',\n },\n {\n token: '{{author.pageUrl}}',\n label: 'This page',\n description: 'The canonical address of the page you are designing.',\n },\n {\n token: '{{author.entryCount}}',\n label: 'Post count',\n description: 'How many entries they have published, across every collection.',\n },\n {\n token: '{{author.entryCountLabel}}',\n label: 'Post count, worded',\n description:\n '\"1 post\" or \"12 posts\" — pluralized for you, because a template has no ' +\n 'conditional to do it with.',\n },\n]\n\n/**\n * The `{{item.*}}` token for one field of the record a repeat is rendering,\n * optionally hopping one reference to a field of the referenced record\n * (AGL-180). Always takes the stable field id — display names are labels\n * only, so renaming a field never breaks a binding (AGL-578).\n */\nexport function repeatItemToken(\n fieldId: string,\n targetFieldId?: string,\n): string {\n return targetFieldId\n ? `{{item.${fieldId}.${targetFieldId}}}`\n : `{{item.${fieldId}}}`\n}\n\n/**\n * The record field type that holds an icon (AGL-4190): `{ iconId, iconPath }`,\n * the shape a reusable component's Icon property holds. Named here, in core,\n * because the plugin that keeps the records declares it and the Besigner's\n * Icon picker binds to it, and neither may import the other. Persisted on\n * field definitions — never rename.\n */\nexport const RECORD_ICON_FIELD_TYPE = 'icon'\n\n/** The part of a record's icon that is its SVG path (AGL-4190). */\nexport const RECORD_ICON_PATH_PART = 'iconPath'\n\n/**\n * The field id of a token that is nothing but one record field, `{{item.x}}`,\n * or `null` for anything else (a hop, words around it, another kind of token).\n */\nexport function matchWholeItemToken(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const match = /^\\s*\\{\\{\\s*item\\.([A-Za-z][A-Za-z0-9_]*)\\s*\\}\\}\\s*$/.exec(value)\n return match ? match[1] : null\n}\n"],"names":["ENTRY_TOKEN_CATALOG","token","label","description","COLLECTION_TOKEN_CATALOG","AUTHOR_TOKEN_CATALOG","repeatItemToken","fieldId","targetFieldId","RECORD_ICON_FIELD_TYPE","RECORD_ICON_PATH_PART","matchWholeItemToken","value","match","exec"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,GAUD;;;;CAIC,GACD,OAAO,MAAMA,sBAA2D;IACtE;QAAEC,OAAO;QAAmBC,OAAO;QAASC,aAAa;IAAsB;IAC/E;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;;;;EAIA,GACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,qEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,2EACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;;;;;;;;EAQA,GACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,0EACA,wEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,wEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,yEACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;CACD,CAAA;AAED;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,2BAAgE;IAC3E;QACEH,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACP,wEAAwE;QACxE,wEAAwE;QACxE,uEAAuE;QACvE,4DAA4D;QAC5DC,aACE;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACP,sEAAsE;QACtE,0EAA0E;QAC1E,kDAAkD;QAClDC,aACE;IACJ;CACD,CAAA;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,MAAME,uBAA4D;IACvE;QACEJ,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,0EACA;IACJ;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aAAa;IACf;IACA;QACEF,OAAO;QACPC,OAAO;QACPC,aACE,4EACA;IACJ;CACD,CAAA;AAED;;;;;CAKC,GACD,OAAO,SAASG,gBACdC,OAAe,EACfC,aAAsB;IAEtB,OAAOA,gBACH,CAAC,OAAO,EAAED,QAAQ,CAAC,EAAEC,cAAc,EAAE,CAAC,GACtC,CAAC,OAAO,EAAED,QAAQ,EAAE,CAAC;AAC3B;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,yBAAyB,OAAM;AAE5C,iEAAiE,GACjE,OAAO,MAAMC,wBAAwB,WAAU;AAE/C;;;CAGC,GACD,OAAO,SAASC,oBAAoBC,KAAc;IAChD,IAAI,OAAOA,UAAU,UAAU,OAAO;IACtC,MAAMC,QAAQ,sDAAsDC,IAAI,CAACF;IACzE,OAAOC,QAAQA,KAAK,CAAC,EAAE,GAAG;AAC5B"}
|
|
@@ -50,6 +50,11 @@ export declare const BUSINESS_SOCIAL_LINKS_MAX = 8;
|
|
|
50
50
|
* to leave its copy too, or the fallback would bring it straight back.
|
|
51
51
|
*/
|
|
52
52
|
export declare const BUSINESS_DETAILS_CLEARABLE_PATHS: readonly ["seo.entity.name", "seo.entity.slogan", "seo.entity.telephone", "seo.entity.email", "seo.entity.address.streetAddress", "seo.entity.address.addressLocality", "seo.entity.address.addressRegion", "seo.entity.address.postalCode", "seo.entity.address.addressCountry", "business.supportEmail", "business.address"];
|
|
53
|
+
/**
|
|
54
|
+
* {@link BUSINESS_DETAILS_CLEARABLE_PATHS} as a plain list: the native apps' Business details
|
|
55
|
+
* cards read it from the contracts, and so clear what the console clears.
|
|
56
|
+
*/
|
|
57
|
+
export declare const BUSINESS_DETAILS_CLEARABLE_PATH_LIST: readonly string[];
|
|
53
58
|
/** The host fields the business details read and write. */
|
|
54
59
|
export interface BusinessDetailsHost {
|
|
55
60
|
displayName?: string;
|
|
@@ -59,6 +59,10 @@ import { siteContactEmail } from "./host-tokens.js";
|
|
|
59
59
|
'business.supportEmail',
|
|
60
60
|
'business.address'
|
|
61
61
|
];
|
|
62
|
+
/**
|
|
63
|
+
* {@link BUSINESS_DETAILS_CLEARABLE_PATHS} as a plain list: the native apps' Business details
|
|
64
|
+
* cards read it from the contracts, and so clear what the console clears.
|
|
65
|
+
*/ export const BUSINESS_DETAILS_CLEARABLE_PATH_LIST = BUSINESS_DETAILS_CLEARABLE_PATHS;
|
|
62
66
|
const trimmed = (value)=>typeof value === 'string' ? value.trim() : '';
|
|
63
67
|
/**
|
|
64
68
|
* The host document as the Business details card is seeded with it: the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/business-details.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 { structuredAddressLine } from './business-profile'\nimport type { HostSeoEntity } from './content-authors'\nimport { siteContactEmail } from './host-tokens'\n\n/**\n * A site's BUSINESS DETAILS, entered in one place (AGL-4136).\n *\n * The business name, slogan, phone, email, postal address and social links\n * are entered on Setup → Business profile and nowhere else, and everything that uses\n * them reads that one place. The storage did not move, so no site's data had\n * to: each fact has one canonical path, and the older path that used to hold\n * it is kept as a read fallback.\n *\n * | fact | canonical | kept in step |\n * | ------------ | ----------------------------- | -------------------------- |\n * | name | `seo.entity.name` | falls back to `displayName` |\n * | slogan | `seo.entity.slogan` | |\n * | phone | `seo.entity.telephone` | |\n * | email | `seo.entity.email` | mirrored to `business.supportEmail` |\n * | address | `seo.entity.address.*` | mirrored, formatted, to `business.address` |\n * | social links | `business.socialLinks` | `seo.entity.sameAs` joins it when read |\n *\n * The two mirrors exist for the readers that have not moved yet: the native\n * apps read and write the `business` copies, so a save here keeps them\n * showing what the console shows until they follow.\n */\n\n/** The longest slogan a site may set, as the field and the structured data hold it. */\nexport const SITE_SLOGAN_MAX_LENGTH = 120\n\n/** The most social links a site keeps, as the editor allows them. */\nexport const BUSINESS_SOCIAL_LINKS_MAX = 8\n\n/**\n * The paths a Setup → Business profile save may take back to EMPTY.\n *\n * The form drops a cleared input from what it submits, and the write merges,\n * so without this a cleared phone would save nothing and report \"Saved!\".\n * Both mirrors are here as well: an email or address cleared on the card has\n * to leave its copy too, or the fallback would bring it straight back.\n */\nexport const BUSINESS_DETAILS_CLEARABLE_PATHS = [\n 'seo.entity.name',\n 'seo.entity.slogan',\n 'seo.entity.telephone',\n 'seo.entity.email',\n 'seo.entity.address.streetAddress',\n 'seo.entity.address.addressLocality',\n 'seo.entity.address.addressRegion',\n 'seo.entity.address.postalCode',\n 'seo.entity.address.addressCountry',\n 'business.supportEmail',\n 'business.address',\n] as const\n\n/** The host fields the business details read and write. */\nexport interface BusinessDetailsHost {\n displayName?: string\n seo?: {\n entity?: Pick<\n HostSeoEntity,\n 'name' | 'slogan' | 'telephone' | 'email' | 'address'\n > | null\n } | null\n business?: {\n supportEmail?: unknown\n address?: unknown\n socialLinks?: Array<{ label?: unknown; url?: unknown } | null> | null\n } | null\n}\n\nconst trimmed = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * The host document as the Business details card is seeded with it: the\n * site's one email in the Email field, so a site whose email so far lived\n * only in the one-block copy shows it, and clearing the field clears it.\n * Everything else is the document as stored. A new object; `host` is not\n * changed.\n */\nexport function businessDetailsSeed<T extends BusinessDetailsHost>(\n host: T | null | undefined,\n): T | null | undefined {\n if (!host) return host\n const email = siteContactEmail(host)\n if (!email || trimmed(host.seo?.entity?.email)) return host\n return {\n ...host,\n seo: { ...(host.seo ?? {}), entity: { ...(host.seo?.entity ?? {}), email } },\n }\n}\n\n/**\n * What a Setup → Business profile save writes, from what the card submitted and what\n * the document stores now (AGL-4136):\n *\n * - every text value trimmed;\n * - the email mirrored into `business.supportEmail`, `''` when it was cleared\n * (a clearable path, so the save deletes it);\n * - the structured address mirrored, as the one line every reader prints,\n * into `business.address` — but ONLY when the structured address changed.\n * A site whose address so far lives only in the one block keeps that block\n * through a save that never touched the address, rather than losing it to\n * an empty structured one;\n * - social links without an address dropped, each label and address trimmed,\n * up to {@link BUSINESS_SOCIAL_LINKS_MAX}.\n *\n * A new object: the form's values are not this function's to edit.\n */\nexport function businessDetailsWrite<T extends Record<string, unknown>>(\n fields: T,\n stored: BusinessDetailsHost | null | undefined,\n): T {\n const seo = { ...((fields?.['seo'] as Record<string, unknown>) ?? {}) }\n const entity = { ...((seo['entity'] as Record<string, unknown>) ?? {}) }\n for (const key of ['name', 'slogan', 'telephone', 'email'] as const) {\n if (typeof entity[key] === 'string') entity[key] = trimmed(entity[key])\n }\n if (entity['address'] && typeof entity['address'] === 'object') {\n const address = { ...(entity['address'] as Record<string, unknown>) }\n for (const [key, value] of Object.entries(address)) {\n if (typeof value === 'string') address[key] = trimmed(value)\n }\n entity['address'] = address\n }\n seo['entity'] = entity\n\n const business = { ...((fields?.['business'] as Record<string, unknown>) ?? {}) }\n const email = trimmed(entity['email'])\n if (email) business['supportEmail'] = email\n else if (trimmed(stored?.business?.supportEmail)) business['supportEmail'] = ''\n else delete business['supportEmail']\n\n const before = structuredAddressLine(stored?.seo?.entity?.address)\n const after = structuredAddressLine(\n entity['address'] as HostSeoEntity['address'] | undefined,\n )\n if (after !== before) {\n if (after) business['address'] = after\n else if (trimmed(stored?.business?.address)) business['address'] = ''\n else delete business['address']\n }\n\n if (Array.isArray(business['socialLinks'])) {\n business['socialLinks'] = (business['socialLinks'] as unknown[])\n .map((link) => link as { label?: unknown; url?: unknown } | null)\n .filter((link) => trimmed(link?.url))\n .slice(0, BUSINESS_SOCIAL_LINKS_MAX)\n .map((link) => ({ label: trimmed(link?.label), url: trimmed(link?.url) }))\n }\n\n return { ...fields, seo, business }\n}\n"],"names":["structuredAddressLine","siteContactEmail","SITE_SLOGAN_MAX_LENGTH","BUSINESS_SOCIAL_LINKS_MAX","BUSINESS_DETAILS_CLEARABLE_PATHS","trimmed","value","trim","businessDetailsSeed","host","email","seo","entity","businessDetailsWrite","fields","stored","key","address","Object","entries","business","supportEmail","before","after","Array","isArray","map","link","filter","url","slice","label"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/business-details.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 { structuredAddressLine } from './business-profile'\nimport type { HostSeoEntity } from './content-authors'\nimport { siteContactEmail } from './host-tokens'\n\n/**\n * A site's BUSINESS DETAILS, entered in one place (AGL-4136).\n *\n * The business name, slogan, phone, email, postal address and social links\n * are entered on Setup → Business profile and nowhere else, and everything that uses\n * them reads that one place. The storage did not move, so no site's data had\n * to: each fact has one canonical path, and the older path that used to hold\n * it is kept as a read fallback.\n *\n * | fact | canonical | kept in step |\n * | ------------ | ----------------------------- | -------------------------- |\n * | name | `seo.entity.name` | falls back to `displayName` |\n * | slogan | `seo.entity.slogan` | |\n * | phone | `seo.entity.telephone` | |\n * | email | `seo.entity.email` | mirrored to `business.supportEmail` |\n * | address | `seo.entity.address.*` | mirrored, formatted, to `business.address` |\n * | social links | `business.socialLinks` | `seo.entity.sameAs` joins it when read |\n *\n * The two mirrors exist for the readers that have not moved yet: the native\n * apps read and write the `business` copies, so a save here keeps them\n * showing what the console shows until they follow.\n */\n\n/** The longest slogan a site may set, as the field and the structured data hold it. */\nexport const SITE_SLOGAN_MAX_LENGTH = 120\n\n/** The most social links a site keeps, as the editor allows them. */\nexport const BUSINESS_SOCIAL_LINKS_MAX = 8\n\n/**\n * The paths a Setup → Business profile save may take back to EMPTY.\n *\n * The form drops a cleared input from what it submits, and the write merges,\n * so without this a cleared phone would save nothing and report \"Saved!\".\n * Both mirrors are here as well: an email or address cleared on the card has\n * to leave its copy too, or the fallback would bring it straight back.\n */\nexport const BUSINESS_DETAILS_CLEARABLE_PATHS = [\n 'seo.entity.name',\n 'seo.entity.slogan',\n 'seo.entity.telephone',\n 'seo.entity.email',\n 'seo.entity.address.streetAddress',\n 'seo.entity.address.addressLocality',\n 'seo.entity.address.addressRegion',\n 'seo.entity.address.postalCode',\n 'seo.entity.address.addressCountry',\n 'business.supportEmail',\n 'business.address',\n] as const\n\n/**\n * {@link BUSINESS_DETAILS_CLEARABLE_PATHS} as a plain list: the native apps' Business details\n * cards read it from the contracts, and so clear what the console clears.\n */\nexport const BUSINESS_DETAILS_CLEARABLE_PATH_LIST: readonly string[] =\n BUSINESS_DETAILS_CLEARABLE_PATHS\n\n/** The host fields the business details read and write. */\nexport interface BusinessDetailsHost {\n displayName?: string\n seo?: {\n entity?: Pick<\n HostSeoEntity,\n 'name' | 'slogan' | 'telephone' | 'email' | 'address'\n > | null\n } | null\n business?: {\n supportEmail?: unknown\n address?: unknown\n socialLinks?: Array<{ label?: unknown; url?: unknown } | null> | null\n } | null\n}\n\nconst trimmed = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * The host document as the Business details card is seeded with it: the\n * site's one email in the Email field, so a site whose email so far lived\n * only in the one-block copy shows it, and clearing the field clears it.\n * Everything else is the document as stored. A new object; `host` is not\n * changed.\n */\nexport function businessDetailsSeed<T extends BusinessDetailsHost>(\n host: T | null | undefined,\n): T | null | undefined {\n if (!host) return host\n const email = siteContactEmail(host)\n if (!email || trimmed(host.seo?.entity?.email)) return host\n return {\n ...host,\n seo: { ...(host.seo ?? {}), entity: { ...(host.seo?.entity ?? {}), email } },\n }\n}\n\n/**\n * What a Setup → Business profile save writes, from what the card submitted and what\n * the document stores now (AGL-4136):\n *\n * - every text value trimmed;\n * - the email mirrored into `business.supportEmail`, `''` when it was cleared\n * (a clearable path, so the save deletes it);\n * - the structured address mirrored, as the one line every reader prints,\n * into `business.address` — but ONLY when the structured address changed.\n * A site whose address so far lives only in the one block keeps that block\n * through a save that never touched the address, rather than losing it to\n * an empty structured one;\n * - social links without an address dropped, each label and address trimmed,\n * up to {@link BUSINESS_SOCIAL_LINKS_MAX}.\n *\n * A new object: the form's values are not this function's to edit.\n */\nexport function businessDetailsWrite<T extends Record<string, unknown>>(\n fields: T,\n stored: BusinessDetailsHost | null | undefined,\n): T {\n const seo = { ...((fields?.['seo'] as Record<string, unknown>) ?? {}) }\n const entity = { ...((seo['entity'] as Record<string, unknown>) ?? {}) }\n for (const key of ['name', 'slogan', 'telephone', 'email'] as const) {\n if (typeof entity[key] === 'string') entity[key] = trimmed(entity[key])\n }\n if (entity['address'] && typeof entity['address'] === 'object') {\n const address = { ...(entity['address'] as Record<string, unknown>) }\n for (const [key, value] of Object.entries(address)) {\n if (typeof value === 'string') address[key] = trimmed(value)\n }\n entity['address'] = address\n }\n seo['entity'] = entity\n\n const business = { ...((fields?.['business'] as Record<string, unknown>) ?? {}) }\n const email = trimmed(entity['email'])\n if (email) business['supportEmail'] = email\n else if (trimmed(stored?.business?.supportEmail)) business['supportEmail'] = ''\n else delete business['supportEmail']\n\n const before = structuredAddressLine(stored?.seo?.entity?.address)\n const after = structuredAddressLine(\n entity['address'] as HostSeoEntity['address'] | undefined,\n )\n if (after !== before) {\n if (after) business['address'] = after\n else if (trimmed(stored?.business?.address)) business['address'] = ''\n else delete business['address']\n }\n\n if (Array.isArray(business['socialLinks'])) {\n business['socialLinks'] = (business['socialLinks'] as unknown[])\n .map((link) => link as { label?: unknown; url?: unknown } | null)\n .filter((link) => trimmed(link?.url))\n .slice(0, BUSINESS_SOCIAL_LINKS_MAX)\n .map((link) => ({ label: trimmed(link?.label), url: trimmed(link?.url) }))\n }\n\n return { ...fields, seo, business }\n}\n"],"names":["structuredAddressLine","siteContactEmail","SITE_SLOGAN_MAX_LENGTH","BUSINESS_SOCIAL_LINKS_MAX","BUSINESS_DETAILS_CLEARABLE_PATHS","BUSINESS_DETAILS_CLEARABLE_PATH_LIST","trimmed","value","trim","businessDetailsSeed","host","email","seo","entity","businessDetailsWrite","fields","stored","key","address","Object","entries","business","supportEmail","before","after","Array","isArray","map","link","filter","url","slice","label"],"mappings":"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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/** The MCP endpoint, which is the protected resource. */
|
|
18
|
+
export declare const CONNECTOR_RESOURCE_PATH = "/api/mcp";
|
|
19
|
+
/** The consent page a person is sent to. A console page, behind sign-in. */
|
|
20
|
+
export declare const CONNECTOR_AUTHORIZE_PATH = "/oauth/authorize";
|
|
21
|
+
/** Dynamic client registration (RFC 7591). */
|
|
22
|
+
export declare const CONNECTOR_REGISTER_PATH = "/api/oauth/register";
|
|
23
|
+
/** Code and refresh exchange. */
|
|
24
|
+
export declare const CONNECTOR_TOKEN_PATH = "/api/oauth/token";
|
|
25
|
+
/** Revocation (RFC 7009). */
|
|
26
|
+
export declare const CONNECTOR_REVOKE_PATH = "/api/oauth/revoke";
|
|
27
|
+
/** RFC 9728 §3: the document for the server as a whole. */
|
|
28
|
+
export declare const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
|
|
29
|
+
/**
|
|
30
|
+
* RFC 9728 §3.1: the document for one resource, at the well-known prefix
|
|
31
|
+
* followed by the resource's path. What the 401 challenge names.
|
|
32
|
+
*/
|
|
33
|
+
export declare const MCP_PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource/api/mcp";
|
|
34
|
+
/** RFC 8414 §3. The issuer has no path, so neither does this. */
|
|
35
|
+
export declare const AUTHORIZATION_SERVER_METADATA_PATH = "/.well-known/oauth-authorization-server";
|
|
36
|
+
/**
|
|
37
|
+
* The MCP Server Card: a static description of the MCP endpoint that a client
|
|
38
|
+
* or a registry can read BEFORE connecting — where it is, which transport,
|
|
39
|
+
* which protocol revisions.
|
|
40
|
+
*
|
|
41
|
+
* SEP-2127 (MCP Server Cards, Final, Extensions Track) reserves
|
|
42
|
+
* `<streamable-http-url>/server-card` as the recommended location, and its
|
|
43
|
+
* discovery document advises against `.well-known` for cards, so this sits
|
|
44
|
+
* under the endpoint it describes rather than beside the OAuth documents.
|
|
45
|
+
* https://modelcontextprotocol.io/seps/2127-mcp-server-cards
|
|
46
|
+
*/
|
|
47
|
+
export declare const MCP_SERVER_CARD_PATH = "/api/mcp/server-card";
|
|
48
|
+
/** The card's media type, per the extension's `docs/discovery.md`. */
|
|
49
|
+
export declare const MCP_SERVER_CARD_MEDIA_TYPE = "application/mcp-server-card+json";
|
|
50
|
+
/**
|
|
51
|
+
* The `$schema` a card must carry. The extension's schema pins this exact
|
|
52
|
+
* URL (versioned by the `v1` segment, not by date).
|
|
53
|
+
*/
|
|
54
|
+
export declare const MCP_SERVER_CARD_SCHEMA = "https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json";
|
|
55
|
+
/**
|
|
56
|
+
* The three discovery documents the console serves, by EXACT path, and the
|
|
57
|
+
* route handler each is rewritten to. Exactly these: any other path under
|
|
58
|
+
* `/.well-known/` still answers 404, which is the posture the namespace is
|
|
59
|
+
* held to (AGL-3016).
|
|
60
|
+
*/
|
|
61
|
+
export declare const CONNECTOR_DISCOVERY_ROUTES: Readonly<Record<string, string>>;
|
|
62
|
+
/** The route handler serving `pathname`, or `null` when it is not one of the three. */
|
|
63
|
+
export declare function connectorDiscoveryRoute(pathname: string): string | null;
|
|
64
|
+
/** The resource identifier for the MCP endpoint on `origin`. */
|
|
65
|
+
export declare function connectorResourceFor(origin: string): string;
|
|
66
|
+
/** What a 401 from the MCP endpoint names, so a client can begin the walk. */
|
|
67
|
+
export declare function connectorResourceMetadataUrl(origin: string): string;
|
|
68
|
+
/** The authorization server's own document (RFC 8414) on `origin`. */
|
|
69
|
+
export declare function connectorAuthorizationServerMetadataUrl(origin: string): string;
|
|
70
|
+
/** The MCP Server Card (SEP-2127) on `origin`. */
|
|
71
|
+
export declare function mcpServerCardUrl(origin: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* The card's `name`: reverse-DNS of the host that serves the endpoint, then
|
|
74
|
+
* `/mcp`. The card schema (and the MCP Registry's `server.json`) require
|
|
75
|
+
* `namespace/name` matching `^[a-zA-Z0-9.-]+/[a-zA-Z0-9._-]+$`, and a
|
|
76
|
+
* reverse-DNS namespace is the one a registry can verify against the domain,
|
|
77
|
+
* so a self-hosted console names itself rather than borrowing ours.
|
|
78
|
+
* `app.aglyn.com` → `com.aglyn.app/mcp`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function mcpServerCardName(origin: string): string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /*==========================================
|
|
17
|
+
* WHERE A CONNECTOR FINDS THE CONSOLE'S SIGN-IN (AGL-4225).
|
|
18
|
+
*
|
|
19
|
+
* An MCP client that is handed `<console>/api/mcp` and answered 401 reads the
|
|
20
|
+
* protected-resource document the challenge names (RFC 9728), then the
|
|
21
|
+
* authorization-server document (RFC 8414), and from there registers, sends
|
|
22
|
+
* the person to the consent page and trades the code for credentials.
|
|
23
|
+
*
|
|
24
|
+
* Every address in that walk is here, in one module with no imports, because
|
|
25
|
+
* the edge middleware has to know the three discovery documents by exact path
|
|
26
|
+
* (it 404s the rest of `/.well-known/*`) and must not pull the server-side
|
|
27
|
+
* credential code into the edge bundle to learn them. The documents
|
|
28
|
+
* themselves are built by `connector-oauth.ts` in the data layer, from these
|
|
29
|
+
* same constants.
|
|
30
|
+
*
|
|
31
|
+
* Nothing here names a host: these are paths, and the functions below take
|
|
32
|
+
* the origin as an argument. Which origin is decided in ONE place, the
|
|
33
|
+
* console's `connectorOrigin` — the configured console URL
|
|
34
|
+
* (`NEXT_PUBLIC_CONSOLE_URL`) when it is set, and only otherwise the host the
|
|
35
|
+
* deployment's proxy reports. A request header cannot choose the issuer of a
|
|
36
|
+
* deployment that has configured its console URL.
|
|
37
|
+
*==========================================*/ /** The MCP endpoint, which is the protected resource. */ export const CONNECTOR_RESOURCE_PATH = '/api/mcp';
|
|
38
|
+
/** The consent page a person is sent to. A console page, behind sign-in. */ export const CONNECTOR_AUTHORIZE_PATH = '/oauth/authorize';
|
|
39
|
+
/** Dynamic client registration (RFC 7591). */ export const CONNECTOR_REGISTER_PATH = '/api/oauth/register';
|
|
40
|
+
/** Code and refresh exchange. */ export const CONNECTOR_TOKEN_PATH = '/api/oauth/token';
|
|
41
|
+
/** Revocation (RFC 7009). */ export const CONNECTOR_REVOKE_PATH = '/api/oauth/revoke';
|
|
42
|
+
/** RFC 9728 §3: the document for the server as a whole. */ export const PROTECTED_RESOURCE_METADATA_PATH = '/.well-known/oauth-protected-resource';
|
|
43
|
+
/**
|
|
44
|
+
* RFC 9728 §3.1: the document for one resource, at the well-known prefix
|
|
45
|
+
* followed by the resource's path. What the 401 challenge names.
|
|
46
|
+
*/ export const MCP_PROTECTED_RESOURCE_METADATA_PATH = `${PROTECTED_RESOURCE_METADATA_PATH}${CONNECTOR_RESOURCE_PATH}`;
|
|
47
|
+
/** RFC 8414 §3. The issuer has no path, so neither does this. */ export const AUTHORIZATION_SERVER_METADATA_PATH = '/.well-known/oauth-authorization-server';
|
|
48
|
+
/**
|
|
49
|
+
* The MCP Server Card: a static description of the MCP endpoint that a client
|
|
50
|
+
* or a registry can read BEFORE connecting — where it is, which transport,
|
|
51
|
+
* which protocol revisions.
|
|
52
|
+
*
|
|
53
|
+
* SEP-2127 (MCP Server Cards, Final, Extensions Track) reserves
|
|
54
|
+
* `<streamable-http-url>/server-card` as the recommended location, and its
|
|
55
|
+
* discovery document advises against `.well-known` for cards, so this sits
|
|
56
|
+
* under the endpoint it describes rather than beside the OAuth documents.
|
|
57
|
+
* https://modelcontextprotocol.io/seps/2127-mcp-server-cards
|
|
58
|
+
*/ export const MCP_SERVER_CARD_PATH = `${CONNECTOR_RESOURCE_PATH}/server-card`;
|
|
59
|
+
/** The card's media type, per the extension's `docs/discovery.md`. */ export const MCP_SERVER_CARD_MEDIA_TYPE = 'application/mcp-server-card+json';
|
|
60
|
+
/**
|
|
61
|
+
* The `$schema` a card must carry. The extension's schema pins this exact
|
|
62
|
+
* URL (versioned by the `v1` segment, not by date).
|
|
63
|
+
*/ export const MCP_SERVER_CARD_SCHEMA = 'https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json';
|
|
64
|
+
/**
|
|
65
|
+
* The three discovery documents the console serves, by EXACT path, and the
|
|
66
|
+
* route handler each is rewritten to. Exactly these: any other path under
|
|
67
|
+
* `/.well-known/` still answers 404, which is the posture the namespace is
|
|
68
|
+
* held to (AGL-3016).
|
|
69
|
+
*/ export const CONNECTOR_DISCOVERY_ROUTES = {
|
|
70
|
+
[PROTECTED_RESOURCE_METADATA_PATH]: '/api/oauth/metadata/protected-resource',
|
|
71
|
+
[MCP_PROTECTED_RESOURCE_METADATA_PATH]: '/api/oauth/metadata/protected-resource',
|
|
72
|
+
[AUTHORIZATION_SERVER_METADATA_PATH]: '/api/oauth/metadata/authorization-server'
|
|
73
|
+
};
|
|
74
|
+
/** The route handler serving `pathname`, or `null` when it is not one of the three. */ export function connectorDiscoveryRoute(pathname) {
|
|
75
|
+
return Object.prototype.hasOwnProperty.call(CONNECTOR_DISCOVERY_ROUTES, pathname) ? CONNECTOR_DISCOVERY_ROUTES[pathname] : null;
|
|
76
|
+
}
|
|
77
|
+
/** The resource identifier for the MCP endpoint on `origin`. */ export function connectorResourceFor(origin) {
|
|
78
|
+
return `${origin}${CONNECTOR_RESOURCE_PATH}`;
|
|
79
|
+
}
|
|
80
|
+
/** What a 401 from the MCP endpoint names, so a client can begin the walk. */ export function connectorResourceMetadataUrl(origin) {
|
|
81
|
+
return `${origin}${MCP_PROTECTED_RESOURCE_METADATA_PATH}`;
|
|
82
|
+
}
|
|
83
|
+
/** The authorization server's own document (RFC 8414) on `origin`. */ export function connectorAuthorizationServerMetadataUrl(origin) {
|
|
84
|
+
return `${origin}${AUTHORIZATION_SERVER_METADATA_PATH}`;
|
|
85
|
+
}
|
|
86
|
+
/** The MCP Server Card (SEP-2127) on `origin`. */ export function mcpServerCardUrl(origin) {
|
|
87
|
+
return `${origin}${MCP_SERVER_CARD_PATH}`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The card's `name`: reverse-DNS of the host that serves the endpoint, then
|
|
91
|
+
* `/mcp`. The card schema (and the MCP Registry's `server.json`) require
|
|
92
|
+
* `namespace/name` matching `^[a-zA-Z0-9.-]+/[a-zA-Z0-9._-]+$`, and a
|
|
93
|
+
* reverse-DNS namespace is the one a registry can verify against the domain,
|
|
94
|
+
* so a self-hosted console names itself rather than borrowing ours.
|
|
95
|
+
* `app.aglyn.com` → `com.aglyn.app/mcp`.
|
|
96
|
+
*/ export function mcpServerCardName(origin) {
|
|
97
|
+
let host;
|
|
98
|
+
try {
|
|
99
|
+
host = new URL(origin).hostname;
|
|
100
|
+
} catch (unused) {
|
|
101
|
+
host = '';
|
|
102
|
+
}
|
|
103
|
+
const namespace = host.split('.').filter(Boolean).reverse().join('.').replace(/[^a-zA-Z0-9.-]/g, '-');
|
|
104
|
+
return `${namespace || 'local'}/mcp`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=connector-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/connector-discovery.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 * WHERE A CONNECTOR FINDS THE CONSOLE'S SIGN-IN (AGL-4225).\n *\n * An MCP client that is handed `<console>/api/mcp` and answered 401 reads the\n * protected-resource document the challenge names (RFC 9728), then the\n * authorization-server document (RFC 8414), and from there registers, sends\n * the person to the consent page and trades the code for credentials.\n *\n * Every address in that walk is here, in one module with no imports, because\n * the edge middleware has to know the three discovery documents by exact path\n * (it 404s the rest of `/.well-known/*`) and must not pull the server-side\n * credential code into the edge bundle to learn them. The documents\n * themselves are built by `connector-oauth.ts` in the data layer, from these\n * same constants.\n *\n * Nothing here names a host: these are paths, and the functions below take\n * the origin as an argument. Which origin is decided in ONE place, the\n * console's `connectorOrigin` — the configured console URL\n * (`NEXT_PUBLIC_CONSOLE_URL`) when it is set, and only otherwise the host the\n * deployment's proxy reports. A request header cannot choose the issuer of a\n * deployment that has configured its console URL.\n *==========================================*/\n\n/** The MCP endpoint, which is the protected resource. */\nexport const CONNECTOR_RESOURCE_PATH = '/api/mcp'\n\n/** The consent page a person is sent to. A console page, behind sign-in. */\nexport const CONNECTOR_AUTHORIZE_PATH = '/oauth/authorize'\n\n/** Dynamic client registration (RFC 7591). */\nexport const CONNECTOR_REGISTER_PATH = '/api/oauth/register'\n\n/** Code and refresh exchange. */\nexport const CONNECTOR_TOKEN_PATH = '/api/oauth/token'\n\n/** Revocation (RFC 7009). */\nexport const CONNECTOR_REVOKE_PATH = '/api/oauth/revoke'\n\n/** RFC 9728 §3: the document for the server as a whole. */\nexport const PROTECTED_RESOURCE_METADATA_PATH = '/.well-known/oauth-protected-resource'\n\n/**\n * RFC 9728 §3.1: the document for one resource, at the well-known prefix\n * followed by the resource's path. What the 401 challenge names.\n */\nexport const MCP_PROTECTED_RESOURCE_METADATA_PATH = `${PROTECTED_RESOURCE_METADATA_PATH}${CONNECTOR_RESOURCE_PATH}`\n\n/** RFC 8414 §3. The issuer has no path, so neither does this. */\nexport const AUTHORIZATION_SERVER_METADATA_PATH = '/.well-known/oauth-authorization-server'\n\n/**\n * The MCP Server Card: a static description of the MCP endpoint that a client\n * or a registry can read BEFORE connecting — where it is, which transport,\n * which protocol revisions.\n *\n * SEP-2127 (MCP Server Cards, Final, Extensions Track) reserves\n * `<streamable-http-url>/server-card` as the recommended location, and its\n * discovery document advises against `.well-known` for cards, so this sits\n * under the endpoint it describes rather than beside the OAuth documents.\n * https://modelcontextprotocol.io/seps/2127-mcp-server-cards\n */\nexport const MCP_SERVER_CARD_PATH = `${CONNECTOR_RESOURCE_PATH}/server-card`\n\n/** The card's media type, per the extension's `docs/discovery.md`. */\nexport const MCP_SERVER_CARD_MEDIA_TYPE = 'application/mcp-server-card+json'\n\n/**\n * The `$schema` a card must carry. The extension's schema pins this exact\n * URL (versioned by the `v1` segment, not by date).\n */\nexport const MCP_SERVER_CARD_SCHEMA =\n 'https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json'\n\n/**\n * The three discovery documents the console serves, by EXACT path, and the\n * route handler each is rewritten to. Exactly these: any other path under\n * `/.well-known/` still answers 404, which is the posture the namespace is\n * held to (AGL-3016).\n */\nexport const CONNECTOR_DISCOVERY_ROUTES: Readonly<Record<string, string>> = {\n [PROTECTED_RESOURCE_METADATA_PATH]: '/api/oauth/metadata/protected-resource',\n [MCP_PROTECTED_RESOURCE_METADATA_PATH]: '/api/oauth/metadata/protected-resource',\n [AUTHORIZATION_SERVER_METADATA_PATH]: '/api/oauth/metadata/authorization-server',\n}\n\n/** The route handler serving `pathname`, or `null` when it is not one of the three. */\nexport function connectorDiscoveryRoute(pathname: string): string | null {\n return Object.prototype.hasOwnProperty.call(CONNECTOR_DISCOVERY_ROUTES, pathname)\n ? CONNECTOR_DISCOVERY_ROUTES[pathname]\n : null\n}\n\n/** The resource identifier for the MCP endpoint on `origin`. */\nexport function connectorResourceFor(origin: string): string {\n return `${origin}${CONNECTOR_RESOURCE_PATH}`\n}\n\n/** What a 401 from the MCP endpoint names, so a client can begin the walk. */\nexport function connectorResourceMetadataUrl(origin: string): string {\n return `${origin}${MCP_PROTECTED_RESOURCE_METADATA_PATH}`\n}\n\n/** The authorization server's own document (RFC 8414) on `origin`. */\nexport function connectorAuthorizationServerMetadataUrl(origin: string): string {\n return `${origin}${AUTHORIZATION_SERVER_METADATA_PATH}`\n}\n\n/** The MCP Server Card (SEP-2127) on `origin`. */\nexport function mcpServerCardUrl(origin: string): string {\n return `${origin}${MCP_SERVER_CARD_PATH}`\n}\n\n/**\n * The card's `name`: reverse-DNS of the host that serves the endpoint, then\n * `/mcp`. The card schema (and the MCP Registry's `server.json`) require\n * `namespace/name` matching `^[a-zA-Z0-9.-]+/[a-zA-Z0-9._-]+$`, and a\n * reverse-DNS namespace is the one a registry can verify against the domain,\n * so a self-hosted console names itself rather than borrowing ours.\n * `app.aglyn.com` → `com.aglyn.app/mcp`.\n */\nexport function mcpServerCardName(origin: string): string {\n let host: string\n try {\n host = new URL(origin).hostname\n } catch {\n host = ''\n }\n const namespace = host\n .split('.')\n .filter(Boolean)\n .reverse()\n .join('.')\n .replace(/[^a-zA-Z0-9.-]/g, '-')\n return `${namespace || 'local'}/mcp`\n}\n"],"names":["CONNECTOR_RESOURCE_PATH","CONNECTOR_AUTHORIZE_PATH","CONNECTOR_REGISTER_PATH","CONNECTOR_TOKEN_PATH","CONNECTOR_REVOKE_PATH","PROTECTED_RESOURCE_METADATA_PATH","MCP_PROTECTED_RESOURCE_METADATA_PATH","AUTHORIZATION_SERVER_METADATA_PATH","MCP_SERVER_CARD_PATH","MCP_SERVER_CARD_MEDIA_TYPE","MCP_SERVER_CARD_SCHEMA","CONNECTOR_DISCOVERY_ROUTES","connectorDiscoveryRoute","pathname","Object","prototype","hasOwnProperty","call","connectorResourceFor","origin","connectorResourceMetadataUrl","connectorAuthorizationServerMetadataUrl","mcpServerCardUrl","mcpServerCardName","host","URL","hostname","namespace","split","filter","Boolean","reverse","join","replace"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;4CAqB4C,GAE5C,uDAAuD,GACvD,OAAO,MAAMA,0BAA0B,WAAU;AAEjD,0EAA0E,GAC1E,OAAO,MAAMC,2BAA2B,mBAAkB;AAE1D,4CAA4C,GAC5C,OAAO,MAAMC,0BAA0B,sBAAqB;AAE5D,+BAA+B,GAC/B,OAAO,MAAMC,uBAAuB,mBAAkB;AAEtD,2BAA2B,GAC3B,OAAO,MAAMC,wBAAwB,oBAAmB;AAExD,yDAAyD,GACzD,OAAO,MAAMC,mCAAmC,wCAAuC;AAEvF;;;CAGC,GACD,OAAO,MAAMC,uCAAuC,GAAGD,mCAAmCL,yBAAyB,CAAA;AAEnH,+DAA+D,GAC/D,OAAO,MAAMO,qCAAqC,0CAAyC;AAE3F;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,uBAAuB,GAAGR,wBAAwB,YAAY,CAAC,CAAA;AAE5E,oEAAoE,GACpE,OAAO,MAAMS,6BAA6B,mCAAkC;AAE5E;;;CAGC,GACD,OAAO,MAAMC,yBACX,4EAA2E;AAE7E;;;;;CAKC,GACD,OAAO,MAAMC,6BAA+D;IAC1E,CAACN,iCAAiC,EAAE;IACpC,CAACC,qCAAqC,EAAE;IACxC,CAACC,mCAAmC,EAAE;AACxC,EAAC;AAED,qFAAqF,GACrF,OAAO,SAASK,wBAAwBC,QAAgB;IACtD,OAAOC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACN,4BAA4BE,YACpEF,0BAA0B,CAACE,SAAS,GACpC;AACN;AAEA,8DAA8D,GAC9D,OAAO,SAASK,qBAAqBC,MAAc;IACjD,OAAO,GAAGA,SAASnB,yBAAyB;AAC9C;AAEA,4EAA4E,GAC5E,OAAO,SAASoB,6BAA6BD,MAAc;IACzD,OAAO,GAAGA,SAASb,sCAAsC;AAC3D;AAEA,oEAAoE,GACpE,OAAO,SAASe,wCAAwCF,MAAc;IACpE,OAAO,GAAGA,SAASZ,oCAAoC;AACzD;AAEA,gDAAgD,GAChD,OAAO,SAASe,iBAAiBH,MAAc;IAC7C,OAAO,GAAGA,SAASX,sBAAsB;AAC3C;AAEA;;;;;;;CAOC,GACD,OAAO,SAASe,kBAAkBJ,MAAc;IAC9C,IAAIK;IACJ,IAAI;QACFA,OAAO,IAAIC,IAAIN,QAAQO,QAAQ;IACjC,EAAE,eAAM;QACNF,OAAO;IACT;IACA,MAAMG,YAAYH,KACfI,KAAK,CAAC,KACNC,MAAM,CAACC,SACPC,OAAO,GACPC,IAAI,CAAC,KACLC,OAAO,CAAC,mBAAmB;IAC9B,OAAO,GAAGN,aAAa,QAAQ,IAAI,CAAC;AACtC"}
|
|
@@ -14,35 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
/**
|
|
18
|
-
* Contacts CRM v2 (AGL-2595): the records that sit BESIDE a contact.
|
|
19
|
-
*
|
|
20
|
-
* v1 is one collection — `contacts` — and everything a holder knows about a
|
|
21
|
-
* person lives in that holder's facet on the shared row. That shape is right
|
|
22
|
-
* for the person and wrong for everything a sales team keeps AROUND the
|
|
23
|
-
* person: a company is known by several contacts, a deal moves through
|
|
24
|
-
* stages on its own clock, a task is due whether or not anybody opens the
|
|
25
|
-
* contact it hangs off, and an activity log grows past anything a facet
|
|
26
|
-
* should carry. So each of those is a collection of its own under
|
|
27
|
-
* `orgs/{orgId}/`, pointing back at the contact by id.
|
|
28
|
-
*
|
|
29
|
-
* ## One scope model, not a second one
|
|
30
|
-
*
|
|
31
|
-
* Every collection here carries `visibleTo`, the same array `contacts`
|
|
32
|
-
* carries, and is stamped the same way — {@link crmScopeTokens} is the
|
|
33
|
-
* contact create path's expression, exported so that no creator computes its
|
|
34
|
-
* own. The rules gate all six on the contacts predicate (`canReadScopedPeople`,
|
|
35
|
-
* `data.manage`), because a deal or a call log is a fact about a person and
|
|
36
|
-
* discloses exactly what the contact row would.
|
|
37
|
-
*
|
|
38
|
-
* What these collections do NOT have is the facet map. A contact is shared
|
|
39
|
-
* across holders because one human is one row; a company, deal or task is
|
|
40
|
-
* one holder's record from the moment it is created, so `visibleTo` alone
|
|
41
|
-
* says who may see it and there is nothing to split per holder.
|
|
42
|
-
*
|
|
43
|
-
* Pure data module: types, constants and the small helpers every surface
|
|
44
|
-
* would otherwise write for itself. No Firestore, no React.
|
|
45
|
-
*/
|
|
46
17
|
import { type AglynPostalAddress } from '../foundation/definitions/contact.types';
|
|
47
18
|
import type { OrgCrmAssignmentRule } from '../foundation/definitions/org-billing.types';
|
|
48
19
|
import { type ConsentGroup } from './consent-groups';
|
|
@@ -1331,9 +1302,25 @@ export declare const PUBLIC_MAILBOX_DOMAINS: ReadonlySet<string>;
|
|
|
1331
1302
|
export declare function isPublicMailboxDomain(domainOrEmail: unknown): boolean;
|
|
1332
1303
|
/**
|
|
1333
1304
|
* The company domain an email address implies, or `null` when it implies
|
|
1334
|
-
* none — a malformed address,
|
|
1305
|
+
* none — a malformed address, one at a public mailbox provider, or one at a
|
|
1306
|
+
* disposable-mailbox service (AGL-4230): an inbox that expires in ten
|
|
1307
|
+
* minutes belongs to nobody, let alone a business.
|
|
1335
1308
|
*/
|
|
1336
1309
|
export declare function companyDomainForEmail(email: unknown): string | null;
|
|
1310
|
+
/**
|
|
1311
|
+
* Whether a company may be CREATED from this domain on its own (AGL-4230),
|
|
1312
|
+
* as opposed to linked to one that already exists.
|
|
1313
|
+
*
|
|
1314
|
+
* {@link companyDomainForEmail} has already turned away public and
|
|
1315
|
+
* disposable mailboxes. What it lets through and this does not is a school
|
|
1316
|
+
* or a university: a student's address at `k12.ipsd.org` or
|
|
1317
|
+
* `aluno.educa.go.gov.br` is a real organisation's domain, but the person
|
|
1318
|
+
* signing up is not that organisation's buyer, and minting "K12" or "Aluno"
|
|
1319
|
+
* from every pupil who tries the product fills the company list with
|
|
1320
|
+
* schools. So a school domain still LINKS to a company somebody created on
|
|
1321
|
+
* purpose, and is never minted into one by the capture door.
|
|
1322
|
+
*/
|
|
1323
|
+
export declare function companyDomainMintable(domain: unknown): boolean;
|
|
1337
1324
|
/**
|
|
1338
1325
|
* The name a company minted from a domain starts with: the first label with
|
|
1339
1326
|
* a capital — `acme.com` → `Acme`, `initech.co.uk` → `Initech`.
|
package/src/lib/app-utils/crm.js
CHANGED
|
@@ -42,7 +42,8 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
42
42
|
*
|
|
43
43
|
* Pure data module: types, constants and the small helpers every surface
|
|
44
44
|
* would otherwise write for itself. No Firestore, no React.
|
|
45
|
-
*/ import {
|
|
45
|
+
*/ import { isDisposableEmailDomain } from "@aglyn/shared-util-email/disposable-email-domains";
|
|
46
|
+
import { normalizeAddress, normalizePhone } from "../foundation/definitions/contact.types.js";
|
|
46
47
|
import { consentGroupScope, soloConsentGroup } from "./consent-groups.js";
|
|
47
48
|
import { CONTACT_LIFECYCLE_STAGES, CRM_TASK_KINDS, isContactLifecycleStage } from "./crm-kinds.js";
|
|
48
49
|
import { CONTACT_ALTERNATE_EMAILS_FIELD, CONTACT_FACETS_FIELD, composeContactName, normalizeContactEmail, readContactFacet } from "./contacts.js";
|
|
@@ -1439,7 +1440,104 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
|
|
|
1439
1440
|
'laposte.net',
|
|
1440
1441
|
't-online.de',
|
|
1441
1442
|
'libero.it',
|
|
1442
|
-
'bigpond.com'
|
|
1443
|
+
'bigpond.com',
|
|
1444
|
+
// More of the free providers people sign up with (AGL-4230): Russia and
|
|
1445
|
+
// the CIS, central and eastern Europe, the rest of western Europe, Latin
|
|
1446
|
+
// America, and Asia.
|
|
1447
|
+
'mail.ru',
|
|
1448
|
+
'inbox.ru',
|
|
1449
|
+
'list.ru',
|
|
1450
|
+
'bk.ru',
|
|
1451
|
+
'internet.ru',
|
|
1452
|
+
'ya.ru',
|
|
1453
|
+
'yandex.ua',
|
|
1454
|
+
'yandex.by',
|
|
1455
|
+
'yandex.kz',
|
|
1456
|
+
'rambler.ru',
|
|
1457
|
+
'ukr.net',
|
|
1458
|
+
'i.ua',
|
|
1459
|
+
'abv.bg',
|
|
1460
|
+
'seznam.cz',
|
|
1461
|
+
'centrum.cz',
|
|
1462
|
+
'wp.pl',
|
|
1463
|
+
'o2.pl',
|
|
1464
|
+
'onet.pl',
|
|
1465
|
+
'interia.pl',
|
|
1466
|
+
'inbox.lv',
|
|
1467
|
+
'gmx.at',
|
|
1468
|
+
'gmx.ch',
|
|
1469
|
+
'gmx.fr',
|
|
1470
|
+
'gmx.es',
|
|
1471
|
+
'freenet.de',
|
|
1472
|
+
'posteo.de',
|
|
1473
|
+
'mailbox.org',
|
|
1474
|
+
'tutanota.de',
|
|
1475
|
+
'tutamail.com',
|
|
1476
|
+
'virgilio.it',
|
|
1477
|
+
'alice.it',
|
|
1478
|
+
'tiscali.it',
|
|
1479
|
+
'sfr.fr',
|
|
1480
|
+
'wanadoo.fr',
|
|
1481
|
+
'bluewin.ch',
|
|
1482
|
+
'telenet.be',
|
|
1483
|
+
'skynet.be',
|
|
1484
|
+
'ziggo.nl',
|
|
1485
|
+
'kpnmail.nl',
|
|
1486
|
+
'home.nl',
|
|
1487
|
+
'planet.nl',
|
|
1488
|
+
'hotmail.es',
|
|
1489
|
+
'hotmail.com.br',
|
|
1490
|
+
'outlook.es',
|
|
1491
|
+
'outlook.fr',
|
|
1492
|
+
'outlook.de',
|
|
1493
|
+
'outlook.it',
|
|
1494
|
+
'outlook.com.br',
|
|
1495
|
+
'live.fr',
|
|
1496
|
+
'live.nl',
|
|
1497
|
+
'live.it',
|
|
1498
|
+
'yahoo.es',
|
|
1499
|
+
'yahoo.it',
|
|
1500
|
+
'yahoo.com.br',
|
|
1501
|
+
'yahoo.com.mx',
|
|
1502
|
+
'yahoo.com.ar',
|
|
1503
|
+
'yahoo.co.jp',
|
|
1504
|
+
'yahoo.co.id',
|
|
1505
|
+
'yahoo.com.ph',
|
|
1506
|
+
'yahoo.com.sg',
|
|
1507
|
+
'yahoo.in',
|
|
1508
|
+
'aol.co.uk',
|
|
1509
|
+
'uol.com.br',
|
|
1510
|
+
'bol.com.br',
|
|
1511
|
+
'terra.com.br',
|
|
1512
|
+
'ig.com.br',
|
|
1513
|
+
'sohu.com',
|
|
1514
|
+
'aliyun.com',
|
|
1515
|
+
'foxmail.com',
|
|
1516
|
+
'yeah.net',
|
|
1517
|
+
'139.com',
|
|
1518
|
+
'daum.net',
|
|
1519
|
+
'nate.com',
|
|
1520
|
+
// Generic mailboxes from the mail.com family and the like.
|
|
1521
|
+
'email.com',
|
|
1522
|
+
'usa.com',
|
|
1523
|
+
'myself.com',
|
|
1524
|
+
'inbox.com',
|
|
1525
|
+
// Subscriber mailboxes at more US, Canadian, Australian and New Zealand
|
|
1526
|
+
// internet providers.
|
|
1527
|
+
'roadrunner.com',
|
|
1528
|
+
'twc.com',
|
|
1529
|
+
'mediacombb.net',
|
|
1530
|
+
'suddenlink.net',
|
|
1531
|
+
'embarqmail.com',
|
|
1532
|
+
'q.com',
|
|
1533
|
+
'cableone.net',
|
|
1534
|
+
'rogers.com',
|
|
1535
|
+
'telus.net',
|
|
1536
|
+
'videotron.ca',
|
|
1537
|
+
'cogeco.ca',
|
|
1538
|
+
'bigpond.net.au',
|
|
1539
|
+
'optusnet.com.au',
|
|
1540
|
+
'xtra.co.nz'
|
|
1443
1541
|
]);
|
|
1444
1542
|
/**
|
|
1445
1543
|
* Whether a domain — or the domain of an address — is one of the
|
|
@@ -1452,7 +1550,9 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
|
|
|
1452
1550
|
}
|
|
1453
1551
|
/**
|
|
1454
1552
|
* The company domain an email address implies, or `null` when it implies
|
|
1455
|
-
* none — a malformed address,
|
|
1553
|
+
* none — a malformed address, one at a public mailbox provider, or one at a
|
|
1554
|
+
* disposable-mailbox service (AGL-4230): an inbox that expires in ten
|
|
1555
|
+
* minutes belongs to nobody, let alone a business.
|
|
1456
1556
|
*/ export function companyDomainForEmail(email) {
|
|
1457
1557
|
const value = String(email != null ? email : '').trim().toLowerCase();
|
|
1458
1558
|
const at = value.lastIndexOf('@');
|
|
@@ -1460,8 +1560,44 @@ const blank = (value)=>value === null || typeof value === 'string' && value.trim
|
|
|
1460
1560
|
if (/[\s@]/.test(value.slice(0, at))) return null;
|
|
1461
1561
|
const domain = normalizeCompanyDomain(value.slice(at + 1));
|
|
1462
1562
|
if (!domain || PUBLIC_MAILBOX_DOMAINS.has(domain)) return null;
|
|
1563
|
+
if (isDisposableEmailDomain(domain)) return null;
|
|
1463
1564
|
return domain;
|
|
1464
1565
|
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Labels that mark a school's or a university's mailbox: `k12`, `edu` and
|
|
1568
|
+
* the academic `ac` (as in `ac.uk`), and the words a student mailbox's host
|
|
1569
|
+
* is built from.
|
|
1570
|
+
*/ const SCHOOL_DOMAIN_LABELS = new Set([
|
|
1571
|
+
'k12',
|
|
1572
|
+
'edu',
|
|
1573
|
+
'ac',
|
|
1574
|
+
'student',
|
|
1575
|
+
'students',
|
|
1576
|
+
'aluno',
|
|
1577
|
+
'alunos',
|
|
1578
|
+
'alumno',
|
|
1579
|
+
'alumnos',
|
|
1580
|
+
'estudiante',
|
|
1581
|
+
'estudiantes'
|
|
1582
|
+
]);
|
|
1583
|
+
/**
|
|
1584
|
+
* Whether a company may be CREATED from this domain on its own (AGL-4230),
|
|
1585
|
+
* as opposed to linked to one that already exists.
|
|
1586
|
+
*
|
|
1587
|
+
* {@link companyDomainForEmail} has already turned away public and
|
|
1588
|
+
* disposable mailboxes. What it lets through and this does not is a school
|
|
1589
|
+
* or a university: a student's address at `k12.ipsd.org` or
|
|
1590
|
+
* `aluno.educa.go.gov.br` is a real organisation's domain, but the person
|
|
1591
|
+
* signing up is not that organisation's buyer, and minting "K12" or "Aluno"
|
|
1592
|
+
* from every pupil who tries the product fills the company list with
|
|
1593
|
+
* schools. So a school domain still LINKS to a company somebody created on
|
|
1594
|
+
* purpose, and is never minted into one by the capture door.
|
|
1595
|
+
*/ export function companyDomainMintable(domain) {
|
|
1596
|
+
const value = normalizeCompanyDomain(domain);
|
|
1597
|
+
if (!value) return false;
|
|
1598
|
+
if (PUBLIC_MAILBOX_DOMAINS.has(value) || isDisposableEmailDomain(value)) return false;
|
|
1599
|
+
return !value.split('.').some((label)=>SCHOOL_DOMAIN_LABELS.has(label) || /schools?/.test(label));
|
|
1600
|
+
}
|
|
1465
1601
|
/**
|
|
1466
1602
|
* The name a company minted from a domain starts with: the first label with
|
|
1467
1603
|
* a capital — `acme.com` → `Acme`, `initech.co.uk` → `Initech`.
|