@bastani/atomic-schema 0.0.0-placeholder.0 → 0.9.88-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +22 -0
- package/NOTICE.md +13 -0
- package/README.md +64 -0
- package/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
- package/dist/annotations.d.ts +44 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/annotations.js +193 -0
- package/dist/annotations.js.map +1 -0
- package/dist/builders.d.ts +143 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +126 -0
- package/dist/builders.js.map +1 -0
- package/dist/checks.d.ts +114 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +578 -0
- package/dist/checks.js.map +1 -0
- package/dist/coerce.d.ts +53 -0
- package/dist/coerce.d.ts.map +1 -0
- package/dist/coerce.js +624 -0
- package/dist/coerce.js.map +1 -0
- package/dist/compiler.d.ts +53 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +551 -0
- package/dist/compiler.js.map +1 -0
- package/dist/explain.d.ts +29 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +392 -0
- package/dist/explain.js.map +1 -0
- package/dist/formats/index.d.ts +7 -0
- package/dist/formats/index.d.ts.map +1 -0
- package/dist/formats/index.js +51 -0
- package/dist/formats/index.js.map +1 -0
- package/dist/formats/typebox/date.d.ts +7 -0
- package/dist/formats/typebox/date.d.ts.map +1 -0
- package/dist/formats/typebox/date.js +47 -0
- package/dist/formats/typebox/date.js.map +1 -0
- package/dist/formats/typebox/date_time.d.ts +7 -0
- package/dist/formats/typebox/date_time.d.ts.map +1 -0
- package/dist/formats/typebox/date_time.js +39 -0
- package/dist/formats/typebox/date_time.js.map +1 -0
- package/dist/formats/typebox/duration.d.ts +6 -0
- package/dist/formats/typebox/duration.d.ts.map +1 -0
- package/dist/formats/typebox/duration.js +36 -0
- package/dist/formats/typebox/duration.js.map +1 -0
- package/dist/formats/typebox/email.d.ts +6 -0
- package/dist/formats/typebox/email.d.ts.map +1 -0
- package/dist/formats/typebox/email.js +36 -0
- package/dist/formats/typebox/email.js.map +1 -0
- package/dist/formats/typebox/hostname.d.ts +8 -0
- package/dist/formats/typebox/hostname.d.ts.map +1 -0
- package/dist/formats/typebox/hostname.js +38 -0
- package/dist/formats/typebox/hostname.js.map +1 -0
- package/dist/formats/typebox/idn_email.d.ts +6 -0
- package/dist/formats/typebox/idn_email.d.ts.map +1 -0
- package/dist/formats/typebox/idn_email.js +36 -0
- package/dist/formats/typebox/idn_email.js.map +1 -0
- package/dist/formats/typebox/idn_hostname.d.ts +9 -0
- package/dist/formats/typebox/idn_hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idn_hostname.js +39 -0
- package/dist/formats/typebox/idn_hostname.js.map +1 -0
- package/dist/formats/typebox/idna/format/bidi.d.ts +4 -0
- package/dist/formats/typebox/idna/format/bidi.d.ts.map +1 -0
- package/dist/formats/typebox/idna/format/bidi.js +132 -0
- package/dist/formats/typebox/idna/format/bidi.js.map +1 -0
- package/dist/formats/typebox/idna/format/puny.d.ts +4 -0
- package/dist/formats/typebox/idna/format/puny.d.ts.map +1 -0
- package/dist/formats/typebox/idna/format/puny.js +172 -0
- package/dist/formats/typebox/idna/format/puny.js.map +1 -0
- package/dist/formats/typebox/idna/hostname.d.ts +2 -0
- package/dist/formats/typebox/idna/hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idna/hostname.js +43 -0
- package/dist/formats/typebox/idna/hostname.js.map +1 -0
- package/dist/formats/typebox/idna/idn-hostname.d.ts +2 -0
- package/dist/formats/typebox/idna/idn-hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idna/idn-hostname.js +71 -0
- package/dist/formats/typebox/idna/idn-hostname.js.map +1 -0
- package/dist/formats/typebox/idna/index.d.ts +3 -0
- package/dist/formats/typebox/idna/index.d.ts.map +1 -0
- package/dist/formats/typebox/idna/index.js +30 -0
- package/dist/formats/typebox/idna/index.js.map +1 -0
- package/dist/formats/typebox/idna/label/ascii.d.ts +2 -0
- package/dist/formats/typebox/idna/label/ascii.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/ascii.js +37 -0
- package/dist/formats/typebox/idna/label/ascii.js.map +1 -0
- package/dist/formats/typebox/idna/label/puny.d.ts +2 -0
- package/dist/formats/typebox/idna/label/puny.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/puny.js +56 -0
- package/dist/formats/typebox/idna/label/puny.js.map +1 -0
- package/dist/formats/typebox/idna/label/unicode.d.ts +2 -0
- package/dist/formats/typebox/idna/label/unicode.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/unicode.js +134 -0
- package/dist/formats/typebox/idna/label/unicode.js.map +1 -0
- package/dist/formats/typebox/idna/pattern/pattern.d.ts +31 -0
- package/dist/formats/typebox/idna/pattern/pattern.d.ts.map +1 -0
- package/dist/formats/typebox/idna/pattern/pattern.js +98 -0
- package/dist/formats/typebox/idna/pattern/pattern.js.map +1 -0
- package/dist/formats/typebox/ipv4.d.ts +6 -0
- package/dist/formats/typebox/ipv4.d.ts.map +1 -0
- package/dist/formats/typebox/ipv4.js +36 -0
- package/dist/formats/typebox/ipv4.js.map +1 -0
- package/dist/formats/typebox/ipv6.d.ts +6 -0
- package/dist/formats/typebox/ipv6.d.ts.map +1 -0
- package/dist/formats/typebox/ipv6.js +36 -0
- package/dist/formats/typebox/ipv6.js.map +1 -0
- package/dist/formats/typebox/iri.d.ts +6 -0
- package/dist/formats/typebox/iri.d.ts.map +1 -0
- package/dist/formats/typebox/iri.js +63 -0
- package/dist/formats/typebox/iri.js.map +1 -0
- package/dist/formats/typebox/iri_reference.d.ts +6 -0
- package/dist/formats/typebox/iri_reference.d.ts.map +1 -0
- package/dist/formats/typebox/iri_reference.js +40 -0
- package/dist/formats/typebox/iri_reference.js.map +1 -0
- package/dist/formats/typebox/json_pointer.d.ts +7 -0
- package/dist/formats/typebox/json_pointer.d.ts.map +1 -0
- package/dist/formats/typebox/json_pointer.js +37 -0
- package/dist/formats/typebox/json_pointer.js.map +1 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.d.ts +7 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.d.ts.map +1 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.js +37 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.js.map +1 -0
- package/dist/formats/typebox/regex.d.ts +6 -0
- package/dist/formats/typebox/regex.d.ts.map +1 -0
- package/dist/formats/typebox/regex.js +41 -0
- package/dist/formats/typebox/regex.js.map +1 -0
- package/dist/formats/typebox/relative_json_pointer.d.ts +7 -0
- package/dist/formats/typebox/relative_json_pointer.d.ts.map +1 -0
- package/dist/formats/typebox/relative_json_pointer.js +37 -0
- package/dist/formats/typebox/relative_json_pointer.js.map +1 -0
- package/dist/formats/typebox/time.d.ts +6 -0
- package/dist/formats/typebox/time.d.ts.map +1 -0
- package/dist/formats/typebox/time.js +60 -0
- package/dist/formats/typebox/time.js.map +1 -0
- package/dist/formats/typebox/uri.d.ts +6 -0
- package/dist/formats/typebox/uri.d.ts.map +1 -0
- package/dist/formats/typebox/uri.js +36 -0
- package/dist/formats/typebox/uri.js.map +1 -0
- package/dist/formats/typebox/uri_reference.d.ts +6 -0
- package/dist/formats/typebox/uri_reference.d.ts.map +1 -0
- package/dist/formats/typebox/uri_reference.js +36 -0
- package/dist/formats/typebox/uri_reference.js.map +1 -0
- package/dist/formats/typebox/uri_template.d.ts +6 -0
- package/dist/formats/typebox/uri_template.d.ts.map +1 -0
- package/dist/formats/typebox/uri_template.js +37 -0
- package/dist/formats/typebox/uri_template.js.map +1 -0
- package/dist/formats/typebox/url.d.ts +7 -0
- package/dist/formats/typebox/url.d.ts.map +1 -0
- package/dist/formats/typebox/url.js +36 -0
- package/dist/formats/typebox/url.js.map +1 -0
- package/dist/formats/typebox/uuid.d.ts +7 -0
- package/dist/formats/typebox/uuid.d.ts.map +1 -0
- package/dist/formats/typebox/uuid.js +37 -0
- package/dist/formats/typebox/uuid.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/resolver.d.ts +58 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +209 -0
- package/dist/resolver.js.map +1 -0
- package/dist/shared.d.ts +9 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +33 -0
- package/dist/shared.js.map +1 -0
- package/dist/typebox-static.d.ts +56 -0
- package/dist/typebox-static.d.ts.map +1 -0
- package/dist/typebox-static.js +7 -0
- package/dist/typebox-static.js.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validator.d.ts +48 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +81 -0
- package/dist/validator.js.map +1 -0
- package/package.json +61 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,kHAAkH;AAClH,kDAAkD;AAElD,OAAO,EACN,gBAAgB,EAChB,eAAe,EAEf,WAAW,EACX,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,MAAM,EACN,GAAG,EACH,QAAQ,EAER,UAAU,EACV,UAAU,EACV,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EAEZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,U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SAAS,CAAC;IACrE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3E,OAAO,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,IAAI,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACpF,CAAC;AAED,wFAAwF;AACxF,SAAS,KAAK,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC9B,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["// The compiler: a schema to one check closure, built once. Keywords group by the type they constrain, so a value\n// is classified once per schema, and the common shapes (closed objects, arrays of one item schema, tagged unions,\n// leaf schemas) get one specialized closure each.\n\nimport {\n\tANNOTATING_FALSE,\n\tANNOTATING_TRUE,\n\ttype AnnotatingCheck,\n\tannotateAll,\n\tannotateAny,\n\tannotateArray,\n\tannotateDependent,\n\tannotateIf,\n\tannotateObject,\n\tignoreAnnotations,\n\tindirectAnnotating,\n\tisolateAnnotations,\n\tscopedAnnotating,\n\tunevaluatedItems,\n\tunevaluatedProperties,\n\twithFreshAnnotations,\n} from \"./annotations.ts\";\nimport {\n\tALWAYS,\n\tand,\n\tanyCheck,\n\ttype Bound,\n\tbytesCheck,\n\tconstCheck,\n\tcontainsCheck,\n\tdeclaredObject,\n\tdependentRequiredCheck,\n\tdependentSchemasCheck,\n\tenumCheck,\n\tGUARD_LOOSE,\n\tGUARD_NONE,\n\tGUARD_STRICT,\n\ttype Guard,\n\tguardArray,\n\tguardObject,\n\tINHERITED,\n\tIS_ARRAY,\n\tIS_OBJECT,\n\tifCheck,\n\tindirect,\n\titemsCheck,\n\tleafOf,\n\tlengthCheck,\n\tlistCheck,\n\tmaskedAnyCheck,\n\tNEVER,\n\tnotCheck,\n\tnumberCheck,\n\toneCheck,\n\topenObject,\n\tpropertyCountCheck,\n\tpropertyNamesCheck,\n\tREQUIRED,\n\tscopedCheck,\n\tstringCheck,\n\tTYPE_CHECKS,\n\ttaggedCheck,\n\ttypeCheck,\n\ttypeMask,\n\tuniqueCheck,\n} from \"./checks.ts\";\nimport { documentOf, isSchemaObject, Resolver, resolveUri } from \"./resolver.ts\";\nimport { sharedRegex } from \"./shared.ts\";\nimport type { Check, CompileOptions, FormatCheck, JsonSchema, SchemaObject } from \"./types.ts\";\n\n/** Thrown when a compile without dynamic scope tracking meets a bookended `$dynamicRef`: compile again with it. */\nexport const RESTART = Symbol(\"restart\");\n\n/** One compile of a schema. Its caches and indexes are garbage once the root check is built. */\nexport class Compiler {\n\treadonly r: Resolver;\n\treadonly draft: \"2020-12\" | \"7\";\n\treadonly formats: Readonly<Record<string, FormatCheck>> | undefined;\n\t/** Whether checks track the dynamic scope (the schema has a bookended `$dynamicRef`). */\n\treadonly dynamic: boolean;\n\tprivate readonly schema: JsonSchema;\n\tprivate readonly scope: string[];\n\tprivate readonly cache = new Map<object, Check>();\n\tprivate readonly annotatingCache = new Map<object, AnnotatingCheck>();\n\n\tconstructor(schema: JsonSchema, options: CompileOptions, dynamic: boolean) {\n\t\tthis.schema = schema;\n\t\tthis.r = new Resolver(schema, options);\n\t\tthis.draft = this.r.draft;\n\t\tthis.formats = options.formats;\n\t\tthis.dynamic = dynamic;\n\t\tthis.scope = [];\n\t}\n\n\t/** The check of the root schema. */\n\troot(): Check {\n\t\treturn this.check(this.schema, this.r.rootBase);\n\t}\n\n\t/** The check of a schema (cached by schema object; a recursive reference goes through an indirection). */\n\tcheck(node: unknown, base: string): Check {\n\t\tif (node === true) return ALWAYS;\n\t\tif (node === false) return NEVER;\n\t\tif (!isSchemaObject(node))\n\t\t\tthrow new Error(`A schema must be an object or a boolean, got ${JSON.stringify(node)}`);\n\t\tconst cached = this.cache.get(node);\n\t\tif (cached !== undefined) return cached;\n\t\tconst bare = this.bareType(node);\n\t\tif (bare !== undefined) return bare;\n\t\tconst slot: { check: Check | undefined } = { check: undefined };\n\t\tthis.cache.set(node, indirect(slot));\n\t\tconst check = this.build(node, this.r.baseFor(node, base));\n\t\tslot.check = check;\n\t\tthis.cache.set(node, check);\n\t\treturn check;\n\t}\n\n\tprivate build(node: SchemaObject, base: string): Check {\n\t\tif (this.draft === \"7\" && typeof node.$ref === \"string\") return this.ref(node.$ref, base);\n\t\tif (this.draft !== \"7\" && (node.unevaluatedProperties !== undefined || node.unevaluatedItems !== undefined)) {\n\t\t\treturn withFreshAnnotations(this.annotating(node, base));\n\t\t}\n\t\tconst check = this.plain(node, base);\n\t\treturn this.dynamic && this.r.isResource(node, base) ? scopedCheck(this.scope, base, check) : check;\n\t}\n\n\t/**\n\t * The module-level check of a schema that is only a `type` (with annotations), `ALWAYS` for one with no assertion\n\t * at all; undefined for every other schema. These are the most common subschemas and cost nothing to share.\n\t */\n\tprivate bareType(node: SchemaObject): Check | undefined {\n\t\tlet type: unknown;\n\t\tfor (const k in node) {\n\t\t\tif (k === \"type\") type = node.type;\n\t\t\telse if (!NEUTRAL_KEYWORDS.has(k)) return undefined;\n\t\t}\n\t\tif (type === undefined) return ALWAYS;\n\t\treturn typeof type === \"string\" ? TYPE_CHECKS.get(type) : undefined;\n\t}\n\n\t/** Every keyword of `node`, not tracking annotations. */\n\tprivate plain(node: SchemaObject, base: string): Check {\n\t\tconst parts: Check[] = [];\n\t\tconst types = node.type === undefined ? undefined : Array.isArray(node.type) ? node.type : [node.type];\n\t\tconst single = types?.length === 1 ? types[0] : undefined;\n\t\tlet typeInGroup = false;\n\t\tif (single === \"bytes\") {\n\t\t\tparts.push(bytesCheck(number(node.minLength) ?? 0, number(node.maxLength) ?? Number.POSITIVE_INFINITY));\n\t\t\ttypeInGroup = true;\n\t\t} else {\n\t\t\tconst string = this.stringGroup(node, single === \"string\");\n\t\t\tif (string !== undefined) parts.push(string);\n\t\t\tconst numeric = single === \"number\" || single === \"integer\" || single === \"bigint\";\n\t\t\tconst mode = single === \"number\" ? 1 : single === \"integer\" ? 2 : single === \"bigint\" ? 3 : 0;\n\t\t\tconst number = this.numberGroup(node, mode);\n\t\t\tif (number !== undefined) parts.push(number);\n\t\t\tconst object = this.objectGroup(node, base, single === \"object\");\n\t\t\tif (object !== undefined) parts.push(object);\n\t\t\tconst array = this.arrayGroup(node, base, single === \"array\");\n\t\t\tif (array !== undefined) parts.push(array);\n\t\t\ttypeInGroup =\n\t\t\t\t(single === \"string\" && string !== undefined) ||\n\t\t\t\t(numeric && number !== undefined) ||\n\t\t\t\t(single === \"object\" && object !== undefined) ||\n\t\t\t\t(single === \"array\" && array !== undefined);\n\t\t}\n\t\tif (types !== undefined && !typeInGroup) parts.unshift(typeCheck(types));\n\t\tthis.inPlace(node, base, parts);\n\t\treturn and(parts);\n\t}\n\n\t// The keywords that apply to the value itself, whatever its type.\n\tprivate inPlace(node: SchemaObject, base: string, parts: Check[]): void {\n\t\tif (Array.isArray(node.enum)) parts.push(enumCheck(node.enum));\n\t\tif (Object.hasOwn(node, \"const\")) parts.push(constCheck(node.const));\n\t\tif (Array.isArray(node.allOf)) parts.push(and(node.allOf.map((s) => this.check(s, base))));\n\t\tif (Array.isArray(node.anyOf)) parts.push(this.union(node.anyOf, base, false));\n\t\tif (Array.isArray(node.oneOf)) parts.push(this.union(node.oneOf, base, true));\n\t\tif (node.not !== undefined) parts.push(notCheck(this.check(node.not, base)));\n\t\tif (node.if !== undefined && (node.then !== undefined || node.else !== undefined)) {\n\t\t\tconst then = node.then === undefined ? ALWAYS : this.check(node.then, base);\n\t\t\tconst otherwise = node.else === undefined ? ALWAYS : this.check(node.else, base);\n\t\t\tparts.push(ifCheck(this.check(node.if, base), then, otherwise));\n\t\t}\n\t\tif (typeof node.$ref === \"string\") parts.push(this.ref(node.$ref, base));\n\t\tif (this.draft !== \"7\" && typeof node.$dynamicRef === \"string\") {\n\t\t\tparts.push(this.dynamicRef(node.$dynamicRef, base));\n\t\t}\n\t}\n\n\tprivate union(branches: readonly unknown[], base: string, exactlyOne: boolean): Check {\n\t\tconst checks = () => branches.map((s) => this.check(s, base));\n\t\treturn (\n\t\t\tconstUnion(branches, exactlyOne) ??\n\t\t\tthis.tagged(branches, base) ??\n\t\t\t(exactlyOne ? oneCheck(checks()) : anyOf(checks()))\n\t\t);\n\t}\n\n\tprivate ref(ref: string, base: string): Check {\n\t\tconst target = this.r.resolve(ref, base);\n\t\tconst check = this.check(target.node, target.base);\n\t\treturn this.dynamic && target.base !== base ? scopedCheck(this.scope, target.base, check) : check;\n\t}\n\n\tprivate dynamicRef(ref: string, base: string): Check {\n\t\tconst resolved = this.bookended(ref, base);\n\t\tif (resolved === undefined) return this.ref(ref, base);\n\t\tconst { initial, name } = resolved;\n\t\tconst fallback = this.check(initial.node, initial.base);\n\t\tconst lookup = this.dynamicLookup(name, (node, b) => this.check(node, b));\n\t\tconst scope = this.scope;\n\t\treturn (v) => {\n\t\t\tfor (let i = 0; i < scope.length; i++) {\n\t\t\t\tconst check = lookup(scope[i]);\n\t\t\t\tif (check !== null) return check(v);\n\t\t\t}\n\t\t\treturn fallback(v);\n\t\t};\n\t}\n\n\t/** The initial target and anchor name of a `$dynamicRef` that resolves dynamically, or undefined for a plain ref. */\n\tprivate bookended(\n\t\tref: string,\n\t\tbase: string,\n\t): { initial: { node: unknown; base: string }; name: string } | undefined {\n\t\tconst initial = this.r.resolve(ref, base);\n\t\tconst uri = resolveUri(ref, base);\n\t\tconst name = uri.slice(documentOf(uri).length + 1);\n\t\tconst anchored = isSchemaObject(initial.node) && initial.node.$dynamicAnchor === name;\n\t\tif (name === \"\" || name.startsWith(\"/\") || !anchored) return undefined;\n\t\tif (!this.dynamic) throw RESTART;\n\t\treturn { initial, name };\n\t}\n\n\t// Resolved at run time against the dynamic scope, so a schema with a bookended $dynamicRef keeps its compiler.\n\tprivate dynamicLookup<T>(name: string, compile: (node: SchemaObject, base: string) => T): (uri: string) => T | null {\n\t\tconst found = new Map<string, T | null>();\n\t\treturn (uri) => {\n\t\t\tconst key = `${uri}#${name}`;\n\t\t\tlet check = found.get(key);\n\t\t\tif (check === undefined) {\n\t\t\t\tconst target = this.r.dynamicAnchors.get(key);\n\t\t\t\tcheck = target === undefined ? null : compile(target, this.r.baseOf.get(target) ?? uri);\n\t\t\t\tfound.set(key, check);\n\t\t\t}\n\t\t\treturn check;\n\t\t};\n\t}\n\n\t/** anyOf/oneOf whose branches are all objects with a distinct required const on one key: the tag picks the branch. */\n\tprivate tagged(branches: readonly unknown[], base: string): Check | undefined {\n\t\tif (branches.length < 2) return undefined;\n\t\tconst resolved: SchemaObject[] = [];\n\t\tfor (const branch of branches) {\n\t\t\tif (!isSchemaObject(branch)) return undefined;\n\t\t\tconst ref = typeof branch.$ref === \"string\" && Object.keys(branch).length === 1 ? branch.$ref : undefined;\n\t\t\tconst node = ref === undefined ? branch : this.r.resolve(ref, this.r.baseFor(branch, base)).node;\n\t\t\tif (!isSchemaObject(node)) return undefined;\n\t\t\tresolved.push(node);\n\t\t}\n\t\tconst first = resolved[0].properties;\n\t\tif (!isSchemaObject(first)) return undefined;\n\t\tfor (const key of Object.keys(first)) {\n\t\t\tconst tags = resolved.map((s) => tagOf(s, key));\n\t\t\tif (tags.some((t) => t === undefined) || new Set(tags).size !== tags.length) continue;\n\t\t\treturn taggedCheck(\n\t\t\t\tkey,\n\t\t\t\ttags,\n\t\t\t\tbranches.map((s) => this.check(s, base)),\n\t\t\t);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate stringGroup(node: SchemaObject, strict: boolean): Check | undefined {\n\t\tconst min = number(node.minLength) ?? 0;\n\t\tconst max = number(node.maxLength) ?? Number.POSITIVE_INFINITY;\n\t\tconst re = typeof node.pattern === \"string\" ? sharedRegex(node.pattern) : undefined;\n\t\tconst format =\n\t\t\tthis.formats !== undefined && typeof node.format === \"string\" && Object.hasOwn(this.formats, node.format)\n\t\t\t\t? this.formats[node.format]\n\t\t\t\t: undefined;\n\t\tif (min === 0 && max === Number.POSITIVE_INFINITY && re === undefined && format === undefined) return undefined;\n\t\treturn stringCheck(strict, min, max, re, format);\n\t}\n\n\tprivate numberGroup(node: SchemaObject, mode: 0 | 1 | 2 | 3): Check | undefined {\n\t\tconst min = bound(node.minimum);\n\t\tconst max = bound(node.maximum);\n\t\tconst xmin = bound(node.exclusiveMinimum);\n\t\tconst xmax = bound(node.exclusiveMaximum);\n\t\tconst multipleOf = bound(node.multipleOf);\n\t\tif ([min, max, xmin, xmax, multipleOf].every((x) => x === undefined)) return undefined;\n\t\tconst inf = Number.POSITIVE_INFINITY;\n\t\treturn numberCheck(mode, min ?? -inf, max ?? inf, xmin ?? -inf, xmax ?? inf, multipleOf);\n\t}\n\n\tprivate objectGroup(node: SchemaObject, base: string, strict: boolean): Check | undefined {\n\t\tconst onlyCore = OBJECT_EXTRAS.every((k) => node[k] === undefined);\n\t\t// A schema with only the core object keywords gets one closure that also does the type guard.\n\t\tconst core = this.objectCore(node, base, onlyCore ? (strict ? GUARD_STRICT : GUARD_LOOSE) : GUARD_NONE);\n\t\tif (core !== undefined && onlyCore) return core;\n\t\tconst parts: Check[] = core === undefined ? [] : [core];\n\t\tif (node.propertyNames !== undefined) parts.push(propertyNamesCheck(this.check(node.propertyNames, base)));\n\t\tconst minProperties = number(node.minProperties);\n\t\tconst maxProperties = number(node.maxProperties);\n\t\tif (minProperties !== undefined || maxProperties !== undefined) {\n\t\t\tparts.push(propertyCountCheck(minProperties ?? 0, maxProperties ?? Number.POSITIVE_INFINITY));\n\t\t}\n\t\tconst dependentRequired: [string, string[]][] = [];\n\t\tconst dependentSchemas: [string, Check][] = [];\n\t\tif (this.draft !== \"7\") {\n\t\t\tfor (const [k, list] of entries(node.dependentRequired))\n\t\t\t\tif (Array.isArray(list)) dependentRequired.push([k, list]);\n\t\t\tfor (const [k, s] of entries(node.dependentSchemas)) dependentSchemas.push([k, this.check(s, base)]);\n\t\t}\n\t\tfor (const [k, d] of entries(node.dependencies)) {\n\t\t\tif (Array.isArray(d)) dependentRequired.push([k, d]);\n\t\t\telse dependentSchemas.push([k, this.check(d, base)]);\n\t\t}\n\t\tif (dependentRequired.length > 0) parts.push(dependentRequiredCheck(dependentRequired));\n\t\tif (dependentSchemas.length > 0) parts.push(dependentSchemasCheck(dependentSchemas));\n\t\tif (parts.length === 0) return strict ? IS_OBJECT : undefined;\n\t\treturn guardObject(and(parts), strict);\n\t}\n\n\tprivate objectCore(node: SchemaObject, base: string, guard: Guard): Check | undefined {\n\t\tconst properties = isSchemaObject(node.properties) ? node.properties : {};\n\t\tconst required = Array.isArray(node.required) ? node.required.filter((k) => typeof k === \"string\") : [];\n\t\tconst patterns = isSchemaObject(node.patternProperties) ? node.patternProperties : {};\n\t\tconst additional = node.additionalProperties;\n\t\tconst keys = Object.keys(properties);\n\t\tconst patternKeys = Object.keys(patterns);\n\t\tif (\n\t\t\tkeys.length + required.length + patternKeys.length === 0 &&\n\t\t\t(additional === undefined || additional === true)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// One array per object: key, check (or a leaf's argument), flags (leaf code, required, key also names an\n\t\t// Object.prototype member).\n\t\tconst entries: unknown[] = [];\n\t\tfor (const k of keys) {\n\t\t\tconst check = this.check(properties[k], base);\n\t\t\tconst leaf = leafOf(check);\n\t\t\tconst flags =\n\t\t\t\t(leaf?.[0] ?? 0) | (required.includes(k) ? REQUIRED : 0) | (k in Object.prototype ? INHERITED : 0);\n\t\t\tentries.push(k, leaf === undefined ? check : leaf[1], flags);\n\t\t}\n\t\tconst extraRequired = required.filter((k) => !Object.hasOwn(properties, k));\n\t\tconst pats = patternKeys.map((p) => [sharedRegex(p), this.check(patterns[p], base)] as const);\n\t\tconst extra = additional === undefined || additional === true ? undefined : this.check(additional, base);\n\t\tif (pats.length === 0 && extraRequired.length === 0 && (extra === undefined || additional === false)) {\n\t\t\tconst requiredCount = keys.filter((k) => required.includes(k)).length;\n\t\t\treturn declaredObject(entries, requiredCount, additional === false, guard);\n\t\t}\n\t\treturn openObject(entries, keys, extraRequired, pats, extra, guard);\n\t}\n\n\tprivate arrayGroup(node: SchemaObject, base: string, strict: boolean): Check | undefined {\n\t\tlet prefix: readonly unknown[] = [];\n\t\tlet rest: unknown;\n\t\tif (Array.isArray(node.items)) {\n\t\t\tprefix = node.items;\n\t\t\trest = node.additionalItems;\n\t\t} else {\n\t\t\tif (this.draft !== \"7\" && Array.isArray(node.prefixItems)) prefix = node.prefixItems;\n\t\t\trest = node.items;\n\t\t}\n\t\tconst prefixChecks = prefix.map((s) => this.check(s, base));\n\t\tconst restCheck = rest === undefined || rest === true ? undefined : this.check(rest, base);\n\t\tconst minItems = number(node.minItems);\n\t\tconst maxItems = number(node.maxItems);\n\t\tif (\n\t\t\tnode.contains === undefined &&\n\t\t\tnode.uniqueItems !== true &&\n\t\t\t(prefixChecks.length > 0 || restCheck !== undefined)\n\t\t) {\n\t\t\t// The common array: one closure for the guard, the length bounds and the items.\n\t\t\tconst guard = strict ? GUARD_STRICT : GUARD_LOOSE;\n\t\t\treturn listCheck(guard, minItems ?? 0, maxItems ?? Number.POSITIVE_INFINITY, prefixChecks, restCheck);\n\t\t}\n\t\tconst parts: Check[] = [];\n\t\tif (prefixChecks.length > 0 || restCheck !== undefined) parts.push(itemsCheck(prefixChecks, restCheck));\n\t\tif (minItems !== undefined || maxItems !== undefined) {\n\t\t\tparts.push(lengthCheck(minItems ?? 0, maxItems ?? Number.POSITIVE_INFINITY));\n\t\t}\n\t\tif (node.contains !== undefined) {\n\t\t\tconst min = this.draft === \"7\" ? 1 : (number(node.minContains) ?? 1);\n\t\t\tconst max =\n\t\t\t\tthis.draft === \"7\" ? Number.POSITIVE_INFINITY : (number(node.maxContains) ?? Number.POSITIVE_INFINITY);\n\t\t\tparts.push(containsCheck(this.check(node.contains, base), min, max));\n\t\t}\n\t\tif (node.uniqueItems === true) parts.push(uniqueCheck);\n\t\tif (parts.length === 0) return strict ? IS_ARRAY : undefined;\n\t\treturn guardArray(and(parts), strict);\n\t}\n\n\t/** The annotating check of a schema evaluated in place (only below `unevaluatedProperties`/`unevaluatedItems`). */\n\tannotating(node: unknown, base: string): AnnotatingCheck {\n\t\tif (node === true) return ANNOTATING_TRUE;\n\t\tif (node === false) return ANNOTATING_FALSE;\n\t\tif (!isSchemaObject(node))\n\t\t\tthrow new Error(`A schema must be an object or a boolean, got ${JSON.stringify(node)}`);\n\t\tconst cached = this.annotatingCache.get(node);\n\t\tif (cached !== undefined) return cached;\n\t\tconst slot: { check: AnnotatingCheck | undefined } = { check: undefined };\n\t\tthis.annotatingCache.set(node, indirectAnnotating(slot));\n\t\tconst check = this.buildAnnotating(node, this.r.baseFor(node, base));\n\t\tslot.check = check;\n\t\tthis.annotatingCache.set(node, check);\n\t\treturn check;\n\t}\n\n\tprivate buildAnnotating(node: SchemaObject, base: string): AnnotatingCheck {\n\t\tconst rest: Record<string, unknown> = {};\n\t\tlet annotates = false;\n\t\tfor (const k of Object.keys(node)) {\n\t\t\tif (ANNOTATING.has(k)) annotates = true;\n\t\t\telse rest[k] = node[k];\n\t\t}\n\t\tconst plain = this.plain(rest, base);\n\t\tconst parts: AnnotatingCheck[] = [];\n\t\tif (annotates) this.annotatingParts(node, base, parts);\n\t\tconst all = parts.length === 0 ? ignoreAnnotations(plain) : annotateAll(plain, parts);\n\t\tconst own =\n\t\t\tnode.unevaluatedProperties !== undefined || node.unevaluatedItems !== undefined\n\t\t\t\t? isolateAnnotations(all)\n\t\t\t\t: all;\n\t\treturn this.dynamic && this.r.isResource(node, base) ? scopedAnnotating(this.scope, base, own) : own;\n\t}\n\n\tprivate annotatingParts(node: SchemaObject, base: string, parts: AnnotatingCheck[]): void {\n\t\tif (\n\t\t\tnode.properties !== undefined ||\n\t\t\tnode.patternProperties !== undefined ||\n\t\t\tnode.additionalProperties !== undefined\n\t\t) {\n\t\t\tconst props = entries(node.properties).map(([k, s]) => [k, this.check(s, base)] as const);\n\t\t\tconst pats = entries(node.patternProperties).map(([p, s]) => [sharedRegex(p), this.check(s, base)] as const);\n\t\t\tconst extra =\n\t\t\t\tnode.additionalProperties === undefined ? undefined : this.check(node.additionalProperties, base);\n\t\t\tparts.push(annotateObject(props, pats, extra));\n\t\t}\n\t\tif (node.prefixItems !== undefined || node.items !== undefined || node.contains !== undefined) {\n\t\t\tconst prefix = Array.isArray(node.prefixItems)\n\t\t\t\t? node.prefixItems\n\t\t\t\t: Array.isArray(node.items)\n\t\t\t\t\t? node.items\n\t\t\t\t\t: [];\n\t\t\tconst rest = Array.isArray(node.items) ? node.additionalItems : node.items;\n\t\t\tparts.push(\n\t\t\t\tannotateArray(\n\t\t\t\t\tprefix.map((s) => this.check(s, base)),\n\t\t\t\t\trest === undefined ? undefined : this.check(rest, base),\n\t\t\t\t\tnode.contains === undefined ? undefined : this.check(node.contains, base),\n\t\t\t\t\tnumber(node.minContains) ?? 1,\n\t\t\t\t\tnumber(node.maxContains) ?? Number.POSITIVE_INFINITY,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (Array.isArray(node.allOf)) for (const s of node.allOf) parts.push(this.annotating(s, base));\n\t\tif (Array.isArray(node.anyOf))\n\t\t\tparts.push(\n\t\t\t\tannotateAny(\n\t\t\t\t\tnode.anyOf.map((s) => this.annotating(s, base)),\n\t\t\t\t\tfalse,\n\t\t\t\t),\n\t\t\t);\n\t\tif (Array.isArray(node.oneOf))\n\t\t\tparts.push(\n\t\t\t\tannotateAny(\n\t\t\t\t\tnode.oneOf.map((s) => this.annotating(s, base)),\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\tif (node.if !== undefined) {\n\t\t\tconst then = node.then === undefined ? undefined : this.annotating(node.then, base);\n\t\t\tconst otherwise = node.else === undefined ? undefined : this.annotating(node.else, base);\n\t\t\tparts.push(annotateIf(this.annotating(node.if, base), then, otherwise));\n\t\t}\n\t\tif (typeof node.$ref === \"string\") parts.push(this.annotatingRef(node.$ref, base));\n\t\tif (typeof node.$dynamicRef === \"string\") parts.push(this.annotatingDynamicRef(node.$dynamicRef, base));\n\t\tfor (const [k, s] of entries(node.dependentSchemas)) parts.push(annotateDependent(k, this.annotating(s, base)));\n\t\tif (node.unevaluatedProperties !== undefined) {\n\t\t\tparts.push(unevaluatedProperties(this.check(node.unevaluatedProperties, base)));\n\t\t}\n\t\tif (node.unevaluatedItems !== undefined) parts.push(unevaluatedItems(this.check(node.unevaluatedItems, base)));\n\t}\n\n\tprivate annotatingRef(ref: string, base: string): AnnotatingCheck {\n\t\tconst target = this.r.resolve(ref, base);\n\t\tconst check = this.annotating(target.node, target.base);\n\t\treturn this.dynamic && target.base !== base ? scopedAnnotating(this.scope, target.base, check) : check;\n\t}\n\n\tprivate annotatingDynamicRef(ref: string, base: string): AnnotatingCheck {\n\t\tconst resolved = this.bookended(ref, base);\n\t\tif (resolved === undefined) return this.annotatingRef(ref, base);\n\t\tconst { initial, name } = resolved;\n\t\tconst fallback = this.annotating(initial.node, initial.base);\n\t\tconst lookup = this.dynamicLookup(name, (node, b) => this.annotating(node, b));\n\t\tconst scope = this.scope;\n\t\treturn (v, a) => {\n\t\t\tfor (let i = 0; i < scope.length; i++) {\n\t\t\t\tconst check = lookup(scope[i]);\n\t\t\t\tif (check !== null) return check(v, a);\n\t\t\t}\n\t\t\treturn fallback(v, a);\n\t\t};\n\t}\n}\n\n/** Keywords that never affect a check. */\nexport const NEUTRAL_KEYWORDS = new Set([\n\t\"$schema\",\n\t\"$comment\",\n\t\"title\",\n\t\"description\",\n\t\"default\",\n\t\"examples\",\n\t\"deprecated\",\n\t\"readOnly\",\n\t\"writeOnly\",\n\t\"$defs\",\n\t\"definitions\",\n\t\"contentEncoding\",\n\t\"contentMediaType\",\n\t\"minContains\",\n\t\"maxContains\",\n\t\"$vocabulary\",\n]);\n\n// The object keywords besides the core (properties, required, patternProperties, additionalProperties).\nconst OBJECT_EXTRAS = [\n\t\"propertyNames\",\n\t\"minProperties\",\n\t\"maxProperties\",\n\t\"dependentRequired\",\n\t\"dependentSchemas\",\n\t\"dependencies\",\n];\n\n// The keywords an annotating check handles itself; every other keyword compiles into its plain part.\nconst ANNOTATING = new Set([\n\t\"properties\",\n\t\"patternProperties\",\n\t\"additionalProperties\",\n\t\"prefixItems\",\n\t\"items\",\n\t\"additionalItems\",\n\t\"contains\",\n\t\"minContains\",\n\t\"maxContains\",\n\t\"allOf\",\n\t\"anyOf\",\n\t\"oneOf\",\n\t\"if\",\n\t\"then\",\n\t\"else\",\n\t\"$ref\",\n\t\"$dynamicRef\",\n\t\"dependentSchemas\",\n\t\"unevaluatedProperties\",\n\t\"unevaluatedItems\",\n]);\n\n/** anyOf/oneOf whose branches are all `{ const: primitive }`: an enum (distinct values make oneOf the same). */\nfunction constUnion(branches: readonly unknown[], exactlyOne: boolean): Check | undefined {\n\tconst values: unknown[] = [];\n\tfor (const branch of branches) {\n\t\tif (!isSchemaObject(branch) || !Object.hasOwn(branch, \"const\")) return undefined;\n\t\tfor (const k of Object.keys(branch)) if (k !== \"const\" && !NEUTRAL_KEYWORDS.has(k)) return undefined;\n\t\tif (typeof branch.const === \"object\" && branch.const !== null) return undefined;\n\t\tif (exactlyOne && values.includes(branch.const)) return undefined;\n\t\tvalues.push(branch.const);\n\t}\n\treturn enumCheck(values);\n}\n\n/** `anyOf`: its bare-type branches (`nullable` gives one) run as one type test. */\nfunction anyOf(checks: readonly Check[]): Check {\n\tconst types: string[] = [];\n\tconst rest: Check[] = [];\n\tfor (const check of checks) {\n\t\tconst type = BARE_TYPES.get(check);\n\t\tif (type === undefined) rest.push(check);\n\t\telse types.push(type);\n\t}\n\treturn types.length === 0 ? anyCheck(rest) : maskedAnyCheck(typeMask(types), rest);\n}\n\nconst BARE_TYPES: ReadonlyMap<Check, string> = new Map([...TYPE_CHECKS].map(([type, check]) => [check, type]));\n\n// The tag of a tagged-union branch: a primitive const on a required property of an object schema.\nfunction tagOf(branch: SchemaObject, key: string): unknown {\n\tconst properties = branch.properties;\n\tif (branch.type !== \"object\" || !Array.isArray(branch.required) || !branch.required.includes(key)) return undefined;\n\tconst tag = isSchemaObject(properties) ? properties[key] : undefined;\n\tif (!isSchemaObject(tag) || !Object.hasOwn(tag, \"const\")) return undefined;\n\treturn typeof tag.const === \"object\" && tag.const !== null ? undefined : tag.const;\n}\n\n/** A number keyword's value: a number, or a bigint (TypeBox's `Type.BigInt` bounds). */\nfunction bound(value: unknown): Bound | undefined {\n\treturn typeof value === \"number\" || typeof value === \"bigint\" ? value : undefined;\n}\n\nfunction number(value: unknown): number | undefined {\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction entries(value: unknown): [string, unknown][] {\n\treturn isSchemaObject(value) ? Object.entries(value) : [];\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Compiler } from "./compiler.ts";
|
|
2
|
+
import type { ValidationError } from "./types.ts";
|
|
3
|
+
/** Explains failures of one compiled schema. */
|
|
4
|
+
export declare class Explainer {
|
|
5
|
+
private readonly c;
|
|
6
|
+
private readonly schema;
|
|
7
|
+
/**
|
|
8
|
+
* The errors of `$ref` targets for object values, within one errors() call: a recursive union explains each branch
|
|
9
|
+
* to pick the one to blame, and every branch would explain the same children again, exponentially in the depth.
|
|
10
|
+
*/
|
|
11
|
+
private memo;
|
|
12
|
+
constructor(compiler: Compiler, schema: unknown);
|
|
13
|
+
/** The errors of `value`, at least one (`value` failed the check). */
|
|
14
|
+
errors(value: unknown): ValidationError[];
|
|
15
|
+
private ok;
|
|
16
|
+
private walk;
|
|
17
|
+
private walkRef;
|
|
18
|
+
private walkString;
|
|
19
|
+
private walkBytes;
|
|
20
|
+
private walkNumber;
|
|
21
|
+
private walkObject;
|
|
22
|
+
private walkArray;
|
|
23
|
+
private walkUnion;
|
|
24
|
+
/** How many of the keys of `v` the branch `s` (through a `$ref`) declares in `properties`. */
|
|
25
|
+
private declaredKeys;
|
|
26
|
+
private tagOf;
|
|
27
|
+
private walkUnevaluated;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EAAgB,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhE,gDAAgD;AAChD,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAW;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC;;;OAGG;IACH,OAAO,CAAC,IAAI,CAAgG;IAE5G,YAAY,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAI9C;IAED,sEAAsE;IACtE,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CASxC;IAED,OAAO,CAAC,EAAE;IAKV,OAAO,CAAC,IAAI;IAmDZ,OAAO,CAAC,OAAO;IA2Bf,OAAO,CAAC,UAAU;IAmBlB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,UAAU;IA4DlB,OAAO,CAAC,SAAS;IAsCjB,OAAO,CAAC,SAAS;IA6CjB,8FAA8F;IAC9F,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,KAAK;IAiBb,OAAO,CAAC,eAAe;CAsBvB"}
|
package/dist/explain.js
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
// Errors of a failed value: a walk over the schema that reports each failing keyword at the value it failed on.
|
|
2
|
+
// It runs only for values that failed the check, using the compiler's checks for subschemas.
|
|
3
|
+
import { newAnnotations } from "./annotations.js";
|
|
4
|
+
import { codePoints, constCheck, containsCheck, enumCheck, isMultiple, isObject, NEVER, TYPE_CHECKS, uniqueCheck, } from "./checks.js";
|
|
5
|
+
import { isSchemaObject } from "./resolver.js";
|
|
6
|
+
import { sharedRegex } from "./shared.js";
|
|
7
|
+
/** Explains failures of one compiled schema. */
|
|
8
|
+
export class Explainer {
|
|
9
|
+
c;
|
|
10
|
+
schema;
|
|
11
|
+
/**
|
|
12
|
+
* The errors of `$ref` targets for object values, within one errors() call: a recursive union explains each branch
|
|
13
|
+
* to pick the one to blame, and every branch would explain the same children again, exponentially in the depth.
|
|
14
|
+
*/
|
|
15
|
+
memo = undefined;
|
|
16
|
+
constructor(compiler, schema) {
|
|
17
|
+
this.c = compiler;
|
|
18
|
+
this.schema = schema;
|
|
19
|
+
compiler.root();
|
|
20
|
+
}
|
|
21
|
+
/** The errors of `value`, at least one (`value` failed the check). */
|
|
22
|
+
errors(value) {
|
|
23
|
+
const out = [];
|
|
24
|
+
try {
|
|
25
|
+
this.walk(this.schema, this.c.r.rootBase, value, "", out);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
this.memo = undefined;
|
|
29
|
+
}
|
|
30
|
+
if (out.length === 0)
|
|
31
|
+
out.push({ path: "", keyword: "schema", message: "invalid" });
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
ok(node, base, v) {
|
|
35
|
+
return this.c.check(node, base)(v);
|
|
36
|
+
}
|
|
37
|
+
// For $dynamicRef schemas this check runs outside the original dynamic scope, so their errors are approximate.
|
|
38
|
+
walk(node, base, v, path, out) {
|
|
39
|
+
if (node === true)
|
|
40
|
+
return;
|
|
41
|
+
if (node === false) {
|
|
42
|
+
out.push({ path, keyword: "false", message: "no value is allowed here" });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!isSchemaObject(node))
|
|
46
|
+
return;
|
|
47
|
+
const b = this.c.r.baseFor(node, base);
|
|
48
|
+
if (this.ok(node, b, v))
|
|
49
|
+
return;
|
|
50
|
+
const start = out.length;
|
|
51
|
+
const push = (keyword, message, at = path) => {
|
|
52
|
+
out.push({ path: at, keyword, message });
|
|
53
|
+
};
|
|
54
|
+
if (this.c.draft === "7" && typeof node.$ref === "string") {
|
|
55
|
+
this.walkRef(node.$ref, b, v, path, out);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (node.type !== undefined) {
|
|
59
|
+
const types = Array.isArray(node.type) ? node.type : [node.type];
|
|
60
|
+
const checks = types.map((t) => (typeof t === "string" ? TYPE_CHECKS.get(t) : undefined) ?? NEVER);
|
|
61
|
+
if (!checks.some((check) => check(v))) {
|
|
62
|
+
push("type", `expected ${types.join(" or ")}, got ${typeName(v)}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(node.enum) && !enumCheck(node.enum)(v))
|
|
67
|
+
push("enum", `expected one of ${listValues(node.enum)}`);
|
|
68
|
+
if (Object.hasOwn(node, "const") && !constCheck(node.const)(v))
|
|
69
|
+
push("const", `expected ${JSON.stringify(node.const)}`);
|
|
70
|
+
if (typeof v === "string" && node.type !== "bytes")
|
|
71
|
+
this.walkString(node, v, push);
|
|
72
|
+
if (v instanceof Uint8Array && node.type === "bytes")
|
|
73
|
+
this.walkBytes(node, v, push);
|
|
74
|
+
if (typeof v === "number" || typeof v === "bigint")
|
|
75
|
+
this.walkNumber(node, v, push);
|
|
76
|
+
if (isObject(v))
|
|
77
|
+
this.walkObject(node, b, v, path, out, push);
|
|
78
|
+
if (Array.isArray(v))
|
|
79
|
+
this.walkArray(node, b, v, path, out, push);
|
|
80
|
+
if (Array.isArray(node.allOf))
|
|
81
|
+
for (const s of node.allOf)
|
|
82
|
+
this.walk(s, b, v, path, out);
|
|
83
|
+
if (Array.isArray(node.anyOf))
|
|
84
|
+
this.walkUnion(node.anyOf, b, v, path, out, false);
|
|
85
|
+
if (Array.isArray(node.oneOf))
|
|
86
|
+
this.walkUnion(node.oneOf, b, v, path, out, true);
|
|
87
|
+
if (node.not !== undefined && this.ok(node.not, b, v))
|
|
88
|
+
push("not", "must not match the schema in not");
|
|
89
|
+
if (node.if !== undefined) {
|
|
90
|
+
const branch = this.ok(node.if, b, v) ? node.then : node.else;
|
|
91
|
+
if (branch !== undefined)
|
|
92
|
+
this.walk(branch, b, v, path, out);
|
|
93
|
+
}
|
|
94
|
+
if (typeof node.$ref === "string")
|
|
95
|
+
this.walkRef(node.$ref, b, v, path, out);
|
|
96
|
+
if (out.length === start && (node.unevaluatedProperties !== undefined || node.unevaluatedItems !== undefined)) {
|
|
97
|
+
this.walkUnevaluated(node, b, v, path, out);
|
|
98
|
+
}
|
|
99
|
+
if (out.length === start && typeof node.$dynamicRef === "string") {
|
|
100
|
+
push("$dynamicRef", "does not match the dynamically referenced schema");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
walkRef(ref, base, v, path, out) {
|
|
104
|
+
const target = this.c.r.resolve(ref, base);
|
|
105
|
+
if (target.node === false && this.c.r.isUnresolved(ref, base)) {
|
|
106
|
+
out.push({ path, keyword: "$ref", message: `unresolved reference ${ref}` });
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!isSchemaObject(target.node) || typeof v !== "object" || v === null) {
|
|
110
|
+
this.walk(target.node, target.base, v, path, out);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.memo ??= new Map();
|
|
114
|
+
let values = this.memo.get(target.node);
|
|
115
|
+
const known = values?.get(v);
|
|
116
|
+
if (known !== undefined && known.path === path) {
|
|
117
|
+
out.push(...known.errors);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const errors = [];
|
|
121
|
+
this.walk(target.node, target.base, v, path, errors);
|
|
122
|
+
if (values === undefined) {
|
|
123
|
+
values = new Map();
|
|
124
|
+
this.memo.set(target.node, values);
|
|
125
|
+
}
|
|
126
|
+
values.set(v, { path, errors });
|
|
127
|
+
out.push(...errors);
|
|
128
|
+
}
|
|
129
|
+
walkString(node, v, push) {
|
|
130
|
+
const n = codePoints(v);
|
|
131
|
+
if (typeof node.minLength === "number" && n < node.minLength) {
|
|
132
|
+
push("minLength", `expected at least ${node.minLength} characters`);
|
|
133
|
+
}
|
|
134
|
+
if (typeof node.maxLength === "number" && n > node.maxLength) {
|
|
135
|
+
push("maxLength", `expected at most ${node.maxLength} characters`);
|
|
136
|
+
}
|
|
137
|
+
if (typeof node.pattern === "string" && !sharedRegex(node.pattern).test(v)) {
|
|
138
|
+
push("pattern", `expected to match ${node.pattern}`);
|
|
139
|
+
}
|
|
140
|
+
const formats = this.c.formats;
|
|
141
|
+
const format = formats !== undefined && typeof node.format === "string" && Object.hasOwn(formats, node.format)
|
|
142
|
+
? formats[node.format]
|
|
143
|
+
: undefined;
|
|
144
|
+
if (format !== undefined && !format(v))
|
|
145
|
+
push("format", `expected format ${node.format}`);
|
|
146
|
+
}
|
|
147
|
+
walkBytes(node, v, push) {
|
|
148
|
+
if (typeof node.minLength === "number" && v.length < node.minLength) {
|
|
149
|
+
push("minLength", `expected at least ${node.minLength} bytes`);
|
|
150
|
+
}
|
|
151
|
+
if (typeof node.maxLength === "number" && v.length > node.maxLength) {
|
|
152
|
+
push("maxLength", `expected at most ${node.maxLength} bytes`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Numbers and bigints alike: bounds of either kind compare with values of either kind.
|
|
156
|
+
walkNumber(node, v, push) {
|
|
157
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf } = node;
|
|
158
|
+
if (isBound(minimum) && v < minimum)
|
|
159
|
+
push("minimum", `expected >= ${minimum}`);
|
|
160
|
+
if (isBound(maximum) && v > maximum)
|
|
161
|
+
push("maximum", `expected <= ${maximum}`);
|
|
162
|
+
if (isBound(exclusiveMinimum) && v <= exclusiveMinimum)
|
|
163
|
+
push("exclusiveMinimum", `expected > ${exclusiveMinimum}`);
|
|
164
|
+
if (isBound(exclusiveMaximum) && v >= exclusiveMaximum)
|
|
165
|
+
push("exclusiveMaximum", `expected < ${exclusiveMaximum}`);
|
|
166
|
+
if (isBound(multipleOf) && !isMultiple(v, multipleOf))
|
|
167
|
+
push("multipleOf", `expected a multiple of ${multipleOf}`);
|
|
168
|
+
}
|
|
169
|
+
walkObject(node, b, v, path, out, push) {
|
|
170
|
+
const properties = isSchemaObject(node.properties) ? node.properties : {};
|
|
171
|
+
const required = Array.isArray(node.required) ? node.required : [];
|
|
172
|
+
for (const k of required) {
|
|
173
|
+
if (typeof k !== "string")
|
|
174
|
+
continue;
|
|
175
|
+
// Present and set to undefined: missing unless its schema takes undefined (see declaredObject).
|
|
176
|
+
const accepted = v[k] === undefined && Object.hasOwn(properties, k) && this.ok(properties[k], b, undefined);
|
|
177
|
+
if (!Object.hasOwn(v, k) || (v[k] === undefined && !accepted))
|
|
178
|
+
push("required", "missing", pointer(path, k));
|
|
179
|
+
}
|
|
180
|
+
for (const k of Object.keys(properties)) {
|
|
181
|
+
if (Object.hasOwn(v, k) && v[k] !== undefined)
|
|
182
|
+
this.walk(properties[k], b, v[k], pointer(path, k), out);
|
|
183
|
+
}
|
|
184
|
+
const patterns = isSchemaObject(node.patternProperties) ? Object.entries(node.patternProperties) : [];
|
|
185
|
+
for (const k of Object.keys(v)) {
|
|
186
|
+
let matched = Object.hasOwn(properties, k);
|
|
187
|
+
for (const [p, s] of patterns) {
|
|
188
|
+
if (sharedRegex(p).test(k)) {
|
|
189
|
+
matched = true;
|
|
190
|
+
this.walk(s, b, v[k], pointer(path, k), out);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (!matched && node.additionalProperties !== undefined) {
|
|
194
|
+
if (node.additionalProperties === false)
|
|
195
|
+
push("additionalProperties", "unknown field", pointer(path, k));
|
|
196
|
+
else
|
|
197
|
+
this.walk(node.additionalProperties, b, v[k], pointer(path, k), out);
|
|
198
|
+
}
|
|
199
|
+
if (node.propertyNames !== undefined && !this.ok(node.propertyNames, b, k)) {
|
|
200
|
+
push("propertyNames", "invalid property name", pointer(path, k));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const count = Object.keys(v).length;
|
|
204
|
+
if (typeof node.minProperties === "number" && count < node.minProperties) {
|
|
205
|
+
push("minProperties", `expected at least ${node.minProperties} properties`);
|
|
206
|
+
}
|
|
207
|
+
if (typeof node.maxProperties === "number" && count > node.maxProperties) {
|
|
208
|
+
push("maxProperties", `expected at most ${node.maxProperties} properties`);
|
|
209
|
+
}
|
|
210
|
+
const dependencies = {
|
|
211
|
+
...(this.c.draft === "7" || !isSchemaObject(node.dependentRequired) ? {} : node.dependentRequired),
|
|
212
|
+
...(isSchemaObject(node.dependencies) ? node.dependencies : {}),
|
|
213
|
+
};
|
|
214
|
+
for (const [k, d] of Object.entries(dependencies)) {
|
|
215
|
+
if (!Object.hasOwn(v, k))
|
|
216
|
+
continue;
|
|
217
|
+
if (!Array.isArray(d))
|
|
218
|
+
this.walk(d, b, v, path, out);
|
|
219
|
+
else
|
|
220
|
+
for (const r of d)
|
|
221
|
+
if (!Object.hasOwn(v, r))
|
|
222
|
+
push("dependentRequired", `required when ${k} is present`, pointer(path, r));
|
|
223
|
+
}
|
|
224
|
+
if (this.c.draft !== "7" && isSchemaObject(node.dependentSchemas)) {
|
|
225
|
+
for (const [k, s] of Object.entries(node.dependentSchemas))
|
|
226
|
+
if (Object.hasOwn(v, k))
|
|
227
|
+
this.walk(s, b, v, path, out);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
walkArray(node, b, v, path, out, push) {
|
|
231
|
+
let prefix = [];
|
|
232
|
+
let rest;
|
|
233
|
+
if (Array.isArray(node.items)) {
|
|
234
|
+
prefix = node.items;
|
|
235
|
+
rest = node.additionalItems;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
if (this.c.draft !== "7" && Array.isArray(node.prefixItems))
|
|
239
|
+
prefix = node.prefixItems;
|
|
240
|
+
rest = node.items;
|
|
241
|
+
}
|
|
242
|
+
for (let i = 0; i < v.length; i++) {
|
|
243
|
+
const s = i < prefix.length ? prefix[i] : rest;
|
|
244
|
+
if (s !== undefined)
|
|
245
|
+
this.walk(s, b, v[i], `${path}/${i}`, out);
|
|
246
|
+
}
|
|
247
|
+
if (typeof node.minItems === "number" && v.length < node.minItems) {
|
|
248
|
+
push("minItems", `expected at least ${node.minItems} items`);
|
|
249
|
+
}
|
|
250
|
+
if (typeof node.maxItems === "number" && v.length > node.maxItems) {
|
|
251
|
+
push("maxItems", `expected at most ${node.maxItems} items`);
|
|
252
|
+
}
|
|
253
|
+
if (node.uniqueItems === true && !uniqueCheck(v))
|
|
254
|
+
push("uniqueItems", "expected unique items");
|
|
255
|
+
if (node.contains !== undefined) {
|
|
256
|
+
const draft7 = this.c.draft === "7";
|
|
257
|
+
const min = draft7 || typeof node.minContains !== "number" ? 1 : node.minContains;
|
|
258
|
+
const max = draft7 || typeof node.maxContains !== "number" ? Number.POSITIVE_INFINITY : node.maxContains;
|
|
259
|
+
if (!containsCheck(this.c.check(node.contains, b), min, max)(v)) {
|
|
260
|
+
push("contains", containsMessage(min, max));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
walkUnion(branches, b, v, path, out, exactlyOne) {
|
|
265
|
+
const matches = branches.filter((s) => this.ok(s, b, v)).length;
|
|
266
|
+
if (matches === 1 || (!exactlyOne && matches > 0))
|
|
267
|
+
return;
|
|
268
|
+
const keyword = exactlyOne ? "oneOf" : "anyOf";
|
|
269
|
+
if (matches > 1) {
|
|
270
|
+
out.push({ path, keyword, message: "matches more than one alternative" });
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
// A tagged union reports the branch its tag selects; otherwise the branch whose first error is deepest.
|
|
274
|
+
const tag = this.tagOf(branches, b);
|
|
275
|
+
if (tag !== undefined && isObject(v)) {
|
|
276
|
+
const i = tag.values.indexOf(v[tag.key]);
|
|
277
|
+
if (i < 0)
|
|
278
|
+
out.push({
|
|
279
|
+
path: pointer(path, tag.key),
|
|
280
|
+
keyword,
|
|
281
|
+
message: `expected one of ${listValues(tag.values)}`,
|
|
282
|
+
});
|
|
283
|
+
else
|
|
284
|
+
this.walk(branches[i], b, v, path, out);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
// An object is blamed on the branch that declares most of its properties (the one it was most likely meant for),
|
|
288
|
+
// then on the branch whose first error is deepest.
|
|
289
|
+
let best;
|
|
290
|
+
for (const s of branches) {
|
|
291
|
+
const errors = [];
|
|
292
|
+
this.walk(s, b, v, path, errors);
|
|
293
|
+
if (errors.length === 0)
|
|
294
|
+
continue;
|
|
295
|
+
const declared = isObject(v) ? this.declaredKeys(s, b, v) : 0;
|
|
296
|
+
const better = best === undefined ||
|
|
297
|
+
declared > best.declared ||
|
|
298
|
+
(declared === best.declared && errors[0].path.length > best.errors[0].path.length);
|
|
299
|
+
if (better)
|
|
300
|
+
best = { errors, declared };
|
|
301
|
+
}
|
|
302
|
+
out.push(...(best?.errors ?? [{ path, keyword, message: "matches no alternative" }]));
|
|
303
|
+
}
|
|
304
|
+
/** How many of the keys of `v` the branch `s` (through a `$ref`) declares in `properties`. */
|
|
305
|
+
declaredKeys(s, b, v) {
|
|
306
|
+
const node = isSchemaObject(s) && typeof s.$ref === "string" ? this.c.r.resolve(s.$ref, this.c.r.baseFor(s, b)).node : s;
|
|
307
|
+
const properties = isSchemaObject(node) && isSchemaObject(node.properties) ? node.properties : {};
|
|
308
|
+
return Object.keys(v).filter((k) => Object.hasOwn(properties, k)).length;
|
|
309
|
+
}
|
|
310
|
+
tagOf(branches, b) {
|
|
311
|
+
const resolved = branches.map((s) => isSchemaObject(s) && typeof s.$ref === "string" ? this.c.r.resolve(s.$ref, this.c.r.baseFor(s, b)).node : s);
|
|
312
|
+
const first = resolved[0];
|
|
313
|
+
if (!isSchemaObject(first) || !isSchemaObject(first.properties))
|
|
314
|
+
return undefined;
|
|
315
|
+
for (const key of Object.keys(first.properties)) {
|
|
316
|
+
const values = resolved.map((s) => {
|
|
317
|
+
const tag = isSchemaObject(s) && isSchemaObject(s.properties) ? s.properties[key] : undefined;
|
|
318
|
+
return isSchemaObject(tag) ? tag.const : undefined;
|
|
319
|
+
});
|
|
320
|
+
const primitive = values.every((x) => x !== undefined && (typeof x !== "object" || x === null));
|
|
321
|
+
if (primitive && new Set(values).size === values.length)
|
|
322
|
+
return { key, values };
|
|
323
|
+
}
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
walkUnevaluated(node, b, v, path, out) {
|
|
327
|
+
// `b` already applies the node's `$id`; the copy must not apply it again.
|
|
328
|
+
const { unevaluatedProperties, unevaluatedItems, $id: _id, ...rest } = node;
|
|
329
|
+
const a = newAnnotations();
|
|
330
|
+
this.c.annotating(rest, b)(v, a);
|
|
331
|
+
if (isObject(v) && unevaluatedProperties !== undefined && !a.allProps) {
|
|
332
|
+
for (const k of Object.keys(v)) {
|
|
333
|
+
if (a.props?.has(k))
|
|
334
|
+
continue;
|
|
335
|
+
if (unevaluatedProperties === false) {
|
|
336
|
+
out.push({ path: pointer(path, k), keyword: "unevaluatedProperties", message: "unknown field" });
|
|
337
|
+
}
|
|
338
|
+
else
|
|
339
|
+
this.walk(unevaluatedProperties, b, v[k], pointer(path, k), out);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (Array.isArray(v) && unevaluatedItems !== undefined && !a.allItems) {
|
|
343
|
+
for (let i = a.items; i < v.length; i++) {
|
|
344
|
+
if (a.indexes?.has(i))
|
|
345
|
+
continue;
|
|
346
|
+
if (unevaluatedItems === false) {
|
|
347
|
+
out.push({ path: `${path}/${i}`, keyword: "unevaluatedItems", message: "unexpected item" });
|
|
348
|
+
}
|
|
349
|
+
else
|
|
350
|
+
this.walk(unevaluatedItems, b, v[i], `${path}/${i}`, out);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// Enum errors name the allowed values; a long list (an enum of thousands) is cut, so the message stays readable.
|
|
356
|
+
const LISTED_VALUES = 20;
|
|
357
|
+
/** `values` as JSON, at most LISTED_VALUES of them, then how many more there are. */
|
|
358
|
+
function listValues(values) {
|
|
359
|
+
if (values.length <= LISTED_VALUES)
|
|
360
|
+
return JSON.stringify(values);
|
|
361
|
+
const listed = JSON.stringify(values.slice(0, LISTED_VALUES));
|
|
362
|
+
return `${listed.slice(0, -1)}, ... and ${values.length - LISTED_VALUES} more]`;
|
|
363
|
+
}
|
|
364
|
+
function containsMessage(min, max) {
|
|
365
|
+
if (max === Number.POSITIVE_INFINITY)
|
|
366
|
+
return `expected at least ${min} matching ${min === 1 ? "item" : "items"}`;
|
|
367
|
+
if (min === 0)
|
|
368
|
+
return `expected at most ${max} matching ${max === 1 ? "item" : "items"}`;
|
|
369
|
+
return `expected between ${min} and ${max} matching items`;
|
|
370
|
+
}
|
|
371
|
+
function isBound(value) {
|
|
372
|
+
return typeof value === "number" || typeof value === "bigint";
|
|
373
|
+
}
|
|
374
|
+
function pointer(path, key) {
|
|
375
|
+
return `${path}/${String(key).replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
376
|
+
}
|
|
377
|
+
function typeName(v) {
|
|
378
|
+
if (v === null)
|
|
379
|
+
return "null";
|
|
380
|
+
if (Array.isArray(v))
|
|
381
|
+
return "array";
|
|
382
|
+
if (v instanceof Uint8Array)
|
|
383
|
+
return "bytes";
|
|
384
|
+
if (typeof v === "bigint")
|
|
385
|
+
return "bigint";
|
|
386
|
+
if (typeof v === "number" && Number.isInteger(v))
|
|
387
|
+
return "integer";
|
|
388
|
+
if (typeof v === "number" && !Number.isFinite(v))
|
|
389
|
+
return String(v);
|
|
390
|
+
return typeof v;
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=explain.js.map
|