@taprootio/site-authoring 0.41.1 → 0.55.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/README.md +50 -0
- package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
- package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
- package/package.json +4 -3
- package/src/api.js +170 -11
- package/src/appearance-contract.js +278 -8
- package/src/authored-tag-names.js +88 -0
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +39 -4
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +154 -0
- package/src/chrome-features.js +152 -0
- package/src/chrome-input.js +147 -0
- package/src/chrome-output.js +92 -0
- package/src/chrome-paint-catalog-taproot.json +52 -0
- package/src/chrome-report.js +173 -0
- package/src/cli.js +48 -17
- package/src/content/components.js +27 -4
- package/src/content/external-link.js +2 -1
- package/src/content/markdown.js +271 -101
- package/src/content/tiptap-prosemirror.ts +125 -43
- package/src/content/validate-document.js +4 -1
- package/src/content-inset.js +48 -0
- package/src/errors.js +1 -0
- package/src/espalier-shared.js +26 -0
- package/src/field-suggestions.js +40 -0
- package/src/fixture-init.js +22 -5
- package/src/font-catalog.js +11 -1
- package/src/footer-brand-inputs.js +25 -2
- package/src/footer-content.js +38 -0
- package/src/footer-contract.js +11 -0
- package/src/footer-cta-styles.js +6 -0
- package/src/footer-draft-hash.js +4 -2
- package/src/footer-fit.js +62 -15
- package/src/footer-workspace.js +60 -16
- package/src/header-presentation.js +16 -0
- package/src/latest-posts-tags.js +57 -0
- package/src/page-structure-checks.js +5 -0
- package/src/page-tag-badge-modes.js +6 -0
- package/src/page-tag-writes.js +158 -0
- package/src/page-type-tags.js +16 -0
- package/src/presentation-reference.js +312 -86
- package/src/recipe-page-options.js +22 -0
- package/src/recipe-step-contract.js +164 -0
- package/src/recipe-step-contract.json +65 -0
- package/src/reference-help.js +164 -78
- package/src/session.js +39 -24
- package/src/setting-reference.js +239 -48
- package/src/settings-catalog.js +63 -0
- package/src/site-check-findings.js +25 -5
- package/src/site-check-rules.json +3 -1
- package/src/site-health-findings.js +13 -13
- package/src/site-navigation-groups.js +70 -0
- package/src/styling-fixed-values.js +71 -0
- package/src/tag-destination-warnings.js +35 -0
- package/src/template-token-reach.json +242 -0
- package/src/theme-proposals.js +18 -27
- package/src/theme-resolve.js +305 -51
- package/src/theme-validation.js +126 -6
- package/src/token-reach.js +222 -0
- package/src/typed-page-reference.js +72 -15
- package/src/typed-pages.js +171 -71
- package/src/verbs/deploy.js +6 -0
- package/src/verbs/footer-push.js +30 -5
- package/src/verbs/forms-push.js +11 -3
- package/src/verbs/pages-delete.js +19 -10
- package/src/verbs/pages-push.js +125 -36
- package/src/verbs/plan.js +10 -4
- package/src/verbs/pull.js +277 -67
- package/src/verbs/staging-review.js +27 -1
- package/src/verbs/status.js +22 -0
- package/src/verbs/theme-push.js +249 -120
- package/src/verbs/theme-resolve.js +310 -47
- package/src/verbs/validate.js +71 -17
- package/src/workspace-check.js +37 -4
- package/src/workspace.js +37 -1
- package/test/fixtures/default-site-theme.json +516 -0
package/README.md
CHANGED
|
@@ -921,6 +921,37 @@ its pages-generated allowance, or the bandwidth pause on deploys,
|
|
|
921
921
|
surfaced at deploy; the allowance shows its reset time, while the bandwidth pause shows the earliest
|
|
922
922
|
time it can lift, since it lifts only after a month ends under the allowance or on upgrade), and `throttled` (back off).
|
|
923
923
|
|
|
924
|
+
### Indexed contrast in `theme resolve`
|
|
925
|
+
|
|
926
|
+
The authoring report measures header and footer text, graphics and focus
|
|
927
|
+
indicators in the selected schemes and contexts. The default table names
|
|
928
|
+
the element, state, ink, backdrop and WCAG AA result. The JSON adds a
|
|
929
|
+
`chrome` map keyed by scheme and a response-local `chromeCatalog`.
|
|
930
|
+
Each chrome card names its role and context and contains rows
|
|
931
|
+
`[identityIndex, ratio, required]`.
|
|
932
|
+
|
|
933
|
+
Look up `chromeCatalog.pairs[identityIndex]` to get
|
|
934
|
+
`[elementIndex, foregroundIndex, backgroundIndex, stateIndex, kindIndex]`.
|
|
935
|
+
Resolve these indexes through `elements`, `colors`, `colors`, `states`, and
|
|
936
|
+
`kinds`, respectively. All indexes are zero-based and belong to the same
|
|
937
|
+
response. Context display names longer than 128 characters carry
|
|
938
|
+
`contextTruncated` and `contextLength`. Context filtering uses the full name.
|
|
939
|
+
The authoring result fits 64 KiB, preserves all selected chrome measurements
|
|
940
|
+
and reserves at least 24 KiB for legacy surfaces. The indexed report is
|
|
941
|
+
produced by the authoring CLI. Retry an omitted named context with
|
|
942
|
+
`--scheme` and `--context`. Retry a root with `--scheme`, which keeps named
|
|
943
|
+
contexts and chrome for that scheme. The reason `surface_too_large` means
|
|
944
|
+
the surface exceeds the output bound under those narrowest selectors.
|
|
945
|
+
`omittedSurfaces.retryRootSchemes` lists roots that fit on retry even when
|
|
946
|
+
the displayed omissions are truncated. Find the full context names under
|
|
947
|
+
`lightTheme.contexts` and `darkTheme.contexts` in `settings/taproot-styles.json`.
|
|
948
|
+
For `--site`, pull in a separate workspace for the same site to read its
|
|
949
|
+
current names. With an account sign-in, run `taproot-site use <site>` from
|
|
950
|
+
an empty directory outside the working copy, then run `taproot-site pull`.
|
|
951
|
+
`surfaces[].footerLinkOnLayer2` identifies an adjusted semantic link whose
|
|
952
|
+
exact surface also paints a resting footer link over layer2. The card's
|
|
953
|
+
display name can be shorter than that surface's context name.
|
|
954
|
+
|
|
924
955
|
When `GITHUB_OUTPUT` names the runner's existing output file, every
|
|
925
956
|
operational verb appends the same JSON under `taproot_site_result` through a
|
|
926
957
|
random delimiter block, plus `taproot_site_verb` on success. Credentials,
|
|
@@ -928,6 +959,25 @@ Authorization values, signed upload headers, preview handoffs outside the
|
|
|
928
959
|
final result, and page bodies never appear in progress, diagnostics, JSON, or
|
|
929
960
|
Actions output.
|
|
930
961
|
|
|
962
|
+
### Indexed token paints
|
|
963
|
+
|
|
964
|
+
`help tokens --json` lists every semantic token. `theme resolve --json` includes
|
|
965
|
+
paint details for pinned or adjusted tokens as space permits. Both key
|
|
966
|
+
`tokens` by semantic name and use zero-based indexes into the response's
|
|
967
|
+
`paintCatalog`.
|
|
968
|
+
|
|
969
|
+
- A component paint indexes `component`, `part`, `state`, `label` and `folder`,
|
|
970
|
+
in that order. An optional sixth index selects the `alias`.
|
|
971
|
+
- A template paint starts with `-1`, then indexes `file`, `markup`, `part` and
|
|
972
|
+
`label`. Its remaining indexes select entries in `topics`.
|
|
973
|
+
- A token's `paintNotes[].paintIndex` points to a row in that token's `paints`.
|
|
974
|
+
|
|
975
|
+
`help page <type> --json` uses `page.tokenReach.dictionary` and
|
|
976
|
+
`page.tokenReach.rows`. Each row indexes `token`, `file`, `markup`, `part`,
|
|
977
|
+
`label` and `topics` in that order. The selected `topics` entry is the
|
|
978
|
+
complete list of page types for the row. The rows include intent names such
|
|
979
|
+
as `intent:info` alongside CSS token names.
|
|
980
|
+
|
|
931
981
|
### Every write answers `platform_paused`
|
|
932
982
|
|
|
933
983
|
`pull` and `status` succeed, and every write is refused with
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
"entityId": "a0000000-0000-4000-8000-000000000023",
|
|
3
3
|
"settingsType": "SETTING_TYPE_SITE_PUBLISHING_PREFERENCES",
|
|
4
4
|
"settings": {
|
|
5
|
+
"recipeJumpControl": "none",
|
|
6
|
+
"pageTagBadges": "none",
|
|
7
|
+
"recipeTagsIcon": "info",
|
|
5
8
|
"footerSettings": {
|
|
6
9
|
"enabled": true,
|
|
7
10
|
"showBrand": true,
|
|
@@ -524,7 +524,18 @@
|
|
|
524
524
|
"viewportMin": 320
|
|
525
525
|
},
|
|
526
526
|
"defaultScheme": "system",
|
|
527
|
+
"breadcrumbSeparator": "arrow-filled",
|
|
528
|
+
"breadcrumbTrailEnd": "arrow-down-filled",
|
|
527
529
|
"blockSpacing": "standard",
|
|
530
|
+
"headingH1SpaceBefore": "",
|
|
531
|
+
"headingH1SpaceAfter": "",
|
|
532
|
+
"headingH2SpaceBefore": "",
|
|
533
|
+
"headingH2SpaceAfter": "",
|
|
534
|
+
"headingH3SpaceBefore": "",
|
|
535
|
+
"headingH3SpaceAfter": "",
|
|
536
|
+
"headingH4SpaceBefore": "",
|
|
537
|
+
"headingH4SpaceAfter": "",
|
|
538
|
+
"contentInset": "small-to-normal",
|
|
528
539
|
"lightLogoId": "a0000000-0000-4000-8000-0000000000a0",
|
|
529
540
|
"darkLogoId": "a0000000-0000-4000-8000-0000000000a1",
|
|
530
541
|
"lightCanvasImageId": "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taprootio/site-authoring",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.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",
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
"examples/",
|
|
26
26
|
"src/",
|
|
27
27
|
"LICENSE",
|
|
28
|
-
"README.md"
|
|
28
|
+
"README.md",
|
|
29
|
+
"test/fixtures/default-site-theme.json"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@taprootio/espalier": "7.
|
|
32
|
+
"@taprootio/espalier": "7.5.0",
|
|
32
33
|
"mediabunny": "1.61.1"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
package/src/api.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { validateAuthoredTagNames } from "./authored-tag-names.js";
|
|
1
2
|
import { normalizeNavigationReadiness } from "./navigation-readiness.js";
|
|
3
|
+
import { isNavigationRevision } from "./navigation-workspace.js";
|
|
2
4
|
import { normalizeLatestCliVersion } from "./cli-release.js";
|
|
3
5
|
import { imageDescriptionRevision, isImageId, safeImagePreviewUrl } from "./image-description-contract.js";
|
|
4
6
|
import {
|
|
@@ -44,7 +46,7 @@ import { ApiError, isWellFormedCredential } from "./transport.js";
|
|
|
44
46
|
// The revision's shape lives with the manifest that records it: a value this
|
|
45
47
|
// module admitted but the registry then dropped would be recorded on a push
|
|
46
48
|
// and unreadable on the next pull, which reads as "never reconciled" forever.
|
|
47
|
-
import { normalizePageBodyRevision } from "./workspace.js";
|
|
49
|
+
import { normalizeAuthoredTagRevision, normalizePageBodyRevision } from "./workspace.js";
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* The proto enum spellings the redirect map travels as. The CLI's own
|
|
@@ -536,6 +538,7 @@ export function isGonePage(summary) {
|
|
|
536
538
|
|
|
537
539
|
export function normalizePageSummary(value) {
|
|
538
540
|
const summary = requireObject(value, "api.page_contract", "page summary");
|
|
541
|
+
const hasAuthor = typeof summary.authorDisplayName === "string" && summary.authorDisplayName.trim() !== "";
|
|
539
542
|
return {
|
|
540
543
|
pageId: requireIdentifier(summary.pageId, "api.page_contract", "page.pageId"),
|
|
541
544
|
resourceId: typeof summary.resourceId === "string" ? summary.resourceId : "",
|
|
@@ -567,7 +570,10 @@ export function normalizePageSummary(value) {
|
|
|
567
570
|
authorRef: typeof summary.authorRef === "string" ? parseAuthorReference(summary.authorRef)?.value ?? "" : "",
|
|
568
571
|
// Whether the page credits anyone at all, which an empty authorRef cannot
|
|
569
572
|
// say: it is also empty for an author this credential may not name.
|
|
570
|
-
hasAuthor
|
|
573
|
+
hasAuthor,
|
|
574
|
+
...(summary.templateType === "TEMPLATE_TYPE_PLACE_REVIEW" ? {
|
|
575
|
+
reviewAuthorMissing: !hasAuthor && summary.memberAccess !== "PAGE_MEMBER_ACCESS_MEMBER_ONLY",
|
|
576
|
+
} : {}),
|
|
571
577
|
};
|
|
572
578
|
}
|
|
573
579
|
|
|
@@ -591,6 +597,130 @@ export async function listSitePages(client, siteId, { onProgress = () => {} } =
|
|
|
591
597
|
return { pages, truncated: true };
|
|
592
598
|
}
|
|
593
599
|
|
|
600
|
+
/**
|
|
601
|
+
* A bare 404 is the compatibility path for a server from before the capability
|
|
602
|
+
* route existed. A classified refusal or a bad response still fails the read.
|
|
603
|
+
*/
|
|
604
|
+
export async function getSiteAuthoringCapabilities(client, siteId) {
|
|
605
|
+
let value;
|
|
606
|
+
try {
|
|
607
|
+
value = await client.request(sitePath(siteId, "authoring-capabilities"));
|
|
608
|
+
} catch (error) {
|
|
609
|
+
if (
|
|
610
|
+
error instanceof ApiError && error.httpStatus === HTTP_NOT_FOUND && error.grpcCode === undefined
|
|
611
|
+
&& error.refusalKind() === REFUSAL_UNCLASSIFIED && error.fields.length === 0
|
|
612
|
+
) return undefined;
|
|
613
|
+
throw error;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const code = "api.authoring_capabilities_contract";
|
|
617
|
+
const response = requireObject(value, code, "site authoring capabilities");
|
|
618
|
+
for (const field of ["authoredTagWritesEnabled", "authoredTagWritesPermitted"]) {
|
|
619
|
+
if (typeof response[field] !== "boolean") {
|
|
620
|
+
throw new SiteAuthoringError(code, `Taproot did not return a valid ${field} capability.`, { field });
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return {
|
|
624
|
+
authoredTagWritesEnabled: response.authoredTagWritesEnabled,
|
|
625
|
+
authoredTagWritesPermitted: response.authoredTagWritesPermitted,
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** The snapshot for the exact page version returned by the selected read. */
|
|
630
|
+
export function requireAuthoredTagSnapshot(page) {
|
|
631
|
+
const code = "api.authored_tag_snapshot_contract";
|
|
632
|
+
const field = "authoredTagSnapshot";
|
|
633
|
+
const snapshot = page?.[field];
|
|
634
|
+
if (snapshot === null || typeof snapshot !== "object" || Array.isArray(snapshot)) {
|
|
635
|
+
throw new SiteAuthoringError(code, "Taproot did not return a valid authored tag snapshot for this page.", { field });
|
|
636
|
+
}
|
|
637
|
+
const revision = normalizeAuthoredTagRevision(snapshot.revision);
|
|
638
|
+
if (revision === undefined) {
|
|
639
|
+
throw new SiteAuthoringError(code, "Taproot did not return a valid authored tag snapshot revision.", {
|
|
640
|
+
field: `${field}.revision`,
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
if (snapshot.entries !== undefined && !Array.isArray(snapshot.entries)) {
|
|
644
|
+
throw new SiteAuthoringError(code, "Taproot did not return a valid list of authored tags.", {
|
|
645
|
+
field: `${field}.entries`,
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
const identifiers = new Set();
|
|
649
|
+
const entries = (snapshot.entries ?? []).map((entry, index) => {
|
|
650
|
+
const id = typeof entry?.id === "string" ? entry.id.toLowerCase() : "";
|
|
651
|
+
if (
|
|
652
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u.test(id)
|
|
653
|
+
|| identifiers.has(id) || typeof entry.name !== "string" || typeof entry.slug !== "string"
|
|
654
|
+
) {
|
|
655
|
+
throw new SiteAuthoringError(code, "Taproot returned an invalid authored tag entry.", {
|
|
656
|
+
field: `${field}.entries[${index}]`,
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
identifiers.add(id);
|
|
660
|
+
return { id, name: entry.name, slug: entry.slug };
|
|
661
|
+
});
|
|
662
|
+
return { entries, revision };
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Keep wrapper presence independent of the repeated field inside it. A clear
|
|
667
|
+
* carries a wrapper with no names, whereas an ordinary write omits the wrapper.
|
|
668
|
+
*/
|
|
669
|
+
export function wireAuthoredTagFields(tags, { expectedAuthoredTagRevision, expectedBodyRevision } = {}) {
|
|
670
|
+
if (tags === undefined) return {};
|
|
671
|
+
const names = requireAuthoredTagNames(tags);
|
|
672
|
+
return {
|
|
673
|
+
authoredTags: { names },
|
|
674
|
+
...(expectedAuthoredTagRevision === undefined ? {} : { expectedAuthoredTagRevision }),
|
|
675
|
+
...(expectedBodyRevision === undefined ? {} : { expectedBodyRevision }),
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function requireAuthoredTagNames(tags) {
|
|
680
|
+
const result = validateAuthoredTagNames(tags);
|
|
681
|
+
if ("reason" in result) throw new SiteAuthoringError("pages.tags_invalid", result.reason, { field: result.field });
|
|
682
|
+
return result.names;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function pageMutationBody(body, updating) {
|
|
686
|
+
if (body.authoredTags === undefined) return body;
|
|
687
|
+
const wrapper = body.authoredTags;
|
|
688
|
+
if (wrapper === null || typeof wrapper !== "object" || Array.isArray(wrapper)) {
|
|
689
|
+
throw new SiteAuthoringError("pages.tags_invalid", "Send authored tags as a tag-name list.", { field: "tags" });
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
const authoredTags = wrapper.names === undefined ? {} : { names: requireAuthoredTagNames(wrapper.names) };
|
|
693
|
+
if (updating) {
|
|
694
|
+
for (const [field, revision] of [
|
|
695
|
+
["expectedAuthoredTagRevision", normalizeAuthoredTagRevision(body.expectedAuthoredTagRevision)],
|
|
696
|
+
["expectedBodyRevision", normalizePageBodyRevision(body.expectedBodyRevision)],
|
|
697
|
+
]) {
|
|
698
|
+
if (revision === undefined) {
|
|
699
|
+
throw new SiteAuthoringError(
|
|
700
|
+
"pages.tag_revision_required",
|
|
701
|
+
"Pull this page before replacing its authored tags so the update can check both revisions.",
|
|
702
|
+
{ field },
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return { ...body, authoredTags };
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function normalizePageMutation(value, tagged) {
|
|
711
|
+
const summary = normalizePageSummary(value);
|
|
712
|
+
if (!tagged) return summary;
|
|
713
|
+
const authoredTagRevision = normalizeAuthoredTagRevision(value.authoredTagRevision);
|
|
714
|
+
if (authoredTagRevision === undefined) {
|
|
715
|
+
throw new SiteAuthoringError(
|
|
716
|
+
"api.page_contract",
|
|
717
|
+
"Taproot did not confirm the authored tag revision. Pull this page to see whether the write succeeded.",
|
|
718
|
+
{ field: "authoredTagRevision" },
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
return { ...summary, authoredTagRevision };
|
|
722
|
+
}
|
|
723
|
+
|
|
594
724
|
/**
|
|
595
725
|
* Reads one page's editable body. `GetPageById` refuses an unspecified status,
|
|
596
726
|
* so the caller must name which version it wants: the draft when the summary
|
|
@@ -605,7 +735,10 @@ export async function getPage(client, pageId, status) {
|
|
|
605
735
|
}
|
|
606
736
|
|
|
607
737
|
export async function createPage(client, body) {
|
|
608
|
-
return
|
|
738
|
+
return normalizePageMutation(
|
|
739
|
+
await client.request("v1/pages", { method: "POST", body: pageMutationBody(body, false) }),
|
|
740
|
+
body.authoredTags !== undefined,
|
|
741
|
+
);
|
|
609
742
|
}
|
|
610
743
|
|
|
611
744
|
/**
|
|
@@ -618,8 +751,12 @@ export async function deletePage(client, pageId) {
|
|
|
618
751
|
}
|
|
619
752
|
|
|
620
753
|
export async function updatePage(client, pageId, body) {
|
|
621
|
-
return
|
|
622
|
-
await client.request(`v1/pages/${encodeURIComponent(pageId)}`, {
|
|
754
|
+
return normalizePageMutation(
|
|
755
|
+
await client.request(`v1/pages/${encodeURIComponent(pageId)}`, {
|
|
756
|
+
method: "PATCH",
|
|
757
|
+
body: pageMutationBody(body, true),
|
|
758
|
+
}),
|
|
759
|
+
body.authoredTags !== undefined,
|
|
623
760
|
);
|
|
624
761
|
}
|
|
625
762
|
|
|
@@ -700,11 +837,11 @@ export async function publishDrafts(client, pageIds) {
|
|
|
700
837
|
* site-authoring key actually holds; production resolves against a published
|
|
701
838
|
* deployment instead.
|
|
702
839
|
*/
|
|
703
|
-
export async function getNavigation(client, siteId) {
|
|
840
|
+
export async function getNavigation(client, siteId, { requireEvidence = false } = {}) {
|
|
704
841
|
const search = query([["environment", SITE_ENVIRONMENT_DRAFT]]);
|
|
705
842
|
return requireNavigation(await client.request(sitePath(siteId, `navigation${search}`), {
|
|
706
843
|
maximumResponseBytes: LIMITS.navigationResponseBytes,
|
|
707
|
-
}));
|
|
844
|
+
}), requireEvidence);
|
|
708
845
|
}
|
|
709
846
|
|
|
710
847
|
/**
|
|
@@ -722,8 +859,13 @@ export async function saveNavigation(client, siteId, navItems, expectedRevision)
|
|
|
722
859
|
}
|
|
723
860
|
|
|
724
861
|
/** A navigation answer: the tree and the revision a later save must present. */
|
|
725
|
-
function requireNavigation(value) {
|
|
862
|
+
function requireNavigation(value, requireEvidence = false) {
|
|
726
863
|
const response = requireObject(value, "api.navigation_contract", "site navigation");
|
|
864
|
+
// ProtoJSON may omit an empty repeated field. A revision proves this is the tree response.
|
|
865
|
+
if (requireEvidence && (!isNavigationRevision(response.revision)
|
|
866
|
+
|| (Object.hasOwn(response, "navItems") && !Array.isArray(response.navItems)))) {
|
|
867
|
+
throw new SiteAuthoringError("api.navigation_contract", "Taproot returned incomplete navigation evidence.");
|
|
868
|
+
}
|
|
727
869
|
return {
|
|
728
870
|
navItems: Array.isArray(response.navItems) ? response.navItems : [],
|
|
729
871
|
revision: typeof response.revision === "string" ? response.revision : "",
|
|
@@ -1502,19 +1644,27 @@ export function describePageEstimate(estimate) {
|
|
|
1502
1644
|
return `${generates} · ${left}${resets}`;
|
|
1503
1645
|
}
|
|
1504
1646
|
|
|
1647
|
+
export const STAGING_HOSTING_SETUP_GUIDANCE = "Activate a staging hostname in the site's Settings under Licence & domain. "
|
|
1648
|
+
+ "For a local Taproot stack, check the stack's staging hostname setup.";
|
|
1649
|
+
|
|
1505
1650
|
export async function getStagingPreviewStatus(client, siteId) {
|
|
1506
1651
|
const response = requireObject(
|
|
1507
1652
|
await client.request(sitePath(siteId, "staging-preview/status")),
|
|
1508
1653
|
"api.staging_preview_contract",
|
|
1509
1654
|
"staging preview status",
|
|
1510
1655
|
);
|
|
1511
|
-
|
|
1656
|
+
const ready = response.ready === undefined ? false : response.ready;
|
|
1657
|
+
if (
|
|
1658
|
+
response.siteId !== siteId || typeof ready !== "boolean"
|
|
1659
|
+
|| (response.hasStagedRelease !== undefined && typeof response.hasStagedRelease !== "boolean")
|
|
1660
|
+
) {
|
|
1512
1661
|
throw new SiteAuthoringError(
|
|
1513
1662
|
"api.staging_preview_contract",
|
|
1514
1663
|
"Taproot returned an invalid staging preview status response.",
|
|
1515
1664
|
);
|
|
1516
1665
|
}
|
|
1517
|
-
|
|
1666
|
+
const releaseStatus = response.hasStagedRelease === undefined ? {} : { hasStagedRelease: response.hasStagedRelease };
|
|
1667
|
+
if (!ready) return { ready: false, stagingUrl: "", ...releaseStatus };
|
|
1518
1668
|
|
|
1519
1669
|
let url;
|
|
1520
1670
|
try {
|
|
@@ -1542,7 +1692,7 @@ export async function getStagingPreviewStatus(client, siteId) {
|
|
|
1542
1692
|
{ field: "stagingUrl" },
|
|
1543
1693
|
);
|
|
1544
1694
|
}
|
|
1545
|
-
return { ready: true, stagingUrl: `https://${url.hostname}
|
|
1695
|
+
return { ready: true, stagingUrl: `https://${url.hostname}/`, ...releaseStatus };
|
|
1546
1696
|
}
|
|
1547
1697
|
|
|
1548
1698
|
// The server accepts 2048, but the edge appends a check parameter before its own 2048 test.
|
|
@@ -1770,6 +1920,15 @@ export async function deploySite(client, siteId, body) {
|
|
|
1770
1920
|
{ field: "AuthoringPreviewFailed", status: error.status },
|
|
1771
1921
|
);
|
|
1772
1922
|
}
|
|
1923
|
+
if (error instanceof ApiError && error.refusalKind() === REFUSAL_UNCLASSIFIED && error.hasField("Hosting")) {
|
|
1924
|
+
const staging = body.environment === DEPLOYMENT_ENVIRONMENT_STAGING;
|
|
1925
|
+
const detail = error.descriptionFor("Hosting") ?? "Taproot could not use the site's hosting configuration.";
|
|
1926
|
+
throw new SiteAuthoringError(
|
|
1927
|
+
"deploy.hosting_unavailable",
|
|
1928
|
+
staging ? detail + " " + STAGING_HOSTING_SETUP_GUIDANCE : detail,
|
|
1929
|
+
{ field: "Hosting", status: error.status },
|
|
1930
|
+
);
|
|
1931
|
+
}
|
|
1773
1932
|
if (error instanceof ApiError && error.hasField("ExpectedPageCount")) {
|
|
1774
1933
|
throw new SiteAuthoringError(
|
|
1775
1934
|
"deploy.page_estimate_changed",
|