@taprootio/site-authoring 0.61.0 → 0.64.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 (71) hide show
  1. package/README.md +97 -23
  2. package/package.json +2 -2
  3. package/src/api.js +149 -21
  4. package/src/appearance-contract.js +27 -0
  5. package/src/article-appearance.js +19 -0
  6. package/src/article-appearance.json +9 -0
  7. package/src/article-end-settings.js +295 -0
  8. package/src/changelog.json +49 -0
  9. package/src/chrome-input.js +1 -1
  10. package/src/cli.js +110 -26
  11. package/src/constants.js +7 -0
  12. package/src/content/components.js +130 -14
  13. package/src/content/cta-decoration-paint.js +321 -0
  14. package/src/content/form-placement-presentation.js +91 -0
  15. package/src/content/form-placement-presentation.json +6 -0
  16. package/src/content/free-form-section-registry.json +19 -1
  17. package/src/content/free-form-sections.js +64 -55
  18. package/src/content/markdown.js +13 -0
  19. package/src/content/tiptap-prosemirror.ts +72 -59
  20. package/src/content/validate-document.js +2 -0
  21. package/src/cta-artwork-warnings.js +164 -0
  22. package/src/errors.js +6 -0
  23. package/src/field-schema.json +6 -2
  24. package/src/field-validation.js +14 -5
  25. package/src/footer-workspace.js +7 -3
  26. package/src/form-references.js +71 -9
  27. package/src/forms-contract.js +3 -5
  28. package/src/heading-outline.js +7 -0
  29. package/src/output.js +2 -0
  30. package/src/page-article-end.js +66 -0
  31. package/src/page-block-catalog.js +54 -0
  32. package/src/page-form-presentation.js +104 -0
  33. package/src/page-structure-checks.js +7 -1
  34. package/src/placed-image-ids.js +15 -18
  35. package/src/presentation-reference.js +31 -53
  36. package/src/reference-help.js +97 -27
  37. package/src/reusable-blocks.js +429 -0
  38. package/src/reusable-placements.js +271 -0
  39. package/src/setting-reference.js +57 -1
  40. package/src/settings-catalog.js +3 -0
  41. package/src/site-check-findings.js +30 -2
  42. package/src/site-check-rules.json +1 -0
  43. package/src/site-checks.js +26 -2
  44. package/src/site-health-findings.js +25 -3
  45. package/src/site-health-image-checks.js +1 -1
  46. package/src/staging-check.js +108 -21
  47. package/src/staging-served.js +5 -49
  48. package/src/status-warning-paints.js +17 -0
  49. package/src/template-token-reach.json +20 -2
  50. package/src/theme-resolve.js +27 -0
  51. package/src/transport.js +41 -5
  52. package/src/typed-page-reference.js +55 -5
  53. package/src/typed-pages.js +27 -4
  54. package/src/verbs/approve.js +2 -1
  55. package/src/verbs/deploy.js +93 -15
  56. package/src/verbs/footer-push.js +4 -2
  57. package/src/verbs/forms-push.js +9 -0
  58. package/src/verbs/health.js +11 -6
  59. package/src/verbs/index.js +3 -0
  60. package/src/verbs/pages-blocks-pull.js +22 -0
  61. package/src/verbs/pages-push.js +89 -34
  62. package/src/verbs/plan.js +34 -5
  63. package/src/verbs/pull.js +213 -124
  64. package/src/verbs/status.js +20 -2
  65. package/src/verbs/theme-push.js +170 -20
  66. package/src/verbs/theme-resolve.js +114 -40
  67. package/src/verbs/validate.js +49 -18
  68. package/src/workspace-check.js +42 -5
  69. package/src/workspace-context-usage.js +54 -1
  70. package/src/workspace.js +37 -7
  71. package/test/fixtures/default-site-theme.json +1 -1
package/README.md CHANGED
@@ -211,6 +211,10 @@ site's library (deleted, another site's, or owned media such as a copied video p
211
211
  in `notInSiteLibrary`; `siteChecks.imageCheckReason` says `read_failed` or
212
212
  `read_partly_failed` when the read did not complete. After staging, the stored
213
213
  deployment report (`health --staging`) is the authority, using frozen image defaults.
214
+ Compact form findings (`form.compact_unavailable`) identify `workspace` or
215
+ `catalog` evidence in `detail`. If the evidence is unavailable,
216
+ `siteChecks.formCompactCheckReason` carries `form_definition_unavailable` and
217
+ a message.
214
218
  Without `--describe-missing-images`, placement alt strings and decorative choices never fill a
215
219
  missing reusable default: alt text only suggests the text for the command. Besides `media images describe` and the
216
220
  app, `pages push --describe-missing-images` is the only path that fills one, and only when
@@ -437,6 +441,18 @@ each step names the reference it relies on.
437
441
  inspect the artwork in both schemes on staging. Offline workspaces have no
438
442
  profile fallback metadata, and unknown image dimensions retain conservative
439
443
  footer-fit estimates.
444
+
445
+ On Standard sites, `taproot-site pull --settings-only` uses Design access to
446
+ refresh presentation files while keeping any existing content inventory.
447
+ Edit `settings/reusable-blocks.json`, then run `taproot-site theme push --dry-run`
448
+ to review the changes. An absent file preserves definitions. An empty
449
+ `blocks` array requests to clear them, subject to the site's removal checks.
450
+ Run `taproot-site help settings` for the source schema.
451
+
452
+ Use `taproot-site pages blocks pull` with Content access in a workspace
453
+ already bound to the site. It refreshes form and reusable placement choices
454
+ in `.taproot-site-manifest.json`.
455
+
440
456
  6. **Review on staging in both schemes.** `staging review` (or
441
457
  `deploy --staging --handoff`) returns a single-use handoff in
442
458
  `stagingPreview.url`, on a managed Docs site too; open it once and use the
@@ -463,10 +479,11 @@ taproot-site deploy --production
463
479
 
464
480
  After `deploy --staging`, `health --staging` reads the Site Health warnings the
465
481
  staged release stored, and `deploy --staging` returns the same report as
466
- `siteHealth`. Fix every warning marked `newSinceProduction` before handing the
467
- release over, then stage again: the report belongs to a release, so a fix
468
- changes it only after another `deploy --staging` (and `approve`, for a page
469
- edit). See [Site Health from the CLI in 0.37.0](#site-health-from-the-cli-in-0370).
482
+ `siteHealth`. Fix every warning marked `newSinceProduction: true` and review
483
+ any image findings whose comparison is incomplete before handing the release
484
+ over. The report belongs to a release, so a fix appears after another
485
+ `deploy --staging` (and `approve`, for a page edit). See
486
+ [Site Health from the CLI in 0.37.0](#site-health-from-the-cli-in-0370).
470
487
 
471
488
  `pull` snapshots pages, navigation, redirects, and settings into the
472
489
  workspace: `pages/`, `nav.json`, `redirects.json`, `settings/`, `media/`, and
@@ -504,9 +521,9 @@ that would be replaced by a new remote page.
504
521
  Pages are not only free-form. A source chooses its template with `template:` in
505
522
  its front matter — `article`, `recipe`, `album` or `place-review`; free-form is
506
523
  the default — and `pull` writes the other four as a `.pm.json` wrapper
507
- (`{ "template", "displayDate", "displayAuthor", "showOnProfile", "coverImageId", "data" }`) that `pages push`
524
+ (`{ "template", "displayDate", "displayAuthor", "showOnProfile", "articleEnd", "coverImageId", "data" }`) that `pages push`
508
525
  sends back unchanged. Typed pages also carry `displayDate` (so an import keeps
509
- its original publication date), `displayAuthor` and `showOnProfile` (below) and `coverImage`, which the site requires to be an
526
+ its original publication date), `displayAuthor`, `showOnProfile`, `articleEnd` (below) and `coverImage`, which the site requires to be an
510
527
  image the page itself uses (place it in the body too; `pages.cover_image_unused`). A page's template is fixed when
511
528
  it is created: a source for another template is refused with
512
529
  `pages.template_immutable`. `taproot-site help page <type>` gives each
@@ -692,6 +709,14 @@ it only when it is `false`, `pull` refreshes an unedited document and keeps a
692
709
  Markdown source, and a push that would overwrite a value that changed on the
693
710
  site since the last pull is refused with `pages.push_conflict`.
694
711
 
712
+ On a Standard site, set `articleEnd: false` in an article, recipe, album or
713
+ place review to omit the site's article-end call to action. Use `true` or omit
714
+ the field to follow the site's rules. Markdown front matter and the `.pm.json`
715
+ wrapper accept only booleans (`pages.article_end_invalid`). Before changing an
716
+ existing page's preference, pull its current revision. A stale baseline is
717
+ refused with `pages.push_conflict`. A server that cannot save the change yet
718
+ reports `pages.article_end_unsupported`.
719
+
695
720
  The CLI only fills a page that has no author: a page that already has a
696
721
  different one is refused (`pages.author_conflict`), by the CLI from what the
697
722
  last pull recorded and by Taproot, and naming the author a page already has
@@ -1211,8 +1236,9 @@ once).
1211
1236
  Taproot account; `author:` front matter or `pages meta set --author` credits
1212
1237
  one on a page that has none, and an author is never replaced from the CLI.
1213
1238
  - `redirects check` and `deploy --staging` report `routeCheck`, `redirects` and
1214
- `stagingPreview` at the top level; result paths spell the home page `/`;
1215
- `approve` skips a page with nothing to approve instead of failing the batch.
1239
+ `stagingPreview` at the top level. The checks use the acknowledged stage
1240
+ and show folder sources waiting for their child move. Result paths spell
1241
+ the home page `/`; `approve` skips a page with nothing to approve.
1216
1242
  - `validate` checks a real pulled workspace offline (`validate --init` keeps the
1217
1243
  generated pages navigation links to), and `validate` and `pages push` warn on
1218
1244
  links that look made by autolinking (`content.link_autolinked`).
@@ -1357,9 +1383,12 @@ exits 0 whenever it reads the report, whatever the findings.
1357
1383
  description yourself. An image the site has since described says
1358
1384
  `currentlyDescribed: true`, and one the site no longer has says
1359
1385
  `imageAvailable: false`.
1360
- - With `--staging`, each finding says `newSinceProduction`, and `comparison`
1361
- says whether production had a complete, untruncated report to compare with.
1362
- Without one, every finding is listed as not compared.
1386
+ - With `--staging`, comparable findings say `newSinceProduction`. An image
1387
+ finding is new when it adds an affected page. If an image group cannot be
1388
+ compared, that finding omits the flag and `comparison.imageIdentityComplete`
1389
+ is `false`. If production lacks a complete, untruncated report, `comparison`
1390
+ records that the reports could not be compared. The terminal summarizes all
1391
+ findings and shows as many individually as its output limit allows.
1363
1392
  - Findings are bounded by size (`findingsTotal`, `imageFindingsTotal`,
1364
1393
  `findingsTruncated`, `imageFindingsTruncated`). A site with no stored report
1365
1394
  returns `available: false` with the reason. A managed Docs site returns
@@ -1503,6 +1532,40 @@ fields beside the message, so the command to run after upgrading is in the
1503
1532
  refusal itself. Every release's notes live in one file, `src/changelog.json`,
1504
1533
  and a package test fails when the installed version has no entry there.
1505
1534
 
1535
+ ### Article appearance
1536
+
1537
+ Edit the `settings` object in the pulled `settings/taproot-styles.json` file.
1538
+ For jereme.net, this example gives inline code a light tint and padding.
1539
+
1540
+ ```json
1541
+ {
1542
+ "articleInlineCodeBackground": "subtle",
1543
+ "articleInlineCodePadding": "light",
1544
+ "articleInlineCodeBorder": "none",
1545
+ "articleInlineCodeShadow": "none"
1546
+ }
1547
+ ```
1548
+
1549
+ The tint uses each scheme's link color. The four fields affect only inline code
1550
+ in the article body. Fenced blocks, numbered-list markers, and code elsewhere
1551
+ have their own styles.
1552
+
1553
+ Use separate fields to size article titles. For example, `"articleTitleMobileSize":
1554
+ "1.25"` sets 1.25rem at 390px and below, `"articleTitleDesktopSize": "3"`
1555
+ caps the title at 3rem, and `"articleTitleDesktopAt": "960"` reaches that
1556
+ cap at a 960px viewport with a 16px root font. The title scales between those
1557
+ points. The mobile default is 1.625rem. Taproot tests it at 390px with a
1558
+ 70-character title, the point above which Site Health warns about title length.
1559
+ Leave the desktop size empty to keep the theme's existing large title size.
1560
+ These fields apply only to the article's title. The shared type scale
1561
+ continues to style the rest of the site.
1562
+
1563
+ Omit an article field to preserve the saved value, or use `""` to reset it.
1564
+ Run `taproot-site validate` and `taproot-site theme push --dry-run`, then
1565
+ `taproot-site theme push`. Stage a release that includes Taproot styles,
1566
+ check the article in both schemes, then promote it. See `taproot-site help
1567
+ appearance` for all values and defaults.
1568
+
1506
1569
  ### Staging verification and deployment evidence
1507
1570
 
1508
1571
  `deploy --staging` selects the same changed pages, settings groups and navigation
@@ -1522,6 +1585,13 @@ without the leading slash, and a query is allowed. When a requested handoff cann
1522
1585
  next; `staging review` mints another on any surface. `status` checks that exact current candidate, so a
1523
1586
  completed CLI stage counts as successful until that candidate changes.
1524
1587
 
1588
+ Use `taproot-site deploy --reset-staging` to put the current production release
1589
+ back on Standard staging. This uses the site’s acknowledged production release,
1590
+ including its published settings, and leaves drafts and approvals available.
1591
+ If staging already serves the same release, the command reports
1592
+ `resetStatus: unchanged`. A reset cannot be promoted. Use `deploy --staging`
1593
+ for your next candidate, then review it before promoting.
1594
+
1525
1595
  A page Taproot cannot stage, such as a folder index no page in the release is
1526
1596
  listed on, refuses deployment as `deploy.page_not_stageable` with Taproot's
1527
1597
  reason, naming the page's title, path and ID.
@@ -1534,18 +1604,22 @@ snapshots removed by normal cleanup and legacy snapshots without a candidate
1534
1604
  fingerprint supply no gating evidence. Typed preview failure diagnostics contain
1535
1605
  only error class and known page/node/attribute labels, never renderer messages.
1536
1606
 
1537
- Staging deploys check the current redirect map through the real staging edge.
1538
- Run `taproot-site redirects check` to repeat once the deployment has completed; a redirect is a file inside the release, so it is live exactly when its release is served.
1539
- The Node CLI consumes a separate handoff, retains its short staging cookie in
1540
- memory, and requests each map path without following redirects. Both
1541
- `redirects check` and `deploy --staging` report `routeCheck` and `redirects` at
1542
- the top level of their result: `redirects.items` lists each path, HTTP status
1543
- and Location, and `redirects.verified` requires all entries to match and the
1544
- map revision to remain unchanged. A mismatch is evidence to investigate, not a
1545
- failed deployment. Checks describe the current map, not a historical release.
1546
- Requests have a 90-second deadline with eight concurrent requests; large JSON
1547
- lists have explicit truncation, prioritizing failures. Progress output reports
1548
- each entry. A gate/transport failure never counts as verified.
1607
+ Staging deploys check the acknowledged release’s frozen redirect map through
1608
+ its staging host. Run `taproot-site redirects check` to repeat the check. The
1609
+ CLI authenticates with a separate handoff, keeps its short staging cookie in
1610
+ memory and requests each map path without following redirects.
1611
+
1612
+ Both commands report `routeCheck` and `redirects`. `redirects.items` lists the
1613
+ path, HTTP status and Location. `redirects.stagingReleaseVerified` records
1614
+ whether the edge served the acknowledged release before and after the check.
1615
+ `redirects.verified` also requires every redirect to match and the acknowledged
1616
+ map revision to stay unchanged. `redirects.waitingForMove` lists authored
1617
+ folder redirects held back because this stage still serves those folders.
1618
+ Include the child moves in a later stage to activate them.
1619
+
1620
+ A mismatch leaves the deployment result available for review. Requests share
1621
+ a 90-second deadline and run up to eight at a time. Progress shows each checked
1622
+ entry. Large JSON lists prioritize failures and report truncation.
1549
1623
 
1550
1624
  With `--handoff`, `stagingPreview.url` is a fresh single-use two-minute handoff
1551
1625
  minted **after** checks; without it the check still authenticates with its own
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taprootio/site-authoring",
3
- "version": "0.61.0",
3
+ "version": "0.64.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.10.0",
32
+ "@taprootio/espalier": "7.12.0",
33
33
  "mediabunny": "1.61.1"
34
34
  },
35
35
  "scripts": {
package/src/api.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  CANONICAL_TIMESTAMP,
9
9
  CAPABILITY_REFUSAL_FIELD,
10
10
  changelogCommandSince,
11
+ CLI_BINARY_NAME,
11
12
  CLI_UPGRADE_COMMAND,
12
13
  CLI_UPGRADE_REFUSAL_FIELD,
13
14
  CLI_VERSION,
@@ -132,9 +133,11 @@ export const DEPLOYMENT_STATUSES = Object.freeze([
132
133
  // deployment or coalesced into an already-anchored one.
133
134
  export const DEPLOYMENT_REQUEST_OUTCOME_ACCEPTED = "DEPLOYMENT_REQUEST_OUTCOME_ACCEPTED";
134
135
  export const DEPLOYMENT_REQUEST_OUTCOME_COALESCED = "DEPLOYMENT_REQUEST_OUTCOME_COALESCED";
136
+ export const DEPLOYMENT_REQUEST_OUTCOME_UNCHANGED = "DEPLOYMENT_REQUEST_OUTCOME_UNCHANGED";
135
137
  export const DEPLOYMENT_REQUEST_OUTCOMES = Object.freeze([
136
138
  DEPLOYMENT_REQUEST_OUTCOME_ACCEPTED,
137
139
  DEPLOYMENT_REQUEST_OUTCOME_COALESCED,
140
+ DEPLOYMENT_REQUEST_OUTCOME_UNCHANGED,
138
141
  ]);
139
142
 
140
143
  export const IMAGE_PROCESSING_STATE_UNKNOWN = "IMAGE_PROCESSING_STATE_UNKNOWN";
@@ -551,6 +554,10 @@ export function showOnProfileOf(wire) {
551
554
  return wire?.excludeFromProfile !== true;
552
555
  }
553
556
 
557
+ function articleEndOf(wire) {
558
+ return typeof wire.suppressArticleEnd === "boolean" ? { articleEnd: !wire.suppressArticleEnd } : {};
559
+ }
560
+
554
561
  function displayAuthorOf(summary) {
555
562
  return typeof summary.displayAuthor === "string" ? normalizeAuthorHandle(summary.displayAuthor) ?? "" : "";
556
563
  }
@@ -589,6 +596,7 @@ export function normalizePageSummary(value) {
589
596
  displayAuthor: displayAuthorOf(summary),
590
597
  // Whether the page may appear on its author's Taproot profile (TR01403).
591
598
  showOnProfile: showOnProfileOf(summary),
599
+ ...articleEndOf(summary),
592
600
  // The name the page's author goes by in a write: a site author's handle or
593
601
  // a member's email address, folded. Empty for a page with no author, for a
594
602
  // former member's page, and against a Taproot that predates authors
@@ -650,6 +658,12 @@ export async function getSiteAuthoringCapabilities(client, siteId) {
650
658
  return {
651
659
  authoredTagWritesEnabled: response.authoredTagWritesEnabled,
652
660
  authoredTagWritesPermitted: response.authoredTagWritesPermitted,
661
+ ...(typeof response.articleEndOptOutWritesEnabled === "boolean"
662
+ ? { articleEndOptOutWritesEnabled: response.articleEndOptOutWritesEnabled }
663
+ : {}),
664
+ ...(typeof response.formPlacementPresentationWritesEnabled === "boolean"
665
+ ? { formPlacementPresentationWritesEnabled: response.formPlacementPresentationWritesEnabled }
666
+ : {}),
653
667
  };
654
668
  }
655
669
 
@@ -719,7 +733,14 @@ function withWireProfileFlag(body) {
719
733
  }
720
734
 
721
735
  function pageMutationBody(source, updating) {
722
- const body = withWireProfileFlag(source);
736
+ const { articleEnd, ...otherFields } = source;
737
+ const body = withWireProfileFlag(otherFields);
738
+ if (articleEnd !== undefined) body.suppressArticleEnd = !articleEnd;
739
+ if (updating && body.formPlacementPresentationEdit === true && normalizePageBodyRevision(body.expectedBodyRevision) === undefined) {
740
+ throw new SiteAuthoringError("pages.form_presentation_pull_required",
741
+ "Pull this page before editing its Form presentation so the update can check the editable body revision.",
742
+ { field: "expectedBodyRevision" });
743
+ }
723
744
  if (body.authoredTags === undefined) return body;
724
745
  const wrapper = body.authoredTags;
725
746
  if (wrapper === null || typeof wrapper !== "object" || Array.isArray(wrapper)) {
@@ -769,14 +790,50 @@ export async function getPage(client, pageId, status) {
769
790
  "api.page_contract",
770
791
  "page",
771
792
  );
772
- return { ...page, showOnProfile: showOnProfileOf(page) };
793
+ return { ...page, showOnProfile: showOnProfileOf(page), ...articleEndOf(page) };
794
+ }
795
+
796
+ const HTTP_METHOD_NOT_ALLOWED = 405;
797
+ const HTTP_NOT_IMPLEMENTED = 501;
798
+
799
+ async function writePage(client, path, method, body) {
800
+ const explicit = typeof body.articleEnd === "boolean";
801
+ let response;
802
+ try {
803
+ response = await client.request(explicit ? `${path}/with-article-end-preference` : path, {
804
+ method,
805
+ body: pageMutationBody(body, method === "PATCH"),
806
+ });
807
+ } catch (error) {
808
+ // Older replicas match the create route's suffix as a page ID, but have no POST for that path.
809
+ if (explicit && error instanceof ApiError && error.grpcCode === undefined &&
810
+ [HTTP_NOT_FOUND, HTTP_METHOD_NOT_ALLOWED, HTTP_NOT_IMPLEMENTED].includes(error.httpStatus)) {
811
+ throw new SiteAuthoringError(
812
+ "pages.article_end_unsupported",
813
+ "This Taproot instance cannot save the article-end preference yet. Retry after the site upgrades.",
814
+ { field: "articleEnd" },
815
+ );
816
+ }
817
+ throw error;
818
+ }
819
+ const summary = normalizePageMutation(response, body.authoredTags !== undefined);
820
+ if (body.formPlacementPresentationEdit === true && summary.bodyRevision === undefined) {
821
+ throw new SiteAuthoringError("api.page_contract",
822
+ "Taproot did not confirm the editable body revision. Pull the page to check the Form presentation write.",
823
+ { field: "bodyRevision" });
824
+ }
825
+ if (explicit && summary.articleEnd !== body.articleEnd) {
826
+ throw new SiteAuthoringError(
827
+ "api.page_contract",
828
+ "Taproot did not confirm the article-end preference. Pull the page to check the write.",
829
+ { field: "articleEnd" },
830
+ );
831
+ }
832
+ return summary;
773
833
  }
774
834
 
775
835
  export async function createPage(client, body) {
776
- return normalizePageMutation(
777
- await client.request("v1/pages", { method: "POST", body: pageMutationBody(body, false) }),
778
- body.authoredTags !== undefined,
779
- );
836
+ return await writePage(client, "v1/pages", "POST", body);
780
837
  }
781
838
 
782
839
  /**
@@ -789,13 +846,7 @@ export async function deletePage(client, pageId) {
789
846
  }
790
847
 
791
848
  export async function updatePage(client, pageId, body) {
792
- return normalizePageMutation(
793
- await client.request(`v1/pages/${encodeURIComponent(pageId)}`, {
794
- method: "PATCH",
795
- body: pageMutationBody(body, true),
796
- }),
797
- body.authoredTags !== undefined,
798
- );
849
+ return await writePage(client, `v1/pages/${encodeURIComponent(pageId)}`, "PATCH", body);
799
850
  }
800
851
 
801
852
  /**
@@ -957,6 +1008,22 @@ export async function getSiteRedirectMap(client, siteId) {
957
1008
  );
958
1009
  }
959
1010
 
1011
+ /** Reads the redirects frozen into the currently acknowledged staging release. */
1012
+ export async function getStagedSiteRedirectMap(client, siteId) {
1013
+ const response = await client.request(sitePath(siteId, "redirects?staging=true"), {
1014
+ maximumResponseBytes: LIMITS.redirectMapResponseBytes,
1015
+ });
1016
+ const map = requireRedirectMap(response, siteId);
1017
+ const paths = response.pathsWaitingForMove ?? [];
1018
+ if (!isCanonicalUuid(response.stagingDeploymentId) || !isCanonicalUuid(response.outputReleaseId)
1019
+ || !Array.isArray(paths) || paths.some((path) => typeof path !== "string")) {
1020
+ throw new SiteAuthoringError("api.redirects_contract", "Taproot did not return an acknowledged staging redirect map.");
1021
+ }
1022
+ return {
1023
+ ...map, deploymentId: response.stagingDeploymentId, outputReleaseId: response.outputReleaseId, pathsWaitingForMove: paths,
1024
+ };
1025
+ }
1026
+
960
1027
  /**
961
1028
  * Replaces the whole map. `expectedRevision` is the revision the map was read
962
1029
  * at; the site refuses the write rather than dropping an entry a rename
@@ -1097,8 +1164,13 @@ export async function getSitePresentation(client, siteId) {
1097
1164
  * committed, and applies it when it did not.
1098
1165
  */
1099
1166
  export async function saveSitePresentation(client, siteId, body) {
1167
+ // Older servers accept unknown JSON fields on the scalar save. A structured
1168
+ // change needs its own binding so an older server refuses the whole request.
1169
+ const path = body.reusableBlockDefinitions !== undefined || body.articleEnd !== undefined
1170
+ ? "structured-presentation"
1171
+ : "presentation";
1100
1172
  const response = requireObject(
1101
- await client.replaceablePost(sitePath(siteId, "presentation"), { body: { siteId, ...body } }),
1173
+ await client.replaceablePost(sitePath(siteId, path), { body: { siteId, ...body } }),
1102
1174
  "api.presentation_contract",
1103
1175
  "presentation save",
1104
1176
  );
@@ -1506,10 +1578,17 @@ export async function updateSiteImageDescription(client, siteId, imageId, body)
1506
1578
  * stored when it was generated and never recomputes it, so it does not reflect edits made since. With no
1507
1579
  * `deploymentId` it is the acknowledged production release; with one, that staged release.
1508
1580
  */
1509
- export async function getSiteHealth(client, siteId, { deploymentId: requestedDeploymentId } = {}) {
1581
+ export async function getSiteHealth(client, siteId, { deploymentId: requestedDeploymentId, includeImagePageResourceIds = false } = {}) {
1510
1582
  const code = "api.site_health_contract";
1583
+ const healthQuery = query([
1584
+ ["deploymentId", requestedDeploymentId],
1585
+ ["includeImagePageResourceIds", includeImagePageResourceIds || undefined],
1586
+ ]);
1511
1587
  const response = requireObject(
1512
- await client.request(sitePath(siteId, `health${query([["deploymentId", requestedDeploymentId]])}`)),
1588
+ await client.request(
1589
+ sitePath(siteId, `health${healthQuery}`),
1590
+ includeImagePageResourceIds ? { maximumResponseBytes: LIMITS.siteHealthComparisonResponseBytes } : undefined,
1591
+ ),
1513
1592
  code,
1514
1593
  "site-health report",
1515
1594
  );
@@ -1580,6 +1659,9 @@ export async function getSiteHealth(client, siteId, { deploymentId: requestedDep
1580
1659
  affectedPages: image.affectedPages.map(page => ({
1581
1660
  pageId: requireCanonicalUuid(page?.pageId, code, "affectedPages.pageId"),
1582
1661
  title: text(page?.title), path: text(page?.path),
1662
+ ...(page?.resourceId === undefined ? {} : {
1663
+ resourceId: requireCanonicalUuid(page.resourceId, code, "affectedPages.resourceId"),
1664
+ }),
1583
1665
  })),
1584
1666
  };
1585
1667
  });
@@ -1622,7 +1704,11 @@ export async function getDeploySelection(client, siteId) {
1622
1704
  if (!CANDIDATE_SELECTABLE_SETTINGS_TYPES.includes(group.settingsType)) {
1623
1705
  throw new SiteAuthoringError(code, "Taproot returned an unsupported candidate settings group.");
1624
1706
  }
1625
- return repeated(group.changes, "settings changes").length > 0;
1707
+ const settings = repeated(group.changes, "settings changes");
1708
+ const reusableBlocks = repeated(group.reusableBlockChanges, "reusable block changes");
1709
+ const articleEnd = group.articleEndChange === undefined
1710
+ ? undefined : requireObject(group.articleEndChange, code, "article-end change");
1711
+ return settings.length > 0 || reusableBlocks.length > 0 || articleEnd !== undefined;
1626
1712
  });
1627
1713
  if (review.navigationChanged !== undefined && typeof review.navigationChanged !== "boolean") {
1628
1714
  throw new SiteAuthoringError(code, "Taproot returned an invalid navigation change flag.");
@@ -1666,8 +1752,11 @@ export async function getPublishingReadiness(client, siteId, selection = {}) {
1666
1752
  approvedPageCount: safeCount(response.approvedPageCount),
1667
1753
  selectedPageCount: safeCount(response.selectedPageCount),
1668
1754
  blockedPageCount: safeCount(response.blockedPageCount),
1755
+ protectedCarryCount: safeCount(response.protectedCarryCount),
1669
1756
  hasCandidateChanges: response.hasCandidateChanges === true,
1670
1757
  hasSuccessfulStagingDeployment: response.hasSuccessfulStagingDeployment === true,
1758
+ stagedReleaseUpdateState: text(response.stagedReleaseUpdateState),
1759
+ stagedReleaseUpdateMessage: text(response.stagedReleaseUpdateMessage),
1671
1760
  // Site-wide inputs frozen with every release that differ from production's.
1672
1761
  redirectsChanged: response.redirectsChanged === true,
1673
1762
  formsChanged: response.formsChanged === true,
@@ -1726,16 +1815,23 @@ export async function getStagingPreviewStatus(client, siteId) {
1726
1815
  "staging preview status",
1727
1816
  );
1728
1817
  const ready = response.ready === undefined ? false : response.ready;
1818
+ const deploymentId = response.currentAcknowledgedStagingDeploymentId ?? "";
1729
1819
  if (
1730
1820
  response.siteId !== siteId || typeof ready !== "boolean"
1731
1821
  || (response.hasStagedRelease !== undefined && typeof response.hasStagedRelease !== "boolean")
1822
+ || (deploymentId !== "" && !isCanonicalUuid(deploymentId))
1823
+ || (response.suggestAuthoringPromotionRetry !== undefined && typeof response.suggestAuthoringPromotionRetry !== "boolean")
1732
1824
  ) {
1733
1825
  throw new SiteAuthoringError(
1734
1826
  "api.staging_preview_contract",
1735
1827
  "Taproot returned an invalid staging preview status response.",
1736
1828
  );
1737
1829
  }
1738
- const releaseStatus = response.hasStagedRelease === undefined ? {} : { hasStagedRelease: response.hasStagedRelease };
1830
+ const releaseStatus = {
1831
+ ...(response.hasStagedRelease === undefined ? {} : { hasStagedRelease: response.hasStagedRelease }),
1832
+ ...(deploymentId === "" ? {} : { currentAcknowledgedStagingDeploymentId: deploymentId }),
1833
+ ...(response.suggestAuthoringPromotionRetry === true ? { suggestAuthoringPromotionRetry: true } : {}),
1834
+ };
1739
1835
  if (!ready) return { ready: false, stagingUrl: "", ...releaseStatus };
1740
1836
 
1741
1837
  let url;
@@ -1933,6 +2029,7 @@ export function normalizeDeployment(value) {
1933
2029
  startedAt: text(deployment.startedAt),
1934
2030
  completedAt: text(deployment.completedAt),
1935
2031
  errorMessage: text(deployment.errorMessage),
2032
+ ...(deployment.stagingReset === true ? { stagingReset: true } : {}),
1936
2033
  pageCount: safeCount(deployment.pageCount),
1937
2034
  pagesGenerated: optionalCount(deployment.pagesGenerated),
1938
2035
  phaseTimings: normalizePhaseTimings(deployment.phaseHistory),
@@ -1977,14 +2074,45 @@ export async function listDeployments(
1977
2074
  }
1978
2075
 
1979
2076
  export async function deploySite(client, siteId, body) {
2077
+ return await requestDeployment(client, siteId, "deploy", body);
2078
+ }
2079
+
2080
+ export async function resetSiteStaging(client, siteId) {
2081
+ return await requestDeployment(client, siteId, "deployments/staging/reset", { siteId });
2082
+ }
2083
+
2084
+ async function requestDeployment(client, siteId, path, body) {
1980
2085
  let response;
1981
2086
  try {
1982
2087
  response = requireObject(
1983
- await client.request(sitePath(siteId, "deploy"), { method: "POST", body }),
2088
+ await client.request(sitePath(siteId, path), { method: "POST", body }),
1984
2089
  "api.deployment_contract",
1985
2090
  "deploy",
1986
2091
  );
1987
2092
  } catch (error) {
2093
+ if (error instanceof ApiError && error.stagingResetRefusal !== undefined) {
2094
+ const reason = error.field === undefined ? undefined : error.readableReasonFor(error.field);
2095
+ throw new SiteAuthoringError(error.stagingResetRefusal, reason || error.message, {
2096
+ field: error.field, status: error.status, reason,
2097
+ });
2098
+ }
2099
+ if (error instanceof ApiError && error.stagedReleasePromotion) {
2100
+ const field = "StagingDeploymentId";
2101
+ const { stageAgain, stageAgainReason } = error.stagedReleasePromotion;
2102
+ const reason = error.readableReasonFor(field) || (stageAgain
2103
+ ? "Taproot could not stage your changes again."
2104
+ : "Taproot is updating your staged changes.");
2105
+ const stageAndPromote = `Run '${CLI_BINARY_NAME} deploy --staging', review the staged changes, then run '${CLI_BINARY_NAME} deploy --production'.`;
2106
+ const nextStep = stageAgain
2107
+ ? stageAndPromote
2108
+ : `Run '${CLI_BINARY_NAME} status' to check whether the update has finished. Review the current acknowledged stage before using the production command status reports. `
2109
+ + `If there is no command after the update finishes, stage again. ${stageAndPromote}`;
2110
+ throw new SiteAuthoringError(
2111
+ stageAgain ? "deploy.stage_again" : "deploy.stage_updating",
2112
+ `${reason} ${nextStep}`,
2113
+ { field, status: error.status, reason, nextStep, stageAgainReason },
2114
+ );
2115
+ }
1988
2116
  if (error instanceof ApiError && error.hasField("AuthoringPreviewFailed")) {
1989
2117
  throw new SiteAuthoringError(
1990
2118
  "deploy.preview_failed",
@@ -1994,7 +2122,7 @@ export async function deploySite(client, siteId, body) {
1994
2122
  );
1995
2123
  }
1996
2124
  if (error instanceof ApiError && error.refusalKind() === REFUSAL_UNCLASSIFIED && error.hasField("Hosting")) {
1997
- const staging = body.environment === DEPLOYMENT_ENVIRONMENT_STAGING;
2125
+ const staging = path !== "deploy" || body.environment === DEPLOYMENT_ENVIRONMENT_STAGING;
1998
2126
  const detail = error.descriptionFor("Hosting") ?? "Taproot could not use the site's hosting configuration.";
1999
2127
  throw new SiteAuthoringError(
2000
2128
  "deploy.hosting_unavailable",
@@ -2159,7 +2287,7 @@ async function awaitDeployment(client, { siteId, deploymentId, environment, onPr
2159
2287
  deployment.errorMessage
2160
2288
  ? `The deployment failed: ${deployment.errorMessage}`
2161
2289
  : "The deployment failed.",
2162
- { status: deployment.status },
2290
+ { status: deployment.status, reason: deployment.errorMessage },
2163
2291
  );
2164
2292
  }
2165
2293
  // The phase a reader sees is the latest one the server recorded, or the
@@ -1,3 +1,4 @@
1
+ import { ARTICLE_APPEARANCE_CONTRACT, ARTICLE_APPEARANCE_FIELDS, isArticleAppearanceValue } from "./article-appearance.js";
1
2
  import {
2
3
  BLOCK_SPACINGS,
3
4
  DEFAULT_BLOCK_SPACING,
@@ -70,6 +71,16 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
70
71
  values: Object.freeze(Object.keys(BLOCK_SPACINGS)),
71
72
  default: DEFAULT_BLOCK_SPACING,
72
73
  }),
74
+ ...ARTICLE_APPEARANCE_FIELDS.map(name => Object.freeze({
75
+ settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
76
+ name,
77
+ path: `taproot-styles.${name}`,
78
+ type: "article-appearance",
79
+ ...ARTICLE_APPEARANCE_CONTRACT[name],
80
+ optional: true,
81
+ onlyIfPresent: true,
82
+ default: "",
83
+ })),
73
84
  ...HEADING_SPACING_FIELDS.map((name) => Object.freeze({
74
85
  settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
75
86
  name,
@@ -275,6 +286,15 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
275
286
  default: "",
276
287
  })
277
288
  ),
289
+ Object.freeze({
290
+ settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
291
+ name: "codeCopyEnabled",
292
+ path: "site-publishing-preferences.codeCopyEnabled",
293
+ type: "boolean",
294
+ default: false,
295
+ optional: true,
296
+ onlyIfPresent: true,
297
+ }),
278
298
  Object.freeze({
279
299
  settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
280
300
  name: "recipeJumpControl",
@@ -521,6 +541,13 @@ function validateScalar(definition, value, knownImageIds) {
521
541
  }
522
542
  return JSON.stringify(artwork);
523
543
  }
544
+ case "article-appearance":
545
+ if (!isArticleAppearanceValue(definition.name, value)) {
546
+ const choices = definition.values?.join(", ")
547
+ ?? `a numeric string from ${definition.min} through ${definition.max}${definition.decimalPlaces ? "" : " (whole numbers)"}`;
548
+ fail("theme.setting_invalid", `${definition.path} must be empty or one of these values: ${choices}.`, definition.path);
549
+ }
550
+ return value;
524
551
  case "heading-spacing":
525
552
  if (value !== "" && !isHeadingSpacing(value)) {
526
553
  fail(
@@ -0,0 +1,19 @@
1
+ // Generated from shared/article-appearance.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ import contract from "./article-appearance.json" with { type: "json" };
3
+ export const ARTICLE_APPEARANCE_FIELDS = Object.keys(contract);
4
+ export { contract as ARTICLE_APPEARANCE_CONTRACT };
5
+ export function isArticleAppearanceValue(field, value) {
6
+ if (typeof value !== "string")
7
+ return false;
8
+ if (value === "")
9
+ return true;
10
+ const rule = contract[field];
11
+ if ("values" in rule)
12
+ return rule.values.includes(value);
13
+ const fraction = rule.decimalPlaces ? `(?:\\.[0-9]{1,${rule.decimalPlaces}})?` : "";
14
+ // Match the whole string, including when a newline is present at the end.
15
+ if (!new RegExp(`^(?:0|[1-9][0-9]*)${fraction}(?![\\s\\S])`, "u").test(value))
16
+ return false;
17
+ const number = Number(value);
18
+ return number >= rule.min && number <= rule.max;
19
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "articleInlineCodeBackground": { "values": ["subtle", "transparent", "layer1", "layer2"] },
3
+ "articleInlineCodePadding": { "values": ["none", "light", "regular"] },
4
+ "articleInlineCodeBorder": { "values": ["none", "dotted", "dashed", "solid"] },
5
+ "articleInlineCodeShadow": { "values": ["none", "1", "2", "3"] },
6
+ "articleTitleMobileSize": { "min": 1, "max": 6, "decimalPlaces": 3, "fallback": 1.625 },
7
+ "articleTitleDesktopSize": { "min": 1, "max": 6, "decimalPlaces": 3 },
8
+ "articleTitleDesktopAt": { "min": 640, "max": 1920, "decimalPlaces": 0, "fallback": 1200 }
9
+ }