@texaryn/schema-json 0.8.1 → 0.8.3

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -2
  3. package/THIRD-PARTY-NOTICES.md +3 -2
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js +0 -2
  6. package/dist/adapter.js.map +1 -1
  7. package/dist/bare-maps.d.ts +1 -1
  8. package/dist/bare-maps.d.ts.map +1 -1
  9. package/dist/bare-maps.js.map +1 -1
  10. package/dist/identity.d.ts +1 -1
  11. package/dist/identity.d.ts.map +1 -1
  12. package/dist/identity.js.map +1 -1
  13. package/dist/metaschemas/2019-09.d.ts +1 -1
  14. package/dist/metaschemas/2019-09.d.ts.map +1 -1
  15. package/dist/metaschemas/2020-12.d.ts +1 -1
  16. package/dist/metaschemas/2020-12.d.ts.map +1 -1
  17. package/dist/metaschemas/draft-07.d.ts +1 -1
  18. package/dist/metaschemas/draft-07.d.ts.map +1 -1
  19. package/dist/metaschemas/index.d.ts +1 -1
  20. package/dist/metaschemas/index.d.ts.map +1 -1
  21. package/dist/projection-validation-coherence.d.ts +1 -1
  22. package/dist/projection-validation-coherence.d.ts.map +1 -1
  23. package/dist/projection-validation-coherence.js.map +1 -1
  24. package/dist/projection.d.ts +1 -1
  25. package/dist/projection.d.ts.map +1 -1
  26. package/dist/projection.js.map +1 -1
  27. package/dist/submission-projection.d.ts +1 -1
  28. package/dist/submission-projection.d.ts.map +1 -1
  29. package/dist/submission-projection.js +19 -3
  30. package/dist/submission-projection.js.map +1 -1
  31. package/dist/vendor/json-schema-library/index.mjs +1 -1
  32. package/dist/vendor/json-schema-library/index.mjs.map +1 -1
  33. package/dist/vendor/json-schema-library/rolldown-runtime-D9-fqq9M.mjs +1 -0
  34. package/package.json +4 -4
  35. package/dist/root-reference.d.ts +0 -4
  36. package/dist/root-reference.d.ts.map +0 -1
  37. package/dist/root-reference.js +0 -86
  38. package/dist/root-reference.js.map +0 -1
@@ -1 +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","$refKeyword","exclusiveMaximumKeyword","exclusiveMinimumKeyword","itemsKeyword","equal","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 /** additional keywords that should not produce an unknown-keyword-warning */\n VALID_ANNOTATION_KEYWORDS: [\"$id\", \"$schema\", \"title\", \"description\", \"default\", \"oneOfProperty\"],\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\", \"default\", \"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 const aIsArray = Array.isArray(a);\n const bIsArray = Array.isArray(b);\n\n if (aIsArray && bIsArray) {\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 // mixed data-type for type keyword\n if (property === \"type\" && (aIsArray || bIsArray)) {\n // we merge to the specific type\n if (aIsArray && a.includes(b)) {\n return b;\n }\n if (bIsArray && b.includes(a)) {\n return a;\n }\n // extend the types if they do not match\n if (aIsArray) {\n return [...a, b];\n }\n if (bIsArray) {\n return [...b, a];\n }\n }\n\n if (bIsArray) {\n return b;\n }\n\n if (aIsArray) {\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\";\nimport { hasProperty } from \"./hasProperty\";\n\nexport function getValue(data: unknown, key: string | number) {\n if (isObject(data) && hasProperty(data, `${key}`)) {\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, VALID_ANNOTATION_KEYWORDS } = 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 & { schemaErrors?: JsonError[]; schemaAnnotations: JsonAnnotation[] };\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\n // parse and validate schema\n // @todo this is a duplicated to compileSchema\n let schemaValidation = addKeywords(remoteNode).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 node.schemaErrors = schemaErrors;\n node.schemaAnnotations = schemaAnnotations;\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) =>\n !key.startsWith(\"x-\") &&\n !VALID_ANNOTATION_KEYWORDS.includes(key) &&\n node.context.keywords.find((keyword) => keyword.keyword === key) == null\n ).forEach((keyword) => {\n errors.push(\n node.createAnnotation(\"unknown-keyword-warning\", {\n $id: node.$id,\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 { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams, ValidationReturnType } 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 for (const propertyName of Object.keys(dependentSchemas)) {\n if (!hasProperty(data, propertyName) && !required.includes(propertyName)) {\n continue;\n }\n const dependency = dependentSchemas[propertyName];\n if (!isSchemaNode(dependency)) {\n continue;\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 { node: reducedDependency, error } = { ...dependency, schema: { ...dependency.schema, required } }.reduceNode(data, {\n key,\n pointer: `${pointer}/${KEYWORD}/${propertyName}`,\n path\n });\n if (error) {\n return error;\n }\n if (!reducedDependency) {\n continue;\n }\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 } else if (Array.isArray(data)) {\n let nodeOfItem: SchemaNode | undefined;\n let schemaOfIndex = -1;\n let errorCount = Infinity;\n\n for (let i = 0; i < node.oneOf.length; i += 1) {\n const oneNode = node.oneOf[i];\n const { errors } = oneNode.validate(data);\n const nextErrorCount = errors.length;\n\n if (nextErrorCount < errorCount) {\n errorCount = nextErrorCount;\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 !== undefined || isRequired || opts.addOptionalProps) {\n const propertyValue = propertyNode.getData(value, opts);\n const dataType = getTypeOf(propertyValue);\n if (\n opts.removeInvalidData &&\n // @attention we do not remove values that might have valid nested values\n dataType !== \"object\" &&\n dataType !== \"array\" &&\n !propertyNode.validate(propertyValue).valid\n ) {\n return;\n }\n\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) => {\n // if we allow additionalProperties, but the current value has a schema that invalidates\n // do not add this value\n const dataType = getTypeOf(key);\n if (\n opts.removeInvalidData &&\n node.properties &&\n node.properties[key] &&\n dataType !== \"object\" &&\n dataType !== \"array\"\n ) {\n const propertyNode = node.properties[key];\n const propertyValue = propertyNode.getData(getValue(data, key), opts);\n if (!propertyNode.validate(propertyValue).valid) {\n return;\n }\n }\n\n if (d[key] == null) {\n d[key] = getValue(data, key);\n }\n });\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 // Properties defined directly on this schema object are always\n // evaluated by the \"properties\" keyword, regardless of whether the\n // value passes validation (per JSON Schema spec, annotations from\n // adjacent keywords are always collected)\n if (node.properties?.[propertyName]) {\n continue;\n }\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.items) {\n const items = node.items.resolveRef();\n if (items?.oneOf) {\n return items.oneOf.map((childNode: SchemaNode) => childNode.resolveRef());\n }\n }\n\n if (node.oneOf) {\n return node.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 (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 !== undefined || isRequired || opts.addOptionalProps) {\n const propertyValue = propertyNode.getData(value, opts);\n const dataType = getTypeOf(propertyValue);\n if (\n opts.removeInvalidData &&\n // @attention we do not remove values that might have valid nested values\n dataType !== \"object\" &&\n dataType !== \"array\" &&\n !propertyNode.validate(propertyValue).valid\n ) {\n return;\n }\n\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 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) => {\n // if we allow additionalProperties, but the current value has a schema that invalidates\n // do not add this value\n const dataType = getTypeOf(key);\n if (\n opts.removeInvalidData &&\n node.properties &&\n node.properties[key] &&\n dataType !== \"object\" &&\n dataType !== \"array\"\n ) {\n const propertyNode = node.properties[key];\n const propertyValue = propertyNode.getData(getValue(data, key), opts);\n if (!propertyNode.validate(propertyValue).valid) {\n return;\n }\n }\n\n if (d[key] == null) {\n d[key] = getValue(data, key);\n }\n });\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 & { schemaErrors?: JsonError[]; schemaAnnotations: JsonAnnotation[] };\n /**\n * a list of remotes to add, requires a unique $id for each schema. Will be ignored if `remote` is set\n */\n remotes?: JsonSchema[];\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 remote = options.remote;\n if (Array.isArray(options.remotes) && options.remotes.length > 0 && !options.remote) {\n const remotes = [...options.remotes];\n remotes.forEach((remote, index) => {\n if (remote.$id == null) {\n throw new Error(`required $id on remotes[${index}] is missing`);\n }\n });\n remote = compileSchema(remotes.shift()!);\n remotes.forEach((r) => remote?.addRemoteSchema(r.$id, r));\n }\n\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 ...(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 (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 error.data.schemaId = node.context.rootNode.$id ?? \"#\";\n schemaErrors.push(error);\n } else if (isJsonAnnotation(error)) {\n error.data.schemaId = node.context.rootNode.$id ?? \"#\";\n schemaAnnotations.push(error);\n }\n });\n if (Array.isArray(remote?.schemaErrors)) {\n schemaErrors.push(...remote.schemaErrors);\n }\n if (Array.isArray(remote?.schemaAnnotations)) {\n schemaAnnotations.push(...remote.schemaAnnotations);\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 * @deprecated\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 dependentValues = dependentProperties[propertyName];\n const value = `${data[propertyName]}`;\n if (hasProperty(dependentValues, value)) {\n matchingSchemata.push({\n property: propertyName,\n value,\n node: dependentValues[value]\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>> = Object.create(null);\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] ?? Object.create(null);\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,CAAC,EACpC,CACE,GAAI,CAAC,MAAM,QAAQ,CAAI,EAInB,OAHI,IAAS,IAAA,GAGN,CAAC,EAFG,CAAC,CAAI,EAIpB,IAAK,IAAM,KAAQ,EACX,MAAM,QAAQ,CAAI,EAClB,EAAe,EAAM,CAAM,GACpB,GAAa,CAAI,GAAK,aAAgB,UAC7C,EAAO,KAAK,CAAI,EAGxB,OAAO,CACX,CCxBA,IAAA,EAAe,CACX,iBAAkB,gBAClB,kBAAmB,CAAC,KAAK,EACzB,mBAAoB,CAChB,OACA,QACA,KACA,OACA,OACA,QACA,QACA,QACA,mBACA,oBACA,cACA,eACA,oBACA,sBACJ,EACA,YAAa,IAEb,0BAA2B,CAAC,MAAO,UAAW,QAAS,cAAe,UAAW,eAAe,EA0BhG,oBAAqB,CAAC,QAAS,cAAe,UAAW,UAAW,YAAa,WAAY,WAAW,CAC5G,EChDA,MAAM,EAAW,OAAO,UAAU,SAclC,SAAgB,EAAU,EAAwB,CACjD,IAAM,EAAO,EAAS,KAAK,CAAK,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,YAAY,EA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AC/D,EAAe,EAAY,EAAc,EAAQ,sBAAsB,CAC3E,CACJ,CAEA,OAAO,EAAK,cACR,EACA,GAAG,EAAK,eAAe,GAAG,IAC1B,EAAK,eACL,GAAG,EAAK,eAAe,GAAG,EAAU,EACxC,CACJ"}
1
+ {"version":3,"file":"index.mjs","names":["suffixes","settings","getDraft","REGEX_FLAGS","addKeywords","DECLARATOR_ONEOF","$refKeyword","parseRef","validateRef","register","resolveRef","resolveRecursiveRef","getRef","settings","compileNext","$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","$refKeyword","exclusiveMaximumKeyword","exclusiveMinimumKeyword","itemsKeyword","equal","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","../node_modules/.pnpm/fast-uri@4.2.1/node_modules/fast-uri/lib/utils.js","../node_modules/.pnpm/fast-uri@4.2.1/node_modules/fast-uri/lib/schemes.js","../node_modules/.pnpm/fast-uri@4.2.1/node_modules/fast-uri/index.js","../src/utils/resolveUri.ts","../src/utils/mergeSchema.ts","../src/utils/pick.ts","../src/mergeNode.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/utils/omit.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 \"$dynamicRef\",\n \"$recursiveRef\",\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 /** additional keywords that should not produce an unknown-keyword-warning */\n VALID_ANNOTATION_KEYWORDS: [\"$id\", \"$schema\", \"title\", \"description\", \"default\", \"oneOfProperty\"],\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\", \"default\", \"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","'use strict'\n\n/** @type {(value: string) => boolean} */\nconst isUUID = RegExp.prototype.test.bind(/^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$/iu)\n\n/** @type {(value: string) => boolean} */\nconst isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)$/u)\n\n/** @type {(value: string) => boolean} */\nconst isPort = RegExp.prototype.test.bind(/^\\d*$/u)\n\n/** @type {(value: string) => boolean} */\nconst isHexPair = RegExp.prototype.test.bind(/^[\\da-f]{2}$/iu)\n\n/** @type {(value: string) => boolean} */\nconst isUnreserved = RegExp.prototype.test.bind(/^[\\da-z\\-._~]$/iu)\n\n/** @type {(value: string) => boolean} */\nconst isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\\-._~!$&'()*+,;=:@/]$/u)\n\n/** @type {(value: string) => boolean} */\nconst isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\\-._~!$&'()*+,;=:@/?]$/u)\n\n/** @type {(value: string) => boolean} */\nconst isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\\-._~!$&'()*+,;=:]$/u)\n\n/**\n * @param {Array<string>} input\n * @returns {string}\n */\nfunction stringArrayToHexStripped (input) {\n let acc = ''\n let code = 0\n let i = 0\n\n for (i = 0; i < input.length; i++) {\n code = input[i].charCodeAt(0)\n if (code === 48) {\n continue\n }\n if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {\n return ''\n }\n acc += input[i]\n break\n }\n\n for (i += 1; i < input.length; i++) {\n code = input[i].charCodeAt(0)\n if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {\n return ''\n }\n acc += input[i]\n }\n return acc\n}\n\n/** @type {(value: string) => boolean} */\nconst isHextet = RegExp.prototype.test.bind(/^[\\dA-Fa-f]{1,4}$/)\n\n/** @type {(value: string) => boolean} */\nconst isIPvFuture = RegExp.prototype.test.bind(/^[vV][\\dA-Fa-f]+\\.[A-Za-z\\d\\-._~!$&'()*+,;=:]+$/)\n\n/** @type {(value: string) => boolean} */\nconst isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\\d\\-._~]$/)\n\n/**\n * @param {string} value\n * @returns {boolean}\n */\nconst nonSimpleDomain = RegExp.prototype.test.bind(/[^!\"$&'()*+,\\-.;=_`a-z{}~]/u)\n\n/** @type {(value: string) => boolean} */\nconst nonSimpleDomainChars = RegExp.prototype.test.bind(/[^\\d!\"$&'()*+,\\-.;=_`a-z{}~]/u)\n\n/** @type {(value: string) => boolean} */\nconst numericLastLabel = RegExp.prototype.test.bind(/(?:^|\\.)\\d+$/u)\n\n/**\n * True when `new URL('http://' + domain).hostname` may differ from `domain`,\n * i.e. when the caller must fall back to the WHATWG parser.\n *\n * Same purpose as `nonSimpleDomain`, but digits are allowed: for this character\n * set `hostname` is the identity, *except* that an all-numeric final label is\n * read as IPv4 shorthand (\"1.2.3\" -> \"1.2.0.3\", \"127.1\" -> \"127.0.0.1\",\n * \"a.b.1\" throws), which is why `nonSimpleDomain` excludes digits outright.\n * Rejecting that one shape lets the common `mail2.example.org` case stay on the\n * fast path.\n *\n * @param {string} domain - must already be lowercased\n * @returns {boolean}\n */\nfunction nonSimpleMailtoDomain (domain) {\n return nonSimpleDomainChars(domain) || numericLastLabel(domain)\n}\n\n/**\n * @param {string} zone\n * @returns {boolean}\n */\nfunction isZoneIdentifier (zone) {\n if (zone.length === 0) return false\n\n for (let i = 0; i < zone.length; i++) {\n if (isZoneCharacter(zone[i])) continue\n if (zone[i] === '%' && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {\n i += 2\n continue\n }\n return false\n }\n\n return true\n}\n\n/**\n * Compresses the longest run of zero hextets to \"::\" per RFC 5952. A run of a\n * single zero hextet is left uncompressed. On ties the leftmost run wins.\n *\n * @param {string[]} hextets\n * @returns {string}\n */\nfunction compressIPv6ZeroRun (hextets) {\n let bestStart = -1\n let bestLength = 0\n let runStart = -1\n let runLength = 0\n for (let i = 0; i < hextets.length; i++) {\n if (hextets[i] === '0') {\n if (runStart === -1) runStart = i\n runLength++\n if (runLength > bestLength) {\n bestLength = runLength\n bestStart = runStart\n }\n } else {\n runStart = -1\n runLength = 0\n }\n }\n\n if (bestLength < 2) return hextets.join(':')\n\n const head = hextets.slice(0, bestStart).join(':')\n const tail = hextets.slice(bestStart + bestLength).join(':')\n return head + '::' + tail\n}\n\n/**\n * Validates an IPv6 address against the alternatives in RFC 3986 section\n * 3.2.2 and returns the same address with leading hextet zeroes removed.\n * An embedded IPv4 address counts as two hextets and is only valid at the end.\n *\n * @param {string} input\n * @returns {string|undefined}\n */\nfunction normalizeIPv6Address (input) {\n const compression = input.indexOf('::')\n if (compression !== -1 && input.indexOf('::', compression + 1) !== -1) return undefined\n\n const left = compression === -1 ? input.split(':') : input.slice(0, compression).split(':')\n const right = compression === -1 ? [] : input.slice(compression + 2).split(':')\n if (compression !== -1) {\n if (left.length === 1 && left[0] === '') left.length = 0\n if (right.length === 1 && right[0] === '') right.length = 0\n }\n\n const parts = left.concat(right)\n let hextetCount = 0\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i]\n if (part === '') return undefined\n\n if (part.indexOf('.') !== -1) {\n if (i !== parts.length - 1 || (compression !== -1 && right.length === 0) || !isIPv4(part)) return undefined\n hextetCount += 2\n continue\n }\n\n if (!isHextet(part)) return undefined\n parts[i] = parseInt(part, 16).toString(16)\n hextetCount++\n }\n\n if (compression === -1) {\n if (hextetCount !== 8) return undefined\n return compressIPv6ZeroRun(parts)\n }\n if (hextetCount >= 8) return undefined\n\n // expand \"::\" then re-compress the longest run for a canonical result\n const expanded = parts.slice(0, left.length)\n for (let i = hextetCount; i < 8; i++) expanded.push('0')\n for (let i = left.length; i < parts.length; i++) expanded.push(parts[i])\n return compressIPv6ZeroRun(expanded)\n}\n\n/**\n * @typedef {Object} NormalizeIPv6Result\n * @property {string} host - The normalized host.\n * @property {string} [escapedHost] - The escaped host.\n * @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.\n * @property {boolean} [isIPVFuture] - Indicates if the host is an IPvFuture literal.\n * @property {boolean} [error] - Indicates if a bracketed IP literal is malformed.\n */\n\n/**\n * Validates and normalizes a bracketed IP literal. Raw zone separators remain\n * accepted for backwards compatibility, while encoded separators and zone\n * contents follow RFC 6874.\n *\n * @param {string} host\n * @returns {NormalizeIPv6Result}\n */\nfunction normalizeIPv6 (host) {\n const bracketed = host[0] === '[' && host[host.length - 1] === ']'\n const hasBracket = host[0] === '[' || host[host.length - 1] === ']'\n if (hasBracket && !bracketed) return { host, isIPV6: false, error: true }\n\n let input = bracketed ? host.slice(1, -1) : host\n if (bracketed && isIPvFuture(input)) {\n input = input.toLowerCase()\n return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true }\n }\n\n if (findToken(input, ':') < 2) {\n return { host, isIPV6: false, error: bracketed }\n }\n\n let zoneIdentifier = ''\n const zoneSeparator = input.indexOf('%')\n if (zoneSeparator !== -1) {\n const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === '%25' ? 3 : 1\n zoneIdentifier = input.slice(zoneSeparator + separatorLength)\n if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true }\n input = input.slice(0, zoneSeparator)\n }\n\n const address = normalizeIPv6Address(input)\n if (address === undefined) return { host, isIPV6: false, error: true }\n\n return {\n host: address + (zoneIdentifier ? '%' + zoneIdentifier : ''),\n escapedHost: address + (zoneIdentifier ? '%25' + zoneIdentifier : ''),\n isIPV6: true\n }\n}\n\n/**\n * @param {string} str\n * @param {string} token\n * @returns {number}\n */\nfunction findToken (str, token) {\n let ind = 0\n for (let i = 0; i < str.length; i++) {\n if (str[i] === token) ind++\n }\n return ind\n}\n\n/**\n * @param {string} path\n * @returns {string}\n *\n * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4\n */\nfunction removeDotSegments (path) {\n let input = path\n const output = []\n let nextSlash = -1\n let len = 0\n\n // eslint-disable-next-line no-cond-assign\n while (len = input.length) {\n if (len === 1) {\n if (input === '.') {\n break\n } else if (input === '/') {\n output.push('/')\n break\n } else {\n output.push(input)\n break\n }\n } else if (len === 2) {\n if (input[0] === '.') {\n if (input[1] === '.') {\n break\n } else if (input[1] === '/') {\n input = input.slice(2)\n continue\n }\n } else if (input[0] === '/') {\n if (input[1] === '.') {\n output.push('/')\n break\n }\n }\n } else if (len === 3) {\n if (input === '/..') {\n if (output.length !== 0) {\n output.pop()\n }\n output.push('/')\n break\n }\n }\n if (input[0] === '.') {\n if (input[1] === '.') {\n if (input[2] === '/') {\n input = input.slice(3)\n continue\n }\n } else if (input[1] === '/') {\n input = input.slice(2)\n continue\n }\n } else if (input[0] === '/') {\n if (input[1] === '.') {\n if (input[2] === '/') {\n input = input.slice(2)\n continue\n } else if (input[2] === '.') {\n if (input[3] === '/') {\n input = input.slice(3)\n if (output.length !== 0) {\n output.pop()\n }\n continue\n }\n }\n }\n }\n\n // Rule 2E: Move normal path segment to output\n if ((nextSlash = input.indexOf('/', 1)) === -1) {\n output.push(input)\n break\n } else {\n output.push(input.slice(0, nextSlash))\n input = input.slice(nextSlash)\n }\n }\n\n return output.join('')\n}\n\n/**\n * Re-escape RFC 3986 gen-delims that must not appear literally in the host.\n * After the URI regex parses, these characters cannot be literal in the host\n * field, so any that appear after decoding came from percent-encoding and\n * must be restored to prevent authority structure changes.\n *\n * @param {string} host\n * @param {boolean} isIP - true for IPv4/IPv6 hosts (skip colon re-escaping)\n * @returns {string}\n */\nconst HOST_DELIMS = { '@': '%40', '/': '%2F', '?': '%3F', '#': '%23', ':': '%3A' }\nconst HOST_DELIM_RE = /[@/?#:]/g\nconst HOST_DELIM_NO_COLON_RE = /[@/?#]/g\n\nfunction reescapeHostDelimiters (host, isIP) {\n const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE\n re.lastIndex = 0\n return host.replace(re, (ch) => HOST_DELIMS[ch])\n}\n\n/**\n * Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.\n * Reserved delimiters such as `%2F` stay escaped; `%2E` is unreserved.\n *\n * @param {string} input\n * @param {boolean} [decodeUnreserved=false]\n * @returns {string}\n */\nfunction normalizePercentEncoding (input, decodeUnreserved = false) {\n if (input.indexOf('%') === -1) {\n return input\n }\n\n let output = ''\n\n for (let i = 0; i < input.length; i++) {\n if (input[i] === '%' && i + 2 < input.length) {\n const hex = input.slice(i + 1, i + 3)\n if (isHexPair(hex)) {\n const normalizedHex = hex.toUpperCase()\n const decoded = String.fromCharCode(parseInt(normalizedHex, 16))\n\n if (decodeUnreserved && isUnreserved(decoded)) {\n output += decoded\n } else {\n output += '%' + normalizedHex\n }\n\n i += 2\n continue\n }\n }\n\n output += input[i]\n }\n\n return output\n}\n\n/** Pre-built `%XX` strings for every byte. Avoids per-call hex math/concat. */\nconst BYTE_HEX = new Array(256)\n{\n const HEX_DIGITS = '0123456789ABCDEF'\n for (let i = 0; i < 256; i++) {\n BYTE_HEX[i] = '%' + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 0xF]\n }\n}\n\n/**\n * Mirrors the pass-through set of the deprecated `escape()` global:\n * `A-Z a-z 0-9 * + - . / @ _`. Keeps drop-in semantics for ASCII input.\n *\n * @param {number} cp\n * @returns {boolean}\n */\nfunction isEscapeSafe (cp) {\n return (\n (cp >= 0x30 && cp <= 0x39) ||\n (cp >= 0x41 && cp <= 0x5A) ||\n (cp >= 0x61 && cp <= 0x7A) ||\n cp === 0x2A || cp === 0x2B || cp === 0x2D || cp === 0x2E ||\n cp === 0x2F || cp === 0x40 || cp === 0x5F\n )\n}\n\n/**\n * RFC 3986 percent-encode a non-ASCII Unicode code point as UTF-8 bytes.\n * Caller handles the ASCII branch inline for speed.\n *\n * @param {number} cp - Unicode code point (>= 0x80, <= 0x10FFFF)\n * @returns {string}\n */\nfunction percentEncodeNonAscii (cp) {\n if (cp < 0x800) {\n return BYTE_HEX[0xC0 | (cp >> 6)] +\n BYTE_HEX[0x80 | (cp & 0x3F)]\n }\n if (cp < 0x10000) {\n return BYTE_HEX[0xE0 | (cp >> 12)] +\n BYTE_HEX[0x80 | ((cp >> 6) & 0x3F)] +\n BYTE_HEX[0x80 | (cp & 0x3F)]\n }\n return BYTE_HEX[0xF0 | (cp >> 18)] +\n BYTE_HEX[0x80 | ((cp >> 12) & 0x3F)] +\n BYTE_HEX[0x80 | ((cp >> 6) & 0x3F)] +\n BYTE_HEX[0x80 | (cp & 0x3F)]\n}\n\n/**\n * Normalizes path data without turning reserved escapes into live path syntax.\n * Valid escapes are uppercased, raw unsafe characters are escaped, and only\n * unreserved bytes that are not `.` are decoded.\n *\n * @param {string} input\n * @returns {string}\n */\nfunction normalizePathEncoding (input) {\n let output = ''\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i]\n if (ch === '%' && i + 2 < input.length) {\n const hex = input.slice(i + 1, i + 3)\n if (isHexPair(hex)) {\n const normalizedHex = hex.toUpperCase()\n const decoded = String.fromCharCode(parseInt(normalizedHex, 16))\n\n if (decoded !== '.' && isUnreserved(decoded)) {\n output += decoded\n } else {\n output += '%' + normalizedHex\n }\n\n i += 2\n continue\n }\n }\n\n if (isPathCharacter(ch)) {\n output += ch\n } else {\n const code = input.charCodeAt(i)\n if (code < 0x80) {\n output += isEscapeSafe(code) ? ch : BYTE_HEX[code]\n } else if (code < 0xD800 || code > 0xDFFF) {\n output += percentEncodeNonAscii(code)\n } else if (code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))\n i++\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n }\n }\n\n return output\n}\n\n/**\n * Serializes a path without rewriting reserved data. Raw RFC 3986 path\n * characters remain literal, valid escapes are preserved and uppercased, and\n * everything else is UTF-8 percent-encoded. In a path-noscheme, a colon in the\n * first segment must be escaped so the result cannot be parsed as a scheme.\n *\n * @param {string} input\n * @param {boolean} [pathNoScheme=false]\n * @returns {string}\n */\nfunction serializePathEncoding (input, pathNoScheme = false) {\n let output = ''\n let firstSegment = pathNoScheme && input[0] !== '/'\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i]\n if (ch === '%' && i + 2 < input.length) {\n const hex = input.slice(i + 1, i + 3)\n if (isHexPair(hex)) {\n output += '%' + hex.toUpperCase()\n i += 2\n continue\n }\n }\n\n if (ch === '/') {\n firstSegment = false\n }\n\n if (isPathCharacter(ch) && (ch !== ':' || !firstSegment)) {\n output += ch\n } else {\n const code = input.charCodeAt(i)\n if (code < 0x80) {\n output += BYTE_HEX[code]\n } else if (code < 0xD800 || code > 0xDFFF) {\n output += percentEncodeNonAscii(code)\n } else if (code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))\n i++\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n }\n }\n\n return output\n}\n\n/**\n * Normalizes the percent-encoding of a query or fragment component.\n *\n * Like `normalizePathEncoding`, but uses the query/fragment character set\n * (which additionally allows `?`) and decodes `.` since it has no dot-segment\n * meaning outside of a path.\n *\n * @param {string} input\n * @returns {string}\n */\nfunction normalizeQueryFragmentEncoding (input) {\n let output = ''\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i]\n if (ch === '%' && i + 2 < input.length) {\n const hex = input.slice(i + 1, i + 3)\n if (isHexPair(hex)) {\n const normalizedHex = hex.toUpperCase()\n const decoded = String.fromCharCode(parseInt(normalizedHex, 16))\n\n if (isUnreserved(decoded)) {\n output += decoded\n } else {\n output += '%' + normalizedHex\n }\n\n i += 2\n continue\n }\n }\n\n if (isQueryFragmentCharacter(ch)) {\n output += ch\n } else {\n const code = input.charCodeAt(i)\n if (code < 0x80) {\n output += isEscapeSafe(code) ? ch : BYTE_HEX[code]\n } else if (code < 0xD800 || code > 0xDFFF) {\n output += percentEncodeNonAscii(code)\n } else if (code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))\n i++\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n }\n }\n\n return output\n}\n\n/**\n * Percent-encodes a URI component using its RFC 3986 literal character set.\n * Existing valid escapes are preserved and normalized to uppercase hex.\n *\n * @param {string} input\n * @param {(value: string) => boolean} isAllowed\n * @returns {string}\n */\nfunction encodeComponent (input, isAllowed) {\n let output = ''\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i]\n if (ch === '%' && i + 2 < input.length) {\n const hex = input.slice(i + 1, i + 3)\n if (isHexPair(hex)) {\n output += '%' + hex.toUpperCase()\n i += 2\n continue\n }\n }\n\n if (isAllowed(ch)) {\n output += ch\n } else {\n const code = input.charCodeAt(i)\n if (code < 0x80) {\n output += BYTE_HEX[code]\n } else if (code < 0xD800 || code > 0xDFFF) {\n output += percentEncodeNonAscii(code)\n } else if (code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))\n i++\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n }\n }\n\n return output\n}\n\n/**\n * Encodes userinfo while preserving its RFC 3986 §3.2.1 literal characters.\n * In particular, authority delimiters such as `@`, `/`, `?`, and `#` are data.\n *\n * @param {string} input\n * @returns {string}\n */\nfunction encodeUserinfo (input) {\n return encodeComponent(input, isUserinfoCharacter)\n}\n\n/**\n * Encodes query data using the RFC 3986 §3.4 grammar. A literal `#` must be\n * escaped because it would otherwise begin the fragment component.\n *\n * @param {string} input\n * @returns {string}\n */\nfunction encodeQuery (input) {\n return encodeComponent(input, isQueryFragmentCharacter)\n}\n\n/**\n * Encodes fragment data using the RFC 3986 §3.5 grammar.\n *\n * @param {string} input\n * @returns {string}\n */\nfunction encodeFragment (input) {\n return encodeComponent(input, isQueryFragmentCharacter)\n}\n\n/**\n * Escapes a component while preserving existing valid percent escapes.\n *\n * @param {string} input\n * @returns {string}\n */\nfunction escapePreservingEscapes (input) {\n let output = ''\n\n for (let i = 0; i < input.length; i++) {\n const ch = input[i]\n if (ch === '%' && i + 2 < input.length) {\n const hex = input.slice(i + 1, i + 3)\n if (isHexPair(hex)) {\n output += '%' + hex.toUpperCase()\n i += 2\n continue\n }\n }\n\n const code = input.charCodeAt(i)\n if (code < 0x80) {\n output += isEscapeSafe(code) ? ch : BYTE_HEX[code]\n } else if (code < 0xD800 || code > 0xDFFF) {\n output += percentEncodeNonAscii(code)\n } else if (code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))\n i++\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n } else {\n output += percentEncodeNonAscii(0xFFFD)\n }\n }\n\n return output\n}\n\n/**\n * Rebuilds the bracketed form of a zoned IPv6 authority from the current\n * `component.host` and its zone identifier (`component.ipv6Zone`), but only\n * when they are consistent and describe a real zoned IPv6 literal that\n * normalizes back to `component.host`. This validates the zone on use, so a\n * caller-supplied `ipv6Zone` that does not match the host (or a host\n * reassigned after `parse`) is never trusted and recomposition falls back to\n * the normal path.\n *\n * @param {import('../types/index').URIComponent} component\n * @returns {string|undefined}\n */\nfunction recomposeZonedIPv6Host (component) {\n const zone = component.ipv6Zone\n // Without an ipv6Zone the single-\"%\" host form is genuinely ambiguous when\n // the zone begins with \"25\", so we fall through to the best-effort heuristic\n // (which matches the pre-existing behavior for hand-built components that do\n // not carry a zone).\n if (zone === undefined) return undefined\n const host = component.host\n const separator = host.indexOf('%')\n if (separator === -1) return undefined\n const address = host.slice(0, separator)\n const escaped = address + '%25' + zone\n const derived = normalizeIPv6('[' + escaped + ']')\n if (derived.isIPV6 === true && derived.host === host) {\n return '[' + escaped + ']'\n }\n return undefined\n}\n\n/**\n * @param {import('../types/index').URIComponent} component\n * @returns {string|undefined}\n */\nfunction recomposeAuthority (component) {\n const uriTokens = []\n\n if (component.userinfo !== undefined) {\n uriTokens.push(encodeUserinfo(component.userinfo))\n uriTokens.push('@')\n }\n\n if (component.host !== undefined) {\n let host = component.host\n if (!isIPv4(host)) {\n // A parse-time zone identifier is authoritative only while it still\n // describes the current host. Re-deriving an IPv6 zone from the\n // single-\"%\" component form is ambiguous when the zone begins with\n // \"25\": it is misread as a %25 separator, rewriting e.g. zone\n // \"25eth0\" into \"eth0\" (or destroying a zone of just \"25\"). A\n // validated zone keeps parse, normalize, serialize and equal in\n // agreement.\n const zonedHost = recomposeZonedIPv6Host(component)\n if (zonedHost !== undefined) {\n host = zonedHost\n } else {\n let ipV6res = normalizeIPv6(host)\n if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {\n // Decode only unreserved bytes, once. In particular, keep %25\n // encoded so it cannot introduce a second escape during\n // recomposition.\n host = normalizePercentEncoding(host, true)\n ipV6res = normalizeIPv6(host)\n }\n if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {\n host = `[${ipV6res.escapedHost}]`\n } else {\n host = reescapeHostDelimiters(host, false)\n }\n }\n }\n uriTokens.push(host)\n }\n\n if (typeof component.port === 'number' || typeof component.port === 'string') {\n const port = String(component.port)\n if (!isPort(port)) {\n throw new TypeError('URI port is malformed.')\n }\n uriTokens.push(':')\n uriTokens.push(port)\n }\n\n return uriTokens.length ? uriTokens.join('') : undefined\n};\n\nmodule.exports = {\n BYTE_HEX,\n percentEncodeNonAscii,\n nonSimpleDomain,\n nonSimpleMailtoDomain,\n recomposeAuthority,\n reescapeHostDelimiters,\n normalizePercentEncoding,\n normalizePathEncoding,\n serializePathEncoding,\n normalizeQueryFragmentEncoding,\n encodeUserinfo,\n encodeQuery,\n encodeFragment,\n escapePreservingEscapes,\n removeDotSegments,\n isIPv4,\n isUUID,\n normalizeIPv6,\n stringArrayToHexStripped\n}\n","'use strict'\n\nconst { isUUID, BYTE_HEX, percentEncodeNonAscii, nonSimpleMailtoDomain } = require('./utils')\nconst URN_REG = /^([\\da-z][\\d\\-a-z]{0,31}):((?:[\\w!$'()*+,\\-./:;=@]|%[\\da-f]{2})+)$/iu\n\nconst supportedSchemeNames = /** @type {const} */ (['http', 'https', 'ws',\n 'wss', 'urn', 'urn:uuid', 'mailto'])\n\n/** @typedef {supportedSchemeNames[number]} SchemeName */\n\n/**\n * @param {string} name\n * @returns {name is SchemeName}\n */\nfunction isValidSchemeName (name) {\n return supportedSchemeNames.indexOf(/** @type {*} */ (name)) !== -1\n}\n\n/**\n * @callback SchemeFn\n * @param {import('../types/index').URIComponent} component\n * @param {import('../types/index').Options} options\n * @returns {import('../types/index').URIComponent}\n */\n\n/**\n * @typedef {Object} SchemeHandler\n * @property {SchemeName} scheme - The scheme name.\n * @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.\n * @property {SchemeFn} parse - Function to parse the URI component for this scheme.\n * @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.\n * @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.\n * @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.\n * @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.\n */\n\n/**\n * @param {import('../types/index').URIComponent} wsComponent\n * @returns {boolean}\n */\nfunction wsIsSecure (wsComponent) {\n if (wsComponent.secure === true) {\n return true\n } else if (wsComponent.secure === false) {\n return false\n } else if (wsComponent.scheme) {\n return (\n wsComponent.scheme.length === 3 &&\n (wsComponent.scheme[0] === 'w' || wsComponent.scheme[0] === 'W') &&\n (wsComponent.scheme[1] === 's' || wsComponent.scheme[1] === 'S') &&\n (wsComponent.scheme[2] === 's' || wsComponent.scheme[2] === 'S')\n )\n } else {\n return false\n }\n}\n\n/** @type {SchemeFn} */\nfunction httpParse (component) {\n if (!component.host) {\n component.error = component.error || 'HTTP URIs must have a host.'\n }\n\n return component\n}\n\n/** @type {SchemeFn} */\nfunction httpSerialize (component) {\n const secure = String(component.scheme).toLowerCase() === 'https'\n\n // normalize the default port\n if (component.port === (secure ? 443 : 80) || component.port === '') {\n component.port = undefined\n }\n\n // normalize the empty path\n if (!component.path) {\n component.path = '/'\n }\n\n // NOTE: We do not parse query strings for HTTP URIs\n // as WWW Form Url Encoded query strings are part of the HTML4+ spec,\n // and not the HTTP spec.\n\n return component\n}\n\n/** @type {SchemeFn} */\nfunction wsParse (wsComponent) {\n// indicate if the secure flag is set\n wsComponent.secure = wsIsSecure(wsComponent)\n\n // construct resouce name\n wsComponent.resourceName = (wsComponent.path || '/') + (wsComponent.query ? '?' + wsComponent.query : '')\n wsComponent.path = undefined\n wsComponent.query = undefined\n\n return wsComponent\n}\n\n/** @type {SchemeFn} */\nfunction wsSerialize (wsComponent) {\n// normalize the default port\n if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === '') {\n wsComponent.port = undefined\n }\n\n // ensure scheme matches secure flag\n if (typeof wsComponent.secure === 'boolean') {\n wsComponent.scheme = (wsComponent.secure ? 'wss' : 'ws')\n wsComponent.secure = undefined\n }\n\n // reconstruct path from resource name\n if (wsComponent.resourceName) {\n const queryIndex = wsComponent.resourceName.indexOf('?')\n const path = queryIndex === -1\n ? wsComponent.resourceName\n : wsComponent.resourceName.slice(0, queryIndex)\n wsComponent.path = (path && path !== '/' ? path : undefined)\n wsComponent.query = queryIndex === -1\n ? undefined\n : wsComponent.resourceName.slice(queryIndex + 1)\n wsComponent.resourceName = undefined\n }\n\n // forbid fragment component\n wsComponent.fragment = undefined\n\n return wsComponent\n}\n\n/** @type {SchemeFn} */\nfunction urnParse (urnComponent, options) {\n if (!urnComponent.path) {\n urnComponent.error = 'URN can not be parsed'\n return urnComponent\n }\n const matches = urnComponent.path.match(URN_REG)\n if (matches && matches[0] === urnComponent.path) {\n const scheme = options.scheme || urnComponent.scheme || 'urn'\n urnComponent.nid = matches[1].toLowerCase()\n urnComponent.nss = matches[2]\n const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`\n const schemeHandler = getSchemeHandler(urnScheme)\n urnComponent.path = undefined\n\n if (schemeHandler) {\n urnComponent = schemeHandler.parse(urnComponent, options)\n }\n } else {\n urnComponent.error = urnComponent.error || 'URN can not be parsed.'\n }\n\n return urnComponent\n}\n\n/** @type {SchemeFn} */\nfunction urnSerialize (urnComponent, options) {\n if (urnComponent.nid === undefined) {\n throw new Error('URN without nid cannot be serialized')\n }\n const scheme = options.scheme || urnComponent.scheme || 'urn'\n const nid = urnComponent.nid.toLowerCase()\n const urnScheme = `${scheme}:${options.nid || nid}`\n const schemeHandler = getSchemeHandler(urnScheme)\n\n if (schemeHandler) {\n urnComponent = schemeHandler.serialize(urnComponent, options)\n }\n\n const uriComponent = urnComponent\n const nss = urnComponent.nss\n uriComponent.path = `${nid || options.nid}:${nss}`\n\n options.skipEscape = true\n return uriComponent\n}\n\n/** @type {SchemeFn} */\nfunction urnuuidParse (urnComponent, options) {\n const uuidComponent = urnComponent\n uuidComponent.uuid = uuidComponent.nss\n uuidComponent.nss = undefined\n\n if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {\n uuidComponent.error = uuidComponent.error || 'UUID is not valid.'\n }\n\n return uuidComponent\n}\n\n/** @type {SchemeFn} */\nfunction urnuuidSerialize (uuidComponent) {\n const urnComponent = uuidComponent\n // normalize UUID\n urnComponent.nss = (uuidComponent.uuid || '').toLowerCase()\n return urnComponent\n}\n\nconst http = /** @type {SchemeHandler} */ ({\n scheme: 'http',\n domainHost: true,\n parse: httpParse,\n serialize: httpSerialize\n})\n\nconst https = /** @type {SchemeHandler} */ ({\n scheme: 'https',\n domainHost: http.domainHost,\n parse: httpParse,\n serialize: httpSerialize\n})\n\nconst ws = /** @type {SchemeHandler} */ ({\n scheme: 'ws',\n domainHost: true,\n parse: wsParse,\n serialize: wsSerialize\n})\n\nconst wss = /** @type {SchemeHandler} */ ({\n scheme: 'wss',\n domainHost: ws.domainHost,\n parse: ws.parse,\n serialize: ws.serialize\n})\n\nconst urn = /** @type {SchemeHandler} */ ({\n scheme: 'urn',\n parse: urnParse,\n serialize: urnSerialize,\n skipNormalize: true\n})\n\nconst urnuuid = /** @type {SchemeHandler} */ ({\n scheme: 'urn:uuid',\n parse: urnuuidParse,\n serialize: urnuuidSerialize,\n skipNormalize: true\n})\n\n/**\n * Allow-sets for `encodeWithAllow`, each a `{ all, table, allowNonAscii }`\n * descriptor built by `allowSet`:\n *\n * - `LOCAL_PART` is the intersection of upstream uri-js's VCHAR and\n * NOT_PATH_NOSCHEME, minus \",\": the serializer joins recipients with \",\" and\n * `mailtoParse` splits the path on it, so a comma left literal inside a local\n * part would silently become a recipient delimiter.\n * - `HFNAME` is the qchar allow-set used for header names/values.\n * - `DTEXT` is RFC 6068 dtext-no-obs restricted to characters that are also\n * safe in a URI path; `DTEXT_IRI` additionally permits non-ASCII for\n * `unicodeSupport`.\n */\nconst LOCAL_PART_ALLOWED = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+=\"\nconst HFNAME_ALLOWED = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+,;:@\"\nconst DTEXT_ALLOWED = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+;:\"\n\n/**\n * @typedef {Object} AllowSet\n * @property {RegExp} all - matches a whole string needing no encoding at all.\n * @property {Uint8Array} table - per-ASCII-code allow lookup for the slow path.\n * @property {boolean} allowNonAscii - pass non-ASCII code points through (IRI).\n */\n\n/**\n * `all` deliberately excludes \"%\" and (for the IRI variant) surrogates, so any\n * input needing escape normalization or surrogate repair falls to the slow path.\n *\n * @param {string} chars\n * @param {boolean} [allowNonAscii=false]\n * @returns {AllowSet}\n */\nfunction allowSet (chars, allowNonAscii = false) {\n const table = new Uint8Array(128)\n for (let i = 0; i < chars.length; i++) {\n table[chars.charCodeAt(i)] = 1\n }\n const escaped = chars.replace(/[\\\\\\]^-]/gu, '\\\\$&')\n const cls = allowNonAscii ? `[${escaped}]|[^\\\\0-\\\\x7F\\\\uD800-\\\\uDFFF]` : `[${escaped}]`\n return { all: new RegExp(`^(?:${cls})*$`, 'u'), table, allowNonAscii }\n}\n\nconst LOCAL_PART = allowSet(LOCAL_PART_ALLOWED)\nconst HFNAME = allowSet(HFNAME_ALLOWED)\nconst DTEXT = allowSet(DTEXT_ALLOWED)\nconst DTEXT_IRI = allowSet(DTEXT_ALLOWED, true)\n\nconst HEX_PAIR = /^[\\da-f]{2}$/iu\nconst MAILTO_DOMAIN_LITERAL = /^\\[[\\x21-\\x5A\\x5E-\\x7E]*\\]$/u\nconst MAILTO_DOMAIN_ERROR = 'URI mailto has an invalid recipient domain.'\nconst MAILTO_AUTHORITY_ERROR = 'URI mailto must not have an authority component.'\nconst HAS_SURROGATE = /[\\uD800-\\uDFFF]/u\n\n/**\n * @param {string} str\n * @returns {string}\n */\nfunction decodeHex (str) {\n if (typeof str !== 'string' || str.indexOf('%') === -1) {\n return str\n }\n try {\n return decodeURIComponent(str)\n } catch {\n return str\n }\n}\n\n/**\n * Replaces lone surrogates with U+FFFD, leaving valid pairs intact. Only called\n * when `HAS_SURROGATE` matched, so the scan cost is not on the common path.\n * (`String.prototype.toWellFormed` would do this natively but is Node 20+.)\n *\n * @param {string} input\n * @returns {string}\n */\nfunction replaceLoneSurrogates (input) {\n let result = ''\n for (let i = 0; i < input.length; i++) {\n const code = input.charCodeAt(i)\n if (code >= 0xD800 && code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n result += input[i] + input[i + 1]\n i++\n continue\n }\n }\n result += (code >= 0xD800 && code <= 0xDFFF) ? '\\uFFFD' : input[i]\n }\n return result\n}\n\n/**\n * Percent-encodes everything outside `set`, preserving existing valid escapes\n * (uppercased) and repairing lone surrogates.\n *\n * ASCII uses `BYTE_HEX` rather than `encodeURIComponent`. That is equivalent\n * only because every character `encodeURIComponent` leaves unescaped\n * (`A-Za-z0-9-_.!~*'()`) is present in all of the allow-sets above, so no such\n * character ever reaches the encode branch. Re-check if a set is narrowed.\n *\n * @param {string} input\n * @param {AllowSet} set\n * @returns {string}\n */\nfunction encodeWithAllow (input, set) {\n if (set.all.test(input)) {\n return input\n }\n\n const table = set.table\n let result = ''\n for (let i = 0; i < input.length; i++) {\n const code = input.charCodeAt(i)\n\n if (code < 0x80) {\n if (table[code] === 1) {\n result += input[i]\n } else if (code === 0x25 && i + 2 < input.length && HEX_PAIR.test(input.slice(i + 1, i + 3))) {\n result += '%' + input.slice(i + 1, i + 3).toUpperCase()\n i += 2\n } else {\n result += BYTE_HEX[code]\n }\n continue\n }\n\n if (code < 0xD800 || code > 0xDFFF) {\n result += set.allowNonAscii ? input[i] : percentEncodeNonAscii(code)\n continue\n }\n\n if (code <= 0xDBFF && i + 1 < input.length) {\n const low = input.charCodeAt(i + 1)\n if (low >= 0xDC00 && low <= 0xDFFF) {\n result += set.allowNonAscii\n ? input[i] + input[i + 1]\n : percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))\n i++\n continue\n }\n }\n\n result += set.allowNonAscii ? '\\uFFFD' : percentEncodeNonAscii(0xFFFD)\n }\n return result\n}\n\n/**\n * @param {string} domain\n * @param {import('../types/index').Options} [options]\n * @param {{error?:string}} [component]\n * @returns {string}\n */\nfunction mailtoNormalizeDomain (domain, options, component) {\n const normalizedDomain = String(domain).toLowerCase()\n\n if (MAILTO_DOMAIN_LITERAL.test(normalizedDomain)) {\n return normalizedDomain\n }\n\n // `hostname` is the identity for these, so skip constructing a WHATWG URL.\n if (normalizedDomain !== '' && !nonSimpleMailtoDomain(normalizedDomain)) {\n return normalizedDomain\n }\n\n try {\n const parsedDomain = new URL('http://' + normalizedDomain)\n if (\n parsedDomain.username ||\n parsedDomain.password ||\n parsedDomain.port ||\n parsedDomain.pathname !== '/' ||\n parsedDomain.search ||\n parsedDomain.hash ||\n !parsedDomain.hostname\n ) {\n throw new Error(MAILTO_DOMAIN_ERROR)\n }\n\n return options && options.unicodeSupport\n ? normalizedDomain\n : parsedDomain.hostname\n } catch {\n if (component) {\n component.error = component.error || MAILTO_DOMAIN_ERROR\n }\n return normalizedDomain\n }\n}\n\n/**\n * Percent-encodes everything in a recipient domain that is not `dtext-no-obs`\n * (RFC 6068). Serialize-only: `mailtoNormalizeDomain` returns the domain\n * verbatim when validation fails, and `MAILTO_DOMAIN_LITERAL` accepts the full\n * RFC 5321 dcontent range (which includes \"?\", \"#\", \"&\" and \"/\"), so without\n * this an attacker-supplied recipient could inject header fields or a fragment\n * into the serialized URI. `mailtoParse` deliberately reports the raw domain\n * instead, so it must not use this.\n * @param {string} domain\n * @param {import('../types/index').Options} [options]\n * @returns {string}\n */\nfunction mailtoEncodeDomain (domain, options) {\n const set = options && options.unicodeSupport ? DTEXT_IRI : DTEXT\n\n // Keep the delimiters of a domain literal, encode its contents.\n if (domain.length > 1 && domain[0] === '[' && domain[domain.length - 1] === ']') {\n return '[' + encodeWithAllow(domain.slice(1, -1), set) + ']'\n }\n\n return encodeWithAllow(domain, set)\n}\n\n/**\n * @param {import('../types/index').URIComponent} component\n * @param {import('../types/index').Options} options\n * @returns {import('../types/index').URIComponent}\n */\nfunction mailtoParse (component, options) {\n const mailtoComponent = component\n\n // The handler sets `skipNormalize`, so path and query arrive raw. Everything\n // here goes through `decodeHex`, which subsumes the generic normalizers --\n // except that they also fold lone surrogates to U+FFFD, so do that here.\n let rawPath = mailtoComponent.path\n let rawQuery = mailtoComponent.query\n if (rawPath && HAS_SURROGATE.test(rawPath)) rawPath = replaceLoneSurrogates(rawPath)\n if (rawQuery && HAS_SURROGATE.test(rawQuery)) rawQuery = replaceLoneSurrogates(rawQuery)\n\n const to = rawPath\n ? (rawPath.indexOf(',') === -1 ? [rawPath] : rawPath.split(','))\n : []\n mailtoComponent.path = undefined\n\n if (rawQuery) {\n // Null prototype: header names come from untrusted input, so `headers[name]`\n // must not resolve to inherited members (\"constructor\", \"toString\", ...),\n // and \"__proto__\" has to land as a plain own property instead of hitting\n // Object.prototype's setter and being silently dropped. Allocated lazily so\n // the common subject/body-only URI does not pay for it.\n /** @type {Record<string,string>|null} */\n let headers = null\n let start = 0\n while (start <= rawQuery.length) {\n let end = rawQuery.indexOf('&', start)\n if (end === -1) end = rawQuery.length\n const token = rawQuery.slice(start, end)\n start = end + 1\n\n const eqIdx = token.indexOf('=')\n if (eqIdx !== token.lastIndexOf('=')) {\n mailtoComponent.error = mailtoComponent.error || 'URI mailto has malformed header fields.'\n continue\n }\n const name = decodeHex(eqIdx === -1 ? token : token.slice(0, eqIdx))\n const normalizedName = name.toLowerCase()\n const value = eqIdx === -1 ? '' : token.slice(eqIdx + 1)\n if (normalizedName === 'to') {\n const addrs = value.split(',')\n for (let j = 0; j < addrs.length; j++) to.push(addrs[j])\n continue\n }\n if (normalizedName === 'subject') {\n mailtoComponent.subject = decodeHex(value)\n continue\n }\n if (normalizedName === 'body') {\n mailtoComponent.body = decodeHex(value)\n continue\n }\n if (headers === null) headers = /** @type {Record<string,string>} */ (Object.create(null))\n headers[name] = decodeHex(value)\n }\n if (headers !== null) mailtoComponent.headers = headers\n }\n\n mailtoComponent.query = undefined\n\n // RFC 6068 defines no authority for the `mailto` scheme. A `mailto://` input\n // that retains an authority and also carries recipients (from the path or a\n // `to=` hfield) folds a leading \"/\" into the recipient local part on the\n // next parse; the generic serializer then reinserts a \"/\" before that path\n // on every pass, so serialize(parse(x)) is not a fixpoint and a\n // renormalize-to-fixpoint loop accretes one \"%2F\" per pass. Drop the\n // retained authority so the parse -> serialize round trip is stable. A bare\n // `mailto://host` with no recipients is left as-is: it is idempotent and host\n // normalization for skip-normalize schemes stays intact.\n if (\n to.length > 0 &&\n (mailtoComponent.userinfo !== undefined ||\n mailtoComponent.host !== undefined ||\n mailtoComponent.port !== undefined)\n ) {\n mailtoComponent.userinfo = undefined\n mailtoComponent.host = undefined\n mailtoComponent.port = undefined\n mailtoComponent.error = mailtoComponent.error || MAILTO_AUTHORITY_ERROR\n }\n\n for (let i = 0; i < to.length; i++) {\n const rawAddr = to[i]\n const atIdx = rawAddr.lastIndexOf('@')\n if (atIdx < 0) {\n mailtoComponent.error = mailtoComponent.error || MAILTO_DOMAIN_ERROR\n to[i] = decodeHex(rawAddr)\n continue\n }\n const local = decodeHex(rawAddr.slice(0, atIdx))\n const domain = mailtoNormalizeDomain(decodeHex(rawAddr.slice(atIdx + 1)), options, mailtoComponent)\n to[i] = local + '@' + domain\n }\n\n if (to.length) mailtoComponent.to = to\n\n return mailtoComponent\n}\n\n/**\n * Encodes a decoded mailto header name. Unlike `encodeWithAllow`, a percent\n * sign is always data here, even when followed by two hex digits. Preserving\n * such a sequence as an existing escape would decode the name again on the\n * next parse and could turn a generic header into `to`, `subject`, or `body`.\n * @param {string} name\n * @returns {string}\n */\nfunction mailtoEncodeHeaderName (name) {\n return encodeWithAllow(name.replace(/%/gu, '%25'), HFNAME)\n}\n\n/**\n * @param {import('../types/index').URIComponent} component\n * @param {import('../types/index').Options} options\n * @returns {import('../types/index').URIComponent}\n */\nfunction mailtoSerialize (component, options) {\n const mailtoComponent = component\n const to = Array.isArray(mailtoComponent.to) ? mailtoComponent.to.slice() : []\n const sourceHeaders = mailtoComponent.headers && typeof mailtoComponent.headers === 'object'\n ? Object.assign(Object.create(null), mailtoComponent.headers)\n : Object.create(null)\n const headers = Object.create(null)\n\n // Header field names are case-insensitive. Canonicalize the fields with\n // dedicated component properties so callers cannot smuggle a second spelling\n // through `headers`. As during parsing, all `to` fields are accumulated;\n // repeated subject/body fields use the last value.\n for (const name in sourceHeaders) {\n const normalizedName = name.toLowerCase()\n if (normalizedName === 'to') {\n const addrs = String(sourceHeaders[name]).split(',')\n for (let i = 0; i < addrs.length; i++) to.push(addrs[i])\n } else if (normalizedName === 'subject' || normalizedName === 'body') {\n headers[normalizedName] = sourceHeaders[name]\n } else {\n headers[name] = sourceHeaders[name]\n }\n }\n\n if (mailtoComponent.subject !== undefined) headers.subject = mailtoComponent.subject\n if (mailtoComponent.body !== undefined) headers.body = mailtoComponent.body\n mailtoComponent.headers = headers\n\n if (to.length) {\n // RFC 6068 defines no authority for the `mailto` scheme. If an\n // application constructs a component with both an authority and recipients,\n // drop the authority before the generic serializer can insert a \"/\" path\n // separator that becomes part of the first recipient on the next parse.\n mailtoComponent.userinfo = undefined\n mailtoComponent.host = undefined\n mailtoComponent.port = undefined\n\n for (let i = 0; i < to.length; i++) {\n const addr = String(to[i])\n const atIdx = addr.lastIndexOf('@')\n const rawLocal = atIdx >= 0 ? addr.slice(0, atIdx) : addr\n const rawDomain = atIdx >= 0 ? addr.slice(atIdx + 1) : ''\n const local = encodeWithAllow(rawLocal, LOCAL_PART)\n const decodedDomain = decodeHex(rawDomain)\n // `component` is intentionally not passed: index.js's `serialize` writes\n // the error onto a private copy and returns only a string, so an error\n // recorded here would be unreachable. Safety comes from encoding instead.\n const normalizedDomain = mailtoNormalizeDomain(decodedDomain, options)\n to[i] = local + '@' + mailtoEncodeDomain(normalizedDomain, options)\n }\n // Every recipient is now fully encoded and only the joining commas are\n // literal, so bypass index.js's generic encoder, whose allow-set is\n // narrower than upstream's and would over-encode.\n mailtoComponent.path = to.join(',')\n options.skipEscape = true\n } else {\n // No recipients: drop any caller-supplied path, matching upstream uri-js.\n // `to` is the only recipient source, and `mailtoParse` always moves the\n // path into it, so a mailto component never legitimately carries one.\n mailtoComponent.path = undefined\n }\n\n // `headers` has a null prototype, so every enumerable key is an own property\n // and no hasOwnProperty guard is needed.\n let query = ''\n let count = 0\n for (const name in headers) {\n if (count++ !== 0) query += '&'\n query += mailtoEncodeHeaderName(name) + '=' + encodeWithAllow(String(headers[name]), HFNAME)\n }\n\n if (count !== 0) {\n mailtoComponent.query = query\n } else {\n mailtoComponent.headers = undefined\n }\n\n return mailtoComponent\n}\n\nconst mailto = /** @type {SchemeHandler} */ ({\n scheme: 'mailto',\n parse: mailtoParse,\n serialize: mailtoSerialize,\n domainHost: false,\n unicodeSupport: true,\n // `mailtoParse` re-derives every component from the raw path/query via\n // `decodeHex`, which subsumes the generic normalizers, so running them first\n // is wasted work (~28% of parsing a URI with header fields).\n skipNormalize: true,\n // A recipient list has no dot segments to remove, and `removeDotSegments`\n // would rewrite a \"./\"-prefixed local part.\n absolutePath: true\n})\n\nconst SCHEMES = /** @type {Record<SchemeName, SchemeHandler>} */ ({\n http,\n https,\n ws,\n wss,\n urn,\n 'urn:uuid': urnuuid,\n mailto\n})\n\nObject.setPrototypeOf(SCHEMES, null)\n\n/**\n * @param {string|undefined} scheme\n * @returns {SchemeHandler|undefined}\n */\nfunction getSchemeHandler (scheme) {\n return (\n scheme && (\n SCHEMES[/** @type {SchemeName} */ (scheme)] ||\n SCHEMES[/** @type {SchemeName} */(scheme.toLowerCase())])\n ) ||\n undefined\n}\n\nmodule.exports = {\n wsIsSecure,\n SCHEMES,\n isValidSchemeName,\n getSchemeHandler,\n}\n","'use strict'\n\nconst { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require('./lib/utils')\nconst { SCHEMES, getSchemeHandler } = require('./lib/schemes')\n\nconst VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u\nconst MALFORMED_SCHEME_ERROR = 'URI scheme is malformed.'\n\n/**\n * @param {string} scheme\n * @returns {string}\n */\nfunction decodeValidScheme (scheme) {\n const decodedScheme = unescape(String(scheme))\n if (!VALID_SCHEME.test(decodedScheme)) {\n throw new TypeError(MALFORMED_SCHEME_ERROR)\n }\n return decodedScheme\n}\n\n/**\n * @template {import('./types/index').URIComponent|string} T\n * @param {T} uri\n * @param {import('./types/index').Options} [options]\n * @returns {T}\n */\nfunction normalize (uri, options) {\n if (typeof uri === 'string') {\n uri = /** @type {T} */ (normalizeString(uri, options))\n } else if (typeof uri === 'object') {\n uri = /** @type {T} */ (parse(serialize(uri, options), options))\n }\n return uri\n}\n\n/**\n * @param {string} baseURI\n * @param {string} relativeURI\n * @param {import('./types/index').Options} [options]\n * @returns {string}\n */\nfunction resolve (baseURI, relativeURI, options) {\n const schemelessOptions = options ? Object.assign({ scheme: 'null' }, options) : { scheme: 'null' }\n const {\n parsed: baseParsed,\n malformedAuthorityOrPort: baseMalformed,\n malformedPercentEncoding: baseMalformedPercentEncoding,\n malformedSchemeSpecific: baseMalformedSchemeSpecific,\n malformedHost: baseMalformedHost,\n malformedScheme: baseMalformedScheme\n } = parseWithStatus(baseURI, schemelessOptions)\n const {\n parsed: relativeParsed,\n malformedAuthorityOrPort: relativeMalformed,\n malformedPercentEncoding: relativeMalformedPercentEncoding,\n malformedSchemeSpecific: relativeMalformedSchemeSpecific,\n malformedHost: relativeMalformedHost,\n malformedScheme: relativeMalformedScheme\n } = parseWithStatus(relativeURI, schemelessOptions)\n if (\n baseMalformed ||\n relativeMalformed ||\n baseMalformedPercentEncoding ||\n relativeMalformedPercentEncoding ||\n baseMalformedSchemeSpecific ||\n relativeMalformedSchemeSpecific ||\n baseMalformedHost ||\n relativeMalformedHost ||\n baseMalformedScheme ||\n relativeMalformedScheme\n ) {\n throw new Error(baseParsed.error || relativeParsed.error || 'URI is malformed.')\n }\n const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true)\n const resolvedSchemeHandler = getSchemeHandler((options && options.scheme) || resolved.scheme)\n const resolvedHost = resolved.host\n const resolvedHostIsIP = resolvedHost !== undefined && resolvedHost !== '' &&\n (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6)\n canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)\n // Percent escapes in an ASCII reg-name are encoded data. The WHATWG hostname\n // parser can reject them even though fast-uri preserves them safely as RFC\n // 3986 data. A raw non-ASCII host must still fail closed if conversion fails.\n const encodedASCIIHost = resolvedHost && resolvedHost.indexOf('%') !== -1 &&\n !/\\P{ASCII}/u.test(resolvedHost)\n if (resolved.error && !encodedASCIIHost) {\n throw new Error(resolved.error)\n }\n schemelessOptions.skipEscape = true\n return serialize(resolved, schemelessOptions)\n}\n\n/**\n * Copies a host component together with its parse-time zone identifier (if\n * any), so downstream recomposition does not re-derive an IPv6 zone from the\n * ambiguous single-\"%\" component form. The zone is validated on use by\n * `recomposeAuthority` rather than blindly trusted.\n *\n * @param {import('./types/index').URIComponent} target\n * @param {import('./types/index').URIComponent} source\n */\nfunction copyHost (target, source) {\n target.host = source.host\n if (source.ipv6Zone !== undefined) {\n target.ipv6Zone = source.ipv6Zone\n }\n}\n\n/**\n * @param {import ('./types/index').URIComponent} base\n * @param {import ('./types/index').URIComponent} relative\n * @param {import('./types/index').Options} [options]\n * @param {boolean} [skipNormalization=false]\n * @returns {import ('./types/index').URIComponent}\n */\nfunction resolveComponent (base, relative, options, skipNormalization) {\n /** @type {import('./types/index').URIComponent} */\n const target = {}\n if (!skipNormalization) {\n base = parse(serialize(base, options), options) // normalize base component\n relative = parse(serialize(relative, options), options) // normalize relative component\n }\n options = options || {}\n\n if (!options.tolerant && relative.scheme) {\n target.scheme = relative.scheme\n // target.authority = relative.authority;\n target.userinfo = relative.userinfo\n copyHost(target, relative)\n target.port = relative.port\n target.path = removeDotSegments(relative.path || '')\n target.query = relative.query\n } else {\n if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {\n // target.authority = relative.authority;\n target.userinfo = relative.userinfo\n copyHost(target, relative)\n target.port = relative.port\n target.path = removeDotSegments(relative.path || '')\n target.query = relative.query\n } else {\n if (!relative.path) {\n target.path = base.path\n if (relative.query !== undefined) {\n target.query = relative.query\n } else {\n target.query = base.query\n }\n } else {\n if (relative.path[0] === '/') {\n target.path = removeDotSegments(relative.path)\n } else {\n if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {\n target.path = '/' + relative.path\n } else if (!base.path) {\n target.path = relative.path\n } else {\n target.path = base.path.slice(0, base.path.lastIndexOf('/') + 1) + relative.path\n }\n target.path = removeDotSegments(target.path)\n }\n target.query = relative.query\n }\n // target.authority = base.authority;\n target.userinfo = base.userinfo\n copyHost(target, base)\n target.port = base.port\n }\n target.scheme = base.scheme\n }\n\n target.fragment = relative.fragment\n\n return target\n}\n\n/**\n * @param {import ('./types/index').URIComponent|string} uriA\n * @param {import ('./types/index').URIComponent|string} uriB\n * @param {import ('./types/index').Options} options\n * @returns {boolean}\n */\nfunction equal (uriA, uriB, options) {\n const normalizedA = normalizeComparableURI(uriA, options)\n const normalizedB = normalizeComparableURI(uriB, options)\n\n return normalizedA !== undefined && normalizedB !== undefined && normalizedA === normalizedB\n}\n\n/**\n * @param {Readonly<import('./types/index').URIComponent>} cmpts\n * @param {import('./types/index').Options} [opts]\n * @returns {string}\n */\nfunction serialize (cmpts, opts) {\n const component = {\n host: cmpts.host,\n ipv6Zone: cmpts.ipv6Zone,\n scheme: cmpts.scheme,\n userinfo: cmpts.userinfo,\n port: cmpts.port,\n path: cmpts.path,\n query: cmpts.query,\n nid: cmpts.nid,\n nss: cmpts.nss,\n uuid: cmpts.uuid,\n fragment: cmpts.fragment,\n reference: cmpts.reference,\n resourceName: cmpts.resourceName,\n secure: cmpts.secure,\n to: cmpts.to,\n subject: cmpts.subject,\n body: cmpts.body,\n headers: cmpts.headers,\n error: ''\n }\n const options = Object.assign({}, opts)\n const uriTokens = []\n\n if (component.scheme) {\n component.scheme = decodeValidScheme(component.scheme)\n }\n\n // find scheme handler\n const schemeHandler = getSchemeHandler(options.scheme || component.scheme)\n\n // perform scheme specific serialization\n if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options)\n\n const hasAuthority = component.userinfo !== undefined || component.host !== undefined || component.port !== undefined\n const pathNoScheme = !options.skipEscape && component.scheme === undefined && !hasAuthority\n\n if (component.path !== undefined) {\n if (!options.skipEscape) {\n component.path = serializePathEncoding(component.path, pathNoScheme)\n } else {\n component.path = normalizePercentEncoding(component.path)\n }\n }\n\n if (options.reference !== 'suffix' && component.scheme) {\n // Scheme handlers may replace the scheme during serialization.\n component.scheme = decodeValidScheme(component.scheme)\n uriTokens.push(component.scheme, ':')\n }\n\n const authority = recomposeAuthority(component)\n if (authority !== undefined) {\n if (options.reference !== 'suffix') {\n uriTokens.push('//')\n }\n\n uriTokens.push(authority)\n\n if (component.path && component.path[0] !== '/') {\n uriTokens.push('/')\n }\n }\n if (component.path !== undefined) {\n let s = component.path\n\n if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {\n s = removeDotSegments(s)\n }\n\n // Dot-segment removal can expose a colon that was not originally in the\n // first segment (for example, \"./a:b\"). Reapply path-noscheme encoding so\n // the serialized relative reference cannot be reparsed as a URI scheme.\n if (pathNoScheme) {\n s = serializePathEncoding(s, true)\n }\n\n if (\n authority === undefined &&\n s[0] === '/' &&\n s[1] === '/'\n ) {\n // don't allow the path to start with \"//\"\n s = '/%2F' + s.slice(2)\n }\n\n uriTokens.push(s)\n }\n\n if (component.query !== undefined) {\n uriTokens.push('?', encodeQuery(component.query))\n }\n\n if (component.fragment !== undefined) {\n uriTokens.push('#', encodeFragment(component.fragment))\n }\n return uriTokens.join('')\n}\n\nconst URI_PARSE = /^(?:([^#/:?]+):)?(?:\\/\\/((?:([^#/?@]*)@)?(\\[[^#/?\\]]+\\]|[^#/:?]*)(?::(\\d*))?))?([^#?]*)(?:\\?([^#]*))?(?:#((?:.|[\\n\\r])*))?/u\n\n// Captures the authority component (between \"//\" and the next \"/\", \"?\" or \"#\"),\n// with or without a scheme prefix, for the literal-backslash rejection below.\nconst AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\\/\\/([^/?#]*)/\n\n// Captures the leading authority-introducer region after an optional scheme: a\n// run of forward slashes, backslashes, and the characters the WHATWG URL parser\n// removes before parsing (TAB U+0009, LF U+000A, CR U+000D). A valid introducer\n// is exactly \"//\". Node treats \"\\\" as \"/\" on special schemes and strips those\n// characters first, so forms like \"\\\\\", \"/\\\", \"\\/\", \"/<TAB>/\", or a leading\n// \"<TAB>//\" reach an authority in Node while fast-uri's URI_PARSE folds them into\n// the path group (host confusion / SSRF / redirect bypass).\nconst AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\\\\t\\n\\r]*)/\n\n/**\n * @param {import('./types/index').URIComponent} parsed\n * @param {RegExpMatchArray} matches\n * @returns {string|undefined}\n */\nfunction getParseError (parsed, matches) {\n if (matches[2] !== undefined && parsed.path && parsed.path[0] !== '/') {\n return 'URI path must start with \"/\" when authority is present.'\n }\n\n if (typeof parsed.port === 'number' && (parsed.port < 0 || parsed.port > 65535)) {\n return 'URI port is malformed.'\n }\n\n return undefined\n}\n\n/**\n * Checks percent syntax without decoding the represented octets. RFC 3986\n * percent-encoding is byte-oriented, so sequences such as `%FF` are valid even\n * though they are not independently valid UTF-8.\n *\n * @param {string|undefined} component\n * @returns {boolean}\n */\nfunction hasMalformedPercentEncoding (component) {\n if (component === undefined) return false\n\n let percent = component.indexOf('%')\n while (percent !== -1) {\n if (percent + 2 >= component.length || !/^[\\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {\n return true\n }\n percent = component.indexOf('%', percent + 3)\n }\n\n return false\n}\n\n/**\n * Whether the host is a bracketed IP literal (RFC 3986 `IP-literal`).\n * An unterminated `[` is not a literal, so it must still be validated as a\n * reg-name instead of being waved through as an IP.\n *\n * @param {string} host\n * @returns {boolean}\n */\nfunction isIPLiteral (host) {\n return host[0] === '[' && host[host.length - 1] === ']'\n}\n\n/**\n * @param {RegExpMatchArray} matches\n * @returns {boolean}\n */\nfunction hasMalformedComponentPercentEncoding (matches) {\n // Bracketed IP literals use a raw \"%\" as the zone separator for historical\n // compatibility. Their parsing is intentionally left to normalizeIPv6.\n const host = matches[4]\n return hasMalformedPercentEncoding(matches[3]) ||\n (host !== undefined && !isIPLiteral(host) && hasMalformedPercentEncoding(host)) ||\n hasMalformedPercentEncoding(matches[6]) ||\n hasMalformedPercentEncoding(matches[7]) ||\n hasMalformedPercentEncoding(matches[8])\n}\n\n/**\n * @param {import('./types/index').URIComponent} parsed\n * @param {import('./types/index').Options} options\n * @param {{ domainHost?: boolean, unicodeSupport?: boolean }|undefined} schemeHandler\n * @param {boolean} isIP\n * @returns {boolean} whether host conversion failed\n */\nfunction canonicalizeHost (parsed, options, schemeHandler, isIP) {\n const bracketedIPLiteral =\n parsed.host &&\n parsed.host[0] === '[' &&\n parsed.host[parsed.host.length - 1] === ']'\n\n if (\n !options.unicodeSupport &&\n (!schemeHandler || !schemeHandler.unicodeSupport) &&\n parsed.host &&\n !isIPLiteral(parsed.host) &&\n (options.domainHost || (schemeHandler && schemeHandler.domainHost)) &&\n isIP === false &&\n !bracketedIPLiteral &&\n nonSimpleDomain(parsed.host)\n ) {\n try {\n parsed.host = new URL('http://' + parsed.host).hostname\n } catch (e) {\n parsed.error = parsed.error || \"Host's domain name can not be converted to ASCII: \" + e\n return true\n }\n }\n\n return false\n}\n\n/**\n * @param {string} uri\n * @param {import('./types/index').Options} [opts]\n * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}\n */\nfunction parseWithStatus (uri, opts) {\n const options = Object.assign({}, opts)\n /** @type {import('./types/index').URIComponent} */\n const parsed = {\n scheme: undefined,\n userinfo: undefined,\n host: '',\n port: undefined,\n path: '',\n query: undefined,\n fragment: undefined\n }\n\n let malformedAuthorityOrPort = false\n let malformedPercentEncoding = false\n let malformedSchemeSpecific = false\n let malformedHost = false\n let malformedIPLiteral = false\n let malformedScheme = false\n\n let isIP = false\n if (options.reference === 'suffix') {\n if (options.scheme) {\n uri = options.scheme + ':' + uri\n } else {\n uri = '//' + uri\n }\n }\n\n // A literal backslash (U+005C) is not a valid RFC 3986 URI character and is\n // not an authority delimiter. Reject it in the authority rather than\n // rewriting it: normalizing \"\\\" -> \"/\" (WHATWG error recovery) could silently\n // change the resource identified by an otherwise-invalid input, and lets \"\\\"\n // act as a host delimiter here while Node's native URL parses a different\n // host (SSRF / redirect / origin-allowlist bypass). Percent-encoded %5C is\n // untouched and remains valid encoded data.\n const authorityMatch = uri.match(AUTHORITY_PREFIX)\n if (authorityMatch !== null && authorityMatch[1].indexOf('\\\\') !== -1) {\n parsed.error = 'URI authority must not contain a literal backslash.'\n malformedAuthorityOrPort = true\n }\n\n // Reject a malformed or whitespace-smuggled authority introducer. fast-uri\n // only recognizes a literal \"//\"; anything else in the leading separator run\n // (a backslash, or a \"//\" that appears only after removing the TAB/LF/CR that\n // Node strips) means the authority fast-uri parses differs from the one Node's\n // URL resolves. Reject rather than rewrite, mirroring the literal-backslash\n // guard above. Percent-encoded forms (%5C, %09) are untouched, valid data.\n const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION)\n if (introducerMatch !== null) {\n const region = introducerMatch[1]\n const normalizedRegion = region.replace(/[\\t\\n\\r]/g, '')\n // Two or more leading separators introduce an authority.\n if (normalizedRegion.length >= 2) {\n if (normalizedRegion.slice(0, 2) !== '//') {\n parsed.error = parsed.error || 'URI authority must not contain a literal backslash.'\n malformedAuthorityOrPort = true\n } else if (region.length !== normalizedRegion.length) {\n parsed.error = parsed.error || 'URI authority introducer must not contain whitespace.'\n malformedAuthorityOrPort = true\n }\n }\n }\n\n const matches = uri.match(URI_PARSE)\n\n if (matches) {\n // store each component\n parsed.scheme = matches[1]\n parsed.userinfo = matches[3]\n parsed.host = matches[4]\n parsed.port = parseInt(matches[5], 10)\n parsed.path = matches[6] || ''\n parsed.query = matches[7]\n parsed.fragment = matches[8]\n\n if (parsed.scheme !== undefined) {\n const decodedScheme = unescape(parsed.scheme)\n if (VALID_SCHEME.test(decodedScheme)) {\n parsed.scheme = decodedScheme.toLowerCase()\n } else {\n parsed.error = parsed.error || MALFORMED_SCHEME_ERROR\n malformedScheme = true\n }\n }\n\n malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches)\n if (malformedPercentEncoding) {\n parsed.error = parsed.error || 'URI contains malformed percent-encoding.'\n }\n\n // fix port number\n if (isNaN(parsed.port)) {\n parsed.port = matches[5]\n }\n\n const parseError = getParseError(parsed, matches)\n if (parseError !== undefined) {\n parsed.error = parsed.error || parseError\n malformedAuthorityOrPort = true\n }\n\n if (parsed.host) {\n const ipv4result = isIPv4(parsed.host)\n if (ipv4result === false) {\n const bracketedIPLiteral = isIPLiteral(parsed.host)\n const hasIPLiteralBracket = parsed.host.indexOf('[') !== -1 || parsed.host.indexOf(']') !== -1\n const ipv6result = normalizeIPv6(parsed.host)\n isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true\n malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true)\n parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase()\n\n if (isIP && ipv6result.isIPV6 === true && parsed.host.indexOf('%') !== -1) {\n // Persist the zone identifier so recomposition never has to re-derive\n // it from the ambiguous single-\"%\" component form, which misreads a\n // zone that begins with \"25\" as a %25 separator. It is validated on\n // use during recomposition, so a host reassigned after parse or an\n // input zone that does not describe the host is ignored. Only zoned\n // literals are ambiguous; plain IPv6 addresses round-trip without it.\n parsed.ipv6Zone = parsed.host.slice(parsed.host.indexOf('%') + 1)\n }\n\n if (malformedIPLiteral) {\n parsed.error = parsed.error || 'URI host is malformed.'\n malformedAuthorityOrPort = true\n }\n } else {\n isIP = true\n }\n }\n if (parsed.scheme === undefined && parsed.userinfo === undefined && parsed.host === undefined && parsed.port === undefined && parsed.query === undefined && !parsed.path) {\n parsed.reference = 'same-document'\n } else if (parsed.scheme === undefined) {\n parsed.reference = 'relative'\n } else if (parsed.fragment === undefined) {\n parsed.reference = 'absolute'\n } else {\n parsed.reference = 'uri'\n }\n\n // check for reference errors\n if (options.reference && options.reference !== 'suffix' && options.reference !== parsed.reference) {\n parsed.error = parsed.error || 'URI is not a ' + options.reference + ' reference.'\n }\n\n // find scheme handler\n const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme)\n\n // convert Unicode IDN -> ASCII IDN when the effective scheme uses domain hosts\n if (!malformedIPLiteral) {\n malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP)\n }\n\n if (uri.indexOf('%') !== -1 && parsed.host !== undefined && !malformedIPLiteral) {\n let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true)\n if (!isIP) {\n // Fold reg-name case after decoding unreserved octets. The second\n // pass only restores uppercase hex in escapes that remain encoded.\n host = normalizePercentEncoding(host.toLowerCase())\n }\n parsed.host = reescapeHostDelimiters(host, isIP)\n }\n\n if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {\n if (parsed.path) {\n parsed.path = normalizePathEncoding(parsed.path)\n }\n if (parsed.query) {\n parsed.query = normalizeQueryFragmentEncoding(parsed.query)\n }\n if (parsed.fragment) {\n parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment)\n }\n }\n\n // perform scheme specific parsing\n if (schemeHandler && schemeHandler.parse) {\n schemeHandler.parse(parsed, options)\n if (schemeHandler === SCHEMES.urn && parsed.nid === undefined) {\n malformedSchemeSpecific = true\n }\n }\n } else {\n parsed.error = parsed.error || 'URI can not be parsed.'\n }\n return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme }\n}\n\n/**\n * @param {string} uri\n * @param {import('./types/index').Options} [opts]\n * @returns\n */\nfunction parse (uri, opts) {\n return parseWithStatus(uri, opts).parsed\n}\n\n/**\n * @param {string} uri\n * @param {import('./types/index').Options} [opts]\n * @returns {string}\n */\nfunction normalizeString (uri, opts) {\n return normalizeStringWithStatus(uri, opts).normalized\n}\n\n/**\n * @param {string} uri\n * @param {import('./types/index').Options} [opts]\n * @returns {{ normalized: string, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}\n */\nfunction normalizeStringWithStatus (uri, opts) {\n const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts)\n return {\n normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),\n malformedAuthorityOrPort,\n malformedPercentEncoding,\n malformedSchemeSpecific,\n malformedHost,\n malformedScheme\n }\n}\n\n/**\n * @param {import ('./types/index').URIComponent|string} uri\n * @param {import('./types/index').Options} [opts]\n * @returns {string|undefined}\n */\nfunction normalizeComparableURI (uri, opts) {\n if (typeof uri !== 'string' && typeof uri !== 'object') {\n return undefined\n }\n\n let value\n try {\n value = typeof uri === 'string' ? uri : serialize(uri, opts)\n } catch {\n return undefined\n }\n const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts)\n return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? undefined : normalized\n}\n\nconst fastUri = {\n SCHEMES,\n normalize,\n resolve,\n resolveComponent,\n equal,\n serialize,\n parse\n}\n\nmodule.exports = fastUri\nmodule.exports.default = fastUri\nmodule.exports.fastUri = fastUri\n","import { resolve } from \"fast-uri\";\n\nconst suffixes = /(#)+$/;\nconst trailingHash = /#$/;\nconst isDomain = /^[^:]+:\\/\\/[^/]+\\//;\nconst idAndPointer = /#.*$/;\n\n/**\n * Resolves a reference URI against a base URI.\n * Uses uri-js (RFC 3986) with JSON Schema fragment handling.\n * The anonymous document root is always represented by \"#\" (RFC 6901 section 6).\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 const aIsArray = Array.isArray(a);\n const bIsArray = Array.isArray(b);\n\n if (aIsArray && bIsArray) {\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 // mixed data-type for type keyword\n if (property === \"type\" && (aIsArray || bIsArray)) {\n // we merge to the specific type\n if (aIsArray && a.includes(b)) {\n return b;\n }\n if (bIsArray && b.includes(a)) {\n return a;\n }\n // extend the types if they do not match\n if (aIsArray) {\n return [...a, b];\n }\n if (bIsArray) {\n return [...b, a];\n }\n }\n\n if (bIsArray) {\n return b;\n }\n\n if (aIsArray) {\n return a;\n }\n\n if (b !== undefined) {\n return b;\n }\n\n return a;\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","import { isSchemaNode, SchemaNode } from \"./types\";\nimport { mergeSchema } from \"./utils/mergeSchema\";\nimport { joinDynamicId } from \"./SchemaNode\";\nimport { pick } from \"./utils/pick\";\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 mergeReducedNode(result: SchemaNode, reduced?: SchemaNode, ...omit: string[]): SchemaNode {\n if (!reduced?.toSchemaNodes().some((child) => child.context !== result.context || child.$id !== result.$id)) {\n return result;\n }\n // Keep foreign resource contexts while retaining the reduction's same-resource locations.\n return {\n ...result,\n ...mergeNode(result, reduced, ...omit),\n ...pick(result, \"schema\", \"context\", \"$id\", \"schemaLocation\", \"evaluationPath\", \"dynamicId\")\n };\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 // In supported drafts the $ref callbacks also own dynamic/recursive references.\n const reference =\n funName === \"$ref\" ? mergedNode.context.keywords.find((keyword) => keyword.keyword === \"$ref\") : undefined;\n if (mergedNode.schema?.[funName] === undefined && !reference?.addValidate?.(mergedNode)) {\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","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 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 // Each keyword owns its branch, including entries appended by reference resolution.\n const result = validate({\n node: node as SchemaNodeWithRequired<keyof SchemaNode>,\n data,\n pointer,\n path: [...path, { pointer, node }]\n });\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\";\nimport { hasProperty } from \"./hasProperty\";\n\nexport function getValue(data: unknown, key: string | number) {\n if (isObject(data) && hasProperty(data, `${key}`)) {\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, options);\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 path.push({ pointer, node: parentNode });\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, pointer, path });\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 `${parentNode.schemaLocation}(createSchema)`\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 { 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, VALID_ANNOTATION_KEYWORDS } = 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 or deriving 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 // Child locations follow the authored parent, even across reference expansions.\n const nextFragment =\n evaluationPath === parentNode.evaluationPath\n ? \"#\"\n : evaluationPath.startsWith(`${parentNode.evaluationPath}/`)\n ? `#${evaluationPath.slice(parentNode.evaluationPath.length)}`\n : evaluationPath;\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(\n createSchema(data),\n node.evaluationPath,\n node.schemaLocation,\n `${node.schemaLocation}(createSchema)`\n );\n path?.push({ pointer, node });\n return { node: nextNode, error: undefined };\n }\n\n let schema;\n // Keep compiled children in their own resource contexts while deriving this node.\n let workingNode = { ...node };\n const reducers = node.reducers;\n for (const reducer of reducers) {\n const result = reducer({ data, key, node, pointer, path: [...(path ?? []), { pointer, node }] });\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 // Retire reduced keywords and their callbacks together.\n workingNode = mergeNode(workingNode, workingNode, DECLARATOR_ONEOF, ...DYNAMIC_PROPERTIES) as SchemaNode;\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 const node = this as SchemaNode & { schemaErrors?: JsonError[]; schemaAnnotations?: JsonAnnotation[] };\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 $id: resolveUri(url),\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\n // parse and validate schema\n // @todo this is a duplicated to compileSchema\n let schemaValidation = addKeywords(remoteNode).filter((err) => err != null);\n if (remoteNode.$id != null) {\n remoteNode.context.remotes[remoteNode.$id] = remoteNode;\n }\n schemaValidation = sanitizeErrors(schemaValidation);\n const schemaErrors: JsonError[] = [];\n const schemaAnnotations: JsonAnnotation[] = [];\n const remoteSchemaId = remoteNode.context.rootNode.$id ?? resolveUri(url);\n schemaValidation.forEach((error) => {\n if (isJsonError(error)) {\n error.data.schemaId = remoteSchemaId;\n schemaErrors.push(error);\n } else if (isJsonAnnotation(error)) {\n error.data.schemaId = remoteSchemaId;\n schemaAnnotations.push(error);\n }\n });\n // accumulate diagnostics instead of overwriting so that registering\n // multiple remotes retains all of their errors/annotations, see #116\n node.schemaErrors = (node.schemaErrors ?? []).concat(schemaErrors);\n node.schemaAnnotations = (node.schemaAnnotations ?? []).concat(schemaAnnotations);\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 != null && noRefMergeDrafts.includes(node.context.version)) {\n // Reference siblings are ignored; definitions remain available as targets.\n return node.context.keywords\n .filter(({ keyword }) => keyword === \"$ref\" || keyword === \"$defs\")\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) =>\n !key.startsWith(\"x-\") &&\n !VALID_ANNOTATION_KEYWORDS.includes(key) &&\n node.context.keywords.find((keyword) => keyword.keyword === key) == null\n ).forEach((keyword) => {\n errors.push(\n node.createAnnotation(\"unknown-keyword-warning\", {\n $id: node.$id,\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","/**\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 { isBooleanSchema, isJsonError, isJsonSchema, 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 // Reductions and reference expansions are not authored reference targets.\n if (!node.dynamicId && 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 = node.schema.$ref != null && node.schema.$dynamicRef != null ? resolveAdjacentRefs : 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.$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 && !node.dynamicId) {\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 && !node.dynamicId) {\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 != null) {\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 (isJsonError(resolvedNode)) {\n return resolvedNode;\n }\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 (node.resolveRef === resolveAdjacentRefs) {\n const result = resolvedNode.reduceNode(data, { key, pointer, path });\n return result.node ?? result.error;\n }\n\n if (\n resolvedNode.context === node.context &&\n resolvedNode.$id === node.$id &&\n resolvedNode.schemaLocation === node.schemaLocation\n ) {\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, options: { pointer?: string; path?: ValidationPath } = {}): SchemaNode | JsonError {\n const { pointer, path = [] } = options;\n if (this.schema.$dynamicRef != null) {\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 return resolveStaticRef.call(this, options);\n}\n\nexport function resolveStaticRef(this: SchemaNode, { pointer, path = [] }: { pointer?: string; path?: ValidationPath } = {}) {\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\nexport function resolveAdjacentRefs(this: SchemaNode) {\n const keyword = this.context.version === \"draft-2019-09\" ? \"$recursiveRef\" : \"$dynamicRef\";\n // A distinct derived location lets schema traversal visit both applicators without replacing authored targets.\n return this.compileSchema(\n {\n ...pick(this.schema, ...settings.PROPERTIES_TO_MERGE),\n allOf: [{ $ref: this.schema.$ref }, { [keyword]: this.schema[keyword] }]\n },\n `${this.evaluationPath}/$ref`,\n `${this.schemaLocation}/$ref`,\n `${this.schemaLocation}($ref+${keyword})`\n );\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// https://json-schema.org/draft/2020-12/json-schema-core#dynamic-ref\nfunction resolveRecursiveRef(node: SchemaNode, path: ValidationPath): SchemaNode | JsonError {\n let refInCurrentScope = resolveUri(node.$id, node.schema.$dynamicRef);\n const [resource, refFragment] = splitRef(refInCurrentScope);\n const remote = resource && node.context.remotes[resource];\n if (remote && refFragment) {\n refInCurrentScope = resolveUri(remote.$id, refFragment);\n }\n // Only an initial URI identifying a dynamic anchor enables dynamic resolution.\n if (node.context.dynamicAnchors[refInCurrentScope] == null) {\n return getRef(node, refInCurrentScope);\n }\n\n // Select the outermost resource in the current scope with an identically named anchor.\n const fragment = node.schema.$dynamicRef.split(\"#\").pop();\n for (const entry of path) {\n const ref = resolveUri(entry.node.$id, `#${fragment}`);\n const anchorNode = node.context.dynamicAnchors[ref];\n if (anchorNode) {\n return compileNext(anchorNode, node);\n }\n }\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 sourceNode.dynamicId || `${sourceNode.schemaLocation}($ref)`\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 (isJsonSchema(targetSchema) || isBooleanSchema(targetSchema)) {\n // A newly reached document location is authored; only its reference expansion is derived.\n const target = node.context.rootNode.compileSchema(targetSchema, $ref, $ref);\n return compileNext(target, node);\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, resolveUri(referencedNode.$id, fragments[1]));\n if (isSchemaNode(nextNode)) {\n return nextNode;\n }\n // @note required for test spec 04\n nextNode = getRef(referencedNode, fragments[1]);\n if (isSchemaNode(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 { resolveStaticRef as 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 ?? node.$id;\n if (node.schema?.$ref == null) {\n currentId = resolveUri(currentId, 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.dynamicId && 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 // Data-dependent reductions must not replace authored reference targets.\n if (!node.dynamicId) {\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\n // precompile reference\n if (node.schema.$ref != null) {\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.dynamicId && 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 ?? node.$id;\n if (node.schema?.$ref == null && node.schema?.id) {\n currentId = resolveUri(currentId, 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 register(node, currentId as string);\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 != null) {\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, sourceNode: SchemaNode) {\n const referencedSchema = isObject(referencedNode.schema)\n ? omit(referencedNode.schema, \"id\")\n : referencedNode.schema;\n return referencedNode.compileSchema(\n referencedSchema,\n `${sourceNode.evaluationPath}/$ref`,\n referencedNode.schemaLocation,\n sourceNode.dynamicId || `${sourceNode.schemaLocation}($ref)`\n );\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);\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);\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 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, resolveUri(referencedNode.$id, fragments[1]));\n if (isSchemaNode(nextNode)) {\n return nextNode;\n }\n // @note required for test spec 04\n nextNode = getRef(referencedNode, fragments[1]);\n if (isSchemaNode(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, pointer = \"#\", path = [] }: JsonSchemaResolverParams) {\n const value = getValue(data, key);\n if (node.additionalProperties) {\n const { node: reduced, error } = node.additionalProperties.reduceNode(value, { pointer, path });\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 { mergeNode, mergeReducedNode } from \"../mergeNode\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams, ValidationReturnType } from \"../Keyword\";\nimport { isBooleanSchema, 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 mergedNode: SchemaNode | undefined;\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: [...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 reduced = isBooleanSchema(node[KEYWORD][i].schema) ? node[KEYWORD][i] : schemaNode;\n mergedSchema = mergeSchema(mergedSchema, reduced.schema, KEYWORD, \"contains\");\n mergedNode = mergeNode(mergedNode, reduced, KEYWORD, \"contains\");\n }\n }\n\n const result = node.compileSchema(\n mergedSchema,\n `${node.evaluationPath}/${dynamicId}`,\n node.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n return mergeReducedNode(result, mergedNode, KEYWORD, \"contains\");\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 { mergeNode, mergeReducedNode } from \"../mergeNode\";\nimport { Keyword, JsonSchemaReducerParams, JsonSchemaValidatorParams } from \"../Keyword\";\nimport { isBooleanSchema, 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, key, pointer, path }: JsonSchemaReducerParams) {\n if (node[KEYWORD] == null) {\n return;\n }\n\n let mergedSchema = {};\n let mergedNode: SchemaNode | undefined;\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, { key, pointer, path: [...path] });\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 reduced = isBooleanSchema(node[KEYWORD][i].schema) ? node[KEYWORD][i] : schemaNode;\n mergedSchema = mergeSchema(mergedSchema, reduced.schema, KEYWORD);\n mergedNode = mergeNode(mergedNode, reduced, KEYWORD);\n }\n }\n }\n const result = node.compileSchema(\n mergedSchema,\n `${node.evaluationPath}${dynamicId}`,\n node.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n return mergeReducedNode(result, mergedNode, KEYWORD);\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 { mergeNode, mergeReducedNode } from \"../mergeNode\";\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, key, pointer, path }: 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 mergedNode: SchemaNode | undefined;\n let added = 0;\n let dynamicId = `${node.schemaLocation}(`;\n for (const propertyName of Object.keys(data)) {\n const dependency = dependentSchemas[propertyName];\n if (dependency == null) {\n continue;\n }\n if (dependency === false) {\n return node.compileSchema(\n false, node.evaluationPath, node.schemaLocation, `${node.schemaLocation}(${KEYWORD}/${propertyName})`\n );\n }\n mergedSchema = mergedSchema ?? {};\n if (isSchemaNode(dependency)) {\n const { node: reduced } = dependency.reduceNode(data, {\n key, pointer, path: [...path]\n });\n if (reduced) {\n mergedSchema = mergeSchema(mergedSchema, reduced.schema);\n mergedNode = mergeNode(mergedNode, reduced, KEYWORD);\n }\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 const result = node.compileSchema(mergedSchema, node.evaluationPath, node.schemaLocation, `${dynamicId})`);\n return mergeReducedNode(result, mergedNode, KEYWORD);\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 for (const propertyName of Object.keys(dependentSchemas)) {\n if (!hasProperty(data, propertyName) && !required.includes(propertyName)) {\n continue;\n }\n const dependency = dependentSchemas[propertyName];\n if (!isSchemaNode(dependency)) {\n continue;\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 { node: reducedDependency, error } = {\n ...dependency,\n schema: { ...dependency.schema, required }\n }.reduceNode(data, {\n key,\n pointer: `${pointer}/${KEYWORD}/${propertyName}`,\n path: [...path]\n });\n\n if (!reducedDependency) {\n return error;\n }\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} from \"../Keyword\";\nimport { isBooleanSchema, 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 reduceOneOfNode(node: SchemaNode, data: unknown, pointer: string, path: ValidationPath) {\n return isBooleanSchema(node.schema)\n ? { node: { ...node }, error: undefined }\n : node.reduceNode(data, { pointer, path });\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 } = reduceOneOfNode(node, 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 } = reduceOneOfNode(node.oneOf[i], 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 } = reduceOneOfNode(nodeOfItem, data, pointer, path);\n if (reducedNode) {\n reducedNode.oneOfIndex = schemaOfIndex; // @evaluation-info\n return reducedNode;\n }\n return error;\n } else if (Array.isArray(data)) {\n let nodeOfItem: SchemaNode | undefined;\n let schemaOfIndex = -1;\n let errorCount = Infinity;\n\n for (let i = 0; i < node.oneOf.length; i += 1) {\n const oneNode = node.oneOf[i];\n const { errors } = oneNode.validate(data);\n const nextErrorCount = errors.length;\n\n if (nextErrorCount < errorCount) {\n errorCount = nextErrorCount;\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 } = reduceOneOfNode(nodeOfItem, 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 !== undefined || isRequired || opts.addOptionalProps) {\n const propertyValue = propertyNode.getData(value, opts);\n const dataType = getTypeOf(propertyValue);\n if (\n opts.removeInvalidData &&\n // @attention we do not remove values that might have valid nested values\n dataType !== \"object\" &&\n dataType !== \"array\" &&\n !propertyNode.validate(propertyValue).valid\n ) {\n return;\n }\n\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) => {\n // if we allow additionalProperties, but the current value has a schema that invalidates\n // do not add this value\n const dataType = getTypeOf(key);\n if (\n opts.removeInvalidData &&\n node.properties &&\n node.properties[key] &&\n dataType !== \"object\" &&\n dataType !== \"array\"\n ) {\n const propertyNode = node.properties[key];\n const propertyValue = propertyNode.getData(getValue(data, key), opts);\n if (!propertyNode.validate(propertyValue).valid) {\n return;\n }\n }\n\n if (d[key] == null) {\n d[key] = getValue(data, key);\n }\n });\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} 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 { mergeReducedNode } from \"../mergeNode\";\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, key, 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, { key, pointer, path: [...path] });\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\").replace(/^#/, \"\") ?? \"\";\n const dynamicId = nestedDynamicId === \"\" ? `(then)` : nestedDynamicId;\n\n const reduced = isBooleanSchema(node.then.schema) ? node.then : schemaNode;\n const result = node.compileSchema(\n reduced.schema,\n node.then.evaluationPath,\n node.schemaLocation,\n `${node.schemaLocation}${dynamicId}`\n );\n return mergeReducedNode(result, reduced, \"if\", \"then\", \"else\");\n }\n }\n } else if (node.else) {\n const { node: schemaNode } = node.else.reduceNode(data, { key, pointer, path: [...path] });\n if (schemaNode) {\n const nestedDynamicId = schemaNode.dynamicId?.replace(node.dynamicId, \"\") ?? \"\";\n const dynamicId = nestedDynamicId === \"\" ? `(else)` : nestedDynamicId;\n\n const reduced = isBooleanSchema(node.else.schema) ? node.else : schemaNode;\n const result = node.compileSchema(\n reduced.schema,\n node.else.evaluationPath,\n node.schemaLocation,\n `${node.schemaLocation}${dynamicId}`\n );\n return mergeReducedNode(result, reduced, \"if\", \"then\", \"else\");\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 { isBooleanSchema, isJsonSchema, isSchemaNode, JsonError, SchemaNode } from \"../../types\";\nimport { get, split } from \"@sagold/json-pointer\";\nimport { reduceRef, compileNext, resolveAdjacentRefs } 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.dynamicId && 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 = node.schema.$ref != null && node.schema.$recursiveRef != null ? resolveAdjacentRefs : 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.$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 && !node.dynamicId) {\n node.context.anchors[`${currentId.replace(/#$/, \"\")}#${node.schema.$anchor}`] = node;\n }\n\n // precompile reference\n if (node.schema.$ref != null) {\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 initialTarget = getRef(node, resolveUri(node.$id, node.schema.$recursiveRef));\n // Only an initial target that enables recursion can rebind through the dynamic scope.\n if (!isSchemaNode(initialTarget) || initialTarget.schema.$recursiveAnchor !== true) {\n return initialTarget;\n }\n let target = initialTarget;\n let resourceId = node.$id;\n for (let i = path.length - 1; i >= 0; i--) {\n const entry = path[i].node;\n if (entry.$id === resourceId) {\n continue;\n }\n resourceId = entry.$id;\n // Reference expansions omit schema.$id; the effective ID still identifies the authored resource.\n const resource = entry.context.refs[resourceId ?? \"#\"];\n if (resource?.schema.$recursiveAnchor !== true) {\n break;\n }\n target = compileNext(resource, node);\n }\n return target;\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 (isJsonSchema(targetSchema) || isBooleanSchema(targetSchema)) {\n // Register the authored location before deriving its evaluation-path expansion.\n const target = node.context.rootNode.compileSchema(targetSchema, ref, ref);\n return compileNext(target, node);\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, resolveUri(referencedNode.$id, fragments[1]));\n if (isSchemaNode(nextNode)) {\n return nextNode;\n }\n // @note required for test spec 04\n nextNode = getRef(referencedNode, fragments[1]);\n if (isSchemaNode(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 { isSchemaNode, 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 // Reference traversal belongs to this branch, not the next property or applicator.\n path = [...path, { pointer, node }];\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 (isSchemaNode(resolved) && 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 // Properties defined directly on this schema object are always\n // evaluated by the \"properties\" keyword, regardless of whether the\n // value passes validation (per JSON Schema spec, annotations from\n // adjacent keywords are always collected)\n if (node.properties?.[propertyName]) {\n continue;\n }\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.items) {\n const items = node.items.resolveRef();\n if (items?.oneOf) {\n return items.oneOf.map((childNode: SchemaNode) => childNode.resolveRef());\n }\n }\n\n if (node.oneOf) {\n return node.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 (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 !== undefined || isRequired || opts.addOptionalProps) {\n const propertyValue = propertyNode.getData(value, opts);\n const dataType = getTypeOf(propertyValue);\n if (\n opts.removeInvalidData &&\n // @attention we do not remove values that might have valid nested values\n dataType !== \"object\" &&\n dataType !== \"array\" &&\n !propertyNode.validate(propertyValue).valid\n ) {\n return;\n }\n\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 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) => {\n // if we allow additionalProperties, but the current value has a schema that invalidates\n // do not add this value\n const dataType = getTypeOf(key);\n if (\n opts.removeInvalidData &&\n node.properties &&\n node.properties[key] &&\n dataType !== \"object\" &&\n dataType !== \"array\"\n ) {\n const propertyNode = node.properties[key];\n const propertyValue = propertyNode.getData(getValue(data, key), opts);\n if (!propertyNode.validate(propertyValue).valid) {\n return;\n }\n }\n\n if (d[key] == null) {\n d[key] = getValue(data, key);\n }\n });\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 { resolveUri } from \"./utils/resolveUri\";\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 /** Retrieval URI of the root document, before resolving its id/$id keyword. */\n baseUri?: string | undefined;\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 \"@texaryn/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 & { schemaErrors?: JsonError[]; schemaAnnotations?: JsonAnnotation[] };\n /**\n * a list of remotes to add, requires a unique $id for each schema. Will be ignored if `remote` is set\n */\n remotes?: JsonSchema[];\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 remote = options.remote;\n if (Array.isArray(options.remotes) && options.remotes.length > 0 && !options.remote) {\n const remotes = [...options.remotes];\n remotes.forEach((remote, index) => {\n if (remote.$id == null) {\n throw new Error(`required $id on remotes[${index}] is missing`);\n }\n });\n const first = remotes.shift()!;\n remote = compileSchema(first, { baseUri: first.$id });\n remotes.forEach((r) => remote?.addRemoteSchema(r.$id, r));\n }\n\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 ...(options.baseUri === undefined ? {} : { $id: resolveUri(options.baseUri) }),\n // @ts-expect-error self-reference added later\n context: {\n remotes: {},\n dynamicAnchors: {},\n ...(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[node.$id ?? (isJsonSchema(schema) ? schema.$id : undefined) ?? \"#\"] = node;\n\n if (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 if (node.$id != null) {\n node.context.remotes[node.$id] = node;\n }\n schemaValidation = sanitizeErrors(schemaValidation);\n const schemaErrors: JsonError[] = [];\n const schemaAnnotations: JsonAnnotation[] = [];\n schemaValidation.forEach((error) => {\n if (isJsonError(error)) {\n error.data.schemaId = node.context.rootNode.$id ?? \"#\";\n schemaErrors.push(error);\n } else if (isJsonAnnotation(error)) {\n error.data.schemaId = node.context.rootNode.$id ?? \"#\";\n schemaAnnotations.push(error);\n }\n });\n if (Array.isArray(remote?.schemaErrors)) {\n schemaErrors.push(...remote.schemaErrors);\n }\n if (Array.isArray(remote?.schemaAnnotations)) {\n schemaAnnotations.push(...remote.schemaAnnotations);\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 * @deprecated\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 { mergeNode, mergeReducedNode } from \"../mergeNode\";\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 dependentValues = dependentProperties[propertyName];\n const value = `${data[propertyName]}`;\n if (hasProperty(dependentValues, value)) {\n matchingSchemata.push({\n property: propertyName,\n value,\n node: dependentValues[value]\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>> = Object.create(null);\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] ?? Object.create(null);\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 mergedNode: SchemaNode | undefined;\n let dynamicId = \"\";\n for (const match of matchingSchemata) {\n const { node: schemaNode } = match.node.reduceNode(data, { key, pointer, path: [...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 reduced = isBooleanSchema(match.node.schema) ? match.node : schemaNode;\n mergedSchema = mergeSchema(mergedSchema, reduced.schema, \"propertyDependencies\");\n mergedNode = mergeNode(mergedNode, reduced, \"propertyDependencies\");\n }\n }\n\n const result = node.compileSchema(\n mergedSchema,\n `${node.evaluationPath}/${dynamicId}`,\n node.schemaLocation,\n `${node.schemaLocation}(${dynamicId})`\n );\n return mergeReducedNode(result, mergedNode, \"propertyDependencies\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