@kubb/agent 5.0.0-beta.75 → 5.0.0-beta.8
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +353 -418
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +1 -1
- package/.output/server/index.mjs +1 -1
- package/.output/server/node_modules/ajv/dist/2019.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/2019.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/2020.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/2020.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/ajv.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/ajv.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/index.d.ts +2 -1
- package/.output/server/node_modules/ajv/dist/compile/index.js +10 -3
- package/.output/server/node_modules/ajv/dist/compile/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js +1 -1
- package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/names.d.ts +1 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js +1 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/compile/validate/index.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js +18 -4
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/core.d.ts +4 -0
- package/.output/server/node_modules/ajv/dist/core.js +15 -1
- package/.output/server/node_modules/ajv/dist/core.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/draft4.d.ts +19 -0
- package/.output/server/node_modules/ajv/dist/draft4.js +57 -0
- package/.output/server/node_modules/ajv/dist/draft4.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-04.json +138 -0
- package/.output/server/node_modules/ajv/dist/types/index.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +2 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +2 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/code.d.ts +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js +10 -3
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +12 -2
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +56 -21
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/draft4.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js +29 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +10 -2
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +22 -3
- package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.d.ts +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js +43 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js +19 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +4 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js +20 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js.map +1 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +8 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.d.ts +3 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js +20 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js.map +1 -0
- package/.output/server/node_modules/ajv/lib/2019.ts +1 -0
- package/.output/server/node_modules/ajv/lib/2020.ts +1 -0
- package/.output/server/node_modules/ajv/lib/ajv.ts +1 -0
- package/.output/server/node_modules/ajv/lib/compile/index.ts +16 -3
- package/.output/server/node_modules/ajv/lib/compile/jtd/parse.ts +3 -1
- package/.output/server/node_modules/ajv/lib/compile/jtd/serialize.ts +3 -1
- package/.output/server/node_modules/ajv/lib/compile/names.ts +1 -0
- package/.output/server/node_modules/ajv/lib/compile/validate/index.ts +21 -4
- package/.output/server/node_modules/ajv/lib/core.ts +20 -1
- package/.output/server/node_modules/ajv/lib/draft4.ts +79 -0
- package/.output/server/node_modules/ajv/lib/refs/json-schema-draft-04.json +138 -0
- package/.output/server/node_modules/ajv/lib/types/index.ts +4 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +2 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +1 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/applicator/properties.ts +4 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/code.ts +10 -3
- package/.output/server/node_modules/ajv/lib/vocabularies/core/ref.ts +21 -5
- package/.output/server/node_modules/ajv/lib/vocabularies/discriminator/index.ts +69 -19
- package/.output/server/node_modules/ajv/lib/vocabularies/draft4.ts +32 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/metadata.ts +10 -2
- package/.output/server/node_modules/ajv/lib/vocabularies/oasContext.ts +27 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +29 -7
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumber.ts +75 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumberExclusive.ts +26 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/index.ts +4 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/readOnly.ts +23 -0
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/required.ts +7 -1
- package/.output/server/node_modules/ajv/lib/vocabularies/validation/writeOnly.ts +22 -0
- package/.output/server/node_modules/ajv/package.json +9 -6
- package/.output/server/node_modules/jiti/LICENSE +21 -0
- package/.output/server/node_modules/jiti/README.md +258 -0
- package/.output/server/node_modules/jiti/dist/babel.cjs +257 -0
- package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/.output/server/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/.output/server/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/.output/server/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/.output/server/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/.output/server/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/.output/server/node_modules/jiti/lib/jiti.cjs +30 -0
- package/.output/server/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/.output/server/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
- package/.output/server/node_modules/jiti/lib/types.d.ts +420 -0
- package/.output/server/node_modules/jiti/package.json +146 -0
- package/.output/server/package.json +2 -5
- package/README.md +62 -27
- package/package.json +13 -12
- package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
- package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.js +0 -256
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.js +0 -75
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/index.js +0 -3
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.js +0 -70
- package/.output/server/node_modules/@rolldown/pluginutils/dist/index.js +0 -1
- package/.output/server/node_modules/@rolldown/pluginutils/dist/utils.js +0 -17
- package/.output/server/node_modules/@rolldown/pluginutils/package.json +0 -37
- package/.output/server/node_modules/rolldown/dist/index.mjs +0 -50
- package/.output/server/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
- package/.output/server/node_modules/rolldown/dist/shared/binding-BeU_1iEk.mjs +0 -582
- package/.output/server/node_modules/rolldown/dist/shared/bindingify-input-options-DbbBhzky.mjs +0 -2211
- package/.output/server/node_modules/rolldown/dist/shared/define-config-DJOr6Iwt.mjs +0 -6
- package/.output/server/node_modules/rolldown/dist/shared/error-DL-e8-oE.mjs +0 -85
- package/.output/server/node_modules/rolldown/dist/shared/logs-D80CXhvg.mjs +0 -180
- package/.output/server/node_modules/rolldown/dist/shared/misc-DJYbNKZX.mjs +0 -21
- package/.output/server/node_modules/rolldown/dist/shared/normalize-string-or-regex-CbQQ69gT.mjs +0 -66
- package/.output/server/node_modules/rolldown/dist/shared/parse-B_ZnWxLZ.mjs +0 -74
- package/.output/server/node_modules/rolldown/dist/shared/prompt-U5ajztzG.mjs +0 -847
- package/.output/server/node_modules/rolldown/dist/shared/rolldown-D3JZ9rMt.mjs +0 -40
- package/.output/server/node_modules/rolldown/dist/shared/rolldown-build-DSxL8qiP.mjs +0 -3325
- package/.output/server/node_modules/rolldown/dist/shared/watch-Bd8v9ewv.mjs +0 -374
- package/.output/server/node_modules/rolldown/package.json +0 -153
- package/.output/server/node_modules/unrun/dist/index.mjs +0 -2
- package/.output/server/node_modules/unrun/dist/src-GU5PtktT.mjs +0 -887
- package/.output/server/node_modules/unrun/package.json +0 -125
|
@@ -56,6 +56,7 @@ export interface SchemaCxt {
|
|
|
56
56
|
readonly createErrors?: boolean
|
|
57
57
|
readonly opts: InstanceOptions // Ajv instance option.
|
|
58
58
|
readonly self: Ajv // current Ajv instance
|
|
59
|
+
readonly isAllOfVariant?: boolean // if the current schema is direct child of allOf
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export interface SchemaObjCxt extends SchemaCxt {
|
|
@@ -116,6 +117,7 @@ export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
|
|
|
116
117
|
const {es5, lines} = this.opts.code
|
|
117
118
|
const {ownProperties} = this.opts
|
|
118
119
|
const gen = new CodeGen(this.scope, {es5, lines, ownProperties})
|
|
120
|
+
|
|
119
121
|
let _ValidationError
|
|
120
122
|
if (sch.$async) {
|
|
121
123
|
_ValidationError = gen.scopeValue("Error", {
|
|
@@ -164,7 +166,9 @@ export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
|
|
|
164
166
|
gen.optimize(this.opts.code.optimize)
|
|
165
167
|
// gen.optimize(1)
|
|
166
168
|
const validateCode = gen.toString()
|
|
167
|
-
sourceCode =
|
|
169
|
+
sourceCode = `const visitedNodesForRef = new WeakMap(); ${gen.scopeRefs(
|
|
170
|
+
N.scope
|
|
171
|
+
)}return ${validateCode}`
|
|
168
172
|
// console.log((codeSize += sourceCode.length), (nodeCount += gen.nodeCount))
|
|
169
173
|
if (this.opts.code.process) sourceCode = this.opts.code.process(sourceCode, sch)
|
|
170
174
|
// console.log("\n\n\n *** \n", sourceCode)
|
|
@@ -206,9 +210,9 @@ export function resolveRef(
|
|
|
206
210
|
this: Ajv,
|
|
207
211
|
root: SchemaEnv,
|
|
208
212
|
baseId: string,
|
|
209
|
-
|
|
213
|
+
origRef: string
|
|
210
214
|
): AnySchema | SchemaEnv | undefined {
|
|
211
|
-
ref = resolveUrl(this.opts.uriResolver, baseId,
|
|
215
|
+
const ref = resolveUrl(this.opts.uriResolver, baseId, origRef)
|
|
212
216
|
const schOrFunc = root.refs[ref]
|
|
213
217
|
if (schOrFunc) return schOrFunc
|
|
214
218
|
|
|
@@ -219,6 +223,15 @@ export function resolveRef(
|
|
|
219
223
|
if (schema) _sch = new SchemaEnv({schema, schemaId, root, baseId})
|
|
220
224
|
}
|
|
221
225
|
|
|
226
|
+
if (_sch === undefined && this.opts.loadSchemaSync) {
|
|
227
|
+
const remoteSchema = this.opts.loadSchemaSync(baseId, origRef, ref)
|
|
228
|
+
|
|
229
|
+
if (remoteSchema && !(this.refs[ref] || this.schemas[ref])) {
|
|
230
|
+
this.addSchema(remoteSchema, ref, undefined)
|
|
231
|
+
_sch = resolve.call(this, root, ref)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
222
235
|
if (_sch === undefined) return
|
|
223
236
|
return (root.refs[ref] = inlineOrCompile.call(this, _sch))
|
|
224
237
|
}
|
|
@@ -65,7 +65,9 @@ export default function compileParser(
|
|
|
65
65
|
parserFunction(cxt)
|
|
66
66
|
gen.optimize(this.opts.code.optimize)
|
|
67
67
|
const parseFuncCode = gen.toString()
|
|
68
|
-
sourceCode =
|
|
68
|
+
sourceCode = `const visitedNodesForRef = new WeakMap(); ${gen.scopeRefs(
|
|
69
|
+
N.scope
|
|
70
|
+
)}return ${parseFuncCode}`
|
|
69
71
|
const makeParse = new Function(`${N.scope}`, sourceCode)
|
|
70
72
|
const parse: (json: string) => unknown = makeParse(this.scope.get())
|
|
71
73
|
this.scope.value(parseName, {ref: parse})
|
|
@@ -61,7 +61,9 @@ export default function compileSerializer(
|
|
|
61
61
|
})
|
|
62
62
|
gen.optimize(this.opts.code.optimize)
|
|
63
63
|
const serializeFuncCode = gen.toString()
|
|
64
|
-
sourceCode =
|
|
64
|
+
sourceCode = `const visitedNodesForRef = new WeakMap(); ${gen.scopeRefs(
|
|
65
|
+
N.scope
|
|
66
|
+
)}return ${serializeFuncCode}`
|
|
65
67
|
const makeSerialize = new Function(`${N.scope}`, sourceCode)
|
|
66
68
|
const serialize: (data: unknown) => string = makeSerialize(this.scope.get())
|
|
67
69
|
this.scope.value(serializeName, {ref: serialize})
|
|
@@ -10,6 +10,7 @@ const names = {
|
|
|
10
10
|
parentDataProperty: new Name("parentDataProperty"),
|
|
11
11
|
rootData: new Name("rootData"), // root data - same as the data passed to the first/top validation function
|
|
12
12
|
dynamicAnchors: new Name("dynamicAnchors"), // used to support recursiveRef and dynamicRef
|
|
13
|
+
isAllOfVariant: new Name("isAllOfVariant"), // used to check in runtime if the current function (ref) is called from allOf
|
|
13
14
|
// function scoped variables
|
|
14
15
|
vErrors: new Name("vErrors"), // null or array of validation errors
|
|
15
16
|
errors: new Name("errors"), // counter of validation errors
|
|
@@ -66,7 +66,7 @@ function validateFunction(
|
|
|
66
66
|
function destructureValCxt(opts: InstanceOptions): Code {
|
|
67
67
|
return _`{${N.instancePath}="", ${N.parentData}, ${N.parentDataProperty}, ${N.rootData}=${
|
|
68
68
|
N.data
|
|
69
|
-
}${opts.dynamicRef ? _`, ${N.dynamicAnchors}={}` : nil}}={}`
|
|
69
|
+
}${opts.dynamicRef ? _`, ${N.dynamicAnchors}={}` : nil}, ${N.isAllOfVariant} = 0}={}`
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
|
|
@@ -77,6 +77,7 @@ function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
|
|
|
77
77
|
gen.var(N.parentData, _`${N.valCxt}.${N.parentData}`)
|
|
78
78
|
gen.var(N.parentDataProperty, _`${N.valCxt}.${N.parentDataProperty}`)
|
|
79
79
|
gen.var(N.rootData, _`${N.valCxt}.${N.rootData}`)
|
|
80
|
+
gen.var(N.isAllOfVariant, _`${N.valCxt}.${N.isAllOfVariant}`)
|
|
80
81
|
if (opts.dynamicRef) gen.var(N.dynamicAnchors, _`${N.valCxt}.${N.dynamicAnchors}`)
|
|
81
82
|
},
|
|
82
83
|
() => {
|
|
@@ -84,6 +85,7 @@ function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
|
|
|
84
85
|
gen.var(N.parentData, _`undefined`)
|
|
85
86
|
gen.var(N.parentDataProperty, _`undefined`)
|
|
86
87
|
gen.var(N.rootData, N.data)
|
|
88
|
+
gen.var(N.isAllOfVariant, _`0`)
|
|
87
89
|
if (opts.dynamicRef) gen.var(N.dynamicAnchors, _`{}`)
|
|
88
90
|
}
|
|
89
91
|
)
|
|
@@ -261,11 +263,20 @@ function iterateKeywords(it: SchemaObjCxt, group: RuleGroup): void {
|
|
|
261
263
|
if (useDefaults) assignDefaults(it, group.type)
|
|
262
264
|
gen.block(() => {
|
|
263
265
|
for (const rule of group.rules) {
|
|
264
|
-
if (shouldUseRule(schema, rule)) {
|
|
266
|
+
if (shouldUseRule(schema, rule) || shouldForceUnevaluatedProperties(schema, rule)) {
|
|
265
267
|
keywordCode(it, rule.keyword, rule.definition, group.type)
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
270
|
})
|
|
271
|
+
|
|
272
|
+
function shouldForceUnevaluatedProperties(schemaObj: AnySchemaObject, rule: Rule): boolean {
|
|
273
|
+
return !!(
|
|
274
|
+
rule.keyword === "unevaluatedProperties" &&
|
|
275
|
+
(schemaObj.properties || schemaObj.patternProperties) &&
|
|
276
|
+
!it.isAllOfVariant &&
|
|
277
|
+
it.opts.defaultUnevaluatedProperties === false
|
|
278
|
+
)
|
|
279
|
+
}
|
|
269
280
|
}
|
|
270
281
|
|
|
271
282
|
function checkStrictTypes(it: SchemaObjCxt, types: JSONType[]): void {
|
|
@@ -492,11 +503,17 @@ export class KeywordCxt implements KeywordErrorCxt {
|
|
|
492
503
|
}
|
|
493
504
|
}
|
|
494
505
|
|
|
495
|
-
subschema(appl: SubschemaArgs, valid: Name): SchemaCxt {
|
|
506
|
+
subschema(appl: SubschemaArgs, valid: Name, isAllOfVariant?: boolean): SchemaCxt {
|
|
496
507
|
const subschema = getSubschema(this.it, appl)
|
|
497
508
|
extendSubschemaData(subschema, this.it, appl)
|
|
498
509
|
extendSubschemaMode(subschema, appl)
|
|
499
|
-
const nextContext = {
|
|
510
|
+
const nextContext = {
|
|
511
|
+
...this.it,
|
|
512
|
+
...subschema,
|
|
513
|
+
items: undefined,
|
|
514
|
+
props: undefined,
|
|
515
|
+
isAllOfVariant,
|
|
516
|
+
}
|
|
500
517
|
subschemaCode(nextContext, valid)
|
|
501
518
|
return nextContext
|
|
502
519
|
}
|
|
@@ -68,7 +68,13 @@ import DefaultUriResolver from "./runtime/uri"
|
|
|
68
68
|
const defaultRegExp: RegExpEngine = (str, flags) => new RegExp(str, flags)
|
|
69
69
|
defaultRegExp.code = "new RegExp"
|
|
70
70
|
|
|
71
|
-
const META_IGNORE_OPTIONS: (keyof Options)[] = [
|
|
71
|
+
const META_IGNORE_OPTIONS: (keyof Options)[] = [
|
|
72
|
+
"removeAdditional",
|
|
73
|
+
"useDefaults",
|
|
74
|
+
"coerceTypes",
|
|
75
|
+
"defaultUnevaluatedProperties",
|
|
76
|
+
"defaultAdditionalProperties",
|
|
77
|
+
]
|
|
72
78
|
const EXT_SCOPE_NAMES = new Set([
|
|
73
79
|
"validate",
|
|
74
80
|
"serialize",
|
|
@@ -116,8 +122,12 @@ export interface CurrentOptions {
|
|
|
116
122
|
schemas?: AnySchema[] | {[Key in string]?: AnySchema}
|
|
117
123
|
logger?: Logger | false
|
|
118
124
|
loadSchema?: (uri: string) => Promise<AnySchemaObject>
|
|
125
|
+
loadSchemaSync?: (base: string, $ref: string, id: string) => AnySchemaObject | boolean
|
|
119
126
|
// options to modify validated data:
|
|
120
127
|
removeAdditional?: boolean | "all" | "failing"
|
|
128
|
+
defaultUnevaluatedProperties?: boolean
|
|
129
|
+
defaultAdditionalProperties?: boolean // @deprecated
|
|
130
|
+
|
|
121
131
|
useDefaults?: boolean | "empty"
|
|
122
132
|
coerceTypes?: boolean | "array"
|
|
123
133
|
// advanced options:
|
|
@@ -334,6 +344,15 @@ export default class Ajv {
|
|
|
334
344
|
return (this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : undefined)
|
|
335
345
|
}
|
|
336
346
|
|
|
347
|
+
// Set the defaultUnevaluatedProperties option.
|
|
348
|
+
// WARNING: This only affects schemas compiled AFTER this method is called.
|
|
349
|
+
// Already-compiled schemas in the cache will NOT be affected.
|
|
350
|
+
// Consider clearing the cache or creating a new Ajv instance if you need
|
|
351
|
+
// different behavior for the same schemas.
|
|
352
|
+
setDefaultUnevaluatedProperties(value: boolean): void {
|
|
353
|
+
this.opts.defaultUnevaluatedProperties = value
|
|
354
|
+
}
|
|
355
|
+
|
|
337
356
|
// Validate data using schema
|
|
338
357
|
// AnySchema will be compiled and cached using schema itself as a key for Map
|
|
339
358
|
validate(schema: Schema | string, data: unknown): boolean
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type {AnySchemaObject, Options} from "./core"
|
|
2
|
+
import AjvCore from "./core"
|
|
3
|
+
import draft4Vocabularies from "./vocabularies/draft4"
|
|
4
|
+
import discriminator from "./vocabularies/discriminator"
|
|
5
|
+
import * as draft4MetaSchema from "./refs/json-schema-draft-04.json"
|
|
6
|
+
|
|
7
|
+
const META_SUPPORT_DATA = ["/properties"]
|
|
8
|
+
|
|
9
|
+
const META_SCHEMA_ID = "http://json-schema.org/draft-04/schema"
|
|
10
|
+
|
|
11
|
+
export class Ajv extends AjvCore {
|
|
12
|
+
constructor(opts: Options = {}) {
|
|
13
|
+
super({
|
|
14
|
+
...opts,
|
|
15
|
+
schemaId: "id",
|
|
16
|
+
dynamicRef: true,
|
|
17
|
+
unevaluated: true,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_addVocabularies(): void {
|
|
22
|
+
super._addVocabularies()
|
|
23
|
+
draft4Vocabularies.forEach((v) => this.addVocabulary(v))
|
|
24
|
+
if (this.opts.discriminator) this.addKeyword(discriminator)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_addDefaultMetaSchema(): void {
|
|
28
|
+
super._addDefaultMetaSchema()
|
|
29
|
+
if (!this.opts.meta) return
|
|
30
|
+
const metaSchema = this.opts.$data
|
|
31
|
+
? this.$dataMetaSchema(draft4MetaSchema, META_SUPPORT_DATA)
|
|
32
|
+
: draft4MetaSchema
|
|
33
|
+
this.addMetaSchema(metaSchema, META_SCHEMA_ID, false)
|
|
34
|
+
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
defaultMeta(): string | AnySchemaObject | undefined {
|
|
38
|
+
return (this.opts.defaultMeta =
|
|
39
|
+
super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = exports = Ajv
|
|
44
|
+
Object.defineProperty(exports, "__esModule", {value: true})
|
|
45
|
+
|
|
46
|
+
export default Ajv
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
Format,
|
|
50
|
+
FormatDefinition,
|
|
51
|
+
AsyncFormatDefinition,
|
|
52
|
+
KeywordDefinition,
|
|
53
|
+
KeywordErrorDefinition,
|
|
54
|
+
CodeKeywordDefinition,
|
|
55
|
+
MacroKeywordDefinition,
|
|
56
|
+
FuncKeywordDefinition,
|
|
57
|
+
Vocabulary,
|
|
58
|
+
Schema,
|
|
59
|
+
SchemaObject,
|
|
60
|
+
AnySchemaObject,
|
|
61
|
+
AsyncSchema,
|
|
62
|
+
AnySchema,
|
|
63
|
+
ValidateFunction,
|
|
64
|
+
AsyncValidateFunction,
|
|
65
|
+
SchemaValidateFunction,
|
|
66
|
+
ErrorObject,
|
|
67
|
+
ErrorNoParams,
|
|
68
|
+
Context,
|
|
69
|
+
} from "./types"
|
|
70
|
+
|
|
71
|
+
export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
|
|
72
|
+
export {SchemaCxt, SchemaObjCxt} from "./compile"
|
|
73
|
+
export {KeywordCxt} from "./compile/validate"
|
|
74
|
+
export {DefinedError} from "./vocabularies/errors"
|
|
75
|
+
export {JSONType} from "./compile/rules"
|
|
76
|
+
export {JSONSchemaType} from "./types/json-schema"
|
|
77
|
+
export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
|
|
78
|
+
export {default as ValidationError} from "./runtime/validation_error"
|
|
79
|
+
export {default as MissingRefError} from "./compile/ref_error"
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
4
|
+
"description": "Core schema meta-schema",
|
|
5
|
+
"definitions": {
|
|
6
|
+
"schemaArray": {
|
|
7
|
+
"type": "array",
|
|
8
|
+
"minItems": 1,
|
|
9
|
+
"items": {"$ref": "#"}
|
|
10
|
+
},
|
|
11
|
+
"positiveInteger": {
|
|
12
|
+
"type": "integer",
|
|
13
|
+
"minimum": 0
|
|
14
|
+
},
|
|
15
|
+
"positiveIntegerDefault0": {
|
|
16
|
+
"allOf": [{"$ref": "#/definitions/positiveInteger"}, {"default": 0}]
|
|
17
|
+
},
|
|
18
|
+
"simpleTypes": {
|
|
19
|
+
"enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
|
20
|
+
},
|
|
21
|
+
"stringArray": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {"type": "string"},
|
|
24
|
+
"minItems": 1,
|
|
25
|
+
"uniqueItems": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"id": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "uri"
|
|
33
|
+
},
|
|
34
|
+
"$schema": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"format": "uri"
|
|
37
|
+
},
|
|
38
|
+
"title": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
"description": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"default": {},
|
|
45
|
+
"multipleOf": {
|
|
46
|
+
"type": "number",
|
|
47
|
+
"minimum": 0,
|
|
48
|
+
"exclusiveMinimum": true
|
|
49
|
+
},
|
|
50
|
+
"maximum": {
|
|
51
|
+
"type": "number"
|
|
52
|
+
},
|
|
53
|
+
"exclusiveMaximum": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"default": false
|
|
56
|
+
},
|
|
57
|
+
"minimum": {
|
|
58
|
+
"type": "number"
|
|
59
|
+
},
|
|
60
|
+
"exclusiveMinimum": {
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"default": false
|
|
63
|
+
},
|
|
64
|
+
"maxLength": {"$ref": "#/definitions/positiveInteger"},
|
|
65
|
+
"minLength": {"$ref": "#/definitions/positiveIntegerDefault0"},
|
|
66
|
+
"pattern": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"format": "regex"
|
|
69
|
+
},
|
|
70
|
+
"additionalItems": {
|
|
71
|
+
"anyOf": [{"type": "boolean"}, {"$ref": "#"}],
|
|
72
|
+
"default": {}
|
|
73
|
+
},
|
|
74
|
+
"items": {
|
|
75
|
+
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}],
|
|
76
|
+
"default": {}
|
|
77
|
+
},
|
|
78
|
+
"maxItems": {"$ref": "#/definitions/positiveInteger"},
|
|
79
|
+
"minItems": {"$ref": "#/definitions/positiveIntegerDefault0"},
|
|
80
|
+
"uniqueItems": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": false
|
|
83
|
+
},
|
|
84
|
+
"maxProperties": {"$ref": "#/definitions/positiveInteger"},
|
|
85
|
+
"minProperties": {"$ref": "#/definitions/positiveIntegerDefault0"},
|
|
86
|
+
"required": {"$ref": "#/definitions/stringArray"},
|
|
87
|
+
"additionalProperties": {
|
|
88
|
+
"anyOf": [{"type": "boolean"}, {"$ref": "#"}],
|
|
89
|
+
"default": {}
|
|
90
|
+
},
|
|
91
|
+
"definitions": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": {"$ref": "#"},
|
|
94
|
+
"default": {}
|
|
95
|
+
},
|
|
96
|
+
"properties": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"additionalProperties": {"$ref": "#"},
|
|
99
|
+
"default": {}
|
|
100
|
+
},
|
|
101
|
+
"patternProperties": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"additionalProperties": {"$ref": "#"},
|
|
104
|
+
"default": {}
|
|
105
|
+
},
|
|
106
|
+
"dependencies": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"additionalProperties": {
|
|
109
|
+
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"enum": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"minItems": 1,
|
|
115
|
+
"uniqueItems": true
|
|
116
|
+
},
|
|
117
|
+
"type": {
|
|
118
|
+
"anyOf": [
|
|
119
|
+
{"$ref": "#/definitions/simpleTypes"},
|
|
120
|
+
{
|
|
121
|
+
"type": "array",
|
|
122
|
+
"items": {"$ref": "#/definitions/simpleTypes"},
|
|
123
|
+
"minItems": 1,
|
|
124
|
+
"uniqueItems": true
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
"allOf": {"$ref": "#/definitions/schemaArray"},
|
|
129
|
+
"anyOf": {"$ref": "#/definitions/schemaArray"},
|
|
130
|
+
"oneOf": {"$ref": "#/definitions/schemaArray"},
|
|
131
|
+
"not": {"$ref": "#"}
|
|
132
|
+
},
|
|
133
|
+
"dependencies": {
|
|
134
|
+
"exclusiveMaximum": ["maximum"],
|
|
135
|
+
"exclusiveMinimum": ["minimum"]
|
|
136
|
+
},
|
|
137
|
+
"default": {}
|
|
138
|
+
}
|
|
@@ -30,7 +30,8 @@ const def: CodeKeywordDefinition & AddedKeywordDefinition = {
|
|
|
30
30
|
trackErrors: true,
|
|
31
31
|
error,
|
|
32
32
|
code(cxt) {
|
|
33
|
-
const {gen,
|
|
33
|
+
const {gen, parentSchema, data, errsCount, it} = cxt
|
|
34
|
+
const {schema = it.opts.defaultAdditionalProperties} = cxt
|
|
34
35
|
/* istanbul ignore if */
|
|
35
36
|
if (!errsCount) throw new Error("ajv implementation error")
|
|
36
37
|
const {allErrors, opts} = it
|
|
@@ -12,7 +12,7 @@ const def: CodeKeywordDefinition = {
|
|
|
12
12
|
const valid = gen.name("valid")
|
|
13
13
|
schema.forEach((sch: AnySchema, i: number) => {
|
|
14
14
|
if (alwaysValidSchema(it, sch)) return
|
|
15
|
-
const schCxt = cxt.subschema({keyword: "allOf", schemaProp: i}, valid)
|
|
15
|
+
const schCxt = cxt.subschema({keyword: "allOf", schemaProp: i}, valid, true)
|
|
16
16
|
cxt.ok(valid)
|
|
17
17
|
cxt.mergeEvaluated(schCxt)
|
|
18
18
|
})
|
|
@@ -10,7 +10,10 @@ const def: CodeKeywordDefinition = {
|
|
|
10
10
|
schemaType: "object",
|
|
11
11
|
code(cxt: KeywordCxt) {
|
|
12
12
|
const {gen, schema, parentSchema, data, it} = cxt
|
|
13
|
-
if (
|
|
13
|
+
if (
|
|
14
|
+
(it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) ||
|
|
15
|
+
it.opts.defaultAdditionalProperties === false
|
|
16
|
+
) {
|
|
14
17
|
apDef.code(new KeywordCxt(it, apDef, "additionalProperties"))
|
|
15
18
|
}
|
|
16
19
|
const allProps = allSchemaProperties(schema)
|
|
@@ -5,6 +5,7 @@ import {CodeGen, _, and, or, not, nil, strConcat, getProperty, Code, Name} from
|
|
|
5
5
|
import {alwaysValidSchema, Type} from "../compile/util"
|
|
6
6
|
import N from "../compile/names"
|
|
7
7
|
import {useFunc} from "../compile/util"
|
|
8
|
+
import {getSkipCondition} from "./oasContext"
|
|
8
9
|
export function checkReportMissingProp(cxt: KeywordCxt, prop: string): void {
|
|
9
10
|
const {gen, data, it} = cxt
|
|
10
11
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
@@ -14,13 +15,17 @@ export function checkReportMissingProp(cxt: KeywordCxt, prop: string): void {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export function checkMissingProp(
|
|
17
|
-
{gen, data, it: {opts}}: KeywordCxt,
|
|
18
|
+
{gen, data, it: {opts}, parentSchema}: KeywordCxt,
|
|
18
19
|
properties: string[],
|
|
19
20
|
missing: Name
|
|
20
21
|
): Code {
|
|
21
22
|
return or(
|
|
22
23
|
...properties.map((prop) =>
|
|
23
|
-
and(
|
|
24
|
+
and(
|
|
25
|
+
not(getSkipCondition(parentSchema, prop) ?? _`false`),
|
|
26
|
+
noPropertyInData(gen, data, prop, opts.ownProperties),
|
|
27
|
+
_`${missing} = ${prop}`
|
|
28
|
+
)
|
|
24
29
|
)
|
|
25
30
|
)
|
|
26
31
|
}
|
|
@@ -84,6 +89,7 @@ export function callValidateCode(
|
|
|
84
89
|
[N.parentData, it.parentData],
|
|
85
90
|
[N.parentDataProperty, it.parentDataProperty],
|
|
86
91
|
[N.rootData, N.rootData],
|
|
92
|
+
[N.isAllOfVariant, it.isAllOfVariant ? 1 : 0],
|
|
87
93
|
]
|
|
88
94
|
if (it.opts.dynamicRef) valCxt.push([N.dynamicAnchors, N.dynamicAnchors])
|
|
89
95
|
const args = _`${dataAndSchema}, ${gen.object(...valCxt)}`
|
|
@@ -133,9 +139,10 @@ export function validateArray(cxt: KeywordCxt): Name {
|
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
export function validateUnion(cxt: KeywordCxt): void {
|
|
136
|
-
const {gen, schema, keyword, it} = cxt
|
|
142
|
+
const {gen, schema, keyword, parentSchema, it} = cxt
|
|
137
143
|
/* istanbul ignore if */
|
|
138
144
|
if (!Array.isArray(schema)) throw new Error("ajv implementation error")
|
|
145
|
+
if (it.opts.discriminator && parentSchema.discriminator) return
|
|
139
146
|
const alwaysValid = schema.some((sch: AnySchema) => alwaysValidSchema(it, sch))
|
|
140
147
|
if (alwaysValid && !it.opts.unevaluated) return
|
|
141
148
|
|
|
@@ -45,7 +45,8 @@ const def: CodeKeywordDefinition = {
|
|
|
45
45
|
topSchemaRef: schName,
|
|
46
46
|
errSchemaPath: $ref,
|
|
47
47
|
},
|
|
48
|
-
valid
|
|
48
|
+
valid,
|
|
49
|
+
it.isAllOfVariant // pass isAllOfVariant into inlined $ref
|
|
49
50
|
)
|
|
50
51
|
cxt.mergeEvaluated(schCxt)
|
|
51
52
|
cxt.ok(valid)
|
|
@@ -86,11 +87,26 @@ export function callRef(cxt: KeywordCxt, v: Code, sch?: SchemaEnv, $async?: bool
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
function callSyncRef(): void {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
()
|
|
92
|
-
() => addErrorsFrom(v)
|
|
90
|
+
const visitedNodes: Name = gen.name("visitedNodes")
|
|
91
|
+
gen.code(
|
|
92
|
+
_`const ${visitedNodes} = (typeof visitedNodesForRef !== 'undefined') && visitedNodesForRef.get(${v}) || new Set()`
|
|
93
93
|
)
|
|
94
|
+
gen.if(_`!${visitedNodes}.has(${cxt.data})`, () => {
|
|
95
|
+
gen.code(
|
|
96
|
+
_`if (typeof visitedNodesForRef !== 'undefined') visitedNodesForRef.set(${v}, ${visitedNodes})`
|
|
97
|
+
)
|
|
98
|
+
gen.code(_`const dataNode = ${cxt.data}`)
|
|
99
|
+
gen.code(
|
|
100
|
+
_`if (typeof dataNode === "object" && dataNode !== null) ${visitedNodes}.add(dataNode)`
|
|
101
|
+
)
|
|
102
|
+
const res = cxt.result(
|
|
103
|
+
callValidateCode(cxt, v, passCxt),
|
|
104
|
+
() => addEvaluatedFrom(v),
|
|
105
|
+
() => addErrorsFrom(v)
|
|
106
|
+
)
|
|
107
|
+
gen.code(_`${visitedNodes}.delete(dataNode)`)
|
|
108
|
+
return res
|
|
109
|
+
})
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
function addErrorsFrom(source: Code): void {
|