pagegraph 0.10.1 → 0.12.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 +163 -124
- package/dist/audit.d.ts +1 -1
- package/dist/audit.js +1 -1
- package/dist/build-only/audit.d.ts +1 -0
- package/dist/build-only/audit.js +6 -0
- package/dist/build-only/audit.js.map +1 -0
- package/dist/build-only/config.d.ts +1 -0
- package/dist/build-only/config.js +6 -0
- package/dist/build-only/config.js.map +1 -0
- package/dist/build-only/tanstack-start.d.ts +1 -0
- package/dist/build-only/tanstack-start.js +6 -0
- package/dist/build-only/tanstack-start.js.map +1 -0
- package/dist/build-only/vite.d.ts +1 -0
- package/dist/build-only/vite.js +6 -0
- package/dist/build-only/vite.js.map +1 -0
- package/dist/checks-uZk5Em9A.js +352 -0
- package/dist/checks-uZk5Em9A.js.map +1 -0
- package/dist/cli.js +3814 -3017
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +10 -45
- package/dist/config.js +10 -98
- package/dist/config.js.map +1 -1
- package/dist/{content-DVL2iyGU.d.ts → content-B1cPtL8b.d.ts} +4 -128
- package/dist/{content-BE9KCTgb.js → content-kcEnQdfi.js} +4 -489
- package/dist/content-kcEnQdfi.js.map +1 -0
- package/dist/declare-D5o7hwmv.js +9 -0
- package/dist/declare-D5o7hwmv.js.map +1 -0
- package/dist/declare-DVgdEdOL.d.ts +12127 -0
- package/dist/graph-Bcsourlv.js +162 -0
- package/dist/graph-Bcsourlv.js.map +1 -0
- package/dist/graph-BxCY90vq.d.ts +104 -0
- package/dist/graph-CBIY71w6.d.ts +57 -0
- package/dist/index.d.ts +37 -73
- package/dist/index.js +23 -133
- package/dist/index.js.map +1 -1
- package/dist/message-DT_CjUdt.js +12 -0
- package/dist/message-DT_CjUdt.js.map +1 -0
- package/dist/page-heads-6y-CARRQ.js +25 -0
- package/dist/page-heads-6y-CARRQ.js.map +1 -0
- package/dist/page-heads-DNkjMUEN.d.ts +21 -0
- package/dist/projections-D0oOFKiY.js +142 -0
- package/dist/projections-D0oOFKiY.js.map +1 -0
- package/dist/projections-DeEFe7XT.d.ts +78 -0
- package/dist/react.d.ts +26 -12051
- package/dist/react.js +12 -3
- package/dist/react.js.map +1 -1
- package/dist/route-config-35ZEzkNC.js +308 -0
- package/dist/route-config-35ZEzkNC.js.map +1 -0
- package/dist/route-config-wneg6ktn.d.ts +29 -0
- package/dist/tanstack-start/index.d.ts +40 -0
- package/dist/tanstack-start/index.js +368 -0
- package/dist/tanstack-start/index.js.map +1 -0
- package/dist/tanstack-start/server.d.ts +14 -0
- package/dist/tanstack-start/server.js +53 -0
- package/dist/tanstack-start/server.js.map +1 -0
- package/dist/vite-graph-loader-01p1WxEq.js +104 -0
- package/dist/vite-graph-loader-01p1WxEq.js.map +1 -0
- package/dist/vite-graph-loader-Btgjz5RH.d.ts +56 -0
- package/dist/vite.d.ts +2 -28
- package/dist/vite.js +1 -307
- package/dist/wire-B4RQMc4e.js +26 -0
- package/dist/wire-B4RQMc4e.js.map +1 -0
- package/package.json +35 -13
- package/dist/content-BE9KCTgb.js.map +0 -1
- package/dist/vite.js.map +0 -1
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { a as parseDeclaredDate, i as lastModified, r as isSitemapEligible } from "./projections-D0oOFKiY.js";
|
|
2
|
+
//#region src/core/freshness.ts
|
|
3
|
+
const DAY_MS = 864e5;
|
|
4
|
+
/**
|
|
5
|
+
* Split the graph's sitemap-eligible pages into stale, fresh, undated, and
|
|
6
|
+
* invalid. An invalid date cannot be aged, but it is listed so a report never
|
|
7
|
+
* reads as complete while it skipped a page.
|
|
8
|
+
*/
|
|
9
|
+
function freshnessReport(graph, policy, now) {
|
|
10
|
+
const stale = [];
|
|
11
|
+
const fresh = [];
|
|
12
|
+
const undated = [];
|
|
13
|
+
const invalid = [];
|
|
14
|
+
for (const node of graph.nodes.values()) {
|
|
15
|
+
if (!isSitemapEligible(node)) continue;
|
|
16
|
+
const declared = lastModified(node);
|
|
17
|
+
if (declared === void 0) {
|
|
18
|
+
undated.push(node.path);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const time = parseDeclaredDate(declared);
|
|
22
|
+
if (time === void 0) {
|
|
23
|
+
invalid.push(node.path);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const entry = {
|
|
27
|
+
path: node.path,
|
|
28
|
+
kind: node.kind,
|
|
29
|
+
source: node.source,
|
|
30
|
+
lastModified: new Date(time).toISOString(),
|
|
31
|
+
ageDays: Math.max(0, Math.floor((now.getTime() - time) / DAY_MS))
|
|
32
|
+
};
|
|
33
|
+
(entry.ageDays > policy.maxAgeDays ? stale : fresh).push(entry);
|
|
34
|
+
}
|
|
35
|
+
stale.sort((a, b) => b.ageDays - a.ageDays || (a.path < b.path ? -1 : 1));
|
|
36
|
+
fresh.sort((a, b) => a.ageDays - b.ageDays || (a.path < b.path ? -1 : 1));
|
|
37
|
+
return {
|
|
38
|
+
asOf: now.toISOString(),
|
|
39
|
+
maxAgeDays: policy.maxAgeDays,
|
|
40
|
+
stale,
|
|
41
|
+
fresh,
|
|
42
|
+
undated,
|
|
43
|
+
invalid
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/core/checks.ts
|
|
48
|
+
/** A positive sitemap policy — the author asked for this page to be indexed. */
|
|
49
|
+
const hasPositiveSitemap = (sitemap) => sitemap !== void 0 && sitemap !== false;
|
|
50
|
+
/** Content and manifest instances carry page-level title/description. */
|
|
51
|
+
const isInstance = (node) => node.source !== "route";
|
|
52
|
+
/** Group instance nodes by a present, non-empty string field for duplicate detection. */
|
|
53
|
+
const groupInstancesBy = (graph, field) => {
|
|
54
|
+
const groups = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const node of graph.nodes.values()) {
|
|
56
|
+
if (!isInstance(node)) continue;
|
|
57
|
+
const value = field(node)?.trim();
|
|
58
|
+
if (!value) continue;
|
|
59
|
+
const bucket = groups.get(value);
|
|
60
|
+
if (bucket) bucket.push(node);
|
|
61
|
+
else groups.set(value, [node]);
|
|
62
|
+
}
|
|
63
|
+
return groups;
|
|
64
|
+
};
|
|
65
|
+
const DESCRIPTION_MAX = 160;
|
|
66
|
+
const DESCRIPTION_MIN = 50;
|
|
67
|
+
/**
|
|
68
|
+
* Every check, in one place. `checkGraph` runs them in order and stamps each
|
|
69
|
+
* finding with its rule name and severity, so the output is grouped by rule and
|
|
70
|
+
* deterministic (nodes iterate in graph insertion order, edges in array order).
|
|
71
|
+
*/
|
|
72
|
+
const CHECK_RULES = [
|
|
73
|
+
{
|
|
74
|
+
name: "path-owner-collision",
|
|
75
|
+
severity: "structural",
|
|
76
|
+
evaluate: (graph) => (graph.collisions ?? []).map((collision) => ({
|
|
77
|
+
path: collision.path,
|
|
78
|
+
message: `Canonical path "${collision.path}" is owned by multiple sources: ${collision.sources.join(", ")}.`,
|
|
79
|
+
fix: "Give every concrete page one canonical path and one graph owner."
|
|
80
|
+
}))
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "canonical-path-collision",
|
|
84
|
+
severity: "structural",
|
|
85
|
+
evaluate: (graph) => {
|
|
86
|
+
const groups = /* @__PURE__ */ new Map();
|
|
87
|
+
for (const path of graph.nodes.keys()) {
|
|
88
|
+
const canonical = path.toLowerCase().replace(/\/$/, "") || "/";
|
|
89
|
+
const paths = groups.get(canonical);
|
|
90
|
+
if (paths) paths.push(path);
|
|
91
|
+
else groups.set(canonical, [path]);
|
|
92
|
+
}
|
|
93
|
+
return [...groups.values()].filter((paths) => paths.length > 1).flatMap((paths) => paths.map((path) => ({
|
|
94
|
+
path,
|
|
95
|
+
message: `Canonical path collides with ${paths.filter((candidate) => candidate !== path).join(", ")}.`,
|
|
96
|
+
fix: "Use one lowercase, trailing-slash-normalized canonical path."
|
|
97
|
+
})));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "self-edge",
|
|
102
|
+
severity: "structural",
|
|
103
|
+
evaluate: (graph) => graph.edges.filter((edge) => edge.from === edge.to).map((edge) => ({
|
|
104
|
+
path: edge.from,
|
|
105
|
+
message: `${edge.type} edge points back to its own source node.`,
|
|
106
|
+
fix: "Remove the self-reference from the canonical manifest or route declaration."
|
|
107
|
+
}))
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "duplicate-edge",
|
|
111
|
+
severity: "structural",
|
|
112
|
+
evaluate: (graph) => {
|
|
113
|
+
const seen = /* @__PURE__ */ new Set();
|
|
114
|
+
const duplicates = [];
|
|
115
|
+
for (const edge of graph.edges) {
|
|
116
|
+
const key = `${edge.from}\u0000${edge.to}\u0000${edge.type}`;
|
|
117
|
+
if (seen.has(key)) duplicates.push({
|
|
118
|
+
path: edge.from,
|
|
119
|
+
message: `Duplicate ${edge.type} edge from "${edge.from}" to "${edge.to}".`,
|
|
120
|
+
fix: "Declare each graph relationship exactly once."
|
|
121
|
+
});
|
|
122
|
+
else seen.add(key);
|
|
123
|
+
}
|
|
124
|
+
return duplicates;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "dead-edge",
|
|
129
|
+
severity: "structural",
|
|
130
|
+
evaluate: (graph) => graph.edges.filter((edge) => edge.type !== "crumb-parent" && !graph.nodes.has(edge.to)).map((edge) => ({
|
|
131
|
+
path: edge.from,
|
|
132
|
+
message: `${edge.type} edge from "${edge.from}" points at "${edge.to}", which is not a node in the graph.`,
|
|
133
|
+
fix: `Update the ${edge.type === "redirect" ? "redirectTo" : "related"} target on the "${edge.from}" route, or restore "${edge.to}".`
|
|
134
|
+
}))
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "instance-missing-title",
|
|
138
|
+
severity: "structural",
|
|
139
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => isInstance(node) && !node.instance?.title.trim()).map((node) => ({
|
|
140
|
+
path: node.path,
|
|
141
|
+
message: `Content page "${node.path}" has no title.`,
|
|
142
|
+
fix: "Add a `title` to the page frontmatter."
|
|
143
|
+
}))
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "sitemap-noindex-contradiction",
|
|
147
|
+
severity: "structural",
|
|
148
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => hasPositiveSitemap(node.policy.sitemap) && node.policy.robots?.toLowerCase().includes("noindex")).map((node) => ({
|
|
149
|
+
path: node.path,
|
|
150
|
+
message: `"${node.path}" declares a sitemap policy but its robots value is "${node.policy.robots}".`,
|
|
151
|
+
fix: "Drop the sitemap policy (or set `sitemap: false`) on a noindex page, or remove the noindex robots value."
|
|
152
|
+
}))
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "robots-not-lowercase",
|
|
156
|
+
severity: "structural",
|
|
157
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => node.policy.robots !== void 0 && node.policy.robots !== node.policy.robots.toLowerCase()).map((node) => ({
|
|
158
|
+
path: node.path,
|
|
159
|
+
message: `"${node.path}" declares robots "${node.policy.robots}" — robots values must be lowercase.`,
|
|
160
|
+
fix: "Lowercase the robots declaration (e.g. \"noindex, follow\")."
|
|
161
|
+
}))
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "related-target-missing-link",
|
|
165
|
+
severity: "structural",
|
|
166
|
+
evaluate: (graph) => {
|
|
167
|
+
const linklessTargets = /* @__PURE__ */ new Set();
|
|
168
|
+
for (const edge of graph.edges) {
|
|
169
|
+
if (edge.type !== "related") continue;
|
|
170
|
+
const target = graph.nodes.get(edge.to);
|
|
171
|
+
if (target && target.source === "route" && target.policy.link === void 0) linklessTargets.add(edge.to);
|
|
172
|
+
}
|
|
173
|
+
return [...linklessTargets].map((path) => ({
|
|
174
|
+
path,
|
|
175
|
+
message: `Route "${path}" is a related-link target but declares no link metadata; its card would render empty.`,
|
|
176
|
+
fix: `Add \`link: { title, description }\` to the "${path}" route's staticData.seo.`
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "redirect-in-sitemap",
|
|
182
|
+
severity: "structural",
|
|
183
|
+
evaluate: (graph) => [...graph.nodes.values()].filter((node) => node.policy.redirectTo !== void 0 && hasPositiveSitemap(node.policy.sitemap)).map((node) => ({
|
|
184
|
+
path: node.path,
|
|
185
|
+
message: `Redirect "${node.path}" (→ "${node.policy.redirectTo}") also declares a sitemap policy.`,
|
|
186
|
+
fix: "Remove the sitemap policy from the redirect route; only its target belongs in the sitemap."
|
|
187
|
+
}))
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "invalid-date",
|
|
191
|
+
severity: "structural",
|
|
192
|
+
evaluate: (graph) => [...graph.nodes.values()].flatMap((node) => {
|
|
193
|
+
return (node.instance ? [["publishedAt", node.instance.publishedAt], ["modifiedAt", node.instance.modifiedAt]] : [["modifiedAt", node.policy.modifiedAt]]).flatMap(([field, value]) => value !== void 0 && parseDeclaredDate(value) === void 0 ? [{
|
|
194
|
+
path: node.path,
|
|
195
|
+
message: `${field} "${value}" is not an ISO 8601 date on a real calendar day.`,
|
|
196
|
+
fix: `Write ${field} as an ISO 8601 date, e.g. "2026-09-29".`
|
|
197
|
+
}] : []);
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "duplicate-title",
|
|
202
|
+
severity: "editorial",
|
|
203
|
+
evaluate: (graph) => [...groupInstancesBy(graph, (node) => node.instance?.title).entries()].filter(([, nodes]) => nodes.length > 1).flatMap(([title, nodes]) => nodes.map((node) => ({
|
|
204
|
+
path: node.path,
|
|
205
|
+
message: `Title "${title}" is shared by ${nodes.length} pages.`,
|
|
206
|
+
fix: "Give each page a distinct title."
|
|
207
|
+
})))
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "duplicate-description",
|
|
211
|
+
severity: "editorial",
|
|
212
|
+
evaluate: (graph) => [...groupInstancesBy(graph, (node) => node.instance?.description).entries()].filter(([, nodes]) => nodes.length > 1).flatMap(([, nodes]) => nodes.map((node) => ({
|
|
213
|
+
path: node.path,
|
|
214
|
+
message: `Description is shared by ${nodes.length} pages.`,
|
|
215
|
+
fix: "Write a distinct meta description for each page."
|
|
216
|
+
})))
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "description-length",
|
|
220
|
+
severity: "editorial",
|
|
221
|
+
evaluate: (graph) => [...graph.nodes.values()].flatMap((node) => {
|
|
222
|
+
if (!isInstance(node)) return [];
|
|
223
|
+
const description = node.instance?.description?.trim();
|
|
224
|
+
if (!description) return [];
|
|
225
|
+
if (description.length > DESCRIPTION_MAX) return [{
|
|
226
|
+
path: node.path,
|
|
227
|
+
message: `Description is ${description.length} chars (max ${DESCRIPTION_MAX}); it will be truncated in results.`,
|
|
228
|
+
fix: `Trim the description to ${DESCRIPTION_MAX} characters or fewer.`
|
|
229
|
+
}];
|
|
230
|
+
if (description.length < DESCRIPTION_MIN) return [{
|
|
231
|
+
path: node.path,
|
|
232
|
+
message: `Description is ${description.length} chars (min ${DESCRIPTION_MIN}); it reads as thin.`,
|
|
233
|
+
fix: `Expand the description to at least ${DESCRIPTION_MIN} characters.`
|
|
234
|
+
}];
|
|
235
|
+
return [];
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
/**
|
|
240
|
+
* Run every static rule against the graph, then any caller-supplied
|
|
241
|
+
* {@link CoverageRule}s and freshness policy, and return the flat list of
|
|
242
|
+
* violations. With no options the result is exactly the static rule set.
|
|
243
|
+
*/
|
|
244
|
+
function checkGraph(graph, options = {}) {
|
|
245
|
+
const violations = CHECK_RULES.flatMap((rule) => rule.evaluate(graph).map((raw) => ({
|
|
246
|
+
severity: rule.severity,
|
|
247
|
+
rule: rule.name,
|
|
248
|
+
path: raw.path,
|
|
249
|
+
message: raw.message,
|
|
250
|
+
fix: raw.fix
|
|
251
|
+
})));
|
|
252
|
+
const coverage = options.coverage;
|
|
253
|
+
if (coverage !== void 0 && coverage.length > 0) violations.push(...checkCoverage(graph, coverage));
|
|
254
|
+
if (options.freshness !== void 0) violations.push(...checkFreshness(graph, options.freshness, options.now));
|
|
255
|
+
return violations;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* One editorial `stale-page` violation per sitemap-eligible page whose last
|
|
259
|
+
* declared change is older than the policy allows. Undated pages are not
|
|
260
|
+
* violations: see {@link freshnessReport} for the full picture.
|
|
261
|
+
*/
|
|
262
|
+
function checkFreshness(graph, policy, now) {
|
|
263
|
+
return freshnessReport(graph, policy, now).stale.map((entry) => ({
|
|
264
|
+
severity: "editorial",
|
|
265
|
+
rule: "stale-page",
|
|
266
|
+
path: entry.path,
|
|
267
|
+
message: `Last changed ${entry.lastModified.slice(0, 10)}, ${entry.ageDays} days ago (limit ${policy.maxAgeDays}).`,
|
|
268
|
+
fix: "Review the page; when its content changes, update its modifiedAt."
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
/** Escape a glob for `RegExp`, then expand `**`, `*`, and `?` to path-aware forms. */
|
|
272
|
+
const globToRegExp = (glob) => {
|
|
273
|
+
const source = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/\u0000/g, ".*");
|
|
274
|
+
return new RegExp(`^${source}$`);
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Enforce contextual-link coverage rules over an explicit surface.
|
|
278
|
+
*
|
|
279
|
+
* A rule that matches no sitemap-eligible page is itself a violation: a typo or
|
|
280
|
+
* a rule aimed at a noindex page would otherwise pass silently forever.
|
|
281
|
+
*/
|
|
282
|
+
const checkCoverageRules = (surface, rules) => {
|
|
283
|
+
const violations = [];
|
|
284
|
+
for (const rule of rules) {
|
|
285
|
+
const matcher = globToRegExp(rule.path);
|
|
286
|
+
const matched = surface.paths.filter((path) => matcher.test(path));
|
|
287
|
+
const eligible = surface.eligiblePaths.filter((path) => matcher.test(path));
|
|
288
|
+
if (eligible.length === 0) {
|
|
289
|
+
violations.push({
|
|
290
|
+
severity: "structural",
|
|
291
|
+
rule: "coverage-rule-unmatched",
|
|
292
|
+
message: matched.length === 0 ? `Coverage rule "${rule.path}" matches no page in the graph.` : `Coverage rule "${rule.path}" matches only pages that are not sitemap-eligible.`,
|
|
293
|
+
fix: "Point the rule at a sitemap-eligible path, or drop it."
|
|
294
|
+
});
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
for (const path of eligible) {
|
|
298
|
+
const inbound = surface.inbound(path);
|
|
299
|
+
if (inbound >= rule.minInbound) continue;
|
|
300
|
+
violations.push({
|
|
301
|
+
severity: "structural",
|
|
302
|
+
rule: "inbound-link-coverage",
|
|
303
|
+
path,
|
|
304
|
+
message: `"${path}" has ${inbound} incoming contextual link(s); the coverage rule requires ${rule.minInbound}.`,
|
|
305
|
+
fix: `Add ${rule.minInbound - inbound} contextual link(s) pointing at "${path}".`
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return violations;
|
|
310
|
+
};
|
|
311
|
+
/** The sitemap-eligible path set of a declared graph, in graph insertion order. */
|
|
312
|
+
const eligiblePathsOf = (graph) => [...graph.nodes.values()].filter(isSitemapEligible).map((node) => node.path);
|
|
313
|
+
/**
|
|
314
|
+
* Enforce contextual-link coverage against the *declared* graph: only `related`
|
|
315
|
+
* edges count — breadcrumb ancestry is navigation, not context.
|
|
316
|
+
*/
|
|
317
|
+
function checkCoverage(graph, rules) {
|
|
318
|
+
return checkCoverageRules({
|
|
319
|
+
paths: [...graph.nodes.keys()],
|
|
320
|
+
eligiblePaths: eligiblePathsOf(graph),
|
|
321
|
+
inbound: (path) => graph.edges.filter((edge) => edge.type === "related" && edge.to === path).length
|
|
322
|
+
}, rules);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Enforce contextual-link coverage against the *rendered* graph: only same-origin
|
|
326
|
+
* body-region anchors count. Nav, header, and footer anchors are site chrome, so
|
|
327
|
+
* a page linked solely from them has no contextual inbound link — the same
|
|
328
|
+
* distinction the declared pass draws by counting `related` edges alone.
|
|
329
|
+
*
|
|
330
|
+
* The target universe is the declared graph's sitemap-eligible pages: the globs
|
|
331
|
+
* in `seo.config.ts` are written against declared paths, and the crawl is what
|
|
332
|
+
* supplies the served edges. Pass the crawl's `internalEdges` (each edge carries
|
|
333
|
+
* its `region`).
|
|
334
|
+
*/
|
|
335
|
+
function checkRenderedCoverage(graph, renderedEdges, rules) {
|
|
336
|
+
const inbound = /* @__PURE__ */ new Map();
|
|
337
|
+
for (const edge of renderedEdges) {
|
|
338
|
+
if (edge.region !== "body") continue;
|
|
339
|
+
inbound.set(edge.to, (inbound.get(edge.to) ?? 0) + 1);
|
|
340
|
+
}
|
|
341
|
+
return checkCoverageRules({
|
|
342
|
+
paths: [...graph.nodes.keys()],
|
|
343
|
+
eligiblePaths: eligiblePathsOf(graph),
|
|
344
|
+
inbound: (path) => inbound.get(path) ?? 0
|
|
345
|
+
}, rules);
|
|
346
|
+
}
|
|
347
|
+
/** Structural violations fail `pagegraph check`; editorial-only stays green. */
|
|
348
|
+
const hasStructuralViolations = (violations) => violations.some((violation) => violation.severity === "structural");
|
|
349
|
+
//#endregion
|
|
350
|
+
export { globToRegExp as a, checkRenderedCoverage as i, checkFreshness as n, hasStructuralViolations as o, checkGraph as r, freshnessReport as s, checkCoverage as t };
|
|
351
|
+
|
|
352
|
+
//# sourceMappingURL=checks-uZk5Em9A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks-uZk5Em9A.js","names":[],"sources":["../src/core/freshness.ts","../src/core/checks.ts"],"sourcesContent":["/**\n * Freshness: how long ago each indexable page last changed, by the dates its\n * declaration carries ({@link lastModified}). Pure — the caller injects `now`,\n * so a test and the CLI read the same verdict from the same graph.\n *\n * Only sitemap-eligible pages are judged: a noindex or redirect page is not a\n * refresh candidate. A page with no date is reported as `undated` rather than\n * stale, because age cannot be inferred; the sitemap omits its `<lastmod>` too.\n */\n\nimport type { SeoKind } from \"./declare\";\nimport type { SeoGraph, SeoSource } from \"./graph\";\nimport { isSitemapEligible, lastModified, parseDeclaredDate } from \"./projections\";\n\n/** Project policy: pages whose last change is older than this are stale. */\nexport interface FreshnessPolicy {\n readonly maxAgeDays: number;\n}\n\nexport interface FreshnessEntry {\n readonly path: string;\n readonly kind: SeoKind;\n readonly source: SeoSource;\n /** The declared date, normalized to ISO 8601. */\n readonly lastModified: string;\n /** Whole days between `lastModified` and the report's `asOf`. */\n readonly ageDays: number;\n}\n\nexport interface FreshnessReport {\n readonly asOf: string;\n readonly maxAgeDays: number;\n /** Pages older than `maxAgeDays`, oldest first: the refresh queue. */\n readonly stale: ReadonlyArray<FreshnessEntry>;\n /** Dated pages within `maxAgeDays`, newest first. */\n readonly fresh: ReadonlyArray<FreshnessEntry>;\n /** Sitemap-eligible pages that declare no date, in graph order. */\n readonly undated: ReadonlyArray<string>;\n /** Sitemap-eligible pages whose date does not parse; `check` fails on each. */\n readonly invalid: ReadonlyArray<string>;\n}\n\nconst DAY_MS = 86_400_000;\n\n/**\n * Split the graph's sitemap-eligible pages into stale, fresh, undated, and\n * invalid. An invalid date cannot be aged, but it is listed so a report never\n * reads as complete while it skipped a page.\n */\nexport function freshnessReport(\n graph: SeoGraph,\n policy: FreshnessPolicy,\n now: Date,\n): FreshnessReport {\n const stale: Array<FreshnessEntry> = [];\n const fresh: Array<FreshnessEntry> = [];\n const undated: Array<string> = [];\n const invalid: Array<string> = [];\n\n for (const node of graph.nodes.values()) {\n if (!isSitemapEligible(node)) continue;\n const declared = lastModified(node);\n if (declared === undefined) {\n undated.push(node.path);\n continue;\n }\n const time = parseDeclaredDate(declared);\n if (time === undefined) {\n invalid.push(node.path);\n continue;\n }\n const entry: FreshnessEntry = {\n path: node.path,\n kind: node.kind,\n source: node.source,\n lastModified: new Date(time).toISOString(),\n ageDays: Math.max(0, Math.floor((now.getTime() - time) / DAY_MS)),\n };\n (entry.ageDays > policy.maxAgeDays ? stale : fresh).push(entry);\n }\n\n stale.sort((a, b) => b.ageDays - a.ageDays || (a.path < b.path ? -1 : 1));\n fresh.sort((a, b) => a.ageDays - b.ageDays || (a.path < b.path ? -1 : 1));\n return {\n asOf: now.toISOString(),\n maxAgeDays: policy.maxAgeDays,\n stale,\n fresh,\n undated,\n invalid,\n };\n}\n","/**\n * The SEO check engine: a set of rules run against the derived {@link SeoGraph}.\n * Pure — no I/O, no `clientEnv`, no React. The CLI's `pagegraph check` command and the\n * vitest suite both call {@link checkGraph}; nothing else derives correctness.\n *\n * Two severities, mapped to the CLI's exit contract:\n * - `structural` — a declaration is internally broken (a link points nowhere, a\n * card would render empty, a page contradicts its own robots/sitemap intent).\n * Any structural violation fails `pagegraph check` (exit 1); these must not ship.\n * - `editorial` — a quality smell (duplicate or mis-sized titles/descriptions).\n * Reported as warnings; `pagegraph check` still exits 0 when only these are present.\n *\n * The graph only knows what declarations and frontmatter carry, so the rules are\n * scoped to that: per-node title/description live only on collection *instances*,\n * never on structural route nodes (whose head tags are composed at render time and\n * are not in the graph). Rules are data-driven and listed once in\n * {@link CHECK_RULES}.\n */\n\nimport type { SitemapPolicy } from \"./declare\";\nimport { freshnessReport, type FreshnessPolicy } from \"./freshness\";\nimport type { SeoGraph, SeoNode } from \"./graph\";\nimport type { LinkEdge } from \"./links\";\nimport { isSitemapEligible, parseDeclaredDate } from \"./projections\";\n\nexport type Severity = \"structural\" | \"editorial\";\n\nexport interface Violation {\n severity: Severity;\n rule: string;\n path?: string | undefined;\n message: string;\n fix?: string | undefined;\n}\n\n/**\n * A contextual-link coverage rule: every sitemap-eligible page matching the\n * `path` glob must have at least `minInbound` incoming contextual links. Unlike\n * the static rules, these come from project policy (a CLI flag or\n * `seo.config.ts`), because \"which pages are money pages\" is app knowledge.\n *\n * The same rule shape is evaluated twice: `checkCoverage` counts declared\n * `related` edges, and `checkRenderedCoverage` counts the contextual anchors a\n * crawl actually served. The target universe is always the declared graph's\n * sitemap-eligible pages — the rendered pass only swaps the edge source.\n */\nexport interface CoverageRule {\n /** Path glob: `*` matches within a segment, `**` matches across segments. */\n readonly path: string;\n /** Minimum incoming contextual links the matched page needs. */\n readonly minInbound: number;\n}\n\n/** A single finding before its rule's `severity`/`rule` name are attached. */\ninterface RawViolation {\n path?: string | undefined;\n message: string;\n fix?: string | undefined;\n}\n\ninterface CheckRule {\n readonly name: string;\n readonly severity: Severity;\n readonly evaluate: (graph: SeoGraph) => ReadonlyArray<RawViolation>;\n}\n\n/** A positive sitemap policy — the author asked for this page to be indexed. */\nconst hasPositiveSitemap = (sitemap: SitemapPolicy | false | undefined): sitemap is SitemapPolicy =>\n sitemap !== undefined && sitemap !== false;\n\n/** Content and manifest instances carry page-level title/description. */\nconst isInstance = (node: SeoNode): boolean => node.source !== \"route\";\n\n/** Group instance nodes by a present, non-empty string field for duplicate detection. */\nconst groupInstancesBy = (\n graph: SeoGraph,\n field: (node: SeoNode) => string | undefined,\n): Map<string, Array<SeoNode>> => {\n const groups = new Map<string, Array<SeoNode>>();\n for (const node of graph.nodes.values()) {\n if (!isInstance(node)) continue;\n const value = field(node)?.trim();\n if (!value) continue;\n const bucket = groups.get(value);\n if (bucket) bucket.push(node);\n else groups.set(value, [node]);\n }\n return groups;\n};\n\nconst DESCRIPTION_MAX = 160;\nconst DESCRIPTION_MIN = 50;\n\n/**\n * Every check, in one place. `checkGraph` runs them in order and stamps each\n * finding with its rule name and severity, so the output is grouped by rule and\n * deterministic (nodes iterate in graph insertion order, edges in array order).\n */\nconst CHECK_RULES: ReadonlyArray<CheckRule> = [\n {\n name: \"path-owner-collision\",\n severity: \"structural\",\n evaluate: (graph) =>\n (graph.collisions ?? []).map((collision) => ({\n path: collision.path,\n message: `Canonical path \"${collision.path}\" is owned by multiple sources: ${collision.sources.join(\", \")}.`,\n fix: \"Give every concrete page one canonical path and one graph owner.\",\n })),\n },\n {\n name: \"canonical-path-collision\",\n severity: \"structural\",\n evaluate: (graph) => {\n const groups = new Map<string, Array<string>>();\n for (const path of graph.nodes.keys()) {\n const canonical = path.toLowerCase().replace(/\\/$/, \"\") || \"/\";\n const paths = groups.get(canonical);\n if (paths) paths.push(path);\n else groups.set(canonical, [path]);\n }\n return [...groups.values()]\n .filter((paths) => paths.length > 1)\n .flatMap((paths) =>\n paths.map((path) => ({\n path,\n message: `Canonical path collides with ${paths.filter((candidate) => candidate !== path).join(\", \")}.`,\n fix: \"Use one lowercase, trailing-slash-normalized canonical path.\",\n })),\n );\n },\n },\n {\n name: \"self-edge\",\n severity: \"structural\",\n evaluate: (graph) =>\n graph.edges\n .filter((edge) => edge.from === edge.to)\n .map((edge) => ({\n path: edge.from,\n message: `${edge.type} edge points back to its own source node.`,\n fix: \"Remove the self-reference from the canonical manifest or route declaration.\",\n })),\n },\n {\n name: \"duplicate-edge\",\n severity: \"structural\",\n evaluate: (graph) => {\n const seen = new Set<string>();\n const duplicates: Array<RawViolation> = [];\n for (const edge of graph.edges) {\n const key = `${edge.from}\\u0000${edge.to}\\u0000${edge.type}`;\n if (seen.has(key)) {\n duplicates.push({\n path: edge.from,\n message: `Duplicate ${edge.type} edge from \"${edge.from}\" to \"${edge.to}\".`,\n fix: \"Declare each graph relationship exactly once.\",\n });\n } else {\n seen.add(key);\n }\n }\n return duplicates;\n },\n },\n {\n // A `related` or `redirect` edge points at a path with no node — the target\n // route/page was renamed or deleted and the declaration wasn't updated.\n name: \"dead-edge\",\n severity: \"structural\",\n evaluate: (graph) =>\n graph.edges\n .filter((edge) => edge.type !== \"crumb-parent\" && !graph.nodes.has(edge.to))\n .map((edge) => ({\n path: edge.from,\n message: `${edge.type} edge from \"${edge.from}\" points at \"${edge.to}\", which is not a node in the graph.`,\n fix: `Update the ${edge.type === \"redirect\" ? \"redirectTo\" : \"related\"} target on the \"${edge.from}\" route, or restore \"${edge.to}\".`,\n })),\n },\n {\n // A content instance with no usable title can't render a legible <title> or card.\n name: \"instance-missing-title\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter((node) => isInstance(node) && !node.instance?.title.trim())\n .map((node) => ({\n path: node.path,\n message: `Content page \"${node.path}\" has no title.`,\n fix: \"Add a `title` to the page frontmatter.\",\n })),\n },\n {\n // The declaration asks for the page to be in the sitemap yet also marks it\n // noindex — contradictory intent. The projection resolves it (noindex wins,\n // excluded), but the declaration should say one thing.\n name: \"sitemap-noindex-contradiction\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) =>\n hasPositiveSitemap(node.policy.sitemap) &&\n node.policy.robots?.toLowerCase().includes(\"noindex\"),\n )\n .map((node) => ({\n path: node.path,\n message: `\"${node.path}\" declares a sitemap policy but its robots value is \"${node.policy.robots}\".`,\n fix: \"Drop the sitemap policy (or set `sitemap: false`) on a noindex page, or remove the noindex robots value.\",\n })),\n },\n {\n // Robots declarations are house-convention lowercase: the sitemap projection\n // matches `includes(\"noindex\")` literally, so a miscased value (\"Noindex\")\n // would silently stay sitemap-eligible. This gate makes that unrepresentable.\n name: \"robots-not-lowercase\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) =>\n node.policy.robots !== undefined &&\n node.policy.robots !== node.policy.robots.toLowerCase(),\n )\n .map((node) => ({\n path: node.path,\n message: `\"${node.path}\" declares robots \"${node.policy.robots}\" — robots values must be lowercase.`,\n fix: 'Lowercase the robots declaration (e.g. \"noindex, follow\").',\n })),\n },\n {\n // A `related` card for a route target renders from that route's `link`\n // metadata; without it the card has no title/description and renders empty.\n // (Content-instance targets render from their frontmatter, so they're exempt.)\n name: \"related-target-missing-link\",\n severity: \"structural\",\n evaluate: (graph) => {\n const linklessTargets = new Set<string>();\n for (const edge of graph.edges) {\n if (edge.type !== \"related\") continue;\n const target = graph.nodes.get(edge.to);\n if (target && target.source === \"route\" && target.policy.link === undefined) {\n linklessTargets.add(edge.to);\n }\n }\n return [...linklessTargets].map((path) => ({\n path,\n message: `Route \"${path}\" is a related-link target but declares no link metadata; its card would render empty.`,\n fix: `Add \\`link: { title, description }\\` to the \"${path}\" route's staticData.seo.`,\n }));\n },\n },\n {\n // A redirect/alias node should never advertise itself in the sitemap.\n name: \"redirect-in-sitemap\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) => node.policy.redirectTo !== undefined && hasPositiveSitemap(node.policy.sitemap),\n )\n .map((node) => ({\n path: node.path,\n message: `Redirect \"${node.path}\" (→ \"${node.policy.redirectTo}\") also declares a sitemap policy.`,\n fix: \"Remove the sitemap policy from the redirect route; only its target belongs in the sitemap.\",\n })),\n },\n {\n // Every declared date feeds the sitemap's `<lastmod>`, and the sitemap\n // projection refuses a date it cannot parse. Catch it here, at the\n // declaration, instead of as a failed sitemap request.\n name: \"invalid-date\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()].flatMap((node) => {\n const dates: Array<[string, string | undefined]> = node.instance\n ? [\n [\"publishedAt\", node.instance.publishedAt],\n [\"modifiedAt\", node.instance.modifiedAt],\n ]\n : [[\"modifiedAt\", node.policy.modifiedAt]];\n return dates.flatMap(([field, value]) =>\n value !== undefined && parseDeclaredDate(value) === undefined\n ? [\n {\n path: node.path,\n message: `${field} \"${value}\" is not an ISO 8601 date on a real calendar day.`,\n fix: `Write ${field} as an ISO 8601 date, e.g. \"2026-09-29\".`,\n },\n ]\n : [],\n );\n }),\n },\n {\n name: \"duplicate-title\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...groupInstancesBy(graph, (node) => node.instance?.title).entries()]\n .filter(([, nodes]) => nodes.length > 1)\n .flatMap(([title, nodes]) =>\n nodes.map((node) => ({\n path: node.path,\n message: `Title \"${title}\" is shared by ${nodes.length} pages.`,\n fix: \"Give each page a distinct title.\",\n })),\n ),\n },\n {\n name: \"duplicate-description\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...groupInstancesBy(graph, (node) => node.instance?.description).entries()]\n .filter(([, nodes]) => nodes.length > 1)\n .flatMap(([, nodes]) =>\n nodes.map((node) => ({\n path: node.path,\n message: `Description is shared by ${nodes.length} pages.`,\n fix: \"Write a distinct meta description for each page.\",\n })),\n ),\n },\n {\n // Meta descriptions outside ~50–160 chars either get truncated in SERPs or\n // read as too thin.\n name: \"description-length\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...graph.nodes.values()].flatMap((node) => {\n if (!isInstance(node)) return [];\n const description = node.instance?.description?.trim();\n if (!description) return [];\n if (description.length > DESCRIPTION_MAX) {\n return [\n {\n path: node.path,\n message: `Description is ${description.length} chars (max ${DESCRIPTION_MAX}); it will be truncated in results.`,\n fix: `Trim the description to ${DESCRIPTION_MAX} characters or fewer.`,\n },\n ];\n }\n if (description.length < DESCRIPTION_MIN) {\n return [\n {\n path: node.path,\n message: `Description is ${description.length} chars (min ${DESCRIPTION_MIN}); it reads as thin.`,\n fix: `Expand the description to at least ${DESCRIPTION_MIN} characters.`,\n },\n ];\n }\n return [];\n }),\n },\n];\n\n/**\n * Options for {@link checkGraph}. Freshness needs a clock, and the engine stays\n * pure, so a freshness policy is only accepted together with the `now` it is\n * judged against.\n */\nexport type CheckGraphOptions = {\n readonly coverage?: ReadonlyArray<CoverageRule> | undefined;\n} & (\n | { readonly freshness: FreshnessPolicy; readonly now: Date }\n | { readonly freshness?: undefined; readonly now?: undefined }\n);\n\n/**\n * Run every static rule against the graph, then any caller-supplied\n * {@link CoverageRule}s and freshness policy, and return the flat list of\n * violations. With no options the result is exactly the static rule set.\n */\nexport function checkGraph(graph: SeoGraph, options: CheckGraphOptions = {}): Array<Violation> {\n const violations: Array<Violation> = CHECK_RULES.flatMap((rule) =>\n rule.evaluate(graph).map((raw): Violation => ({\n severity: rule.severity,\n rule: rule.name,\n path: raw.path,\n message: raw.message,\n fix: raw.fix,\n })),\n );\n const coverage = options.coverage;\n if (coverage !== undefined && coverage.length > 0) {\n violations.push(...checkCoverage(graph, coverage));\n }\n if (options.freshness !== undefined) {\n violations.push(...checkFreshness(graph, options.freshness, options.now));\n }\n return violations;\n}\n\n/**\n * One editorial `stale-page` violation per sitemap-eligible page whose last\n * declared change is older than the policy allows. Undated pages are not\n * violations: see {@link freshnessReport} for the full picture.\n */\nexport function checkFreshness(\n graph: SeoGraph,\n policy: FreshnessPolicy,\n now: Date,\n): Array<Violation> {\n return freshnessReport(graph, policy, now).stale.map((entry) => ({\n severity: \"editorial\",\n rule: \"stale-page\",\n path: entry.path,\n message: `Last changed ${entry.lastModified.slice(0, 10)}, ${entry.ageDays} days ago (limit ${policy.maxAgeDays}).`,\n fix: \"Review the page; when its content changes, update its modifiedAt.\",\n }));\n}\n\n/** Escape a glob for `RegExp`, then expand `**`, `*`, and `?` to path-aware forms. */\nexport const globToRegExp = (glob: string): RegExp => {\n const escaped = glob.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const source = escaped\n .replace(/\\*\\*/g, \"\\u0000\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/\\?/g, \"[^/]\")\n .replace(/\\u0000/g, \".*\");\n return new RegExp(`^${source}$`);\n};\n\n/**\n * The minimal view a coverage rule needs: which paths exist (for the glob), which\n * of them are sitemap-eligible (the enforced set), and how many contextual links\n * each receives. Declared and rendered coverage differ only in how this surface\n * is built, so the rule engine itself stays single-sourced.\n */\ninterface CoverageSurface {\n readonly paths: ReadonlyArray<string>;\n readonly eligiblePaths: ReadonlyArray<string>;\n readonly inbound: (path: string) => number;\n}\n\n/**\n * Enforce contextual-link coverage rules over an explicit surface.\n *\n * A rule that matches no sitemap-eligible page is itself a violation: a typo or\n * a rule aimed at a noindex page would otherwise pass silently forever.\n */\nconst checkCoverageRules = (\n surface: CoverageSurface,\n rules: ReadonlyArray<CoverageRule>,\n): Array<Violation> => {\n const violations: Array<Violation> = [];\n for (const rule of rules) {\n const matcher = globToRegExp(rule.path);\n const matched = surface.paths.filter((path) => matcher.test(path));\n const eligible = surface.eligiblePaths.filter((path) => matcher.test(path));\n\n if (eligible.length === 0) {\n violations.push({\n severity: \"structural\",\n rule: \"coverage-rule-unmatched\",\n message:\n matched.length === 0\n ? `Coverage rule \"${rule.path}\" matches no page in the graph.`\n : `Coverage rule \"${rule.path}\" matches only pages that are not sitemap-eligible.`,\n fix: \"Point the rule at a sitemap-eligible path, or drop it.\",\n });\n continue;\n }\n\n for (const path of eligible) {\n const inbound = surface.inbound(path);\n if (inbound >= rule.minInbound) continue;\n violations.push({\n severity: \"structural\",\n rule: \"inbound-link-coverage\",\n path,\n message: `\"${path}\" has ${inbound} incoming contextual link(s); the coverage rule requires ${rule.minInbound}.`,\n fix: `Add ${rule.minInbound - inbound} contextual link(s) pointing at \"${path}\".`,\n });\n }\n }\n return violations;\n};\n\n/** The sitemap-eligible path set of a declared graph, in graph insertion order. */\nconst eligiblePathsOf = (graph: SeoGraph): ReadonlyArray<string> =>\n [...graph.nodes.values()].filter(isSitemapEligible).map((node) => node.path);\n\n/**\n * Enforce contextual-link coverage against the *declared* graph: only `related`\n * edges count — breadcrumb ancestry is navigation, not context.\n */\nexport function checkCoverage(\n graph: SeoGraph,\n rules: ReadonlyArray<CoverageRule>,\n): Array<Violation> {\n return checkCoverageRules(\n {\n paths: [...graph.nodes.keys()],\n eligiblePaths: eligiblePathsOf(graph),\n inbound: (path) =>\n graph.edges.filter((edge) => edge.type === \"related\" && edge.to === path).length,\n },\n rules,\n );\n}\n\n/**\n * Enforce contextual-link coverage against the *rendered* graph: only same-origin\n * body-region anchors count. Nav, header, and footer anchors are site chrome, so\n * a page linked solely from them has no contextual inbound link — the same\n * distinction the declared pass draws by counting `related` edges alone.\n *\n * The target universe is the declared graph's sitemap-eligible pages: the globs\n * in `seo.config.ts` are written against declared paths, and the crawl is what\n * supplies the served edges. Pass the crawl's `internalEdges` (each edge carries\n * its `region`).\n */\nexport function checkRenderedCoverage(\n graph: SeoGraph,\n renderedEdges: ReadonlyArray<LinkEdge>,\n rules: ReadonlyArray<CoverageRule>,\n): Array<Violation> {\n const inbound = new Map<string, number>();\n for (const edge of renderedEdges) {\n if (edge.region !== \"body\") continue;\n inbound.set(edge.to, (inbound.get(edge.to) ?? 0) + 1);\n }\n return checkCoverageRules(\n {\n paths: [...graph.nodes.keys()],\n eligiblePaths: eligiblePathsOf(graph),\n inbound: (path) => inbound.get(path) ?? 0,\n },\n rules,\n );\n}\n\n/** Structural violations fail `pagegraph check`; editorial-only stays green. */\nexport const hasStructuralViolations = (violations: ReadonlyArray<Violation>): boolean =>\n violations.some((violation) => violation.severity === \"structural\");\n"],"mappings":";;AA0CA,MAAM,SAAS;;;;;;AAOf,SAAgB,gBACd,OACA,QACA,KACiB;CACjB,MAAM,QAA+B,CAAC;CACtC,MAAM,QAA+B,CAAC;CACtC,MAAM,UAAyB,CAAC;CAChC,MAAM,UAAyB,CAAC;CAEhC,KAAK,MAAM,QAAQ,MAAM,MAAM,OAAO,GAAG;EACvC,IAAI,CAAC,kBAAkB,IAAI,GAAG;EAC9B,MAAM,WAAW,aAAa,IAAI;EAClC,IAAI,aAAa,KAAA,GAAW;GAC1B,QAAQ,KAAK,KAAK,IAAI;GACtB;EACF;EACA,MAAM,OAAO,kBAAkB,QAAQ;EACvC,IAAI,SAAS,KAAA,GAAW;GACtB,QAAQ,KAAK,KAAK,IAAI;GACtB;EACF;EACA,MAAM,QAAwB;GAC5B,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,KAAK;GACb,cAAc,IAAI,KAAK,IAAI,CAAC,CAAC,YAAY;GACzC,SAAS,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,QAAQ,IAAI,QAAQ,MAAM,CAAC;EAClE;EACA,CAAC,MAAM,UAAU,OAAO,aAAa,QAAQ,MAAA,CAAO,KAAK,KAAK;CAChE;CAEA,MAAM,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE;CACxE,MAAM,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE;CACxE,OAAO;EACL,MAAM,IA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