@taprootio/site-authoring 0.41.1 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +50 -0
  2. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
  3. package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
  4. package/package.json +4 -3
  5. package/src/api.js +170 -11
  6. package/src/appearance-contract.js +278 -8
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/block-flow.js +103 -1
  9. package/src/brand-color.js +39 -4
  10. package/src/breadcrumb-artwork.js +234 -0
  11. package/src/breadcrumb-separators.js +11 -0
  12. package/src/changelog.json +154 -0
  13. package/src/chrome-features.js +152 -0
  14. package/src/chrome-input.js +147 -0
  15. package/src/chrome-output.js +92 -0
  16. package/src/chrome-paint-catalog-taproot.json +52 -0
  17. package/src/chrome-report.js +173 -0
  18. package/src/cli.js +48 -17
  19. package/src/content/components.js +27 -4
  20. package/src/content/external-link.js +2 -1
  21. package/src/content/markdown.js +271 -101
  22. package/src/content/tiptap-prosemirror.ts +125 -43
  23. package/src/content/validate-document.js +4 -1
  24. package/src/content-inset.js +48 -0
  25. package/src/errors.js +1 -0
  26. package/src/espalier-shared.js +26 -0
  27. package/src/field-suggestions.js +40 -0
  28. package/src/fixture-init.js +22 -5
  29. package/src/font-catalog.js +11 -1
  30. package/src/footer-brand-inputs.js +25 -2
  31. package/src/footer-content.js +38 -0
  32. package/src/footer-contract.js +11 -0
  33. package/src/footer-cta-styles.js +6 -0
  34. package/src/footer-draft-hash.js +4 -2
  35. package/src/footer-fit.js +62 -15
  36. package/src/footer-workspace.js +60 -16
  37. package/src/header-presentation.js +16 -0
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-structure-checks.js +5 -0
  40. package/src/page-tag-badge-modes.js +6 -0
  41. package/src/page-tag-writes.js +158 -0
  42. package/src/page-type-tags.js +16 -0
  43. package/src/presentation-reference.js +312 -86
  44. package/src/recipe-page-options.js +22 -0
  45. package/src/recipe-step-contract.js +164 -0
  46. package/src/recipe-step-contract.json +65 -0
  47. package/src/reference-help.js +164 -78
  48. package/src/session.js +39 -24
  49. package/src/setting-reference.js +239 -48
  50. package/src/settings-catalog.js +63 -0
  51. package/src/site-check-findings.js +25 -5
  52. package/src/site-check-rules.json +3 -1
  53. package/src/site-health-findings.js +13 -13
  54. package/src/site-navigation-groups.js +70 -0
  55. package/src/styling-fixed-values.js +71 -0
  56. package/src/tag-destination-warnings.js +35 -0
  57. package/src/template-token-reach.json +242 -0
  58. package/src/theme-proposals.js +18 -27
  59. package/src/theme-resolve.js +305 -51
  60. package/src/theme-validation.js +126 -6
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +72 -15
  63. package/src/typed-pages.js +171 -71
  64. package/src/verbs/deploy.js +6 -0
  65. package/src/verbs/footer-push.js +30 -5
  66. package/src/verbs/forms-push.js +11 -3
  67. package/src/verbs/pages-delete.js +19 -10
  68. package/src/verbs/pages-push.js +125 -36
  69. package/src/verbs/plan.js +10 -4
  70. package/src/verbs/pull.js +277 -67
  71. package/src/verbs/staging-review.js +27 -1
  72. package/src/verbs/status.js +22 -0
  73. package/src/verbs/theme-push.js +249 -120
  74. package/src/verbs/theme-resolve.js +310 -47
  75. package/src/verbs/validate.js +71 -17
  76. package/src/workspace-check.js +37 -4
  77. package/src/workspace.js +37 -1
  78. package/test/fixtures/default-site-theme.json +516 -0
@@ -36,11 +36,13 @@ import { normalizeColumnsBody, validateColumnsBody } from "../content/free-form-
36
36
  import { autolinkWarnings } from "../content/link-warnings.js";
37
37
  import { placedFormKeys, readFormIndex, withFormIds } from "../form-references.js";
38
38
  import { workspaceFormKeys } from "../forms-workspace.js";
39
+ import { latestPostsTagProblems } from "../latest-posts-tags.js";
39
40
  import { ApiError } from "../transport.js";
40
41
  import { waitForProcessing } from "./media-upload.js";
41
42
  import { outcomeUnknown, SiteAuthoringError } from "../errors.js";
42
43
  import { DESCRIPTION_MAXIMUM_LENGTH, DESCRIPTION_WARN_LENGTH, descriptionWarnings } from "../page-metadata.js";
43
44
  import { stableJson } from "../footer-draft-hash.js";
45
+ import { outgoingTagIntent, preflightPageTagWrites, tagBaselineAfterWrite, translatePageTagRefusal } from "../page-tag-writes.js";
44
46
  import { CHECK_AREA, collectProblems, planStale, problemsOf, refuseProblems } from "../problems.js";
45
47
  import { RUNTIME_MIRROR_PATH_REASON, isRuntimeMirrorPath } from "../reserved-paths.js";
46
48
  import { boundedByBytes, openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
@@ -53,8 +55,10 @@ import {
53
55
  generatedMarkdownFault,
54
56
  legalMarkdownFault,
55
57
  legalIdentity,
58
+ supportsAuthoredTags,
56
59
  workspaceDocumentFromPage,
57
60
  TEMPLATE_LEGAL,
61
+ TEMPLATE_PLACE_REVIEW,
58
62
  generatedPageDescription,
59
63
  generatedPageTitle,
60
64
  placedVideoIds,
@@ -69,6 +73,8 @@ import {
69
73
  templateFrontMatterFault,
70
74
  typedDocumentFromJson,
71
75
  typedDocumentFromMarkdown,
76
+ requireRecipeStepDocuments,
77
+ TEMPLATE_RECIPE,
72
78
  unusedCoverImageId,
73
79
  unsupportedRestrictedNode,
74
80
  wirePageFields,
@@ -85,6 +91,7 @@ import {
85
91
  deleteWorkspaceFile,
86
92
  internalPageObservedRevisionFile,
87
93
  MEDIA_MANIFEST_FILE_NAME,
94
+ normalizeAuthoredTagBaseline,
88
95
  normalizePageBodyRevision,
89
96
  normalizePagePath,
90
97
  PAGE_SOURCE_EXTENSIONS,
@@ -108,6 +115,7 @@ import {
108
115
  canonicalDocumentHash,
109
116
  workspaceContentHash,
110
117
  workspaceFileExists,
118
+ workspacePageSourceBodyHash,
111
119
  writeManifest,
112
120
  writeWorkspaceJson,
113
121
  } from "../workspace.js";
@@ -215,7 +223,7 @@ function unquote(value) {
215
223
  * dropping an unrecognized key is how authored metadata disappears without a
216
224
  * trace, and the server would never notice.
217
225
  */
218
- function parseFrontMatter(source, file) {
226
+ export function parseFrontMatter(source, file) {
219
227
  const lines = source.split(/\r?\n/u);
220
228
  if (lines[0]?.trim() !== FRONT_MATTER_FENCE) {
221
229
  throw documentError(
@@ -237,11 +245,12 @@ function parseFrontMatter(source, file) {
237
245
  // as though it were the only one. The caller raises the fault for any page
238
246
  // it actually intends to send.
239
247
  const values = new Map();
248
+ let tagsLine;
240
249
  let fault;
241
250
  const record = (candidate) => {
242
251
  fault ??= candidate;
243
252
  };
244
- for (const line of lines.slice(1, closing)) {
253
+ for (const [index, line] of lines.slice(1, closing).entries()) {
245
254
  if (line.trim() === "" || line.trimStart().startsWith("#")) continue;
246
255
  const match = FRONT_MATTER_ENTRY.exec(line);
247
256
  if (!match) {
@@ -264,6 +273,7 @@ function parseFrontMatter(source, file) {
264
273
  }
265
274
  const seen = values.get(key);
266
275
  if (seen === undefined) {
276
+ if (key === "tags") tagsLine = index + 1;
267
277
  values.set(key, [unquote(rawValue)]);
268
278
  continue;
269
279
  }
@@ -306,6 +316,8 @@ function parseFrontMatter(source, file) {
306
316
  candidates,
307
317
  fault,
308
318
  template,
319
+ tagsLine,
320
+ markdownFirstLine: closing + 2,
309
321
  markdown: lines.slice(closing + 1).join("\n"),
310
322
  };
311
323
  }
@@ -431,8 +443,8 @@ function requireContentFunctions(content) {
431
443
  return content;
432
444
  }
433
445
 
434
- function assertValid(content, document_, file, { mayBeEmpty = false } = {}) {
435
- const outcome = content.validateDocument(document_);
446
+ function assertValid(content, document_, file, { mayBeEmpty = false, recipeStep = false } = {}) {
447
+ const outcome = content.validateDocument(document_, { checkLinkValues: !recipeStep });
436
448
  const reported = outcome === null || typeof outcome !== "object" ? undefined : outcome.errors;
437
449
  if (!Array.isArray(reported)) {
438
450
  throw new SiteAuthoringError(
@@ -517,6 +529,8 @@ export async function readWorkspacePageSource({ workspaceDir, file, manifestEntr
517
529
  const source = bytes.toString("utf8");
518
530
 
519
531
  let markdown;
532
+ let markdownFirstLine;
533
+ let markdownBodyHash;
520
534
  let fault;
521
535
  let pathCandidates = [];
522
536
  let title;
@@ -536,6 +550,12 @@ export async function readWorkspacePageSource({ workspaceDir, file, manifestEntr
536
550
  declaredAuthor = frontMatter.fields.get("author") || manifestEntry?.author;
537
551
  declaredPath = frontMatter.fields.has("path") ? frontMatter.fields.get("path") : manifestEntry?.path;
538
552
  markdown = frontMatter.markdown;
553
+ markdownFirstLine = frontMatter.markdownFirstLine;
554
+ if (frontMatter.tagsLine !== undefined) {
555
+ const lines = source.split(/(?<=\n)/u);
556
+ lines.splice(frontMatter.tagsLine, 1);
557
+ markdownBodyHash = workspaceContentHash(lines.join(""));
558
+ }
539
559
  fault = frontMatter.fault;
540
560
  pathCandidates = frontMatter.candidates.get("path") ?? [];
541
561
  } else {
@@ -608,7 +628,9 @@ export async function readWorkspacePageSource({ workspaceDir, file, manifestEntr
608
628
  fields,
609
629
  sourceFormat: isMarkdown ? PAGE_SOURCE_FORMAT_MARKDOWN : PAGE_SOURCE_FORMAT_PROSEMIRROR,
610
630
  sourceHash: workspaceContentHash(bytes),
631
+ markdownBodyHash,
611
632
  markdown,
633
+ markdownFirstLine,
612
634
  text: source,
613
635
  };
614
636
  }
@@ -749,7 +771,11 @@ export function requireCompletePageMetadata(source) {
749
771
  * wire carries — converting Markdown through the bounded subset and resolving
750
772
  * its media, or unwrapping an authored document.
751
773
  */
752
- export async function convertWorkspacePageSource({ source, mediaManifest, content: injectedContent }) {
774
+ export async function convertWorkspacePageSource(options) {
775
+ return (await convertedWorkspacePageSource(options)).document;
776
+ }
777
+
778
+ async function convertedWorkspacePageSource({ source, mediaManifest, content: injectedContent }) {
753
779
  const content = requireContentFunctions(await loadContentModule(injectedContent));
754
780
  const { file } = source;
755
781
  if (source.sourceFormat === PAGE_SOURCE_FORMAT_MARKDOWN) {
@@ -761,15 +787,19 @@ export async function convertWorkspacePageSource({ source, mediaManifest, conten
761
787
  file,
762
788
  );
763
789
  };
764
- if (source.template === TEMPLATE_FREE_FORM) return await convert(source.markdown);
765
- return await typedDocumentFromMarkdown({
766
- template: source.template,
767
- fields: source.fields,
768
- markdown: source.markdown,
769
- file,
770
- convert,
771
- resolveImage,
772
- });
790
+ const document = source.template === TEMPLATE_FREE_FORM
791
+ ? await convert(source.markdown)
792
+ : await typedDocumentFromMarkdown({
793
+ template: source.template,
794
+ fields: source.fields,
795
+ markdown: source.markdown,
796
+ file,
797
+ convert,
798
+ convertStep: (markdown, firstLine) => content.markdownToProseMirror(markdown, { resolveImage, recipeStep: true, firstLine }),
799
+ firstLine: source.markdownFirstLine,
800
+ resolveImage,
801
+ });
802
+ return { document };
773
803
  }
774
804
  let parsed;
775
805
  try {
@@ -777,8 +807,15 @@ export async function convertWorkspacePageSource({ source, mediaManifest, conten
777
807
  } catch {
778
808
  throw documentError("pages.document_shape", `'${file}' is not valid JSON.`, file);
779
809
  }
780
- if (source.template !== TEMPLATE_FREE_FORM) return typedDocumentFromJson(parsed, file);
781
- return normalizeColumnsBody(unwrapProseMirrorDocument(parsed, file)).body;
810
+ if (source.template !== TEMPLATE_FREE_FORM) {
811
+ const document = typedDocumentFromJson(parsed, file);
812
+ const sourceBodyHash = supportsAuthoredTags(source.template) ? workspacePageSourceBodyHash(parsed) : undefined;
813
+ return { document, sourceBodyHash };
814
+ }
815
+ if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, "tags")) {
816
+ throw documentError("pages.tags_unsupported", `'${file}' declares tags, which the free-form template does not accept.`, "tags");
817
+ }
818
+ return { document: normalizeColumnsBody(unwrapProseMirrorDocument(parsed, file)).body };
782
819
  }
783
820
 
784
821
  /**
@@ -820,19 +857,19 @@ export async function validateWorkspacePageDocument({
820
857
  getSharedThemeContexts,
821
858
  }) {
822
859
  const content = requireContentFunctions(await loadContentModule(injectedContent));
823
- // A typed page carries several ProseMirror documents (an introduction, each
824
- // recipe step); every one goes through the same vocabulary and context checks
825
- // a free-form body does.
860
+ if (documentTemplate(document_) === TEMPLATE_RECIPE) {
861
+ requireRecipeStepDocuments(document_.data.instructionSections ?? [], file);
862
+ }
826
863
  const unusedCover = unusedCoverImageId(document_);
827
864
  if (unusedCover !== undefined) {
828
865
  throw documentError(
829
866
  "pages.cover_image_unused",
830
867
  `${COVER_IMAGE_UNUSED_MESSAGE} '${file}' selects cover image ${unusedCover}, but no image in the page's own `
831
- + "content uses it: place that image in the body (or introduction, steps, or album images), or remove coverImage.",
868
+ + "content uses it: place that image in the body, introduction or album images, or remove coverImage.",
832
869
  `${file}:coverImageId`,
833
870
  );
834
871
  }
835
- for (const { doc, path, mayBeEmpty, restricted } of contentDocuments(document_)) {
872
+ for (const { doc, path, mayBeEmpty, restricted, recipeStep } of contentDocuments(document_)) {
836
873
  const location = path === "" ? file : `${file}:${path}`;
837
874
  const columns = validateColumnsBody(doc, { allowColumns: documentTemplate(document_) === TEMPLATE_FREE_FORM });
838
875
  if (columns.errors.length > 0) {
@@ -840,12 +877,12 @@ export async function validateWorkspacePageDocument({
840
877
  throw documentError("pages.document_invalid", `'${location}' has an invalid columns layout. Columns are available only inside sections of a free-form page.`, `${location}:${first.path}`)
841
878
  .withProblems(columns.errors.map(error => ({ code: error.code, field: `${location}:${error.path}`, message: "Use a valid columns layout in a free-form section." })));
842
879
  }
843
- assertValid(content, doc, location, { mayBeEmpty });
880
+ assertValid(content, doc, location, { mayBeEmpty, recipeStep });
844
881
  const unsupported = restricted ? unsupportedRestrictedNode(doc) : undefined;
845
882
  if (unsupported !== undefined) {
846
883
  throw documentError(
847
884
  "pages.node_unsupported_for_template",
848
- `'${location}' uses the '${unsupported}' node, which a ${documentTemplate(document_)} introduction or step `
885
+ `'${location}' uses the '${unsupported}' node, which a ${documentTemplate(document_)} introduction `
849
886
  + "does not accept. Put that content in a free-form page or an article, or remove it.",
850
887
  location,
851
888
  );
@@ -1354,7 +1391,7 @@ export async function planPages({
1354
1391
  );
1355
1392
  return;
1356
1393
  }
1357
- const document_ = await convertWorkspacePageSource({ source, mediaManifest, content });
1394
+ const { document: document_, sourceBodyHash } = await convertedWorkspacePageSource({ source, mediaManifest, content });
1358
1395
  if (documentTemplate(document_) === TEMPLATE_LEGAL && target === undefined && manifestEntry?.pageId !== undefined) {
1359
1396
  throw documentError("pages.legal_missing", `'${file}' tracks a legal page that the site no longer lists. Pull and reconcile it before creating another page.`, file);
1360
1397
  }
@@ -1364,6 +1401,9 @@ export async function planPages({
1364
1401
  // fields the workspace never restated; without it the whole-object
1365
1402
  // UpdatePage sends "" and false and silently clears both.
1366
1403
  const targetEntry = target === undefined ? undefined : manifestByPageId.get(target.pageId);
1404
+ const baseline = targetEntry?.baseline;
1405
+ const tagBaseline = normalizeAuthoredTagBaseline(baseline);
1406
+ const tagIntent = outgoingTagIntent(document_.tags, tagBaseline?.authoredTagSlugs);
1367
1407
  const description = generated
1368
1408
  // The manifest's title and description are what the site reported; the owner's are in the document.
1369
1409
  ? generatedPageDescription(document_.data, declaredDescription ?? targetEntry?.description ?? "")
@@ -1374,29 +1414,45 @@ export async function planPages({
1374
1414
  // already covers; only a .pm.json page keeps one in the manifest, where
1375
1415
  // the key has to see it. Absent, the key is the one it always was.
1376
1416
  const markdownSource = source.sourceFormat === PAGE_SOURCE_FORMAT_MARKDOWN;
1377
- const contentKeyFor = (author) => pageContentKey(
1378
- source.sourceHash,
1417
+ const markdownDocumentHash = !markdownSource
1418
+ ? ""
1419
+ : document_.tags === undefined
1420
+ ? canonicalDocumentHash(document_)
1421
+ : workspacePageSourceBodyHash(document_);
1422
+ const contentKeyFor = (author, inputHash = source.markdownBodyHash ?? source.sourceHash) => pageContentKey(
1423
+ inputHash,
1379
1424
  {
1380
1425
  title: sentTitle,
1381
1426
  path: pagePath,
1382
1427
  description: sentDescription,
1383
1428
  author: markdownSource ? "" : author,
1384
1429
  },
1385
- markdownSource ? canonicalDocumentHash(document_) : "",
1430
+ markdownDocumentHash,
1386
1431
  );
1387
1432
  // A generated page has no author, so its key is final here. Every other
1388
1433
  // page's key waits for the author resolved below.
1389
1434
  let contentKey = contentKeyFor("");
1435
+ const bodyMatches = (author) => {
1436
+ if (baseline?.contentKey === contentKey) return true;
1437
+ if (
1438
+ sourceBodyHash === undefined || sourceBodyHash !== baseline?.sourceBodyHash
1439
+ || (document_.tags === undefined && !Array.isArray(tagBaseline?.authoredTagSlugs))
1440
+ ) return false;
1441
+ // Tag-bearing JSON can keep its body and metadata through edits to the tag labels.
1442
+ return baseline.contentKey === contentKeyFor(author, sourceBodyHash)
1443
+ || (baseline.sourceHash !== undefined && baseline.contentKey === contentKeyFor(author, baseline.sourceHash));
1444
+ };
1390
1445
  // The source and everything sent with it match what the site last agreed
1391
1446
  // to, so sending again would only turn an approved page back into a draft.
1392
1447
  // Not when the operator was shown a conflict for this page (the record
1393
1448
  // exists to let this push reassert the source), and not when the source
1394
1449
  // moved or changed format, which the send re-registers in the manifest.
1395
- const isUnchanged = (record) => target !== undefined
1396
- && targetEntry?.baseline?.contentKey === contentKey
1450
+ const isUnchanged = (record, author = "") => target !== undefined
1451
+ && tagIntent === undefined
1397
1452
  && record === undefined
1398
- && targetEntry.file === file
1399
- && targetEntry.sourceFormat === source.sourceFormat;
1453
+ && targetEntry?.file === file
1454
+ && targetEntry.sourceFormat === source.sourceFormat
1455
+ && bodyMatches(author);
1400
1456
  // An untouched generated page is not this push's to judge. Taproot
1401
1457
  // moves its revision and its path on its own (a folder that
1402
1458
  // gained a post), and refusing the whole push for a page nothing here
@@ -1459,7 +1515,7 @@ export async function planPages({
1459
1515
  };
1460
1516
  if (sourceTemplate === TEMPLATE_LEGAL) legalRevisionGuard = guard;
1461
1517
  else {
1462
- requireReconciledRevision(guard);
1518
+ if (tagIntent === undefined) requireReconciledRevision(guard);
1463
1519
  requireReconciledDisplayDate({ ...guard, document_, observed });
1464
1520
  }
1465
1521
  }
@@ -1516,7 +1572,8 @@ export async function planPages({
1516
1572
  contentKey = contentKeyFor(authorship.author);
1517
1573
  // An author the site no longer holds is a change to send, however the
1518
1574
  // source compares with the record.
1519
- const unchanged = isUnchanged(observedRecord) && !(online && target !== undefined && authorship.sendAuthor);
1575
+ const unchanged = isUnchanged(observedRecord, authorship.author)
1576
+ && !(online && target !== undefined && authorship.sendAuthor);
1520
1577
  if (documentTemplate(document_) === TEMPLATE_LEGAL && !unchanged && online) {
1521
1578
  if (legalRevisionGuard !== undefined) requireReconciledRevision(legalRevisionGuard);
1522
1579
  if (!legalDrafts) {
@@ -1547,6 +1604,11 @@ export async function planPages({
1547
1604
  file,
1548
1605
  );
1549
1606
  }
1607
+ const reviewAuthorMissing = documentTemplate(document_) === TEMPLATE_PLACE_REVIEW
1608
+ && authorship.author === ""
1609
+ && (online && target !== undefined
1610
+ ? target.reviewAuthorMissing === true
1611
+ : targetEntry?.pageId === undefined || targetEntry.reviewAuthorMissing === true);
1550
1612
  planned.push({
1551
1613
  file,
1552
1614
  pagePath,
@@ -1559,10 +1621,16 @@ export async function planPages({
1559
1621
  description: sentDescription,
1560
1622
  author: authorship.author,
1561
1623
  sendAuthor: authorship.sendAuthor,
1624
+ reviewAuthorMissing,
1562
1625
  ...(authorship.unverified === true ? { authorUnverified: true } : {}),
1563
1626
  document: document_,
1564
1627
  sourceFormat: source.sourceFormat,
1565
1628
  sourceHash: source.sourceHash,
1629
+ sourceBodyHash,
1630
+ tagIntent,
1631
+ ...(tagIntent === undefined || target === undefined ? {} : {
1632
+ tagUpdate: { target, tagBaseline, bodyRevision: baseline?.revision },
1633
+ }),
1566
1634
  pageId: target?.pageId,
1567
1635
  // The live revision this page would be sent against; `plan` binds it
1568
1636
  // into its hash so a concurrent edit invalidates the plan.
@@ -1595,6 +1663,20 @@ export function staleGeneratedSourcesField(staleGenerated) {
1595
1663
  : { staleGeneratedSources: { total: staleGenerated.length, ...reportedList("items", staleGenerated, LIST_BYTES) } };
1596
1664
  }
1597
1665
 
1666
+ /** The live target and any tag write that apply must still find after earlier steps. */
1667
+ export function plannedPageWriteIdentity(page) {
1668
+ return [
1669
+ page.pageId ?? "",
1670
+ page.revision ?? "",
1671
+ page.action,
1672
+ ...(page.tagIntent === undefined ? [] : [
1673
+ page.tagIntent.names,
1674
+ page.tagFields?.expectedAuthoredTagRevision ?? "",
1675
+ page.tagFields?.expectedBodyRevision ?? "",
1676
+ ]),
1677
+ ];
1678
+ }
1679
+
1598
1680
  /** What a dry run or a plan reports for one planned page. */
1599
1681
  export function plannedPageItem(page) {
1600
1682
  return { file: page.file, path: displayPagePath(page.pagePath), action: page.unchanged ? "unchanged" : page.action };
@@ -1734,6 +1816,8 @@ export async function pagesPush(invocation) {
1734
1816
  onProgress,
1735
1817
  });
1736
1818
  const { planned, targeted, unresolved, staleGenerated } = plan;
1819
+ await preflightPageTagWrites(client, siteId, plan, invocation.pageTagCapabilities);
1820
+ plan.problems.push(...latestPostsTagProblems(planned, manifest, { sendingOnly: true }));
1737
1821
  // A page that places a video names it by id, and only the library knows
1738
1822
  // whether that id is one of this site's videos. Asked once for the whole
1739
1823
  // push, before anything is written, so a page cannot be sent that
@@ -1753,8 +1837,8 @@ export async function pagesPush(invocation) {
1753
1837
  const byFile = new Map(planned.map((page) => [page.file, page]));
1754
1838
  for (const [file, expected] of invocation.plannedPages) {
1755
1839
  const page = byFile.get(file);
1756
- if (page === undefined || stableJson([page.pageId ?? "", page.revision ?? "", page.action]) !== expected) {
1757
- throw planStale(`'${file}'`, file);
1840
+ if (page === undefined || stableJson(plannedPageWriteIdentity(page)) !== expected) {
1841
+ throw planStale(`'${file}'`, file).withProblems(plan.problems);
1758
1842
  }
1759
1843
  }
1760
1844
  const unplanned = planned.find((page) => !page.unchanged && !invocation.plannedPages.has(page.file));
@@ -1821,6 +1905,7 @@ export async function pagesPush(invocation) {
1821
1905
  shortDescription: page.description,
1822
1906
  template: wireTemplate(withFormIds(page.document, placedForms.idByKey)),
1823
1907
  ...wirePageFields(page.document),
1908
+ ...page.tagFields,
1824
1909
  // Only a name the site has not been told: repeating the author a page
1825
1910
  // already has would let a later change of that person's permissions
1826
1911
  // refuse a push that changes nothing about authorship.
@@ -1840,7 +1925,7 @@ export async function pagesPush(invocation) {
1840
1925
  ? await createPage(client, { siteId, ...fields })
1841
1926
  : await updatePage(client, page.pageId, { pageId: page.pageId, ...fields });
1842
1927
  } catch (error) {
1843
- throw translateAuthorRefusal(error, page.file);
1928
+ throw translateAuthorRefusal(translatePageTagRefusal(error, page), page.file);
1844
1929
  }
1845
1930
  attempting = undefined;
1846
1931
  manifestDirty = true;
@@ -1900,7 +1985,9 @@ export async function pagesPush(invocation) {
1900
1985
  // this workspace made itself.
1901
1986
  baseline: {
1902
1987
  sourceHash: page.sourceHash,
1988
+ ...(page.sourceBodyHash === undefined ? {} : { sourceBodyHash: page.sourceBodyHash }),
1903
1989
  contentKey: page.contentKey,
1990
+ ...tagBaselineAfterWrite(record.baseline, page, summary),
1904
1991
  ...(summary.bodyRevision === undefined ? {} : { revision: summary.bodyRevision }),
1905
1992
  // Recorded for the pages whose push sends a date, so the next push
1906
1993
  // can tell a date the site changed from one it already holds.
@@ -1912,6 +1999,8 @@ export async function pagesPush(invocation) {
1912
1999
  // What the source names, kept beside the site's own for a .pm.json
1913
2000
  // page, whose manifest entry is the only place it is written down.
1914
2001
  if (documentTemplate(page.document) === TEMPLATE_LEGAL) record.legal = legalIdentity(page.document.data);
2002
+ if (summary.reviewAuthorMissing === undefined) delete record.reviewAuthorMissing;
2003
+ else record.reviewAuthorMissing = summary.reviewAuthorMissing && page.author === "";
1915
2004
  if (page.author === "") delete record.author;
1916
2005
  else record.author = page.author;
1917
2006
  if (existing === undefined) manifest.pages.push(record);
package/src/verbs/plan.js CHANGED
@@ -30,6 +30,8 @@ import { SiteAuthoringError } from "../errors.js";
30
30
  import { computeFooterContentHash, computeFooterDraftHash, stableJson } from "../footer-draft-hash.js";
31
31
  import { FOOTER_SETTINGS_FILE } from "../footer-workspace.js";
32
32
  import { workspaceFormKeys } from "../forms-workspace.js";
33
+ import { preflightPageTagWrites } from "../page-tag-writes.js";
34
+ import { latestPostsTagProblems } from "../latest-posts-tags.js";
33
35
  import { CHECK_AREA, collectProblems, problemsError, problemsOf, problemsWithinBudget, withinByteBudget } from "../problems.js";
34
36
  import { openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
35
37
  import { IMAGE_IDENTIFIER, usedImageIds } from "../typed-pages.js";
@@ -54,6 +56,7 @@ import {
54
56
  placedVideoProblems,
55
57
  planPages,
56
58
  plannedPageItem,
59
+ plannedPageWriteIdentity,
57
60
  staleGeneratedSourcesField,
58
61
  } from "./pages-push.js";
59
62
  import { comparePresentation, presentationMovedRefusal, presentationPullRequired, themePush } from "./theme-push.js";
@@ -289,7 +292,8 @@ async function preflight(session, invocation) {
289
292
  : sharedThemeContextNames(offline.presentation.style.lightTheme, offline.presentation.style.darkTheme),
290
293
  onProgress,
291
294
  });
292
- problems.push(...pages.problems);
295
+ const pageTagCapabilities = await preflightPageTagWrites(client, siteId, pages);
296
+ problems.push(...pages.problems, ...latestPostsTagProblems(pages.planned, manifest, { sendingOnly: true }));
293
297
  problems.push(...await placedVideoProblems(client, siteId, pages.planned));
294
298
  problems.push(...(await placedFormProblems(client, siteId, pages.planned, () => workspaceFormKeys(workspaceDir))).problems);
295
299
  const sending = pages.planned.filter((page) => !page.unchanged);
@@ -430,7 +434,7 @@ async function preflight(session, invocation) {
430
434
  version: 1,
431
435
  siteId,
432
436
  media: pendingMedia.map((entry) => [entry.file, entry.identity]),
433
- pages: pages.planned.map((page) => [page.file, page.action, page.unchanged, page.contentKey, page.pageId ?? "", page.revision ?? ""]),
437
+ pages: pages.planned.map((page) => [page.file, page.unchanged, page.contentKey, plannedPageWriteIdentity(page)]),
434
438
  footer: [footerChanged, workspaceFooter === undefined ? "" : computeFooterContentHash(workspaceFooter), liveFooterDraftHash ?? ""],
435
439
  theme: theme === undefined ? [] : [theme.changeSetHash, theme.current.revision],
436
440
  navigation: [stableJson(offline.navigation?.navItems ?? null), stableJson(liveNavigation ?? null)],
@@ -443,7 +447,8 @@ async function preflight(session, invocation) {
443
447
  planHash,
444
448
  // The live state each step must still find: page revisions and the navigation tree, which the steps check
445
449
  // themselves (the theme and footer saves are fenced by the server, and the navigation save is as well).
446
- plannedPages: new Map(sending.map((page) => [page.file, stableJson([page.pageId ?? "", page.revision ?? "", page.action])])),
450
+ plannedPages: new Map(sending.map((page) => [page.file, stableJson(plannedPageWriteIdentity(page))])),
451
+ pageTagCapabilities,
447
452
  plannedLiveNavigation: stableJson(liveNavigation ?? null),
448
453
  };
449
454
  });
@@ -522,6 +527,7 @@ const STEP_RUNNERS = Object.freeze({
522
527
  pagePaths: undefined,
523
528
  dryRun: false,
524
529
  plannedPages: planned.plannedPages,
530
+ pageTagCapabilities: planned.pageTagCapabilities,
525
531
  }),
526
532
  [PLAN_STEP.footer]: (invocation) => footerPush({ ...invocation, verb: PLAN_STEP.footer }),
527
533
  [PLAN_STEP.theme]: (invocation) => themePush({ ...invocation, verb: PLAN_STEP.theme, dryRun: false }),
@@ -548,7 +554,7 @@ export async function apply(invocation) {
548
554
  "The workspace or the site changed since that plan was made, so nothing was applied. Run 'taproot-site plan' "
549
555
  + "again, read it, and apply the new planHash.",
550
556
  { field: "planHash", alternatives: [planned.planHash] },
551
- );
557
+ ).withProblems(planned.problems);
552
558
  }
553
559
  if (planned.problems.length > 0) throw problemsError(planned.problems, "apply sent nothing; the plan has problems");
554
560