json-schema-compatibility-checker 1.1.10 → 1.1.12
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/dist/cjs/semantic-errors.js +1 -1
- package/dist/cjs/semantic-errors.js.map +1 -1
- package/dist/cjs/subset-checker.d.ts +0 -20
- package/dist/cjs/subset-checker.js +1 -1
- package/dist/cjs/subset-checker.js.map +1 -1
- package/dist/esm/semantic-errors.js +1 -1
- package/dist/esm/semantic-errors.js.map +1 -1
- package/dist/esm/subset-checker.d.ts +0 -20
- package/dist/esm/subset-checker.js +1 -1
- package/dist/esm/subset-checker.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get computeSemanticErrors(){return computeSemanticErrors},get formatSchemaType(){return formatSchemaType}});const _typests=require("./types.js");const _utilsts=require("./utils.js");function formatEnumValues(values){const parts=values.map(v=>typeof v==="string"?v:JSON.stringify(v));if(parts.length===0)return"never";if(parts.length===1)return parts[0];if(parts.length===2)return`${parts[0]} or ${parts[1]}`;const last=parts.pop();return`${parts.join(", ")}, or ${last}`}function formatSchemaType(def){return formatSchemaTypeInternal(def)}function formatSchemaTypeInternal(def){if(def===undefined)return"undefined";if(typeof def==="boolean")return def?"any":"never";const schema=def;if((0,_utilsts.hasOwn)(schema,"const")){const v=schema.const;return typeof v==="string"?v:JSON.stringify(v)}if(Array.isArray(schema.enum)){return formatEnumValues(schema.enum)}const branches=schema.anyOf??schema.oneOf;if(Array.isArray(branches)&&branches.length>0){const parts=branches.map(b=>formatSchemaType(b));return parts.join(" | ")}if(schema.type==="array"){if(schema.items!==undefined&&typeof schema.items!=="boolean"){const itemSchema=schema.items;const itemBranches=itemSchema.anyOf??itemSchema.oneOf;if(Array.isArray(itemBranches)&&itemBranches.length>0){const parts=itemBranches.map(b=>`${formatSchemaType(b)}[]`);return parts.join(" | ")}if(Array.isArray(itemSchema.type)){const parts=itemSchema.type.map(t=>`${t}[]`);return parts.join(" | ")}const itemType=formatSchemaType(itemSchema);return`${itemType}[]`}return"array"}if(typeof schema.type==="string"){return schema.type}if(Array.isArray(schema.type)){return schema.type.join(" | ")}if((0,_utilsts.hasOwn)(schema,"not")&&!schema.type&&!(0,_utilsts.isPlainObj)(schema.properties)&&schema.items===undefined&&!Array.isArray(schema.enum)&&!(0,_utilsts.hasOwn)(schema,"const")){return`not ${formatSchemaType(schema.not)}`}if((0,_utilsts.isPlainObj)(schema.properties))return"object";if(schema.items!==undefined)return"array";return"unknown"}function joinPath(parent,key){if(!parent)return key;return`${parent}.${key}`}function arrayPath(parent){if(!parent)return"[]";return`${parent}[]`}function getProperties(schema){if((0,_utilsts.isPlainObj)(schema.properties)){return schema.properties}return null}function getRequired(schema){if(Array.isArray(schema.required)){return schema.required}return[]}function getEffectiveType(schema){if(schema.type!==undefined)return schema.type;if((0,_utilsts.hasOwn)(schema,"const")){const v=schema.const;if(v===null)return"null";if(Array.isArray(v))return"array";return typeof v}if((0,_utilsts.isPlainObj)(schema.properties))return"object";if(schema.items!==undefined)return"array";return undefined}function typeIncludes(schemaType,target){if(schemaType===undefined)return false;if(typeof schemaType==="string"){if(target==="number"&&schemaType==="integer")return true;if(target==="integer"&&schemaType==="number")return true;return schemaType===target}return schemaType.includes(target)}function typesAreCompatible(subType,supType){if(supType===undefined)return true;if(subType===undefined)return true;if(typeof subType==="string"&&typeof supType==="string"){if(subType===supType)return true;if(subType==="integer"&&supType==="number")return true;return false}if(typeof subType==="string"&&Array.isArray(supType)){return supType.some(t=>t===subType||subType==="integer"&&t==="number")}if(Array.isArray(subType)&&typeof supType==="string"){return subType.every(t=>t===supType||t==="integer"&&supType==="number")}if(Array.isArray(subType)&&Array.isArray(supType)){return subType.every(st=>supType.some(supt=>supt===st||st==="integer"&&supt==="number"))}return true}function fmtConstraint(name,value){if(value===undefined)return`${name}: not set`;if(typeof value==="boolean")return`${name}: ${value}`;if(typeof value==="number"||typeof value==="string")return`${name}: ${value}`;return`${name}: ${JSON.stringify(value)}`}function checkMinConstraint(subVal,supVal,name,path,errors,type){if(supVal!==undefined){if(subVal===undefined||subVal<supVal){errors.push({type,key:path||"$root",expected:fmtConstraint(name,supVal),received:fmtConstraint(name,subVal)})}}}function checkMaxConstraint(subVal,supVal,name,path,errors,type){if(supVal!==undefined){if(subVal===undefined||subVal>supVal){errors.push({type,key:path||"$root",expected:fmtConstraint(name,supVal),received:fmtConstraint(name,subVal)})}}}function checkNumericConstraints(sub,sup,path,errors){const subMin=sub.minimum;const subExclMin=sub.exclusiveMinimum;const subMax=sub.maximum;const subExclMax=sub.exclusiveMaximum;const supMin=sup.minimum;const supExclMin=sup.exclusiveMinimum;const supMax=sup.maximum;const supExclMax=sup.exclusiveMaximum;if(supMin!==undefined){const satisfiedByMin=subMin!==undefined&&subMin>=supMin;const satisfiedByExclMin=subExclMin!==undefined&&subExclMin>=supMin;if(!satisfiedByMin&&!satisfiedByExclMin){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("minimum",supMin),received:subMin!==undefined?fmtConstraint("minimum",subMin):subExclMin!==undefined?fmtConstraint("exclusiveMinimum",subExclMin):fmtConstraint("minimum",undefined)})}}if(supExclMin!==undefined){const satisfiedByExclMin=subExclMin!==undefined&&subExclMin>=supExclMin;const satisfiedByMin=subMin!==undefined&&subMin>supExclMin;if(!satisfiedByExclMin&&!satisfiedByMin){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("exclusiveMinimum",supExclMin),received:subExclMin!==undefined?fmtConstraint("exclusiveMinimum",subExclMin):subMin!==undefined?fmtConstraint("minimum",subMin):fmtConstraint("exclusiveMinimum",undefined)})}}if(supMax!==undefined){const satisfiedByMax=subMax!==undefined&&subMax<=supMax;const satisfiedByExclMax=subExclMax!==undefined&&subExclMax<=supMax;if(!satisfiedByMax&&!satisfiedByExclMax){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("maximum",supMax),received:subMax!==undefined?fmtConstraint("maximum",subMax):subExclMax!==undefined?fmtConstraint("exclusiveMaximum",subExclMax):fmtConstraint("maximum",undefined)})}}if(supExclMax!==undefined){const satisfiedByExclMax=subExclMax!==undefined&&subExclMax<=supExclMax;const satisfiedByMax=subMax!==undefined&&subMax<supExclMax;if(!satisfiedByExclMax&&!satisfiedByMax){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("exclusiveMaximum",supExclMax),received:subExclMax!==undefined?fmtConstraint("exclusiveMaximum",subExclMax):subMax!==undefined?fmtConstraint("maximum",subMax):fmtConstraint("exclusiveMaximum",undefined)})}}if(sup.multipleOf!==undefined){if(sub.multipleOf===undefined){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("multipleOf",sup.multipleOf),received:fmtConstraint("multipleOf",sub.multipleOf)})}else if(sub.multipleOf!==sup.multipleOf){if(sub.multipleOf%sup.multipleOf!==0){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("multipleOf",sup.multipleOf),received:fmtConstraint("multipleOf",sub.multipleOf)})}}}}function checkStringConstraints(sub,sup,path,errors){checkMinConstraint(sub.minLength,sup.minLength,"minLength",path,errors,_typests.SchemaErrorType.StringConstraint);checkMaxConstraint(sub.maxLength,sup.maxLength,"maxLength",path,errors,_typests.SchemaErrorType.StringConstraint);if(sup.pattern!==undefined){if(sub.pattern===undefined){errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("pattern",sup.pattern),received:"no pattern constraint"})}else if(sub.pattern!==sup.pattern){errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("pattern",sup.pattern),received:fmtConstraint("pattern",sub.pattern)})}}if(sup.format!==undefined&&sub.format!==sup.format){if(sub.format===undefined){errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("format",sup.format),received:"no format constraint"})}else{errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("format",sup.format),received:fmtConstraint("format",sub.format)})}}}function checkObjectConstraints(sub,sup,path,errors){if(sup.additionalProperties!==undefined){if(sup.additionalProperties===false){if(sub.additionalProperties===undefined||sub.additionalProperties===true){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:"additionalProperties: false",received:"additional properties allowed"})}else if(typeof sub.additionalProperties==="object"&&sub.additionalProperties!==null){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:"additionalProperties: false",received:"additionalProperties: schema"})}}else if(typeof sup.additionalProperties==="object"&&sup.additionalProperties!==null){if(sub.additionalProperties===undefined||sub.additionalProperties===true){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`additionalProperties: ${formatSchemaType(sup.additionalProperties)}`,received:"additional properties allowed"})}else if(typeof sub.additionalProperties==="object"&&sub.additionalProperties!==null){const apPath=path?`${path}.<additionalProperties>`:"<additionalProperties>";const apErrors=computeSemanticErrors(sub.additionalProperties,sup.additionalProperties,apPath);errors.push(...apErrors)}}}checkMinConstraint(sub.minProperties,sup.minProperties,"minProperties",path,errors,_typests.SchemaErrorType.ObjectConstraint);checkMaxConstraint(sub.maxProperties,sup.maxProperties,"maxProperties",path,errors,_typests.SchemaErrorType.ObjectConstraint);if(sup.propertyNames!==undefined){if(sub.propertyNames===undefined){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`propertyNames: ${formatSchemaType(sup.propertyNames)}`,received:"no propertyNames constraint"})}else{const pnErrors=computeSemanticErrors(sub.propertyNames,sup.propertyNames,path?`${path}.<propertyNames>`:"<propertyNames>");errors.push(...pnErrors)}}if((0,_utilsts.isPlainObj)(sup.dependencies)){const supDeps=sup.dependencies;const subDeps=(0,_utilsts.isPlainObj)(sub.dependencies)?sub.dependencies:null;const subRequired=Array.isArray(sub.required)?sub.required:[];const subProps=(0,_utilsts.isPlainObj)(sub.properties)?sub.properties:{};for(const key of Object.keys(supDeps)){const supDep=supDeps[key];const subDep=subDeps?.[key];if(subDep===undefined){if(Array.isArray(supDep)){const allDepsAlwaysRequired=supDep.every(d=>subRequired.includes(d));const triggerNeverProduced=!(0,_utilsts.hasOwn)(subProps,key)&&!subRequired.includes(key);if(!allDepsAlwaysRequired&&!triggerNeverProduced){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires ${supDep.join(", ")}`,received:`no dependency for ${key}`})}}else{const triggerNeverProduced=!(0,_utilsts.hasOwn)(subProps,key)&&!subRequired.includes(key);if(!triggerNeverProduced){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires schema`,received:`no dependency for ${key}`})}}}else if(Array.isArray(supDep)&&Array.isArray(subDep)){const missing=supDep.filter(d=>!subDep.includes(d));if(missing.length>0){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires ${supDep.join(", ")}`,received:`dependency: ${key} requires ${subDep.join(", ")}`})}}else if(!Array.isArray(supDep)&&!Array.isArray(subDep)){const depPath=path?`${path}.<dependency:${key}>`:`<dependency:${key}>`;const depErrors=computeSemanticErrors(subDep,supDep,depPath);errors.push(...depErrors)}else{errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:Array.isArray(supDep)?`dependency: ${key} requires ${supDep.join(", ")}`:`dependency: ${key} requires schema`,received:Array.isArray(subDep)?`dependency: ${key} requires ${subDep.join(", ")}`:`dependency: ${key} requires schema`})}}}if((0,_utilsts.isPlainObj)(sup.patternProperties)){const supPP=sup.patternProperties;const subPP=(0,_utilsts.isPlainObj)(sub.patternProperties)?sub.patternProperties:null;for(const pattern of Object.keys(supPP)){const supPropDef=supPP[pattern];if(supPropDef===undefined)continue;const subPropDef=subPP?.[pattern];const ppPath=path?`${path}.<patternProperties:${pattern}>`:`<patternProperties:${pattern}>`;if(subPropDef===undefined){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:ppPath,expected:formatSchemaType(supPropDef),received:"no constraint for this pattern"})}else{const ppErrors=computeSemanticErrors(subPropDef,supPropDef,ppPath);errors.push(...ppErrors)}}}}function checkArrayConstraints(sub,sup,path,errors){checkMinConstraint(sub.minItems,sup.minItems,"minItems",path,errors,_typests.SchemaErrorType.ArrayConstraint);checkMaxConstraint(sub.maxItems,sup.maxItems,"maxItems",path,errors,_typests.SchemaErrorType.ArrayConstraint);if(sup.uniqueItems===true&&sub.uniqueItems!==true){errors.push({type:_typests.SchemaErrorType.ArrayConstraint,key:path||"$root",expected:"uniqueItems: true",received:fmtConstraint("uniqueItems",sub.uniqueItems??false)})}if(sup.contains!==undefined){if(sub.contains===undefined){errors.push({type:_typests.SchemaErrorType.ArrayConstraint,key:path||"$root",expected:`contains: ${formatSchemaType(sup.contains)}`,received:"no contains constraint"})}else{const containsPath=path?`${path}.<contains>`:"<contains>";const containsErrors=computeSemanticErrors(sub.contains,sup.contains,containsPath);errors.push(...containsErrors)}}}function isNumericType(t){if(t===undefined)return false;if(typeof t==="string")return t==="number"||t==="integer";return t.some(v=>v==="number"||v==="integer")}function isStringType(t){if(t===undefined)return false;if(typeof t==="string")return t==="string";return t.includes("string")}function isObjectType(t){if(t===undefined)return false;if(typeof t==="string")return t==="object";return t.includes("object")}function isArrayType(t){if(t===undefined)return false;if(typeof t==="string")return t==="array";return t.includes("array")}function hasNumericKeywords(s){return s.minimum!==undefined||s.maximum!==undefined||s.exclusiveMinimum!==undefined||s.exclusiveMaximum!==undefined||s.multipleOf!==undefined}function hasStringKeywords(s){return s.minLength!==undefined||s.maxLength!==undefined||s.pattern!==undefined||s.format!==undefined}function hasObjectKeywords(s){return s.minProperties!==undefined||s.maxProperties!==undefined||s.propertyNames!==undefined||s.additionalProperties!==undefined||(0,_utilsts.isPlainObj)(s.patternProperties)||(0,_utilsts.isPlainObj)(s.dependencies)}function hasArrayKeywords(s){return s.minItems!==undefined||s.maxItems!==undefined||s.uniqueItems!==undefined||s.contains!==undefined}function isNotSatisfied(sub,sup){if(!(0,_utilsts.hasOwn)(sup,"not")||!(0,_utilsts.isPlainObj)(sup.not)||typeof sup.not==="boolean"){return null}const notSchema=sup.not;if(sub.type!==undefined&¬Schema.type!==undefined){const subTypes=Array.isArray(sub.type)?sub.type:[sub.type];const notTypes=Array.isArray(notSchema.type)?notSchema.type:[notSchema.type];const hasOverlap=subTypes.some(t=>notTypes.includes(t));const notKeys=Object.keys(notSchema);const isTypeOnly=notKeys.length===1&¬Keys[0]==="type";if(isTypeOnly){if(!hasOverlap)return true;if(subTypes.every(t=>notTypes.includes(t)))return false}}if((0,_utilsts.hasOwn)(notSchema,"const")){if((0,_utilsts.hasOwn)(sub,"const")){return!(0,_utilsts.deepEqual)(sub.const,notSchema.const)}if(Array.isArray(sub.enum)){const allDisjoint=sub.enum.every(v=>!(0,_utilsts.deepEqual)(v,notSchema.const));if(allDisjoint)return true}}if(Array.isArray(notSchema.enum)){if((0,_utilsts.hasOwn)(sub,"const")){const constInNotEnum=notSchema.enum.some(v=>(0,_utilsts.deepEqual)(v,sub.const));if(!constInNotEnum)return true;return false}if(Array.isArray(sub.enum)){const hasOverlap=sub.enum.some(v=>notSchema.enum?.some(nv=>(0,_utilsts.deepEqual)(v,nv)));if(!hasOverlap)return true}}return null}function computeSemanticErrors(sub,sup,path=""){if(typeof sup==="boolean"){if(sup===false){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:"never",received:formatSchemaType(sub)}]}return[]}if(typeof sub==="boolean"){if(sub===true){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(sup),received:"any"}]}return[]}const subSchema=sub;const supSchema=sup;const errors=[];if((0,_utilsts.hasOwn)(supSchema,"not")&&(0,_utilsts.isPlainObj)(supSchema.not)&&typeof supSchema.not!=="boolean"){const notSchema=supSchema.not;const notFormatted=formatSchemaType(notSchema);const notResult=isNotSatisfied(subSchema,supSchema);if(notResult===false){errors.push({type:_typests.SchemaErrorType.NotSchema,key:path||"$root",expected:`not ${notFormatted}`,received:formatSchemaType(subSchema)})}else if(notResult===null){if(!(0,_utilsts.hasOwn)(subSchema,"not")){errors.push({type:_typests.SchemaErrorType.NotSchema,key:path||"$root",expected:`not ${notFormatted}`,received:formatSchemaType(subSchema)})}else if((0,_utilsts.isPlainObj)(subSchema.not)&&typeof subSchema.not!=="boolean"){const subNotSchema=subSchema.not;if(!(0,_utilsts.deepEqual)(subNotSchema,notSchema)){errors.push({type:_typests.SchemaErrorType.NotSchema,key:path||"$root",expected:`not ${notFormatted}`,received:`not ${formatSchemaType(subNotSchema)}`})}}}}const subType=getEffectiveType(subSchema);const supType=getEffectiveType(supSchema);const supBranches=supSchema.anyOf??supSchema.oneOf;if(Array.isArray(supBranches)&&supBranches.length>0&&!supSchema.type){return computeErrorsAgainstBranches(subSchema,supBranches,path)}const subBranches=subSchema.anyOf??subSchema.oneOf;if(Array.isArray(subBranches)&&subBranches.length>0&&!subSchema.type){const branchErrors=[];for(const branch of subBranches){const errs=computeSemanticErrors(branch,sup,path);branchErrors.push(...errs)}return branchErrors}const supProps=getProperties(supSchema);const subProps=getProperties(subSchema);if(supProps!==null||isObjectType(supType)){if(subType!==undefined&&!typeIncludes(subType,"object")){errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)});return errors}if(supProps!==null){const supRequired=getRequired(supSchema);const subRequired=getRequired(subSchema);for(const key of Object.keys(supProps)){const propPath=joinPath(path,key);const supPropDef=supProps[key];const subPropDef=subProps?.[key];if(supPropDef===undefined)continue;const isRequiredInSup=supRequired.includes(key);if(subPropDef===undefined){if(isRequiredInSup){errors.push({type:_typests.SchemaErrorType.MissingProperty,key:propPath,expected:formatSchemaType(supPropDef),received:"undefined"})}continue}if(isRequiredInSup&&!subRequired.includes(key)){errors.push({type:_typests.SchemaErrorType.Optionality,key:propPath,expected:"not optional",received:"optional"});continue}const propErrors=comparePropertySchemas(subPropDef,supPropDef,propPath);errors.push(...propErrors)}}checkObjectConstraints(subSchema,supSchema,path,errors);return errors}if((supType==="array"||supSchema.items!==undefined)&&(subType==="array"||subSchema.items!==undefined)){if(supSchema.items!==undefined&&typeof supSchema.items!=="boolean"){if(subSchema.items!==undefined&&typeof subSchema.items!=="boolean"){if(Array.isArray(supSchema.items)&&Array.isArray(subSchema.items)){const maxLen=Math.max(supSchema.items.length,subSchema.items.length);for(let i=0;i<maxLen;i++){const supItem=supSchema.items[i];const subItem=subSchema.items[i];const itemPath=joinPath(path,`[${i}]`);if(supItem!==undefined&&subItem===undefined){errors.push({type:_typests.SchemaErrorType.MissingProperty,key:itemPath,expected:formatSchemaType(supItem),received:"undefined"})}else if(supItem!==undefined&&subItem!==undefined){errors.push(...computeSemanticErrors(subItem,supItem,itemPath))}}}else if(!Array.isArray(supSchema.items)&&!Array.isArray(subSchema.items)){const itemPath=arrayPath(path);const itemErrors=computeSemanticErrors(subSchema.items,supSchema.items,itemPath);errors.push(...itemErrors)}}else{errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)})}}checkArrayConstraints(subSchema,supSchema,path,errors);return errors}if(subType!==undefined&&supType!==undefined){if(!typesAreCompatible(subType,supType)){errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)});return errors}}if(Array.isArray(supSchema.enum)){if(Array.isArray(subSchema.enum)){const subExtra=subSchema.enum.filter(v=>!supSchema.enum?.some(sv=>(0,_utilsts.deepEqual)(v,sv)));if(subExtra.length>0){errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatEnumValues(supSchema.enum),received:formatEnumValues(subSchema.enum)})}}else if((0,_utilsts.hasOwn)(subSchema,"const")){const constInEnum=supSchema.enum.some(v=>(0,_utilsts.deepEqual)(v,subSchema.const));if(!constInEnum){errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)})}}else{errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)})}return errors}if((0,_utilsts.hasOwn)(supSchema,"const")&&(0,_utilsts.hasOwn)(subSchema,"const")){if(!(0,_utilsts.deepEqual)(supSchema.const,subSchema.const)){errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)})}return errors}if(isNumericType(subType)||isNumericType(supType)||hasNumericKeywords(supSchema)||hasNumericKeywords(subSchema)){checkNumericConstraints(subSchema,supSchema,path,errors)}if(isStringType(subType)||isStringType(supType)||hasStringKeywords(supSchema)||hasStringKeywords(subSchema)){checkStringConstraints(subSchema,supSchema,path,errors)}if(isObjectType(subType)||isObjectType(supType)||hasObjectKeywords(supSchema)||hasObjectKeywords(subSchema)){checkObjectConstraints(subSchema,supSchema,path,errors)}if(isArrayType(subType)||isArrayType(supType)||hasArrayKeywords(supSchema)||hasArrayKeywords(subSchema)){checkArrayConstraints(subSchema,supSchema,path,errors)}if(errors.length>0){return errors}const expectedStr=formatSchemaType(supSchema);const receivedStr=formatSchemaType(subSchema);if(expectedStr!==receivedStr){errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:expectedStr,received:receivedStr})}return errors}function comparePropertySchemas(subDef,supDef,path){if(typeof subDef==="boolean"||typeof supDef==="boolean"){if(subDef!==supDef){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path,expected:formatSchemaType(supDef),received:formatSchemaType(subDef)}]}return[]}const subSchema=subDef;const supSchema=supDef;const subType=getEffectiveType(subSchema);const supType=getEffectiveType(supSchema);if(Array.isArray(supSchema.enum)){if(Array.isArray(subSchema.enum)){const subExtra=subSchema.enum.filter(v=>!supSchema.enum?.some(sv=>(0,_utilsts.deepEqual)(v,sv)));if(subExtra.length>0){return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatEnumValues(supSchema.enum),received:formatEnumValues(subSchema.enum)}]}return[]}if((0,_utilsts.hasOwn)(subSchema,"const")){const constInEnum=supSchema.enum.some(v=>(0,_utilsts.deepEqual)(v,subSchema.const));if(!constInEnum){return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)}]}return[]}return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)}]}if((0,_utilsts.hasOwn)(supSchema,"const")&&(0,_utilsts.hasOwn)(subSchema,"const")){if(!(0,_utilsts.deepEqual)(supSchema.const,subSchema.const)){return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)}]}return[]}if(subType!==undefined&&supType!==undefined){if(!typesAreCompatible(subType,supType)){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path,expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)}]}}return computeSemanticErrors(subDef,supDef,path)}function computeErrorsAgainstBranches(sub,branches,path){let bestErrors=null;for(const branch of branches){const errors=computeSemanticErrors(sub,branch,path);if(errors.length===0)return[];if(bestErrors===null||errors.length<bestErrors.length){bestErrors=errors}}return bestErrors??[{type:_typests.SchemaErrorType.BranchMismatch,key:path||"$root",expected:formatSchemaType({anyOf:branches}),received:formatSchemaType(sub)}]}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get computeSemanticErrors(){return computeSemanticErrors},get formatSchemaType(){return formatSchemaType}});const _typests=require("./types.js");const _utilsts=require("./utils.js");function formatEnumValues(values){const parts=values.map(v=>typeof v==="string"?v:JSON.stringify(v));if(parts.length===0)return"never";if(parts.length===1)return parts[0];if(parts.length===2)return`${parts[0]} or ${parts[1]}`;const last=parts.pop();return`${parts.join(", ")}, or ${last}`}function formatSchemaType(def){return formatSchemaTypeInternal(def)}function formatSchemaTypeInternal(def){if(def===undefined)return"undefined";if(typeof def==="boolean")return def?"any":"never";const schema=def;if((0,_utilsts.hasOwn)(schema,"const")){const v=schema.const;return typeof v==="string"?v:JSON.stringify(v)}if(Array.isArray(schema.enum)){return formatEnumValues(schema.enum)}const branches=schema.anyOf??schema.oneOf;if(Array.isArray(branches)&&branches.length>0){const parts=branches.map(b=>formatSchemaType(b));return parts.join(" | ")}if(schema.type==="array"){if(schema.items!==undefined&&typeof schema.items!=="boolean"){const itemSchema=schema.items;const itemBranches=itemSchema.anyOf??itemSchema.oneOf;if(Array.isArray(itemBranches)&&itemBranches.length>0){const parts=itemBranches.map(b=>`${formatSchemaType(b)}[]`);return parts.join(" | ")}if(Array.isArray(itemSchema.type)){const parts=itemSchema.type.map(t=>`${t}[]`);return parts.join(" | ")}const itemType=formatSchemaType(itemSchema);return`${itemType}[]`}return"array"}if(typeof schema.type==="string"){return schema.type}if(Array.isArray(schema.type)){return schema.type.join(" | ")}if((0,_utilsts.hasOwn)(schema,"not")&&!schema.type&&!(0,_utilsts.isPlainObj)(schema.properties)&&schema.items===undefined&&!Array.isArray(schema.enum)&&!(0,_utilsts.hasOwn)(schema,"const")){return`not ${formatSchemaType(schema.not)}`}if((0,_utilsts.isPlainObj)(schema.properties))return"object";if(schema.items!==undefined)return"array";return"unknown"}function joinPath(parent,key){if(!parent)return key;return`${parent}.${key}`}function arrayPath(parent){if(!parent)return"[]";return`${parent}[]`}function getProperties(schema){if((0,_utilsts.isPlainObj)(schema.properties)){return schema.properties}return null}function getRequired(schema){if(Array.isArray(schema.required)){return schema.required}return[]}function getEffectiveType(schema){if(schema.type!==undefined)return schema.type;if((0,_utilsts.hasOwn)(schema,"const")){const v=schema.const;if(v===null)return"null";if(Array.isArray(v))return"array";return typeof v}if((0,_utilsts.isPlainObj)(schema.properties))return"object";if(schema.items!==undefined)return"array";return undefined}function typeIncludes(schemaType,target){if(schemaType===undefined)return false;if(typeof schemaType==="string"){if(target==="number"&&schemaType==="integer")return true;if(target==="integer"&&schemaType==="number")return true;return schemaType===target}return schemaType.includes(target)}function typesAreCompatible(subType,supType){if(supType===undefined)return true;if(subType===undefined)return true;if(typeof subType==="string"&&typeof supType==="string"){if(subType===supType)return true;if(subType==="integer"&&supType==="number")return true;return false}if(typeof subType==="string"&&Array.isArray(supType)){return supType.some(t=>t===subType||subType==="integer"&&t==="number")}if(Array.isArray(subType)&&typeof supType==="string"){return subType.every(t=>t===supType||t==="integer"&&supType==="number")}if(Array.isArray(subType)&&Array.isArray(supType)){return subType.every(st=>supType.some(supt=>supt===st||st==="integer"&&supt==="number"))}return true}function fmtConstraint(name,value){if(value===undefined)return`${name}: not set`;if(typeof value==="boolean")return`${name}: ${value}`;if(typeof value==="number"||typeof value==="string")return`${name}: ${value}`;return`${name}: ${JSON.stringify(value)}`}function checkMinConstraint(subVal,supVal,name,path,errors,type){if(supVal!==undefined){if(subVal===undefined||subVal<supVal){errors.push({type,key:path||"$root",expected:fmtConstraint(name,supVal),received:fmtConstraint(name,subVal)})}}}function checkMaxConstraint(subVal,supVal,name,path,errors,type){if(supVal!==undefined){if(subVal===undefined||subVal>supVal){errors.push({type,key:path||"$root",expected:fmtConstraint(name,supVal),received:fmtConstraint(name,subVal)})}}}function checkNumericConstraints(sub,sup,path,errors){const subMin=sub.minimum;const subExclMin=sub.exclusiveMinimum;const subMax=sub.maximum;const subExclMax=sub.exclusiveMaximum;const supMin=sup.minimum;const supExclMin=sup.exclusiveMinimum;const supMax=sup.maximum;const supExclMax=sup.exclusiveMaximum;if(supMin!==undefined){const satisfiedByMin=subMin!==undefined&&subMin>=supMin;const satisfiedByExclMin=subExclMin!==undefined&&subExclMin>=supMin;if(!satisfiedByMin&&!satisfiedByExclMin){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("minimum",supMin),received:subMin!==undefined?fmtConstraint("minimum",subMin):subExclMin!==undefined?fmtConstraint("exclusiveMinimum",subExclMin):fmtConstraint("minimum",undefined)})}}if(supExclMin!==undefined){const satisfiedByExclMin=subExclMin!==undefined&&subExclMin>=supExclMin;const satisfiedByMin=subMin!==undefined&&subMin>supExclMin;if(!satisfiedByExclMin&&!satisfiedByMin){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("exclusiveMinimum",supExclMin),received:subExclMin!==undefined?fmtConstraint("exclusiveMinimum",subExclMin):subMin!==undefined?fmtConstraint("minimum",subMin):fmtConstraint("exclusiveMinimum",undefined)})}}if(supMax!==undefined){const satisfiedByMax=subMax!==undefined&&subMax<=supMax;const satisfiedByExclMax=subExclMax!==undefined&&subExclMax<=supMax;if(!satisfiedByMax&&!satisfiedByExclMax){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("maximum",supMax),received:subMax!==undefined?fmtConstraint("maximum",subMax):subExclMax!==undefined?fmtConstraint("exclusiveMaximum",subExclMax):fmtConstraint("maximum",undefined)})}}if(supExclMax!==undefined){const satisfiedByExclMax=subExclMax!==undefined&&subExclMax<=supExclMax;const satisfiedByMax=subMax!==undefined&&subMax<supExclMax;if(!satisfiedByExclMax&&!satisfiedByMax){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("exclusiveMaximum",supExclMax),received:subExclMax!==undefined?fmtConstraint("exclusiveMaximum",subExclMax):subMax!==undefined?fmtConstraint("maximum",subMax):fmtConstraint("exclusiveMaximum",undefined)})}}if(sup.multipleOf!==undefined){if(sub.multipleOf===undefined){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("multipleOf",sup.multipleOf),received:fmtConstraint("multipleOf",sub.multipleOf)})}else if(sub.multipleOf!==sup.multipleOf){if(sub.multipleOf%sup.multipleOf!==0){errors.push({type:_typests.SchemaErrorType.NumericConstraint,key:path||"$root",expected:fmtConstraint("multipleOf",sup.multipleOf),received:fmtConstraint("multipleOf",sub.multipleOf)})}}}}function checkStringConstraints(sub,sup,path,errors){checkMinConstraint(sub.minLength,sup.minLength,"minLength",path,errors,_typests.SchemaErrorType.StringConstraint);checkMaxConstraint(sub.maxLength,sup.maxLength,"maxLength",path,errors,_typests.SchemaErrorType.StringConstraint);if(sup.pattern!==undefined){if(sub.pattern===undefined){errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("pattern",sup.pattern),received:"no pattern constraint"})}else if(sub.pattern!==sup.pattern){errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("pattern",sup.pattern),received:fmtConstraint("pattern",sub.pattern)})}}if(sup.format!==undefined&&sub.format!==sup.format){if(sub.format===undefined){errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("format",sup.format),received:"no format constraint"})}else{errors.push({type:_typests.SchemaErrorType.StringConstraint,key:path||"$root",expected:fmtConstraint("format",sup.format),received:fmtConstraint("format",sub.format)})}}}function checkObjectConstraints(sub,sup,path,errors){if(sup.additionalProperties!==undefined){if(sup.additionalProperties===false){if(sub.additionalProperties===undefined||sub.additionalProperties===true){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:"additionalProperties: false",received:"additional properties allowed"})}else if(typeof sub.additionalProperties==="object"&&sub.additionalProperties!==null){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:"additionalProperties: false",received:"additionalProperties: schema"})}}else if(typeof sup.additionalProperties==="object"&&sup.additionalProperties!==null){if(sub.additionalProperties===undefined||sub.additionalProperties===true){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`additionalProperties: ${formatSchemaType(sup.additionalProperties)}`,received:"additional properties allowed"})}else if(typeof sub.additionalProperties==="object"&&sub.additionalProperties!==null){const apPath=path?`${path}.<additionalProperties>`:"<additionalProperties>";const apErrors=computeSemanticErrors(sub.additionalProperties,sup.additionalProperties,apPath);errors.push(...apErrors)}}}checkMinConstraint(sub.minProperties,sup.minProperties,"minProperties",path,errors,_typests.SchemaErrorType.ObjectConstraint);checkMaxConstraint(sub.maxProperties,sup.maxProperties,"maxProperties",path,errors,_typests.SchemaErrorType.ObjectConstraint);if(sup.propertyNames!==undefined){if(sub.propertyNames===undefined){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`propertyNames: ${formatSchemaType(sup.propertyNames)}`,received:"no propertyNames constraint"})}else{const pnErrors=computeSemanticErrors(sub.propertyNames,sup.propertyNames,path?`${path}.<propertyNames>`:"<propertyNames>");errors.push(...pnErrors)}}if((0,_utilsts.isPlainObj)(sup.dependencies)){const supDeps=sup.dependencies;const subDeps=(0,_utilsts.isPlainObj)(sub.dependencies)?sub.dependencies:null;const subRequired=Array.isArray(sub.required)?sub.required:[];const subProps=(0,_utilsts.isPlainObj)(sub.properties)?sub.properties:{};for(const key of Object.keys(supDeps)){const supDep=supDeps[key];const subDep=subDeps?.[key];if(subDep===undefined){if(Array.isArray(supDep)){const allDepsAlwaysRequired=supDep.every(d=>subRequired.includes(d));const triggerNeverProduced=!(0,_utilsts.hasOwn)(subProps,key)&&!subRequired.includes(key);if(!allDepsAlwaysRequired&&!triggerNeverProduced){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires ${supDep.join(", ")}`,received:`no dependency for ${key}`})}}else if((0,_utilsts.isPlainObj)(supDep)){const triggerNeverProduced=!(0,_utilsts.hasOwn)(subProps,key)&&!subRequired.includes(key);if(triggerNeverProduced){}else{const depSchema=supDep;const depRequired=Array.isArray(depSchema.required)?depSchema.required:[];const depProps=(0,_utilsts.isPlainObj)(depSchema.properties)?depSchema.properties:{};const allDepRequiredSatisfied=depRequired.every(r=>subRequired.includes(r));let allDepPropsSatisfied=true;if(allDepRequiredSatisfied){for(const propKey of Object.keys(depProps)){if(!(0,_utilsts.hasOwn)(subProps,propKey)){allDepPropsSatisfied=false;break}const subPropDef=subProps[propKey];const depPropDef=depProps[propKey];if(subPropDef===undefined||depPropDef===undefined||typeof subPropDef==="boolean"||typeof depPropDef==="boolean"){if(subPropDef!==depPropDef){allDepPropsSatisfied=false;break}continue}const depPropKeys=Object.keys(depPropDef);const propSatisfied=depPropKeys.every(dk=>{const depVal=depPropDef[dk];const subVal=subPropDef[dk];if(subVal===undefined)return false;if(typeof depVal==="number"&&typeof subVal==="number"){if(dk==="minLength"||dk==="minimum"||dk==="exclusiveMinimum"||dk==="minItems"||dk==="minProperties"){return subVal>=depVal}if(dk==="maxLength"||dk==="maximum"||dk==="exclusiveMaximum"||dk==="maxItems"||dk==="maxProperties"){return subVal<=depVal}}return(0,_utilsts.deepEqual)(depVal,subVal)});if(!propSatisfied){allDepPropsSatisfied=false;break}}}if(!allDepRequiredSatisfied||!allDepPropsSatisfied){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires schema`,received:`no dependency for ${key}`})}}}}else if(Array.isArray(supDep)&&Array.isArray(subDep)){const missing=supDep.filter(d=>!subDep.includes(d));if(missing.length>0){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires ${supDep.join(", ")}`,received:`dependency: ${key} requires ${subDep.join(", ")}`})}}else if(!Array.isArray(supDep)&&!Array.isArray(subDep)){const depPath=path?`${path}.<dependency:${key}>`:`<dependency:${key}>`;const depErrors=computeSemanticErrors(subDep,supDep,depPath);errors.push(...depErrors)}else{errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:Array.isArray(supDep)?`dependency: ${key} requires ${supDep.join(", ")}`:`dependency: ${key} requires schema`,received:Array.isArray(subDep)?`dependency: ${key} requires ${subDep.join(", ")}`:`dependency: ${key} requires schema`})}}}if((0,_utilsts.isPlainObj)(sup.patternProperties)){const supPP=sup.patternProperties;const subPP=(0,_utilsts.isPlainObj)(sub.patternProperties)?sub.patternProperties:null;for(const pattern of Object.keys(supPP)){const supPropDef=supPP[pattern];if(supPropDef===undefined)continue;const subPropDef=subPP?.[pattern];const ppPath=path?`${path}.<patternProperties:${pattern}>`:`<patternProperties:${pattern}>`;if(subPropDef===undefined){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:ppPath,expected:formatSchemaType(supPropDef),received:"no constraint for this pattern"})}else{const ppErrors=computeSemanticErrors(subPropDef,supPropDef,ppPath);errors.push(...ppErrors)}}}}function checkArrayConstraints(sub,sup,path,errors){checkMinConstraint(sub.minItems,sup.minItems,"minItems",path,errors,_typests.SchemaErrorType.ArrayConstraint);checkMaxConstraint(sub.maxItems,sup.maxItems,"maxItems",path,errors,_typests.SchemaErrorType.ArrayConstraint);if(sup.uniqueItems===true&&sub.uniqueItems!==true){errors.push({type:_typests.SchemaErrorType.ArrayConstraint,key:path||"$root",expected:"uniqueItems: true",received:fmtConstraint("uniqueItems",sub.uniqueItems??false)})}if(sup.contains!==undefined){if(sub.contains===undefined){errors.push({type:_typests.SchemaErrorType.ArrayConstraint,key:path||"$root",expected:`contains: ${formatSchemaType(sup.contains)}`,received:"no contains constraint"})}else{const containsPath=path?`${path}.<contains>`:"<contains>";const containsErrors=computeSemanticErrors(sub.contains,sup.contains,containsPath);errors.push(...containsErrors)}}}function isNumericType(t){if(t===undefined)return false;if(typeof t==="string")return t==="number"||t==="integer";return t.some(v=>v==="number"||v==="integer")}function isStringType(t){if(t===undefined)return false;if(typeof t==="string")return t==="string";return t.includes("string")}function isObjectType(t){if(t===undefined)return false;if(typeof t==="string")return t==="object";return t.includes("object")}function isArrayType(t){if(t===undefined)return false;if(typeof t==="string")return t==="array";return t.includes("array")}function hasNumericKeywords(s){return s.minimum!==undefined||s.maximum!==undefined||s.exclusiveMinimum!==undefined||s.exclusiveMaximum!==undefined||s.multipleOf!==undefined}function hasStringKeywords(s){return s.minLength!==undefined||s.maxLength!==undefined||s.pattern!==undefined||s.format!==undefined}function hasObjectKeywords(s){return s.minProperties!==undefined||s.maxProperties!==undefined||s.propertyNames!==undefined||s.additionalProperties!==undefined||(0,_utilsts.isPlainObj)(s.patternProperties)||(0,_utilsts.isPlainObj)(s.dependencies)}function hasArrayKeywords(s){return s.minItems!==undefined||s.maxItems!==undefined||s.uniqueItems!==undefined||s.contains!==undefined}function isNotSatisfied(sub,sup){if(!(0,_utilsts.hasOwn)(sup,"not")||!(0,_utilsts.isPlainObj)(sup.not)||typeof sup.not==="boolean"){return null}const notSchema=sup.not;if(sub.type!==undefined&¬Schema.type!==undefined){const subTypes=Array.isArray(sub.type)?sub.type:[sub.type];const notTypes=Array.isArray(notSchema.type)?notSchema.type:[notSchema.type];const hasOverlap=subTypes.some(t=>notTypes.includes(t));const notKeys=Object.keys(notSchema);const isTypeOnly=notKeys.length===1&¬Keys[0]==="type";if(isTypeOnly){if(!hasOverlap)return true;if(subTypes.every(t=>notTypes.includes(t)))return false}}if((0,_utilsts.hasOwn)(notSchema,"const")){if((0,_utilsts.hasOwn)(sub,"const")){return!(0,_utilsts.deepEqual)(sub.const,notSchema.const)}if(Array.isArray(sub.enum)){const allDisjoint=sub.enum.every(v=>!(0,_utilsts.deepEqual)(v,notSchema.const));if(allDisjoint)return true}}if(Array.isArray(notSchema.enum)){if((0,_utilsts.hasOwn)(sub,"const")){const constInNotEnum=notSchema.enum.some(v=>(0,_utilsts.deepEqual)(v,sub.const));if(!constInNotEnum)return true;return false}if(Array.isArray(sub.enum)){const hasOverlap=sub.enum.some(v=>notSchema.enum?.some(nv=>(0,_utilsts.deepEqual)(v,nv)));if(!hasOverlap)return true}}return null}function computeSemanticErrors(sub,sup,path=""){if(typeof sup==="boolean"){if(sup===false){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:"never",received:formatSchemaType(sub)}]}return[]}if(typeof sub==="boolean"){if(sub===true){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(sup),received:"any"}]}return[]}const subSchema=sub;const supSchema=sup;const errors=[];if((0,_utilsts.hasOwn)(supSchema,"not")&&(0,_utilsts.isPlainObj)(supSchema.not)&&typeof supSchema.not!=="boolean"){const notSchema=supSchema.not;const notFormatted=formatSchemaType(notSchema);const notResult=isNotSatisfied(subSchema,supSchema);if(notResult===false){errors.push({type:_typests.SchemaErrorType.NotSchema,key:path||"$root",expected:`not ${notFormatted}`,received:formatSchemaType(subSchema)})}else if(notResult===null){if(!(0,_utilsts.hasOwn)(subSchema,"not")){errors.push({type:_typests.SchemaErrorType.NotSchema,key:path||"$root",expected:`not ${notFormatted}`,received:formatSchemaType(subSchema)})}else if((0,_utilsts.isPlainObj)(subSchema.not)&&typeof subSchema.not!=="boolean"){const subNotSchema=subSchema.not;if(!(0,_utilsts.deepEqual)(subNotSchema,notSchema)){errors.push({type:_typests.SchemaErrorType.NotSchema,key:path||"$root",expected:`not ${notFormatted}`,received:`not ${formatSchemaType(subNotSchema)}`})}}}}const subType=getEffectiveType(subSchema);const supType=getEffectiveType(supSchema);const supBranches=supSchema.anyOf??supSchema.oneOf;if(Array.isArray(supBranches)&&supBranches.length>0&&!supSchema.type){return computeErrorsAgainstBranches(subSchema,supBranches,path)}const subBranches=subSchema.anyOf??subSchema.oneOf;if(Array.isArray(subBranches)&&subBranches.length>0&&!subSchema.type){const branchErrors=[];for(const branch of subBranches){const errs=computeSemanticErrors(branch,sup,path);branchErrors.push(...errs)}return branchErrors}const supProps=getProperties(supSchema);const subProps=getProperties(subSchema);if(supProps!==null||isObjectType(supType)){if(subType!==undefined&&!typeIncludes(subType,"object")){errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)});return errors}if(supProps!==null){const supRequired=getRequired(supSchema);const subRequired=getRequired(subSchema);for(const key of Object.keys(supProps)){const propPath=joinPath(path,key);const supPropDef=supProps[key];const subPropDef=subProps?.[key];if(supPropDef===undefined)continue;const isRequiredInSup=supRequired.includes(key);if(subPropDef===undefined){if(isRequiredInSup){errors.push({type:_typests.SchemaErrorType.MissingProperty,key:propPath,expected:formatSchemaType(supPropDef),received:"undefined"})}continue}if(isRequiredInSup&&!subRequired.includes(key)){errors.push({type:_typests.SchemaErrorType.Optionality,key:propPath,expected:"not optional",received:"optional"});continue}const propErrors=comparePropertySchemas(subPropDef,supPropDef,propPath);errors.push(...propErrors)}}checkObjectConstraints(subSchema,supSchema,path,errors);return errors}if((supType==="array"||supSchema.items!==undefined)&&(subType==="array"||subSchema.items!==undefined)){if(supSchema.items!==undefined&&typeof supSchema.items!=="boolean"){if(subSchema.items!==undefined&&typeof subSchema.items!=="boolean"){if(Array.isArray(supSchema.items)&&Array.isArray(subSchema.items)){const maxLen=Math.max(supSchema.items.length,subSchema.items.length);for(let i=0;i<maxLen;i++){const supItem=supSchema.items[i];const subItem=subSchema.items[i];const itemPath=joinPath(path,`[${i}]`);if(supItem!==undefined&&subItem===undefined){errors.push({type:_typests.SchemaErrorType.MissingProperty,key:itemPath,expected:formatSchemaType(supItem),received:"undefined"})}else if(supItem!==undefined&&subItem!==undefined){errors.push(...computeSemanticErrors(subItem,supItem,itemPath))}}}else if(!Array.isArray(supSchema.items)&&!Array.isArray(subSchema.items)){const itemPath=arrayPath(path);const itemErrors=computeSemanticErrors(subSchema.items,supSchema.items,itemPath);errors.push(...itemErrors)}}else{errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)})}}checkArrayConstraints(subSchema,supSchema,path,errors);return errors}if(subType!==undefined&&supType!==undefined){if(!typesAreCompatible(subType,supType)){errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)});return errors}}if(Array.isArray(supSchema.enum)){if(Array.isArray(subSchema.enum)){const subExtra=subSchema.enum.filter(v=>!supSchema.enum?.some(sv=>(0,_utilsts.deepEqual)(v,sv)));if(subExtra.length>0){errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatEnumValues(supSchema.enum),received:formatEnumValues(subSchema.enum)})}}else if((0,_utilsts.hasOwn)(subSchema,"const")){const constInEnum=supSchema.enum.some(v=>(0,_utilsts.deepEqual)(v,subSchema.const));if(!constInEnum){errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)})}}else{errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)})}return errors}if((0,_utilsts.hasOwn)(supSchema,"const")&&(0,_utilsts.hasOwn)(subSchema,"const")){if(!(0,_utilsts.deepEqual)(supSchema.const,subSchema.const)){errors.push({type:_typests.SchemaErrorType.EnumMismatch,key:path||"$root",expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)})}return errors}if(isNumericType(subType)||isNumericType(supType)||hasNumericKeywords(supSchema)||hasNumericKeywords(subSchema)){checkNumericConstraints(subSchema,supSchema,path,errors)}if(isStringType(subType)||isStringType(supType)||hasStringKeywords(supSchema)||hasStringKeywords(subSchema)){checkStringConstraints(subSchema,supSchema,path,errors)}if(isObjectType(subType)||isObjectType(supType)||hasObjectKeywords(supSchema)||hasObjectKeywords(subSchema)){checkObjectConstraints(subSchema,supSchema,path,errors)}if(isArrayType(subType)||isArrayType(supType)||hasArrayKeywords(supSchema)||hasArrayKeywords(subSchema)){checkArrayConstraints(subSchema,supSchema,path,errors)}if(errors.length>0){return errors}const expectedStr=formatSchemaType(supSchema);const receivedStr=formatSchemaType(subSchema);if(expectedStr!==receivedStr){const supNotSatisfied=(0,_utilsts.hasOwn)(supSchema,"not")&&(0,_utilsts.isPlainObj)(supSchema.not)&&isNotSatisfied(subSchema,supSchema)===true;const isEnumCompatibleWithSupNot=Array.isArray(subSchema.enum)&&supSchema.type!==undefined&&subSchema.type!==undefined&&typesAreCompatible(subSchema.type,supSchema.type)&&supNotSatisfied;if(!isEnumCompatibleWithSupNot){errors.push({type:_typests.SchemaErrorType.TypeMismatch,key:path||"$root",expected:expectedStr,received:receivedStr})}}return errors}function comparePropertySchemas(subDef,supDef,path){if(typeof subDef==="boolean"||typeof supDef==="boolean"){if(subDef!==supDef){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path,expected:formatSchemaType(supDef),received:formatSchemaType(subDef)}]}return[]}const subSchema=subDef;const supSchema=supDef;const subType=getEffectiveType(subSchema);const supType=getEffectiveType(supSchema);if(Array.isArray(supSchema.enum)){if(Array.isArray(subSchema.enum)){const subExtra=subSchema.enum.filter(v=>!supSchema.enum?.some(sv=>(0,_utilsts.deepEqual)(v,sv)));if(subExtra.length>0){return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatEnumValues(supSchema.enum),received:formatEnumValues(subSchema.enum)}]}return[]}if((0,_utilsts.hasOwn)(subSchema,"const")){const constInEnum=supSchema.enum.some(v=>(0,_utilsts.deepEqual)(v,subSchema.const));if(!constInEnum){return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)}]}return[]}return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatEnumValues(supSchema.enum),received:formatSchemaType(subSchema)}]}if((0,_utilsts.hasOwn)(supSchema,"const")&&(0,_utilsts.hasOwn)(subSchema,"const")){if(!(0,_utilsts.deepEqual)(supSchema.const,subSchema.const)){return[{type:_typests.SchemaErrorType.EnumMismatch,key:path,expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)}]}return[]}if(subType!==undefined&&supType!==undefined){if(!typesAreCompatible(subType,supType)){return[{type:_typests.SchemaErrorType.TypeMismatch,key:path,expected:formatSchemaType(supSchema),received:formatSchemaType(subSchema)}]}}return computeSemanticErrors(subDef,supDef,path)}function computeErrorsAgainstBranches(sub,branches,path){let bestErrors=null;for(const branch of branches){const errors=computeSemanticErrors(sub,branch,path);if(errors.length===0)return[];if(bestErrors===null||errors.length<bestErrors.length){bestErrors=errors}}return bestErrors??[{type:_typests.SchemaErrorType.BranchMismatch,key:path||"$root",expected:formatSchemaType({anyOf:branches}),received:formatSchemaType(sub)}]}
|
|
2
2
|
//# sourceMappingURL=semantic-errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/semantic-errors.ts"],"sourcesContent":["import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport type { SchemaError } from \"./types.ts\";\nimport { SchemaErrorType } from \"./types.ts\";\nimport { deepEqual, hasOwn, isPlainObj } from \"./utils.ts\";\n\n// ─── Semantic Error Generator ────────────────────────────────────────────────\n//\n// Generates human-readable semantic errors by directly comparing two schemas.\n//\n// Unlike a structural differ (which would compare sub vs merged), this module\n// directly compares sub (source/received) and sup (target/expected) to produce\n// business-oriented error messages.\n//\n// Property paths are normalized:\n// - `accountId` (top-level property)\n// - `user.name` (nested property)\n// - `users[].name` (property inside array items)\n//\n// Convention:\n// - `expected` = what the target schema (sup) expects\n// - `received` = what the source schema (sub) provides\n\n// ─── Type Formatting ─────────────────────────────────────────────────────────\n\n/**\n * Formats enum values into a readable string.\n *\n * Examples:\n * - 1 value : `\"123\"`\n * - 2 values : `\"123 or hello\"`\n * - 3 values : `\"10, 20, or 30\"`\n */\nfunction formatEnumValues(values: unknown[]): string {\n\tconst parts = values.map((v) =>\n\t\ttypeof v === \"string\" ? v : JSON.stringify(v),\n\t);\n\tif (parts.length === 0) return \"never\";\n\tif (parts.length === 1) return parts[0] as string;\n\tif (parts.length === 2) return `${parts[0]} or ${parts[1]}`;\n\tconst last = parts.pop();\n\treturn `${parts.join(\", \")}, or ${last}`;\n}\n\n/**\n * Formats a schema into a readable type representation.\n *\n * Examples:\n * - `{ type: \"string\" }` → `\"string\"`\n * - `{ type: \"array\", items: { type: \"string\" } }` → `\"string[]\"`\n * - `{ type: \"array\", items: { type: [\"string\",\"number\"] }` → `\"string[] | number[]\"`\n * - `{ enum: [1, 2, 3] }` → `\"1, 2, or 3\"`\n * - `{ const: \"hello\" }` → `\"hello\"`\n * - `{ anyOf: [{type:\"string\"},{type:\"number\"}] }` → `\"string | number\"`\n * - `undefined` → `\"undefined\"`\n */\nexport function formatSchemaType(\n\tdef: JSONSchema7Definition | undefined,\n): string {\n\treturn formatSchemaTypeInternal(def);\n}\n\nfunction formatSchemaTypeInternal(\n\tdef: JSONSchema7Definition | undefined,\n): string {\n\tif (def === undefined) return \"undefined\";\n\tif (typeof def === \"boolean\") return def ? \"any\" : \"never\";\n\n\tconst schema = def as JSONSchema7;\n\n\t// ── Const ──\n\tif (hasOwn(schema, \"const\")) {\n\t\tconst v = schema.const;\n\t\treturn typeof v === \"string\" ? v : JSON.stringify(v);\n\t}\n\n\t// ── Enum ──\n\tif (Array.isArray(schema.enum)) {\n\t\treturn formatEnumValues(schema.enum);\n\t}\n\n\t// ── anyOf / oneOf (union types) ──\n\tconst branches = schema.anyOf ?? schema.oneOf;\n\tif (Array.isArray(branches) && branches.length > 0) {\n\t\tconst parts = branches.map((b) => formatSchemaType(b));\n\t\treturn parts.join(\" | \");\n\t}\n\n\t// ── Array type ──\n\tif (schema.type === \"array\") {\n\t\tif (schema.items !== undefined && typeof schema.items !== \"boolean\") {\n\t\t\tconst itemSchema = schema.items as JSONSchema7;\n\n\t\t\t// Items with anyOf/oneOf → \"string[] | number[]\"\n\t\t\tconst itemBranches = itemSchema.anyOf ?? itemSchema.oneOf;\n\t\t\tif (Array.isArray(itemBranches) && itemBranches.length > 0) {\n\t\t\t\tconst parts = itemBranches.map((b) => `${formatSchemaType(b)}[]`);\n\t\t\t\treturn parts.join(\" | \");\n\t\t\t}\n\n\t\t\t// Items with multiple types → \"string[] | number[]\"\n\t\t\tif (Array.isArray(itemSchema.type)) {\n\t\t\t\tconst parts = itemSchema.type.map((t) => `${t}[]`);\n\t\t\t\treturn parts.join(\" | \");\n\t\t\t}\n\n\t\t\tconst itemType = formatSchemaType(itemSchema);\n\t\t\treturn `${itemType}[]`;\n\t\t}\n\t\t// items is boolean true or missing\n\t\treturn \"array\";\n\t}\n\n\t// ── Simple type ──\n\tif (typeof schema.type === \"string\") {\n\t\treturn schema.type;\n\t}\n\n\t// ── Multiple types (type: [\"string\", \"number\"]) ──\n\tif (Array.isArray(schema.type)) {\n\t\treturn schema.type.join(\" | \");\n\t}\n\n\t// ── not (pure-not schema, no other significant keywords) ──\n\tif (\n\t\thasOwn(schema, \"not\") &&\n\t\t!schema.type &&\n\t\t!isPlainObj(schema.properties) &&\n\t\tschema.items === undefined &&\n\t\t!Array.isArray(schema.enum) &&\n\t\t!hasOwn(schema, \"const\")\n\t) {\n\t\treturn `not ${formatSchemaType(schema.not as JSONSchema7Definition)}`;\n\t}\n\n\t// ── Fallback ──\n\t// Schema without explicit type — try to infer from structure\n\tif (isPlainObj(schema.properties)) return \"object\";\n\tif (schema.items !== undefined) return \"array\";\n\n\treturn \"unknown\";\n}\n\n// ─── Path Helpers ────────────────────────────────────────────────────────────\n\n/**\n * Builds a normalized property path.\n * - Root + key → `\"accountId\"`\n * - Parent + key → `\"user.name\"`\n * - Parent[] + key → `\"users[].name\"`\n */\nfunction joinPath(parent: string, key: string): string {\n\tif (!parent) return key;\n\treturn `${parent}.${key}`;\n}\n\n/**\n * Appends the `[]` suffix to indicate entering array items.\n */\nfunction arrayPath(parent: string): string {\n\tif (!parent) return \"[]\";\n\treturn `${parent}[]`;\n}\n\n// ─── Schema Accessors ────────────────────────────────────────────────────────\n\n/**\n * Safely extracts the properties from a schema.\n */\nfunction getProperties(\n\tschema: JSONSchema7,\n): Record<string, JSONSchema7Definition> | null {\n\tif (isPlainObj(schema.properties)) {\n\t\treturn schema.properties as Record<string, JSONSchema7Definition>;\n\t}\n\treturn null;\n}\n\n/**\n * Safely extracts the required fields from a schema.\n */\nfunction getRequired(schema: JSONSchema7): string[] {\n\tif (Array.isArray(schema.required)) {\n\t\treturn schema.required as string[];\n\t}\n\treturn [];\n}\n\n/**\n * Determines the effective type of a schema (string or array of types).\n */\nfunction getEffectiveType(schema: JSONSchema7): string | string[] | undefined {\n\tif (schema.type !== undefined) return schema.type as string | string[];\n\n\t// Infer from const\n\tif (hasOwn(schema, \"const\")) {\n\t\tconst v = schema.const;\n\t\tif (v === null) return \"null\";\n\t\tif (Array.isArray(v)) return \"array\";\n\t\treturn typeof v;\n\t}\n\n\t// Infer from properties\n\tif (isPlainObj(schema.properties)) return \"object\";\n\n\t// Infer from items\n\tif (schema.items !== undefined) return \"array\";\n\n\treturn undefined;\n}\n\n/**\n * Checks whether a type (string) is included in a type or array of types.\n */\nfunction typeIncludes(\n\tschemaType: string | string[] | undefined,\n\ttarget: string,\n): boolean {\n\tif (schemaType === undefined) return false;\n\tif (typeof schemaType === \"string\") {\n\t\t// integer is a subset of number\n\t\tif (target === \"number\" && schemaType === \"integer\") return true;\n\t\tif (target === \"integer\" && schemaType === \"number\") return true;\n\t\treturn schemaType === target;\n\t}\n\treturn schemaType.includes(target);\n}\n\n/**\n * Checks whether two types are compatible.\n * A type is compatible if the sub type is included in the sup type.\n */\nfunction typesAreCompatible(\n\tsubType: string | string[] | undefined,\n\tsupType: string | string[] | undefined,\n): boolean {\n\tif (supType === undefined) return true; // sup accepts anything\n\tif (subType === undefined) return true; // sub is undetermined, cannot conclude\n\n\tif (typeof subType === \"string\" && typeof supType === \"string\") {\n\t\tif (subType === supType) return true;\n\t\t// integer ⊆ number\n\t\tif (subType === \"integer\" && supType === \"number\") return true;\n\t\treturn false;\n\t}\n\n\tif (typeof subType === \"string\" && Array.isArray(supType)) {\n\t\treturn supType.some(\n\t\t\t(t) => t === subType || (subType === \"integer\" && t === \"number\"),\n\t\t);\n\t}\n\n\tif (Array.isArray(subType) && typeof supType === \"string\") {\n\t\treturn subType.every(\n\t\t\t(t) => t === supType || (t === \"integer\" && supType === \"number\"),\n\t\t);\n\t}\n\n\tif (Array.isArray(subType) && Array.isArray(supType)) {\n\t\treturn subType.every((st) =>\n\t\t\tsupType.some(\n\t\t\t\t(supt) => supt === st || (st === \"integer\" && supt === \"number\"),\n\t\t\t),\n\t\t);\n\t}\n\n\treturn true;\n}\n\n// ─── Constraint Helpers ──────────────────────────────────────────────────────\n\n/**\n * Formats a constraint value into a readable string.\n */\nfunction fmtConstraint(name: string, value: unknown): string {\n\tif (value === undefined) return `${name}: not set`;\n\tif (typeof value === \"boolean\") return `${name}: ${value}`;\n\tif (typeof value === \"number\" || typeof value === \"string\")\n\t\treturn `${name}: ${value}`;\n\treturn `${name}: ${JSON.stringify(value)}`;\n}\n\n/**\n * Compares a \"minimum-like\" numeric constraint (sub.X must be >= sup.X for sub ⊆ sup).\n * Examples: minimum, exclusiveMinimum, minLength, minItems, minProperties\n */\nfunction checkMinConstraint(\n\tsubVal: number | undefined,\n\tsupVal: number | undefined,\n\tname: string,\n\tpath: string,\n\terrors: SchemaError[],\n\ttype: SchemaErrorType,\n): void {\n\tif (supVal !== undefined) {\n\t\tif (subVal === undefined || subVal < supVal) {\n\t\t\terrors.push({\n\t\t\t\ttype,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(name, supVal),\n\t\t\t\treceived: fmtConstraint(name, subVal),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Compares a \"maximum-like\" numeric constraint (sub.X must be <= sup.X for sub ⊆ sup).\n * Examples: maximum, exclusiveMaximum, maxLength, maxItems, maxProperties\n */\nfunction checkMaxConstraint(\n\tsubVal: number | undefined,\n\tsupVal: number | undefined,\n\tname: string,\n\tpath: string,\n\terrors: SchemaError[],\n\ttype: SchemaErrorType,\n): void {\n\tif (supVal !== undefined) {\n\t\tif (subVal === undefined || subVal > supVal) {\n\t\t\terrors.push({\n\t\t\t\ttype,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(name, supVal),\n\t\t\t\treceived: fmtConstraint(name, subVal),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Compares numeric constraints between sub and sup.\n */\nfunction checkNumericConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\tconst subMin = sub.minimum;\n\tconst subExclMin = sub.exclusiveMinimum as number | undefined;\n\tconst subMax = sub.maximum;\n\tconst subExclMax = sub.exclusiveMaximum as number | undefined;\n\n\tconst supMin = sup.minimum;\n\tconst supExclMin = sup.exclusiveMinimum as number | undefined;\n\tconst supMax = sup.maximum;\n\tconst supExclMax = sup.exclusiveMaximum as number | undefined;\n\n\t// ── LOWER BOUND cross-check ──\n\n\t// Check sup.minimum\n\tif (supMin !== undefined) {\n\t\t// sub satisfies sup.minimum if:\n\t\t// sub.minimum >= sup.minimum OR\n\t\t// sub.exclusiveMinimum >= sup.minimum (>X implies >=X when X is the same)\n\t\tconst satisfiedByMin = subMin !== undefined && subMin >= supMin;\n\t\tconst satisfiedByExclMin = subExclMin !== undefined && subExclMin >= supMin;\n\n\t\tif (!satisfiedByMin && !satisfiedByExclMin) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"minimum\", supMin),\n\t\t\t\treceived:\n\t\t\t\t\tsubMin !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"minimum\", subMin)\n\t\t\t\t\t\t: subExclMin !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"exclusiveMinimum\", subExclMin)\n\t\t\t\t\t\t\t: fmtConstraint(\"minimum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// Check sup.exclusiveMinimum\n\tif (supExclMin !== undefined) {\n\t\t// sub satisfies sup.exclusiveMinimum if:\n\t\t// sub.exclusiveMinimum >= sup.exclusiveMinimum OR\n\t\t// sub.minimum > sup.exclusiveMinimum (>=X with X>B implies >B)\n\t\tconst satisfiedByExclMin =\n\t\t\tsubExclMin !== undefined && subExclMin >= supExclMin;\n\t\tconst satisfiedByMin = subMin !== undefined && subMin > supExclMin;\n\n\t\tif (!satisfiedByExclMin && !satisfiedByMin) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"exclusiveMinimum\", supExclMin),\n\t\t\t\treceived:\n\t\t\t\t\tsubExclMin !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"exclusiveMinimum\", subExclMin)\n\t\t\t\t\t\t: subMin !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"minimum\", subMin)\n\t\t\t\t\t\t\t: fmtConstraint(\"exclusiveMinimum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── UPPER BOUND cross-check ──\n\n\t// Check sup.maximum\n\tif (supMax !== undefined) {\n\t\t// sub satisfies sup.maximum if:\n\t\t// sub.maximum <= sup.maximum OR\n\t\t// sub.exclusiveMaximum <= sup.maximum\n\t\tconst satisfiedByMax = subMax !== undefined && subMax <= supMax;\n\t\tconst satisfiedByExclMax = subExclMax !== undefined && subExclMax <= supMax;\n\n\t\tif (!satisfiedByMax && !satisfiedByExclMax) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"maximum\", supMax),\n\t\t\t\treceived:\n\t\t\t\t\tsubMax !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"maximum\", subMax)\n\t\t\t\t\t\t: subExclMax !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"exclusiveMaximum\", subExclMax)\n\t\t\t\t\t\t\t: fmtConstraint(\"maximum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// Check sup.exclusiveMaximum\n\tif (supExclMax !== undefined) {\n\t\t// sub satisfies sup.exclusiveMaximum if:\n\t\t// sub.exclusiveMaximum <= sup.exclusiveMaximum OR\n\t\t// sub.maximum < sup.exclusiveMaximum\n\t\tconst satisfiedByExclMax =\n\t\t\tsubExclMax !== undefined && subExclMax <= supExclMax;\n\t\tconst satisfiedByMax = subMax !== undefined && subMax < supExclMax;\n\n\t\tif (!satisfiedByExclMax && !satisfiedByMax) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"exclusiveMaximum\", supExclMax),\n\t\t\t\treceived:\n\t\t\t\t\tsubExclMax !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"exclusiveMaximum\", subExclMax)\n\t\t\t\t\t\t: subMax !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"maximum\", subMax)\n\t\t\t\t\t\t\t: fmtConstraint(\"exclusiveMaximum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── multipleOf (unchanged) ──\n\tif (sup.multipleOf !== undefined) {\n\t\tif (sub.multipleOf === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"multipleOf\", sup.multipleOf),\n\t\t\t\treceived: fmtConstraint(\"multipleOf\", sub.multipleOf),\n\t\t\t});\n\t\t} else if (sub.multipleOf !== sup.multipleOf) {\n\t\t\t// sub.multipleOf must be a multiple of sup.multipleOf for sub ⊆ sup\n\t\t\tif (sub.multipleOf % sup.multipleOf !== 0) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: fmtConstraint(\"multipleOf\", sup.multipleOf),\n\t\t\t\t\treceived: fmtConstraint(\"multipleOf\", sub.multipleOf),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Compares string constraints between sub and sup.\n */\nfunction checkStringConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\tcheckMinConstraint(\n\t\tsub.minLength,\n\t\tsup.minLength,\n\t\t\"minLength\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.StringConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maxLength,\n\t\tsup.maxLength,\n\t\t\"maxLength\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.StringConstraint,\n\t);\n\n\t// ── Pattern ──\n\tif (sup.pattern !== undefined) {\n\t\tif (sub.pattern === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"pattern\", sup.pattern),\n\t\t\t\treceived: \"no pattern constraint\",\n\t\t\t});\n\t\t} else if (sub.pattern !== sup.pattern) {\n\t\t\t// Different patterns — we can't statically determine subset relationship\n\t\t\t// without sampling, so report it as a potential mismatch.\n\t\t\t// The subset checker may have already stripped equivalent patterns,\n\t\t\t// so if we get here, they're genuinely different.\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"pattern\", sup.pattern),\n\t\t\t\treceived: fmtConstraint(\"pattern\", sub.pattern),\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── Format ──\n\tif (sup.format !== undefined && sub.format !== sup.format) {\n\t\tif (sub.format === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"format\", sup.format),\n\t\t\t\treceived: \"no format constraint\",\n\t\t\t});\n\t\t} else {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"format\", sup.format),\n\t\t\t\treceived: fmtConstraint(\"format\", sub.format),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Compares object constraints (excluding properties/required) between sub and sup.\n */\nfunction checkObjectConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\t// ── additionalProperties ──\n\tif (sup.additionalProperties !== undefined) {\n\t\tif (sup.additionalProperties === false) {\n\t\t\t// sup forbids additional properties\n\t\t\tif (\n\t\t\t\tsub.additionalProperties === undefined ||\n\t\t\t\tsub.additionalProperties === true\n\t\t\t) {\n\t\t\t\t// sub allows them → incompatible\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: \"additionalProperties: false\",\n\t\t\t\t\treceived: \"additional properties allowed\",\n\t\t\t\t});\n\t\t\t} else if (\n\t\t\t\ttypeof sub.additionalProperties === \"object\" &&\n\t\t\t\tsub.additionalProperties !== null\n\t\t\t) {\n\t\t\t\t// sub has a schema for additional properties → still allows them\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: \"additionalProperties: false\",\n\t\t\t\t\treceived: \"additionalProperties: schema\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (\n\t\t\ttypeof sup.additionalProperties === \"object\" &&\n\t\t\tsup.additionalProperties !== null\n\t\t) {\n\t\t\t// sup has a schema for additionalProperties\n\t\t\tif (\n\t\t\t\tsub.additionalProperties === undefined ||\n\t\t\t\tsub.additionalProperties === true\n\t\t\t) {\n\t\t\t\t// sub allows anything → more permissive\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: `additionalProperties: ${formatSchemaType(sup.additionalProperties as JSONSchema7Definition)}`,\n\t\t\t\t\treceived: \"additional properties allowed\",\n\t\t\t\t});\n\t\t\t} else if (\n\t\t\t\ttypeof sub.additionalProperties === \"object\" &&\n\t\t\t\tsub.additionalProperties !== null\n\t\t\t) {\n\t\t\t\t// Both have schema-form additionalProperties — recurse\n\t\t\t\tconst apPath = path\n\t\t\t\t\t? `${path}.<additionalProperties>`\n\t\t\t\t\t: \"<additionalProperties>\";\n\t\t\t\tconst apErrors = computeSemanticErrors(\n\t\t\t\t\tsub.additionalProperties as JSONSchema7Definition,\n\t\t\t\t\tsup.additionalProperties as JSONSchema7Definition,\n\t\t\t\t\tapPath,\n\t\t\t\t);\n\t\t\t\terrors.push(...apErrors);\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── minProperties / maxProperties ──\n\tcheckMinConstraint(\n\t\tsub.minProperties,\n\t\tsup.minProperties,\n\t\t\"minProperties\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ObjectConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maxProperties,\n\t\tsup.maxProperties,\n\t\t\"maxProperties\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ObjectConstraint,\n\t);\n\n\t// ── propertyNames ──\n\tif (sup.propertyNames !== undefined) {\n\t\tif (sub.propertyNames === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: `propertyNames: ${formatSchemaType(sup.propertyNames)}`,\n\t\t\t\treceived: \"no propertyNames constraint\",\n\t\t\t});\n\t\t} else {\n\t\t\t// Both have propertyNames — recurse\n\t\t\tconst pnErrors = computeSemanticErrors(\n\t\t\t\tsub.propertyNames as JSONSchema7Definition,\n\t\t\t\tsup.propertyNames as JSONSchema7Definition,\n\t\t\t\tpath ? `${path}.<propertyNames>` : \"<propertyNames>\",\n\t\t\t);\n\t\t\terrors.push(...pnErrors);\n\t\t}\n\t}\n\n\t// ── dependencies ──\n\tif (isPlainObj(sup.dependencies)) {\n\t\tconst supDeps = sup.dependencies as Record<\n\t\t\tstring,\n\t\t\tJSONSchema7Definition | string[]\n\t\t>;\n\t\tconst subDeps = isPlainObj(sub.dependencies)\n\t\t\t? (sub.dependencies as Record<string, JSONSchema7Definition | string[]>)\n\t\t\t: null;\n\n\t\tconst subRequired = Array.isArray(sub.required)\n\t\t\t? (sub.required as string[])\n\t\t\t: [];\n\t\tconst subProps = isPlainObj(sub.properties) ? sub.properties : {};\n\n\t\tfor (const key of Object.keys(supDeps)) {\n\t\t\tconst supDep = supDeps[key];\n\t\t\tconst subDep = subDeps?.[key];\n\n\t\t\tif (subDep === undefined) {\n\t\t\t\tif (Array.isArray(supDep)) {\n\t\t\t\t\t// ── Semantic deduction for array-form dependencies ──\n\t\t\t\t\t//\n\t\t\t\t\t// A dependency `{ A: ['B', 'C'] }` means:\n\t\t\t\t\t// \"if A is present → B and C must also be present\"\n\t\t\t\t\t//\n\t\t\t\t\t// Case 1: All dependent properties (B, C) are in sub.required\n\t\t\t\t\t// → The dependency is trivially satisfied (B and C are ALWAYS present)\n\t\t\t\t\t//\n\t\t\t\t\t// Case 2: The trigger property (A) doesn't exist in sub.properties\n\t\t\t\t\t// AND is not in sub.required\n\t\t\t\t\t// → sub will never produce A, so the dependency is never triggered\n\t\t\t\t\tconst allDepsAlwaysRequired = supDep.every((d) =>\n\t\t\t\t\t\tsubRequired.includes(d),\n\t\t\t\t\t);\n\t\t\t\t\tconst triggerNeverProduced =\n\t\t\t\t\t\t!hasOwn(subProps, key) && !subRequired.includes(key);\n\n\t\t\t\t\tif (!allDepsAlwaysRequired && !triggerNeverProduced) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\t\texpected: `dependency: ${key} requires ${supDep.join(\", \")}`,\n\t\t\t\t\t\t\treceived: `no dependency for ${key}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// ── Schema-form dependencies ──\n\t\t\t\t\t// Check if the trigger property is never produced by sub\n\t\t\t\t\tconst triggerNeverProduced =\n\t\t\t\t\t\t!hasOwn(subProps, key) && !subRequired.includes(key);\n\n\t\t\t\t\tif (!triggerNeverProduced) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\t\texpected: `dependency: ${key} requires schema`,\n\t\t\t\t\t\t\treceived: `no dependency for ${key}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (Array.isArray(supDep) && Array.isArray(subDep)) {\n\t\t\t\t// Both are array form — check if sub includes all required props from sup\n\t\t\t\tconst missing = supDep.filter((d) => !subDep.includes(d));\n\t\t\t\tif (missing.length > 0) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\texpected: `dependency: ${key} requires ${supDep.join(\", \")}`,\n\t\t\t\t\t\treceived: `dependency: ${key} requires ${subDep.join(\", \")}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (!Array.isArray(supDep) && !Array.isArray(subDep)) {\n\t\t\t\t// Both are schema form — recurse\n\t\t\t\tconst depPath = path\n\t\t\t\t\t? `${path}.<dependency:${key}>`\n\t\t\t\t\t: `<dependency:${key}>`;\n\t\t\t\tconst depErrors = computeSemanticErrors(\n\t\t\t\t\tsubDep as JSONSchema7Definition,\n\t\t\t\t\tsupDep as JSONSchema7Definition,\n\t\t\t\t\tdepPath,\n\t\t\t\t);\n\t\t\t\terrors.push(...depErrors);\n\t\t\t} else {\n\t\t\t\t// Mixed forms (one array, one schema) — report mismatch\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: Array.isArray(supDep)\n\t\t\t\t\t\t? `dependency: ${key} requires ${supDep.join(\", \")}`\n\t\t\t\t\t\t: `dependency: ${key} requires schema`,\n\t\t\t\t\treceived: Array.isArray(subDep)\n\t\t\t\t\t\t? `dependency: ${key} requires ${subDep.join(\", \")}`\n\t\t\t\t\t\t: `dependency: ${key} requires schema`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── patternProperties ──\n\tif (isPlainObj(sup.patternProperties)) {\n\t\tconst supPP = sup.patternProperties as Record<\n\t\t\tstring,\n\t\t\tJSONSchema7Definition\n\t\t>;\n\t\tconst subPP = isPlainObj(sub.patternProperties)\n\t\t\t? (sub.patternProperties as Record<string, JSONSchema7Definition>)\n\t\t\t: null;\n\n\t\tfor (const pattern of Object.keys(supPP)) {\n\t\t\tconst supPropDef = supPP[pattern];\n\t\t\tif (supPropDef === undefined) continue;\n\n\t\t\tconst subPropDef = subPP?.[pattern];\n\t\t\tconst ppPath = path\n\t\t\t\t? `${path}.<patternProperties:${pattern}>`\n\t\t\t\t: `<patternProperties:${pattern}>`;\n\n\t\t\tif (subPropDef === undefined) {\n\t\t\t\t// sub doesn't constrain this pattern at all — more permissive\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: ppPath,\n\t\t\t\t\texpected: formatSchemaType(supPropDef),\n\t\t\t\t\treceived: \"no constraint for this pattern\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Both define the same pattern — recurse\n\t\t\t\tconst ppErrors = computeSemanticErrors(subPropDef, supPropDef, ppPath);\n\t\t\t\terrors.push(...ppErrors);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Compares array constraints (excluding items) between sub and sup.\n */\nfunction checkArrayConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\tcheckMinConstraint(\n\t\tsub.minItems,\n\t\tsup.minItems,\n\t\t\"minItems\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ArrayConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maxItems,\n\t\tsup.maxItems,\n\t\t\"maxItems\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ArrayConstraint,\n\t);\n\n\t// ── uniqueItems ──\n\tif (sup.uniqueItems === true && sub.uniqueItems !== true) {\n\t\terrors.push({\n\t\t\ttype: SchemaErrorType.ArrayConstraint,\n\t\t\tkey: path || \"$root\",\n\t\t\texpected: \"uniqueItems: true\",\n\t\t\treceived: fmtConstraint(\"uniqueItems\", sub.uniqueItems ?? false),\n\t\t});\n\t}\n\n\t// ── contains ──\n\tif (sup.contains !== undefined) {\n\t\tif (sub.contains === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.ArrayConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: `contains: ${formatSchemaType(sup.contains as JSONSchema7Definition)}`,\n\t\t\t\treceived: \"no contains constraint\",\n\t\t\t});\n\t\t} else {\n\t\t\t// Both have contains — recurse to compare the contained schemas\n\t\t\tconst containsPath = path ? `${path}.<contains>` : \"<contains>\";\n\t\t\tconst containsErrors = computeSemanticErrors(\n\t\t\t\tsub.contains as JSONSchema7Definition,\n\t\t\t\tsup.contains as JSONSchema7Definition,\n\t\t\t\tcontainsPath,\n\t\t\t);\n\t\t\terrors.push(...containsErrors);\n\t\t}\n\t}\n}\n\n/**\n * Detects whether a schema has a numeric type.\n */\nfunction isNumericType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"number\" || t === \"integer\";\n\treturn t.some((v) => v === \"number\" || v === \"integer\");\n}\n\n/**\n * Detects whether a schema has a string type.\n */\nfunction isStringType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"string\";\n\treturn t.includes(\"string\");\n}\n\n/**\n * Detects whether a schema has an object type.\n */\nfunction isObjectType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"object\";\n\treturn t.includes(\"object\");\n}\n\n/**\n * Detects whether a schema has an array type.\n */\nfunction isArrayType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"array\";\n\treturn t.includes(\"array\");\n}\n\n// ─── Keyword-based implicit type detection ───────────────────────────────────\n//\n// propertyNames schemas (e.g. { minLength: 1 }) don't always carry an explicit\n// `type`, yet their keywords unambiguously imply a type family. These helpers\n// let us trigger the right constraint checks even when `getEffectiveType`\n// returns `undefined`.\n\nfunction hasNumericKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minimum !== undefined ||\n\t\ts.maximum !== undefined ||\n\t\ts.exclusiveMinimum !== undefined ||\n\t\ts.exclusiveMaximum !== undefined ||\n\t\ts.multipleOf !== undefined\n\t);\n}\n\nfunction hasStringKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minLength !== undefined ||\n\t\ts.maxLength !== undefined ||\n\t\ts.pattern !== undefined ||\n\t\ts.format !== undefined\n\t);\n}\n\nfunction hasObjectKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minProperties !== undefined ||\n\t\ts.maxProperties !== undefined ||\n\t\ts.propertyNames !== undefined ||\n\t\ts.additionalProperties !== undefined ||\n\t\tisPlainObj(s.patternProperties) ||\n\t\tisPlainObj(s.dependencies)\n\t);\n}\n\nfunction hasArrayKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minItems !== undefined ||\n\t\ts.maxItems !== undefined ||\n\t\ts.uniqueItems !== undefined ||\n\t\ts.contains !== undefined\n\t);\n}\n\n// ─── Core Comparison ─────────────────────────────────────────────────────────\n\n/**\n * Compares two schemas and produces semantic errors.\n *\n * @param sub The source schema (what is produced / received)\n * @param sup The target schema (what is expected)\n * @param path The current normalized path\n * @returns List of semantic errors\n */\n/**\n * Lightweight semantic check for whether `sub` trivially satisfies `sup.not`.\n *\n * Returns:\n * - `true` — the `not` is definitely satisfied (no error should be reported)\n * - `false` — the `not` is definitely violated (error should be reported)\n * - `null` — cannot determine (fall back to structural check)\n *\n * This inlines the most common cases from `evaluateNot` in `subset-checker.ts`\n * to avoid circular imports.\n */\nfunction isNotSatisfied(sub: JSONSchema7, sup: JSONSchema7): boolean | null {\n\tif (\n\t\t!hasOwn(sup, \"not\") ||\n\t\t!isPlainObj(sup.not) ||\n\t\ttypeof sup.not === \"boolean\"\n\t) {\n\t\treturn null;\n\t}\n\tconst notSchema = sup.not as JSONSchema7;\n\n\t// ── Type disjointness ──\n\t// If sub has a type and not has a type, and they're completely disjoint → satisfied\n\tif (sub.type !== undefined && notSchema.type !== undefined) {\n\t\tconst subTypes = Array.isArray(sub.type) ? sub.type : [sub.type];\n\t\tconst notTypes = Array.isArray(notSchema.type)\n\t\t\t? notSchema.type\n\t\t\t: [notSchema.type];\n\t\tconst hasOverlap = subTypes.some((t) => notTypes.includes(t));\n\n\t\t// Only consider pure type-only not schemas (no extra constraints)\n\t\tconst notKeys = Object.keys(notSchema);\n\t\tconst isTypeOnly = notKeys.length === 1 && notKeys[0] === \"type\";\n\n\t\tif (isTypeOnly) {\n\t\t\tif (!hasOverlap) return true; // disjoint types → not is satisfied\n\t\t\t// If sub's types are entirely within not's types → definitely violated\n\t\t\tif (subTypes.every((t) => notTypes.includes(t))) return false;\n\t\t}\n\t}\n\n\t// ── Const disjointness ──\n\tif (hasOwn(notSchema, \"const\")) {\n\t\tif (hasOwn(sub, \"const\")) {\n\t\t\treturn !deepEqual(sub.const, notSchema.const);\n\t\t}\n\t\tif (Array.isArray(sub.enum)) {\n\t\t\tconst allDisjoint = sub.enum.every((v) => !deepEqual(v, notSchema.const));\n\t\t\tif (allDisjoint) return true;\n\t\t}\n\t}\n\n\t// ── Enum disjointness ──\n\tif (Array.isArray(notSchema.enum)) {\n\t\tif (hasOwn(sub, \"const\")) {\n\t\t\tconst constInNotEnum = notSchema.enum.some((v) =>\n\t\t\t\tdeepEqual(v, sub.const),\n\t\t\t);\n\t\t\tif (!constInNotEnum) return true;\n\t\t\treturn false;\n\t\t}\n\t\tif (Array.isArray(sub.enum)) {\n\t\t\tconst hasOverlap = sub.enum.some((v) =>\n\t\t\t\tnotSchema.enum?.some((nv) => deepEqual(v, nv)),\n\t\t\t);\n\t\t\tif (!hasOverlap) return true;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function computeSemanticErrors(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n\tpath = \"\",\n): SchemaError[] {\n\t// ── Boolean schemas ──\n\tif (typeof sup === \"boolean\") {\n\t\tif (sup === false) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: \"never\",\n\t\t\t\t\treceived: formatSchemaType(sub),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn []; // sup = true accepts everything\n\t}\n\tif (typeof sub === \"boolean\") {\n\t\tif (sub === true) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatSchemaType(sup),\n\t\t\t\t\treceived: \"any\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn []; // sub = false produces nothing, trivially subset\n\t}\n\n\tconst subSchema = sub as JSONSchema7;\n\tconst supSchema = sup as JSONSchema7;\n\n\tconst errors: SchemaError[] = [];\n\n\t// ── Handle `not` keyword ──\n\t// Use semantic evaluation to check if the `not` is satisfied before\n\t// falling back to structural comparison.\n\tif (\n\t\thasOwn(supSchema, \"not\") &&\n\t\tisPlainObj(supSchema.not) &&\n\t\ttypeof supSchema.not !== \"boolean\"\n\t) {\n\t\tconst notSchema = supSchema.not as JSONSchema7;\n\t\tconst notFormatted = formatSchemaType(notSchema);\n\n\t\t// Use semantic evaluation to check if the `not` is satisfied\n\t\tconst notResult = isNotSatisfied(subSchema, supSchema);\n\n\t\tif (notResult === false) {\n\t\t\t// Sub definitely violates the `not` → confirmed error\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NotSchema,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: `not ${notFormatted}`,\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t} else if (notResult === null) {\n\t\t\t// Indeterminate → fall back to structural check\n\t\t\tif (!hasOwn(subSchema, \"not\")) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.NotSchema,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: `not ${notFormatted}`,\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t});\n\t\t\t} else if (\n\t\t\t\tisPlainObj(subSchema.not) &&\n\t\t\t\ttypeof subSchema.not !== \"boolean\"\n\t\t\t) {\n\t\t\t\tconst subNotSchema = subSchema.not as JSONSchema7;\n\t\t\t\tif (!deepEqual(subNotSchema, notSchema)) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\ttype: SchemaErrorType.NotSchema,\n\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\texpected: `not ${notFormatted}`,\n\t\t\t\t\t\treceived: `not ${formatSchemaType(subNotSchema)}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// If notResult === true → not is satisfied, no error\n\t}\n\n\t// ── Get effective types ──\n\tconst subType = getEffectiveType(subSchema);\n\tconst supType = getEffectiveType(supSchema);\n\n\t// ── Handle anyOf/oneOf in sup ──\n\t// If sup has branches, try to find the best matching one for error reporting\n\tconst supBranches = supSchema.anyOf ?? supSchema.oneOf;\n\tif (Array.isArray(supBranches) && supBranches.length > 0 && !supSchema.type) {\n\t\treturn computeErrorsAgainstBranches(subSchema, supBranches, path);\n\t}\n\n\t// ── Handle anyOf/oneOf in sub ──\n\tconst subBranches = subSchema.anyOf ?? subSchema.oneOf;\n\tif (Array.isArray(subBranches) && subBranches.length > 0 && !subSchema.type) {\n\t\tconst branchErrors: SchemaError[] = [];\n\t\tfor (const branch of subBranches) {\n\t\t\tconst errs = computeSemanticErrors(branch, sup, path);\n\t\t\tbranchErrors.push(...errs);\n\t\t}\n\t\treturn branchErrors;\n\t}\n\n\t// ── Both are object types → compare properties + object constraints ──\n\tconst supProps = getProperties(supSchema);\n\tconst subProps = getProperties(subSchema);\n\n\tif (supProps !== null || isObjectType(supType)) {\n\t\t// sup is an object schema\n\t\tif (subType !== undefined && !typeIncludes(subType, \"object\")) {\n\t\t\t// sub is not an object at all\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t\treturn errors;\n\t\t}\n\n\t\tif (supProps !== null) {\n\t\t\tconst supRequired = getRequired(supSchema);\n\t\t\tconst subRequired = getRequired(subSchema);\n\n\t\t\tfor (const key of Object.keys(supProps)) {\n\t\t\t\tconst propPath = joinPath(path, key);\n\t\t\t\tconst supPropDef = supProps[key];\n\t\t\t\tconst subPropDef = subProps?.[key];\n\n\t\t\t\tif (supPropDef === undefined) continue;\n\n\t\t\t\tconst isRequiredInSup = supRequired.includes(key);\n\n\t\t\t\t// ── Missing property (required in sup, absent in sub) ──\n\t\t\t\tif (subPropDef === undefined) {\n\t\t\t\t\tif (isRequiredInSup) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\ttype: SchemaErrorType.MissingProperty,\n\t\t\t\t\t\t\tkey: propPath,\n\t\t\t\t\t\t\texpected: formatSchemaType(supPropDef),\n\t\t\t\t\t\t\treceived: \"undefined\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// ── Optionality mismatch (required in sup, optional in sub) ──\n\t\t\t\tif (isRequiredInSup && !subRequired.includes(key)) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\ttype: SchemaErrorType.Optionality,\n\t\t\t\t\t\tkey: propPath,\n\t\t\t\t\t\texpected: \"not optional\",\n\t\t\t\t\t\treceived: \"optional\",\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// ── Recurse into the property schemas ──\n\t\t\t\tconst propErrors = comparePropertySchemas(\n\t\t\t\t\tsubPropDef,\n\t\t\t\t\tsupPropDef,\n\t\t\t\t\tpropPath,\n\t\t\t\t);\n\t\t\t\terrors.push(...propErrors);\n\t\t\t}\n\t\t}\n\n\t\t// ── Object-level constraints ──\n\t\tcheckObjectConstraints(subSchema, supSchema, path, errors);\n\n\t\treturn errors;\n\t}\n\n\t// ── Both are array types → compare items + array constraints ──\n\tif (\n\t\t(supType === \"array\" || supSchema.items !== undefined) &&\n\t\t(subType === \"array\" || subSchema.items !== undefined)\n\t) {\n\t\t// Check items compatibility\n\t\tif (supSchema.items !== undefined && typeof supSchema.items !== \"boolean\") {\n\t\t\tif (\n\t\t\t\tsubSchema.items !== undefined &&\n\t\t\t\ttypeof subSchema.items !== \"boolean\"\n\t\t\t) {\n\t\t\t\t// Both have items schemas — recurse\n\t\t\t\tif (Array.isArray(supSchema.items) && Array.isArray(subSchema.items)) {\n\t\t\t\t\t// Tuple comparison\n\t\t\t\t\tconst maxLen = Math.max(\n\t\t\t\t\t\tsupSchema.items.length,\n\t\t\t\t\t\tsubSchema.items.length,\n\t\t\t\t\t);\n\t\t\t\t\tfor (let i = 0; i < maxLen; i++) {\n\t\t\t\t\t\tconst supItem = supSchema.items[i];\n\t\t\t\t\t\tconst subItem = subSchema.items[i];\n\t\t\t\t\t\tconst itemPath = joinPath(path, `[${i}]`);\n\t\t\t\t\t\tif (supItem !== undefined && subItem === undefined) {\n\t\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\t\ttype: SchemaErrorType.MissingProperty,\n\t\t\t\t\t\t\t\tkey: itemPath,\n\t\t\t\t\t\t\t\texpected: formatSchemaType(supItem),\n\t\t\t\t\t\t\t\treceived: \"undefined\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if (supItem !== undefined && subItem !== undefined) {\n\t\t\t\t\t\t\terrors.push(...computeSemanticErrors(subItem, supItem, itemPath));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\t!Array.isArray(supSchema.items) &&\n\t\t\t\t\t!Array.isArray(subSchema.items)\n\t\t\t\t) {\n\t\t\t\t\t// Single items schema — recurse with [] path\n\t\t\t\t\tconst itemPath = arrayPath(path);\n\t\t\t\t\tconst itemErrors = computeSemanticErrors(\n\t\t\t\t\t\tsubSchema.items as JSONSchema7Definition,\n\t\t\t\t\t\tsupSchema.items as JSONSchema7Definition,\n\t\t\t\t\t\titemPath,\n\t\t\t\t\t);\n\t\t\t\t\terrors.push(...itemErrors);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// sup has items schema but sub doesn't\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// ── Array-level constraints ──\n\t\tcheckArrayConstraints(subSchema, supSchema, path, errors);\n\n\t\treturn errors;\n\t}\n\n\t// ── Type mismatch at current level ──\n\tif (subType !== undefined && supType !== undefined) {\n\t\tif (!typesAreCompatible(subType, supType)) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t\treturn errors;\n\t\t}\n\t}\n\n\t// ── Enum comparison ──\n\tif (Array.isArray(supSchema.enum)) {\n\t\tif (Array.isArray(subSchema.enum)) {\n\t\t\t// Both have enums — check if sub.enum ⊆ sup.enum\n\t\t\tconst subExtra = subSchema.enum.filter(\n\t\t\t\t(v) => !supSchema.enum?.some((sv) => deepEqual(v, sv)),\n\t\t\t);\n\t\t\tif (subExtra.length > 0) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\treceived: formatEnumValues(subSchema.enum),\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (hasOwn(subSchema, \"const\")) {\n\t\t\t// sub has const, sup has enum — check inclusion\n\t\t\tconst constInEnum = supSchema.enum.some((v) =>\n\t\t\t\tdeepEqual(v, subSchema.const),\n\t\t\t);\n\t\t\tif (!constInEnum) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// sup has enum but sub is a plain type (no enum restriction)\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t}\n\t\treturn errors;\n\t}\n\n\t// ── Const comparison ──\n\tif (hasOwn(supSchema, \"const\") && hasOwn(subSchema, \"const\")) {\n\t\tif (!deepEqual(supSchema.const, subSchema.const)) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t}\n\t\treturn errors;\n\t}\n\n\t// ── Same-type constraint comparison ──\n\t// Types are compatible (or unspecified), now check individual keywords.\n\n\tif (\n\t\tisNumericType(subType) ||\n\t\tisNumericType(supType) ||\n\t\thasNumericKeywords(supSchema) ||\n\t\thasNumericKeywords(subSchema)\n\t) {\n\t\tcheckNumericConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\tif (\n\t\tisStringType(subType) ||\n\t\tisStringType(supType) ||\n\t\thasStringKeywords(supSchema) ||\n\t\thasStringKeywords(subSchema)\n\t) {\n\t\tcheckStringConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\t// Object-level constraints when sup doesn't have explicit properties\n\t// but still has object constraints (e.g., just { type: \"object\", minProperties: 3 })\n\tif (\n\t\tisObjectType(subType) ||\n\t\tisObjectType(supType) ||\n\t\thasObjectKeywords(supSchema) ||\n\t\thasObjectKeywords(subSchema)\n\t) {\n\t\tcheckObjectConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\t// Array-level constraints when sup doesn't have explicit items\n\t// but still has array constraints (e.g., just { type: \"array\", minItems: 2 })\n\tif (\n\t\tisArrayType(subType) ||\n\t\tisArrayType(supType) ||\n\t\thasArrayKeywords(supSchema) ||\n\t\thasArrayKeywords(subSchema)\n\t) {\n\t\tcheckArrayConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\tif (errors.length > 0) {\n\t\treturn errors;\n\t}\n\n\t// ── Fallback: generic incompatibility ──\n\t// If we get here, there's an incompatibility we couldn't pinpoint precisely.\n\t// Produce a root-level error with the formatted types.\n\tconst expectedStr = formatSchemaType(supSchema);\n\tconst receivedStr = formatSchemaType(subSchema);\n\tif (expectedStr !== receivedStr) {\n\t\terrors.push({\n\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\tkey: path || \"$root\",\n\t\t\texpected: expectedStr,\n\t\t\treceived: receivedStr,\n\t\t});\n\t}\n\n\treturn errors;\n}\n\n// ─── Property Schema Comparison ──────────────────────────────────────────────\n\n/**\n * Compares two property schemas and produces errors.\n * Handles recursion into nested objects and arrays.\n */\nfunction comparePropertySchemas(\n\tsubDef: JSONSchema7Definition,\n\tsupDef: JSONSchema7Definition,\n\tpath: string,\n): SchemaError[] {\n\tif (typeof subDef === \"boolean\" || typeof supDef === \"boolean\") {\n\t\tif (subDef !== supDef) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path,\n\t\t\t\t\texpected: formatSchemaType(supDef),\n\t\t\t\t\treceived: formatSchemaType(subDef),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t}\n\n\tconst subSchema = subDef as JSONSchema7;\n\tconst supSchema = supDef as JSONSchema7;\n\n\tconst subType = getEffectiveType(subSchema);\n\tconst supType = getEffectiveType(supSchema);\n\n\t// ── Enum comparison (before type check, as enums can cross types) ──\n\tif (Array.isArray(supSchema.enum)) {\n\t\tif (Array.isArray(subSchema.enum)) {\n\t\t\tconst subExtra = subSchema.enum.filter(\n\t\t\t\t(v) => !supSchema.enum?.some((sv) => deepEqual(v, sv)),\n\t\t\t);\n\t\t\tif (subExtra.length > 0) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\t\tkey: path,\n\t\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\t\treceived: formatEnumValues(subSchema.enum),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\t\tif (hasOwn(subSchema, \"const\")) {\n\t\t\tconst constInEnum = supSchema.enum.some((v) =>\n\t\t\t\tdeepEqual(v, subSchema.const),\n\t\t\t);\n\t\t\tif (!constInEnum) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\t\tkey: path,\n\t\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\t\t// sup has enum, sub is a plain type\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\tkey: path,\n\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t},\n\t\t];\n\t}\n\n\t// ── Const comparison ──\n\tif (hasOwn(supSchema, \"const\") && hasOwn(subSchema, \"const\")) {\n\t\tif (!deepEqual(supSchema.const, subSchema.const)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\tkey: path,\n\t\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t}\n\n\t// ── Type mismatch ──\n\tif (subType !== undefined && supType !== undefined) {\n\t\tif (!typesAreCompatible(subType, supType)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path,\n\t\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t}\n\n\t// ── If same types, recurse deeper ──\n\treturn computeSemanticErrors(subDef, supDef, path);\n}\n\n// ─── Branch Error Computation ────────────────────────────────────────────────\n\n/**\n * When sup has branches (anyOf/oneOf), attempts to find the closest\n * matching branch and generates errors against it.\n *\n * Strategy: compute errors for each branch and return those from the\n * branch with the fewest errors (best match).\n */\nfunction computeErrorsAgainstBranches(\n\tsub: JSONSchema7,\n\tbranches: JSONSchema7Definition[],\n\tpath: string,\n): SchemaError[] {\n\tlet bestErrors: SchemaError[] | null = null;\n\n\tfor (const branch of branches) {\n\t\tconst errors = computeSemanticErrors(sub, branch, path);\n\t\tif (errors.length === 0) return [];\n\t\tif (bestErrors === null || errors.length < bestErrors.length) {\n\t\t\tbestErrors = errors;\n\t\t}\n\t}\n\n\treturn (\n\t\tbestErrors ?? [\n\t\t\t{\n\t\t\t\ttype: SchemaErrorType.BranchMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType({ anyOf: branches } as JSONSchema7),\n\t\t\t\treceived: formatSchemaType(sub),\n\t\t\t},\n\t\t]\n\t);\n}\n"],"names":["computeSemanticErrors","formatSchemaType","formatEnumValues","values","parts","map","v","JSON","stringify","length","last","pop","join","def","formatSchemaTypeInternal","undefined","schema","hasOwn","const","Array","isArray","enum","branches","anyOf","oneOf","b","type","items","itemSchema","itemBranches","t","itemType","isPlainObj","properties","not","joinPath","parent","key","arrayPath","getProperties","getRequired","required","getEffectiveType","typeIncludes","schemaType","target","includes","typesAreCompatible","subType","supType","some","every","st","supt","fmtConstraint","name","value","checkMinConstraint","subVal","supVal","path","errors","push","expected","received","checkMaxConstraint","checkNumericConstraints","sub","sup","subMin","minimum","subExclMin","exclusiveMinimum","subMax","maximum","subExclMax","exclusiveMaximum","supMin","supExclMin","supMax","supExclMax","satisfiedByMin","satisfiedByExclMin","SchemaErrorType","NumericConstraint","satisfiedByMax","satisfiedByExclMax","multipleOf","checkStringConstraints","minLength","StringConstraint","maxLength","pattern","format","checkObjectConstraints","additionalProperties","ObjectConstraint","apPath","apErrors","minProperties","maxProperties","propertyNames","pnErrors","dependencies","supDeps","subDeps","subRequired","subProps","Object","keys","supDep","subDep","allDepsAlwaysRequired","d","triggerNeverProduced","missing","filter","depPath","depErrors","patternProperties","supPP","subPP","supPropDef","subPropDef","ppPath","ppErrors","checkArrayConstraints","minItems","ArrayConstraint","maxItems","uniqueItems","contains","containsPath","containsErrors","isNumericType","isStringType","isObjectType","isArrayType","hasNumericKeywords","s","hasStringKeywords","hasObjectKeywords","hasArrayKeywords","isNotSatisfied","notSchema","subTypes","notTypes","hasOverlap","notKeys","isTypeOnly","deepEqual","allDisjoint","constInNotEnum","nv","TypeMismatch","subSchema","supSchema","notFormatted","notResult","NotSchema","subNotSchema","supBranches","computeErrorsAgainstBranches","subBranches","branchErrors","branch","errs","supProps","supRequired","propPath","isRequiredInSup","MissingProperty","Optionality","propErrors","comparePropertySchemas","maxLen","Math","max","i","supItem","subItem","itemPath","itemErrors","subExtra","sv","EnumMismatch","constInEnum","expectedStr","receivedStr","subDef","supDef","bestErrors","BranchMismatch"],"mappings":"mPA2+BgBA,+BAAAA,2BAp7BAC,0BAAAA,2CArDgB,qCACc,cA6B9C,SAASC,iBAAiBC,MAAiB,EAC1C,MAAMC,MAAQD,OAAOE,GAAG,CAAC,AAACC,GACzB,OAAOA,IAAM,SAAWA,EAAIC,KAAKC,SAAS,CAACF,IAE5C,GAAIF,MAAMK,MAAM,GAAK,EAAG,MAAO,QAC/B,GAAIL,MAAMK,MAAM,GAAK,EAAG,OAAOL,KAAK,CAAC,EAAE,CACvC,GAAIA,MAAMK,MAAM,GAAK,EAAG,MAAO,CAAC,EAAEL,KAAK,CAAC,EAAE,CAAC,IAAI,EAAEA,KAAK,CAAC,EAAE,CAAC,CAAC,CAC3D,MAAMM,KAAON,MAAMO,GAAG,GACtB,MAAO,CAAC,EAAEP,MAAMQ,IAAI,CAAC,MAAM,KAAK,EAAEF,KAAK,CAAC,AACzC,CAcO,SAAST,iBACfY,GAAsC,EAEtC,OAAOC,yBAAyBD,IACjC,CAEA,SAASC,yBACRD,GAAsC,EAEtC,GAAIA,MAAQE,UAAW,MAAO,YAC9B,GAAI,OAAOF,MAAQ,UAAW,OAAOA,IAAM,MAAQ,QAEnD,MAAMG,OAASH,IAGf,GAAII,GAAAA,eAAM,EAACD,OAAQ,SAAU,CAC5B,MAAMV,EAAIU,OAAOE,KAAK,CACtB,OAAO,OAAOZ,IAAM,SAAWA,EAAIC,KAAKC,SAAS,CAACF,EACnD,CAGA,GAAIa,MAAMC,OAAO,CAACJ,OAAOK,IAAI,EAAG,CAC/B,OAAOnB,iBAAiBc,OAAOK,IAAI,CACpC,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QC,OAAQlI,KAC9C,CAWA,SAASsG,6BACR/F,GAAgB,CAChB7C,QAAiC,CACjCsC,IAAY,EAEZ,IAAImI,WAAmC,KAEvC,IAAK,MAAM1B,UAAU/I,SAAU,CAC9B,MAAMuC,OAAS7D,sBAAsBmE,IAAKkG,OAAQzG,MAClD,GAAIC,OAAOpD,MAAM,GAAK,EAAG,MAAO,EAAE,CAClC,GAAIsL,aAAe,MAAQlI,OAAOpD,MAAM,CAAGsL,WAAWtL,MAAM,CAAE,CAC7DsL,WAAalI,MACd,CACD,CAEA,OACCkI,YAAc,CACb,CACCrK,KAAMyD,wBAAe,CAAC6G,cAAc,CACpC3J,IAAKuB,MAAQ,QACbG,SAAU9D,iBAAiB,CAAEsB,MAAOD,QAAS,GAC7C0C,SAAU/D,iBAAiBkE,IAC5B,EACA,AAEH"}
|
|
1
|
+
{"version":3,"sources":["../../src/semantic-errors.ts"],"sourcesContent":["import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport type { SchemaError } from \"./types.ts\";\nimport { SchemaErrorType } from \"./types.ts\";\nimport { deepEqual, hasOwn, isPlainObj } from \"./utils.ts\";\n\n// ─── Semantic Error Generator ────────────────────────────────────────────────\n//\n// Generates human-readable semantic errors by directly comparing two schemas.\n//\n// Unlike a structural differ (which would compare sub vs merged), this module\n// directly compares sub (source/received) and sup (target/expected) to produce\n// business-oriented error messages.\n//\n// Property paths are normalized:\n// - `accountId` (top-level property)\n// - `user.name` (nested property)\n// - `users[].name` (property inside array items)\n//\n// Convention:\n// - `expected` = what the target schema (sup) expects\n// - `received` = what the source schema (sub) provides\n\n// ─── Type Formatting ─────────────────────────────────────────────────────────\n\n/**\n * Formats enum values into a readable string.\n *\n * Examples:\n * - 1 value : `\"123\"`\n * - 2 values : `\"123 or hello\"`\n * - 3 values : `\"10, 20, or 30\"`\n */\nfunction formatEnumValues(values: unknown[]): string {\n\tconst parts = values.map((v) =>\n\t\ttypeof v === \"string\" ? v : JSON.stringify(v),\n\t);\n\tif (parts.length === 0) return \"never\";\n\tif (parts.length === 1) return parts[0] as string;\n\tif (parts.length === 2) return `${parts[0]} or ${parts[1]}`;\n\tconst last = parts.pop();\n\treturn `${parts.join(\", \")}, or ${last}`;\n}\n\n/**\n * Formats a schema into a readable type representation.\n *\n * Examples:\n * - `{ type: \"string\" }` → `\"string\"`\n * - `{ type: \"array\", items: { type: \"string\" } }` → `\"string[]\"`\n * - `{ type: \"array\", items: { type: [\"string\",\"number\"] }` → `\"string[] | number[]\"`\n * - `{ enum: [1, 2, 3] }` → `\"1, 2, or 3\"`\n * - `{ const: \"hello\" }` → `\"hello\"`\n * - `{ anyOf: [{type:\"string\"},{type:\"number\"}] }` → `\"string | number\"`\n * - `undefined` → `\"undefined\"`\n */\nexport function formatSchemaType(\n\tdef: JSONSchema7Definition | undefined,\n): string {\n\treturn formatSchemaTypeInternal(def);\n}\n\nfunction formatSchemaTypeInternal(\n\tdef: JSONSchema7Definition | undefined,\n): string {\n\tif (def === undefined) return \"undefined\";\n\tif (typeof def === \"boolean\") return def ? \"any\" : \"never\";\n\n\tconst schema = def as JSONSchema7;\n\n\t// ── Const ──\n\tif (hasOwn(schema, \"const\")) {\n\t\tconst v = schema.const;\n\t\treturn typeof v === \"string\" ? v : JSON.stringify(v);\n\t}\n\n\t// ── Enum ──\n\tif (Array.isArray(schema.enum)) {\n\t\treturn formatEnumValues(schema.enum);\n\t}\n\n\t// ── anyOf / oneOf (union types) ──\n\tconst branches = schema.anyOf ?? schema.oneOf;\n\tif (Array.isArray(branches) && branches.length > 0) {\n\t\tconst parts = branches.map((b) => formatSchemaType(b));\n\t\treturn parts.join(\" | \");\n\t}\n\n\t// ── Array type ──\n\tif (schema.type === \"array\") {\n\t\tif (schema.items !== undefined && typeof schema.items !== \"boolean\") {\n\t\t\tconst itemSchema = schema.items as JSONSchema7;\n\n\t\t\t// Items with anyOf/oneOf → \"string[] | number[]\"\n\t\t\tconst itemBranches = itemSchema.anyOf ?? itemSchema.oneOf;\n\t\t\tif (Array.isArray(itemBranches) && itemBranches.length > 0) {\n\t\t\t\tconst parts = itemBranches.map((b) => `${formatSchemaType(b)}[]`);\n\t\t\t\treturn parts.join(\" | \");\n\t\t\t}\n\n\t\t\t// Items with multiple types → \"string[] | number[]\"\n\t\t\tif (Array.isArray(itemSchema.type)) {\n\t\t\t\tconst parts = itemSchema.type.map((t) => `${t}[]`);\n\t\t\t\treturn parts.join(\" | \");\n\t\t\t}\n\n\t\t\tconst itemType = formatSchemaType(itemSchema);\n\t\t\treturn `${itemType}[]`;\n\t\t}\n\t\t// items is boolean true or missing\n\t\treturn \"array\";\n\t}\n\n\t// ── Simple type ──\n\tif (typeof schema.type === \"string\") {\n\t\treturn schema.type;\n\t}\n\n\t// ── Multiple types (type: [\"string\", \"number\"]) ──\n\tif (Array.isArray(schema.type)) {\n\t\treturn schema.type.join(\" | \");\n\t}\n\n\t// ── not (pure-not schema, no other significant keywords) ──\n\tif (\n\t\thasOwn(schema, \"not\") &&\n\t\t!schema.type &&\n\t\t!isPlainObj(schema.properties) &&\n\t\tschema.items === undefined &&\n\t\t!Array.isArray(schema.enum) &&\n\t\t!hasOwn(schema, \"const\")\n\t) {\n\t\treturn `not ${formatSchemaType(schema.not as JSONSchema7Definition)}`;\n\t}\n\n\t// ── Fallback ──\n\t// Schema without explicit type — try to infer from structure\n\tif (isPlainObj(schema.properties)) return \"object\";\n\tif (schema.items !== undefined) return \"array\";\n\n\treturn \"unknown\";\n}\n\n// ─── Path Helpers ────────────────────────────────────────────────────────────\n\n/**\n * Builds a normalized property path.\n * - Root + key → `\"accountId\"`\n * - Parent + key → `\"user.name\"`\n * - Parent[] + key → `\"users[].name\"`\n */\nfunction joinPath(parent: string, key: string): string {\n\tif (!parent) return key;\n\treturn `${parent}.${key}`;\n}\n\n/**\n * Appends the `[]` suffix to indicate entering array items.\n */\nfunction arrayPath(parent: string): string {\n\tif (!parent) return \"[]\";\n\treturn `${parent}[]`;\n}\n\n// ─── Schema Accessors ────────────────────────────────────────────────────────\n\n/**\n * Safely extracts the properties from a schema.\n */\nfunction getProperties(\n\tschema: JSONSchema7,\n): Record<string, JSONSchema7Definition> | null {\n\tif (isPlainObj(schema.properties)) {\n\t\treturn schema.properties as Record<string, JSONSchema7Definition>;\n\t}\n\treturn null;\n}\n\n/**\n * Safely extracts the required fields from a schema.\n */\nfunction getRequired(schema: JSONSchema7): string[] {\n\tif (Array.isArray(schema.required)) {\n\t\treturn schema.required as string[];\n\t}\n\treturn [];\n}\n\n/**\n * Determines the effective type of a schema (string or array of types).\n */\nfunction getEffectiveType(schema: JSONSchema7): string | string[] | undefined {\n\tif (schema.type !== undefined) return schema.type as string | string[];\n\n\t// Infer from const\n\tif (hasOwn(schema, \"const\")) {\n\t\tconst v = schema.const;\n\t\tif (v === null) return \"null\";\n\t\tif (Array.isArray(v)) return \"array\";\n\t\treturn typeof v;\n\t}\n\n\t// Infer from properties\n\tif (isPlainObj(schema.properties)) return \"object\";\n\n\t// Infer from items\n\tif (schema.items !== undefined) return \"array\";\n\n\treturn undefined;\n}\n\n/**\n * Checks whether a type (string) is included in a type or array of types.\n */\nfunction typeIncludes(\n\tschemaType: string | string[] | undefined,\n\ttarget: string,\n): boolean {\n\tif (schemaType === undefined) return false;\n\tif (typeof schemaType === \"string\") {\n\t\t// integer is a subset of number\n\t\tif (target === \"number\" && schemaType === \"integer\") return true;\n\t\tif (target === \"integer\" && schemaType === \"number\") return true;\n\t\treturn schemaType === target;\n\t}\n\treturn schemaType.includes(target);\n}\n\n/**\n * Checks whether two types are compatible.\n * A type is compatible if the sub type is included in the sup type.\n */\nfunction typesAreCompatible(\n\tsubType: string | string[] | undefined,\n\tsupType: string | string[] | undefined,\n): boolean {\n\tif (supType === undefined) return true; // sup accepts anything\n\tif (subType === undefined) return true; // sub is undetermined, cannot conclude\n\n\tif (typeof subType === \"string\" && typeof supType === \"string\") {\n\t\tif (subType === supType) return true;\n\t\t// integer ⊆ number\n\t\tif (subType === \"integer\" && supType === \"number\") return true;\n\t\treturn false;\n\t}\n\n\tif (typeof subType === \"string\" && Array.isArray(supType)) {\n\t\treturn supType.some(\n\t\t\t(t) => t === subType || (subType === \"integer\" && t === \"number\"),\n\t\t);\n\t}\n\n\tif (Array.isArray(subType) && typeof supType === \"string\") {\n\t\treturn subType.every(\n\t\t\t(t) => t === supType || (t === \"integer\" && supType === \"number\"),\n\t\t);\n\t}\n\n\tif (Array.isArray(subType) && Array.isArray(supType)) {\n\t\treturn subType.every((st) =>\n\t\t\tsupType.some(\n\t\t\t\t(supt) => supt === st || (st === \"integer\" && supt === \"number\"),\n\t\t\t),\n\t\t);\n\t}\n\n\treturn true;\n}\n\n// ─── Constraint Helpers ──────────────────────────────────────────────────────\n\n/**\n * Formats a constraint value into a readable string.\n */\nfunction fmtConstraint(name: string, value: unknown): string {\n\tif (value === undefined) return `${name}: not set`;\n\tif (typeof value === \"boolean\") return `${name}: ${value}`;\n\tif (typeof value === \"number\" || typeof value === \"string\")\n\t\treturn `${name}: ${value}`;\n\treturn `${name}: ${JSON.stringify(value)}`;\n}\n\n/**\n * Compares a \"minimum-like\" numeric constraint (sub.X must be >= sup.X for sub ⊆ sup).\n * Examples: minimum, exclusiveMinimum, minLength, minItems, minProperties\n */\nfunction checkMinConstraint(\n\tsubVal: number | undefined,\n\tsupVal: number | undefined,\n\tname: string,\n\tpath: string,\n\terrors: SchemaError[],\n\ttype: SchemaErrorType,\n): void {\n\tif (supVal !== undefined) {\n\t\tif (subVal === undefined || subVal < supVal) {\n\t\t\terrors.push({\n\t\t\t\ttype,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(name, supVal),\n\t\t\t\treceived: fmtConstraint(name, subVal),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Compares a \"maximum-like\" numeric constraint (sub.X must be <= sup.X for sub ⊆ sup).\n * Examples: maximum, exclusiveMaximum, maxLength, maxItems, maxProperties\n */\nfunction checkMaxConstraint(\n\tsubVal: number | undefined,\n\tsupVal: number | undefined,\n\tname: string,\n\tpath: string,\n\terrors: SchemaError[],\n\ttype: SchemaErrorType,\n): void {\n\tif (supVal !== undefined) {\n\t\tif (subVal === undefined || subVal > supVal) {\n\t\t\terrors.push({\n\t\t\t\ttype,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(name, supVal),\n\t\t\t\treceived: fmtConstraint(name, subVal),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Compares numeric constraints between sub and sup.\n */\nfunction checkNumericConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\tconst subMin = sub.minimum;\n\tconst subExclMin = sub.exclusiveMinimum as number | undefined;\n\tconst subMax = sub.maximum;\n\tconst subExclMax = sub.exclusiveMaximum as number | undefined;\n\n\tconst supMin = sup.minimum;\n\tconst supExclMin = sup.exclusiveMinimum as number | undefined;\n\tconst supMax = sup.maximum;\n\tconst supExclMax = sup.exclusiveMaximum as number | undefined;\n\n\t// ── LOWER BOUND cross-check ──\n\n\t// Check sup.minimum\n\tif (supMin !== undefined) {\n\t\t// sub satisfies sup.minimum if:\n\t\t// sub.minimum >= sup.minimum OR\n\t\t// sub.exclusiveMinimum >= sup.minimum (>X implies >=X when X is the same)\n\t\tconst satisfiedByMin = subMin !== undefined && subMin >= supMin;\n\t\tconst satisfiedByExclMin = subExclMin !== undefined && subExclMin >= supMin;\n\n\t\tif (!satisfiedByMin && !satisfiedByExclMin) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"minimum\", supMin),\n\t\t\t\treceived:\n\t\t\t\t\tsubMin !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"minimum\", subMin)\n\t\t\t\t\t\t: subExclMin !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"exclusiveMinimum\", subExclMin)\n\t\t\t\t\t\t\t: fmtConstraint(\"minimum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// Check sup.exclusiveMinimum\n\tif (supExclMin !== undefined) {\n\t\t// sub satisfies sup.exclusiveMinimum if:\n\t\t// sub.exclusiveMinimum >= sup.exclusiveMinimum OR\n\t\t// sub.minimum > sup.exclusiveMinimum (>=X with X>B implies >B)\n\t\tconst satisfiedByExclMin =\n\t\t\tsubExclMin !== undefined && subExclMin >= supExclMin;\n\t\tconst satisfiedByMin = subMin !== undefined && subMin > supExclMin;\n\n\t\tif (!satisfiedByExclMin && !satisfiedByMin) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"exclusiveMinimum\", supExclMin),\n\t\t\t\treceived:\n\t\t\t\t\tsubExclMin !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"exclusiveMinimum\", subExclMin)\n\t\t\t\t\t\t: subMin !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"minimum\", subMin)\n\t\t\t\t\t\t\t: fmtConstraint(\"exclusiveMinimum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── UPPER BOUND cross-check ──\n\n\t// Check sup.maximum\n\tif (supMax !== undefined) {\n\t\t// sub satisfies sup.maximum if:\n\t\t// sub.maximum <= sup.maximum OR\n\t\t// sub.exclusiveMaximum <= sup.maximum\n\t\tconst satisfiedByMax = subMax !== undefined && subMax <= supMax;\n\t\tconst satisfiedByExclMax = subExclMax !== undefined && subExclMax <= supMax;\n\n\t\tif (!satisfiedByMax && !satisfiedByExclMax) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"maximum\", supMax),\n\t\t\t\treceived:\n\t\t\t\t\tsubMax !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"maximum\", subMax)\n\t\t\t\t\t\t: subExclMax !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"exclusiveMaximum\", subExclMax)\n\t\t\t\t\t\t\t: fmtConstraint(\"maximum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// Check sup.exclusiveMaximum\n\tif (supExclMax !== undefined) {\n\t\t// sub satisfies sup.exclusiveMaximum if:\n\t\t// sub.exclusiveMaximum <= sup.exclusiveMaximum OR\n\t\t// sub.maximum < sup.exclusiveMaximum\n\t\tconst satisfiedByExclMax =\n\t\t\tsubExclMax !== undefined && subExclMax <= supExclMax;\n\t\tconst satisfiedByMax = subMax !== undefined && subMax < supExclMax;\n\n\t\tif (!satisfiedByExclMax && !satisfiedByMax) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"exclusiveMaximum\", supExclMax),\n\t\t\t\treceived:\n\t\t\t\t\tsubExclMax !== undefined\n\t\t\t\t\t\t? fmtConstraint(\"exclusiveMaximum\", subExclMax)\n\t\t\t\t\t\t: subMax !== undefined\n\t\t\t\t\t\t\t? fmtConstraint(\"maximum\", subMax)\n\t\t\t\t\t\t\t: fmtConstraint(\"exclusiveMaximum\", undefined),\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── multipleOf (unchanged) ──\n\tif (sup.multipleOf !== undefined) {\n\t\tif (sub.multipleOf === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"multipleOf\", sup.multipleOf),\n\t\t\t\treceived: fmtConstraint(\"multipleOf\", sub.multipleOf),\n\t\t\t});\n\t\t} else if (sub.multipleOf !== sup.multipleOf) {\n\t\t\t// sub.multipleOf must be a multiple of sup.multipleOf for sub ⊆ sup\n\t\t\tif (sub.multipleOf % sup.multipleOf !== 0) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.NumericConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: fmtConstraint(\"multipleOf\", sup.multipleOf),\n\t\t\t\t\treceived: fmtConstraint(\"multipleOf\", sub.multipleOf),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Compares string constraints between sub and sup.\n */\nfunction checkStringConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\tcheckMinConstraint(\n\t\tsub.minLength,\n\t\tsup.minLength,\n\t\t\"minLength\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.StringConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maxLength,\n\t\tsup.maxLength,\n\t\t\"maxLength\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.StringConstraint,\n\t);\n\n\t// ── Pattern ──\n\tif (sup.pattern !== undefined) {\n\t\tif (sub.pattern === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"pattern\", sup.pattern),\n\t\t\t\treceived: \"no pattern constraint\",\n\t\t\t});\n\t\t} else if (sub.pattern !== sup.pattern) {\n\t\t\t// Different patterns — we can't statically determine subset relationship\n\t\t\t// without sampling, so report it as a potential mismatch.\n\t\t\t// The subset checker may have already stripped equivalent patterns,\n\t\t\t// so if we get here, they're genuinely different.\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"pattern\", sup.pattern),\n\t\t\t\treceived: fmtConstraint(\"pattern\", sub.pattern),\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── Format ──\n\tif (sup.format !== undefined && sub.format !== sup.format) {\n\t\tif (sub.format === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"format\", sup.format),\n\t\t\t\treceived: \"no format constraint\",\n\t\t\t});\n\t\t} else {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.StringConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: fmtConstraint(\"format\", sup.format),\n\t\t\t\treceived: fmtConstraint(\"format\", sub.format),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Compares object constraints (excluding properties/required) between sub and sup.\n */\nfunction checkObjectConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\t// ── additionalProperties ──\n\tif (sup.additionalProperties !== undefined) {\n\t\tif (sup.additionalProperties === false) {\n\t\t\t// sup forbids additional properties\n\t\t\tif (\n\t\t\t\tsub.additionalProperties === undefined ||\n\t\t\t\tsub.additionalProperties === true\n\t\t\t) {\n\t\t\t\t// sub allows them → incompatible\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: \"additionalProperties: false\",\n\t\t\t\t\treceived: \"additional properties allowed\",\n\t\t\t\t});\n\t\t\t} else if (\n\t\t\t\ttypeof sub.additionalProperties === \"object\" &&\n\t\t\t\tsub.additionalProperties !== null\n\t\t\t) {\n\t\t\t\t// sub has a schema for additional properties → still allows them\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: \"additionalProperties: false\",\n\t\t\t\t\treceived: \"additionalProperties: schema\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (\n\t\t\ttypeof sup.additionalProperties === \"object\" &&\n\t\t\tsup.additionalProperties !== null\n\t\t) {\n\t\t\t// sup has a schema for additionalProperties\n\t\t\tif (\n\t\t\t\tsub.additionalProperties === undefined ||\n\t\t\t\tsub.additionalProperties === true\n\t\t\t) {\n\t\t\t\t// sub allows anything → more permissive\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: `additionalProperties: ${formatSchemaType(sup.additionalProperties as JSONSchema7Definition)}`,\n\t\t\t\t\treceived: \"additional properties allowed\",\n\t\t\t\t});\n\t\t\t} else if (\n\t\t\t\ttypeof sub.additionalProperties === \"object\" &&\n\t\t\t\tsub.additionalProperties !== null\n\t\t\t) {\n\t\t\t\t// Both have schema-form additionalProperties — recurse\n\t\t\t\tconst apPath = path\n\t\t\t\t\t? `${path}.<additionalProperties>`\n\t\t\t\t\t: \"<additionalProperties>\";\n\t\t\t\tconst apErrors = computeSemanticErrors(\n\t\t\t\t\tsub.additionalProperties as JSONSchema7Definition,\n\t\t\t\t\tsup.additionalProperties as JSONSchema7Definition,\n\t\t\t\t\tapPath,\n\t\t\t\t);\n\t\t\t\terrors.push(...apErrors);\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── minProperties / maxProperties ──\n\tcheckMinConstraint(\n\t\tsub.minProperties,\n\t\tsup.minProperties,\n\t\t\"minProperties\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ObjectConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maxProperties,\n\t\tsup.maxProperties,\n\t\t\"maxProperties\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ObjectConstraint,\n\t);\n\n\t// ── propertyNames ──\n\tif (sup.propertyNames !== undefined) {\n\t\tif (sub.propertyNames === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: `propertyNames: ${formatSchemaType(sup.propertyNames)}`,\n\t\t\t\treceived: \"no propertyNames constraint\",\n\t\t\t});\n\t\t} else {\n\t\t\t// Both have propertyNames — recurse\n\t\t\tconst pnErrors = computeSemanticErrors(\n\t\t\t\tsub.propertyNames as JSONSchema7Definition,\n\t\t\t\tsup.propertyNames as JSONSchema7Definition,\n\t\t\t\tpath ? `${path}.<propertyNames>` : \"<propertyNames>\",\n\t\t\t);\n\t\t\terrors.push(...pnErrors);\n\t\t}\n\t}\n\n\t// ── dependencies ──\n\tif (isPlainObj(sup.dependencies)) {\n\t\tconst supDeps = sup.dependencies as Record<\n\t\t\tstring,\n\t\t\tJSONSchema7Definition | string[]\n\t\t>;\n\t\tconst subDeps = isPlainObj(sub.dependencies)\n\t\t\t? (sub.dependencies as Record<string, JSONSchema7Definition | string[]>)\n\t\t\t: null;\n\n\t\tconst subRequired = Array.isArray(sub.required)\n\t\t\t? (sub.required as string[])\n\t\t\t: [];\n\t\tconst subProps = isPlainObj(sub.properties) ? sub.properties : {};\n\n\t\tfor (const key of Object.keys(supDeps)) {\n\t\t\tconst supDep = supDeps[key];\n\t\t\tconst subDep = subDeps?.[key];\n\n\t\t\tif (subDep === undefined) {\n\t\t\t\tif (Array.isArray(supDep)) {\n\t\t\t\t\t// ── Semantic deduction for array-form dependencies ──\n\t\t\t\t\t//\n\t\t\t\t\t// A dependency `{ A: ['B', 'C'] }` means:\n\t\t\t\t\t// \"if A is present → B and C must also be present\"\n\t\t\t\t\t//\n\t\t\t\t\t// Case 1: All dependent properties (B, C) are in sub.required\n\t\t\t\t\t// → The dependency is trivially satisfied (B and C are ALWAYS present)\n\t\t\t\t\t//\n\t\t\t\t\t// Case 2: The trigger property (A) doesn't exist in sub.properties\n\t\t\t\t\t// AND is not in sub.required\n\t\t\t\t\t// → sub will never produce A, so the dependency is never triggered\n\t\t\t\t\tconst allDepsAlwaysRequired = supDep.every((d) =>\n\t\t\t\t\t\tsubRequired.includes(d),\n\t\t\t\t\t);\n\t\t\t\t\tconst triggerNeverProduced =\n\t\t\t\t\t\t!hasOwn(subProps, key) && !subRequired.includes(key);\n\n\t\t\t\t\tif (!allDepsAlwaysRequired && !triggerNeverProduced) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\t\texpected: `dependency: ${key} requires ${supDep.join(\", \")}`,\n\t\t\t\t\t\t\treceived: `no dependency for ${key}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (isPlainObj(supDep)) {\n\t\t\t\t\t// ── Schema-form dependencies ──\n\t\t\t\t\t// Check if the trigger property is never produced by sub\n\t\t\t\t\tconst triggerNeverProduced =\n\t\t\t\t\t\t!hasOwn(subProps, key) && !subRequired.includes(key);\n\n\t\t\t\t\tif (triggerNeverProduced) {\n\t\t\t\t\t\t// Vacuously true — trigger never fires\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// The trigger exists in sub — check if sub structurally\n\t\t\t\t\t\t// satisfies the dep schema (required + properties).\n\t\t\t\t\t\tconst depSchema = supDep as JSONSchema7;\n\t\t\t\t\t\tconst depRequired = Array.isArray(depSchema.required)\n\t\t\t\t\t\t\t? (depSchema.required as string[])\n\t\t\t\t\t\t\t: [];\n\t\t\t\t\t\tconst depProps = isPlainObj(depSchema.properties)\n\t\t\t\t\t\t\t? (depSchema.properties as Record<string, JSONSchema7Definition>)\n\t\t\t\t\t\t\t: {};\n\n\t\t\t\t\t\tconst allDepRequiredSatisfied = depRequired.every((r) =>\n\t\t\t\t\t\t\tsubRequired.includes(r),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlet allDepPropsSatisfied = true;\n\t\t\t\t\t\tif (allDepRequiredSatisfied) {\n\t\t\t\t\t\t\tfor (const propKey of Object.keys(depProps)) {\n\t\t\t\t\t\t\t\tif (!hasOwn(subProps, propKey)) {\n\t\t\t\t\t\t\t\t\tallDepPropsSatisfied = false;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst subPropDef = subProps[propKey];\n\t\t\t\t\t\t\t\tconst depPropDef = depProps[propKey];\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tsubPropDef === undefined ||\n\t\t\t\t\t\t\t\t\tdepPropDef === undefined ||\n\t\t\t\t\t\t\t\t\ttypeof subPropDef === \"boolean\" ||\n\t\t\t\t\t\t\t\t\ttypeof depPropDef === \"boolean\"\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tif (subPropDef !== depPropDef) {\n\t\t\t\t\t\t\t\t\t\tallDepPropsSatisfied = false;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Check that every keyword in the dep property exists\n\t\t\t\t\t\t\t\t// in sub property with an equal or stricter value\n\t\t\t\t\t\t\t\tconst depPropKeys = Object.keys(depPropDef);\n\t\t\t\t\t\t\t\tconst propSatisfied = depPropKeys.every((dk) => {\n\t\t\t\t\t\t\t\t\tconst depVal = (depPropDef as Record<string, unknown>)[dk];\n\t\t\t\t\t\t\t\t\tconst subVal = (subPropDef as Record<string, unknown>)[dk];\n\t\t\t\t\t\t\t\t\tif (subVal === undefined) return false;\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\ttypeof depVal === \"number\" &&\n\t\t\t\t\t\t\t\t\t\ttypeof subVal === \"number\"\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tdk === \"minLength\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"minimum\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"exclusiveMinimum\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"minItems\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"minProperties\"\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn subVal >= depVal;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tdk === \"maxLength\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"maximum\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"exclusiveMaximum\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"maxItems\" ||\n\t\t\t\t\t\t\t\t\t\t\tdk === \"maxProperties\"\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn subVal <= depVal;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn deepEqual(depVal, subVal);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!propSatisfied) {\n\t\t\t\t\t\t\t\t\tallDepPropsSatisfied = false;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!allDepRequiredSatisfied || !allDepPropsSatisfied) {\n\t\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\t\t\texpected: `dependency: ${key} requires schema`,\n\t\t\t\t\t\t\t\treceived: `no dependency for ${key}`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (Array.isArray(supDep) && Array.isArray(subDep)) {\n\t\t\t\t// Both are array form — check if sub includes all required props from sup\n\t\t\t\tconst missing = supDep.filter((d) => !subDep.includes(d));\n\t\t\t\tif (missing.length > 0) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\texpected: `dependency: ${key} requires ${supDep.join(\", \")}`,\n\t\t\t\t\t\treceived: `dependency: ${key} requires ${subDep.join(\", \")}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (!Array.isArray(supDep) && !Array.isArray(subDep)) {\n\t\t\t\t// Both are schema form — recurse\n\t\t\t\tconst depPath = path\n\t\t\t\t\t? `${path}.<dependency:${key}>`\n\t\t\t\t\t: `<dependency:${key}>`;\n\t\t\t\tconst depErrors = computeSemanticErrors(\n\t\t\t\t\tsubDep as JSONSchema7Definition,\n\t\t\t\t\tsupDep as JSONSchema7Definition,\n\t\t\t\t\tdepPath,\n\t\t\t\t);\n\t\t\t\terrors.push(...depErrors);\n\t\t\t} else {\n\t\t\t\t// Mixed forms (one array, one schema) — report mismatch\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: Array.isArray(supDep)\n\t\t\t\t\t\t? `dependency: ${key} requires ${supDep.join(\", \")}`\n\t\t\t\t\t\t: `dependency: ${key} requires schema`,\n\t\t\t\t\treceived: Array.isArray(subDep)\n\t\t\t\t\t\t? `dependency: ${key} requires ${subDep.join(\", \")}`\n\t\t\t\t\t\t: `dependency: ${key} requires schema`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── patternProperties ──\n\tif (isPlainObj(sup.patternProperties)) {\n\t\tconst supPP = sup.patternProperties as Record<\n\t\t\tstring,\n\t\t\tJSONSchema7Definition\n\t\t>;\n\t\tconst subPP = isPlainObj(sub.patternProperties)\n\t\t\t? (sub.patternProperties as Record<string, JSONSchema7Definition>)\n\t\t\t: null;\n\n\t\tfor (const pattern of Object.keys(supPP)) {\n\t\t\tconst supPropDef = supPP[pattern];\n\t\t\tif (supPropDef === undefined) continue;\n\n\t\t\tconst subPropDef = subPP?.[pattern];\n\t\t\tconst ppPath = path\n\t\t\t\t? `${path}.<patternProperties:${pattern}>`\n\t\t\t\t: `<patternProperties:${pattern}>`;\n\n\t\t\tif (subPropDef === undefined) {\n\t\t\t\t// sub doesn't constrain this pattern at all — more permissive\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.ObjectConstraint,\n\t\t\t\t\tkey: ppPath,\n\t\t\t\t\texpected: formatSchemaType(supPropDef),\n\t\t\t\t\treceived: \"no constraint for this pattern\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Both define the same pattern — recurse\n\t\t\t\tconst ppErrors = computeSemanticErrors(subPropDef, supPropDef, ppPath);\n\t\t\t\terrors.push(...ppErrors);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Compares array constraints (excluding items) between sub and sup.\n */\nfunction checkArrayConstraints(\n\tsub: JSONSchema7,\n\tsup: JSONSchema7,\n\tpath: string,\n\terrors: SchemaError[],\n): void {\n\tcheckMinConstraint(\n\t\tsub.minItems,\n\t\tsup.minItems,\n\t\t\"minItems\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ArrayConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maxItems,\n\t\tsup.maxItems,\n\t\t\"maxItems\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.ArrayConstraint,\n\t);\n\n\t// ── uniqueItems ──\n\tif (sup.uniqueItems === true && sub.uniqueItems !== true) {\n\t\terrors.push({\n\t\t\ttype: SchemaErrorType.ArrayConstraint,\n\t\t\tkey: path || \"$root\",\n\t\t\texpected: \"uniqueItems: true\",\n\t\t\treceived: fmtConstraint(\"uniqueItems\", sub.uniqueItems ?? false),\n\t\t});\n\t}\n\n\t// ── contains ──\n\tif (sup.contains !== undefined) {\n\t\tif (sub.contains === undefined) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.ArrayConstraint,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: `contains: ${formatSchemaType(sup.contains as JSONSchema7Definition)}`,\n\t\t\t\treceived: \"no contains constraint\",\n\t\t\t});\n\t\t} else {\n\t\t\t// Both have contains — recurse to compare the contained schemas\n\t\t\tconst containsPath = path ? `${path}.<contains>` : \"<contains>\";\n\t\t\tconst containsErrors = computeSemanticErrors(\n\t\t\t\tsub.contains as JSONSchema7Definition,\n\t\t\t\tsup.contains as JSONSchema7Definition,\n\t\t\t\tcontainsPath,\n\t\t\t);\n\t\t\terrors.push(...containsErrors);\n\t\t}\n\t}\n}\n\n/**\n * Detects whether a schema has a numeric type.\n */\nfunction isNumericType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"number\" || t === \"integer\";\n\treturn t.some((v) => v === \"number\" || v === \"integer\");\n}\n\n/**\n * Detects whether a schema has a string type.\n */\nfunction isStringType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"string\";\n\treturn t.includes(\"string\");\n}\n\n/**\n * Detects whether a schema has an object type.\n */\nfunction isObjectType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"object\";\n\treturn t.includes(\"object\");\n}\n\n/**\n * Detects whether a schema has an array type.\n */\nfunction isArrayType(t: string | string[] | undefined): boolean {\n\tif (t === undefined) return false;\n\tif (typeof t === \"string\") return t === \"array\";\n\treturn t.includes(\"array\");\n}\n\n// ─── Keyword-based implicit type detection ───────────────────────────────────\n//\n// propertyNames schemas (e.g. { minLength: 1 }) don't always carry an explicit\n// `type`, yet their keywords unambiguously imply a type family. These helpers\n// let us trigger the right constraint checks even when `getEffectiveType`\n// returns `undefined`.\n\nfunction hasNumericKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minimum !== undefined ||\n\t\ts.maximum !== undefined ||\n\t\ts.exclusiveMinimum !== undefined ||\n\t\ts.exclusiveMaximum !== undefined ||\n\t\ts.multipleOf !== undefined\n\t);\n}\n\nfunction hasStringKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minLength !== undefined ||\n\t\ts.maxLength !== undefined ||\n\t\ts.pattern !== undefined ||\n\t\ts.format !== undefined\n\t);\n}\n\nfunction hasObjectKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minProperties !== undefined ||\n\t\ts.maxProperties !== undefined ||\n\t\ts.propertyNames !== undefined ||\n\t\ts.additionalProperties !== undefined ||\n\t\tisPlainObj(s.patternProperties) ||\n\t\tisPlainObj(s.dependencies)\n\t);\n}\n\nfunction hasArrayKeywords(s: JSONSchema7): boolean {\n\treturn (\n\t\ts.minItems !== undefined ||\n\t\ts.maxItems !== undefined ||\n\t\ts.uniqueItems !== undefined ||\n\t\ts.contains !== undefined\n\t);\n}\n\n// ─── Core Comparison ─────────────────────────────────────────────────────────\n\n/**\n * Compares two schemas and produces semantic errors.\n *\n * @param sub The source schema (what is produced / received)\n * @param sup The target schema (what is expected)\n * @param path The current normalized path\n * @returns List of semantic errors\n */\n/**\n * Lightweight semantic check for whether `sub` trivially satisfies `sup.not`.\n *\n * Returns:\n * - `true` — the `not` is definitely satisfied (no error should be reported)\n * - `false` — the `not` is definitely violated (error should be reported)\n * - `null` — cannot determine (fall back to structural check)\n *\n * This inlines the most common cases from `evaluateNot` in `subset-checker.ts`\n * to avoid circular imports.\n */\nfunction isNotSatisfied(sub: JSONSchema7, sup: JSONSchema7): boolean | null {\n\tif (\n\t\t!hasOwn(sup, \"not\") ||\n\t\t!isPlainObj(sup.not) ||\n\t\ttypeof sup.not === \"boolean\"\n\t) {\n\t\treturn null;\n\t}\n\tconst notSchema = sup.not as JSONSchema7;\n\n\t// ── Type disjointness ──\n\t// If sub has a type and not has a type, and they're completely disjoint → satisfied\n\tif (sub.type !== undefined && notSchema.type !== undefined) {\n\t\tconst subTypes = Array.isArray(sub.type) ? sub.type : [sub.type];\n\t\tconst notTypes = Array.isArray(notSchema.type)\n\t\t\t? notSchema.type\n\t\t\t: [notSchema.type];\n\t\tconst hasOverlap = subTypes.some((t) => notTypes.includes(t));\n\n\t\t// Only consider pure type-only not schemas (no extra constraints)\n\t\tconst notKeys = Object.keys(notSchema);\n\t\tconst isTypeOnly = notKeys.length === 1 && notKeys[0] === \"type\";\n\n\t\tif (isTypeOnly) {\n\t\t\tif (!hasOverlap) return true; // disjoint types → not is satisfied\n\t\t\t// If sub's types are entirely within not's types → definitely violated\n\t\t\tif (subTypes.every((t) => notTypes.includes(t))) return false;\n\t\t}\n\t}\n\n\t// ── Const disjointness ──\n\tif (hasOwn(notSchema, \"const\")) {\n\t\tif (hasOwn(sub, \"const\")) {\n\t\t\treturn !deepEqual(sub.const, notSchema.const);\n\t\t}\n\t\tif (Array.isArray(sub.enum)) {\n\t\t\tconst allDisjoint = sub.enum.every((v) => !deepEqual(v, notSchema.const));\n\t\t\tif (allDisjoint) return true;\n\t\t}\n\t}\n\n\t// ── Enum disjointness ──\n\tif (Array.isArray(notSchema.enum)) {\n\t\tif (hasOwn(sub, \"const\")) {\n\t\t\tconst constInNotEnum = notSchema.enum.some((v) =>\n\t\t\t\tdeepEqual(v, sub.const),\n\t\t\t);\n\t\t\tif (!constInNotEnum) return true;\n\t\t\treturn false;\n\t\t}\n\t\tif (Array.isArray(sub.enum)) {\n\t\t\tconst hasOverlap = sub.enum.some((v) =>\n\t\t\t\tnotSchema.enum?.some((nv) => deepEqual(v, nv)),\n\t\t\t);\n\t\t\tif (!hasOverlap) return true;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function computeSemanticErrors(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n\tpath = \"\",\n): SchemaError[] {\n\t// ── Boolean schemas ──\n\tif (typeof sup === \"boolean\") {\n\t\tif (sup === false) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: \"never\",\n\t\t\t\t\treceived: formatSchemaType(sub),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn []; // sup = true accepts everything\n\t}\n\tif (typeof sub === \"boolean\") {\n\t\tif (sub === true) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatSchemaType(sup),\n\t\t\t\t\treceived: \"any\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn []; // sub = false produces nothing, trivially subset\n\t}\n\n\tconst subSchema = sub as JSONSchema7;\n\tconst supSchema = sup as JSONSchema7;\n\n\tconst errors: SchemaError[] = [];\n\n\t// ── Handle `not` keyword ──\n\t// Use semantic evaluation to check if the `not` is satisfied before\n\t// falling back to structural comparison.\n\tif (\n\t\thasOwn(supSchema, \"not\") &&\n\t\tisPlainObj(supSchema.not) &&\n\t\ttypeof supSchema.not !== \"boolean\"\n\t) {\n\t\tconst notSchema = supSchema.not as JSONSchema7;\n\t\tconst notFormatted = formatSchemaType(notSchema);\n\n\t\t// Use semantic evaluation to check if the `not` is satisfied\n\t\tconst notResult = isNotSatisfied(subSchema, supSchema);\n\n\t\tif (notResult === false) {\n\t\t\t// Sub definitely violates the `not` → confirmed error\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.NotSchema,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: `not ${notFormatted}`,\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t} else if (notResult === null) {\n\t\t\t// Indeterminate → fall back to structural check\n\t\t\tif (!hasOwn(subSchema, \"not\")) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.NotSchema,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: `not ${notFormatted}`,\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t});\n\t\t\t} else if (\n\t\t\t\tisPlainObj(subSchema.not) &&\n\t\t\t\ttypeof subSchema.not !== \"boolean\"\n\t\t\t) {\n\t\t\t\tconst subNotSchema = subSchema.not as JSONSchema7;\n\t\t\t\tif (!deepEqual(subNotSchema, notSchema)) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\ttype: SchemaErrorType.NotSchema,\n\t\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\t\texpected: `not ${notFormatted}`,\n\t\t\t\t\t\treceived: `not ${formatSchemaType(subNotSchema)}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// If notResult === true → not is satisfied, no error\n\t}\n\n\t// ── Get effective types ──\n\tconst subType = getEffectiveType(subSchema);\n\tconst supType = getEffectiveType(supSchema);\n\n\t// ── Handle anyOf/oneOf in sup ──\n\t// If sup has branches, try to find the best matching one for error reporting\n\tconst supBranches = supSchema.anyOf ?? supSchema.oneOf;\n\tif (Array.isArray(supBranches) && supBranches.length > 0 && !supSchema.type) {\n\t\treturn computeErrorsAgainstBranches(subSchema, supBranches, path);\n\t}\n\n\t// ── Handle anyOf/oneOf in sub ──\n\tconst subBranches = subSchema.anyOf ?? subSchema.oneOf;\n\tif (Array.isArray(subBranches) && subBranches.length > 0 && !subSchema.type) {\n\t\tconst branchErrors: SchemaError[] = [];\n\t\tfor (const branch of subBranches) {\n\t\t\tconst errs = computeSemanticErrors(branch, sup, path);\n\t\t\tbranchErrors.push(...errs);\n\t\t}\n\t\treturn branchErrors;\n\t}\n\n\t// ── Both are object types → compare properties + object constraints ──\n\tconst supProps = getProperties(supSchema);\n\tconst subProps = getProperties(subSchema);\n\n\tif (supProps !== null || isObjectType(supType)) {\n\t\t// sup is an object schema\n\t\tif (subType !== undefined && !typeIncludes(subType, \"object\")) {\n\t\t\t// sub is not an object at all\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t\treturn errors;\n\t\t}\n\n\t\tif (supProps !== null) {\n\t\t\tconst supRequired = getRequired(supSchema);\n\t\t\tconst subRequired = getRequired(subSchema);\n\n\t\t\tfor (const key of Object.keys(supProps)) {\n\t\t\t\tconst propPath = joinPath(path, key);\n\t\t\t\tconst supPropDef = supProps[key];\n\t\t\t\tconst subPropDef = subProps?.[key];\n\n\t\t\t\tif (supPropDef === undefined) continue;\n\n\t\t\t\tconst isRequiredInSup = supRequired.includes(key);\n\n\t\t\t\t// ── Missing property (required in sup, absent in sub) ──\n\t\t\t\tif (subPropDef === undefined) {\n\t\t\t\t\tif (isRequiredInSup) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\ttype: SchemaErrorType.MissingProperty,\n\t\t\t\t\t\t\tkey: propPath,\n\t\t\t\t\t\t\texpected: formatSchemaType(supPropDef),\n\t\t\t\t\t\t\treceived: \"undefined\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// ── Optionality mismatch (required in sup, optional in sub) ──\n\t\t\t\tif (isRequiredInSup && !subRequired.includes(key)) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\ttype: SchemaErrorType.Optionality,\n\t\t\t\t\t\tkey: propPath,\n\t\t\t\t\t\texpected: \"not optional\",\n\t\t\t\t\t\treceived: \"optional\",\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// ── Recurse into the property schemas ──\n\t\t\t\tconst propErrors = comparePropertySchemas(\n\t\t\t\t\tsubPropDef,\n\t\t\t\t\tsupPropDef,\n\t\t\t\t\tpropPath,\n\t\t\t\t);\n\t\t\t\terrors.push(...propErrors);\n\t\t\t}\n\t\t}\n\n\t\t// ── Object-level constraints ──\n\t\tcheckObjectConstraints(subSchema, supSchema, path, errors);\n\n\t\treturn errors;\n\t}\n\n\t// ── Both are array types → compare items + array constraints ──\n\tif (\n\t\t(supType === \"array\" || supSchema.items !== undefined) &&\n\t\t(subType === \"array\" || subSchema.items !== undefined)\n\t) {\n\t\t// Check items compatibility\n\t\tif (supSchema.items !== undefined && typeof supSchema.items !== \"boolean\") {\n\t\t\tif (\n\t\t\t\tsubSchema.items !== undefined &&\n\t\t\t\ttypeof subSchema.items !== \"boolean\"\n\t\t\t) {\n\t\t\t\t// Both have items schemas — recurse\n\t\t\t\tif (Array.isArray(supSchema.items) && Array.isArray(subSchema.items)) {\n\t\t\t\t\t// Tuple comparison\n\t\t\t\t\tconst maxLen = Math.max(\n\t\t\t\t\t\tsupSchema.items.length,\n\t\t\t\t\t\tsubSchema.items.length,\n\t\t\t\t\t);\n\t\t\t\t\tfor (let i = 0; i < maxLen; i++) {\n\t\t\t\t\t\tconst supItem = supSchema.items[i];\n\t\t\t\t\t\tconst subItem = subSchema.items[i];\n\t\t\t\t\t\tconst itemPath = joinPath(path, `[${i}]`);\n\t\t\t\t\t\tif (supItem !== undefined && subItem === undefined) {\n\t\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\t\ttype: SchemaErrorType.MissingProperty,\n\t\t\t\t\t\t\t\tkey: itemPath,\n\t\t\t\t\t\t\t\texpected: formatSchemaType(supItem),\n\t\t\t\t\t\t\t\treceived: \"undefined\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if (supItem !== undefined && subItem !== undefined) {\n\t\t\t\t\t\t\terrors.push(...computeSemanticErrors(subItem, supItem, itemPath));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\t!Array.isArray(supSchema.items) &&\n\t\t\t\t\t!Array.isArray(subSchema.items)\n\t\t\t\t) {\n\t\t\t\t\t// Single items schema — recurse with [] path\n\t\t\t\t\tconst itemPath = arrayPath(path);\n\t\t\t\t\tconst itemErrors = computeSemanticErrors(\n\t\t\t\t\t\tsubSchema.items as JSONSchema7Definition,\n\t\t\t\t\t\tsupSchema.items as JSONSchema7Definition,\n\t\t\t\t\t\titemPath,\n\t\t\t\t\t);\n\t\t\t\t\terrors.push(...itemErrors);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// sup has items schema but sub doesn't\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// ── Array-level constraints ──\n\t\tcheckArrayConstraints(subSchema, supSchema, path, errors);\n\n\t\treturn errors;\n\t}\n\n\t// ── Type mismatch at current level ──\n\tif (subType !== undefined && supType !== undefined) {\n\t\tif (!typesAreCompatible(subType, supType)) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t\treturn errors;\n\t\t}\n\t}\n\n\t// ── Enum comparison ──\n\tif (Array.isArray(supSchema.enum)) {\n\t\tif (Array.isArray(subSchema.enum)) {\n\t\t\t// Both have enums — check if sub.enum ⊆ sup.enum\n\t\t\tconst subExtra = subSchema.enum.filter(\n\t\t\t\t(v) => !supSchema.enum?.some((sv) => deepEqual(v, sv)),\n\t\t\t);\n\t\t\tif (subExtra.length > 0) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\treceived: formatEnumValues(subSchema.enum),\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (hasOwn(subSchema, \"const\")) {\n\t\t\t// sub has const, sup has enum — check inclusion\n\t\t\tconst constInEnum = supSchema.enum.some((v) =>\n\t\t\t\tdeepEqual(v, subSchema.const),\n\t\t\t);\n\t\t\tif (!constInEnum) {\n\t\t\t\terrors.push({\n\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\tkey: path || \"$root\",\n\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// sup has enum but sub is a plain type (no enum restriction)\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t}\n\t\treturn errors;\n\t}\n\n\t// ── Const comparison ──\n\tif (hasOwn(supSchema, \"const\") && hasOwn(subSchema, \"const\")) {\n\t\tif (!deepEqual(supSchema.const, subSchema.const)) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t});\n\t\t}\n\t\treturn errors;\n\t}\n\n\t// ── Same-type constraint comparison ──\n\t// Types are compatible (or unspecified), now check individual keywords.\n\n\tif (\n\t\tisNumericType(subType) ||\n\t\tisNumericType(supType) ||\n\t\thasNumericKeywords(supSchema) ||\n\t\thasNumericKeywords(subSchema)\n\t) {\n\t\tcheckNumericConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\tif (\n\t\tisStringType(subType) ||\n\t\tisStringType(supType) ||\n\t\thasStringKeywords(supSchema) ||\n\t\thasStringKeywords(subSchema)\n\t) {\n\t\tcheckStringConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\t// Object-level constraints when sup doesn't have explicit properties\n\t// but still has object constraints (e.g., just { type: \"object\", minProperties: 3 })\n\tif (\n\t\tisObjectType(subType) ||\n\t\tisObjectType(supType) ||\n\t\thasObjectKeywords(supSchema) ||\n\t\thasObjectKeywords(subSchema)\n\t) {\n\t\tcheckObjectConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\t// Array-level constraints when sup doesn't have explicit items\n\t// but still has array constraints (e.g., just { type: \"array\", minItems: 2 })\n\tif (\n\t\tisArrayType(subType) ||\n\t\tisArrayType(supType) ||\n\t\thasArrayKeywords(supSchema) ||\n\t\thasArrayKeywords(subSchema)\n\t) {\n\t\tcheckArrayConstraints(subSchema, supSchema, path, errors);\n\t}\n\n\tif (errors.length > 0) {\n\t\treturn errors;\n\t}\n\n\t// ── Fallback: generic incompatibility ──\n\t// If we get here, there's an incompatibility we couldn't pinpoint precisely.\n\t// Produce a root-level error with the formatted types.\n\tconst expectedStr = formatSchemaType(supSchema);\n\tconst receivedStr = formatSchemaType(subSchema);\n\tif (expectedStr !== receivedStr) {\n\t\t// Do not report type_mismatch when:\n\t\t// - sub has an enum (formatting as \"active or pending\")\n\t\t// - sup has a `not` constraint that is confirmed satisfied (notResult === true)\n\t\t// - the base types are compatible\n\t\t//\n\t\t// In this scenario the only source of incompatibility was the `not` keyword,\n\t\t// which is confirmed to be satisfied by sub's enum values. The textual\n\t\t// representations differ (\"active or pending\" vs \"string\") solely because\n\t\t// formatSchemaType renders enum values rather than their declared type —\n\t\t// there is no actual semantic incompatibility.\n\t\tconst supNotSatisfied =\n\t\t\thasOwn(supSchema, \"not\") &&\n\t\t\tisPlainObj(supSchema.not) &&\n\t\t\tisNotSatisfied(subSchema, supSchema) === true;\n\n\t\tconst isEnumCompatibleWithSupNot =\n\t\t\tArray.isArray(subSchema.enum) &&\n\t\t\tsupSchema.type !== undefined &&\n\t\t\tsubSchema.type !== undefined &&\n\t\t\ttypesAreCompatible(subSchema.type, supSchema.type) &&\n\t\t\tsupNotSatisfied;\n\n\t\tif (!isEnumCompatibleWithSupNot) {\n\t\t\terrors.push({\n\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: expectedStr,\n\t\t\t\treceived: receivedStr,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn errors;\n}\n\n// ─── Property Schema Comparison ──────────────────────────────────────────────\n\n/**\n * Compares two property schemas and produces errors.\n * Handles recursion into nested objects and arrays.\n */\nfunction comparePropertySchemas(\n\tsubDef: JSONSchema7Definition,\n\tsupDef: JSONSchema7Definition,\n\tpath: string,\n): SchemaError[] {\n\tif (typeof subDef === \"boolean\" || typeof supDef === \"boolean\") {\n\t\tif (subDef !== supDef) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path,\n\t\t\t\t\texpected: formatSchemaType(supDef),\n\t\t\t\t\treceived: formatSchemaType(subDef),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t}\n\n\tconst subSchema = subDef as JSONSchema7;\n\tconst supSchema = supDef as JSONSchema7;\n\n\tconst subType = getEffectiveType(subSchema);\n\tconst supType = getEffectiveType(supSchema);\n\n\t// ── Enum comparison (before type check, as enums can cross types) ──\n\tif (Array.isArray(supSchema.enum)) {\n\t\tif (Array.isArray(subSchema.enum)) {\n\t\t\tconst subExtra = subSchema.enum.filter(\n\t\t\t\t(v) => !supSchema.enum?.some((sv) => deepEqual(v, sv)),\n\t\t\t);\n\t\t\tif (subExtra.length > 0) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\t\tkey: path,\n\t\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\t\treceived: formatEnumValues(subSchema.enum),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\t\tif (hasOwn(subSchema, \"const\")) {\n\t\t\tconst constInEnum = supSchema.enum.some((v) =>\n\t\t\t\tdeepEqual(v, subSchema.const),\n\t\t\t);\n\t\t\tif (!constInEnum) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\t\tkey: path,\n\t\t\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\t\t// sup has enum, sub is a plain type\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\tkey: path,\n\t\t\t\texpected: formatEnumValues(supSchema.enum),\n\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t},\n\t\t];\n\t}\n\n\t// ── Const comparison ──\n\tif (hasOwn(supSchema, \"const\") && hasOwn(subSchema, \"const\")) {\n\t\tif (!deepEqual(supSchema.const, subSchema.const)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.EnumMismatch,\n\t\t\t\t\tkey: path,\n\t\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t}\n\n\t// ── Type mismatch ──\n\tif (subType !== undefined && supType !== undefined) {\n\t\tif (!typesAreCompatible(subType, supType)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttype: SchemaErrorType.TypeMismatch,\n\t\t\t\t\tkey: path,\n\t\t\t\t\texpected: formatSchemaType(supSchema),\n\t\t\t\t\treceived: formatSchemaType(subSchema),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t}\n\n\t// ── If same types, recurse deeper ──\n\treturn computeSemanticErrors(subDef, supDef, path);\n}\n\n// ─── Branch Error Computation ────────────────────────────────────────────────\n\n/**\n * When sup has branches (anyOf/oneOf), attempts to find the closest\n * matching branch and generates errors against it.\n *\n * Strategy: compute errors for each branch and return those from the\n * branch with the fewest errors (best match).\n */\nfunction computeErrorsAgainstBranches(\n\tsub: JSONSchema7,\n\tbranches: JSONSchema7Definition[],\n\tpath: string,\n): SchemaError[] {\n\tlet bestErrors: SchemaError[] | null = null;\n\n\tfor (const branch of branches) {\n\t\tconst errors = computeSemanticErrors(sub, branch, path);\n\t\tif (errors.length === 0) return [];\n\t\tif (bestErrors === null || errors.length < bestErrors.length) {\n\t\t\tbestErrors = errors;\n\t\t}\n\t}\n\n\treturn (\n\t\tbestErrors ?? [\n\t\t\t{\n\t\t\t\ttype: SchemaErrorType.BranchMismatch,\n\t\t\t\tkey: path || \"$root\",\n\t\t\t\texpected: formatSchemaType({ anyOf: branches } as JSONSchema7),\n\t\t\t\treceived: formatSchemaType(sub),\n\t\t\t},\n\t\t]\n\t);\n}\n"],"names":["computeSemanticErrors","formatSchemaType","formatEnumValues","values","parts","map","v","JSON","stringify","length","last","pop","join","def","formatSchemaTypeInternal","undefined","schema","hasOwn","const","Array","isArray","enum","branches","anyOf","oneOf","b","type","items","itemSchema","itemBranches","t","itemType","isPlainObj","properties","not","joinPath","parent","key","arrayPath","getProperties","getRequired","required","getEffectiveType","typeIncludes","schemaType","target","includes","typesAreCompatible","subType","supType","some","every","st","supt","fmtConstraint","name","value","checkMinConstraint","subVal","supVal","path","errors","push","expected","received","checkMaxConstraint","checkNumericConstraints","sub","sup","subMin","minimum","subExclMin","exclusiveMinimum","subMax","maximum","subExclMax","exclusiveMaximum","supMin","supExclMin","supMax","supExclMax","satisfiedByMin","satisfiedByExclMin","SchemaErrorType","NumericConstraint","satisfiedByMax","satisfiedByExclMax","multipleOf","checkStringConstraints","minLength","StringConstraint","maxLength","pattern","format","checkObjectConstraints","additionalProperties","ObjectConstraint","apPath","apErrors","minProperties","maxProperties","propertyNames","pnErrors","dependencies","supDeps","subDeps","subRequired","subProps","Object","keys","supDep","subDep","allDepsAlwaysRequired","d","triggerNeverProduced","depSchema","depRequired","depProps","allDepRequiredSatisfied","r","allDepPropsSatisfied","propKey","subPropDef","depPropDef","depPropKeys","propSatisfied","dk","depVal","deepEqual","missing","filter","depPath","depErrors","patternProperties","supPP","subPP","supPropDef","ppPath","ppErrors","checkArrayConstraints","minItems","ArrayConstraint","maxItems","uniqueItems","contains","containsPath","containsErrors","isNumericType","isStringType","isObjectType","isArrayType","hasNumericKeywords","s","hasStringKeywords","hasObjectKeywords","hasArrayKeywords","isNotSatisfied","notSchema","subTypes","notTypes","hasOverlap","notKeys","isTypeOnly","allDisjoint","constInNotEnum","nv","TypeMismatch","subSchema","supSchema","notFormatted","notResult","NotSchema","subNotSchema","supBranches","computeErrorsAgainstBranches","subBranches","branchErrors","branch","errs","supProps","supRequired","propPath","isRequiredInSup","MissingProperty","Optionality","propErrors","comparePropertySchemas","maxLen","Math","max","i","supItem","subItem","itemPath","itemErrors","subExtra","sv","EnumMismatch","constInEnum","expectedStr","receivedStr","supNotSatisfied","isEnumCompatibleWithSupNot","subDef","supDef","bestErrors","BranchMismatch"],"mappings":"mPAyjCgBA,+BAAAA,2BAlgCAC,0BAAAA,2CArDgB,qCACc,cA6B9C,SAASC,iBAAiBC,MAAiB,EAC1C,MAAMC,MAAQD,OAAOE,GAAG,CAAC,AAACC,GACzB,OAAOA,IAAM,SAAWA,EAAIC,KAAKC,SAAS,CAACF,IAE5C,GAAIF,MAAMK,MAAM,GAAK,EAAG,MAAO,QAC/B,GAAIL,MAAMK,MAAM,GAAK,EAAG,OAAOL,KAAK,CAAC,EAAE,CACvC,GAAIA,MAAMK,MAAM,GAAK,EAAG,MAAO,CAAC,EAAEL,KAAK,CAAC,EAAE,CAAC,IAAI,EAAEA,KAAK,CAAC,EAAE,CAAC,CAAC,CAC3D,MAAMM,KAAON,MAAMO,GAAG,GACtB,MAAO,CAAC,EAAEP,MAAMQ,IAAI,CAAC,MAAM,KAAK,EAAEF,KAAK,CAAC,AACzC,CAcO,SAAST,iBACfY,GAAsC,EAEtC,OAAOC,yBAAyBD,IACjC,CAEA,SAASC,yBACRD,GAAsC,EAEtC,GAAIA,MAAQE,UAAW,MAAO,YAC9B,GAAI,OAAOF,MAAQ,UAAW,OAAOA,IAAM,MAAQ,QAEnD,MAAMG,OAASH,IAGf,GAAII,GAAAA,eAAM,EAACD,OAAQ,SAAU,CAC5B,MAAMV,EAAIU,OAAOE,KAAK,CACtB,OAAO,OAAOZ,IAAM,SAAWA,EAAIC,KAAKC,SAAS,CAACF,EACnD,CAGA,GAAIa,MAA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CAGA,GAAItJ,GAAAA,eAAM,EAACuJ,UAAW,UAAYvJ,GAAAA,eAAM,EAACsJ,UAAW,SAAU,CAC7D,GAAI,CAACvC,GAAAA,kBAAS,EAACwC,UAAUtJ,KAAK,CAAEqJ,UAAUrJ,KAAK,EAAG,CACjD,MAAO,CACN,CACCQ,KAAMyD,wBAAe,CAACkH,YAAY,CAClChK,IAAKuB,KACLG,SAAU9D,iBAAiBuK,WAC3BxG,SAAU/D,iBAAiBsK,UAC5B,EACA,AACF,CACA,MAAO,EAAE,AACV,CAGA,GAAIvH,UAAYjC,WAAakC,UAAYlC,UAAW,CACnD,GAAI,CAACgC,mBAAmBC,QAASC,SAAU,CAC1C,MAAO,CACN,CACCvB,KAAMyD,wBAAe,CAACmF,YAAY,CAClCjI,IAAKuB,KACLG,SAAU9D,iBAAiBuK,WAC3BxG,SAAU/D,iBAAiBsK,UAC5B,EACA,AACF,CACD,CAGA,OAAOvK,sBAAsB2M,OAAQC,OAAQhJ,KAC9C,CAWA,SAASkH,6BACR3G,GAAgB,CAChB7C,QAAiC,CACjCsC,IAAY,EAEZ,IAAIiJ,WAAmC,KAEvC,IAAK,MAAM5B,UAAU3J,SAAU,CAC9B,MAAMuC,OAAS7D,sBAAsBmE,IAAK8G,OAAQrH,MAClD,GAAIC,OAAOpD,MAAM,GAAK,EAAG,MAAO,EAAE,CAClC,GAAIoM,aAAe,MAAQhJ,OAAOpD,MAAM,CAAGoM,WAAWpM,MAAM,CAAE,CAC7DoM,WAAahJ,MACd,CACD,CAEA,OACCgJ,YAAc,CACb,CACCnL,KAAMyD,wBAAe,CAAC2H,cAAc,CACpCzK,IAAKuB,MAAQ,QACbG,SAAU9D,iBAAiB,CAAEsB,MAAOD,QAAS,GAC7C0C,SAAU/D,iBAAiBkE,IAC5B,EACA,AAEH"}
|
|
@@ -32,26 +32,6 @@ export interface BranchResult {
|
|
|
32
32
|
* avoid allocations on these frequent paths.
|
|
33
33
|
*/
|
|
34
34
|
export declare function getBranchesTyped(def: JSONSchema7Definition): BranchResult;
|
|
35
|
-
/**
|
|
36
|
-
* Checks whether `sub ⊆ sup` for two schemas without anyOf/oneOf (or with
|
|
37
|
-
* anyOf/oneOf only on the sup side).
|
|
38
|
-
*
|
|
39
|
-
* Point 7 — Integrates an extended `not` pre-check (`evaluateNot`) before the merge.
|
|
40
|
-
*
|
|
41
|
-
* When `evaluateNot` confirms compatibility (`true`), the `not` is removed
|
|
42
|
-
* from `sup` before the merge to prevent the merge engine from adding a `not`
|
|
43
|
-
* constraint that `sub` doesn't have (which would cause `isEqual(merged, sub)` to fail).
|
|
44
|
-
*
|
|
45
|
-
* Pattern pre-check — When both schemas have different patterns, checks
|
|
46
|
-
* inclusion via sampling with `isPatternSubset`. If confirmed, removes the
|
|
47
|
-
* pattern from sup before the merge (same strategy as for `not`).
|
|
48
|
-
*
|
|
49
|
-
* Principle: merge(sub, sup) ≡ sub → sub is a subset of sup.
|
|
50
|
-
*
|
|
51
|
-
* When the merge-based check fails and either sub or sup contains nested
|
|
52
|
-
* `oneOf`/`anyOf` in properties or items, falls back to a property-by-property
|
|
53
|
-
* comparison via `isObjectSubsetByProperties`.
|
|
54
|
-
*/
|
|
55
35
|
export declare function isAtomicSubsetOf(sub: JSONSchema7Definition, sup: JSONSchema7Definition, engine: MergeEngine): boolean;
|
|
56
36
|
/**
|
|
57
37
|
* Checks `sub ⊆ sup` for a sub that has branches (anyOf/oneOf).
|