@taprootio/site-authoring 0.59.0 → 0.61.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 (42) hide show
  1. package/README.md +14 -1
  2. package/package.json +2 -2
  3. package/src/api.js +9 -0
  4. package/src/appearance-contract.js +36 -1
  5. package/src/changelog.json +33 -0
  6. package/src/chrome-additions.js +25 -7
  7. package/src/chrome-input.js +47 -0
  8. package/src/cli.js +4 -2
  9. package/src/content/components.js +21 -6
  10. package/src/content/media-presentation.js +13 -2
  11. package/src/content/validate-document.js +2 -0
  12. package/src/latest-posts-settings.js +78 -0
  13. package/src/legal-roles.js +121 -0
  14. package/src/output.js +2 -0
  15. package/src/page-metadata.js +3 -0
  16. package/src/presentation-reference.js +11 -4
  17. package/src/reference-help.js +16 -3
  18. package/src/session.js +19 -1
  19. package/src/setting-reference.js +21 -2
  20. package/src/settings-catalog.js +5 -0
  21. package/src/site-check-findings.js +8 -3
  22. package/src/status-warning-paints.js +2 -2
  23. package/src/template-token-reach.json +10 -8
  24. package/src/theme-resolve.js +10 -0
  25. package/src/theme-validation.js +11 -1
  26. package/src/token-reach.js +2 -1
  27. package/src/transport.js +15 -2
  28. package/src/typed-page-reference.js +18 -3
  29. package/src/typed-pages.js +3 -1
  30. package/src/verbs/delivery-check.js +31 -10
  31. package/src/verbs/footer-push.js +33 -7
  32. package/src/verbs/pages-meta-set.js +10 -1
  33. package/src/verbs/pages-push.js +12 -4
  34. package/src/verbs/plan.js +1 -0
  35. package/src/verbs/pull.js +26 -4
  36. package/src/verbs/status.js +23 -0
  37. package/src/verbs/theme-push.js +9 -0
  38. package/src/verbs/theme-resolve.js +1 -0
  39. package/src/verbs/validate.js +14 -5
  40. package/src/workspace-check.js +20 -8
  41. package/src/workspace-context-usage.js +12 -5
  42. package/test/fixtures/default-site-theme.json +1 -1
package/README.md CHANGED
@@ -729,7 +729,16 @@ push of the whole workspace, even when Taproot changed it since the pull. If the
729
729
  site no longer has the page (its folder is gone, or Taproot retired its kind),
730
730
  a whole-workspace push reports the file under `pages.staleGeneratedSources` and
731
731
  sends nothing for it, and `pull` says so; delete the file. Naming that path in
732
- `pages push <page-path>` is refused with `pages.generated_create`. A description over 160 characters is warned about,
732
+ `pages push <page-path>` is refused with `pages.generated_create`. A folder index
733
+ lives while a page is listed in its folder, as a draft, approved or published.
734
+ When approving a move leaves none there, an index with no live version (never
735
+ published, or already retired) is deleted, if the approver may delete any page,
736
+ and the next `pull` reports its source as gone. While no page is listed in
737
+ a folder, an approved edit of its index is left out of `deploy`, `status` and the
738
+ page estimate, and a published index is retired by the promotion that publishes
739
+ the move. An index the navigation links to is kept and marked unavailable: remove
740
+ the link, unapprove the index on the site's Pages page (the CLI cannot
741
+ unapprove), then save any page to delete it. A description over 160 characters is warned about,
733
742
  since search results cut it off, and one over 1000 is refused.
734
743
 
735
744
  `pages push [page-path...]` validates and sends the selected pages, or every
@@ -1513,6 +1522,10 @@ without the leading slash, and a query is allowed. When a requested handoff cann
1513
1522
  next; `staging review` mints another on any surface. `status` checks that exact current candidate, so a
1514
1523
  completed CLI stage counts as successful until that candidate changes.
1515
1524
 
1525
+ A page Taproot cannot stage, such as a folder index no page in the release is
1526
+ listed on, refuses deployment as `deploy.page_not_stageable` with Taproot's
1527
+ reason, naming the page's title, path and ID.
1528
+
1516
1529
  A retained failed preview of selected page content refuses deployment as
1517
1530
  `deploy.preview_failed`, naming the page and snapshot. Render a new successful
1518
1531
  preview or change the content; `--allow-failed-preview` is the explicit override.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taprootio/site-authoring",
3
- "version": "0.59.0",
3
+ "version": "0.61.0",
4
4
  "description": "Taproot site authoring CLI: sign in once in the browser, then pull, validate, push, preview, approve, and deploy a site from the terminal",
5
5
  "type": "module",
6
6
  "license": "ISC",
@@ -29,7 +29,7 @@
29
29
  "test/fixtures/default-site-theme.json"
30
30
  ],
31
31
  "dependencies": {
32
- "@taprootio/espalier": "7.8.0",
32
+ "@taprootio/espalier": "7.10.0",
33
33
  "mediabunny": "1.61.1"
34
34
  },
35
35
  "scripts": {
package/src/api.js CHANGED
@@ -2010,6 +2010,15 @@ export async function deploySite(client, siteId, body) {
2010
2010
  { field: "ExpectedPageCount", status: error.status },
2011
2011
  );
2012
2012
  }
2013
+ if (error instanceof ApiError && error.hasField("StagedPageIds")) {
2014
+ // The server names the page and says why it cannot be staged (TR01430); the bare field name did not.
2015
+ const fallback = "Taproot cannot stage a page in this release. Nothing was staged.";
2016
+ throw new SiteAuthoringError(
2017
+ "deploy.page_not_stageable",
2018
+ sanitizeDiagnostic(error.descriptionFor("StagedPageIds") ?? fallback, fallback),
2019
+ { field: "StagedPageIds", status: error.status },
2020
+ );
2021
+ }
2013
2022
  throw error;
2014
2023
  }
2015
2024
  const deployment = normalizeDeployment(response.deployment);
@@ -19,6 +19,7 @@ import { AUTHORED_TAG_SLUG, authoredTagSlug, validateAuthoredTagNames } from "./
19
19
  import { CONTENT_INSET_OPTIONS, DEFAULT_CONTENT_INSET } from "./content-inset.js";
20
20
  import { hasControlCharacter, isCanonicalUuid, SiteAuthoringError } from "./errors.js";
21
21
  import { FOOTER_PRESENTATION_FIELDS } from "./footer-content.js";
22
+ import { LATEST_POSTS_INTERACTIONS, LISTING_CARD_BORDER_WIDTH_MAX } from "./latest-posts-settings.js";
22
23
  import { DEFAULT_PAGE_TAG_BADGES, PAGE_TAG_BADGE_MODES } from "./page-tag-badge-modes.js";
23
24
  import { refuseRetiredFooterColors } from "./footer-contract.js";
24
25
  import { HEADER_HEIGHT_MULTIPLIER_LIMITS, LOGO_VARIANTS, parseHeaderHeightMultiplier } from "./header-presentation.js";
@@ -315,6 +316,39 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
315
316
  onlyIfPresent: true,
316
317
  })
317
318
  ),
319
+ Object.freeze({
320
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
321
+ name: "listingCardInteraction",
322
+ path: "site-publishing-preferences.listingCardInteraction",
323
+ type: "enum",
324
+ values: LATEST_POSTS_INTERACTIONS,
325
+ default: LATEST_POSTS_INTERACTIONS[0],
326
+ emptyIsDefault: true,
327
+ optional: true,
328
+ onlyIfPresent: true,
329
+ }),
330
+ Object.freeze({
331
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
332
+ name: "listingCardBorderWidth",
333
+ path: "site-publishing-preferences.listingCardBorderWidth",
334
+ type: "number",
335
+ integer: true,
336
+ minimum: 0,
337
+ maximum: LISTING_CARD_BORDER_WIDTH_MAX,
338
+ default: 1,
339
+ emptyIsDefault: true,
340
+ optional: true,
341
+ onlyIfPresent: true,
342
+ }),
343
+ Object.freeze({
344
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
345
+ name: "listingCardContext",
346
+ path: "site-publishing-preferences.listingCardContext",
347
+ type: "theme-context",
348
+ default: "",
349
+ optional: true,
350
+ onlyIfPresent: true,
351
+ }),
318
352
  Object.freeze({
319
353
  settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
320
354
  name: "recipeMetadataDestinations",
@@ -556,10 +590,11 @@ function validateScalar(definition, value, knownImageIds) {
556
590
  || !Number.isFinite(value)
557
591
  || value < definition.minimum
558
592
  || value > definition.maximum
593
+ || (definition.integer === true && !Number.isInteger(value))
559
594
  ) {
560
595
  fail(
561
596
  "theme.setting_invalid",
562
- `${definition.path} must be a number from ${definition.minimum} through ${definition.maximum}.`,
597
+ `${definition.path} must be ${definition.integer === true ? "a whole" : "a"} number from ${definition.minimum} through ${definition.maximum}.`,
563
598
  definition.path,
564
599
  );
565
600
  }
@@ -1,5 +1,38 @@
1
1
  {
2
2
  "entries": [
3
+ {
4
+ "version": "0.61.0",
5
+ "note": "Feedback from building jereme.net on 0.59.0: a deleted page's path can take a redirect, legal roles and keys are checked before a push, refused fields carry Taproot's reason, Espalier 7.9.0 and 7.10.0 add button, header and heading controls, and listing cards take a site default.",
6
+ "behavior": [
7
+ "Server side, once this release deploys: a page you delete (pages delete, which stages a live page's removal) no longer holds its path, and neither does a folder index once every page under it is deleted, so redirects push accepts a redirect from that path and it goes live in the release that removes the page. Keeping or restoring the page takes its path back. 0.60.0's site refused such a redirect forever. validate applies the same rule offline, and help redirects describes moving pages to another site.",
8
+ "Server side: a deployment held behind a briefly busy budget lock retries within seconds instead of waiting five minutes, and the reason for every hold is logged.",
9
+ "A refused field now carries Taproot's reason: \"Taproot rejected the request field 'DocumentRole': This document role is managed by Taproot…\". The JSON failure adds error.reason. A reason that looks like a key or a signed URL is withheld.",
10
+ "validate, plan and pages push refuse a legal source whose documentRole only Taproot's platform legal site may use (pages.legal_role_taproot_owned), an empty or unknown role, an other_notice whose documentKey is not the last segment of its path (pages.legal_key_path_mismatch), one with a key Taproot reserves (pages.legal_key_reserved), or a membership_terms source whose documentKey is not '<product-slug>-membership-terms' at /<product-slug>/membership-terms (pages.legal_membership_terms_mismatch; the site still checks the product exists). help page legal names the roles a creator site may use: other_notice (its privacy policy included) and membership_terms.",
11
+ "Legal pages carry no description, so validate and deploy health no longer report seo.description_* for them, and pages meta set --description refuses a legal page (pages.legal_description_unsupported).",
12
+ "status reports authoredTagWrites { enabled, permitted } and says when a push that sets tags would be refused. help page article lists tags? in the .pm.json form.",
13
+ "pull records whether each legal page was ever published. delivery check --staging leaves an approved, never-published legal page out of its sample and lists it in uncheckedRoutes with the reason; footer push (and its dry run) and validate report footerLinkWarnings for a footer link whose page the release will not carry, named by its label or, for an inline link, its words.",
14
+ "pull lists retiredGeneratedSources in its JSON, and a targeted pages push reports staleGeneratedSources too. theme resolve --json names the usedIn and contextUsageSkipped fields it had to drop in usageFieldsOmitted. validate's help says problemsTruncated appears only when problems were cut.",
15
+ "Published sites: an image maxHeight given as a bare percentage (\"50%\") is that share of the screen height, as the site's image height is; a percentage inside calc() is ignored and the site height applies. Post-card titles step down with the card's width and take up to five lines over a cover, which holds a title within the 15–70 character guidance on the usual card widths; a longer one ends in an ellipsis, and validate's seo.title_long advice says cards may cut it. A Latest Posts card with tag badges presses under a held mouse button and takes its hover step only on keyboard focus. Latest Posts takes interaction: grow (the default), lift, press or none, sharing the card grid's motion.",
16
+ "site-publishing-preferences.json takes a site-level listing card default, all three optional: listingCardInteraction (grow, lift, press or none), listingCardBorderWidth (0–20, default 1) and listingCardContext (a theme context name, checked against the theme like the header and footer contexts; a profile site, which renders in its owner's theme, accepts only an empty value). Folder index, archive and profile feed cards follow it, and a Latest Posts component uses it for an interaction or border width it leaves out; the context colors every list's cards, so their border and shadow can differ from the page around them. help settings describes them.",
17
+ "Espalier 7.9.0 settables: --esp-byline-color (author and date links), --esp-header-shadow and --esp-header-border-bottom-width, --esp-footer-bottom-size (tiny, small, normal), --esp-badge-shape (pill, theme, square), --esp-button-outline-hover-background (a filled outline button otherwise hovers from its own fill), and a negative --esp-button-hover-offset that moves a button toward its shadow, keyboard focus included. The theme field typeRatioMin sets the type ratio at viewportMin, and headings balance their lines. theme resolve (its text view included) and the fit lints now report the label ink fitted to an outline fill, so a theme that passed before can see a new apca-target-unmet finding.",
18
+ "Espalier 7.10.0: buttons ease their hover and press move and shadow over 0.2s, as cards do (reduced motion still drops the move); --esp-button-border-color edges filled buttons per context apart from the zone border (outline buttons keep --esp-button-outline-border-color); and the outline-hover fit lint names a hover the theme leaves unset as derived from the resting fill.",
19
+ "Taproot refuses older authoring clients at sign-in and token exchange once this release deploys. Automation that signs in with TAPROOT_SITE_KEY skips that exchange, so upgrade it explicitly. Upgrade with npm install -g @taprootio/site-authoring@latest.",
20
+ "The help reference version is 85."
21
+ ],
22
+ "help": ["redirects", "page", "pages", "delivery", "footer", "theme", "component", "tokens"]
23
+ },
24
+ {
25
+ "version": "0.60.0",
26
+ "note": "An emptied folder index no longer blocks staging: deploys leave it out, approving the move that empties a folder deletes its unpublished index, and deploy shows Taproot's reason when it cannot stage a page.",
27
+ "behavior": [
28
+ "Server side, once this release deploys: an approved edit of a generated page that no staging could produce, such as a folder index no page is listed in any more, is left out of the deploy review's release set, of status readiness (approvedPageCount and the default selection) and of the page estimate, and staging no longer refuses it when it is left unselected. A folder index you customized and approved, whose last page then moved to another folder, used to make deploy --staging fail with StagedPageIds while status reported READY.",
29
+ "When approving a move leaves no draft, approved or published page listed in a folder, that folder's index is deleted if it has no live version (never published, or already retired) and the approver may delete any page; the next pull reports its source as gone. A published index is retired by the promotion that publishes the move. An index the navigation links to is kept and marked unavailable until the link is removed. approve's approved list leaves out an index this deleted. help page generated says so.",
30
+ "deploy fails with deploy.page_not_stageable (field StagedPageIds) and Taproot's reason, naming the page's title, path and ID, when a page in the release cannot be staged; 0.59.0 printed only \"Taproot rejected the request field 'StagedPageIds'.\" The deploy note names the code.",
31
+ "Taproot refuses older authoring clients at sign-in and token exchange once this release deploys. Automation that signs in with TAPROOT_SITE_KEY skips that exchange, so upgrade it explicitly. Upgrade with npm install -g @taprootio/site-authoring@latest.",
32
+ "The help reference version is 84."
33
+ ],
34
+ "help": ["pages", "page"]
35
+ },
3
36
  {
4
37
  "version": "0.59.0",
5
38
  "note": "Follow-ups from the 0.58.0 trial: Espalier 7.8.0 outline buttons, button shadow and footer heading colors, file lines and every section problem in validate, pages and sections behind each context count, and delivery and help fixes.",
@@ -39,18 +39,35 @@ export function addUsageFields(result, { usedIn = new Map(), skipped } = {}) {
39
39
  if (wanted.length === 0 && skipped === undefined) return result;
40
40
  // The result is already wrapped, so what it measures is what is left.
41
41
  const room = LIMITS.githubOutputBytes - bytes(result);
42
+ const fit = (available) => {
43
+ const kept = [...wanted];
44
+ while (kept.length > 0 && listCost(kept) + skippedCost > available) kept.pop();
45
+ let reported = skipped;
46
+ if (skipped !== undefined && listCost(kept) + skippedCost > available) {
47
+ const left = available - listCost(kept);
48
+ reported = boundSkippedLinks(skipped, left - keyBytes);
49
+ if (keyBytes + bytes(reported) > left) reported = undefined;
50
+ }
51
+ return { kept, reported };
52
+ };
42
53
  // Adding a list to a record costs its comma and `"usedIn":[...]`, which is the object's size less its two braces.
43
54
  const listCost = (rows) => rows.reduce((sum, [, list]) => sum + bytes({ usedIn: list }) - 1, 0);
44
55
  // What the field adds beyond its value: the comma, the quoted key and the colon.
45
56
  const keyBytes = bytes({ contextUsageSkipped: 0 }) - 3 + 1;
46
57
  const skippedCost = skipped === undefined ? 0 : keyBytes + bytes(skipped);
47
- const kept = [...wanted];
48
- while (kept.length > 0 && listCost(kept) + skippedCost > room) kept.pop();
49
- let reported = skipped;
50
- if (skipped !== undefined && listCost(kept) + skippedCost > room) {
51
- const available = room - listCost(kept);
52
- reported = boundSkippedLinks(skipped, available - keyBytes);
53
- if (keyBytes + bytes(reported) > available) reported = undefined;
58
+ let { kept, reported } = fit(room);
59
+ // A field left out is named, so a caller reading only JSON knows to narrow the run (TR01433).
60
+ let omitted;
61
+ const marker = (left, dropped) => ({
62
+ ...(left > 0 ? { usedIn: left } : {}),
63
+ ...(dropped ? { contextUsageSkipped: true } : {}),
64
+ narrowWith: "taproot-site theme resolve --scheme <light|dark> --context <name>",
65
+ });
66
+ const markerCost = bytes({ usageFieldsOmitted: marker(wanted.length, true) }) + 1;
67
+ // When even the marker cannot fit, the progress text is all that is left.
68
+ if ((kept.length < wanted.length || (skipped !== undefined && reported === undefined)) && room >= markerCost) {
69
+ ({ kept, reported } = fit(room - markerCost));
70
+ omitted = marker(wanted.length - kept.length, skipped !== undefined && reported === undefined);
54
71
  }
55
72
  const lists = new Map(kept);
56
73
  const seen = new Set();
@@ -64,6 +81,7 @@ export function addUsageFields(result, { usedIn = new Map(), skipped } = {}) {
64
81
  }),
65
82
  }),
66
83
  ...(reported === undefined ? {} : { contextUsageSkipped: reported }),
84
+ ...(omitted === undefined ? {} : { usageFieldsOmitted: omitted }),
67
85
  };
68
86
  }
69
87
 
@@ -124,10 +124,57 @@ function* navigationPageItems(items) {
124
124
 
125
125
  function* footerPageTargets(node) {
126
126
  if (node === null || typeof node !== "object") return;
127
+ // An inline link is a rich-text run, and its words are its label (TR01437).
128
+ if (typeof node.link?.pageResourceId === "string") {
129
+ yield { label: node.text, resourceId: node.link.pageResourceId };
130
+ return;
131
+ }
127
132
  if (typeof node.pageResourceId === "string") yield { label: node.label, resourceId: node.pageResourceId };
128
133
  for (const value of Object.values(node)) yield* footerPageTargets(value);
129
134
  }
130
135
 
136
+ /**
137
+ * An approved legal page that pull recorded as never published: deploy leaves legal pages to the app, so no CLI
138
+ * release carries it (TR01433). A published legal page with an approved revision still serves its published version,
139
+ * and an entry from an older pull, which records neither, is not assumed absent.
140
+ */
141
+ export function isUnpublishedApprovedLegalPage(page) {
142
+ return page?.templateType === "TEMPLATE_TYPE_LEGAL" && page.status === PAGE_STATUS_APPROVED
143
+ && page.neverPublished === true;
144
+ }
145
+
146
+ /**
147
+ * Footer links to a page the CLI's next release will not carry, which the published footer prints as plain words
148
+ * (TR01433): a page not yet approved, or an approved legal page that was never published, since deploy leaves legal
149
+ * pages to the app.
150
+ */
151
+ export function unservedFooterLinks(pages, footerSettings) {
152
+ if (footerSettings?.enabled !== true) return [];
153
+ const byResource = new Map((pages ?? []).filter((page) => isCanonicalUuid(page?.resourceId))
154
+ .map((page) => [page.resourceId, page]));
155
+ const found = [];
156
+ for (const target of footerPageTargets(footerSettings)) {
157
+ const page = byResource.get(target.resourceId);
158
+ // A page this workspace does not know is refused by the footer contract before this check runs.
159
+ const reason = page === undefined
160
+ ? undefined
161
+ : !LINKED_PAGE_STATUSES.has(page.status)
162
+ ? "page_not_approved"
163
+ : isUnpublishedApprovedLegalPage(page)
164
+ ? "legal_page_not_published"
165
+ : undefined;
166
+ if (reason === undefined) continue;
167
+ const path = normalizePagePath(page?.path);
168
+ found.push({
169
+ label: [...sanitizeDiagnostic(String(target.label || ""), "footer link")].slice(0, MAXIMUM_SKIPPED_LABEL).join(""),
170
+ resourceId: target.resourceId,
171
+ path: path === undefined ? null : sanitizedPath(`/${path}`),
172
+ reason,
173
+ });
174
+ }
175
+ return found;
176
+ }
177
+
131
178
  /** A path safe to print and to put in a result: control and bidirectional characters removed, null when none is left. */
132
179
  function sanitizedPath(path) {
133
180
  return typeof path === "string" ? sanitizeDiagnostic(path, "") || null : null;
package/src/cli.js CHANGED
@@ -160,7 +160,7 @@ const VERBS = Object.freeze([
160
160
  + "is the other shape: it carries file plus a document-relative field. Any other Markdown problem "
161
161
  + "stops that file at its first, and so does a decoration or background problem in a typed page such as an "
162
162
  + "article; recipe steps report all of theirs. The JSON keeps the problems that fit its size budget and reports "
163
- + "problemCount and problemsTruncated, error.problems holds at most 5,000, and stderr lists the problems kept. "
163
+ + "problemCount always, and problemsTruncated: true only when some were dropped; error.problems holds at most 5,000, and stderr lists the problems kept. "
164
164
  + "A pulled workspace is checked offline against the pages (generated ones included, "
165
165
  + "so navigation to a folder index resolves), images, and baselines its manifests recorded at the pull. "
166
166
  + "A link whose address is only http(s):// plus its own text (left by older editor autolinking) is reported in "
@@ -934,7 +934,9 @@ const VERBS = Object.freeze([
934
934
  + "rendered, and is null when the server reports none (a production promotion of a staged output, a failed "
935
935
  + "deployment, or an older record); null is not 0. selection.stagedPageCount is the pages selected for this "
936
936
  + "deploy. readiness.pageEstimate.plannedPageCount is the pages staging would generate, the number charged "
937
- + "against the pages-generated allowance. "
937
+ + "against the pages-generated allowance. deploy.page_not_stageable carries Taproot's reason a page in the release "
938
+ + "cannot be staged, naming its title, path and ID, such as a folder index no page in the release is listed on "
939
+ + "(see 'help page generated'). "
938
940
  + STAGING_REVIEW_SESSION_NOTE,
939
941
  },
940
942
  {
@@ -96,7 +96,10 @@ const image = (options = {}) => Object.freeze({ kind: "image", ...options });
96
96
  */
97
97
  const safeUrl = (options = {}) =>
98
98
  Object.freeze({ kind: "safe-url", ...(options.https ? { required: true, allowEmpty: false } : {}), ...options });
99
- /** A CSS length the published renderer accepts as a per-block override; `allowNone` adds `none` (a max height). */
99
+ /**
100
+ * A CSS length the published renderer accepts as a per-block override. `allowNone` makes it a max height: it adds
101
+ * `none` and reads a bare percentage as that share of the screen height (TR01434).
102
+ */
100
103
  const cssLength = (options = {}) => Object.freeze({ kind: "css-length", ...options });
101
104
  // A border width: CSS takes no percentage there.
102
105
  const borderLength = (options = {}) => cssLength({ ...options, percent: false });
@@ -331,9 +334,15 @@ const LATEST_POSTS = Object.freeze({
331
334
  borderWidth: num({
332
335
  integer: true,
333
336
  minimum: 0,
334
- description: "Pixel border around each card, as on a card grid; the grid itself is never framed. 0 boxes nothing; omitted publishes 1.",
337
+ description: "Pixel border around each card, as on a card grid; the grid itself is never framed. 0 boxes nothing; omitted follows the site's listing card default, 1 until set (taproot-site help settings).",
335
338
  }),
336
339
  bannerScheme: enumOf("auto", "light", "dark"),
340
+ interaction: describedEnum({
341
+ grow: "On hover or focus a card grows slightly and casts a shadow. The default until the site's listingCardInteraction setting says otherwise; omitted follows that setting, which folder and archive pages use too.",
342
+ lift: "On hover or focus a card rises and casts a shadow, as on a card grid.",
343
+ press: "A card rests on a shadow, moves toward it on hover and presses flat when pressed, as on a card grid. It reads as a press when theme shadow levels 1 and 2 are hard offsets; see 'help theme'.",
344
+ none: "No hover effect.",
345
+ }),
337
346
  });
338
347
 
339
348
  /** The registry owns the row heights; the help text and the renderer derive from the same map. */
@@ -475,7 +484,7 @@ const VIDEO_ASPECT_RATIO_RE = new RegExp(VIDEO_ASPECT_RATIO_PATTERN, "u");
475
484
 
476
485
  /** Shown with both video blocks: the two optional fields follow the same site settings images use. */
477
486
  const MEDIA_PRESENTATION_HELP =
478
- "Leave maxHeight and borderWidth out to follow the site's image max height and border; set maxHeight (a viewport or fixed height such as 50vh or 30rem, or none) or borderWidth (such as 4px, or 0 for no border) to override them for this block. The frame is never wider than the video's own pixel size.";
487
+ "Leave maxHeight and borderWidth out to follow the site's image max height and border; set maxHeight (a viewport or fixed height such as 50vh or 30rem, a bare percentage such as 50% for that share of the screen height, or none; a percentage inside calc() is ignored and the site height applies) or borderWidth (such as 4px, or 0 for no border) to override them for this block. The frame is never wider than the video's own pixel size.";
479
488
 
480
489
  /**
481
490
  * `VideoData`. The page names a library video by id and nothing about where it
@@ -847,6 +856,7 @@ const COMPONENT_DEFINITIONS = Object.freeze({
847
856
  showAuthor: false,
848
857
  borderWidth: 1,
849
858
  bannerScheme: "auto",
859
+ interaction: "grow",
850
860
  },
851
861
  [
852
862
  "Use tags with tagMatch any (the default) or all. Names are case-insensitive. Omit tags or pass [] for no tag filter.",
@@ -1341,7 +1351,7 @@ function describe(spec) {
1341
1351
  } safe HTTP(S), mailto, tel, non-protocol-relative root path, fragment, query, or relative URL; backslashes and ASCII control characters are rejected`;
1342
1352
  case "css-length":
1343
1353
  return spec.allowNone
1344
- ? "a CSS height such as 60vh or 32rem, or none"
1354
+ ? "a CSS height such as 60vh or 32rem, a percentage of the screen height such as 50%, or none"
1345
1355
  : "a CSS width such as 2px or 0.25rem, or 0 for no border";
1346
1356
  case "texture-name":
1347
1357
  return "a lowercase hyphenated texture identifier of at most 64 characters";
@@ -1388,8 +1398,13 @@ function validateValue(spec, value, path, errors) {
1388
1398
  }
1389
1399
  return;
1390
1400
  case "css-length":
1391
- // The renderer drops a value outside this grammar silently, so it is refused here instead.
1392
- if (normalizeCssLengthOverride(value, { allowNone: spec.allowNone === true, percent: spec.percent !== false }) === null) fail(describe(spec));
1401
+ // The renderer drops a value outside this grammar silently, so it is refused here instead. A max height keeps the
1402
+ // grammar it always had: a bare percentage is now read as screen height, and a percentage inside calc() falls
1403
+ // back to the site height rather than blocking a source saved before TR01434.
1404
+ if (
1405
+ normalizeCssLengthOverride(value, { ...(spec.allowNone === true ? { allowNone: true } : {}), percent: spec.percent !== false })
1406
+ === null
1407
+ ) fail(describe(spec));
1393
1408
  return;
1394
1409
  case "texture-name":
1395
1410
  if (
@@ -108,9 +108,20 @@ export function normalizeCssLengthOverride(value, options) {
108
108
  return trimmed;
109
109
  return null;
110
110
  }
111
- /** The validated max height override of a block (a CSS length or "none"), or null for the site default. */
111
+ /**
112
+ * The validated max height override of a block (a CSS length or "none"), or null for the site default.
113
+ * A bare percentage reads as that share of the screen height, the unit of the site default: a page body
114
+ * has no set height, so `max-height: 50%` would not cap the image at all. A percentage inside `calc()`
115
+ * cannot be read that way, so it is refused (TR01434).
116
+ */
112
117
  export function normalizeMaxHeightOverride(value) {
113
- return normalizeCssLengthOverride(value, { allowNone: true });
118
+ const length = normalizeCssLengthOverride(value, { allowNone: true });
119
+ if (length === null)
120
+ return null;
121
+ const percent = /^(\d+(?:\.\d+)?)%$/.exec(length);
122
+ if (percent)
123
+ return `${percent[1]}vh`;
124
+ return length.includes("%") ? null : length;
114
125
  }
115
126
  /** The validated border width override of a block (a CSS length), or null for the site default. */
116
127
  export function normalizeBorderWidthOverride(value) {
@@ -193,6 +193,8 @@ const IMAGE_ATTRS = Object.freeze({
193
193
  ? null
194
194
  : `one of ${IMAGE_MAX_HEIGHT_OPTIONS.join(", ")} or "site-default"`;
195
195
  }),
196
+ // A bare percentage is read as screen height; a percentage inside calc() falls back to the site height (TR01434),
197
+ // so a source saved before then still pushes.
196
198
  maxHeight: optionalCssLength({ allowNone: true }),
197
199
  borderWidth: optionalCssLength(),
198
200
  presentationPlacement: optionalEnum(IMAGE_PRESENTATION_PLACEMENTS, [TIPTAP_SITE_DEFAULT]),
@@ -0,0 +1,78 @@
1
+ // Generated from shared/latest-posts-settings.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ /**
3
+ * The Latest Posts component's settings rules, shared by the generator's
4
+ * renderer and the editor's form and preview so all three agree on what a
5
+ * stored value means.
6
+ *
7
+ * This file is the canonical source. The generator and the UX editor each keep
8
+ * an identical copy (see `shared/css-validation.ts` for why the generator
9
+ * cannot import from `shared/` directly); a parity test keeps them in step.
10
+ */
11
+ export const LATEST_POSTS_MAX_COUNT = 12;
12
+ /** How a card answers a pointer or keyboard focus; grow is the look cards have always had (TR01434). */
13
+ export const LATEST_POSTS_INTERACTIONS = ["grow", "lift", "press", "none"];
14
+ /** The widest border the site listing card default accepts; the API's `ListingCardValues.MaxBorderWidth` agrees (TR01438). */
15
+ export const LISTING_CARD_BORDER_WIDTH_MAX = 20;
16
+ export const LATEST_POSTS_DEFAULTS = Object.freeze({
17
+ count: 6,
18
+ columns: 3,
19
+ // Cards are bordered unless an author sets 0 (TR00930).
20
+ borderWidth: 1,
21
+ bannerScheme: "auto",
22
+ interaction: "grow",
23
+ });
24
+ const COLUMN_CHOICES = new Set([1, 2, 3, 4]);
25
+ const BANNER_SCHEMES = new Set(["auto", "light", "dark"]);
26
+ function finiteNumber(value) {
27
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
28
+ }
29
+ export function latestPostsCount(value) {
30
+ if (value === "all")
31
+ return value;
32
+ const count = finiteNumber(value);
33
+ return count === undefined
34
+ ? LATEST_POSTS_DEFAULTS.count
35
+ : Math.min(Math.max(Math.round(count), 1), LATEST_POSTS_MAX_COUNT);
36
+ }
37
+ /** Grid columns. A single post spans the full width whatever was saved. */
38
+ export function latestPostsColumns(value, count) {
39
+ if (count === 1)
40
+ return 1;
41
+ return COLUMN_CHOICES.has(value) ? value : LATEST_POSTS_DEFAULTS.columns;
42
+ }
43
+ /** `fallback` is the site's listing card default for a list that leaves the width out (TR01438). */
44
+ export function latestPostsBorderWidth(value, fallback = LATEST_POSTS_DEFAULTS.borderWidth) {
45
+ // Only an absent option follows the site; a stored value that cannot be read keeps today's default.
46
+ if (value === undefined)
47
+ return fallback;
48
+ const width = finiteNumber(value);
49
+ return width === undefined || width < 0 ? LATEST_POSTS_DEFAULTS.borderWidth : Math.round(width);
50
+ }
51
+ /** `auto` follows the page scheme. */
52
+ export function latestPostsBannerScheme(value) {
53
+ return BANNER_SCHEMES.has(value)
54
+ ? value
55
+ : LATEST_POSTS_DEFAULTS.bannerScheme;
56
+ }
57
+ /** `fallback` is the site's listing card default for a list that leaves the interaction out (TR01438). */
58
+ export function latestPostsInteraction(value, fallback = LATEST_POSTS_DEFAULTS.interaction) {
59
+ if (value === undefined)
60
+ return fallback;
61
+ return LATEST_POSTS_INTERACTIONS.includes(value)
62
+ ? value
63
+ : LATEST_POSTS_DEFAULTS.interaction;
64
+ }
65
+ /** The site's border width is a whole number of pixels within its limit, else the default; a list's own override keeps its looser rule. */
66
+ function listingCardBorderWidth(value) {
67
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= LISTING_CARD_BORDER_WIDTH_MAX
68
+ ? value
69
+ : LATEST_POSTS_DEFAULTS.borderWidth;
70
+ }
71
+ /** Unset preferences give the look cards had before the site setting existed. */
72
+ export function resolveListingCardDefaults(preferences) {
73
+ return {
74
+ interaction: latestPostsInteraction(preferences?.listingCardInteraction),
75
+ borderWidth: listingCardBorderWidth(preferences?.listingCardBorderWidth),
76
+ context: typeof preferences?.listingCardContext === "string" ? preferences.listingCardContext : "",
77
+ };
78
+ }
@@ -0,0 +1,121 @@
1
+ import { SiteAuthoringError } from "./errors.js";
2
+
3
+ /**
4
+ * Legal document roles as the site checks them (`LegalDocumentRoles` and
5
+ * `LegalDocumentPageValidation` in the API), so a creator site learns before a
6
+ * push which role it may use (TR01433).
7
+ */
8
+
9
+ export const LEGAL_ROLE_OTHER_NOTICE = "other_notice";
10
+ export const LEGAL_ROLE_MEMBERSHIP_TERMS = "membership_terms";
11
+
12
+ /** The roles a creator site may use. Every other role is Taproot's own. */
13
+ export const CREATOR_LEGAL_ROLES = Object.freeze([LEGAL_ROLE_OTHER_NOTICE, LEGAL_ROLE_MEMBERSHIP_TERMS]);
14
+
15
+ /** Roles only Taproot's platform legal site may use (`LegalDocumentRoles.IsTaprootOwned`). */
16
+ export const TAPROOT_OWNED_LEGAL_ROLES = Object.freeze([
17
+ "platform_terms",
18
+ "privacy_notice",
19
+ "cookie_notice",
20
+ "affiliate_agreement",
21
+ "creator_commerce_terms",
22
+ "creator_merchant_commerce_terms",
23
+ "member_purchase_terms",
24
+ "creator_merchant_member_purchase_terms",
25
+ "free_membership_program_terms",
26
+ "free_membership_join_terms",
27
+ ]);
28
+
29
+ /** A membership-terms key is its product slug and this suffix, at `/<product-slug>/membership-terms` (`LegalDocumentRoles`). */
30
+ const MEMBERSHIP_TERMS_KEY_SUFFIX = "-membership-terms";
31
+ const MEMBERSHIP_TERMS_PATH_SEGMENT = "membership-terms";
32
+
33
+ /** The site's document key rule (`LegalDocumentPageValidation.DocumentKeyPattern`). */
34
+ const DOCUMENT_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
35
+
36
+ /**
37
+ * Document keys Taproot reserves for its own roles: the site resolves an other_notice with one of these keys to the
38
+ * Taproot-owned role (`LegalDocumentRoles.Resolve`).
39
+ */
40
+ export const TAPROOT_RESERVED_LEGAL_KEYS = Object.freeze([
41
+ "terms-of-service",
42
+ "privacy-notice",
43
+ "cookie-notice",
44
+ "affiliate-agreement",
45
+ "creator-commerce-terms",
46
+ "member-purchase-terms",
47
+ "creator-merchant-commerce-terms",
48
+ "creator-merchant-member-purchase-terms",
49
+ "free-membership-program-terms",
50
+ "free-membership-join-terms",
51
+ ]);
52
+
53
+ /**
54
+ * The refusal for a legal source's role and key at its path, or undefined. `platformLegalSite` is true only when
55
+ * the stored legal-drafts sign-in says this is Taproot's platform legal site. Whether a membership-terms key names
56
+ * one of the site's products only the site can check; its key and path shape are checked here (TR01437).
57
+ */
58
+ export function legalRoleRefusal({ documentRole, documentKey }, pagePath, file, { platformLegalSite = false } = {}) {
59
+ const role = (documentRole ?? "").trim().toLowerCase();
60
+ if (TAPROOT_OWNED_LEGAL_ROLES.includes(role)) {
61
+ if (platformLegalSite) return undefined;
62
+ return new SiteAuthoringError(
63
+ "pages.legal_role_taproot_owned",
64
+ `'${file}' uses the documentRole '${role}', which only Taproot's platform legal site may use. A site's own `
65
+ + `policy, its privacy policy included, uses '${LEGAL_ROLE_OTHER_NOTICE}' with the documentKey equal to the `
66
+ + "last segment of its path (documentKey 'privacy' at /privacy).",
67
+ { field: `${file}:data.documentRole` },
68
+ );
69
+ }
70
+ if (!CREATOR_LEGAL_ROLES.includes(role)) {
71
+ return new SiteAuthoringError(
72
+ "pages.legal_role_unknown",
73
+ `'${file}' ${role === "" ? "has no documentRole" : `has the documentRole '${role}', which Taproot does not know`}. Use one of: `
74
+ + `${CREATOR_LEGAL_ROLES.join(", ")}.`,
75
+ { field: `${file}:data.documentRole` },
76
+ );
77
+ }
78
+ // As the site compares them: the key trimmed of spaces and slashes and lower-cased, the last path segment as written.
79
+ const lastSegment = (pagePath ?? "").split("/").filter(Boolean).at(-1) ?? "";
80
+ const key = (documentKey ?? "").trim().replace(/^\/+|\/+$/gu, "").toLowerCase();
81
+ if (role === LEGAL_ROLE_OTHER_NOTICE && !platformLegalSite
82
+ && TAPROOT_RESERVED_LEGAL_KEYS.includes(key)) {
83
+ return new SiteAuthoringError(
84
+ "pages.legal_key_reserved",
85
+ `'${file}' uses the documentKey '${key}', which Taproot reserves for its own documents. Use another key and `
86
+ + "a path ending in it (documentKey 'privacy' at /privacy).",
87
+ { field: `${file}:data.documentKey` },
88
+ );
89
+ }
90
+ if (!DOCUMENT_KEY_PATTERN.test(key)) {
91
+ return new SiteAuthoringError(
92
+ "pages.legal_key_invalid",
93
+ `'${file}' has the documentKey '${key}'; a document key uses lowercase letters, numbers and hyphens.`,
94
+ { field: `${file}:data.documentKey` },
95
+ );
96
+ }
97
+ if (role === LEGAL_ROLE_OTHER_NOTICE && key !== lastSegment) {
98
+ return new SiteAuthoringError(
99
+ "pages.legal_key_path_mismatch",
100
+ `'${file}' is an ${LEGAL_ROLE_OTHER_NOTICE} with the documentKey '${documentKey ?? ""}', but its path ends in `
101
+ + `'${lastSegment}'. An ${LEGAL_ROLE_OTHER_NOTICE}'s documentKey is the last segment of its path.`,
102
+ { field: `${file}:data.documentKey` },
103
+ );
104
+ }
105
+ if (role === LEGAL_ROLE_MEMBERSHIP_TERMS) {
106
+ const productSlug = key.endsWith(MEMBERSHIP_TERMS_KEY_SUFFIX) ? key.slice(0, -MEMBERSHIP_TERMS_KEY_SUFFIX.length) : "";
107
+ // The site trims the path of slashes and compares it as written.
108
+ const path = (pagePath ?? "").replace(/^\/+|\/+$/gu, "");
109
+ if (productSlug === "" || path !== `${productSlug}/${MEMBERSHIP_TERMS_PATH_SEGMENT}`) {
110
+ return new SiteAuthoringError(
111
+ "pages.legal_membership_terms_mismatch",
112
+ `'${file}' is ${LEGAL_ROLE_MEMBERSHIP_TERMS} with the documentKey '${documentKey ?? ""}' at /${path}. Membership `
113
+ + `terms use the documentKey '<product-slug>${MEMBERSHIP_TERMS_KEY_SUFFIX}' at `
114
+ + `/<product-slug>/${MEMBERSHIP_TERMS_PATH_SEGMENT}, where <product-slug> is one of the site's membership `
115
+ + "products; the site checks that the product exists.",
116
+ { field: `${file}:data.documentKey` },
117
+ );
118
+ }
119
+ }
120
+ return undefined;
121
+ }
package/src/output.js CHANGED
@@ -39,6 +39,8 @@ export function failureResult(error) {
39
39
  error: { code: error.code },
40
40
  };
41
41
  if (error.field) result.error.field = error.field;
42
+ // The site's reason for a refused field, so an agent reading only JSON learns what to change (TR01433).
43
+ if (typeof error.reason === "string" && error.reason !== "") result.error.reason = error.reason;
42
44
  if (error.rule) result.error.rule = error.rule;
43
45
  if (error.details?.length) result.error.details = error.details;
44
46
  if (error.status) result.error.status = error.status;
@@ -1,3 +1,4 @@
1
+ import { documentTemplate, TEMPLATE_LEGAL } from "./typed-pages.js";
1
2
  import { SiteAuthoringError } from "./errors.js";
2
3
  import { DESCRIPTION_WARN_LENGTH } from "./page-structure-checks.js";
3
4
  import { boundedByBytes } from "./session.js";
@@ -30,6 +31,8 @@ export function requireDescriptionLength(description, field = "description") {
30
31
  export function descriptionWarnings(pages, onProgress) {
31
32
  const items = [];
32
33
  for (const page of pages ?? []) {
34
+ // A legal page carries no description: Taproot drops it (TR01433).
35
+ if (page.document !== null && typeof page.document === "object" && documentTemplate(page.document) === TEMPLATE_LEGAL) continue;
33
36
  const description = page.metadataDescriptionKnown === false ? undefined : page.declaredDescription ?? page.description;
34
37
  if (typeof description !== "string" || length(description.trim()) <= DESCRIPTION_WARN_LENGTH) continue;
35
38
  const item = {