mcp-web-validator 1.3.51 → 1.3.54
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/CHANGELOG.md +55 -0
- package/README.md +64 -4
- package/dist/audit-history.d.ts +9 -0
- package/dist/audit-history.js +27 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +2508 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp-bounds.js +8 -3
- package/dist/mcp-bounds.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab-probe.d.ts +21 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +190 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -0
- package/dist/modules/browser-ux/lighthouse-lab.d.ts +61 -0
- package/dist/modules/browser-ux/lighthouse-lab.js +98 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -0
- package/dist/modules/browser-ux/media-diagnostics.d.ts +41 -0
- package/dist/modules/browser-ux/media-diagnostics.js +183 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-diff.d.ts +70 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js +262 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-probe.d.ts +17 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js +163 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures-probe.d.ts +11 -0
- package/dist/modules/browser-ux/resource-failures-probe.js +231 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures.d.ts +79 -0
- package/dist/modules/browser-ux/resource-failures.js +178 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity-probe.d.ts +5 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js +316 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity.d.ts +112 -0
- package/dist/modules/browser-ux/viewport-parity.js +224 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -0
- package/dist/modules/browser-ux/wcag-interactions.d.ts +95 -0
- package/dist/modules/browser-ux/wcag-interactions.js +360 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -0
- package/dist/modules/change-regression/availability-history-store.d.ts +18 -0
- package/dist/modules/change-regression/availability-history-store.js +168 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -0
- package/dist/modules/change-regression/crawler-log-correlation.d.ts +111 -0
- package/dist/modules/change-regression/crawler-log-correlation.js +374 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -0
- package/dist/modules/change-regression/google-common-crawler-ip.d.ts +15 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js +129 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -0
- package/dist/modules/change-regression/historical-comparisons.d.ts +120 -0
- package/dist/modules/change-regression/historical-comparisons.js +330 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -0
- package/dist/modules/change-regression/production-change-comparison.d.ts +68 -0
- package/dist/modules/change-regression/production-change-comparison.js +214 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -0
- package/dist/modules/change-regression/regression-alerts.d.ts +73 -0
- package/dist/modules/change-regression/regression-alerts.js +183 -0
- package/dist/modules/change-regression/regression-alerts.js.map +1 -0
- package/dist/modules/change-regression/strict-observation-time.d.ts +7 -0
- package/dist/modules/change-regression/strict-observation-time.js +31 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -0
- package/dist/modules/content-schema/citation-methodology-consistency.d.ts +108 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js +360 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -0
- package/dist/modules/content-schema/competitor-intent-comparison.d.ts +74 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js +185 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -0
- package/dist/modules/content-schema/empty-boilerplate-content.d.ts +36 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js +225 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -0
- package/dist/modules/content-schema/extract-citation-methodology.d.ts +6 -0
- package/dist/modules/content-schema/extract-citation-methodology.js +201 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -0
- package/dist/modules/content-schema/extract-competitor-intent.d.ts +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js +140 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -0
- package/dist/modules/content-schema/extract-main-content.d.ts +6 -0
- package/dist/modules/content-schema/extract-main-content.js +33 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -0
- package/dist/modules/content-schema/extract-metadata-consistency.d.ts +3 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js +62 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/extract-product-claims.d.ts +3 -0
- package/dist/modules/content-schema/extract-product-claims.js +58 -0
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -0
- package/dist/modules/content-schema/extract-structured-data.d.ts +3 -0
- package/dist/modules/content-schema/extract-structured-data.js +25 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -0
- package/dist/modules/content-schema/metadata-consistency.d.ts +66 -0
- package/dist/modules/content-schema/metadata-consistency.js +282 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/product-claims.d.ts +73 -0
- package/dist/modules/content-schema/product-claims.js +195 -0
- package/dist/modules/content-schema/product-claims.js.map +1 -0
- package/dist/modules/content-schema/same-language-duplicates.d.ts +52 -0
- package/dist/modules/content-schema/same-language-duplicates.js +158 -0
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -0
- package/dist/modules/content-schema/structured-data-validation.d.ts +37 -0
- package/dist/modules/content-schema/structured-data-validation.js +385 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -0
- package/dist/modules/external-metrics/crux-field-probe.d.ts +10 -0
- package/dist/modules/external-metrics/crux-field-probe.js +113 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -0
- package/dist/modules/external-metrics/crux-field.d.ts +61 -0
- package/dist/modules/external-metrics/crux-field.js +231 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -0
- package/dist/modules/http-crawl/availability-observations.d.ts +68 -0
- package/dist/modules/http-crawl/availability-observations.js +206 -0
- package/dist/modules/http-crawl/availability-observations.js.map +1 -0
- package/dist/modules/http-crawl/availability-probe.d.ts +8 -0
- package/dist/modules/http-crawl/availability-probe.js +46 -0
- package/dist/modules/http-crawl/availability-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access-probe.d.ts +6 -0
- package/dist/modules/http-crawl/crawler-access-probe.js +79 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access.d.ts +75 -0
- package/dist/modules/http-crawl/crawler-access.js +404 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery-probe.d.ts +3 -0
- package/dist/modules/http-crawl/http-delivery-probe.js +44 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery.d.ts +64 -0
- package/dist/modules/http-crawl/http-delivery.js +273 -0
- package/dist/modules/http-crawl/http-delivery.js.map +1 -0
- package/dist/modules/http-crawl/https-security.d.ts +84 -0
- package/dist/modules/http-crawl/https-security.js +441 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -0
- package/dist/modules/http-crawl/non-html-directives.d.ts +74 -0
- package/dist/modules/http-crawl/non-html-directives.js +353 -0
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.d.ts +80 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js +459 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.d.ts +6 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js +83 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.d.ts +8 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +155 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory.d.ts +107 -0
- package/dist/modules/http-crawl/sitemap-inventory.js +557 -0
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -0
- package/dist/modules/http-crawl/url-variants.d.ts +86 -0
- package/dist/modules/http-crawl/url-variants.js +379 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -0
- package/dist/modules/site-architecture/extract-internal-links.d.ts +3 -0
- package/dist/modules/site-architecture/extract-internal-links.js +88 -0
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -0
- package/dist/modules/site-architecture/extract-multilingual-page.d.ts +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js +29 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.d.ts +7 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js +116 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph.d.ts +113 -0
- package/dist/modules/site-architecture/internal-link-graph.js +414 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-quality.d.ts +77 -0
- package/dist/modules/site-architecture/internal-link-quality.js +260 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -0
- package/dist/modules/site-architecture/multilingual-clusters.d.ts +82 -0
- package/dist/modules/site-architecture/multilingual-clusters.js +363 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -0
- package/dist/network.d.ts +4 -0
- package/dist/network.js +25 -8
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +53 -0
- package/dist/presentation.js +526 -0
- package/dist/presentation.js.map +1 -1
- package/dist/screenshot.d.ts +2 -1
- package/dist/screenshot.js +4 -2
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +16 -6
- package/dist/seo-auditor.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1-07: conservative, bounded JSON-LD structural review profiles.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally NOT a full JSON-LD processor, Schema.org ontology validator,
|
|
5
|
+
* Google Rich Results Test, or eligibility/ranking prediction.
|
|
6
|
+
* No remote contexts, URLs or schema documents are resolved.
|
|
7
|
+
*/
|
|
8
|
+
import { normalizedEvidenceDate } from "./citation-methodology-consistency.js";
|
|
9
|
+
export const MAX_SUPPORTED_SCHEMA_HTML_BYTES = 250_000;
|
|
10
|
+
export const MAX_SUPPORTED_SCHEMA_SCRIPTS = 12;
|
|
11
|
+
export const MAX_SUPPORTED_SCHEMA_SCRIPT_BYTES = 64_000;
|
|
12
|
+
export const MAX_SUPPORTED_SCHEMA_NODES = 64;
|
|
13
|
+
export const MAX_SUPPORTED_SCHEMA_FINDINGS = 12;
|
|
14
|
+
export const SUPPORTED_SCHEMA_TYPES = [
|
|
15
|
+
"Article", "NewsArticle", "BlogPosting", "Product",
|
|
16
|
+
"BreadcrumbList", "FAQPage", "Organization", "WebSite",
|
|
17
|
+
];
|
|
18
|
+
const EMPTY_CONTEXT = { vocab: false, prefixes: new Set() };
|
|
19
|
+
const schemaRoot = /^https?:\/\/schema\.org\/?$/i;
|
|
20
|
+
const validType = new Set(SUPPORTED_SCHEMA_TYPES);
|
|
21
|
+
const severityOrder = { error: 0, warning: 1, info: 2 };
|
|
22
|
+
const safeProperties = new Set([
|
|
23
|
+
"@context", "@type", "@graph", "headline", "author", "datePublished", "dateModified",
|
|
24
|
+
"name", "image", "offers", "review", "aggregateRating", "price", "priceSpecification",
|
|
25
|
+
"lowPrice", "priceCurrency", "itemListElement", "item", "position", "mainEntity",
|
|
26
|
+
"acceptedAnswer", "text", "url",
|
|
27
|
+
]);
|
|
28
|
+
function obj(value) {
|
|
29
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
function values(value) {
|
|
32
|
+
return Array.isArray(value) ? value : [value];
|
|
33
|
+
}
|
|
34
|
+
function text(value) {
|
|
35
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
36
|
+
}
|
|
37
|
+
function absoluteHttp(value) {
|
|
38
|
+
if (typeof value !== "string" || value.length > 1024)
|
|
39
|
+
return false;
|
|
40
|
+
try {
|
|
41
|
+
const parsed = new URL(value);
|
|
42
|
+
return ["https:", "http:"].includes(parsed.protocol) &&
|
|
43
|
+
!!parsed.hostname && !parsed.username && !parsed.password;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function schemaContext(value, parent) {
|
|
50
|
+
if (value === undefined)
|
|
51
|
+
return parent;
|
|
52
|
+
const contexts = Array.isArray(value) ? value.slice(0, 8) : [value];
|
|
53
|
+
let vocab = false;
|
|
54
|
+
const prefixes = new Set();
|
|
55
|
+
for (const entry of contexts) {
|
|
56
|
+
if (typeof entry === "string" && schemaRoot.test(entry))
|
|
57
|
+
vocab = true;
|
|
58
|
+
if (obj(entry)) {
|
|
59
|
+
if (typeof entry["@vocab"] === "string" && schemaRoot.test(entry["@vocab"]))
|
|
60
|
+
vocab = true;
|
|
61
|
+
for (const [key, prefix] of Object.entries(entry).slice(0, 32)) {
|
|
62
|
+
if (/^[a-z][a-z0-9_-]{0,24}$/i.test(key) && typeof prefix === "string" &&
|
|
63
|
+
schemaRoot.test(prefix))
|
|
64
|
+
prefixes.add(key);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { vocab, prefixes };
|
|
69
|
+
}
|
|
70
|
+
function normalizedType(value, context) {
|
|
71
|
+
const direct = /^https?:\/\/schema\.org\/([a-zA-Z]+)$/i.exec(value)?.[1];
|
|
72
|
+
const prefixed = /^([a-z][a-z0-9_-]{0,24}):([a-zA-Z]+)$/i.exec(value);
|
|
73
|
+
const candidate = direct ?? (prefixed && context.prefixes.has(prefixed[1])
|
|
74
|
+
? prefixed[2] : context.vocab ? value : undefined);
|
|
75
|
+
return candidate && validType.has(candidate) ? candidate : undefined;
|
|
76
|
+
}
|
|
77
|
+
function validPrice(value) {
|
|
78
|
+
if (typeof value === "number")
|
|
79
|
+
return Number.isFinite(value) && value >= 0;
|
|
80
|
+
return typeof value === "string" && /^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(value.trim());
|
|
81
|
+
}
|
|
82
|
+
export function reviewSupportedJsonLd(scriptTexts, blocksSeen = scriptTexts.length) {
|
|
83
|
+
if (!Number.isSafeInteger(blocksSeen) || blocksSeen < scriptTexts.length ||
|
|
84
|
+
scriptTexts.length > MAX_SUPPORTED_SCHEMA_SCRIPTS) {
|
|
85
|
+
throw new Error("JSON-LD script sample is outside the 12-block limit.");
|
|
86
|
+
}
|
|
87
|
+
const findings = [];
|
|
88
|
+
const types = new Set();
|
|
89
|
+
let checked = 0;
|
|
90
|
+
let skipped = blocksSeen - scriptTexts.length;
|
|
91
|
+
let nodesExamined = 0;
|
|
92
|
+
let supported = 0;
|
|
93
|
+
let unsupported = 0;
|
|
94
|
+
let unknownContext = 0;
|
|
95
|
+
let hitNodeLimit = false;
|
|
96
|
+
function issue(code, severity, block, node, message, type, property) {
|
|
97
|
+
findings.push({
|
|
98
|
+
code, severity, block, node,
|
|
99
|
+
...(type ? { type } : {}),
|
|
100
|
+
...(property && safeProperties.has(property) ? { property } : {}),
|
|
101
|
+
message,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function field(record, property, type, block, node, requiredProfile = false) {
|
|
105
|
+
const value = record[property];
|
|
106
|
+
if (value === undefined || value === null || value === "") {
|
|
107
|
+
if (requiredProfile) {
|
|
108
|
+
issue("missing_profile_field", "warning", block, node, "This property is expected by the selected limited review profile; absence is not proof of invalid Schema.org markup.", type, property);
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (!text(value)) {
|
|
113
|
+
issue("invalid_field_type", "warning", block, node, "The explicit property is not a nonempty text value in the selected review profile.", type, property);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
function dateField(record, property, type, block, node) {
|
|
119
|
+
if (record[property] === undefined)
|
|
120
|
+
return;
|
|
121
|
+
if (typeof record[property] !== "string" || !normalizedEvidenceDate(record[property])) {
|
|
122
|
+
issue("invalid_date", "warning", block, node, "An explicit article date is not a calendar-valid ISO date or timezone-qualified timestamp.", type, property);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function checkProduct(record, block, node) {
|
|
126
|
+
const type = "Product";
|
|
127
|
+
field(record, "name", type, block, node, true);
|
|
128
|
+
if (record.offers === undefined && record.review === undefined && record.aggregateRating === undefined) {
|
|
129
|
+
issue("product_evidence_missing", "warning", block, node, "The limited Product snippet review profile expects offers, review or aggregateRating; no rich-result eligibility is asserted.", type);
|
|
130
|
+
}
|
|
131
|
+
if (record.offers === undefined)
|
|
132
|
+
return;
|
|
133
|
+
const offers = values(record.offers).slice(0, 8);
|
|
134
|
+
if (Array.isArray(record.offers) && record.offers.length > 8)
|
|
135
|
+
hitNodeLimit = true;
|
|
136
|
+
for (const offer of offers) {
|
|
137
|
+
if (!obj(offer)) {
|
|
138
|
+
issue("invalid_offer", "warning", block, node, "An offers entry must be a structured object for this review profile.", type, "offers");
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (text(offer["@id"]) && Object.keys(offer).length === 1) {
|
|
142
|
+
issue("reference_unresolved", "info", block, node, "The offer is a reference only; this offline review does not resolve linked graph objects.", type, "offers");
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const offerType = typeof offer["@type"] === "string" ? offer["@type"].split("/").at(-1) : undefined;
|
|
146
|
+
const priceProperty = offerType === "AggregateOffer" ? "lowPrice" : "price";
|
|
147
|
+
let candidate = offer[priceProperty];
|
|
148
|
+
if (candidate === undefined && obj(offer.priceSpecification)) {
|
|
149
|
+
candidate = offer.priceSpecification.price;
|
|
150
|
+
}
|
|
151
|
+
if (candidate === undefined) {
|
|
152
|
+
issue("missing_profile_field", "warning", block, node, "The nested offer has no observed price/lowPrice or priceSpecification.price for this review profile.", type, priceProperty);
|
|
153
|
+
}
|
|
154
|
+
else if (!validPrice(candidate)) {
|
|
155
|
+
issue("invalid_price", "warning", block, node, "The nested offer price is not a nonnegative numeric value.", type, priceProperty);
|
|
156
|
+
}
|
|
157
|
+
const currency = offer.priceCurrency ??
|
|
158
|
+
(obj(offer.priceSpecification) ? offer.priceSpecification.priceCurrency : undefined);
|
|
159
|
+
if (currency !== undefined && (typeof currency !== "string" || !/^[A-Z]{3}$/.test(currency))) {
|
|
160
|
+
issue("invalid_currency", "warning", block, node, "The explicit offer currency does not have a three-letter uppercase ISO-style code.", type, "priceCurrency");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function checkBreadcrumbs(record, block, node) {
|
|
165
|
+
const type = "BreadcrumbList";
|
|
166
|
+
const entries = record.itemListElement === undefined ? [] : values(record.itemListElement);
|
|
167
|
+
if (entries.length < 2) {
|
|
168
|
+
issue("breadcrumb_too_short", "warning", block, node, "The limited breadcrumb display profile expects at least two ListItem entries.", type, "itemListElement");
|
|
169
|
+
}
|
|
170
|
+
if (entries.length > 16)
|
|
171
|
+
hitNodeLimit = true;
|
|
172
|
+
const positions = [];
|
|
173
|
+
for (const [index, entry] of entries.slice(0, 16).entries()) {
|
|
174
|
+
if (!obj(entry)) {
|
|
175
|
+
issue("invalid_field_type", "warning", block, node, "An itemListElement entry is not a structured ListItem object.", type, "itemListElement");
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const position = entry.position;
|
|
179
|
+
if (!Number.isInteger(position) || typeof position !== "number" || position <= 0 || position > 10000) {
|
|
180
|
+
issue("breadcrumb_invalid_position", "warning", block, node, "A breadcrumb ListItem has no positive integer position.", type, "position");
|
|
181
|
+
}
|
|
182
|
+
else if (positions.includes(position)) {
|
|
183
|
+
issue("breadcrumb_duplicate_position", "warning", block, node, "Two breadcrumb ListItems share an explicit position.", type, "position");
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
positions.push(position);
|
|
187
|
+
}
|
|
188
|
+
const childName = obj(entry.item) ? entry.item.name : undefined;
|
|
189
|
+
if (!text(entry.name) && !text(childName)) {
|
|
190
|
+
issue("missing_profile_field", "warning", block, node, "A breadcrumb ListItem lacks a name in either the item or the item itself.", type, "name");
|
|
191
|
+
}
|
|
192
|
+
if (index < entries.length - 1 && entry.item === undefined) {
|
|
193
|
+
issue("breadcrumb_item_missing", "warning", block, node, "A nonfinal breadcrumb ListItem lacks an explicit item target.", type, "item");
|
|
194
|
+
}
|
|
195
|
+
if (entry.item !== undefined && !(absoluteHttp(entry.item) ||
|
|
196
|
+
(obj(entry.item) && (text(entry.item["@id"]) || text(entry.item.name))))) {
|
|
197
|
+
issue("invalid_field_type", "warning", block, node, "A breadcrumb item target is not a supported absolute URL or Thing object.", type, "item");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (positions.length >= 2 && positions.length === Math.min(entries.length, 16)) {
|
|
201
|
+
const sorted = [...positions].sort((a, b) => a - b);
|
|
202
|
+
if (sorted.some((p, i) => p !== i + 1)) {
|
|
203
|
+
issue("breadcrumb_gap", "warning", block, node, "Breadcrumb positions do not form a contiguous one-based sequence.", type, "position");
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function checkFAQ(record, block, node) {
|
|
208
|
+
const type = "FAQPage";
|
|
209
|
+
if (record.mainEntity === undefined) {
|
|
210
|
+
issue("missing_profile_field", "warning", block, node, "The limited FAQ review profile expects a mainEntity Question.", type, "mainEntity");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const questions = values(record.mainEntity);
|
|
214
|
+
if (questions.length > 16)
|
|
215
|
+
hitNodeLimit = true;
|
|
216
|
+
for (const question of questions.slice(0, 16)) {
|
|
217
|
+
if (!obj(question)) {
|
|
218
|
+
issue("faq_question_incomplete", "warning", block, node, "A mainEntity entry is not a structured Question object.", type, "mainEntity");
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (text(question["@id"]) && Object.keys(question).length === 1) {
|
|
222
|
+
issue("reference_unresolved", "info", block, node, "A Question reference is not resolved in this limited offline review.", type, "mainEntity");
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (!text(question.name)) {
|
|
226
|
+
issue("faq_question_incomplete", "warning", block, node, "The FAQ Question lacks a nonempty text name.", type, "name");
|
|
227
|
+
}
|
|
228
|
+
const answers = question.acceptedAnswer === undefined ? [] : values(question.acceptedAnswer);
|
|
229
|
+
if (answers.length === 0 || !answers.some((answer) => obj(answer) &&
|
|
230
|
+
text(answer.text))) {
|
|
231
|
+
issue("faq_question_incomplete", "warning", block, node, "The FAQ Question lacks an acceptedAnswer with a nonempty text property.", type, "acceptedAnswer");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function checkNode(record, type, block, node) {
|
|
236
|
+
switch (type) {
|
|
237
|
+
case "Article":
|
|
238
|
+
case "NewsArticle":
|
|
239
|
+
case "BlogPosting":
|
|
240
|
+
field(record, "headline", type, block, node, true); // Google recommends but does not require it.
|
|
241
|
+
if (record.author === undefined) {
|
|
242
|
+
issue("missing_profile_field", "info", block, node, "Author is a recommended Article property, not a required one.", type, "author");
|
|
243
|
+
}
|
|
244
|
+
else if (!(obj(record.author) || Array.isArray(record.author))) {
|
|
245
|
+
issue("invalid_field_type", "info", block, node, "An author is best described by a Person or Organization object for the selected review profile.", type, "author");
|
|
246
|
+
}
|
|
247
|
+
dateField(record, "datePublished", type, block, node);
|
|
248
|
+
dateField(record, "dateModified", type, block, node);
|
|
249
|
+
break;
|
|
250
|
+
case "Product":
|
|
251
|
+
checkProduct(record, block, node);
|
|
252
|
+
break;
|
|
253
|
+
case "BreadcrumbList":
|
|
254
|
+
checkBreadcrumbs(record, block, node);
|
|
255
|
+
break;
|
|
256
|
+
case "FAQPage":
|
|
257
|
+
checkFAQ(record, block, node);
|
|
258
|
+
break;
|
|
259
|
+
case "Organization":
|
|
260
|
+
case "WebSite":
|
|
261
|
+
field(record, "name", type, block, node, true);
|
|
262
|
+
if (record.url !== undefined && !absoluteHttp(record.url)) {
|
|
263
|
+
issue("invalid_field_type", "info", block, node, "The supplied URL cannot be confirmed as an absolute HTTP(S) URL in this limited profile.", type, "url");
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
for (const [index, source] of scriptTexts.entries()) {
|
|
269
|
+
const block = index + 1;
|
|
270
|
+
const size = new TextEncoder().encode(source).byteLength;
|
|
271
|
+
if (size > MAX_SUPPORTED_SCHEMA_SCRIPT_BYTES) {
|
|
272
|
+
skipped += 1;
|
|
273
|
+
issue("large_block_skipped", "info", block, 0, "This JSON-LD block exceeds the per-block parsing cap and was not inspected.");
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (!source.trim()) {
|
|
277
|
+
checked += 1;
|
|
278
|
+
issue("empty_block", "warning", block, 0, "An explicit JSON-LD block is empty.");
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
let document;
|
|
282
|
+
try {
|
|
283
|
+
document = JSON.parse(source.replace(/^\uFEFF/, ""));
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
checked += 1;
|
|
287
|
+
issue("invalid_json", "error", block, 0, "The JSON-LD block contains invalid JSON syntax; use the existing syntax checker for detailed diagnostics.");
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
checked += 1;
|
|
291
|
+
const roots = Array.isArray(document) ? document : [document];
|
|
292
|
+
if (roots.length === 0 || roots.some((value) => !obj(value))) {
|
|
293
|
+
issue("invalid_document", "error", block, 0, "The JSON-LD document root must be a nonempty object or array of objects.");
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const work = roots.map((value) => ({ value: value, context: EMPTY_CONTEXT }));
|
|
297
|
+
while (work.length > 0) {
|
|
298
|
+
if (nodesExamined >= MAX_SUPPORTED_SCHEMA_NODES) {
|
|
299
|
+
hitNodeLimit = true;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
const next = work.shift();
|
|
303
|
+
const node = ++nodesExamined;
|
|
304
|
+
const ctx = schemaContext(next.value["@context"], next.context);
|
|
305
|
+
const graph = next.value["@graph"];
|
|
306
|
+
if (graph !== undefined) {
|
|
307
|
+
const graphNodes = Array.isArray(graph) ? graph : [graph];
|
|
308
|
+
if (graphNodes.some((value) => !obj(value))) {
|
|
309
|
+
issue("invalid_graph", "warning", block, node, "The explicit @graph contains a nonobject entry; this limited reviewer did not interpret it.");
|
|
310
|
+
}
|
|
311
|
+
// Cap queued work before loading any unbounded nested graph.
|
|
312
|
+
for (const item of graphNodes) {
|
|
313
|
+
if (obj(item) && work.length < MAX_SUPPORTED_SCHEMA_NODES)
|
|
314
|
+
work.push({ value: item, context: ctx });
|
|
315
|
+
else if (obj(item))
|
|
316
|
+
hitNodeLimit = true;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const typeValue = next.value["@type"];
|
|
320
|
+
if (typeValue === undefined) {
|
|
321
|
+
if (graph === undefined && Object.keys(next.value).some((key) => !key.startsWith("@"))) {
|
|
322
|
+
unknownContext += 1;
|
|
323
|
+
issue("type_unverified", "info", block, node, "This JSON-LD node has no explicit @type for the supported review profiles.");
|
|
324
|
+
}
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
const typeNames = values(typeValue);
|
|
328
|
+
if (typeNames.length === 0 || typeNames.some((value) => typeof value !== "string")) {
|
|
329
|
+
unknownContext += 1;
|
|
330
|
+
issue("type_unverified", "info", block, node, "The JSON-LD @type is not a comparable string or array of strings.");
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
const known = new Set();
|
|
334
|
+
for (const name of typeNames.slice(0, 8)) {
|
|
335
|
+
const normalized = normalizedType(name, ctx);
|
|
336
|
+
if (normalized)
|
|
337
|
+
known.add(normalized);
|
|
338
|
+
else if (typeof name === "string" && validType.has(name)) {
|
|
339
|
+
unknownContext += 1;
|
|
340
|
+
issue("context_unverified", "info", block, node, "This known type has no supported Schema.org context, so profile checks were skipped.");
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
unsupported += 1;
|
|
344
|
+
issue("unsupported_type", "info", block, node, "A declared JSON-LD type falls outside this explicit small set of structural profiles.");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (typeNames.length > 8)
|
|
348
|
+
hitNodeLimit = true;
|
|
349
|
+
for (const kind of known) {
|
|
350
|
+
supported += 1;
|
|
351
|
+
types.add(kind);
|
|
352
|
+
checkNode(next.value, kind, block, node);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const ordered = findings.sort((a, b) => severityOrder[a.severity] - severityOrder[b.severity] ||
|
|
357
|
+
a.block - b.block || a.node - b.node || a.code.localeCompare(b.code));
|
|
358
|
+
const errors = ordered.filter((f) => f.severity === "error").length;
|
|
359
|
+
const warnings = ordered.filter((f) => f.severity === "warning").length;
|
|
360
|
+
return {
|
|
361
|
+
scope: "bounded_jsonld_structural_profiles",
|
|
362
|
+
blocks_seen: blocksSeen,
|
|
363
|
+
blocks_checked: checked,
|
|
364
|
+
blocks_skipped: skipped,
|
|
365
|
+
nodes_examined: nodesExamined,
|
|
366
|
+
supported_nodes: supported,
|
|
367
|
+
unsupported_nodes: unsupported,
|
|
368
|
+
context_unverified_nodes: unknownContext,
|
|
369
|
+
types_checked: SUPPORTED_SCHEMA_TYPES.filter((type) => types.has(type)),
|
|
370
|
+
errors, warnings, unverified: ordered.filter((f) => f.severity === "info").length,
|
|
371
|
+
coverage_limited: true,
|
|
372
|
+
limitations: [
|
|
373
|
+
"Only explicit sampled JSON-LD and a fixed small set of structural review profiles are inspected; no full JSON-LD expansion, alias resolution, external context fetching, microdata or RDFa.",
|
|
374
|
+
"Profile warnings do not prove invalid Schema.org markup; passing checks do not establish content truth, Google eligibility, rich-result display, crawlability or ranking.",
|
|
375
|
+
...(skipped || hitNodeLimit || blocksSeen > scriptTexts.length
|
|
376
|
+
? ["A parsing or sampling cap was reached; excluded declarations remain unverified."] : []),
|
|
377
|
+
...(unsupported || unknownContext
|
|
378
|
+
? ["Unknown types or contexts are not evaluated; use a complete standards-aware validator for those types."] : []),
|
|
379
|
+
],
|
|
380
|
+
total_findings: ordered.length,
|
|
381
|
+
findings: ordered.slice(0, MAX_SUPPORTED_SCHEMA_FINDINGS),
|
|
382
|
+
findings_truncated: ordered.length > MAX_SUPPORTED_SCHEMA_FINDINGS,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=structured-data-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-data-validation.js","sourceRoot":"","sources":["../../../src/modules/content-schema/structured-data-validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,MAAM,CAAC,MAAM,+BAA+B,GAAG,OAAO,CAAC;AACvD,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,sBA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Q,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;IACxE,OAAO;QACL,KAAK,EAAE,oCAAoC;QAC3C,WAAW,EAAE,UAAU;QACvB,cAAc,EAAE,OAAO;QACvB,cAAc,EAAE,OAAO;QACvB,cAAc,EAAE,aAAa;QAC7B,eAAe,EAAE,SAAS;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,wBAAwB,EAAE,cAAc;QACxC,aAAa,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;QACjF,gBAAgB,EAAE,IAAI;QACtB,WAAW,EAAE;YACX,6LAA6L;YAC7L,2KAA2K;YAC3K,GAAG,CAAC,OAAO,IAAI,YAAY,IAAI,UAAU,GAAG,WAAW,CAAC,MAAM;gBAC5D,CAAC,CAAC,CAAC,iFAAiF,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7F,GAAG,CAAC,WAAW,IAAI,cAAc;gBAC/B,CAAC,CAAC,CAAC,wGAAwG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACrH;QACD,cAAc,EAAE,OAAO,CAAC,MAAM;QAC9B,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,6BAA6B,CAAC;QACzD,kBAAkB,EAAE,OAAO,CAAC,MAAM,GAAG,6BAA6B;KACnE,CAAC;AACJ,CAAC","sourcesContent":["/**\n * P1-07: conservative, bounded JSON-LD structural review profiles.\n *\n * Intentionally NOT a full JSON-LD processor, Schema.org ontology validator,\n * Google Rich Results Test, or eligibility/ranking prediction.\n * No remote contexts, URLs or schema documents are resolved.\n */\nimport { normalizedEvidenceDate } from \"./citation-methodology-consistency.js\";\n\nexport const MAX_SUPPORTED_SCHEMA_HTML_BYTES = 250_000;\nexport const MAX_SUPPORTED_SCHEMA_SCRIPTS = 12;\nexport const MAX_SUPPORTED_SCHEMA_SCRIPT_BYTES = 64_000;\nexport const MAX_SUPPORTED_SCHEMA_NODES = 64;\nexport const MAX_SUPPORTED_SCHEMA_FINDINGS = 12;\n\nexport const SUPPORTED_SCHEMA_TYPES = [\n \"Article\", \"NewsArticle\", \"BlogPosting\", \"Product\",\n \"BreadcrumbList\", \"FAQPage\", \"Organization\", \"WebSite\",\n] as const;\nexport type SupportedSchemaType = typeof SUPPORTED_SCHEMA_TYPES[number];\nexport type SchemaFindingCode =\n | \"empty_block\" | \"invalid_json\" | \"invalid_document\" | \"invalid_graph\"\n | \"large_block_skipped\" | \"context_unverified\" | \"type_unverified\"\n | \"unsupported_type\" | \"missing_profile_field\" | \"invalid_field_type\"\n | \"invalid_date\" | \"product_evidence_missing\" | \"invalid_offer\"\n | \"invalid_price\" | \"invalid_currency\" | \"breadcrumb_too_short\"\n | \"breadcrumb_invalid_position\" | \"breadcrumb_duplicate_position\"\n | \"breadcrumb_gap\" | \"breadcrumb_item_missing\"\n | \"faq_question_incomplete\" | \"reference_unresolved\";\n\nexport interface StructuredSchemaFinding {\n code: SchemaFindingCode;\n severity: \"error\" | \"warning\" | \"info\";\n block: number;\n node: number;\n type?: SupportedSchemaType;\n property?: string;\n message: string;\n}\n\nexport interface SupportedSchemaReview {\n scope: \"bounded_jsonld_structural_profiles\";\n blocks_seen: number;\n blocks_checked: number;\n blocks_skipped: number;\n nodes_examined: number;\n supported_nodes: number;\n unsupported_nodes: number;\n context_unverified_nodes: number;\n types_checked: SupportedSchemaType[];\n errors: number;\n warnings: number;\n unverified: number;\n coverage_limited: boolean;\n limitations: string[];\n total_findings: number;\n findings: StructuredSchemaFinding[];\n findings_truncated: boolean;\n}\n\ntype JsonRecord = Record<string, unknown>;\ntype Context = { vocab: boolean; prefixes: ReadonlySet<string> };\nconst EMPTY_CONTEXT: Context = { vocab: false, prefixes: new Set<string>() };\nconst schemaRoot = /^https?:\\/\\/schema\\.org\\/?$/i;\nconst validType = new Set<string>(SUPPORTED_SCHEMA_TYPES);\nconst severityOrder = { error: 0, warning: 1, info: 2 } as const;\nconst safeProperties = new Set([\n \"@context\", \"@type\", \"@graph\", \"headline\", \"author\", \"datePublished\", \"dateModified\",\n \"name\", \"image\", \"offers\", \"review\", \"aggregateRating\", \"price\", \"priceSpecification\",\n \"lowPrice\", \"priceCurrency\", \"itemListElement\", \"item\", \"position\", \"mainEntity\",\n \"acceptedAnswer\", \"text\", \"url\",\n]);\n\nfunction obj(value: unknown): value is JsonRecord {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\nfunction values(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [value];\n}\nfunction text(value: unknown): boolean {\n return typeof value === \"string\" && value.trim().length > 0;\n}\nfunction absoluteHttp(value: unknown): boolean {\n if (typeof value !== \"string\" || value.length > 1024) return false;\n try {\n const parsed = new URL(value);\n return [\"https:\", \"http:\"].includes(parsed.protocol) &&\n !!parsed.hostname && !parsed.username && !parsed.password;\n } catch {\n return false;\n }\n}\nfunction schemaContext(value: unknown, parent: Context): Context {\n if (value === undefined) return parent;\n const contexts = Array.isArray(value) ? value.slice(0, 8) : [value];\n let vocab = false;\n const prefixes = new Set<string>();\n for (const entry of contexts) {\n if (typeof entry === \"string\" && schemaRoot.test(entry)) vocab = true;\n if (obj(entry)) {\n if (typeof entry[\"@vocab\"] === \"string\" && schemaRoot.test(entry[\"@vocab\"])) vocab = true;\n for (const [key, prefix] of Object.entries(entry).slice(0, 32)) {\n if (/^[a-z][a-z0-9_-]{0,24}$/i.test(key) && typeof prefix === \"string\" &&\n schemaRoot.test(prefix)) prefixes.add(key);\n }\n }\n }\n return { vocab, prefixes };\n}\nfunction normalizedType(value: string, context: Context): SupportedSchemaType | undefined {\n const direct = /^https?:\\/\\/schema\\.org\\/([a-zA-Z]+)$/i.exec(value)?.[1];\n const prefixed = /^([a-z][a-z0-9_-]{0,24}):([a-zA-Z]+)$/i.exec(value);\n const candidate = direct ?? (prefixed && context.prefixes.has(prefixed[1])\n ? prefixed[2] : context.vocab ? value : undefined);\n return candidate && validType.has(candidate) ? candidate as SupportedSchemaType : undefined;\n}\nfunction validPrice(value: unknown): boolean {\n if (typeof value === \"number\") return Number.isFinite(value) && value >= 0;\n return typeof value === \"string\" && /^(?:0|[1-9]\\d*)(?:\\.\\d+)?$/.test(value.trim());\n}\n\nexport function reviewSupportedJsonLd(scriptTexts: readonly string[], blocksSeen = scriptTexts.length): SupportedSchemaReview {\n if (!Number.isSafeInteger(blocksSeen) || blocksSeen < scriptTexts.length ||\n scriptTexts.length > MAX_SUPPORTED_SCHEMA_SCRIPTS) {\n throw new Error(\"JSON-LD script sample is outside the 12-block limit.\");\n }\n const findings: StructuredSchemaFinding[] = [];\n const types = new Set<SupportedSchemaType>();\n let checked = 0;\n let skipped = blocksSeen - scriptTexts.length;\n let nodesExamined = 0;\n let supported = 0;\n let unsupported = 0;\n let unknownContext = 0;\n let hitNodeLimit = false;\n\n function issue(code: SchemaFindingCode, severity: StructuredSchemaFinding[\"severity\"],\n block: number, node: number, message: string, type?: SupportedSchemaType, property?: string) {\n findings.push({\n code, severity, block, node,\n ...(type ? { type } : {}),\n ...(property && safeProperties.has(property) ? { property } : {}),\n message,\n });\n }\n function field(record: JsonRecord, property: string, type: SupportedSchemaType,\n block: number, node: number, requiredProfile = false) {\n const value = record[property];\n if (value === undefined || value === null || value === \"\") {\n if (requiredProfile) {\n issue(\"missing_profile_field\", \"warning\", block, node,\n \"This property is expected by the selected limited review profile; absence is not proof of invalid Schema.org markup.\", type, property);\n }\n return false;\n }\n if (!text(value)) {\n issue(\"invalid_field_type\", \"warning\", block, node,\n \"The explicit property is not a nonempty text value in the selected review profile.\", type, property);\n return false;\n }\n return true;\n }\n function dateField(record: JsonRecord, property: \"datePublished\" | \"dateModified\",\n type: SupportedSchemaType, block: number, node: number) {\n if (record[property] === undefined) return;\n if (typeof record[property] !== \"string\" || !normalizedEvidenceDate(record[property])) {\n issue(\"invalid_date\", \"warning\", block, node,\n \"An explicit article date is not a calendar-valid ISO date or timezone-qualified timestamp.\", type, property);\n }\n }\n function checkProduct(record: JsonRecord, block: number, node: number) {\n const type = \"Product\" as const;\n field(record, \"name\", type, block, node, true);\n if (record.offers === undefined && record.review === undefined && record.aggregateRating === undefined) {\n issue(\"product_evidence_missing\", \"warning\", block, node,\n \"The limited Product snippet review profile expects offers, review or aggregateRating; no rich-result eligibility is asserted.\", type);\n }\n if (record.offers === undefined) return;\n const offers = values(record.offers).slice(0, 8);\n if (Array.isArray(record.offers) && record.offers.length > 8) hitNodeLimit = true;\n for (const offer of offers) {\n if (!obj(offer)) {\n issue(\"invalid_offer\", \"warning\", block, node,\n \"An offers entry must be a structured object for this review profile.\", type, \"offers\");\n continue;\n }\n if (text(offer[\"@id\"]) && Object.keys(offer).length === 1) {\n issue(\"reference_unresolved\", \"info\", block, node,\n \"The offer is a reference only; this offline review does not resolve linked graph objects.\", type, \"offers\");\n continue;\n }\n const offerType = typeof offer[\"@type\"] === \"string\" ? offer[\"@type\"].split(\"/\").at(-1) : undefined;\n const priceProperty = offerType === \"AggregateOffer\" ? \"lowPrice\" : \"price\";\n let candidate: unknown = offer[priceProperty];\n if (candidate === undefined && obj(offer.priceSpecification)) {\n candidate = offer.priceSpecification.price;\n }\n if (candidate === undefined) {\n issue(\"missing_profile_field\", \"warning\", block, node,\n \"The nested offer has no observed price/lowPrice or priceSpecification.price for this review profile.\", type, priceProperty);\n } else if (!validPrice(candidate)) {\n issue(\"invalid_price\", \"warning\", block, node,\n \"The nested offer price is not a nonnegative numeric value.\", type, priceProperty);\n }\n const currency = offer.priceCurrency ??\n (obj(offer.priceSpecification) ? offer.priceSpecification.priceCurrency : undefined);\n if (currency !== undefined && (typeof currency !== \"string\" || !/^[A-Z]{3}$/.test(currency))) {\n issue(\"invalid_currency\", \"warning\", block, node,\n \"The explicit offer currency does not have a three-letter uppercase ISO-style code.\", type, \"priceCurrency\");\n }\n }\n }\n function checkBreadcrumbs(record: JsonRecord, block: number, node: number) {\n const type = \"BreadcrumbList\" as const;\n const entries = record.itemListElement === undefined ? [] : values(record.itemListElement);\n if (entries.length < 2) {\n issue(\"breadcrumb_too_short\", \"warning\", block, node,\n \"The limited breadcrumb display profile expects at least two ListItem entries.\", type, \"itemListElement\");\n }\n if (entries.length > 16) hitNodeLimit = true;\n const positions: number[] = [];\n for (const [index, entry] of entries.slice(0, 16).entries()) {\n if (!obj(entry)) {\n issue(\"invalid_field_type\", \"warning\", block, node,\n \"An itemListElement entry is not a structured ListItem object.\", type, \"itemListElement\");\n continue;\n }\n const position = entry.position;\n if (!Number.isInteger(position) || typeof position !== \"number\" || position <= 0 || position > 10000) {\n issue(\"breadcrumb_invalid_position\", \"warning\", block, node,\n \"A breadcrumb ListItem has no positive integer position.\", type, \"position\");\n } else if (positions.includes(position)) {\n issue(\"breadcrumb_duplicate_position\", \"warning\", block, node,\n \"Two breadcrumb ListItems share an explicit position.\", type, \"position\");\n } else {\n positions.push(position);\n }\n const childName = obj(entry.item) ? entry.item.name : undefined;\n if (!text(entry.name) && !text(childName)) {\n issue(\"missing_profile_field\", \"warning\", block, node,\n \"A breadcrumb ListItem lacks a name in either the item or the item itself.\", type, \"name\");\n }\n if (index < entries.length - 1 && entry.item === undefined) {\n issue(\"breadcrumb_item_missing\", \"warning\", block, node,\n \"A nonfinal breadcrumb ListItem lacks an explicit item target.\", type, \"item\");\n }\n if (entry.item !== undefined && !(absoluteHttp(entry.item) ||\n (obj(entry.item) && (text(entry.item[\"@id\"]) || text(entry.item.name))))) {\n issue(\"invalid_field_type\", \"warning\", block, node,\n \"A breadcrumb item target is not a supported absolute URL or Thing object.\", type, \"item\");\n }\n }\n if (positions.length >= 2 && positions.length === Math.min(entries.length, 16)) {\n const sorted = [...positions].sort((a, b) => a - b);\n if (sorted.some((p, i) => p !== i + 1)) {\n issue(\"breadcrumb_gap\", \"warning\", block, node,\n \"Breadcrumb positions do not form a contiguous one-based sequence.\", type, \"position\");\n }\n }\n }\n function checkFAQ(record: JsonRecord, block: number, node: number) {\n const type = \"FAQPage\" as const;\n if (record.mainEntity === undefined) {\n issue(\"missing_profile_field\", \"warning\", block, node,\n \"The limited FAQ review profile expects a mainEntity Question.\", type, \"mainEntity\");\n return;\n }\n const questions = values(record.mainEntity);\n if (questions.length > 16) hitNodeLimit = true;\n for (const question of questions.slice(0, 16)) {\n if (!obj(question)) {\n issue(\"faq_question_incomplete\", \"warning\", block, node,\n \"A mainEntity entry is not a structured Question object.\", type, \"mainEntity\");\n continue;\n }\n if (text(question[\"@id\"]) && Object.keys(question).length === 1) {\n issue(\"reference_unresolved\", \"info\", block, node,\n \"A Question reference is not resolved in this limited offline review.\", type, \"mainEntity\");\n continue;\n }\n if (!text(question.name)) {\n issue(\"faq_question_incomplete\", \"warning\", block, node,\n \"The FAQ Question lacks a nonempty text name.\", type, \"name\");\n }\n const answers = question.acceptedAnswer === undefined ? [] : values(question.acceptedAnswer);\n if (answers.length === 0 || !answers.some((answer) => obj(answer) &&\n text(answer.text))) {\n issue(\"faq_question_incomplete\", \"warning\", block, node,\n \"The FAQ Question lacks an acceptedAnswer with a nonempty text property.\", type, \"acceptedAnswer\");\n }\n }\n }\n function checkNode(record: JsonRecord, type: SupportedSchemaType, block: number, node: number) {\n switch (type) {\n case \"Article\":\n case \"NewsArticle\":\n case \"BlogPosting\":\n field(record, \"headline\", type, block, node, true); // Google recommends but does not require it.\n if (record.author === undefined) {\n issue(\"missing_profile_field\", \"info\", block, node,\n \"Author is a recommended Article property, not a required one.\", type, \"author\");\n } else if (!(obj(record.author) || Array.isArray(record.author))) {\n issue(\"invalid_field_type\", \"info\", block, node,\n \"An author is best described by a Person or Organization object for the selected review profile.\", type, \"author\");\n }\n dateField(record, \"datePublished\", type, block, node);\n dateField(record, \"dateModified\", type, block, node);\n break;\n case \"Product\":\n checkProduct(record, block, node);\n break;\n case \"BreadcrumbList\":\n checkBreadcrumbs(record, block, node);\n break;\n case \"FAQPage\":\n checkFAQ(record, block, node);\n break;\n case \"Organization\":\n case \"WebSite\":\n field(record, \"name\", type, block, node, true);\n if (record.url !== undefined && !absoluteHttp(record.url)) {\n issue(\"invalid_field_type\", \"info\", block, node,\n \"The supplied URL cannot be confirmed as an absolute HTTP(S) URL in this limited profile.\", type, \"url\");\n }\n break;\n }\n }\n for (const [index, source] of scriptTexts.entries()) {\n const block = index + 1;\n const size = new TextEncoder().encode(source).byteLength;\n if (size > MAX_SUPPORTED_SCHEMA_SCRIPT_BYTES) {\n skipped += 1;\n issue(\"large_block_skipped\", \"info\", block, 0,\n \"This JSON-LD block exceeds the per-block parsing cap and was not inspected.\");\n continue;\n }\n if (!source.trim()) {\n checked += 1;\n issue(\"empty_block\", \"warning\", block, 0,\n \"An explicit JSON-LD block is empty.\");\n continue;\n }\n let document: unknown;\n try {\n document = JSON.parse(source.replace(/^\\uFEFF/, \"\"));\n } catch {\n checked += 1;\n issue(\"invalid_json\", \"error\", block, 0,\n \"The JSON-LD block contains invalid JSON syntax; use the existing syntax checker for detailed diagnostics.\");\n continue;\n }\n checked += 1;\n const roots = Array.isArray(document) ? document : [document];\n if (roots.length === 0 || roots.some((value) => !obj(value))) {\n issue(\"invalid_document\", \"error\", block, 0,\n \"The JSON-LD document root must be a nonempty object or array of objects.\");\n continue;\n }\n const work: Array<{ value: JsonRecord; context: Context }> =\n roots.map((value) => ({ value: value as JsonRecord, context: EMPTY_CONTEXT }));\n while (work.length > 0) {\n if (nodesExamined >= MAX_SUPPORTED_SCHEMA_NODES) {\n hitNodeLimit = true;\n break;\n }\n const next = work.shift()!;\n const node = ++nodesExamined;\n const ctx = schemaContext(next.value[\"@context\"], next.context);\n const graph = next.value[\"@graph\"];\n if (graph !== undefined) {\n const graphNodes = Array.isArray(graph) ? graph : [graph];\n if (graphNodes.some((value) => !obj(value))) {\n issue(\"invalid_graph\", \"warning\", block, node,\n \"The explicit @graph contains a nonobject entry; this limited reviewer did not interpret it.\");\n }\n // Cap queued work before loading any unbounded nested graph.\n for (const item of graphNodes) {\n if (obj(item) && work.length < MAX_SUPPORTED_SCHEMA_NODES) work.push({ value: item, context: ctx });\n else if (obj(item)) hitNodeLimit = true;\n }\n }\n const typeValue = next.value[\"@type\"];\n if (typeValue === undefined) {\n if (graph === undefined && Object.keys(next.value).some((key) => !key.startsWith(\"@\"))) {\n unknownContext += 1;\n issue(\"type_unverified\", \"info\", block, node,\n \"This JSON-LD node has no explicit @type for the supported review profiles.\");\n }\n continue;\n }\n const typeNames = values(typeValue);\n if (typeNames.length === 0 || typeNames.some((value) => typeof value !== \"string\")) {\n unknownContext += 1;\n issue(\"type_unverified\", \"info\", block, node,\n \"The JSON-LD @type is not a comparable string or array of strings.\");\n continue;\n }\n const known = new Set<SupportedSchemaType>();\n for (const name of typeNames.slice(0, 8)) {\n const normalized = normalizedType(name as string, ctx);\n if (normalized) known.add(normalized);\n else if (typeof name === \"string\" && validType.has(name)) {\n unknownContext += 1;\n issue(\"context_unverified\", \"info\", block, node,\n \"This known type has no supported Schema.org context, so profile checks were skipped.\");\n } else {\n unsupported += 1;\n issue(\"unsupported_type\", \"info\", block, node,\n \"A declared JSON-LD type falls outside this explicit small set of structural profiles.\");\n }\n }\n if (typeNames.length > 8) hitNodeLimit = true;\n for (const kind of known) {\n supported += 1;\n types.add(kind);\n checkNode(next.value, kind, block, node);\n }\n }\n }\n const ordered = findings.sort((a, b) =>\n severityOrder[a.severity] - severityOrder[b.severity] ||\n a.block - b.block || a.node - b.node || a.code.localeCompare(b.code));\n const errors = ordered.filter((f) => f.severity === \"error\").length;\n const warnings = ordered.filter((f) => f.severity === \"warning\").length;\n return {\n scope: \"bounded_jsonld_structural_profiles\",\n blocks_seen: blocksSeen,\n blocks_checked: checked,\n blocks_skipped: skipped,\n nodes_examined: nodesExamined,\n supported_nodes: supported,\n unsupported_nodes: unsupported,\n context_unverified_nodes: unknownContext,\n types_checked: SUPPORTED_SCHEMA_TYPES.filter((type) => types.has(type)),\n errors, warnings, unverified: ordered.filter((f) => f.severity === \"info\").length,\n coverage_limited: true,\n limitations: [\n \"Only explicit sampled JSON-LD and a fixed small set of structural review profiles are inspected; no full JSON-LD expansion, alias resolution, external context fetching, microdata or RDFa.\",\n \"Profile warnings do not prove invalid Schema.org markup; passing checks do not establish content truth, Google eligibility, rich-result display, crawlability or ranking.\",\n ...(skipped || hitNodeLimit || blocksSeen > scriptTexts.length\n ? [\"A parsing or sampling cap was reached; excluded declarations remain unverified.\"] : []),\n ...(unsupported || unknownContext\n ? [\"Unknown types or contexts are not evaluated; use a complete standards-aware validator for those types.\"] : []),\n ],\n total_findings: ordered.length,\n findings: ordered.slice(0, MAX_SUPPORTED_SCHEMA_FINDINGS),\n findings_truncated: ordered.length > MAX_SUPPORTED_SCHEMA_FINDINGS,\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** V11-FIELD: opt-in fixed Google CrUX API client; no target-URL fetch. */
|
|
2
|
+
import { type CruxFieldReview, type CruxQuery } from "./crux-field.js";
|
|
3
|
+
export declare const CRUX_TIMEOUT_MS = 12000;
|
|
4
|
+
export declare class CruxRequestError extends Error {
|
|
5
|
+
readonly code: "missing_key" | "rate_limited" | "access_denied" | "api_unavailable" | "invalid_response";
|
|
6
|
+
constructor(code: "missing_key" | "rate_limited" | "access_denied" | "api_unavailable" | "invalid_response");
|
|
7
|
+
}
|
|
8
|
+
type FetchFunction = (url: string, options: RequestInit) => Promise<Response>;
|
|
9
|
+
export declare function queryCruxField(query: CruxQuery, fetchFn?: FetchFunction, apiKey?: string | undefined): Promise<CruxFieldReview>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** V11-FIELD: opt-in fixed Google CrUX API client; no target-URL fetch. */
|
|
2
|
+
import { analyzeCruxField, emptyCruxFieldReview, validateCruxQuery, MAX_CRUX_RESPONSE_BYTES, CRUX_METRICS, } from "./crux-field.js";
|
|
3
|
+
const ENDPOINT = "https://chromeuxreport.googleapis.com/v1/records:";
|
|
4
|
+
export const CRUX_TIMEOUT_MS = 12_000;
|
|
5
|
+
export class CruxRequestError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(code) {
|
|
8
|
+
super("CrUX request unavailable: " + code);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = "CruxRequestError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async function jsonBounded(response) {
|
|
14
|
+
const type = response.headers.get("content-type")?.split(";", 1)[0].trim().toLowerCase();
|
|
15
|
+
if (type !== "application/json")
|
|
16
|
+
throw new CruxRequestError("invalid_response");
|
|
17
|
+
const declared = Number(response.headers.get("content-length"));
|
|
18
|
+
if (Number.isFinite(declared) && declared > MAX_CRUX_RESPONSE_BYTES)
|
|
19
|
+
throw new CruxRequestError("invalid_response");
|
|
20
|
+
if (!response.body)
|
|
21
|
+
throw new CruxRequestError("invalid_response");
|
|
22
|
+
const reader = response.body.getReader();
|
|
23
|
+
const chunks = [];
|
|
24
|
+
let total = 0;
|
|
25
|
+
try {
|
|
26
|
+
while (true) {
|
|
27
|
+
const { done, value } = await reader.read();
|
|
28
|
+
if (done)
|
|
29
|
+
break;
|
|
30
|
+
total += value.byteLength;
|
|
31
|
+
if (total > MAX_CRUX_RESPONSE_BYTES)
|
|
32
|
+
throw new CruxRequestError("invalid_response");
|
|
33
|
+
chunks.push(value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
try {
|
|
38
|
+
await reader.cancel();
|
|
39
|
+
}
|
|
40
|
+
catch { /* Reader already closed. */ }
|
|
41
|
+
reader.releaseLock();
|
|
42
|
+
}
|
|
43
|
+
const merged = new Uint8Array(total);
|
|
44
|
+
let offset = 0;
|
|
45
|
+
for (const chunk of chunks) {
|
|
46
|
+
merged.set(chunk, offset);
|
|
47
|
+
offset += chunk.byteLength;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(merged));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new CruxRequestError("invalid_response");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function queryCruxField(query, fetchFn = (url, opts) => fetch(url, opts), apiKey = process.env.CRUX_API_KEY) {
|
|
57
|
+
const q = validateCruxQuery(query);
|
|
58
|
+
if (!apiKey || !/^[-_A-Za-z0-9]{15,150}$/u.test(apiKey))
|
|
59
|
+
throw new CruxRequestError("missing_key");
|
|
60
|
+
const endpoint = ENDPOINT + (q.mode === "daily" ? "queryRecord" : "queryHistoryRecord");
|
|
61
|
+
const url = endpoint + "?" + new URLSearchParams({ key: apiKey }).toString();
|
|
62
|
+
const body = {
|
|
63
|
+
[q.granularity]: q.target,
|
|
64
|
+
metrics: [...CRUX_METRICS],
|
|
65
|
+
};
|
|
66
|
+
if (q.form_factor !== "ALL")
|
|
67
|
+
body.formFactor = q.form_factor;
|
|
68
|
+
if (q.mode === "history")
|
|
69
|
+
body.collectionPeriodCount = 40;
|
|
70
|
+
let response;
|
|
71
|
+
try {
|
|
72
|
+
response = await fetchFn(url, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: { "Content-Type": "application/json", "Accept": "application/json" },
|
|
75
|
+
body: JSON.stringify(body),
|
|
76
|
+
signal: AbortSignal.timeout(CRUX_TIMEOUT_MS),
|
|
77
|
+
redirect: "error", credentials: "omit", cache: "no-store",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new CruxRequestError("api_unavailable");
|
|
82
|
+
}
|
|
83
|
+
if (response.redirected)
|
|
84
|
+
throw new CruxRequestError("api_unavailable");
|
|
85
|
+
if (response.status === 404) {
|
|
86
|
+
try {
|
|
87
|
+
await response.body?.cancel();
|
|
88
|
+
}
|
|
89
|
+
catch { /* no body */ }
|
|
90
|
+
const empty = emptyCruxFieldReview(q.mode, "verified_crux_api", q.granularity, q.form_factor);
|
|
91
|
+
empty.error = "No eligible CrUX field data is available for this requested population.";
|
|
92
|
+
return empty;
|
|
93
|
+
}
|
|
94
|
+
if (response.status !== 200 || !response.ok) {
|
|
95
|
+
try {
|
|
96
|
+
await response.body?.cancel();
|
|
97
|
+
}
|
|
98
|
+
catch { /* Remote body not needed. */ }
|
|
99
|
+
if (response.status === 429)
|
|
100
|
+
throw new CruxRequestError("rate_limited");
|
|
101
|
+
if (response.status === 401 || response.status === 403)
|
|
102
|
+
throw new CruxRequestError("access_denied");
|
|
103
|
+
throw new CruxRequestError("api_unavailable");
|
|
104
|
+
}
|
|
105
|
+
const parsed = await jsonBounded(response);
|
|
106
|
+
try {
|
|
107
|
+
return analyzeCruxField(parsed, q, "verified_crux_api");
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
throw new CruxRequestError("invalid_response");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=crux-field-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crux-field-probe.js","sourceRoot":"","sources":["../../../src/modules/external-metrics/crux-field-probe.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,EACL,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EACzD,uBAAuB,EAAE,YAAY,GACtC,MAAM,iBAAiB,CAAC;AACzB,MAAM,QAAQ,GAAG,mDAAmD,CAAC;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACpB,IAAI;IAAzB,YAAqB,IAAsF;QACzG,KAAK,CAAC,4BAA4B,GAAC,IAAI,CAAC,CAAC;oBADtB,IAAI;QAEvB,IAAI,CAAC,IAAI,GAAC,kBAAkB,CAAC;IAC/B,CAAC;CACF;AACD,KAA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K,GAAC,yEAAyE,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAG,QAAQ,CAAC,MAAM,KAAG,GAAG,IAAE,CAAC,QAAQ,CAAC,EAAE,EAAC,CAAC;QACtC,IAAG,CAAC;YAAA,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAA,CAAC;QAAA,MAAK,CAAC,CAAA,6BAA6B,CAAA,CAAC;QACvE,IAAG,QAAQ,CAAC,MAAM,KAAG,GAAG;YAAC,MAAM,IAAI,gBAAgB,CAAC,cAAc,CAAC,CAAC;QACpE,IAAG,QAAQ,CAAC,MAAM,KAAG,GAAG,IAAE,QAAQ,CAAC,MAAM,KAAG,GAAG;YAAC,MAAM,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC;QAC5F,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,MAAM,GAAC,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAG,CAAC;QAAA,OAAO,gBAAgB,CAAC,MAAM,EAAC,CAAC,EAAC,mBAAmB,CAAC,CAAC;IAAA,CAAC;IAC3D,MAAK,CAAC;QAAA,MAAM,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAAA,CAAC;AACxD,CAAC","sourcesContent":["/** V11-FIELD: opt-in fixed Google CrUX API client; no target-URL fetch. */\nimport {\n analyzeCruxField, emptyCruxFieldReview, validateCruxQuery,\n MAX_CRUX_RESPONSE_BYTES, CRUX_METRICS, type CruxFieldReview, type CruxQuery,\n} from \"./crux-field.js\";\nconst ENDPOINT = \"https://chromeuxreport.googleapis.com/v1/records:\";\nexport const CRUX_TIMEOUT_MS = 12_000;\nexport class CruxRequestError extends Error {\n constructor(readonly code:\"missing_key\"|\"rate_limited\"|\"access_denied\"|\"api_unavailable\"|\"invalid_response\") {\n super(\"CrUX request unavailable: \"+code);\n this.name=\"CruxRequestError\";\n }\n}\nasync function jsonBounded(response:Response):Promise<unknown> {\n const type=response.headers.get(\"content-type\")?.split(\";\",1)[0].trim().toLowerCase();\n if(type!==\"application/json\")throw new CruxRequestError(\"invalid_response\");\n const declared=Number(response.headers.get(\"content-length\"));\n if(Number.isFinite(declared)&&declared>MAX_CRUX_RESPONSE_BYTES)\n throw new CruxRequestError(\"invalid_response\");\n if(!response.body)throw new CruxRequestError(\"invalid_response\");\n const reader=response.body.getReader();\n const chunks:Uint8Array[]=[];\n let total=0;\n try{\n while(true){\n const {done,value}=await reader.read();\n if(done)break;\n total+=value.byteLength;\n if(total>MAX_CRUX_RESPONSE_BYTES)throw new CruxRequestError(\"invalid_response\");\n chunks.push(value);\n }\n }finally{try{await reader.cancel();}catch{/* Reader already closed. */}reader.releaseLock();}\n const merged=new Uint8Array(total);\n let offset=0;\n for(const chunk of chunks){merged.set(chunk,offset);offset+=chunk.byteLength;}\n try{return JSON.parse(new TextDecoder(\"utf-8\",{fatal:true}).decode(merged));}\n catch{throw new CruxRequestError(\"invalid_response\");}\n}\ntype FetchFunction=(url:string,options:RequestInit)=>Promise<Response>;\nexport async function queryCruxField(\n query:CruxQuery,\n fetchFn:FetchFunction=(url,opts)=>fetch(url,opts),\n apiKey:string|undefined=process.env.CRUX_API_KEY,\n):Promise<CruxFieldReview>{\n const q=validateCruxQuery(query);\n if(!apiKey||!/^[-_A-Za-z0-9]{15,150}$/u.test(apiKey))\n throw new CruxRequestError(\"missing_key\");\n const endpoint=ENDPOINT+(q.mode===\"daily\"?\"queryRecord\":\"queryHistoryRecord\");\n const url=endpoint+\"?\"+new URLSearchParams({key:apiKey}).toString();\n const body:Record<string,unknown>={\n [q.granularity]:q.target,\n metrics:[...CRUX_METRICS],\n };\n if(q.form_factor!==\"ALL\")body.formFactor=q.form_factor;\n if(q.mode===\"history\")body.collectionPeriodCount=40;\n let response:Response;\n try{\n response=await fetchFn(url,{\n method:\"POST\",\n headers:{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"},\n body:JSON.stringify(body),\n signal:AbortSignal.timeout(CRUX_TIMEOUT_MS),\n redirect:\"error\",credentials:\"omit\",cache:\"no-store\",\n });\n }catch{throw new CruxRequestError(\"api_unavailable\");}\n if(response.redirected)throw new CruxRequestError(\"api_unavailable\");\n if(response.status===404) {\n try{await response.body?.cancel();}catch{/* no body */ }\n const empty=emptyCruxFieldReview(q.mode,\"verified_crux_api\",q.granularity,q.form_factor);\n empty.error=\"No eligible CrUX field data is available for this requested population.\";\n return empty;\n }\n if(response.status!==200||!response.ok){\n try{await response.body?.cancel();}catch{/* Remote body not needed. */}\n if(response.status===429)throw new CruxRequestError(\"rate_limited\");\n if(response.status===401||response.status===403)throw new CruxRequestError(\"access_denied\");\n throw new CruxRequestError(\"api_unavailable\");\n }\n const parsed=await jsonBounded(response);\n try{return analyzeCruxField(parsed,q,\"verified_crux_api\");}\n catch{throw new CruxRequestError(\"invalid_response\");}\n}\n"]}
|