json-schema-library 11.3.1 → 11.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -2
- package/README.md +44 -35
- package/dist/chunk-350yNsax.cjs +1 -0
- package/dist/formats.cjs +2 -0
- package/dist/formats.cjs.map +1 -0
- package/dist/formats.d.cts +8 -0
- package/dist/formats.d.mts +8 -0
- package/dist/formats.mjs +2 -0
- package/dist/formats.mjs.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -0
- package/dist/jlib.js +2 -2
- package/dist/jlibFormats.iife.js +1 -0
- package/dist/jlibRemote.iife.js +1 -0
- package/dist/{remotes/index.cjs → remotes.cjs} +2 -1
- package/dist/remotes.cjs.map +1 -0
- package/dist/remotes.d.cts +8 -0
- package/dist/remotes.d.mts +8 -0
- package/dist/{remotes/index.mjs → remotes.mjs} +2 -1
- package/dist/remotes.mjs.map +1 -0
- package/dist/{types-DVyFDxCv.d.mts → types-BDjKcTVR.d.cts} +4 -2
- package/dist/{types-ZgoQMSny.d.cts → types-CqkCJmt8.d.mts} +4 -2
- package/package.json +21 -15
- package/src/SchemaNode.ts +12 -18
- package/src/compileSchema.ts +0 -3
- package/src/errors/errors.ts +3 -2
- package/src/formats/additionalFormats.ts +118 -0
- package/src/formats/formats.ts +3 -111
- package/src/keywords/$defs.ts +3 -0
- package/src/keywords/additionalProperties.ts +1 -0
- package/src/keywords/allOf.ts +2 -5
- package/src/keywords/anyOf.ts +2 -4
- package/src/keywords/dependencies.ts +2 -0
- package/src/keywords/dependentSchemas.ts +2 -3
- package/src/keywords/format.ts +8 -0
- package/src/keywords/ifthenelse.ts +4 -9
- package/src/keywords/oneOf.ts +2 -5
- package/src/keywords/patternProperties.ts +5 -1
- package/src/keywords/prefixItems.ts +14 -9
- package/src/keywords/properties.ts +2 -3
- package/src/keywords/propertyDependencies.ts +2 -3
- package/src/keywords/propertyNames.ts +1 -1
- package/src/utils/collectValidationErrors.ts +9 -0
- package/src/validateSchema.test.ts +29 -30
- package/tsconfig.json +1 -0
- package/tsconfig.test.json +1 -0
- package/tsdown.config.ts +5 -2
- package/tsdown.iife.config.ts +29 -8
- package/dist/remotes/index.d.cts +0 -7
- package/dist/remotes/index.d.mts +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["suffixes","settings","getDraft","REGEX_FLAGS","addKeywords","DECLARATOR_ONEOF","$refKeyword","parseRef","validateRef","register","resolveRef","resolveRecursiveRef","getRef","compileNext","settings","$refKeyword","parseRef","validateRef","resolveRef","$refKeyword","parseRef","draft06Keyword","register","resolveRef","getRef","KEYWORD","settings","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","exclusiveMaximumKeyword","validateExclusiveMaximum","parse","exclusiveMinimumKeyword","validateExclusiveMinimum","KEYWORD","settings","REGEX_FLAGS","getChildSelection","KEYWORD","settings","safeResolveRef","canResolveRef","convertValue","getData","TYPE","getDefault","KEYWORD","itemsKeyword","parseItems","itemsResolver","validateItems","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","parseMinItems","KEYWORD","KEYWORD","KEYWORD","KEYWORD","KEYWORD","settings","REGEX_FLAGS","settings","REGEX_FLAGS","KEYWORD","KEYWORD","KEYWORD","KEYWORD","deepEqual","$refKeyword","exclusiveMaximumKeyword","exclusiveMinimumKeyword","itemsKeyword","KEYWORD","KEYWORD","$refKeyword","itemsKeyword","$refKeyword","itemsKeyword","compileNext","KEYWORD","unevaluatedItemsKeyword","parseUnevaluatedItems","validateUnevaluatedItems","KEYWORD","itemsKeyword","unevaluatedItemsKeyword","KEYWORD","parseItems","KEYWORD","KEYWORD","$refKeyword","settings","getRef","addKeywords"],"sources":["../src/utils/sanitizeErrors.ts","../src/settings.ts","../src/utils/getTypeOf.ts","../src/utils/isObject.ts","../src/methods/createSchema.ts","../src/methods/toSchemaNodes.ts","../src/utils/resolveUri.ts","../src/utils/mergeSchema.ts","../src/mergeNode.ts","../src/utils/omit.ts","../src/utils/pick.ts","../src/errors/render.ts","../src/validateNode.ts","../src/utils/hasProperty.ts","../src/utils/getValue.ts","../src/getNode.ts","../src/getNodeChild.ts","../src/SchemaNode.ts","../src/types.ts","../src/utils/splitRef.ts","../src/keywords/$ref.ts","../src/utils/collectValidationErrors.ts","../src/keywords/$defs.ts","../src/draft06/keywords/$ref.ts","../src/draft04/keywords/$ref.ts","../src/draft2019-09/keywords/additionalItems.ts","../src/keywords/additionalProperties.ts","../src/keywords/allOf.ts","../src/keywords/anyOf.ts","../src/keywords/contains.ts","../src/utils/isListOfStrings.ts","../src/keywords/dependentRequired.ts","../src/keywords/dependentSchemas.ts","../src/keywords/dependencies.ts","../src/keywords/deprecated.ts","../src/keywords/enum.ts","../src/errors/errors.ts","../src/draft04/keywords/exclusiveMaximum.ts","../src/draft04/keywords/exclusiveMinimum.ts","../src/keywords/format.ts","../src/formats/formats.ts","../src/draft2019-09/methods/getChildSelection.ts","../src/utils/getSchemaType.ts","../src/utils/isEmpty.ts","../src/keywords/oneOf.ts","../src/utils/isFile.ts","../src/draft2019-09/methods/getData.ts","../src/draft2019-09/keywords/items.ts","../src/keywords/maximum.ts","../src/keywords/maxItems.ts","../src/utils/punycode.ucs2decode.ts","../src/keywords/maxLength.ts","../src/keywords/maxProperties.ts","../src/keywords/minimum.ts","../src/keywords/minItems.ts","../src/keywords/minLength.ts","../src/keywords/minProperties.ts","../src/utils/getPrecision.ts","../src/keywords/multipleOf.ts","../src/keywords/not.ts","../src/keywords/pattern.ts","../src/keywords/patternProperties.ts","../src/keywords/properties.ts","../src/keywords/propertyNames.ts","../src/keywords/required.ts","../src/utils/copyDraft.ts","../src/Draft.ts","../src/methods/toDataNodes.ts","../src/keywords/type.ts","../src/keywords/uniqueItems.ts","../src/draft04.ts","../src/keywords/const.ts","../src/keywords/exclusiveMaximum.ts","../src/keywords/exclusiveMinimum.ts","../src/draft06.ts","../src/keywords/ifthenelse.ts","../src/draft07.ts","../src/draft2019-09/keywords/$ref.ts","../src/draft2019-09/keywords/unevaluatedItems.ts","../src/isPropertyEvaluated.ts","../src/keywords/unevaluatedProperties.ts","../src/draft2019.ts","../src/methods/getChildSelection.ts","../src/methods/getData.ts","../src/keywords/items.ts","../src/keywords/prefixItems.ts","../src/isItemEvaluated.ts","../src/keywords/unevaluatedItems.ts","../src/draft2020.ts","../src/compileSchema.ts","../src/draftEditor.ts","../src/keywords/propertyDependencies.ts"],"sourcesContent":["import { isAnnotation } from \"../types\";\nimport { ValidationAnnotation, ValidationReturnType } from \"../Keyword\";\n\n/**\n * Flattens nested validation array results and filters items to only include errors, annotations and promises\n */\nexport default function sanitizeErrors(\n list: ValidationReturnType | ValidationReturnType[] | ValidationAnnotation[],\n result: ValidationAnnotation[] = []\n) {\n if (!Array.isArray(list)) {\n if (list !== undefined) {\n return [list];\n }\n return [];\n }\n for (const item of list) {\n if (Array.isArray(item)) {\n sanitizeErrors(item, result);\n } else if (isAnnotation(item) || item instanceof Promise) {\n result.push(item);\n }\n }\n return result;\n}\n","export default {\n DECLARATOR_ONEOF: \"oneOfProperty\",\n propertyBlacklist: [\"_id\"],\n DYNAMIC_PROPERTIES: [\n \"$ref\",\n \"$defs\",\n \"if\",\n \"then\",\n \"else\",\n \"allOf\",\n \"anyOf\",\n \"oneOf\",\n \"dependentSchemas\",\n \"dependentRequired\",\n \"definitions\",\n \"dependencies\",\n \"patternProperties\",\n \"propertyDependencies\"\n ],\n REGEX_FLAGS: \"u\",\n /**\n * properties to keep from a $ref-schema when resolving a $ref (recursively)\n * this allows to overwrite specified properties locally on a $ref-definition\n *\n * - draft 2019-09\n * - draft 2020-12\n *\n * @example\n * {\n * title: \"custom component\",\n * $ref: \"#/$defs/component\",\n *\n * $defs: {\n * component: {\n * title: \"component\",\n * type: \"object\"\n * }\n * }\n * }\n * // results in\n * {\n * title: \"custom component\"\n * type: \"object\"\n * }\n */\n PROPERTIES_TO_MERGE: [\"title\", \"description\", \"options\", \"x-options\", \"readOnly\", \"writeOnly\"]\n};\n","const toString = Object.prototype.toString;\n\nexport type JSType =\n\t| \"array\"\n\t| \"bigint\"\n\t| \"boolean\"\n\t| \"function\"\n\t| \"null\"\n\t| \"number\"\n\t| \"object\"\n\t| \"string\"\n\t| \"symbol\"\n\t| \"undefined\";\n\nexport function getTypeOf(value: unknown): JSType {\n\tconst type = toString.call(value).slice(8, -1).toLowerCase();\n\tif (type === \"file\") {\n\t\treturn \"object\";\n\t}\n\treturn type as JSType;\n}\n","import { getTypeOf } from \"./getTypeOf\";\n\nexport function isObject(v: unknown): v is Record<string, unknown> {\n return getTypeOf(v) === \"object\";\n}\n","import { getTypeOf } from \"../utils/getTypeOf\";\nimport { JsonSchema } from \"../types\";\nimport { isObject } from \"../utils/isObject\";\n\n/**\n * Create a simple json schema for the given input data\n * @param data - data to get json schema for\n */\nexport function createSchema(data: unknown): JsonSchema {\n // if (data === undefined) {\n // return undefined;\n // }\n\n const schema: JsonSchema =\n data === undefined\n ? {}\n : {\n type: getTypeOf(data)\n };\n\n if (schema.type === \"object\" && isObject(data)) {\n schema.properties = {};\n Object.keys(data).forEach((key) => (schema.properties[key] = createSchema(data[key])));\n }\n\n if (schema.type === \"array\" && Array.isArray(data)) {\n if (data.length === 1) {\n schema.items = createSchema(data[0]);\n } else {\n schema.items = data.map(createSchema);\n const sameTypes = schema.items.find((item: JsonSchema) => item.type !== schema.items[0].type) == null;\n if (sameTypes) {\n schema.items = schema.items[0];\n }\n }\n }\n\n return schema;\n}\n","/* eslint-disable @typescript-eslint/no-unused-expressions */\nimport { isSchemaNode, SchemaNode } from \"../types\";\n\nfunction eachProperty(nodeList: SchemaNode[], o?: Record<string, SchemaNode | unknown>) {\n if (o != null) {\n Object.values(o).forEach((node) => toSchemaNodes(node, nodeList));\n }\n}\n\nfunction eachItem(nodeList: SchemaNode[], a?: SchemaNode[]) {\n if (a != null) {\n a.forEach((node) => toSchemaNodes(node, nodeList));\n }\n}\n\nexport function toSchemaNodes(node: SchemaNode | unknown, nodeList: SchemaNode[] = []): SchemaNode[] {\n if (!isSchemaNode(node)) {\n return nodeList;\n }\n\n nodeList.push(node);\n\n eachProperty(nodeList, node.$defs);\n node.additionalProperties && toSchemaNodes(node.additionalProperties, nodeList);\n eachItem(nodeList, node.allOf);\n eachItem(nodeList, node.anyOf);\n node.contains && toSchemaNodes(node.contains, nodeList);\n eachProperty(nodeList, node.dependentSchemas);\n node.if && toSchemaNodes(node.if, nodeList);\n node.else && toSchemaNodes(node.else, nodeList);\n node.then && toSchemaNodes(node.then, nodeList);\n node.items && toSchemaNodes(node.items, nodeList);\n eachItem(nodeList, node.prefixItems);\n node.not && toSchemaNodes(node.not, nodeList);\n eachItem(nodeList, node.oneOf);\n node.patternProperties &&\n Object.values(node.patternProperties).forEach(({ node }) => toSchemaNodes(node, nodeList));\n eachProperty(nodeList, node.properties);\n node.propertyNames && toSchemaNodes(node.propertyNames, nodeList);\n node.unevaluatedProperties && toSchemaNodes(node.unevaluatedProperties, nodeList);\n node.unevaluatedItems && toSchemaNodes(node.unevaluatedItems, nodeList);\n\n return nodeList;\n}\n","import { resolve } from \"uri-js\";\n\nconst suffixes = /(#)+$/;\nconst trailingHash = /#$/;\nconst isDomain = /^[^:]+:\\/\\/[^/]+\\//;\nconst idAndPointer = /#.*$/;\n\n/**\n * Resolves a reference URI against a base URI.\n * Uses fast-uri (RFC 3986 compliant) for most cases, with special handling for JSON Schema specifics.\n *\n * This replaces the custom joinId logic while leveraging the standards-compliant fast-uri library.\n *\n * @param base - The base URI (e.g., current scope $id)\n * @param ref - The reference to resolve (e.g., $id, $ref, or json-pointer)\n * @returns The resolved absolute URI\n */\nexport function resolveUri(base?: string, ref?: string): string {\n if (ref == null) {\n return base?.replace(trailingHash, \"\") ?? \"#\";\n }\n\n if (base == null || base === \"#\") {\n return ref?.replace(trailingHash, \"\");\n }\n\n // If ref starts with #, it's a fragment - for JSON Schema, append to base without its fragment\n if (ref[0] === \"#\") {\n if (base[0] === \"/\") {\n return ref;\n }\n return `${base.replace(idAndPointer, \"\")}${ref.replace(suffixes, \"\")}`;\n }\n\n // If ref is a full domain, it's absolute\n if (isDomain.test(ref)) {\n return ref.replace(trailingHash, \"\");\n }\n\n return resolve(base, ref ?? \"\") ?? \"#\";\n}\n","import { JsonSchema } from \"../types\";\nimport { getTypeOf } from \"./getTypeOf\";\nimport { isObject } from \"./isObject\";\n\nexport function mergeSchema<T extends JsonSchema>(a: T, b: T, ...omit: string[]): T {\n if (b?.type === \"error\") {\n return b;\n } else if (a?.type === \"error\") {\n return a;\n }\n\n const aType = getTypeOf(a);\n const bType = getTypeOf(b);\n if (aType !== bType) {\n return a;\n }\n\n const schema = mergeSchema2(a, b) as T;\n for (const s of omit) {\n delete schema[s]; // eslint-disable-line @typescript-eslint/no-dynamic-delete\n }\n\n return schema;\n}\n\nexport function mergeSchema2(a: unknown, b: unknown, property?: string): unknown {\n if (isObject(a) && isObject(b)) {\n const newObject: Record<string, unknown> = {};\n [...Object.keys(a), ...Object.keys(b)]\n .filter((item, index, array) => array.indexOf(item) === index)\n .forEach((key) => (newObject[key] = mergeSchema2(a[key], b[key], key)));\n return newObject;\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (property === \"required\" || property === \"anyOf\") {\n return a.concat(b).filter((item, index, array) => array.indexOf(item) === index);\n }\n if (property === \"items\" || property === \"prefixItems\") {\n const result: unknown[] = [];\n for (let i = 0; i < b.length; i += 1) {\n if (isObject(a[i]) && isObject(b[i]) && a[i].type === b[i].type) {\n result[i] = mergeSchema2(a[i], b[i]);\n } else {\n result.push(b[i] ?? a[i]);\n }\n }\n return result;\n }\n const result: unknown[] = [];\n const append: unknown[] = [];\n for (let i = 0; i < Math.max(a.length, b.length); i += 1) {\n if (isObject(a[i]) && isObject(b[i])) {\n result[i] = mergeSchema2(a[i], b[i]);\n } else {\n if (a[i] !== undefined && b[i] !== undefined) {\n result[i] = a[i];\n append.push(b[i]);\n } else if (a[i] !== undefined) {\n result[i] = a[i];\n } else if (b[i] !== undefined) {\n append.push(b[i]);\n }\n }\n }\n return [...result, ...append].filter((item, index, array) => array.indexOf(item) === index);\n }\n\n if (Array.isArray(b)) {\n return b;\n }\n\n if (Array.isArray(a)) {\n return a;\n }\n\n if (b !== undefined) {\n return b;\n }\n\n return a;\n}\n","import { isSchemaNode, SchemaNode } from \"./types\";\nimport { mergeSchema } from \"./utils/mergeSchema\";\nimport { joinDynamicId } from \"./SchemaNode\";\n\ninterface SchemaNodeCB {\n toJSON?: () => string;\n order?: number;\n (...args: any[]): any; // eslint-disable-line @typescript-eslint/no-explicit-any\n}\n\nfunction sortCb(a: SchemaNodeCB, b: SchemaNodeCB) {\n return (b.order ?? 0) - (a.order ?? 0);\n}\n\nexport function removeDuplicates(fun: SchemaNodeCB, funIndex: number, list: SchemaNodeCB[]) {\n if (fun == null || list.indexOf(fun) !== funIndex) {\n return false;\n }\n const funName = fun.toJSON?.() ?? fun.name;\n return list.find((fun: SchemaNodeCB, index) => (fun.toJSON?.() ?? fun.name) === funName && index === funIndex);\n}\n\nfunction mergeObjects(a?: Record<string, SchemaNode>, b?: Record<string, SchemaNode>) {\n if (a == null || b == null) {\n return b || a;\n }\n const object: Record<string, SchemaNode> = {};\n [...Object.keys(a), ...Object.keys(b)]\n .filter((p, i, l) => l.indexOf(p) === i)\n .forEach((key) => {\n const result = mergeNode(a[key], b[key]);\n if (isSchemaNode(result)) {\n object[key] = result;\n }\n });\n\n return object;\n}\n\nfunction combineArrays<T>(a?: T[], b?: T[]): T[] | undefined {\n if (a == null || b == null) {\n return b || a;\n }\n return a.concat(b).filter((value, index, list) => list.indexOf(value) === index);\n}\n\nfunction mergePatternProperties(a?: SchemaNode[\"patternProperties\"], b?: SchemaNode[\"patternProperties\"]) {\n if (a == null || b == null) {\n return a || b;\n }\n const result = [...a];\n const pointerList = a.map((p) => p.node.evaluationPath);\n b.forEach((p) => {\n if (!pointerList.includes(p.node.evaluationPath)) {\n result.push(p);\n }\n });\n return result;\n}\n\nexport function mergeNode(a?: SchemaNode, b?: SchemaNode, ...omit: string[]): SchemaNode | undefined {\n if (a == null || b == null) {\n return a || b;\n }\n\n // do not merge items and prefixItems (+ additionalItems)\n const arraySelection: Partial<SchemaNode> = {};\n if ((a.items && b.prefixItems) || (a.prefixItems && b.items)) {\n if (b.prefixItems) {\n arraySelection.prefixItems = b.prefixItems;\n } else {\n arraySelection.items = b.items!;\n }\n } else {\n // prefixItems?: SchemaNode[];\n arraySelection.prefixItems = (b.prefixItems ?? a.prefixItems)!;\n arraySelection.items = mergeNode(a.items, b.items)!;\n }\n\n // we have no node-type if (atype !== b.type) {return a; }\n\n // @ts-expect-error simplified merging of objects\n const mergedNode: SchemaNode = {\n // note: {x: b.x ?? a.x} is already done by {...a, ...b}\n ...a,\n ...b,\n ...arraySelection,\n dynamicId: joinDynamicId(a.dynamicId, b.dynamicId),\n oneOfIndex: a.oneOfIndex ?? b.oneOfIndex,\n schema: mergeSchema(a.schema, b.schema, ...omit),\n parent: a.parent,\n resolvers: a.resolvers.concat(b.resolvers).filter(removeDuplicates).sort(sortCb),\n reducers: a.reducers.concat(b.reducers).filter(removeDuplicates).sort(sortCb),\n validators: a.validators.concat(b.validators).filter(removeDuplicates).sort(sortCb),\n\n additionalProperties: mergeNode(a.additionalProperties, b.additionalProperties),\n contains: mergeNode(a.contains, b.contains),\n enum: combineArrays(a.enum, b.enum),\n if: mergeNode(a.if, b.if),\n then: mergeNode(a.then, b.then),\n else: mergeNode(a.else, b.else),\n not: mergeNode(a.not, b.not),\n propertyNames: mergeNode(a.propertyNames, b.propertyNames),\n unevaluatedProperties: mergeNode(a.unevaluatedProperties, b.unevaluatedProperties),\n unevaluatedItems: mergeNode(a.unevaluatedItems, b.unevaluatedItems),\n $defs: mergeObjects(a.$defs, b.$defs),\n patternProperties: mergePatternProperties(a.patternProperties, b.patternProperties),\n properties: mergeObjects(a.properties, b.properties),\n required: combineArrays(a.required, b.required)\n };\n\n // this removes any function that has no keyword associated on schema\n function filterKeywordsBySchema(fun: SchemaNodeCB) {\n const funName = fun.toJSON?.() ?? fun.name;\n if (mergedNode.schema?.[funName] === undefined) {\n // @ts-expect-error forced key\n mergedNode[funName] = undefined;\n return false;\n }\n return true;\n }\n\n // @ts-expect-error forced key\n omit?.forEach((key) => (mergedNode[key] = undefined));\n // @todo better run addX features to determine removal as it is more performant and direct?\n mergedNode.resolvers = mergedNode.resolvers.filter(filterKeywordsBySchema);\n mergedNode.reducers = mergedNode.reducers.filter(filterKeywordsBySchema);\n mergedNode.validators = mergedNode.validators.filter(filterKeywordsBySchema);\n\n return mergedNode;\n}\n","/**\n * Omit properties from input schema. Accepts any number of properties to\n * remove. Example:\n *\n * ```ts\n * omit(myObject, \"if\", \"dependencies\");\n * ```\n *\n * @returns shallow copy of input object without specified properties\n */\nexport function omit(object: Record<string, unknown>, ...keysToOmit: string[]) {\n const result: Record<string, unknown> = {};\n Object.keys(object).forEach((key) => {\n if (!keysToOmit.includes(key)) {\n result[key] = object[key];\n }\n });\n return result;\n}\n","import { isObject } from \"../utils/isObject\";\n\nexport function pick<T extends { [P in keyof T]: unknown }, K extends keyof T>(value: T, ...properties: K[]) {\n if (!isObject(value) || properties.length === 0) {\n return value;\n }\n const result = {} as Pick<T, K>;\n properties.forEach((property) => {\n if (value[property] !== undefined) {\n result[property] = value[property];\n }\n });\n return result;\n}\n","export function render(template: string, data: Record<string, unknown> = {}): string {\n return template.replace(/\\{\\{(\\w+)\\}\\}/g, (_, key) => {\n const variable = data[key];\n if (variable === null || variable === undefined) return \"\"; // optional\n if (typeof variable === \"object\") {\n return JSON.stringify(variable);\n }\n return String(variable);\n });\n}\n","import { BooleanSchema, isJsonError, JsonSchema, SchemaNode } from \"./types\";\nimport { SchemaNodeWithRequired, ValidationPath, ValidationReturnType } from \"./Keyword\";\nimport sanitizeErrors from \"./utils/sanitizeErrors\";\n\nexport function validateNode(node: SchemaNode, data: unknown, pointer: string, path: ValidationPath) {\n if (isJsonError(node)) {\n return [node];\n }\n path.push({ pointer, node });\n const schema = node.schema as BooleanSchema | JsonSchema;\n if (schema === true) {\n return [];\n }\n if (schema === false) {\n return [\n node.createError(\"invalid-data-error\", {\n value: data,\n pointer,\n schema: node.schema\n })\n ];\n }\n const errors: ValidationReturnType = [];\n for (const validate of node.validators) {\n const result = validate({ node: node as SchemaNodeWithRequired<keyof SchemaNode>, data, pointer, path });\n if (Array.isArray(result)) {\n errors.push(...result);\n } else if (result) {\n errors.push(result);\n }\n }\n return sanitizeErrors(errors);\n}\n","const hasOwnProperty = Object.prototype.hasOwnProperty;\nexport const hasProperty = (value: Record<string, unknown>, property: string) =>\n !(value[property] === undefined || !hasOwnProperty.call(value, property));\n","import { isObject } from \"../utils/isObject\";\n\nexport function getValue(data: unknown, key: string | number) {\n if (isObject(data)) {\n return data[key];\n } else if (Array.isArray(data)) {\n return data[key as number];\n }\n}\n","import { GetNodeOptions, isSchemaNode, SchemaNode } from \"./SchemaNode\";\nimport { isJsonError, NodeOrError, OptionalNodeOrError } from \"./types\";\nimport { split } from \"@sagold/json-pointer\";\nimport { getValue } from \"./utils/getValue\";\n\n// prettier-ignore\nexport function getNode(pointer: string, data: unknown, options: { withSchemaWarning: true } & GetNodeOptions): NodeOrError;\nexport function getNode(pointer: string, data: unknown, options: { createSchema: true } & GetNodeOptions): NodeOrError;\nexport function getNode(pointer: string, data?: unknown, options?: GetNodeOptions): OptionalNodeOrError;\n\n/**\n * Returns a node containing JSON Schema of a data JSON Pointer.\n *\n * - the returned node will have a reduced schema based on given input data\n * - the returned node $ref is resolved\n *\n * To resolve dynamic schema where the type of JSON Schema is evaluated by\n * its value, a data object has to be passed in options.\n *\n * Per default this function will return `undefined` schema for valid properties\n * that do not have a defined schema. Use the option `withSchemaWarning: true` to\n * receive an error with `code: schema-warning` containing the location of its\n * last evaluated json-schema.\n *\n * @returns { node } or { error } where node can also be undefined (valid but undefined)\n */\nexport function getNode(\n pointer: string,\n data?: unknown,\n options: GetNodeOptions = {}\n): OptionalNodeOrError | NodeOrError {\n options.path = options.path ?? [];\n options.withSchemaWarning = options.withSchemaWarning ?? false;\n options.pointer = options.pointer ?? \"#\";\n // @ts-expect-error explicitely any\n const node = this as SchemaNode;\n const keys = split(pointer);\n if (keys.length === 0) {\n const result = node.resolveRef(options);\n return isJsonError(result) ? { node: undefined, error: result } : { node: result, error: undefined };\n }\n let currentPointer = \"#\";\n let currentNode = node;\n for (let i = 0, l = keys.length; i < l; i += 1) {\n currentPointer = `${currentPointer}/${keys[i]}`;\n const result = currentNode.getNodeChild(keys[i], data, { ...options, pointer: currentPointer });\n if (result.error) {\n return result;\n }\n if (result.node == null) {\n return result;\n }\n currentNode = result.node;\n data = getValue(data, keys[i]);\n }\n\n const { node: reducedNode, error: reduceError } = currentNode.resolveRef(options).reduceNode(data);\n\n if (isJsonError(reduceError)) {\n return { node: undefined, error: reduceError };\n }\n if (isSchemaNode(reducedNode)) {\n return { node: reducedNode, error: undefined };\n }\n\n return { error: undefined };\n}\n","import { GetNodeOptions, isSchemaNode, SchemaNode } from \"./SchemaNode\";\nimport { isJsonError, NodeOrError, OptionalNodeOrError } from \"./types\";\nimport { getValue } from \"./utils/getValue\";\n\nexport function getNodeChild(key: string | number, data: unknown, options: { withSchemaWarning: true } & GetNodeOptions): NodeOrError; // prettier-ignore\nexport function getNodeChild(key: string | number, data: unknown, options: { createSchema: true } & GetNodeOptions): NodeOrError; // prettier-ignore\nexport function getNodeChild(key: string | number, data?: unknown, options?: GetNodeOptions): OptionalNodeOrError;\n\n/**\n * Returns the child for the given property-name or array-index\n *\n * - the returned child node is **not reduced**\n * - a child node $ref is resolved\n *\n * @returns { node } or { error } where node can also be undefined (valid but undefined)\n */\nexport function getNodeChild(\n key: string | number,\n data?: unknown,\n options: GetNodeOptions = {}\n): OptionalNodeOrError | NodeOrError {\n options.path = options.path ?? [];\n options.withSchemaWarning = options.withSchemaWarning ?? false;\n options.pointer = options.pointer ?? \"#\";\n const { path, pointer } = options;\n\n // reduce parent\n // @ts-expect-error implicitely any\n let parentNode = this as SchemaNode;\n if (parentNode.reducers.length) {\n const result = parentNode.reduceNode(data, { key, path, pointer });\n if (result.error) {\n return result;\n }\n if (isSchemaNode(result.node)) {\n parentNode = result.node;\n }\n }\n\n // find child node\n for (const resolver of parentNode.resolvers) {\n const schemaNode = resolver({ data, key, node: parentNode });\n // a matching resolver found an error, return\n if (isJsonError(schemaNode)) {\n return { node: undefined, error: schemaNode };\n }\n // a matching resolver found a child node, return\n if (isSchemaNode(schemaNode)) {\n return { node: schemaNode.resolveRef({ pointer, path }), error: undefined };\n }\n }\n\n // no child node was found, but the child node is valid\n if (options.createSchema === true) {\n const newNode = parentNode.compileSchema(\n parentNode.createSchema(getValue(data, key)),\n `${parentNode.evaluationPath}/additional`,\n `${parentNode.schemaLocation}/additional`\n );\n return { node: newNode, error: undefined };\n }\n\n if (options.withSchemaWarning === true) {\n const error = parentNode.createError(\"schema-warning\", {\n pointer,\n value: data,\n schema: parentNode.schema,\n key\n });\n return { node: undefined, error };\n }\n\n return { node: undefined };\n}\n","import { copy } from \"fast-copy\";\nimport sanitizeErrors from \"./utils/sanitizeErrors\";\nimport settings from \"./settings\";\nimport type {\n JsonSchemaReducer,\n JsonSchemaResolver,\n JsonSchemaValidator,\n Keyword,\n Maybe,\n ValidationAnnotation,\n ValidationPath\n} from \"./Keyword\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { Draft } from \"./Draft\";\nimport { toSchemaNodes } from \"./methods/toSchemaNodes\";\nimport {\n isJsonError,\n isJsonSchema,\n JsonSchema,\n BooleanSchema,\n JsonError,\n AnnotationData,\n DefaultErrors,\n OptionalNodeOrError,\n NodeOrError,\n JsonAnnotation,\n isJsonAnnotation,\n isBooleanSchema\n} from \"./types\";\nimport { isObject } from \"./utils/isObject\";\nimport { join } from \"@sagold/json-pointer\";\nimport { resolveUri } from \"./utils/resolveUri\";\nimport { mergeNode } from \"./mergeNode\";\nimport { omit } from \"./utils/omit\";\nimport { pick } from \"./utils/pick\";\nimport { render } from \"./errors/render\";\nimport { TemplateOptions } from \"./methods/getData\";\nimport { validateNode } from \"./validateNode\";\nimport { hasProperty } from \"./utils/hasProperty\";\nimport { getNode } from \"./getNode\";\nimport { getNodeChild } from \"./getNodeChild\";\nimport { DataNode } from \"./methods/toDataNodes\";\n\nconst { DYNAMIC_PROPERTIES, REGEX_FLAGS, DECLARATOR_ONEOF } = settings;\n\nexport function isSchemaNode(value: unknown): value is SchemaNode {\n return isObject(value) && Array.isArray(value?.reducers) && Array.isArray(value?.resolvers);\n}\n\nexport function isReduceable(node: SchemaNode) {\n for (let i = 0, l = DYNAMIC_PROPERTIES.length; i < l; i += 1) {\n // @ts-expect-error interface to object conversion\n if (hasProperty(node, DYNAMIC_PROPERTIES[i])) {\n return true;\n }\n }\n return false;\n}\n\nfunction getDraft(drafts: Draft[], $schema: string) {\n if (!Array.isArray(drafts) || drafts.length === 0) {\n throw new Error(`Missing drafts in 'compileSchema({ $schema: \"${$schema}\" })'`);\n }\n if (drafts.length === 1) {\n return drafts[0];\n }\n return drafts.find((d) => new RegExp(d.$schemaRegEx, REGEX_FLAGS).test($schema)) ?? drafts[drafts.length - 1];\n}\n\nexport type Context = {\n /** root node of this JSON Schema */\n rootNode: SchemaNode;\n /** Fallback _draft_ version in case no _draft_ is specified by `schema.$schema` */\n draft?: string;\n /** available draft configurations */\n drafts: Draft[];\n /** [SHARED ACROSS REMOTES] root nodes of registered remote JSON Schema, stored by id/url */\n remotes: Record<string, SchemaNode>;\n /** references stored by fully resolved schema-$id + local-pointer */\n refs: Record<string, SchemaNode>;\n /** anchors stored by fully resolved schema-$id + $anchor */\n anchors: Record<string, SchemaNode>;\n /** [SHARED ACROSS REMOTES] dynamicAnchors stored by fully resolved schema-$id + $anchor */\n dynamicAnchors: Record<string, SchemaNode>;\n /** JSON Schema parser, validator, reducer and resolver for this JSON Schema (root schema and its child nodes) */\n keywords: Draft[\"keywords\"];\n /** JSON Schema draft dependend methods */\n methods: Draft[\"methods\"];\n /** draft version */\n version: Draft[\"version\"];\n /** draft errors & template-strings */\n errors: Draft[\"errors\"];\n /** draft formats & validators */\n formats: Draft[\"formats\"];\n /** [SHARED USING ADD REMOTE] getData default options */\n getDataDefaultOptions?: TemplateOptions;\n /** [SHARED USING ADD REMOTE] collect unknown keywords in schemaAnnotations */\n withSchemaAnnotations?: boolean;\n /** [SHARED USING ADD REMOTE] throw error on validation when ref cannot be resolved */\n throwOnInvalidRef?: boolean;\n};\n\nexport interface SchemaNode extends SchemaNodeMethodsType {\n /** shared context across nodes of JSON schema and shared properties across all remotes */\n context: Context;\n /** JSON Schema of node */\n schema: JsonSchema;\n /**\n * Evaluation Path - The location of the keyword that produced the annotation or error.\n * The purpose of this data is to show the resolution path which resulted in the subschema\n * that contains the keyword.\n *\n * - relative to the root of the principal schema; should include (inline) any $ref segments in the path\n * - JSON pointer\n */\n evaluationPath: string;\n /**\n * Schema Location - The direct location to the keyword that produced the annotation\n * or error. This is provided as a convenience to the user so that they don't have to resolve\n * the keyword's subschema, which may not be trivial task. It is only provided if the relative\n * location contains $refs (otherwise, the two locations will be the same).\n *\n * - absolute URI\n * - may not have any association to the principal schema\n */\n schemaLocation: string;\n /** id created when combining subschemas */\n dynamicId: string;\n /** reference to parent node (node used to compile this node) */\n parent?: SchemaNode | undefined;\n /** JSON Pointer from last $id ~~to this location~~ to resolve $refs to $id#/idLocalPointer */\n lastIdPointer: string;\n /** when reduced schema containing `oneOf` schema, `oneOfIndex` stores `oneOf`-item used for merge */\n oneOfIndex?: number;\n\n reducers: JsonSchemaReducer[];\n resolvers: JsonSchemaResolver[];\n validators: JsonSchemaValidator[];\n schemaValidation?: ValidationAnnotation[];\n\n // parsed schema properties (registered by parsers)\n $id?: string;\n $defs?: Record<string, SchemaNode>;\n $ref?: string;\n additionalProperties?: SchemaNode;\n allOf?: SchemaNode[];\n anyOf?: SchemaNode[];\n contains?: SchemaNode;\n dependentRequired?: Record<string, string[]>;\n dependentSchemas?: Record<string, SchemaNode | boolean>;\n deprecated?: boolean;\n else?: SchemaNode;\n enum?: unknown[];\n if?: SchemaNode;\n /**\n * # Items-array schema - for all drafts\n *\n * - for drafts prior 2020-12 `schema.items[]`-schema stored as `node.prefixItems`\n *\n * Validation succeeds if each element of the instance validates against the schema at the\n * same position, if any.\n *\n * The `prefixItems` keyword restricts a number of items from the start of an array instance\n * to validate against the given sequence of subschemas, where the item at a given index in\n * the array instance is evaluated against the subschema at the given index in the `prefixItems`\n * array, if any. Array items outside the range described by the `prefixItems` keyword is\n * evaluated against the items keyword, if present.\n *\n * [Docs](https://www.learnjsonschema.com/2020-12/applicator/prefixitems/)\n * | [Examples](https://json-schema.org/understanding-json-schema/reference/array#tupleValidation)\n */\n prefixItems?: SchemaNode[];\n /**\n * # Items-object schema for additional array item - for all drafts\n *\n * - for drafts prior 2020-12 `schema.additionalItems` object-schema stored as `node.items`\n *\n * Validation succeeds if each element of the instance not covered by `prefixItems` validates\n * against this schema.\n *\n * The items keyword restricts array instance items not described by the sibling `prefixItems`\n * keyword (if any), to validate against the given subschema. Whetherthis keyword was evaluated\n * against any item of the array instance is reported using annotations.\n *\n * [Docs](https://www.learnjsonschema.com/2020-12/applicator/items/)\n * | [Examples](https://json-schema.org/understanding-json-schema/reference/array#items)\n * | [AdditionalItems Specification](https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#additionalItems)\n */\n items?: SchemaNode;\n maximum?: number;\n minimum?: number;\n maxItems?: number;\n maxLength?: number;\n maxProperties?: number;\n minItems?: number;\n minLength?: number;\n minProperties?: number;\n not?: SchemaNode;\n oneOf?: SchemaNode[];\n multipleOf?: number;\n pattern?: RegExp;\n patternProperties?: { name: string; pattern: RegExp; node: SchemaNode }[];\n propertyDependencies?: Record<string, Record<string, SchemaNode>>;\n properties?: Record<string, SchemaNode>;\n propertyNames?: SchemaNode;\n required?: string[];\n then?: SchemaNode;\n type?: string | string[];\n unevaluatedItems?: SchemaNode;\n unevaluatedProperties?: SchemaNode;\n uniqueItems?: true;\n}\n\n/**\n * Fixed SchemaNode mixin methods\n */\ninterface SchemaNodeMethodsType {\n compileSchema(\n schema: JsonSchema | BooleanSchema,\n evaluationPath?: string,\n schemaLocation?: string,\n dynamicId?: string\n ): SchemaNode;\n createError<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonError;\n createAnnotation<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonAnnotation;\n createSchema(data?: unknown): JsonSchema;\n\n /**\n * Returns a node matching the given location (pointer) in data\n *\n * - the returned node will have a **reduced schema** based on given input data\n * - return returned node $ref is resolved\n *\n * To resolve dynamic schema where the type of JSON Schema is evaluated by\n * its value, a data object has to be passed in options.\n *\n * Per default this function will return `undefined` schema for valid properties\n * that do not have a defined schema. Use the option `withSchemaWarning: true` to\n * receive an error with `code: schema-warning` containing the location of its\n * last evaluated json-schema.\n *\n * @returns { node } or { error } where node can also be undefined (valid but undefined)\n */\n getNode(pointer: string, data: unknown, options: { withSchemaWarning: true } & GetNodeOptions): NodeOrError;\n getNode(pointer: string, data: unknown, options: { createSchema: true } & GetNodeOptions): NodeOrError;\n getNode(pointer: string, data?: unknown, options?: GetNodeOptions): OptionalNodeOrError;\n\n /**\n * Returns the child for the given property-name or array-index\n *\n * - the returned child node is **not reduced**\n * - a child node $ref is resolved\n *\n * @returns { node } or { error } where node can also be undefined (valid but undefined)\n */\n getNodeChild(\n key: string | number,\n data: unknown,\n options: { withSchemaWarning: true } & GetNodeOptions\n ): NodeOrError;\n getNodeChild(key: string | number, data: unknown, options: { createSchema: true } & GetNodeOptions): NodeOrError;\n getNodeChild(key: string | number, data?: unknown, options?: GetNodeOptions): OptionalNodeOrError;\n\n getChildSelection(property: string | number): JsonError | SchemaNode[];\n getNodeRef($ref: string): SchemaNode | undefined;\n getNodeRoot(): SchemaNode;\n getDraftVersion(): string;\n getData(data?: unknown, options?: TemplateOptions): any; // eslint-disable-line @typescript-eslint/no-explicit-any\n reduceNode(\n data: unknown,\n options?: { key?: string | number; pointer?: string; path?: ValidationPath }\n ): OptionalNodeOrError;\n resolveRef: (args?: { pointer?: string; path?: ValidationPath }) => SchemaNode;\n validate(data: unknown, pointer?: string, path?: ValidationPath): ValidateReturnType;\n addRemoteSchema(url: string, schema: JsonSchema | BooleanSchema): SchemaNode;\n toSchemaNodes(): SchemaNode[];\n toDataNodes(data: unknown, pointer?: string): DataNode[];\n toJSON(): unknown;\n}\n\nexport type GetNodeOptions = {\n /**\n * Per default `undefined` is returned for valid data, but undefined schema.\n *\n * - Using `withSchemaWarning:true` will return an error instead: `{ type: \"error\", code: \"schema-warning\" }`\n */\n withSchemaWarning?: boolean;\n /**\n * Per default `undefined` is returned for valid data, but undefined schema.\n *\n * - Using `createSchema:true` will create a schema instead\n */\n createSchema?: boolean;\n path?: ValidationPath;\n pointer?: string;\n};\n\nexport type ValidateReturnType = {\n /**\n * True, if data is valid to the compiled schema.\n * Does not include async errors.\n */\n valid: boolean;\n /**\n * List of validation errors or empty\n */\n errors: JsonError[];\n /**\n * List of annotations from validators\n */\n annotations: JsonAnnotation[];\n /**\n * List of Promises resolving to `JsonError|undefined` or empty.\n */\n errorsAsync: Promise<Maybe<ValidationAnnotation>[]>[];\n};\n\nexport function joinDynamicId(a?: string, b?: string) {\n if (a == b) {\n return a ?? \"\";\n }\n if (a == null || b == null) {\n return (a || b) ?? \"\";\n }\n if (a.startsWith(b)) {\n return a;\n }\n if (b.startsWith(a)) {\n return b;\n }\n return `${a}+${b}`;\n}\n\nexport const SchemaNodeMethods = {\n /**\n * Compiles a child-schema of this node to its context\n * @returns SchemaNode representing the passed JSON Schema\n */\n compileSchema(schema: JsonSchema, evaluationPath: string, schemaLocation?: string, dynamicId?: string): SchemaNode {\n const parentNode = this as SchemaNode;\n evaluationPath = evaluationPath ?? parentNode.evaluationPath;\n const nextFragment = evaluationPath.split(\"/$ref\")[0];\n const node: SchemaNode = {\n lastIdPointer: parentNode.lastIdPointer, // ref helper\n context: parentNode.context,\n parent: parentNode,\n evaluationPath,\n dynamicId: joinDynamicId(parentNode.dynamicId, dynamicId),\n schemaLocation: schemaLocation ?? join(parentNode.schemaLocation, nextFragment),\n reducers: [],\n resolvers: [],\n validators: [],\n schema,\n ...SchemaNodeMethods\n };\n\n if (!isJsonSchema(schema) && !isBooleanSchema(schema)) {\n node.schemaValidation = [\n node.createError(\"schema-error\", {\n pointer: schemaLocation ?? evaluationPath,\n schema,\n value: undefined,\n message: `JSON schema must be object or boolean - reveived: '${schema}'`\n })\n ];\n return node;\n }\n const schemaValidation = addKeywords(node).filter((err) => err != null);\n node.schemaValidation = sanitizeErrors(schemaValidation);\n\n return node;\n },\n\n createError<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonError {\n const node = this as SchemaNode;\n let errorMessage = message;\n if (errorMessage === undefined) {\n const error = node.schema?.errorMessages?.[code] ?? node.context.errors[code];\n if (typeof error === \"function\") {\n return error(data);\n }\n errorMessage = render(error ?? name, data);\n }\n return { type: \"error\", code, message: errorMessage, data };\n },\n\n createAnnotation<T extends string = DefaultErrors>(\n code: T,\n data: AnnotationData,\n message?: string\n ): JsonAnnotation {\n const node = this as SchemaNode;\n let annotationMessage = message;\n if (annotationMessage === undefined) {\n const error = node.schema?.errorMessages?.[code] ?? node.context.errors[code];\n if (typeof error === \"function\") {\n return error(data);\n }\n annotationMessage = render(error ?? name, data);\n }\n return { type: \"annotation\", code, message: annotationMessage, data };\n },\n\n createSchema,\n\n getChildSelection(property: string | number): JsonError | SchemaNode[] {\n const node = this as SchemaNode;\n return node.context.methods.getChildSelection(node, property);\n },\n\n getNode,\n getNodeChild,\n\n /**\n * @returns for $ref, the corresponding SchemaNode or undefined\n */\n getNodeRef($ref: string): SchemaNode | undefined {\n const node = this as SchemaNode;\n return node.compileSchema({ $ref }, \"$dynamic\").resolveRef();\n },\n\n getNodeRoot() {\n const node = this as SchemaNode;\n return node.context.rootNode;\n },\n\n /**\n * @returns draft version this JSON Schema is evaluated by\n */\n getDraftVersion() {\n return (this as SchemaNode).context.version;\n },\n\n /**\n * @returns data that is valid to the schema of this node\n */\n getData(data?: unknown, options?: TemplateOptions) {\n const node = this as SchemaNode;\n const opts = {\n recursionLimit: 1,\n ...node.context.getDataDefaultOptions,\n cache: {},\n ...(options ?? {})\n };\n return node.context.methods.getData(node, data, opts);\n },\n\n /**\n * @returns SchemaNode with a reduced JSON Schema matching the given data\n */\n reduceNode(\n data: unknown,\n options: { key?: string | number; pointer?: string; path?: ValidationPath } = {}\n ): OptionalNodeOrError {\n const node = this as SchemaNode;\n const { key = \"missing-key\", pointer = node.evaluationPath, path } = options;\n\n // @ts-expect-error bool schema\n if (node.schema === false) {\n return { node, error: undefined };\n // @ts-expect-error bool schema\n } else if (node.schema === true) {\n const nextNode = node.compileSchema(createSchema(data), node.evaluationPath, node.schemaLocation);\n path?.push({ pointer, node });\n return { node: nextNode, error: undefined };\n }\n\n let schema;\n // we need to copy node to prevent modification of source\n // @todo does mergeNode break immutability?\n let workingNode = node.compileSchema(node.schema, node.evaluationPath, node.schemaLocation);\n const reducers = node.reducers;\n for (const reducer of reducers) {\n const result = reducer({ data, key, node, pointer, path: path ?? [] });\n if (isJsonError(result)) {\n return { node: undefined, error: result };\n }\n if (result) {\n // @ts-expect-error bool schema - for undefined & false schema return false schema\n if (result.schema === false) {\n schema = false;\n break;\n }\n // compilation result for data of current schemain order to merge results, we rebuild\n // node from schema alternatively we would need to merge by node-property\n workingNode = mergeNode(workingNode, result) as SchemaNode;\n }\n }\n\n if (schema === false) {\n // @ts-expect-error bool schema\n return { node: { ...node, schema: false, reducers: [] } as SchemaNode, error: undefined };\n }\n\n if (workingNode !== node) {\n path?.push({ pointer, node });\n }\n\n // remove dynamic properties of node\n workingNode.schema = omit(workingNode.schema, DECLARATOR_ONEOF, ...DYNAMIC_PROPERTIES);\n // @ts-expect-error string accessing schema props\n DYNAMIC_PROPERTIES.forEach((prop) => (workingNode[prop] = undefined));\n return { node: workingNode, error: undefined };\n },\n\n /**\n * @returns validation result of data validated by this node's JSON Schema\n */\n validate(data: unknown, pointer = \"#\", path: ValidationPath = []) {\n const node = this as SchemaNode;\n const errors = validateNode(node, data, pointer, path) ?? [];\n const syncErrors: JsonError[] = [];\n const annotations: JsonAnnotation[] = [];\n const flatErrorList = sanitizeErrors(Array.isArray(errors) ? errors : [errors]).filter(isJsonError);\n\n const errorsAsync: Promise<Maybe<ValidationAnnotation>[]>[] = [];\n sanitizeErrors(Array.isArray(errors) ? errors : [errors]).forEach((error) => {\n if (isJsonError(error)) {\n if (node.context.throwOnInvalidRef && error.code === \"ref-error\") {\n const refError = new Error(\"Invalid $ref: \" + error.message);\n // @ts-expect-error unknown error-property\n refError.data = syncErrors;\n throw refError;\n }\n\n syncErrors.push(error);\n } else if (error instanceof Promise) {\n errorsAsync.push(error.then(sanitizeErrors));\n } else if (isJsonAnnotation(error)) {\n annotations.push(error);\n }\n });\n\n const result: ValidateReturnType = {\n valid: flatErrorList.length === 0,\n errors: syncErrors,\n annotations,\n errorsAsync\n };\n\n return result;\n },\n\n /**\n * Register a JSON Schema as a remote-schema to be resolved by $ref, $anchor, etc\n * @returns the current node (not the remote schema-node)\n */\n addRemoteSchema(url: string, schema: JsonSchema | BooleanSchema): SchemaNode {\n // @draft >= 6\n if (isJsonSchema(schema)) {\n schema.$id = resolveUri(schema.$id || url);\n }\n\n const node = this as SchemaNode;\n const { context } = node;\n const schemaId = isJsonSchema(schema) ? (node.context.draft ?? schema.$schema) : undefined;\n const draft = getDraft(context.drafts, schemaId ?? context.rootNode.schema?.$schema);\n\n const remoteNode: SchemaNode = {\n evaluationPath: \"#\",\n lastIdPointer: \"#\",\n schemaLocation: \"#\",\n dynamicId: \"\",\n reducers: [],\n resolvers: [],\n validators: [],\n schema,\n context: {\n ...context,\n refs: {},\n anchors: {},\n ...copy(pick(draft, \"methods\", \"keywords\", \"version\", \"formats\", \"errors\"))\n },\n ...SchemaNodeMethods\n } as SchemaNode;\n\n remoteNode.context.rootNode = remoteNode;\n remoteNode.context.remotes[resolveUri(url)] = remoteNode;\n addKeywords(remoteNode);\n\n return node;\n },\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n resolveRef(args?: { pointer?: string; path?: ValidationPath }) {\n throw new Error(\"method 'resolveRef' is not implemented\");\n return this as SchemaNode;\n },\n\n /**\n * @returns a list of all sub-schema as SchemaNode\n */\n toSchemaNodes() {\n return toSchemaNodes(this);\n },\n\n /**\n * @returns a list of values (including objects and arrays) and their corresponding JSON Schema as SchemaNode\n */\n toDataNodes(data: unknown, pointer?: string): DataNode[] {\n const node = this as SchemaNode;\n return node.context.methods.toDataNodes(node, data, pointer);\n },\n\n toJSON() {\n const node = this as SchemaNode;\n return { ...node, context: undefined, errors: undefined, parent: node.parent?.evaluationPath };\n }\n} as const;\n\nconst whitelist = [\"$ref\", \"if\", \"$defs\"];\nconst noRefMergeDrafts = [\"draft-04\", \"draft-06\", \"draft-07\"];\n\nexport function addKeywords(node: SchemaNode) {\n if (node.schema.$ref && noRefMergeDrafts.includes(node.context.version)) {\n // for these draft versions only ref is validated\n return node.context.keywords\n .filter(({ keyword }) => whitelist.includes(keyword))\n .map((keyword) => execKeyword(keyword, node));\n }\n const keys = Object.keys(node.schema);\n const errors = node.context.keywords\n .filter(({ keyword }) => whitelist.includes(keyword) || keys.includes(keyword))\n .map((keyword) => execKeyword(keyword, node));\n\n keys.filter(\n (key) => !key.startsWith(\"x-\") && node.context.keywords.find((keyword) => keyword.keyword === key) == null\n ).forEach((keyword) => {\n errors.push(\n node.createAnnotation(\"unknown-keyword-warning\", {\n pointer: `${node.schemaLocation}/${keyword}`,\n schema: node.schema,\n value: keyword,\n draft: node.getDraftVersion()\n })\n );\n });\n\n return errors;\n}\n\nexport function execKeyword(keyword: Keyword, node: SchemaNode) {\n // @todo consider first parsing all nodes\n const errors = keyword.parse?.(node);\n if (keyword.reduce && keyword.addReduce?.(node)) {\n node.reducers.push(keyword.reduce);\n }\n if (keyword.resolve && keyword.addResolve?.(node)) {\n node.resolvers.push(keyword.resolve);\n }\n if (keyword.validate && keyword.addValidate?.(node)) {\n node.validators.push(keyword.validate);\n }\n return errors;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Draft } from \"./Draft\";\nimport { errors } from \"./errors/errors\";\nimport { SchemaNode, isSchemaNode, GetNodeOptions } from \"./SchemaNode\";\nimport { isObject } from \"./utils/isObject\";\n\nexport type BooleanSchema = boolean;\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\nexport interface JsonSchema {\n [keyword: string]: any;\n}\nexport function isJsonSchema(value: unknown): value is JsonSchema {\n return isObject(value);\n}\n\nexport function isBooleanSchema(value: unknown): value is BooleanSchema {\n return typeof value === \"boolean\";\n}\n\nexport type JsonPointer = string;\n\nexport type AnnotationData<D extends Record<string, unknown> = Record<string, unknown>> = D & {\n /* json-pointer to location of error */\n pointer: string;\n /* json-schema of error location */\n schema: JsonSchema;\n /* value: data in error location */\n value: unknown;\n};\n\nexport type Annotation<T = string, D extends AnnotationData = AnnotationData, S = string> = {\n type: T;\n code: S;\n message: string;\n data: D;\n [p: string]: unknown;\n};\n\nexport type DefaultErrors = keyof typeof errors;\nexport type ErrorConfig = Record<DefaultErrors | string, string | ((error: AnnotationData) => void)>;\nexport type OptionalNodeOrError = { node?: SchemaNode; error: undefined } | { node: undefined; error?: JsonError };\nexport type NodeOrError = { node: SchemaNode; error: undefined } | { node: undefined; error: JsonError };\nexport type JsonError<D extends AnnotationData = AnnotationData> = Annotation<\"error\", D, ErrorConfig | string>;\nexport type JsonAnnotation<D extends AnnotationData = AnnotationData> = Annotation<\"annotation\", D>;\n\nexport type { SchemaNode, GetNodeOptions, Draft };\nexport { isSchemaNode };\n\nexport function isAnnotation(value: any): value is Annotation {\n return isObject(value) && (value?.type && value?.code && value?.data) != null;\n}\n\n/**\n * ts type guard for json error\n * @returns true if passed type is a JsonError\n */\nexport function isJsonAnnotation(error: unknown): error is JsonAnnotation {\n return isObject(error) && error.type === \"annotation\";\n}\n\n/**\n * ts type guard for json error\n * @returns true if passed type is a JsonError\n */\nexport function isJsonError(error: unknown): error is JsonError {\n return isObject(error) && error.type === \"error\";\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\n","const suffixes = /(#)+$/g;\nconst emptyValues = [\"\", null, \"#\"];\n\nexport default function splitRef($ref: string) {\n if (emptyValues.includes($ref)) {\n return [];\n }\n\n $ref = $ref.replace(suffixes, \"\");\n if ($ref.indexOf(\"#\") === -1) {\n return [$ref.replace(/(#|\\/)+$/g, \"\")];\n }\n\n if ($ref.indexOf(\"#\") === 0) {\n return [$ref.replace(suffixes, \"\")];\n }\n\n const result = $ref.split(\"#\");\n result[0] = result[0].replace(/(#|\\/)+$/g, \"\");\n result[1] = `#${result[1].replace(suffixes, \"\")}`;\n return result;\n}\n","import { isJsonError, isSchemaNode, JsonError, SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaValidatorParams, ValidationPath, JsonSchemaReducerParams } from \"../Keyword\";\nimport { resolveUri } from \"../utils/resolveUri\";\nimport splitRef from \"../utils/splitRef\";\nimport { omit } from \"../utils/omit\";\nimport { isObject } from \"../utils/isObject\";\nimport { validateNode } from \"../validateNode\";\nimport { get, split } from \"@sagold/json-pointer\";\nimport { mergeNode } from \"../mergeNode\";\nimport { pick } from \"../utils/pick\";\nimport settings from \"src/settings\";\n\nexport const $refKeyword: Keyword = {\n id: \"$ref\",\n keyword: \"$ref\",\n order: 10,\n parse: parseRef,\n addReduce: (node) => node.$ref != null || node.schema.$dynamicRef != null,\n reduce: reduceRef,\n addValidate: ({ schema }) => schema.$ref != null || schema.$dynamicRef != null,\n validate: validateRef\n};\n\nfunction register(node: SchemaNode, path: string) {\n if (node.context.refs[path] == null) {\n node.context.refs[path] = node;\n }\n}\n\nexport function parseRef(node: SchemaNode) {\n // @ts-expect-error add ref resolution method to node\n node.resolveRef = resolveRef;\n\n // get and store current $id of node - this may be the same as parent $id\n const currentId = resolveUri(node.parent?.$id, node.schema?.$id);\n node.$id = currentId;\n node.lastIdPointer = node.parent?.lastIdPointer ?? \"#\";\n if (currentId !== node.parent?.$id && node.evaluationPath !== \"#\") {\n node.lastIdPointer = node.evaluationPath;\n }\n\n // store this node for retrieval by $id + json-pointer from $id\n if (node.lastIdPointer !== \"#\" && node.evaluationPath.startsWith(node.lastIdPointer)) {\n const localPointer = `#${node.evaluationPath.replace(node.lastIdPointer, \"\")}`;\n register(node, resolveUri(currentId, localPointer));\n }\n // store $rootId + json-pointer to this node\n register(node, resolveUri(node.context.rootNode.$id, node.evaluationPath));\n\n // @draft-2020: A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor\n const anchor = node.schema.$anchor;\n if (anchor) {\n // store this node for retrieval by $id + anchor\n const anchorUrl = `${currentId.replace(/#$/, \"\")}#${anchor}`;\n if (node.context.anchors[anchorUrl] == null) {\n node.context.anchors[anchorUrl] = node;\n }\n }\n\n const dynamicAnchor = node.schema.$dynamicAnchor;\n if (dynamicAnchor) {\n // store this node for retrieval by $id + anchor\n const dynamicAnchorUrl = `${currentId.replace(/#$/, \"\")}#${dynamicAnchor}`;\n if (node.context.dynamicAnchors[dynamicAnchorUrl] == null) {\n node.context.dynamicAnchors[dynamicAnchorUrl] = node;\n }\n }\n\n // precompile reference\n if (node.schema.$ref) {\n node.$ref = resolveUri(currentId, node.schema.$ref);\n if (node.$ref.startsWith(\"/\")) {\n node.$ref = `#${node.$ref}`;\n }\n }\n\n // validate simple ref to definitions\n if (node.$ref?.startsWith(\"#/$defs/\")) {\n if (get(node.getNodeRoot().schema, node.$ref) == null) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/$ref`,\n schema: node.schema,\n value: node.schema.$ref,\n message: `Invalid $ref to missing target '${node.schema.ref}'`\n });\n }\n }\n}\n\nexport function reduceRef({ node, data, key, pointer, path }: JsonSchemaReducerParams) {\n if (node == null) {\n return;\n }\n\n const resolvedNode = node.resolveRef({ pointer, path });\n if (resolvedNode == null) {\n return node.createError(\"ref-error\", {\n ref: node.schema.$ref ?? node.schema.$dynamicRef,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n\n if (resolvedNode.schemaLocation === node.schemaLocation) {\n return resolvedNode;\n }\n const merged = mergeNode(node, resolvedNode) as SchemaNode;\n const { node: reducedNode, error } = merged.reduceNode(data, { key, pointer, path });\n return reducedNode ?? error;\n}\n\nexport function resolveRef(this: SchemaNode, { pointer, path = [] }: { pointer?: string; path?: ValidationPath } = {}) {\n if (this.schema.$dynamicRef) {\n const nextNode = resolveRecursiveRef(this, path);\n if (isJsonError(nextNode)) {\n return nextNode;\n }\n path.push({ pointer: pointer!, node: nextNode! });\n return nextNode;\n }\n\n if (this.$ref == null) {\n return this;\n }\n\n const resolvedNode = getRef(this);\n if (isSchemaNode(resolvedNode)) {\n path.push({ pointer: pointer!, node: resolvedNode });\n }\n\n return resolvedNode;\n}\n\nfunction validateRef({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const nextNode = node.resolveRef({ pointer, path });\n if (nextNode != null) {\n // recursively resolveRef and validate\n return validateNode(nextNode, data, pointer, path);\n }\n return node.createError(\"ref-error\", {\n ref: node.schema.$ref ?? node.schema.$dynamicRef,\n pointer,\n schema: node.schema,\n value: data\n });\n}\n\n// 1. https://json-schema.org/draft/2019-09/json-schema-core#scopes\nfunction resolveRecursiveRef(node: SchemaNode, path: ValidationPath): SchemaNode | JsonError {\n const history = path;\n const refInCurrentScope = resolveUri(node.$id, node.schema.$dynamicRef);\n\n // A $dynamicRef with a non-matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor\n const nonMatchingDynamicAnchor = node.context.dynamicAnchors[refInCurrentScope] == null;\n if (nonMatchingDynamicAnchor) {\n if (node.context.anchors[refInCurrentScope]) {\n return compileNext(node.context.anchors[refInCurrentScope], node);\n }\n }\n\n for (const entry of history) {\n // A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope\n if (entry.node.schema.$dynamicAnchor) {\n return compileNext(entry.node, node);\n }\n\n // A $dynamicRef only stops at a $dynamicAnchor if it is in the same dynamic scope.\n const refWithoutScope = node.schema.$dynamicRef.split(\"#\").pop();\n const ref = resolveUri(entry.node.$id, `#${refWithoutScope}`);\n const anchorNode = node.context.dynamicAnchors[ref];\n if (anchorNode) {\n return compileNext(node.context.dynamicAnchors[ref], node);\n }\n }\n\n // A $dynamicRef without a matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor\n return getRef(node, refInCurrentScope);\n}\n\nexport function compileNext(referencedNode: SchemaNode, sourceNode: SchemaNode) {\n let referencedSchema = referencedNode.schema;\n if (isObject(referencedNode.schema)) {\n referencedSchema = {\n ...omit(referencedNode.schema, \"$id\"),\n ...pick(sourceNode.schema, ...settings.PROPERTIES_TO_MERGE)\n };\n }\n return referencedNode.compileSchema(\n referencedSchema,\n `${sourceNode.evaluationPath}/$ref`,\n referencedNode.schemaLocation\n );\n}\n\nexport function getRef(node: SchemaNode, $ref = node?.$ref): SchemaNode | JsonError {\n if ($ref == null) {\n return node;\n }\n\n // resolve $ref by json-evaluationPath\n if (node.context.refs[$ref]) {\n return compileNext(node.context.refs[$ref], node);\n }\n // resolve $ref from $anchor\n if (node.context.anchors[$ref]) {\n return compileNext(node.context.anchors[$ref], node);\n }\n // resolve $ref from $dynamicAnchor\n if (node.context.dynamicAnchors[$ref]) {\n // A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor\n return compileNext(node.context.dynamicAnchors[$ref], node);\n }\n\n // check for remote-host + pointer pair to switch rootSchema\n const fragments = splitRef($ref);\n if (fragments.length === 0) {\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n }\n\n // resolve $ref as remote-host\n if (fragments.length === 1) {\n const $ref = fragments[0];\n // this is a reference to remote-host root node\n if (node.context.remotes[$ref]) {\n return compileNext(node.context.remotes[$ref], node);\n }\n\n if ($ref[0] === \"#\") {\n // support refOfUnknownKeyword\n const rootSchema = node.context.rootNode.schema;\n const targetSchema = get(rootSchema, $ref);\n if (targetSchema) {\n return node.compileSchema(targetSchema, `${node.evaluationPath}/$ref`, $ref);\n }\n }\n // console.error(\"REF: UNFOUND 1\", $ref);\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n }\n\n if (fragments.length === 2) {\n const $remoteHostRef = fragments[0];\n // this is a reference to remote-host root node (and not a self reference)\n if (node.context.remotes[$remoteHostRef] && node !== node.context.remotes[$remoteHostRef]) {\n const referencedNode = node.context.remotes[$remoteHostRef];\n // resolve full ref on remote schema - we store currently only store ref with domain\n let nextNode = getRef(referencedNode, $ref);\n if (nextNode) {\n return nextNode;\n }\n // @note required for test spec 04\n nextNode = getRef(referencedNode, fragments[1]);\n if (nextNode) {\n return nextNode;\n }\n }\n\n // resolve by json-pointer (optional dynamicRef)\n if (node.context.refs[$remoteHostRef]) {\n const parentNode = node.context.refs[$remoteHostRef];\n const path = split(fragments[1]);\n // @todo add utility to resolve schema-pointer to schema\n let currentNode = parentNode;\n for (const item of path) {\n const property = item === \"definitions\" ? \"$defs\" : item;\n // @ts-expect-error random path\n currentNode = currentNode[property];\n if (currentNode == null) {\n // console.error(\"REF: FAILED RESOLVING ref json-pointer\", fragments[1]);\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined,\n host: fragments[0],\n local: fragments[1]\n });\n }\n }\n return currentNode;\n }\n }\n\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n}\n","import { ValidationAnnotation } from \"src/Keyword\";\nimport { SchemaNode } from \"src/SchemaNode\";\n\nexport function collectValidationErrors(errors: ValidationAnnotation[], ...compiled: SchemaNode[]) {\n return compiled.reduce((errors, node) => {\n if (node.schemaValidation) errors.push(...node.schemaValidation);\n return errors;\n }, errors);\n}\n","import { collectValidationErrors } from \"src/utils/collectValidationErrors\";\nimport { Keyword, ValidationAnnotation } from \"../Keyword\";\nimport { SchemaNode } from \"../types\";\nimport { isObject } from \"../utils/isObject\";\n\nexport const $defsKeyword: Keyword = {\n id: \"$defs\",\n keyword: \"$defs\",\n parse: parseDefs\n};\n\nexport function parseDefs(node: SchemaNode) {\n const errors: ValidationAnnotation[] = [];\n\n if (node.schema.$defs) {\n if (!isObject(node.schema.$defs)) {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: node.schemaLocation,\n schema: node.schema,\n value: node.schema.$defs,\n message: `$defs must be an object - received: ${typeof node.schema.$defs}`\n })\n );\n } else {\n node.$defs = node.$defs ?? {};\n Object.keys(node.schema.$defs).forEach((property) => {\n node.$defs![property] = node.compileSchema(\n node.schema.$defs[property],\n `${node.evaluationPath}/$defs/${urlEncodeJsonPointerProperty(property)}`,\n `${node.schemaLocation}/$defs/${property}`\n );\n collectValidationErrors(errors, node.$defs![property]);\n });\n }\n }\n if (node.schema.definitions) {\n if (!isObject(node.schema.definitions)) {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: node.schemaLocation,\n schema: node.schema,\n value: node.schema.$defs,\n message: `definitions must be an object - received: ${typeof node.schema.definitions}`\n })\n );\n }\n node.$defs = node.$defs ?? {};\n Object.keys(node.schema.definitions).forEach((property) => {\n node.$defs![property] = node.compileSchema(\n node.schema.definitions[property],\n `${node.evaluationPath}/definitions/${urlEncodeJsonPointerProperty(property)}`,\n `${node.schemaLocation}/definitions/${urlEncodeJsonPointerProperty(property)}`\n );\n collectValidationErrors(errors, node.$defs![property]);\n });\n }\n\n return errors;\n}\n\nfunction urlEncodeJsonPointerProperty(property: string) {\n property = property.replace(/~/g, \"~0\");\n property = property.replace(/\\//g, \"~1\");\n return encodeURIComponent(property);\n}\n","import { Keyword, JsonSchemaValidatorParams, ValidationPath } from \"../../Keyword\";\nimport { resolveRef } from \"../../keywords/$ref\";\nimport { isSchemaNode, SchemaNode } from \"../../types\";\nimport { resolveUri } from \"../../utils/resolveUri\";\nimport { validateNode } from \"../../validateNode\";\n\nexport const $refKeyword: Keyword = {\n id: \"$ref\",\n keyword: \"$ref\",\n parse: parseRef,\n addValidate: ({ schema }) => schema.$ref != null,\n validate: validateRef\n};\n\nfunction parseRef(node: SchemaNode) {\n // get and store current $id of node - this may be the same as parent $id\n let currentId = node.parent?.$id;\n if (node.schema?.$ref == null) {\n currentId = resolveUri(node.parent?.$id, node.schema?.$id);\n }\n node.$id = currentId as string;\n node.lastIdPointer = node.parent?.lastIdPointer ?? \"#\";\n\n // @ts-expect-error add ref resolution method to node\n node.resolveRef = resolveRef;\n\n // store this node for retrieval by $id\n if (node.context.refs[currentId as string] == null) {\n node.context.refs[currentId as string] = node;\n }\n\n const idChanged = currentId !== node.parent?.$id;\n if (idChanged) {\n node.lastIdPointer = node.evaluationPath;\n }\n\n // store this node for retrieval by $id + json-pointer from $id\n if (node.lastIdPointer !== \"#\" && node.evaluationPath.startsWith(node.lastIdPointer)) {\n const localPointer = `#${node.evaluationPath.replace(node.lastIdPointer, \"\")}`;\n node.context.refs[resolveUri(currentId, localPointer)] = node;\n } else {\n node.context.refs[resolveUri(currentId, node.evaluationPath)] = node;\n }\n node.context.refs[resolveUri(node.context.rootNode.$id, node.evaluationPath)] = node;\n\n // precompile reference\n if (node.schema.$ref) {\n node.$ref = resolveUri(currentId, node.schema.$ref);\n }\n}\n\nfunction validateRef({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const nextNode = resolveAllRefs(node, pointer, path);\n if (!isSchemaNode(nextNode)) {\n return node.createError(\"ref-error\", {\n ref: node.schema.$ref,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n return validateNode(nextNode, data, pointer, path);\n}\n\nfunction resolveAllRefs(node: SchemaNode, pointer: string, path: ValidationPath) {\n const nextNode = node.resolveRef({ pointer, path });\n if (!isSchemaNode(nextNode)) {\n return node.createError(\"ref-error\", {\n ref: node.schema.$ref,\n pointer,\n schema: node.schema,\n value: undefined\n });\n }\n if (nextNode !== node && nextNode) {\n return resolveAllRefs(nextNode, pointer, path);\n }\n return node;\n}\n","import { Keyword, ValidationPath } from \"../../Keyword\";\nimport { resolveUri } from \"../../utils/resolveUri\";\nimport { isObject } from \"../../utils/isObject\";\nimport { omit } from \"../../utils/omit\";\nimport splitRef from \"../../utils/splitRef\";\nimport { $refKeyword as draft06Keyword } from \"../../draft06/keywords/$ref\";\nimport { isSchemaNode, JsonError, SchemaNode } from \"../../types\";\n\nexport const $refKeyword: Keyword = {\n id: \"$ref\",\n keyword: \"$ref\",\n parse: parseRef,\n addValidate: ({ schema }) => schema.$ref != null,\n validate: draft06Keyword.validate!\n};\n\nfunction register(node: SchemaNode, path: string) {\n if (node.context.refs[path] == null) {\n node.context.refs[path] = node;\n }\n}\n\nfunction parseRef(node: SchemaNode) {\n // get and store current id of node - this may be the same as parent id\n let currentId = node.parent?.$id;\n if (node.schema?.$ref == null && node.schema?.id) {\n currentId = resolveUri(node.parent?.$id, node.schema.id);\n // console.log(\"create id\", node.evaluationPath, \":\", node.parent?.$id, node.schema?.id, \"=>\", currentId);\n }\n node.$id = currentId as string;\n node.lastIdPointer = node.parent?.lastIdPointer ?? \"#\";\n\n // @ts-expect-error add ref resolution method to node\n node.resolveRef = resolveRef;\n\n // store this node for retrieval by id\n if (node.context.refs[currentId as string] == null) {\n node.context.refs[currentId as string] = node;\n }\n\n const idChanged = currentId !== node.parent?.$id;\n if (idChanged) {\n node.lastIdPointer = node.evaluationPath;\n }\n\n // store this node for retrieval by id + json-pointer from id\n if (node.lastIdPointer !== \"#\" && node.evaluationPath.startsWith(node.lastIdPointer)) {\n const localPointer = `#${node.evaluationPath.replace(node.lastIdPointer, \"\")}`;\n register(node, resolveUri(currentId, localPointer));\n } else {\n register(node, resolveUri(currentId, node.evaluationPath));\n }\n register(node, resolveUri(node.context.rootNode.$id, node.evaluationPath));\n\n // precompile reference\n if (node.schema.$ref) {\n node.$ref = resolveUri(currentId, node.schema.$ref);\n }\n}\n\nfunction resolveRef(this: SchemaNode, { pointer, path }: { pointer?: string; path?: ValidationPath } = {}) {\n if (this.$ref == null) {\n return this;\n }\n const resolvedNode = getRef(this);\n if (isSchemaNode(resolvedNode)) {\n path?.push({ pointer: pointer!, node: resolvedNode });\n }\n return resolvedNode;\n}\n\nfunction compileNext(referencedNode: SchemaNode, evaluationPath = referencedNode.evaluationPath) {\n const referencedSchema = isObject(referencedNode.schema)\n ? omit(referencedNode.schema, \"id\")\n : referencedNode.schema;\n return referencedNode.compileSchema(referencedSchema, `${evaluationPath}/$ref`, referencedSchema.schemaLocation);\n}\n\nfunction getRef(node: SchemaNode, $ref = node?.$ref): SchemaNode | JsonError | undefined {\n if ($ref == null) {\n return node;\n }\n\n // resolve $ref by json-evaluationPath\n if (node.context.refs[$ref]) {\n // console.log(`ref resolve ${$ref} from refs`, node.context.refs[$ref].ref);\n return compileNext(node.context.refs[$ref], node.evaluationPath);\n }\n\n if (node.context.anchors[$ref]) {\n // console.log(`ref resolve ${$ref} from anchors`, node.context.anchors[$ref].ref);\n return compileNext(node.context.anchors[$ref], node.evaluationPath);\n }\n\n // check for remote-host + pointer pair to switch rootSchema\n const fragments = splitRef($ref);\n if (fragments.length === 0) {\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n }\n\n // resolve $ref as remote-host\n if (fragments.length === 1) {\n const $ref = fragments[0];\n // this is a reference to remote-host root node\n if (node.context.remotes[$ref]) {\n return compileNext(node.context.remotes[$ref], node.evaluationPath);\n }\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n }\n\n if (fragments.length === 2) {\n const $remoteHostRef = fragments[0];\n // this is a reference to remote-host root node (and not a self reference)\n if (node.context.remotes[$remoteHostRef] && node !== node.context.remotes[$remoteHostRef]) {\n const referencedNode = node.context.remotes[$remoteHostRef];\n // resolve full ref on remote schema - we store currently only store ref with domain\n let nextNode = getRef(referencedNode, $ref);\n if (nextNode) {\n return nextNode;\n }\n // @note required for test spec 04\n nextNode = getRef(referencedNode, fragments[1]);\n if (nextNode) {\n return nextNode;\n }\n }\n\n // @todo this is a poc\n const $localRef = fragments[0];\n if (node.context.refs[$localRef]) {\n const nextNode = node.context.refs[$localRef];\n const property = fragments[1].split(\"$defs/\").pop();\n if (property && nextNode?.$defs) {\n return getRef(nextNode.$defs[property]);\n }\n }\n\n // @todo returning error here breaks specs\n return undefined;\n }\n\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n}\n","import { isObject } from \"../../utils/isObject\";\nimport { Keyword, JsonSchemaResolverParams, JsonSchemaValidatorParams, ValidationReturnType } from \"../../Keyword\";\nimport { SchemaNode } from \"../../types\";\nimport { getValue } from \"../../utils/getValue\";\nimport { validateNode } from \"../../validateNode\";\n\nconst KEYWORD = \"additionalItems\";\n\nexport const additionalItemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n order: -10,\n parse: parseAdditionalItems,\n addResolve: (node: SchemaNode) => node.items != null,\n resolve: additionalItemsResolver,\n addValidate: ({ schema }) => schema[KEYWORD] != null && schema[KEYWORD] !== true && Array.isArray(schema.items),\n validate: validateAdditionalItems\n};\n\n// must come as last resolver\nexport function parseAdditionalItems(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n if (schema.additionalItems == null || schema.additionalItems === false) {\n return;\n }\n\n const additionalItems = schema[KEYWORD];\n\n if (!(isObject(additionalItems) || additionalItems === true)) {\n return node.createError(\"schema-error\", {\n pointer: evaluationPath,\n schema,\n value: undefined,\n message: `Keyword '${KEYWORD}' must be an object or a boolean - received '${typeof additionalItems}'`\n });\n }\n\n if (!Array.isArray(schema.items)) {\n return node.createAnnotation(\"schema-error\", {\n pointer: evaluationPath,\n schema,\n value: undefined,\n message: `Keyword '${KEYWORD}' is only evaluated with a given items-array`\n });\n }\n\n node.items = node.compileSchema(\n schema.additionalItems,\n `${evaluationPath}/additionalItems`,\n `${schemaLocation}/additionalItems`\n );\n}\n\nfunction additionalItemsResolver({ node, key, data }: JsonSchemaResolverParams) {\n if (Array.isArray(data)) {\n // @attention: items, etc should already have been tried\n const value = getValue(data, key);\n // items is ensures by addResolve\n const { node: childNode, error } = node.items!.reduceNode(value);\n return childNode ?? error;\n }\n}\n\nfunction validateAdditionalItems({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n if (!Array.isArray(data) || data.length === 0) {\n // - no items to validate\n return;\n }\n if (Array.isArray(schema.items) && schema.items.length >= data.length) {\n // - no additional items\n return;\n }\n const startIndex = Array.isArray(schema.items) ? schema.items.length : 0;\n const errors: ValidationReturnType = [];\n for (let i = startIndex; i < data.length; i += 1) {\n const item = data[i];\n if (node.items) {\n const validationResult = validateNode(node.items, item, `${pointer}/${i}`, path);\n if (validationResult) {\n errors.push(...validationResult);\n }\n } else if (schema.additionalItems === false) {\n errors.push(\n node.createError(\"additional-items-error\", {\n key: i,\n pointer: `${pointer}/${i}`,\n value: data,\n schema\n })\n );\n }\n }\n return errors;\n}\n","import settings from \"../settings\";\nimport { isObject } from \"../utils/isObject\";\nimport { Keyword, JsonSchemaResolverParams, JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport { isBooleanSchema, SchemaNode } from \"../types\";\nimport { getValue } from \"../utils/getValue\";\nimport { validateNode } from \"../validateNode\";\n\nexport const additionalPropertiesKeyword: Keyword = {\n id: \"additionalProperties\",\n keyword: \"additionalProperties\",\n order: -10,\n parse: parseAdditionalProperties,\n addResolve: ({ schema }) => schema.additionalProperties != null,\n resolve: additionalPropertyResolver,\n addValidate: ({ schema }) =>\n schema.additionalProperties !== true &&\n schema.additionalProperties != null &&\n // this is an arrangement with patternProperties. patternProperties validate before additionalProperties:\n // https://spacetelescope.github.io/understanding-json-schema/reference/object.html#index-5\n !(schema.additionalProperties === false && isObject(schema.patternProperties)),\n validate: validateAdditionalProperty\n};\n\n// must come as last resolver\nexport function parseAdditionalProperties(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n if (schema.additionalProperties == null || isBooleanSchema(schema.additionalProperties)) {\n return;\n }\n\n if (!isObject(schema.additionalProperties)) {\n return node.createError(\"schema-error\", {\n pointer: node.schemaLocation,\n schema,\n value: schema.additionalProperties,\n message: `keyword 'additionalProperties' must be a valid JSON Schema - receoved: ${typeof schema.additionalProperties}`\n });\n }\n\n node.additionalProperties = node.compileSchema(\n schema.additionalProperties,\n `${evaluationPath}/additionalProperties`,\n `${schemaLocation}/additionalProperties`\n );\n return node.additionalProperties.schemaValidation;\n}\n\nfunction additionalPropertyResolver({ node, data, key }: JsonSchemaResolverParams) {\n const value = getValue(data, key);\n if (node.additionalProperties) {\n const { node: reduced, error } = node.additionalProperties.reduceNode(value);\n return reduced ?? error;\n }\n if (node.schema.additionalProperties === false) {\n return node.createError(\"no-additional-properties-error\", {\n pointer: `${key}`,\n schema: node.schema,\n value: getValue(data, key),\n property: `${key}`\n // @todo add pointer to resolver\n // properties: expectedProperties\n });\n }\n}\n\n/**\n * @additionalProperties only checks properties and additionalProperties\n *\n * The additionalProperties keyword is used to control the handling of extra stuff, that is,\n * properties whose names are not listed in the properties keyword or match any of the regular\n * expressions in the patternProperties keyword. By default any additional properties are allowed.\n * https://json-schema.org/understanding-json-schema/reference/object\n */\nfunction validateAdditionalProperty({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n if (!isObject(data)) {\n return;\n }\n\n const { schema } = node;\n const errors: ValidationReturnType = [];\n let receivedProperties = Object.keys(data).filter((prop) => settings.propertyBlacklist.includes(prop) === false);\n const patternProperties = node.patternProperties;\n if (Array.isArray(patternProperties)) {\n // filter received properties by matching patternProperties\n receivedProperties = receivedProperties.filter((prop) => {\n for (const property of patternProperties) {\n if (property.pattern.test(prop)) {\n return false; // remove\n }\n }\n return true;\n });\n }\n\n // adds an error for each an unexpected property\n const expectedProperties = node.properties ? Object.keys(node.properties) : [];\n receivedProperties\n .filter((property) => expectedProperties.indexOf(property) === -1)\n .forEach((property) => {\n const propertyValue = getValue(data, property);\n if (propertyValue === undefined) {\n return; // do not validate undefined properties\n }\n\n if (isObject(node.additionalProperties)) {\n const validationErrors = validateNode(\n node.additionalProperties,\n propertyValue,\n `${pointer}/${property}`,\n path\n );\n if (validationErrors) {\n // @note: we pass through specific errors here\n errors.push(...validationErrors);\n }\n } else {\n errors.push(\n node.createError(\"no-additional-properties-error\", {\n pointer: `${pointer}/${property}`,\n schema,\n value: data,\n property,\n properties: expectedProperties\n })\n );\n }\n });\n\n return errors;\n}\n","import { mergeSchema } from \"../utils/mergeSchema\";\nimport {\n Keyword,\n JsonSchemaReducerParams,\n JsonSchemaValidatorParams,\n ValidationReturnType,\n ValidationAnnotation\n} from \"../Keyword\";\nimport { SchemaNode } from \"../types\";\nimport { validateNode } from \"../validateNode\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst KEYWORD = \"allOf\";\n\nexport const allOfKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseAllOf,\n addReduce: (node: SchemaNode) => node[KEYWORD] != null,\n reduce: reduceAllOf,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateAllOf\n};\n\nexport function parseAllOf(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n if (schema[KEYWORD] == null) {\n return;\n }\n if (!Array.isArray(schema[KEYWORD])) {\n return node.createError(\"schema-error\", {\n pointer: schemaLocation,\n schema,\n value: schema[KEYWORD],\n message: `Keyword '${KEYWORD}' must be an array - received '${typeof schema[KEYWORD]}'`\n });\n }\n if (schema[KEYWORD].length === 0) {\n return;\n }\n\n node[KEYWORD] = schema[KEYWORD].map((s, index) =>\n node.compileSchema(s, `${evaluationPath}/${KEYWORD}/${index}`, `${schemaLocation}/${KEYWORD}/${index}`)\n );\n return collectValidationErrors([], ...node[KEYWORD]);\n}\n\nfunction reduceAllOf({ node, data, key, pointer, path }: JsonSchemaReducerParams) {\n if (node[KEYWORD] == null) {\n return;\n }\n\n // note: parts of schemas could be merged, e.g. if they do not include\n // dynamic schema parts\n let mergedSchema = {};\n let dynamicId = \"\";\n for (let i = 0; i < node[KEYWORD].length; i += 1) {\n const { node: schemaNode } = node[KEYWORD][i].reduceNode(data, { key, pointer, path });\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const localDynamicId = nestedDynamicId === \"\" ? `${KEYWORD}/${i}` : nestedDynamicId;\n dynamicId += `${dynamicId === \"\" ? \"\" : \",\"}${localDynamicId}`;\n\n const schema = mergeSchema(node[KEYWORD][i].schema, schemaNode.schema);\n mergedSchema = mergeSchema(mergedSchema, schema, KEYWORD, \"contains\");\n }\n }\n\n return node.compileSchema(\n mergedSchema,\n `${node.evaluationPath}/${dynamicId}`,\n node.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n}\n\nfunction validateAllOf({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n if (!Array.isArray(node[KEYWORD]) || node[KEYWORD].length === 0) {\n return;\n }\n const errors: ValidationReturnType = [];\n node[KEYWORD].forEach((allOfNode) => {\n errors.push(...validateNode(allOfNode, data, pointer, path));\n });\n return errors;\n}\n","import { mergeSchema } from \"../utils/mergeSchema\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams, ValidationAnnotation } from \"../Keyword\";\nimport { SchemaNode } from \"../types\";\nimport { validateNode } from \"../validateNode\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst KEYWORD = \"anyOf\";\n\nexport const anyOfKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseAnyOf,\n addReduce: (node) => node[KEYWORD] != null,\n reduce: reduceAnyOf,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateAnyOf\n};\n\nexport function parseAnyOf(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n if (schema[KEYWORD] == null) {\n return;\n }\n if (!Array.isArray(schema[KEYWORD])) {\n return node.createError(\"schema-error\", {\n pointer: schemaLocation,\n schema,\n value: schema[KEYWORD],\n message: `Keyword '${KEYWORD}' must be an array - received '${typeof schema[KEYWORD]}'`\n });\n }\n if (schema[KEYWORD].length === 0) {\n return;\n }\n node[KEYWORD] = schema[KEYWORD].map((s, index) =>\n node.compileSchema(s, `${evaluationPath}/${KEYWORD}/${index}`, `${schemaLocation}/${KEYWORD}/${index}`)\n );\n\n return collectValidationErrors([], ...node[KEYWORD]);\n}\n\nfunction reduceAnyOf({ node, data, pointer, path }: JsonSchemaReducerParams) {\n if (node[KEYWORD] == null) {\n return;\n }\n\n let mergedSchema = {};\n let dynamicId = \"\";\n for (let i = 0; i < node[KEYWORD].length; i += 1) {\n if (validateNode(node[KEYWORD][i], data, pointer, path).length === 0) {\n const { node: schemaNode } = node[KEYWORD][i].reduceNode(data);\n\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const localDynamicId = nestedDynamicId === \"\" ? `${KEYWORD}/${i}` : nestedDynamicId;\n dynamicId += `${dynamicId === \"\" ? \"\" : \",\"}${localDynamicId}`;\n\n const schema = mergeSchema(node[KEYWORD][i].schema, schemaNode.schema);\n mergedSchema = mergeSchema(mergedSchema, schema, KEYWORD);\n }\n }\n }\n return node.compileSchema(\n mergedSchema,\n `${node.evaluationPath}${dynamicId}`,\n node.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n}\n\nfunction validateAnyOf({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n if (node[KEYWORD] == null) {\n return;\n }\n for (const anyOf of node[KEYWORD]) {\n if (validateNode(anyOf, data, pointer, path).length === 0) {\n return undefined;\n }\n }\n return node.createError(\"any-of-error\", { pointer, schema: node.schema, value: data, anyOf: node.schema[KEYWORD] });\n}\n","import { isObject } from \"../utils/isObject\";\nimport { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { validateNode } from \"../validateNode\";\n\nconst KEYWORD = \"contains\";\n\nexport const containsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseContains,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateContains,\n addReduce: (node) => node[KEYWORD] != null,\n reduce: ({ node }) => {\n return node.compileSchema(\n {\n items: {\n anyOf: [node[KEYWORD]!.schema] // we tested for contains in addReduce\n }\n },\n node.evaluationPath,\n node.schemaLocation\n );\n }\n};\n\nexport function parseContains(node: SchemaNode) {\n const contains = node.schema[KEYWORD];\n if (contains == null) {\n return;\n }\n if (!(isJsonSchema(contains) || isBooleanSchema(contains))) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: contains,\n message: `Keyword '${KEYWORD}' must be a valid JSON Schema - received '${typeof contains}'`\n });\n }\n\n node[KEYWORD] = node.compileSchema(contains, `${node.evaluationPath}/${KEYWORD}`);\n return node[KEYWORD].schemaValidation;\n}\n\nfunction validateContains({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n if (!Array.isArray(data)) {\n return;\n }\n if (schema.contains === false) {\n return node.createError(\"contains-array-error\", { pointer, value: data, schema });\n }\n\n if (schema.contains === true) {\n if (Array.isArray(data) && data.length === 0) {\n return node.createError(\"contains-any-error\", { pointer, value: data, schema });\n }\n return undefined;\n }\n\n if (!isObject(schema.contains) || !Array.isArray(data)) {\n // - ignore invalid schema\n // - ignore invalid dara\n return undefined;\n }\n\n let count = 0;\n for (const d of data) {\n // we tested for contains in addValidate\n if (validateNode(node.contains!, d, pointer, path).length === 0) {\n count++;\n }\n }\n\n // @draft >= 2019-09\n const max = schema.maxContains ?? Infinity;\n const min = schema.minContains ?? 1;\n if (max >= count && min <= count) {\n return undefined;\n }\n if (max < count) {\n return node.createError(\"contains-max-error\", { pointer, schema, delta: count - max, value: data });\n }\n if (min > count) {\n return node.createError(\"contains-min-error\", { pointer, schema, delta: min - count, value: data });\n }\n return node.createError(\"contains-error\", { pointer, schema, value: data });\n}\n","export function isListOfStrings(v: unknown): v is string[] {\n return Array.isArray(v) && v.find((item) => typeof item !== \"string\") == null;\n}\n","import { Keyword, JsonSchemaValidatorParams, ValidationReturnType, ValidationAnnotation } from \"../Keyword\";\nimport { JsonError, SchemaNode } from \"../types\";\nimport { isListOfStrings } from \"../utils/isListOfStrings\";\nimport { isObject } from \"../utils/isObject\";\n\nconst KEYWORD = \"dependentRequired\";\n\nexport const dependentRequiredKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseDependentRequired,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateDependentRequired\n};\n\nexport function parseDependentRequired(node: SchemaNode) {\n const { schema } = node;\n if (schema[KEYWORD] == null) {\n return;\n }\n if (!isObject(schema[KEYWORD])) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema,\n value: schema[KEYWORD],\n message: `Keyword '${KEYWORD}' must be an object - received '${typeof schema[KEYWORD]}'`\n });\n }\n\n const errors: ValidationAnnotation[] = [];\n node.dependentRequired = {};\n for (const propertyName of Object.keys(schema[KEYWORD])) {\n const list = schema[KEYWORD][propertyName];\n if (isListOfStrings(list)) {\n node.dependentRequired[propertyName] = list;\n } else {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}/${propertyName}`,\n schema,\n value: list,\n message: `Keyword '${KEYWORD}[string]' must be a string[] - received '${typeof list}'`\n })\n );\n }\n }\n\n return errors;\n}\n\nexport function validateDependentRequired({\n node,\n data,\n pointer = \"#\"\n}: JsonSchemaValidatorParams): ValidationReturnType {\n const { dependentRequired } = node;\n if (dependentRequired == null || !isObject(data)) {\n return undefined;\n }\n const errors: JsonError[] = [];\n Object.keys(data).forEach((property) => {\n const dependencies = dependentRequired[property];\n if (!Array.isArray(dependencies)) {\n return;\n }\n for (let i = 0, l = dependencies.length; i < l; i += 1) {\n if (data[dependencies[i]] === undefined) {\n errors.push(\n node.createError(\"missing-dependency-error\", {\n missingProperty: dependencies[i],\n pointer,\n schema: node.schema,\n value: data\n })\n );\n }\n }\n });\n return errors;\n}\n","import { mergeSchema } from \"../utils/mergeSchema\";\nimport { isObject } from \"../utils/isObject\";\nimport { isSchemaNode, SchemaNode, JsonSchema, isBooleanSchema } from \"../types\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams, ValidationAnnotation } from \"../Keyword\";\nimport { validateNode } from \"../validateNode\";\nimport sanitizeErrors from \"../utils/sanitizeErrors\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst KEYWORD = \"dependentSchemas\";\n\nexport const dependentSchemasKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseDependentSchemas,\n addReduce: (node) => node.dependentSchemas != null,\n reduce: reduceDependentSchemas,\n addValidate: (node) => node.dependentSchemas != null,\n validate: validateDependentSchemas\n};\n\nexport function parseDependentSchemas(node: SchemaNode) {\n const { dependentSchemas } = node.schema;\n if (dependentSchemas == null) {\n return;\n }\n if (!isObject(dependentSchemas)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: dependentSchemas,\n message: `Keyword '${KEYWORD}' must be an object - received '${typeof dependentSchemas}'`\n });\n }\n\n const dependentProperties = Object.keys(dependentSchemas);\n if (dependentProperties.length === 0) {\n return;\n }\n\n const errors: ValidationAnnotation[] = [];\n const parsedSchemas: Record<string, boolean | SchemaNode> = {};\n for (const property of Object.keys(dependentSchemas)) {\n const schema = dependentSchemas[property];\n if (isObject(schema)) {\n parsedSchemas[property] = node.compileSchema(\n schema,\n `${node.evaluationPath}/${KEYWORD}/${property}`,\n `${node.schemaLocation}/${KEYWORD}/${property}`\n );\n collectValidationErrors(errors, parsedSchemas[property]);\n } else if (isBooleanSchema(schema)) {\n parsedSchemas[property] = schema;\n } else {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}/${property}`,\n schema: node.schema,\n value: schema,\n message: `Keyword '${KEYWORD}[string]' must be a valid JSON Schema'`\n })\n );\n }\n }\n node.dependentSchemas = parsedSchemas;\n return errors;\n}\n\nexport function reduceDependentSchemas({ node, data }: JsonSchemaReducerParams) {\n const { dependentSchemas } = node;\n if (!isObject(data) || dependentSchemas == null) {\n // @todo remove dependentSchemas\n return node;\n }\n\n let mergedSchema: JsonSchema | undefined;\n let added = 0;\n let dynamicId = `${node.schemaLocation}(`;\n Object.keys(data).forEach((propertyName) => {\n if (dependentSchemas[propertyName] == null) {\n return;\n }\n mergedSchema = mergedSchema ?? { properties: {} };\n if (isSchemaNode(dependentSchemas[propertyName])) {\n mergedSchema = mergeSchema(mergedSchema, dependentSchemas[propertyName].schema);\n } else {\n mergedSchema.properties[propertyName] = dependentSchemas[propertyName];\n }\n dynamicId += `${added ? \",\" : \"\"}${KEYWORD}/${propertyName}`;\n added++;\n });\n\n if (mergedSchema == null) {\n return node;\n }\n\n mergedSchema = mergeSchema(node.schema, mergedSchema, KEYWORD);\n return node.compileSchema(mergedSchema, node.evaluationPath, node.schemaLocation, `${dynamicId})`);\n}\n\nexport function validateDependentSchemas({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n const { schema, dependentSchemas } = node;\n if (!isObject(data) || dependentSchemas == null) {\n return undefined;\n }\n const errors: ValidationAnnotation[] = [];\n Object.keys(data).forEach((property) => {\n const dependencies = dependentSchemas[property];\n // @draft >= 6 boolean schema\n if (dependencies === true) {\n return;\n }\n if (dependencies === false) {\n errors.push(node.createError(\"missing-dependency-error\", { pointer, schema, value: data }));\n return;\n }\n if (isSchemaNode(dependencies)) {\n sanitizeErrors(validateNode(dependencies, data, pointer, path), errors);\n return;\n }\n });\n return errors;\n}\n","import { isBooleanSchema, isJsonSchema, isSchemaNode, SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams, ValidationAnnotation } from \"../Keyword\";\nimport { isObject } from \"../utils/isObject\";\nimport { mergeNode } from \"../mergeNode\";\nimport { hasProperty } from \"../utils/hasProperty\";\nimport { validateDependentRequired } from \"./dependentRequired\";\nimport { validateDependentSchemas } from \"./dependentSchemas\";\nimport sanitizeErrors from \"../utils/sanitizeErrors\";\nimport { isListOfStrings } from \"../utils/isListOfStrings\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst KEYWORD = \"dependencies\";\n\nexport const dependenciesKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseDependencies,\n order: -9,\n addReduce: (node) => node.schema[KEYWORD] != null, // because we remap this has to be tested on schema\n reduce: reduceDependencies,\n addValidate: (node) => node.schema[KEYWORD] != null, // because we remap this has to be tested on schema\n validate: validateDependencies\n};\n\nexport function parseDependencies(node: SchemaNode) {\n const { dependencies } = node.schema;\n if (!isObject(dependencies)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: dependencies,\n message: `Keyword '${KEYWORD}' must be an object - received ${typeof dependencies}`\n });\n }\n\n const errors: ValidationAnnotation[] = [];\n for (const property of Object.keys(dependencies)) {\n const schema = dependencies[property] as string[];\n if (isJsonSchema(schema) || isBooleanSchema(schema)) {\n node.dependentSchemas = node.dependentSchemas ?? {};\n node.dependentSchemas[property] = node.compileSchema(\n schema,\n `${node.evaluationPath}/${KEYWORD}/${property}`,\n `${node.schemaLocation}/${KEYWORD}/${property}`\n );\n collectValidationErrors(errors, node.dependentSchemas[property]);\n } else if (isListOfStrings(schema)) {\n node.dependentRequired = node.dependentRequired ?? {};\n node.dependentRequired[property] = schema;\n } else {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: dependencies,\n message: `Keyword '${KEYWORD}[string]' must be JSON Schema or string[]`\n })\n );\n }\n }\n\n return errors;\n}\n\nexport function reduceDependencies({ node, data, key, pointer, path }: JsonSchemaReducerParams) {\n if (!isObject(data)) {\n // @todo remove dependentSchemas\n return node;\n }\n\n if (node.dependentRequired == null && node.dependentSchemas == null) {\n return node;\n }\n\n let workingNode = node.compileSchema(node.schema, node.evaluationPath, node.schemaLocation);\n let required = workingNode.schema.required ?? [];\n\n let dynamicId = \"\";\n const dependentRequired = node.dependentRequired;\n if (dependentRequired) {\n Object.keys(dependentRequired).forEach((propertyName) => {\n if (!hasProperty(data, propertyName) && !required.includes(propertyName)) {\n return;\n }\n if (dependentRequired[propertyName] == null) {\n return;\n }\n required.push(...dependentRequired[propertyName]);\n\n // @dynamicId\n const localDynamicId = `${KEYWORD}/${propertyName}`;\n dynamicId += `${dynamicId === \"\" ? \"\" : \",\"}${localDynamicId}`;\n });\n }\n\n const dependentSchemas = node.dependentSchemas;\n if (dependentSchemas) {\n Object.keys(dependentSchemas).forEach((propertyName) => {\n if (!hasProperty(data, propertyName) && !required.includes(propertyName)) {\n return true;\n }\n const dependency = dependentSchemas[propertyName];\n if (!isSchemaNode(dependency)) {\n return true;\n }\n\n if (Array.isArray(dependency.schema.required)) {\n required.push(...dependency.schema.required);\n }\n\n // @note pass on updated required-list to resolve nested dependencies. This is currently supported,\n // but probably not how json-schema spec defines this behaviour (resolve only within sub-schema)\n const reducedDependency = { ...dependency, schema: { ...dependency.schema, required } }.reduceNode(data, {\n key,\n pointer: `${pointer}/${KEYWORD}/${propertyName}`,\n path\n }).node as SchemaNode;\n\n workingNode = mergeNode(workingNode, reducedDependency) as SchemaNode;\n\n // @dynamicId\n const nestedDynamicId = reducedDependency.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const localDynamicId = nestedDynamicId === \"\" ? `${KEYWORD}/${propertyName}` : nestedDynamicId;\n dynamicId += `${dynamicId === \"\" ? \"\" : \",\"}${localDynamicId}`;\n });\n }\n\n if (workingNode === node) {\n return node;\n }\n\n if (required.length === 0) {\n return workingNode;\n }\n\n required = workingNode.schema.required ? workingNode.schema.required.concat(...required) : required;\n required = required.filter((r: string, index: number, list: string[]) => list.indexOf(r) === index);\n workingNode = mergeNode(workingNode, workingNode, KEYWORD) as SchemaNode;\n return workingNode.compileSchema(\n { ...workingNode.schema, required },\n workingNode.evaluationPath,\n workingNode.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n}\n\nfunction validateDependencies({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n if (!isObject(data)) {\n return undefined;\n }\n const errors: ValidationAnnotation[] = [];\n if (node.dependentRequired) {\n sanitizeErrors(validateDependentRequired({ node, data, pointer, path }), errors);\n }\n if (node.dependentSchemas) {\n const schemaErrors = validateDependentSchemas({ node, data, pointer, path });\n sanitizeErrors(schemaErrors, errors);\n }\n return errors;\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\n\nconst KEYWORD = \"deprecated\";\n\nexport const deprecatedKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseDeprecated,\n addValidate: (node) => node[KEYWORD] === true,\n validate: validateDeprecated\n};\n\nfunction parseDeprecated(node: SchemaNode) {\n const deprecated = node.schema[KEYWORD];\n if (deprecated == null) {\n return;\n }\n if (typeof deprecated !== \"boolean\") {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: deprecated,\n message: `Keyword '${KEYWORD}' must be a boolean - received '${typeof deprecated}'`\n });\n }\n node[KEYWORD] = deprecated;\n}\n\nfunction validateDeprecated({ node, data, pointer }: JsonSchemaValidatorParams) {\n return [\n node.createAnnotation(\n \"deprecated-warning\",\n {\n pointer,\n schema: node.schema,\n value: data\n },\n node.schema.deprecatedMessage\n )\n ];\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { getTypeOf } from \"../utils/getTypeOf\";\n\nconst KEYWORD = \"enum\";\n\nexport const enumKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseEnum,\n addValidate: (node) => node.enum != null,\n validate: validateEnum\n};\n\nexport function parseEnum(node: SchemaNode) {\n const { schema } = node;\n if (schema[KEYWORD] == null) {\n return;\n }\n if (!Array.isArray(schema[KEYWORD])) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema,\n value: schema[KEYWORD],\n message: `Keyword '${KEYWORD}' must be an array - received '${typeof schema[KEYWORD]}'`\n });\n }\n node.enum = schema[KEYWORD];\n}\n\nfunction validateEnum({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams) {\n if (node.enum == null) {\n return;\n }\n const type = getTypeOf(data);\n if (type === \"object\" || type === \"array\") {\n const valueStr = JSON.stringify(data);\n for (const e of node.enum) {\n if (JSON.stringify(e) === valueStr) {\n return undefined;\n }\n }\n } else if (node.enum.includes(data)) {\n return undefined;\n }\n return node.createError(\"enum-error\", {\n pointer,\n schema: node.schema,\n value: data,\n values: node.enum\n });\n}\n","export const errors = {\n \"additional-items-error\": \"Array at `{{pointer}}` may not have an additional item `{{key}}`\",\n \"additional-properties-error\":\n \"Additional property `{{property}}` on `{{pointer}}` does not match schema `{{schema}}`\",\n \"all-of-error\": \"Value `{{value}}` at `{{pointer}}` does not match schema of `{{allOf}}`\",\n \"any-of-error\": \"Value `{{value}}` at `{{pointer}}` does not match any schema of `{{anyOf}}`\",\n \"const-error\": \"Expected value at `{{pointer}}` to be `{{expected}}`, but value given is `{{value}}`\",\n \"contains-any-error\": \"The array at `{{pointer}}` must contain at least one item\",\n \"contains-array-error\": \"The property at `{{pointer}}` must not be an array\",\n \"contains-error\": \"The array at `{{pointer}}` must contain an element that matches `{{schema}}`\",\n \"contains-min-error\": \"The array at `{{pointer}}` contains {{delta}} too few items matching `{{schema}}`\",\n \"contains-max-error\": \"The array at `{{pointer}}` contains {{delta}} too many items matching `{{schema}}`\",\n \"enum-error\": \"Expected given value `{{value}}` in `{{pointer}}` to be one of `{{values}}`\",\n \"exclusive-maximum-error\": \"Value in `{{pointer}}` is `{{length}}`, but should be at most `{{maximum}}`\",\n \"exclusive-minimum-error\": \"Value in `{{pointer}}` is `{{length}}`, but should be at minimum `{{minimum}}`\",\n \"forbidden-property-error\": \"Property name `{{property}}` at `{{pointer}}` is not allowed\",\n \"format-date-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid date\",\n \"format-date-time-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid date-time\",\n \"format-duration-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid duration\",\n \"format-email-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid email\",\n \"format-hostname-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid hostname\",\n \"format-idn-hostname-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid idn hostname\",\n \"format-ipv4-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid IPv4 address\",\n \"format-ipv4-leading-zero-error\":\n \"IPv4 addresses starting with zero are invalid, since they are interpreted as octals\",\n \"format-ipv6-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid IPv6 address\",\n \"format-ipv6-leading-zero-error\":\n \"IPv6 addresses starting with zero are invalid, since they are interpreted as octals\",\n \"format-iri-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid iri\",\n \"format-iri-reference-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid iri-reference\",\n \"format-json-pointer-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid json-pointer\",\n \"format-regex-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid regular expression\",\n \"format-time-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid time\",\n \"format-uri-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid uri\",\n \"format-uri-reference-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid uri-reference\",\n \"format-uri-template-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid uri-template\",\n \"format-url-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid url\",\n \"format-uuid-error\": \"Value `{{value}}` at `{{pointer}}` is not a valid uuid\",\n \"invalid-data-error\": \"No value may be specified in `{{pointer}}`\",\n \"invalid-property-name-error\": \"Invalid property name `{{property}}` at `{{pointer}}`\",\n \"maximum-error\": \"Value in `{{pointer}}` is `{{length}}`, but should be `{{maximum}}` at maximum\",\n \"max-items-error\": \"Too many items in `{{pointer}}`, should be `{{maximum}}` at most, but got `{{length}}`\",\n \"max-length-error\": \"Value `{{pointer}}` should have a maximum length of `{{maxLength}}`, but got `{{length}}`.\",\n \"max-properties-error\":\n \"Too many properties in `{{pointer}}`, should be `{{maxProperties}}` at most, but got `{{length}}`\",\n \"minimum-error\": \"Value in `{{pointer}}` is `{{length}}`, but should be `{{minimum}}` at minimum\",\n \"min-items-error\": \"Too few items in `{{pointer}}`, should be at least `{{minItems}}`, but got `{{length}}`\",\n \"min-items-one-error\": \"At least one item is required in `{{pointer}}`\",\n \"min-length-error\": \"Value `{{pointer}}` should have a minimum length of `{{minLength}}`, but got `{{length}}`.\",\n \"min-length-one-error\": \"A value is required in `{{pointer}}`\",\n \"missing-one-of-declarator-error\": \"Missing oneOf declarator `{{declarator}}` in schema `{{schemaLocation}}`\",\n \"min-properties-error\":\n \"Too few properties in `{{pointer}}`, should be at least `{{minProperties}}`, but got `{{length}}`\",\n \"missing-array-item-error\": \"Array at '{{pointer}}' has a missing item at '{{key}}'\",\n \"missing-dependency-error\": \"The required propery '{{missingProperty}}' in `{{pointer}}` is missing\",\n \"missing-one-of-property-error\":\n \"Value at `{{pointer}}` must be object or array and have a property ${oneOfProperty}: ${value}\",\n \"multiple-of-error\": \"Expected `{{value}}` in `{{pointer}}` to be multiple of `{{multipleOf}}`\",\n \"multiple-one-of-error\": \"Value `{{value}}` should not match multiple schemas in oneOf `{{matches}}`\",\n \"no-additional-properties-error\": \"Additional property `{{property}}` in `{{pointer}}` is not allowed\",\n \"not-error\": \"Value `{{value}}` at pointer should not match schema `{{not}}`\",\n \"one-of-error\": \"Value `{{value}}` in `{{pointer}}` does not match any given oneof schema\",\n \"one-of-property-error\":\n \"Failed finding a matching oneOfProperty schema in `{{pointer}}` where `{{property}}` matches `{{value}}`\",\n \"pattern-error\": \"Value in `{{pointer}}` should match `{{description}}`, but received `{{received}}`\",\n \"pattern-properties-error\":\n \"Property `{{key}}` does not match any patterns in `{{pointer}}`. Valid patterns are: {{patterns}}\",\n \"ref-error\": \"Could not resolve $ref '{{ref}}' from '{{pointer}}'\",\n \"required-property-error\": \"The required property `{{key}}` is missing at `{{pointer}}`\",\n /** return schema-warning with createSchemaWarning:true when a valid, but undefined property was found */\n \"schema-warning\": \"Failed retrieving a schema from '{{pointer}}' to key '{{key}}'\",\n \"type-error\": \"Expected `{{value}}` ({{received}}) in `{{pointer}}` to be of type `{{expected}}`\",\n \"undefined-value-error\": \"Value must not be undefined in `{{pointer}}`\",\n \"unevaluated-property-error\": \"Invalid unevaluated property `{{pointer}}`\",\n \"unevaluated-items-error\": \"Invalid unevaluated item `{{pointer}}`\",\n \"unique-items-error\":\n \"Items in array must be unique. Value `{{value}}` in `{{pointer}}` is a duplicate of {{duplicatePointer}}.\",\n \"unknown-property-error\": \"Could not find a valid schema for property `{{pointer}}` within object\",\n \"value-not-empty-error\": \"A value for `{{property}}` is required at `{{pointer}}`\",\n // annotations\n \"deprecated-warning\": \"Value at `{{pointer}}` is deprecated\",\n // schema validation\n \"schema-error\": \"Invalid schema found at {{pointer}}: {{message}}\",\n \"unknown-keyword-warning\": \"Keyword '{{value}}' is not a valid keyword to draft '{{draft}}'\",\n \"unknown-format-warning\": \"Format {{value}} is not a valid format\"\n};\n","import { Keyword, JsonSchemaValidatorParams } from \"../../Keyword\";\nimport { SchemaNode } from \"../../SchemaNode\";\n\nexport const exclusiveMaximumKeyword: Keyword = {\n id: \"exclusiveMaximum\",\n keyword: \"exclusiveMaximum\",\n parse,\n addValidate: ({ schema }) => schema.exclusiveMaximum === true || !isNaN(schema.maximum),\n validate: validateExclusiveMaximum\n};\n\nfunction parse(node: SchemaNode) {\n const { exclusiveMaximum } = node.schema;\n if (exclusiveMaximum != null && !(typeof exclusiveMaximum === \"number\" || typeof exclusiveMaximum === \"boolean\")) {\n return node.createError(\"schema-error\", {\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined,\n message: `Keyword 'exclusiveMaximum' must be a number - received '${typeof exclusiveMaximum}'`\n });\n }\n}\n\nfunction validateExclusiveMaximum({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (typeof data !== \"number\") {\n return undefined;\n }\n if (node.schema.exclusiveMaximum && node.schema.maximum === data) {\n return node.createError(\"maximum-error\", {\n maximum: node.schema.exclusiveMaximum,\n length: data,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../../Keyword\";\nimport { SchemaNode } from \"../../SchemaNode\";\n\nexport const exclusiveMinimumKeyword: Keyword = {\n id: \"exclusiveMinimum\",\n keyword: \"exclusiveMinimum\",\n parse,\n addValidate: ({ schema }) => schema.exclusiveMinimum === true || !isNaN(schema.minimum),\n validate: validateExclusiveMinimum\n};\n\nfunction parse(node: SchemaNode) {\n const { exclusiveMinimum } = node.schema;\n if (exclusiveMinimum != null && !(typeof exclusiveMinimum === \"number\" || typeof exclusiveMinimum === \"boolean\")) {\n return node.createError(\"schema-error\", {\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined,\n message: `Keyword 'exclusiveMinimum' must be a number - received '${typeof exclusiveMinimum}'`\n });\n }\n}\n\nfunction validateExclusiveMinimum({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (typeof data !== \"number\") {\n return undefined;\n }\n if (node.schema.exclusiveMinimum && node.schema.minimum === data) {\n return node.createError(\"minimum-error\", {\n minimum: node.schema.exclusiveMinimum,\n length: data,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\n\nconst KEYWORD = \"format\";\n\nexport const formatKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseFormat,\n addValidate: ({ schema }) => schema?.format != null,\n validate: validateFormat\n};\n\nfunction parseFormat(node: SchemaNode) {\n const format = node.schema[KEYWORD];\n if (format == null) {\n return;\n }\n if (typeof format !== \"string\") {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: format,\n message: `Keyword '${KEYWORD}' must be a string - received '${typeof format}'`\n });\n }\n if (node.context.formats[format] == null) {\n return node.createAnnotation(\"unknown-format-warning\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: format,\n message: `Keyword '${KEYWORD}' must be a string - received '${typeof format}'`\n });\n }\n}\n\nfunction validateFormat(options: JsonSchemaValidatorParams) {\n const { node } = options;\n const formatValidator = node.context.formats[node.schema.format];\n return formatValidator?.(options);\n}\n","import { isWebUri } from \"valid-url\";\nimport { getTypeOf } from \"../utils/getTypeOf\";\nimport { JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport settings from \"../settings\";\n\nconst { REGEX_FLAGS } = settings;\nconst isValidIPV4 = /^(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/;\nconst isValidIPV6 =\n /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))$/i;\nconst matchDate = /^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/;\nconst matchTime =\n /^(?<time>(?:([0-1]\\d|2[0-3]):[0-5]\\d:(?<second>[0-5]\\d|60)))(?:\\.\\d+)?(?<offset>(?:z|[+-]([0-1]\\d|2[0-3])(?::?[0-5]\\d)?))$/i;\nconst DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nconst isValidJsonPointer = /^(?:\\/(?:[^~/]|~0|~1)*)*$/;\nconst isValidRelativeJsonPointer = /^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/;\nconst isValidDurationString = /^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?$/;\n\n// Default Json-Schema formats: date-time, email, hostname, ipv4, ipv6, uri, uriref\nexport const formats: Record<string, (options: JsonSchemaValidatorParams) => ValidationReturnType> = {\n date: ({ node, pointer, data }) => {\n const { schema } = node;\n if (typeof data !== \"string\" || data === \"\") {\n return undefined;\n }\n // https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts\n // full-date from http://tools.ietf.org/html/rfc3339#section-5.6\n const matches = data.match(matchDate);\n if (!matches) {\n return node.createError(\"format-date-error\", { value: data, pointer, schema });\n }\n const year = +matches[1];\n const month = +matches[2];\n const day = +matches[3];\n // https://tools.ietf.org/html/rfc3339#appendix-C\n const isLeapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n if (month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear ? 29 : DAYS[month])) {\n return undefined;\n }\n return node.createError(\"format-date-error\", { value: data, pointer, schema });\n },\n\n \"date-time\": ({ node, pointer, data, path }) => {\n const { schema } = node;\n if (typeof data !== \"string\" || data === \"\") {\n return undefined;\n }\n const dateAndTime = data.split(/t/i);\n if (dateAndTime.length === 2) {\n const dateIsValid = formats.date({ node, pointer, data: dateAndTime[0], path }) === undefined;\n const timeIsValid = formats.time({ node, pointer, data: dateAndTime[1], path }) === undefined;\n if (dateIsValid && timeIsValid) {\n return undefined;\n }\n }\n return node.createError(\"format-date-time-error\", { value: data, pointer, schema });\n },\n\n duration: ({ node, pointer, data }) => {\n const type = getTypeOf(data);\n if (type !== \"string\") {\n return undefined;\n }\n\n // weeks cannot be combined with other units\n const isInvalidDurationString = /(\\d+M)(\\d+W)|(\\d+Y)(\\d+W)/;\n\n if (!isValidDurationString.test(data as string) || isInvalidDurationString.test(data as string)) {\n return node.createError(\"format-duration-error\", {\n value: data,\n pointer,\n schema: node.schema\n });\n }\n },\n\n email: ({ node, pointer, data }) => {\n const { schema } = node;\n if (typeof data !== \"string\" || data === \"\") {\n return undefined;\n }\n\n const lastIndex = data.lastIndexOf(\"@\");\n const name = data.substr(0, lastIndex);\n const host = data.substr(lastIndex + 1);\n if (!name || !host || name.length > 64 || host.length > 253) {\n return node.createError(\"format-email-error\", { value: data, pointer, schema });\n }\n\n // if name is in double quotes: \"joe bloggs\"@example.com, whitespaces, dots etc are allowed\n // so, we remove valid strings in quote\n let strippedName = name;\n if (/^\".*\"$/.test(name)) {\n strippedName = name.replace(/(^\")|([. @]+)|(\"$)/g, \"\");\n }\n\n if (strippedName[0] === \".\" || strippedName.endsWith(\".\") || strippedName.includes(\"..\")) {\n return node.createError(\"format-email-error\", { value: data, pointer, schema });\n }\n if (!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(strippedName)) {\n return node.createError(\"format-email-error\", { value: data, pointer, schema });\n }\n\n if (/^\\[.*\\]$/.test(host)) {\n const possibleIp = host.substr(1, host.length - 2);\n if (\n isValidIPV4.test(possibleIp) ||\n isValidIPV6.test(possibleIp) ||\n /IPv6:::[0-9a-f]{1,4}/.test(possibleIp)\n ) {\n return undefined;\n }\n }\n\n if (!/^[a-z0-9.-]+$/i.test(host)) {\n return node.createError(\"format-email-error\", { value: data, pointer, schema });\n }\n if (!host.split(\".\").every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part))) {\n return node.createError(\"format-email-error\", { value: data, pointer, schema });\n }\n return undefined;\n },\n\n \"json-pointer\": ({ node, pointer, data }) => {\n const { schema } = node;\n if (typeof data !== \"string\" || data === \"\") {\n return undefined;\n }\n if (isValidJsonPointer.test(data)) {\n return undefined;\n }\n return node.createError(\"format-json-pointer-error\", { value: data, pointer, schema });\n },\n\n \"relative-json-pointer\": ({ node, pointer, data }) => {\n const { schema } = node;\n if (typeof data !== \"string\") {\n return undefined;\n }\n if (isValidRelativeJsonPointer.test(data)) {\n return undefined;\n }\n return node.createError(\"format-json-pointer-error\", { value: data, pointer, schema });\n },\n\n regex: ({ node, pointer, data }) => {\n const { schema } = node;\n if (\n typeof data === \"object\" ||\n typeof data === \"number\" ||\n Array.isArray(data) ||\n getTypeOf(data) === \"boolean\"\n ) {\n return undefined;\n }\n if (typeof data === \"string\" && /\\\\Z$/.test(data) === false) {\n try {\n new RegExp(data, schema.regexFlags ?? REGEX_FLAGS);\n return undefined;\n } catch (e) {} // eslint-disable-line @typescript-eslint/no-unused-vars, no-empty\n\n return node.createError(\"format-regex-error\", { value: data, pointer, schema });\n }\n // v7 tests, ignore non-regex values\n\n return node.createError(\"format-regex-error\", { value: data, pointer, schema });\n },\n\n // hh:mm:ss.sTZD\n // RFC 3339 https://datatracker.ietf.org/doc/html/rfc3339#section-4\n time: ({ node, pointer, data }) => {\n const { schema } = node;\n if (typeof data !== \"string\" || data === \"\") {\n return undefined;\n }\n\n // https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts\n const matches = data.match(matchTime);\n if (!matches) {\n return node.createError(\"format-date-time-error\", { value: data, pointer, schema });\n }\n\n // leap second\n if (matches.groups?.second === \"60\") {\n // bail early\n if (/23:59:60(z|\\+00:00)/i.test(data)) {\n return undefined;\n }\n // check if sum matches 23:59\n const minutes = matches.groups.time.match(/(\\d+):(\\d+):/);\n const offsetMinutes = matches.groups.offset.match(/(\\d+):(\\d+)/);\n if (minutes && offsetMinutes) {\n const hour = parseInt(minutes[1]);\n const offsetHour = parseInt(offsetMinutes[1]);\n const min = parseInt(minutes[2]);\n const offsetMin = parseInt(offsetMinutes[2]);\n let deltaTime;\n if (/^-/.test(matches.groups.offset)) {\n deltaTime = (hour + offsetHour) * 60 + (min + offsetMin);\n } else {\n deltaTime = (24 + hour - offsetHour) * 60 + (min - offsetMin);\n }\n const hours = Math.floor(deltaTime / 60);\n const actualHour = hours % 24;\n const actualMinutes = deltaTime - hours * 60;\n if (actualHour === 23 && actualMinutes === 59) {\n return undefined;\n }\n }\n return node.createError(\"format-date-time-error\", { value: data, pointer, schema });\n }\n\n return undefined;\n },\n\n url: ({ node, data, pointer }) => {\n const { schema } = node;\n if (data === \"\" || isWebUri(`${data}`)) {\n return undefined;\n }\n return node.createError(\"format-url-error\", { value: data, pointer, schema });\n },\n\n uuid: ({ node, data, pointer }) => {\n const { schema } = node;\n if (typeof data !== \"string\" || data === \"\") {\n return undefined;\n }\n if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(data)) {\n return undefined;\n }\n return node.createError(\"format-uuid-error\", { value: data, pointer, schema });\n }\n};\n","import { JsonError, SchemaNode } from \"../../types\";\n\n/**\n * Returns a list of possible child-schemas for the given property key. In case of a oneOf selection, multiple schemas\n * could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases\n * a list with a single item will be returned\n */\nexport function getChildSelection(node: SchemaNode, property: string | number): SchemaNode[] | JsonError {\n if (node.oneOf) {\n return node.oneOf.map((childNode: SchemaNode) => childNode.resolveRef());\n }\n if (node.items?.oneOf) {\n return node.items.oneOf.map((childNode: SchemaNode) => childNode.resolveRef());\n }\n\n // array.items[] found\n if (node.prefixItems && node.prefixItems.length > +property) {\n const { node: childNode, error } = node.getNodeChild(property);\n if (childNode) {\n return [childNode];\n }\n return error as JsonError;\n }\n\n // array.items[] exceeded (or undefined), but additionalItems specified\n if (node.schema.additionalItems) {\n // we fallback to a string if no schema is defined - might be subject for configuration\n if (node.schema.additionalItems === true) {\n return [node.compileSchema({ type: \"string\" })];\n }\n if (node.items) {\n return [node.items.resolveRef()];\n }\n }\n\n // array.items[] exceeded\n if (node.prefixItems && node.prefixItems.length <= +property) {\n return [];\n }\n\n const { node: childNode, error } = node.getNodeChild(property);\n if (childNode) {\n return [childNode as SchemaNode];\n }\n return error as JsonError;\n}\n","import { getTypeOf } from \"./getTypeOf\";\nimport { isObject } from \"../utils/isObject\";\nimport { BooleanSchema, JsonSchema, SchemaNode } from \"../types\";\n\nexport const SCHEMA_TYPES = [\"string\", \"number\", \"integer\", \"boolean\", \"null\", \"array\", \"object\"] as const;\nexport type SchemaType = (typeof SCHEMA_TYPES)[number];\nconst OBJECT_PROPERTIES = [\n \"additionalProperties\",\n // \"allOf\",\n // \"anyOf\",\n \"dependencies\",\n \"dependentSchemas\",\n \"dependentRequired\",\n // \"enum\",\n // \"format\",\n // \"if\",\n \"maxProperties\",\n \"minProperties\",\n // \"not\",\n // \"oneOf\",\n \"patternProperties\",\n \"properties\",\n \"propertyNames\",\n \"required\",\n \"unevaluatedProperties\" // 2019-09\n];\nconst ARRAY_PROPERTIES = [\n // \"allOf\",\n // \"anyOf\",\n \"contains\",\n // \"enum\",\n // \"if\",\n \"items\",\n \"maxItems\",\n \"minItems\",\n // \"not\",\n // \"oneOf\",\n \"unevaluatedItems\",\n \"uniqueItems\"\n];\n\n/**\n * @helper for getData\n * returns schema type, which might be an educated guess based on defined schema\n * properties if an exact type cannot be retried from type.\n */\nexport function getSchemaType(node: SchemaNode, data: unknown): SchemaType | undefined {\n const dataType = getTypeOf(data);\n const schema = node.schema as JsonSchema | BooleanSchema;\n if (schema === true) {\n if (dataType === \"bigint\") {\n return \"number\";\n }\n return SCHEMA_TYPES.some((schemaType) => schemaType === dataType) ? (dataType as SchemaType) : undefined;\n }\n // boolean schema false or invalid schema\n if (!isObject(schema)) {\n return undefined;\n }\n const schemaType = schema.type;\n\n // type: []\n if (Array.isArray(schemaType)) {\n if (schemaType.includes(dataType)) {\n return dataType as SchemaType;\n }\n const defaultType = getTypeOf(schema.default);\n if (schemaType.includes(defaultType)) {\n return defaultType as SchemaType;\n }\n return schemaType[0];\n }\n\n // type: \"\"\n if (schemaType) {\n return schemaType as SchemaType;\n }\n\n // type: undefined, enum: []\n if (Array.isArray(schema.enum)) {\n const schemaEnum: unknown[] = schema.enum;\n const enumSchemaType = schemaEnum.map((value) => getTypeOf(value)).filter((p, i, l) => l.indexOf(p) === i);\n if (enumSchemaType.includes(dataType)) {\n return dataType as SchemaType;\n }\n const defaultType = getTypeOf(schema.default);\n if (enumSchemaType.includes(defaultType)) {\n return defaultType as SchemaType;\n }\n return enumSchemaType[0] as SchemaType;\n }\n\n // type: undefined, enum: undefined -- define type by schema-properties\n // @attenation this is prone to wrong results\n const schemaProperties = Object.keys(node.schema);\n const objectProperties = schemaProperties.filter((p) => OBJECT_PROPERTIES.includes(p));\n const arrayProperties = schemaProperties.filter((p) => ARRAY_PROPERTIES.includes(p));\n\n if (objectProperties.length > 0 && objectProperties.length > arrayProperties.length) {\n return \"object\";\n }\n\n if (arrayProperties.length > 0 && arrayProperties.length > objectProperties.length) {\n return \"array\";\n }\n\n // nothing found yet check dynamic properties for a type\n if (node.if) {\n return getSchemaType(node.if.resolveRef() ?? node.if, data);\n }\n\n if (node.allOf) {\n for (const allOf of node.allOf) {\n const type = getSchemaType(allOf.resolveRef() ?? allOf, data);\n if (type) {\n return type;\n }\n }\n }\n\n if (node.oneOf) {\n for (const oneOf of node.oneOf) {\n const type = getSchemaType(oneOf.resolveRef() ?? oneOf, data);\n if (type) {\n return type;\n }\n }\n }\n\n if (node.anyOf) {\n for (const anyOf of node.anyOf) {\n const type = getSchemaType(anyOf.resolveRef() ?? anyOf, data);\n if (type) {\n return type;\n }\n }\n }\n\n if (schema.$ref) {\n const refNode = node.resolveRef();\n if (refNode) {\n return getSchemaType(refNode, data);\n }\n }\n\n return undefined;\n}\n","import { getTypeOf } from \"./getTypeOf\";\n\nexport function isEmpty(v: unknown): boolean {\n\tconst type = getTypeOf(v);\n\tswitch (type) {\n\t\tcase \"string\":\n\t\tcase \"array\":\n\t\t\treturn (v as [])?.length === 0;\n\t\tcase \"null\":\n\t\tcase \"undefined\":\n\t\t\treturn true;\n\t\tcase \"object\":\n\t\t\treturn Object.keys(v as object).length === 0;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n","import {\n Keyword,\n JsonSchemaReducerParams,\n JsonSchemaValidatorParams,\n ValidationPath,\n ValidationReturnType,\n ValidationAnnotation\n} from \"../Keyword\";\nimport { isSchemaNode, SchemaNode } from \"../types\";\nimport settings from \"../settings\";\nimport { getValue } from \"../utils/getValue\";\nimport sanitizeErrors from \"../utils/sanitizeErrors\";\nimport { isObject } from \"../utils/isObject\";\nimport { validateNode } from \"../validateNode\";\nimport { joinDynamicId } from \"../SchemaNode\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst KEYWORD = \"oneOf\";\nconst { DECLARATOR_ONEOF } = settings;\n\nexport const oneOfKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseOneOf,\n addReduce: (node) => node[KEYWORD] != null,\n reduce: reduceOneOf,\n addValidate: (node) => node[KEYWORD] != null,\n validate: oneOfValidator\n};\n\nexport const oneOfFuzzyKeyword: Keyword = {\n id: \"oneOf-fuzzy\",\n keyword: \"oneOf\",\n parse: parseOneOf,\n addReduce: (node) => node.oneOf != null,\n reduce: reduceOneOfFuzzy,\n addValidate: (node) => node.oneOf != null,\n validate: oneOfValidator\n};\n\nexport function parseOneOf(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n if (schema[KEYWORD] == null) {\n return;\n }\n if (!Array.isArray(schema[KEYWORD])) {\n return node.createError(\"schema-error\", {\n pointer: schemaLocation,\n schema,\n value: schema[KEYWORD],\n message: `Keyword '${KEYWORD}' must be an array - received '${typeof schema[KEYWORD]}'`\n });\n }\n if (schema[KEYWORD].length === 0) {\n return;\n }\n\n node[KEYWORD] = schema[KEYWORD].map((s, index) =>\n node.compileSchema(s, `${evaluationPath}/${KEYWORD}/${index}`, `${schemaLocation}/${KEYWORD}/${index}`)\n );\n return collectValidationErrors([], ...node[KEYWORD]);\n}\n\nfunction reduceOneOf({ node, data, pointer, path }: Omit<JsonSchemaReducerParams, \"key\">) {\n if (node.oneOf == null) {\n return;\n }\n\n // !keyword: oneOfProperty\n // an additional <DECLARATOR_ONEOF> (default `oneOfProperty`) on the schema will exactly determine the\n // oneOf value (if set in data)\n if (data != null && node.schema[DECLARATOR_ONEOF]) {\n return reduceOneOfDeclarator({ node, data, pointer, path });\n }\n\n const matches: { index: number; node: SchemaNode }[] = [];\n const errors: ValidationReturnType[] = [];\n for (let i = 0; i < node.oneOf.length; i += 1) {\n const validationErrors = validateNode(node.oneOf[i], data, pointer, path);\n if (validationErrors.length === 0) {\n matches.push({ index: i, node: node.oneOf[i] });\n } else {\n errors.push(...validationErrors);\n }\n }\n\n if (matches.length === 1) {\n const { node, index } = matches[0];\n const { node: reducedNode, error } = node.reduceNode(data, { pointer, path });\n\n if (reducedNode) {\n const nestedDynamicId = reducedNode.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const dynamicId = nestedDynamicId === \"\" ? `oneOf/${index}` : nestedDynamicId;\n\n reducedNode.oneOfIndex = index; // @evaluation-info\n reducedNode.dynamicId = joinDynamicId(reducedNode.dynamicId, `+${node.schemaLocation}(${dynamicId})`);\n return reducedNode;\n }\n return error;\n }\n\n if (matches.length === 0) {\n return node.createError(\"one-of-error\", {\n value: JSON.stringify(data),\n pointer,\n schema: node.schema,\n oneOf: node.schema.oneOf,\n errors\n });\n }\n\n return node.createError(\"one-of-error\", {\n value: JSON.stringify(data),\n pointer,\n schema: node.schema,\n oneOf: node.schema.oneOf,\n errors\n });\n}\n\n/**\n * Returns matching oneOf schema identified by matching schema for oneOfProperty\n */\nexport function reduceOneOfDeclarator({ node, data, pointer, path }: Omit<JsonSchemaReducerParams, \"key\">) {\n if (node.oneOf == null) {\n return;\n }\n\n const oneOfProperty = node.schema[DECLARATOR_ONEOF];\n const oneOfPropertyValue = getValue(data, oneOfProperty);\n\n // in this case, we also fail when data undefined as this always is valid,\n // but not in context on an expected oneOfProperty\n if (data === undefined || oneOfPropertyValue === undefined) {\n return node.createError(\"missing-one-of-property-error\", {\n oneOfProperty,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n\n // find oneOf schema that has a matching oneOfProperty to the current input data\n // TODO throw an error if multiple matches were found\n const errors: ValidationReturnType = [];\n for (let i = 0; i < node.oneOf.length; i += 1) {\n const { node: resultNode } = node.oneOf[i].getNodeChild(oneOfProperty, data);\n if (!isSchemaNode(resultNode)) {\n // one of the oneOf schemas has a missing oneOfTypeProperty\n // TODO this still might succeed\n // TODO there is a possibility this throws an invalid error as we use input data\n return node.createError(\"missing-one-of-declarator-error\", {\n declarator: DECLARATOR_ONEOF,\n oneOfProperty,\n schemaLocation: node.oneOf[i].schemaLocation,\n pointer: `${pointer}/oneOf/${i}`,\n schema: node.schema,\n value: data\n });\n }\n\n // collect errors in case we fail finding a matching schema\n const result = sanitizeErrors(\n validateNode(resultNode, oneOfPropertyValue, `${pointer}/${oneOfProperty}`, path)\n );\n\n if (result.length > 0) {\n errors.push(...result);\n } else {\n // return at once when we found a schema\n // TODO should check all oneOf-schema\n const { node: reducedNode } = node.oneOf[i].reduceNode(data, { pointer, path });\n if (reducedNode) {\n reducedNode.oneOfIndex = i; // @evaluation-info\n return reducedNode;\n }\n }\n }\n\n return node.createError(\"one-of-property-error\", {\n property: oneOfProperty,\n value: data,\n pointer,\n schema: node.schema,\n errors\n });\n}\n\n/**\n * Returns a ranking for the data and given schema\n *\n * @param draft\n * @param - json schema type: object\n * @param data\n * @param [pointer]\n * @return ranking value (higher is better)\n */\nfunction fuzzyObjectValue(node: SchemaNode, data: Record<string, unknown>, pointer: string, path: ValidationPath) {\n if (data == null || node.properties == null) {\n return -1;\n }\n let value = 0;\n const keys = Object.keys(node.properties ?? {});\n for (const key of keys) {\n if (data[key]) {\n if (validateNode(node.properties[key], data[key], pointer, path).length === 0) {\n value += 1;\n }\n }\n }\n return value;\n}\n\n/**\n * Selects and returns a oneOf schema for the given data\n *\n * @param draft\n * @param data\n * @param [schema] - current json schema containing property oneOf\n * @param [pointer] - json pointer to data\n * @return oneOf schema or an error\n */\nexport function reduceOneOfFuzzy({ node, data, pointer, path }: Omit<JsonSchemaReducerParams, \"key\">) {\n // @todo: usingMergeNode may add reducers that are no longer available\n if (node.oneOf == null) {\n return node;\n }\n\n const oneOfResult = reduceOneOf({ node, data, pointer, path });\n if (isSchemaNode(oneOfResult)) {\n return oneOfResult;\n }\n\n // fuzzy match oneOf\n if (isObject(data)) {\n let nodeOfItem: SchemaNode | undefined;\n let schemaOfIndex = -1;\n let fuzzyGreatest = 0;\n\n for (let i = 0; i < node.oneOf.length; i += 1) {\n const oneNode = node.oneOf[i];\n const fuzzyValue = fuzzyObjectValue(oneNode, data, pointer, path);\n\n if (fuzzyGreatest < fuzzyValue) {\n fuzzyGreatest = fuzzyValue;\n nodeOfItem = oneNode;\n schemaOfIndex = i;\n }\n }\n\n if (nodeOfItem === undefined) {\n return node.createError(\"one-of-error\", {\n value: JSON.stringify(data),\n pointer,\n schema: node.schema,\n oneOf: node.schema.oneOf\n });\n }\n\n const { node: reducedNode, error } = nodeOfItem.reduceNode(data, { pointer, path });\n if (reducedNode) {\n reducedNode.oneOfIndex = schemaOfIndex; // @evaluation-info\n return reducedNode;\n }\n return error;\n }\n\n return oneOfResult;\n}\n\nfunction validateFromDeclarator({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const { oneOf, schema } = node;\n if (!oneOf) {\n return;\n }\n\n // with a declarator we only validate by a declarator to retrieve matches.\n // - if a single match was found, we return validation errors if any\n // - if no match was found we return a one-of-error\n // - if multiples matches were found we return a multiple-one-of-error\n const oneOfProperty = schema[DECLARATOR_ONEOF];\n const oneOfValue = getValue(data, oneOfProperty);\n const matches: { index: number; node: SchemaNode }[] = [];\n const errors: ValidationReturnType = [];\n for (const oneOfNode of oneOf) {\n const { node: oneOfPropertyNode, error } = oneOfNode.getNodeChild(oneOfProperty, oneOfValue);\n if (oneOfPropertyNode) {\n const validationResult = validateNode(oneOfPropertyNode, oneOfValue, `${pointer}/${oneOfProperty}`, path);\n if (validationResult.length > 0) {\n errors.push(...validationResult);\n } else {\n matches.push({ index: oneOf.indexOf(oneOfNode), node: oneOfNode });\n }\n } else {\n console.log(\n `jlib oneOf error: failed getting schema for '${oneOfProperty}' to resolve ${DECLARATOR_ONEOF} in ${pointer}/oneOf/${oneOf.indexOf(oneOfNode)}`,\n error\n );\n }\n }\n\n if (matches.length === 1) {\n const match = matches[0];\n match.node.oneOfIndex = match.index; // @evaluation-info\n return validateNode(match.node, data, pointer, path);\n }\n\n if (matches.length > 1) {\n return node.createError(\"multiple-one-of-error\", {\n value: data,\n pointer,\n schema,\n matches\n });\n }\n\n return node.createError(\"one-of-error\", {\n value: JSON.stringify(data),\n pointer,\n schema,\n oneOf: schema.oneOf,\n errors\n });\n}\n\nfunction oneOfValidator({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const { oneOf, schema } = node;\n if (!oneOf) {\n return;\n }\n\n if (schema[DECLARATOR_ONEOF]) {\n return validateFromDeclarator({ node, data, pointer, path });\n }\n\n const matches: { index: number; node: SchemaNode }[] = [];\n const errors: ValidationReturnType = [];\n for (let i = 0; i < oneOf.length; i += 1) {\n const validationResult = validateNode(oneOf[i], data, pointer, path);\n if (validationResult.length > 0) {\n errors.push(...validationResult);\n } else {\n matches.push({ index: i, node: oneOf[i] });\n }\n }\n\n if (matches.length === 1) {\n const { node, index } = matches[0];\n node.oneOfIndex = index; // @evaluation-info\n return undefined;\n }\n\n if (matches.length > 1) {\n return node.createError(\"multiple-one-of-error\", {\n value: data,\n pointer,\n schema,\n matches\n });\n }\n\n return node.createError(\"one-of-error\", {\n value: JSON.stringify(data),\n pointer,\n schema,\n oneOf: schema.oneOf,\n errors\n });\n}\n","let isFile: (value: unknown) => value is File;\n// @ts-expect-error forced types\nisFile = () => false;\n\ntry {\n if (typeof File === \"function\") {\n isFile = (value: unknown) => value instanceof File;\n }\n} catch (e) {} // eslint-disable-line\n\nexport { isFile };\n","import { copy } from \"fast-copy\";\nimport { getTypeOf } from \"../../utils/getTypeOf\";\nimport { getSchemaType } from \"../../utils/getSchemaType\";\nimport { getValue } from \"../../utils/getValue\";\nimport { isEmpty } from \"../../utils/isEmpty\";\nimport { isJsonError } from \"../../types\";\nimport { isObject } from \"../../utils/isObject\";\nimport { isSchemaNode, SchemaNode } from \"../../types\";\nimport { mergeNode } from \"../../mergeNode\";\nimport { reduceOneOfFuzzy } from \"../../keywords/oneOf\";\nimport { isFile } from \"../../utils/isFile\";\n\nexport type TemplateOptions = {\n /** Add all properties (required and optional) to the generated data */\n addOptionalProps?: boolean;\n /** Remove data that does not match input schema. Defaults to false */\n removeInvalidData?: boolean;\n /** Set to false to take default values as they are and not extend them.\n * Defaults to true.\n * This allows to control template data e.g. enforcing arrays to be empty,\n * regardless of minItems settings.\n */\n extendDefaults?: boolean;\n /**\n * Set to false to not use type specific initial values.Defaults to true\n */\n useTypeDefaults?: boolean;\n /**\n * Limits how often a $ref should be followed before aborting. Prevents infinite data-structure.\n * Defaults to 1\n */\n recursionLimit?: number;\n /** @internal disables recursion limit for next call */\n disableRecursionLimit?: boolean;\n /** @internal context to track recursion limit */\n cache?: Record<string, Record<string, number>>;\n};\n\nfunction safeResolveRef(node: SchemaNode, options: TemplateOptions) {\n if (node.$ref == null) {\n return undefined;\n }\n\n options.cache = options.cache ?? {};\n const { cache, recursionLimit = 1 } = options;\n\n const origin = node.schemaLocation;\n cache[origin] = cache[origin] ?? {};\n cache[origin][node.$ref] = cache[origin][node.$ref] ?? 0;\n const value = cache[origin][node.$ref];\n if (value >= recursionLimit && options.disableRecursionLimit !== true) {\n return false;\n }\n options.disableRecursionLimit = false;\n cache[origin][node.$ref] += 1;\n const resolvedNode = node.resolveRef();\n if (resolvedNode && resolvedNode !== node) {\n return resolvedNode;\n }\n\n return undefined;\n}\n\nfunction canResolveRef(node: SchemaNode, options: TemplateOptions) {\n // @ts-expect-error unknown index\n const counter = options.cache?.[node.schemaLocation]?.[node.$ref] ?? -1;\n return counter < (options.recursionLimit ?? 1);\n}\n\n// only convert values where we do not lose original data\nfunction convertValue(type: string | undefined, value: unknown) {\n const valueType = getTypeOf(value);\n if (type === undefined || value == null || valueType === type || (valueType === \"number\" && type === \"integer\")) {\n return value;\n }\n\n if (type === \"string\") {\n return JSON.stringify(value);\n } else if (valueType !== \"string\") {\n return value;\n }\n\n try {\n const parsedValue = JSON.parse(value as string);\n if (getTypeOf(parsedValue) === type) {\n return parsedValue;\n }\n } catch (e) {} // eslint-disable-line @typescript-eslint/no-unused-vars, no-empty\n\n return value;\n}\n\nexport function getData(node: SchemaNode, data?: unknown, opts?: TemplateOptions) {\n if (opts?.cache == null) {\n throw new Error(\"Missing options\");\n }\n\n // @ts-expect-error boolean schema\n if (node.schema === false || node.schema === true) {\n return data;\n }\n // @attention - very special case to support file instances\n if (isFile(data)) {\n return data;\n }\n\n if (node.schema?.const !== undefined) {\n return node.schema?.const;\n }\n\n let currentNode = node;\n let defaultData = data;\n\n if (Array.isArray(node.schema.enum) && node.schema.enum.length > 0) {\n if (data === undefined) {\n return node.schema.default ?? node.schema.enum[0];\n }\n }\n\n if (node.schema.default !== undefined) {\n if (defaultData === undefined) {\n defaultData = node.schema.default;\n }\n }\n\n // @keyword allOf\n if (currentNode.allOf?.length) {\n currentNode.allOf.forEach((partialNode) => {\n defaultData = partialNode.getData(defaultData, opts) ?? defaultData;\n });\n }\n\n // @keyword anyOf\n if (currentNode.anyOf && currentNode.anyOf?.length > 0) {\n defaultData = currentNode.anyOf[0].getData(defaultData, opts) ?? defaultData;\n }\n\n // @keyword oneOf\n if (currentNode.oneOf && currentNode.oneOf?.length > 0) {\n if (isEmpty(defaultData)) {\n currentNode = mergeNode(currentNode, currentNode.oneOf[0]) as SchemaNode;\n } else {\n // find correct schema for data\n const resolvedNode = reduceOneOfFuzzy({ node: currentNode, data: defaultData, path: [], pointer: \"#\" });\n if (isJsonError(resolvedNode)) {\n if (defaultData != null && opts.removeInvalidData !== true) {\n return defaultData;\n }\n // override\n currentNode = currentNode.oneOf[0];\n defaultData = undefined;\n } else {\n currentNode = mergeNode(currentNode, resolvedNode) as SchemaNode;\n }\n }\n }\n\n const resolvedNode = safeResolveRef(currentNode, opts);\n if (resolvedNode === false) {\n return defaultData;\n }\n\n if (isSchemaNode(resolvedNode)) {\n defaultData = resolvedNode.getData(defaultData, opts) ?? defaultData;\n currentNode = resolvedNode;\n }\n\n const type = getSchemaType(currentNode, defaultData);\n const templateData = TYPE[type as string]?.(currentNode, defaultData, opts);\n return templateData === undefined ? defaultData : templateData;\n}\n\nconst TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptions) => unknown> = {\n null: (node, data, opts) => getDefault(node, data, null, opts.useTypeDefaults),\n string: (node, data, opts) => getDefault(node, data, \"\", opts.useTypeDefaults),\n number: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),\n integer: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),\n boolean: (node, data, opts) => getDefault(node, data, false, opts.useTypeDefaults),\n // object: (draft, schema, data: Record<string, unknown> | undefined, pointer: JsonPointer, opts: TemplateOptions) => {\n object: (node, data, opts) => {\n const schema = node.schema;\n const template = schema.default === undefined ? {} : schema.default;\n const d: Record<string, unknown> = {}; // do not assign data here, to keep ordering from json-schema\n const required = opts.extendDefaults === false && schema.default !== undefined ? [] : (schema.required ?? []);\n\n const properties = node.properties;\n if (properties) {\n Object.keys(properties).forEach((propertyName) => {\n const propertyNode = properties[propertyName];\n const isRequired = required.includes(propertyName);\n const input = getValue(data, propertyName);\n const value = data === undefined || input === undefined ? getValue(template, propertyName) : input;\n // Omit adding a property if it is not required or optional props should be added\n if (value != null || isRequired || opts.addOptionalProps) {\n const propertyValue = propertyNode.getData(value, opts);\n if (propertyValue !== undefined || opts.useTypeDefaults !== false) {\n d[propertyName] = propertyValue;\n }\n }\n });\n }\n\n const dependentRequired = node.dependentRequired;\n if (isObject(dependentRequired)) {\n Object.keys(dependentRequired).forEach((propertyName) => {\n const propertyValue = dependentRequired[propertyName];\n const hasValue = getValue(d, propertyName) !== undefined;\n if (hasValue) {\n propertyValue.forEach((addProperty) => {\n const { node: propertyNode } = node.getNodeChild(addProperty, d);\n if (propertyNode) {\n d[addProperty] = propertyNode.getData(getValue(d, addProperty), opts);\n }\n });\n }\n // if false and removeInvalidData => remove from data\n });\n }\n\n // @keyword dependencies - has to be done after resolving properties so dependency may trigger\n const dependentSchemas = node.dependentSchemas;\n if (dependentSchemas) {\n Object.keys(dependentSchemas).forEach((prop) => {\n const dependency = dependentSchemas[prop];\n if (d[prop] !== undefined && isSchemaNode(dependency)) {\n const dependencyData = dependency.getData(data ?? d, opts);\n Object.assign(d, dependencyData);\n }\n // if false and removeInvalidData => remove from data\n });\n }\n\n // console.log(\"getData object\", data, opts);\n if (data) {\n if (\n opts.removeInvalidData === true &&\n (schema.additionalProperties === false || isObject(schema.additionalProperties))\n ) {\n const additionalProperties = node.additionalProperties;\n if (isSchemaNode(additionalProperties)) {\n Object.keys(data).forEach((key) => {\n if (d[key] == null) {\n // merge valid missing data (additionals) to resulting object\n const value = getValue(data, key);\n if (additionalProperties.validate(value).valid) {\n d[key] = value;\n }\n }\n });\n }\n } else {\n // merge any missing data (additionals) to resulting object\n Object.keys(data).forEach((key) => d[key] == null && (d[key] = getValue(data, key)));\n }\n }\n\n // @keyword if-then-else\n if (node.if) {\n const { valid } = node.if.validate(d);\n if (valid && node.then) {\n const templateData = node.then.getData(d, opts);\n Object.assign(d, templateData);\n } else if (!valid && node.else) {\n const templateData = node.else.getData(d, opts);\n Object.assign(d, templateData);\n }\n }\n\n // returns object, which is ordered by json-schema\n return { ...template, ...d };\n },\n // build array type of items, ignores additionalItems\n array: (node, data, opts) => {\n const schema = node.schema;\n const template = schema.default === undefined ? [] : schema.default;\n const d: unknown[] = Array.isArray(data) ? [...data] : template;\n const minItems = opts.extendDefaults === false && schema.default !== undefined ? 0 : (schema.minItems ?? 0);\n\n // when there are no array-items are defined\n if (schema.items == null) {\n // => all items are additionalItems\n if (node.items) {\n const itemCount = Math.max(minItems, d.length);\n for (let i = 0; i < itemCount; i += 1) {\n d[i] = node.items.getData(d[i], opts);\n }\n }\n return d || [];\n }\n\n // when items are defined per index\n if (node.prefixItems) {\n const input = Array.isArray(data) ? data : [];\n\n // build defined set of items\n const length = Math.max(minItems ?? 0, node.prefixItems.length);\n for (let i = 0; i < length; i += 1) {\n const childNode = node.prefixItems[i] ?? node.items;\n if ((childNode && canResolveRef(childNode, opts)) || input[i] !== undefined) {\n const result = childNode.getData(d[i] == null ? template[i] : d[i], opts);\n if (result !== undefined) {\n d[i] = result;\n }\n }\n }\n return d || [];\n }\n\n // this has to be defined as we checked all other cases\n if (node.items == null) {\n return d;\n }\n\n // build data from items-definition\n if ((node.items && canResolveRef(node.items, opts)) || (Array.isArray(data) && data?.length > 0)) {\n // @attention this should disable cache or break intended behaviour as we reset it after loop\n // intention: reset cache after each property. last call will add counters\n const cache = { ...opts.cache };\n for (let i = 0, l = Math.max(minItems, d.length); i < l; i += 1) {\n opts.cache = copy(cache);\n const options = { ...opts, disableRecursionLimit: true };\n const result = node.items.getData(d[i] == null ? template[i] : d[i], options);\n // @attention if getData aborts recursion it currently returns undefined)\n if (result === undefined) {\n return d;\n } else {\n d[i] = result;\n }\n }\n }\n\n return d;\n }\n};\n\nfunction getDefault({ schema }: SchemaNode, templateValue: unknown, initValue: unknown, useTypeDefaults?: boolean) {\n if (templateValue !== undefined) {\n return convertValue(schema.type, templateValue);\n } else if (schema.const) {\n return schema.const;\n } else if (schema.default === undefined && Array.isArray(schema.enum)) {\n return schema.enum[0];\n } else if (schema.default === undefined && useTypeDefaults !== false) {\n return initValue;\n }\n return schema.default;\n}\n","import { Keyword, JsonSchemaResolverParams, JsonSchemaValidatorParams, ValidationReturnType } from \"../../Keyword\";\nimport { SchemaNode } from \"../../types\";\nimport { isObject } from \"../../utils/isObject\";\nimport { validateNode } from \"../../validateNode\";\n\nconst KEYWORD = \"items\";\n\nexport const itemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseItems,\n addResolve: (node) => (node.prefixItems || node[KEYWORD]) != null,\n resolve: itemsResolver,\n addValidate: ({ schema }) => schema.items != null,\n validate: validateItems\n};\n\nfunction itemsResolver({ node, key }: JsonSchemaResolverParams) {\n if (node.prefixItems?.[key as number]) {\n return node.prefixItems[key as number];\n }\n if (node.items) {\n return node.items;\n }\n}\n\nexport function parseItems(node: SchemaNode) {\n const { schema, evaluationPath } = node;\n const items = schema[KEYWORD];\n if (items == null || typeof items === \"boolean\") {\n return;\n }\n\n if (isObject(items)) {\n const propertyNode = node.compileSchema(\n items,\n `${evaluationPath}/${KEYWORD}`,\n `${node.schemaLocation}/${KEYWORD}`\n );\n node.items = propertyNode;\n return;\n }\n\n if (Array.isArray(items)) {\n node.prefixItems = items.map((itemSchema, index) =>\n node.compileSchema(\n itemSchema,\n `${evaluationPath}/${KEYWORD}/${index}`,\n `${node.schemaLocation}/${KEYWORD}/${index}`\n )\n );\n return;\n }\n\n return node.createError(\"schema-error\", {\n pointer: evaluationPath,\n schema,\n value: undefined,\n message: `Keyword '${KEYWORD}' must be an object or array - received '${typeof items}'`\n });\n}\n\nfunction validateItems({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n if (!Array.isArray(data) || data.length === 0) {\n return;\n }\n\n // @draft >= 7 bool schema\n if (schema.items === false) {\n if (Array.isArray(data) && data.length === 0) {\n return undefined;\n }\n return node.createError(\"invalid-data-error\", { pointer, value: data, schema });\n }\n\n const errors: ValidationReturnType = [];\n if (node.prefixItems) {\n // note: schema is valid when data does not have enough elements as defined by array-list\n for (let i = 0; i < Math.min(node.prefixItems.length, data.length); i += 1) {\n const itemData = data[i];\n const itemNode = node.prefixItems[i];\n const result = validateNode(itemNode, itemData, `${pointer}/${i}`, path);\n errors.push(...result);\n }\n return errors;\n }\n\n if (node.items) {\n for (let i = 0; i < data.length; i += 1) {\n const itemData = data[i];\n const result = validateNode(node.items, itemData, `${pointer}/${i}`, path);\n if (result) {\n errors.push(...result);\n }\n }\n return errors;\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { isNumber, SchemaNode } from \"../types\";\n\nconst KEYWORD = \"maximum\";\n\nexport const maximumKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMaximum,\n addValidate: (node) => node.maximum != null,\n validate: validateMaximum\n};\n\nfunction parseMaximum(node: SchemaNode) {\n const max = node.schema[KEYWORD];\n if (max == null) {\n return;\n }\n if (!isNumber(max)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: max,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof max}'`\n });\n }\n node[KEYWORD] = max;\n}\n\nfunction validateMaximum({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (!isNumber(data)) {\n return undefined;\n }\n\n const max = node[KEYWORD];\n const { schema } = node;\n if (max && max < data) {\n return node.createError(\"maximum-error\", {\n maximum: max,\n length: data,\n value: data,\n pointer,\n schema\n });\n }\n if (max && schema.exclusiveMaximum === true && max === data) {\n return node.createError(\"maximum-error\", {\n maximum: max,\n length: data,\n pointer,\n schema,\n value: data\n });\n }\n return undefined;\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { isNumber, SchemaNode } from \"../types\";\n\nconst KEYWORD = \"maxItems\";\n\nexport const maxItemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMaxItems,\n addValidate: ({ schema }) => !isNaN(schema.maxItems),\n validate: validateMaxItems\n};\n\nfunction parseMaxItems(node: SchemaNode) {\n const max = node.schema[KEYWORD];\n if (max == null) {\n return;\n }\n if (!isNumber(max)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: max,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof max}'`\n });\n }\n node[KEYWORD] = max;\n}\n\nfunction validateMaxItems({ node, data, pointer }: JsonSchemaValidatorParams) {\n const { schema } = node;\n if (Array.isArray(data) && schema.maxItems < data.length) {\n return node.createError(\"max-items-error\", {\n maximum: schema.maxItems,\n length: data.length,\n schema,\n value: data,\n pointer\n });\n }\n}\n","/* eslint no-bitwise: 0 */\n\n/**\n * taken from punycode@2.1.0\n *\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see <https://mathiasbynens.be/notes/javascript-encoding>\n * @memberOf punycode.ucs2\n * @name decode\n * @param string The Unicode input string (UCS-2).\n * @returns The new array of code points.\n */\nexport default function ucs2decode(string: string): string[] {\n const output: number[] = [];\n let counter = 0;\n const length = string.length;\n while (counter < length) {\n const value = string.charCodeAt(counter++);\n if (value >= 0xd800 && value <= 0xdbff && counter < length) {\n // It's a high surrogate, and there is a next character.\n const extra = string.charCodeAt(counter++);\n if ((extra & 0xfc00) == 0xdc00) {\n // Low surrogate.\n output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\n } else {\n // It's an unmatched surrogate; only append this code unit, in case the\n // next code unit is the high surrogate of a surrogate pair.\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n return output as unknown as string[];\n}\n","import ucs2decode from \"../utils/punycode.ucs2decode\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isNumber } from \"../types\";\n\nconst KEYWORD = \"maxLength\";\n\nexport const maxLengthKeyword: Keyword<\"maxLength\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMaxLength,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMaxLength\n};\n\nfunction parseMaxLength(node: SchemaNode) {\n const max = node.schema[KEYWORD];\n if (max == null) {\n return;\n }\n if (!isNumber(max)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: max,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof max}'`\n });\n }\n node[KEYWORD] = max;\n}\n\nfunction validateMaxLength({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams<\"maxLength\">) {\n if (typeof data !== \"string\") {\n return;\n }\n const maxLength = node[KEYWORD];\n const length = ucs2decode(data).length;\n if (maxLength < length) {\n return node.createError(\"max-length-error\", {\n maxLength: maxLength,\n length,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import { isObject } from \"../utils/isObject\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isNumber } from \"../types\";\n\nconst KEYWORD = \"maxProperties\";\n\nexport const maxPropertiesKeyword: Keyword<typeof KEYWORD> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMaxProperties,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMaxProperties\n};\n\nfunction parseMaxProperties(node: SchemaNode) {\n const max = node.schema[KEYWORD];\n if (max == null) {\n return;\n }\n if (!isNumber(max)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: max,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof max}'`\n });\n }\n node[KEYWORD] = max;\n}\n\nfunction validateMaxProperties({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams<typeof KEYWORD>) {\n if (!isObject(data)) {\n return;\n }\n const maxProperties = node[KEYWORD];\n const propertyCount = Object.keys(data).length;\n if (maxProperties < propertyCount) {\n return node.createError(\"max-properties-error\", {\n maxProperties: maxProperties,\n length: propertyCount,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { isNumber, SchemaNode } from \"../types\";\n\nconst KEYWORD = \"minimum\";\n\nexport const minimumKeyword: Keyword<\"minimum\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMinimum,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMinimum\n};\n\nfunction parseMinimum(node: SchemaNode) {\n const min = node.schema[KEYWORD];\n if (min == null) {\n return;\n }\n if (!isNumber(min)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: min,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof min}'`\n });\n }\n node[KEYWORD] = min;\n}\n\nfunction validateMinimum({ node, data, pointer }: JsonSchemaValidatorParams<\"minimum\">) {\n if (!isNumber(data)) {\n return undefined;\n }\n const min = node[KEYWORD];\n if (min > data) {\n return node.createError(\"minimum-error\", {\n minimum: min,\n length: data,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n if (node.schema.exclusiveMinimum === true && node.schema.minimum === data) {\n return node.createError(\"minimum-error\", {\n minimum: min,\n length: data,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n return undefined;\n}\n","import { JsonSchemaValidatorParams, Keyword } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isNumber } from \"../types\";\n\nconst KEYWORD = \"minItems\";\n\nexport const minItemsKeyword: Keyword<\"minItems\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMinItems,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMinItems\n};\n\nfunction parseMinItems(node: SchemaNode) {\n const min = node.schema[KEYWORD];\n if (min == null) {\n return;\n }\n if (!isNumber(min)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: min,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof min}'`\n });\n }\n node[KEYWORD] = min;\n}\n\nfunction validateMinItems({ node, data, pointer }: JsonSchemaValidatorParams<\"minItems\">) {\n if (!Array.isArray(data)) {\n return;\n }\n const minItems = node[KEYWORD];\n if (minItems > data.length) {\n return node.createError(\"min-items-error\", {\n minItems: minItems,\n length: data.length,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import ucs2decode from \"../utils/punycode.ucs2decode\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isNumber } from \"../types\";\n\nconst KEYWORD = \"minLength\";\n\nexport const minLengthKeyword: Keyword<\"minLength\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMinLength,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMinLength\n};\n\nfunction parseMinLength(node: SchemaNode) {\n const min = node.schema[KEYWORD];\n if (min == null) {\n return;\n }\n if (!isNumber(min)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: min,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof min}'`\n });\n }\n node[KEYWORD] = min;\n}\n\nfunction validateMinLength({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams<\"minLength\">) {\n if (typeof data !== \"string\") {\n return;\n }\n const length = ucs2decode(data).length;\n const minLength = node[KEYWORD];\n if (minLength <= length) {\n return;\n }\n return node.createError(\"min-length-error\", {\n minLength,\n length,\n pointer,\n schema: node.schema,\n value: data\n });\n}\n","import { isObject } from \"../utils/isObject\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isNumber } from \"../types\";\n\nconst KEYWORD = \"minProperties\";\n\nexport const minPropertiesKeyword: Keyword<\"minProperties\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMinItems,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMinProperties\n};\n\nfunction parseMinItems(node: SchemaNode) {\n const min = node.schema[KEYWORD];\n if (min == null) {\n return;\n }\n if (!isNumber(min)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: min,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof min}'`\n });\n }\n node[KEYWORD] = min;\n}\n\nfunction validateMinProperties({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams<\"minProperties\">) {\n if (!isObject(data)) {\n return;\n }\n const propertyCount = Object.keys(data).length;\n if (node.schema.minProperties > propertyCount) {\n return node.createError(\"min-properties-error\", {\n minProperties: node.schema.minProperties,\n length: propertyCount,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","/**\n * returns the floating point precision of a decimal number or 0\n */\nexport function getPrecision(value: number): number {\n const string = `${value}`;\n if (string.includes(\"e-\")) {\n return parseInt(string.replace(/.*e-/, \"\"));\n }\n const index = string.indexOf(\".\");\n return index === -1 ? 0 : string.length - (index + 1);\n}\n","import { getPrecision } from \"../utils/getPrecision\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isNumber } from \"../types\";\n\nconst KEYWORD = \"multipleOf\";\n\nexport const multipleOfKeyword: Keyword<\"multipleOf\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseMultipleOf,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateMultipleOf\n};\n\nfunction parseMultipleOf(node: SchemaNode) {\n const multipleOf = node.schema[KEYWORD];\n if (multipleOf == null) {\n return;\n }\n if (!isNumber(multipleOf)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: multipleOf,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof multipleOf}'`\n });\n }\n node[KEYWORD] = multipleOf;\n}\n\nfunction validateMultipleOf({ node, data, pointer }: JsonSchemaValidatorParams<\"multipleOf\">) {\n if (typeof data !== \"number\") {\n return undefined;\n }\n const multipleOf = node[KEYWORD];\n const valuePrecision = getPrecision(data);\n const multiplePrecision = getPrecision(multipleOf);\n if (valuePrecision > multiplePrecision) {\n // value with higher precision then multipleOf-precision can never be multiple\n return node.createError(\"multiple-of-error\", {\n multipleOf,\n value: data,\n pointer,\n schema: node.schema\n });\n }\n\n const precision = Math.pow(10, multiplePrecision);\n const val = Math.round(data * precision);\n const multiple = Math.round(multipleOf * precision);\n if ((val % multiple) / precision !== 0) {\n return node.createError(\"multiple-of-error\", {\n multipleOf: multipleOf,\n value: data,\n pointer,\n schema: node.schema\n });\n }\n\n // maybe also check overflow\n // https://stackoverflow.com/questions/1815367/catch-and-compute-overflow-during-multiplication-of-two-large-integers\n return undefined;\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { validateNode } from \"../validateNode\";\n\nconst KEYWORD = \"not\";\n\nexport const notKeyword: Keyword<\"not\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseNot,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateNot\n};\n\nexport function parseNot(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n const not = schema[KEYWORD];\n if (not == null) {\n return;\n }\n if (!isJsonSchema(not) && !isBooleanSchema(not)) {\n return node.createError(\"schema-error\", {\n pointer: `${schemaLocation}/${KEYWORD}`,\n schema,\n value: not,\n message: `Keyword '${KEYWORD}' must be a valid JSON Schema - received '${typeof not}'`\n });\n }\n node[KEYWORD] = node.compileSchema(schema[KEYWORD], `${evaluationPath}/not`, `${schemaLocation}/not`);\n return node[KEYWORD].schemaValidation;\n}\n\nfunction validateNot({ node, data, pointer, path }: JsonSchemaValidatorParams<\"not\">) {\n const { schema } = node;\n // not has been tested in addValidate\n if (validateNode(node[KEYWORD]!, data, pointer, path).length === 0) {\n return node.createError(\"not-error\", { value: data, not: schema[KEYWORD], pointer, schema });\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport settings from \"../settings\";\n\nconst KEYWORD = \"pattern\";\nconst { REGEX_FLAGS } = settings;\n\nexport const patternKeyword: Keyword<\"pattern\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parsePattern,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validatePattern\n};\n\nfunction parsePattern(node: SchemaNode) {\n const pattern = node.schema[KEYWORD];\n if (pattern == null) {\n return;\n }\n if (typeof pattern !== \"string\") {\n return node.createError(\"schema-error\", {\n pointer: node.schemaLocation,\n schema: node.schema,\n value: pattern,\n message: `Keyword 'pattern' must be a string - received '${typeof pattern}'`\n });\n }\n try {\n node[KEYWORD] = new RegExp(pattern, node.schema.regexFlags ?? REGEX_FLAGS);\n } catch (e) {\n return node.createError(\"schema-error\", {\n pointer: node.schemaLocation,\n schema: node.schema,\n value: pattern,\n message: (e as Error).message\n });\n }\n}\n\nfunction validatePattern({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams<\"pattern\">) {\n if (typeof data !== \"string\") {\n return;\n }\n if (node.pattern.test(data) === false) {\n const { schema } = node;\n return node.createError(\"pattern-error\", {\n pattern: schema.pattern,\n description: schema.patternExample || schema.pattern,\n received: data,\n schema,\n value: data,\n pointer\n });\n }\n}\n","import { mergeSchema } from \"../utils/mergeSchema\";\nimport { JsonSchema, SchemaNode } from \"../types\";\nimport { isObject } from \"../utils/isObject\";\nimport {\n Keyword,\n JsonSchemaReducerParams,\n JsonSchemaResolverParams,\n JsonSchemaValidatorParams,\n ValidationReturnType,\n ValidationAnnotation\n} from \"../Keyword\";\nimport { getValue } from \"../utils/getValue\";\nimport { validateNode } from \"../validateNode\";\nimport settings from \"../settings\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst { REGEX_FLAGS } = settings;\n\nexport const patternPropertiesKeyword: Keyword = {\n id: \"patternProperties\",\n keyword: \"patternProperties\",\n parse: parsePatternProperties,\n addReduce: (node) => node.patternProperties != null,\n reduce: reducePatternProperties,\n addResolve: (node) => node.patternProperties != null,\n resolve: patternPropertyResolver,\n addValidate: (node) => node.patternProperties != null,\n validate: validatePatternProperties\n};\n\nexport function parsePatternProperties(node: SchemaNode) {\n const { schema } = node;\n if (!isObject(schema.patternProperties)) {\n return;\n }\n const patterns = Object.keys(schema.patternProperties);\n if (patterns.length === 0) {\n return;\n }\n\n node.patternProperties = patterns.map((pattern) => ({\n name: pattern,\n pattern: new RegExp(pattern, schema.regexFlags ?? REGEX_FLAGS),\n node: node.compileSchema(\n schema.patternProperties[pattern],\n `${node.evaluationPath}/patternProperties/${pattern}`,\n `${node.schemaLocation}/patternProperties/${pattern}`\n )\n }));\n\n return collectValidationErrors([], ...node.patternProperties.map(({ node }) => node));\n}\n\nfunction patternPropertyResolver({ node, key }: JsonSchemaResolverParams) {\n return node.patternProperties?.find(({ pattern }) => pattern.test(`${key}`))?.node;\n}\n\nfunction reducePatternProperties({ node, data, key }: JsonSchemaReducerParams) {\n const { patternProperties } = node;\n if (patternProperties == null) {\n return;\n }\n\n let mergedSchema: JsonSchema | undefined;\n const dataProperties = Object.keys(data ?? {});\n if (key) {\n dataProperties.push(`${key}`);\n }\n\n let dynamicId = `${node.schemaLocation}(`;\n dataProperties.push(...Object.keys(node.schema.properties ?? {}));\n dataProperties.forEach((propertyName, index, list) => {\n if (list.indexOf(propertyName) !== index) {\n // duplicate\n return;\n }\n // build schema of property\n let propertySchema = node.schema.properties?.[propertyName] ?? {};\n const matchingPatterns = patternProperties.filter((property) => property.pattern.test(propertyName));\n matchingPatterns.forEach((pp) => (propertySchema = mergeSchema(propertySchema, pp.node.schema)));\n if (matchingPatterns.length > 0) {\n mergedSchema = mergedSchema ?? { properties: {} };\n mergedSchema.properties[propertyName] = propertySchema;\n dynamicId += `${matchingPatterns.map(({ name }) => `patternProperties/${name}`).join(\",\")}`;\n }\n });\n\n if (mergedSchema == null) {\n return node;\n }\n\n mergedSchema = mergeSchema(node.schema, mergedSchema, \"patternProperties\");\n return node.compileSchema(mergedSchema, node.evaluationPath, node.schemaLocation, `${dynamicId})`);\n}\n\nfunction validatePatternProperties({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n if (!isObject(data)) {\n return;\n }\n const { schema, patternProperties } = node;\n const properties = schema.properties || {};\n const patterns = Object.keys(schema.patternProperties).join(\",\");\n const errors: ValidationReturnType = [];\n const keys = Object.keys(data);\n\n keys.forEach((key) => {\n const value = getValue(data, key);\n // patternProperties was tested in addValidate\n const matchingPatterns = patternProperties!.filter((property) => property.pattern.test(key));\n matchingPatterns.forEach(({ node }) => errors.push(...validateNode(node, value, `${pointer}/${key}`, path)));\n\n if (properties[key]) {\n return;\n }\n\n if (matchingPatterns.length === 0 && schema.additionalProperties === false) {\n // this is an arrangement with additionalProperties\n errors.push(\n node.createError(\"no-additional-properties-error\", {\n key,\n pointer: `${pointer}/${key}`,\n schema,\n value,\n patterns\n })\n );\n }\n });\n\n return errors;\n}\n","import { getValue } from \"../utils/getValue\";\nimport { SchemaNode } from \"../types\";\nimport {\n Keyword,\n JsonSchemaResolverParams,\n JsonSchemaValidatorParams,\n ValidationReturnType,\n ValidationAnnotation\n} from \"../Keyword\";\nimport { isObject } from \"../utils/isObject\";\nimport { validateNode } from \"../validateNode\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nexport const propertiesKeyword: Keyword = {\n id: \"property\",\n keyword: \"properties\",\n parse: parseProperties,\n addResolve: (node: SchemaNode) => node.properties != null,\n resolve: propertyResolver,\n addValidate: (node: SchemaNode) => node.properties != null,\n validate: validateProperties\n};\n\nfunction propertyResolver({ node, key }: JsonSchemaResolverParams) {\n return node.properties?.[key];\n}\n\nexport function parseProperties(node: SchemaNode) {\n const { schema, evaluationPath, schemaLocation } = node;\n if (schema.properties == null) {\n return;\n }\n\n if (schema.properties && !isObject(schema.properties)) {\n return node.createError(\"schema-error\", {\n pointer: schemaLocation,\n schema,\n value: undefined,\n message: \"keyword `properties` must be of type `object`\"\n });\n }\n\n const errors: ValidationAnnotation[] = [];\n const parsedProperties: Record<string, SchemaNode> = {};\n Object.keys(schema.properties).forEach((propertyName) => {\n const propertyNode = node.compileSchema(\n schema.properties[propertyName],\n `${evaluationPath}/properties/${propertyName}`,\n `${schemaLocation}/properties/${propertyName}`\n );\n parsedProperties[propertyName] = propertyNode;\n collectValidationErrors(errors, parsedProperties[propertyName]);\n });\n node.properties = parsedProperties;\n\n return errors;\n}\n\nfunction validateProperties({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n if (!isObject(data)) {\n return;\n }\n // move validation through properties\n const errors: ValidationReturnType = [];\n const properties = node.properties ?? {};\n Object.keys(data).forEach((propertyName) => {\n const value = getValue(data, propertyName);\n const propertyNode = properties[propertyName];\n\n if (propertyNode == null || value === void 0) {\n return;\n }\n\n const result = validateNode(propertyNode, value, `${pointer}/${propertyName}`, path);\n errors.push(...result);\n });\n return errors;\n}\n","import { isBooleanSchema, isJsonSchema, JsonError } from \"../types\";\nimport { isObject } from \"../utils/isObject\";\nimport { SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { validateNode } from \"../validateNode\";\n\nconst KEYWORD = \"propertyNames\";\n\nexport const propertyNamesKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parsePropertyNames,\n addValidate: (node) => node.schema[KEYWORD] != null,\n validate: validatePropertyNames\n};\n\nexport function parsePropertyNames(node: SchemaNode) {\n const propertyNames = node.schema[KEYWORD];\n if (propertyNames == null) {\n return;\n }\n if (!(isJsonSchema(propertyNames) || isBooleanSchema(propertyNames))) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: propertyNames,\n message: `Keyword '${KEYWORD}' must be a valid JSON Schema - received '${typeof propertyNames}'`\n });\n }\n if (isBooleanSchema(propertyNames)) {\n return;\n }\n node.propertyNames = node.compileSchema(\n propertyNames,\n `${node.evaluationPath}/propertyNames`,\n `${node.schemaLocation}/propertyNames`\n );\n return node.propertyNames.schemaValidation;\n}\n\nfunction validatePropertyNames({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n if (!isObject(data)) {\n return undefined;\n }\n\n // bool schema\n if (schema.propertyNames === false) {\n // empty objects are valid\n if (Object.keys(data).length === 0) {\n return undefined;\n }\n return node.createError(\"invalid-property-name-error\", {\n property: Object.keys(data),\n pointer,\n value: data,\n schema\n });\n }\n\n if (schema[KEYWORD] === true) {\n return undefined;\n }\n\n const propertyNames = node[KEYWORD];\n if (!isObject(propertyNames)) {\n // ignore invalid schema\n return undefined;\n }\n\n const errors: JsonError[] = [];\n const properties = Object.keys(data);\n properties.forEach((prop) => {\n const validationResult = validateNode(propertyNames, prop, `${pointer}/${prop}`, path);\n if (validationResult.length > 0) {\n errors.push(\n node.createError(\"invalid-property-name-error\", {\n property: prop,\n pointer,\n validationError: validationResult[0],\n value: data[prop],\n schema\n })\n );\n }\n });\n\n return errors;\n}\n","import { isObject } from \"../utils/isObject\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { hasProperty } from \"../utils/hasProperty\";\nimport { SchemaNode } from \"../SchemaNode\";\nimport { isListOfStrings } from \"../utils/isListOfStrings\";\n\nconst KEYWORD = \"required\";\n\nexport const requiredKeyword: Keyword<\"required\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseRequired,\n addValidate: (node) => node.required != null,\n validate: validateRequired\n};\n\nfunction parseRequired(node: SchemaNode) {\n const required = node.schema[KEYWORD];\n if (required == null) {\n return;\n }\n\n if (!isListOfStrings(required)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: required,\n message: `Keyword '${KEYWORD}' must be a string[]`\n });\n }\n\n node.required = required;\n}\n\nfunction validateRequired({ node, data, pointer = \"#\" }: JsonSchemaValidatorParams<\"required\">) {\n const { required } = node;\n if (!isObject(data)) {\n return undefined;\n }\n return required.map((property: string) => {\n if (!hasProperty(data, property)) {\n return node.createError(\"required-property-error\", {\n key: property,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n return undefined;\n });\n}\n","import { Draft } from \"../types\";\n\nexport function copyDraft(draft: Draft) {\n return {\n ...draft,\n keywords: [...draft.keywords.map((f) => ({ ...f }))]\n };\n}\n","import type { JsonSchemaValidator, Keyword } from \"./Keyword\";\nimport { copyDraft } from \"./utils/copyDraft\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { toDataNodes } from \"./methods/toDataNodes\";\nimport { ErrorConfig } from \"./types\";\nimport { getChildSelection } from \"./methods/getChildSelection\";\nimport { getData } from \"./methods/getData\";\n\nexport type DraftVersion = \"draft-04\" | \"draft-06\" | \"draft-07\" | \"draft-2019-09\" | \"draft-2020-12\" | \"latest\";\n\nexport interface Draft {\n /** test-string if draft can be used with $schema-url */\n $schemaRegEx: string;\n /** draft-version of this draft, e.g. draft-2020-12 */\n version: DraftVersion;\n /** supported keywords and implementation */\n keywords: Keyword[];\n /** draft-dependent methods */\n methods: {\n createSchema: typeof createSchema;\n getChildSelection: typeof getChildSelection;\n getData: typeof getData;\n toDataNodes: typeof toDataNodes;\n };\n /** meta-schema url associated with this draft */\n $schema?: string;\n /** draft errors (this can still be global) */\n errors: ErrorConfig;\n formats: Record<string, JsonSchemaValidator>;\n}\n\ntype PartialDraft = Partial<Omit<Draft, \"errors\" | \"formats\">> & {\n errors?: Partial<Draft[\"errors\"]>;\n formats?: Partial<Draft[\"formats\"]>;\n};\n\nexport function extendDraft(draft: Draft, extension: PartialDraft) {\n const { keywords } = addKeywords(draft, ...(extension.keywords ?? []));\n const errors = { ...draft.errors, ...(extension.errors ?? {}) } as Draft[\"errors\"];\n const formats = { ...draft.formats, ...((extension.formats ?? {}) as Draft[\"formats\"]) };\n return sanitizeKeywords({\n ...draft,\n ...extension,\n formats,\n keywords,\n errors\n });\n}\n\nexport function addKeywords(draft: Draft, ...keywords: Keyword[]): Draft {\n const customizedDraft = copyDraft(draft);\n keywords.forEach((keyword) => addKeyword(customizedDraft, keyword));\n return customizedDraft;\n}\n\n/**\n * Create a new draft adding or replacing a keyword based on keyword-property\n */\nfunction addKeyword(draft: Draft, keyword: Keyword) {\n const index = draft.keywords.findIndex((f) => f.keyword === keyword.keyword);\n if (index === -1) {\n draft.keywords.push(keyword);\n } else {\n draft.keywords[index] = keyword;\n }\n}\n\nexport function sanitizeKeywords(draft: Draft) {\n draft.keywords?.forEach((keyword) => {\n const logKeyword = () => keyword.keyword;\n if (keyword.validate) {\n keyword.validate.toJSON = logKeyword;\n keyword.validate.order = keyword.order ?? 0;\n }\n if (keyword.reduce) {\n keyword.reduce.toJSON = logKeyword;\n keyword.reduce.order = keyword.order ?? 0;\n }\n if (keyword.resolve) {\n keyword.resolve.toJSON = logKeyword;\n keyword.resolve.order = keyword.order ?? 0;\n }\n });\n draft.keywords?.sort((a, b) => (b.order ?? 0) - (a.order ?? 0));\n return draft;\n}\n","import { getValue } from \"../utils/getValue\";\nimport { isObject } from \"../utils/isObject\";\nimport { SchemaNode } from \"../types\";\n\nexport type DataNode = { node: SchemaNode; value: unknown; pointer: string };\n\nexport function toDataNodes(node: SchemaNode, data: unknown, pointer = \"#\", dataNodes: DataNode[] = []) {\n const currentNode = node.resolveRef() ?? node;\n dataNodes.push({\n node: currentNode,\n value: data,\n pointer\n });\n\n if (isObject(data)) {\n Object.keys(data).forEach((key) => {\n const { node: nextNode } = currentNode.getNodeChild(key, data);\n if (nextNode) {\n toDataNodes(nextNode, getValue(data, key), `${pointer}/${key}`, dataNodes);\n }\n });\n } else if (Array.isArray(data)) {\n data.forEach((next: unknown, key: number) => {\n const { node: nextNode } = currentNode.getNodeChild(key, data);\n if (nextNode) {\n toDataNodes(nextNode, getValue(data, key), `${pointer}/${key}`, dataNodes);\n }\n });\n }\n\n return dataNodes;\n}\n","import { getTypeOf, JSType } from \"../utils/getTypeOf\";\nimport { SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams } from \"../Keyword\";\n\nconst KEYWORD = \"type\";\nconst validTyes = [\"null\", \"boolean\", \"number\", \"integer\", \"string\", \"object\", \"array\"];\n\nexport const typeKeyword: Keyword<\"type\"> = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseType,\n addReduce: (node) => Array.isArray(node.type),\n reduce: reduceType,\n addValidate: (node) => node.type != null,\n validate: validateType\n};\n\nfunction parseType(node: SchemaNode) {\n const type = node.schema[KEYWORD];\n if (type == null) {\n return;\n }\n if (typeof type !== \"string\" && !Array.isArray(type)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: type,\n message: `Keyword '${KEYWORD}' must be a string or a string[] - received ${typeof type}`\n });\n }\n if (typeof type === \"string\" && !validTyes.includes(type)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: type,\n message: `Keyword '${KEYWORD}' is not a valid JSON Schema type - received '${type}'. Expected one of ${validTyes.join(\", \")}`\n });\n }\n\n if (Array.isArray(type)) {\n const invalidTypeIndex = type.findIndex((t) => !validTyes.includes(t));\n if (invalidTypeIndex !== -1) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}/${invalidTypeIndex}`,\n schema: node.schema,\n value: type[invalidTypeIndex],\n message: `Keyword '${KEYWORD}' contains an invalid JSON Schema type: '${type[invalidTypeIndex]}'`\n });\n }\n }\n\n node[KEYWORD] = type;\n}\n\nfunction reduceType({ node, pointer, data }: JsonSchemaReducerParams): undefined | SchemaNode {\n const dataType = getJsonSchemaType(data, node.type!);\n if (dataType !== \"undefined\" && Array.isArray(node.schema.type) && node.schema.type.includes(dataType)) {\n return node.compileSchema({ ...node.schema, pointer, type: dataType }, node.evaluationPath);\n }\n return undefined;\n}\n\nfunction getJsonSchemaType(value: unknown, expectedType: string | string[]): JSType | \"integer\" {\n const jsType = getTypeOf(value);\n if (\n jsType === \"number\" &&\n (expectedType === \"integer\" || (Array.isArray(expectedType) && expectedType.includes(\"integer\")))\n ) {\n return Number.isInteger(value) || isNaN(value as number) ? \"integer\" : \"number\";\n }\n return jsType;\n}\n\nfunction validateType({ node, data, pointer }: JsonSchemaValidatorParams<\"type\">) {\n const type = node[KEYWORD];\n const dataType = getJsonSchemaType(data, type);\n if (data === undefined || type === dataType || (Array.isArray(type) && type.includes(dataType))) {\n return;\n }\n\n return node.createError(\"type-error\", {\n value: data,\n received: dataType,\n expected: type,\n schema: node.schema,\n pointer\n });\n}\n","import { JsonError, SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport deepEqual from \"fast-deep-equal\";\n\nconst KEYWORD = \"uniqueItems\";\n\nexport const uniqueItemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseUniqueItems,\n addValidate: ({ schema }) => schema[KEYWORD] === true,\n validate: validateUniqueItems\n};\n\nfunction parseUniqueItems(node: SchemaNode) {\n const uniqueItems = node.schema[KEYWORD];\n if (uniqueItems == null || uniqueItems === false) {\n return;\n }\n if (typeof uniqueItems !== \"boolean\") {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: uniqueItems,\n message: `Keyword '${KEYWORD}' must be a boolean - received ${typeof uniqueItems}`\n });\n }\n node.uniqueItems = true;\n}\n\nfunction validateUniqueItems({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (!Array.isArray(data)) {\n return undefined;\n }\n const { schema } = node;\n const duplicates: number[] = [];\n const errors: JsonError[] = [];\n data.forEach((item, index) => {\n for (let i = index + 1; i < data.length; i += 1) {\n if (deepEqual(item, data[i]) && !duplicates.includes(i)) {\n errors.push(\n node.createError(\"unique-items-error\", {\n pointer: `${pointer}/${i}`,\n duplicatePointer: `${pointer}/${index}`,\n arrayPointer: pointer,\n value: JSON.stringify(item),\n schema\n })\n );\n duplicates.push(i);\n }\n }\n });\n\n return errors;\n}\n","import { $defsKeyword } from \"./keywords/$defs\";\nimport { $refKeyword } from \"./draft04/keywords/$ref\";\nimport { additionalItemsKeyword } from \"./draft2019-09/keywords/additionalItems\";\nimport { additionalPropertiesKeyword } from \"./keywords/additionalProperties\";\nimport { allOfKeyword } from \"./keywords/allOf\";\nimport { anyOfKeyword } from \"./keywords/anyOf\";\nimport { containsKeyword } from \"./keywords/contains\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { dependenciesKeyword } from \"./keywords/dependencies\";\nimport { deprecatedKeyword } from \"./keywords/deprecated\";\nimport { enumKeyword } from \"./keywords/enum\";\nimport { errors } from \"./errors/errors\";\nimport { exclusiveMaximumKeyword } from \"./draft04/keywords/exclusiveMaximum\";\nimport { exclusiveMinimumKeyword } from \"./draft04/keywords/exclusiveMinimum\";\nimport { formatKeyword } from \"./keywords/format\";\nimport { formats } from \"./formats/formats\";\nimport { getChildSelection } from \"./draft2019-09/methods/getChildSelection\";\nimport { getData } from \"./draft2019-09/methods/getData\";\nimport { itemsKeyword } from \"./draft2019-09/keywords/items\";\nimport { maximumKeyword } from \"./keywords/maximum\";\nimport { maxItemsKeyword } from \"./keywords/maxItems\";\nimport { maxLengthKeyword } from \"./keywords/maxLength\";\nimport { maxPropertiesKeyword } from \"./keywords/maxProperties\";\nimport { minimumKeyword } from \"./keywords/minimum\";\nimport { minItemsKeyword } from \"./keywords/minItems\";\nimport { minLengthKeyword } from \"./keywords/minLength\";\nimport { minPropertiesKeyword } from \"./keywords/minProperties\";\nimport { multipleOfKeyword } from \"./keywords/multipleOf\";\nimport { notKeyword } from \"./keywords/not\";\nimport { oneOfKeyword } from \"./keywords/oneOf\";\nimport { patternKeyword } from \"./keywords/pattern\";\nimport { patternPropertiesKeyword } from \"./keywords/patternProperties\";\nimport { propertiesKeyword } from \"./keywords/properties\";\nimport { propertyNamesKeyword } from \"./keywords/propertyNames\";\nimport { requiredKeyword } from \"./keywords/required\";\nimport { sanitizeKeywords } from \"./Draft\";\nimport { toDataNodes } from \"./methods/toDataNodes\";\nimport { typeKeyword } from \"./keywords/type\";\nimport { uniqueItemsKeyword } from \"./keywords/uniqueItems\";\n\n/**\n * @draft-04\n *\n * remove from draft06\n * - booleans as schemas allowable anywhere, not just \"additionalProperties\" and \"additionalItems\"\n * - propertyNames\n * - contains\n * - const\n * - format: uri-reference\n * - format: uri-template\n * - format: json-pointer\n * - examples: array of examples with no validation effect; the value of \"default\" is usable as an example without repeating it under this keyword\n *\n * revert from draft06\n * - $id replaces id\n * - $ref only allowed where a schema is expected\n * - \"exclusiveMinimum\" and exclusiveMaximum changed from a boolean to a number to be consistent with the principle of keyword independence\n * - type integer any number with a zero fractional part; 1.0 is now a valid \"integer\" type in draft-06 and later\n * - required allows an empty array\n * - dependencies allows an empty array for property dependencies\n */\nexport const draft04 = sanitizeKeywords({\n version: \"draft-04\",\n $schemaRegEx: \"draft-?0?4\",\n $schema: \"http://json-schema.org/draft-04/schema#\",\n errors,\n formats,\n methods: {\n createSchema,\n getData,\n getChildSelection,\n toDataNodes\n },\n keywords: [\n $refKeyword,\n allOfKeyword,\n anyOfKeyword,\n containsKeyword,\n $defsKeyword,\n dependenciesKeyword, // optional support for old draft-version\n deprecatedKeyword,\n enumKeyword,\n exclusiveMaximumKeyword,\n exclusiveMinimumKeyword,\n formatKeyword,\n itemsKeyword,\n maximumKeyword,\n maxItemsKeyword,\n maxLengthKeyword,\n maxPropertiesKeyword,\n minimumKeyword,\n minItemsKeyword,\n minLengthKeyword,\n minPropertiesKeyword,\n multipleOfKeyword,\n notKeyword,\n patternPropertiesKeyword,\n patternKeyword,\n propertiesKeyword,\n propertyNamesKeyword,\n requiredKeyword,\n typeKeyword,\n uniqueItemsKeyword,\n oneOfKeyword,\n additionalItemsKeyword,\n additionalPropertiesKeyword\n ]\n});\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport equal from \"fast-deep-equal\";\n\nexport const constKeyword: Keyword = {\n id: \"const\",\n keyword: \"const\",\n addValidate: ({ schema }) => schema.const !== undefined,\n validate: validateConst\n};\n\nfunction validateConst({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (!equal(data, node.schema.const)) {\n return [\n node.createError(\"const-error\", { pointer, schema: node.schema, value: data, expected: node.schema.const })\n ];\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\n\nconst KEYWORD = \"exclusiveMaximum\";\n\nexport const exclusiveMaximumKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseExclusiveMaximum,\n addValidate: ({ schema }) => schema.exclusiveMaximum != null && !isNaN(parseInt(schema.exclusiveMaximum)),\n validate: validateExclusiveMaximum\n};\n\nfunction parseExclusiveMaximum(node: SchemaNode) {\n const max = node.schema[KEYWORD];\n if (max == null) {\n return;\n }\n if (typeof max !== \"number\") {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: max,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof max}'`\n });\n }\n}\n\nfunction validateExclusiveMaximum({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (typeof data !== \"number\") {\n return undefined;\n }\n if (node.schema.exclusiveMaximum <= data) {\n return node.createError(\"exclusive-maximum-error\", {\n maximum: node.schema.exclusiveMaximum,\n length: data,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import { Keyword, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { SchemaNode } from \"../SchemaNode\";\n\nconst KEYWORD = \"exclusiveMinimum\";\n\nexport const exclusiveMinimumKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseExclusiveMinimum,\n addValidate: ({ schema }) => schema[KEYWORD] != null && !isNaN(parseInt(schema[KEYWORD])),\n validate: validateExclusiveMinimum\n};\n\nfunction parseExclusiveMinimum(node: SchemaNode) {\n const min = node.schema[KEYWORD];\n if (min == null) {\n return;\n }\n if (typeof min !== \"number\") {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: min,\n message: `Keyword '${KEYWORD}' must be a number - received '${typeof min}'`\n });\n }\n}\n\nfunction validateExclusiveMinimum({ node, data, pointer }: JsonSchemaValidatorParams) {\n if (typeof data !== \"number\") {\n return undefined;\n }\n if (node.schema.exclusiveMinimum >= data) {\n return node.createError(\"exclusive-minimum-error\", {\n minimum: node.schema.exclusiveMinimum,\n length: data,\n pointer,\n schema: node.schema,\n value: data\n });\n }\n}\n","import { $defsKeyword } from \"./keywords/$defs\";\nimport { $refKeyword } from \"./draft06/keywords/$ref\";\nimport { additionalItemsKeyword } from \"./draft2019-09/keywords/additionalItems\";\nimport { additionalPropertiesKeyword } from \"./keywords/additionalProperties\";\nimport { allOfKeyword } from \"./keywords/allOf\";\nimport { anyOfKeyword } from \"./keywords/anyOf\";\nimport { constKeyword } from \"./keywords/const\";\nimport { containsKeyword } from \"./keywords/contains\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { dependenciesKeyword } from \"./keywords/dependencies\";\nimport { deprecatedKeyword } from \"./keywords/deprecated\";\nimport { enumKeyword } from \"./keywords/enum\";\nimport { errors } from \"./errors/errors\";\nimport { exclusiveMaximumKeyword } from \"./keywords/exclusiveMaximum\";\nimport { exclusiveMinimumKeyword } from \"./keywords/exclusiveMinimum\";\nimport { formatKeyword } from \"./keywords/format\";\nimport { formats } from \"./formats/formats\";\nimport { getChildSelection } from \"./draft2019-09/methods/getChildSelection\";\nimport { getData } from \"./draft2019-09/methods/getData\";\nimport { itemsKeyword } from \"./draft2019-09/keywords/items\";\nimport { maximumKeyword } from \"./keywords/maximum\";\nimport { maxItemsKeyword } from \"./keywords/maxItems\";\nimport { maxLengthKeyword } from \"./keywords/maxLength\";\nimport { maxPropertiesKeyword } from \"./keywords/maxProperties\";\nimport { minimumKeyword } from \"./keywords/minimum\";\nimport { minItemsKeyword } from \"./keywords/minItems\";\nimport { minLengthKeyword } from \"./keywords/minLength\";\nimport { minPropertiesKeyword } from \"./keywords/minProperties\";\nimport { multipleOfKeyword } from \"./keywords/multipleOf\";\nimport { notKeyword } from \"./keywords/not\";\nimport { oneOfKeyword } from \"./keywords/oneOf\";\nimport { patternKeyword } from \"./keywords/pattern\";\nimport { patternPropertiesKeyword } from \"./keywords/patternProperties\";\nimport { propertiesKeyword } from \"./keywords/properties\";\nimport { propertyNamesKeyword } from \"./keywords/propertyNames\";\nimport { requiredKeyword } from \"./keywords/required\";\nimport { sanitizeKeywords } from \"./Draft\";\nimport { toDataNodes } from \"./methods/toDataNodes\";\nimport { typeKeyword } from \"./keywords/type\";\nimport { uniqueItemsKeyword } from \"./keywords/uniqueItems\";\n\n/**\n * @draft-06 https://json-schema.org/draft-06/json-schema-release-notes\n *\n * new\n * - booleans as schemas allowable anywhere, not just \"additionalProperties\" and \"additionalItems\"\n * - propertyNames\n * - contains\n * - const\n * - format: uri-reference\n * - format: uri-template\n * - format: json-pointer\n * - examples: array of examples with no validation effect; the value of \"default\" is usable as an example without repeating it under this keyword\n *\n * changes\n * - $id replaces id\n * - $ref only allowed where a schema is expected\n * - \"exclusiveMinimum\" and exclusiveMaximum changed from a boolean to a number to be consistent with the principle of keyword independence\n * - type integer any number with a zero fractional part; 1.0 is now a valid \"integer\" type in draft-06 and later\n * - required allows an empty array\n * - dependencies allows an empty array for property dependencies\n */\nexport const draft06 = sanitizeKeywords({\n version: \"draft-06\",\n $schemaRegEx: \"draft-?0?6\",\n $schema: \"http://json-schema.org/draft-06/schema#\",\n errors,\n formats,\n methods: {\n createSchema,\n getData,\n getChildSelection,\n toDataNodes\n },\n keywords: [\n $refKeyword,\n allOfKeyword,\n anyOfKeyword,\n constKeyword,\n containsKeyword,\n $defsKeyword,\n dependenciesKeyword, // optional support for old draft-version\n deprecatedKeyword,\n enumKeyword,\n exclusiveMaximumKeyword,\n exclusiveMinimumKeyword,\n formatKeyword,\n itemsKeyword,\n maximumKeyword,\n maxItemsKeyword,\n maxLengthKeyword,\n maxPropertiesKeyword,\n minimumKeyword,\n minItemsKeyword,\n minLengthKeyword,\n minPropertiesKeyword,\n multipleOfKeyword,\n notKeyword,\n patternPropertiesKeyword,\n patternKeyword,\n propertiesKeyword,\n propertyNamesKeyword,\n requiredKeyword,\n typeKeyword,\n uniqueItemsKeyword,\n oneOfKeyword,\n additionalItemsKeyword,\n additionalPropertiesKeyword\n ]\n});\n","import { mergeSchema } from \"../utils/mergeSchema\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams, ValidationAnnotation } from \"../Keyword\";\nimport { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { validateNode } from \"../validateNode\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nexport const ifKeyword: Keyword = {\n id: \"if-then-else\",\n keyword: \"if\",\n parse: parseIfThenElse,\n addReduce: (node: SchemaNode) => node.if != null && (node.then != null || node.else != null),\n reduce: reduceIf,\n addValidate: (node) => node.if != null,\n validate: validateIfThenElse\n};\n\nexport function parseIfThenElse(node: SchemaNode) {\n const { schema, evaluationPath } = node;\n const errors: ValidationAnnotation[] = [];\n if (schema.if != null) {\n if (isJsonSchema(schema.if) || isBooleanSchema(schema.if)) {\n node.if = node.compileSchema(schema.if, `${evaluationPath}/if`);\n collectValidationErrors(errors, node.if);\n } else {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/if`,\n schema: node.schema,\n value: schema.if,\n message: `Keyword 'if' must be valid JSON Schema - received '${typeof schema.if}'`\n })\n );\n }\n }\n if (schema.then != null) {\n if (isJsonSchema(schema.then) || isBooleanSchema(schema.then)) {\n node.then = node.compileSchema(schema.then, `${evaluationPath}/then`);\n collectValidationErrors(errors, node.then);\n } else {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/then`,\n schema: node.schema,\n value: schema.then,\n message: `Keyword 'then' must be valid JSON Schema - received '${typeof schema.then}'`\n })\n );\n }\n }\n if (schema.else != null) {\n if (isJsonSchema(schema.else) || isBooleanSchema(schema.else)) {\n node.else = node.compileSchema(schema.else, `${evaluationPath}/else`);\n collectValidationErrors(errors, node.else);\n } else {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/else`,\n schema: node.schema,\n value: schema.else,\n message: `Keyword 'else' must be valid JSON Schema - received '${typeof schema.else}'`\n })\n );\n }\n }\n return errors;\n}\n\nfunction reduceIf({ node, data, pointer, path }: JsonSchemaReducerParams) {\n // @todo issue with mergeNode (node.if == null)\n if (data === undefined || node.if == null) {\n return undefined;\n }\n\n if (validateNode(node.if, data, pointer, [...(path ?? [])]).length === 0) {\n if (node.then) {\n // reduce creates a new node\n const { node: schemaNode } = node.then.reduceNode(data);\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\").replace(/^#/, \"\") ?? \"\";\n const dynamicId = nestedDynamicId === \"\" ? `(then)` : nestedDynamicId;\n\n const schema = mergeSchema(node.then.schema, schemaNode.schema, \"if\", \"then\", \"else\");\n return node.compileSchema(\n schema,\n node.then.evaluationPath,\n node.schemaLocation,\n `${node.schemaLocation}${dynamicId}`\n );\n }\n }\n } else if (node.else) {\n const { node: schemaNode } = node.else.reduceNode(data);\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const dynamicId = nestedDynamicId === \"\" ? `(else)` : nestedDynamicId;\n\n const schema = mergeSchema(node.else.schema, schemaNode.schema, \"if\", \"then\", \"else\");\n return node.compileSchema(\n schema,\n node.else.evaluationPath,\n node.schemaLocation,\n `${node.schemaLocation}${dynamicId}`\n );\n }\n }\n return undefined;\n}\n\nfunction validateIfThenElse({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n // @todo issue with mergeNode\n if (node.if == null) {\n return;\n }\n if (validateNode(node.if, data, pointer, [...(path ?? [])]).length === 0) {\n if (node.then) {\n return validateNode(node.then, data, pointer, path);\n }\n } else if (node.else) {\n return validateNode(node.else, data, pointer, path);\n }\n}\n","import { $defsKeyword } from \"./keywords/$defs\";\nimport { $refKeyword } from \"./draft06/keywords/$ref\";\nimport { additionalItemsKeyword } from \"./draft2019-09/keywords/additionalItems\";\nimport { additionalPropertiesKeyword } from \"./keywords/additionalProperties\";\nimport { allOfKeyword } from \"./keywords/allOf\";\nimport { anyOfKeyword } from \"./keywords/anyOf\";\nimport { constKeyword } from \"./keywords/const\";\nimport { containsKeyword } from \"./keywords/contains\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { dependenciesKeyword } from \"./keywords/dependencies\";\nimport { deprecatedKeyword } from \"./keywords/deprecated\";\nimport { enumKeyword } from \"./keywords/enum\";\nimport { errors } from \"./errors/errors\";\nimport { exclusiveMaximumKeyword } from \"./keywords/exclusiveMaximum\";\nimport { exclusiveMinimumKeyword } from \"./keywords/exclusiveMinimum\";\nimport { formatKeyword } from \"./keywords/format\";\nimport { formats } from \"./formats/formats\";\nimport { getChildSelection } from \"./draft2019-09/methods/getChildSelection\";\nimport { getData } from \"./draft2019-09/methods/getData\";\nimport { ifKeyword } from \"./keywords/ifthenelse\";\nimport { itemsKeyword } from \"./draft2019-09/keywords/items\";\nimport { maximumKeyword } from \"./keywords/maximum\";\nimport { maxItemsKeyword } from \"./keywords/maxItems\";\nimport { maxLengthKeyword } from \"./keywords/maxLength\";\nimport { maxPropertiesKeyword } from \"./keywords/maxProperties\";\nimport { minimumKeyword } from \"./keywords/minimum\";\nimport { minItemsKeyword } from \"./keywords/minItems\";\nimport { minLengthKeyword } from \"./keywords/minLength\";\nimport { minPropertiesKeyword } from \"./keywords/minProperties\";\nimport { multipleOfKeyword } from \"./keywords/multipleOf\";\nimport { notKeyword } from \"./keywords/not\";\nimport { oneOfKeyword } from \"./keywords/oneOf\";\nimport { patternKeyword } from \"./keywords/pattern\";\nimport { patternPropertiesKeyword } from \"./keywords/patternProperties\";\nimport { propertiesKeyword } from \"./keywords/properties\";\nimport { propertyNamesKeyword } from \"./keywords/propertyNames\";\nimport { requiredKeyword } from \"./keywords/required\";\nimport { sanitizeKeywords } from \"./Draft\";\nimport { toDataNodes } from \"./methods/toDataNodes\";\nimport { typeKeyword } from \"./keywords/type\";\nimport { uniqueItemsKeyword } from \"./keywords/uniqueItems\";\n\n/**\n * @draft-07 https://json-schema.org/draft-07/json-schema-release-notes\n *\n * new\n * - \"$comment\"\n * - \"if\", \"then\", \"else\"\n * - \"readOnly\"\n * - \"writeOnly\"\n * - \"contentMediaType\"\n * - \"contentEncoding\"\n */\nexport const draft07 = sanitizeKeywords({\n version: \"draft-07\",\n $schemaRegEx: \"draft-?0?7\",\n $schema: \"http://json-schema.org/draft-07/schema#\",\n errors,\n formats,\n methods: {\n createSchema,\n getData,\n getChildSelection,\n toDataNodes\n },\n keywords: [\n $refKeyword,\n allOfKeyword,\n anyOfKeyword,\n constKeyword,\n containsKeyword,\n $defsKeyword,\n dependenciesKeyword, // optional support for old draft-version\n deprecatedKeyword,\n enumKeyword,\n exclusiveMaximumKeyword,\n exclusiveMinimumKeyword,\n formatKeyword,\n ifKeyword,\n itemsKeyword,\n maximumKeyword,\n maxItemsKeyword,\n maxLengthKeyword,\n maxPropertiesKeyword,\n minimumKeyword,\n minItemsKeyword,\n minLengthKeyword,\n minPropertiesKeyword,\n multipleOfKeyword,\n notKeyword,\n patternPropertiesKeyword,\n patternKeyword,\n propertiesKeyword,\n propertyNamesKeyword,\n requiredKeyword,\n typeKeyword,\n uniqueItemsKeyword,\n oneOfKeyword,\n additionalItemsKeyword,\n additionalPropertiesKeyword\n ]\n});\n","import { Keyword, JsonSchemaValidatorParams, ValidationPath } from \"../../Keyword\";\nimport { resolveUri } from \"../../utils/resolveUri\";\nimport splitRef from \"../../utils/splitRef\";\nimport { validateNode } from \"../../validateNode\";\nimport { isSchemaNode, JsonError, SchemaNode } from \"../../types\";\nimport { get, split } from \"@sagold/json-pointer\";\nimport { reduceRef, compileNext } from \"../../keywords/$ref\";\n\nexport const $refKeyword: Keyword = {\n id: \"$ref\",\n keyword: \"$ref\",\n parse: parseRef,\n addValidate: ({ schema }) => schema.$ref != null || schema.$recursiveRef != null,\n validate: validateRef,\n addReduce: ({ schema }) => schema.$ref != null || schema.$recursiveRef != null,\n reduce: reduceRef\n};\n\nfunction register(node: SchemaNode, path: string) {\n if (node.context.refs[path] == null) {\n node.context.refs[path] = node;\n }\n}\n\nexport function parseRef(node: SchemaNode) {\n // @ts-expect-error add ref resolution method to node\n node.resolveRef = resolveRef;\n\n // get and store current $id of node - this may be the same as parent $id\n const currentId = resolveUri(node.parent?.$id, node.schema?.$id);\n node.$id = currentId;\n node.lastIdPointer = node.parent?.lastIdPointer ?? \"#\";\n if (currentId !== node.parent?.$id && node.evaluationPath !== \"#\") {\n node.lastIdPointer = node.evaluationPath;\n }\n\n // store this node for retrieval by $id + json-pointer from $id\n if (node.lastIdPointer !== \"#\" && node.evaluationPath.startsWith(node.lastIdPointer)) {\n const localPointer = `#${node.evaluationPath.replace(node.lastIdPointer, \"\")}`;\n register(node, resolveUri(currentId, localPointer));\n }\n // store $rootId + json-pointer to this node\n register(node, resolveUri(node.context.rootNode.$id, node.evaluationPath));\n\n // store this node for retrieval by $id + anchor\n if (node.schema.$anchor) {\n node.context.anchors[`${currentId.replace(/#$/, \"\")}#${node.schema.$anchor}`] = node;\n }\n\n // precompile reference\n if (node.schema.$ref) {\n node.$ref = resolveUri(currentId, node.schema.$ref);\n if (node.$ref.startsWith(\"/\")) {\n node.$ref = `#${node.$ref}`;\n }\n }\n}\n\n// export function reduceRef({ node, data, key, pointer, path }: JsonSchemaReducerParams) {\n// const resolvedNode = node.resolveRef({ pointer, path });\n// if (resolvedNode.schemaLocation === node.schemaLocation) {\n// return resolvedNode;\n// }\n// const result = resolvedNode.reduceNode(data, { key, pointer, path });\n// return result.node ?? result.error;\n// // const merged = mergeNode({ ...node, $ref: undefined, schema: { ...node.schema, $ref: undefined } }, resolvedNode);\n// // const { node: reducedNode, error } = merged.reduceNode(data, { key, pointer, path });\n// // return reducedNode ?? error;\n// }\n\nexport function resolveRef(this: SchemaNode, { pointer, path }: { pointer?: string; path?: ValidationPath } = {}) {\n if (this.schema.$recursiveRef) {\n const nextNode = resolveRecursiveRef(this, path ?? []);\n if (isSchemaNode(nextNode)) {\n path?.push({ pointer: pointer!, node: nextNode! });\n }\n return nextNode;\n }\n\n if (this.$ref == null) {\n return this;\n }\n\n const resolvedNode = getRef(this);\n if (isSchemaNode(resolvedNode)) {\n path?.push({ pointer: pointer!, node: resolvedNode });\n }\n return resolvedNode;\n}\n\nfunction validateRef({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const nextNode = node.resolveRef({ pointer, path });\n if (nextNode != null) {\n return validateNode(nextNode, data, pointer, path);\n }\n return node.createError(\"ref-error\", {\n ref: node.schema.$ref ?? node.schema.$recursiveRef,\n pointer,\n schema: node.schema,\n value: data\n });\n}\n\n// 1. https://json-schema.org/draft/2019-09/json-schema-core#scopes\nfunction resolveRecursiveRef(node: SchemaNode, path: ValidationPath): SchemaNode | JsonError {\n const history = path;\n\n // RESTRICT BY CHANGE IN BASE-URL\n // go back in history until we have a domain definition and use this as start node to search for an anchor\n let startIndex = 0;\n for (let i = history.length - 1; i >= 0; i--) {\n if (history[i].node.schema.$recursiveAnchor === false) {\n // $recursiveRef with $recursiveAnchor: false works like $ref\n return getRef(node, resolveUri(node.$id, node.schema.$recursiveRef));\n }\n if (/^https?:\\/\\//.test(history[i].node.schema.$id ?? \"\") && history[i].node.schema.$recursiveAnchor !== true) {\n startIndex = i;\n break;\n }\n }\n\n // FROM THERE FIND FIRST OCCURENCE OF AN ANCHOR\n const firstAnchor = history.find((s, index) => index >= startIndex && s.node.schema.$recursiveAnchor === true);\n if (firstAnchor) {\n return firstAnchor.node;\n }\n\n // $recursiveRef with no $recursiveAnchor works like $ref?\n const nextNode = getRef(node, resolveUri(node.$id, node.schema.$recursiveRef));\n return nextNode;\n}\n\nexport default function getRef(node: SchemaNode, $ref = node?.$ref): SchemaNode | JsonError {\n if ($ref == null) {\n return node;\n }\n\n // resolve $ref by json-evaluationPath\n if (node.context.refs[$ref]) {\n return compileNext(node.context.refs[$ref], node);\n }\n // resolve $ref from $anchor\n if (node.context.anchors[$ref]) {\n return compileNext(node.context.anchors[$ref], node);\n }\n\n // check for remote-host + pointer pair to switch rootSchema\n const fragments = splitRef($ref);\n if (fragments.length === 0) {\n // console.error(\"REF: INVALID\", $ref);\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n }\n\n // resolve $ref as remote-host\n if (fragments.length === 1) {\n const $ref = fragments[0];\n // this is a reference to remote-host root node\n if (node.context.remotes[$ref]) {\n return compileNext(node.context.remotes[$ref], node);\n }\n if ($ref[0] === \"#\") {\n // @todo there is a bug joining multiple fragments to e.g. #/base#/examples/0\n // from \"$id\": \"/base\" + $ref \"#/examples/0\" (in refOfUnknownKeyword spec)\n const ref = $ref.match(/#[^#]*$/)?.pop() as string; // sanitize pointer\n // support refOfUnknownKeyword\n const rootSchema = node.context.rootNode.schema;\n const targetSchema = get(rootSchema, ref);\n if (targetSchema) {\n return node.compileSchema(targetSchema, `${node.evaluationPath}/$ref`, ref);\n }\n }\n // console.error(\"REF: UNFOUND 1\", $ref);\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n }\n\n if (fragments.length === 2) {\n const $remoteHostRef = fragments[0];\n // this is a reference to remote-host root node (and not a self reference)\n if (node.context.remotes[$remoteHostRef] && node !== node.context.remotes[$remoteHostRef]) {\n const referencedNode = node.context.remotes[$remoteHostRef];\n // resolve full ref on remote schema - we store currently only store ref with domain\n let nextNode = getRef(referencedNode, $ref);\n if (nextNode) {\n return nextNode;\n }\n // @note required for test spec 04\n nextNode = getRef(referencedNode, fragments[1]);\n if (nextNode) {\n return nextNode;\n }\n }\n\n // resolve by json-pointer (optional dynamicRef)\n if (node.context.refs[$remoteHostRef]) {\n const parentNode = node.context.refs[$remoteHostRef];\n const path = split(fragments[1]);\n // @todo add utility to resolve schema-pointer to schema\n let currentNode = parentNode;\n for (const item of path) {\n const property = item === \"definitions\" ? \"$defs\" : item;\n // @ts-expect-error random path\n currentNode = currentNode[property];\n if (currentNode == null) {\n // console.error(\"REF: FAILED RESOLVING ref json-pointer\", fragments[1]);\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined,\n host: fragments[0],\n local: fragments[1]\n });\n }\n }\n return currentNode;\n }\n }\n\n return node.createError(\"ref-error\", {\n ref: $ref,\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined\n });\n}\n","import { isObject } from \"../../utils/isObject\";\nimport { SchemaNode } from \"../../types\";\nimport { Keyword, JsonSchemaValidatorParams, ValidationReturnType } from \"../../Keyword\";\nimport { validateNode } from \"../../validateNode\";\n\nconst KEYWORD = \"unevaluatedItems\";\n\n/**\n * @draft >= 2019-09\n * Similar to additionalItems, but can \"see\" into subschemas and across references\n * https://json-schema.org/draft/2019-09/json-schema-core#rfc.section.9.3.1.3\n */\nexport const unevaluatedItemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseUnevaluatedItems,\n addValidate: ({ schema }) => schema[KEYWORD] != null,\n validate: validateUnevaluatedItems\n};\n\nexport function parseUnevaluatedItems(node: SchemaNode) {\n const { unevaluatedItems } = node.schema;\n if (unevaluatedItems == null || typeof unevaluatedItems === \"boolean\") {\n return;\n }\n\n if (!isObject(unevaluatedItems)) {\n return node.createError(\"schema-error\", {\n pointer: node.evaluationPath,\n schema: node.schema,\n value: undefined,\n message: `Keyword '${KEYWORD}' must be an object - received '${typeof unevaluatedItems}'`\n });\n }\n\n node.unevaluatedItems = node.compileSchema(\n node.schema.unevaluatedItems,\n `${node.evaluationPath}/${KEYWORD}`,\n `${node.schemaLocation}/${KEYWORD}`\n );\n}\n\nfunction validateUnevaluatedItems({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n // if not in items, and not matches additionalItems\n if (\n !Array.isArray(data) ||\n data.length === 0 ||\n schema.unevaluatedItems == null ||\n schema.unevaluatedItems === true\n ) {\n return undefined;\n }\n\n // const reducedNode = node;\n let { node: reducedNode } = node.reduceNode(data, { pointer, path });\n reducedNode = reducedNode ?? node;\n if (reducedNode.schema.unevaluatedItems === true || reducedNode.schema.additionalItems === true) {\n return undefined;\n }\n\n // console.log(\"EVAL\", reducedNode.schema);\n\n const validIf = node.if != null && validateNode(node.if, data, pointer, path).length === 0;\n const errors: ValidationReturnType = [];\n // \"unevaluatedItems with nested items\"\n for (let i = 0; i < data.length; i += 1) {\n const value = data[i];\n const { node: child } = node.getNodeChild(i, data, { path });\n // console.log(`CHILD '${i}':`, data[i], \"=>\", child?.schema);\n\n if (child) {\n // when a single node is invalid\n if (validateNode(child, value, `${pointer}/${i}`, path).length > 0) {\n // nothing should validate, so we validate unevaluated items only\n const unevaluatedItems = node.unevaluatedItems;\n if (unevaluatedItems) {\n data.forEach((value) => {\n const result = validateNode(unevaluatedItems, value, `${pointer}/${i}`, path);\n if (result == null) {\n return;\n }\n if (Array.isArray(result)) {\n return errors.push(...result);\n }\n errors.push(result);\n });\n }\n if (node.schema.unevaluatedItems === false) {\n return node.createError(\"unevaluated-items-error\", {\n pointer: `${pointer}/${i}`,\n value: JSON.stringify(value),\n schema\n });\n }\n }\n }\n // \"unevaluatedItems false\"\n if (child === undefined) {\n // valid if ensures node.if is set\n if (validIf && node.if!.prefixItems && node.if!.prefixItems.length > i) {\n // evaluated by if -- skip\n } else if (node.unevaluatedItems) {\n const result = validateNode(node.unevaluatedItems, value, `${pointer}/${i}`, path);\n if (result.length > 0) {\n errors.push(...result);\n }\n } else {\n errors.push(\n node.createError(\"unevaluated-items-error\", {\n pointer: `${pointer}/${i}`,\n value: JSON.stringify(value),\n schema\n })\n );\n }\n }\n }\n\n return errors;\n}\n","import { ValidationPath } from \"./Keyword\";\nimport { SchemaNode } from \"./types\";\nimport { hasProperty } from \"./utils/hasProperty\";\n// import { getValue } from \"./utils/getValue\";\nimport { validateNode } from \"./validateNode\";\n\ntype Options = {\n /** array node */\n node: SchemaNode;\n /** array data */\n data: Record<string, unknown>;\n /** array index to evaluate */\n key: string;\n /** pointer to array */\n pointer: string;\n\n path: ValidationPath;\n};\n\n/**\n * Returns true if an item is evaluated\n *\n * - Note that this check is partial, the remainder is done in unevaluatedItems\n * - This function currently checks for schema that are not visible by simple validation\n * - We could introduce this method as a new keyword-layer\n */\nexport function isPropertyEvaluated({ node, data, key, pointer, path }: Options) {\n if (Array.isArray(node.schema.required) && !node.schema.required.find((prop) => hasProperty(data, prop))) {\n return false;\n }\n\n if (node.schema.unevaluatedProperties === true || node.schema.additionalProperties === true) {\n return true;\n }\n\n if (node.properties?.[key] && node.properties[key].validate(data[key], pointer, path).valid) {\n return true;\n }\n\n if (node.patternProperties && node.patternProperties.find((p) => p.pattern.test(key))) {\n return true;\n }\n\n if (node.allOf) {\n for (const allOf of node.allOf) {\n if (isPropertyEvaluated({ node: allOf, data, key, pointer, path })) {\n return true;\n }\n }\n }\n\n if (node.anyOf) {\n for (const anyOf of node.anyOf) {\n if (isPropertyEvaluated({ node: anyOf, data, key, pointer, path })) {\n return true;\n }\n }\n }\n\n if (node.oneOf) {\n for (const oneOf of node.oneOf) {\n if (isPropertyEvaluated({ node: oneOf, data, key, pointer, path })) {\n return true;\n }\n }\n }\n\n if (node.if) {\n if (isPropertyEvaluated({ node: node.if, data, key, pointer, path })) {\n return true;\n }\n\n const validIf = validateNode(node.if, data, pointer, path).length === 0;\n if (validIf && node.then) {\n if (isPropertyEvaluated({ node: node.then, data, key, pointer, path })) {\n return true;\n }\n } else if (!validIf && node.else) {\n if (isPropertyEvaluated({ node: node.else, data, key, pointer, path })) {\n return true;\n }\n }\n }\n\n const resolved = node.resolveRef({ pointer, path });\n if (resolved !== node) {\n if (isPropertyEvaluated({ node: resolved, data, key, pointer, path })) {\n return true;\n }\n }\n\n return false;\n}\n","import { isObject } from \"../utils/isObject\";\nimport { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport { validateNode } from \"../validateNode\";\nimport { isPropertyEvaluated } from \"../isPropertyEvaluated\";\n\nconst KEYWORD = \"unevaluatedProperties\";\n\nexport const unevaluatedPropertiesKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseUnevaluatedProperties,\n addValidate: ({ schema }) => schema[KEYWORD] != null, // currently we do not store boolean schema\n validate: validateUnevaluatedProperties\n};\n\nexport function parseUnevaluatedProperties(node: SchemaNode) {\n const unevaluatedProperties = node.schema[KEYWORD];\n if (unevaluatedProperties == null) {\n return;\n }\n if (!(isJsonSchema(unevaluatedProperties) || isBooleanSchema(unevaluatedProperties))) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: unevaluatedProperties,\n message: `Keyword '${KEYWORD}' must be a valid JSON Schema - received '${typeof unevaluatedProperties}'`\n });\n }\n\n if (isBooleanSchema(unevaluatedProperties)) {\n return;\n }\n\n node.unevaluatedProperties = node.compileSchema(\n node.schema.unevaluatedProperties,\n `${node.evaluationPath}/${KEYWORD}`,\n `${node.schemaLocation}/${KEYWORD}`\n );\n return node.unevaluatedProperties.schemaValidation;\n}\n\n// @todo we should use collected annotation to evaluated unevaluate properties\nfunction validateUnevaluatedProperties({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n if (!isObject(data)) {\n return undefined;\n }\n\n const unevaluated = Object.keys(data)\n // do not validate undefined properties\n .filter((property) => data[property] !== undefined);\n\n if (unevaluated.length === 0) {\n return undefined;\n }\n\n const errors: ValidationReturnType = [];\n for (const propertyName of unevaluated) {\n if (isPropertyEvaluated({ node, data, key: propertyName, pointer, path })) {\n continue;\n }\n\n const { node: child } = node.getNodeChild(propertyName, data, { pointer, path });\n\n if (child === undefined) {\n if (node.unevaluatedProperties) {\n const validationResult = validateNode(\n node.unevaluatedProperties,\n data[propertyName],\n `${pointer}/${propertyName}`,\n path\n );\n errors.push(...validationResult);\n } else if (node.schema.unevaluatedProperties === false) {\n errors.push(\n node.createError(\"unevaluated-property-error\", {\n pointer: `${pointer}/${propertyName}`,\n value: JSON.stringify(data[propertyName]),\n schema: node.schema\n })\n );\n }\n }\n\n if (child && validateNode(child, data[propertyName], `${pointer}/${propertyName}`, path).length > 0) {\n if (node.unevaluatedProperties) {\n const validationResult = validateNode(\n node.unevaluatedProperties,\n data[propertyName],\n `${pointer}/${propertyName}`,\n path\n );\n errors.push(...validationResult);\n } else if (node.schema.unevaluatedProperties === false) {\n errors.push(\n node.createError(\"unevaluated-property-error\", {\n pointer: `${pointer}/${propertyName}`,\n value: JSON.stringify(data[propertyName]),\n schema: node.schema\n })\n );\n }\n }\n }\n\n return errors;\n}\n","import { $defsKeyword } from \"./keywords/$defs\";\nimport { $refKeyword } from \"./draft2019-09/keywords/$ref\";\nimport { additionalItemsKeyword } from \"./draft2019-09/keywords/additionalItems\";\nimport { additionalPropertiesKeyword } from \"./keywords/additionalProperties\";\nimport { allOfKeyword } from \"./keywords/allOf\";\nimport { anyOfKeyword } from \"./keywords/anyOf\";\nimport { constKeyword } from \"./keywords/const\";\nimport { containsKeyword } from \"./keywords/contains\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { dependenciesKeyword } from \"./keywords/dependencies\";\nimport { dependentRequiredKeyword } from \"./keywords/dependentRequired\";\nimport { dependentSchemasKeyword } from \"./keywords/dependentSchemas\";\nimport { deprecatedKeyword } from \"./keywords/deprecated\";\nimport { enumKeyword } from \"./keywords/enum\";\nimport { errors } from \"./errors/errors\";\nimport { exclusiveMaximumKeyword } from \"./keywords/exclusiveMaximum\";\nimport { exclusiveMinimumKeyword } from \"./keywords/exclusiveMinimum\";\nimport { formatKeyword } from \"./keywords/format\";\nimport { formats } from \"./formats/formats\";\nimport { getChildSelection } from \"./draft2019-09/methods/getChildSelection\";\nimport { getData } from \"./draft2019-09/methods/getData\";\nimport { ifKeyword } from \"./keywords/ifthenelse\";\nimport { itemsKeyword } from \"./draft2019-09/keywords/items\";\nimport { maximumKeyword } from \"./keywords/maximum\";\nimport { maxItemsKeyword } from \"./keywords/maxItems\";\nimport { maxLengthKeyword } from \"./keywords/maxLength\";\nimport { maxPropertiesKeyword } from \"./keywords/maxProperties\";\nimport { minimumKeyword } from \"./keywords/minimum\";\nimport { minItemsKeyword } from \"./keywords/minItems\";\nimport { minLengthKeyword } from \"./keywords/minLength\";\nimport { minPropertiesKeyword } from \"./keywords/minProperties\";\nimport { multipleOfKeyword } from \"./keywords/multipleOf\";\nimport { notKeyword } from \"./keywords/not\";\nimport { oneOfKeyword } from \"./keywords/oneOf\";\nimport { patternKeyword } from \"./keywords/pattern\";\nimport { patternPropertiesKeyword } from \"./keywords/patternProperties\";\nimport { propertiesKeyword } from \"./keywords/properties\";\nimport { propertyNamesKeyword } from \"./keywords/propertyNames\";\nimport { requiredKeyword } from \"./keywords/required\";\nimport { sanitizeKeywords } from \"./Draft\";\nimport { toDataNodes } from \"./methods/toDataNodes\";\nimport { typeKeyword } from \"./keywords/type\";\nimport { unevaluatedItemsKeyword } from \"./draft2019-09/keywords/unevaluatedItems\";\nimport { unevaluatedPropertiesKeyword } from \"./keywords/unevaluatedProperties\";\nimport { uniqueItemsKeyword } from \"./keywords/uniqueItems\";\n\n/**\n * @draft-2019 https://json-schema.org/draft/2019-09/release-notes\n *\n * new\n * - $anchor\n * - $recursiveAnchor and $recursiveRef\n * - $vocabulary\n *\n * changed\n * - $defs (renamed from definitions)\n * - $id\n * - $ref\n * - dependencies has been split into dependentSchemas and dependentRequired\n */\nexport const draft2019 = sanitizeKeywords({\n version: \"draft-2019-09\",\n $schemaRegEx: \"draft[/-]2019-?(09)?\",\n $schema: \"https://json-schema.org/draft/2019-09/schema\",\n errors,\n formats,\n methods: {\n createSchema,\n getData,\n getChildSelection,\n toDataNodes\n },\n keywords: [\n $refKeyword,\n allOfKeyword,\n anyOfKeyword,\n constKeyword,\n containsKeyword,\n $defsKeyword,\n dependenciesKeyword, // optional support for old draft-version\n dependentRequiredKeyword, // draft-2019: new\n dependentSchemasKeyword, // draft-2019: new\n deprecatedKeyword,\n enumKeyword,\n exclusiveMaximumKeyword,\n exclusiveMinimumKeyword,\n formatKeyword,\n ifKeyword,\n itemsKeyword,\n maximumKeyword,\n maxItemsKeyword,\n maxLengthKeyword,\n maxPropertiesKeyword,\n minimumKeyword,\n minItemsKeyword,\n minLengthKeyword,\n minPropertiesKeyword,\n multipleOfKeyword,\n notKeyword,\n patternPropertiesKeyword,\n patternKeyword,\n propertiesKeyword,\n propertyNamesKeyword,\n requiredKeyword,\n typeKeyword,\n unevaluatedItemsKeyword,\n unevaluatedPropertiesKeyword,\n uniqueItemsKeyword,\n oneOfKeyword,\n additionalItemsKeyword,\n additionalPropertiesKeyword\n ]\n});\n","import { isSchemaNode, JsonError, SchemaNode } from \"../types\";\n\n/**\n * Returns a list of possible child-schemas for the given property key. In case of a oneOf selection, multiple schemas\n * could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases\n * a list with a single item will be returned\n */\nexport function getChildSelection(node: SchemaNode, property: string | number) {\n if (node.oneOf) {\n return node.oneOf.map((childNode: SchemaNode) => childNode.resolveRef());\n }\n if (node.items?.oneOf) {\n return node.items.oneOf.map((childNode: SchemaNode) => childNode.resolveRef());\n }\n // array.items[] found\n if (node.prefixItems && node.prefixItems.length > +property) {\n const { node: childNode, error } = node.getNodeChild(property);\n if (isSchemaNode(childNode)) {\n return [childNode];\n }\n // @todo improve return type guard?\n return error as JsonError;\n }\n if (node.schema.items === true) {\n return [node.compileSchema({ type: \"string\" })];\n }\n if (node.schema.items === false) {\n return [];\n }\n // array.items[] exceeded (or undefined), but additionalItems specified\n if (node.items) {\n // we fallback to a string if no schema is defined - might be subject for configuration\n return [node.items.resolveRef()];\n }\n // array.items[] exceeded\n if (node.prefixItems && node.prefixItems.length <= +property) {\n return [];\n }\n\n const { node: childNode, error } = node.getNodeChild(property);\n // @todo improve return type?\n return (error as JsonError) ?? [childNode];\n}\n","import { copy } from \"fast-copy\";\nimport { getTypeOf } from \"../utils/getTypeOf\";\nimport { getSchemaType } from \"../utils/getSchemaType\";\nimport { getValue } from \"../utils/getValue\";\nimport { isEmpty } from \"../utils/isEmpty\";\nimport { isJsonError } from \"../types\";\nimport { isObject } from \"../utils/isObject\";\nimport { isSchemaNode, SchemaNode } from \"../types\";\nimport { mergeNode } from \"../mergeNode\";\nimport { reduceOneOfFuzzy } from \"../keywords/oneOf\";\nimport { isFile } from \"../utils/isFile\";\n\nexport type TemplateOptions = {\n /** Add all properties (required and optional) to the generated data */\n addOptionalProps?: boolean;\n /** Remove data that does not match input schema. Defaults to false */\n removeInvalidData?: boolean;\n /** Set to false to take default values as they are and not extend them.\n * Defaults to true.\n * This allows to control template data e.g. enforcing arrays to be empty,\n * regardless of minItems settings.\n */\n extendDefaults?: boolean;\n /**\n * Set to false to not use type specific initial values.Defaults to true\n */\n useTypeDefaults?: boolean;\n /**\n * Limits how often a $ref should be followed before aborting. Prevents infinite data-structure.\n * Defaults to 1\n */\n recursionLimit?: number;\n /** @internal disables recursion limit for next call */\n disableRecursionLimit?: boolean;\n /** @internal context to track recursion limit */\n cache?: Record<string, Record<string, number>>;\n};\n\nfunction safeResolveRef(node: SchemaNode, options: TemplateOptions) {\n if (node.$ref == null) {\n return undefined;\n }\n options.cache = options.cache ?? {};\n const { cache, recursionLimit = 1 } = options;\n\n const origin = node.schemaLocation;\n cache[origin] = cache[origin] ?? {};\n cache[origin][node.$ref] = cache[origin][node.$ref] ?? 0;\n const value = cache[origin][node.$ref];\n if (value >= recursionLimit && options.disableRecursionLimit !== true) {\n return false;\n }\n options.disableRecursionLimit = false;\n cache[origin][node.$ref] += 1;\n const resolvedNode = node.resolveRef();\n if (resolvedNode && resolvedNode !== node) {\n return resolvedNode;\n }\n\n return undefined;\n}\n\nfunction canResolveRef(node: SchemaNode, options: TemplateOptions) {\n // @ts-expect-error unknown index\n const counter = options.cache?.[node.schemaLocation]?.[node.$ref] ?? -1;\n return counter < (options.recursionLimit ?? 1);\n}\n\n// only convert values where we do not lose original data\nfunction convertValue(type: string | undefined, value: unknown) {\n const valueType = getTypeOf(value);\n if (type === undefined || value == null || valueType === type || (valueType === \"number\" && type === \"integer\")) {\n return value;\n }\n\n if (type === \"string\") {\n return JSON.stringify(value);\n } else if (valueType !== \"string\") {\n return value;\n }\n\n try {\n const parsedValue = JSON.parse(value as string);\n if (getTypeOf(parsedValue) === type) {\n return parsedValue;\n }\n } catch (e) {} // eslint-disable-line @typescript-eslint/no-unused-vars, no-empty\n\n return value;\n}\n\nexport function getData(node: SchemaNode, data?: unknown, opts?: TemplateOptions) {\n if (opts?.cache == null) {\n throw new Error(\"Missing options\");\n }\n\n // @ts-expect-error boolean schema\n if (node.schema === false || node.schema === true) {\n return data;\n }\n // @attention - very special case to support file instances\n if (isFile(data)) {\n return data;\n }\n\n if (node.schema?.const !== undefined) {\n return node.schema?.const;\n }\n\n let currentNode = node;\n let defaultData = data;\n\n if (Array.isArray(node.schema.enum) && node.schema.enum.length > 0) {\n if (data === undefined) {\n return node.schema.default ?? node.schema.enum[0];\n }\n }\n\n if (node.schema.default !== undefined) {\n if (defaultData === undefined) {\n defaultData = node.schema.default;\n }\n }\n\n // @keyword allOf\n if (currentNode.allOf?.length) {\n currentNode.allOf.forEach((partialNode) => {\n defaultData = partialNode.getData(defaultData, opts) ?? defaultData;\n });\n }\n\n // @keyword anyOf\n if (currentNode.anyOf && currentNode.anyOf?.length > 0) {\n defaultData = currentNode.anyOf[0].getData(defaultData, opts) ?? defaultData;\n }\n\n // @keyword oneOf\n if (currentNode.oneOf && currentNode.oneOf?.length > 0) {\n if (isEmpty(defaultData)) {\n currentNode = mergeNode(currentNode, currentNode.oneOf[0]) as SchemaNode;\n } else {\n // find correct schema for data\n const resolvedNode = reduceOneOfFuzzy({ node: currentNode, data: defaultData, path: [], pointer: \"#\" });\n if (isJsonError(resolvedNode)) {\n if (defaultData != null && opts.removeInvalidData !== true) {\n return defaultData;\n }\n // override\n currentNode = currentNode.oneOf[0];\n defaultData = undefined;\n } else {\n currentNode = mergeNode(currentNode, resolvedNode) as SchemaNode;\n }\n }\n }\n\n const resolvedNode = safeResolveRef(currentNode, opts);\n if (resolvedNode === false) {\n return defaultData;\n }\n\n if (isSchemaNode(resolvedNode)) {\n defaultData = resolvedNode.getData(defaultData, opts) ?? defaultData;\n currentNode = resolvedNode;\n }\n\n const type = getSchemaType(currentNode, defaultData);\n const templateData = TYPE[type as string]?.(currentNode, defaultData, opts);\n return templateData === undefined ? defaultData : templateData;\n}\n\nconst TYPE: Record<string, (node: SchemaNode, data: unknown, opts: TemplateOptions) => unknown> = {\n null: (node, data, opts) => getDefault(node, data, null, opts.useTypeDefaults),\n string: (node, data, opts) => getDefault(node, data, \"\", opts.useTypeDefaults),\n number: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),\n integer: (node, data, opts) => getDefault(node, data, 0, opts.useTypeDefaults),\n boolean: (node, data, opts) => getDefault(node, data, false, opts.useTypeDefaults),\n // object: (draft, schema, data: Record<string, unknown> | undefined, pointer: JsonPointer, opts: TemplateOptions) => {\n object: (node, data, opts) => {\n const schema = node.schema;\n const template = schema.default === undefined ? {} : schema.default;\n const d: Record<string, unknown> = {}; // do not assign data here, to keep ordering from json-schema\n const required = opts.extendDefaults === false && schema.default !== undefined ? [] : (schema.required ?? []);\n\n const properties = node.properties;\n if (properties) {\n Object.keys(properties).forEach((propertyName) => {\n const propertyNode = properties[propertyName];\n const isRequired = required.includes(propertyName);\n const input = getValue(data, propertyName);\n const value = data === undefined || input === undefined ? getValue(template, propertyName) : input;\n // Omit adding a property if it is not required or optional props should be added\n if (value != null || isRequired || opts.addOptionalProps) {\n const propertyValue = propertyNode.getData(value, opts);\n if (propertyValue !== undefined || opts.useTypeDefaults !== false) {\n d[propertyName] = propertyValue;\n }\n }\n });\n }\n\n const dependentRequired = node.dependentRequired;\n if (isObject(dependentRequired)) {\n Object.keys(dependentRequired).forEach((propertyName) => {\n const propertyValue = dependentRequired[propertyName];\n const hasValue = getValue(d, propertyName) !== undefined;\n if (hasValue) {\n propertyValue.forEach((addProperty) => {\n const { node: propertyNode } = node.getNodeChild(addProperty, d);\n if (propertyNode) {\n d[addProperty] = propertyNode.getData(getValue(d, addProperty), opts);\n }\n });\n }\n // if false and removeInvalidData => remove from data\n });\n }\n\n // @keyword dependencies - has to be done after resolving properties so dependency may trigger\n const dependentSchemas = node.dependentSchemas;\n if (dependentSchemas) {\n Object.keys(dependentSchemas).forEach((prop) => {\n const dependency = dependentSchemas[prop];\n if (d[prop] !== undefined && isSchemaNode(dependency)) {\n const dependencyData = dependency.getData(data ?? d, opts);\n Object.assign(d, dependencyData);\n }\n // if false and removeInvalidData => remove from data\n });\n }\n\n // console.log(\"getData object\", data, opts);\n if (data) {\n if (\n opts.removeInvalidData === true &&\n (schema.additionalProperties === false || isObject(schema.additionalProperties))\n ) {\n if (isSchemaNode(node.additionalProperties)) {\n Object.keys(data).forEach((key) => {\n if (d[key] == null) {\n // merge valid missing data (additionals) to resulting object\n const value = getValue(data, key);\n if (node.additionalProperties?.validate(value).valid) {\n d[key] = value;\n }\n }\n });\n }\n } else {\n // merge any missing data (additionals) to resulting object\n Object.keys(data).forEach((key) => d[key] == null && (d[key] = getValue(data, key)));\n }\n }\n\n // @keyword if-then-else\n if (node.if) {\n const { errors } = node.if.validate(d);\n if (errors.length === 0 && node.then) {\n const templateData = node.then.getData(d, opts);\n Object.assign(d, templateData);\n } else if (errors.length > 0 && node.else) {\n const templateData = node.else.getData(d, opts);\n Object.assign(d, templateData);\n }\n }\n\n // returns object, which is ordered by json-schema\n return { ...template, ...d };\n },\n // build array type of items, ignores additionalItems\n array: (node, data, opts) => {\n const schema = node.schema;\n const template = schema.default === undefined ? [] : schema.default;\n const d: unknown[] = Array.isArray(data) ? [...data] : template;\n const minItems = opts.extendDefaults === false && schema.default !== undefined ? 0 : (schema.minItems ?? 0);\n\n // when there are no array-items are defined\n if (schema.prefixItems == null) {\n // => all items are additionalItems\n if (node.items && (canResolveRef(node.items, opts) || d?.length > 0)) {\n const cache = { ...opts.cache };\n const itemCount = Math.max(minItems, d.length);\n for (let i = 0; i < itemCount; i += 1) {\n opts.cache = copy(cache);\n const options = { ...opts, disableRecursionLimit: true };\n d[i] = node.items.getData(d[i] == null ? template[i] : d[i], options);\n }\n }\n return d || [];\n }\n\n // when items are defined per index\n if (node.prefixItems) {\n const input = Array.isArray(data) ? data : [];\n\n // build defined set of items\n const length = Math.max(minItems ?? 0, node.prefixItems.length);\n for (let i = 0; i < length; i += 1) {\n const childNode = node.prefixItems[i] ?? node.items;\n if ((childNode && canResolveRef(childNode, opts)) || input[i] !== undefined) {\n const result = childNode.getData(d[i] == null ? template[i] : d[i], opts);\n if (result !== undefined) {\n d[i] = result;\n }\n }\n }\n return d || [];\n }\n\n // this has to be defined as we checked all other cases\n if (node.items == null) {\n return d;\n }\n\n // build data from items-definition\n // @ts-expect-error testing length of unknown type of data\n if ((node.items && canResolveRef(node.items, opts)) || data?.length > 0) {\n // @attention this should disable cache or break intended behaviour as we reset it after loop\n // @todo test recursion of items\n // intention: reset cache after each property. last call will add counters\n const cache = { ...opts.cache };\n for (let i = 0, l = Math.max(minItems, d.length); i < l; i += 1) {\n opts.cache = copy(cache);\n const options = { ...opts, disableRecursionLimit: true };\n const result = node.items.getData(d[i] == null ? template[i] : d[i], options);\n // @attention if getData aborts recursion it currently returns undefined)\n if (result === undefined) {\n return d;\n } else {\n d[i] = result;\n }\n }\n }\n\n return d;\n }\n};\n\nfunction getDefault({ schema }: SchemaNode, templateValue: unknown, initValue: unknown, useTypeDefaults?: boolean) {\n if (templateValue !== undefined) {\n return convertValue(schema.type, templateValue);\n } else if (schema.const) {\n return schema.const;\n } else if (schema.default === undefined && Array.isArray(schema.enum)) {\n return schema.enum[0];\n } else if (schema.default === undefined && useTypeDefaults !== false) {\n return initValue;\n }\n return schema.default;\n}\n","import { Keyword, JsonSchemaResolverParams, JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { validateNode } from \"../validateNode\";\n\nconst KEYWORD = \"items\";\n\nexport const itemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseItems,\n addResolve: (node) => node[KEYWORD] != null,\n resolve: itemsResolver,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validateItems\n};\n\nfunction itemsResolver({ node, key }: JsonSchemaResolverParams) {\n // prefixItems should handle this, abort\n // Note: This keeps features sort independent for arrays\n if (node.prefixItems && node.prefixItems?.length > +key) {\n return;\n }\n return node.items;\n}\n\nexport function parseItems(node: SchemaNode) {\n const items = node.schema[KEYWORD];\n if (items == null) {\n return;\n }\n if (!(isJsonSchema(items) || isBooleanSchema(items))) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: items,\n message: `Keyword '${KEYWORD}' must be a valid JSON Schema - received '${typeof items}'`\n });\n }\n\n if (items !== true) {\n // @todo remove skipping boolean schema\n node[KEYWORD] = node.compileSchema(\n items,\n `${node.evaluationPath}/${KEYWORD}`,\n `${node.schemaLocation}/${KEYWORD}`\n );\n return node[KEYWORD].schemaValidation;\n }\n}\n\nfunction validateItems({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n if (!Array.isArray(data) || data.length === 0) {\n return;\n }\n\n const withPrefixItems = Array.isArray(schema.prefixItems);\n if (withPrefixItems && schema.prefixItems.length >= data.length) {\n return undefined;\n }\n\n if (schema.items === false) {\n if (Array.isArray(data) && data.length === 0) {\n return undefined;\n }\n return node.createError(\"invalid-data-error\", { pointer, value: data, schema });\n }\n\n const errors: ValidationReturnType = [];\n if (node.items) {\n for (let i = schema.prefixItems?.length ?? 0; i < data.length; i += 1) {\n const itemData = data[i];\n const result = validateNode(node.items, itemData, `${pointer}/${i}`, path);\n if (result) {\n errors.push(...result);\n }\n }\n return errors;\n }\n}\n","import { SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaResolverParams, JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport { validateNode } from \"../validateNode\";\nimport { collectValidationErrors } from \"src/utils/collectValidationErrors\";\n\nconst KEYWORD = \"prefixItems\";\n\nexport const prefixItemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseItems,\n addResolve: (node) => node[KEYWORD] != null,\n resolve: prefixItemsResolver,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validatePrefixItems\n};\n\nfunction prefixItemsResolver({ node, key }: JsonSchemaResolverParams) {\n if (node.prefixItems && node.prefixItems[key as number]) {\n return node.prefixItems[key as number];\n }\n}\n\nexport function parseItems(node: SchemaNode) {\n const { schema, evaluationPath } = node;\n if (Array.isArray(schema.prefixItems)) {\n node.prefixItems = schema.prefixItems.map((itemSchema, index) =>\n node.compileSchema(\n itemSchema,\n `${evaluationPath}/${KEYWORD}/${index}`,\n `${node.schemaLocation}/${KEYWORD}/${index}`\n )\n );\n return collectValidationErrors([], ...node.prefixItems);\n }\n}\n\nfunction validatePrefixItems({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n if (!Array.isArray(data) || data.length === 0) {\n return;\n }\n\n const errors: ValidationReturnType = [];\n const prefixItems = node[KEYWORD];\n if (prefixItems) {\n // note: schema is valid when data does not have enough elements as defined by array-list\n for (let i = 0; i < Math.min(prefixItems.length, data.length); i += 1) {\n const itemData = data[i];\n // @todo v1 reevaluate: incomplete schema is created here?\n const itemNode = prefixItems[i];\n const result = validateNode(itemNode, itemData, `${pointer}/${i}`, path);\n errors.push(...result);\n }\n return errors;\n }\n}\n","import { ValidationPath } from \"./Keyword\";\nimport { SchemaNode } from \"./types\";\nimport { getValue } from \"./utils/getValue\";\nimport { validateNode } from \"./validateNode\";\n\ntype Options = {\n /** array node */\n node: SchemaNode;\n /** array data */\n data: unknown[];\n /** array index to evaluate */\n key: number;\n /** pointer to array */\n pointer: string;\n\n path: ValidationPath;\n};\n\n/**\n * Returns true if an item is evaluated\n *\n * - Note that this check is partial, the remainder is done in unevaluatedItems\n * - This function currently checks for schema that are not visible by simple validation\n * - We could introduce this method as a new keyword-layer\n */\nexport function isItemEvaluated({ node, data, key, pointer, path }: Options) {\n const value = getValue(data, key);\n\n if (node.schema.unevaluatedItems === true || node.schema.items === true) {\n return true;\n }\n\n if (node.contains && validateNode(node.contains, value, `${pointer}/${key}`, path).length === 0) {\n return true;\n }\n\n if (node.allOf) {\n for (const allOf of node.allOf) {\n if (isItemEvaluated({ node: allOf, data, key, pointer, path })) {\n return true;\n }\n }\n }\n if (node.anyOf) {\n for (const anyOf of node.anyOf) {\n if (isItemEvaluated({ node: anyOf, data, key, pointer, path })) {\n return true;\n }\n }\n }\n\n if (node.oneOf) {\n for (const oneOf of node.oneOf) {\n if (isItemEvaluated({ node: oneOf, data, key, pointer, path })) {\n return true;\n }\n }\n }\n\n if (node.if) {\n if (isItemEvaluated({ node: node.if, data, key, pointer, path })) {\n return true;\n }\n const validIf = validateNode(node.if, data, pointer, path).length === 0;\n\n if (validIf && node.if.prefixItems && node.if.prefixItems.length > key) {\n // evaluated by if\n return true;\n }\n\n if (validIf && node.then) {\n if (isItemEvaluated({ node: node.then, data, key, pointer, path })) {\n return true;\n }\n } else if (!validIf && node.else) {\n if (isItemEvaluated({ node: node.else, data, key, pointer, path })) {\n return true;\n }\n }\n }\n}\n","import { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { Keyword, JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport { validateNode } from \"../validateNode\";\nimport { isItemEvaluated } from \"../isItemEvaluated\";\n\nconst KEYWORD = \"unevaluatedItems\";\n\n/**\n * @draft >= 2019-09\n * Similar to additionalItems, but can \"see\" into subschemas and across references\n * https://json-schema.org/draft/2019-09/json-schema-core#rfc.section.9.3.1.3\n */\nexport const unevaluatedItemsKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parseUnevaluatedItems,\n addValidate: ({ schema }) => schema.unevaluatedItems != null, // currently we do not store boolean schema\n validate: validateUnevaluatedItems\n};\n\nexport function parseUnevaluatedItems(node: SchemaNode) {\n const unevaluatedItems = node.schema[KEYWORD];\n if (unevaluatedItems == null) {\n return;\n }\n if (!(isJsonSchema(unevaluatedItems) || isBooleanSchema(unevaluatedItems))) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: unevaluatedItems,\n message: `Keyword '${KEYWORD}' must be a valid JSON Schema - received '${typeof unevaluatedItems}'`\n });\n }\n\n if (isBooleanSchema(unevaluatedItems)) {\n return;\n }\n\n node.unevaluatedItems = node.compileSchema(\n node.schema.unevaluatedItems,\n `${node.evaluationPath}/${KEYWORD}`,\n `${node.schemaLocation}/${KEYWORD}`\n );\n return node.unevaluatedItems.schemaValidation;\n}\n\nfunction validateUnevaluatedItems({ node, data, pointer, path }: JsonSchemaValidatorParams) {\n const { schema } = node;\n // if not in items, and not matches additionalItems\n if (\n !Array.isArray(data) ||\n data.length === 0 ||\n schema.unevaluatedItems == null ||\n schema.unevaluatedItems === true\n ) {\n return undefined;\n }\n\n const errors: ValidationReturnType = [];\n // \"unevaluatedItems with nested items\"\n for (let i = 0; i < data.length; i += 1) {\n if (isItemEvaluated({ node, data, pointer, key: i, path })) {\n continue;\n }\n\n const value = data[i];\n const { node: child } = node.getNodeChild(i, data, { path });\n\n if (child === undefined) {\n if (node.unevaluatedItems) {\n const result = validateNode(node.unevaluatedItems, value, `${pointer}/${i}`, path);\n if (result.length > 0) {\n errors.push(...result);\n }\n } else {\n errors.push(\n node.createError(\"unevaluated-items-error\", {\n pointer: `${pointer}/${i}`,\n value: JSON.stringify(value),\n schema\n })\n );\n }\n }\n\n if (child && validateNode(child, value, `${pointer}/${i}`, path).length > 0) {\n // when a single node is invalid\n if (\n node.unevaluatedItems &&\n node.unevaluatedItems.validate(value, `${pointer}/${i}`, path).valid === false\n ) {\n return node.createError(\"unevaluated-items-error\", {\n pointer: `${pointer}/${i}`,\n value: JSON.stringify(value),\n schema\n });\n }\n\n if (node.schema.unevaluatedItems === false) {\n return node.createError(\"unevaluated-items-error\", {\n pointer: `${pointer}/${i}`,\n value: JSON.stringify(value),\n schema\n });\n }\n }\n }\n\n return errors;\n}\n","import { $defsKeyword } from \"./keywords/$defs\";\nimport { $refKeyword } from \"./keywords/$ref\";\nimport { additionalPropertiesKeyword } from \"./keywords/additionalProperties\";\nimport { allOfKeyword } from \"./keywords/allOf\";\nimport { anyOfKeyword } from \"./keywords/anyOf\";\nimport { constKeyword } from \"./keywords/const\";\nimport { containsKeyword } from \"./keywords/contains\";\nimport { createSchema } from \"./methods/createSchema\";\nimport { dependenciesKeyword } from \"./keywords/dependencies\";\nimport { dependentRequiredKeyword } from \"./keywords/dependentRequired\";\nimport { dependentSchemasKeyword } from \"./keywords/dependentSchemas\";\nimport { deprecatedKeyword } from \"./keywords/deprecated\";\nimport { enumKeyword } from \"./keywords/enum\";\nimport { errors } from \"./errors/errors\";\nimport { exclusiveMaximumKeyword } from \"./keywords/exclusiveMaximum\";\nimport { exclusiveMinimumKeyword } from \"./keywords/exclusiveMinimum\";\nimport { formatKeyword } from \"./keywords/format\";\nimport { formats } from \"./formats/formats\";\nimport { getChildSelection } from \"./methods/getChildSelection\";\nimport { getData } from \"./methods/getData\";\nimport { ifKeyword } from \"./keywords/ifthenelse\";\nimport { itemsKeyword } from \"./keywords/items\";\nimport { maximumKeyword } from \"./keywords/maximum\";\nimport { maxItemsKeyword } from \"./keywords/maxItems\";\nimport { maxLengthKeyword } from \"./keywords/maxLength\";\nimport { maxPropertiesKeyword } from \"./keywords/maxProperties\";\nimport { minimumKeyword } from \"./keywords/minimum\";\nimport { minItemsKeyword } from \"./keywords/minItems\";\nimport { minLengthKeyword } from \"./keywords/minLength\";\nimport { minPropertiesKeyword } from \"./keywords/minProperties\";\nimport { multipleOfKeyword } from \"./keywords/multipleOf\";\nimport { notKeyword } from \"./keywords/not\";\nimport { oneOfKeyword } from \"./keywords/oneOf\";\nimport { patternKeyword } from \"./keywords/pattern\";\nimport { patternPropertiesKeyword } from \"./keywords/patternProperties\";\nimport { prefixItemsKeyword } from \"./keywords/prefixItems\";\nimport { propertiesKeyword } from \"./keywords/properties\";\nimport { propertyNamesKeyword } from \"./keywords/propertyNames\";\nimport { requiredKeyword } from \"./keywords/required\";\nimport { sanitizeKeywords } from \"./Draft\";\nimport { toDataNodes } from \"./methods/toDataNodes\";\nimport { typeKeyword } from \"./keywords/type\";\nimport { unevaluatedItemsKeyword } from \"./keywords/unevaluatedItems\";\nimport { unevaluatedPropertiesKeyword } from \"./keywords/unevaluatedProperties\";\nimport { uniqueItemsKeyword } from \"./keywords/uniqueItems\";\n\n/**\n * @draft-2020-12 https://json-schema.org/draft/2020-12/release-notes\n *\n * - The items and additionalItems keywords have been replaced with prefixItems and items\n * - Although the meaning of items has changed, the syntax for defining arrays remains the same.\n * Only the syntax for defining tuples has changed. The idea is that an array has items (items)\n * and optionally has some positionally defined items that come before the normal items (prefixItems).\n * - The $recursiveRef and $recursiveAnchor keywords were replaced by the more powerful $dynamicRef and\n * $dynamicAnchor keywords\n * - This draft specifies that any item in an array that passes validation of the contains schema is\n * considered \"evaluated\".\n * - Regular expressions are now expected (but not strictly required) to support unicode characters.\n * - This draft drops support for the schema media type parameter\n * - If you reference an external schema, that schema can declare its own $schema and that may be different\n * than the $schema of the referencing schema. Implementations need to be prepared to switch processing\n * modes or throw an error if they don't support the $schema of the referenced schema\n * - Implementations that collect annotations should now include annotations for unknown keywords in the\n * \"verbose\" output format.\n * - The format vocabulary was broken into two separate vocabularies. The \"format-annotation\" vocabulary\n * treats the format keyword as an annotation and the \"format-assertion\" vocabulary treats the format\n * keyword as an assertion. The \"format-annotation\" vocabulary is used in the default meta-schema and\n * is required.\n *\n */\nexport const draft2020 = sanitizeKeywords({\n version: \"draft-2020-12\",\n $schemaRegEx: \"draft[/-]2020-?(12)?\",\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n errors,\n formats,\n methods: {\n createSchema,\n getData,\n getChildSelection,\n toDataNodes\n },\n keywords: [\n $refKeyword,\n additionalPropertiesKeyword,\n allOfKeyword,\n anyOfKeyword,\n constKeyword,\n containsKeyword,\n $defsKeyword,\n dependenciesKeyword,\n dependentRequiredKeyword,\n dependentSchemasKeyword,\n deprecatedKeyword,\n enumKeyword,\n exclusiveMaximumKeyword,\n exclusiveMinimumKeyword,\n formatKeyword,\n ifKeyword,\n itemsKeyword,\n maximumKeyword,\n maxItemsKeyword,\n maxLengthKeyword,\n maxPropertiesKeyword,\n minimumKeyword,\n minItemsKeyword,\n minLengthKeyword,\n minPropertiesKeyword,\n multipleOfKeyword,\n notKeyword,\n oneOfKeyword,\n patternKeyword,\n patternPropertiesKeyword,\n prefixItemsKeyword,\n propertiesKeyword,\n propertyNamesKeyword,\n requiredKeyword,\n typeKeyword,\n unevaluatedItemsKeyword,\n unevaluatedPropertiesKeyword,\n uniqueItemsKeyword\n ]\n});\n","import { copy } from \"fast-copy\";\nimport { getRef } from \"./keywords/$ref\";\nimport { draft04 } from \"./draft04\";\nimport { draft06 } from \"./draft06\";\nimport { draft07 } from \"./draft07\";\nimport { draft2019 } from \"./draft2019\";\nimport { draft2020 } from \"./draft2020\";\nimport { pick } from \"./utils/pick\";\nimport {\n JsonSchema,\n BooleanSchema,\n Draft,\n isJsonSchema,\n JsonAnnotation,\n JsonError,\n isJsonError,\n isJsonAnnotation,\n isBooleanSchema\n} from \"./types\";\nimport { TemplateOptions } from \"./methods/getData\";\nimport { SchemaNode, SchemaNodeMethods, addKeywords, isSchemaNode } from \"./SchemaNode\";\nimport settings from \"./settings\";\nimport sanitizeErrors from \"./utils/sanitizeErrors\";\n\nconst { REGEX_FLAGS } = settings;\n\nexport type CompileOptions = {\n /**\n * List of drafts to support.\n *\n * Drafts are selected by testing the passed `schema.$schema` for a matching id, which\n * is tested by each draft's `Draft.$schemaRegEx`. In case no draft matches `schema.$schema`\n * the last draft in the list will be used.\n *\n * @default [draft04, draft06, draft07, draft2019, draft2020]\n *\n * @example\n * import { draft04, draft07, draft2020 } from \"json-schema-library\"\n * compileSchema({ $schema: \"draft-04\" }, { drafts: [draft04, draft07, draft2020] })\n */\n drafts?: Draft[];\n /**\n * Fallback _draft_ version in case no _draft_ is specified by `schema.$schema`.\n *\n * Drafts are selected by given `schema.$schema` or the last draft from `drafts` as a fallback.\n * Specifying `draft` will workthe same as a specifying `schema.$schema` in case no $schema is\n * defined. When no match can be found, the last _draft_ from `drafts` will be used.\n *\n * @example\n * // uses draft-04\n * compileSchema({ $schema: \"draft-04\" }, { drafts: [draft04, draft07, draft2020] })\n *\n * // uses draft-2020-12\n * compileSchema({}, { drafts: [draft04, draft07, draft2020] })\n *\n * // uses draft-07\n * compileSchema({}, { draft: \"draft-07\", drafts: [draft04, draft07, draft2020] })\n\n * // uses draft-04\n * compileSchema({ $schema: \"draft-04\" }, { draft: \"draft-07\", drafts: [draft04, draft07, draft2020] })\n *\n * // uses draft-2020\n * compileSchema({ $schema: \"draft-04\" }, { draft: \"draft-07\", drafts: [draft2020] })\n */\n draft?: string;\n /**\n * Set node and its remote schemata as remote schemata for this node and schema to resolve $ref\n */\n remote?: SchemaNode;\n /**\n * Enables `format`-keyword assertions when this is set tor `true` or sets assertion as defined by\n * the given meta-schema. Set to `false` to deactivate format validation.\n *\n * @default true\n */\n formatAssertion?: boolean | \"meta-schema\" | undefined;\n /** Set default options for all `node.getData` requests */\n getDataDefaultOptions?: TemplateOptions;\n /** Set to true to throw an Error on errors in input schema. Defaults to false */\n throwOnInvalidSchema?: boolean;\n /** Set to true to throw an Error when encountering an unresolvable ref */\n throwOnInvalidRef?: boolean;\n};\n\nconst defaultDrafts: Draft[] = [draft04, draft06, draft07, draft2019, draft2020];\n\nfunction getDraft(drafts: Draft[], $schema: string) {\n return drafts.find((d) => new RegExp(d.$schemaRegEx, REGEX_FLAGS).test($schema)) ?? drafts[drafts.length - 1];\n}\n\n/**\n * With compileSchema we replace the schema and all sub-schemas with a schemaNode,\n * wrapping each schema with utilities and as much preevaluation as possible. Each\n * node will be reused for each task, but will create a compiledNode for bound data.\n */\nexport function compileSchema(schema: JsonSchema | BooleanSchema, options: CompileOptions = {}) {\n let formatAssertion = options.formatAssertion ?? true;\n const drafts = options.drafts ?? defaultDrafts;\n const draft = getDraft(drafts, isJsonSchema(schema) ? (options.draft ?? schema.$schema) : undefined);\n const node: SchemaNode & { schemaErrors?: JsonError[]; schemaAnnotations: JsonAnnotation[] } = {\n evaluationPath: \"#\",\n lastIdPointer: \"#\",\n schemaLocation: \"#\",\n dynamicId: \"\",\n reducers: [],\n resolvers: [],\n validators: [],\n schema: schema as JsonSchema,\n // @ts-expect-error self-reference added later\n context: {\n remotes: {},\n dynamicAnchors: {},\n ...(options.remote?.context ?? {}),\n anchors: {},\n refs: {},\n ...copy(pick(draft, \"methods\", \"keywords\", \"version\", \"formats\", \"errors\")),\n draft: options.draft,\n getDataDefaultOptions: options.getDataDefaultOptions,\n throwOnInvalidRef: options.throwOnInvalidRef ?? false,\n drafts\n },\n ...SchemaNodeMethods\n };\n\n node.context.rootNode = node;\n node.context.remotes[(isJsonSchema(schema) ? schema.$id : undefined) ?? \"#\"] = node;\n\n if (options.remote) {\n const metaSchema = getRef(node, node.schema.$schema);\n if (isSchemaNode(metaSchema) && metaSchema.schema.$vocabulary) {\n const vocabs = Object.keys(metaSchema.schema.$vocabulary);\n // const withAnnotations = vocabs.find((vocab) => vocab.includes(\"vocab/format-annotation\"));\n const formatAssertionString = vocabs.find((vocab) => vocab.includes(\"vocab/format-assertion\"));\n if (formatAssertionString && formatAssertion === \"meta-schema\") {\n formatAssertion = metaSchema.schema.$vocabulary[formatAssertionString] === true;\n }\n const validKeywords = Object.keys(metaSchema.getData({}, { addOptionalProps: true }) as object);\n if (validKeywords.length > 0) {\n node.context.keywords = node.context.keywords.filter((f) => validKeywords.includes(f.keyword));\n }\n }\n }\n\n if (formatAssertion === false) {\n node.context.keywords = node.context.keywords.filter((f) => f.keyword !== \"format\");\n }\n\n if (!isJsonSchema(schema) && !isBooleanSchema(schema)) {\n node.schemaErrors = [\n node.createError(\"schema-error\", {\n pointer: \"#\",\n schema,\n value: undefined,\n message: `JSON schema must be object or boolean - reveived: '${schema}'`\n })\n ];\n return node;\n }\n\n // parse and validate schema\n let schemaValidation = addKeywords(node).filter((err) => err != null);\n schemaValidation = sanitizeErrors(schemaValidation);\n const schemaErrors: JsonError[] = [];\n const schemaAnnotations: JsonAnnotation[] = [];\n schemaValidation.forEach((error) => {\n if (isJsonError(error)) {\n schemaErrors.push(error);\n } else if (isJsonAnnotation(error)) {\n schemaAnnotations.push(error);\n }\n });\n\n if (options.throwOnInvalidSchema && schemaErrors.length > 0) {\n const error = new Error(\"Invalid schema passed to compileSchema\");\n // @ts-expect-error unknown error-property\n error.data = schemaErrors;\n throw error;\n }\n\n node.schemaErrors = schemaErrors;\n node.schemaAnnotations = schemaAnnotations;\n\n return node;\n}\n","import { extendDraft } from \"./Draft\";\nimport { draft2020 } from \"./draft2020\";\nimport { oneOfFuzzyKeyword } from \"./keywords/oneOf\";\nimport { render } from \"./errors/render\";\n\n/**\n * @draft-editor https://json-schema.org/draft/2020-12/release-notes\n *\n * Uses Draft 2020-12 and changes resolveOneOf to be fuzzy\n */\nexport const draftEditor = extendDraft(draft2020, {\n $schemaRegEx: \".\",\n keywords: [oneOfFuzzyKeyword],\n errors: {\n \"min-length-error\": (data) => {\n if (data.minLength === 1) {\n return {\n type: \"error\",\n code: \"min-length-one-error\",\n message: \"An input is required\",\n data\n };\n }\n return {\n type: \"error\",\n code: \"min-length-error\",\n message: render(\n \"Value in `{{pointer}}` is `{{length}}`, but should be `{{minLength}}` at minimum\",\n data\n ),\n data\n };\n }\n }\n});\n","import { collectValidationErrors } from \"src/utils/collectValidationErrors\";\nimport {\n Keyword,\n JsonSchemaValidatorParams,\n JsonSchemaReducerParams,\n ValidationReturnType,\n ValidationAnnotation\n} from \"../Keyword\";\nimport { isBooleanSchema, isJsonSchema, SchemaNode } from \"../types\";\nimport { hasProperty } from \"../utils/hasProperty\";\nimport { isObject } from \"../utils/isObject\";\nimport { mergeSchema } from \"../utils/mergeSchema\";\nimport sanitizeErrors from \"../utils/sanitizeErrors\";\nimport { validateNode } from \"../validateNode\";\n\nconst KEYWORD = \"propertyDependencies\";\n\nfunction findMatchingSchemata(node: SchemaNode, data: Record<string, unknown>) {\n const dependentProperties = node[KEYWORD];\n if (dependentProperties == null) {\n return undefined;\n }\n const dependentPropertyNames = Object.keys(dependentProperties);\n const matchingSchemata: { property: string; value: string; node: SchemaNode }[] = [];\n for (const propertyName of dependentPropertyNames) {\n if (hasProperty(data, propertyName)) {\n const value = data[propertyName];\n if (dependentProperties[propertyName][value as string]) {\n matchingSchemata.push({\n property: propertyName,\n value: `${value}`,\n node: dependentProperties[propertyName][value as string]\n });\n }\n }\n }\n return matchingSchemata;\n}\n\n/**\n * @experimental `propertyDependencies` to resolve schema by nested name and value\n * @reference https://docs.google.com/presentation/d/1ajXlCQcsjjiMLsluFIILR7sN5aDRBnfqQ9DLbcFbqjI/mobilepresent?slide=id.p\n *\n * - matching schemas are resolved and validiated\n * - multiple matching schemas are resolved and validiated\n * - ignores keyword if no schema is matched\n *\n * @example\n * {\n * type: \"object\",\n * propertyDependencies: {\n * propertyName: {\n * propertyValue: { $ref: \"#/$defs/schema\" }\n * }\n * }\n * }\n *\n * matches\n *\n * {\n * \"propertyName\": \"propertyValue\",\n * \"otherData\": 123\n * } with \"#/$defs/schema\"\n */\nexport const propertyDependenciesKeyword: Keyword = {\n id: KEYWORD,\n keyword: KEYWORD,\n parse: parsePropertyDependencies,\n addValidate: (node) => node[KEYWORD] != null,\n validate: validatePropertyDependencies,\n addReduce: (node) => node[KEYWORD] != null,\n reduce: reducePropertyDependencies\n};\n\nfunction parsePropertyDependencies(node: SchemaNode) {\n const propertyDependencies = node.schema[KEYWORD];\n if (!isObject(propertyDependencies)) {\n return node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}`,\n schema: node.schema,\n value: propertyDependencies,\n message: `Keyword '${KEYWORD}' must be an object - received '${typeof propertyDependencies}'`\n });\n }\n const parsed: Record<string, Record<string, SchemaNode>> = {};\n const errors: ValidationAnnotation[] = [];\n Object.keys(propertyDependencies).map((propertyName) => {\n const values = propertyDependencies[propertyName];\n if (!isObject(values)) {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}/${propertyName}`,\n schema: node.schema,\n value: propertyDependencies,\n message: `Keyword '${KEYWORD}[string]' must be an object - received '${typeof propertyDependencies}'`\n })\n );\n return;\n }\n Object.keys(values).forEach((value) => {\n const schema = values[value];\n if (!(isJsonSchema(schema) || isBooleanSchema(schema))) {\n errors.push(\n node.createError(\"schema-error\", {\n pointer: `${node.schemaLocation}/${KEYWORD}/${propertyName}/${value}`,\n schema: node.schema,\n value: schema,\n message: `Keyword '${KEYWORD}[string][string]' must be a valid JSON Schema - received '${typeof schema}'`\n })\n );\n return;\n }\n parsed[propertyName] = parsed[propertyName] ?? {};\n parsed[propertyName][value] = node.compileSchema(\n schema,\n `${node.evaluationPath}/${KEYWORD}/${propertyName}/${value}`,\n `${node.schemaLocation}/${KEYWORD}/${propertyName}/${value}`\n );\n collectValidationErrors(errors, parsed[propertyName][value]);\n });\n });\n node[KEYWORD] = parsed;\n return errors;\n}\n\nfunction validatePropertyDependencies({ node, data, pointer = \"#\", path }: JsonSchemaValidatorParams) {\n if (!isObject(data)) {\n return undefined;\n }\n const matchingSchemata = findMatchingSchemata(node, data);\n if (matchingSchemata == null || matchingSchemata.length === 0) {\n return undefined;\n }\n const errors: ValidationReturnType[] = [];\n for (const match of matchingSchemata) {\n const result = validateNode(match.node, data, pointer, path);\n errors.push(result);\n }\n return sanitizeErrors(errors);\n}\n\nfunction reducePropertyDependencies({ node, data, key, pointer, path }: JsonSchemaReducerParams) {\n if (!isObject(data)) {\n return undefined;\n }\n const matchingSchemata = findMatchingSchemata(node, data);\n if (matchingSchemata == null || matchingSchemata.length === 0) {\n return undefined;\n }\n\n let mergedSchema = {};\n let dynamicId = \"\";\n for (const match of matchingSchemata) {\n const { node: schemaNode } = match.node.reduceNode(data, { key, pointer, path });\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const localDynamicId =\n nestedDynamicId === \"\" ? `propertyDependencies/${match.property}/${match.value}` : nestedDynamicId;\n dynamicId += `${dynamicId === \"\" ? \"\" : \",\"}${localDynamicId}`;\n\n const schema = mergeSchema(match.node.schema, schemaNode.schema);\n mergedSchema = mergeSchema(mergedSchema, schema, \"propertyDependencies\");\n }\n }\n\n return node.compileSchema(\n mergedSchema,\n `${node.evaluationPath}/${dynamicId}`,\n node.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n}\n"],"mappings":"sMAMA,SAAwB,EACpB,EACA,EAAiC,EAAE,CACrC,CACE,GAAI,CAAC,MAAM,QAAQ,EAAK,CAIpB,OAHI,IAAS,IAAA,GAGN,EAAE,CAFE,CAAC,EAAK,CAIrB,IAAK,IAAM,KAAQ,EACX,MAAM,QAAQ,EAAK,CACnB,EAAe,EAAM,EAAO,EACrB,GAAa,EAAK,EAAI,aAAgB,UAC7C,EAAO,KAAK,EAAK,CAGzB,OAAO,ECvBX,IAAA,EAAe,CACX,iBAAkB,gBAClB,kBAAmB,CAAC,MAAM,CAC1B,mBAAoB,CAChB,OACA,QACA,KACA,OACA,OACA,QACA,QACA,QACA,mBACA,oBACA,cACA,eACA,oBACA,uBACH,CACD,YAAa,IA0Bb,oBAAqB,CAAC,QAAS,cAAe,UAAW,YAAa,WAAY,YAAY,CACjG,CC9CD,MAAM,EAAW,OAAO,UAAU,SAclC,SAAgB,EAAU,EAAwB,CACjD,IAAM,EAAO,EAAS,KAAK,EAAM,CAAC,MAAM,EAAG,GAAG,CAAC,aAAa,CAI5D,OAHI,IAAS,OACL,SAED,ECjBR,SAAgB,EAAS,EAA0C,CAC/D,OAAO,EAAU,EAAE,GAAK,SCK5B,SAAgB,EAAa,EAA2B,CAKpD,IAAM,EACF,IAAS,IAAA,GACH,EAAE,CACF,CACI,KA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