@taprootio/site-authoring 0.55.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 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
- there is no profile link or follow button, because there is no account;
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. Adding a handle the site
608
- already has under the same name succeeds and reports `existing: true`, so a
609
- script can repeat itself; a different name for a taken handle is refused
610
- (`authors.handle_taken`), naming the one the site has. `authors.json` holds the
611
- members' email addresses, so keep it out of a public repository.
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
@@ -1128,8 +1195,8 @@ once).
1128
1195
  1000, here and by Taproot.
1129
1196
  - Generated pages (the published archive, the map, folders) pull as update-only sources
1130
1197
  whose custom title, breadcrumb, description and introduction you can edit.
1131
- - Pages are authorless by default. `authors list`, `authors add` and
1132
- `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
1133
1200
  Taproot account; `author:` front matter or `pages meta set --author` credits
1134
1201
  one on a page that has none, and an author is never replaced from the CLI.
1135
1202
  - `redirects check` and `deploy --staging` report `routeCheck`, `redirects` and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taprootio/site-authoring",
3
- "version": "0.55.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",
package/src/api.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  import { KEY_PREFIX } from "./credentials.js";
32
32
  import { CAPABILITY_LEGAL_DRAFTS, SITE_AUTHORING_CAPABILITIES } from "./capabilities.js";
33
33
  import { isCanonicalUuid, normalizePreviewDiagnostic, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
34
- import { normalizeAuthorListing, parseAuthorReference } from "./authors-contract.js";
34
+ import { normalizeAuthorHandle, normalizeAuthorListing, parseAuthorReference } from "./authors-contract.js";
35
35
  import { docsPublicationModeFromWire, siteKindFromWire, surfaceFromWire } from "./surface.js";
36
36
  import {
37
37
  DEFAULT_REDIRECT_STATUS,
@@ -536,6 +536,19 @@ export function isGonePage(summary) {
536
536
  return summary.status === PAGE_STATUS_DELETED || summary.removalStaged === true;
537
537
  }
538
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
+
539
552
  export function normalizePageSummary(value) {
540
553
  const summary = requireObject(value, "api.page_contract", "page summary");
541
554
  const hasAuthor = typeof summary.authorDisplayName === "string" && summary.authorDisplayName.trim() !== "";
@@ -563,6 +576,13 @@ export function normalizePageSummary(value) {
563
576
  // The page's calendar date, empty when it has none. It is not part of
564
577
  // `bodyRevision`, so a typed page's push guard compares it separately.
565
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),
566
586
  // The name the page's author goes by in a write: a site author's handle or
567
587
  // a member's email address, folded. Empty for a page with no author, for a
568
588
  // former member's page, and against a Taproot that predates authors
@@ -572,7 +592,8 @@ export function normalizePageSummary(value) {
572
592
  // say: it is also empty for an author this credential may not name.
573
593
  hasAuthor,
574
594
  ...(summary.templateType === "TEMPLATE_TYPE_PLACE_REVIEW" ? {
575
- reviewAuthorMissing: !hasAuthor && summary.memberAccess !== "PAGE_MEMBER_ACCESS_MEMBER_ONLY",
595
+ reviewAuthorMissing: !hasAuthor && displayAuthorOf(summary) === ""
596
+ && summary.memberAccess !== "PAGE_MEMBER_ACCESS_MEMBER_ONLY",
576
597
  } : {}),
577
598
  };
578
599
  }
@@ -682,7 +703,17 @@ function requireAuthoredTagNames(tags) {
682
703
  return result.names;
683
704
  }
684
705
 
685
- function pageMutationBody(body, updating) {
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);
686
717
  if (body.authoredTags === undefined) return body;
687
718
  const wrapper = body.authoredTags;
688
719
  if (wrapper === null || typeof wrapper !== "object" || Array.isArray(wrapper)) {
@@ -727,11 +758,12 @@ function normalizePageMutation(value, tagged) {
727
758
  * says one exists, otherwise the version the summary reports.
728
759
  */
729
760
  export async function getPage(client, pageId, status) {
730
- return requireObject(
761
+ const page = requireObject(
731
762
  await client.request(`v1/pages/${encodeURIComponent(pageId)}${query([["status", status]])}`),
732
763
  "api.page_contract",
733
764
  "page",
734
765
  );
766
+ return { ...page, showOnProfile: showOnProfileOf(page) };
735
767
  }
736
768
 
737
769
  export async function createPage(client, body) {
@@ -761,8 +793,8 @@ export async function updatePage(client, pageId, body) {
761
793
  }
762
794
 
763
795
  /**
764
- * Gives the site's two author refusals the stable codes the CLI documents
765
- * (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
766
798
  * the same field and wording on purpose; this keeps them one code too.
767
799
  */
768
800
  export function translateAuthorRefusal(error, file) {
@@ -770,6 +802,7 @@ export function translateAuthorRefusal(error, file) {
770
802
  for (const [field, code, fallback] of [
771
803
  ["AuthorUnknown", "pages.author_unknown", "No site author or member who can create pages has that name."],
772
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."],
773
806
  ]) {
774
807
  if (error.hasField(field)) {
775
808
  const detail = sanitizeDiagnostic(error.descriptionFor(field) ?? fallback, fallback);
@@ -795,17 +828,12 @@ export async function listSiteAuthors(client, siteId) {
795
828
  );
796
829
  }
797
830
 
798
- /** Creates a site author. The site folds the handle and the address. */
799
- export async function createSiteAuthor(client, siteId, { handle, displayName, email }) {
800
- const created = requireObject(
801
- await client.request(sitePath(siteId, "authors"), {
802
- method: "POST",
803
- body: { handle, displayName, ...(email === undefined ? {} : { email }) },
804
- }),
805
- "api.authors_contract",
806
- "site author",
807
- );
808
- 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
+ });
809
837
  if (listing.authors.length !== 1) {
810
838
  throw new SiteAuthoringError(
811
839
  "api.authors_contract",
@@ -816,6 +844,44 @@ export async function createSiteAuthor(client, siteId, { handle, displayName, em
816
844
  return listing.authors[0];
817
845
  }
818
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
+
819
885
  export async function publishDrafts(client, pageIds) {
820
886
  const response = requireObject(
821
887
  await client.request("v1/pages/publish_drafts", { method: "POST", body: { pageIds } }),
@@ -1,4 +1,4 @@
1
- import { SiteAuthoringError } from "./errors.js";
1
+ import { isCanonicalUuid, SiteAuthoringError } from "./errors.js";
2
2
 
3
3
  /**
4
4
  * Who a page can be credited to (TR01196).
@@ -20,6 +20,7 @@ export const AUTHORS_FILE_NAME = "authors.json";
20
20
  export const AUTHOR_HANDLE_MAXIMUM_LENGTH = 64;
21
21
  export const AUTHOR_DISPLAY_NAME_MAXIMUM_LENGTH = 256;
22
22
  export const AUTHOR_EMAIL_MAXIMUM_LENGTH = 320;
23
+ export const AUTHOR_LINK_URL_MAXIMUM_LENGTH = 2048;
23
24
 
24
25
  const HANDLE = /^[a-z0-9]+(-[a-z0-9]+)*$/u;
25
26
  // Deliberately loose: the site canonicalizes and decides. This only tells an
@@ -92,6 +93,11 @@ export function normalizeAuthorListing(value) {
92
93
  handle,
93
94
  displayName: boundedText(raw.displayName, AUTHOR_DISPLAY_NAME_MAXIMUM_LENGTH) ?? "",
94
95
  hasEmail: raw.hasEmail === true || (typeof raw.email === "string" && raw.email !== ""),
96
+ ...(isCanonicalUuid(raw.linkPageResourceId) ? { linkPageResourceId: raw.linkPageResourceId } : {}),
97
+ ...(typeof raw.linkUrl === "string" && raw.linkUrl !== "" && raw.linkUrl.length <= AUTHOR_LINK_URL_MAXIMUM_LENGTH
98
+ ? { linkUrl: raw.linkUrl }
99
+ : {}),
100
+ ...(isCanonicalUuid(raw.imageId) ? { imageId: raw.imageId } : {}),
95
101
  });
96
102
  }
97
103
  const members = [];
@@ -109,12 +115,20 @@ export function normalizeAuthorListing(value) {
109
115
  /**
110
116
  * The workspace file `pull` and `authors list` write. Site authors carry no
111
117
  * address: it is private to the site and nothing local needs it. Members carry
112
- * theirs, because that is how a page names them.
118
+ * theirs, because that is how a page names them. A byline link and image are
119
+ * recorded only for an author who has one (TR01401); the file stays a
120
+ * read-only projection of the site.
113
121
  */
114
122
  export function projectAuthorsForWorkspace(siteId, listing) {
115
123
  return {
116
124
  siteId,
117
- authors: listing.authors.map(({ handle, displayName }) => ({ handle, displayName })),
125
+ authors: listing.authors.map(({ handle, displayName, linkPageResourceId, linkUrl, imageId }) => ({
126
+ handle,
127
+ displayName,
128
+ ...(linkPageResourceId === undefined ? {} : { linkPageResourceId }),
129
+ ...(linkUrl === undefined ? {} : { linkUrl }),
130
+ ...(imageId === undefined ? {} : { imageId }),
131
+ })),
118
132
  members: listing.members.map(({ email, displayName }) => ({ email, displayName })),
119
133
  };
120
134
  }
@@ -168,3 +182,57 @@ export function authorConflictMessage({ shown, file, held, wanted, markdown }) {
168
182
  : `${lead}: run 'taproot-site pages meta set ${shown} --author ${held}' to match the site. To credit someone `
169
183
  + "else, change it in the app.";
170
184
  }
185
+
186
+ /**
187
+ * Refuses options that contradict each other, or `authors set` with nothing to
188
+ * set, before any request (TR01401). They are usage errors, so exit code 2.
189
+ */
190
+ export function requireConsistentAuthorOptions(options, { set }) {
191
+ const usage = (code, message) => new SiteAuthoringError(code, message, { exitCode: 2 });
192
+ const hasLink = options.authorLinkPage !== undefined || options.authorLinkUrl !== undefined;
193
+ if (options.authorLinkPage !== undefined && options.authorLinkUrl !== undefined) {
194
+ throw usage("authors.link_conflict", "--link-page and --link-url cannot be used together: a byline links to one place.");
195
+ }
196
+ if (options.authorNoLink === true && hasLink) {
197
+ throw usage("authors.link_conflict", "--no-link cannot be used with --link-page or --link-url.");
198
+ }
199
+ if (options.authorNoImage === true && options.authorImage !== undefined) {
200
+ throw usage("authors.image_conflict", "--no-image cannot be used with --image.");
201
+ }
202
+ if (options.authorNoEmail === true && options.authorEmail !== undefined) {
203
+ throw usage("authors.email_conflict", "--no-email cannot be used with --email.");
204
+ }
205
+ if (set && ![
206
+ options.authorName,
207
+ options.authorEmail,
208
+ options.authorLinkPage,
209
+ options.authorLinkUrl,
210
+ options.authorImage,
211
+ options.authorNoLink,
212
+ options.authorNoImage,
213
+ options.authorNoEmail,
214
+ ].some((value) => value !== undefined && value !== false)) {
215
+ throw usage(
216
+ "authors.set_empty",
217
+ "authors set needs something to change: --name, --email, --no-email, --link-page, --link-url, --no-link, "
218
+ + "--image or --no-image.",
219
+ );
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Whether a held author already has what an `authors add` repeat asked for. The
225
+ * name is always compared; a link or image only when its flag was passed, so a
226
+ * script that re-runs after someone added a link still succeeds. Returns the
227
+ * names of the values that differ.
228
+ */
229
+ export function differingAuthorValues(held, wanted) {
230
+ const differs = [];
231
+ if (held.displayName !== wanted.displayName) differs.push("name");
232
+ if (wanted.linkPageResourceId !== undefined && held.linkPageResourceId !== wanted.linkPageResourceId) {
233
+ differs.push("link");
234
+ }
235
+ if (wanted.linkUrl !== undefined && held.linkUrl !== wanted.linkUrl) differs.push("link");
236
+ if (wanted.imageId !== undefined && held.imageId !== wanted.imageId) differs.push("image");
237
+ return [...new Set(differs)];
238
+ }
@@ -1,5 +1,22 @@
1
1
  {
2
2
  "entries": [
3
+ {
4
+ "version": "0.56.0",
5
+ "note": "Give a site author a byline link and an image, and change an author with authors set.",
6
+ "behavior": [
7
+ "authors add takes --link-page (a page path from the manifest, or a resourceId), --link-url and --image (a media path or an image id). A byline links to one place, so --link-page and --link-url together are refused (authors.link_conflict).",
8
+ "authors set <handle> changes the name, email, link or image and sends only what was passed. --no-link, --no-image and --no-email clear. It needs the deployments capability too, because changing the byline of an author on published pages queues a deployment.",
9
+ "Repeating authors add for an existing handle succeeds when the name matches and any link or image option passed matches; options not passed are not compared. A difference is authors.handle_taken and points at authors set.",
10
+ "New refusal codes: authors.link_url_invalid, authors.link_page_unknown, authors.image_unknown, authors.deployment_refused, authors.handle_unknown, authors.image_conflict, authors.email_conflict and authors.set_empty.",
11
+ "authors.json records linkPageResourceId, linkUrl and imageId for each author that has one.",
12
+ "Typed pages (article, album, recipe, place review) take displayAuthor, a site author's handle that replaces the member on the byline and keeps the page off the member's profile. A quoted empty value (displayAuthor: \"\") clears it, a bare displayAuthor: line is refused (pages.display_author_invalid), and an absent key leaves the site's alone.",
13
+ "Pull refreshes an unedited .pm.json document with the site's display author, and a push that would overwrite one that changed on the site is refused with pages.push_conflict until a pull has shown it.",
14
+ "New codes: pages.display_author_invalid, pages.display_author_unknown and the warning pages.display_author_unverified. A place review with a display author raises no missing-reviewer warning, and a page credited only through displayAuthor is not in pages.authorless.",
15
+ "Typed pages take showOnProfile: false to keep a page off its author's Taproot profile (it keeps its byline and profile link), and true to put it back. Only the words true and false are accepted in front matter and a JSON boolean in .pm.json; anything else is pages.show_on_profile_invalid. The profile changes after the page is published and its release goes live. An absent key leaves the site's setting alone, and pull and push treat it like displayDate.",
16
+ "The help reference version is 80."
17
+ ],
18
+ "help": ["page"]
19
+ },
3
20
  {
4
21
  "version": "0.55.0",
5
22
  "note": "Style linked tag badges by state and choose what the recipe card tag bar displays.",
package/src/cli.js CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  VERB_APPROVE,
24
24
  VERB_AUTHORS_ADD,
25
25
  VERB_AUTHORS_LIST,
26
+ VERB_AUTHORS_SET,
26
27
  VERB_DELIVERY_CHECK,
27
28
  VERB_DEPLOY,
28
29
  VERB_STAGING_REVIEW,
@@ -397,10 +398,46 @@ const VERBS = Object.freeze([
397
398
  summary: "Create a site author, someone a page can be credited to who has no Taproot account.",
398
399
  note: "Give the handle (lowercase letters, digits and single hyphens, at most 64 characters; it never changes) "
399
400
  + "and --name, the name readers see on the byline. --email is optional: it is kept private, never published, "
400
- + "and lets the person be linked to a Taproot account later. Then credit pages to the author with "
401
+ + "and lets the person be linked to a Taproot account later. --link-page <site path or resourceId> or "
402
+ + "--link-url <address> gives the byline a link, one or the other (authors.link_conflict): a page is named by "
403
+ + "the path .taproot-site-manifest.json records for it ('/' for the home page) and a web address is an "
404
+ + "absolute http or https address. --image <media path or image id> shows an image from the site's media "
405
+ + "library beside the byline; a path is resolved through .taproot-site-media.json. A page path or media path "
406
+ + "the workspace does not record is refused before any request (authors.link_page_unknown, "
407
+ + "authors.image_unknown); the site refuses an address it cannot link (authors.link_url_invalid) and an id "
408
+ + "that is not this site's page or image (the same codes). Then credit pages to the author with "
401
409
  + "'author: <handle>' in a page's front matter or 'pages meta set <path> --author <handle>'. A handle the site "
402
410
  + "already has under another name is refused (authors.handle_taken); under the same name it succeeds with "
403
- + "existing: true. authors.json is updated with the new author.",
411
+ + "existing: true. A link or image is compared only when its option was passed, so repeating a command after "
412
+ + "someone added a link still succeeds; a passed value that differs is refused with authors.handle_taken and "
413
+ + "points at 'authors set'. authors.json is updated with the new author.",
414
+ },
415
+ {
416
+ name: VERB_AUTHORS_SET,
417
+ surface: SURFACE_STANDARD,
418
+ // A change to the name, link or image of an author on published pages
419
+ // queues a deployment, so a content-only credential would always be
420
+ // refused there. One static declaration per verb: an email-only change
421
+ // asks for both too (TR01401).
422
+ capabilities: [CAPABILITY_CONTENT, CAPABILITY_DEPLOYMENTS],
423
+ tokens: ["authors", "set"],
424
+ positionals: "authorHandle",
425
+ authorOptions: true,
426
+ authorSet: true,
427
+ summary: "Change a site author's name, private email, byline link or image.",
428
+ note: "Names one site author by handle and sends only the options given; everything else keeps its stored value. "
429
+ + "--name changes the name readers see and --email the private address (--no-email removes it). --link-page "
430
+ + "<site path or resourceId> or --link-url <address> sets the byline link, replacing the other kind; --no-link "
431
+ + "removes it. --image <media path or image id> sets the image from the site's media library and --no-image "
432
+ + "removes it. With no option the command is refused (authors.set_empty), as are options that contradict each "
433
+ + "other (authors.link_conflict for --link-page with --link-url or --no-link with either, "
434
+ + "authors.image_conflict for --image with --no-image, authors.email_conflict for --email with --no-email), "
435
+ + "before any request. A page or media path the workspace does not record is authors.link_page_unknown or "
436
+ + "authors.image_unknown, and the site refuses an unusable address (authors.link_url_invalid) or id the same "
437
+ + "way. A handle the site does not have is authors.handle_unknown. Changing the name, link or image of an "
438
+ + "author who appears on published pages queues one production deployment, so the credential needs the "
439
+ + "deployments capability and the account must be allowed to deploy; otherwise the change is refused with "
440
+ + "authors.deployment_refused, or while a deployment is running. authors.json is refreshed.",
404
441
  },
405
442
  {
406
443
  name: VERB_PAGES_PUSH,
@@ -434,7 +471,8 @@ const VERBS = Object.freeze([
434
471
  + "exits 0. Once images are set, nextStep is approve while any selected page holds a draft and deploy --staging "
435
472
  + "otherwise. "
436
473
  + "A page is created without an author unless its source names one ('author:' in the front matter, or 'pages "
437
- + "meta set --author'); the pages created that way are listed in pages.authorless with how to credit them. "
474
+ + "meta set --author'); the pages created that way are listed in pages.authorless with how to credit them, except one whose "
475
+ + "typed source names a displayAuthor (a site author's handle the byline shows instead of the member). "
438
476
  + "The homepage is recorded with an empty path, so address it as '/'. "
439
477
  + "A selected path resolves to its one authoritative source from metadata alone, and that page is then validated "
440
478
  + "exactly as a whole push would validate it — site binding, manifest integrity, live create-or-update "
@@ -1112,8 +1150,10 @@ function verbHelp(verb) {
1112
1150
  ? " <page-path>"
1113
1151
  : verb.positionals === "metaPagePath"
1114
1152
  ? " <page-path> [--title <text>] [--description <text>] [--author <handle-or-email>]"
1153
+ : verb.positionals === "authorHandle" && verb.authorSet
1154
+ ? " <handle> [--name <display-name>] [--email <address> | --no-email] [--link-page <path> | --link-url <address> | --no-link] [--image <path> | --no-image]"
1115
1155
  : verb.positionals === "authorHandle"
1116
- ? " <handle> --name <display-name> [--email <address>]"
1156
+ ? " <handle> --name <display-name> [--email <address>] [--link-page <path> | --link-url <address>] [--image <path>]"
1117
1157
  : verb.positionals === "imageId"
1118
1158
  ? " <image-id>"
1119
1159
  : verb.positionals
@@ -1160,8 +1200,16 @@ function verbHelp(verb) {
1160
1200
  --if-missing Save only while the stored default is still null; cannot clear.`
1161
1201
  : "";
1162
1202
  const authorOptions = verb.authorOptions
1163
- ? `\n --name <text> The name readers see on the byline (required).
1164
- --email <address> A private address, kept to link the person to an account later (optional).`
1203
+ ? `\n --name <text> The name readers see on the byline${verb.authorSet ? "" : " (required)"}.
1204
+ --email <address> A private address, kept to link the person to an account later (optional).
1205
+ --link-page <ref> Link the byline to a page: its path from the manifest ('/' for home) or its resourceId.
1206
+ --link-url <address> Link the byline to a web address (absolute http or https). Not with --link-page.
1207
+ --image <ref> Show an image from the media library: its media path or image id.${verb.authorSet
1208
+ ? `
1209
+ --no-email Remove the private address.
1210
+ --no-link Remove the byline link.
1211
+ --no-image Remove the image.`
1212
+ : ""}`
1165
1213
  : "";
1166
1214
  const jsonOption = verb.json && !verb.resolveOptions
1167
1215
  ? "\n --json Emit the stable JSON contract (operational output is always JSON)."
@@ -1296,6 +1344,24 @@ function matchVerb(arguments_) {
1296
1344
  return matched;
1297
1345
  }
1298
1346
 
1347
+ /** The `authors add` and `authors set` options and the invocation field each fills (TR01401). */
1348
+ const AUTHOR_VALUE_OPTIONS = Object.freeze({
1349
+ "--name": "authorName",
1350
+ "--email": "authorEmail",
1351
+ "--link-page": "authorLinkPage",
1352
+ "--link-url": "authorLinkUrl",
1353
+ "--image": "authorImage",
1354
+ });
1355
+ const AUTHOR_CLEAR_OPTIONS = Object.freeze({
1356
+ "--no-email": "authorNoEmail",
1357
+ "--no-link": "authorNoLink",
1358
+ "--no-image": "authorNoImage",
1359
+ });
1360
+ const AUTHOR_INVOCATION_FIELDS = Object.freeze([
1361
+ ...Object.values(AUTHOR_VALUE_OPTIONS),
1362
+ ...Object.values(AUTHOR_CLEAR_OPTIONS),
1363
+ ]);
1364
+
1299
1365
  /** The `link build` options and the invocation field each fills. */
1300
1366
  const LINK_OPTION_FIELDS = Object.freeze({
1301
1367
  "--path": "linkPath",
@@ -1589,7 +1655,7 @@ function parseMetaOption(arguments_, index, option) {
1589
1655
  return candidate;
1590
1656
  }
1591
1657
 
1592
- /** The text after --author, --name (authors add) or --email: one printable value, bounded. */
1658
+ /** The text after --author or an `authors add` / `authors set` option: one printable value, bounded. */
1593
1659
  function parseAuthorOption(arguments_, index, option, { allowEmpty = false } = {}) {
1594
1660
  const candidate = arguments_[index + 1];
1595
1661
  if (
@@ -1729,8 +1795,7 @@ function parseArguments(arguments_) {
1729
1795
  let metaTitle;
1730
1796
  let metaDescription;
1731
1797
  let metaAuthor;
1732
- let authorName;
1733
- let authorEmail;
1798
+ const authorValues = {};
1734
1799
  const positionals = [];
1735
1800
  for (let index = 0; index < rest.length; index += 1) {
1736
1801
  const argument = rest[index];
@@ -1902,18 +1967,24 @@ function parseArguments(arguments_) {
1902
1967
  index += 1;
1903
1968
  continue;
1904
1969
  }
1905
- if (verb.authorOptions && (argument === "--name" || argument === "--email")) {
1970
+ if (verb.authorOptions && Object.hasOwn(AUTHOR_VALUE_OPTIONS, argument)) {
1906
1971
  const value = parseAuthorOption(rest, index, argument);
1907
- if (argument === "--name") {
1908
- if (authorName !== undefined) throw usageError("cli.duplicate_option", "--name may be supplied only once.");
1909
- authorName = value;
1910
- } else {
1911
- if (authorEmail !== undefined) throw usageError("cli.duplicate_option", "--email may be supplied only once.");
1912
- authorEmail = value;
1972
+ const field = AUTHOR_VALUE_OPTIONS[argument];
1973
+ if (authorValues[field] !== undefined) {
1974
+ throw usageError("cli.duplicate_option", `${argument} may be supplied only once.`);
1913
1975
  }
1976
+ authorValues[field] = value;
1914
1977
  index += 1;
1915
1978
  continue;
1916
1979
  }
1980
+ if (verb.authorSet && Object.hasOwn(AUTHOR_CLEAR_OPTIONS, argument)) {
1981
+ const field = AUTHOR_CLEAR_OPTIONS[argument];
1982
+ if (authorValues[field] !== undefined) {
1983
+ throw usageError("cli.duplicate_option", `${argument} may be supplied only once.`);
1984
+ }
1985
+ authorValues[field] = true;
1986
+ continue;
1987
+ }
1917
1988
  if (verb.keyName && argument === "--name") {
1918
1989
  if (keyName !== undefined) throw usageError("cli.duplicate_option", "--name may be supplied only once.");
1919
1990
  keyName = parseNameOption(rest, index);
@@ -2049,11 +2120,11 @@ function parseArguments(arguments_) {
2049
2120
  if (verb.imageListOptions) imageListOptions(imageValues);
2050
2121
  if (verb.imageDescriptionOptions) imageDescriptionOptions(imageValues);
2051
2122
  if (verb.positionals === "authorHandle" && positionals.length !== 1) {
2052
- throw usageError("authors.handle_missing", "authors add needs exactly one handle, such as jane-doe.", {
2123
+ throw usageError("authors.handle_missing", `${verb.name} needs exactly one handle, such as jane-doe.`, {
2053
2124
  field: "handle",
2054
2125
  });
2055
2126
  }
2056
- if (verb.authorOptions && authorName === undefined) {
2127
+ if (verb.authorOptions && !verb.authorSet && authorValues.authorName === undefined) {
2057
2128
  throw usageError("authors.name_missing", "authors add needs --name, the name readers see on the byline.", {
2058
2129
  field: "name",
2059
2130
  });
@@ -2123,8 +2194,7 @@ function parseArguments(arguments_) {
2123
2194
  ...(metaTitle === undefined ? {} : { metaTitle }),
2124
2195
  ...(metaDescription === undefined ? {} : { metaDescription }),
2125
2196
  ...(metaAuthor === undefined ? {} : { metaAuthor }),
2126
- ...(authorName === undefined ? {} : { authorName }),
2127
- ...(authorEmail === undefined ? {} : { authorEmail }),
2197
+ ...authorValues,
2128
2198
  positionals: verb.positionals
2129
2199
  ? {
2130
2200
  key: verb.positionals,
@@ -2230,8 +2300,7 @@ export async function runCli({
2230
2300
  ...(parsed.metaTitle === undefined ? {} : { metaTitle: parsed.metaTitle }),
2231
2301
  ...(parsed.metaDescription === undefined ? {} : { metaDescription: parsed.metaDescription }),
2232
2302
  ...(parsed.metaAuthor === undefined ? {} : { metaAuthor: parsed.metaAuthor }),
2233
- ...(parsed.authorName === undefined ? {} : { authorName: parsed.authorName }),
2234
- ...(parsed.authorEmail === undefined ? {} : { authorEmail: parsed.authorEmail }),
2303
+ ...Object.fromEntries(AUTHOR_INVOCATION_FIELDS.filter((field) => parsed[field] !== undefined).map((field) => [field, parsed[field]])),
2235
2304
  ...Object.fromEntries(["pageSize", "pageToken", "missingDescription", "imageDescription", "clearDescription", "expectedRevision", "onlyIfMissing"]
2236
2305
  .filter((field) => parsed[field] !== undefined).map((field) => [field, parsed[field]])),
2237
2306
  capabilities: parsed.capabilities,
package/src/constants.js CHANGED
@@ -87,6 +87,7 @@ export const VERB_PAGES_META_SET = "pages meta set";
87
87
  export const VERB_PAGES_DELETE = "pages delete";
88
88
  export const VERB_AUTHORS_LIST = "authors list";
89
89
  export const VERB_AUTHORS_ADD = "authors add";
90
+ export const VERB_AUTHORS_SET = "authors set";
90
91
  export const VERB_NAV_PUSH = "nav push";
91
92
  export const VERB_REDIRECTS_CHECK = "redirects check";
92
93
  export const VERB_REDIRECTS_PULL = "redirects pull";