@taprootio/site-authoring 0.42.0 → 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 +32 -1
- 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 +161 -8
- package/src/appearance-contract.js +264 -3
- package/src/authored-tag-names.js +88 -0
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +22 -0
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +143 -0
- package/src/chrome-features.js +6 -2
- package/src/chrome-input.js +1 -0
- package/src/chrome-paint-catalog-taproot.json +3 -3
- package/src/chrome-report.js +91 -12
- package/src/cli.js +45 -16
- 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 +22 -3
- package/src/footer-content.js +1 -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 +44 -7
- 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 +297 -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 +23 -5
- package/src/site-check-rules.json +1 -0
- package/src/site-health-findings.js +13 -13
- 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 +265 -23
- package/src/theme-validation.js +118 -7
- 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 +93 -25
- package/src/verbs/theme-resolve.js +189 -55
- package/src/verbs/validate.js +6 -5
- package/src/workspace-check.js +35 -3
- package/src/workspace.js +37 -1
- package/test/fixtures/default-site-theme.json +516 -0
package/README.md
CHANGED
|
@@ -938,7 +938,19 @@ response. Context display names longer than 128 characters carry
|
|
|
938
938
|
`contextTruncated` and `contextLength`. Context filtering uses the full name.
|
|
939
939
|
The authoring result fits 64 KiB, preserves all selected chrome measurements
|
|
940
940
|
and reserves at least 24 KiB for legacy surfaces. The indexed report is
|
|
941
|
-
produced by the authoring CLI.
|
|
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.
|
|
942
954
|
|
|
943
955
|
When `GITHUB_OUTPUT` names the runner's existing output file, every
|
|
944
956
|
operational verb appends the same JSON under `taproot_site_result` through a
|
|
@@ -947,6 +959,25 @@ Authorization values, signed upload headers, preview handoffs outside the
|
|
|
947
959
|
final result, and page bodies never appear in progress, diagnostics, JSON, or
|
|
948
960
|
Actions output.
|
|
949
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
|
+
|
|
950
981
|
### Every write answers `platform_paused`
|
|
951
982
|
|
|
952
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,3 +1,4 @@
|
|
|
1
|
+
import { validateAuthoredTagNames } from "./authored-tag-names.js";
|
|
1
2
|
import { normalizeNavigationReadiness } from "./navigation-readiness.js";
|
|
2
3
|
import { isNavigationRevision } from "./navigation-workspace.js";
|
|
3
4
|
import { normalizeLatestCliVersion } from "./cli-release.js";
|
|
@@ -45,7 +46,7 @@ import { ApiError, isWellFormedCredential } from "./transport.js";
|
|
|
45
46
|
// The revision's shape lives with the manifest that records it: a value this
|
|
46
47
|
// module admitted but the registry then dropped would be recorded on a push
|
|
47
48
|
// and unreadable on the next pull, which reads as "never reconciled" forever.
|
|
48
|
-
import { normalizePageBodyRevision } from "./workspace.js";
|
|
49
|
+
import { normalizeAuthoredTagRevision, normalizePageBodyRevision } from "./workspace.js";
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* The proto enum spellings the redirect map travels as. The CLI's own
|
|
@@ -537,6 +538,7 @@ export function isGonePage(summary) {
|
|
|
537
538
|
|
|
538
539
|
export function normalizePageSummary(value) {
|
|
539
540
|
const summary = requireObject(value, "api.page_contract", "page summary");
|
|
541
|
+
const hasAuthor = typeof summary.authorDisplayName === "string" && summary.authorDisplayName.trim() !== "";
|
|
540
542
|
return {
|
|
541
543
|
pageId: requireIdentifier(summary.pageId, "api.page_contract", "page.pageId"),
|
|
542
544
|
resourceId: typeof summary.resourceId === "string" ? summary.resourceId : "",
|
|
@@ -568,7 +570,10 @@ export function normalizePageSummary(value) {
|
|
|
568
570
|
authorRef: typeof summary.authorRef === "string" ? parseAuthorReference(summary.authorRef)?.value ?? "" : "",
|
|
569
571
|
// Whether the page credits anyone at all, which an empty authorRef cannot
|
|
570
572
|
// say: it is also empty for an author this credential may not name.
|
|
571
|
-
hasAuthor
|
|
573
|
+
hasAuthor,
|
|
574
|
+
...(summary.templateType === "TEMPLATE_TYPE_PLACE_REVIEW" ? {
|
|
575
|
+
reviewAuthorMissing: !hasAuthor && summary.memberAccess !== "PAGE_MEMBER_ACCESS_MEMBER_ONLY",
|
|
576
|
+
} : {}),
|
|
572
577
|
};
|
|
573
578
|
}
|
|
574
579
|
|
|
@@ -592,6 +597,130 @@ export async function listSitePages(client, siteId, { onProgress = () => {} } =
|
|
|
592
597
|
return { pages, truncated: true };
|
|
593
598
|
}
|
|
594
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
|
+
|
|
595
724
|
/**
|
|
596
725
|
* Reads one page's editable body. `GetPageById` refuses an unspecified status,
|
|
597
726
|
* so the caller must name which version it wants: the draft when the summary
|
|
@@ -606,7 +735,10 @@ export async function getPage(client, pageId, status) {
|
|
|
606
735
|
}
|
|
607
736
|
|
|
608
737
|
export async function createPage(client, body) {
|
|
609
|
-
return
|
|
738
|
+
return normalizePageMutation(
|
|
739
|
+
await client.request("v1/pages", { method: "POST", body: pageMutationBody(body, false) }),
|
|
740
|
+
body.authoredTags !== undefined,
|
|
741
|
+
);
|
|
610
742
|
}
|
|
611
743
|
|
|
612
744
|
/**
|
|
@@ -619,8 +751,12 @@ export async function deletePage(client, pageId) {
|
|
|
619
751
|
}
|
|
620
752
|
|
|
621
753
|
export async function updatePage(client, pageId, body) {
|
|
622
|
-
return
|
|
623
|
-
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,
|
|
624
760
|
);
|
|
625
761
|
}
|
|
626
762
|
|
|
@@ -1508,19 +1644,27 @@ export function describePageEstimate(estimate) {
|
|
|
1508
1644
|
return `${generates} · ${left}${resets}`;
|
|
1509
1645
|
}
|
|
1510
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
|
+
|
|
1511
1650
|
export async function getStagingPreviewStatus(client, siteId) {
|
|
1512
1651
|
const response = requireObject(
|
|
1513
1652
|
await client.request(sitePath(siteId, "staging-preview/status")),
|
|
1514
1653
|
"api.staging_preview_contract",
|
|
1515
1654
|
"staging preview status",
|
|
1516
1655
|
);
|
|
1517
|
-
|
|
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
|
+
) {
|
|
1518
1661
|
throw new SiteAuthoringError(
|
|
1519
1662
|
"api.staging_preview_contract",
|
|
1520
1663
|
"Taproot returned an invalid staging preview status response.",
|
|
1521
1664
|
);
|
|
1522
1665
|
}
|
|
1523
|
-
|
|
1666
|
+
const releaseStatus = response.hasStagedRelease === undefined ? {} : { hasStagedRelease: response.hasStagedRelease };
|
|
1667
|
+
if (!ready) return { ready: false, stagingUrl: "", ...releaseStatus };
|
|
1524
1668
|
|
|
1525
1669
|
let url;
|
|
1526
1670
|
try {
|
|
@@ -1548,7 +1692,7 @@ export async function getStagingPreviewStatus(client, siteId) {
|
|
|
1548
1692
|
{ field: "stagingUrl" },
|
|
1549
1693
|
);
|
|
1550
1694
|
}
|
|
1551
|
-
return { ready: true, stagingUrl: `https://${url.hostname}
|
|
1695
|
+
return { ready: true, stagingUrl: `https://${url.hostname}/`, ...releaseStatus };
|
|
1552
1696
|
}
|
|
1553
1697
|
|
|
1554
1698
|
// The server accepts 2048, but the edge appends a check parameter before its own 2048 test.
|
|
@@ -1776,6 +1920,15 @@ export async function deploySite(client, siteId, body) {
|
|
|
1776
1920
|
{ field: "AuthoringPreviewFailed", status: error.status },
|
|
1777
1921
|
);
|
|
1778
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
|
+
}
|
|
1779
1932
|
if (error instanceof ApiError && error.hasField("ExpectedPageCount")) {
|
|
1780
1933
|
throw new SiteAuthoringError(
|
|
1781
1934
|
"deploy.page_estimate_changed",
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BLOCK_SPACINGS,
|
|
3
|
+
DEFAULT_BLOCK_SPACING,
|
|
4
|
+
HEADING_SPACING_FIELDS,
|
|
5
|
+
HEADING_SPACING_MAX,
|
|
6
|
+
HEADING_SPACING_MIN,
|
|
7
|
+
HEADING_SPACING_STEP,
|
|
8
|
+
isHeadingSpacing,
|
|
9
|
+
} from "./block-flow.js";
|
|
10
|
+
import {
|
|
11
|
+
BREADCRUMB_SEPARATOR_DEFAULT,
|
|
12
|
+
BREADCRUMB_SEPARATOR_STYLES,
|
|
13
|
+
BREADCRUMB_TRAIL_END_DEFAULT,
|
|
14
|
+
BREADCRUMB_TRAIL_ENDS,
|
|
15
|
+
} from "./breadcrumb-separators.js";
|
|
16
|
+
import { BREADCRUMB_ARTWORK_FIELDS, BREADCRUMB_ARTWORK_MAX_BYTES, importBreadcrumbSvg, parseBreadcrumbArtwork } from "./breadcrumb-artwork.js";
|
|
17
|
+
import { RECIPE_TAGS_BAR_COLOR_TOKENS } from "./brand-color.js";
|
|
18
|
+
import { AUTHORED_TAG_SLUG, authoredTagSlug, validateAuthoredTagNames } from "./authored-tag-names.js";
|
|
19
|
+
import { CONTENT_INSET_OPTIONS, DEFAULT_CONTENT_INSET } from "./content-inset.js";
|
|
2
20
|
import { hasControlCharacter, isCanonicalUuid, SiteAuthoringError } from "./errors.js";
|
|
3
21
|
import { FOOTER_PRESENTATION_FIELDS } from "./footer-content.js";
|
|
22
|
+
import { DEFAULT_PAGE_TAG_BADGES, PAGE_TAG_BADGE_MODES } from "./page-tag-badge-modes.js";
|
|
4
23
|
import { refuseRetiredFooterColors } from "./footer-contract.js";
|
|
5
24
|
import { HEADER_HEIGHT_MULTIPLIER_LIMITS, LOGO_VARIANTS, parseHeaderHeightMultiplier } from "./header-presentation.js";
|
|
25
|
+
import {
|
|
26
|
+
DEFAULT_RECIPE_JUMP_CONTROL,
|
|
27
|
+
DEFAULT_RECIPE_TAGS_ICON,
|
|
28
|
+
DEFAULT_RECIPE_TAGS_CONTENT,
|
|
29
|
+
RECIPE_TAGS_CONTENT,
|
|
30
|
+
RECIPE_JUMP_CONTROLS,
|
|
31
|
+
RECIPE_TAGS_ICONS,
|
|
32
|
+
} from "./recipe-page-options.js";
|
|
6
33
|
import {
|
|
7
34
|
SETTINGS_TYPE_BRAND,
|
|
8
35
|
SETTINGS_TYPE_SITE_HEADER,
|
|
@@ -11,6 +38,8 @@ import {
|
|
|
11
38
|
} from "./settings-catalog.js";
|
|
12
39
|
import { HEADER_BRAND_COLOR_TOKENS, requireAppearanceColor } from "./theme-validation.js";
|
|
13
40
|
|
|
41
|
+
import { readWorkspaceFile } from "./workspace.js";
|
|
42
|
+
|
|
14
43
|
export const APPEARANCE_FILES = Object.freeze({
|
|
15
44
|
[SETTINGS_TYPE_TAPROOT_STYLES]: "settings/taproot-styles.json",
|
|
16
45
|
[SETTINGS_TYPE_BRAND]: "settings/brand.json",
|
|
@@ -40,6 +69,51 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
|
|
|
40
69
|
values: Object.freeze(Object.keys(BLOCK_SPACINGS)),
|
|
41
70
|
default: DEFAULT_BLOCK_SPACING,
|
|
42
71
|
}),
|
|
72
|
+
...HEADING_SPACING_FIELDS.map((name) => Object.freeze({
|
|
73
|
+
settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
|
|
74
|
+
name,
|
|
75
|
+
path: `taproot-styles.${name}`,
|
|
76
|
+
type: "heading-spacing",
|
|
77
|
+
minimum: HEADING_SPACING_MIN,
|
|
78
|
+
maximum: HEADING_SPACING_MAX,
|
|
79
|
+
step: HEADING_SPACING_STEP,
|
|
80
|
+
default: "",
|
|
81
|
+
})),
|
|
82
|
+
Object.freeze({
|
|
83
|
+
settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
|
|
84
|
+
name: "contentInset",
|
|
85
|
+
path: "taproot-styles.contentInset",
|
|
86
|
+
type: "enum",
|
|
87
|
+
values: CONTENT_INSET_OPTIONS,
|
|
88
|
+
default: DEFAULT_CONTENT_INSET,
|
|
89
|
+
emptyIsDefault: true,
|
|
90
|
+
}),
|
|
91
|
+
Object.freeze({
|
|
92
|
+
settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
|
|
93
|
+
name: "breadcrumbSeparator",
|
|
94
|
+
path: "taproot-styles.breadcrumbSeparator",
|
|
95
|
+
type: "enum",
|
|
96
|
+
values: BREADCRUMB_SEPARATOR_STYLES,
|
|
97
|
+
default: BREADCRUMB_SEPARATOR_DEFAULT,
|
|
98
|
+
emptyIsDefault: true,
|
|
99
|
+
}),
|
|
100
|
+
Object.freeze({
|
|
101
|
+
settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
|
|
102
|
+
name: "breadcrumbTrailEnd",
|
|
103
|
+
path: "taproot-styles.breadcrumbTrailEnd",
|
|
104
|
+
type: "enum",
|
|
105
|
+
values: BREADCRUMB_TRAIL_ENDS,
|
|
106
|
+
default: BREADCRUMB_TRAIL_END_DEFAULT,
|
|
107
|
+
emptyIsDefault: true,
|
|
108
|
+
}),
|
|
109
|
+
...BREADCRUMB_ARTWORK_FIELDS.map(name => Object.freeze({
|
|
110
|
+
settingsType: SETTINGS_TYPE_TAPROOT_STYLES,
|
|
111
|
+
name,
|
|
112
|
+
path: "taproot-styles." + name,
|
|
113
|
+
type: "breadcrumb-artwork",
|
|
114
|
+
optional: true,
|
|
115
|
+
default: "",
|
|
116
|
+
})),
|
|
43
117
|
...["lightLogoId", "darkLogoId", "lightCompactLogoId", "darkCompactLogoId", "lightCanvasImageId", "darkCanvasImageId"]
|
|
44
118
|
.map((name) =>
|
|
45
119
|
Object.freeze({
|
|
@@ -200,6 +274,74 @@ export const APPEARANCE_SCALAR_FIELDS = Object.freeze([
|
|
|
200
274
|
default: "",
|
|
201
275
|
})
|
|
202
276
|
),
|
|
277
|
+
Object.freeze({
|
|
278
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
279
|
+
name: "recipeJumpControl",
|
|
280
|
+
path: "site-publishing-preferences.recipeJumpControl",
|
|
281
|
+
type: "enum",
|
|
282
|
+
values: RECIPE_JUMP_CONTROLS,
|
|
283
|
+
default: DEFAULT_RECIPE_JUMP_CONTROL,
|
|
284
|
+
emptyIsDefault: true,
|
|
285
|
+
}),
|
|
286
|
+
Object.freeze({
|
|
287
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
288
|
+
name: "recipeTagsIcon",
|
|
289
|
+
path: "site-publishing-preferences.recipeTagsIcon",
|
|
290
|
+
type: "enum",
|
|
291
|
+
values: RECIPE_TAGS_ICONS,
|
|
292
|
+
default: DEFAULT_RECIPE_TAGS_ICON,
|
|
293
|
+
emptyIsDefault: true,
|
|
294
|
+
}),
|
|
295
|
+
Object.freeze({
|
|
296
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
297
|
+
name: "recipeTagsContent",
|
|
298
|
+
path: "site-publishing-preferences.recipeTagsContent",
|
|
299
|
+
type: "enum",
|
|
300
|
+
values: RECIPE_TAGS_CONTENT,
|
|
301
|
+
default: DEFAULT_RECIPE_TAGS_CONTENT,
|
|
302
|
+
emptyIsDefault: true,
|
|
303
|
+
optional: true,
|
|
304
|
+
onlyIfPresent: true,
|
|
305
|
+
}),
|
|
306
|
+
...["recipeTagsBarBackground", "recipeTagsBarBorderColor", "recipeTagsBarColor"].map(name =>
|
|
307
|
+
Object.freeze({
|
|
308
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
309
|
+
name,
|
|
310
|
+
path: `site-publishing-preferences.${name}`,
|
|
311
|
+
type: "appearance-color",
|
|
312
|
+
allowedTokens: RECIPE_TAGS_BAR_COLOR_TOKENS,
|
|
313
|
+
default: "",
|
|
314
|
+
optional: true,
|
|
315
|
+
onlyIfPresent: true,
|
|
316
|
+
})
|
|
317
|
+
),
|
|
318
|
+
Object.freeze({
|
|
319
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
320
|
+
name: "recipeMetadataDestinations",
|
|
321
|
+
path: "site-publishing-preferences.recipeMetadataDestinations",
|
|
322
|
+
type: "tag-destinations",
|
|
323
|
+
onlyIfPresent: true,
|
|
324
|
+
optional: true,
|
|
325
|
+
default: Object.freeze({}),
|
|
326
|
+
}),
|
|
327
|
+
Object.freeze({
|
|
328
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
329
|
+
name: "pageTagBadges",
|
|
330
|
+
path: "site-publishing-preferences.pageTagBadges",
|
|
331
|
+
type: "enum",
|
|
332
|
+
values: PAGE_TAG_BADGE_MODES,
|
|
333
|
+
default: DEFAULT_PAGE_TAG_BADGES,
|
|
334
|
+
emptyIsDefault: true,
|
|
335
|
+
}),
|
|
336
|
+
Object.freeze({
|
|
337
|
+
settingsType: SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
|
|
338
|
+
name: "tagDestinations",
|
|
339
|
+
path: "site-publishing-preferences.tagDestinations",
|
|
340
|
+
type: "tag-destinations",
|
|
341
|
+
onlyIfPresent: true,
|
|
342
|
+
optional: true,
|
|
343
|
+
default: Object.freeze({}),
|
|
344
|
+
}),
|
|
203
345
|
]);
|
|
204
346
|
|
|
205
347
|
// TR00728: these four scalars were retired in favor of per-scheme theme
|
|
@@ -215,7 +357,7 @@ const RETIRED_TAPROOT_STYLES_SCALARS = Object.freeze([
|
|
|
215
357
|
"fontWeightMenu",
|
|
216
358
|
]);
|
|
217
359
|
|
|
218
|
-
function refuseRetiredScalarFonts(stylesDocument) {
|
|
360
|
+
export function refuseRetiredScalarFonts(stylesDocument) {
|
|
219
361
|
if (stylesDocument === null || typeof stylesDocument !== "object") return;
|
|
220
362
|
for (const name of RETIRED_TAPROOT_STYLES_SCALARS) {
|
|
221
363
|
if (Object.hasOwn(stylesDocument, name)) {
|
|
@@ -275,8 +417,85 @@ function requireString(value, field, maximum = 256 * 1024) {
|
|
|
275
417
|
return value;
|
|
276
418
|
}
|
|
277
419
|
|
|
420
|
+
const recipeMetadataDestinationPath = "site-publishing-preferences.recipeMetadataDestinations";
|
|
421
|
+
|
|
422
|
+
export function normalizeTagDestinations(value, path = "site-publishing-preferences.tagDestinations") {
|
|
423
|
+
if (value === undefined) return {};
|
|
424
|
+
const metadata = path === recipeMetadataDestinationPath;
|
|
425
|
+
const label = metadata ? "Recipe metadata value" : "Tag";
|
|
426
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
427
|
+
fail("theme.tag_destinations_invalid", path + " maps names to page resource IDs.", path);
|
|
428
|
+
}
|
|
429
|
+
const destinations = new Map();
|
|
430
|
+
for (const [name, resourceId] of Object.entries(value)) {
|
|
431
|
+
const field = path + "." + name;
|
|
432
|
+
if (!metadata) {
|
|
433
|
+
const names = validateAuthoredTagNames([name]);
|
|
434
|
+
if ("field" in names) fail("theme.tag_destinations_invalid", names.reason, field);
|
|
435
|
+
}
|
|
436
|
+
const slug = authoredTagSlug(name);
|
|
437
|
+
if (metadata && (!AUTHORED_TAG_SLUG.test(slug) || slug.length > 100 || /[\p{Cc}\p{Cs}]/u.test(name))) {
|
|
438
|
+
fail("theme.tag_destinations_invalid", "Use a metadata value that forms a slug of up to 100 characters.", field);
|
|
439
|
+
}
|
|
440
|
+
if (destinations.has(slug)) fail("theme.tag_destinations_invalid", label + " '" + name + "' is listed more than once.", field);
|
|
441
|
+
if (!isCanonicalUuid(resourceId) || resourceId === "00000000-0000-0000-0000-000000000000") {
|
|
442
|
+
fail("theme.tag_destination_page_invalid", label + " '" + name + "' needs a lowercase page resource ID from pull.", field);
|
|
443
|
+
}
|
|
444
|
+
destinations.set(slug, resourceId);
|
|
445
|
+
}
|
|
446
|
+
return Object.fromEntries([...destinations].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** Older servers omitted the catalog. A present empty message is an empty catalog. */
|
|
450
|
+
export function tagDestinationCatalogSlugs(catalog) {
|
|
451
|
+
return catalog && typeof catalog === "object" && !Array.isArray(catalog)
|
|
452
|
+
? Array.isArray(catalog.authoredTagSlugs) ? catalog.authoredTagSlugs : []
|
|
453
|
+
: undefined;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export function checkTagDestinationTargets(proposed, existing, manifest, onProgress = () => {}, authoredTagSlugs, metadata = false) {
|
|
457
|
+
const knownSlugs = new Set(authoredTagSlugs ?? manifest.presentation?.authoredTagSlugs
|
|
458
|
+
?? manifest.pages.flatMap(page => page.baseline?.authoredTagSlugs ?? []));
|
|
459
|
+
const knownPages = new Set(manifest.pages.map(page => page.resourceId));
|
|
460
|
+
for (const [slug, resourceId] of Object.entries(proposed)) {
|
|
461
|
+
if (resourceId === existing?.[slug]) {
|
|
462
|
+
if (!knownPages.has(resourceId)) {
|
|
463
|
+
onProgress("Tag '" + slug + "' has a destination absent from this pull. Published badges stay plain when the destination is unavailable.");
|
|
464
|
+
}
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
const field = (metadata ? recipeMetadataDestinationPath : "site-publishing-preferences.tagDestinations") + "." + slug;
|
|
468
|
+
if (!metadata && !knownSlugs.has(slug)) {
|
|
469
|
+
fail("theme.tag_destination_tag_unknown", "Unknown site tag '" + slug + "'. Correct the spelling or create the tag, then pull again.", field);
|
|
470
|
+
}
|
|
471
|
+
if (!knownPages.has(resourceId)) {
|
|
472
|
+
const label = metadata ? "Recipe metadata value" : "Tag";
|
|
473
|
+
fail("theme.tag_destination_page_unknown", label + " '" + slug + "' must target a page resource in this workspace. Pull the site to refresh the page inventory.", field);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
278
478
|
function validateScalar(definition, value, knownImageIds) {
|
|
279
479
|
switch (definition.type) {
|
|
480
|
+
case "tag-destinations":
|
|
481
|
+
return JSON.stringify(normalizeTagDestinations(value, definition.path));
|
|
482
|
+
case "breadcrumb-artwork": {
|
|
483
|
+
if (value === "") return "";
|
|
484
|
+
const artwork = parseBreadcrumbArtwork(value);
|
|
485
|
+
if (artwork === undefined) {
|
|
486
|
+
fail("theme.breadcrumb_artwork_invalid", definition.path + " requires a supported SVG file or artwork from pull. See 'taproot-site help appearance'.", definition.path);
|
|
487
|
+
}
|
|
488
|
+
return JSON.stringify(artwork);
|
|
489
|
+
}
|
|
490
|
+
case "heading-spacing":
|
|
491
|
+
if (value !== "" && !isHeadingSpacing(value)) {
|
|
492
|
+
fail(
|
|
493
|
+
"theme.setting_invalid",
|
|
494
|
+
`${definition.path} must be empty or a canonical string from ${definition.minimum} through ${definition.maximum} in ${definition.step} rem steps.`,
|
|
495
|
+
definition.path,
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
return value;
|
|
280
499
|
case "header-height-multiplier": {
|
|
281
500
|
const height = parseHeaderHeightMultiplier(value);
|
|
282
501
|
if (!height) {
|
|
@@ -359,11 +578,51 @@ function validateScalar(definition, value, knownImageIds) {
|
|
|
359
578
|
|
|
360
579
|
/** Compare authored aliases and omitted optional fields with the same values sent to Taproot. */
|
|
361
580
|
export function appearanceScalarInput(definition, value) {
|
|
581
|
+
if (value === "" && definition.emptyIsDefault) return definition.default;
|
|
362
582
|
const input = value === undefined && definition.optional ? definition.default : value;
|
|
363
583
|
if (definition.type === "header-height-multiplier") return parseHeaderHeightMultiplier(input)?.canonical ?? input;
|
|
364
584
|
return input;
|
|
365
585
|
}
|
|
366
586
|
|
|
587
|
+
/** Import local source files before comparing or saving the frozen presentation. */
|
|
588
|
+
export async function readBreadcrumbArtworkSettings(workspaceDir, settings) {
|
|
589
|
+
const result = { ...settings };
|
|
590
|
+
for (const name of BREADCRUMB_ARTWORK_FIELDS) {
|
|
591
|
+
const reference = settings[name];
|
|
592
|
+
if (reference === null || typeof reference !== "object" || !Object.hasOwn(reference, "file")) continue;
|
|
593
|
+
const { file, color = "theme" } = reference;
|
|
594
|
+
const field = "taproot-styles." + name;
|
|
595
|
+
if (typeof file !== "string" || hasControlCharacter(file)) {
|
|
596
|
+
fail("theme.breadcrumb_artwork_invalid", field + " requires a workspace-relative .svg file.", field);
|
|
597
|
+
}
|
|
598
|
+
if (!file.endsWith(".svg")) {
|
|
599
|
+
fail("theme.breadcrumb_artwork_invalid", "Artwork file '" + file + "' must have a .svg extension.", field);
|
|
600
|
+
}
|
|
601
|
+
const unknownKey = Object.keys(reference).find(key => key !== "file" && key !== "color");
|
|
602
|
+
if (unknownKey !== undefined) {
|
|
603
|
+
fail("theme.breadcrumb_artwork_invalid", "The reference to SVG file '" + file + "' has an unknown '" + unknownKey + "' field. Use 'file' and optionally 'color'.", field);
|
|
604
|
+
}
|
|
605
|
+
if (color !== "theme" && color !== "original") {
|
|
606
|
+
fail("theme.breadcrumb_artwork_invalid", "SVG file '" + file + "' must use color 'theme' or 'original'.", field);
|
|
607
|
+
}
|
|
608
|
+
let bytes;
|
|
609
|
+
try {
|
|
610
|
+
bytes = await readWorkspaceFile(workspaceDir, file, BREADCRUMB_ARTWORK_MAX_BYTES);
|
|
611
|
+
} catch (error) {
|
|
612
|
+
if (error instanceof SiteAuthoringError) {
|
|
613
|
+
fail("theme.breadcrumb_artwork_invalid", error.message, field);
|
|
614
|
+
}
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
const imported = importBreadcrumbSvg(bytes.toString("utf8"), color === "theme");
|
|
618
|
+
if ("reason" in imported) {
|
|
619
|
+
fail("theme.breadcrumb_artwork_invalid", "SVG file '" + file + "' " + imported.reason + ". See 'taproot-site help appearance'.", field);
|
|
620
|
+
}
|
|
621
|
+
result[name] = imported.artwork;
|
|
622
|
+
}
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
|
|
367
626
|
function checkedScalar(definition, settings, knownImageIds) {
|
|
368
627
|
return validateScalar(definition, appearanceScalarInput(definition, settings?.[definition.name]), knownImageIds);
|
|
369
628
|
}
|
|
@@ -382,7 +641,9 @@ export function buildAppearanceScalarOperations(documents, knownImageIds) {
|
|
|
382
641
|
throw new TypeError("Appearance validation requires the known site-owned image identities.");
|
|
383
642
|
}
|
|
384
643
|
refuseRetiredScalarFonts(documents[SETTINGS_TYPE_TAPROOT_STYLES]);
|
|
385
|
-
return APPEARANCE_SCALAR_FIELDS.
|
|
644
|
+
return APPEARANCE_SCALAR_FIELDS.filter((definition) =>
|
|
645
|
+
!definition.onlyIfPresent || Object.hasOwn(documents[definition.settingsType], definition.name)
|
|
646
|
+
).map((definition) => ({
|
|
386
647
|
settingsType: definition.settingsType,
|
|
387
648
|
setting: definition.name,
|
|
388
649
|
value: checkedScalar(definition, documents[definition.settingsType], knownImageIds),
|