@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
|
@@ -12,11 +12,28 @@ const error: KeywordErrorDefinition = {
|
|
|
12
12
|
message: ({params: {discrError, tagName}}) =>
|
|
13
13
|
discrError === DiscrError.Tag
|
|
14
14
|
? `tag "${tagName}" must be string`
|
|
15
|
-
: `value of tag "${tagName}" must be in oneOf`,
|
|
15
|
+
: `value of tag "${tagName}" must be in oneOf or anyOf`,
|
|
16
16
|
params: ({params: {discrError, tag, tagName}}) =>
|
|
17
17
|
_`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function getDiscriminatorPropertyFromAllOf(
|
|
21
|
+
sch: AnySchemaObject,
|
|
22
|
+
tagName: string
|
|
23
|
+
): AnySchemaObject | undefined {
|
|
24
|
+
if (!sch.allOf || !Array.isArray(sch.allOf)) {
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const subschema of sch.allOf) {
|
|
29
|
+
if (subschema?.properties?.[tagName]) {
|
|
30
|
+
return subschema.properties[tagName] as AnySchemaObject
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
const def: CodeKeywordDefinition = {
|
|
21
38
|
keyword: "discriminator",
|
|
22
39
|
type: "object",
|
|
@@ -24,14 +41,16 @@ const def: CodeKeywordDefinition = {
|
|
|
24
41
|
error,
|
|
25
42
|
code(cxt: KeywordCxt) {
|
|
26
43
|
const {gen, data, schema, parentSchema, it} = cxt
|
|
27
|
-
|
|
44
|
+
|
|
45
|
+
const keyword = parentSchema.oneOf ? "oneOf" : parentSchema.anyOf ? "anyOf" : undefined
|
|
46
|
+
|
|
28
47
|
if (!it.opts.discriminator) {
|
|
29
48
|
throw new Error("discriminator: requires discriminator option")
|
|
30
49
|
}
|
|
31
50
|
const tagName = schema.propertyName
|
|
32
51
|
if (typeof tagName != "string") throw new Error("discriminator: requires propertyName")
|
|
33
|
-
if (
|
|
34
|
-
|
|
52
|
+
if (!keyword) throw new Error("discriminator: requires oneOf or anyOf composite keyword")
|
|
53
|
+
const parentSchemaVariants = parentSchema[keyword]
|
|
35
54
|
const valid = gen.let("valid", false)
|
|
36
55
|
const tag = gen.const("tag", _`${data}${getProperty(tagName)}`)
|
|
37
56
|
gen.if(
|
|
@@ -55,37 +74,68 @@ const def: CodeKeywordDefinition = {
|
|
|
55
74
|
|
|
56
75
|
function applyTagSchema(schemaProp?: number): Name {
|
|
57
76
|
const _valid = gen.name("valid")
|
|
58
|
-
const schCxt = cxt.subschema({keyword
|
|
77
|
+
const schCxt = cxt.subschema({keyword, schemaProp}, _valid)
|
|
59
78
|
cxt.mergeEvaluated(schCxt, Name)
|
|
60
79
|
return _valid
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
function getMapping(): {[T in string]?: number} {
|
|
64
|
-
const
|
|
83
|
+
const discriminatorMapping: {[T in string]?: number} = {}
|
|
65
84
|
const topRequired = hasRequired(parentSchema)
|
|
66
85
|
let tagRequired = true
|
|
67
|
-
for (let i = 0; i <
|
|
68
|
-
let sch =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
for (let i = 0; i < parentSchemaVariants.length; i++) {
|
|
87
|
+
let sch = parentSchemaVariants[i]
|
|
88
|
+
const schRef = sch?.$ref
|
|
89
|
+
|
|
90
|
+
if (schRef && schema.mapping) {
|
|
91
|
+
const {mapping} = schema
|
|
92
|
+
const matchedKeys = Object.keys(mapping).filter((key) => mapping[key] === sch.$ref)
|
|
93
|
+
|
|
94
|
+
if (matchedKeys.length) {
|
|
95
|
+
for (const key of matchedKeys) {
|
|
96
|
+
addMapping(key, i)
|
|
97
|
+
}
|
|
98
|
+
continue
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (schRef && !schemaHasRulesButRef(sch, it.self.RULES)) {
|
|
103
|
+
sch = resolveRef.call(it.self, it.schemaEnv.root, it.baseId, schRef)
|
|
72
104
|
if (sch instanceof SchemaEnv) sch = sch.schema
|
|
73
|
-
if (sch === undefined) throw new MissingRefError(it.opts.uriResolver, it.baseId,
|
|
105
|
+
if (sch === undefined) throw new MissingRefError(it.opts.uriResolver, it.baseId, schRef)
|
|
74
106
|
}
|
|
75
|
-
|
|
107
|
+
|
|
108
|
+
let propSch = sch?.properties?.[tagName]
|
|
109
|
+
if (!propSch && sch?.allOf) {
|
|
110
|
+
propSch = getDiscriminatorPropertyFromAllOf(sch, tagName)
|
|
111
|
+
}
|
|
112
|
+
|
|
76
113
|
if (typeof propSch != "object") {
|
|
77
114
|
throw new Error(
|
|
78
|
-
`discriminator:
|
|
115
|
+
`discriminator: ${keyword} subschemas (or referenced schemas) must have "properties/${tagName}" or match mapping`
|
|
79
116
|
)
|
|
80
117
|
}
|
|
81
118
|
tagRequired = tagRequired && (topRequired || hasRequired(sch))
|
|
82
119
|
addMappings(propSch, i)
|
|
83
120
|
}
|
|
84
121
|
if (!tagRequired) throw new Error(`discriminator: "${tagName}" must be required`)
|
|
85
|
-
return
|
|
122
|
+
return discriminatorMapping
|
|
123
|
+
|
|
124
|
+
function hasRequired(sch: AnySchemaObject): boolean {
|
|
125
|
+
if (Array.isArray(sch.required) && sch.required.includes(tagName)) {
|
|
126
|
+
return true
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (sch.allOf && Array.isArray(sch.allOf)) {
|
|
130
|
+
for (const subschema of sch.allOf) {
|
|
131
|
+
const subSch = subschema as AnySchemaObject
|
|
132
|
+
if (Array.isArray(subSch.required) && subSch.required.includes(tagName)) {
|
|
133
|
+
return true
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
86
137
|
|
|
87
|
-
|
|
88
|
-
return Array.isArray(required) && required.includes(tagName)
|
|
138
|
+
return false
|
|
89
139
|
}
|
|
90
140
|
|
|
91
141
|
function addMappings(sch: AnySchemaObject, i: number): void {
|
|
@@ -101,10 +151,10 @@ const def: CodeKeywordDefinition = {
|
|
|
101
151
|
}
|
|
102
152
|
|
|
103
153
|
function addMapping(tagValue: unknown, i: number): void {
|
|
104
|
-
if (typeof tagValue != "string" || tagValue in
|
|
154
|
+
if (typeof tagValue != "string" || tagValue in discriminatorMapping) {
|
|
105
155
|
throw new Error(`discriminator: "${tagName}" values must be unique strings`)
|
|
106
156
|
}
|
|
107
|
-
|
|
157
|
+
discriminatorMapping[tagValue] = i
|
|
108
158
|
}
|
|
109
159
|
}
|
|
110
160
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Vocabulary} from "../types"
|
|
2
|
+
import refKeyword from "./core/ref"
|
|
3
|
+
import getApplicatorVocabulary from "./applicator"
|
|
4
|
+
import unevaluatedVocabulary from "./unevaluated"
|
|
5
|
+
import formatVocabulary from "./format"
|
|
6
|
+
import validationVocabulary from "./validation"
|
|
7
|
+
import limitNumber from "./validation/draft04/limitNumber"
|
|
8
|
+
import limitNumberExclusive from "./validation/draft04/limitNumberExclusive"
|
|
9
|
+
|
|
10
|
+
const metadataVocabulary: Vocabulary = ["title", "description", "default"]
|
|
11
|
+
|
|
12
|
+
const coreVocabulary: Vocabulary = [
|
|
13
|
+
"$schema",
|
|
14
|
+
"id",
|
|
15
|
+
"$defs",
|
|
16
|
+
{keyword: "$comment"},
|
|
17
|
+
"definitions",
|
|
18
|
+
refKeyword,
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const validation: Vocabulary = [...validationVocabulary.slice(1), limitNumber, limitNumberExclusive]
|
|
22
|
+
|
|
23
|
+
const draft4Vocabularies: Vocabulary[] = [
|
|
24
|
+
coreVocabulary,
|
|
25
|
+
validation,
|
|
26
|
+
getApplicatorVocabulary(),
|
|
27
|
+
formatVocabulary,
|
|
28
|
+
metadataVocabulary,
|
|
29
|
+
unevaluatedVocabulary,
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
export default draft4Vocabularies
|
|
@@ -5,8 +5,16 @@ export const metadataVocabulary: Vocabulary = [
|
|
|
5
5
|
"description",
|
|
6
6
|
"default",
|
|
7
7
|
"deprecated",
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* readOnly/writeOnly are handled as validation keywords when OAS context is provided.
|
|
10
|
+
* Keeping them here would register them as annotation-only metadata and would
|
|
11
|
+
* prevent the context-aware validation behavior.
|
|
12
|
+
*
|
|
13
|
+
* @see ./validation/readOnly.ts
|
|
14
|
+
* @see ./validation/writeOnly.ts
|
|
15
|
+
*/
|
|
16
|
+
// "readOnly",
|
|
17
|
+
// "writeOnly",
|
|
10
18
|
"examples",
|
|
11
19
|
]
|
|
12
20
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {AnySchemaObject} from "../types"
|
|
2
|
+
|
|
3
|
+
import {_, or, type Code} from "../compile/codegen"
|
|
4
|
+
import N from "../compile/names"
|
|
5
|
+
|
|
6
|
+
export function getSkipCondition(schema: AnySchemaObject, prop: string): Code | undefined {
|
|
7
|
+
const propSchema = schema.properties?.[prop]
|
|
8
|
+
if (!propSchema) return undefined
|
|
9
|
+
|
|
10
|
+
const hasReadOnly = propSchema.readOnly === true
|
|
11
|
+
const hasWriteOnly = propSchema.writeOnly === true
|
|
12
|
+
|
|
13
|
+
if (!hasReadOnly && !hasWriteOnly) return undefined
|
|
14
|
+
|
|
15
|
+
const conditions: Code[] = []
|
|
16
|
+
const apiContext = _`typeof ${N.this} == "object" && ${N.this} && ${N.this}.apiContext`
|
|
17
|
+
|
|
18
|
+
if (hasReadOnly) {
|
|
19
|
+
conditions.push(_`${apiContext} === "request"`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (hasWriteOnly) {
|
|
23
|
+
conditions.push(_`${apiContext} === "response"`)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return or(...conditions)
|
|
27
|
+
}
|
package/.output/server/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts
CHANGED
|
@@ -23,10 +23,12 @@ const def: CodeKeywordDefinition = {
|
|
|
23
23
|
keyword: "unevaluatedProperties",
|
|
24
24
|
type: "object",
|
|
25
25
|
schemaType: ["boolean", "object"],
|
|
26
|
+
allowUndefined: true,
|
|
26
27
|
trackErrors: true,
|
|
27
28
|
error,
|
|
28
29
|
code(cxt) {
|
|
29
|
-
const {gen, schema, data, errsCount, it} = cxt
|
|
30
|
+
const {gen, schema = cxt.it.opts.defaultUnevaluatedProperties, data, errsCount, it} = cxt
|
|
31
|
+
const isForced = cxt.schema === undefined && cxt.it.opts.defaultUnevaluatedProperties === false
|
|
30
32
|
/* istanbul ignore if */
|
|
31
33
|
if (!errsCount) throw new Error("ajv implementation error")
|
|
32
34
|
const {allErrors, props} = it
|
|
@@ -37,13 +39,33 @@ const def: CodeKeywordDefinition = {
|
|
|
37
39
|
)
|
|
38
40
|
)
|
|
39
41
|
} else if (props !== true) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
43
|
+
const staticCheck = () =>
|
|
44
|
+
gen.forIn("key", data, (key: Name) =>
|
|
45
|
+
props === undefined
|
|
46
|
+
? unevaluatedPropCode(key)
|
|
47
|
+
: gen.if(unevaluatedStatic(props, key), () => unevaluatedPropCode(key))
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if (isForced && it.errorPath.emptyStr() && !it.compositeRule) {
|
|
51
|
+
// $refs are compiled into functions
|
|
52
|
+
// We need to check in runtime if function was called from allOf.
|
|
53
|
+
// We need to check only on the top level of the function:
|
|
54
|
+
// it is ensured with `it.errorPath.emptyStr()` check
|
|
55
|
+
gen.if(_`${N.isAllOfVariant} === 0`, staticCheck)
|
|
56
|
+
} else {
|
|
57
|
+
if (!it.compositeRule || cxt.schema !== undefined) {
|
|
58
|
+
staticCheck()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!isForced) {
|
|
64
|
+
// disable shot-circut for forced unevaluatedProperties=false
|
|
65
|
+
// we may run or not the check in runtime so we can't short-circuit in compile-time
|
|
66
|
+
it.props = true
|
|
45
67
|
}
|
|
46
|
-
|
|
68
|
+
|
|
47
69
|
cxt.ok(_`${errsCount} === ${N.errors}`)
|
|
48
70
|
|
|
49
71
|
function unevaluatedPropCode(key: Name): void {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CodeKeywordDefinition,
|
|
3
|
+
ErrorObject,
|
|
4
|
+
KeywordErrorDefinition,
|
|
5
|
+
KeywordErrorCxt,
|
|
6
|
+
} from "../../../types"
|
|
7
|
+
import type {KeywordCxt} from "../../../compile/validate"
|
|
8
|
+
import {_, str, operators, Code} from "../../../compile/codegen"
|
|
9
|
+
|
|
10
|
+
const ops = operators
|
|
11
|
+
|
|
12
|
+
export type LimitKwd = "maximum" | "minimum"
|
|
13
|
+
|
|
14
|
+
export type ExclusiveLimitKwd = "exclusiveMaximum" | "exclusiveMinimum"
|
|
15
|
+
|
|
16
|
+
type Comparison = "<=" | ">=" | "<" | ">"
|
|
17
|
+
|
|
18
|
+
interface KwdOp {
|
|
19
|
+
okStr: Comparison
|
|
20
|
+
ok: Code
|
|
21
|
+
fail: Code
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface KwdDef {
|
|
25
|
+
exclusive: ExclusiveLimitKwd
|
|
26
|
+
ops: [KwdOp, KwdOp]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const KWDs: {[K in LimitKwd]: KwdDef} = {
|
|
30
|
+
maximum: {
|
|
31
|
+
exclusive: "exclusiveMaximum",
|
|
32
|
+
ops: [
|
|
33
|
+
{okStr: "<=", ok: ops.LTE, fail: ops.GT},
|
|
34
|
+
{okStr: "<", ok: ops.LT, fail: ops.GTE},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
minimum: {
|
|
38
|
+
exclusive: "exclusiveMinimum",
|
|
39
|
+
ops: [
|
|
40
|
+
{okStr: ">=", ok: ops.GTE, fail: ops.LT},
|
|
41
|
+
{okStr: ">", ok: ops.GT, fail: ops.LTE},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type LimitNumberError = ErrorObject<
|
|
47
|
+
LimitKwd,
|
|
48
|
+
{limit: number; comparison: Comparison},
|
|
49
|
+
number | {$data: string}
|
|
50
|
+
>
|
|
51
|
+
|
|
52
|
+
const error: KeywordErrorDefinition = {
|
|
53
|
+
message: (cxt) => str`must be ${kwdOp(cxt).okStr} ${cxt.schemaCode}`,
|
|
54
|
+
params: (cxt) => _`{comparison: ${kwdOp(cxt).okStr}, limit: ${cxt.schemaCode}}`,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const def: CodeKeywordDefinition = {
|
|
58
|
+
keyword: Object.keys(KWDs),
|
|
59
|
+
type: "number",
|
|
60
|
+
schemaType: "number",
|
|
61
|
+
$data: true,
|
|
62
|
+
error,
|
|
63
|
+
code(cxt: KeywordCxt) {
|
|
64
|
+
const {data, schemaCode} = cxt
|
|
65
|
+
cxt.fail$data(_`${data} ${kwdOp(cxt).fail} ${schemaCode} || isNaN(${data})`)
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function kwdOp(cxt: KeywordErrorCxt): KwdOp {
|
|
70
|
+
const keyword = cxt.keyword as LimitKwd
|
|
71
|
+
const opsIdx = cxt.parentSchema?.[KWDs[keyword].exclusive] ? 1 : 0
|
|
72
|
+
return KWDs[keyword].ops[opsIdx]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default def
|
package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumberExclusive.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CodeKeywordDefinition,
|
|
3
|
+
// ErrorObject,
|
|
4
|
+
// KeywordErrorDefinition,
|
|
5
|
+
} from "../../../types"
|
|
6
|
+
import type {KeywordCxt} from "../../../compile/validate"
|
|
7
|
+
import {LimitKwd, ExclusiveLimitKwd} from "./limitNumber"
|
|
8
|
+
|
|
9
|
+
const KWDs: {[K in ExclusiveLimitKwd]: LimitKwd} = {
|
|
10
|
+
exclusiveMaximum: "maximum",
|
|
11
|
+
exclusiveMinimum: "minimum",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const def: CodeKeywordDefinition = {
|
|
15
|
+
keyword: Object.keys(KWDs),
|
|
16
|
+
type: "number",
|
|
17
|
+
schemaType: "boolean",
|
|
18
|
+
code({keyword, parentSchema}: KeywordCxt) {
|
|
19
|
+
const limitKwd = KWDs[keyword as ExclusiveLimitKwd]
|
|
20
|
+
if (parentSchema[limitKwd] === undefined) {
|
|
21
|
+
throw new Error(`${keyword} can only be used with ${limitKwd}`)
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default def
|
|
@@ -5,6 +5,8 @@ import limitLength from "./limitLength"
|
|
|
5
5
|
import pattern, {PatternError} from "./pattern"
|
|
6
6
|
import limitProperties from "./limitProperties"
|
|
7
7
|
import required, {RequiredError} from "./required"
|
|
8
|
+
import readOnlyKeyword from "./readOnly"
|
|
9
|
+
import writeOnlyKeyword from "./writeOnly"
|
|
8
10
|
import limitItems from "./limitItems"
|
|
9
11
|
import uniqueItems, {UniqueItemsError} from "./uniqueItems"
|
|
10
12
|
import constKeyword, {ConstError} from "./const"
|
|
@@ -20,6 +22,8 @@ const validation: Vocabulary = [
|
|
|
20
22
|
// object
|
|
21
23
|
limitProperties,
|
|
22
24
|
required,
|
|
25
|
+
readOnlyKeyword,
|
|
26
|
+
writeOnlyKeyword,
|
|
23
27
|
// array
|
|
24
28
|
limitItems,
|
|
25
29
|
uniqueItems,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
|
|
2
|
+
import type {KeywordCxt} from "../../compile/validate"
|
|
3
|
+
import {_, str} from "../../compile/codegen"
|
|
4
|
+
import N from "../../compile/names"
|
|
5
|
+
|
|
6
|
+
const error: KeywordErrorDefinition = {
|
|
7
|
+
message: () => str`must NOT be present in request context`,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const def: CodeKeywordDefinition = {
|
|
11
|
+
keyword: "readOnly",
|
|
12
|
+
schemaType: "boolean",
|
|
13
|
+
error,
|
|
14
|
+
code(cxt: KeywordCxt) {
|
|
15
|
+
if (cxt.schema !== true) return
|
|
16
|
+
|
|
17
|
+
const apiContext = _`(${N.this} && ${N.this}.apiContext)`
|
|
18
|
+
|
|
19
|
+
cxt.fail(_`${apiContext} === "request"`)
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default def
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
propertyInData,
|
|
8
8
|
noPropertyInData,
|
|
9
9
|
} from "../code"
|
|
10
|
+
import {getSkipCondition} from "../oasContext"
|
|
10
11
|
import {_, str, nil, not, Name, Code} from "../../compile/codegen"
|
|
11
12
|
import {checkStrictMode} from "../../compile/util"
|
|
12
13
|
|
|
@@ -52,7 +53,12 @@ const def: CodeKeywordDefinition = {
|
|
|
52
53
|
cxt.block$data(nil, loopAllRequired)
|
|
53
54
|
} else {
|
|
54
55
|
for (const prop of schema) {
|
|
55
|
-
|
|
56
|
+
const skip = getSkipCondition(cxt.parentSchema, prop) ?? _`false`
|
|
57
|
+
/**
|
|
58
|
+
* Generate a runtime check: validate `required` only when this property
|
|
59
|
+
* should NOT be skipped in the current context (readOnly/writeOnly).
|
|
60
|
+
*/
|
|
61
|
+
gen.if(not(skip), () => checkReportMissingProp(cxt, prop))
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"
|
|
2
|
+
import type {KeywordCxt} from "../../compile/validate"
|
|
3
|
+
import {_, str} from "../../compile/codegen"
|
|
4
|
+
import N from "../../compile/names"
|
|
5
|
+
|
|
6
|
+
const error: KeywordErrorDefinition = {
|
|
7
|
+
message: () => str`must NOT be present in response context`,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const def: CodeKeywordDefinition = {
|
|
11
|
+
keyword: "writeOnly",
|
|
12
|
+
schemaType: "boolean",
|
|
13
|
+
error,
|
|
14
|
+
code(cxt: KeywordCxt) {
|
|
15
|
+
if (cxt.schema !== true) return
|
|
16
|
+
const apiContext = _`(${N.this} && ${N.this}.apiContext)`
|
|
17
|
+
|
|
18
|
+
cxt.fail(_`${apiContext} === "response"`)
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default def
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "ajv",
|
|
3
|
-
"version": "8.18.
|
|
2
|
+
"name": "@redocly/ajv",
|
|
3
|
+
"version": "8.18.1",
|
|
4
4
|
"description": "Another JSON Schema Validator",
|
|
5
5
|
"main": "dist/ajv.js",
|
|
6
6
|
"types": "dist/ajv.d.ts",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"prepublish": "npm run build",
|
|
31
31
|
"benchmark": "npm i && npm run build && npm link && cd ./benchmark && npm link --legacy-peer-deps ajv && npm i && node ./jtd",
|
|
32
32
|
"docs:dev": "./scripts/prepare-site && vuepress dev docs",
|
|
33
|
-
"docs:build": "./scripts/prepare-site && vuepress build docs"
|
|
33
|
+
"docs:build": "./scripts/prepare-site && vuepress build docs",
|
|
34
|
+
"pretest": "npx npe name ajv",
|
|
35
|
+
"posttest": "npx npe name @redocly/ajv"
|
|
34
36
|
},
|
|
35
37
|
"nyc": {
|
|
36
38
|
"exclude": [
|
|
@@ -42,7 +44,10 @@
|
|
|
42
44
|
"text-summary"
|
|
43
45
|
]
|
|
44
46
|
},
|
|
45
|
-
"repository":
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/Redocly/ajv.git"
|
|
50
|
+
},
|
|
46
51
|
"keywords": [
|
|
47
52
|
"JSON",
|
|
48
53
|
"schema",
|
|
@@ -55,8 +60,6 @@
|
|
|
55
60
|
],
|
|
56
61
|
"author": "Evgeny Poberezkin",
|
|
57
62
|
"license": "MIT",
|
|
58
|
-
"bugs": "https://github.com/ajv-validator/ajv/issues",
|
|
59
|
-
"homepage": "https://ajv.js.org",
|
|
60
63
|
"runkitExampleFilename": ".runkit_example.js",
|
|
61
64
|
"dependencies": {
|
|
62
65
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|