@taprootio/site-authoring 0.42.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +110 -12
  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 +242 -23
  6. package/src/appearance-contract.js +264 -3
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/authors-contract.js +71 -3
  9. package/src/block-flow.js +103 -1
  10. package/src/brand-color.js +22 -0
  11. package/src/breadcrumb-artwork.js +234 -0
  12. package/src/breadcrumb-separators.js +11 -0
  13. package/src/changelog.json +160 -0
  14. package/src/chrome-features.js +6 -2
  15. package/src/chrome-input.js +1 -0
  16. package/src/chrome-paint-catalog-taproot.json +3 -3
  17. package/src/chrome-report.js +91 -12
  18. package/src/cli.js +136 -38
  19. package/src/constants.js +1 -0
  20. package/src/content/components.js +27 -4
  21. package/src/content/external-link.js +2 -1
  22. package/src/content/markdown.js +271 -101
  23. package/src/content/tiptap-prosemirror.ts +125 -43
  24. package/src/content/validate-document.js +4 -1
  25. package/src/content-inset.js +48 -0
  26. package/src/errors.js +1 -0
  27. package/src/espalier-shared.js +26 -0
  28. package/src/field-suggestions.js +40 -0
  29. package/src/fixture-init.js +22 -5
  30. package/src/font-catalog.js +11 -1
  31. package/src/footer-brand-inputs.js +22 -3
  32. package/src/footer-content.js +1 -0
  33. package/src/footer-contract.js +11 -0
  34. package/src/footer-cta-styles.js +6 -0
  35. package/src/footer-draft-hash.js +4 -2
  36. package/src/footer-fit.js +62 -15
  37. package/src/footer-workspace.js +44 -7
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-metadata.js +15 -13
  40. package/src/page-structure-checks.js +5 -0
  41. package/src/page-tag-badge-modes.js +6 -0
  42. package/src/page-tag-writes.js +158 -0
  43. package/src/page-type-tags.js +16 -0
  44. package/src/presentation-reference.js +297 -86
  45. package/src/recipe-page-options.js +22 -0
  46. package/src/recipe-step-contract.js +164 -0
  47. package/src/recipe-step-contract.json +65 -0
  48. package/src/reference-help.js +182 -79
  49. package/src/session.js +39 -24
  50. package/src/setting-reference.js +239 -48
  51. package/src/settings-catalog.js +63 -0
  52. package/src/site-check-findings.js +23 -5
  53. package/src/site-check-rules.json +1 -0
  54. package/src/site-health-findings.js +13 -13
  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 +265 -23
  60. package/src/theme-validation.js +118 -7
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +94 -16
  63. package/src/typed-pages.js +233 -74
  64. package/src/verbs/authors.js +198 -33
  65. package/src/verbs/deploy.js +6 -0
  66. package/src/verbs/footer-push.js +30 -5
  67. package/src/verbs/forms-push.js +11 -3
  68. package/src/verbs/index.js +4 -2
  69. package/src/verbs/pages-delete.js +19 -10
  70. package/src/verbs/pages-push.js +225 -71
  71. package/src/verbs/plan.js +10 -4
  72. package/src/verbs/pull.js +324 -69
  73. package/src/verbs/staging-review.js +27 -1
  74. package/src/verbs/status.js +22 -0
  75. package/src/verbs/theme-push.js +93 -25
  76. package/src/verbs/theme-resolve.js +189 -55
  77. package/src/verbs/validate.js +6 -5
  78. package/src/workspace-check.js +35 -3
  79. package/src/workspace.js +73 -2
  80. package/test/fixtures/default-site-theme.json +516 -0
@@ -20,8 +20,7 @@ import {
20
20
  import { initializeFixture } from "../fixture-init.js";
21
21
  import { evaluateLogoSurfaceChecks } from "../logo-surface-checks.js";
22
22
  import { loadThemeEngines } from "../theme-resolve.js";
23
- import { footerBrandInputsFromSettings } from "../footer-brand-inputs.js";
24
- import { buildFooterFitInput } from "../footer-fit.js";
23
+ import { footerFitInputFromSettings } from "../footer-brand-inputs.js";
25
24
  import { appearanceManifestEntry, footerManifestEntry } from "../footer-workspace.js";
26
25
  import { FORMS_DIRECTORY } from "../forms-contract.js";
27
26
  import { authorWarnings, descriptionWarnings } from "../page-metadata.js";
@@ -696,12 +695,12 @@ async function offlineSiteChecks(checked, manifest, mediaManifest, onProgress, i
696
695
  const footer = checked.footer?.footerSettings;
697
696
  const footerInput = footer === undefined
698
697
  ? undefined
699
- : buildFooterFitInput(footer, footerBrandInputsFromSettings(
698
+ : footerFitInputFromSettings(
700
699
  checked.presentation?.header,
701
700
  checked.presentation?.style,
702
701
  mediaManifest.media,
703
702
  footer,
704
- ));
703
+ );
705
704
  const evaluated = evaluateOfflineSiteChecks({
706
705
  planned: checked.settingsOnly ? [] : checked.pages?.planned,
707
706
  footerInput,
@@ -864,7 +863,7 @@ export async function validateFixture(invocation = {}, {
864
863
  siteId: manifest.siteId,
865
864
  manifest,
866
865
  mediaManifest,
867
- binding: { knownImageIds: imageIds, settingsEntityIds: contract.settingsEntityIds, pageIds, resourceIds },
866
+ binding: { fixture: true, knownImageIds: imageIds, settingsEntityIds: contract.settingsEntityIds, pageIds, resourceIds },
868
867
  content: invocation.content,
869
868
  onProgress,
870
869
  });
@@ -970,6 +969,8 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
970
969
  ...await offlineSiteChecks(checked, manifest, mediaManifest, onProgress, site.imageCheck, options),
971
970
  };
972
971
  // The Docs settings checks do not own the skipped image reason reported by --site.
972
+ if (checked.latestPostsWarnings?.count > 0) warnings.latestPostsWarnings = checked.latestPostsWarnings;
973
+ if (checked.tagDestinationWarnings !== undefined) warnings.tagDestinationWarnings = checked.tagDestinationWarnings;
973
974
  const docsReason = checked.settingsOnly && invocation.fromSite === true
974
975
  ? {
975
976
  imageCheckReason: {
@@ -1,13 +1,17 @@
1
+ import { checkTagDestinationTargets } from "./appearance-contract.js";
1
2
  import { sharedThemeContextNames } from "./content/free-form-sections.js";
2
3
  import { readAppearanceWorkspaceContext, FOOTER_SETTINGS_FILE } from "./footer-workspace.js";
3
4
  import { placedFormKeys } from "./form-references.js";
5
+ import { latestPostsTagProblems } from "./latest-posts-tags.js";
4
6
  import { FORMS_DIRECTORY } from "./forms-contract.js";
5
7
  import { readWorkspaceForms } from "./forms-workspace.js";
6
8
  import { describeSiteFinding } from "./site-check-findings.js";
7
9
  import { unknownFormKeyFindings } from "./site-checks.js";
8
10
  import { CHECK_AREA, collectProblems, problemsOf } from "./problems.js";
9
11
  import { normalizeRedirectPath, REDIRECTS_FILE_NAME, validateRedirectsDocument } from "./redirects-contract.js";
12
+ import { boundedByBytes } from "./session.js";
10
13
  import { SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES } from "./settings-catalog.js";
14
+ import { missingTagDestinations, reportTagDestinationWarnings } from "./tag-destination-warnings.js";
11
15
  import { validateFooterWorkspaceDocument } from "./verbs/footer-push.js";
12
16
  import { validateNavigationWorkspaceDocument } from "./verbs/nav-push.js";
13
17
  import { planPages } from "./verbs/pages-push.js";
@@ -71,8 +75,27 @@ export async function checkWorkspace({
71
75
  onProgress("Validating the complete light/dark theme, appearance, header, brand, and surface contexts.");
72
76
  const presentation = knownImageIds === undefined
73
77
  ? undefined
74
- : await collectProblems(problems, { area: CHECK_AREA.presentation }, async () =>
75
- await validateThemeWorkspace(workspaceDir, siteId, knownImageIds, binding.settingsEntityIds));
78
+ : await collectProblems(problems, { area: CHECK_AREA.presentation }, async () => {
79
+ const validated = await validateThemeWorkspace(workspaceDir, siteId, knownImageIds, binding.settingsEntityIds);
80
+ if (validated.publishing.tagDestinations !== undefined) {
81
+ // A fixture declares its own tag names and has no live tag catalog.
82
+ const fixtureTagSlugs = binding.fixture ? Object.keys(validated.publishing.tagDestinations) : undefined;
83
+ checkTagDestinationTargets(
84
+ validated.publishing.tagDestinations, manifest.presentation?.tagDestinations, manifest,
85
+ undefined, fixtureTagSlugs,
86
+ );
87
+ }
88
+ if (validated.publishing.recipeMetadataDestinations !== undefined) {
89
+ checkTagDestinationTargets(
90
+ validated.publishing.recipeMetadataDestinations, manifest.presentation?.recipeMetadataDestinations,
91
+ manifest, undefined, undefined, true,
92
+ );
93
+ }
94
+ return validated;
95
+ });
96
+ const tagDestinationWarnings = reportTagDestinationWarnings(
97
+ missingTagDestinations(presentation?.publishing, manifest), onProgress,
98
+ );
76
99
 
77
100
  onProgress("Validating the closed footer document and its page and image targets.");
78
101
  const footer = knownImageIds === undefined
@@ -124,6 +147,12 @@ export async function checkWorkspace({
124
147
  onProgress,
125
148
  }));
126
149
  if (pages !== undefined) problems.push(...pages.problems);
150
+ const listingTagProblems = pages === undefined ? [] : latestPostsTagProblems(pages.planned, manifest);
151
+ const latestPostsWarnings = { count: listingTagProblems.length, ...boundedByBytes(listingTagProblems, 8 * 1024) };
152
+ for (const { message } of latestPostsWarnings.items) onProgress("Warning: " + message);
153
+ if (latestPostsWarnings.truncated) {
154
+ onProgress("Additional Latest Posts tag warnings: " + (latestPostsWarnings.count - latestPostsWarnings.items.length) + ".");
155
+ }
127
156
 
128
157
  // `plan` leaves redirects and forms to their own pushes.
129
158
  if (areas.has(CHECK_AREA.redirects)) {
@@ -161,7 +190,10 @@ export async function checkWorkspace({
161
190
  }
162
191
  }
163
192
 
164
- return { problems, settingsOnly, presentation, footer, navigation, pages, redirects, forms, formKeysChecked };
193
+ return {
194
+ problems, settingsOnly, presentation, footer, navigation, pages, redirects, forms, formKeysChecked,
195
+ tagDestinationWarnings, latestPostsWarnings,
196
+ };
165
197
  }
166
198
 
167
199
  /**
package/src/workspace.js CHANGED
@@ -4,9 +4,11 @@ import { lstat, mkdir, open, readdir, unlink } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
 
6
6
  import { atomicWriteFile } from "./atomic-file.js";
7
- import { parseAuthorReference } from "./authors-contract.js";
7
+ import { AUTHORED_TAG_SLUG, MAX_AUTHORED_TAG_NAME_SCALARS, MAX_AUTHORED_TAGS } from "./authored-tag-names.js";
8
+ import { normalizeAuthorHandle, parseAuthorReference } from "./authors-contract.js";
8
9
  import { LIMITS } from "./constants.js";
9
10
  import { hasAsciiControl, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
11
+ import { isSystemPageTypeTag } from "./page-type-tags.js";
10
12
  import {
11
13
  noteEntry,
12
14
  noteExists,
@@ -172,6 +174,31 @@ export function normalizePageBodyRevision(value) {
172
174
  return typeof value === "string" && PAGE_BODY_REVISION.test(value) ? value : undefined;
173
175
  }
174
176
 
177
+ /** Tag revisions use the same bounded envelope and an independent namespace. */
178
+ export const normalizeAuthoredTagRevision = normalizePageBodyRevision;
179
+
180
+ function normalizeAuthoredTagSlugs(value) {
181
+ if (value === null) return null;
182
+ if (!Array.isArray(value) || value.length > MAX_AUTHORED_TAGS) return undefined;
183
+ const distinct = new Set();
184
+ for (const slug of value) {
185
+ if (
186
+ typeof slug !== "string" || slug.length > MAX_AUTHORED_TAG_NAME_SCALARS || !AUTHORED_TAG_SLUG.test(slug)
187
+ || isSystemPageTypeTag("", slug) || distinct.has(slug)
188
+ ) return undefined;
189
+ distinct.add(slug);
190
+ }
191
+ return [...distinct].sort();
192
+ }
193
+
194
+ export function normalizeAuthoredTagBaseline(value) {
195
+ const authoredTagRevision = normalizeAuthoredTagRevision(value?.authoredTagRevision);
196
+ const authoredTagSlugs = normalizeAuthoredTagSlugs(value?.authoredTagSlugs);
197
+ return authoredTagRevision === undefined || authoredTagSlugs === undefined
198
+ ? undefined
199
+ : { authoredTagRevision, authoredTagSlugs };
200
+ }
201
+
175
202
  /**
176
203
  * The revision of the remote body this workspace last saw for a page, or
177
204
  * `undefined` when it has not seen one it did not also reconcile with.
@@ -237,6 +264,8 @@ export async function readObservedPageRecord(workspaceDir, pageId) {
237
264
  // The date the refusal showed, for a typed page. A date edit does not move
238
265
  // the revision, so the record has to name it to say what was seen.
239
266
  displayDate: normalizeBaselineDisplayDate(parsed.displayDate),
267
+ displayAuthor: normalizeBaselineDisplayAuthor(parsed.displayAuthor),
268
+ showOnProfile: normalizeBaselineShowOnProfile(parsed.showOnProfile),
240
269
  differences: normalizeObservedDifferences(parsed.differences),
241
270
  };
242
271
  }
@@ -344,6 +373,11 @@ export function canonicalDocumentHash(document_) {
344
373
  return `sha256:${createHash("sha256").update(canonicalJson(document_, 0), "utf8").digest("hex")}`;
345
374
  }
346
375
 
376
+ /** The typed source's body and metadata, independent of the authored tag list. */
377
+ export function workspacePageSourceBodyHash({ tags: _tags, ...document_ }) {
378
+ return canonicalDocumentHash(document_);
379
+ }
380
+
347
381
  /**
348
382
  * What a push would send for a page, as one hash: the source's bytes plus the
349
383
  * title, path, description and author that travel with it (for a `.pm.json`
@@ -389,6 +423,19 @@ function normalizeBaselineDisplayDate(value) {
389
423
  return typeof value === "string" && (value === "" || /^\d{4}-\d{2}-\d{2}$/u.test(value)) ? value : undefined;
390
424
  }
391
425
 
426
+ // A site author's handle or "" (no display author). Anything else is a damaged
427
+ // baseline member, and a baseline written before TR01402 has none: it counts as
428
+ // not having seen the value.
429
+ function normalizeBaselineDisplayAuthor(value) {
430
+ return value === "" || (typeof value === "string" && normalizeAuthorHandle(value) === value) ? value : undefined;
431
+ }
432
+
433
+ // A boolean (TR01403). A baseline written before showOnProfile existed has
434
+ // none: it counts as not having seen the value.
435
+ function normalizeBaselineShowOnProfile(value) {
436
+ return typeof value === "boolean" ? value : undefined;
437
+ }
438
+
392
439
  /**
393
440
  * Whether a manifest entry names a file `walkWorkspaceFiles` could have
394
441
  * produced: under `pages/`, bounded, and every segment in the workspace
@@ -456,24 +503,33 @@ export function pageSourceRegistry(manifest) {
456
503
  const declared = entry.baseline;
457
504
  const remoteHash = normalizeBaselineHash(declared?.remoteHash);
458
505
  const sourceHash = normalizeBaselineHash(declared?.sourceHash);
506
+ const sourceBodyHash = normalizeBaselineHash(declared?.sourceBodyHash);
459
507
  const contentKey = normalizeBaselineHash(declared?.contentKey);
460
508
  const revision = normalizePageBodyRevision(declared?.revision);
461
509
  const displayDate = normalizeBaselineDisplayDate(declared?.displayDate);
510
+ const displayAuthor = normalizeBaselineDisplayAuthor(declared?.displayAuthor);
511
+ const showOnProfile = normalizeBaselineShowOnProfile(declared?.showOnProfile);
462
512
  const author = normalizeAuthorValue(declared?.author);
513
+ const tagBaseline = normalizeAuthoredTagBaseline(declared);
463
514
  const baseline =
464
515
  remoteHash === undefined && sourceHash === undefined && revision === undefined && displayDate === undefined
465
- && contentKey === undefined && author === undefined
516
+ && displayAuthor === undefined && showOnProfile === undefined
517
+ && sourceBodyHash === undefined && contentKey === undefined && author === undefined && tagBaseline === undefined
466
518
  ? undefined
467
519
  : {
468
520
  ...(remoteHash === undefined ? {} : { remoteHash }),
469
521
  ...(sourceHash === undefined ? {} : { sourceHash }),
522
+ ...(sourceBodyHash === undefined ? {} : { sourceBodyHash }),
470
523
  ...(contentKey === undefined ? {} : { contentKey }),
471
524
  ...(revision === undefined ? {} : { revision }),
472
525
  ...(displayDate === undefined ? {} : { displayDate }),
526
+ ...(displayAuthor === undefined ? {} : { displayAuthor }),
527
+ ...(showOnProfile === undefined ? {} : { showOnProfile }),
473
528
  // The author the site held for the page when this workspace last
474
529
  // reconciled with it: what a page's own author reference is
475
530
  // compared with before anything is sent (TR01196).
476
531
  ...(author === undefined || author === "" ? {} : { author }),
532
+ ...tagBaseline,
477
533
  };
478
534
  const record = {
479
535
  pageId: entry.pageId,
@@ -1423,6 +1479,21 @@ export async function readMediaManifest(workspaceDir, expectedSiteId) {
1423
1479
  };
1424
1480
  }
1425
1481
 
1482
+ /**
1483
+ * The candidate keys a Markdown image reference could match in the media
1484
+ * manifest. Authors write `./media/hero.png`, `media/hero.png`, or
1485
+ * `/media/hero.png` for the same file, and a resolver that accepted only one
1486
+ * spelling would refuse content that is plainly correct.
1487
+ */
1488
+ export function mediaReferenceCandidates(reference) {
1489
+ if (typeof reference !== "string" || reference === "") return [];
1490
+ const withoutQuery = reference.split("#")[0].split("?")[0];
1491
+ const stripped = withoutQuery.replace(/^\.\//u, "").replace(/^\/+/u, "");
1492
+ const candidates = new Set([reference, withoutQuery, stripped]);
1493
+ if (!stripped.includes("/")) candidates.add(`media/${stripped}`);
1494
+ return [...candidates];
1495
+ }
1496
+
1426
1497
  /** The alt text a media record keeps when its file is uploaded again: the author's own, or none. */
1427
1498
  export function recordedAlt(entry) {
1428
1499
  return typeof entry?.alt === "string" ? entry.alt : "";