@aglyn/plugins-ai 1.11.0 → 1.13.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 +17 -17
- package/src/lib/components/ai-media-create.component.js +1 -1
- package/src/lib/components/ai-media-create.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-import-step.js +37 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-privacy-step.js +2 -2
- package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +27 -37
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
- package/src/lib/jobs/ai-site-import-look.js +162 -46
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +7 -1
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +15 -0
- package/src/lib/model/ai-credit-estimate.js +13 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +46 -3
- package/src/lib/model/ai-site-import-fidelity.js +254 -62
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-report.d.ts +7 -0
- package/src/lib/model/ai-site-import-report.js +17 -5
- package/src/lib/model/ai-site-import-report.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +75 -4
- package/src/lib/model/ai-site-import.js +34 -11
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +16 -0
- package/src/lib/model/ai-site-look.js +76 -14
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +1 -1
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.d.ts +2 -1
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js +3 -2
- package/src/lib/site-import/fixtures/aglyn-com-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.d.ts +5 -0
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js +116 -3
- package/src/lib/site-import/fixtures/site-import-crawl-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +7 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +15 -0
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +59 -3
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/fixtures/site-look-slate.d.ts +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js +2 -1
- package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +9 -1
- package/src/lib/site-import/site-import-crawl.js +128 -23
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +89 -1
- package/src/lib/site-import/site-import-css.js +468 -28
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
- package/src/lib/site-import/site-import-data-forms.js +531 -0
- package/src/lib/site-import/site-import-data-forms.js.map +1 -0
- package/src/lib/site-import/site-import-html.d.ts +10 -1
- package/src/lib/site-import/site-import-html.js +21 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +9 -2
- package/src/lib/site-import/site-import-layout.js +383 -62
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +17 -3
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +5 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/site-import/site-import-same-page.d.ts +41 -0
- package/src/lib/site-import/site-import-same-page.js +108 -0
- package/src/lib/site-import/site-import-same-page.js.map +1 -0
|
@@ -127,7 +127,7 @@ const VISIBILITY_LABELS = {
|
|
|
127
127
|
properties: {
|
|
128
128
|
maintenance: {
|
|
129
129
|
type: 'boolean',
|
|
130
|
-
description: 'true takes the whole site offline: every address shows its 503 page to every visitor, including anyone with a link, until it is turned off. false brings the site back. Leave it out unless the person asked to take the whole site offline, keep it from everyone until launch, or bring it back.'
|
|
130
|
+
description: 'true takes the whole site offline for visitors: every address shows its 503 page to every visitor, including anyone with a link, until it is turned off, while the site team still sees the site. false brings the site back. Leave it out unless the person asked to take the whole site offline, keep it from everyone until launch, or bring it back.'
|
|
131
131
|
},
|
|
132
132
|
discourageSearchEngines: {
|
|
133
133
|
type: 'boolean',
|
|
@@ -245,7 +245,7 @@ const flag = (value)=>typeof value === 'boolean' ? value : null;
|
|
|
245
245
|
const assigned = !!((_host_get = host.get('errorScreens')) == null ? void 0 : _host_get['unavailable']);
|
|
246
246
|
done.push({
|
|
247
247
|
output: 'maintenance',
|
|
248
|
-
said: maintenance ? `Maintenance mode is on: every address shows ${assigned ? 'your 503 page' : `${PLATFORM_BRAND_NAME}’s plain “undergoing maintenance” notice, because no 503 page is assigned yet`} to every visitor.` : 'Maintenance mode is off: the site is open to visitors again.'
|
|
248
|
+
said: maintenance ? `Maintenance mode is on: every address shows ${assigned ? 'your 503 page' : `${PLATFORM_BRAND_NAME}’s plain “undergoing maintenance” notice, because no 503 page is assigned yet`} to every visitor. You and your team still see the site.` : 'Maintenance mode is off: the site is open to visitors again.'
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-privacy-step.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 { createResourceUid } from '@aglyn/aglyn/app-utils/create-resource-uid'\nimport { holdsSiteKey } from '@aglyn/aglyn/app-utils/host-permissions'\nimport { orgPermissionLabel } from '@aglyn/aglyn/app-utils/org-permissions'\nimport {\n aiAddonName,\n checkEntitlement,\n ENTERPRISE_PLAN_LABEL,\n planLabelGrantingFeature,\n} from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport { SCREEN_ROOT_PATH } from '@aglyn/aglyn/app-utils/screen-route'\nimport { HostScreenVisibility } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport { dropPluginSiteCache } from '@aglyn/aglyn/plugin-manager/plugin-site-cache'\nimport type { PluginAiCapabilityArgsSchema } from '@aglyn/aglyn/plugin-manager/plugin-ai-capabilities'\nimport { getLockdownVerdict } from '@aglyn/tenant-data-admin/server/lockdown'\nimport { resolveOrgIdForHost } from '@aglyn/tenant-data-admin/server/organizations'\nimport { FieldValue, type Firestore } from 'firebase-admin/firestore'\nimport type { AiJobOutput } from '../model/ai-jobs.types'\nimport { registerAiJobAdmission, type AiJobAdmission, type AiJobAdmissionRefusal } from './ai-job-admission'\nimport { aiJobEditModel } from './ai-job-edit-step'\nimport { aiLimitReview, aiUnspentOutcome } from './ai-job-generation'\nimport type { AiJobStepOutcome, AiJobStepRunner } from './ai-job-text-step'\nimport { registerAiJobStep } from './ai-jobs'\n\n/**\n * The `privacy` step (AGL-4033): who can see the site, as the console's own\n * three controls set it — maintenance mode (Admin → Error pages), the\n * Discourage search engines switch (Setup → SEO) and a page's Visibility\n * (its Page Access card) — as a first-class build operation, so \"make my site\n * private until launch\" or \"hide the pricing page\" is one item on Assist's\n * plan card. The docs page it mirrors is Site Protection → Make your site\n * private.\n *\n * NO MODEL. The planner already wrote the choices as the item's arguments;\n * this checks each against the rule the console's own control holds it to and\n * writes it, so it costs no credits.\n *\n * ── Only the controls' own fields ────────────────────────────────────────\n *\n * `maintenance` (true, or deleted on the way off, as the Error pages card\n * writes it), `seo.discourageSearchEngines` (likewise, as the Search engines\n * card does), and a page's `visibility` as Public, Unlisted or Members only.\n * Leaving password mode drops the page's stored hash, as the Page Access card\n * does, so protection never lingers on a page that no longer asks for it.\n *\n * NEVER: a page password. Setting one would put the password in the chat and\n * the plan, so it is not an argument; the note sends the person to the Page\n * Access card instead. Nor layouts, emails or record templates, which have no\n * Page Access card, nor the error pages themselves.\n *\n * ── Who may ──────────────────────────────────────────────────────────────\n *\n * Search indexing and page visibility: the Firestore rules' own for those\n * keys, a member with a write role on the site (admin, editor or author)\n * while no lockdown freezes it. Maintenance mode takes every page of the site\n * offline for every visitor, so, as the console keeps its card in the Admin\n * area, only a site ADMIN may change it here. A non-admin's request still\n * makes the rest of its changes and says why that one was not made.\n *\n * Members only is made only where the plan has content gating (Business and\n * above): the tenant serves gated pages nowhere else, so on a lower plan the\n * write would close the page to everyone, and the note says why it was not.\n *\n * ── Live on confirm, idempotent ──────────────────────────────────────────\n *\n * As the `settings` and `tracking` steps: none of these has a draft, so the\n * plan card's confirm is the agreement and the write is live. One transaction\n * re-reads the host and each page, re-checks the role, writes only what\n * differs, and queues a site-wide publish outbox entry, because visibility\n * changes navigation and the sitemap and both switches change every page.\n */\n\nexport const AI_PRIVACY_KIND = 'privacy' as const\n\n/** ASSUMED: the least time the step needs — the site, the org, the pages named and one transaction. */\nexport const AI_JOB_PRIVACY_STEP_MINIMUM_MS = 5_000\n\nexport const AI_PRIVACY_NO_SITE_COPY = 'Open the site whose privacy should change.'\n/** Names \"Edit site content\" (`site.edit`, AGL-4047), never a role. */\nexport const AI_PRIVACY_ROLE_COPY = `Changing who can see the site needs the \"${orgPermissionLabel('site.edit')}\" permission on this site — ask an organization admin.`\n/** Names \"Manage site settings\" (`site.manage`, AGL-4047), never a role. */\nexport const AI_PRIVACY_ADMIN_COPY = `Turning maintenance mode on or off needs the \"${orgPermissionLabel('site.manage')}\" permission, so it was left as it is.`\nexport const AI_PRIVACY_LOCKED_COPY = 'This site is not accepting changes right now.'\nexport const AI_PRIVACY_NOTHING_COPY = 'The request named no privacy change this could make.'\nexport const AI_PRIVACY_PASSWORD_COPY =\n `To put a page behind a password, set it in that page’s Page Access card; ${aiAddonName()} never handles passwords.`\n\n/** The most pages one item may change. */\n/**\n * The cheapest plan with members-only pages (`contentGating`), read from\n * `PLAN_ENTITLEMENTS` so the copy can never name a retired plan (AGL-4158).\n */\nexport const AI_MEMBERS_ONLY_PLAN_LABEL =\n planLabelGrantingFeature('contentGating') ?? ENTERPRISE_PLAN_LABEL\n\nexport const AI_PRIVACY_MAX_PAGES = 20\n\n/** The visibilities a build may set, by the Page Access card's labels. */\nexport const AI_PRIVACY_VISIBILITIES = ['public', 'unlisted', 'members'] as const\nexport type AiPrivacyVisibility = (typeof AI_PRIVACY_VISIBILITIES)[number]\n\nconst VISIBILITY_VALUES: Readonly<Record<AiPrivacyVisibility, HostScreenVisibility>> = {\n public: HostScreenVisibility.PUBLIC,\n unlisted: HostScreenVisibility.UNLISTED,\n members: HostScreenVisibility.AUTHENTICATED,\n}\n\nconst VISIBILITY_LABELS: Readonly<Record<AiPrivacyVisibility, string>> = {\n public: 'Public',\n unlisted: 'Unlisted',\n members: 'Members only',\n}\n\n/** Where a person finds each change, as the output links and notes name it. */\nexport const AI_PRIVACY_OUTPUTS = {\n maintenance: { id: 'maintenance', label: 'Maintenance mode', where: 'Admin → Error pages' },\n search: { id: 'search', label: 'Search engines', where: 'Setup → SEO' },\n pages: { id: 'pages', label: 'Page access', where: 'each page’s Page Access card' },\n} as const\n\n/** Where the operation's changes are made, as the build's notes name it. */\nexport const AI_PRIVACY_WHERE = 'the site’s privacy settings'\n\n/** The item's arguments, as the planner fills them in. Every one optional. */\nexport const AI_PRIVACY_ARGS_SCHEMA: PluginAiCapabilityArgsSchema = {\n type: 'object',\n properties: {\n maintenance: {\n type: 'boolean',\n description:\n 'true takes the whole site offline: every address shows its 503 page to every visitor, including anyone with a link, until it is turned off. false brings the site back. Leave it out unless the person asked to take the whole site offline, keep it from everyone until launch, or bring it back.',\n },\n discourageSearchEngines: {\n type: 'boolean',\n description:\n 'true asks search engines not to index any page of the site (it stays open to anyone with a link); false lets them index it again. Leave it out unless the person asked about search engines or Google.',\n },\n publicPages: {\n type: 'array',\n description: 'Pages to make Public: anyone can open them, and they are offered to search engines. Each by its id from the site inventory.',\n items: { type: 'string', maxLength: 64 },\n maxItems: AI_PRIVACY_MAX_PAGES,\n },\n unlistedPages: {\n type: 'array',\n description: 'Pages to make Unlisted: anyone with the link can open them, kept out of search results, the sitemap and navigation. Each by its id from the site inventory.',\n items: { type: 'string', maxLength: 64 },\n maxItems: AI_PRIVACY_MAX_PAGES,\n },\n membersPages: {\n type: 'array',\n description: `Pages to make Members only: only visitors signed in to the site can open them (the ${AI_MEMBERS_ONLY_PLAN_LABEL} plan and above). Each by its id from the site inventory.`,\n items: { type: 'string', maxLength: 64 },\n maxItems: AI_PRIVACY_MAX_PAGES,\n },\n },\n additionalProperties: false,\n}\n\n/** Each visibility's argument, as the planner lists the pages for it. */\nconst VISIBILITY_ARGS: Readonly<Record<AiPrivacyVisibility, string>> = {\n public: 'publicPages',\n unlisted: 'unlistedPages',\n members: 'membersPages',\n}\n\n/** What an item asks: each switch to set, and each page's new visibility. */\nexport interface AiPrivacyRequest {\n maintenance: boolean | null\n discourageSearchEngines: boolean | null\n pages: { page: string; visibility: AiPrivacyVisibility }[]\n}\n\nexport interface AiPrivacyRead {\n request: AiPrivacyRequest\n /** A sentence per value that could not be used, so the rest still are. */\n problems: string[]\n}\n\nconst flag = (value: unknown): boolean | null => (typeof value === 'boolean' ? value : null)\n\n/** A page id as the site inventory gives it: one document id, never a path. */\nconst PAGE_ID = /^[A-Za-z0-9_-]{1,64}$/\n\n/** The item's arguments read: what may be written, and a sentence for each that may not. */\nexport function aiPrivacyRequestOf(inputs: Readonly<Record<string, unknown>> | null | undefined): AiPrivacyRead {\n const problems: string[] = []\n const pages: AiPrivacyRequest['pages'] = []\n const asked = new Map<string, Set<AiPrivacyVisibility>>()\n for (const visibility of AI_PRIVACY_VISIBILITIES) {\n const listed = inputs?.[VISIBILITY_ARGS[visibility]]\n for (const entry of Array.isArray(listed) ? listed : []) {\n const page = typeof entry === 'string' ? entry.trim() : ''\n if (PAGE_ID.test(page)) asked.set(page, (asked.get(page) ?? new Set()).add(visibility))\n }\n }\n for (const [page, visibilities] of asked) {\n // A page asked to be two things is left alone rather than guessed at.\n if (visibilities.size > 1) problems.push('A page was asked to be two things at once, so it was left as it is.')\n else pages.push({ page, visibility: [...visibilities][0] })\n }\n if (pages.length > AI_PRIVACY_MAX_PAGES) {\n pages.splice(AI_PRIVACY_MAX_PAGES)\n problems.push(`Only the first ${AI_PRIVACY_MAX_PAGES} pages were changed; ask again for the rest.`)\n }\n return {\n request: {\n maintenance: flag(inputs?.['maintenance']),\n discourageSearchEngines: flag(inputs?.['discourageSearchEngines']),\n pages,\n },\n problems,\n }\n}\n\n/** Whether a read request asks for anything at all. */\nexport function aiPrivacyRequestEmpty(request: AiPrivacyRequest): boolean {\n return request.maintenance === null && request.discourageSearchEngines === null && request.pages.length === 0\n}\n\n// ── The write ─────────────────────────────────────────────────────────────\n\nexport type AiPrivacyWrite =\n | {\n ok: true\n /** A sentence per change asked, made now or already so, by output id. */\n done: { output: keyof typeof AI_PRIVACY_OUTPUTS; said: string }[]\n /** A sentence per part that was not made, and why. */\n notDone: string[]\n changedAny: boolean\n outboxId: string | null\n }\n | { ok: false; error: string }\n\n/**\n * The changes written, in one transaction that reads the host and each named\n * page as they are stored NOW: the member still holds a write role (and is an\n * admin, for maintenance), each page exists and is a page, and only what\n * differs from what is stored is written, with a site-wide publish outbox\n * entry beside it so the live site's cached pages are dropped.\n */\nexport async function writeAiSitePrivacy(\n firestore: Firestore,\n input: { hostId: string; uid: string; request: AiPrivacyRequest; contentGating: boolean; now: Date },\n): Promise<AiPrivacyWrite> {\n const hostRef = firestore.collection('hosts').doc(input.hostId)\n const screens = hostRef.collection('screens')\n return firestore.runTransaction(async (tx): Promise<AiPrivacyWrite> => {\n const host = await tx.get(hostRef)\n if (!host.exists) return { ok: false, error: 'Unknown site' }\n if (!holdsSiteKey(host, input.uid, 'site.edit')) return { ok: false, error: AI_PRIVACY_ROLE_COPY }\n const managesSite = holdsSiteKey(host, input.uid, 'site.manage')\n const pageDocs = await Promise.all(input.request.pages.map((one) => tx.get(screens.doc(one.page))))\n\n const done: { output: keyof typeof AI_PRIVACY_OUTPUTS; said: string }[] = []\n const notDone: string[] = []\n const hostUpdates: Record<string, unknown> = {}\n const pageUpdates: { ref: FirebaseFirestore.DocumentReference; update: Record<string, unknown> }[] = []\n\n const { maintenance, discourageSearchEngines } = input.request\n if (maintenance !== null) {\n if (!managesSite) {\n notDone.push(AI_PRIVACY_ADMIN_COPY)\n } else {\n if ((host.get('maintenance') === true) !== maintenance) {\n hostUpdates['maintenance'] = maintenance || FieldValue.delete()\n }\n const assigned = !!(host.get('errorScreens') as Record<string, unknown> | undefined)?.['unavailable']\n done.push({\n output: 'maintenance',\n said: maintenance\n ? `Maintenance mode is on: every address shows ${assigned ? 'your 503 page' : `${PLATFORM_BRAND_NAME}’s plain “undergoing maintenance” notice, because no 503 page is assigned yet`} to every visitor.`\n : 'Maintenance mode is off: the site is open to visitors again.',\n })\n }\n }\n if (discourageSearchEngines !== null) {\n const stored = (host.get('seo') as Record<string, unknown> | undefined)?.['discourageSearchEngines'] === true\n if (stored !== discourageSearchEngines) {\n hostUpdates['seo.discourageSearchEngines'] = discourageSearchEngines || FieldValue.delete()\n }\n done.push({\n output: 'search',\n said: discourageSearchEngines\n ? 'Search engines are asked not to index this site. Anyone with a link can still open it.'\n : 'Search engines may index this site again. They take days to come back.',\n })\n }\n input.request.pages.forEach((asked, index) => {\n const page = pageDocs[index]\n if (!page.exists || page.get('deletedAt') != null || page.get('kind')) {\n notDone.push('A page named is not one of this site’s pages, so it was left out.')\n return\n }\n const name = String(page.get('displayName') ?? '').trim() || 'A page'\n if (asked.visibility === 'members' && !input.contentGating) {\n // The tenant serves gated pages only on plans with content gating, so\n // writing it here would close the page to everyone.\n notDone.push(`“${name}” was not made Members only: members-only pages need the ${AI_MEMBERS_ONLY_PLAN_LABEL} plan or above.`)\n return\n }\n const value = VISIBILITY_VALUES[asked.visibility]\n const update: Record<string, unknown> = {}\n if ((page.get('visibility') ?? HostScreenVisibility.PUBLIC) !== value) update['visibility'] = value\n const hadPassword = !!(page.get('protection') as Record<string, unknown> | undefined)?.['passwordHash']\n if (hadPassword) update['protection'] = FieldValue.delete()\n if (Object.keys(update).length) pageUpdates.push({ ref: page.ref, update: { ...update, updatedAt: input.now } })\n const extra = hadPassword ? ' Its page password was removed.' : ''\n done.push({ output: 'pages', said: `“${name}” is now ${VISIBILITY_LABELS[asked.visibility]}.${extra}` })\n })\n\n const changedAny = Object.keys(hostUpdates).length > 0 || pageUpdates.length > 0\n if (!changedAny) return { ok: true, done, notDone, changedAny, outboxId: null }\n if (Object.keys(hostUpdates).length) tx.update(hostRef, { ...hostUpdates, updatedAt: input.now })\n for (const { ref, update } of pageUpdates) tx.update(ref, update)\n // Both switches change every page, and a page's visibility changes the\n // navigation and the sitemap every other page carries.\n const outboxRef = firestore.collection('publishOutbox').doc(createResourceUid())\n tx.set(outboxRef, {\n hostId: input.hostId,\n paths: [SCREEN_ROOT_PATH],\n entireHost: true,\n createdAt: FieldValue.serverTimestamp(),\n attempts: 0,\n })\n return { ok: true, done, notDone, changedAny, outboxId: outboxRef.id }\n })\n}\n\n// ── The step ──────────────────────────────────────────────────────────────\n\n/** Why this member may not change who can see this site now, or `null`. */\nexport async function aiPrivacyAccessRefusal(\n input: { host: FirebaseFirestore.DocumentSnapshot; uid: string; org: object | null; request: AiPrivacyRequest },\n deps: { lockdown?: typeof getLockdownVerdict } = {},\n): Promise<string | null> {\n if (!input.host.exists) return 'Unknown site'\n if (!holdsSiteKey(input.host, input.uid, 'site.edit')) return AI_PRIVACY_ROLE_COPY\n // A request that is ONLY maintenance has nothing a non-admin may make.\n const onlyMaintenance =\n input.request.maintenance !== null && input.request.discourageSearchEngines === null && !input.request.pages.length\n if (onlyMaintenance && !holdsSiteKey(input.host, input.uid, 'site.manage')) return AI_PRIVACY_ADMIN_COPY\n const locked = await (deps.lockdown ?? getLockdownVerdict)({\n staff: false,\n uid: input.uid,\n org: input.org as never,\n host: input.host.data() as never,\n intent: 'write',\n })\n return locked ? AI_PRIVACY_LOCKED_COPY : null\n}\n\n/** One output's note: what changed, that it is live, and what was not done. */\nexport function aiPrivacyOutputNote(said: readonly string[], where: string, notDone: readonly string[], changedAny: boolean): string {\n const did = said.length\n ? `${said.join(' ')} Live now, in ${where}.${changedAny ? '' : ' It already was, so nothing was written.'}`\n : 'Nothing needed changing.'\n const not = notDone.length ? ` Not done: ${notDone.join(' ')}` : ''\n return `${did}${not}`.slice(0, 1_000)\n}\n\nexport interface AiJobPrivacyStepDeps {\n write?: typeof writeAiSitePrivacy\n lockdown?: typeof getLockdownVerdict\n dropCache?: typeof dropPluginSiteCache\n}\n\nexport function createAiJobPrivacyStep(deps: AiJobPrivacyStepDeps = {}): AiJobStepRunner {\n const write = deps.write ?? writeAiSitePrivacy\n const dropCache = deps.dropCache ?? dropPluginSiteCache\n return async ({ job, now, firestore, org, modelFor }): Promise<AiJobStepOutcome> => {\n // No model is asked: the outcome records the edit step's at no cost.\n const model = modelFor?.('job.edit') ?? aiJobEditModel()\n const unspent = (failure: string): AiJobStepOutcome => ({ ...aiUnspentOutcome(model), failure })\n const hostId = job.hostId\n if (!hostId) return unspent(AI_PRIVACY_NO_SITE_COPY)\n const read = aiPrivacyRequestOf(job.inputs)\n if (aiPrivacyRequestEmpty(read.request)) return unspent([AI_PRIVACY_NOTHING_COPY, ...read.problems].join(' '))\n const orgData = (org ?? ((await firestore.collection('orgs').doc(job.orgId).get()).data() ?? null)) as Record<string, unknown> | null\n const host = await firestore.collection('hosts').doc(hostId).get()\n const refused = await aiPrivacyAccessRefusal({ host, uid: job.createdBy, org: orgData, request: read.request }, { lockdown: deps.lockdown })\n if (refused) return aiUnspentOutcome(model, { review: aiLimitReview(refused) })\n const written = await write(firestore, {\n hostId,\n uid: job.createdBy,\n request: read.request,\n contentGating: checkEntitlement(orgData as never, 'contentGating'),\n now,\n })\n if (written.ok === false) return unspent(written.error)\n if (written.outboxId) {\n // The live site's cached pages go now; the outbox entry stays for the\n // drain unless the drop certainly happened.\n const dropped = await dropCache({ hostIds: [hostId], reason: 'AI build changed site privacy' }).catch(() => ({ complete: false }))\n if (dropped.complete) await firestore.collection('publishOutbox').doc(written.outboxId).delete().catch(() => undefined)\n }\n const notDone = [...read.problems, ...written.notDone]\n const hostSubdomain = (typeof host.get('subdomain') === 'string' && host.get('subdomain')) || null\n const outputs: AiJobOutput[] = (Object.keys(AI_PRIVACY_OUTPUTS) as (keyof typeof AI_PRIVACY_OUTPUTS)[])\n .filter((key) => written.done.some((one) => one.output === key))\n .map((key, index) => ({\n resource: 'privacy',\n id: AI_PRIVACY_OUTPUTS[key].id,\n hostId,\n hostSubdomain,\n label: AI_PRIVACY_OUTPUTS[key].label,\n note: aiPrivacyOutputNote(\n written.done.filter((one) => one.output === key).map((one) => one.said),\n AI_PRIVACY_OUTPUTS[key].where,\n // What was not done is said once, on the first output.\n index === 0 ? notDone : [],\n written.changedAny,\n ),\n }))\n if (!outputs.length) return unspent([AI_PRIVACY_NOTHING_COPY, ...notDone].join(' '))\n return aiUnspentOutcome(model, { outputs })\n }\n}\n\nexport const runAiJobPrivacyStep = createAiJobPrivacyStep()\n\n// ── Admission ─────────────────────────────────────────────────────────────\n\nexport interface AiPrivacyJobAdmissionDeps {\n ownerOf?: typeof resolveOrgIdForHost\n lockdown?: typeof getLockdownVerdict\n}\n\n/**\n * A privacy change is admitted on a site of the job's own org, for a member\n * who may write it now, where the request names at least one change this can\n * make. Refused in those words before anything is written.\n */\nexport function createAiPrivacyJobAdmission(deps: AiPrivacyJobAdmissionDeps = {}): AiJobAdmission {\n const ownerOf = deps.ownerOf ?? resolveOrgIdForHost\n return async (context): Promise<AiJobAdmissionRefusal | null> => {\n if (!context.hostId) return { status: 400, error: AI_PRIVACY_NO_SITE_COPY }\n const owner = await ownerOf(context.hostId)\n if (!owner || owner !== context.orgId) return { status: 404, error: 'Unknown site' }\n const read = aiPrivacyRequestOf(context.inputs as Record<string, unknown>)\n if (aiPrivacyRequestEmpty(read.request)) return { status: 400, error: [AI_PRIVACY_NOTHING_COPY, ...read.problems].join(' ') }\n const host = await context.firestore.collection('hosts').doc(context.hostId).get()\n const refused = await aiPrivacyAccessRefusal(\n { host, uid: context.uid ?? '', org: context.org, request: read.request },\n { lockdown: deps.lockdown },\n )\n return refused ? { status: 403, error: refused } : null\n }\n}\n\nexport const aiPrivacyJobAdmission = createAiPrivacyJobAdmission()\n\n/** Registers the privacy step and its door (AGL-4033). */\nexport function registerAiPrivacyJob(): void {\n registerAiJobStep(AI_PRIVACY_KIND, runAiJobPrivacyStep, { minimumMs: AI_JOB_PRIVACY_STEP_MINIMUM_MS })\n registerAiJobAdmission(AI_PRIVACY_KIND, aiPrivacyJobAdmission)\n}\n"],"names":["planLabelGrantingFeature","createResourceUid","holdsSiteKey","orgPermissionLabel","aiAddonName","checkEntitlement","ENTERPRISE_PLAN_LABEL","PLATFORM_BRAND_NAME","SCREEN_ROOT_PATH","HostScreenVisibility","dropPluginSiteCache","getLockdownVerdict","resolveOrgIdForHost","FieldValue","registerAiJobAdmission","aiJobEditModel","aiLimitReview","aiUnspentOutcome","registerAiJobStep","AI_PRIVACY_KIND","AI_JOB_PRIVACY_STEP_MINIMUM_MS","AI_PRIVACY_NO_SITE_COPY","AI_PRIVACY_ROLE_COPY","AI_PRIVACY_ADMIN_COPY","AI_PRIVACY_LOCKED_COPY","AI_PRIVACY_NOTHING_COPY","AI_PRIVACY_PASSWORD_COPY","AI_MEMBERS_ONLY_PLAN_LABEL","AI_PRIVACY_MAX_PAGES","AI_PRIVACY_VISIBILITIES","VISIBILITY_VALUES","public","PUBLIC","unlisted","UNLISTED","members","AUTHENTICATED","VISIBILITY_LABELS","AI_PRIVACY_OUTPUTS","maintenance","id","label","where","search","pages","AI_PRIVACY_WHERE","AI_PRIVACY_ARGS_SCHEMA","type","properties","description","discourageSearchEngines","publicPages","items","maxLength","maxItems","unlistedPages","membersPages","additionalProperties","VISIBILITY_ARGS","flag","value","PAGE_ID","aiPrivacyRequestOf","inputs","problems","asked","Map","visibility","listed","entry","Array","isArray","page","trim","test","set","get","Set","add","visibilities","size","push","length","splice","request","aiPrivacyRequestEmpty","writeAiSitePrivacy","firestore","input","hostRef","collection","doc","hostId","screens","runTransaction","tx","host","exists","ok","error","uid","managesSite","pageDocs","Promise","all","map","one","done","notDone","hostUpdates","pageUpdates","delete","assigned","output","said","stored","forEach","index","name","String","contentGating","update","hadPassword","Object","keys","ref","updatedAt","now","extra","changedAny","outboxId","outboxRef","paths","entireHost","createdAt","serverTimestamp","attempts","aiPrivacyAccessRefusal","deps","onlyMaintenance","locked","lockdown","staff","org","data","intent","aiPrivacyOutputNote","did","join","not","slice","createAiJobPrivacyStep","write","dropCache","job","modelFor","model","unspent","failure","read","orgData","orgId","refused","createdBy","review","written","dropped","hostIds","reason","catch","complete","undefined","hostSubdomain","outputs","filter","key","some","resource","note","runAiJobPrivacyStep","createA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GAAEkF,eAAAA,QAAQlF,GAAG,YAAXkF,eAAe;YAAIvC,KAAKuC,QAAQvC,GAAG;YAAE3D,SAAS2E,KAAK3E,OAAO;QAAC,GACxE;YAAEyD,UAAUH,KAAKG,QAAQ;QAAC;QAE5B,OAAOqB,UAAU;YAAEqB,QAAQ;YAAKpF,OAAO+D;QAAQ,IAAI;IACrD;AACF;AAEA,OAAO,MAAMuB,wBAAwBL,8BAA6B;AAElE,wDAAwD,GACxD,OAAO,SAASM;IACdxK,kBAAkBC,iBAAiBgK,qBAAqB;QAAEQ,WAAWvK;IAA+B;IACpGN,uBAAuBK,iBAAiBsK;AAC1C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-privacy-step.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 { createResourceUid } from '@aglyn/aglyn/app-utils/create-resource-uid'\nimport { holdsSiteKey } from '@aglyn/aglyn/app-utils/host-permissions'\nimport { orgPermissionLabel } from '@aglyn/aglyn/app-utils/org-permissions'\nimport {\n aiAddonName,\n checkEntitlement,\n ENTERPRISE_PLAN_LABEL,\n planLabelGrantingFeature,\n} from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport { PLATFORM_BRAND_NAME } from '@aglyn/aglyn/app-utils/platform-brand'\nimport { SCREEN_ROOT_PATH } from '@aglyn/aglyn/app-utils/screen-route'\nimport { HostScreenVisibility } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport { dropPluginSiteCache } from '@aglyn/aglyn/plugin-manager/plugin-site-cache'\nimport type { PluginAiCapabilityArgsSchema } from '@aglyn/aglyn/plugin-manager/plugin-ai-capabilities'\nimport { getLockdownVerdict } from '@aglyn/tenant-data-admin/server/lockdown'\nimport { resolveOrgIdForHost } from '@aglyn/tenant-data-admin/server/organizations'\nimport { FieldValue, type Firestore } from 'firebase-admin/firestore'\nimport type { AiJobOutput } from '../model/ai-jobs.types'\nimport { registerAiJobAdmission, type AiJobAdmission, type AiJobAdmissionRefusal } from './ai-job-admission'\nimport { aiJobEditModel } from './ai-job-edit-step'\nimport { aiLimitReview, aiUnspentOutcome } from './ai-job-generation'\nimport type { AiJobStepOutcome, AiJobStepRunner } from './ai-job-text-step'\nimport { registerAiJobStep } from './ai-jobs'\n\n/**\n * The `privacy` step (AGL-4033): who can see the site, as the console's own\n * three controls set it — maintenance mode (Admin → Error pages), the\n * Discourage search engines switch (Setup → SEO) and a page's Visibility\n * (its Page Access card) — as a first-class build operation, so \"make my site\n * private until launch\" or \"hide the pricing page\" is one item on Assist's\n * plan card. The docs page it mirrors is Site Protection → Make your site\n * private.\n *\n * NO MODEL. The planner already wrote the choices as the item's arguments;\n * this checks each against the rule the console's own control holds it to and\n * writes it, so it costs no credits.\n *\n * ── Only the controls' own fields ────────────────────────────────────────\n *\n * `maintenance` (true, or deleted on the way off, as the Error pages card\n * writes it), `seo.discourageSearchEngines` (likewise, as the Search engines\n * card does), and a page's `visibility` as Public, Unlisted or Members only.\n * Leaving password mode drops the page's stored hash, as the Page Access card\n * does, so protection never lingers on a page that no longer asks for it.\n *\n * NEVER: a page password. Setting one would put the password in the chat and\n * the plan, so it is not an argument; the note sends the person to the Page\n * Access card instead. Nor layouts, emails or record templates, which have no\n * Page Access card, nor the error pages themselves.\n *\n * ── Who may ──────────────────────────────────────────────────────────────\n *\n * Search indexing and page visibility: the Firestore rules' own for those\n * keys, a member with a write role on the site (admin, editor or author)\n * while no lockdown freezes it. Maintenance mode takes every page of the site\n * offline for every visitor, so, as the console keeps its card in the Admin\n * area, only a site ADMIN may change it here. A non-admin's request still\n * makes the rest of its changes and says why that one was not made.\n *\n * Members only is made only where the plan has content gating (Business and\n * above): the tenant serves gated pages nowhere else, so on a lower plan the\n * write would close the page to everyone, and the note says why it was not.\n *\n * ── Live on confirm, idempotent ──────────────────────────────────────────\n *\n * As the `settings` and `tracking` steps: none of these has a draft, so the\n * plan card's confirm is the agreement and the write is live. One transaction\n * re-reads the host and each page, re-checks the role, writes only what\n * differs, and queues a site-wide publish outbox entry, because visibility\n * changes navigation and the sitemap and both switches change every page.\n */\n\nexport const AI_PRIVACY_KIND = 'privacy' as const\n\n/** ASSUMED: the least time the step needs — the site, the org, the pages named and one transaction. */\nexport const AI_JOB_PRIVACY_STEP_MINIMUM_MS = 5_000\n\nexport const AI_PRIVACY_NO_SITE_COPY = 'Open the site whose privacy should change.'\n/** Names \"Edit site content\" (`site.edit`, AGL-4047), never a role. */\nexport const AI_PRIVACY_ROLE_COPY = `Changing who can see the site needs the \"${orgPermissionLabel('site.edit')}\" permission on this site — ask an organization admin.`\n/** Names \"Manage site settings\" (`site.manage`, AGL-4047), never a role. */\nexport const AI_PRIVACY_ADMIN_COPY = `Turning maintenance mode on or off needs the \"${orgPermissionLabel('site.manage')}\" permission, so it was left as it is.`\nexport const AI_PRIVACY_LOCKED_COPY = 'This site is not accepting changes right now.'\nexport const AI_PRIVACY_NOTHING_COPY = 'The request named no privacy change this could make.'\nexport const AI_PRIVACY_PASSWORD_COPY =\n `To put a page behind a password, set it in that page’s Page Access card; ${aiAddonName()} never handles passwords.`\n\n/** The most pages one item may change. */\n/**\n * The cheapest plan with members-only pages (`contentGating`), read from\n * `PLAN_ENTITLEMENTS` so the copy can never name a retired plan (AGL-4158).\n */\nexport const AI_MEMBERS_ONLY_PLAN_LABEL =\n planLabelGrantingFeature('contentGating') ?? ENTERPRISE_PLAN_LABEL\n\nexport const AI_PRIVACY_MAX_PAGES = 20\n\n/** The visibilities a build may set, by the Page Access card's labels. */\nexport const AI_PRIVACY_VISIBILITIES = ['public', 'unlisted', 'members'] as const\nexport type AiPrivacyVisibility = (typeof AI_PRIVACY_VISIBILITIES)[number]\n\nconst VISIBILITY_VALUES: Readonly<Record<AiPrivacyVisibility, HostScreenVisibility>> = {\n public: HostScreenVisibility.PUBLIC,\n unlisted: HostScreenVisibility.UNLISTED,\n members: HostScreenVisibility.AUTHENTICATED,\n}\n\nconst VISIBILITY_LABELS: Readonly<Record<AiPrivacyVisibility, string>> = {\n public: 'Public',\n unlisted: 'Unlisted',\n members: 'Members only',\n}\n\n/** Where a person finds each change, as the output links and notes name it. */\nexport const AI_PRIVACY_OUTPUTS = {\n maintenance: { id: 'maintenance', label: 'Maintenance mode', where: 'Admin → Error pages' },\n search: { id: 'search', label: 'Search engines', where: 'Setup → SEO' },\n pages: { id: 'pages', label: 'Page access', where: 'each page’s Page Access card' },\n} as const\n\n/** Where the operation's changes are made, as the build's notes name it. */\nexport const AI_PRIVACY_WHERE = 'the site’s privacy settings'\n\n/** The item's arguments, as the planner fills them in. Every one optional. */\nexport const AI_PRIVACY_ARGS_SCHEMA: PluginAiCapabilityArgsSchema = {\n type: 'object',\n properties: {\n maintenance: {\n type: 'boolean',\n description:\n 'true takes the whole site offline for visitors: every address shows its 503 page to every visitor, including anyone with a link, until it is turned off, while the site team still sees the site. false brings the site back. Leave it out unless the person asked to take the whole site offline, keep it from everyone until launch, or bring it back.',\n },\n discourageSearchEngines: {\n type: 'boolean',\n description:\n 'true asks search engines not to index any page of the site (it stays open to anyone with a link); false lets them index it again. Leave it out unless the person asked about search engines or Google.',\n },\n publicPages: {\n type: 'array',\n description: 'Pages to make Public: anyone can open them, and they are offered to search engines. Each by its id from the site inventory.',\n items: { type: 'string', maxLength: 64 },\n maxItems: AI_PRIVACY_MAX_PAGES,\n },\n unlistedPages: {\n type: 'array',\n description: 'Pages to make Unlisted: anyone with the link can open them, kept out of search results, the sitemap and navigation. Each by its id from the site inventory.',\n items: { type: 'string', maxLength: 64 },\n maxItems: AI_PRIVACY_MAX_PAGES,\n },\n membersPages: {\n type: 'array',\n description: `Pages to make Members only: only visitors signed in to the site can open them (the ${AI_MEMBERS_ONLY_PLAN_LABEL} plan and above). Each by its id from the site inventory.`,\n items: { type: 'string', maxLength: 64 },\n maxItems: AI_PRIVACY_MAX_PAGES,\n },\n },\n additionalProperties: false,\n}\n\n/** Each visibility's argument, as the planner lists the pages for it. */\nconst VISIBILITY_ARGS: Readonly<Record<AiPrivacyVisibility, string>> = {\n public: 'publicPages',\n unlisted: 'unlistedPages',\n members: 'membersPages',\n}\n\n/** What an item asks: each switch to set, and each page's new visibility. */\nexport interface AiPrivacyRequest {\n maintenance: boolean | null\n discourageSearchEngines: boolean | null\n pages: { page: string; visibility: AiPrivacyVisibility }[]\n}\n\nexport interface AiPrivacyRead {\n request: AiPrivacyRequest\n /** A sentence per value that could not be used, so the rest still are. */\n problems: string[]\n}\n\nconst flag = (value: unknown): boolean | null => (typeof value === 'boolean' ? value : null)\n\n/** A page id as the site inventory gives it: one document id, never a path. */\nconst PAGE_ID = /^[A-Za-z0-9_-]{1,64}$/\n\n/** The item's arguments read: what may be written, and a sentence for each that may not. */\nexport function aiPrivacyRequestOf(inputs: Readonly<Record<string, unknown>> | null | undefined): AiPrivacyRead {\n const problems: string[] = []\n const pages: AiPrivacyRequest['pages'] = []\n const asked = new Map<string, Set<AiPrivacyVisibility>>()\n for (const visibility of AI_PRIVACY_VISIBILITIES) {\n const listed = inputs?.[VISIBILITY_ARGS[visibility]]\n for (const entry of Array.isArray(listed) ? listed : []) {\n const page = typeof entry === 'string' ? entry.trim() : ''\n if (PAGE_ID.test(page)) asked.set(page, (asked.get(page) ?? new Set()).add(visibility))\n }\n }\n for (const [page, visibilities] of asked) {\n // A page asked to be two things is left alone rather than guessed at.\n if (visibilities.size > 1) problems.push('A page was asked to be two things at once, so it was left as it is.')\n else pages.push({ page, visibility: [...visibilities][0] })\n }\n if (pages.length > AI_PRIVACY_MAX_PAGES) {\n pages.splice(AI_PRIVACY_MAX_PAGES)\n problems.push(`Only the first ${AI_PRIVACY_MAX_PAGES} pages were changed; ask again for the rest.`)\n }\n return {\n request: {\n maintenance: flag(inputs?.['maintenance']),\n discourageSearchEngines: flag(inputs?.['discourageSearchEngines']),\n pages,\n },\n problems,\n }\n}\n\n/** Whether a read request asks for anything at all. */\nexport function aiPrivacyRequestEmpty(request: AiPrivacyRequest): boolean {\n return request.maintenance === null && request.discourageSearchEngines === null && request.pages.length === 0\n}\n\n// ── The write ─────────────────────────────────────────────────────────────\n\nexport type AiPrivacyWrite =\n | {\n ok: true\n /** A sentence per change asked, made now or already so, by output id. */\n done: { output: keyof typeof AI_PRIVACY_OUTPUTS; said: string }[]\n /** A sentence per part that was not made, and why. */\n notDone: string[]\n changedAny: boolean\n outboxId: string | null\n }\n | { ok: false; error: string }\n\n/**\n * The changes written, in one transaction that reads the host and each named\n * page as they are stored NOW: the member still holds a write role (and is an\n * admin, for maintenance), each page exists and is a page, and only what\n * differs from what is stored is written, with a site-wide publish outbox\n * entry beside it so the live site's cached pages are dropped.\n */\nexport async function writeAiSitePrivacy(\n firestore: Firestore,\n input: { hostId: string; uid: string; request: AiPrivacyRequest; contentGating: boolean; now: Date },\n): Promise<AiPrivacyWrite> {\n const hostRef = firestore.collection('hosts').doc(input.hostId)\n const screens = hostRef.collection('screens')\n return firestore.runTransaction(async (tx): Promise<AiPrivacyWrite> => {\n const host = await tx.get(hostRef)\n if (!host.exists) return { ok: false, error: 'Unknown site' }\n if (!holdsSiteKey(host, input.uid, 'site.edit')) return { ok: false, error: AI_PRIVACY_ROLE_COPY }\n const managesSite = holdsSiteKey(host, input.uid, 'site.manage')\n const pageDocs = await Promise.all(input.request.pages.map((one) => tx.get(screens.doc(one.page))))\n\n const done: { output: keyof typeof AI_PRIVACY_OUTPUTS; said: string }[] = []\n const notDone: string[] = []\n const hostUpdates: Record<string, unknown> = {}\n const pageUpdates: { ref: FirebaseFirestore.DocumentReference; update: Record<string, unknown> }[] = []\n\n const { maintenance, discourageSearchEngines } = input.request\n if (maintenance !== null) {\n if (!managesSite) {\n notDone.push(AI_PRIVACY_ADMIN_COPY)\n } else {\n if ((host.get('maintenance') === true) !== maintenance) {\n hostUpdates['maintenance'] = maintenance || FieldValue.delete()\n }\n const assigned = !!(host.get('errorScreens') as Record<string, unknown> | undefined)?.['unavailable']\n done.push({\n output: 'maintenance',\n said: maintenance\n ? `Maintenance mode is on: every address shows ${assigned ? 'your 503 page' : `${PLATFORM_BRAND_NAME}’s plain “undergoing maintenance” notice, because no 503 page is assigned yet`} to every visitor. You and your team still see the site.`\n : 'Maintenance mode is off: the site is open to visitors again.',\n })\n }\n }\n if (discourageSearchEngines !== null) {\n const stored = (host.get('seo') as Record<string, unknown> | undefined)?.['discourageSearchEngines'] === true\n if (stored !== discourageSearchEngines) {\n hostUpdates['seo.discourageSearchEngines'] = discourageSearchEngines || FieldValue.delete()\n }\n done.push({\n output: 'search',\n said: discourageSearchEngines\n ? 'Search engines are asked not to index this site. Anyone with a link can still open it.'\n : 'Search engines may index this site again. They take days to come back.',\n })\n }\n input.request.pages.forEach((asked, index) => {\n const page = pageDocs[index]\n if (!page.exists || page.get('deletedAt') != null || page.get('kind')) {\n notDone.push('A page named is not one of this site’s pages, so it was left out.')\n return\n }\n const name = String(page.get('displayName') ?? '').trim() || 'A page'\n if (asked.visibility === 'members' && !input.contentGating) {\n // The tenant serves gated pages only on plans with content gating, so\n // writing it here would close the page to everyone.\n notDone.push(`“${name}” was not made Members only: members-only pages need the ${AI_MEMBERS_ONLY_PLAN_LABEL} plan or above.`)\n return\n }\n const value = VISIBILITY_VALUES[asked.visibility]\n const update: Record<string, unknown> = {}\n if ((page.get('visibility') ?? HostScreenVisibility.PUBLIC) !== value) update['visibility'] = value\n const hadPassword = !!(page.get('protection') as Record<string, unknown> | undefined)?.['passwordHash']\n if (hadPassword) update['protection'] = FieldValue.delete()\n if (Object.keys(update).length) pageUpdates.push({ ref: page.ref, update: { ...update, updatedAt: input.now } })\n const extra = hadPassword ? ' Its page password was removed.' : ''\n done.push({ output: 'pages', said: `“${name}” is now ${VISIBILITY_LABELS[asked.visibility]}.${extra}` })\n })\n\n const changedAny = Object.keys(hostUpdates).length > 0 || pageUpdates.length > 0\n if (!changedAny) return { ok: true, done, notDone, changedAny, outboxId: null }\n if (Object.keys(hostUpdates).length) tx.update(hostRef, { ...hostUpdates, updatedAt: input.now })\n for (const { ref, update } of pageUpdates) tx.update(ref, update)\n // Both switches change every page, and a page's visibility changes the\n // navigation and the sitemap every other page carries.\n const outboxRef = firestore.collection('publishOutbox').doc(createResourceUid())\n tx.set(outboxRef, {\n hostId: input.hostId,\n paths: [SCREEN_ROOT_PATH],\n entireHost: true,\n createdAt: FieldValue.serverTimestamp(),\n attempts: 0,\n })\n return { ok: true, done, notDone, changedAny, outboxId: outboxRef.id }\n })\n}\n\n// ── The step ──────────────────────────────────────────────────────────────\n\n/** Why this member may not change who can see this site now, or `null`. */\nexport async function aiPrivacyAccessRefusal(\n input: { host: FirebaseFirestore.DocumentSnapshot; uid: string; org: object | null; request: AiPrivacyRequest },\n deps: { lockdown?: typeof getLockdownVerdict } = {},\n): Promise<string | null> {\n if (!input.host.exists) return 'Unknown site'\n if (!holdsSiteKey(input.host, input.uid, 'site.edit')) return AI_PRIVACY_ROLE_COPY\n // A request that is ONLY maintenance has nothing a non-admin may make.\n const onlyMaintenance =\n input.request.maintenance !== null && input.request.discourageSearchEngines === null && !input.request.pages.length\n if (onlyMaintenance && !holdsSiteKey(input.host, input.uid, 'site.manage')) return AI_PRIVACY_ADMIN_COPY\n const locked = await (deps.lockdown ?? getLockdownVerdict)({\n staff: false,\n uid: input.uid,\n org: input.org as never,\n host: input.host.data() as never,\n intent: 'write',\n })\n return locked ? AI_PRIVACY_LOCKED_COPY : null\n}\n\n/** One output's note: what changed, that it is live, and what was not done. */\nexport function aiPrivacyOutputNote(said: readonly string[], where: string, notDone: readonly string[], changedAny: boolean): string {\n const did = said.length\n ? `${said.join(' ')} Live now, in ${where}.${changedAny ? '' : ' It already was, so nothing was written.'}`\n : 'Nothing needed changing.'\n const not = notDone.length ? ` Not done: ${notDone.join(' ')}` : ''\n return `${did}${not}`.slice(0, 1_000)\n}\n\nexport interface AiJobPrivacyStepDeps {\n write?: typeof writeAiSitePrivacy\n lockdown?: typeof getLockdownVerdict\n dropCache?: typeof dropPluginSiteCache\n}\n\nexport function createAiJobPrivacyStep(deps: AiJobPrivacyStepDeps = {}): AiJobStepRunner {\n const write = deps.write ?? writeAiSitePrivacy\n const dropCache = deps.dropCache ?? dropPluginSiteCache\n return async ({ job, now, firestore, org, modelFor }): Promise<AiJobStepOutcome> => {\n // No model is asked: the outcome records the edit step's at no cost.\n const model = modelFor?.('job.edit') ?? aiJobEditModel()\n const unspent = (failure: string): AiJobStepOutcome => ({ ...aiUnspentOutcome(model), failure })\n const hostId = job.hostId\n if (!hostId) return unspent(AI_PRIVACY_NO_SITE_COPY)\n const read = aiPrivacyRequestOf(job.inputs)\n if (aiPrivacyRequestEmpty(read.request)) return unspent([AI_PRIVACY_NOTHING_COPY, ...read.problems].join(' '))\n const orgData = (org ?? ((await firestore.collection('orgs').doc(job.orgId).get()).data() ?? null)) as Record<string, unknown> | null\n const host = await firestore.collection('hosts').doc(hostId).get()\n const refused = await aiPrivacyAccessRefusal({ host, uid: job.createdBy, org: orgData, request: read.request }, { lockdown: deps.lockdown })\n if (refused) return aiUnspentOutcome(model, { review: aiLimitReview(refused) })\n const written = await write(firestore, {\n hostId,\n uid: job.createdBy,\n request: read.request,\n contentGating: checkEntitlement(orgData as never, 'contentGating'),\n now,\n })\n if (written.ok === false) return unspent(written.error)\n if (written.outboxId) {\n // The live site's cached pages go now; the outbox entry stays for the\n // drain unless the drop certainly happened.\n const dropped = await dropCache({ hostIds: [hostId], reason: 'AI build changed site privacy' }).catch(() => ({ complete: false }))\n if (dropped.complete) await firestore.collection('publishOutbox').doc(written.outboxId).delete().catch(() => undefined)\n }\n const notDone = [...read.problems, ...written.notDone]\n const hostSubdomain = (typeof host.get('subdomain') === 'string' && host.get('subdomain')) || null\n const outputs: AiJobOutput[] = (Object.keys(AI_PRIVACY_OUTPUTS) as (keyof typeof AI_PRIVACY_OUTPUTS)[])\n .filter((key) => written.done.some((one) => one.output === key))\n .map((key, index) => ({\n resource: 'privacy',\n id: AI_PRIVACY_OUTPUTS[key].id,\n hostId,\n hostSubdomain,\n label: AI_PRIVACY_OUTPUTS[key].label,\n note: aiPrivacyOutputNote(\n written.done.filter((one) => one.output === key).map((one) => one.said),\n AI_PRIVACY_OUTPUTS[key].where,\n // What was not done is said once, on the first output.\n index === 0 ? notDone : [],\n written.changedAny,\n ),\n }))\n if (!outputs.length) return unspent([AI_PRIVACY_NOTHING_COPY, ...notDone].join(' '))\n return aiUnspentOutcome(model, { outputs })\n }\n}\n\nexport const runAiJobPrivacyStep = createAiJobPrivacyStep()\n\n// ── Admission ─────────────────────────────────────────────────────────────\n\nexport interface AiPrivacyJobAdmissionDeps {\n ownerOf?: typeof resolveOrgIdForHost\n lockdown?: typeof getLockdownVerdict\n}\n\n/**\n * A privacy change is admitted on a site of the job's own org, for a member\n * who may write it now, where the request names at least one change this can\n * make. Refused in those words before anything is written.\n */\nexport function createAiPrivacyJobAdmission(deps: AiPrivacyJobAdmissionDeps = {}): AiJobAdmission {\n const ownerOf = deps.ownerOf ?? resolveOrgIdForHost\n return async (context): Promise<AiJobAdmissionRefusal | null> => {\n if (!context.hostId) return { status: 400, error: AI_PRIVACY_NO_SITE_COPY }\n const owner = await ownerOf(context.hostId)\n if (!owner || owner !== context.orgId) return { status: 404, error: 'Unknown site' }\n const read = aiPrivacyRequestOf(context.inputs as Record<string, unknown>)\n if (aiPrivacyRequestEmpty(read.request)) return { status: 400, error: [AI_PRIVACY_NOTHING_COPY, ...read.problems].join(' ') }\n const host = await context.firestore.collection('hosts').doc(context.hostId).get()\n const refused = await aiPrivacyAccessRefusal(\n { host, uid: context.uid ?? '', org: context.org, request: read.request },\n { lockdown: deps.lockdown },\n )\n return refused ? { status: 403, error: refused } : null\n }\n}\n\nexport const aiPrivacyJobAdmission = createAiPrivacyJobAdmission()\n\n/** Registers the privacy step and its door (AGL-4033). */\nexport function registerAiPrivacyJob(): void {\n registerAiJobStep(AI_PRIVACY_KIND, runAiJobPrivacyStep, { minimumMs: AI_JOB_PRIVACY_STEP_MINIMUM_MS })\n registerAiJobAdmission(AI_PRIVACY_KIND, aiPrivacyJobAdmission)\n}\n"],"names":["planLabelGrantingFeature","createResourceUid","holdsSiteKey","orgPermissionLabel","aiAddonName","checkEntitlement","ENTERPRISE_PLAN_LABEL","PLATFORM_BRAND_NAME","SCREEN_ROOT_PATH","HostScreenVisibility","dropPluginSiteCache","getLockdownVerdict","resolveOrgIdForHost","FieldValue","registerAiJobAdmission","aiJobEditModel","aiLimitReview","aiUnspentOutcome","registerAiJobStep","AI_PRIVACY_KIND","AI_JOB_PRIVACY_STEP_MINIMUM_MS","AI_PRIVACY_NO_SITE_COPY","AI_PRIVACY_ROLE_COPY","AI_PRIVACY_ADMIN_COPY","AI_PRIVACY_LOCKED_COPY","AI_PRIVACY_NOTHING_COPY","AI_PRIVACY_PASSWORD_COPY","AI_MEMBERS_ONLY_PLAN_LABEL","AI_PRIVACY_MAX_PAGES","AI_PRIVACY_VISIBILITIES","VISIBILITY_VALUES","public","PUBLIC","unlisted","UNLISTED","members","AUTHENTICATED","VISIBILITY_LABELS","AI_PRIVACY_OUTPUTS","maintenance","id","label","where","search","pages","AI_PRIVACY_WHERE","AI_PRIVACY_ARGS_SCHEMA","type","properties","description","discourageSearchEngines","publicPages","items","maxLength","maxItems","unlistedPages","membersPages","additionalProperties","VISIBILITY_ARGS","flag","value","PAGE_ID","aiPrivacyRequestOf","inputs","problems","asked","Map","visibility","listed","entry","Array","isArray","page","trim","test","set","get","Set","add","visibilities","size","push","length","splice","request","aiPrivacyRequestEmpty","writeAiSitePrivacy","firestore","input","hostRef","collection","doc","hostId","screens","runTransaction","tx","host","exists","ok","error","uid","managesSite","pageDocs","Promise","all","map","one","done","notDone","hostUpdates","pageUpdates","delete","assigned","output","said","stored","forEach","index","name","String","contentGating","update","hadPassword","Object","keys","ref","updatedAt","now","extra","changedAny","outboxId","outboxRef","paths","entireHost","createdAt","serverTimestamp","attempts","aiPrivacyAccessRefusal","deps","onlyMaintenance","locked","lockdown","staff","org","data","intent","aiPrivacyOutputNote","did","join","not","slice","createAiJobPrivacyStep","write","dropCache","job","modelFor","model","unspent","failure","read","orgData","orgId","refused","createdBy","review","written","dropped","hostIds","reason","catch","complete","undefined","hostSubdomain","outputs","filter","key","some","resource","note","runAiJobPrivacyStep","createAiPrivacyJobAdmission","ownerOf","context","status","owner","aiPrivacyJobAdmission","registerAiPrivacyJob","minimumMs"],"mappings":";IA8GEA;AA9GF;;;;;;;;;;;;;;;CAeC,GAED,SAASC,iBAAiB,QAAQ,6CAA4C;AAC9E,SAASC,YAAY,QAAQ,0CAAyC;AACtE,SAASC,kBAAkB,QAAQ,yCAAwC;AAC3E,SACEC,WAAW,EACXC,gBAAgB,EAChBC,qBAAqB,EACrBN,wBAAwB,QACnB,2CAA0C;AACjD,SAASO,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,oBAAoB,QAAQ,qDAAoD;AACzF,SAASC,mBAAmB,QAAQ,gDAA+C;AAEnF,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,mBAAmB,QAAQ,gDAA+C;AACnF,SAASC,UAAU,QAAwB,2BAA0B;AAErE,SAASC,sBAAsB,QAAyD,wBAAoB;AAC5G,SAASC,cAAc,QAAQ,wBAAoB;AACnD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,yBAAqB;AAErE,SAASC,iBAAiB,QAAQ,eAAW;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CC,GAED,OAAO,MAAMC,kBAAkB,UAAkB;AAEjD,qGAAqG,GACrG,OAAO,MAAMC,iCAAiC,KAAK;A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QACnF,MAAM4D,OAAOjG,mBAAmBwH,QAAQvH,MAAM;QAC9C,IAAIsB,sBAAsB0E,KAAK3E,OAAO,GAAG,OAAO;YAAEmG,QAAQ;YAAKpF,OAAO;gBAAC1E;mBAA4BsI,KAAK/F,QAAQ;aAAC,CAACoF,IAAI,CAAC;QAAK;QAC5H,MAAMpD,OAAO,MAAMsF,QAAQ/F,SAAS,CAACG,UAAU,CAAC,SAASC,GAAG,CAAC2F,QAAQ1F,MAAM,EAAEhB,GAAG;QAChF,MAAMsF,UAAU,MAAMzB,uBACpB;YAAEzC;YAAMI,GAAG,GAAEkF,eAAAA,QAAQlF,GAAG,YAAXkF,eAAe;YAAIvC,KAAKuC,QAAQvC,GAAG;YAAE3D,SAAS2E,KAAK3E,OAAO;QAAC,GACxE;YAAEyD,UAAUH,KAAKG,QAAQ;QAAC;QAE5B,OAAOqB,UAAU;YAAEqB,QAAQ;YAAKpF,OAAO+D;QAAQ,IAAI;IACrD;AACF;AAEA,OAAO,MAAMuB,wBAAwBL,8BAA6B;AAElE,wDAAwD,GACxD,OAAO,SAASM;IACdxK,kBAAkBC,iBAAiBgK,qBAAqB;QAAEQ,WAAWvK;IAA+B;IACpGN,uBAAuBK,iBAAiBsK;AAC1C"}
|
|
@@ -398,6 +398,15 @@ const OPEN_STYLES = new Set([
|
|
|
398
398
|
below: 'column',
|
|
399
399
|
above: 'column'
|
|
400
400
|
};
|
|
401
|
+
/**
|
|
402
|
+
* The source's own opening as a hero (AGL-4152): its picture's place, refined
|
|
403
|
+
* by how it sets its words. Over or under a picture, a centered column or a
|
|
404
|
+
* start-aligned editorial; behind them, a poster or a cover; beside them, a split.
|
|
405
|
+
*/ function ownHeroOf(section, place) {
|
|
406
|
+
if (place === 'beside') return 'split';
|
|
407
|
+
if (place === 'behind') return section.align === 'center' ? 'poster' : 'cover';
|
|
408
|
+
return section.align === 'center' ? 'column' : 'editorial';
|
|
409
|
+
}
|
|
401
410
|
/** Where a link of the source goes on the new site, in the compiler's words; `undefined` where it can go nowhere a page may send a visitor. */ function linkTo(scope, href) {
|
|
402
411
|
const value = (href != null ? href : '').trim();
|
|
403
412
|
if (/^mailto:[^\s@]+@[^\s@]+$/i.test(value) || /^tel:\+?[\d\s().-]{3,}$/i.test(value)) return value;
|
|
@@ -1289,30 +1298,6 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1289
1298
|
'cover',
|
|
1290
1299
|
'poster'
|
|
1291
1300
|
]);
|
|
1292
|
-
/**
|
|
1293
|
-
* The heroes that keep the source's picture where it lays it (AGL-4138): under
|
|
1294
|
-
* or over its words in a column, beside them, or behind them. An answer may
|
|
1295
|
-
* choose among these alone.
|
|
1296
|
-
*/ const HEROES_AT = {
|
|
1297
|
-
below: new Set([
|
|
1298
|
-
'column',
|
|
1299
|
-
'editorial'
|
|
1300
|
-
]),
|
|
1301
|
-
above: new Set([
|
|
1302
|
-
'column',
|
|
1303
|
-
'editorial'
|
|
1304
|
-
]),
|
|
1305
|
-
beside: new Set([
|
|
1306
|
-
'split',
|
|
1307
|
-
'bleed',
|
|
1308
|
-
'panel'
|
|
1309
|
-
]),
|
|
1310
|
-
behind: new Set([
|
|
1311
|
-
'cover',
|
|
1312
|
-
'poster',
|
|
1313
|
-
'panel'
|
|
1314
|
-
])
|
|
1315
|
-
};
|
|
1316
1301
|
/**
|
|
1317
1302
|
* The hero a section's opening takes: the first section's, around its picture
|
|
1318
1303
|
* beside, behind or under its words. Words dimmed over the picture draw the
|
|
@@ -1320,14 +1305,24 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1320
1305
|
* picture anywhere but behind it, opens as its source does (AGL-4083): an
|
|
1321
1306
|
* answer never repaints a section's own band. Nor does it move the picture
|
|
1322
1307
|
* (AGL-4138): a picture under centered words stays under them, as a picture
|
|
1323
|
-
* beside the words stays beside them.
|
|
1308
|
+
* beside the words stays beside them. Kept as it is (AGL-4152), the opening is
|
|
1309
|
+
* the source's own whatever the answer says: a hero that moved its words is
|
|
1310
|
+
* set aside with what it asked.
|
|
1324
1311
|
*/ function heroOf(section, index, answer, settled, drawn) {
|
|
1325
1312
|
var _ref;
|
|
1326
1313
|
var _section_hero;
|
|
1327
1314
|
if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
|
|
1315
|
+
const place = section.hero.picture;
|
|
1316
|
+
if (drawn.finish !== 'improve') {
|
|
1317
|
+
const own = ownHeroOf(section, place);
|
|
1318
|
+
if ((answer == null ? void 0 : answer.hero) && answer.hero !== 'none' && answer.hero !== own) settled.push({
|
|
1319
|
+
at: 'sections[0]',
|
|
1320
|
+
what: `the ${answer.hero} hero set aside: the page keeps its source's own opening, a ${own} hero`
|
|
1321
|
+
});
|
|
1322
|
+
return own;
|
|
1323
|
+
}
|
|
1328
1324
|
// An answer of "none" keeps the opening as the source lays it out.
|
|
1329
1325
|
if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
|
|
1330
|
-
const place = section.hero.picture;
|
|
1331
1326
|
const own = HERO_FOR[place];
|
|
1332
1327
|
// Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).
|
|
1333
1328
|
if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {
|
|
@@ -1337,14 +1332,6 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1337
1332
|
});
|
|
1338
1333
|
return own;
|
|
1339
1334
|
}
|
|
1340
|
-
// The picture stays where the source lays it, unless the owner asked the page improved (AGL-4152).
|
|
1341
|
-
if ((answer == null ? void 0 : answer.hero) && drawn.finish !== 'improve' && !HEROES_AT[place].has(answer.hero)) {
|
|
1342
|
-
settled.push({
|
|
1343
|
-
at: 'sections[0]',
|
|
1344
|
-
what: `the ${answer.hero} hero set aside: the source lays its picture ${place} its words`
|
|
1345
|
-
});
|
|
1346
|
-
return own;
|
|
1347
|
-
}
|
|
1348
1335
|
return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
|
|
1349
1336
|
}
|
|
1350
1337
|
/** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */ export function aiSiteImportFinishOf(doc, asked) {
|
|
@@ -1402,7 +1389,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1402
1389
|
};
|
|
1403
1390
|
const pageFilm = layout.sections.reduce((found, section)=>found != null ? found : firstFilm(scope, section.nodes), null);
|
|
1404
1391
|
const sections = layout.sections.map((section, index)=>{
|
|
1405
|
-
var _ref, _firstFilm, _ref1, _ref2;
|
|
1392
|
+
var _ref, _firstFilm, _section_absoluteBand, _ref1, _ref2;
|
|
1406
1393
|
const given = (_ref = answer == null ? void 0 : answer.sections[index]) != null ? _ref : null;
|
|
1407
1394
|
scope.answer = given;
|
|
1408
1395
|
scope.groupAt = 0;
|
|
@@ -1440,7 +1427,9 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1440
1427
|
}));
|
|
1441
1428
|
}
|
|
1442
1429
|
// A band only where the source gave the section none of its own; any section's, on a page its owner asked improved (AGL-4152).
|
|
1443
|
-
|
|
1430
|
+
// Kept, its band against its page's ground (AGL-4152); improved, as its color alone reads.
|
|
1431
|
+
const own = improve ? (_section_absoluteBand = section.absoluteBand) != null ? _section_absoluteBand : section.band : section.band;
|
|
1432
|
+
const band = (given == null ? void 0 : given.band) && (improve || section.background === null && !section.backdrop) ? given.band : own;
|
|
1444
1433
|
const hero = heroOf(section, index, given, scope.settled, {
|
|
1445
1434
|
band: improve ? band : section.band,
|
|
1446
1435
|
finish
|
|
@@ -1630,12 +1619,13 @@ const HEX = /^#[0-9a-f]{6}$/i;
|
|
|
1630
1619
|
const layout = aiSiteImportLayoutOf(doc);
|
|
1631
1620
|
const names = aiSiteImportSectionNames(doc);
|
|
1632
1621
|
return layout.sections.map((section, index)=>{
|
|
1622
|
+
var _section_absoluteBand;
|
|
1633
1623
|
var _section_backdrop, _section_hero;
|
|
1634
1624
|
const groups = {
|
|
1635
1625
|
count: 0
|
|
1636
1626
|
};
|
|
1637
1627
|
const shows = describeNodes(doc, section.nodes, groups);
|
|
1638
|
-
const band = section.background === null && !section.backdrop ? 'no band of its own' : `${section.band} band${((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'gradient' ? ' with a gradient' : ''}`;
|
|
1628
|
+
const band = section.background === null && !section.backdrop ? 'no band of its own' : `${(_section_absoluteBand = section.absoluteBand) != null ? _section_absoluteBand : section.band} band${((_section_backdrop = section.backdrop) == null ? void 0 : _section_backdrop.kind) === 'gradient' ? ' with a gradient' : ''}`;
|
|
1639
1629
|
const hero = index === 0 && ((_section_hero = section.hero) == null ? void 0 : _section_hero.picture) ? `; opens the page, its picture ${section.hero.picture} its words` : index === 0 ? '; opens the page, with no picture' : '';
|
|
1640
1630
|
return `Section ${index + 1} "${names[index]}": ${band}, ${section.align === 'center' ? 'centered' : 'aligned to the start'}${hero}. Groups: ${groups.count}. Shows: ${counted(shows)}.`;
|
|
1641
1631
|
}).join('\n');
|