@taprootio/site-authoring 0.42.0 → 0.56.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 +110 -12
- 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 +242 -23
- package/src/appearance-contract.js +264 -3
- package/src/authored-tag-names.js +88 -0
- package/src/authors-contract.js +71 -3
- 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 +160 -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 +136 -38
- package/src/constants.js +1 -0
- 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-metadata.js +15 -13
- 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 +182 -79
- 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 +94 -16
- package/src/typed-pages.js +233 -74
- package/src/verbs/authors.js +198 -33
- 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/index.js +4 -2
- package/src/verbs/pages-delete.js +19 -10
- package/src/verbs/pages-push.js +225 -71
- package/src/verbs/plan.js +10 -4
- package/src/verbs/pull.js +324 -69
- 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 +73 -2
- package/test/fixtures/default-site-theme.json +516 -0
package/README.md
CHANGED
|
@@ -502,9 +502,9 @@ that would be replaced by a new remote page.
|
|
|
502
502
|
Pages are not only free-form. A source chooses its template with `template:` in
|
|
503
503
|
its front matter — `article`, `recipe`, `album` or `place-review`; free-form is
|
|
504
504
|
the default — and `pull` writes the other four as a `.pm.json` wrapper
|
|
505
|
-
(`{ "template", "displayDate", "coverImageId", "data" }`) that `pages push`
|
|
505
|
+
(`{ "template", "displayDate", "displayAuthor", "showOnProfile", "coverImageId", "data" }`) that `pages push`
|
|
506
506
|
sends back unchanged. Typed pages also carry `displayDate` (so an import keeps
|
|
507
|
-
its original publication date) and `coverImage`, which the site requires to be an
|
|
507
|
+
its original publication date), `displayAuthor` and `showOnProfile` (below) and `coverImage`, which the site requires to be an
|
|
508
508
|
image the page itself uses (place it in the body too; `pages.cover_image_unused`). A page's template is fixed when
|
|
509
509
|
it is created: a source for another template is refused with
|
|
510
510
|
`pages.template_immutable`. `taproot-site help page <type>` gives each
|
|
@@ -597,18 +597,46 @@ kinds of person, named by one string:
|
|
|
597
597
|
- a **site author without a Taproot account** — one of an imported blog's
|
|
598
598
|
authors, say — named by handle (`jane-doe`: lowercase letters, digits and
|
|
599
599
|
single hyphens, at most 64 characters, fixed when the author is created). A
|
|
600
|
-
site author's name appears on the byline and in the page's structured data
|
|
601
|
-
|
|
600
|
+
site author's name appears on the byline and in the page's structured data.
|
|
601
|
+
The byline can link to a page on the site or to a web address and can show an
|
|
602
|
+
image from the media library; there is no follow button, because there is no
|
|
603
|
+
account;
|
|
602
604
|
- a **site member who can create pages**, named by email address.
|
|
603
605
|
|
|
604
606
|
`authors list` prints both and rewrites `authors.json` (`pull` writes it too).
|
|
605
607
|
`authors add jane-doe --name "Jane Doe" [--email jane@example.com]` creates a
|
|
606
608
|
site author; `--email` is kept private (never published, never listed) so the
|
|
607
|
-
person can be linked to a Taproot account later.
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
609
|
+
person can be linked to a Taproot account later. `--link-page <path>` links the
|
|
610
|
+
byline to a page on the site, named by the path `pull` recorded in
|
|
611
|
+
`.taproot-site-manifest.json` (`/` for the home page) or by its `resourceId`;
|
|
612
|
+
`--link-url <address>` links it to an absolute `http` or `https` address. A
|
|
613
|
+
byline links to one place, so passing both is refused (`authors.link_conflict`).
|
|
614
|
+
`--image <media path or image id>` shows an image from the site's media library
|
|
615
|
+
beside the byline; a path is resolved through `.taproot-site-media.json`, as a
|
|
616
|
+
`coverImage` is. A page or media path the workspace does not record is refused
|
|
617
|
+
before any request (`authors.link_page_unknown`, `authors.image_unknown`).
|
|
618
|
+
|
|
619
|
+
`authors set <handle>` changes an author's `--name`, `--email`, link or image
|
|
620
|
+
and sends only the options passed, so everything else keeps its stored value.
|
|
621
|
+
`--no-link`, `--no-image` and `--no-email` remove the link, the image and the
|
|
622
|
+
private address. With no option it is refused (`authors.set_empty`), as are
|
|
623
|
+
options that contradict each other (`authors.link_conflict`,
|
|
624
|
+
`authors.image_conflict`, `authors.email_conflict`), and a handle the site does
|
|
625
|
+
not have is `authors.handle_unknown`. Changing the name, link or image of an
|
|
626
|
+
author who appears on published pages queues one production deployment, so the
|
|
627
|
+
verb asks a signed-in credential for the deployments capability as well as
|
|
628
|
+
content, and a caller who may not deploy is refused
|
|
629
|
+
(`authors.deployment_refused`), as is a change while a deployment is running.
|
|
630
|
+
|
|
631
|
+
Adding a handle the site already has under the same name succeeds and reports
|
|
632
|
+
`existing: true`, so a script can repeat itself. The name is always compared; a
|
|
633
|
+
link or image is compared only when its option was passed, so repeating an
|
|
634
|
+
import script after someone added a link still succeeds. A name, link or image
|
|
635
|
+
that differs is refused (`authors.handle_taken`) and points at `authors set`.
|
|
636
|
+
`authors.json` holds the members' email addresses, so keep it out of a public
|
|
637
|
+
repository; it also records each site author's `linkPageResourceId`, `linkUrl`
|
|
638
|
+
and `imageId` when they have one, and is a read-only copy of the site that
|
|
639
|
+
`pull` and the `authors` verbs refresh.
|
|
612
640
|
|
|
613
641
|
A page names its author with `author: jane-doe` in its front matter (any
|
|
614
642
|
template), or, for a `.pm.json` page, `pages meta set <path> --author jane-doe`.
|
|
@@ -623,6 +651,45 @@ current list once (`pages push` rewrites `authors.json` with it) and refuse
|
|
|
623
651
|
(`pages.author_unknown`) only a name the site really lacks. A member who cannot
|
|
624
652
|
create pages is `pages.author_unknown` as well, with the same wording.
|
|
625
653
|
|
|
654
|
+
`displayAuthor` is a typed page's byline under a pen name: article,
|
|
655
|
+
album, recipe and place-review pages take `displayAuthor: jane-doe` in front
|
|
656
|
+
matter or `"displayAuthor": "jane-doe"` in the `.pm.json` document, naming a
|
|
657
|
+
site author by handle (`none` is a handle like any other; a member's email
|
|
658
|
+
address is refused with `pages.display_author_invalid`). The published byline
|
|
659
|
+
then shows that author, with their link and image, and carries no trace of the
|
|
660
|
+
member who wrote the page, who also loses the page from their Taproot profile.
|
|
661
|
+
Unlike `author` it can be set, replaced and cleared at any time: an empty value
|
|
662
|
+
(`displayAuthor: ""`) clears it and an absent key leaves the site's value alone.
|
|
663
|
+
A bare `displayAuthor:` line is refused (`pages.display_author_invalid`), so an
|
|
664
|
+
unfinished line cannot clear a pen name.
|
|
665
|
+
Set it before the page is first published when it must be kept apart from the
|
|
666
|
+
member, because a page already published under the member's name was public
|
|
667
|
+
with it. A handle missing from `authors.json` is only warned about offline
|
|
668
|
+
(`pages.display_author_unverified`); `pages push` and `plan` check the site's
|
|
669
|
+
list once and refuse an unknown handle (`pages.display_author_unknown`). Like
|
|
670
|
+
`displayDate` it is not covered by the body revision: `pull` refreshes an
|
|
671
|
+
unedited `.pm.json` document with the site's value and keeps a Markdown source,
|
|
672
|
+
and a push that would overwrite a display author that changed on the site since
|
|
673
|
+
the last pull is refused with `pages.push_conflict`. A place review with a
|
|
674
|
+
display author raises no missing-reviewer warning, and a page credited only
|
|
675
|
+
through `displayAuthor` is not listed in `pages.authorless`.
|
|
676
|
+
|
|
677
|
+
`showOnProfile` (article, album, recipe and place-review pages) says whether
|
|
678
|
+
the page may appear on its author's Taproot profile. It matters only for a
|
|
679
|
+
page a profile can list: one written by a member, with no display author. Such
|
|
680
|
+
a page is on the profile when new, unless the source says `showOnProfile: false`,
|
|
681
|
+
which keeps the page off the profile while it keeps its byline and its profile link; `showOnProfile: true` over a page the
|
|
682
|
+
site excludes puts it back. Only the words `true` and `false` are accepted in
|
|
683
|
+
front matter and a JSON boolean in a `.pm.json` document; anything else,
|
|
684
|
+
including a quoted JSON string, is refused by `validate` and `pages push`
|
|
685
|
+
(`pages.show_on_profile_invalid`). The profile changes after the page is
|
|
686
|
+
published and its release goes live, not when the page is saved. To keep a page
|
|
687
|
+
apart from the member entirely, give it a `displayAuthor`. Like `displayDate`
|
|
688
|
+
it is left alone when the key is absent, a pulled `.pm.json` document carries
|
|
689
|
+
it only when it is `false`, `pull` refreshes an unedited document and keeps a
|
|
690
|
+
Markdown source, and a push that would overwrite a value that changed on the
|
|
691
|
+
site since the last pull is refused with `pages.push_conflict`.
|
|
692
|
+
|
|
626
693
|
The CLI only fills a page that has no author: a page that already has a
|
|
627
694
|
different one is refused (`pages.author_conflict`), by the CLI from what the
|
|
628
695
|
last pull recorded and by Taproot, and naming the author a page already has
|
|
@@ -938,7 +1005,19 @@ response. Context display names longer than 128 characters carry
|
|
|
938
1005
|
`contextTruncated` and `contextLength`. Context filtering uses the full name.
|
|
939
1006
|
The authoring result fits 64 KiB, preserves all selected chrome measurements
|
|
940
1007
|
and reserves at least 24 KiB for legacy surfaces. The indexed report is
|
|
941
|
-
produced by the authoring CLI.
|
|
1008
|
+
produced by the authoring CLI. Retry an omitted named context with
|
|
1009
|
+
`--scheme` and `--context`. Retry a root with `--scheme`, which keeps named
|
|
1010
|
+
contexts and chrome for that scheme. The reason `surface_too_large` means
|
|
1011
|
+
the surface exceeds the output bound under those narrowest selectors.
|
|
1012
|
+
`omittedSurfaces.retryRootSchemes` lists roots that fit on retry even when
|
|
1013
|
+
the displayed omissions are truncated. Find the full context names under
|
|
1014
|
+
`lightTheme.contexts` and `darkTheme.contexts` in `settings/taproot-styles.json`.
|
|
1015
|
+
For `--site`, pull in a separate workspace for the same site to read its
|
|
1016
|
+
current names. With an account sign-in, run `taproot-site use <site>` from
|
|
1017
|
+
an empty directory outside the working copy, then run `taproot-site pull`.
|
|
1018
|
+
`surfaces[].footerLinkOnLayer2` identifies an adjusted semantic link whose
|
|
1019
|
+
exact surface also paints a resting footer link over layer2. The card's
|
|
1020
|
+
display name can be shorter than that surface's context name.
|
|
942
1021
|
|
|
943
1022
|
When `GITHUB_OUTPUT` names the runner's existing output file, every
|
|
944
1023
|
operational verb appends the same JSON under `taproot_site_result` through a
|
|
@@ -947,6 +1026,25 @@ Authorization values, signed upload headers, preview handoffs outside the
|
|
|
947
1026
|
final result, and page bodies never appear in progress, diagnostics, JSON, or
|
|
948
1027
|
Actions output.
|
|
949
1028
|
|
|
1029
|
+
### Indexed token paints
|
|
1030
|
+
|
|
1031
|
+
`help tokens --json` lists every semantic token. `theme resolve --json` includes
|
|
1032
|
+
paint details for pinned or adjusted tokens as space permits. Both key
|
|
1033
|
+
`tokens` by semantic name and use zero-based indexes into the response's
|
|
1034
|
+
`paintCatalog`.
|
|
1035
|
+
|
|
1036
|
+
- A component paint indexes `component`, `part`, `state`, `label` and `folder`,
|
|
1037
|
+
in that order. An optional sixth index selects the `alias`.
|
|
1038
|
+
- A template paint starts with `-1`, then indexes `file`, `markup`, `part` and
|
|
1039
|
+
`label`. Its remaining indexes select entries in `topics`.
|
|
1040
|
+
- A token's `paintNotes[].paintIndex` points to a row in that token's `paints`.
|
|
1041
|
+
|
|
1042
|
+
`help page <type> --json` uses `page.tokenReach.dictionary` and
|
|
1043
|
+
`page.tokenReach.rows`. Each row indexes `token`, `file`, `markup`, `part`,
|
|
1044
|
+
`label` and `topics` in that order. The selected `topics` entry is the
|
|
1045
|
+
complete list of page types for the row. The rows include intent names such
|
|
1046
|
+
as `intent:info` alongside CSS token names.
|
|
1047
|
+
|
|
950
1048
|
### Every write answers `platform_paused`
|
|
951
1049
|
|
|
952
1050
|
`pull` and `status` succeed, and every write is refused with
|
|
@@ -1097,8 +1195,8 @@ once).
|
|
|
1097
1195
|
1000, here and by Taproot.
|
|
1098
1196
|
- Generated pages (the published archive, the map, folders) pull as update-only sources
|
|
1099
1197
|
whose custom title, breadcrumb, description and introduction you can edit.
|
|
1100
|
-
- Pages are authorless by default. `authors list`, `authors add`
|
|
1101
|
-
`authors.json` name a member who can create pages or a site author without a
|
|
1198
|
+
- Pages are authorless by default. `authors list`, `authors add`, `authors set`
|
|
1199
|
+
and `authors.json` name a member who can create pages or a site author without a
|
|
1102
1200
|
Taproot account; `author:` front matter or `pages meta set --author` credits
|
|
1103
1201
|
one on a page that has none, and an author is never replaced from the CLI.
|
|
1104
1202
|
- `redirects check` and `deploy --staging` report `routeCheck`, `redirects` and
|
|
@@ -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.56.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";
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
import { KEY_PREFIX } from "./credentials.js";
|
|
31
32
|
import { CAPABILITY_LEGAL_DRAFTS, SITE_AUTHORING_CAPABILITIES } from "./capabilities.js";
|
|
32
33
|
import { isCanonicalUuid, normalizePreviewDiagnostic, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
|
|
33
|
-
import { normalizeAuthorListing, parseAuthorReference } from "./authors-contract.js";
|
|
34
|
+
import { normalizeAuthorHandle, normalizeAuthorListing, parseAuthorReference } from "./authors-contract.js";
|
|
34
35
|
import { docsPublicationModeFromWire, siteKindFromWire, surfaceFromWire } from "./surface.js";
|
|
35
36
|
import {
|
|
36
37
|
DEFAULT_REDIRECT_STATUS,
|
|
@@ -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
|
|
@@ -535,8 +536,22 @@ export function isGonePage(summary) {
|
|
|
535
536
|
return summary.status === PAGE_STATUS_DELETED || summary.removalStaged === true;
|
|
536
537
|
}
|
|
537
538
|
|
|
539
|
+
/**
|
|
540
|
+
* The one inbound conversion of the wire's `excludeFromProfile` (absent means
|
|
541
|
+
* false) to the workspace's positive `showOnProfile` (TR01403). Pull, the push
|
|
542
|
+
* baseline and the push guard all compare in this sense.
|
|
543
|
+
*/
|
|
544
|
+
export function showOnProfileOf(wire) {
|
|
545
|
+
return wire?.excludeFromProfile !== true;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function displayAuthorOf(summary) {
|
|
549
|
+
return typeof summary.displayAuthor === "string" ? normalizeAuthorHandle(summary.displayAuthor) ?? "" : "";
|
|
550
|
+
}
|
|
551
|
+
|
|
538
552
|
export function normalizePageSummary(value) {
|
|
539
553
|
const summary = requireObject(value, "api.page_contract", "page summary");
|
|
554
|
+
const hasAuthor = typeof summary.authorDisplayName === "string" && summary.authorDisplayName.trim() !== "";
|
|
540
555
|
return {
|
|
541
556
|
pageId: requireIdentifier(summary.pageId, "api.page_contract", "page.pageId"),
|
|
542
557
|
resourceId: typeof summary.resourceId === "string" ? summary.resourceId : "",
|
|
@@ -561,6 +576,13 @@ export function normalizePageSummary(value) {
|
|
|
561
576
|
// The page's calendar date, empty when it has none. It is not part of
|
|
562
577
|
// `bodyRevision`, so a typed page's push guard compares it separately.
|
|
563
578
|
displayDate: typeof summary.displayDate === "string" ? summary.displayDate : "",
|
|
579
|
+
// The site author the byline shows instead of the member who wrote the page
|
|
580
|
+
// (TR01402): a folded handle, empty for none. Like the date it is not part
|
|
581
|
+
// of `bodyRevision`. Only a site-authoring credential sees it, and an older
|
|
582
|
+
// Taproot sends none.
|
|
583
|
+
displayAuthor: displayAuthorOf(summary),
|
|
584
|
+
// Whether the page may appear on its author's Taproot profile (TR01403).
|
|
585
|
+
showOnProfile: showOnProfileOf(summary),
|
|
564
586
|
// The name the page's author goes by in a write: a site author's handle or
|
|
565
587
|
// a member's email address, folded. Empty for a page with no author, for a
|
|
566
588
|
// former member's page, and against a Taproot that predates authors
|
|
@@ -568,7 +590,11 @@ export function normalizePageSummary(value) {
|
|
|
568
590
|
authorRef: typeof summary.authorRef === "string" ? parseAuthorReference(summary.authorRef)?.value ?? "" : "",
|
|
569
591
|
// Whether the page credits anyone at all, which an empty authorRef cannot
|
|
570
592
|
// say: it is also empty for an author this credential may not name.
|
|
571
|
-
hasAuthor
|
|
593
|
+
hasAuthor,
|
|
594
|
+
...(summary.templateType === "TEMPLATE_TYPE_PLACE_REVIEW" ? {
|
|
595
|
+
reviewAuthorMissing: !hasAuthor && displayAuthorOf(summary) === ""
|
|
596
|
+
&& summary.memberAccess !== "PAGE_MEMBER_ACCESS_MEMBER_ONLY",
|
|
597
|
+
} : {}),
|
|
572
598
|
};
|
|
573
599
|
}
|
|
574
600
|
|
|
@@ -592,21 +618,159 @@ export async function listSitePages(client, siteId, { onProgress = () => {} } =
|
|
|
592
618
|
return { pages, truncated: true };
|
|
593
619
|
}
|
|
594
620
|
|
|
621
|
+
/**
|
|
622
|
+
* A bare 404 is the compatibility path for a server from before the capability
|
|
623
|
+
* route existed. A classified refusal or a bad response still fails the read.
|
|
624
|
+
*/
|
|
625
|
+
export async function getSiteAuthoringCapabilities(client, siteId) {
|
|
626
|
+
let value;
|
|
627
|
+
try {
|
|
628
|
+
value = await client.request(sitePath(siteId, "authoring-capabilities"));
|
|
629
|
+
} catch (error) {
|
|
630
|
+
if (
|
|
631
|
+
error instanceof ApiError && error.httpStatus === HTTP_NOT_FOUND && error.grpcCode === undefined
|
|
632
|
+
&& error.refusalKind() === REFUSAL_UNCLASSIFIED && error.fields.length === 0
|
|
633
|
+
) return undefined;
|
|
634
|
+
throw error;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
const code = "api.authoring_capabilities_contract";
|
|
638
|
+
const response = requireObject(value, code, "site authoring capabilities");
|
|
639
|
+
for (const field of ["authoredTagWritesEnabled", "authoredTagWritesPermitted"]) {
|
|
640
|
+
if (typeof response[field] !== "boolean") {
|
|
641
|
+
throw new SiteAuthoringError(code, `Taproot did not return a valid ${field} capability.`, { field });
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
authoredTagWritesEnabled: response.authoredTagWritesEnabled,
|
|
646
|
+
authoredTagWritesPermitted: response.authoredTagWritesPermitted,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** The snapshot for the exact page version returned by the selected read. */
|
|
651
|
+
export function requireAuthoredTagSnapshot(page) {
|
|
652
|
+
const code = "api.authored_tag_snapshot_contract";
|
|
653
|
+
const field = "authoredTagSnapshot";
|
|
654
|
+
const snapshot = page?.[field];
|
|
655
|
+
if (snapshot === null || typeof snapshot !== "object" || Array.isArray(snapshot)) {
|
|
656
|
+
throw new SiteAuthoringError(code, "Taproot did not return a valid authored tag snapshot for this page.", { field });
|
|
657
|
+
}
|
|
658
|
+
const revision = normalizeAuthoredTagRevision(snapshot.revision);
|
|
659
|
+
if (revision === undefined) {
|
|
660
|
+
throw new SiteAuthoringError(code, "Taproot did not return a valid authored tag snapshot revision.", {
|
|
661
|
+
field: `${field}.revision`,
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
if (snapshot.entries !== undefined && !Array.isArray(snapshot.entries)) {
|
|
665
|
+
throw new SiteAuthoringError(code, "Taproot did not return a valid list of authored tags.", {
|
|
666
|
+
field: `${field}.entries`,
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
const identifiers = new Set();
|
|
670
|
+
const entries = (snapshot.entries ?? []).map((entry, index) => {
|
|
671
|
+
const id = typeof entry?.id === "string" ? entry.id.toLowerCase() : "";
|
|
672
|
+
if (
|
|
673
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u.test(id)
|
|
674
|
+
|| identifiers.has(id) || typeof entry.name !== "string" || typeof entry.slug !== "string"
|
|
675
|
+
) {
|
|
676
|
+
throw new SiteAuthoringError(code, "Taproot returned an invalid authored tag entry.", {
|
|
677
|
+
field: `${field}.entries[${index}]`,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
identifiers.add(id);
|
|
681
|
+
return { id, name: entry.name, slug: entry.slug };
|
|
682
|
+
});
|
|
683
|
+
return { entries, revision };
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Keep wrapper presence independent of the repeated field inside it. A clear
|
|
688
|
+
* carries a wrapper with no names, whereas an ordinary write omits the wrapper.
|
|
689
|
+
*/
|
|
690
|
+
export function wireAuthoredTagFields(tags, { expectedAuthoredTagRevision, expectedBodyRevision } = {}) {
|
|
691
|
+
if (tags === undefined) return {};
|
|
692
|
+
const names = requireAuthoredTagNames(tags);
|
|
693
|
+
return {
|
|
694
|
+
authoredTags: { names },
|
|
695
|
+
...(expectedAuthoredTagRevision === undefined ? {} : { expectedAuthoredTagRevision }),
|
|
696
|
+
...(expectedBodyRevision === undefined ? {} : { expectedBodyRevision }),
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function requireAuthoredTagNames(tags) {
|
|
701
|
+
const result = validateAuthoredTagNames(tags);
|
|
702
|
+
if ("reason" in result) throw new SiteAuthoringError("pages.tags_invalid", result.reason, { field: result.field });
|
|
703
|
+
return result.names;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* The one outbound conversion: the workspace's `showOnProfile` leaves as the
|
|
708
|
+
* wire's `excludeFromProfile`, and only when the document stated it (TR01403).
|
|
709
|
+
*/
|
|
710
|
+
function withWireProfileFlag(body) {
|
|
711
|
+
const { showOnProfile, ...rest } = body;
|
|
712
|
+
return showOnProfile === undefined ? rest : { ...rest, excludeFromProfile: !showOnProfile };
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function pageMutationBody(source, updating) {
|
|
716
|
+
const body = withWireProfileFlag(source);
|
|
717
|
+
if (body.authoredTags === undefined) return body;
|
|
718
|
+
const wrapper = body.authoredTags;
|
|
719
|
+
if (wrapper === null || typeof wrapper !== "object" || Array.isArray(wrapper)) {
|
|
720
|
+
throw new SiteAuthoringError("pages.tags_invalid", "Send authored tags as a tag-name list.", { field: "tags" });
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const authoredTags = wrapper.names === undefined ? {} : { names: requireAuthoredTagNames(wrapper.names) };
|
|
724
|
+
if (updating) {
|
|
725
|
+
for (const [field, revision] of [
|
|
726
|
+
["expectedAuthoredTagRevision", normalizeAuthoredTagRevision(body.expectedAuthoredTagRevision)],
|
|
727
|
+
["expectedBodyRevision", normalizePageBodyRevision(body.expectedBodyRevision)],
|
|
728
|
+
]) {
|
|
729
|
+
if (revision === undefined) {
|
|
730
|
+
throw new SiteAuthoringError(
|
|
731
|
+
"pages.tag_revision_required",
|
|
732
|
+
"Pull this page before replacing its authored tags so the update can check both revisions.",
|
|
733
|
+
{ field },
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return { ...body, authoredTags };
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function normalizePageMutation(value, tagged) {
|
|
742
|
+
const summary = normalizePageSummary(value);
|
|
743
|
+
if (!tagged) return summary;
|
|
744
|
+
const authoredTagRevision = normalizeAuthoredTagRevision(value.authoredTagRevision);
|
|
745
|
+
if (authoredTagRevision === undefined) {
|
|
746
|
+
throw new SiteAuthoringError(
|
|
747
|
+
"api.page_contract",
|
|
748
|
+
"Taproot did not confirm the authored tag revision. Pull this page to see whether the write succeeded.",
|
|
749
|
+
{ field: "authoredTagRevision" },
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
return { ...summary, authoredTagRevision };
|
|
753
|
+
}
|
|
754
|
+
|
|
595
755
|
/**
|
|
596
756
|
* Reads one page's editable body. `GetPageById` refuses an unspecified status,
|
|
597
757
|
* so the caller must name which version it wants: the draft when the summary
|
|
598
758
|
* says one exists, otherwise the version the summary reports.
|
|
599
759
|
*/
|
|
600
760
|
export async function getPage(client, pageId, status) {
|
|
601
|
-
|
|
761
|
+
const page = requireObject(
|
|
602
762
|
await client.request(`v1/pages/${encodeURIComponent(pageId)}${query([["status", status]])}`),
|
|
603
763
|
"api.page_contract",
|
|
604
764
|
"page",
|
|
605
765
|
);
|
|
766
|
+
return { ...page, showOnProfile: showOnProfileOf(page) };
|
|
606
767
|
}
|
|
607
768
|
|
|
608
769
|
export async function createPage(client, body) {
|
|
609
|
-
return
|
|
770
|
+
return normalizePageMutation(
|
|
771
|
+
await client.request("v1/pages", { method: "POST", body: pageMutationBody(body, false) }),
|
|
772
|
+
body.authoredTags !== undefined,
|
|
773
|
+
);
|
|
610
774
|
}
|
|
611
775
|
|
|
612
776
|
/**
|
|
@@ -619,14 +783,18 @@ export async function deletePage(client, pageId) {
|
|
|
619
783
|
}
|
|
620
784
|
|
|
621
785
|
export async function updatePage(client, pageId, body) {
|
|
622
|
-
return
|
|
623
|
-
await client.request(`v1/pages/${encodeURIComponent(pageId)}`, {
|
|
786
|
+
return normalizePageMutation(
|
|
787
|
+
await client.request(`v1/pages/${encodeURIComponent(pageId)}`, {
|
|
788
|
+
method: "PATCH",
|
|
789
|
+
body: pageMutationBody(body, true),
|
|
790
|
+
}),
|
|
791
|
+
body.authoredTags !== undefined,
|
|
624
792
|
);
|
|
625
793
|
}
|
|
626
794
|
|
|
627
795
|
/**
|
|
628
|
-
* Gives the site's
|
|
629
|
-
* (TR01196). The site answers an unknown name and one that cannot be named with
|
|
796
|
+
* Gives the site's author refusals, and the display author's (TR01402), the
|
|
797
|
+
* stable codes the CLI documents (TR01196). The site answers an unknown name and one that cannot be named with
|
|
630
798
|
* the same field and wording on purpose; this keeps them one code too.
|
|
631
799
|
*/
|
|
632
800
|
export function translateAuthorRefusal(error, file) {
|
|
@@ -634,6 +802,7 @@ export function translateAuthorRefusal(error, file) {
|
|
|
634
802
|
for (const [field, code, fallback] of [
|
|
635
803
|
["AuthorUnknown", "pages.author_unknown", "No site author or member who can create pages has that name."],
|
|
636
804
|
["AuthorConflict", "pages.author_conflict", "The page already has a different author, which is never replaced."],
|
|
805
|
+
["DisplayAuthorUnknown", "pages.display_author_unknown", "That handle is not a site author of this site."],
|
|
637
806
|
]) {
|
|
638
807
|
if (error.hasField(field)) {
|
|
639
808
|
const detail = sanitizeDiagnostic(error.descriptionFor(field) ?? fallback, fallback);
|
|
@@ -659,17 +828,12 @@ export async function listSiteAuthors(client, siteId) {
|
|
|
659
828
|
);
|
|
660
829
|
}
|
|
661
830
|
|
|
662
|
-
/**
|
|
663
|
-
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}),
|
|
669
|
-
"api.authors_contract",
|
|
670
|
-
"site author",
|
|
671
|
-
);
|
|
672
|
-
const listing = normalizeAuthorListing({ authors: [created], members: [] });
|
|
831
|
+
/** Reads one author the site returned, refusing a response this CLI cannot use. */
|
|
832
|
+
function readSiteAuthor(value) {
|
|
833
|
+
const listing = normalizeAuthorListing({
|
|
834
|
+
authors: [requireObject(value, "api.authors_contract", "site author")],
|
|
835
|
+
members: [],
|
|
836
|
+
});
|
|
673
837
|
if (listing.authors.length !== 1) {
|
|
674
838
|
throw new SiteAuthoringError(
|
|
675
839
|
"api.authors_contract",
|
|
@@ -680,6 +844,44 @@ export async function createSiteAuthor(client, siteId, { handle, displayName, em
|
|
|
680
844
|
return listing.authors[0];
|
|
681
845
|
}
|
|
682
846
|
|
|
847
|
+
/**
|
|
848
|
+
* Creates a site author. The site folds the handle and the address. The byline
|
|
849
|
+
* link (one of linkPageResourceId or linkUrl) and the image are sent only when
|
|
850
|
+
* given (TR01401).
|
|
851
|
+
*/
|
|
852
|
+
export async function createSiteAuthor(
|
|
853
|
+
client,
|
|
854
|
+
siteId,
|
|
855
|
+
{ handle, displayName, email, linkPageResourceId, linkUrl, imageId },
|
|
856
|
+
) {
|
|
857
|
+
return readSiteAuthor(
|
|
858
|
+
await client.request(sitePath(siteId, "authors"), {
|
|
859
|
+
method: "POST",
|
|
860
|
+
body: {
|
|
861
|
+
handle,
|
|
862
|
+
displayName,
|
|
863
|
+
...(email === undefined ? {} : { email }),
|
|
864
|
+
...(linkPageResourceId === undefined ? {} : { linkPageResourceId }),
|
|
865
|
+
...(linkUrl === undefined ? {} : { linkUrl }),
|
|
866
|
+
...(imageId === undefined ? {} : { imageId }),
|
|
867
|
+
},
|
|
868
|
+
}),
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Changes a site author. `changes` holds only what the caller wants changed: a
|
|
874
|
+
* field left out keeps its stored value and an empty string clears it.
|
|
875
|
+
*/
|
|
876
|
+
export async function updateSiteAuthor(client, siteId, handle, changes) {
|
|
877
|
+
return readSiteAuthor(
|
|
878
|
+
await client.request(sitePath(siteId, `authors/${encodeURIComponent(handle)}`), {
|
|
879
|
+
method: "PATCH",
|
|
880
|
+
body: changes,
|
|
881
|
+
}),
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
|
|
683
885
|
export async function publishDrafts(client, pageIds) {
|
|
684
886
|
const response = requireObject(
|
|
685
887
|
await client.request("v1/pages/publish_drafts", { method: "POST", body: { pageIds } }),
|
|
@@ -1508,19 +1710,27 @@ export function describePageEstimate(estimate) {
|
|
|
1508
1710
|
return `${generates} · ${left}${resets}`;
|
|
1509
1711
|
}
|
|
1510
1712
|
|
|
1713
|
+
export const STAGING_HOSTING_SETUP_GUIDANCE = "Activate a staging hostname in the site's Settings under Licence & domain. "
|
|
1714
|
+
+ "For a local Taproot stack, check the stack's staging hostname setup.";
|
|
1715
|
+
|
|
1511
1716
|
export async function getStagingPreviewStatus(client, siteId) {
|
|
1512
1717
|
const response = requireObject(
|
|
1513
1718
|
await client.request(sitePath(siteId, "staging-preview/status")),
|
|
1514
1719
|
"api.staging_preview_contract",
|
|
1515
1720
|
"staging preview status",
|
|
1516
1721
|
);
|
|
1517
|
-
|
|
1722
|
+
const ready = response.ready === undefined ? false : response.ready;
|
|
1723
|
+
if (
|
|
1724
|
+
response.siteId !== siteId || typeof ready !== "boolean"
|
|
1725
|
+
|| (response.hasStagedRelease !== undefined && typeof response.hasStagedRelease !== "boolean")
|
|
1726
|
+
) {
|
|
1518
1727
|
throw new SiteAuthoringError(
|
|
1519
1728
|
"api.staging_preview_contract",
|
|
1520
1729
|
"Taproot returned an invalid staging preview status response.",
|
|
1521
1730
|
);
|
|
1522
1731
|
}
|
|
1523
|
-
|
|
1732
|
+
const releaseStatus = response.hasStagedRelease === undefined ? {} : { hasStagedRelease: response.hasStagedRelease };
|
|
1733
|
+
if (!ready) return { ready: false, stagingUrl: "", ...releaseStatus };
|
|
1524
1734
|
|
|
1525
1735
|
let url;
|
|
1526
1736
|
try {
|
|
@@ -1548,7 +1758,7 @@ export async function getStagingPreviewStatus(client, siteId) {
|
|
|
1548
1758
|
{ field: "stagingUrl" },
|
|
1549
1759
|
);
|
|
1550
1760
|
}
|
|
1551
|
-
return { ready: true, stagingUrl: `https://${url.hostname}
|
|
1761
|
+
return { ready: true, stagingUrl: `https://${url.hostname}/`, ...releaseStatus };
|
|
1552
1762
|
}
|
|
1553
1763
|
|
|
1554
1764
|
// The server accepts 2048, but the edge appends a check parameter before its own 2048 test.
|
|
@@ -1776,6 +1986,15 @@ export async function deploySite(client, siteId, body) {
|
|
|
1776
1986
|
{ field: "AuthoringPreviewFailed", status: error.status },
|
|
1777
1987
|
);
|
|
1778
1988
|
}
|
|
1989
|
+
if (error instanceof ApiError && error.refusalKind() === REFUSAL_UNCLASSIFIED && error.hasField("Hosting")) {
|
|
1990
|
+
const staging = body.environment === DEPLOYMENT_ENVIRONMENT_STAGING;
|
|
1991
|
+
const detail = error.descriptionFor("Hosting") ?? "Taproot could not use the site's hosting configuration.";
|
|
1992
|
+
throw new SiteAuthoringError(
|
|
1993
|
+
"deploy.hosting_unavailable",
|
|
1994
|
+
staging ? detail + " " + STAGING_HOSTING_SETUP_GUIDANCE : detail,
|
|
1995
|
+
{ field: "Hosting", status: error.status },
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1779
1998
|
if (error instanceof ApiError && error.hasField("ExpectedPageCount")) {
|
|
1780
1999
|
throw new SiteAuthoringError(
|
|
1781
2000
|
"deploy.page_estimate_changed",
|