// Generated by scripts/generate-extraction-validators.mjs. Do not hand-edit. const SCHEMAS = { "build-plan": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/build-plan.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "pageKey", "route", "manifestHash", "status", "units" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "build-plan" }, "pageKey": { "const": "home" }, "route": { "const": "/" }, "manifestHash": { "type": "string" }, "status": { "enum": [ "accepted", "done_with_gaps" ] }, "units": { "type": "array" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "candidate": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/candidate.schema.json", "type": "object", "required": [ "schemaVersion", "detectorId", "detectorVersion", "unitKind", "evidenceRefs", "variant", "score", "signals", "kind" ], "properties": { "schemaVersion": { "const": "0083.1" }, "detectorId": { "type": "string", "minLength": 1 }, "detectorVersion": { "type": "string", "minLength": 1 }, "unitKind": { "enum": [ "section", "component" ] }, "evidenceRefs": { "type": "array", "items": { "type": "string" } }, "variant": { "type": "string", "minLength": 1 }, "score": { "type": "number", "minimum": 0, "maximum": 1 }, "signals": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "kind": { "type": "string", "minLength": 1 }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "decision-patch": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/decision-patch.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "requestId", "choice", "confidence", "reasonCodes" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "decision-patch" }, "requestId": { "type": "string" }, "choice": {}, "confidence": { "enum": [ "high", "medium", "low" ] }, "reasonCodes": { "type": "array", "items": { "type": "string" } }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "decision-request": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/decision-request.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "decisionType", "allowedChoices", "evidenceRefs", "detectorVersions", "responseSchema" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "decision-request" }, "id": { "type": "string" }, "decisionType": { "enum": [ "classification", "ownership", "relevance", "reconstruction" ] }, "allowedChoices": { "type": "array", "minItems": 1 }, "evidenceRefs": { "type": "array" }, "detectorVersions": { "type": "object" }, "responseSchema": { "type": "object" }, "cacheKey": { "type": "string" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "extraction-gap": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/extraction-gap.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "ownerUnitId", "scope", "status", "missingFields", "reason", "evidenceRefs", "dependencyClosure", "affectedAcceptance", "attempts", "remainingAttempts", "assumptions", "omissions" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "extraction-gap" }, "id": { "type": "string", "minLength": 1 }, "ownerUnitId": { "type": "string", "minLength": 1 }, "scope": { "enum": [ "local", "global" ] }, "status": { "enum": [ "recoverable", "provisional", "resolved", "needs-user-decision", "global-blocker" ] }, "missingFields": { "type": "array", "items": { "type": "string" } }, "reason": { "type": "string", "minLength": 1 }, "evidenceRefs": { "type": "array", "items": { "type": "string" } }, "confidence": { "enum": [ "high", "medium", "low" ] }, "dependencyClosure": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "affectedAcceptance": { "type": "array", "items": { "type": "string" } }, "attempts": { "type": "array", "maxItems": 2 }, "remainingAttempts": { "type": "integer", "minimum": 0, "maximum": 2 }, "assumptions": { "type": "array", "items": { "type": "string" } }, "omissions": { "type": "array", "items": { "type": "string" } }, "unblockAction": { "type": [ "string", "null" ] }, "userDecision": { "type": [ "object", "null" ] }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "extraction-manifest": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/extraction-manifest.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "captureId", "pageKey", "pageResolution", "pageCapture", "observationRefs", "specs", "gaps", "budgets", "status", "manifestHash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "extraction-manifest" }, "captureId": { "type": "string", "minLength": 1 }, "pageKey": { "const": "home" }, "pageResolution": { "type": "object", "required": [ "id", "hash" ], "additionalProperties": false, "properties": { "id": { "type": "string" }, "hash": { "type": "string" } } }, "pageCapture": { "type": "object", "required": [ "id", "hash" ], "additionalProperties": false, "properties": { "id": { "type": "string" }, "hash": { "type": "string" } } }, "observationRefs": { "type": "array", "items": { "type": "object", "required": [ "ref", "hash" ], "properties": { "ref": { "type": "string", "minLength": 1 }, "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" } }, "additionalProperties": false }, "uniqueItems": true }, "specs": { "type": "array", "items": { "type": "object" } }, "gaps": { "type": "array", "items": { "type": "object" } }, "budgets": { "type": "object" }, "status": { "enum": [ "accepted", "done_with_gaps" ] }, "manifestHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "final-report": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/final-report.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "captureId", "manifestHash", "status", "summary", "gaps", "qa" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "final-report" }, "captureId": { "type": "string" }, "manifestHash": { "type": "string" }, "status": { "enum": [ "blocked", "done_with_gaps", "verification_pending", "implementation_pending", "done" ] }, "summary": { "type": "object" }, "gaps": { "type": "array" }, "qa": { "type": [ "object", "null" ] }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "foundation": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/foundation.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "pageKey", "status", "tokens", "fonts", "primitives", "globalCssIntent", "evidenceRefs", "acceptance", "gapRefs", "hash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "foundation" }, "id": { "type": "string" }, "pageKey": { "const": "home" }, "status": { "enum": [ "accepted", "provisional" ] }, "tokens": { "type": "object" }, "fonts": { "type": "object" }, "primitives": { "type": "array" }, "globalCssIntent": { "type": "object" }, "evidenceRefs": { "type": "array" }, "acceptance": { "type": "object" }, "gapRefs": { "type": "array" }, "dependencyHashes": { "type": "array" }, "hash": { "type": "string" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "metadata": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/metadata.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "pageKey", "status", "document", "evidenceRefs", "acceptance", "gapRefs", "hash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "metadata" }, "id": { "type": "string" }, "pageKey": { "const": "home" }, "status": { "enum": [ "accepted", "provisional" ] }, "document": { "type": "object" }, "evidenceRefs": { "type": "array" }, "acceptance": { "type": "object" }, "gapRefs": { "type": "array" }, "dependencyHashes": { "type": "array" }, "hash": { "type": "string" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "observation-packet": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/observation-packet.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "packetType", "sourceFingerprint", "payload" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "observation-packet" }, "packetType": { "type": "string" }, "sourceFingerprint": { "type": "string" }, "viewport": { "type": [ "object", "null" ] }, "state": { "type": [ "string", "null" ] }, "payload": {}, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "page-capture": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/page-capture.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "pageKey", "status", "sourceFingerprint", "viewportSet", "sectionOrder", "ignoredSurfaces", "normalizationActions", "observationRefs", "gapRefs", "hash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "page-capture" }, "id": { "type": "string" }, "pageKey": { "const": "home" }, "status": { "enum": [ "accepted", "provisional" ] }, "sourceFingerprint": { "type": "string" }, "viewportSet": { "type": "array" }, "sectionOrder": { "type": "array" }, "ignoredSurfaces": { "type": "array" }, "normalizationActions": { "type": "array" }, "observationRefs": { "type": "array" }, "gapRefs": { "type": "array" }, "dependencyHashes": { "type": "array" }, "hash": { "type": "string" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "page-resolution": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/page-resolution.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "pageKey", "destinationRoute", "source", "status", "gapRefs", "hash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "page-resolution" }, "id": { "const": "page-resolution:home" }, "pageKey": { "const": "home" }, "destinationRoute": { "const": "/" }, "status": { "enum": [ "accepted", "provisional" ] }, "source": { "type": "object", "required": [ "requestedUrl", "resolvedUrl" ], "properties": { "requestedUrl": { "type": "string", "format": "uri" }, "candidateUrl": { "type": "string", "format": "uri" }, "resolvedUrl": { "type": "string", "format": "uri" }, "canonicalUrl": { "type": "string", "format": "uri" }, "redirectsFollowed": { "type": "boolean" }, "fingerprint": { "type": "string" } }, "additionalProperties": false }, "evidence": { "type": "array", "items": { "type": "object" } }, "gapRefs": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "dependencyHashes": { "type": "array", "items": { "type": "string" } }, "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "shared-chrome": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/shared-chrome.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "pageKey", "status", "header", "footer", "controls", "visualAssets", "behavior", "evidenceRefs", "acceptance", "gapRefs", "hash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "shared-chrome" }, "id": { "type": "string" }, "pageKey": { "const": "home" }, "status": { "enum": [ "accepted", "provisional" ] }, "header": {}, "footer": {}, "controls": { "type": "array" }, "visualAssets": { "type": "object" }, "behavior": {}, "evidenceRefs": { "type": "array" }, "acceptance": { "type": "object" }, "gapRefs": { "type": "array" }, "dependencyHashes": { "type": "array" }, "hash": { "type": "string" }, "extensions": { "type": "object", "additionalProperties": true } }, "additionalProperties": false }, "unit": { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://wix.com/replatform/0083/unit.schema.json", "type": "object", "required": [ "schemaVersion", "kind", "id", "unitKind", "pageKey", "status", "classification", "scope", "content", "assets", "layers", "layout", "styleables", "behavior", "children", "reconstruction", "acceptance", "diagnostics", "provenance", "gapRefs", "hash" ], "properties": { "schemaVersion": { "const": "0083.1" }, "kind": { "const": "unit" }, "id": { "type": "string", "minLength": 1 }, "unitKind": { "enum": [ "section", "component" ] }, "pageKey": { "const": "home" }, "parentUnitId": { "type": [ "string", "null" ] }, "order": { "type": "integer", "minimum": 1 }, "status": { "enum": [ "accepted", "provisional" ] }, "classification": { "type": "object" }, "scope": { "type": "object" }, "content": { "type": "object" }, "assets": { "type": "array" }, "layers": { "type": "array" }, "layout": { "type": "object" }, "styleables": { "type": "array" }, "behavior": {}, "children": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "reconstruction": { "type": "object" }, "acceptance": { "type": "object" }, "diagnostics": { "type": "array" }, "provenance": { "type": "object" }, "gapRefs": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "dependencyHashes": { "type": "array", "items": { "type": "string" } }, "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, "extensions": { "type": "object", "additionalProperties": true } }, "allOf": [ { "if": { "properties": { "status": { "const": "provisional" } } }, "then": { "properties": { "gapRefs": { "minItems": 1 } } } } ], "additionalProperties": false } }; export const GENERATED_SCHEMA_VERSION = "0083.1"; export const GENERATED_SCHEMA_KINDS = Object.freeze(Object.keys(SCHEMAS).sort()); export function validateGeneratedArtifact(value, kind) { const schema = SCHEMAS[kind]; if (!schema) return { ok: false, errors: [`unsupported generated schema: ${kind}`] }; const errors = []; validate(value, schema, "$", errors, false); return { ok: errors.length === 0, errors }; } function validate(value, schema, at, errors, conditionOnly) { if (!schema || typeof schema !== "object") return true; const before = errors.length; if (schema.const !== undefined && !same(value, schema.const)) errors.push(`${at}: must equal ${JSON.stringify(schema.const)}`); if (schema.enum && !schema.enum.some((entry) => same(value, entry))) errors.push(`${at}: must be one of ${schema.enum.map(String).join(", ")}`); if (schema.type && !matchesType(value, schema.type)) errors.push(`${at}: must be type ${Array.isArray(schema.type) ? schema.type.join("|") : schema.type}`); if (typeof value === "string") { if (schema.minLength !== undefined && value.length < schema.minLength) errors.push(`${at}: must have length >= ${schema.minLength}`); if (schema.pattern && !new RegExp(schema.pattern, "u").test(value)) errors.push(`${at}: must match ${schema.pattern}`); if (schema.format === "uri") { try { new URL(value); } catch { errors.push(`${at}: must be a URI`); } } } if (typeof value === "number") { if (schema.minimum !== undefined && value < schema.minimum) errors.push(`${at}: must be >= ${schema.minimum}`); if (schema.maximum !== undefined && value > schema.maximum) errors.push(`${at}: must be <= ${schema.maximum}`); } if (Array.isArray(value)) { if (schema.minItems !== undefined && value.length < schema.minItems) errors.push(`${at}: must contain >= ${schema.minItems} items`); if (schema.maxItems !== undefined && value.length > schema.maxItems) errors.push(`${at}: must contain <= ${schema.maxItems} items`); if (schema.uniqueItems && new Set(value.map((entry) => JSON.stringify(entry))).size !== value.length) errors.push(`${at}: items must be unique`); if (schema.items) value.forEach((entry, index) => validate(entry, schema.items, `${at}[${index}]`, errors, conditionOnly)); } if (value && typeof value === "object" && !Array.isArray(value)) { for (const required of schema.required || []) if (!(required in value)) errors.push(`${at}.${required}: is required`); const properties = schema.properties || {}; for (const [key, entry] of Object.entries(value)) { if (properties[key]) validate(entry, properties[key], `${at}.${key}`, errors, conditionOnly); else if (schema.additionalProperties === false) errors.push(`${at}.${key}: additional property is not allowed`); else if (schema.additionalProperties && typeof schema.additionalProperties === "object") validate(entry, schema.additionalProperties, `${at}.${key}`, errors, conditionOnly); if (schema.propertyNames?.pattern && !new RegExp(schema.propertyNames.pattern, "u").test(key)) errors.push(`${at}.${key}: property name must match ${schema.propertyNames.pattern}`); } } for (const child of schema.allOf || []) validate(value, child, at, errors, conditionOnly); if (schema.if) { const probe = []; validate(value, schema.if, at, probe, true); if (!probe.length && schema.then) validate(value, schema.then, at, errors, conditionOnly); } if (conditionOnly && errors.length > before) return false; return errors.length === before; } function matchesType(value, expected) { const types = Array.isArray(expected) ? expected : [expected]; return types.some((type) => type === "null" ? value === null : type === "array" ? Array.isArray(value) : type === "object" ? Boolean(value) && typeof value === "object" && !Array.isArray(value) : type === "integer" ? Number.isInteger(value) : type === "number" ? typeof value === "number" && Number.isFinite(value) : typeof value === type); } function same(left, right) { return JSON.stringify(left) === JSON.stringify(right); }