@taprootio/site-authoring 0.61.0 → 0.64.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 (71) hide show
  1. package/README.md +97 -23
  2. package/package.json +2 -2
  3. package/src/api.js +149 -21
  4. package/src/appearance-contract.js +27 -0
  5. package/src/article-appearance.js +19 -0
  6. package/src/article-appearance.json +9 -0
  7. package/src/article-end-settings.js +295 -0
  8. package/src/changelog.json +49 -0
  9. package/src/chrome-input.js +1 -1
  10. package/src/cli.js +110 -26
  11. package/src/constants.js +7 -0
  12. package/src/content/components.js +130 -14
  13. package/src/content/cta-decoration-paint.js +321 -0
  14. package/src/content/form-placement-presentation.js +91 -0
  15. package/src/content/form-placement-presentation.json +6 -0
  16. package/src/content/free-form-section-registry.json +19 -1
  17. package/src/content/free-form-sections.js +64 -55
  18. package/src/content/markdown.js +13 -0
  19. package/src/content/tiptap-prosemirror.ts +72 -59
  20. package/src/content/validate-document.js +2 -0
  21. package/src/cta-artwork-warnings.js +164 -0
  22. package/src/errors.js +6 -0
  23. package/src/field-schema.json +6 -2
  24. package/src/field-validation.js +14 -5
  25. package/src/footer-workspace.js +7 -3
  26. package/src/form-references.js +71 -9
  27. package/src/forms-contract.js +3 -5
  28. package/src/heading-outline.js +7 -0
  29. package/src/output.js +2 -0
  30. package/src/page-article-end.js +66 -0
  31. package/src/page-block-catalog.js +54 -0
  32. package/src/page-form-presentation.js +104 -0
  33. package/src/page-structure-checks.js +7 -1
  34. package/src/placed-image-ids.js +15 -18
  35. package/src/presentation-reference.js +31 -53
  36. package/src/reference-help.js +97 -27
  37. package/src/reusable-blocks.js +429 -0
  38. package/src/reusable-placements.js +271 -0
  39. package/src/setting-reference.js +57 -1
  40. package/src/settings-catalog.js +3 -0
  41. package/src/site-check-findings.js +30 -2
  42. package/src/site-check-rules.json +1 -0
  43. package/src/site-checks.js +26 -2
  44. package/src/site-health-findings.js +25 -3
  45. package/src/site-health-image-checks.js +1 -1
  46. package/src/staging-check.js +108 -21
  47. package/src/staging-served.js +5 -49
  48. package/src/status-warning-paints.js +17 -0
  49. package/src/template-token-reach.json +20 -2
  50. package/src/theme-resolve.js +27 -0
  51. package/src/transport.js +41 -5
  52. package/src/typed-page-reference.js +55 -5
  53. package/src/typed-pages.js +27 -4
  54. package/src/verbs/approve.js +2 -1
  55. package/src/verbs/deploy.js +93 -15
  56. package/src/verbs/footer-push.js +4 -2
  57. package/src/verbs/forms-push.js +9 -0
  58. package/src/verbs/health.js +11 -6
  59. package/src/verbs/index.js +3 -0
  60. package/src/verbs/pages-blocks-pull.js +22 -0
  61. package/src/verbs/pages-push.js +89 -34
  62. package/src/verbs/plan.js +34 -5
  63. package/src/verbs/pull.js +213 -124
  64. package/src/verbs/status.js +20 -2
  65. package/src/verbs/theme-push.js +170 -20
  66. package/src/verbs/theme-resolve.js +114 -40
  67. package/src/verbs/validate.js +49 -18
  68. package/src/workspace-check.js +42 -5
  69. package/src/workspace-context-usage.js +54 -1
  70. package/src/workspace.js +37 -7
  71. package/test/fixtures/default-site-theme.json +1 -1
@@ -34,7 +34,8 @@ import {
34
34
  import { VERB_PAGES_PUSH } from "../constants.js";
35
35
  import { normalizeColumnsBody, validateColumnsBody } from "../content/free-form-columns.js";
36
36
  import { autolinkWarnings } from "../content/link-warnings.js";
37
- import { placedFormKeys, readFormIndex, withFormIds } from "../form-references.js";
37
+ import { appendReusablePlacementReport, checkLiveReusablePlacements, normalizeReusablePlacements, requireSupportedReusablePlacements } from "../reusable-placements.js";
38
+ import { formPresentationHash, liveFormIndexReader, placedFormKeys, withFormIds } from "../form-references.js";
38
39
  import { workspaceFormKeys } from "../forms-workspace.js";
39
40
  import { latestPostsTagProblems } from "../latest-posts-tags.js";
40
41
  import { ApiError } from "../transport.js";
@@ -42,7 +43,9 @@ import { waitForProcessing } from "./media-upload.js";
42
43
  import { outcomeUnknown, SiteAuthoringError } from "../errors.js";
43
44
  import { DESCRIPTION_MAXIMUM_LENGTH, DESCRIPTION_WARN_LENGTH, descriptionWarnings } from "../page-metadata.js";
44
45
  import { stableJson } from "../footer-draft-hash.js";
46
+ import { articleEndBaselineAfterWrite, articleEndWriteIntent, preflightArticleEndWrites, translateArticleEndRefusal } from "../page-article-end.js";
45
47
  import { outgoingTagIntent, preflightPageTagWrites, tagBaselineAfterWrite, translatePageTagRefusal } from "../page-tag-writes.js";
48
+ import { formPresentationWriteIntent, preflightFormPresentationWrites, translateFormPresentationRefusal } from "../page-form-presentation.js";
46
49
  import { CHECK_AREA, appendAll, attachProblemsFile, collectProblems, planStale, problemsOf, refuseProblems, withFullProblems } from "../problems.js";
47
50
  import { RUNTIME_MIRROR_PATH_REASON, isRuntimeMirrorPath } from "../reserved-paths.js";
48
51
  import { boundedByBytes, openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
@@ -65,6 +68,7 @@ import {
65
68
  posterlessVideoEmbeds,
66
69
  FRONT_MATTER_KEYS,
67
70
  PAGE_TEMPLATES,
71
+ requireArticleEnd,
68
72
  requireTemplateName,
69
73
  RETIRED_GENERATED_PAGE_KINDS,
70
74
  sentDisplayAuthor,
@@ -121,7 +125,7 @@ import {
121
125
  workspacePageSourceBodyHash,
122
126
  writeManifest,
123
127
  writeWorkspaceJson,
124
- mediaReferenceCandidates,
128
+ workspaceImageFromReference,
125
129
  retiredSourcesByFile,
126
130
  } from "../workspace.js";
127
131
 
@@ -288,10 +292,11 @@ export function parseFrontMatter(source, file) {
288
292
  ));
289
293
  continue;
290
294
  }
295
+ const value = key === "articleEnd" ? rawValue.trim() : unquote(rawValue);
291
296
  const seen = values.get(key);
292
297
  if (seen === undefined) {
293
298
  if (key === "tags") tagsLine = index + 1;
294
- values.set(key, [unquote(rawValue)]);
299
+ values.set(key, [value]);
295
300
  continue;
296
301
  }
297
302
  record(documentError(
@@ -299,7 +304,7 @@ export function parseFrontMatter(source, file) {
299
304
  `'${file}' declares front-matter field '${key}' twice.`,
300
305
  key,
301
306
  ));
302
- seen.push(unquote(rawValue));
307
+ seen.push(value);
303
308
  }
304
309
  // A repeated key is always a fault, but it is not always an *ambiguity*:
305
310
  // the same value written twice says exactly one thing. Only genuinely
@@ -320,8 +325,17 @@ export function parseFrontMatter(source, file) {
320
325
  if (fields.has("template")) {
321
326
  try {
322
327
  template = requireTemplateName(fields.get("template"), file);
323
- if (template === TEMPLATE_GENERATED) record(generatedMarkdownFault(file));
324
- if (template === TEMPLATE_LEGAL) record(legalMarkdownFault(file));
328
+ if (!fields.has("articleEnd")) {
329
+ if (template === TEMPLATE_GENERATED) record(generatedMarkdownFault(file));
330
+ if (template === TEMPLATE_LEGAL) record(legalMarkdownFault(file));
331
+ }
332
+ } catch (error) {
333
+ record(error);
334
+ }
335
+ }
336
+ if (fields.has("articleEnd")) {
337
+ try {
338
+ requireArticleEnd(template, fields.get("articleEnd"), file, { fromText: true });
325
339
  } catch (error) {
326
340
  record(error);
327
341
  }
@@ -387,22 +401,17 @@ function unwrapProseMirrorDocument(parsed, file) {
387
401
 
388
402
  function makeResolveImage(mediaManifest, file) {
389
403
  return async (reference) => {
390
- for (const candidate of mediaReferenceCandidates(reference)) {
391
- const entry = mediaManifest.media[candidate];
392
- if (entry !== null && typeof entry === "object" && typeof entry.imageId === "string" && entry.imageId !== "") {
393
- return {
394
- imageId: entry.imageId,
395
- // `PageImageDeliveryRewriter` only replaces keys that are already
396
- // present, so a `taprootImage` node missing `src` or `urls` is
397
- // rewritten into nothing and renders blank. Both are handed back
398
- // empty and present.
399
- src: typeof entry.src === "string" ? entry.src : "",
400
- urls: Array.isArray(entry.urls) ? entry.urls : [],
401
- width: Number.isSafeInteger(entry.width) ? entry.width : 0,
402
- height: Number.isSafeInteger(entry.height) ? entry.height : 0,
403
- alt: typeof entry.alt === "string" ? entry.alt : "",
404
- };
405
- }
404
+ const entry = workspaceImageFromReference(mediaManifest, reference);
405
+ if (entry !== undefined) {
406
+ return {
407
+ imageId: entry.imageId,
408
+ // Page delivery rewriting fills the existing src and urls keys.
409
+ src: typeof entry.src === "string" ? entry.src : "",
410
+ urls: Array.isArray(entry.urls) ? entry.urls : [],
411
+ width: Number.isSafeInteger(entry.width) ? entry.width : 0,
412
+ height: Number.isSafeInteger(entry.height) ? entry.height : 0,
413
+ alt: typeof entry.alt === "string" ? entry.alt : "",
414
+ };
406
415
  }
407
416
  throw documentError(
408
417
  "media.unresolved_reference",
@@ -808,7 +817,7 @@ async function convertedWorkspacePageSource({ source, mediaManifest, content: in
808
817
  firstLine: source.markdownFirstLine,
809
818
  resolveImage,
810
819
  });
811
- return { document };
820
+ return { document: normalizeReusablePlacements(document) };
812
821
  } catch (error) {
813
822
  // A lone refusal is rethrown as raised, so the file is attached to its problems here.
814
823
  throw attachProblemsFile(error, file);
@@ -823,7 +832,10 @@ async function convertedWorkspacePageSource({ source, mediaManifest, content: in
823
832
  if (source.template !== TEMPLATE_FREE_FORM) {
824
833
  const document = typedDocumentFromJson(parsed, file);
825
834
  const sourceBodyHash = supportsAuthoredTags(source.template) ? workspacePageSourceBodyHash(parsed) : undefined;
826
- return { document, sourceBodyHash };
835
+ return { document: normalizeReusablePlacements(document), sourceBodyHash };
836
+ }
837
+ if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, "articleEnd")) {
838
+ requireArticleEnd(TEMPLATE_FREE_FORM, parsed.articleEnd, file);
827
839
  }
828
840
  if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, "tags")) {
829
841
  throw documentError("pages.tags_unsupported", `'${file}' declares tags, which the free-form template does not accept.`, "tags");
@@ -834,7 +846,7 @@ async function convertedWorkspacePageSource({ source, mediaManifest, content: in
834
846
  throw documentError("pages.document_shape", `'${file}' declares ${key}, which the free-form template does not accept.`, key);
835
847
  }
836
848
  }
837
- return { document: normalizeColumnsBody(unwrapProseMirrorDocument(parsed, file)).body };
849
+ return { document: normalizeReusablePlacements(normalizeColumnsBody(unwrapProseMirrorDocument(parsed, file)).body) };
838
850
  }
839
851
 
840
852
  /**
@@ -879,6 +891,7 @@ export async function validateWorkspacePageDocument({
879
891
  if (documentTemplate(document_) === TEMPLATE_RECIPE) {
880
892
  requireRecipeStepDocuments(document_.data.instructionSections ?? [], file);
881
893
  }
894
+ requireSupportedReusablePlacements(document_, file);
882
895
  const unusedCover = unusedCoverImageId(document_);
883
896
  if (unusedCover !== undefined) {
884
897
  throw documentError(
@@ -974,7 +987,7 @@ export async function placedVideoProblems(client, siteId, planned) {
974
987
  * reads the workspace's own form files (TR01081), only once a key turns out to be one the site lacks, so the
975
988
  * refusal can say whether the key's file is there to push.
976
989
  */
977
- export async function placedFormProblems(client, siteId, planned, readLocalFormKeys) {
990
+ export async function placedFormProblems(planned, readFormIndex, readLocalFormKeys) {
978
991
  const placements = new Map();
979
992
  for (const page of planned) {
980
993
  if (page.unchanged) continue;
@@ -984,7 +997,7 @@ export async function placedFormProblems(client, siteId, planned, readLocalFormK
984
997
  }
985
998
  if (placements.size === 0) return { problems: [], idByKey: new Map() };
986
999
 
987
- const index = await readFormIndex(client, siteId);
1000
+ const index = await readFormIndex();
988
1001
  const problems = [];
989
1002
  let localFormKeys;
990
1003
  let localRead = false;
@@ -1214,6 +1227,8 @@ export async function planPages({
1214
1227
  legalDrafts = false,
1215
1228
  platformLegalSite = false,
1216
1229
  readLegalPage,
1230
+ readFormPresentationPage,
1231
+ readFormIndex,
1217
1232
  onProgress = () => {},
1218
1233
  }) {
1219
1234
  const problems = [];
@@ -1567,6 +1582,10 @@ export async function planPages({
1567
1582
  }
1568
1583
  }
1569
1584
 
1585
+ const articleEndWrite = online ? articleEndWriteIntent({
1586
+ file, document: document_, target, baseline, observed: observedRecord,
1587
+ }) : undefined;
1588
+
1570
1589
  // The duplicate-source check above only catches two workspace files
1571
1590
  // fighting over one path. This catches the other half: a path some *live*
1572
1591
  // page already holds. Renaming onto it, or creating at it, is a duplicate
@@ -1595,6 +1614,11 @@ export async function planPages({
1595
1614
  }),
1596
1615
  });
1597
1616
 
1617
+ const formHash = formPresentationHash(document_);
1618
+ const formPresentationWrite = online ? await formPresentationWriteIntent({
1619
+ file, hash: formHash, target, baseline, observed: observedRecord, readEditablePage: readFormPresentationPage, readFormIndex,
1620
+ }) : undefined;
1621
+
1598
1622
  // Online, the listing says whom the site credits now; the baseline is
1599
1623
  // only whom it credited at the last reconcile. Discarding a draft in the
1600
1624
  // app can drop an author the CLI assigned, and the push must then ask
@@ -1628,6 +1652,7 @@ export async function planPages({
1628
1652
  // An author the site no longer holds is a change to send, however the
1629
1653
  // source compares with the record.
1630
1654
  const unchanged = isUnchanged(observedRecord, authorship.author)
1655
+ && articleEndWrite === undefined && formPresentationWrite === undefined
1631
1656
  && !(online && target !== undefined && authorship.sendAuthor);
1632
1657
  if (documentTemplate(document_) === TEMPLATE_LEGAL && !unchanged && online) {
1633
1658
  if (legalRevisionGuard !== undefined) requireReconciledRevision(legalRevisionGuard);
@@ -1697,10 +1722,14 @@ export async function planPages({
1697
1722
  sourceHash: source.sourceHash,
1698
1723
  sourceBodyHash,
1699
1724
  tagIntent,
1725
+ ...(articleEndWrite === undefined ? {} : { articleEndWrite }),
1726
+ ...(formHash === undefined ? {} : { formPresentationHash: formHash }),
1727
+ ...(formPresentationWrite === undefined ? {} : { formPresentationWrite }),
1700
1728
  ...(tagIntent === undefined || target === undefined ? {} : {
1701
1729
  tagUpdate: { target, tagBaseline, bodyRevision: baseline?.revision },
1702
1730
  }),
1703
1731
  pageId: target?.pageId,
1732
+ storedStatus: target?.hasDraft ? PAGE_STATUS_DRAFT : target?.status,
1704
1733
  // The live revision this page would be sent against; `plan` binds it
1705
1734
  // into its hash so a concurrent edit invalidates the plan.
1706
1735
  revision: target?.bodyRevision,
@@ -1740,6 +1769,8 @@ export function plannedPageWriteIdentity(page) {
1740
1769
  page.pageId ?? "",
1741
1770
  page.revision ?? "",
1742
1771
  page.action,
1772
+ ...(page.articleEndWrite === undefined ? [] : [page.articleEndWrite]),
1773
+ ...(page.formPresentationWrite === undefined ? [] : [page.formPresentationWrite]),
1743
1774
  ...(page.tagIntent === undefined ? [] : [
1744
1775
  page.tagIntent.names,
1745
1776
  page.tagFields?.expectedAuthoredTagRevision ?? "",
@@ -1818,6 +1849,13 @@ export async function pagesPush(invocation) {
1818
1849
  // every id in them is site-scoped, and a workspace pulled from another site
1819
1850
  // reads as entirely valid until phase two is already writing.
1820
1851
  const manifest = await readManifest(config.workspaceDir, siteId);
1852
+ if (manifest.settingsOnly === true) {
1853
+ throw new SiteAuthoringError(
1854
+ "pages.pull_required",
1855
+ "Run a full 'taproot-site pull' before pushing pages.",
1856
+ { field: "settingsOnly", exitCode: 2 },
1857
+ );
1858
+ }
1821
1859
  const mediaManifest = await readMediaManifest(config.workspaceDir, siteId);
1822
1860
  const content = requireContentFunctions(await loadContentModule(invocation.content));
1823
1861
  const requestedPaths = Array.isArray(invocation.pagePaths)
@@ -1864,6 +1902,8 @@ export async function pagesPush(invocation) {
1864
1902
  { field: PAGES_DIRECTORY },
1865
1903
  );
1866
1904
  }
1905
+ const readEditablePage = (target) => getPage(client, target.pageId, target.hasDraft ? PAGE_STATUS_DRAFT : target.status);
1906
+ const readFormIndex = liveFormIndexReader(client, siteId);
1867
1907
  const plan = await planPages({
1868
1908
  workspaceDir: config.workspaceDir,
1869
1909
  siteId,
@@ -1875,7 +1915,9 @@ export async function pagesPush(invocation) {
1875
1915
  online: true,
1876
1916
  legalDrafts: session.legalDrafts === true,
1877
1917
  platformLegalSite: session.legalDraftPlatformSite === true,
1878
- readLegalPage: (target) => getPage(client, target.pageId, target.hasDraft ? PAGE_STATUS_DRAFT : target.status),
1918
+ readLegalPage: readEditablePage,
1919
+ readFormPresentationPage: readEditablePage,
1920
+ readFormIndex,
1879
1921
  requestedPaths,
1880
1922
  refreshAuthors: liveAuthorsRefresher({
1881
1923
  client,
@@ -1888,7 +1930,11 @@ export async function pagesPush(invocation) {
1888
1930
  onProgress,
1889
1931
  });
1890
1932
  const { planned, targeted, unresolved, staleGenerated } = plan;
1891
- await preflightPageTagWrites(client, siteId, plan, invocation.pageTagCapabilities);
1933
+ const reusablePlacements = await checkLiveReusablePlacements(client, siteId, planned, onProgress);
1934
+ appendAll(plan.problems, reusablePlacements.problems);
1935
+ const tagCapabilities = await preflightPageTagWrites(client, siteId, plan, invocation.pageTagCapabilities);
1936
+ const articleEndCapabilities = await preflightArticleEndWrites(client, siteId, plan, invocation.pageArticleEndCapabilities ?? tagCapabilities);
1937
+ await preflightFormPresentationWrites(client, siteId, plan, invocation.pageFormPresentationCapabilities ?? articleEndCapabilities ?? tagCapabilities);
1892
1938
  appendAll(plan.problems, latestPostsTagProblems(planned, manifest, { sendingOnly: true }));
1893
1939
  // A page that places a video names it by id, and only the library knows
1894
1940
  // whether that id is one of this site's videos. Asked once for the whole
@@ -1896,7 +1942,7 @@ export async function pagesPush(invocation) {
1896
1942
  // publishing would then refuse.
1897
1943
  appendAll(plan.problems, await placedVideoProblems(client, siteId, planned));
1898
1944
  // Likewise a form: pages store its id, which only the site's own forms can supply.
1899
- const placedForms = await placedFormProblems(client, siteId, planned, () => workspaceFormKeys(config.workspaceDir));
1945
+ const placedForms = await placedFormProblems(planned, readFormIndex, () => workspaceFormKeys(config.workspaceDir));
1900
1946
  appendAll(plan.problems, placedForms.problems);
1901
1947
 
1902
1948
  // Under apply, the workspace read ledger has already held every source and
@@ -1936,7 +1982,7 @@ export async function pagesPush(invocation) {
1936
1982
  ? describedImagesFor(precheck, planImageDescriptions(precheck.state, precheck.pages), undefined, onProgress)
1937
1983
  : undefined;
1938
1984
  onProgress("Dry run: nothing was sent.");
1939
- return withImagePrecheck(successResult(VERB_PAGES_PUSH, siteId, {
1985
+ const result = withImagePrecheck(successResult(VERB_PAGES_PUSH, siteId, {
1940
1986
  dryRun: true,
1941
1987
  pages: {
1942
1988
  total: planned.length,
@@ -1951,6 +1997,7 @@ export async function pagesPush(invocation) {
1951
1997
  ...warnings,
1952
1998
  ...(describedImages === undefined ? {} : { describedImages }),
1953
1999
  }), precheck, onProgress);
2000
+ return appendReusablePlacementReport(result, reusablePlacements.report, onProgress);
1954
2001
  }
1955
2002
  refuseProblems(plan.problems, "pages push sent nothing");
1956
2003
  // Before the video posters are copied, so a poster this push places is outside the check; the stored report
@@ -1978,6 +2025,8 @@ export async function pagesPush(invocation) {
1978
2025
  template: wireTemplate(withFormIds(page.document, placedForms.idByKey)),
1979
2026
  ...wirePageFields(page.document),
1980
2027
  ...page.tagFields,
2028
+ ...page.articleEndWrite,
2029
+ ...page.formPresentationWrite,
1981
2030
  // Only a name the site has not been told: repeating the author a page
1982
2031
  // already has would let a later change of that person's permissions
1983
2032
  // refuse a push that changes nothing about authorship.
@@ -1997,7 +2046,8 @@ export async function pagesPush(invocation) {
1997
2046
  ? await createPage(client, { siteId, ...fields })
1998
2047
  : await updatePage(client, page.pageId, { pageId: page.pageId, ...fields });
1999
2048
  } catch (error) {
2000
- throw translateAuthorRefusal(translatePageTagRefusal(error, page), page.file);
2049
+ const formError = translateFormPresentationRefusal(error, page);
2050
+ throw translateAuthorRefusal(translatePageTagRefusal(translateArticleEndRefusal(formError, page), page), page.file);
2001
2051
  }
2002
2052
  attempting = undefined;
2003
2053
  manifestDirty = true;
@@ -2025,6 +2075,9 @@ export async function pagesPush(invocation) {
2025
2075
  // accepted, else what this workspace already knew it held.
2026
2076
  const heldAuthor = summary.authorRef
2027
2077
  || (page.sendAuthor ? page.author : parseAuthorReference(record.baseline?.author)?.value ?? "");
2078
+ const bodyBaseline = articleEndBaselineAfterWrite(record.baseline, page, summary);
2079
+ const formHash = bodyBaseline.revision === undefined ? undefined
2080
+ : bodyBaseline.revision === summary.bodyRevision ? page.formPresentationHash : record.baseline?.formPresentationHash;
2028
2081
  Object.assign(record, {
2029
2082
  pageId: summary.pageId,
2030
2083
  resourceId: summary.resourceId || record.resourceId || "",
@@ -2061,7 +2114,8 @@ export async function pagesPush(invocation) {
2061
2114
  ...(page.sourceBodyHash === undefined ? {} : { sourceBodyHash: page.sourceBodyHash }),
2062
2115
  contentKey: page.contentKey,
2063
2116
  ...tagBaselineAfterWrite(record.baseline, page, summary),
2064
- ...(summary.bodyRevision === undefined ? {} : { revision: summary.bodyRevision }),
2117
+ ...bodyBaseline,
2118
+ ...(formHash === undefined ? {} : { formPresentationHash: formHash }),
2065
2119
  // Recorded for the pages whose push sends a date, so the next push
2066
2120
  // can tell a date the site changed from one it already holds.
2067
2121
  ...(sentDisplayDate(page.templateType) ? { displayDate: summary.displayDate } : {}),
@@ -2164,7 +2218,7 @@ export async function pagesPush(invocation) {
2164
2218
  + "<handle or email>', then push again; 'taproot-site authors list' shows who can be named.",
2165
2219
  );
2166
2220
  }
2167
- return withImagePrecheck(successResult(VERB_PAGES_PUSH, siteId, {
2221
+ const result = withImagePrecheck(successResult(VERB_PAGES_PUSH, siteId, {
2168
2222
  pages: {
2169
2223
  total: planned.length,
2170
2224
  unchanged: planned.filter((page) => page.unchanged).length,
@@ -2193,5 +2247,6 @@ export async function pagesPush(invocation) {
2193
2247
  ...(nextStep === undefined ? {} : { nextStep }),
2194
2248
  ...(describedImages === undefined ? {} : { describedImages }),
2195
2249
  }), precheck, onProgress);
2250
+ return appendReusablePlacementReport(result, reusablePlacements.report, onProgress);
2196
2251
  });
2197
2252
  }
package/src/verbs/plan.js CHANGED
@@ -30,8 +30,13 @@ 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 { appendReusablePlacementReport, checkLiveReusablePlacements } from "../reusable-placements.js";
34
+ import { preflightArticleEndWrites } from "../page-article-end.js";
33
35
  import { preflightPageTagWrites } from "../page-tag-writes.js";
36
+ import { liveFormIndexReader } from "../form-references.js";
37
+ import { preflightFormPresentationWrites } from "../page-form-presentation.js";
34
38
  import { latestPostsTagProblems } from "../latest-posts-tags.js";
39
+ import { reusableWorkspaceReport } from "../reusable-blocks.js";
35
40
  import { CHECK_AREA, appendAll, collectProblems, omittedAreas, omittedProblemDigest, problemTotal, problemsError, problemsOf, problemsWithinBudget, withFullProblems, withinByteBudget } from "../problems.js";
36
41
  import { openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
37
42
  import { IMAGE_IDENTIFIER, usedImageIds } from "../typed-pages.js";
@@ -180,6 +185,13 @@ async function preflight(session, invocation) {
180
185
  const { client, config, siteId, onProgress } = session;
181
186
  const workspaceDir = config.workspaceDir;
182
187
  const manifest = await readManifest(workspaceDir, siteId);
188
+ if (manifest.settingsOnly === true) {
189
+ throw new SiteAuthoringError(
190
+ "plan.pull_required",
191
+ "Run a full 'taproot-site pull' before planning changes to pages and navigation.",
192
+ { field: "settingsOnly", exitCode: 2 },
193
+ );
194
+ }
183
195
  if (manifest.authoringSurface !== undefined) {
184
196
  throw new SiteAuthoringError(
185
197
  "plan.surface_unsupported",
@@ -226,6 +238,7 @@ async function preflight(session, invocation) {
226
238
  },
227
239
  content: invocation.content,
228
240
  areas: PLANNED_AREAS,
241
+ deferReusableTargets: true,
229
242
  onProgress,
230
243
  });
231
244
  appendAll(problems, offline.problems);
@@ -272,6 +285,8 @@ async function preflight(session, invocation) {
272
285
  },
273
286
  };
274
287
 
288
+ const readEditablePage = (target) => getPage(client, target.pageId, target.hasDraft ? PAGE_STATUS_DRAFT : target.status);
289
+ const readFormIndex = liveFormIndexReader(client, siteId);
275
290
  const pages = await planPages({
276
291
  workspaceDir,
277
292
  siteId,
@@ -283,7 +298,9 @@ async function preflight(session, invocation) {
283
298
  online: true,
284
299
  legalDrafts: session.legalDrafts === true,
285
300
  platformLegalSite: session.legalDraftPlatformSite === true,
286
- readLegalPage: (target) => getPage(client, target.pageId, target.hasDraft ? PAGE_STATUS_DRAFT : target.status),
301
+ readLegalPage: readEditablePage,
302
+ readFormPresentationPage: readEditablePage,
303
+ readFormIndex,
287
304
  // Asked of the site but never written down: `plan` leaves the workspace as it found it.
288
305
  refreshAuthors: liveAuthorsRefresher({ client, workspaceDir, siteId, write: false, onProgress }),
289
306
  // From the theme validated above, so a broken styles file is one problem, not one per page.
@@ -294,10 +311,14 @@ async function preflight(session, invocation) {
294
311
  onProgress,
295
312
  });
296
313
  const pageTagCapabilities = await preflightPageTagWrites(client, siteId, pages);
314
+ const pageArticleEndCapabilities = await preflightArticleEndWrites(client, siteId, pages, pageTagCapabilities);
315
+ const pageFormPresentationCapabilities = await preflightFormPresentationWrites(client, siteId, pages, pageArticleEndCapabilities ?? pageTagCapabilities);
297
316
  appendAll(problems, pages.problems);
317
+ const reusablePlacements = await checkLiveReusablePlacements(client, siteId, pages.planned, onProgress);
318
+ appendAll(problems, reusablePlacements.problems);
298
319
  appendAll(problems, latestPostsTagProblems(pages.planned, manifest, { sendingOnly: true }));
299
320
  appendAll(problems, await placedVideoProblems(client, siteId, pages.planned));
300
- appendAll(problems, (await placedFormProblems(client, siteId, pages.planned, () => workspaceFormKeys(workspaceDir))).problems);
321
+ appendAll(problems, (await placedFormProblems(pages.planned, readFormIndex, () => workspaceFormKeys(workspaceDir))).problems);
301
322
  const sending = pages.planned.filter((page) => !page.unchanged);
302
323
 
303
324
  // An image a page names must be one the site holds; an image this plan
@@ -325,7 +346,10 @@ async function preflight(session, invocation) {
325
346
  onProgress("Reading the site's presentation.");
326
347
  let theme;
327
348
  if (offline.presentation !== undefined) {
328
- theme = await comparePresentation(client, siteId, offline.presentation, manifest);
349
+ theme = await comparePresentation(client, siteId, offline.presentation, manifest, session.surface, {
350
+ onProgress, plannedPages: pages.planned,
351
+ });
352
+ await reusableWorkspaceReport(offline.presentation.reusableBlocks, offline.presentation.style, theme.reusableTargets, onProgress);
329
353
  // Only a theme step that would run can be refused.
330
354
  if (theme.changed && theme.baseline === undefined) {
331
355
  appendAll(problems, problemsOf(presentationPullRequired(), { area: CHECK_AREA.presentation }));
@@ -451,10 +475,13 @@ async function preflight(session, invocation) {
451
475
  problems,
452
476
  pendingMedia,
453
477
  planHash,
478
+ reusablePlacements: reusablePlacements.report,
454
479
  // The live state each step must still find: page revisions and the navigation tree, which the steps check
455
480
  // themselves (the theme and footer saves are fenced by the server, and the navigation save is as well).
456
481
  plannedPages: new Map(sending.map((page) => [page.file, stableJson(plannedPageWriteIdentity(page))])),
457
482
  pageTagCapabilities,
483
+ pageArticleEndCapabilities,
484
+ pageFormPresentationCapabilities,
458
485
  plannedLiveNavigation: stableJson(liveNavigation ?? null),
459
486
  };
460
487
  });
@@ -472,7 +499,7 @@ async function recordedPlan(session, invocation) {
472
499
 
473
500
  function planReport(planned) {
474
501
  const { steps, problems, planHash } = planned;
475
- const report = {
502
+ const report = appendReusablePlacementReport({
476
503
  planHash,
477
504
  ready: problems.length === 0,
478
505
  steps,
@@ -489,7 +516,7 @@ function planReport(planned) {
489
516
  "rendering: preview pages before approving them",
490
517
  "approval, staging, and production, which stay separate commands",
491
518
  ],
492
- };
519
+ }, planned.reusablePlacements);
493
520
  // The problems get whatever the rest of the report leaves of the result's
494
521
  // bound, so a long plan still serializes.
495
522
  const rest = Buffer.byteLength(JSON.stringify(report), "utf8");
@@ -535,6 +562,8 @@ const STEP_RUNNERS = Object.freeze({
535
562
  dryRun: false,
536
563
  plannedPages: planned.plannedPages,
537
564
  pageTagCapabilities: planned.pageTagCapabilities,
565
+ pageArticleEndCapabilities: planned.pageArticleEndCapabilities,
566
+ pageFormPresentationCapabilities: planned.pageFormPresentationCapabilities,
538
567
  }),
539
568
  [PLAN_STEP.footer]: (invocation) => footerPush({ ...invocation, verb: PLAN_STEP.footer }),
540
569
  [PLAN_STEP.theme]: (invocation) => themePush({ ...invocation, verb: PLAN_STEP.theme, dryRun: false }),