@aglyn/aglyn 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/account-preferences.d.ts +15 -13
  3. package/src/lib/app-utils/account-preferences.js +20 -20
  4. package/src/lib/app-utils/account-preferences.js.map +1 -1
  5. package/src/lib/app-utils/crm.d.ts +3 -1
  6. package/src/lib/app-utils/crm.js +6 -3
  7. package/src/lib/app-utils/crm.js.map +1 -1
  8. package/src/lib/app-utils/docs-help-sections.generated.js +3 -3
  9. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  10. package/src/lib/app-utils/docs-help.generated.d.ts +2 -2
  11. package/src/lib/app-utils/docs-help.generated.js +2 -0
  12. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  13. package/src/lib/app-utils/docs-index.generated.js +76 -69
  14. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  15. package/src/lib/app-utils/full-use-cost.d.ts +28 -11
  16. package/src/lib/app-utils/full-use-cost.js +31 -15
  17. package/src/lib/app-utils/full-use-cost.js.map +1 -1
  18. package/src/lib/app-utils/markdown-lite.js +8 -1
  19. package/src/lib/app-utils/markdown-lite.js.map +1 -1
  20. package/src/lib/app-utils/org-role-grants.d.ts +6 -0
  21. package/src/lib/app-utils/org-role-grants.js +3 -1
  22. package/src/lib/app-utils/org-role-grants.js.map +1 -1
  23. package/src/lib/app-utils/person-erasure.d.ts +8 -0
  24. package/src/lib/app-utils/person-erasure.js +6 -0
  25. package/src/lib/app-utils/person-erasure.js.map +1 -1
  26. package/src/lib/app-utils/plan-entitlements.d.ts +27 -1
  27. package/src/lib/app-utils/plan-entitlements.js +44 -3
  28. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  29. package/src/lib/app-utils/site-preview.d.ts +6 -2
  30. package/src/lib/app-utils/site-preview.js +5 -3
  31. package/src/lib/app-utils/site-preview.js.map +1 -1
  32. package/src/lib/app-utils/site-unavailable.d.ts +4 -7
  33. package/src/lib/app-utils/site-unavailable.js +4 -8
  34. package/src/lib/app-utils/site-unavailable.js.map +1 -1
  35. package/src/lib/app-utils/upgrade-proposal.d.ts +17 -3
  36. package/src/lib/app-utils/upgrade-proposal.js +28 -6
  37. package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
  38. package/src/lib/foundation/definitions/org-billing.types.d.ts +22 -0
  39. package/src/lib/foundation/definitions/org-billing.types.js +2 -2
  40. package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
  41. package/src/lib/foundation/definitions/platform.types.d.ts +1 -1
  42. package/src/lib/foundation/definitions/platform.types.js.map +1 -1
  43. package/src/lib/foundation/definitions/write-deny-coverage.util.d.ts +1 -1
  44. package/src/lib/foundation/definitions/write-deny-coverage.util.js +1 -1
  45. package/src/lib/foundation/definitions/write-deny-coverage.util.js.map +1 -1
  46. package/src/lib/plugin-manager/first-party-plugins.generated.js +1 -1
  47. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  48. package/src/lib/plugin-manager/plugin-contact-capture.d.ts +18 -0
  49. package/src/lib/plugin-manager/plugin-contact-capture.js +26 -0
  50. package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
  51. package/src/lib/plugin-manager/plugin-person-erasure-notes.d.ts +61 -0
  52. package/src/lib/plugin-manager/plugin-person-erasure-notes.js +114 -0
  53. package/src/lib/plugin-manager/plugin-person-erasure-notes.js.map +1 -0
  54. package/src/lib/plugin-manager/plugin-site-starters.d.ts +7 -0
  55. package/src/lib/plugin-manager/plugin-site-starters.js.map +1 -1
@@ -320,3 +320,21 @@ export declare function pluginContactSource(source: string): ResolvedPluginConta
320
320
  * the console's browser and on both servers before a page renders.
321
321
  */
322
322
  export declare function labelContactSource(source: unknown, fallback?: string): string;
323
+ /**
324
+ * Whether a word is a source this process can name: one of the core's, or a
325
+ * door a plugin declared. What keeps a saved filter from carrying a word
326
+ * nothing answers to, without closing the list against a plugin's door.
327
+ */
328
+ export declare function isKnownContactSource(source: unknown): boolean;
329
+ /** One source a filter offers: the stored word, and how it reads. */
330
+ export interface PluginContactSourceOption {
331
+ value: string;
332
+ label: string;
333
+ }
334
+ /**
335
+ * Every source a filter can offer: the core's, then each door a plugin
336
+ * declared, each reading as {@link labelContactSource} reads it, so a filter's
337
+ * choice and a row's chip cannot disagree. A plugin that declares a core word
338
+ * adds no second entry and does not change its label.
339
+ */
340
+ export declare function listContactSourceOptions(): PluginContactSourceOption[];
@@ -108,5 +108,31 @@ export const PLUGIN_CONTACT_SOURCES = definePluginServiceContract('core.contact-
108
108
  }
109
109
  return ((_pluginContactSource = pluginContactSource(word)) == null ? void 0 : _pluginContactSource.label) || (fallback != null ? fallback : word);
110
110
  }
111
+ /**
112
+ * Whether a word is a source this process can name: one of the core's, or a
113
+ * door a plugin declared. What keeps a saved filter from carrying a word
114
+ * nothing answers to, without closing the list against a plugin's door.
115
+ */ export function isKnownContactSource(source) {
116
+ const word = typeof source === 'string' ? source.trim() : '';
117
+ if (!word) return false;
118
+ return Object.hasOwn(CONTACT_SOURCE_LABELS, word) || pluginContactSource(word) !== null;
119
+ }
120
+ /**
121
+ * Every source a filter can offer: the core's, then each door a plugin
122
+ * declared, each reading as {@link labelContactSource} reads it, so a filter's
123
+ * choice and a row's chip cannot disagree. A plugin that declares a core word
124
+ * adds no second entry and does not change its label.
125
+ */ export function listContactSourceOptions() {
126
+ const words = new Set([
127
+ ...Object.keys(CONTACT_SOURCE_LABELS),
128
+ ...listPluginContactSources().map((door)=>door.source)
129
+ ]);
130
+ return [
131
+ ...words
132
+ ].map((value)=>({
133
+ value,
134
+ label: labelContactSource(value)
135
+ }));
136
+ }
111
137
 
112
138
  //# sourceMappingURL=plugin-contact-capture.js.map
@@ -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"],"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"],"mappings":"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"}
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,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,wBAAwBa,IAAI,CAClE,CAACC,QAAUA,MAAMP,GAAG,KAAKA;IAE3B,IAAIK,aAAaR,YAAYQ,UAAUR,QAAQ,KAAKA,UAAU;QAC5D,MAAM,IAAIM,MACR,CAAC,wBAAwB,EAAEH,IAAI,yBAAyB,CAAC,GACvD,CAAC,CAAC,EAAEK,UAAUR,QAAQ,CAAC,YAAY,EAAEA,SAAS,CAAC,CAAC;IAEtD;IACAR,sBACEI,wBACA,aAAKM;QAAaE,QAAQD;QAC1B,aACMJ,CAAAA,2BAAAA,QAASC,QAAQ,IAAG;QAAEA,UAAUD,QAAQC,QAAQ;IAAC,IAAI,CAAC;QAC1DG;;AAGN;AAQA,2EAA2E,GAC3E,OAAO,SAASQ;IACd,MAAMD,QAAQjB,sBAAsBC,uBAAuB,CAAC,EAAE;IAC9D,OAAOgB,QAAQ;QAAEV,UAAUU,MAAMV,QAAQ;QAAEF,QAAQY,MAAME,IAAI;IAAC,IAAI;AACpE;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeC,qBACpBC,OAAoC;IAEpC,MAAMC,QAAQJ;IACd,IAAI,CAACI,OAAO,OAAO;IACnB,OAAOA,MAAMjB,MAAM,CAACkB,OAAO,CAACF;AAC9B;AAEA,uEAAuE,GACvE,OAAO,SAASG;IACd,OAAOxB,sBAAsBG,wBAAwBsB,GAAG,CAAC,CAACR,QAAW,aAChEA,MAAME,IAAI;YACbZ,UAAUU,MAAMV,QAAQ;;AAE5B;AAEA,6DAA6D,GAC7D,OAAO,SAASmB,oBACdf,MAAc;IAEd,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"}
@@ -0,0 +1,61 @@
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
+ /** What a source is asked about. */
18
+ export interface PersonErasureNotesRequest {
19
+ /** The workspace the card is open on. */
20
+ orgId: string;
21
+ }
22
+ /** One thing a plugin says it keeps. */
23
+ export interface PersonErasureNote {
24
+ /** Stable, and unique for the plugin. */
25
+ id: string;
26
+ /** One plain sentence: what is kept, how, and for how long. */
27
+ text: string;
28
+ }
29
+ /** A note as the reader answers it, with the plugin that said it. */
30
+ export type PersonErasureNoteAnswer = PersonErasureNote & {
31
+ pluginId: string;
32
+ };
33
+ export interface PersonErasureNoteSource {
34
+ /** The notes for one workspace; none when it holds nothing the plugin keeps. May throw. */
35
+ notes(request: PersonErasureNotesRequest): Promise<readonly PersonErasureNote[]>;
36
+ }
37
+ /** Every plugin may answer; one source per plugin. */
38
+ export declare const PERSON_ERASURE_NOTE_SOURCES: import("./plugin-services").PluginServiceContract<PersonErasureNoteSource>;
39
+ /**
40
+ * Installs a plugin's note source. Owner = the loader's marker inside a
41
+ * register fn, else `options.pluginId`. Registering again replaces the
42
+ * plugin's earlier source.
43
+ */
44
+ export declare function registerPersonErasureNoteSource(source: PersonErasureNoteSource, options?: {
45
+ pluginId?: string;
46
+ }): void;
47
+ /** Whether a note can be printed: an id and words. */
48
+ export declare function isPrintablePersonErasureNote(note: unknown): note is PersonErasureNote;
49
+ /** What every source answered for one workspace. */
50
+ export interface PersonErasureNotesRead {
51
+ notes: PersonErasureNoteAnswer[];
52
+ /** Plugins whose answer could not be read: the card says details are missing. */
53
+ unavailable: string[];
54
+ }
55
+ /**
56
+ * Asks every source about one workspace. NEVER THROWS: a source that threw or
57
+ * answered something unprintable is listed in `unavailable`, and the rest are
58
+ * answered. With no source registered, runs the app's boot step once and asks
59
+ * again.
60
+ */
61
+ export declare function readPersonErasureNotes(request: PersonErasureNotesRequest): Promise<PersonErasureNotesRead>;
@@ -0,0 +1,114 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ /**
18
+ * WHAT A PLUGIN KEEPS THROUGH A PERSON ERASURE, said before it is filed
19
+ * (AGL-4042).
20
+ *
21
+ * Its sibling `plugin-person-erasure` does the erasing, and each plugin decides
22
+ * there what it deletes and what it keeps. The console's Erase a person card
23
+ * lists the platform's own removed and kept records; a plugin that keeps a
24
+ * record with the person still on it registers a NOTE SOURCE here, and the card
25
+ * prints what it answers, so the person filing hears it first.
26
+ *
27
+ * The platform owns the question and the card. What a plugin keeps, and the
28
+ * sentence the person reads, are the plugin's. A note is information, never a
29
+ * gate: nothing it answers holds an erasure back.
30
+ *
31
+ * A source answers for the workspace, not for one person, because the card is
32
+ * opened before an address is typed. It answers nothing when the workspace
33
+ * holds nothing of the kind, and otherwise words the sentence so it is true of
34
+ * someone with no such record.
35
+ *
36
+ * ## Not answered is said, not hidden
37
+ *
38
+ * A source that throws, or answers something that cannot be printed, is listed
39
+ * in `unavailable` by plugin id, and the card says some details could not be
40
+ * checked, so a missing note never reads as "nothing is kept". A process where
41
+ * no source is registered at all runs the app's boot step once more first
42
+ * (`plugin-declarations-repair`), as the erasures do.
43
+ *
44
+ * Logic only: the contract, the registry and the reader. The card is the
45
+ * console's.
46
+ */ import { runPluginDeclarationsRepair } from "./plugin-declarations-repair.js";
47
+ import { definePluginServiceContract, registerPluginService, resolvePluginServices } from "./plugin-services.js";
48
+ /** Every plugin may answer; one source per plugin. */ export const PERSON_ERASURE_NOTE_SOURCES = definePluginServiceContract('core.person-erasure-notes', {
49
+ multiple: true
50
+ });
51
+ /**
52
+ * Installs a plugin's note source. Owner = the loader's marker inside a
53
+ * register fn, else `options.pluginId`. Registering again replaces the
54
+ * plugin's earlier source.
55
+ */ export function registerPersonErasureNoteSource(source, options) {
56
+ if (typeof (source == null ? void 0 : source.notes) !== 'function') {
57
+ throw new Error('a person erasure note source needs a notes function');
58
+ }
59
+ registerPluginService(PERSON_ERASURE_NOTE_SOURCES, source, _extends({}, (options == null ? void 0 : options.pluginId) ? {
60
+ pluginId: options.pluginId
61
+ } : {}));
62
+ }
63
+ const isText = (value)=>typeof value === 'string' && value.trim().length > 0;
64
+ /** Whether a note can be printed: an id and words. */ export function isPrintablePersonErasureNote(note) {
65
+ const candidate = note;
66
+ return Boolean(candidate) && typeof candidate === 'object' && isText(candidate == null ? void 0 : candidate.id) && isText(candidate == null ? void 0 : candidate.text);
67
+ }
68
+ /**
69
+ * Asks every source about one workspace. NEVER THROWS: a source that threw or
70
+ * answered something unprintable is listed in `unavailable`, and the rest are
71
+ * answered. With no source registered, runs the app's boot step once and asks
72
+ * again.
73
+ */ export async function readPersonErasureNotes(request) {
74
+ let registered = resolvePluginServices(PERSON_ERASURE_NOTE_SOURCES);
75
+ if (!registered.length) {
76
+ const repaired = await runPluginDeclarationsRepair().catch(()=>false);
77
+ if (repaired) registered = resolvePluginServices(PERSON_ERASURE_NOTE_SOURCES);
78
+ }
79
+ const answers = await Promise.all(registered.map(async ({ pluginId, impl })=>{
80
+ try {
81
+ const notes = await impl.notes(request);
82
+ if (!Array.isArray(notes) || !notes.every(isPrintablePersonErasureNote)) {
83
+ console.error(`[person-erasure-notes] "${pluginId}" answered a note that cannot be printed`);
84
+ return {
85
+ pluginId,
86
+ notes: null
87
+ };
88
+ }
89
+ return {
90
+ pluginId,
91
+ notes: notes.map((note)=>({
92
+ id: note.id,
93
+ text: note.text,
94
+ pluginId
95
+ }))
96
+ };
97
+ } catch (error) {
98
+ console.error(`[person-erasure-notes] "${pluginId}" could not answer`, error);
99
+ return {
100
+ pluginId,
101
+ notes: null
102
+ };
103
+ }
104
+ }));
105
+ return {
106
+ notes: answers.flatMap((answer)=>{
107
+ var _answer_notes;
108
+ return (_answer_notes = answer.notes) != null ? _answer_notes : [];
109
+ }),
110
+ unavailable: answers.filter((answer)=>answer.notes === null).map((answer)=>answer.pluginId)
111
+ };
112
+ }
113
+
114
+ //# sourceMappingURL=plugin-person-erasure-notes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-person-erasure-notes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT A PLUGIN KEEPS THROUGH A PERSON ERASURE, said before it is filed\n * (AGL-4042).\n *\n * Its sibling `plugin-person-erasure` does the erasing, and each plugin decides\n * there what it deletes and what it keeps. The console's Erase a person card\n * lists the platform's own removed and kept records; a plugin that keeps a\n * record with the person still on it registers a NOTE SOURCE here, and the card\n * prints what it answers, so the person filing hears it first.\n *\n * The platform owns the question and the card. What a plugin keeps, and the\n * sentence the person reads, are the plugin's. A note is information, never a\n * gate: nothing it answers holds an erasure back.\n *\n * A source answers for the workspace, not for one person, because the card is\n * opened before an address is typed. It answers nothing when the workspace\n * holds nothing of the kind, and otherwise words the sentence so it is true of\n * someone with no such record.\n *\n * ## Not answered is said, not hidden\n *\n * A source that throws, or answers something that cannot be printed, is listed\n * in `unavailable` by plugin id, and the card says some details could not be\n * checked, so a missing note never reads as \"nothing is kept\". A process where\n * no source is registered at all runs the app's boot step once more first\n * (`plugin-declarations-repair`), as the erasures do.\n *\n * Logic only: the contract, the registry and the reader. The card is the\n * console's.\n */\n\nimport { runPluginDeclarationsRepair } from './plugin-declarations-repair'\nimport {\n definePluginServiceContract,\n registerPluginService,\n resolvePluginServices,\n} from './plugin-services'\n\n/** What a source is asked about. */\nexport interface PersonErasureNotesRequest {\n /** The workspace the card is open on. */\n orgId: string\n}\n\n/** One thing a plugin says it keeps. */\nexport interface PersonErasureNote {\n /** Stable, and unique for the plugin. */\n id: string\n /** One plain sentence: what is kept, how, and for how long. */\n text: string\n}\n\n/** A note as the reader answers it, with the plugin that said it. */\nexport type PersonErasureNoteAnswer = PersonErasureNote & { pluginId: string }\n\nexport interface PersonErasureNoteSource {\n /** The notes for one workspace; none when it holds nothing the plugin keeps. May throw. */\n notes(request: PersonErasureNotesRequest): Promise<readonly PersonErasureNote[]>\n}\n\n/** Every plugin may answer; one source per plugin. */\nexport const PERSON_ERASURE_NOTE_SOURCES = definePluginServiceContract<PersonErasureNoteSource>(\n 'core.person-erasure-notes',\n { multiple: true },\n)\n\n/**\n * Installs a plugin's note source. Owner = the loader's marker inside a\n * register fn, else `options.pluginId`. Registering again replaces the\n * plugin's earlier source.\n */\nexport function registerPersonErasureNoteSource(\n source: PersonErasureNoteSource,\n options?: { pluginId?: string },\n): void {\n if (typeof source?.notes !== 'function') {\n throw new Error('a person erasure note source needs a notes function')\n }\n registerPluginService(PERSON_ERASURE_NOTE_SOURCES, source, {\n ...(options?.pluginId ? { pluginId: options.pluginId } : {}),\n })\n}\n\nconst isText = (value: unknown): value is string => typeof value === 'string' && value.trim().length > 0\n\n/** Whether a note can be printed: an id and words. */\nexport function isPrintablePersonErasureNote(note: unknown): note is PersonErasureNote {\n const candidate = note as PersonErasureNote | null | undefined\n return Boolean(candidate) && typeof candidate === 'object' && isText(candidate?.id) && isText(candidate?.text)\n}\n\n/** What every source answered for one workspace. */\nexport interface PersonErasureNotesRead {\n notes: PersonErasureNoteAnswer[]\n /** Plugins whose answer could not be read: the card says details are missing. */\n unavailable: string[]\n}\n\n/**\n * Asks every source about one workspace. NEVER THROWS: a source that threw or\n * answered something unprintable is listed in `unavailable`, and the rest are\n * answered. With no source registered, runs the app's boot step once and asks\n * again.\n */\nexport async function readPersonErasureNotes(\n request: PersonErasureNotesRequest,\n): Promise<PersonErasureNotesRead> {\n let registered = resolvePluginServices(PERSON_ERASURE_NOTE_SOURCES)\n if (!registered.length) {\n const repaired = await runPluginDeclarationsRepair().catch(() => false)\n if (repaired) registered = resolvePluginServices(PERSON_ERASURE_NOTE_SOURCES)\n }\n const answers = await Promise.all(\n registered.map(async ({ pluginId, impl }) => {\n try {\n const notes = await impl.notes(request)\n if (!Array.isArray(notes) || !notes.every(isPrintablePersonErasureNote)) {\n console.error(`[person-erasure-notes] \"${pluginId}\" answered a note that cannot be printed`)\n return { pluginId, notes: null }\n }\n return { pluginId, notes: notes.map((note) => ({ id: note.id, text: note.text, pluginId })) }\n } catch (error) {\n console.error(`[person-erasure-notes] \"${pluginId}\" could not answer`, error)\n return { pluginId, notes: null }\n }\n }),\n )\n return {\n notes: answers.flatMap((answer) => answer.notes ?? []),\n unavailable: answers.filter((answer) => answer.notes === null).map((answer) => answer.pluginId),\n }\n}\n"],"names":["runPluginDeclarationsRepair","definePluginServiceContract","registerPluginService","resolvePluginServices","PERSON_ERASURE_NOTE_SOURCES","multiple","registerPersonErasureNoteSource","source","options","notes","Error","pluginId","isText","value","trim","length","isPrintablePersonErasureNote","note","candidate","Boolean","id","text","readPersonErasureNotes","request","registered","repaired","catch","answers","Promise","all","map","impl","Array","isArray","every","console","error","flatMap","answer","unavailable","filter"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GAED,SAASA,2BAA2B,QAAQ,kCAA8B;AAC1E,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,QAChB,uBAAmB;AAwB1B,oDAAoD,GACpD,OAAO,MAAMC,8BAA8BH,4BACzC,6BACA;IAAEI,UAAU;AAAK,GAClB;AAED;;;;CAIC,GACD,OAAO,SAASC,gCACdC,MAA+B,EAC/BC,OAA+B;IAE/B,IAAI,QAAOD,0BAAAA,OAAQE,KAAK,MAAK,YAAY;QACvC,MAAM,IAAIC,MAAM;IAClB;IACAR,sBAAsBE,6BAA6BG,QAAQ,aACrDC,CAAAA,2BAAAA,QAASG,QAAQ,IAAG;QAAEA,UAAUH,QAAQG,QAAQ;IAAC,IAAI,CAAC;AAE9D;AAEA,MAAMC,SAAS,CAACC,QAAoC,OAAOA,UAAU,YAAYA,MAAMC,IAAI,GAAGC,MAAM,GAAG;AAEvG,oDAAoD,GACpD,OAAO,SAASC,6BAA6BC,IAAa;IACxD,MAAMC,YAAYD;IAClB,OAAOE,QAAQD,cAAc,OAAOA,cAAc,YAAYN,OAAOM,6BAAAA,UAAWE,EAAE,KAAKR,OAAOM,6BAAAA,UAAWG,IAAI;AAC/G;AASA;;;;;CAKC,GACD,OAAO,eAAeC,uBACpBC,OAAkC;IAElC,IAAIC,aAAarB,sBAAsBC;IACvC,IAAI,CAACoB,WAAWT,MAAM,EAAE;QACtB,MAAMU,WAAW,MAAMzB,8BAA8B0B,KAAK,CAAC,IAAM;QACjE,IAAID,UAAUD,aAAarB,sBAAsBC;IACnD;IACA,MAAMuB,UAAU,MAAMC,QAAQC,GAAG,CAC/BL,WAAWM,GAAG,CAAC,OAAO,EAAEnB,QAAQ,EAAEoB,IAAI,EAAE;QACtC,IAAI;YACF,MAAMtB,QAAQ,MAAMsB,KAAKtB,KAAK,CAACc;YAC/B,IAAI,CAACS,MAAMC,OAAO,CAACxB,UAAU,CAACA,MAAMyB,KAAK,CAAClB,+BAA+B;gBACvEmB,QAAQC,KAAK,CAAC,CAAC,wBAAwB,EAAEzB,SAAS,wCAAwC,CAAC;gBAC3F,OAAO;oBAAEA;oBAAUF,OAAO;gBAAK;YACjC;YACA,OAAO;gBAAEE;gBAAUF,OAAOA,MAAMqB,GAAG,CAAC,CAACb,OAAU,CAAA;wBAAEG,IAAIH,KAAKG,EAAE;wBAAEC,MAAMJ,KAAKI,IAAI;wBAAEV;oBAAS,CAAA;YAAI;QAC9F,EAAE,OAAOyB,OAAO;YACdD,QAAQC,KAAK,CAAC,CAAC,wBAAwB,EAAEzB,SAAS,kBAAkB,CAAC,EAAEyB;YACvE,OAAO;gBAAEzB;gBAAUF,OAAO;YAAK;QACjC;IACF;IAEF,OAAO;QACLA,OAAOkB,QAAQU,OAAO,CAAC,CAACC;gBAAWA;oBAAAA,gBAAAA,OAAO7B,KAAK,YAAZ6B,gBAAgB,EAAE;;QACrDC,aAAaZ,QAAQa,MAAM,CAAC,CAACF,SAAWA,OAAO7B,KAAK,KAAK,MAAMqB,GAAG,CAAC,CAACQ,SAAWA,OAAO3B,QAAQ;IAChG;AACF"}
@@ -53,6 +53,13 @@ export interface SiteStarterSummary {
53
53
  * say; a free starter needs no purchase either way.
54
54
  */
55
55
  owned?: boolean;
56
+ /**
57
+ * Why this person cannot buy it, in one sentence, when the source knows they
58
+ * cannot (AGL-4047). The surface keeps Buy on screen, switched off, with
59
+ * these words; absent, anyone may buy it. Read for the person who asked, like
60
+ * `owned`.
61
+ */
62
+ buyBlockedReason?: string;
56
63
  }
57
64
  /** Who is asking: the workspace the site will belong to, and the person. */
58
65
  export interface SiteStarterViewer {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-site-starters.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 {\n SiteStarterChoice,\n SiteStarterFacets,\n SiteStarterPayload,\n} from '../app-utils/site-starter'\nimport {\n definePluginServiceContract,\n registerPluginService,\n resolvePluginService,\n} from './plugin-services'\n\n/**\n * Where site starters come from, as the console's SERVER reads them\n * (AGL-4049).\n *\n * \"Create site\" offers a starter for every site, chosen before the site\n * exists, and the site is created from the one picked. The starters are\n * listings a plugin keeps — searched, priced and bought there — so the core\n * names the two questions the create path asks and one plugin answers them:\n * which starters match a search, and what a picked one creates. With none\n * registered there are no starters to offer, and the create path keeps its\n * own default site.\n */\n\n/** One starter as a search lists it. */\nexport interface SiteStarterSummary {\n listingId: string\n displayName: string\n description: string\n /** Who made it, as the search shows them. */\n authorName: string\n /** Published by the platform itself; listed first. */\n official: boolean\n /** The price in US dollars; 0 for free. */\n priceUsd: number\n previewImageUrl: string | null\n facets: SiteStarterFacets\n /**\n * What kind of site it is, in words a card shows (\"Restaurant & café\"), or\n * `null` where it names none. Optional: a source with no such words still\n * satisfies the seam, and `facets.kind` stays the id a search filters on.\n */\n category?: string | null\n /**\n * The asking workspace may create from it without paying (AGL-4049):\n * bought already, or its own. Read for the person who asked, so it is set\n * only by an answer that knows who that is, and absent where it does not\n * say; a free starter needs no purchase either way.\n */\n owned?: boolean\n}\n\n/** Who is asking: the workspace the site will belong to, and the person. */\nexport interface SiteStarterViewer {\n orgId: string | null\n uid: string\n}\n\nexport interface PluginSiteStarterSource {\n /** The starters matching a search, best first, at most `limit` of them. */\n search(\n input: { word: string; filter: Partial<SiteStarterFacets>; limit: number },\n viewer: SiteStarterViewer,\n ): Promise<SiteStarterSummary[]>\n /**\n * What a picked starter creates, or why this viewer cannot have it: 402\n * while a priced starter is unpaid (with its price), 403 when the viewer may\n * not install it, 404 when it is gone.\n */\n resolve(\n choice: SiteStarterChoice,\n viewer: SiteStarterViewer,\n ): Promise<SiteStarterPayload | { error: string; status: 402 | 403 | 404; priceUsd?: number }>\n /**\n * Records that a site was created from a starter; best-effort, never throws.\n * Optional, so a source that does not count installs still satisfies the seam.\n */\n installed?(choice: SiteStarterChoice, viewer: SiteStarterViewer, site: { hostId: string }): Promise<void>\n /**\n * One starter as a search would list it for this viewer, or `null` when it\n * is not one they may see (AGL-4049): what the create path records a site\n * was started from, and the name it files the starter's theme under, and\n * what \"Choose your starter\" shows for a pick it restores. Best-effort.\n * Optional, so a source that cannot describe a single listing still\n * satisfies the seam; read it through {@link describeSiteStarter}.\n */\n describe?(choice: SiteStarterChoice, viewer: SiteStarterViewer): Promise<SiteStarterSummary | null>\n}\n\nexport const PLUGIN_SITE_STARTERS = definePluginServiceContract<PluginSiteStarterSource>(\n 'core.site-starters',\n { multiple: false },\n)\n\n/** Registers the plugin that serves site starters. One per deployment; a second is refused. */\nexport function registerPluginSiteStarterSource(\n impl: PluginSiteStarterSource,\n options: { pluginId: string },\n): void {\n registerPluginService(PLUGIN_SITE_STARTERS, impl, { pluginId: options.pluginId })\n}\n\n/** The registered starter source, or `null` when no plugin serves starters. */\nexport function resolveSiteStarterSource(): PluginSiteStarterSource | null {\n return resolvePluginService(PLUGIN_SITE_STARTERS) ?? null\n}\n\n/**\n * A starter as the source describes it, or `null` when the source cannot say\n * (AGL-4049): no `describe`, a listing the viewer may not see, or a source\n * that failed. Never throws, because nothing it answers is required: the\n * create path falls back to the payload's own facts, and the picker to the\n * search.\n */\nexport async function describeSiteStarter(\n source: PluginSiteStarterSource | null,\n choice: SiteStarterChoice,\n viewer: SiteStarterViewer,\n): Promise<SiteStarterSummary | null> {\n if (!source?.describe || !choice?.listingId) return null\n try {\n const summary = await source.describe(choice, viewer)\n return summary && typeof summary === 'object' && summary.listingId === choice.listingId ? summary : null\n } catch (error) {\n console.error('[site-starters] describe failed', { listingId: choice.listingId, error })\n return null\n }\n}\n"],"names":["definePluginServiceContract","registerPluginService","resolvePluginService","PLUGIN_SITE_STARTERS","multiple","registerPluginSiteStarterSource","impl","options","pluginId","resolveSiteStarterSource","describeSiteStarter","source","choice","viewer","describe","listingId","summary","error","console"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAOD,SACEA,2BAA2B,EAC3BC,qBAAqB,EACrBC,oBAAoB,QACf,uBAAmB;AAgF1B,OAAO,MAAMC,uBAAuBH,4BAClC,sBACA;IAAEI,UAAU;AAAM,GACnB;AAED,6FAA6F,GAC7F,OAAO,SAASC,gCACdC,IAA6B,EAC7BC,OAA6B;IAE7BN,sBAAsBE,sBAAsBG,MAAM;QAAEE,UAAUD,QAAQC,QAAQ;IAAC;AACjF;AAEA,6EAA6E,GAC7E,OAAO,SAASC;QACPP;IAAP,QAAOA,wBAAAA,qBAAqBC,iCAArBD,wBAA8C;AACvD;AAEA;;;;;;CAMC,GACD,OAAO,eAAeQ,oBACpBC,MAAsC,EACtCC,MAAyB,EACzBC,MAAyB;IAEzB,IAAI,EAACF,0BAAAA,OAAQG,QAAQ,KAAI,EAACF,0BAAAA,OAAQG,SAAS,GAAE,OAAO;IACpD,IAAI;QACF,MAAMC,UAAU,MAAML,OAAOG,QAAQ,CAACF,QAAQC;QAC9C,OAAOG,WAAW,OAAOA,YAAY,YAAYA,QAAQD,SAAS,KAAKH,OAAOG,SAAS,GAAGC,UAAU;IACtG,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAAC,mCAAmC;YAAEF,WAAWH,OAAOG,SAAS;YAAEE;QAAM;QACtF,OAAO;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-site-starters.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 {\n SiteStarterChoice,\n SiteStarterFacets,\n SiteStarterPayload,\n} from '../app-utils/site-starter'\nimport {\n definePluginServiceContract,\n registerPluginService,\n resolvePluginService,\n} from './plugin-services'\n\n/**\n * Where site starters come from, as the console's SERVER reads them\n * (AGL-4049).\n *\n * \"Create site\" offers a starter for every site, chosen before the site\n * exists, and the site is created from the one picked. The starters are\n * listings a plugin keeps — searched, priced and bought there — so the core\n * names the two questions the create path asks and one plugin answers them:\n * which starters match a search, and what a picked one creates. With none\n * registered there are no starters to offer, and the create path keeps its\n * own default site.\n */\n\n/** One starter as a search lists it. */\nexport interface SiteStarterSummary {\n listingId: string\n displayName: string\n description: string\n /** Who made it, as the search shows them. */\n authorName: string\n /** Published by the platform itself; listed first. */\n official: boolean\n /** The price in US dollars; 0 for free. */\n priceUsd: number\n previewImageUrl: string | null\n facets: SiteStarterFacets\n /**\n * What kind of site it is, in words a card shows (\"Restaurant & café\"), or\n * `null` where it names none. Optional: a source with no such words still\n * satisfies the seam, and `facets.kind` stays the id a search filters on.\n */\n category?: string | null\n /**\n * The asking workspace may create from it without paying (AGL-4049):\n * bought already, or its own. Read for the person who asked, so it is set\n * only by an answer that knows who that is, and absent where it does not\n * say; a free starter needs no purchase either way.\n */\n owned?: boolean\n /**\n * Why this person cannot buy it, in one sentence, when the source knows they\n * cannot (AGL-4047). The surface keeps Buy on screen, switched off, with\n * these words; absent, anyone may buy it. Read for the person who asked, like\n * `owned`.\n */\n buyBlockedReason?: string\n}\n\n/** Who is asking: the workspace the site will belong to, and the person. */\nexport interface SiteStarterViewer {\n orgId: string | null\n uid: string\n}\n\nexport interface PluginSiteStarterSource {\n /** The starters matching a search, best first, at most `limit` of them. */\n search(\n input: { word: string; filter: Partial<SiteStarterFacets>; limit: number },\n viewer: SiteStarterViewer,\n ): Promise<SiteStarterSummary[]>\n /**\n * What a picked starter creates, or why this viewer cannot have it: 402\n * while a priced starter is unpaid (with its price), 403 when the viewer may\n * not install it, 404 when it is gone.\n */\n resolve(\n choice: SiteStarterChoice,\n viewer: SiteStarterViewer,\n ): Promise<SiteStarterPayload | { error: string; status: 402 | 403 | 404; priceUsd?: number }>\n /**\n * Records that a site was created from a starter; best-effort, never throws.\n * Optional, so a source that does not count installs still satisfies the seam.\n */\n installed?(choice: SiteStarterChoice, viewer: SiteStarterViewer, site: { hostId: string }): Promise<void>\n /**\n * One starter as a search would list it for this viewer, or `null` when it\n * is not one they may see (AGL-4049): what the create path records a site\n * was started from, and the name it files the starter's theme under, and\n * what \"Choose your starter\" shows for a pick it restores. Best-effort.\n * Optional, so a source that cannot describe a single listing still\n * satisfies the seam; read it through {@link describeSiteStarter}.\n */\n describe?(choice: SiteStarterChoice, viewer: SiteStarterViewer): Promise<SiteStarterSummary | null>\n}\n\nexport const PLUGIN_SITE_STARTERS = definePluginServiceContract<PluginSiteStarterSource>(\n 'core.site-starters',\n { multiple: false },\n)\n\n/** Registers the plugin that serves site starters. One per deployment; a second is refused. */\nexport function registerPluginSiteStarterSource(\n impl: PluginSiteStarterSource,\n options: { pluginId: string },\n): void {\n registerPluginService(PLUGIN_SITE_STARTERS, impl, { pluginId: options.pluginId })\n}\n\n/** The registered starter source, or `null` when no plugin serves starters. */\nexport function resolveSiteStarterSource(): PluginSiteStarterSource | null {\n return resolvePluginService(PLUGIN_SITE_STARTERS) ?? null\n}\n\n/**\n * A starter as the source describes it, or `null` when the source cannot say\n * (AGL-4049): no `describe`, a listing the viewer may not see, or a source\n * that failed. Never throws, because nothing it answers is required: the\n * create path falls back to the payload's own facts, and the picker to the\n * search.\n */\nexport async function describeSiteStarter(\n source: PluginSiteStarterSource | null,\n choice: SiteStarterChoice,\n viewer: SiteStarterViewer,\n): Promise<SiteStarterSummary | null> {\n if (!source?.describe || !choice?.listingId) return null\n try {\n const summary = await source.describe(choice, viewer)\n return summary && typeof summary === 'object' && summary.listingId === choice.listingId ? summary : null\n } catch (error) {\n console.error('[site-starters] describe failed', { listingId: choice.listingId, error })\n return null\n }\n}\n"],"names":["definePluginServiceContract","registerPluginService","resolvePluginService","PLUGIN_SITE_STARTERS","multiple","registerPluginSiteStarterSource","impl","options","pluginId","resolveSiteStarterSource","describeSiteStarter","source","choice","viewer","describe","listingId","summary","error","console"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAOD,SACEA,2BAA2B,EAC3BC,qBAAqB,EACrBC,oBAAoB,QACf,uBAAmB;AAuF1B,OAAO,MAAMC,uBAAuBH,4BAClC,sBACA;IAAEI,UAAU;AAAM,GACnB;AAED,6FAA6F,GAC7F,OAAO,SAASC,gCACdC,IAA6B,EAC7BC,OAA6B;IAE7BN,sBAAsBE,sBAAsBG,MAAM;QAAEE,UAAUD,QAAQC,QAAQ;IAAC;AACjF;AAEA,6EAA6E,GAC7E,OAAO,SAASC;QACPP;IAAP,QAAOA,wBAAAA,qBAAqBC,iCAArBD,wBAA8C;AACvD;AAEA;;;;;;CAMC,GACD,OAAO,eAAeQ,oBACpBC,MAAsC,EACtCC,MAAyB,EACzBC,MAAyB;IAEzB,IAAI,EAACF,0BAAAA,OAAQG,QAAQ,KAAI,EAACF,0BAAAA,OAAQG,SAAS,GAAE,OAAO;IACpD,IAAI;QACF,MAAMC,UAAU,MAAML,OAAOG,QAAQ,CAACF,QAAQC;QAC9C,OAAOG,WAAW,OAAOA,YAAY,YAAYA,QAAQD,SAAS,KAAKH,OAAOG,SAAS,GAAGC,UAAU;IACtG,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAAC,mCAAmC;YAAEF,WAAWH,OAAOG,SAAS;YAAEE;QAAM;QACtF,OAAO;IACT;AACF"}