@testsmith/api-spector 0.1.7 → 0.1.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.
|
@@ -2076,7 +2076,7 @@ if (canUseDOM)
|
|
|
2076
2076
|
passiveBrowserEventsSupported = false;
|
|
2077
2077
|
}
|
|
2078
2078
|
var root = null, startText = null, fallbackText = null;
|
|
2079
|
-
function getData() {
|
|
2079
|
+
function getData$1() {
|
|
2080
2080
|
if (fallbackText) return fallbackText;
|
|
2081
2081
|
var start, startValue = startText, startLength = startValue.length, end, endValue = "value" in root ? root.value : root.textContent, endLength = endValue.length;
|
|
2082
2082
|
for (start = 0; start < startLength && startValue[start] === endValue[start]; start++) ;
|
|
@@ -2331,7 +2331,7 @@ function getNativeBeforeInputChars(domEventName, nativeEvent) {
|
|
|
2331
2331
|
}
|
|
2332
2332
|
function getFallbackBeforeInputChars(domEventName, nativeEvent) {
|
|
2333
2333
|
if (isComposing)
|
|
2334
|
-
return "compositionend" === domEventName || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent) ? (domEventName = getData(), fallbackText = startText = root = null, isComposing = false, domEventName) : null;
|
|
2334
|
+
return "compositionend" === domEventName || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent) ? (domEventName = getData$1(), fallbackText = startText = root = null, isComposing = false, domEventName) : null;
|
|
2335
2335
|
switch (domEventName) {
|
|
2336
2336
|
case "paste":
|
|
2337
2337
|
return null;
|
|
@@ -10063,7 +10063,7 @@ function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativ
|
|
|
10063
10063
|
}
|
|
10064
10064
|
else
|
|
10065
10065
|
isComposing ? isFallbackCompositionEnd(domEventName, nativeEvent) && (eventType = "onCompositionEnd") : "keydown" === domEventName && 229 === nativeEvent.keyCode && (eventType = "onCompositionStart");
|
|
10066
|
-
eventType && (useFallbackCompositionData && "ko" !== nativeEvent.locale && (isComposing || "onCompositionStart" !== eventType ? "onCompositionEnd" === eventType && isComposing && (fallbackData = getData()) : (root = nativeEventTarget, startText = "value" in root ? root.value : root.textContent, isComposing = true)), handleEventFunc = accumulateTwoPhaseListeners(targetInst, eventType), 0 < handleEventFunc.length && (eventType = new SyntheticCompositionEvent(
|
|
10066
|
+
eventType && (useFallbackCompositionData && "ko" !== nativeEvent.locale && (isComposing || "onCompositionStart" !== eventType ? "onCompositionEnd" === eventType && isComposing && (fallbackData = getData$1()) : (root = nativeEventTarget, startText = "value" in root ? root.value : root.textContent, isComposing = true)), handleEventFunc = accumulateTwoPhaseListeners(targetInst, eventType), 0 < handleEventFunc.length && (eventType = new SyntheticCompositionEvent(
|
|
10067
10067
|
eventType,
|
|
10068
10068
|
domEventName,
|
|
10069
10069
|
null,
|
|
@@ -44895,8 +44895,8 @@ var scope = {};
|
|
|
44895
44895
|
var util = {};
|
|
44896
44896
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
44897
44897
|
util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
|
|
44898
|
-
const codegen_1$
|
|
44899
|
-
const code_1$
|
|
44898
|
+
const codegen_1$v = codegen;
|
|
44899
|
+
const code_1$a = code$1;
|
|
44900
44900
|
function toHash(arr) {
|
|
44901
44901
|
const hash = {};
|
|
44902
44902
|
for (const item of arr)
|
|
@@ -44949,9 +44949,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
|
|
|
44949
44949
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
44950
44950
|
return schema;
|
|
44951
44951
|
if (typeof schema == "string")
|
|
44952
|
-
return (0, codegen_1$
|
|
44952
|
+
return (0, codegen_1$v._)`${schema}`;
|
|
44953
44953
|
}
|
|
44954
|
-
return (0, codegen_1$
|
|
44954
|
+
return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
|
|
44955
44955
|
}
|
|
44956
44956
|
util.schemaRefOrVal = schemaRefOrVal;
|
|
44957
44957
|
function unescapeFragment(str) {
|
|
@@ -44983,20 +44983,20 @@ function eachItem(xs, f) {
|
|
|
44983
44983
|
util.eachItem = eachItem;
|
|
44984
44984
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
|
|
44985
44985
|
return (gen, from, to, toName) => {
|
|
44986
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
44987
|
-
return toName === codegen_1$
|
|
44986
|
+
const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
|
|
44987
|
+
return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
|
|
44988
44988
|
};
|
|
44989
44989
|
}
|
|
44990
44990
|
util.mergeEvaluated = {
|
|
44991
44991
|
props: makeMergeEvaluated({
|
|
44992
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
44993
|
-
gen.if((0, codegen_1$
|
|
44992
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
|
|
44993
|
+
gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
|
|
44994
44994
|
}),
|
|
44995
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
44995
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
|
|
44996
44996
|
if (from === true) {
|
|
44997
44997
|
gen.assign(to, true);
|
|
44998
44998
|
} else {
|
|
44999
|
-
gen.assign(to, (0, codegen_1$
|
|
44999
|
+
gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
|
|
45000
45000
|
setEvaluated(gen, to, from);
|
|
45001
45001
|
}
|
|
45002
45002
|
}),
|
|
@@ -45004,8 +45004,8 @@ util.mergeEvaluated = {
|
|
|
45004
45004
|
resultToName: evaluatedPropsToName
|
|
45005
45005
|
}),
|
|
45006
45006
|
items: makeMergeEvaluated({
|
|
45007
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
45008
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
45007
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
|
|
45008
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
|
|
45009
45009
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
45010
45010
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
45011
45011
|
})
|
|
@@ -45013,21 +45013,21 @@ util.mergeEvaluated = {
|
|
|
45013
45013
|
function evaluatedPropsToName(gen, ps) {
|
|
45014
45014
|
if (ps === true)
|
|
45015
45015
|
return gen.var("props", true);
|
|
45016
|
-
const props = gen.var("props", (0, codegen_1$
|
|
45016
|
+
const props = gen.var("props", (0, codegen_1$v._)`{}`);
|
|
45017
45017
|
if (ps !== void 0)
|
|
45018
45018
|
setEvaluated(gen, props, ps);
|
|
45019
45019
|
return props;
|
|
45020
45020
|
}
|
|
45021
45021
|
util.evaluatedPropsToName = evaluatedPropsToName;
|
|
45022
45022
|
function setEvaluated(gen, props, ps) {
|
|
45023
|
-
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$
|
|
45023
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
|
|
45024
45024
|
}
|
|
45025
45025
|
util.setEvaluated = setEvaluated;
|
|
45026
45026
|
const snippets = {};
|
|
45027
45027
|
function useFunc(gen, f) {
|
|
45028
45028
|
return gen.scopeValue("func", {
|
|
45029
45029
|
ref: f,
|
|
45030
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
45030
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
|
|
45031
45031
|
});
|
|
45032
45032
|
}
|
|
45033
45033
|
util.useFunc = useFunc;
|
|
@@ -45037,11 +45037,11 @@ var Type;
|
|
|
45037
45037
|
Type2[Type2["Str"] = 1] = "Str";
|
|
45038
45038
|
})(Type || (util.Type = Type = {}));
|
|
45039
45039
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
45040
|
-
if (dataProp instanceof codegen_1$
|
|
45040
|
+
if (dataProp instanceof codegen_1$v.Name) {
|
|
45041
45041
|
const isNumber = dataPropType === Type.Num;
|
|
45042
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
45042
|
+
return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
45043
45043
|
}
|
|
45044
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
45044
|
+
return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
|
45045
45045
|
}
|
|
45046
45046
|
util.getErrorPath = getErrorPath;
|
|
45047
45047
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -45055,35 +45055,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
|
45055
45055
|
util.checkStrictMode = checkStrictMode;
|
|
45056
45056
|
var names$1 = {};
|
|
45057
45057
|
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
45058
|
-
const codegen_1$
|
|
45058
|
+
const codegen_1$u = codegen;
|
|
45059
45059
|
const names = {
|
|
45060
45060
|
// validation function arguments
|
|
45061
|
-
data: new codegen_1$
|
|
45061
|
+
data: new codegen_1$u.Name("data"),
|
|
45062
45062
|
// data passed to validation function
|
|
45063
45063
|
// args passed from referencing schema
|
|
45064
|
-
valCxt: new codegen_1$
|
|
45064
|
+
valCxt: new codegen_1$u.Name("valCxt"),
|
|
45065
45065
|
// validation/data context - should not be used directly, it is destructured to the names below
|
|
45066
|
-
instancePath: new codegen_1$
|
|
45067
|
-
parentData: new codegen_1$
|
|
45068
|
-
parentDataProperty: new codegen_1$
|
|
45069
|
-
rootData: new codegen_1$
|
|
45066
|
+
instancePath: new codegen_1$u.Name("instancePath"),
|
|
45067
|
+
parentData: new codegen_1$u.Name("parentData"),
|
|
45068
|
+
parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
|
|
45069
|
+
rootData: new codegen_1$u.Name("rootData"),
|
|
45070
45070
|
// root data - same as the data passed to the first/top validation function
|
|
45071
|
-
dynamicAnchors: new codegen_1$
|
|
45071
|
+
dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
|
|
45072
45072
|
// used to support recursiveRef and dynamicRef
|
|
45073
45073
|
// function scoped variables
|
|
45074
|
-
vErrors: new codegen_1$
|
|
45074
|
+
vErrors: new codegen_1$u.Name("vErrors"),
|
|
45075
45075
|
// null or array of validation errors
|
|
45076
|
-
errors: new codegen_1$
|
|
45076
|
+
errors: new codegen_1$u.Name("errors"),
|
|
45077
45077
|
// counter of validation errors
|
|
45078
|
-
this: new codegen_1$
|
|
45078
|
+
this: new codegen_1$u.Name("this"),
|
|
45079
45079
|
// "globals"
|
|
45080
|
-
self: new codegen_1$
|
|
45081
|
-
scope: new codegen_1$
|
|
45080
|
+
self: new codegen_1$u.Name("self"),
|
|
45081
|
+
scope: new codegen_1$u.Name("scope"),
|
|
45082
45082
|
// JTD serialize/parse name for JSON string and position
|
|
45083
|
-
json: new codegen_1$
|
|
45084
|
-
jsonPos: new codegen_1$
|
|
45085
|
-
jsonLen: new codegen_1$
|
|
45086
|
-
jsonPart: new codegen_1$
|
|
45083
|
+
json: new codegen_1$u.Name("json"),
|
|
45084
|
+
jsonPos: new codegen_1$u.Name("jsonPos"),
|
|
45085
|
+
jsonLen: new codegen_1$u.Name("jsonLen"),
|
|
45086
|
+
jsonPart: new codegen_1$u.Name("jsonPart")
|
|
45087
45087
|
};
|
|
45088
45088
|
names$1.default = names;
|
|
45089
45089
|
(function(exports$1) {
|
|
@@ -45203,55 +45203,49 @@ names$1.default = names;
|
|
|
45203
45203
|
keyValues.push([E.propertyName, propertyName2]);
|
|
45204
45204
|
}
|
|
45205
45205
|
})(errors);
|
|
45206
|
-
|
|
45207
|
-
|
|
45208
|
-
|
|
45209
|
-
|
|
45210
|
-
|
|
45211
|
-
|
|
45212
|
-
|
|
45213
|
-
|
|
45214
|
-
|
|
45215
|
-
const
|
|
45216
|
-
|
|
45217
|
-
|
|
45218
|
-
|
|
45219
|
-
|
|
45220
|
-
|
|
45221
|
-
|
|
45222
|
-
|
|
45223
|
-
gen.return(names_12.default.data);
|
|
45224
|
-
} else {
|
|
45225
|
-
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
45226
|
-
gen.return(true);
|
|
45227
|
-
}
|
|
45206
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
45207
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
45208
|
+
const errors_1$3 = errors;
|
|
45209
|
+
const codegen_1$t = codegen;
|
|
45210
|
+
const names_1$6 = names$1;
|
|
45211
|
+
const boolError = {
|
|
45212
|
+
message: "boolean schema is false"
|
|
45213
|
+
};
|
|
45214
|
+
function topBoolOrEmptySchema(it) {
|
|
45215
|
+
const { gen, schema, validateName } = it;
|
|
45216
|
+
if (schema === false) {
|
|
45217
|
+
falseSchemaError(it, false);
|
|
45218
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
45219
|
+
gen.return(names_1$6.default.data);
|
|
45220
|
+
} else {
|
|
45221
|
+
gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
|
|
45222
|
+
gen.return(true);
|
|
45228
45223
|
}
|
|
45229
|
-
|
|
45230
|
-
|
|
45231
|
-
|
|
45232
|
-
|
|
45233
|
-
|
|
45234
|
-
|
|
45235
|
-
|
|
45236
|
-
|
|
45237
|
-
|
|
45238
|
-
}
|
|
45239
|
-
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
45240
|
-
function falseSchemaError(it, overrideAllErrors) {
|
|
45241
|
-
const { gen, data } = it;
|
|
45242
|
-
const cxt = {
|
|
45243
|
-
gen,
|
|
45244
|
-
keyword: "false schema",
|
|
45245
|
-
data,
|
|
45246
|
-
schema: false,
|
|
45247
|
-
schemaCode: false,
|
|
45248
|
-
schemaValue: false,
|
|
45249
|
-
params: {},
|
|
45250
|
-
it
|
|
45251
|
-
};
|
|
45252
|
-
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
45224
|
+
}
|
|
45225
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
45226
|
+
function boolOrEmptySchema(it, valid) {
|
|
45227
|
+
const { gen, schema } = it;
|
|
45228
|
+
if (schema === false) {
|
|
45229
|
+
gen.var(valid, false);
|
|
45230
|
+
falseSchemaError(it);
|
|
45231
|
+
} else {
|
|
45232
|
+
gen.var(valid, true);
|
|
45253
45233
|
}
|
|
45254
|
-
|
|
45234
|
+
}
|
|
45235
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
45236
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
45237
|
+
const { gen, data } = it;
|
|
45238
|
+
const cxt = {
|
|
45239
|
+
gen,
|
|
45240
|
+
keyword: "false schema",
|
|
45241
|
+
data,
|
|
45242
|
+
schema: false,
|
|
45243
|
+
schemaCode: false,
|
|
45244
|
+
schemaValue: false,
|
|
45245
|
+
params: {},
|
|
45246
|
+
it
|
|
45247
|
+
};
|
|
45248
|
+
(0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
45255
45249
|
}
|
|
45256
45250
|
var dataType = {};
|
|
45257
45251
|
var rules = {};
|
|
@@ -45299,10 +45293,10 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
45299
45293
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
45300
45294
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
45301
45295
|
const rules_1 = rules;
|
|
45302
|
-
const applicability_1 = applicability;
|
|
45303
|
-
const errors_1 = errors;
|
|
45304
|
-
const codegen_1$
|
|
45305
|
-
const util_1$
|
|
45296
|
+
const applicability_1$1 = applicability;
|
|
45297
|
+
const errors_1$2 = errors;
|
|
45298
|
+
const codegen_1$s = codegen;
|
|
45299
|
+
const util_1$r = util;
|
|
45306
45300
|
var DataType;
|
|
45307
45301
|
(function(DataType2) {
|
|
45308
45302
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -45334,7 +45328,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
45334
45328
|
function coerceAndCheckDataType(it, types2) {
|
|
45335
45329
|
const { gen, data, opts } = it;
|
|
45336
45330
|
const coerceTo = coerceToTypes(types2, opts.coerceTypes);
|
|
45337
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
45331
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
|
|
45338
45332
|
if (checkTypes) {
|
|
45339
45333
|
const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
|
|
45340
45334
|
gen.if(wrongType, () => {
|
|
@@ -45353,12 +45347,12 @@ function coerceToTypes(types2, coerceTypes) {
|
|
|
45353
45347
|
}
|
|
45354
45348
|
function coerceData(it, types2, coerceTo) {
|
|
45355
45349
|
const { gen, data, opts } = it;
|
|
45356
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
45357
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
45350
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
|
|
45351
|
+
const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
|
|
45358
45352
|
if (opts.coerceTypes === "array") {
|
|
45359
|
-
gen.if((0, codegen_1$
|
|
45353
|
+
gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
45360
45354
|
}
|
|
45361
|
-
gen.if((0, codegen_1$
|
|
45355
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
|
|
45362
45356
|
for (const t2 of coerceTo) {
|
|
45363
45357
|
if (COERCIBLE.has(t2) || t2 === "array" && opts.coerceTypes === "array") {
|
|
45364
45358
|
coerceSpecificType(t2);
|
|
@@ -45367,63 +45361,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
45367
45361
|
gen.else();
|
|
45368
45362
|
reportTypeError(it);
|
|
45369
45363
|
gen.endIf();
|
|
45370
|
-
gen.if((0, codegen_1$
|
|
45364
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
|
|
45371
45365
|
gen.assign(data, coerced);
|
|
45372
45366
|
assignParentData(it, coerced);
|
|
45373
45367
|
});
|
|
45374
45368
|
function coerceSpecificType(t2) {
|
|
45375
45369
|
switch (t2) {
|
|
45376
45370
|
case "string":
|
|
45377
|
-
gen.elseIf((0, codegen_1$
|
|
45371
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
|
|
45378
45372
|
return;
|
|
45379
45373
|
case "number":
|
|
45380
|
-
gen.elseIf((0, codegen_1$
|
|
45381
|
-
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$
|
|
45374
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
|
|
45375
|
+
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
|
|
45382
45376
|
return;
|
|
45383
45377
|
case "integer":
|
|
45384
|
-
gen.elseIf((0, codegen_1$
|
|
45385
|
-
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$
|
|
45378
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
|
|
45379
|
+
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
|
|
45386
45380
|
return;
|
|
45387
45381
|
case "boolean":
|
|
45388
|
-
gen.elseIf((0, codegen_1$
|
|
45382
|
+
gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
|
|
45389
45383
|
return;
|
|
45390
45384
|
case "null":
|
|
45391
|
-
gen.elseIf((0, codegen_1$
|
|
45385
|
+
gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
|
|
45392
45386
|
gen.assign(coerced, null);
|
|
45393
45387
|
return;
|
|
45394
45388
|
case "array":
|
|
45395
|
-
gen.elseIf((0, codegen_1$
|
|
45396
|
-
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$
|
|
45389
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
45390
|
+
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
|
|
45397
45391
|
}
|
|
45398
45392
|
}
|
|
45399
45393
|
}
|
|
45400
45394
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
45401
|
-
gen.if((0, codegen_1$
|
|
45395
|
+
gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
|
|
45402
45396
|
}
|
|
45403
45397
|
function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
|
|
45404
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
45398
|
+
const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
|
|
45405
45399
|
let cond;
|
|
45406
45400
|
switch (dataType2) {
|
|
45407
45401
|
case "null":
|
|
45408
|
-
return (0, codegen_1$
|
|
45402
|
+
return (0, codegen_1$s._)`${data} ${EQ} null`;
|
|
45409
45403
|
case "array":
|
|
45410
|
-
cond = (0, codegen_1$
|
|
45404
|
+
cond = (0, codegen_1$s._)`Array.isArray(${data})`;
|
|
45411
45405
|
break;
|
|
45412
45406
|
case "object":
|
|
45413
|
-
cond = (0, codegen_1$
|
|
45407
|
+
cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
|
|
45414
45408
|
break;
|
|
45415
45409
|
case "integer":
|
|
45416
|
-
cond = numCond((0, codegen_1$
|
|
45410
|
+
cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
|
|
45417
45411
|
break;
|
|
45418
45412
|
case "number":
|
|
45419
45413
|
cond = numCond();
|
|
45420
45414
|
break;
|
|
45421
45415
|
default:
|
|
45422
|
-
return (0, codegen_1$
|
|
45416
|
+
return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
|
|
45423
45417
|
}
|
|
45424
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
45425
|
-
function numCond(_cond = codegen_1$
|
|
45426
|
-
return (0, codegen_1$
|
|
45418
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
|
|
45419
|
+
function numCond(_cond = codegen_1$s.nil) {
|
|
45420
|
+
return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
|
|
45427
45421
|
}
|
|
45428
45422
|
}
|
|
45429
45423
|
dataType.checkDataType = checkDataType;
|
|
@@ -45432,35 +45426,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
|
45432
45426
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
45433
45427
|
}
|
|
45434
45428
|
let cond;
|
|
45435
|
-
const types2 = (0, util_1$
|
|
45429
|
+
const types2 = (0, util_1$r.toHash)(dataTypes);
|
|
45436
45430
|
if (types2.array && types2.object) {
|
|
45437
|
-
const notObj = (0, codegen_1$
|
|
45438
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
45431
|
+
const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
|
|
45432
|
+
cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
|
|
45439
45433
|
delete types2.null;
|
|
45440
45434
|
delete types2.array;
|
|
45441
45435
|
delete types2.object;
|
|
45442
45436
|
} else {
|
|
45443
|
-
cond = codegen_1$
|
|
45437
|
+
cond = codegen_1$s.nil;
|
|
45444
45438
|
}
|
|
45445
45439
|
if (types2.number)
|
|
45446
45440
|
delete types2.integer;
|
|
45447
45441
|
for (const t2 in types2)
|
|
45448
|
-
cond = (0, codegen_1$
|
|
45442
|
+
cond = (0, codegen_1$s.and)(cond, checkDataType(t2, data, strictNums, correct));
|
|
45449
45443
|
return cond;
|
|
45450
45444
|
}
|
|
45451
45445
|
dataType.checkDataTypes = checkDataTypes;
|
|
45452
45446
|
const typeError = {
|
|
45453
45447
|
message: ({ schema }) => `must be ${schema}`,
|
|
45454
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
45448
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
|
|
45455
45449
|
};
|
|
45456
45450
|
function reportTypeError(it) {
|
|
45457
45451
|
const cxt = getTypeErrorContext(it);
|
|
45458
|
-
(0, errors_1.reportError)(cxt, typeError);
|
|
45452
|
+
(0, errors_1$2.reportError)(cxt, typeError);
|
|
45459
45453
|
}
|
|
45460
45454
|
dataType.reportTypeError = reportTypeError;
|
|
45461
45455
|
function getTypeErrorContext(it) {
|
|
45462
45456
|
const { gen, data, schema } = it;
|
|
45463
|
-
const schemaCode = (0, util_1$
|
|
45457
|
+
const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
|
|
45464
45458
|
return {
|
|
45465
45459
|
gen,
|
|
45466
45460
|
keyword: "type",
|
|
@@ -45474,60 +45468,54 @@ function getTypeErrorContext(it) {
|
|
|
45474
45468
|
};
|
|
45475
45469
|
}
|
|
45476
45470
|
var defaults = {};
|
|
45477
|
-
|
|
45478
|
-
|
|
45479
|
-
|
|
45480
|
-
|
|
45481
|
-
|
|
45482
|
-
|
|
45483
|
-
|
|
45484
|
-
|
|
45485
|
-
|
|
45486
|
-
|
|
45487
|
-
|
|
45488
|
-
|
|
45489
|
-
|
|
45490
|
-
|
|
45491
|
-
|
|
45492
|
-
|
|
45493
|
-
|
|
45471
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
45472
|
+
defaults.assignDefaults = void 0;
|
|
45473
|
+
const codegen_1$r = codegen;
|
|
45474
|
+
const util_1$q = util;
|
|
45475
|
+
function assignDefaults(it, ty) {
|
|
45476
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
45477
|
+
if (ty === "object" && properties2) {
|
|
45478
|
+
for (const key in properties2) {
|
|
45479
|
+
assignDefault(it, key, properties2[key].default);
|
|
45480
|
+
}
|
|
45481
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
45482
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
45483
|
+
}
|
|
45484
|
+
}
|
|
45485
|
+
defaults.assignDefaults = assignDefaults;
|
|
45486
|
+
function assignDefault(it, prop, defaultValue) {
|
|
45487
|
+
const { gen, compositeRule, data, opts } = it;
|
|
45488
|
+
if (defaultValue === void 0)
|
|
45489
|
+
return;
|
|
45490
|
+
const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
45491
|
+
if (compositeRule) {
|
|
45492
|
+
(0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
45493
|
+
return;
|
|
45494
45494
|
}
|
|
45495
|
-
|
|
45496
|
-
|
|
45497
|
-
|
|
45498
|
-
if (defaultValue === void 0)
|
|
45499
|
-
return;
|
|
45500
|
-
const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
|
|
45501
|
-
if (compositeRule) {
|
|
45502
|
-
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
45503
|
-
return;
|
|
45504
|
-
}
|
|
45505
|
-
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
45506
|
-
if (opts.useDefaults === "empty") {
|
|
45507
|
-
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
45508
|
-
}
|
|
45509
|
-
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
45495
|
+
let condition = (0, codegen_1$r._)`${childData} === undefined`;
|
|
45496
|
+
if (opts.useDefaults === "empty") {
|
|
45497
|
+
condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
45510
45498
|
}
|
|
45511
|
-
|
|
45499
|
+
gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
|
|
45512
45500
|
}
|
|
45513
45501
|
var keyword = {};
|
|
45514
45502
|
var code = {};
|
|
45515
45503
|
Object.defineProperty(code, "__esModule", { value: true });
|
|
45516
45504
|
code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0;
|
|
45517
|
-
const codegen_1$
|
|
45518
|
-
const util_1$
|
|
45519
|
-
const names_1$
|
|
45505
|
+
const codegen_1$q = codegen;
|
|
45506
|
+
const util_1$p = util;
|
|
45507
|
+
const names_1$5 = names$1;
|
|
45520
45508
|
const util_2$1 = util;
|
|
45521
45509
|
function checkReportMissingProp(cxt, prop) {
|
|
45522
45510
|
const { gen, data, it } = cxt;
|
|
45523
45511
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
45524
|
-
cxt.setParams({ missingProperty: (0, codegen_1$
|
|
45512
|
+
cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
|
|
45525
45513
|
cxt.error();
|
|
45526
45514
|
});
|
|
45527
45515
|
}
|
|
45528
45516
|
code.checkReportMissingProp = checkReportMissingProp;
|
|
45529
45517
|
function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
|
|
45530
|
-
return (0, codegen_1$
|
|
45518
|
+
return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
|
|
45531
45519
|
}
|
|
45532
45520
|
code.checkMissingProp = checkMissingProp;
|
|
45533
45521
|
function reportMissingProp(cxt, missing) {
|
|
@@ -45539,22 +45527,22 @@ function hasPropFunc(gen) {
|
|
|
45539
45527
|
return gen.scopeValue("func", {
|
|
45540
45528
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
45541
45529
|
ref: Object.prototype.hasOwnProperty,
|
|
45542
|
-
code: (0, codegen_1$
|
|
45530
|
+
code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
|
|
45543
45531
|
});
|
|
45544
45532
|
}
|
|
45545
45533
|
code.hasPropFunc = hasPropFunc;
|
|
45546
45534
|
function isOwnProperty(gen, data, property) {
|
|
45547
|
-
return (0, codegen_1$
|
|
45535
|
+
return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
|
|
45548
45536
|
}
|
|
45549
45537
|
code.isOwnProperty = isOwnProperty;
|
|
45550
45538
|
function propertyInData(gen, data, property, ownProperties) {
|
|
45551
|
-
const cond = (0, codegen_1$
|
|
45552
|
-
return ownProperties ? (0, codegen_1$
|
|
45539
|
+
const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
|
|
45540
|
+
return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
|
|
45553
45541
|
}
|
|
45554
45542
|
code.propertyInData = propertyInData;
|
|
45555
45543
|
function noPropertyInData(gen, data, property, ownProperties) {
|
|
45556
|
-
const cond = (0, codegen_1$
|
|
45557
|
-
return ownProperties ? (0, codegen_1$
|
|
45544
|
+
const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
|
|
45545
|
+
return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
|
|
45558
45546
|
}
|
|
45559
45547
|
code.noPropertyInData = noPropertyInData;
|
|
45560
45548
|
function allSchemaProperties(schemaMap) {
|
|
@@ -45562,24 +45550,24 @@ function allSchemaProperties(schemaMap) {
|
|
|
45562
45550
|
}
|
|
45563
45551
|
code.allSchemaProperties = allSchemaProperties;
|
|
45564
45552
|
function schemaProperties(it, schemaMap) {
|
|
45565
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$
|
|
45553
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p]));
|
|
45566
45554
|
}
|
|
45567
45555
|
code.schemaProperties = schemaProperties;
|
|
45568
45556
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
45569
|
-
const dataAndSchema = passSchema ? (0, codegen_1$
|
|
45557
|
+
const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
|
|
45570
45558
|
const valCxt = [
|
|
45571
|
-
[names_1$
|
|
45572
|
-
[names_1$
|
|
45573
|
-
[names_1$
|
|
45574
|
-
[names_1$
|
|
45559
|
+
[names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
|
|
45560
|
+
[names_1$5.default.parentData, it.parentData],
|
|
45561
|
+
[names_1$5.default.parentDataProperty, it.parentDataProperty],
|
|
45562
|
+
[names_1$5.default.rootData, names_1$5.default.rootData]
|
|
45575
45563
|
];
|
|
45576
45564
|
if (it.opts.dynamicRef)
|
|
45577
|
-
valCxt.push([names_1$
|
|
45578
|
-
const args = (0, codegen_1$
|
|
45579
|
-
return context !== codegen_1$
|
|
45565
|
+
valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
|
|
45566
|
+
const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
45567
|
+
return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
|
|
45580
45568
|
}
|
|
45581
45569
|
code.callValidateCode = callValidateCode;
|
|
45582
|
-
const newRegExp = (0, codegen_1$
|
|
45570
|
+
const newRegExp = (0, codegen_1$q._)`new RegExp`;
|
|
45583
45571
|
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
45584
45572
|
const u = opts.unicodeRegExp ? "u" : "";
|
|
45585
45573
|
const { regExp } = opts.code;
|
|
@@ -45587,7 +45575,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
|
|
|
45587
45575
|
return gen.scopeValue("pattern", {
|
|
45588
45576
|
key: rx.toString(),
|
|
45589
45577
|
ref: rx,
|
|
45590
|
-
code: (0, codegen_1$
|
|
45578
|
+
code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
45591
45579
|
});
|
|
45592
45580
|
}
|
|
45593
45581
|
code.usePattern = usePattern;
|
|
@@ -45603,14 +45591,14 @@ function validateArray(cxt) {
|
|
|
45603
45591
|
validateItems(() => gen.break());
|
|
45604
45592
|
return valid;
|
|
45605
45593
|
function validateItems(notValid) {
|
|
45606
|
-
const len = gen.const("len", (0, codegen_1$
|
|
45594
|
+
const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
|
|
45607
45595
|
gen.forRange("i", 0, len, (i) => {
|
|
45608
45596
|
cxt.subschema({
|
|
45609
45597
|
keyword: keyword2,
|
|
45610
45598
|
dataProp: i,
|
|
45611
|
-
dataPropType: util_1$
|
|
45599
|
+
dataPropType: util_1$p.Type.Num
|
|
45612
45600
|
}, valid);
|
|
45613
|
-
gen.if((0, codegen_1$
|
|
45601
|
+
gen.if((0, codegen_1$q.not)(valid), notValid);
|
|
45614
45602
|
});
|
|
45615
45603
|
}
|
|
45616
45604
|
}
|
|
@@ -45619,7 +45607,7 @@ function validateUnion(cxt) {
|
|
|
45619
45607
|
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
45620
45608
|
if (!Array.isArray(schema))
|
|
45621
45609
|
throw new Error("ajv implementation error");
|
|
45622
|
-
const alwaysValid = schema.some((sch) => (0, util_1$
|
|
45610
|
+
const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
|
|
45623
45611
|
if (alwaysValid && !it.opts.unevaluated)
|
|
45624
45612
|
return;
|
|
45625
45613
|
const valid = gen.let("valid", false);
|
|
@@ -45630,214 +45618,202 @@ function validateUnion(cxt) {
|
|
|
45630
45618
|
schemaProp: i,
|
|
45631
45619
|
compositeRule: true
|
|
45632
45620
|
}, schValid);
|
|
45633
|
-
gen.assign(valid, (0, codegen_1$
|
|
45621
|
+
gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
|
|
45634
45622
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
45635
45623
|
if (!merged)
|
|
45636
|
-
gen.if((0, codegen_1$
|
|
45624
|
+
gen.if((0, codegen_1$q.not)(valid));
|
|
45637
45625
|
}));
|
|
45638
45626
|
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
45639
45627
|
}
|
|
45640
45628
|
code.validateUnion = validateUnion;
|
|
45641
|
-
|
|
45642
|
-
|
|
45643
|
-
|
|
45644
|
-
|
|
45645
|
-
|
|
45646
|
-
|
|
45647
|
-
|
|
45648
|
-
const
|
|
45649
|
-
const
|
|
45650
|
-
const
|
|
45651
|
-
|
|
45652
|
-
|
|
45653
|
-
|
|
45654
|
-
|
|
45655
|
-
|
|
45656
|
-
|
|
45657
|
-
|
|
45658
|
-
|
|
45659
|
-
|
|
45660
|
-
|
|
45661
|
-
|
|
45662
|
-
|
|
45663
|
-
|
|
45664
|
-
|
|
45665
|
-
|
|
45666
|
-
}
|
|
45667
|
-
|
|
45668
|
-
|
|
45669
|
-
|
|
45670
|
-
|
|
45671
|
-
|
|
45672
|
-
|
|
45673
|
-
|
|
45674
|
-
|
|
45675
|
-
|
|
45676
|
-
|
|
45677
|
-
|
|
45678
|
-
|
|
45679
|
-
|
|
45680
|
-
|
|
45681
|
-
|
|
45682
|
-
|
|
45683
|
-
|
|
45684
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
45685
|
-
if (def2.modifying)
|
|
45686
|
-
modifyData(cxt);
|
|
45687
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
45688
|
-
}
|
|
45689
|
-
}
|
|
45690
|
-
function validateAsync() {
|
|
45691
|
-
const ruleErrs = gen.let("ruleErrs", null);
|
|
45692
|
-
gen.try(() => assignValid((0, codegen_12._)`await `), (e) => gen.assign(valid, false).if((0, codegen_12._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_12._)`${e}.errors`), () => gen.throw(e)));
|
|
45693
|
-
return ruleErrs;
|
|
45694
|
-
}
|
|
45695
|
-
function validateSync() {
|
|
45696
|
-
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
45697
|
-
gen.assign(validateErrs, null);
|
|
45698
|
-
assignValid(codegen_12.nil);
|
|
45699
|
-
return validateErrs;
|
|
45700
|
-
}
|
|
45701
|
-
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
45702
|
-
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
45703
|
-
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
45704
|
-
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
45705
|
-
}
|
|
45706
|
-
function reportErrs(errors2) {
|
|
45707
|
-
var _a3;
|
|
45708
|
-
gen.if((0, codegen_12.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
|
|
45629
|
+
Object.defineProperty(keyword, "__esModule", { value: true });
|
|
45630
|
+
keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
|
|
45631
|
+
const codegen_1$p = codegen;
|
|
45632
|
+
const names_1$4 = names$1;
|
|
45633
|
+
const code_1$9 = code;
|
|
45634
|
+
const errors_1$1 = errors;
|
|
45635
|
+
function macroKeywordCode(cxt, def2) {
|
|
45636
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
45637
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
45638
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
45639
|
+
if (it.opts.validateSchema !== false)
|
|
45640
|
+
it.self.validateSchema(macroSchema, true);
|
|
45641
|
+
const valid = gen.name("valid");
|
|
45642
|
+
cxt.subschema({
|
|
45643
|
+
schema: macroSchema,
|
|
45644
|
+
schemaPath: codegen_1$p.nil,
|
|
45645
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
45646
|
+
topSchemaRef: schemaRef,
|
|
45647
|
+
compositeRule: true
|
|
45648
|
+
}, valid);
|
|
45649
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
45650
|
+
}
|
|
45651
|
+
keyword.macroKeywordCode = macroKeywordCode;
|
|
45652
|
+
function funcKeywordCode(cxt, def2) {
|
|
45653
|
+
var _a2;
|
|
45654
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
45655
|
+
checkAsyncKeyword(it, def2);
|
|
45656
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
45657
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
45658
|
+
const valid = gen.let("valid");
|
|
45659
|
+
cxt.block$data(valid, validateKeyword);
|
|
45660
|
+
cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
|
|
45661
|
+
function validateKeyword() {
|
|
45662
|
+
if (def2.errors === false) {
|
|
45663
|
+
assignValid();
|
|
45664
|
+
if (def2.modifying)
|
|
45665
|
+
modifyData(cxt);
|
|
45666
|
+
reportErrs(() => cxt.error());
|
|
45667
|
+
} else {
|
|
45668
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
45669
|
+
if (def2.modifying)
|
|
45670
|
+
modifyData(cxt);
|
|
45671
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
45709
45672
|
}
|
|
45710
45673
|
}
|
|
45711
|
-
|
|
45712
|
-
|
|
45713
|
-
|
|
45714
|
-
|
|
45715
|
-
}
|
|
45716
|
-
function
|
|
45717
|
-
const
|
|
45718
|
-
gen.
|
|
45719
|
-
|
|
45720
|
-
|
|
45721
|
-
|
|
45722
|
-
|
|
45723
|
-
|
|
45724
|
-
|
|
45725
|
-
|
|
45726
|
-
}
|
|
45727
|
-
function
|
|
45728
|
-
|
|
45729
|
-
|
|
45730
|
-
|
|
45731
|
-
|
|
45732
|
-
|
|
45733
|
-
|
|
45734
|
-
}
|
|
45735
|
-
|
|
45736
|
-
|
|
45737
|
-
|
|
45738
|
-
|
|
45739
|
-
|
|
45740
|
-
|
|
45741
|
-
|
|
45742
|
-
|
|
45743
|
-
|
|
45744
|
-
|
|
45745
|
-
|
|
45746
|
-
|
|
45747
|
-
|
|
45748
|
-
|
|
45749
|
-
|
|
45750
|
-
|
|
45751
|
-
|
|
45752
|
-
|
|
45674
|
+
function validateAsync() {
|
|
45675
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
45676
|
+
gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
|
|
45677
|
+
return ruleErrs;
|
|
45678
|
+
}
|
|
45679
|
+
function validateSync() {
|
|
45680
|
+
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
45681
|
+
gen.assign(validateErrs, null);
|
|
45682
|
+
assignValid(codegen_1$p.nil);
|
|
45683
|
+
return validateErrs;
|
|
45684
|
+
}
|
|
45685
|
+
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
45686
|
+
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
45687
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
45688
|
+
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
45689
|
+
}
|
|
45690
|
+
function reportErrs(errors2) {
|
|
45691
|
+
var _a3;
|
|
45692
|
+
gen.if((0, codegen_1$p.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
|
|
45693
|
+
}
|
|
45694
|
+
}
|
|
45695
|
+
keyword.funcKeywordCode = funcKeywordCode;
|
|
45696
|
+
function modifyData(cxt) {
|
|
45697
|
+
const { gen, data, it } = cxt;
|
|
45698
|
+
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
45699
|
+
}
|
|
45700
|
+
function addErrs(cxt, errs) {
|
|
45701
|
+
const { gen } = cxt;
|
|
45702
|
+
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
45703
|
+
gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
|
|
45704
|
+
(0, errors_1$1.extendErrors)(cxt);
|
|
45705
|
+
}, () => cxt.error());
|
|
45706
|
+
}
|
|
45707
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
45708
|
+
if (def2.async && !schemaEnv.$async)
|
|
45709
|
+
throw new Error("async keyword in sync schema");
|
|
45710
|
+
}
|
|
45711
|
+
function useKeyword(gen, keyword2, result) {
|
|
45712
|
+
if (result === void 0)
|
|
45713
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
45714
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
45715
|
+
}
|
|
45716
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
45717
|
+
return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
|
|
45718
|
+
}
|
|
45719
|
+
keyword.validSchemaType = validSchemaType;
|
|
45720
|
+
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
|
|
45721
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
45722
|
+
throw new Error("ajv implementation error");
|
|
45723
|
+
}
|
|
45724
|
+
const deps = def2.dependencies;
|
|
45725
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
45726
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
45727
|
+
}
|
|
45728
|
+
if (def2.validateSchema) {
|
|
45729
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
45730
|
+
if (!valid) {
|
|
45731
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
|
|
45732
|
+
if (opts.validateSchema === "log")
|
|
45733
|
+
self.logger.error(msg);
|
|
45734
|
+
else
|
|
45735
|
+
throw new Error(msg);
|
|
45753
45736
|
}
|
|
45754
45737
|
}
|
|
45755
|
-
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
45756
|
-
return keyword;
|
|
45757
45738
|
}
|
|
45739
|
+
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
45758
45740
|
var subschema = {};
|
|
45759
|
-
|
|
45760
|
-
|
|
45761
|
-
|
|
45762
|
-
|
|
45763
|
-
|
|
45764
|
-
|
|
45765
|
-
|
|
45766
|
-
|
|
45767
|
-
|
|
45768
|
-
|
|
45769
|
-
|
|
45770
|
-
|
|
45771
|
-
|
|
45772
|
-
|
|
45773
|
-
|
|
45774
|
-
|
|
45775
|
-
|
|
45776
|
-
|
|
45777
|
-
|
|
45778
|
-
|
|
45779
|
-
|
|
45780
|
-
|
|
45781
|
-
|
|
45782
|
-
}
|
|
45783
|
-
if (schema !== void 0) {
|
|
45784
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
45785
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
45786
|
-
}
|
|
45787
|
-
return {
|
|
45788
|
-
schema,
|
|
45789
|
-
schemaPath,
|
|
45790
|
-
topSchemaRef,
|
|
45791
|
-
errSchemaPath
|
|
45792
|
-
};
|
|
45741
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
45742
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
45743
|
+
const codegen_1$o = codegen;
|
|
45744
|
+
const util_1$o = util;
|
|
45745
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
45746
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
45747
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
45748
|
+
}
|
|
45749
|
+
if (keyword2 !== void 0) {
|
|
45750
|
+
const sch = it.schema[keyword2];
|
|
45751
|
+
return schemaProp === void 0 ? {
|
|
45752
|
+
schema: sch,
|
|
45753
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
45754
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
45755
|
+
} : {
|
|
45756
|
+
schema: sch[schemaProp],
|
|
45757
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
45758
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
|
|
45759
|
+
};
|
|
45760
|
+
}
|
|
45761
|
+
if (schema !== void 0) {
|
|
45762
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
45763
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
45793
45764
|
}
|
|
45794
|
-
|
|
45795
|
-
|
|
45796
|
-
|
|
45797
|
-
|
|
45798
|
-
|
|
45799
|
-
|
|
45800
|
-
|
|
45801
|
-
|
|
45802
|
-
|
|
45803
|
-
|
|
45804
|
-
|
|
45805
|
-
|
|
45806
|
-
|
|
45807
|
-
|
|
45808
|
-
|
|
45809
|
-
|
|
45810
|
-
|
|
45811
|
-
|
|
45812
|
-
|
|
45813
|
-
|
|
45814
|
-
|
|
45815
|
-
|
|
45816
|
-
|
|
45817
|
-
|
|
45818
|
-
|
|
45819
|
-
|
|
45820
|
-
|
|
45821
|
-
subschema2.
|
|
45822
|
-
|
|
45823
|
-
|
|
45824
|
-
|
|
45825
|
-
|
|
45826
|
-
|
|
45827
|
-
|
|
45828
|
-
|
|
45829
|
-
|
|
45830
|
-
|
|
45831
|
-
|
|
45832
|
-
|
|
45833
|
-
|
|
45834
|
-
|
|
45835
|
-
|
|
45836
|
-
|
|
45837
|
-
|
|
45838
|
-
|
|
45839
|
-
|
|
45840
|
-
|
|
45765
|
+
return {
|
|
45766
|
+
schema,
|
|
45767
|
+
schemaPath,
|
|
45768
|
+
topSchemaRef,
|
|
45769
|
+
errSchemaPath
|
|
45770
|
+
};
|
|
45771
|
+
}
|
|
45772
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
45773
|
+
}
|
|
45774
|
+
subschema.getSubschema = getSubschema;
|
|
45775
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
|
|
45776
|
+
if (data !== void 0 && dataProp !== void 0) {
|
|
45777
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
45778
|
+
}
|
|
45779
|
+
const { gen } = it;
|
|
45780
|
+
if (dataProp !== void 0) {
|
|
45781
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
45782
|
+
const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
|
|
45783
|
+
dataContextProps(nextData);
|
|
45784
|
+
subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
45785
|
+
subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
|
|
45786
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
45787
|
+
}
|
|
45788
|
+
if (data !== void 0) {
|
|
45789
|
+
const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
|
|
45790
|
+
dataContextProps(nextData);
|
|
45791
|
+
if (propertyName2 !== void 0)
|
|
45792
|
+
subschema2.propertyName = propertyName2;
|
|
45793
|
+
}
|
|
45794
|
+
if (dataTypes)
|
|
45795
|
+
subschema2.dataTypes = dataTypes;
|
|
45796
|
+
function dataContextProps(_nextData) {
|
|
45797
|
+
subschema2.data = _nextData;
|
|
45798
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
45799
|
+
subschema2.dataTypes = [];
|
|
45800
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
45801
|
+
subschema2.parentData = it.data;
|
|
45802
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
45803
|
+
}
|
|
45804
|
+
}
|
|
45805
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
45806
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
45807
|
+
if (compositeRule !== void 0)
|
|
45808
|
+
subschema2.compositeRule = compositeRule;
|
|
45809
|
+
if (createErrors !== void 0)
|
|
45810
|
+
subschema2.createErrors = createErrors;
|
|
45811
|
+
if (allErrors !== void 0)
|
|
45812
|
+
subschema2.allErrors = allErrors;
|
|
45813
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
45814
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
45815
|
+
}
|
|
45816
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
45841
45817
|
var resolve$2 = {};
|
|
45842
45818
|
var fastDeepEqual = function equal(a, b) {
|
|
45843
45819
|
if (a === b) return true;
|
|
@@ -45952,7 +45928,7 @@ function escapeJsonPtr(str) {
|
|
|
45952
45928
|
var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
|
|
45953
45929
|
Object.defineProperty(resolve$2, "__esModule", { value: true });
|
|
45954
45930
|
resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
|
|
45955
|
-
const util_1$
|
|
45931
|
+
const util_1$n = util;
|
|
45956
45932
|
const equal$3 = fastDeepEqual;
|
|
45957
45933
|
const traverse = jsonSchemaTraverseExports;
|
|
45958
45934
|
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
@@ -46011,7 +45987,7 @@ function countKeys(schema) {
|
|
|
46011
45987
|
if (SIMPLE_INLINED.has(key))
|
|
46012
45988
|
continue;
|
|
46013
45989
|
if (typeof schema[key] == "object") {
|
|
46014
|
-
(0, util_1$
|
|
45990
|
+
(0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
|
|
46015
45991
|
}
|
|
46016
45992
|
if (count === Infinity)
|
|
46017
45993
|
return Infinity;
|
|
@@ -46099,528 +46075,516 @@ function getSchemaRefs(schema, baseId) {
|
|
|
46099
46075
|
}
|
|
46100
46076
|
}
|
|
46101
46077
|
resolve$2.getSchemaRefs = getSchemaRefs;
|
|
46102
|
-
|
|
46103
|
-
|
|
46104
|
-
|
|
46105
|
-
|
|
46106
|
-
|
|
46107
|
-
|
|
46108
|
-
|
|
46109
|
-
|
|
46110
|
-
|
|
46111
|
-
|
|
46112
|
-
|
|
46113
|
-
|
|
46114
|
-
|
|
46115
|
-
|
|
46116
|
-
|
|
46117
|
-
|
|
46118
|
-
|
|
46119
|
-
|
|
46120
|
-
|
|
46121
|
-
|
|
46122
|
-
checkKeywords(it);
|
|
46123
|
-
if (schemaCxtHasRules(it)) {
|
|
46124
|
-
topSchemaObjCode(it);
|
|
46125
|
-
return;
|
|
46126
|
-
}
|
|
46078
|
+
Object.defineProperty(validate, "__esModule", { value: true });
|
|
46079
|
+
validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
|
|
46080
|
+
const boolSchema_1 = boolSchema;
|
|
46081
|
+
const dataType_1$1 = dataType;
|
|
46082
|
+
const applicability_1 = applicability;
|
|
46083
|
+
const dataType_2 = dataType;
|
|
46084
|
+
const defaults_1 = defaults;
|
|
46085
|
+
const keyword_1 = keyword;
|
|
46086
|
+
const subschema_1 = subschema;
|
|
46087
|
+
const codegen_1$n = codegen;
|
|
46088
|
+
const names_1$3 = names$1;
|
|
46089
|
+
const resolve_1$2 = resolve$2;
|
|
46090
|
+
const util_1$m = util;
|
|
46091
|
+
const errors_1 = errors;
|
|
46092
|
+
function validateFunctionCode(it) {
|
|
46093
|
+
if (isSchemaObj(it)) {
|
|
46094
|
+
checkKeywords(it);
|
|
46095
|
+
if (schemaCxtHasRules(it)) {
|
|
46096
|
+
topSchemaObjCode(it);
|
|
46097
|
+
return;
|
|
46127
46098
|
}
|
|
46128
|
-
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
46129
46099
|
}
|
|
46130
|
-
|
|
46131
|
-
|
|
46132
|
-
|
|
46133
|
-
|
|
46134
|
-
|
|
46135
|
-
|
|
46136
|
-
|
|
46137
|
-
|
|
46138
|
-
|
|
46139
|
-
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
46140
|
-
}
|
|
46141
|
-
}
|
|
46142
|
-
function destructureValCxt(opts) {
|
|
46143
|
-
return (0, codegen_12._)`{${names_12.default.instancePath}="", ${names_12.default.parentData}, ${names_12.default.parentDataProperty}, ${names_12.default.rootData}=${names_12.default.data}${opts.dynamicRef ? (0, codegen_12._)`, ${names_12.default.dynamicAnchors}={}` : codegen_12.nil}}={}`;
|
|
46144
|
-
}
|
|
46145
|
-
function destructureValCxtES5(gen, opts) {
|
|
46146
|
-
gen.if(names_12.default.valCxt, () => {
|
|
46147
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
46148
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
46149
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
46150
|
-
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
46151
|
-
if (opts.dynamicRef)
|
|
46152
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
46153
|
-
}, () => {
|
|
46154
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
46155
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
46156
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
46157
|
-
gen.var(names_12.default.rootData, names_12.default.data);
|
|
46158
|
-
if (opts.dynamicRef)
|
|
46159
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
46160
|
-
});
|
|
46161
|
-
}
|
|
46162
|
-
function topSchemaObjCode(it) {
|
|
46163
|
-
const { schema, opts, gen } = it;
|
|
46164
|
-
validateFunction(it, () => {
|
|
46165
|
-
if (opts.$comment && schema.$comment)
|
|
46166
|
-
commentKeyword(it);
|
|
46167
|
-
checkNoDefault(it);
|
|
46168
|
-
gen.let(names_12.default.vErrors, null);
|
|
46169
|
-
gen.let(names_12.default.errors, 0);
|
|
46170
|
-
if (opts.unevaluated)
|
|
46171
|
-
resetEvaluated(it);
|
|
46172
|
-
typeAndKeywords(it);
|
|
46173
|
-
returnResults(it);
|
|
46100
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
46101
|
+
}
|
|
46102
|
+
validate.validateFunctionCode = validateFunctionCode;
|
|
46103
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
46104
|
+
if (opts.code.es5) {
|
|
46105
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
|
|
46106
|
+
gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
46107
|
+
destructureValCxtES5(gen, opts);
|
|
46108
|
+
gen.code(body);
|
|
46174
46109
|
});
|
|
46175
|
-
|
|
46176
|
-
|
|
46177
|
-
|
|
46178
|
-
|
|
46179
|
-
|
|
46180
|
-
|
|
46181
|
-
|
|
46182
|
-
|
|
46183
|
-
|
|
46184
|
-
|
|
46185
|
-
|
|
46186
|
-
|
|
46187
|
-
|
|
46188
|
-
if (
|
|
46189
|
-
|
|
46190
|
-
|
|
46191
|
-
|
|
46192
|
-
|
|
46193
|
-
|
|
46194
|
-
|
|
46195
|
-
(
|
|
46196
|
-
|
|
46197
|
-
|
|
46198
|
-
|
|
46199
|
-
|
|
46200
|
-
|
|
46201
|
-
|
|
46202
|
-
return true;
|
|
46203
|
-
return false;
|
|
46204
|
-
}
|
|
46205
|
-
function isSchemaObj(it) {
|
|
46206
|
-
return typeof it.schema != "boolean";
|
|
46207
|
-
}
|
|
46208
|
-
function subSchemaObjCode(it, valid) {
|
|
46209
|
-
const { schema, gen, opts } = it;
|
|
46110
|
+
} else {
|
|
46111
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
46112
|
+
}
|
|
46113
|
+
}
|
|
46114
|
+
function destructureValCxt(opts) {
|
|
46115
|
+
return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
|
|
46116
|
+
}
|
|
46117
|
+
function destructureValCxtES5(gen, opts) {
|
|
46118
|
+
gen.if(names_1$3.default.valCxt, () => {
|
|
46119
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
|
|
46120
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
|
|
46121
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
|
|
46122
|
+
gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
|
|
46123
|
+
if (opts.dynamicRef)
|
|
46124
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
|
|
46125
|
+
}, () => {
|
|
46126
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
|
|
46127
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
|
|
46128
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
|
|
46129
|
+
gen.var(names_1$3.default.rootData, names_1$3.default.data);
|
|
46130
|
+
if (opts.dynamicRef)
|
|
46131
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
|
|
46132
|
+
});
|
|
46133
|
+
}
|
|
46134
|
+
function topSchemaObjCode(it) {
|
|
46135
|
+
const { schema, opts, gen } = it;
|
|
46136
|
+
validateFunction(it, () => {
|
|
46210
46137
|
if (opts.$comment && schema.$comment)
|
|
46211
46138
|
commentKeyword(it);
|
|
46212
|
-
|
|
46213
|
-
|
|
46214
|
-
|
|
46215
|
-
|
|
46216
|
-
|
|
46217
|
-
|
|
46218
|
-
|
|
46219
|
-
|
|
46220
|
-
|
|
46221
|
-
|
|
46222
|
-
|
|
46223
|
-
|
|
46224
|
-
|
|
46225
|
-
|
|
46226
|
-
|
|
46227
|
-
|
|
46228
|
-
|
|
46229
|
-
|
|
46230
|
-
|
|
46231
|
-
|
|
46232
|
-
|
|
46233
|
-
|
|
46234
|
-
|
|
46235
|
-
|
|
46236
|
-
|
|
46237
|
-
|
|
46238
|
-
(0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
|
|
46139
|
+
checkNoDefault(it);
|
|
46140
|
+
gen.let(names_1$3.default.vErrors, null);
|
|
46141
|
+
gen.let(names_1$3.default.errors, 0);
|
|
46142
|
+
if (opts.unevaluated)
|
|
46143
|
+
resetEvaluated(it);
|
|
46144
|
+
typeAndKeywords(it);
|
|
46145
|
+
returnResults(it);
|
|
46146
|
+
});
|
|
46147
|
+
return;
|
|
46148
|
+
}
|
|
46149
|
+
function resetEvaluated(it) {
|
|
46150
|
+
const { gen, validateName } = it;
|
|
46151
|
+
it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
|
|
46152
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
|
|
46153
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
|
|
46154
|
+
}
|
|
46155
|
+
function funcSourceUrl(schema, opts) {
|
|
46156
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
46157
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
|
|
46158
|
+
}
|
|
46159
|
+
function subschemaCode(it, valid) {
|
|
46160
|
+
if (isSchemaObj(it)) {
|
|
46161
|
+
checkKeywords(it);
|
|
46162
|
+
if (schemaCxtHasRules(it)) {
|
|
46163
|
+
subSchemaObjCode(it, valid);
|
|
46164
|
+
return;
|
|
46239
46165
|
}
|
|
46240
46166
|
}
|
|
46241
|
-
|
|
46242
|
-
|
|
46243
|
-
|
|
46244
|
-
|
|
46245
|
-
|
|
46246
|
-
|
|
46247
|
-
if (
|
|
46248
|
-
|
|
46249
|
-
|
|
46250
|
-
|
|
46251
|
-
|
|
46252
|
-
|
|
46253
|
-
|
|
46254
|
-
|
|
46255
|
-
|
|
46256
|
-
|
|
46257
|
-
|
|
46258
|
-
|
|
46167
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
46168
|
+
}
|
|
46169
|
+
function schemaCxtHasRules({ schema, self }) {
|
|
46170
|
+
if (typeof schema == "boolean")
|
|
46171
|
+
return !schema;
|
|
46172
|
+
for (const key in schema)
|
|
46173
|
+
if (self.RULES.all[key])
|
|
46174
|
+
return true;
|
|
46175
|
+
return false;
|
|
46176
|
+
}
|
|
46177
|
+
function isSchemaObj(it) {
|
|
46178
|
+
return typeof it.schema != "boolean";
|
|
46179
|
+
}
|
|
46180
|
+
function subSchemaObjCode(it, valid) {
|
|
46181
|
+
const { schema, gen, opts } = it;
|
|
46182
|
+
if (opts.$comment && schema.$comment)
|
|
46183
|
+
commentKeyword(it);
|
|
46184
|
+
updateContext(it);
|
|
46185
|
+
checkAsyncSchema(it);
|
|
46186
|
+
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
46187
|
+
typeAndKeywords(it, errsCount);
|
|
46188
|
+
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
46189
|
+
}
|
|
46190
|
+
function checkKeywords(it) {
|
|
46191
|
+
(0, util_1$m.checkUnknownRules)(it);
|
|
46192
|
+
checkRefsAndKeywords(it);
|
|
46193
|
+
}
|
|
46194
|
+
function typeAndKeywords(it, errsCount) {
|
|
46195
|
+
if (it.opts.jtd)
|
|
46196
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
46197
|
+
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
46198
|
+
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
46199
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
46200
|
+
}
|
|
46201
|
+
function checkRefsAndKeywords(it) {
|
|
46202
|
+
const { schema, errSchemaPath, opts, self } = it;
|
|
46203
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
|
|
46204
|
+
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
46205
|
+
}
|
|
46206
|
+
}
|
|
46207
|
+
function checkNoDefault(it) {
|
|
46208
|
+
const { schema, opts } = it;
|
|
46209
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
46210
|
+
(0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
|
|
46211
|
+
}
|
|
46212
|
+
}
|
|
46213
|
+
function updateContext(it) {
|
|
46214
|
+
const schId = it.schema[it.opts.schemaId];
|
|
46215
|
+
if (schId)
|
|
46216
|
+
it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
46217
|
+
}
|
|
46218
|
+
function checkAsyncSchema(it) {
|
|
46219
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
46220
|
+
throw new Error("async schema in sync schema");
|
|
46221
|
+
}
|
|
46222
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
46223
|
+
const msg = schema.$comment;
|
|
46224
|
+
if (opts.$comment === true) {
|
|
46225
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
46226
|
+
} else if (typeof opts.$comment == "function") {
|
|
46227
|
+
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
46228
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
46229
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
46230
|
+
}
|
|
46231
|
+
}
|
|
46232
|
+
function returnResults(it) {
|
|
46233
|
+
const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
|
|
46234
|
+
if (schemaEnv.$async) {
|
|
46235
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError2}(${names_1$3.default.vErrors})`));
|
|
46236
|
+
} else {
|
|
46237
|
+
gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
|
|
46238
|
+
if (opts.unevaluated)
|
|
46239
|
+
assignEvaluated(it);
|
|
46240
|
+
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
46241
|
+
}
|
|
46242
|
+
}
|
|
46243
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
46244
|
+
if (props instanceof codegen_1$n.Name)
|
|
46245
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
|
|
46246
|
+
if (items2 instanceof codegen_1$n.Name)
|
|
46247
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
46248
|
+
}
|
|
46249
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
46250
|
+
const { gen, schema, data, allErrors, opts, self } = it;
|
|
46251
|
+
const { RULES } = self;
|
|
46252
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
|
|
46253
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
46254
|
+
return;
|
|
46259
46255
|
}
|
|
46260
|
-
|
|
46261
|
-
|
|
46262
|
-
|
|
46263
|
-
|
|
46264
|
-
|
|
46265
|
-
|
|
46266
|
-
|
|
46267
|
-
|
|
46268
|
-
|
|
46269
|
-
}
|
|
46270
|
-
}
|
|
46271
|
-
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
46272
|
-
if (props instanceof codegen_12.Name)
|
|
46273
|
-
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
46274
|
-
if (items2 instanceof codegen_12.Name)
|
|
46275
|
-
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
46276
|
-
}
|
|
46277
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
46278
|
-
const { gen, schema, data, allErrors, opts, self } = it;
|
|
46279
|
-
const { RULES } = self;
|
|
46280
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
46281
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
46256
|
+
if (!opts.jtd)
|
|
46257
|
+
checkStrictTypes(it, types2);
|
|
46258
|
+
gen.block(() => {
|
|
46259
|
+
for (const group of RULES.rules)
|
|
46260
|
+
groupKeywords(group);
|
|
46261
|
+
groupKeywords(RULES.post);
|
|
46262
|
+
});
|
|
46263
|
+
function groupKeywords(group) {
|
|
46264
|
+
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
46282
46265
|
return;
|
|
46283
|
-
|
|
46284
|
-
|
|
46285
|
-
|
|
46286
|
-
|
|
46287
|
-
|
|
46288
|
-
|
|
46289
|
-
groupKeywords(RULES.post);
|
|
46290
|
-
});
|
|
46291
|
-
function groupKeywords(group) {
|
|
46292
|
-
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
46293
|
-
return;
|
|
46294
|
-
if (group.type) {
|
|
46295
|
-
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
46296
|
-
iterateKeywords(it, group);
|
|
46297
|
-
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
46298
|
-
gen.else();
|
|
46299
|
-
(0, dataType_2.reportTypeError)(it);
|
|
46300
|
-
}
|
|
46301
|
-
gen.endIf();
|
|
46302
|
-
} else {
|
|
46303
|
-
iterateKeywords(it, group);
|
|
46266
|
+
if (group.type) {
|
|
46267
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
46268
|
+
iterateKeywords(it, group);
|
|
46269
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
46270
|
+
gen.else();
|
|
46271
|
+
(0, dataType_2.reportTypeError)(it);
|
|
46304
46272
|
}
|
|
46305
|
-
|
|
46306
|
-
|
|
46273
|
+
gen.endIf();
|
|
46274
|
+
} else {
|
|
46275
|
+
iterateKeywords(it, group);
|
|
46307
46276
|
}
|
|
46277
|
+
if (!allErrors)
|
|
46278
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
46308
46279
|
}
|
|
46309
|
-
|
|
46310
|
-
|
|
46311
|
-
|
|
46312
|
-
|
|
46313
|
-
|
|
46314
|
-
|
|
46315
|
-
|
|
46316
|
-
|
|
46317
|
-
|
|
46318
|
-
}
|
|
46319
|
-
});
|
|
46320
|
-
}
|
|
46321
|
-
function checkStrictTypes(it, types2) {
|
|
46322
|
-
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
46323
|
-
return;
|
|
46324
|
-
checkContextTypes(it, types2);
|
|
46325
|
-
if (!it.opts.allowUnionTypes)
|
|
46326
|
-
checkMultipleTypes(it, types2);
|
|
46327
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
46328
|
-
}
|
|
46329
|
-
function checkContextTypes(it, types2) {
|
|
46330
|
-
if (!types2.length)
|
|
46331
|
-
return;
|
|
46332
|
-
if (!it.dataTypes.length) {
|
|
46333
|
-
it.dataTypes = types2;
|
|
46334
|
-
return;
|
|
46335
|
-
}
|
|
46336
|
-
types2.forEach((t2) => {
|
|
46337
|
-
if (!includesType(it.dataTypes, t2)) {
|
|
46338
|
-
strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
46339
|
-
}
|
|
46340
|
-
});
|
|
46341
|
-
narrowSchemaTypes(it, types2);
|
|
46342
|
-
}
|
|
46343
|
-
function checkMultipleTypes(it, ts) {
|
|
46344
|
-
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
46345
|
-
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
46346
|
-
}
|
|
46347
|
-
}
|
|
46348
|
-
function checkKeywordTypes(it, ts) {
|
|
46349
|
-
const rules2 = it.self.RULES.all;
|
|
46350
|
-
for (const keyword2 in rules2) {
|
|
46351
|
-
const rule = rules2[keyword2];
|
|
46352
|
-
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
46353
|
-
const { type: type2 } = rule.definition;
|
|
46354
|
-
if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
|
|
46355
|
-
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
46356
|
-
}
|
|
46357
|
-
}
|
|
46358
|
-
}
|
|
46359
|
-
}
|
|
46360
|
-
function hasApplicableType(schTs, kwdT) {
|
|
46361
|
-
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
46362
|
-
}
|
|
46363
|
-
function includesType(ts, t2) {
|
|
46364
|
-
return ts.includes(t2) || t2 === "integer" && ts.includes("number");
|
|
46365
|
-
}
|
|
46366
|
-
function narrowSchemaTypes(it, withTypes) {
|
|
46367
|
-
const ts = [];
|
|
46368
|
-
for (const t2 of it.dataTypes) {
|
|
46369
|
-
if (includesType(withTypes, t2))
|
|
46370
|
-
ts.push(t2);
|
|
46371
|
-
else if (withTypes.includes("integer") && t2 === "number")
|
|
46372
|
-
ts.push("integer");
|
|
46373
|
-
}
|
|
46374
|
-
it.dataTypes = ts;
|
|
46375
|
-
}
|
|
46376
|
-
function strictTypesError(it, msg) {
|
|
46377
|
-
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
46378
|
-
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
46379
|
-
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
46380
|
-
}
|
|
46381
|
-
class KeywordCxt {
|
|
46382
|
-
constructor(it, def2, keyword2) {
|
|
46383
|
-
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
46384
|
-
this.gen = it.gen;
|
|
46385
|
-
this.allErrors = it.allErrors;
|
|
46386
|
-
this.keyword = keyword2;
|
|
46387
|
-
this.data = it.data;
|
|
46388
|
-
this.schema = it.schema[keyword2];
|
|
46389
|
-
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
46390
|
-
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
46391
|
-
this.schemaType = def2.schemaType;
|
|
46392
|
-
this.parentSchema = it.schema;
|
|
46393
|
-
this.params = {};
|
|
46394
|
-
this.it = it;
|
|
46395
|
-
this.def = def2;
|
|
46396
|
-
if (this.$data) {
|
|
46397
|
-
this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
|
|
46398
|
-
} else {
|
|
46399
|
-
this.schemaCode = this.schemaValue;
|
|
46400
|
-
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
46401
|
-
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
46402
|
-
}
|
|
46403
|
-
}
|
|
46404
|
-
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
46405
|
-
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
46280
|
+
}
|
|
46281
|
+
function iterateKeywords(it, group) {
|
|
46282
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
46283
|
+
if (useDefaults)
|
|
46284
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
46285
|
+
gen.block(() => {
|
|
46286
|
+
for (const rule of group.rules) {
|
|
46287
|
+
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
|
46288
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
46406
46289
|
}
|
|
46407
46290
|
}
|
|
46408
|
-
|
|
46409
|
-
|
|
46291
|
+
});
|
|
46292
|
+
}
|
|
46293
|
+
function checkStrictTypes(it, types2) {
|
|
46294
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
46295
|
+
return;
|
|
46296
|
+
checkContextTypes(it, types2);
|
|
46297
|
+
if (!it.opts.allowUnionTypes)
|
|
46298
|
+
checkMultipleTypes(it, types2);
|
|
46299
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
46300
|
+
}
|
|
46301
|
+
function checkContextTypes(it, types2) {
|
|
46302
|
+
if (!types2.length)
|
|
46303
|
+
return;
|
|
46304
|
+
if (!it.dataTypes.length) {
|
|
46305
|
+
it.dataTypes = types2;
|
|
46306
|
+
return;
|
|
46307
|
+
}
|
|
46308
|
+
types2.forEach((t2) => {
|
|
46309
|
+
if (!includesType(it.dataTypes, t2)) {
|
|
46310
|
+
strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
46410
46311
|
}
|
|
46411
|
-
|
|
46412
|
-
|
|
46413
|
-
|
|
46414
|
-
|
|
46415
|
-
|
|
46416
|
-
|
|
46417
|
-
|
|
46418
|
-
|
|
46419
|
-
|
|
46420
|
-
|
|
46421
|
-
|
|
46422
|
-
|
|
46423
|
-
|
|
46424
|
-
|
|
46425
|
-
|
|
46426
|
-
|
|
46312
|
+
});
|
|
46313
|
+
narrowSchemaTypes(it, types2);
|
|
46314
|
+
}
|
|
46315
|
+
function checkMultipleTypes(it, ts) {
|
|
46316
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
46317
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
46318
|
+
}
|
|
46319
|
+
}
|
|
46320
|
+
function checkKeywordTypes(it, ts) {
|
|
46321
|
+
const rules2 = it.self.RULES.all;
|
|
46322
|
+
for (const keyword2 in rules2) {
|
|
46323
|
+
const rule = rules2[keyword2];
|
|
46324
|
+
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
|
46325
|
+
const { type: type2 } = rule.definition;
|
|
46326
|
+
if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
|
|
46327
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
46328
|
+
}
|
|
46329
|
+
}
|
|
46330
|
+
}
|
|
46331
|
+
}
|
|
46332
|
+
function hasApplicableType(schTs, kwdT) {
|
|
46333
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
46334
|
+
}
|
|
46335
|
+
function includesType(ts, t2) {
|
|
46336
|
+
return ts.includes(t2) || t2 === "integer" && ts.includes("number");
|
|
46337
|
+
}
|
|
46338
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
46339
|
+
const ts = [];
|
|
46340
|
+
for (const t2 of it.dataTypes) {
|
|
46341
|
+
if (includesType(withTypes, t2))
|
|
46342
|
+
ts.push(t2);
|
|
46343
|
+
else if (withTypes.includes("integer") && t2 === "number")
|
|
46344
|
+
ts.push("integer");
|
|
46345
|
+
}
|
|
46346
|
+
it.dataTypes = ts;
|
|
46347
|
+
}
|
|
46348
|
+
function strictTypesError(it, msg) {
|
|
46349
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
46350
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
46351
|
+
(0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
46352
|
+
}
|
|
46353
|
+
class KeywordCxt {
|
|
46354
|
+
constructor(it, def2, keyword2) {
|
|
46355
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
46356
|
+
this.gen = it.gen;
|
|
46357
|
+
this.allErrors = it.allErrors;
|
|
46358
|
+
this.keyword = keyword2;
|
|
46359
|
+
this.data = it.data;
|
|
46360
|
+
this.schema = it.schema[keyword2];
|
|
46361
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
46362
|
+
this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
46363
|
+
this.schemaType = def2.schemaType;
|
|
46364
|
+
this.parentSchema = it.schema;
|
|
46365
|
+
this.params = {};
|
|
46366
|
+
this.it = it;
|
|
46367
|
+
this.def = def2;
|
|
46368
|
+
if (this.$data) {
|
|
46369
|
+
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
46370
|
+
} else {
|
|
46371
|
+
this.schemaCode = this.schemaValue;
|
|
46372
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
46373
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
46427
46374
|
}
|
|
46428
46375
|
}
|
|
46429
|
-
|
|
46430
|
-
this.
|
|
46376
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
46377
|
+
this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
|
|
46431
46378
|
}
|
|
46432
|
-
|
|
46433
|
-
|
|
46434
|
-
|
|
46435
|
-
|
|
46436
|
-
|
|
46437
|
-
|
|
46438
|
-
|
|
46439
|
-
|
|
46379
|
+
}
|
|
46380
|
+
result(condition, successAction, failAction) {
|
|
46381
|
+
this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
|
|
46382
|
+
}
|
|
46383
|
+
failResult(condition, successAction, failAction) {
|
|
46384
|
+
this.gen.if(condition);
|
|
46385
|
+
if (failAction)
|
|
46386
|
+
failAction();
|
|
46387
|
+
else
|
|
46440
46388
|
this.error();
|
|
46389
|
+
if (successAction) {
|
|
46390
|
+
this.gen.else();
|
|
46391
|
+
successAction();
|
|
46392
|
+
if (this.allErrors)
|
|
46393
|
+
this.gen.endIf();
|
|
46394
|
+
} else {
|
|
46441
46395
|
if (this.allErrors)
|
|
46442
46396
|
this.gen.endIf();
|
|
46443
46397
|
else
|
|
46444
46398
|
this.gen.else();
|
|
46445
46399
|
}
|
|
46446
|
-
|
|
46447
|
-
|
|
46448
|
-
|
|
46449
|
-
|
|
46450
|
-
|
|
46451
|
-
|
|
46452
|
-
|
|
46453
|
-
if (errorParams) {
|
|
46454
|
-
this.setParams(errorParams);
|
|
46455
|
-
this._error(append, errorPaths);
|
|
46456
|
-
this.setParams({});
|
|
46457
|
-
return;
|
|
46458
|
-
}
|
|
46459
|
-
this._error(append, errorPaths);
|
|
46460
|
-
}
|
|
46461
|
-
_error(append, errorPaths) {
|
|
46462
|
-
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
46463
|
-
}
|
|
46464
|
-
$dataError() {
|
|
46465
|
-
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
46466
|
-
}
|
|
46467
|
-
reset() {
|
|
46468
|
-
if (this.errsCount === void 0)
|
|
46469
|
-
throw new Error('add "trackErrors" to keyword definition');
|
|
46470
|
-
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
46471
|
-
}
|
|
46472
|
-
ok(cond) {
|
|
46400
|
+
}
|
|
46401
|
+
pass(condition, failAction) {
|
|
46402
|
+
this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
|
|
46403
|
+
}
|
|
46404
|
+
fail(condition) {
|
|
46405
|
+
if (condition === void 0) {
|
|
46406
|
+
this.error();
|
|
46473
46407
|
if (!this.allErrors)
|
|
46474
|
-
this.gen.if(
|
|
46475
|
-
|
|
46476
|
-
setParams(obj, assign2) {
|
|
46477
|
-
if (assign2)
|
|
46478
|
-
Object.assign(this.params, obj);
|
|
46479
|
-
else
|
|
46480
|
-
this.params = obj;
|
|
46408
|
+
this.gen.if(false);
|
|
46409
|
+
return;
|
|
46481
46410
|
}
|
|
46482
|
-
|
|
46483
|
-
|
|
46484
|
-
|
|
46485
|
-
|
|
46486
|
-
|
|
46411
|
+
this.gen.if(condition);
|
|
46412
|
+
this.error();
|
|
46413
|
+
if (this.allErrors)
|
|
46414
|
+
this.gen.endIf();
|
|
46415
|
+
else
|
|
46416
|
+
this.gen.else();
|
|
46417
|
+
}
|
|
46418
|
+
fail$data(condition) {
|
|
46419
|
+
if (!this.$data)
|
|
46420
|
+
return this.fail(condition);
|
|
46421
|
+
const { schemaCode } = this;
|
|
46422
|
+
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
46423
|
+
}
|
|
46424
|
+
error(append, errorParams, errorPaths) {
|
|
46425
|
+
if (errorParams) {
|
|
46426
|
+
this.setParams(errorParams);
|
|
46427
|
+
this._error(append, errorPaths);
|
|
46428
|
+
this.setParams({});
|
|
46429
|
+
return;
|
|
46487
46430
|
}
|
|
46488
|
-
|
|
46489
|
-
|
|
46490
|
-
|
|
46491
|
-
|
|
46492
|
-
|
|
46493
|
-
|
|
46494
|
-
|
|
46495
|
-
|
|
46496
|
-
|
|
46497
|
-
|
|
46498
|
-
|
|
46499
|
-
|
|
46500
|
-
|
|
46501
|
-
|
|
46431
|
+
this._error(append, errorPaths);
|
|
46432
|
+
}
|
|
46433
|
+
_error(append, errorPaths) {
|
|
46434
|
+
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
46435
|
+
}
|
|
46436
|
+
$dataError() {
|
|
46437
|
+
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
46438
|
+
}
|
|
46439
|
+
reset() {
|
|
46440
|
+
if (this.errsCount === void 0)
|
|
46441
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
46442
|
+
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
46443
|
+
}
|
|
46444
|
+
ok(cond) {
|
|
46445
|
+
if (!this.allErrors)
|
|
46446
|
+
this.gen.if(cond);
|
|
46447
|
+
}
|
|
46448
|
+
setParams(obj, assign2) {
|
|
46449
|
+
if (assign2)
|
|
46450
|
+
Object.assign(this.params, obj);
|
|
46451
|
+
else
|
|
46452
|
+
this.params = obj;
|
|
46453
|
+
}
|
|
46454
|
+
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
46455
|
+
this.gen.block(() => {
|
|
46456
|
+
this.check$data(valid, $dataValid);
|
|
46457
|
+
codeBlock();
|
|
46458
|
+
});
|
|
46459
|
+
}
|
|
46460
|
+
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
46461
|
+
if (!this.$data)
|
|
46462
|
+
return;
|
|
46463
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
46464
|
+
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
46465
|
+
if (valid !== codegen_1$n.nil)
|
|
46466
|
+
gen.assign(valid, true);
|
|
46467
|
+
if (schemaType.length || def2.validateSchema) {
|
|
46468
|
+
gen.elseIf(this.invalid$data());
|
|
46469
|
+
this.$dataError();
|
|
46470
|
+
if (valid !== codegen_1$n.nil)
|
|
46471
|
+
gen.assign(valid, false);
|
|
46502
46472
|
}
|
|
46503
|
-
|
|
46504
|
-
|
|
46505
|
-
|
|
46506
|
-
|
|
46507
|
-
|
|
46508
|
-
|
|
46509
|
-
|
|
46510
|
-
|
|
46511
|
-
|
|
46512
|
-
|
|
46513
|
-
return
|
|
46514
|
-
}
|
|
46515
|
-
function invalid$DataSchema() {
|
|
46516
|
-
if (def2.validateSchema) {
|
|
46517
|
-
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
46518
|
-
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
46519
|
-
}
|
|
46520
|
-
return codegen_12.nil;
|
|
46521
|
-
}
|
|
46522
|
-
}
|
|
46523
|
-
subschema(appl, valid) {
|
|
46524
|
-
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
46525
|
-
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
46526
|
-
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
46527
|
-
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
46528
|
-
subschemaCode(nextContext, valid);
|
|
46529
|
-
return nextContext;
|
|
46530
|
-
}
|
|
46531
|
-
mergeEvaluated(schemaCxt, toName) {
|
|
46532
|
-
const { it, gen } = this;
|
|
46533
|
-
if (!it.opts.unevaluated)
|
|
46534
|
-
return;
|
|
46535
|
-
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
46536
|
-
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
46537
|
-
}
|
|
46538
|
-
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
46539
|
-
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
46473
|
+
gen.else();
|
|
46474
|
+
}
|
|
46475
|
+
invalid$data() {
|
|
46476
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
46477
|
+
return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
|
|
46478
|
+
function wrong$DataType() {
|
|
46479
|
+
if (schemaType.length) {
|
|
46480
|
+
if (!(schemaCode instanceof codegen_1$n.Name))
|
|
46481
|
+
throw new Error("ajv implementation error");
|
|
46482
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
46483
|
+
return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
46540
46484
|
}
|
|
46485
|
+
return codegen_1$n.nil;
|
|
46541
46486
|
}
|
|
46542
|
-
|
|
46543
|
-
|
|
46544
|
-
|
|
46545
|
-
|
|
46546
|
-
return true;
|
|
46487
|
+
function invalid$DataSchema() {
|
|
46488
|
+
if (def2.validateSchema) {
|
|
46489
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
46490
|
+
return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
|
|
46547
46491
|
}
|
|
46492
|
+
return codegen_1$n.nil;
|
|
46548
46493
|
}
|
|
46549
46494
|
}
|
|
46550
|
-
|
|
46551
|
-
|
|
46552
|
-
|
|
46553
|
-
|
|
46554
|
-
|
|
46555
|
-
|
|
46556
|
-
|
|
46557
|
-
|
|
46558
|
-
|
|
46559
|
-
|
|
46560
|
-
|
|
46495
|
+
subschema(appl, valid) {
|
|
46496
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
46497
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
46498
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
46499
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
46500
|
+
subschemaCode(nextContext, valid);
|
|
46501
|
+
return nextContext;
|
|
46502
|
+
}
|
|
46503
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
46504
|
+
const { it, gen } = this;
|
|
46505
|
+
if (!it.opts.unevaluated)
|
|
46506
|
+
return;
|
|
46507
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
46508
|
+
it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
46509
|
+
}
|
|
46510
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
46511
|
+
it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
46561
46512
|
}
|
|
46562
46513
|
}
|
|
46563
|
-
|
|
46564
|
-
|
|
46565
|
-
|
|
46566
|
-
|
|
46567
|
-
|
|
46568
|
-
if ($data === "")
|
|
46569
|
-
return names_12.default.rootData;
|
|
46570
|
-
if ($data[0] === "/") {
|
|
46571
|
-
if (!JSON_POINTER.test($data))
|
|
46572
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
46573
|
-
jsonPointer = $data;
|
|
46574
|
-
data = names_12.default.rootData;
|
|
46575
|
-
} else {
|
|
46576
|
-
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
46577
|
-
if (!matches)
|
|
46578
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
46579
|
-
const up = +matches[1];
|
|
46580
|
-
jsonPointer = matches[2];
|
|
46581
|
-
if (jsonPointer === "#") {
|
|
46582
|
-
if (up >= dataLevel)
|
|
46583
|
-
throw new Error(errorMsg("property/index", up));
|
|
46584
|
-
return dataPathArr[dataLevel - up];
|
|
46585
|
-
}
|
|
46586
|
-
if (up > dataLevel)
|
|
46587
|
-
throw new Error(errorMsg("data", up));
|
|
46588
|
-
data = dataNames[dataLevel - up];
|
|
46589
|
-
if (!jsonPointer)
|
|
46590
|
-
return data;
|
|
46591
|
-
}
|
|
46592
|
-
let expr = data;
|
|
46593
|
-
const segments = jsonPointer.split("/");
|
|
46594
|
-
for (const segment of segments) {
|
|
46595
|
-
if (segment) {
|
|
46596
|
-
data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
|
|
46597
|
-
expr = (0, codegen_12._)`${expr} && ${data}`;
|
|
46598
|
-
}
|
|
46514
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
46515
|
+
const { it, gen } = this;
|
|
46516
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
46517
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
|
|
46518
|
+
return true;
|
|
46599
46519
|
}
|
|
46600
|
-
|
|
46601
|
-
|
|
46602
|
-
|
|
46520
|
+
}
|
|
46521
|
+
}
|
|
46522
|
+
validate.KeywordCxt = KeywordCxt;
|
|
46523
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
46524
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
46525
|
+
if ("code" in def2) {
|
|
46526
|
+
def2.code(cxt, ruleType);
|
|
46527
|
+
} else if (cxt.$data && def2.validate) {
|
|
46528
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
46529
|
+
} else if ("macro" in def2) {
|
|
46530
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
46531
|
+
} else if (def2.compile || def2.validate) {
|
|
46532
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
46533
|
+
}
|
|
46534
|
+
}
|
|
46535
|
+
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
46536
|
+
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
46537
|
+
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
46538
|
+
let jsonPointer;
|
|
46539
|
+
let data;
|
|
46540
|
+
if ($data === "")
|
|
46541
|
+
return names_1$3.default.rootData;
|
|
46542
|
+
if ($data[0] === "/") {
|
|
46543
|
+
if (!JSON_POINTER.test($data))
|
|
46544
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
46545
|
+
jsonPointer = $data;
|
|
46546
|
+
data = names_1$3.default.rootData;
|
|
46547
|
+
} else {
|
|
46548
|
+
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
46549
|
+
if (!matches)
|
|
46550
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
46551
|
+
const up = +matches[1];
|
|
46552
|
+
jsonPointer = matches[2];
|
|
46553
|
+
if (jsonPointer === "#") {
|
|
46554
|
+
if (up >= dataLevel)
|
|
46555
|
+
throw new Error(errorMsg("property/index", up));
|
|
46556
|
+
return dataPathArr[dataLevel - up];
|
|
46557
|
+
}
|
|
46558
|
+
if (up > dataLevel)
|
|
46559
|
+
throw new Error(errorMsg("data", up));
|
|
46560
|
+
data = dataNames[dataLevel - up];
|
|
46561
|
+
if (!jsonPointer)
|
|
46562
|
+
return data;
|
|
46563
|
+
}
|
|
46564
|
+
let expr = data;
|
|
46565
|
+
const segments = jsonPointer.split("/");
|
|
46566
|
+
for (const segment of segments) {
|
|
46567
|
+
if (segment) {
|
|
46568
|
+
data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
|
|
46569
|
+
expr = (0, codegen_1$n._)`${expr} && ${data}`;
|
|
46603
46570
|
}
|
|
46604
46571
|
}
|
|
46605
|
-
|
|
46606
|
-
|
|
46572
|
+
return expr;
|
|
46573
|
+
function errorMsg(pointerType, up) {
|
|
46574
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
46575
|
+
}
|
|
46607
46576
|
}
|
|
46577
|
+
validate.getData = getData;
|
|
46608
46578
|
var validation_error = {};
|
|
46609
|
-
|
|
46610
|
-
|
|
46611
|
-
|
|
46612
|
-
|
|
46613
|
-
|
|
46614
|
-
|
|
46615
|
-
constructor(errors2) {
|
|
46616
|
-
super("validation failed");
|
|
46617
|
-
this.errors = errors2;
|
|
46618
|
-
this.ajv = this.validation = true;
|
|
46619
|
-
}
|
|
46579
|
+
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
46580
|
+
class ValidationError extends Error {
|
|
46581
|
+
constructor(errors2) {
|
|
46582
|
+
super("validation failed");
|
|
46583
|
+
this.errors = errors2;
|
|
46584
|
+
this.ajv = this.validation = true;
|
|
46620
46585
|
}
|
|
46621
|
-
validation_error.default = ValidationError;
|
|
46622
|
-
return validation_error;
|
|
46623
46586
|
}
|
|
46587
|
+
validation_error.default = ValidationError;
|
|
46624
46588
|
var ref_error = {};
|
|
46625
46589
|
Object.defineProperty(ref_error, "__esModule", { value: true });
|
|
46626
46590
|
const resolve_1$1 = resolve$2;
|
|
@@ -46636,11 +46600,11 @@ var compile = {};
|
|
|
46636
46600
|
Object.defineProperty(compile, "__esModule", { value: true });
|
|
46637
46601
|
compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
|
|
46638
46602
|
const codegen_1$m = codegen;
|
|
46639
|
-
const validation_error_1 =
|
|
46603
|
+
const validation_error_1 = validation_error;
|
|
46640
46604
|
const names_1$2 = names$1;
|
|
46641
46605
|
const resolve_1 = resolve$2;
|
|
46642
46606
|
const util_1$l = util;
|
|
46643
|
-
const validate_1$1 =
|
|
46607
|
+
const validate_1$1 = validate;
|
|
46644
46608
|
class SchemaEnv {
|
|
46645
46609
|
constructor(env) {
|
|
46646
46610
|
var _a2;
|
|
@@ -47569,7 +47533,7 @@ uri$1.default = uri;
|
|
|
47569
47533
|
(function(exports$1) {
|
|
47570
47534
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
47571
47535
|
exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
|
|
47572
|
-
var validate_12 =
|
|
47536
|
+
var validate_12 = validate;
|
|
47573
47537
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
47574
47538
|
return validate_12.KeywordCxt;
|
|
47575
47539
|
} });
|
|
@@ -47592,7 +47556,7 @@ uri$1.default = uri;
|
|
|
47592
47556
|
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
47593
47557
|
return codegen_12.CodeGen;
|
|
47594
47558
|
} });
|
|
47595
|
-
const validation_error_12 =
|
|
47559
|
+
const validation_error_12 = validation_error;
|
|
47596
47560
|
const ref_error_12 = ref_error;
|
|
47597
47561
|
const rules_12 = rules;
|
|
47598
47562
|
const compile_12 = compile;
|
|
@@ -49180,7 +49144,7 @@ const def$a = {
|
|
|
49180
49144
|
additionalProperties.default = def$a;
|
|
49181
49145
|
var properties$1 = {};
|
|
49182
49146
|
Object.defineProperty(properties$1, "__esModule", { value: true });
|
|
49183
|
-
const validate_1 =
|
|
49147
|
+
const validate_1 = validate;
|
|
49184
49148
|
const code_1$2 = code;
|
|
49185
49149
|
const util_1$7 = util;
|
|
49186
49150
|
const additionalProperties_1$1 = additionalProperties;
|
|
@@ -50031,7 +49995,7 @@ const require$$3 = {
|
|
|
50031
49995
|
module.exports.Ajv = Ajv2;
|
|
50032
49996
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
50033
49997
|
exports$1.default = Ajv2;
|
|
50034
|
-
var validate_12 =
|
|
49998
|
+
var validate_12 = validate;
|
|
50035
49999
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
50036
50000
|
return validate_12.KeywordCxt;
|
|
50037
50001
|
} });
|
|
@@ -50054,7 +50018,7 @@ const require$$3 = {
|
|
|
50054
50018
|
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
50055
50019
|
return codegen_12.CodeGen;
|
|
50056
50020
|
} });
|
|
50057
|
-
var validation_error_12 =
|
|
50021
|
+
var validation_error_12 = validation_error;
|
|
50058
50022
|
Object.defineProperty(exports$1, "ValidationError", { enumerable: true, get: function() {
|
|
50059
50023
|
return validation_error_12.default;
|
|
50060
50024
|
} });
|
|
@@ -56993,7 +56957,7 @@ function App() {
|
|
|
56993
56957
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#6aa3c8" }, children: "Spector" }),
|
|
56994
56958
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-[10px] font-normal opacity-50", children: [
|
|
56995
56959
|
"v",
|
|
56996
|
-
"0.1.
|
|
56960
|
+
"0.1.8"
|
|
56997
56961
|
] }),
|
|
56998
56962
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mx-2 opacity-30", children: "·" }),
|
|
56999
56963
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|