@taprootio/site-authoring 0.42.0 → 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.
- package/README.md +32 -1
- package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
- package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
- package/package.json +4 -3
- package/src/api.js +161 -8
- package/src/appearance-contract.js +264 -3
- package/src/authored-tag-names.js +88 -0
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +22 -0
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +143 -0
- package/src/chrome-features.js +6 -2
- package/src/chrome-input.js +1 -0
- package/src/chrome-paint-catalog-taproot.json +3 -3
- package/src/chrome-report.js +91 -12
- package/src/cli.js +45 -16
- package/src/content/components.js +27 -4
- package/src/content/external-link.js +2 -1
- package/src/content/markdown.js +271 -101
- package/src/content/tiptap-prosemirror.ts +125 -43
- package/src/content/validate-document.js +4 -1
- package/src/content-inset.js +48 -0
- package/src/errors.js +1 -0
- package/src/espalier-shared.js +26 -0
- package/src/field-suggestions.js +40 -0
- package/src/fixture-init.js +22 -5
- package/src/font-catalog.js +11 -1
- package/src/footer-brand-inputs.js +22 -3
- package/src/footer-content.js +1 -0
- package/src/footer-contract.js +11 -0
- package/src/footer-cta-styles.js +6 -0
- package/src/footer-draft-hash.js +4 -2
- package/src/footer-fit.js +62 -15
- package/src/footer-workspace.js +44 -7
- package/src/latest-posts-tags.js +57 -0
- package/src/page-structure-checks.js +5 -0
- package/src/page-tag-badge-modes.js +6 -0
- package/src/page-tag-writes.js +158 -0
- package/src/page-type-tags.js +16 -0
- package/src/presentation-reference.js +297 -86
- package/src/recipe-page-options.js +22 -0
- package/src/recipe-step-contract.js +164 -0
- package/src/recipe-step-contract.json +65 -0
- package/src/reference-help.js +164 -78
- package/src/session.js +39 -24
- package/src/setting-reference.js +239 -48
- package/src/settings-catalog.js +63 -0
- package/src/site-check-findings.js +23 -5
- package/src/site-check-rules.json +1 -0
- package/src/site-health-findings.js +13 -13
- package/src/styling-fixed-values.js +71 -0
- package/src/tag-destination-warnings.js +35 -0
- package/src/template-token-reach.json +242 -0
- package/src/theme-proposals.js +18 -27
- package/src/theme-resolve.js +265 -23
- package/src/theme-validation.js +118 -7
- package/src/token-reach.js +222 -0
- package/src/typed-page-reference.js +72 -15
- package/src/typed-pages.js +171 -71
- package/src/verbs/deploy.js +6 -0
- package/src/verbs/footer-push.js +30 -5
- package/src/verbs/forms-push.js +11 -3
- package/src/verbs/pages-delete.js +19 -10
- package/src/verbs/pages-push.js +125 -36
- package/src/verbs/plan.js +10 -4
- package/src/verbs/pull.js +277 -67
- package/src/verbs/staging-review.js +27 -1
- package/src/verbs/status.js +22 -0
- package/src/verbs/theme-push.js +93 -25
- package/src/verbs/theme-resolve.js +189 -55
- package/src/verbs/validate.js +6 -5
- package/src/workspace-check.js +35 -3
- package/src/workspace.js +37 -1
- package/test/fixtures/default-site-theme.json +516 -0
package/src/typed-pages.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { FREE_FORM_TEMPLATE_VERSION, TEMPLATE_TYPE_FREE_FORM } from "./api.js";
|
|
2
|
+
import { authoredTagSlug, validateAuthoredTagNames } from "./authored-tag-names.js";
|
|
2
3
|
import { isVideoEmbedId } from "./content/video-embed-url.js";
|
|
3
|
-
import { SiteAuthoringError } from "./errors.js";
|
|
4
|
+
import { hasControlCharacter, SiteAuthoringError } from "./errors.js";
|
|
4
5
|
import { isImageDescriptionMode } from "./content/image-description-validation.js";
|
|
5
6
|
import { stripImageDescriptionHydration } from "./content/image-description-document.js";
|
|
6
7
|
import { requireDescriptionLength } from "./page-metadata.js";
|
|
8
|
+
import { recipeStepProblems } from "./recipe-step-contract.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* The authored page templates (TR00893).
|
|
@@ -61,7 +63,7 @@ export const SHARED_FRONT_MATTER_KEYS = Object.freeze(["title", "path", "descrip
|
|
|
61
63
|
* its bare document, which has nowhere to carry them, so it does not accept
|
|
62
64
|
* them.
|
|
63
65
|
*/
|
|
64
|
-
const TYPED_PAGE_FRONT_MATTER_KEYS = Object.freeze(["displayDate", "coverImage"]);
|
|
66
|
+
const TYPED_PAGE_FRONT_MATTER_KEYS = Object.freeze(["displayDate", "coverImage", "tags"]);
|
|
65
67
|
|
|
66
68
|
/** Front-matter fields only one template accepts. Others are refused for it. */
|
|
67
69
|
const TEMPLATE_FRONT_MATTER_KEYS = Object.freeze({
|
|
@@ -171,6 +173,36 @@ export function isAuthorableTemplateType(wireType) {
|
|
|
171
173
|
return templateNameForWireType(wireType) !== undefined;
|
|
172
174
|
}
|
|
173
175
|
|
|
176
|
+
/** Whether the workspace template accepts an authored tag list. */
|
|
177
|
+
export function supportsAuthoredTags(template) {
|
|
178
|
+
return Object.hasOwn(TEMPLATE_FRONT_MATTER_KEYS, template) && TEMPLATE_FRONT_MATTER_KEYS[template].includes("tags");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Whether a site's wire template supports authored tags. */
|
|
182
|
+
export function supportsAuthoredTagWireType(wireType) {
|
|
183
|
+
return supportsAuthoredTags(templateNameForWireType(wireType));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** A snapshot can have valid wire data that a present source list could not write back. */
|
|
187
|
+
export function projectAuthoredTagSnapshot({ entries }) {
|
|
188
|
+
const projected = validateAuthoredTagNames(entries.map(({ name }) => name));
|
|
189
|
+
if ("reason" in projected) return projected;
|
|
190
|
+
|
|
191
|
+
const bySlug = new Map();
|
|
192
|
+
for (const [index, entry] of entries.entries()) {
|
|
193
|
+
const name = projected.names[index];
|
|
194
|
+
const slug = authoredTagSlug(name);
|
|
195
|
+
if (hasControlCharacter(entry.name)) {
|
|
196
|
+
return { field: `tags[${index}]`, reason: "A stored tag name contains control characters." };
|
|
197
|
+
}
|
|
198
|
+
if (slug !== entry.slug.toLowerCase()) {
|
|
199
|
+
return { field: `tags[${index}]`, reason: "A stored tag name cannot round-trip to its current slug." };
|
|
200
|
+
}
|
|
201
|
+
bySlug.set(slug, name);
|
|
202
|
+
}
|
|
203
|
+
return { names: projected.slugs.map((slug) => bySlug.get(slug)), slugs: projected.slugs };
|
|
204
|
+
}
|
|
205
|
+
|
|
174
206
|
/** Whether this wire template type is a legal document. */
|
|
175
207
|
export function isLegalTemplateType(wireType) {
|
|
176
208
|
return wireType === PAGE_TEMPLATES[TEMPLATE_LEGAL].wireType;
|
|
@@ -273,6 +305,43 @@ function requireDocument(value, file, path, { nonEmpty = false } = {}) {
|
|
|
273
305
|
return value;
|
|
274
306
|
}
|
|
275
307
|
|
|
308
|
+
export const RECIPE_STEP_UNSUPPORTED = "pages.recipe_step_unsupported";
|
|
309
|
+
|
|
310
|
+
function appendRecipeStepProblems(problems, issues, { file, name, sectionIndex, stepIndex, firstLine }) {
|
|
311
|
+
const section = name?.trim() ? `section ${sectionIndex + 1} ('${name.trim()}')` : `section ${sectionIndex + 1}`;
|
|
312
|
+
const stepPath = `data.instructionSections[${sectionIndex}].stepBodies[${stepIndex}]`;
|
|
313
|
+
for (const issue of issues) {
|
|
314
|
+
const line = issue.line ?? firstLine;
|
|
315
|
+
const source = line === undefined ? "" : ` (line ${line})`;
|
|
316
|
+
problems.push({
|
|
317
|
+
code: RECIPE_STEP_UNSUPPORTED,
|
|
318
|
+
file,
|
|
319
|
+
field: stepPath + (issue.path ?? ""),
|
|
320
|
+
...(line === undefined ? {} : { line }),
|
|
321
|
+
message: `'${file}', ${section}, step ${stepIndex + 1}${source}. ${issue.message}`,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function refuseRecipeStepProblems(problems) {
|
|
327
|
+
const first = problems[0];
|
|
328
|
+
if (first === undefined) return;
|
|
329
|
+
throw fail(first.code, first.message, first.field).withProblems(problems);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export function requireRecipeStepDocuments(sections, file) {
|
|
333
|
+
const problems = [];
|
|
334
|
+
for (const [sectionIndex, { name, stepBodies }] of sections.entries()) {
|
|
335
|
+
for (const [stepIndex, step] of stepBodies.entries()) {
|
|
336
|
+
appendRecipeStepProblems(problems, recipeStepProblems(step), { file, name, sectionIndex, stepIndex });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
refuseRecipeStepProblems(problems);
|
|
340
|
+
if (!sections.some(({ stepBodies }) => stepBodies.length > 0)) {
|
|
341
|
+
throw fail("pages.recipe_incomplete", `'${file}' needs at least one instruction step with text.`, file);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
276
345
|
function requireArray(value, file, path) {
|
|
277
346
|
if (!Array.isArray(value)) throw fail("pages.document_shape", `'${file}' ${path} must be a list.`, file);
|
|
278
347
|
return value;
|
|
@@ -539,18 +608,12 @@ function canonicalSourceData(template, data, file) {
|
|
|
539
608
|
const at = `${path}.instructionSections[${sectionIndex}]`;
|
|
540
609
|
requireKeys(section, ["name", "stepBodies"], file, at);
|
|
541
610
|
if (section.name !== undefined) requireString(section.name, file, `${at}.name`);
|
|
542
|
-
requireArray(section.stepBodies, file, `${at}.stepBodies`)
|
|
543
|
-
requireDocument(step, file, `${at}.stepBodies[${index}]`, { nonEmpty: true })
|
|
544
|
-
);
|
|
611
|
+
requireArray(section.stepBodies, file, `${at}.stepBodies`);
|
|
545
612
|
});
|
|
613
|
+
requireRecipeStepDocuments(instructionSections, file);
|
|
546
614
|
const hasIngredient = ingredientGroups.some((group) => group.ingredients.length > 0);
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
throw fail(
|
|
550
|
-
"pages.recipe_incomplete",
|
|
551
|
-
`'${file}' is a recipe, which needs at least one ingredient and one instruction step.`,
|
|
552
|
-
file,
|
|
553
|
-
);
|
|
615
|
+
if (!hasIngredient) {
|
|
616
|
+
throw fail("pages.recipe_incomplete", `'${file}' needs at least one ingredient.`, file);
|
|
554
617
|
}
|
|
555
618
|
if (data.prepTimeMinutes !== undefined) {
|
|
556
619
|
requireCount(data.prepTimeMinutes, file, `${path}.prepTimeMinutes`, MAXIMUM_MINUTES);
|
|
@@ -572,19 +635,21 @@ function canonicalSourceData(template, data, file) {
|
|
|
572
635
|
* The canonical workspace document for a typed page, with keys in one fixed
|
|
573
636
|
* order. The order is part of the byte-stability contract.
|
|
574
637
|
*/
|
|
575
|
-
function typedDocument(template, { displayDate, coverImageId, data }) {
|
|
638
|
+
function typedDocument(template, { displayDate, coverImageId, tags, data }) {
|
|
576
639
|
return {
|
|
577
640
|
template,
|
|
578
641
|
...(displayDate === undefined ? {} : { displayDate }),
|
|
579
642
|
...(coverImageId === undefined ? {} : { coverImageId }),
|
|
643
|
+
...(tags === undefined ? {} : { tags }),
|
|
580
644
|
data,
|
|
581
645
|
};
|
|
582
646
|
}
|
|
583
647
|
|
|
584
648
|
/** Validates a parsed `.pm.json` that declares a template, and returns its canonical form. */
|
|
585
649
|
export function typedDocumentFromJson(parsed, file) {
|
|
586
|
-
requireKeys(parsed, ["template", "displayDate", "coverImageId", "data"], file, "document");
|
|
650
|
+
requireKeys(parsed, ["template", "displayDate", "coverImageId", "tags", "data"], file, "document");
|
|
587
651
|
const template = requireTemplateName(parsed.template, file);
|
|
652
|
+
const tags = Object.hasOwn(parsed, "tags") ? requireSourceTags(template, parsed.tags, file).names : undefined;
|
|
588
653
|
if (template === TEMPLATE_FREE_FORM) {
|
|
589
654
|
throw fail(
|
|
590
655
|
"pages.document_shape",
|
|
@@ -609,10 +674,20 @@ export function typedDocumentFromJson(parsed, file) {
|
|
|
609
674
|
return typedDocument(template, {
|
|
610
675
|
displayDate,
|
|
611
676
|
coverImageId,
|
|
677
|
+
tags,
|
|
612
678
|
data: canonicalSourceData(template, parsed.data, file),
|
|
613
679
|
});
|
|
614
680
|
}
|
|
615
681
|
|
|
682
|
+
function requireSourceTags(template, value, file) {
|
|
683
|
+
if (!supportsAuthoredTags(template)) {
|
|
684
|
+
throw fail("pages.tags_unsupported", `'${file}' declares tags, which the ${template} template does not accept.`, "tags");
|
|
685
|
+
}
|
|
686
|
+
const result = validateAuthoredTagNames(value);
|
|
687
|
+
if ("reason" in result) throw fail("pages.tags_invalid", `'${file}', ${result.field}. ${result.reason}`, result.field);
|
|
688
|
+
return result;
|
|
689
|
+
}
|
|
690
|
+
|
|
616
691
|
// ── The site's page → the workspace document (pull) ──────────────────────────
|
|
617
692
|
|
|
618
693
|
const ratingName = (wire) => RATING_NAME_BY_WIRE[wire];
|
|
@@ -729,12 +804,12 @@ export function contentDocuments(document_) {
|
|
|
729
804
|
};
|
|
730
805
|
add(data.body, "data.body");
|
|
731
806
|
// The server accepts an empty introduction (the editor saves one for every
|
|
732
|
-
// recipe and album that has none), so it is validated but may be blank.
|
|
733
|
-
//
|
|
807
|
+
// recipe and album that has none), so it is validated but may be blank.
|
|
808
|
+
// Introductions accept fewer nodes than free-form and more than recipe steps.
|
|
734
809
|
add(data.introductionBody, "data.introductionBody", { mayBeEmpty: true, restricted: true });
|
|
735
810
|
for (const [sectionIndex, section] of (data.instructionSections ?? []).entries()) {
|
|
736
811
|
for (const [stepIndex, step] of section.stepBodies.entries()) {
|
|
737
|
-
add(step, `data.instructionSections[${sectionIndex}].stepBodies[${stepIndex}]`, {
|
|
812
|
+
add(step, `data.instructionSections[${sectionIndex}].stepBodies[${stepIndex}]`, { recipeStep: true });
|
|
738
813
|
}
|
|
739
814
|
}
|
|
740
815
|
return found;
|
|
@@ -746,8 +821,8 @@ export function sentDisplayDate(wireType) {
|
|
|
746
821
|
return name !== undefined && name !== TEMPLATE_FREE_FORM && name !== TEMPLATE_GENERATED && name !== TEMPLATE_LEGAL;
|
|
747
822
|
}
|
|
748
823
|
|
|
749
|
-
// The nodes the API accepts in an album or recipe introduction
|
|
750
|
-
//
|
|
824
|
+
// The nodes the API accepts in an album or recipe introduction
|
|
825
|
+
// (`MembershipTermsDocumentRules.AllowedNodeTypes`). A page body accepts
|
|
751
826
|
// more, such as `section` and `inlineFacts`, so a document valid as a body can
|
|
752
827
|
// still be refused there, after earlier pages have been saved.
|
|
753
828
|
const RESTRICTED_NODE_TYPES = new Set([
|
|
@@ -768,8 +843,8 @@ const RESTRICTED_NODE_TYPES = new Set([
|
|
|
768
843
|
]);
|
|
769
844
|
|
|
770
845
|
/**
|
|
771
|
-
* The first node type
|
|
772
|
-
*
|
|
846
|
+
* The first node type a restricted introduction cannot hold, or
|
|
847
|
+
* `undefined`. A table is allowed only directly
|
|
773
848
|
* under the document root; the content validator already checks its cells.
|
|
774
849
|
*/
|
|
775
850
|
export function unsupportedRestrictedNode(doc) {
|
|
@@ -959,12 +1034,12 @@ const IMAGE_LINE = /^!\[([^\]]*)\]\(\s*([^)\s]+)(?:\s+"[^"]*")?\s*\)$/u;
|
|
|
959
1034
|
const CONTINUATION = /^(?: {2,}|\t)/u;
|
|
960
1035
|
|
|
961
1036
|
/** Splits a body at its level-2 headings, ignoring anything inside a code fence. */
|
|
962
|
-
function splitSections(markdown) {
|
|
1037
|
+
function splitSections(markdown, firstLine = 1) {
|
|
963
1038
|
const lead = [];
|
|
964
1039
|
const sections = [];
|
|
965
1040
|
let current;
|
|
966
1041
|
let fence;
|
|
967
|
-
for (const line of markdown.split(/\r?\n/u)) {
|
|
1042
|
+
for (const [index, line] of markdown.split(/\r?\n/u).entries()) {
|
|
968
1043
|
const fenceMatch = FENCE.exec(line);
|
|
969
1044
|
if (fenceMatch !== null) {
|
|
970
1045
|
if (fence === undefined) fence = fenceMatch[1];
|
|
@@ -972,7 +1047,7 @@ function splitSections(markdown) {
|
|
|
972
1047
|
}
|
|
973
1048
|
const heading = fence === undefined && fenceMatch === null ? H2.exec(line) : null;
|
|
974
1049
|
if (heading !== null) {
|
|
975
|
-
current = { title: heading[1].trim(), lines: [] };
|
|
1050
|
+
current = { title: heading[1].trim(), lines: [], firstLine: firstLine + index + 1 };
|
|
976
1051
|
sections.push(current);
|
|
977
1052
|
} else {
|
|
978
1053
|
(current?.lines ?? lead).push(line);
|
|
@@ -1011,86 +1086,94 @@ function dedent(line, width) {
|
|
|
1011
1086
|
return line.slice(removed);
|
|
1012
1087
|
}
|
|
1013
1088
|
|
|
1014
|
-
function groupedLines(lines,
|
|
1089
|
+
function groupedLines({ lines, firstLine }, file, itemPattern, describe) {
|
|
1015
1090
|
const groups = [{ name: "", items: [] }];
|
|
1016
|
-
let
|
|
1017
|
-
// How far the open item's marker pushes its text in ("1. " is 3), which is
|
|
1018
|
-
// how far its continuation lines are indented. Removing exactly that much
|
|
1019
|
-
// keeps the relative indentation of nested lists and code inside the step.
|
|
1091
|
+
let item;
|
|
1020
1092
|
let markerWidth = 0;
|
|
1021
1093
|
let blanks = 0;
|
|
1022
|
-
const closeStep = () => {
|
|
1023
|
-
if (step !== undefined) groups.at(-1).items.push(step.join("\n"));
|
|
1024
|
-
step = undefined;
|
|
1025
|
-
};
|
|
1026
1094
|
let fence;
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1095
|
+
const closeItem = () => {
|
|
1096
|
+
if (item !== undefined) groups.at(-1).items.push({ text: item.lines.join("\n"), line: item.line });
|
|
1097
|
+
item = undefined;
|
|
1098
|
+
};
|
|
1099
|
+
const readFence = (text) => {
|
|
1100
|
+
const delimiter = /^( {0,3})(```+|~~~+)/u.exec(text)?.[2];
|
|
1101
|
+
if (fence === undefined) fence = delimiter;
|
|
1102
|
+
else if (delimiter?.[0] === fence[0] && delimiter.length >= fence.length && text.trim() === delimiter) fence = undefined;
|
|
1103
|
+
};
|
|
1104
|
+
for (const [index, line] of lines.entries()) {
|
|
1032
1105
|
if (line.trim() === "") {
|
|
1033
1106
|
blanks += 1;
|
|
1034
1107
|
continue;
|
|
1035
1108
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1109
|
+
const continuation = item === undefined ? null : CONTINUATION.exec(line);
|
|
1110
|
+
if (item !== undefined && (fence !== undefined || continuation !== null)) {
|
|
1111
|
+
for (let blank = 0; blank < blanks; blank += 1) item.lines.push("");
|
|
1112
|
+
const text = dedent(line, markerWidth);
|
|
1113
|
+
item.lines.push(text);
|
|
1114
|
+
if (itemPattern === STEP) readFence(text);
|
|
1041
1115
|
blanks = 0;
|
|
1042
1116
|
continue;
|
|
1043
1117
|
}
|
|
1044
1118
|
const group = H3.exec(line);
|
|
1045
1119
|
if (group !== null) {
|
|
1046
|
-
|
|
1120
|
+
closeItem();
|
|
1047
1121
|
groups.push({ name: group[1].trim(), items: [] });
|
|
1048
1122
|
blanks = 0;
|
|
1049
1123
|
continue;
|
|
1050
1124
|
}
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
markerWidth = line.length -
|
|
1056
|
-
|
|
1057
|
-
continue;
|
|
1058
|
-
}
|
|
1059
|
-
const continuation = step === undefined ? null : CONTINUATION.exec(line);
|
|
1060
|
-
if (continuation !== null) {
|
|
1061
|
-
for (let index = 0; index < blanks; index += 1) step.push("");
|
|
1062
|
-
step.push(dedent(line, markerWidth));
|
|
1125
|
+
const first = itemPattern.exec(line);
|
|
1126
|
+
if (first !== null) {
|
|
1127
|
+
closeItem();
|
|
1128
|
+
item = { lines: [first[1]], line: firstLine + index };
|
|
1129
|
+
markerWidth = line.length - first[1].length;
|
|
1130
|
+
if (itemPattern === STEP) readFence(first[1]);
|
|
1063
1131
|
blanks = 0;
|
|
1064
1132
|
continue;
|
|
1065
1133
|
}
|
|
1066
1134
|
throw fail(
|
|
1067
|
-
|
|
1068
|
-
`'${file}' has a line in ${describe} that is not a list item or a '### group' heading
|
|
1135
|
+
"pages.recipe_section_invalid",
|
|
1136
|
+
`'${file}' has a line in ${describe} that is not a list item or a '### group' heading. `
|
|
1069
1137
|
+ `'${line.trim().slice(0, 80)}'.`,
|
|
1070
1138
|
file,
|
|
1071
1139
|
);
|
|
1072
1140
|
}
|
|
1073
|
-
|
|
1141
|
+
closeItem();
|
|
1074
1142
|
return groups.filter((group) => group.items.length > 0 || group.name !== "");
|
|
1075
1143
|
}
|
|
1076
1144
|
|
|
1077
|
-
async function parseRecipeBody(markdown, { file, convert }) {
|
|
1078
|
-
const { lead, sections } = splitSections(markdown);
|
|
1145
|
+
async function parseRecipeBody(markdown, { file, convert, convertStep, firstLine }) {
|
|
1146
|
+
const { lead, sections } = splitSections(markdown, firstLine);
|
|
1079
1147
|
requireSectionTitles(sections, RECIPE_HEADINGS, file, TEMPLATE_RECIPE);
|
|
1080
|
-
const ingredientGroups = groupedLines(sections[0]
|
|
1148
|
+
const ingredientGroups = groupedLines(sections[0], file, BULLET, "the Ingredients section")
|
|
1081
1149
|
.map((group) => ({
|
|
1082
1150
|
name: group.name,
|
|
1083
|
-
ingredients: group.items.map((
|
|
1151
|
+
ingredients: group.items.map(({ text }) => ({ rawText: text.trim() })),
|
|
1084
1152
|
}))
|
|
1085
1153
|
.filter((group) => group.ingredients.length > 0);
|
|
1086
1154
|
const instructionSections = [];
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1155
|
+
const problems = [];
|
|
1156
|
+
for (const { name, items } of groupedLines(sections[1], file, STEP, "the Instructions section")) {
|
|
1157
|
+
if (items.length === 0) continue;
|
|
1158
|
+
const sectionIndex = instructionSections.length;
|
|
1090
1159
|
const stepBodies = [];
|
|
1091
|
-
for (const text of
|
|
1092
|
-
|
|
1160
|
+
for (const [stepIndex, { text, line }] of items.entries()) {
|
|
1161
|
+
const location = { file, name, sectionIndex, stepIndex, firstLine: line };
|
|
1162
|
+
try {
|
|
1163
|
+
const { doc, recipeStepIssues = [] } = await convertStep(text, line);
|
|
1164
|
+
appendRecipeStepProblems(problems, recipeStepIssues.length > 0 ? recipeStepIssues : recipeStepProblems(doc), location);
|
|
1165
|
+
stepBodies.push(doc);
|
|
1166
|
+
} catch (error) {
|
|
1167
|
+
if (!(error instanceof SiteAuthoringError)) throw error;
|
|
1168
|
+
appendRecipeStepProblems(problems, [{
|
|
1169
|
+
line: error.markdownLine,
|
|
1170
|
+
message: error.message.replace(/ \(line \d+\)$/u, ""),
|
|
1171
|
+
}], location);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
instructionSections.push({ name, stepBodies });
|
|
1093
1175
|
}
|
|
1176
|
+
refuseRecipeStepProblems(problems);
|
|
1094
1177
|
return {
|
|
1095
1178
|
introductionBody: lead.trim() === "" ? undefined : await convert(lead),
|
|
1096
1179
|
ingredientGroups,
|
|
@@ -1189,9 +1272,14 @@ export function templateFrontMatterFault(template, fieldNames, file) {
|
|
|
1189
1272
|
* a media reference through the media manifest; both are injected so this
|
|
1190
1273
|
* module stays pure.
|
|
1191
1274
|
*/
|
|
1192
|
-
export async function typedDocumentFromMarkdown({
|
|
1275
|
+
export async function typedDocumentFromMarkdown({
|
|
1276
|
+
template, fields, markdown, file, convert, resolveImage,
|
|
1277
|
+
firstLine = 1,
|
|
1278
|
+
convertStep = async text => ({ doc: await convert(text) }),
|
|
1279
|
+
}) {
|
|
1193
1280
|
if (template === TEMPLATE_GENERATED) throw generatedMarkdownFault(file);
|
|
1194
1281
|
if (template === TEMPLATE_LEGAL) throw legalMarkdownFault(file);
|
|
1282
|
+
const tags = fields.has("tags") ? parseMarkdownTags(fields.get("tags"), file) : undefined;
|
|
1195
1283
|
const displayDate = fields.has("displayDate") ? requireDisplayDate(fields.get("displayDate"), file) : undefined;
|
|
1196
1284
|
let coverImageId;
|
|
1197
1285
|
if (fields.has("coverImage")) {
|
|
@@ -1222,7 +1310,7 @@ export async function typedDocumentFromMarkdown({ template, fields, markdown, fi
|
|
|
1222
1310
|
};
|
|
1223
1311
|
} else {
|
|
1224
1312
|
data = {
|
|
1225
|
-
...(await parseRecipeBody(markdown, { file, convert })),
|
|
1313
|
+
...(await parseRecipeBody(markdown, { file, convert, convertStep, firstLine })),
|
|
1226
1314
|
prepTimeMinutes: parseCount(fields, "prepTimeMinutes", file, MAXIMUM_MINUTES),
|
|
1227
1315
|
cookTimeMinutes: parseCount(fields, "cookTimeMinutes", file, MAXIMUM_MINUTES),
|
|
1228
1316
|
servings: parseCount(fields, "servings", file, MAXIMUM_SERVINGS),
|
|
@@ -1236,13 +1324,25 @@ export async function typedDocumentFromMarkdown({ template, fields, markdown, fi
|
|
|
1236
1324
|
return typedDocumentFromJson(
|
|
1237
1325
|
{
|
|
1238
1326
|
template,
|
|
1239
|
-
...definedEntries([["displayDate", displayDate], ["coverImageId", coverImageId]]),
|
|
1327
|
+
...definedEntries([["displayDate", displayDate], ["coverImageId", coverImageId], ["tags", tags]]),
|
|
1240
1328
|
data: withoutUndefined(data),
|
|
1241
1329
|
},
|
|
1242
1330
|
file,
|
|
1243
1331
|
);
|
|
1244
1332
|
}
|
|
1245
1333
|
|
|
1334
|
+
function parseMarkdownTags(value, file) {
|
|
1335
|
+
try {
|
|
1336
|
+
return JSON.parse(value);
|
|
1337
|
+
} catch {
|
|
1338
|
+
throw fail(
|
|
1339
|
+
"pages.tags_invalid",
|
|
1340
|
+
`'${file}' needs a one-line JSON array of tag names, for example tags: ["Trail running", "PNW"].`,
|
|
1341
|
+
"tags",
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1246
1346
|
function withoutUndefined(value) {
|
|
1247
1347
|
return definedEntries(Object.entries(value));
|
|
1248
1348
|
}
|
package/src/verbs/deploy.js
CHANGED
|
@@ -27,6 +27,7 @@ import { SiteAuthoringError } from "../errors.js";
|
|
|
27
27
|
import { boundedList, openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
28
28
|
import { HANDOFF_NOT_REQUESTED_PROGRESS, handoffNotRequested, inspectStagingPreview } from "../staging-check.js";
|
|
29
29
|
import { confirmStagingServed, readStagingReleaseBefore, unverifiedStagingServed } from "../staging-served.js";
|
|
30
|
+
import { missingTagDestinations, reportTagDestinationWarnings } from "../tag-destination-warnings.js";
|
|
30
31
|
import { ApiError } from "../transport.js";
|
|
31
32
|
import { readManifest, writeManifest } from "../workspace.js";
|
|
32
33
|
import { DEPLOY_HEALTH_BUDGETS, DOCS_SITE_HEALTH_NOT_COVERED, readFailureCode, readSiteHealthReport } from "./health.js";
|
|
@@ -270,6 +271,9 @@ export async function deploy(invocation) {
|
|
|
270
271
|
warnIfExternalWritesPaused(session, VERB_DEPLOY);
|
|
271
272
|
const manifest = await readManifest(config.workspaceDir, siteId, { required: false });
|
|
272
273
|
const selection = explicitSelection(invocation);
|
|
274
|
+
const tagDestinationWarnings = presentationOnly ? undefined : reportTagDestinationWarnings(
|
|
275
|
+
missingTagDestinations(manifest?.presentation, manifest), onProgress,
|
|
276
|
+
);
|
|
273
277
|
|
|
274
278
|
return await withRefusalGuidance(onProgress, "deploy", async () => {
|
|
275
279
|
if (target === DEPLOY_TARGET_PRODUCTION) {
|
|
@@ -309,6 +313,7 @@ export async function deploy(invocation) {
|
|
|
309
313
|
deployment: completed,
|
|
310
314
|
outcome: created.outcome,
|
|
311
315
|
readiness: reportReadiness(readiness),
|
|
316
|
+
...(tagDestinationWarnings === undefined ? {} : { tagDestinationWarnings }),
|
|
312
317
|
});
|
|
313
318
|
}
|
|
314
319
|
|
|
@@ -498,6 +503,7 @@ export async function deploy(invocation) {
|
|
|
498
503
|
deployment: completed,
|
|
499
504
|
outcome: created.outcome,
|
|
500
505
|
readiness: reportReadiness(readiness),
|
|
506
|
+
...(tagDestinationWarnings === undefined ? {} : { tagDestinationWarnings }),
|
|
501
507
|
stagingServed,
|
|
502
508
|
siteHealth,
|
|
503
509
|
routeCheck,
|
package/src/verbs/footer-push.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { PRESENTATION_REVISION, saveSiteFooterSettings, withRefusalGuidance } from "../api.js";
|
|
1
|
+
import { getSettingsGroup, PRESENTATION_REVISION, saveSiteFooterSettings, withRefusalGuidance } from "../api.js";
|
|
2
2
|
import { VERB_FOOTER_PUSH } from "../constants.js";
|
|
3
3
|
import { SiteAuthoringError } from "../errors.js";
|
|
4
4
|
import { FOOTER_PRESENTATION_FIELDS, projectFooterContent } from "../footer-content.js";
|
|
5
5
|
import { projectFooterSettingsForWorkspace, validateFooterDocument } from "../footer-contract.js";
|
|
6
6
|
import { computeFooterDraftHash } from "../footer-draft-hash.js";
|
|
7
|
-
import {
|
|
8
|
-
import { buildFooterFitInput } from "../footer-fit.js";
|
|
7
|
+
import { readFooterFitInput } from "../footer-brand-inputs.js";
|
|
9
8
|
import { evaluateOfflineSiteChecks } from "../site-check-findings.js";
|
|
10
9
|
import {
|
|
11
10
|
advanceFooterManifest,
|
|
11
|
+
compareFooterContent,
|
|
12
12
|
FOOTER_SETTINGS_FILE,
|
|
13
13
|
readFooterWorkspaceContext,
|
|
14
14
|
readPresentationBaseline,
|
|
15
|
+
reportFooterPreview,
|
|
15
16
|
} from "../footer-workspace.js";
|
|
16
17
|
import { openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
17
18
|
import { SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES } from "../settings-catalog.js";
|
|
@@ -67,10 +68,11 @@ function translateConcurrency(error) {
|
|
|
67
68
|
export async function footerPush(invocation) {
|
|
68
69
|
const session = await openSession(invocation);
|
|
69
70
|
const { client, config, siteId, onProgress } = session;
|
|
71
|
+
const dryRun = invocation.dryRun === true;
|
|
70
72
|
// One advisory line before this verb does any work, and only when the
|
|
71
73
|
// exchange said the platform is paused. It changes nothing else: the write
|
|
72
74
|
// still runs and its refusal still classifies as platform_paused (TR00692).
|
|
73
|
-
warnIfExternalWritesPaused(session, VERB_FOOTER_PUSH);
|
|
75
|
+
if (!dryRun) warnIfExternalWritesPaused(session, VERB_FOOTER_PUSH);
|
|
74
76
|
const context = await readFooterWorkspaceContext(config.workspaceDir, siteId);
|
|
75
77
|
const { document: document_, footerSettings } = validateFooterWorkspaceDocument(
|
|
76
78
|
await readWorkspaceJson(config.workspaceDir, FOOTER_SETTINGS_FILE, WORKSPACE_LIMITS.settingsBytes),
|
|
@@ -85,10 +87,30 @@ export async function footerPush(invocation) {
|
|
|
85
87
|
const footerChecks = evaluateOfflineSiteChecks({
|
|
86
88
|
pagePaths: [],
|
|
87
89
|
footerOnly: true,
|
|
88
|
-
footerInput:
|
|
90
|
+
footerInput: await readFooterFitInput(config.workspaceDir, footerSettings),
|
|
89
91
|
onProgress,
|
|
90
92
|
});
|
|
91
93
|
|
|
94
|
+
if (dryRun) {
|
|
95
|
+
const response = await withRefusalGuidance(onProgress, VERB_FOOTER_PUSH, () =>
|
|
96
|
+
getSettingsGroup(client, siteId, SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES));
|
|
97
|
+
const current = response.sitePublishingPreferences?.footerSettings;
|
|
98
|
+
if (!isPlainObject(current)) {
|
|
99
|
+
throw new SiteAuthoringError("api.footer_settings_contract", "Taproot returned no draft footer document.", {
|
|
100
|
+
field: "footerSettings",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const preview = compareFooterContent(context.footer, projectFooterSettingsForWorkspace(current), footerSettings);
|
|
104
|
+
reportFooterPreview(preview, onProgress);
|
|
105
|
+
onProgress("Dry run: nothing was written.");
|
|
106
|
+
return successResult(VERB_FOOTER_PUSH, siteId, {
|
|
107
|
+
dryRun: true,
|
|
108
|
+
footerFile: FOOTER_SETTINGS_FILE,
|
|
109
|
+
...preview,
|
|
110
|
+
...footerChecks,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
92
114
|
let response;
|
|
93
115
|
try {
|
|
94
116
|
response = await withRefusalGuidance(onProgress, "footer push", async () =>
|
|
@@ -140,6 +162,9 @@ export async function footerPush(invocation) {
|
|
|
140
162
|
}
|
|
141
163
|
await advanceFooterManifest(config.workspaceDir, siteId, saved, footerDraftHash, {
|
|
142
164
|
presentationRevision: advances ? response.presentationRevision : undefined,
|
|
165
|
+
tagDestinations: context.manifest.presentation?.tagDestinations,
|
|
166
|
+
recipeMetadataDestinations: context.manifest.presentation?.recipeMetadataDestinations,
|
|
167
|
+
authoredTagSlugs: context.manifest.presentation?.authoredTagSlugs,
|
|
143
168
|
});
|
|
144
169
|
} catch (error) {
|
|
145
170
|
if (error instanceof SiteAuthoringError) throw error.withCompletedWrites(["footerSettings"]);
|
package/src/verbs/forms-push.js
CHANGED
|
@@ -236,9 +236,17 @@ export async function formsPush(invocation) {
|
|
|
236
236
|
} catch (caught) {
|
|
237
237
|
// The site checks the recorded version and settings under its own lock,
|
|
238
238
|
// which is what closes the gap between the comparison above and the write.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
let error = caught;
|
|
240
|
+
if (caught instanceof ApiError && (caught.hasField("ExpectedVersion") || caught.hasField("ExpectedSettings"))) {
|
|
241
|
+
error = changedOnTheSite(form.key, caught, applied);
|
|
242
|
+
} else if (caught instanceof ApiError && caught.descriptionFor("Sink") === "newsletter_disabled") {
|
|
243
|
+
error = new SiteAuthoringError(
|
|
244
|
+
"forms.newsletter_disabled",
|
|
245
|
+
`${formFileName(form.key)}: Taproot has disabled newsletter capture. Set sink to 'none' to keep collecting `
|
|
246
|
+
+ "form submissions, or ask a Taproot administrator to turn on Site Forms → Newsletter sink enabled.",
|
|
247
|
+
{ field: `${formFileName(form.key)}:sink`, status: caught.status },
|
|
248
|
+
);
|
|
249
|
+
}
|
|
242
250
|
if (error instanceof SiteAuthoringError) {
|
|
243
251
|
const completed = results.filter((item) => item.action !== "unchanged").map((item) => item.key);
|
|
244
252
|
if (applied.settings || applied.definition) completed.push(form.key);
|
|
@@ -14,6 +14,7 @@ import { FOOTER_SETTINGS_FILE } from "../footer-workspace.js";
|
|
|
14
14
|
import { afterSubmitPage, FORM_FILE_EXTENSION, FORMS_DIRECTORY, normalizePagePath as normalizeFormPagePath } from "../forms-contract.js";
|
|
15
15
|
import { normalizeRedirectPath } from "../site-checks.js";
|
|
16
16
|
import { boundedList, openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
17
|
+
import { reportTagDestinationWarnings, tagDestinationEntries } from "../tag-destination-warnings.js";
|
|
17
18
|
import { isAuthorableTemplateType, isGeneratedTemplateType, isLegalTemplateType } from "../typed-pages.js";
|
|
18
19
|
import {
|
|
19
20
|
deleteWorkspaceFile,
|
|
@@ -131,15 +132,12 @@ async function formsSendingTo(workspaceDir, pagePath, resourceId) {
|
|
|
131
132
|
return found;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
async function
|
|
135
|
-
if (!await workspaceFileExists(workspaceDir, FOOTER_SETTINGS_FILE)) return
|
|
136
|
-
return
|
|
137
|
-
await
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
shown,
|
|
141
|
-
),
|
|
142
|
-
resourceId,
|
|
135
|
+
async function readPublishingDocument(workspaceDir, shown) {
|
|
136
|
+
if (!await workspaceFileExists(workspaceDir, FOOTER_SETTINGS_FILE)) return undefined;
|
|
137
|
+
return await readReferenceSource(
|
|
138
|
+
async () => await readWorkspaceJson(workspaceDir, FOOTER_SETTINGS_FILE, WORKSPACE_LIMITS.documentBytes),
|
|
139
|
+
FOOTER_SETTINGS_FILE,
|
|
140
|
+
shown,
|
|
143
141
|
);
|
|
144
142
|
}
|
|
145
143
|
|
|
@@ -259,10 +257,12 @@ export async function pagesDelete(invocation) {
|
|
|
259
257
|
|
|
260
258
|
const references = { navigation: [], footer: [], forms: [] };
|
|
261
259
|
let redirects = [];
|
|
260
|
+
let publishingDocument;
|
|
262
261
|
if (!alreadyGone) {
|
|
263
262
|
onProgress("Checking what refers to the page.");
|
|
264
263
|
references.navigation = navigationItemsTo((await getNavigation(client, siteId)).navItems, live.resourceId);
|
|
265
|
-
|
|
264
|
+
publishingDocument = await readPublishingDocument(config.workspaceDir, shown);
|
|
265
|
+
references.footer = footerLinksTo(publishingDocument, live.resourceId);
|
|
266
266
|
references.forms = await formsSendingTo(config.workspaceDir, pagePath, live.resourceId);
|
|
267
267
|
if (references.navigation.length + references.footer.length + references.forms.length > 0) {
|
|
268
268
|
throw refusal(
|
|
@@ -286,7 +286,16 @@ export async function pagesDelete(invocation) {
|
|
|
286
286
|
redirects = redirectsLandingOn((await getSiteRedirectMap(client, siteId)).entries, pagePath);
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
const resourceId = live?.resourceId || entry.resourceId;
|
|
290
|
+
const destinations = new Map();
|
|
291
|
+
for (const source of [manifest.presentation, publishingDocument?.settings]) {
|
|
292
|
+
for (const item of tagDestinationEntries(source)) {
|
|
293
|
+
if (item.resourceId === resourceId) destinations.set(item.setting + "." + item.name, item);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const tagDestinationWarnings = reportTagDestinationWarnings([...destinations.values()], onProgress, shown);
|
|
289
297
|
const report = {
|
|
298
|
+
...(tagDestinationWarnings === undefined ? {} : { tagDestinationWarnings }),
|
|
290
299
|
page: {
|
|
291
300
|
path: shown,
|
|
292
301
|
...(entry.file === undefined ? {} : { file: entry.file }),
|