json-schema-compatibility-checker 1.1.8 → 1.1.10

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.
@@ -13,12 +13,4 @@ import type { SchemaError } from "./types.js";
13
13
  * - `undefined` → `"undefined"`
14
14
  */
15
15
  export declare function formatSchemaType(def: JSONSchema7Definition | undefined): string;
16
- /**
17
- * Compares two schemas and produces semantic errors.
18
- *
19
- * @param sub The source schema (what is produced / received)
20
- * @param sup The target schema (what is expected)
21
- * @param path The current normalized path
22
- * @returns List of semantic errors
23
- */
24
16
  export declare function computeSemanticErrors(sub: JSONSchema7Definition, sup: JSONSchema7Definition, path?: string): SchemaError[];
@@ -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){checkMinConstraint(sub.minimum,sup.minimum,"minimum",path,errors,_typests.SchemaErrorType.NumericConstraint);checkMaxConstraint(sub.maximum,sup.maximum,"maximum",path,errors,_typests.SchemaErrorType.NumericConstraint);checkMinConstraint(sub.exclusiveMinimum,sup.exclusiveMinimum,"exclusiveMinimum",path,errors,_typests.SchemaErrorType.NumericConstraint);checkMaxConstraint(sub.exclusiveMaximum,sup.exclusiveMaximum,"exclusiveMaximum",path,errors,_typests.SchemaErrorType.NumericConstraint);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;for(const key of Object.keys(supDeps)){const supDep=supDeps[key];const subDep=subDeps?.[key];if(subDep===undefined){if(Array.isArray(supDep)){errors.push({type:_typests.SchemaErrorType.ObjectConstraint,key:path||"$root",expected:`dependency: ${key} requires ${supDep.join(", ")}`,received:`no dependency for ${key}`})}else{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 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);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{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&&notSchema.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&&notKeys[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)}]}
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\tcheckMinConstraint(\n\t\tsub.minimum,\n\t\tsup.minimum,\n\t\t\"minimum\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.NumericConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.maximum,\n\t\tsup.maximum,\n\t\t\"maximum\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.NumericConstraint,\n\t);\n\tcheckMinConstraint(\n\t\tsub.exclusiveMinimum as number | undefined,\n\t\tsup.exclusiveMinimum as number | undefined,\n\t\t\"exclusiveMinimum\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.NumericConstraint,\n\t);\n\tcheckMaxConstraint(\n\t\tsub.exclusiveMaximum as number | undefined,\n\t\tsup.exclusiveMaximum as number | undefined,\n\t\t\"exclusiveMaximum\",\n\t\tpath,\n\t\terrors,\n\t\tSchemaErrorType.NumericConstraint,\n\t);\n\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\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\t// sup requires a dependency that sub doesn't have\n\t\t\t\tif (Array.isArray(supDep)) {\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: `no dependency for ${key}`,\n\t\t\t\t\t});\n\t\t\t\t} else {\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 schema`,\n\t\t\t\t\t\treceived: `no dependency for ${key}`,\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 */\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// Check sup.not: sub must not satisfy the not-schema for sub ⊆ sup.\n\t// Check sub.not: if sub has a not that sup doesn't, sub is more constrained (OK).\n\t// if sup has a not that sub doesn't, sub may be too permissive.\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\tif (!hasOwn(subSchema, \"not\")) {\n\t\t\t// sup excludes something, sub doesn't → sub is more permissive\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 (\n\t\t\tisPlainObj(subSchema.not) &&\n\t\t\ttypeof subSchema.not !== \"boolean\"\n\t\t) {\n\t\t\t// Both have not — compare the not schemas\n\t\t\t// For sub ⊆ sup, sub.not must be at least as broad as sup.not\n\t\t\t// (i.e. sub excludes at least as much). We report if they differ.\n\t\t\tconst subNotSchema = subSchema.not as JSONSchema7;\n\t\t\tif (!deepEqual(subNotSchema, notSchema)) {\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: `not ${formatSchemaType(subNotSchema)}`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\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","minimum","SchemaErrorType","NumericConstraint","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","checkStringConstraints","minLength","StringConstraint","maxLength","pattern","format","checkObjectConstraints","additionalProperties","ObjectConstraint","apPath","apErrors","minProperties","maxProperties","propertyNames","pnErrors","dependencies","supDeps","subDeps","Object","keys","supDep","subDep","missing","filter","d","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","TypeMismatch","subSchema","supSchema","notSchema","notFormatted","NotSchema","subNotSchema","deepEqual","supBranches","computeErrorsAgainstBranches","subBranches","branchErrors","branch","errs","supProps","subProps","supRequired","subRequired","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":"mPAyzBgBA,+BAAAA,2BAlwBAC,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,K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ACC0G,YAAc,CACb,CACC7I,KAAM4C,wBAAe,CAACkG,cAAc,CACpCnI,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 {\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,CAGA,MAAMC,SAAWN,OAAOO,KAAK,EAAIP,OAAOQ,KAAK,CAC7C,GAAIL,MAAMC,OAAO,CAACE,WAAaA,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mC,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,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 checkAtomic(){return checkAtomic},get checkBranchedSub(){return checkBranchedSub},get checkBranchedSup(){return checkBranchedSup},get getBranchesTyped(){return getBranchesTyped},get isAtomicSubsetOf(){return isAtomicSubsetOf}});const _formatvalidatorts=require("./format-validator.js");const _normalizerts=require("./normalizer.js");const _patternsubsetts=require("./pattern-subset.js");const _semanticerrorsts=require("./semantic-errors.js");const _utilsts=require("./utils.js");const BRANCH_TRUE={branches:[true],type:"none"};const BRANCH_FALSE={branches:[false],type:"none"};const atomicBranchCache=new WeakMap;function getBranchesTyped(def){if(typeof def==="boolean"){return def?BRANCH_TRUE:BRANCH_FALSE}if((0,_utilsts.hasOwn)(def,"anyOf")&&Array.isArray(def.anyOf)){return{branches:def.anyOf,type:"anyOf"}}if((0,_utilsts.hasOwn)(def,"oneOf")&&Array.isArray(def.oneOf)){return{branches:def.oneOf,type:"oneOf"}}let cached=atomicBranchCache.get(def);if(cached===undefined){cached={branches:[def],type:"none"};atomicBranchCache.set(def,cached)}return cached}function evaluateNot(sub,sup){if(typeof sub==="boolean"||typeof sup==="boolean")return null;if((0,_utilsts.hasOwn)(sup,"not")&&(0,_utilsts.isPlainObj)(sup.not)){const notSchema=sup.not;if((0,_utilsts.isPlainObj)(notSchema.properties)&&Array.isArray(notSchema.required)){const notProps=notSchema.properties;const notRequired=notSchema.required;if((0,_utilsts.isPlainObj)(sub.properties)){const subProps=sub.properties;const subRequired=Array.isArray(sub.required)?sub.required:[];const notPropKeys=Object.keys(notProps);const hasIncompatibleProp=notPropKeys.some(key=>{const notPropDef=notProps[key];if(typeof notPropDef==="boolean")return false;const notProp=notPropDef;if(notRequired.includes(key)&&!subRequired.includes(key)&&!(0,_utilsts.hasOwn)(subProps,key)){return true}if(!(0,_utilsts.hasOwn)(subProps,key))return false;const subPropDef=subProps[key];if(typeof subPropDef==="boolean")return false;const subProp=subPropDef;if((0,_utilsts.hasOwn)(notProp,"const")&&(0,_utilsts.hasOwn)(subProp,"const")){if(!(0,_utilsts.deepEqual)(notProp.const,subProp.const)){return true}}if((0,_utilsts.hasOwn)(notProp,"enum")&&Array.isArray(notProp.enum)){if((0,_utilsts.hasOwn)(subProp,"const")){const inNotEnum=notProp.enum.some(v=>(0,_utilsts.deepEqual)(v,subProp.const));if(!inNotEnum)return true}if((0,_utilsts.hasOwn)(subProp,"enum")&&Array.isArray(subProp.enum)){const noneInNotEnum=subProp.enum.every(v=>!notProp.enum?.some(nv=>(0,_utilsts.deepEqual)(v,nv)));if(noneInNotEnum)return true}}return false});if(hasIncompatibleProp)return true;const allPropsMatch=notPropKeys.every(key=>{const notPropDef=notProps[key];if(typeof notPropDef==="boolean")return true;const notProp=notPropDef;if(notRequired.includes(key)&&!subRequired.includes(key))return false;if(!(0,_utilsts.hasOwn)(subProps,key))return false;const subPropDef=subProps[key];if(typeof subPropDef==="boolean")return true;const subProp=subPropDef;if((0,_utilsts.hasOwn)(notProp,"const")&&(0,_utilsts.hasOwn)(subProp,"const")){return(0,_utilsts.deepEqual)(notProp.const,subProp.const)}if((0,_utilsts.hasOwn)(notProp,"enum")&&Array.isArray(notProp.enum)){if((0,_utilsts.hasOwn)(subProp,"const")){return notProp.enum.some(v=>(0,_utilsts.deepEqual)(v,subProp.const))}if((0,_utilsts.hasOwn)(subProp,"enum")&&Array.isArray(subProp.enum)){return subProp.enum.every(v=>notProp.enum?.some(nv=>(0,_utilsts.deepEqual)(v,nv)))}}return false});if(allPropsMatch)return false}}if((0,_utilsts.hasOwn)(notSchema,"const")&&(0,_utilsts.hasOwn)(sub,"const")){const notConst=notSchema.const;const subConst=sub.const;if((0,_utilsts.deepEqual)(subConst,notConst))return false;return true}if((0,_utilsts.hasOwn)(notSchema,"enum")&&Array.isArray(notSchema.enum)&&(0,_utilsts.hasOwn)(sub,"enum")&&Array.isArray(sub.enum)){const allExcluded=sub.enum.every(val=>!notSchema.enum?.some(notVal=>(0,_utilsts.deepEqual)(val,notVal)));if(allExcluded)return true}if((0,_utilsts.hasOwn)(notSchema,"type")&&(0,_utilsts.hasOwn)(sub,"type")){const notType=notSchema.type;const subType=sub.type;if(typeof notType==="string"&&typeof subType==="string"){if(!(0,_utilsts.hasOwn)(notSchema,"const")&&!(0,_utilsts.hasOwn)(notSchema,"enum")&&!(0,_utilsts.isPlainObj)(notSchema.properties)){if(subType===notType)return false;return true}}if(Array.isArray(notType)&&typeof subType==="string"){if(notType.includes(subType))return false;return true}}if((0,_utilsts.hasOwn)(notSchema,"anyOf")&&Array.isArray(notSchema.anyOf)){const branches=notSchema.anyOf;const allIncompatible=branches.every(branch=>{if(typeof branch==="boolean")return!branch;const result=evaluateNot(sub,{not:branch});return result===true});if(allIncompatible)return true;const anyBranchMatches=branches.some(branch=>{if(typeof branch==="boolean")return branch;const result=evaluateNot(sub,{not:branch});return result===false});if(anyBranchMatches)return false}if((0,_utilsts.hasOwn)(notSchema,"oneOf")&&Array.isArray(notSchema.oneOf)){const branches=notSchema.oneOf;const allIncompatible=branches.every(branch=>{if(typeof branch==="boolean")return!branch;const result=evaluateNot(sub,{not:branch});return result===true});if(allIncompatible)return true;const anyBranchMatches=branches.some(branch=>{if(typeof branch==="boolean")return branch;const result=evaluateNot(sub,{not:branch});return result===false});if(anyBranchMatches)return false}if((0,_utilsts.hasOwn)(notSchema,"format")&&(0,_utilsts.hasOwn)(sub,"format")){const subFormat=sub.format;const notFormat=notSchema.format;if(subFormat===notFormat)return false;return true}}if((0,_utilsts.hasOwn)(sub,"not")&&(0,_utilsts.hasOwn)(sup,"not")){if((0,_utilsts.deepEqual)(sub.not,sup.not))return true}return null}function stripNotFromSup(sub,sup,stripTopLevel=true){if(typeof sup==="boolean"||typeof sub==="boolean")return sup;let result=sup;if(stripTopLevel&&(0,_utilsts.hasOwn)(result,"not")){result=(0,_utilsts.omitKeys)(result,["not"])}if((0,_utilsts.isPlainObj)(result.properties)&&(0,_utilsts.isPlainObj)(sub.properties)){const subProps=sub.properties;const supProps=result.properties;let newProps;for(const key of Object.keys(supProps)){const supPropDef=supProps[key];const subPropDef=subProps[key];if(supPropDef!==undefined&&subPropDef!==undefined&&typeof supPropDef!=="boolean"&&typeof subPropDef!=="boolean"&&(0,_utilsts.hasOwn)(supPropDef,"not")){const propNotResult=evaluateNot(subPropDef,supPropDef);if(propNotResult===true){if(!newProps)newProps={...supProps};newProps[key]=(0,_utilsts.omitKeys)(supPropDef,["not"])}}}if(newProps){result={...result,properties:newProps}}}return result}function stripPatternFromSup(sub,sup){if(typeof sub==="boolean"||typeof sup==="boolean")return sup;const supObj=sup;let result=supObj;let copied=false;function ensureCopy(){if(!copied){result={...supObj};copied=true}return result}if((0,_utilsts.hasOwn)(result,"pattern")&&(0,_utilsts.hasOwn)(sub,"pattern")&&result.pattern!==sub.pattern){const patResult=(0,_patternsubsetts.isPatternSubset)(sub.pattern,result.pattern);if(patResult===true){result=(0,_utilsts.omitKeys)(ensureCopy(),["pattern"]);copied=true}}if((0,_utilsts.isPlainObj)(result.properties)&&(0,_utilsts.isPlainObj)(sub.properties)){const subProps=sub.properties;const supProps=result.properties;let propsModified=false;let newProps;for(const key of Object.keys(supProps)){const supPropDef=supProps[key];const subPropDef=subProps[key];if(supPropDef!==undefined&&subPropDef!==undefined&&typeof supPropDef!=="boolean"&&typeof subPropDef!=="boolean"&&(0,_utilsts.hasOwn)(supPropDef,"pattern")&&(0,_utilsts.hasOwn)(subPropDef,"pattern")&&supPropDef.pattern!==subPropDef.pattern){const propPatResult=(0,_patternsubsetts.isPatternSubset)(subPropDef.pattern,supPropDef.pattern);if(propPatResult===true){if(!newProps)newProps={...supProps};newProps[key]=(0,_utilsts.omitKeys)(supPropDef,["pattern"]);propsModified=true}}}if(propsModified&&newProps){ensureCopy().properties=newProps}}if((0,_utilsts.isPlainObj)(result.items)&&typeof result.items!=="boolean"&&(0,_utilsts.isPlainObj)(sub.items)&&typeof sub.items!=="boolean"){const subItems=sub.items;const supItems=result.items;if((0,_utilsts.hasOwn)(supItems,"pattern")&&(0,_utilsts.hasOwn)(subItems,"pattern")&&supItems.pattern!==subItems.pattern){const itemsPatResult=(0,_patternsubsetts.isPatternSubset)(subItems.pattern,supItems.pattern);if(itemsPatResult===true){ensureCopy().items=(0,_utilsts.omitKeys)(supItems,["pattern"])}}}return result}function stripVacuousFalseProperties(merged,sub){if(typeof merged==="boolean"||typeof sub==="boolean")return merged;if(!(0,_utilsts.isPlainObj)(merged.properties))return merged;const mergedProps=merged.properties;const subProps=(0,_utilsts.isPlainObj)(sub.properties)?sub.properties:{};let strippedProps=null;for(const key of Object.keys(mergedProps)){if(mergedProps[key]===false&&!(0,_utilsts.hasOwn)(subProps,key)){if(strippedProps===null){strippedProps={...mergedProps}}delete strippedProps[key]}}if(strippedProps===null)return merged;const result={...merged,properties:strippedProps};if(Object.keys(strippedProps).length===0&&!(0,_utilsts.isPlainObj)(sub.properties)){delete result.properties}return result}function hasNestedBranching(schema){if(typeof schema==="boolean")return false;if((0,_utilsts.isPlainObj)(schema.properties)){const props=schema.properties;for(const key of Object.keys(props)){const prop=props[key];if(prop===undefined||typeof prop==="boolean")continue;if((0,_utilsts.hasOwn)(prop,"oneOf")||(0,_utilsts.hasOwn)(prop,"anyOf"))return true;if(hasNestedBranching(prop))return true}}if((0,_utilsts.isPlainObj)(schema.items)&&typeof schema.items!=="boolean"){const items=schema.items;if((0,_utilsts.hasOwn)(items,"oneOf")||(0,_utilsts.hasOwn)(items,"anyOf"))return true;if(hasNestedBranching(items))return true}return false}function isPropertySubsetOf(sub,sup,engine){const{branches:subBranches}=getBranchesTyped(sub);if(subBranches.length>1||subBranches[0]!==sub){for(const branch of subBranches){if(branch===undefined)continue;if(!isAtomicSubsetOf(branch,sup,engine))return false}return true}return isAtomicSubsetOf(sub,sup,engine)}function isObjectSubsetByProperties(sub,sup,engine){const subIsObj=sub.type==="object"||(0,_utilsts.isPlainObj)(sub.properties);const supIsObj=sup.type==="object"||(0,_utilsts.isPlainObj)(sup.properties);if(!subIsObj&&!supIsObj){if(sub.type==="array"&&sup.type==="array"&&(0,_utilsts.isPlainObj)(sub.items)&&(0,_utilsts.isPlainObj)(sup.items)){return isPropertySubsetOf(sub.items,sup.items,engine)}return false}if(!subIsObj||!supIsObj)return false;if((0,_utilsts.hasOwn)(sub,"type")&&(0,_utilsts.hasOwn)(sup,"type")&&sub.type!==sup.type){return false}const subProps=(0,_utilsts.isPlainObj)(sub.properties)?sub.properties:{};const supProps=(0,_utilsts.isPlainObj)(sup.properties)?sup.properties:{};const subRequired=Array.isArray(sub.required)?sub.required:[];const supRequired=Array.isArray(sup.required)?sup.required:[];for(const key of supRequired){if(!subRequired.includes(key))return false}if(sup.additionalProperties===false){for(const key of Object.keys(subProps)){if(!(0,_utilsts.hasOwn)(supProps,key))return false}}for(const key of Object.keys(supProps)){const supProp=supProps[key];const subProp=subProps[key];if(supProp===undefined||subProp===undefined)continue;if(!isPropertySubsetOf(subProp,supProp,engine)){return false}}if((0,_utilsts.isPlainObj)(sup.additionalProperties)&&typeof sup.additionalProperties!=="boolean"){const addPropSchema=sup.additionalProperties;for(const key of Object.keys(subProps)){if((0,_utilsts.hasOwn)(supProps,key))continue;const subProp=subProps[key];if(subProp===undefined)continue;if(!isPropertySubsetOf(subProp,addPropSchema,engine)){return false}}}if((0,_utilsts.isPlainObj)(sub.items)&&(0,_utilsts.isPlainObj)(sup.items)){if(!isPropertySubsetOf(sub.items,sup.items,engine)){return false}}return true}function tryNestedBranchingFallback(sub,sup,engine){if(typeof sub==="boolean"||typeof sup==="boolean")return null;if(!hasNestedBranching(sub)&&!hasNestedBranching(sup))return null;return isObjectSubsetByProperties(sub,sup,engine)}function isAtomicSubsetOf(sub,sup,engine){const{branches:supBranches}=getBranchesTyped(sup);if(supBranches.length===1&&supBranches[0]===sup){const notResult=evaluateNot(sub,sup);if(notResult===false)return false;if(typeof sub!=="boolean"&&typeof sup!=="boolean"&&(0,_utilsts.hasOwn)(sub,"format")&&(0,_utilsts.hasOwn)(sup,"format")&&sub.format!==sup.format){const fmtResult=(0,_formatvalidatorts.isFormatSubset)(sub.format,sup.format);if(fmtResult!==true)return false}if(typeof sub!=="boolean"&&typeof sup!=="boolean"&&(0,_utilsts.hasOwn)(sub,"pattern")&&(0,_utilsts.hasOwn)(sup,"pattern")&&sub.pattern!==sup.pattern){const patResult=(0,_patternsubsetts.isPatternSubset)(sub.pattern,sup.pattern);if(patResult===false)return false}let effectiveSup=sup;if(typeof sup!=="boolean"){if(notResult===true){effectiveSup=stripNotFromSup(sub,sup,true);if(typeof effectiveSup!=="boolean"&&Object.keys(effectiveSup).length===0){return true}}else{effectiveSup=stripNotFromSup(sub,sup,false)}effectiveSup=stripPatternFromSup(sub,effectiveSup)}const merged=engine.merge(sub,effectiveSup);if(merged===null){return tryNestedBranchingFallback(sub,effectiveSup,engine)??false}if((0,_utilsts.deepEqual)(merged,sub))return true;const strippedMerged=stripVacuousFalseProperties(merged,sub);if(strippedMerged!==merged&&(0,_utilsts.deepEqual)(strippedMerged,sub)){return true}const normalizedMerged=(0,_normalizerts.normalize)(strippedMerged);if((0,_utilsts.deepEqual)(normalizedMerged,sub)||engine.isEqual(normalizedMerged,sub)){return true}return tryNestedBranchingFallback(sub,effectiveSup,engine)??false}return supBranches.some(branch=>{const notResult=evaluateNot(sub,branch);if(notResult===false)return false;if(typeof sub!=="boolean"&&typeof branch!=="boolean"&&(0,_utilsts.hasOwn)(sub,"pattern")&&(0,_utilsts.hasOwn)(branch,"pattern")&&sub.pattern!==branch.pattern){const patResult=(0,_patternsubsetts.isPatternSubset)(sub.pattern,branch.pattern);if(patResult===false)return false}let effectiveBranch=branch;if(typeof branch!=="boolean"){if(notResult===true){effectiveBranch=stripNotFromSup(sub,branch,true);if(typeof effectiveBranch!=="boolean"&&Object.keys(effectiveBranch).length===0){return true}}else{effectiveBranch=stripNotFromSup(sub,branch,false)}effectiveBranch=stripPatternFromSup(sub,effectiveBranch)}const merged=engine.merge(sub,effectiveBranch);if(merged===null){return tryNestedBranchingFallback(sub,effectiveBranch,engine)===true}if((0,_utilsts.deepEqual)(merged,sub))return true;const strippedBranch=stripVacuousFalseProperties(merged,sub);if(strippedBranch!==merged&&(0,_utilsts.deepEqual)(strippedBranch,sub)){return true}const normalizedBranch=(0,_normalizerts.normalize)(strippedBranch);if((0,_utilsts.deepEqual)(normalizedBranch,sub)||engine.isEqual(normalizedBranch,sub)){return true}return tryNestedBranchingFallback(sub,effectiveBranch,engine)===true})}function checkBranchedSub(subBranches,sup,engine,branchType="anyOf"){const allErrors=[];let allSubset=true;for(let i=0;i<subBranches.length;i++){const branch=subBranches[i];if(branch===undefined)continue;if(!isAtomicSubsetOf(branch,sup,engine)){allSubset=false;const branchErrors=(0,_semanticerrorsts.computeSemanticErrors)(branch,sup,"");allErrors.push(...branchErrors)}}return{isSubset:allSubset,merged:allSubset?branchType==="oneOf"?{oneOf:subBranches}:{anyOf:subBranches}:null,errors:allErrors}}function checkBranchedSup(sub,supBranches,engine,_branchType="anyOf"){for(const branch of supBranches){let effectiveBranch=branch;if(typeof sub!=="boolean"&&typeof branch!=="boolean"){effectiveBranch=stripPatternFromSup(sub,branch)}const merged=engine.merge(sub,effectiveBranch);if(merged!==null){if((0,_utilsts.deepEqual)(merged,sub)){return{isSubset:true,merged,errors:[]}}const normalizedMerged=(0,_normalizerts.normalize)(merged);if((0,_utilsts.deepEqual)(normalizedMerged,sub)||engine.isEqual(normalizedMerged,sub)){return{isSubset:true,merged,errors:[]}}}}const semanticErrors=(0,_semanticerrorsts.computeSemanticErrors)(sub,{anyOf:supBranches},"");return{isSubset:false,merged:null,errors:semanticErrors}}function checkAtomic(sub,sup,engine){let effectiveSup=sup;if(typeof sub!=="boolean"&&typeof sup!=="boolean"){effectiveSup=stripPatternFromSup(sub,sup)}try{const merged=engine.mergeOrThrow(sub,effectiveSup);if((0,_utilsts.deepEqual)(merged,sub)){return{isSubset:true,merged,errors:[]}}const strippedMerged=stripVacuousFalseProperties(merged,sub);if(strippedMerged!==merged&&(0,_utilsts.deepEqual)(strippedMerged,sub)){return{isSubset:true,merged:strippedMerged,errors:[]}}const normalizedMerged=(0,_normalizerts.normalize)(strippedMerged);if((0,_utilsts.deepEqual)(normalizedMerged,sub)||engine.isEqual(normalizedMerged,sub)){return{isSubset:true,merged:normalizedMerged,errors:[]}}if(tryNestedBranchingFallback(sub,effectiveSup,engine)===true){return{isSubset:true,merged:sub,errors:[]}}const errors=(0,_semanticerrorsts.computeSemanticErrors)(sub,sup,"");return{isSubset:false,merged:normalizedMerged,errors}}catch(_e){if(tryNestedBranchingFallback(sub,effectiveSup,engine)===true){return{isSubset:true,merged:sub,errors:[]}}const errors=(0,_semanticerrorsts.computeSemanticErrors)(sub,sup,"");return{isSubset:false,merged:null,errors}}}
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 checkAtomic(){return checkAtomic},get checkBranchedSub(){return checkBranchedSub},get checkBranchedSup(){return checkBranchedSup},get getBranchesTyped(){return getBranchesTyped},get isAtomicSubsetOf(){return isAtomicSubsetOf}});const _formatvalidatorts=require("./format-validator.js");const _normalizerts=require("./normalizer.js");const _patternsubsetts=require("./pattern-subset.js");const _semanticerrorsts=require("./semantic-errors.js");const _utilsts=require("./utils.js");const BRANCH_TRUE={branches:[true],type:"none"};const BRANCH_FALSE={branches:[false],type:"none"};const atomicBranchCache=new WeakMap;function getBranchesTyped(def){if(typeof def==="boolean"){return def?BRANCH_TRUE:BRANCH_FALSE}if((0,_utilsts.hasOwn)(def,"anyOf")&&Array.isArray(def.anyOf)){return{branches:def.anyOf,type:"anyOf"}}if((0,_utilsts.hasOwn)(def,"oneOf")&&Array.isArray(def.oneOf)){return{branches:def.oneOf,type:"oneOf"}}let cached=atomicBranchCache.get(def);if(cached===undefined){cached={branches:[def],type:"none"};atomicBranchCache.set(def,cached)}return cached}function evaluateNot(sub,sup){if(typeof sub==="boolean"||typeof sup==="boolean")return null;if((0,_utilsts.hasOwn)(sup,"not")&&(0,_utilsts.isPlainObj)(sup.not)){const notSchema=sup.not;if((0,_utilsts.isPlainObj)(notSchema.properties)&&Array.isArray(notSchema.required)){const notProps=notSchema.properties;const notRequired=notSchema.required;if((0,_utilsts.isPlainObj)(sub.properties)){const subProps=sub.properties;const subRequired=Array.isArray(sub.required)?sub.required:[];const notPropKeys=Object.keys(notProps);const hasIncompatibleProp=notPropKeys.some(key=>{const notPropDef=notProps[key];if(typeof notPropDef==="boolean")return false;const notProp=notPropDef;if(notRequired.includes(key)&&!subRequired.includes(key)&&!(0,_utilsts.hasOwn)(subProps,key)){return true}if(!(0,_utilsts.hasOwn)(subProps,key))return false;const subPropDef=subProps[key];if(typeof subPropDef==="boolean")return false;const subProp=subPropDef;if((0,_utilsts.hasOwn)(notProp,"const")&&(0,_utilsts.hasOwn)(subProp,"const")){if(!(0,_utilsts.deepEqual)(notProp.const,subProp.const)){return true}}if((0,_utilsts.hasOwn)(notProp,"enum")&&Array.isArray(notProp.enum)){if((0,_utilsts.hasOwn)(subProp,"const")){const inNotEnum=notProp.enum.some(v=>(0,_utilsts.deepEqual)(v,subProp.const));if(!inNotEnum)return true}if((0,_utilsts.hasOwn)(subProp,"enum")&&Array.isArray(subProp.enum)){const noneInNotEnum=subProp.enum.every(v=>!notProp.enum?.some(nv=>(0,_utilsts.deepEqual)(v,nv)));if(noneInNotEnum)return true}}return false});if(hasIncompatibleProp)return true;const allPropsMatch=notPropKeys.every(key=>{const notPropDef=notProps[key];if(typeof notPropDef==="boolean")return true;const notProp=notPropDef;if(notRequired.includes(key)&&!subRequired.includes(key))return false;if(!(0,_utilsts.hasOwn)(subProps,key))return false;const subPropDef=subProps[key];if(typeof subPropDef==="boolean")return true;const subProp=subPropDef;if((0,_utilsts.hasOwn)(notProp,"const")&&(0,_utilsts.hasOwn)(subProp,"const")){return(0,_utilsts.deepEqual)(notProp.const,subProp.const)}if((0,_utilsts.hasOwn)(notProp,"enum")&&Array.isArray(notProp.enum)){if((0,_utilsts.hasOwn)(subProp,"const")){return notProp.enum.some(v=>(0,_utilsts.deepEqual)(v,subProp.const))}if((0,_utilsts.hasOwn)(subProp,"enum")&&Array.isArray(subProp.enum)){return subProp.enum.every(v=>notProp.enum?.some(nv=>(0,_utilsts.deepEqual)(v,nv)))}}return false});if(allPropsMatch)return false}}if((0,_utilsts.hasOwn)(notSchema,"const")&&(0,_utilsts.hasOwn)(sub,"const")){const notConst=notSchema.const;const subConst=sub.const;if((0,_utilsts.deepEqual)(subConst,notConst))return false;return true}if((0,_utilsts.hasOwn)(notSchema,"enum")&&Array.isArray(notSchema.enum)&&(0,_utilsts.hasOwn)(sub,"enum")&&Array.isArray(sub.enum)){const allExcluded=sub.enum.every(val=>!notSchema.enum?.some(notVal=>(0,_utilsts.deepEqual)(val,notVal)));if(allExcluded)return true}if((0,_utilsts.hasOwn)(notSchema,"type")&&(0,_utilsts.hasOwn)(sub,"type")){const notType=notSchema.type;const subType=sub.type;if(typeof notType==="string"&&typeof subType==="string"){if(!(0,_utilsts.hasOwn)(notSchema,"const")&&!(0,_utilsts.hasOwn)(notSchema,"enum")&&!(0,_utilsts.isPlainObj)(notSchema.properties)){if(subType===notType)return false;return true}}if(Array.isArray(notType)&&typeof subType==="string"){if(notType.includes(subType))return false;return true}}if((0,_utilsts.hasOwn)(notSchema,"anyOf")&&Array.isArray(notSchema.anyOf)){const branches=notSchema.anyOf;const allIncompatible=branches.every(branch=>{if(typeof branch==="boolean")return!branch;const result=evaluateNot(sub,{not:branch});return result===true});if(allIncompatible)return true;const anyBranchMatches=branches.some(branch=>{if(typeof branch==="boolean")return branch;const result=evaluateNot(sub,{not:branch});return result===false});if(anyBranchMatches)return false}if((0,_utilsts.hasOwn)(notSchema,"oneOf")&&Array.isArray(notSchema.oneOf)){const branches=notSchema.oneOf;const allIncompatible=branches.every(branch=>{if(typeof branch==="boolean")return!branch;const result=evaluateNot(sub,{not:branch});return result===true});if(allIncompatible)return true;const anyBranchMatches=branches.some(branch=>{if(typeof branch==="boolean")return branch;const result=evaluateNot(sub,{not:branch});return result===false});if(anyBranchMatches)return false}if((0,_utilsts.hasOwn)(notSchema,"format")&&(0,_utilsts.hasOwn)(sub,"format")){const subFormat=sub.format;const notFormat=notSchema.format;if(subFormat===notFormat)return false;return true}}if((0,_utilsts.hasOwn)(sub,"not")&&(0,_utilsts.hasOwn)(sup,"not")){if((0,_utilsts.deepEqual)(sub.not,sup.not))return true}return null}function stripNotFromSup(sub,sup,stripTopLevel=true){if(typeof sup==="boolean"||typeof sub==="boolean")return sup;let result=sup;if(stripTopLevel&&(0,_utilsts.hasOwn)(result,"not")){result=(0,_utilsts.omitKeys)(result,["not"])}if((0,_utilsts.isPlainObj)(result.properties)&&(0,_utilsts.isPlainObj)(sub.properties)){const subProps=sub.properties;const supProps=result.properties;let newProps;for(const key of Object.keys(supProps)){const supPropDef=supProps[key];const subPropDef=subProps[key];if(supPropDef!==undefined&&subPropDef!==undefined&&typeof supPropDef!=="boolean"&&typeof subPropDef!=="boolean"&&(0,_utilsts.hasOwn)(supPropDef,"not")){const propNotResult=evaluateNot(subPropDef,supPropDef);if(propNotResult===true){if(!newProps)newProps={...supProps};newProps[key]=(0,_utilsts.omitKeys)(supPropDef,["not"])}}}if(newProps){result={...result,properties:newProps}}}return result}function stripPatternFromSup(sub,sup){if(typeof sub==="boolean"||typeof sup==="boolean")return sup;const supObj=sup;let result=supObj;let copied=false;function ensureCopy(){if(!copied){result={...supObj};copied=true}return result}if((0,_utilsts.hasOwn)(result,"pattern")&&(0,_utilsts.hasOwn)(sub,"pattern")&&result.pattern!==sub.pattern){const patResult=(0,_patternsubsetts.isPatternSubset)(sub.pattern,result.pattern);if(patResult===true){result=(0,_utilsts.omitKeys)(ensureCopy(),["pattern"]);copied=true}}if((0,_utilsts.isPlainObj)(result.properties)&&(0,_utilsts.isPlainObj)(sub.properties)){const subProps=sub.properties;const supProps=result.properties;let propsModified=false;let newProps;for(const key of Object.keys(supProps)){const supPropDef=supProps[key];const subPropDef=subProps[key];if(supPropDef!==undefined&&subPropDef!==undefined&&typeof supPropDef!=="boolean"&&typeof subPropDef!=="boolean"&&(0,_utilsts.hasOwn)(supPropDef,"pattern")&&(0,_utilsts.hasOwn)(subPropDef,"pattern")&&supPropDef.pattern!==subPropDef.pattern){const propPatResult=(0,_patternsubsetts.isPatternSubset)(subPropDef.pattern,supPropDef.pattern);if(propPatResult===true){if(!newProps)newProps={...supProps};newProps[key]=(0,_utilsts.omitKeys)(supPropDef,["pattern"]);propsModified=true}}}if(propsModified&&newProps){ensureCopy().properties=newProps}}if((0,_utilsts.isPlainObj)(result.items)&&typeof result.items!=="boolean"&&(0,_utilsts.isPlainObj)(sub.items)&&typeof sub.items!=="boolean"){const subItems=sub.items;const supItems=result.items;if((0,_utilsts.hasOwn)(supItems,"pattern")&&(0,_utilsts.hasOwn)(subItems,"pattern")&&supItems.pattern!==subItems.pattern){const itemsPatResult=(0,_patternsubsetts.isPatternSubset)(subItems.pattern,supItems.pattern);if(itemsPatResult===true){ensureCopy().items=(0,_utilsts.omitKeys)(supItems,["pattern"])}}}return result}function stripVacuousFalseProperties(merged,sub){if(typeof merged==="boolean"||typeof sub==="boolean")return merged;if(!(0,_utilsts.isPlainObj)(merged.properties))return merged;const mergedProps=merged.properties;const subProps=(0,_utilsts.isPlainObj)(sub.properties)?sub.properties:{};let strippedProps=null;for(const key of Object.keys(mergedProps)){if(mergedProps[key]===false&&!(0,_utilsts.hasOwn)(subProps,key)){if(strippedProps===null){strippedProps={...mergedProps}}delete strippedProps[key]}}if(strippedProps===null)return merged;const result={...merged,properties:strippedProps};if(Object.keys(strippedProps).length===0&&!(0,_utilsts.isPlainObj)(sub.properties)){delete result.properties}return result}function hasNestedBranching(schema){if(typeof schema==="boolean")return false;if((0,_utilsts.isPlainObj)(schema.properties)){const props=schema.properties;for(const key of Object.keys(props)){const prop=props[key];if(prop===undefined||typeof prop==="boolean")continue;if((0,_utilsts.hasOwn)(prop,"oneOf")||(0,_utilsts.hasOwn)(prop,"anyOf"))return true;if(hasNestedBranching(prop))return true}}if((0,_utilsts.isPlainObj)(schema.items)&&typeof schema.items!=="boolean"){const items=schema.items;if((0,_utilsts.hasOwn)(items,"oneOf")||(0,_utilsts.hasOwn)(items,"anyOf"))return true;if(hasNestedBranching(items))return true}return false}function isPropertySubsetOf(sub,sup,engine){const{branches:subBranches}=getBranchesTyped(sub);if(subBranches.length>1||subBranches[0]!==sub){for(const branch of subBranches){if(branch===undefined)continue;if(!isAtomicSubsetOf(branch,sup,engine))return false}return true}return isAtomicSubsetOf(sub,sup,engine)}function isArrayConstraintsSubset(sub,sup){if(sup.minItems!==undefined){if(sub.minItems===undefined||sub.minItems<sup.minItems){return false}}if(sup.maxItems!==undefined){if(sub.maxItems===undefined||sub.maxItems>sup.maxItems){return false}}if(sup.uniqueItems===true&&sub.uniqueItems!==true){return false}return true}function isObjectSubsetByProperties(sub,sup,engine){const subIsObj=sub.type==="object"||(0,_utilsts.isPlainObj)(sub.properties);const supIsObj=sup.type==="object"||(0,_utilsts.isPlainObj)(sup.properties);if(!subIsObj&&!supIsObj){if(sub.type==="array"&&sup.type==="array"&&(0,_utilsts.isPlainObj)(sub.items)&&(0,_utilsts.isPlainObj)(sup.items)){if(!isPropertySubsetOf(sub.items,sup.items,engine)){return false}return isArrayConstraintsSubset(sub,sup)}return false}if(!subIsObj||!supIsObj)return false;if((0,_utilsts.hasOwn)(sub,"type")&&(0,_utilsts.hasOwn)(sup,"type")&&sub.type!==sup.type){return false}const subProps=(0,_utilsts.isPlainObj)(sub.properties)?sub.properties:{};const supProps=(0,_utilsts.isPlainObj)(sup.properties)?sup.properties:{};const subRequired=Array.isArray(sub.required)?sub.required:[];const supRequired=Array.isArray(sup.required)?sup.required:[];for(const key of supRequired){if(!subRequired.includes(key))return false}if(sup.additionalProperties===false){for(const key of Object.keys(subProps)){if(!(0,_utilsts.hasOwn)(supProps,key))return false}}for(const key of Object.keys(supProps)){const supProp=supProps[key];const subProp=subProps[key];if(supProp===undefined||subProp===undefined)continue;if(!isPropertySubsetOf(subProp,supProp,engine)){return false}}if((0,_utilsts.isPlainObj)(sup.additionalProperties)&&typeof sup.additionalProperties!=="boolean"){const addPropSchema=sup.additionalProperties;for(const key of Object.keys(subProps)){if((0,_utilsts.hasOwn)(supProps,key))continue;const subProp=subProps[key];if(subProp===undefined)continue;if(!isPropertySubsetOf(subProp,addPropSchema,engine)){return false}}}if((0,_utilsts.isPlainObj)(sub.items)&&(0,_utilsts.isPlainObj)(sup.items)){if(!isPropertySubsetOf(sub.items,sup.items,engine)){return false}if(!isArrayConstraintsSubset(sub,sup)){return false}}return true}function tryNestedBranchingFallback(sub,sup,engine){if(typeof sub==="boolean"||typeof sup==="boolean")return null;if(!hasNestedBranching(sub)&&!hasNestedBranching(sup))return null;return isObjectSubsetByProperties(sub,sup,engine)}function isAtomicSubsetOf(sub,sup,engine){const{branches:supBranches}=getBranchesTyped(sup);if(supBranches.length===1&&supBranches[0]===sup){const notResult=evaluateNot(sub,sup);if(notResult===false)return false;if(typeof sub!=="boolean"&&typeof sup!=="boolean"&&(0,_utilsts.hasOwn)(sub,"format")&&(0,_utilsts.hasOwn)(sup,"format")&&sub.format!==sup.format){const fmtResult=(0,_formatvalidatorts.isFormatSubset)(sub.format,sup.format);if(fmtResult!==true)return false}if(typeof sub!=="boolean"&&typeof sup!=="boolean"&&(0,_utilsts.hasOwn)(sub,"pattern")&&(0,_utilsts.hasOwn)(sup,"pattern")&&sub.pattern!==sup.pattern){const patResult=(0,_patternsubsetts.isPatternSubset)(sub.pattern,sup.pattern);if(patResult===false)return false}let effectiveSup=sup;if(typeof sup!=="boolean"){if(notResult===true){effectiveSup=stripNotFromSup(sub,sup,true);if(typeof effectiveSup!=="boolean"&&Object.keys(effectiveSup).length===0){return true}}else{effectiveSup=stripNotFromSup(sub,sup,false)}effectiveSup=stripPatternFromSup(sub,effectiveSup)}const merged=engine.merge(sub,effectiveSup);if(merged===null){return tryNestedBranchingFallback(sub,effectiveSup,engine)??false}if((0,_utilsts.deepEqual)(merged,sub))return true;const strippedMerged=stripVacuousFalseProperties(merged,sub);if(strippedMerged!==merged&&(0,_utilsts.deepEqual)(strippedMerged,sub)){return true}const normalizedMerged=(0,_normalizerts.normalize)(strippedMerged);if((0,_utilsts.deepEqual)(normalizedMerged,sub)||engine.isEqual(normalizedMerged,sub)){return true}return tryNestedBranchingFallback(sub,effectiveSup,engine)??false}return supBranches.some(branch=>{const notResult=evaluateNot(sub,branch);if(notResult===false)return false;if(typeof sub!=="boolean"&&typeof branch!=="boolean"&&(0,_utilsts.hasOwn)(sub,"pattern")&&(0,_utilsts.hasOwn)(branch,"pattern")&&sub.pattern!==branch.pattern){const patResult=(0,_patternsubsetts.isPatternSubset)(sub.pattern,branch.pattern);if(patResult===false)return false}let effectiveBranch=branch;if(typeof branch!=="boolean"){if(notResult===true){effectiveBranch=stripNotFromSup(sub,branch,true);if(typeof effectiveBranch!=="boolean"&&Object.keys(effectiveBranch).length===0){return true}}else{effectiveBranch=stripNotFromSup(sub,branch,false)}effectiveBranch=stripPatternFromSup(sub,effectiveBranch)}const merged=engine.merge(sub,effectiveBranch);if(merged===null){return tryNestedBranchingFallback(sub,effectiveBranch,engine)===true}if((0,_utilsts.deepEqual)(merged,sub))return true;const strippedBranch=stripVacuousFalseProperties(merged,sub);if(strippedBranch!==merged&&(0,_utilsts.deepEqual)(strippedBranch,sub)){return true}const normalizedBranch=(0,_normalizerts.normalize)(strippedBranch);if((0,_utilsts.deepEqual)(normalizedBranch,sub)||engine.isEqual(normalizedBranch,sub)){return true}return tryNestedBranchingFallback(sub,effectiveBranch,engine)===true})}function checkBranchedSub(subBranches,sup,engine,branchType="anyOf"){const allErrors=[];let allSubset=true;for(let i=0;i<subBranches.length;i++){const branch=subBranches[i];if(branch===undefined)continue;if(!isAtomicSubsetOf(branch,sup,engine)){allSubset=false;const branchErrors=(0,_semanticerrorsts.computeSemanticErrors)(branch,sup,"");allErrors.push(...branchErrors)}}return{isSubset:allSubset,merged:allSubset?branchType==="oneOf"?{oneOf:subBranches}:{anyOf:subBranches}:null,errors:allErrors}}function checkBranchedSup(sub,supBranches,engine,_branchType="anyOf"){for(const branch of supBranches){let effectiveBranch=branch;if(typeof sub!=="boolean"&&typeof branch!=="boolean"){const notResult=evaluateNot(sub,branch);if(notResult===false)continue;if(notResult===true){effectiveBranch=stripNotFromSup(sub,branch,true);if(typeof effectiveBranch!=="boolean"&&Object.keys(effectiveBranch).length===0){return{isSubset:true,merged:sub,errors:[]}}}else{effectiveBranch=stripNotFromSup(sub,branch,false)}effectiveBranch=stripPatternFromSup(sub,effectiveBranch)}const merged=engine.merge(sub,effectiveBranch);if(merged!==null){if((0,_utilsts.deepEqual)(merged,sub)){return{isSubset:true,merged,errors:[]}}const normalizedMerged=(0,_normalizerts.normalize)(merged);if((0,_utilsts.deepEqual)(normalizedMerged,sub)||engine.isEqual(normalizedMerged,sub)){return{isSubset:true,merged,errors:[]}}}}const semanticErrors=(0,_semanticerrorsts.computeSemanticErrors)(sub,{anyOf:supBranches},"");return{isSubset:false,merged:null,errors:semanticErrors}}function checkAtomic(sub,sup,engine){const notResult=typeof sub!=="boolean"&&typeof sup!=="boolean"?evaluateNot(sub,sup):null;if(notResult===false){const errors=(0,_semanticerrorsts.computeSemanticErrors)(sub,sup,"");return{isSubset:false,merged:null,errors}}let effectiveSup=sup;if(typeof sub!=="boolean"&&typeof sup!=="boolean"){if(notResult===true){effectiveSup=stripNotFromSup(sub,sup,true);if(typeof effectiveSup!=="boolean"&&Object.keys(effectiveSup).length===0){return{isSubset:true,merged:sub,errors:[]}}}else{effectiveSup=stripNotFromSup(sub,sup,false)}effectiveSup=stripPatternFromSup(sub,effectiveSup)}try{const merged=engine.mergeOrThrow(sub,effectiveSup);if((0,_utilsts.deepEqual)(merged,sub)){return{isSubset:true,merged,errors:[]}}const strippedMerged=stripVacuousFalseProperties(merged,sub);if(strippedMerged!==merged&&(0,_utilsts.deepEqual)(strippedMerged,sub)){return{isSubset:true,merged:strippedMerged,errors:[]}}const normalizedMerged=(0,_normalizerts.normalize)(strippedMerged);if((0,_utilsts.deepEqual)(normalizedMerged,sub)||engine.isEqual(normalizedMerged,sub)){return{isSubset:true,merged:normalizedMerged,errors:[]}}if(tryNestedBranchingFallback(sub,effectiveSup,engine)===true){return{isSubset:true,merged:sub,errors:[]}}const errors=(0,_semanticerrorsts.computeSemanticErrors)(sub,sup,"");return{isSubset:false,merged:normalizedMerged,errors}}catch(_e){if(tryNestedBranchingFallback(sub,effectiveSup,engine)===true){return{isSubset:true,merged:sub,errors:[]}}const errors=(0,_semanticerrorsts.computeSemanticErrors)(sub,sup,"");return{isSubset:false,merged:null,errors}}}
2
2
  //# sourceMappingURL=subset-checker.js.map