@testsmith/api-spector 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +180 -39
- package/out/main/runner.js +1 -1
- package/out/renderer/assets/{index-vRsURTUY.js → index-BjjOh-E5.js} +830 -866
- package/out/renderer/index.html +1 -1
- package/package.json +1 -1
- package/readme.md +3 -0
|
@@ -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,
|
|
@@ -57729,8 +57729,8 @@ var scope = {};
|
|
|
57729
57729
|
var util = {};
|
|
57730
57730
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
57731
57731
|
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;
|
|
57732
|
-
const codegen_1$
|
|
57733
|
-
const code_1$
|
|
57732
|
+
const codegen_1$v = codegen;
|
|
57733
|
+
const code_1$a = code$1;
|
|
57734
57734
|
function toHash(arr) {
|
|
57735
57735
|
const hash = {};
|
|
57736
57736
|
for (const item of arr)
|
|
@@ -57783,9 +57783,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
|
|
|
57783
57783
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
57784
57784
|
return schema;
|
|
57785
57785
|
if (typeof schema == "string")
|
|
57786
|
-
return (0, codegen_1$
|
|
57786
|
+
return (0, codegen_1$v._)`${schema}`;
|
|
57787
57787
|
}
|
|
57788
|
-
return (0, codegen_1$
|
|
57788
|
+
return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
|
|
57789
57789
|
}
|
|
57790
57790
|
util.schemaRefOrVal = schemaRefOrVal;
|
|
57791
57791
|
function unescapeFragment(str) {
|
|
@@ -57817,20 +57817,20 @@ function eachItem(xs, f) {
|
|
|
57817
57817
|
util.eachItem = eachItem;
|
|
57818
57818
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
|
|
57819
57819
|
return (gen, from, to, toName) => {
|
|
57820
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
57821
|
-
return toName === codegen_1$
|
|
57820
|
+
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);
|
|
57821
|
+
return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
|
|
57822
57822
|
};
|
|
57823
57823
|
}
|
|
57824
57824
|
util.mergeEvaluated = {
|
|
57825
57825
|
props: makeMergeEvaluated({
|
|
57826
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
57827
|
-
gen.if((0, codegen_1$
|
|
57826
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
|
|
57827
|
+
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})`));
|
|
57828
57828
|
}),
|
|
57829
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
57829
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
|
|
57830
57830
|
if (from === true) {
|
|
57831
57831
|
gen.assign(to, true);
|
|
57832
57832
|
} else {
|
|
57833
|
-
gen.assign(to, (0, codegen_1$
|
|
57833
|
+
gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
|
|
57834
57834
|
setEvaluated(gen, to, from);
|
|
57835
57835
|
}
|
|
57836
57836
|
}),
|
|
@@ -57838,8 +57838,8 @@ util.mergeEvaluated = {
|
|
|
57838
57838
|
resultToName: evaluatedPropsToName
|
|
57839
57839
|
}),
|
|
57840
57840
|
items: makeMergeEvaluated({
|
|
57841
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
57842
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
57841
|
+
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}`)),
|
|
57842
|
+
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}`)),
|
|
57843
57843
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
57844
57844
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
57845
57845
|
})
|
|
@@ -57847,21 +57847,21 @@ util.mergeEvaluated = {
|
|
|
57847
57847
|
function evaluatedPropsToName(gen, ps) {
|
|
57848
57848
|
if (ps === true)
|
|
57849
57849
|
return gen.var("props", true);
|
|
57850
|
-
const props = gen.var("props", (0, codegen_1$
|
|
57850
|
+
const props = gen.var("props", (0, codegen_1$v._)`{}`);
|
|
57851
57851
|
if (ps !== void 0)
|
|
57852
57852
|
setEvaluated(gen, props, ps);
|
|
57853
57853
|
return props;
|
|
57854
57854
|
}
|
|
57855
57855
|
util.evaluatedPropsToName = evaluatedPropsToName;
|
|
57856
57856
|
function setEvaluated(gen, props, ps) {
|
|
57857
|
-
Object.keys(ps).forEach((p2) => gen.assign((0, codegen_1$
|
|
57857
|
+
Object.keys(ps).forEach((p2) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p2)}`, true));
|
|
57858
57858
|
}
|
|
57859
57859
|
util.setEvaluated = setEvaluated;
|
|
57860
57860
|
const snippets = {};
|
|
57861
57861
|
function useFunc(gen, f) {
|
|
57862
57862
|
return gen.scopeValue("func", {
|
|
57863
57863
|
ref: f,
|
|
57864
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
57864
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
|
|
57865
57865
|
});
|
|
57866
57866
|
}
|
|
57867
57867
|
util.useFunc = useFunc;
|
|
@@ -57871,11 +57871,11 @@ var Type;
|
|
|
57871
57871
|
Type2[Type2["Str"] = 1] = "Str";
|
|
57872
57872
|
})(Type || (util.Type = Type = {}));
|
|
57873
57873
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
57874
|
-
if (dataProp instanceof codegen_1$
|
|
57874
|
+
if (dataProp instanceof codegen_1$v.Name) {
|
|
57875
57875
|
const isNumber = dataPropType === Type.Num;
|
|
57876
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
57876
|
+
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")`;
|
|
57877
57877
|
}
|
|
57878
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
57878
|
+
return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
|
57879
57879
|
}
|
|
57880
57880
|
util.getErrorPath = getErrorPath;
|
|
57881
57881
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -57889,35 +57889,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
|
57889
57889
|
util.checkStrictMode = checkStrictMode;
|
|
57890
57890
|
var names$1 = {};
|
|
57891
57891
|
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
57892
|
-
const codegen_1$
|
|
57892
|
+
const codegen_1$u = codegen;
|
|
57893
57893
|
const names = {
|
|
57894
57894
|
// validation function arguments
|
|
57895
|
-
data: new codegen_1$
|
|
57895
|
+
data: new codegen_1$u.Name("data"),
|
|
57896
57896
|
// data passed to validation function
|
|
57897
57897
|
// args passed from referencing schema
|
|
57898
|
-
valCxt: new codegen_1$
|
|
57898
|
+
valCxt: new codegen_1$u.Name("valCxt"),
|
|
57899
57899
|
// validation/data context - should not be used directly, it is destructured to the names below
|
|
57900
|
-
instancePath: new codegen_1$
|
|
57901
|
-
parentData: new codegen_1$
|
|
57902
|
-
parentDataProperty: new codegen_1$
|
|
57903
|
-
rootData: new codegen_1$
|
|
57900
|
+
instancePath: new codegen_1$u.Name("instancePath"),
|
|
57901
|
+
parentData: new codegen_1$u.Name("parentData"),
|
|
57902
|
+
parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
|
|
57903
|
+
rootData: new codegen_1$u.Name("rootData"),
|
|
57904
57904
|
// root data - same as the data passed to the first/top validation function
|
|
57905
|
-
dynamicAnchors: new codegen_1$
|
|
57905
|
+
dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
|
|
57906
57906
|
// used to support recursiveRef and dynamicRef
|
|
57907
57907
|
// function scoped variables
|
|
57908
|
-
vErrors: new codegen_1$
|
|
57908
|
+
vErrors: new codegen_1$u.Name("vErrors"),
|
|
57909
57909
|
// null or array of validation errors
|
|
57910
|
-
errors: new codegen_1$
|
|
57910
|
+
errors: new codegen_1$u.Name("errors"),
|
|
57911
57911
|
// counter of validation errors
|
|
57912
|
-
this: new codegen_1$
|
|
57912
|
+
this: new codegen_1$u.Name("this"),
|
|
57913
57913
|
// "globals"
|
|
57914
|
-
self: new codegen_1$
|
|
57915
|
-
scope: new codegen_1$
|
|
57914
|
+
self: new codegen_1$u.Name("self"),
|
|
57915
|
+
scope: new codegen_1$u.Name("scope"),
|
|
57916
57916
|
// JTD serialize/parse name for JSON string and position
|
|
57917
|
-
json: new codegen_1$
|
|
57918
|
-
jsonPos: new codegen_1$
|
|
57919
|
-
jsonLen: new codegen_1$
|
|
57920
|
-
jsonPart: new codegen_1$
|
|
57917
|
+
json: new codegen_1$u.Name("json"),
|
|
57918
|
+
jsonPos: new codegen_1$u.Name("jsonPos"),
|
|
57919
|
+
jsonLen: new codegen_1$u.Name("jsonLen"),
|
|
57920
|
+
jsonPart: new codegen_1$u.Name("jsonPart")
|
|
57921
57921
|
};
|
|
57922
57922
|
names$1.default = names;
|
|
57923
57923
|
(function(exports$1) {
|
|
@@ -58037,55 +58037,49 @@ names$1.default = names;
|
|
|
58037
58037
|
keyValues.push([E.propertyName, propertyName2]);
|
|
58038
58038
|
}
|
|
58039
58039
|
})(errors);
|
|
58040
|
-
|
|
58041
|
-
|
|
58042
|
-
|
|
58043
|
-
|
|
58044
|
-
|
|
58045
|
-
|
|
58046
|
-
|
|
58047
|
-
|
|
58048
|
-
|
|
58049
|
-
const
|
|
58050
|
-
|
|
58051
|
-
|
|
58052
|
-
|
|
58053
|
-
|
|
58054
|
-
|
|
58055
|
-
|
|
58056
|
-
|
|
58057
|
-
gen.return(names_12.default.data);
|
|
58058
|
-
} else {
|
|
58059
|
-
gen.assign((0, codegen_12._)`${validateName2}.errors`, null);
|
|
58060
|
-
gen.return(true);
|
|
58061
|
-
}
|
|
58040
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
58041
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
58042
|
+
const errors_1$3 = errors;
|
|
58043
|
+
const codegen_1$t = codegen;
|
|
58044
|
+
const names_1$6 = names$1;
|
|
58045
|
+
const boolError = {
|
|
58046
|
+
message: "boolean schema is false"
|
|
58047
|
+
};
|
|
58048
|
+
function topBoolOrEmptySchema(it) {
|
|
58049
|
+
const { gen, schema, validateName: validateName2 } = it;
|
|
58050
|
+
if (schema === false) {
|
|
58051
|
+
falseSchemaError(it, false);
|
|
58052
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
58053
|
+
gen.return(names_1$6.default.data);
|
|
58054
|
+
} else {
|
|
58055
|
+
gen.assign((0, codegen_1$t._)`${validateName2}.errors`, null);
|
|
58056
|
+
gen.return(true);
|
|
58062
58057
|
}
|
|
58063
|
-
|
|
58064
|
-
|
|
58065
|
-
|
|
58066
|
-
|
|
58067
|
-
|
|
58068
|
-
|
|
58069
|
-
|
|
58070
|
-
|
|
58071
|
-
|
|
58072
|
-
}
|
|
58073
|
-
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
58074
|
-
function falseSchemaError(it, overrideAllErrors) {
|
|
58075
|
-
const { gen, data } = it;
|
|
58076
|
-
const cxt = {
|
|
58077
|
-
gen,
|
|
58078
|
-
keyword: "false schema",
|
|
58079
|
-
data,
|
|
58080
|
-
schema: false,
|
|
58081
|
-
schemaCode: false,
|
|
58082
|
-
schemaValue: false,
|
|
58083
|
-
params: {},
|
|
58084
|
-
it
|
|
58085
|
-
};
|
|
58086
|
-
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
58058
|
+
}
|
|
58059
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
58060
|
+
function boolOrEmptySchema(it, valid) {
|
|
58061
|
+
const { gen, schema } = it;
|
|
58062
|
+
if (schema === false) {
|
|
58063
|
+
gen.var(valid, false);
|
|
58064
|
+
falseSchemaError(it);
|
|
58065
|
+
} else {
|
|
58066
|
+
gen.var(valid, true);
|
|
58087
58067
|
}
|
|
58088
|
-
|
|
58068
|
+
}
|
|
58069
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
58070
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
58071
|
+
const { gen, data } = it;
|
|
58072
|
+
const cxt = {
|
|
58073
|
+
gen,
|
|
58074
|
+
keyword: "false schema",
|
|
58075
|
+
data,
|
|
58076
|
+
schema: false,
|
|
58077
|
+
schemaCode: false,
|
|
58078
|
+
schemaValue: false,
|
|
58079
|
+
params: {},
|
|
58080
|
+
it
|
|
58081
|
+
};
|
|
58082
|
+
(0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
58089
58083
|
}
|
|
58090
58084
|
var dataType = {};
|
|
58091
58085
|
var rules = {};
|
|
@@ -58133,10 +58127,10 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
58133
58127
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
58134
58128
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
58135
58129
|
const rules_1 = rules;
|
|
58136
|
-
const applicability_1 = applicability;
|
|
58137
|
-
const errors_1 = errors;
|
|
58138
|
-
const codegen_1$
|
|
58139
|
-
const util_1$
|
|
58130
|
+
const applicability_1$1 = applicability;
|
|
58131
|
+
const errors_1$2 = errors;
|
|
58132
|
+
const codegen_1$s = codegen;
|
|
58133
|
+
const util_1$r = util;
|
|
58140
58134
|
var DataType;
|
|
58141
58135
|
(function(DataType2) {
|
|
58142
58136
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -58168,7 +58162,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
58168
58162
|
function coerceAndCheckDataType(it, types2) {
|
|
58169
58163
|
const { gen, data, opts } = it;
|
|
58170
58164
|
const coerceTo = coerceToTypes(types2, opts.coerceTypes);
|
|
58171
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
58165
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
|
|
58172
58166
|
if (checkTypes) {
|
|
58173
58167
|
const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
|
|
58174
58168
|
gen.if(wrongType, () => {
|
|
@@ -58187,12 +58181,12 @@ function coerceToTypes(types2, coerceTypes) {
|
|
|
58187
58181
|
}
|
|
58188
58182
|
function coerceData(it, types2, coerceTo) {
|
|
58189
58183
|
const { gen, data, opts } = it;
|
|
58190
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
58191
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
58184
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
|
|
58185
|
+
const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
|
|
58192
58186
|
if (opts.coerceTypes === "array") {
|
|
58193
|
-
gen.if((0, codegen_1$
|
|
58187
|
+
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)));
|
|
58194
58188
|
}
|
|
58195
|
-
gen.if((0, codegen_1$
|
|
58189
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
|
|
58196
58190
|
for (const t2 of coerceTo) {
|
|
58197
58191
|
if (COERCIBLE.has(t2) || t2 === "array" && opts.coerceTypes === "array") {
|
|
58198
58192
|
coerceSpecificType(t2);
|
|
@@ -58201,63 +58195,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
58201
58195
|
gen.else();
|
|
58202
58196
|
reportTypeError(it);
|
|
58203
58197
|
gen.endIf();
|
|
58204
|
-
gen.if((0, codegen_1$
|
|
58198
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
|
|
58205
58199
|
gen.assign(data, coerced);
|
|
58206
58200
|
assignParentData(it, coerced);
|
|
58207
58201
|
});
|
|
58208
58202
|
function coerceSpecificType(t2) {
|
|
58209
58203
|
switch (t2) {
|
|
58210
58204
|
case "string":
|
|
58211
|
-
gen.elseIf((0, codegen_1$
|
|
58205
|
+
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._)`""`);
|
|
58212
58206
|
return;
|
|
58213
58207
|
case "number":
|
|
58214
|
-
gen.elseIf((0, codegen_1$
|
|
58215
|
-
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$
|
|
58208
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
|
|
58209
|
+
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
|
|
58216
58210
|
return;
|
|
58217
58211
|
case "integer":
|
|
58218
|
-
gen.elseIf((0, codegen_1$
|
|
58219
|
-
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$
|
|
58212
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
|
|
58213
|
+
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
|
|
58220
58214
|
return;
|
|
58221
58215
|
case "boolean":
|
|
58222
|
-
gen.elseIf((0, codegen_1$
|
|
58216
|
+
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);
|
|
58223
58217
|
return;
|
|
58224
58218
|
case "null":
|
|
58225
|
-
gen.elseIf((0, codegen_1$
|
|
58219
|
+
gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
|
|
58226
58220
|
gen.assign(coerced, null);
|
|
58227
58221
|
return;
|
|
58228
58222
|
case "array":
|
|
58229
|
-
gen.elseIf((0, codegen_1$
|
|
58230
|
-
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$
|
|
58223
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
58224
|
+
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
|
|
58231
58225
|
}
|
|
58232
58226
|
}
|
|
58233
58227
|
}
|
|
58234
58228
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
58235
|
-
gen.if((0, codegen_1$
|
|
58229
|
+
gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
|
|
58236
58230
|
}
|
|
58237
58231
|
function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
|
|
58238
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
58232
|
+
const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
|
|
58239
58233
|
let cond;
|
|
58240
58234
|
switch (dataType2) {
|
|
58241
58235
|
case "null":
|
|
58242
|
-
return (0, codegen_1$
|
|
58236
|
+
return (0, codegen_1$s._)`${data} ${EQ} null`;
|
|
58243
58237
|
case "array":
|
|
58244
|
-
cond = (0, codegen_1$
|
|
58238
|
+
cond = (0, codegen_1$s._)`Array.isArray(${data})`;
|
|
58245
58239
|
break;
|
|
58246
58240
|
case "object":
|
|
58247
|
-
cond = (0, codegen_1$
|
|
58241
|
+
cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
|
|
58248
58242
|
break;
|
|
58249
58243
|
case "integer":
|
|
58250
|
-
cond = numCond((0, codegen_1$
|
|
58244
|
+
cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
|
|
58251
58245
|
break;
|
|
58252
58246
|
case "number":
|
|
58253
58247
|
cond = numCond();
|
|
58254
58248
|
break;
|
|
58255
58249
|
default:
|
|
58256
|
-
return (0, codegen_1$
|
|
58250
|
+
return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
|
|
58257
58251
|
}
|
|
58258
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
58259
|
-
function numCond(_cond = codegen_1$
|
|
58260
|
-
return (0, codegen_1$
|
|
58252
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
|
|
58253
|
+
function numCond(_cond = codegen_1$s.nil) {
|
|
58254
|
+
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);
|
|
58261
58255
|
}
|
|
58262
58256
|
}
|
|
58263
58257
|
dataType.checkDataType = checkDataType;
|
|
@@ -58266,35 +58260,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
|
58266
58260
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
58267
58261
|
}
|
|
58268
58262
|
let cond;
|
|
58269
|
-
const types2 = (0, util_1$
|
|
58263
|
+
const types2 = (0, util_1$r.toHash)(dataTypes);
|
|
58270
58264
|
if (types2.array && types2.object) {
|
|
58271
|
-
const notObj = (0, codegen_1$
|
|
58272
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
58265
|
+
const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
|
|
58266
|
+
cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
|
|
58273
58267
|
delete types2.null;
|
|
58274
58268
|
delete types2.array;
|
|
58275
58269
|
delete types2.object;
|
|
58276
58270
|
} else {
|
|
58277
|
-
cond = codegen_1$
|
|
58271
|
+
cond = codegen_1$s.nil;
|
|
58278
58272
|
}
|
|
58279
58273
|
if (types2.number)
|
|
58280
58274
|
delete types2.integer;
|
|
58281
58275
|
for (const t2 in types2)
|
|
58282
|
-
cond = (0, codegen_1$
|
|
58276
|
+
cond = (0, codegen_1$s.and)(cond, checkDataType(t2, data, strictNums, correct));
|
|
58283
58277
|
return cond;
|
|
58284
58278
|
}
|
|
58285
58279
|
dataType.checkDataTypes = checkDataTypes;
|
|
58286
58280
|
const typeError = {
|
|
58287
58281
|
message: ({ schema }) => `must be ${schema}`,
|
|
58288
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
58282
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
|
|
58289
58283
|
};
|
|
58290
58284
|
function reportTypeError(it) {
|
|
58291
58285
|
const cxt = getTypeErrorContext(it);
|
|
58292
|
-
(0, errors_1.reportError)(cxt, typeError);
|
|
58286
|
+
(0, errors_1$2.reportError)(cxt, typeError);
|
|
58293
58287
|
}
|
|
58294
58288
|
dataType.reportTypeError = reportTypeError;
|
|
58295
58289
|
function getTypeErrorContext(it) {
|
|
58296
58290
|
const { gen, data, schema } = it;
|
|
58297
|
-
const schemaCode = (0, util_1$
|
|
58291
|
+
const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
|
|
58298
58292
|
return {
|
|
58299
58293
|
gen,
|
|
58300
58294
|
keyword: "type",
|
|
@@ -58308,60 +58302,54 @@ function getTypeErrorContext(it) {
|
|
|
58308
58302
|
};
|
|
58309
58303
|
}
|
|
58310
58304
|
var defaults = {};
|
|
58311
|
-
|
|
58312
|
-
|
|
58313
|
-
|
|
58314
|
-
|
|
58315
|
-
|
|
58316
|
-
|
|
58317
|
-
|
|
58318
|
-
|
|
58319
|
-
|
|
58320
|
-
|
|
58321
|
-
|
|
58322
|
-
|
|
58323
|
-
|
|
58324
|
-
|
|
58325
|
-
|
|
58326
|
-
|
|
58327
|
-
|
|
58305
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
58306
|
+
defaults.assignDefaults = void 0;
|
|
58307
|
+
const codegen_1$r = codegen;
|
|
58308
|
+
const util_1$q = util;
|
|
58309
|
+
function assignDefaults(it, ty) {
|
|
58310
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
58311
|
+
if (ty === "object" && properties2) {
|
|
58312
|
+
for (const key in properties2) {
|
|
58313
|
+
assignDefault(it, key, properties2[key].default);
|
|
58314
|
+
}
|
|
58315
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
58316
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
58317
|
+
}
|
|
58318
|
+
}
|
|
58319
|
+
defaults.assignDefaults = assignDefaults;
|
|
58320
|
+
function assignDefault(it, prop, defaultValue) {
|
|
58321
|
+
const { gen, compositeRule, data, opts } = it;
|
|
58322
|
+
if (defaultValue === void 0)
|
|
58323
|
+
return;
|
|
58324
|
+
const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
58325
|
+
if (compositeRule) {
|
|
58326
|
+
(0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
58327
|
+
return;
|
|
58328
58328
|
}
|
|
58329
|
-
|
|
58330
|
-
|
|
58331
|
-
|
|
58332
|
-
if (defaultValue === void 0)
|
|
58333
|
-
return;
|
|
58334
|
-
const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
|
|
58335
|
-
if (compositeRule) {
|
|
58336
|
-
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
58337
|
-
return;
|
|
58338
|
-
}
|
|
58339
|
-
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
58340
|
-
if (opts.useDefaults === "empty") {
|
|
58341
|
-
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
58342
|
-
}
|
|
58343
|
-
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
58329
|
+
let condition = (0, codegen_1$r._)`${childData} === undefined`;
|
|
58330
|
+
if (opts.useDefaults === "empty") {
|
|
58331
|
+
condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
58344
58332
|
}
|
|
58345
|
-
|
|
58333
|
+
gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
|
|
58346
58334
|
}
|
|
58347
58335
|
var keyword = {};
|
|
58348
58336
|
var code = {};
|
|
58349
58337
|
Object.defineProperty(code, "__esModule", { value: true });
|
|
58350
58338
|
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;
|
|
58351
|
-
const codegen_1$
|
|
58352
|
-
const util_1$
|
|
58353
|
-
const names_1$
|
|
58339
|
+
const codegen_1$q = codegen;
|
|
58340
|
+
const util_1$p = util;
|
|
58341
|
+
const names_1$5 = names$1;
|
|
58354
58342
|
const util_2$1 = util;
|
|
58355
58343
|
function checkReportMissingProp(cxt, prop) {
|
|
58356
58344
|
const { gen, data, it } = cxt;
|
|
58357
58345
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
58358
|
-
cxt.setParams({ missingProperty: (0, codegen_1$
|
|
58346
|
+
cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
|
|
58359
58347
|
cxt.error();
|
|
58360
58348
|
});
|
|
58361
58349
|
}
|
|
58362
58350
|
code.checkReportMissingProp = checkReportMissingProp;
|
|
58363
58351
|
function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
|
|
58364
|
-
return (0, codegen_1$
|
|
58352
|
+
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}`)));
|
|
58365
58353
|
}
|
|
58366
58354
|
code.checkMissingProp = checkMissingProp;
|
|
58367
58355
|
function reportMissingProp(cxt, missing) {
|
|
@@ -58373,22 +58361,22 @@ function hasPropFunc(gen) {
|
|
|
58373
58361
|
return gen.scopeValue("func", {
|
|
58374
58362
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
58375
58363
|
ref: Object.prototype.hasOwnProperty,
|
|
58376
|
-
code: (0, codegen_1$
|
|
58364
|
+
code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
|
|
58377
58365
|
});
|
|
58378
58366
|
}
|
|
58379
58367
|
code.hasPropFunc = hasPropFunc;
|
|
58380
58368
|
function isOwnProperty(gen, data, property) {
|
|
58381
|
-
return (0, codegen_1$
|
|
58369
|
+
return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
|
|
58382
58370
|
}
|
|
58383
58371
|
code.isOwnProperty = isOwnProperty;
|
|
58384
58372
|
function propertyInData(gen, data, property, ownProperties) {
|
|
58385
|
-
const cond = (0, codegen_1$
|
|
58386
|
-
return ownProperties ? (0, codegen_1$
|
|
58373
|
+
const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
|
|
58374
|
+
return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
|
|
58387
58375
|
}
|
|
58388
58376
|
code.propertyInData = propertyInData;
|
|
58389
58377
|
function noPropertyInData(gen, data, property, ownProperties) {
|
|
58390
|
-
const cond = (0, codegen_1$
|
|
58391
|
-
return ownProperties ? (0, codegen_1$
|
|
58378
|
+
const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
|
|
58379
|
+
return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
|
|
58392
58380
|
}
|
|
58393
58381
|
code.noPropertyInData = noPropertyInData;
|
|
58394
58382
|
function allSchemaProperties(schemaMap) {
|
|
@@ -58396,24 +58384,24 @@ function allSchemaProperties(schemaMap) {
|
|
|
58396
58384
|
}
|
|
58397
58385
|
code.allSchemaProperties = allSchemaProperties;
|
|
58398
58386
|
function schemaProperties(it, schemaMap) {
|
|
58399
|
-
return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1$
|
|
58387
|
+
return allSchemaProperties(schemaMap).filter((p2) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p2]));
|
|
58400
58388
|
}
|
|
58401
58389
|
code.schemaProperties = schemaProperties;
|
|
58402
58390
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
58403
|
-
const dataAndSchema = passSchema ? (0, codegen_1$
|
|
58391
|
+
const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
|
|
58404
58392
|
const valCxt = [
|
|
58405
|
-
[names_1$
|
|
58406
|
-
[names_1$
|
|
58407
|
-
[names_1$
|
|
58408
|
-
[names_1$
|
|
58393
|
+
[names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
|
|
58394
|
+
[names_1$5.default.parentData, it.parentData],
|
|
58395
|
+
[names_1$5.default.parentDataProperty, it.parentDataProperty],
|
|
58396
|
+
[names_1$5.default.rootData, names_1$5.default.rootData]
|
|
58409
58397
|
];
|
|
58410
58398
|
if (it.opts.dynamicRef)
|
|
58411
|
-
valCxt.push([names_1$
|
|
58412
|
-
const args = (0, codegen_1$
|
|
58413
|
-
return context !== codegen_1$
|
|
58399
|
+
valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
|
|
58400
|
+
const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
58401
|
+
return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
|
|
58414
58402
|
}
|
|
58415
58403
|
code.callValidateCode = callValidateCode;
|
|
58416
|
-
const newRegExp = (0, codegen_1$
|
|
58404
|
+
const newRegExp = (0, codegen_1$q._)`new RegExp`;
|
|
58417
58405
|
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
58418
58406
|
const u = opts.unicodeRegExp ? "u" : "";
|
|
58419
58407
|
const { regExp } = opts.code;
|
|
@@ -58421,7 +58409,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
|
|
|
58421
58409
|
return gen.scopeValue("pattern", {
|
|
58422
58410
|
key: rx.toString(),
|
|
58423
58411
|
ref: rx,
|
|
58424
|
-
code: (0, codegen_1$
|
|
58412
|
+
code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
58425
58413
|
});
|
|
58426
58414
|
}
|
|
58427
58415
|
code.usePattern = usePattern;
|
|
@@ -58437,14 +58425,14 @@ function validateArray(cxt) {
|
|
|
58437
58425
|
validateItems(() => gen.break());
|
|
58438
58426
|
return valid;
|
|
58439
58427
|
function validateItems(notValid) {
|
|
58440
|
-
const len = gen.const("len", (0, codegen_1$
|
|
58428
|
+
const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
|
|
58441
58429
|
gen.forRange("i", 0, len, (i) => {
|
|
58442
58430
|
cxt.subschema({
|
|
58443
58431
|
keyword: keyword2,
|
|
58444
58432
|
dataProp: i,
|
|
58445
|
-
dataPropType: util_1$
|
|
58433
|
+
dataPropType: util_1$p.Type.Num
|
|
58446
58434
|
}, valid);
|
|
58447
|
-
gen.if((0, codegen_1$
|
|
58435
|
+
gen.if((0, codegen_1$q.not)(valid), notValid);
|
|
58448
58436
|
});
|
|
58449
58437
|
}
|
|
58450
58438
|
}
|
|
@@ -58453,7 +58441,7 @@ function validateUnion(cxt) {
|
|
|
58453
58441
|
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
58454
58442
|
if (!Array.isArray(schema))
|
|
58455
58443
|
throw new Error("ajv implementation error");
|
|
58456
|
-
const alwaysValid = schema.some((sch) => (0, util_1$
|
|
58444
|
+
const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
|
|
58457
58445
|
if (alwaysValid && !it.opts.unevaluated)
|
|
58458
58446
|
return;
|
|
58459
58447
|
const valid = gen.let("valid", false);
|
|
@@ -58464,214 +58452,202 @@ function validateUnion(cxt) {
|
|
|
58464
58452
|
schemaProp: i,
|
|
58465
58453
|
compositeRule: true
|
|
58466
58454
|
}, schValid);
|
|
58467
|
-
gen.assign(valid, (0, codegen_1$
|
|
58455
|
+
gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
|
|
58468
58456
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
58469
58457
|
if (!merged)
|
|
58470
|
-
gen.if((0, codegen_1$
|
|
58458
|
+
gen.if((0, codegen_1$q.not)(valid));
|
|
58471
58459
|
}));
|
|
58472
58460
|
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
58473
58461
|
}
|
|
58474
58462
|
code.validateUnion = validateUnion;
|
|
58475
|
-
|
|
58476
|
-
|
|
58477
|
-
|
|
58478
|
-
|
|
58479
|
-
|
|
58480
|
-
|
|
58481
|
-
|
|
58482
|
-
const
|
|
58483
|
-
const
|
|
58484
|
-
const
|
|
58485
|
-
|
|
58486
|
-
|
|
58487
|
-
|
|
58488
|
-
|
|
58489
|
-
|
|
58490
|
-
|
|
58491
|
-
|
|
58492
|
-
|
|
58493
|
-
|
|
58494
|
-
|
|
58495
|
-
|
|
58496
|
-
|
|
58497
|
-
|
|
58498
|
-
|
|
58499
|
-
|
|
58500
|
-
}
|
|
58501
|
-
|
|
58502
|
-
|
|
58503
|
-
|
|
58504
|
-
|
|
58505
|
-
|
|
58506
|
-
|
|
58507
|
-
|
|
58508
|
-
|
|
58509
|
-
|
|
58510
|
-
|
|
58511
|
-
|
|
58512
|
-
|
|
58513
|
-
|
|
58514
|
-
|
|
58515
|
-
|
|
58516
|
-
|
|
58517
|
-
|
|
58518
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
58519
|
-
if (def2.modifying)
|
|
58520
|
-
modifyData(cxt);
|
|
58521
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
58522
|
-
}
|
|
58523
|
-
}
|
|
58524
|
-
function validateAsync() {
|
|
58525
|
-
const ruleErrs = gen.let("ruleErrs", null);
|
|
58526
|
-
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)));
|
|
58527
|
-
return ruleErrs;
|
|
58528
|
-
}
|
|
58529
|
-
function validateSync() {
|
|
58530
|
-
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
58531
|
-
gen.assign(validateErrs, null);
|
|
58532
|
-
assignValid(codegen_12.nil);
|
|
58533
|
-
return validateErrs;
|
|
58534
|
-
}
|
|
58535
|
-
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
58536
|
-
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
58537
|
-
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
58538
|
-
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
58539
|
-
}
|
|
58540
|
-
function reportErrs(errors2) {
|
|
58541
|
-
var _a3;
|
|
58542
|
-
gen.if((0, codegen_12.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
|
|
58463
|
+
Object.defineProperty(keyword, "__esModule", { value: true });
|
|
58464
|
+
keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
|
|
58465
|
+
const codegen_1$p = codegen;
|
|
58466
|
+
const names_1$4 = names$1;
|
|
58467
|
+
const code_1$9 = code;
|
|
58468
|
+
const errors_1$1 = errors;
|
|
58469
|
+
function macroKeywordCode(cxt, def2) {
|
|
58470
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
58471
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
58472
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
58473
|
+
if (it.opts.validateSchema !== false)
|
|
58474
|
+
it.self.validateSchema(macroSchema, true);
|
|
58475
|
+
const valid = gen.name("valid");
|
|
58476
|
+
cxt.subschema({
|
|
58477
|
+
schema: macroSchema,
|
|
58478
|
+
schemaPath: codegen_1$p.nil,
|
|
58479
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
58480
|
+
topSchemaRef: schemaRef,
|
|
58481
|
+
compositeRule: true
|
|
58482
|
+
}, valid);
|
|
58483
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
58484
|
+
}
|
|
58485
|
+
keyword.macroKeywordCode = macroKeywordCode;
|
|
58486
|
+
function funcKeywordCode(cxt, def2) {
|
|
58487
|
+
var _a2;
|
|
58488
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
58489
|
+
checkAsyncKeyword(it, def2);
|
|
58490
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
58491
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
58492
|
+
const valid = gen.let("valid");
|
|
58493
|
+
cxt.block$data(valid, validateKeyword);
|
|
58494
|
+
cxt.ok((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid);
|
|
58495
|
+
function validateKeyword() {
|
|
58496
|
+
if (def2.errors === false) {
|
|
58497
|
+
assignValid();
|
|
58498
|
+
if (def2.modifying)
|
|
58499
|
+
modifyData(cxt);
|
|
58500
|
+
reportErrs(() => cxt.error());
|
|
58501
|
+
} else {
|
|
58502
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
58503
|
+
if (def2.modifying)
|
|
58504
|
+
modifyData(cxt);
|
|
58505
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
58543
58506
|
}
|
|
58544
58507
|
}
|
|
58545
|
-
|
|
58546
|
-
|
|
58547
|
-
|
|
58548
|
-
|
|
58549
|
-
}
|
|
58550
|
-
function
|
|
58551
|
-
const
|
|
58552
|
-
gen.
|
|
58553
|
-
|
|
58554
|
-
|
|
58555
|
-
|
|
58556
|
-
|
|
58557
|
-
|
|
58558
|
-
|
|
58559
|
-
|
|
58560
|
-
}
|
|
58561
|
-
function
|
|
58562
|
-
|
|
58563
|
-
|
|
58564
|
-
|
|
58565
|
-
|
|
58566
|
-
|
|
58567
|
-
|
|
58568
|
-
}
|
|
58569
|
-
|
|
58570
|
-
|
|
58571
|
-
|
|
58572
|
-
|
|
58573
|
-
|
|
58574
|
-
|
|
58575
|
-
|
|
58576
|
-
|
|
58577
|
-
|
|
58578
|
-
|
|
58579
|
-
|
|
58580
|
-
|
|
58581
|
-
|
|
58582
|
-
|
|
58583
|
-
|
|
58584
|
-
|
|
58585
|
-
|
|
58586
|
-
|
|
58508
|
+
function validateAsync() {
|
|
58509
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
58510
|
+
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)));
|
|
58511
|
+
return ruleErrs;
|
|
58512
|
+
}
|
|
58513
|
+
function validateSync() {
|
|
58514
|
+
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
58515
|
+
gen.assign(validateErrs, null);
|
|
58516
|
+
assignValid(codegen_1$p.nil);
|
|
58517
|
+
return validateErrs;
|
|
58518
|
+
}
|
|
58519
|
+
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
58520
|
+
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
58521
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
58522
|
+
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
58523
|
+
}
|
|
58524
|
+
function reportErrs(errors2) {
|
|
58525
|
+
var _a3;
|
|
58526
|
+
gen.if((0, codegen_1$p.not)((_a3 = def2.valid) !== null && _a3 !== void 0 ? _a3 : valid), errors2);
|
|
58527
|
+
}
|
|
58528
|
+
}
|
|
58529
|
+
keyword.funcKeywordCode = funcKeywordCode;
|
|
58530
|
+
function modifyData(cxt) {
|
|
58531
|
+
const { gen, data, it } = cxt;
|
|
58532
|
+
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
58533
|
+
}
|
|
58534
|
+
function addErrs(cxt, errs) {
|
|
58535
|
+
const { gen } = cxt;
|
|
58536
|
+
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
58537
|
+
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`);
|
|
58538
|
+
(0, errors_1$1.extendErrors)(cxt);
|
|
58539
|
+
}, () => cxt.error());
|
|
58540
|
+
}
|
|
58541
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
58542
|
+
if (def2.async && !schemaEnv.$async)
|
|
58543
|
+
throw new Error("async keyword in sync schema");
|
|
58544
|
+
}
|
|
58545
|
+
function useKeyword(gen, keyword2, result) {
|
|
58546
|
+
if (result === void 0)
|
|
58547
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
58548
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
58549
|
+
}
|
|
58550
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
58551
|
+
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");
|
|
58552
|
+
}
|
|
58553
|
+
keyword.validSchemaType = validSchemaType;
|
|
58554
|
+
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
|
|
58555
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
58556
|
+
throw new Error("ajv implementation error");
|
|
58557
|
+
}
|
|
58558
|
+
const deps = def2.dependencies;
|
|
58559
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
58560
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
58561
|
+
}
|
|
58562
|
+
if (def2.validateSchema) {
|
|
58563
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
58564
|
+
if (!valid) {
|
|
58565
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
|
|
58566
|
+
if (opts.validateSchema === "log")
|
|
58567
|
+
self.logger.error(msg);
|
|
58568
|
+
else
|
|
58569
|
+
throw new Error(msg);
|
|
58587
58570
|
}
|
|
58588
58571
|
}
|
|
58589
|
-
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
58590
|
-
return keyword;
|
|
58591
58572
|
}
|
|
58573
|
+
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
58592
58574
|
var subschema = {};
|
|
58593
|
-
|
|
58594
|
-
|
|
58595
|
-
|
|
58596
|
-
|
|
58597
|
-
|
|
58598
|
-
|
|
58599
|
-
|
|
58600
|
-
|
|
58601
|
-
|
|
58602
|
-
|
|
58603
|
-
|
|
58604
|
-
|
|
58605
|
-
|
|
58606
|
-
|
|
58607
|
-
|
|
58608
|
-
|
|
58609
|
-
|
|
58610
|
-
|
|
58611
|
-
|
|
58612
|
-
|
|
58613
|
-
|
|
58614
|
-
|
|
58615
|
-
|
|
58616
|
-
}
|
|
58617
|
-
if (schema !== void 0) {
|
|
58618
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
58619
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
58620
|
-
}
|
|
58621
|
-
return {
|
|
58622
|
-
schema,
|
|
58623
|
-
schemaPath,
|
|
58624
|
-
topSchemaRef,
|
|
58625
|
-
errSchemaPath
|
|
58626
|
-
};
|
|
58575
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
58576
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
58577
|
+
const codegen_1$o = codegen;
|
|
58578
|
+
const util_1$o = util;
|
|
58579
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
58580
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
58581
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
58582
|
+
}
|
|
58583
|
+
if (keyword2 !== void 0) {
|
|
58584
|
+
const sch = it.schema[keyword2];
|
|
58585
|
+
return schemaProp === void 0 ? {
|
|
58586
|
+
schema: sch,
|
|
58587
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
58588
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
58589
|
+
} : {
|
|
58590
|
+
schema: sch[schemaProp],
|
|
58591
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
58592
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
|
|
58593
|
+
};
|
|
58594
|
+
}
|
|
58595
|
+
if (schema !== void 0) {
|
|
58596
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
58597
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
58627
58598
|
}
|
|
58628
|
-
|
|
58629
|
-
|
|
58630
|
-
|
|
58631
|
-
|
|
58632
|
-
|
|
58633
|
-
|
|
58634
|
-
|
|
58635
|
-
|
|
58636
|
-
|
|
58637
|
-
|
|
58638
|
-
|
|
58639
|
-
|
|
58640
|
-
|
|
58641
|
-
|
|
58642
|
-
|
|
58643
|
-
|
|
58644
|
-
|
|
58645
|
-
|
|
58646
|
-
|
|
58647
|
-
|
|
58648
|
-
|
|
58649
|
-
|
|
58650
|
-
|
|
58651
|
-
|
|
58652
|
-
|
|
58653
|
-
|
|
58654
|
-
|
|
58655
|
-
subschema2.
|
|
58656
|
-
|
|
58657
|
-
|
|
58658
|
-
|
|
58659
|
-
|
|
58660
|
-
|
|
58661
|
-
|
|
58662
|
-
|
|
58663
|
-
|
|
58664
|
-
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58669
|
-
|
|
58670
|
-
|
|
58671
|
-
|
|
58672
|
-
|
|
58673
|
-
|
|
58674
|
-
|
|
58599
|
+
return {
|
|
58600
|
+
schema,
|
|
58601
|
+
schemaPath,
|
|
58602
|
+
topSchemaRef,
|
|
58603
|
+
errSchemaPath
|
|
58604
|
+
};
|
|
58605
|
+
}
|
|
58606
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
58607
|
+
}
|
|
58608
|
+
subschema.getSubschema = getSubschema;
|
|
58609
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName: propertyName2 }) {
|
|
58610
|
+
if (data !== void 0 && dataProp !== void 0) {
|
|
58611
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
58612
|
+
}
|
|
58613
|
+
const { gen } = it;
|
|
58614
|
+
if (dataProp !== void 0) {
|
|
58615
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
58616
|
+
const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
|
|
58617
|
+
dataContextProps(nextData);
|
|
58618
|
+
subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
58619
|
+
subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
|
|
58620
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
58621
|
+
}
|
|
58622
|
+
if (data !== void 0) {
|
|
58623
|
+
const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
|
|
58624
|
+
dataContextProps(nextData);
|
|
58625
|
+
if (propertyName2 !== void 0)
|
|
58626
|
+
subschema2.propertyName = propertyName2;
|
|
58627
|
+
}
|
|
58628
|
+
if (dataTypes)
|
|
58629
|
+
subschema2.dataTypes = dataTypes;
|
|
58630
|
+
function dataContextProps(_nextData) {
|
|
58631
|
+
subschema2.data = _nextData;
|
|
58632
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
58633
|
+
subschema2.dataTypes = [];
|
|
58634
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
58635
|
+
subschema2.parentData = it.data;
|
|
58636
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
58637
|
+
}
|
|
58638
|
+
}
|
|
58639
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
58640
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
58641
|
+
if (compositeRule !== void 0)
|
|
58642
|
+
subschema2.compositeRule = compositeRule;
|
|
58643
|
+
if (createErrors !== void 0)
|
|
58644
|
+
subschema2.createErrors = createErrors;
|
|
58645
|
+
if (allErrors !== void 0)
|
|
58646
|
+
subschema2.allErrors = allErrors;
|
|
58647
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
58648
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
58649
|
+
}
|
|
58650
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
58675
58651
|
var resolve$2 = {};
|
|
58676
58652
|
var fastDeepEqual = function equal(a, b) {
|
|
58677
58653
|
if (a === b) return true;
|
|
@@ -58786,7 +58762,7 @@ function escapeJsonPtr(str) {
|
|
|
58786
58762
|
var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
|
|
58787
58763
|
Object.defineProperty(resolve$2, "__esModule", { value: true });
|
|
58788
58764
|
resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
|
|
58789
|
-
const util_1$
|
|
58765
|
+
const util_1$n = util;
|
|
58790
58766
|
const equal$3 = fastDeepEqual;
|
|
58791
58767
|
const traverse = jsonSchemaTraverseExports;
|
|
58792
58768
|
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
@@ -58845,7 +58821,7 @@ function countKeys(schema) {
|
|
|
58845
58821
|
if (SIMPLE_INLINED.has(key))
|
|
58846
58822
|
continue;
|
|
58847
58823
|
if (typeof schema[key] == "object") {
|
|
58848
|
-
(0, util_1$
|
|
58824
|
+
(0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
|
|
58849
58825
|
}
|
|
58850
58826
|
if (count === Infinity)
|
|
58851
58827
|
return Infinity;
|
|
@@ -58933,528 +58909,516 @@ function getSchemaRefs(schema, baseId) {
|
|
|
58933
58909
|
}
|
|
58934
58910
|
}
|
|
58935
58911
|
resolve$2.getSchemaRefs = getSchemaRefs;
|
|
58936
|
-
|
|
58937
|
-
|
|
58938
|
-
|
|
58939
|
-
|
|
58940
|
-
|
|
58941
|
-
|
|
58942
|
-
|
|
58943
|
-
|
|
58944
|
-
|
|
58945
|
-
|
|
58946
|
-
|
|
58947
|
-
|
|
58948
|
-
|
|
58949
|
-
|
|
58950
|
-
|
|
58951
|
-
|
|
58952
|
-
|
|
58953
|
-
|
|
58954
|
-
|
|
58955
|
-
|
|
58956
|
-
checkKeywords(it);
|
|
58957
|
-
if (schemaCxtHasRules(it)) {
|
|
58958
|
-
topSchemaObjCode(it);
|
|
58959
|
-
return;
|
|
58960
|
-
}
|
|
58912
|
+
Object.defineProperty(validate, "__esModule", { value: true });
|
|
58913
|
+
validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
|
|
58914
|
+
const boolSchema_1 = boolSchema;
|
|
58915
|
+
const dataType_1$1 = dataType;
|
|
58916
|
+
const applicability_1 = applicability;
|
|
58917
|
+
const dataType_2 = dataType;
|
|
58918
|
+
const defaults_1 = defaults;
|
|
58919
|
+
const keyword_1 = keyword;
|
|
58920
|
+
const subschema_1 = subschema;
|
|
58921
|
+
const codegen_1$n = codegen;
|
|
58922
|
+
const names_1$3 = names$1;
|
|
58923
|
+
const resolve_1$2 = resolve$2;
|
|
58924
|
+
const util_1$m = util;
|
|
58925
|
+
const errors_1 = errors;
|
|
58926
|
+
function validateFunctionCode(it) {
|
|
58927
|
+
if (isSchemaObj(it)) {
|
|
58928
|
+
checkKeywords(it);
|
|
58929
|
+
if (schemaCxtHasRules(it)) {
|
|
58930
|
+
topSchemaObjCode(it);
|
|
58931
|
+
return;
|
|
58961
58932
|
}
|
|
58962
|
-
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
58963
|
-
}
|
|
58964
|
-
validate.validateFunctionCode = validateFunctionCode;
|
|
58965
|
-
function validateFunction({ gen, validateName: validateName2, schema, schemaEnv, opts }, body) {
|
|
58966
|
-
if (opts.code.es5) {
|
|
58967
|
-
gen.func(validateName2, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
|
|
58968
|
-
gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
58969
|
-
destructureValCxtES5(gen, opts);
|
|
58970
|
-
gen.code(body);
|
|
58971
|
-
});
|
|
58972
|
-
} else {
|
|
58973
|
-
gen.func(validateName2, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
58974
|
-
}
|
|
58975
|
-
}
|
|
58976
|
-
function destructureValCxt(opts) {
|
|
58977
|
-
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}}={}`;
|
|
58978
|
-
}
|
|
58979
|
-
function destructureValCxtES5(gen, opts) {
|
|
58980
|
-
gen.if(names_12.default.valCxt, () => {
|
|
58981
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
58982
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
58983
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
58984
|
-
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
58985
|
-
if (opts.dynamicRef)
|
|
58986
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
58987
|
-
}, () => {
|
|
58988
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
58989
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
58990
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
58991
|
-
gen.var(names_12.default.rootData, names_12.default.data);
|
|
58992
|
-
if (opts.dynamicRef)
|
|
58993
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
58994
|
-
});
|
|
58995
58933
|
}
|
|
58996
|
-
|
|
58997
|
-
|
|
58998
|
-
|
|
58999
|
-
|
|
59000
|
-
|
|
59001
|
-
|
|
59002
|
-
gen.
|
|
59003
|
-
gen
|
|
59004
|
-
|
|
59005
|
-
resetEvaluated(it);
|
|
59006
|
-
typeAndKeywords(it);
|
|
59007
|
-
returnResults(it);
|
|
58934
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
58935
|
+
}
|
|
58936
|
+
validate.validateFunctionCode = validateFunctionCode;
|
|
58937
|
+
function validateFunction({ gen, validateName: validateName2, schema, schemaEnv, opts }, body) {
|
|
58938
|
+
if (opts.code.es5) {
|
|
58939
|
+
gen.func(validateName2, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
|
|
58940
|
+
gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
58941
|
+
destructureValCxtES5(gen, opts);
|
|
58942
|
+
gen.code(body);
|
|
59008
58943
|
});
|
|
59009
|
-
|
|
59010
|
-
|
|
59011
|
-
|
|
59012
|
-
|
|
59013
|
-
|
|
59014
|
-
|
|
59015
|
-
|
|
59016
|
-
|
|
59017
|
-
|
|
59018
|
-
|
|
59019
|
-
|
|
59020
|
-
|
|
59021
|
-
|
|
59022
|
-
if (
|
|
59023
|
-
|
|
59024
|
-
|
|
59025
|
-
|
|
59026
|
-
|
|
59027
|
-
|
|
59028
|
-
|
|
59029
|
-
(
|
|
59030
|
-
|
|
59031
|
-
|
|
59032
|
-
|
|
59033
|
-
|
|
59034
|
-
|
|
59035
|
-
|
|
59036
|
-
return true;
|
|
59037
|
-
return false;
|
|
59038
|
-
}
|
|
59039
|
-
function isSchemaObj(it) {
|
|
59040
|
-
return typeof it.schema != "boolean";
|
|
59041
|
-
}
|
|
59042
|
-
function subSchemaObjCode(it, valid) {
|
|
59043
|
-
const { schema, gen, opts } = it;
|
|
58944
|
+
} else {
|
|
58945
|
+
gen.func(validateName2, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
58946
|
+
}
|
|
58947
|
+
}
|
|
58948
|
+
function destructureValCxt(opts) {
|
|
58949
|
+
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}}={}`;
|
|
58950
|
+
}
|
|
58951
|
+
function destructureValCxtES5(gen, opts) {
|
|
58952
|
+
gen.if(names_1$3.default.valCxt, () => {
|
|
58953
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
|
|
58954
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
|
|
58955
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
|
|
58956
|
+
gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
|
|
58957
|
+
if (opts.dynamicRef)
|
|
58958
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
|
|
58959
|
+
}, () => {
|
|
58960
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
|
|
58961
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
|
|
58962
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
|
|
58963
|
+
gen.var(names_1$3.default.rootData, names_1$3.default.data);
|
|
58964
|
+
if (opts.dynamicRef)
|
|
58965
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
|
|
58966
|
+
});
|
|
58967
|
+
}
|
|
58968
|
+
function topSchemaObjCode(it) {
|
|
58969
|
+
const { schema, opts, gen } = it;
|
|
58970
|
+
validateFunction(it, () => {
|
|
59044
58971
|
if (opts.$comment && schema.$comment)
|
|
59045
58972
|
commentKeyword(it);
|
|
59046
|
-
|
|
59047
|
-
|
|
59048
|
-
|
|
59049
|
-
|
|
59050
|
-
|
|
59051
|
-
|
|
59052
|
-
|
|
59053
|
-
|
|
59054
|
-
|
|
59055
|
-
|
|
59056
|
-
|
|
59057
|
-
|
|
59058
|
-
|
|
59059
|
-
|
|
59060
|
-
|
|
59061
|
-
|
|
59062
|
-
|
|
59063
|
-
|
|
59064
|
-
|
|
59065
|
-
|
|
59066
|
-
|
|
59067
|
-
|
|
59068
|
-
|
|
59069
|
-
|
|
59070
|
-
|
|
59071
|
-
|
|
59072
|
-
(0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
|
|
58973
|
+
checkNoDefault(it);
|
|
58974
|
+
gen.let(names_1$3.default.vErrors, null);
|
|
58975
|
+
gen.let(names_1$3.default.errors, 0);
|
|
58976
|
+
if (opts.unevaluated)
|
|
58977
|
+
resetEvaluated(it);
|
|
58978
|
+
typeAndKeywords(it);
|
|
58979
|
+
returnResults(it);
|
|
58980
|
+
});
|
|
58981
|
+
return;
|
|
58982
|
+
}
|
|
58983
|
+
function resetEvaluated(it) {
|
|
58984
|
+
const { gen, validateName: validateName2 } = it;
|
|
58985
|
+
it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName2}.evaluated`);
|
|
58986
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
|
|
58987
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
|
|
58988
|
+
}
|
|
58989
|
+
function funcSourceUrl(schema, opts) {
|
|
58990
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
58991
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
|
|
58992
|
+
}
|
|
58993
|
+
function subschemaCode(it, valid) {
|
|
58994
|
+
if (isSchemaObj(it)) {
|
|
58995
|
+
checkKeywords(it);
|
|
58996
|
+
if (schemaCxtHasRules(it)) {
|
|
58997
|
+
subSchemaObjCode(it, valid);
|
|
58998
|
+
return;
|
|
59073
58999
|
}
|
|
59074
59000
|
}
|
|
59075
|
-
|
|
59076
|
-
|
|
59077
|
-
|
|
59078
|
-
|
|
59079
|
-
|
|
59080
|
-
|
|
59081
|
-
if (
|
|
59082
|
-
|
|
59083
|
-
|
|
59084
|
-
|
|
59085
|
-
|
|
59086
|
-
|
|
59087
|
-
|
|
59088
|
-
|
|
59089
|
-
|
|
59090
|
-
|
|
59091
|
-
|
|
59092
|
-
|
|
59001
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
59002
|
+
}
|
|
59003
|
+
function schemaCxtHasRules({ schema, self }) {
|
|
59004
|
+
if (typeof schema == "boolean")
|
|
59005
|
+
return !schema;
|
|
59006
|
+
for (const key in schema)
|
|
59007
|
+
if (self.RULES.all[key])
|
|
59008
|
+
return true;
|
|
59009
|
+
return false;
|
|
59010
|
+
}
|
|
59011
|
+
function isSchemaObj(it) {
|
|
59012
|
+
return typeof it.schema != "boolean";
|
|
59013
|
+
}
|
|
59014
|
+
function subSchemaObjCode(it, valid) {
|
|
59015
|
+
const { schema, gen, opts } = it;
|
|
59016
|
+
if (opts.$comment && schema.$comment)
|
|
59017
|
+
commentKeyword(it);
|
|
59018
|
+
updateContext(it);
|
|
59019
|
+
checkAsyncSchema(it);
|
|
59020
|
+
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
59021
|
+
typeAndKeywords(it, errsCount);
|
|
59022
|
+
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
59023
|
+
}
|
|
59024
|
+
function checkKeywords(it) {
|
|
59025
|
+
(0, util_1$m.checkUnknownRules)(it);
|
|
59026
|
+
checkRefsAndKeywords(it);
|
|
59027
|
+
}
|
|
59028
|
+
function typeAndKeywords(it, errsCount) {
|
|
59029
|
+
if (it.opts.jtd)
|
|
59030
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
59031
|
+
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
59032
|
+
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
59033
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
59034
|
+
}
|
|
59035
|
+
function checkRefsAndKeywords(it) {
|
|
59036
|
+
const { schema, errSchemaPath, opts, self } = it;
|
|
59037
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
|
|
59038
|
+
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
59039
|
+
}
|
|
59040
|
+
}
|
|
59041
|
+
function checkNoDefault(it) {
|
|
59042
|
+
const { schema, opts } = it;
|
|
59043
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
59044
|
+
(0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
|
|
59045
|
+
}
|
|
59046
|
+
}
|
|
59047
|
+
function updateContext(it) {
|
|
59048
|
+
const schId = it.schema[it.opts.schemaId];
|
|
59049
|
+
if (schId)
|
|
59050
|
+
it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
59051
|
+
}
|
|
59052
|
+
function checkAsyncSchema(it) {
|
|
59053
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
59054
|
+
throw new Error("async schema in sync schema");
|
|
59055
|
+
}
|
|
59056
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
59057
|
+
const msg = schema.$comment;
|
|
59058
|
+
if (opts.$comment === true) {
|
|
59059
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
59060
|
+
} else if (typeof opts.$comment == "function") {
|
|
59061
|
+
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
59062
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
59063
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
59064
|
+
}
|
|
59065
|
+
}
|
|
59066
|
+
function returnResults(it) {
|
|
59067
|
+
const { gen, schemaEnv, validateName: validateName2, ValidationError: ValidationError2, opts } = it;
|
|
59068
|
+
if (schemaEnv.$async) {
|
|
59069
|
+
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})`));
|
|
59070
|
+
} else {
|
|
59071
|
+
gen.assign((0, codegen_1$n._)`${validateName2}.errors`, names_1$3.default.vErrors);
|
|
59072
|
+
if (opts.unevaluated)
|
|
59073
|
+
assignEvaluated(it);
|
|
59074
|
+
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
59075
|
+
}
|
|
59076
|
+
}
|
|
59077
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
59078
|
+
if (props instanceof codegen_1$n.Name)
|
|
59079
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
|
|
59080
|
+
if (items2 instanceof codegen_1$n.Name)
|
|
59081
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
59082
|
+
}
|
|
59083
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
59084
|
+
const { gen, schema, data, allErrors, opts, self } = it;
|
|
59085
|
+
const { RULES } = self;
|
|
59086
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
|
|
59087
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
59088
|
+
return;
|
|
59093
59089
|
}
|
|
59094
|
-
|
|
59095
|
-
|
|
59096
|
-
|
|
59097
|
-
|
|
59098
|
-
|
|
59099
|
-
|
|
59100
|
-
|
|
59101
|
-
|
|
59102
|
-
|
|
59103
|
-
}
|
|
59104
|
-
}
|
|
59105
|
-
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
59106
|
-
if (props instanceof codegen_12.Name)
|
|
59107
|
-
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
59108
|
-
if (items2 instanceof codegen_12.Name)
|
|
59109
|
-
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
59110
|
-
}
|
|
59111
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
59112
|
-
const { gen, schema, data, allErrors, opts, self } = it;
|
|
59113
|
-
const { RULES } = self;
|
|
59114
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
59115
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
59090
|
+
if (!opts.jtd)
|
|
59091
|
+
checkStrictTypes(it, types2);
|
|
59092
|
+
gen.block(() => {
|
|
59093
|
+
for (const group of RULES.rules)
|
|
59094
|
+
groupKeywords(group);
|
|
59095
|
+
groupKeywords(RULES.post);
|
|
59096
|
+
});
|
|
59097
|
+
function groupKeywords(group) {
|
|
59098
|
+
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
59116
59099
|
return;
|
|
59117
|
-
|
|
59118
|
-
|
|
59119
|
-
|
|
59120
|
-
|
|
59121
|
-
|
|
59122
|
-
|
|
59123
|
-
groupKeywords(RULES.post);
|
|
59124
|
-
});
|
|
59125
|
-
function groupKeywords(group) {
|
|
59126
|
-
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
59127
|
-
return;
|
|
59128
|
-
if (group.type) {
|
|
59129
|
-
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
59130
|
-
iterateKeywords(it, group);
|
|
59131
|
-
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
59132
|
-
gen.else();
|
|
59133
|
-
(0, dataType_2.reportTypeError)(it);
|
|
59134
|
-
}
|
|
59135
|
-
gen.endIf();
|
|
59136
|
-
} else {
|
|
59137
|
-
iterateKeywords(it, group);
|
|
59100
|
+
if (group.type) {
|
|
59101
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
59102
|
+
iterateKeywords(it, group);
|
|
59103
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
59104
|
+
gen.else();
|
|
59105
|
+
(0, dataType_2.reportTypeError)(it);
|
|
59138
59106
|
}
|
|
59139
|
-
|
|
59140
|
-
|
|
59107
|
+
gen.endIf();
|
|
59108
|
+
} else {
|
|
59109
|
+
iterateKeywords(it, group);
|
|
59141
59110
|
}
|
|
59111
|
+
if (!allErrors)
|
|
59112
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
59142
59113
|
}
|
|
59143
|
-
|
|
59144
|
-
|
|
59145
|
-
|
|
59146
|
-
|
|
59147
|
-
|
|
59148
|
-
|
|
59149
|
-
|
|
59150
|
-
|
|
59151
|
-
|
|
59152
|
-
}
|
|
59153
|
-
});
|
|
59154
|
-
}
|
|
59155
|
-
function checkStrictTypes(it, types2) {
|
|
59156
|
-
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
59157
|
-
return;
|
|
59158
|
-
checkContextTypes(it, types2);
|
|
59159
|
-
if (!it.opts.allowUnionTypes)
|
|
59160
|
-
checkMultipleTypes(it, types2);
|
|
59161
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
59162
|
-
}
|
|
59163
|
-
function checkContextTypes(it, types2) {
|
|
59164
|
-
if (!types2.length)
|
|
59165
|
-
return;
|
|
59166
|
-
if (!it.dataTypes.length) {
|
|
59167
|
-
it.dataTypes = types2;
|
|
59168
|
-
return;
|
|
59169
|
-
}
|
|
59170
|
-
types2.forEach((t2) => {
|
|
59171
|
-
if (!includesType(it.dataTypes, t2)) {
|
|
59172
|
-
strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
59173
|
-
}
|
|
59174
|
-
});
|
|
59175
|
-
narrowSchemaTypes(it, types2);
|
|
59176
|
-
}
|
|
59177
|
-
function checkMultipleTypes(it, ts) {
|
|
59178
|
-
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
59179
|
-
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
59180
|
-
}
|
|
59181
|
-
}
|
|
59182
|
-
function checkKeywordTypes(it, ts) {
|
|
59183
|
-
const rules2 = it.self.RULES.all;
|
|
59184
|
-
for (const keyword2 in rules2) {
|
|
59185
|
-
const rule = rules2[keyword2];
|
|
59186
|
-
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
59187
|
-
const { type: type2 } = rule.definition;
|
|
59188
|
-
if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
|
|
59189
|
-
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
59190
|
-
}
|
|
59191
|
-
}
|
|
59192
|
-
}
|
|
59193
|
-
}
|
|
59194
|
-
function hasApplicableType(schTs, kwdT) {
|
|
59195
|
-
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
59196
|
-
}
|
|
59197
|
-
function includesType(ts, t2) {
|
|
59198
|
-
return ts.includes(t2) || t2 === "integer" && ts.includes("number");
|
|
59199
|
-
}
|
|
59200
|
-
function narrowSchemaTypes(it, withTypes) {
|
|
59201
|
-
const ts = [];
|
|
59202
|
-
for (const t2 of it.dataTypes) {
|
|
59203
|
-
if (includesType(withTypes, t2))
|
|
59204
|
-
ts.push(t2);
|
|
59205
|
-
else if (withTypes.includes("integer") && t2 === "number")
|
|
59206
|
-
ts.push("integer");
|
|
59207
|
-
}
|
|
59208
|
-
it.dataTypes = ts;
|
|
59209
|
-
}
|
|
59210
|
-
function strictTypesError(it, msg) {
|
|
59211
|
-
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
59212
|
-
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
59213
|
-
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
59214
|
-
}
|
|
59215
|
-
class KeywordCxt {
|
|
59216
|
-
constructor(it, def2, keyword2) {
|
|
59217
|
-
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
59218
|
-
this.gen = it.gen;
|
|
59219
|
-
this.allErrors = it.allErrors;
|
|
59220
|
-
this.keyword = keyword2;
|
|
59221
|
-
this.data = it.data;
|
|
59222
|
-
this.schema = it.schema[keyword2];
|
|
59223
|
-
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
59224
|
-
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
59225
|
-
this.schemaType = def2.schemaType;
|
|
59226
|
-
this.parentSchema = it.schema;
|
|
59227
|
-
this.params = {};
|
|
59228
|
-
this.it = it;
|
|
59229
|
-
this.def = def2;
|
|
59230
|
-
if (this.$data) {
|
|
59231
|
-
this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
|
|
59232
|
-
} else {
|
|
59233
|
-
this.schemaCode = this.schemaValue;
|
|
59234
|
-
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
59235
|
-
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
59236
|
-
}
|
|
59237
|
-
}
|
|
59238
|
-
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
59239
|
-
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
59114
|
+
}
|
|
59115
|
+
function iterateKeywords(it, group) {
|
|
59116
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
59117
|
+
if (useDefaults)
|
|
59118
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
59119
|
+
gen.block(() => {
|
|
59120
|
+
for (const rule of group.rules) {
|
|
59121
|
+
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
|
59122
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
59240
59123
|
}
|
|
59241
59124
|
}
|
|
59242
|
-
|
|
59243
|
-
|
|
59125
|
+
});
|
|
59126
|
+
}
|
|
59127
|
+
function checkStrictTypes(it, types2) {
|
|
59128
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
59129
|
+
return;
|
|
59130
|
+
checkContextTypes(it, types2);
|
|
59131
|
+
if (!it.opts.allowUnionTypes)
|
|
59132
|
+
checkMultipleTypes(it, types2);
|
|
59133
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
59134
|
+
}
|
|
59135
|
+
function checkContextTypes(it, types2) {
|
|
59136
|
+
if (!types2.length)
|
|
59137
|
+
return;
|
|
59138
|
+
if (!it.dataTypes.length) {
|
|
59139
|
+
it.dataTypes = types2;
|
|
59140
|
+
return;
|
|
59141
|
+
}
|
|
59142
|
+
types2.forEach((t2) => {
|
|
59143
|
+
if (!includesType(it.dataTypes, t2)) {
|
|
59144
|
+
strictTypesError(it, `type "${t2}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
59244
59145
|
}
|
|
59245
|
-
|
|
59246
|
-
|
|
59247
|
-
|
|
59248
|
-
|
|
59249
|
-
|
|
59250
|
-
|
|
59251
|
-
|
|
59252
|
-
|
|
59253
|
-
|
|
59254
|
-
|
|
59255
|
-
|
|
59256
|
-
|
|
59257
|
-
|
|
59258
|
-
|
|
59259
|
-
|
|
59260
|
-
|
|
59146
|
+
});
|
|
59147
|
+
narrowSchemaTypes(it, types2);
|
|
59148
|
+
}
|
|
59149
|
+
function checkMultipleTypes(it, ts) {
|
|
59150
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
59151
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
59152
|
+
}
|
|
59153
|
+
}
|
|
59154
|
+
function checkKeywordTypes(it, ts) {
|
|
59155
|
+
const rules2 = it.self.RULES.all;
|
|
59156
|
+
for (const keyword2 in rules2) {
|
|
59157
|
+
const rule = rules2[keyword2];
|
|
59158
|
+
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
|
59159
|
+
const { type: type2 } = rule.definition;
|
|
59160
|
+
if (type2.length && !type2.some((t2) => hasApplicableType(ts, t2))) {
|
|
59161
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
59162
|
+
}
|
|
59163
|
+
}
|
|
59164
|
+
}
|
|
59165
|
+
}
|
|
59166
|
+
function hasApplicableType(schTs, kwdT) {
|
|
59167
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
59168
|
+
}
|
|
59169
|
+
function includesType(ts, t2) {
|
|
59170
|
+
return ts.includes(t2) || t2 === "integer" && ts.includes("number");
|
|
59171
|
+
}
|
|
59172
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
59173
|
+
const ts = [];
|
|
59174
|
+
for (const t2 of it.dataTypes) {
|
|
59175
|
+
if (includesType(withTypes, t2))
|
|
59176
|
+
ts.push(t2);
|
|
59177
|
+
else if (withTypes.includes("integer") && t2 === "number")
|
|
59178
|
+
ts.push("integer");
|
|
59179
|
+
}
|
|
59180
|
+
it.dataTypes = ts;
|
|
59181
|
+
}
|
|
59182
|
+
function strictTypesError(it, msg) {
|
|
59183
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
59184
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
59185
|
+
(0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
59186
|
+
}
|
|
59187
|
+
class KeywordCxt {
|
|
59188
|
+
constructor(it, def2, keyword2) {
|
|
59189
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
59190
|
+
this.gen = it.gen;
|
|
59191
|
+
this.allErrors = it.allErrors;
|
|
59192
|
+
this.keyword = keyword2;
|
|
59193
|
+
this.data = it.data;
|
|
59194
|
+
this.schema = it.schema[keyword2];
|
|
59195
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
59196
|
+
this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
59197
|
+
this.schemaType = def2.schemaType;
|
|
59198
|
+
this.parentSchema = it.schema;
|
|
59199
|
+
this.params = {};
|
|
59200
|
+
this.it = it;
|
|
59201
|
+
this.def = def2;
|
|
59202
|
+
if (this.$data) {
|
|
59203
|
+
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
59204
|
+
} else {
|
|
59205
|
+
this.schemaCode = this.schemaValue;
|
|
59206
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
59207
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
59261
59208
|
}
|
|
59262
59209
|
}
|
|
59263
|
-
|
|
59264
|
-
this.
|
|
59210
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
59211
|
+
this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
|
|
59265
59212
|
}
|
|
59266
|
-
|
|
59267
|
-
|
|
59268
|
-
|
|
59269
|
-
|
|
59270
|
-
|
|
59271
|
-
|
|
59272
|
-
|
|
59273
|
-
|
|
59213
|
+
}
|
|
59214
|
+
result(condition, successAction, failAction) {
|
|
59215
|
+
this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
|
|
59216
|
+
}
|
|
59217
|
+
failResult(condition, successAction, failAction) {
|
|
59218
|
+
this.gen.if(condition);
|
|
59219
|
+
if (failAction)
|
|
59220
|
+
failAction();
|
|
59221
|
+
else
|
|
59274
59222
|
this.error();
|
|
59223
|
+
if (successAction) {
|
|
59224
|
+
this.gen.else();
|
|
59225
|
+
successAction();
|
|
59226
|
+
if (this.allErrors)
|
|
59227
|
+
this.gen.endIf();
|
|
59228
|
+
} else {
|
|
59275
59229
|
if (this.allErrors)
|
|
59276
59230
|
this.gen.endIf();
|
|
59277
59231
|
else
|
|
59278
59232
|
this.gen.else();
|
|
59279
59233
|
}
|
|
59280
|
-
|
|
59281
|
-
|
|
59282
|
-
|
|
59283
|
-
|
|
59284
|
-
|
|
59285
|
-
|
|
59286
|
-
|
|
59287
|
-
if (errorParams) {
|
|
59288
|
-
this.setParams(errorParams);
|
|
59289
|
-
this._error(append, errorPaths);
|
|
59290
|
-
this.setParams({});
|
|
59291
|
-
return;
|
|
59292
|
-
}
|
|
59293
|
-
this._error(append, errorPaths);
|
|
59294
|
-
}
|
|
59295
|
-
_error(append, errorPaths) {
|
|
59296
|
-
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
59297
|
-
}
|
|
59298
|
-
$dataError() {
|
|
59299
|
-
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
59300
|
-
}
|
|
59301
|
-
reset() {
|
|
59302
|
-
if (this.errsCount === void 0)
|
|
59303
|
-
throw new Error('add "trackErrors" to keyword definition');
|
|
59304
|
-
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
59305
|
-
}
|
|
59306
|
-
ok(cond) {
|
|
59234
|
+
}
|
|
59235
|
+
pass(condition, failAction) {
|
|
59236
|
+
this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
|
|
59237
|
+
}
|
|
59238
|
+
fail(condition) {
|
|
59239
|
+
if (condition === void 0) {
|
|
59240
|
+
this.error();
|
|
59307
59241
|
if (!this.allErrors)
|
|
59308
|
-
this.gen.if(
|
|
59309
|
-
|
|
59310
|
-
setParams(obj, assign2) {
|
|
59311
|
-
if (assign2)
|
|
59312
|
-
Object.assign(this.params, obj);
|
|
59313
|
-
else
|
|
59314
|
-
this.params = obj;
|
|
59242
|
+
this.gen.if(false);
|
|
59243
|
+
return;
|
|
59315
59244
|
}
|
|
59316
|
-
|
|
59317
|
-
|
|
59318
|
-
|
|
59319
|
-
|
|
59320
|
-
|
|
59245
|
+
this.gen.if(condition);
|
|
59246
|
+
this.error();
|
|
59247
|
+
if (this.allErrors)
|
|
59248
|
+
this.gen.endIf();
|
|
59249
|
+
else
|
|
59250
|
+
this.gen.else();
|
|
59251
|
+
}
|
|
59252
|
+
fail$data(condition) {
|
|
59253
|
+
if (!this.$data)
|
|
59254
|
+
return this.fail(condition);
|
|
59255
|
+
const { schemaCode } = this;
|
|
59256
|
+
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
59257
|
+
}
|
|
59258
|
+
error(append, errorParams, errorPaths) {
|
|
59259
|
+
if (errorParams) {
|
|
59260
|
+
this.setParams(errorParams);
|
|
59261
|
+
this._error(append, errorPaths);
|
|
59262
|
+
this.setParams({});
|
|
59263
|
+
return;
|
|
59321
59264
|
}
|
|
59322
|
-
|
|
59323
|
-
|
|
59324
|
-
|
|
59325
|
-
|
|
59326
|
-
|
|
59327
|
-
|
|
59328
|
-
|
|
59329
|
-
|
|
59330
|
-
|
|
59331
|
-
|
|
59332
|
-
|
|
59333
|
-
|
|
59334
|
-
|
|
59335
|
-
|
|
59265
|
+
this._error(append, errorPaths);
|
|
59266
|
+
}
|
|
59267
|
+
_error(append, errorPaths) {
|
|
59268
|
+
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
59269
|
+
}
|
|
59270
|
+
$dataError() {
|
|
59271
|
+
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
59272
|
+
}
|
|
59273
|
+
reset() {
|
|
59274
|
+
if (this.errsCount === void 0)
|
|
59275
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
59276
|
+
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
59277
|
+
}
|
|
59278
|
+
ok(cond) {
|
|
59279
|
+
if (!this.allErrors)
|
|
59280
|
+
this.gen.if(cond);
|
|
59281
|
+
}
|
|
59282
|
+
setParams(obj, assign2) {
|
|
59283
|
+
if (assign2)
|
|
59284
|
+
Object.assign(this.params, obj);
|
|
59285
|
+
else
|
|
59286
|
+
this.params = obj;
|
|
59287
|
+
}
|
|
59288
|
+
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
59289
|
+
this.gen.block(() => {
|
|
59290
|
+
this.check$data(valid, $dataValid);
|
|
59291
|
+
codeBlock();
|
|
59292
|
+
});
|
|
59293
|
+
}
|
|
59294
|
+
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
59295
|
+
if (!this.$data)
|
|
59296
|
+
return;
|
|
59297
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
59298
|
+
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
59299
|
+
if (valid !== codegen_1$n.nil)
|
|
59300
|
+
gen.assign(valid, true);
|
|
59301
|
+
if (schemaType.length || def2.validateSchema) {
|
|
59302
|
+
gen.elseIf(this.invalid$data());
|
|
59303
|
+
this.$dataError();
|
|
59304
|
+
if (valid !== codegen_1$n.nil)
|
|
59305
|
+
gen.assign(valid, false);
|
|
59336
59306
|
}
|
|
59337
|
-
|
|
59338
|
-
|
|
59339
|
-
|
|
59340
|
-
|
|
59341
|
-
|
|
59342
|
-
|
|
59343
|
-
|
|
59344
|
-
|
|
59345
|
-
|
|
59346
|
-
|
|
59347
|
-
return
|
|
59348
|
-
}
|
|
59349
|
-
function invalid$DataSchema() {
|
|
59350
|
-
if (def2.validateSchema) {
|
|
59351
|
-
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
59352
|
-
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
59353
|
-
}
|
|
59354
|
-
return codegen_12.nil;
|
|
59355
|
-
}
|
|
59356
|
-
}
|
|
59357
|
-
subschema(appl, valid) {
|
|
59358
|
-
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
59359
|
-
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
59360
|
-
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
59361
|
-
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
59362
|
-
subschemaCode(nextContext, valid);
|
|
59363
|
-
return nextContext;
|
|
59364
|
-
}
|
|
59365
|
-
mergeEvaluated(schemaCxt, toName) {
|
|
59366
|
-
const { it, gen } = this;
|
|
59367
|
-
if (!it.opts.unevaluated)
|
|
59368
|
-
return;
|
|
59369
|
-
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
59370
|
-
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
59371
|
-
}
|
|
59372
|
-
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
59373
|
-
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
59307
|
+
gen.else();
|
|
59308
|
+
}
|
|
59309
|
+
invalid$data() {
|
|
59310
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
59311
|
+
return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
|
|
59312
|
+
function wrong$DataType() {
|
|
59313
|
+
if (schemaType.length) {
|
|
59314
|
+
if (!(schemaCode instanceof codegen_1$n.Name))
|
|
59315
|
+
throw new Error("ajv implementation error");
|
|
59316
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
59317
|
+
return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
59374
59318
|
}
|
|
59319
|
+
return codegen_1$n.nil;
|
|
59375
59320
|
}
|
|
59376
|
-
|
|
59377
|
-
|
|
59378
|
-
|
|
59379
|
-
|
|
59380
|
-
return true;
|
|
59321
|
+
function invalid$DataSchema() {
|
|
59322
|
+
if (def2.validateSchema) {
|
|
59323
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
59324
|
+
return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
|
|
59381
59325
|
}
|
|
59326
|
+
return codegen_1$n.nil;
|
|
59382
59327
|
}
|
|
59383
59328
|
}
|
|
59384
|
-
|
|
59385
|
-
|
|
59386
|
-
|
|
59387
|
-
|
|
59388
|
-
|
|
59389
|
-
|
|
59390
|
-
|
|
59391
|
-
|
|
59392
|
-
|
|
59393
|
-
|
|
59394
|
-
|
|
59329
|
+
subschema(appl, valid) {
|
|
59330
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
59331
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
59332
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
59333
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
59334
|
+
subschemaCode(nextContext, valid);
|
|
59335
|
+
return nextContext;
|
|
59336
|
+
}
|
|
59337
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
59338
|
+
const { it, gen } = this;
|
|
59339
|
+
if (!it.opts.unevaluated)
|
|
59340
|
+
return;
|
|
59341
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
59342
|
+
it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
59343
|
+
}
|
|
59344
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
59345
|
+
it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
59395
59346
|
}
|
|
59396
59347
|
}
|
|
59397
|
-
|
|
59398
|
-
|
|
59399
|
-
|
|
59400
|
-
|
|
59401
|
-
|
|
59402
|
-
if ($data === "")
|
|
59403
|
-
return names_12.default.rootData;
|
|
59404
|
-
if ($data[0] === "/") {
|
|
59405
|
-
if (!JSON_POINTER.test($data))
|
|
59406
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
59407
|
-
jsonPointer = $data;
|
|
59408
|
-
data = names_12.default.rootData;
|
|
59409
|
-
} else {
|
|
59410
|
-
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
59411
|
-
if (!matches)
|
|
59412
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
59413
|
-
const up = +matches[1];
|
|
59414
|
-
jsonPointer = matches[2];
|
|
59415
|
-
if (jsonPointer === "#") {
|
|
59416
|
-
if (up >= dataLevel)
|
|
59417
|
-
throw new Error(errorMsg("property/index", up));
|
|
59418
|
-
return dataPathArr[dataLevel - up];
|
|
59419
|
-
}
|
|
59420
|
-
if (up > dataLevel)
|
|
59421
|
-
throw new Error(errorMsg("data", up));
|
|
59422
|
-
data = dataNames[dataLevel - up];
|
|
59423
|
-
if (!jsonPointer)
|
|
59424
|
-
return data;
|
|
59425
|
-
}
|
|
59426
|
-
let expr = data;
|
|
59427
|
-
const segments = jsonPointer.split("/");
|
|
59428
|
-
for (const segment of segments) {
|
|
59429
|
-
if (segment) {
|
|
59430
|
-
data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
|
|
59431
|
-
expr = (0, codegen_12._)`${expr} && ${data}`;
|
|
59432
|
-
}
|
|
59348
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
59349
|
+
const { it, gen } = this;
|
|
59350
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
59351
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
|
|
59352
|
+
return true;
|
|
59433
59353
|
}
|
|
59434
|
-
|
|
59435
|
-
|
|
59436
|
-
|
|
59354
|
+
}
|
|
59355
|
+
}
|
|
59356
|
+
validate.KeywordCxt = KeywordCxt;
|
|
59357
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
59358
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
59359
|
+
if ("code" in def2) {
|
|
59360
|
+
def2.code(cxt, ruleType);
|
|
59361
|
+
} else if (cxt.$data && def2.validate) {
|
|
59362
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
59363
|
+
} else if ("macro" in def2) {
|
|
59364
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
59365
|
+
} else if (def2.compile || def2.validate) {
|
|
59366
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
59367
|
+
}
|
|
59368
|
+
}
|
|
59369
|
+
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
59370
|
+
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
59371
|
+
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
59372
|
+
let jsonPointer;
|
|
59373
|
+
let data;
|
|
59374
|
+
if ($data === "")
|
|
59375
|
+
return names_1$3.default.rootData;
|
|
59376
|
+
if ($data[0] === "/") {
|
|
59377
|
+
if (!JSON_POINTER.test($data))
|
|
59378
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
59379
|
+
jsonPointer = $data;
|
|
59380
|
+
data = names_1$3.default.rootData;
|
|
59381
|
+
} else {
|
|
59382
|
+
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
59383
|
+
if (!matches)
|
|
59384
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
59385
|
+
const up = +matches[1];
|
|
59386
|
+
jsonPointer = matches[2];
|
|
59387
|
+
if (jsonPointer === "#") {
|
|
59388
|
+
if (up >= dataLevel)
|
|
59389
|
+
throw new Error(errorMsg("property/index", up));
|
|
59390
|
+
return dataPathArr[dataLevel - up];
|
|
59391
|
+
}
|
|
59392
|
+
if (up > dataLevel)
|
|
59393
|
+
throw new Error(errorMsg("data", up));
|
|
59394
|
+
data = dataNames[dataLevel - up];
|
|
59395
|
+
if (!jsonPointer)
|
|
59396
|
+
return data;
|
|
59397
|
+
}
|
|
59398
|
+
let expr = data;
|
|
59399
|
+
const segments = jsonPointer.split("/");
|
|
59400
|
+
for (const segment of segments) {
|
|
59401
|
+
if (segment) {
|
|
59402
|
+
data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
|
|
59403
|
+
expr = (0, codegen_1$n._)`${expr} && ${data}`;
|
|
59437
59404
|
}
|
|
59438
59405
|
}
|
|
59439
|
-
|
|
59440
|
-
|
|
59406
|
+
return expr;
|
|
59407
|
+
function errorMsg(pointerType, up) {
|
|
59408
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
59409
|
+
}
|
|
59441
59410
|
}
|
|
59411
|
+
validate.getData = getData;
|
|
59442
59412
|
var validation_error = {};
|
|
59443
|
-
|
|
59444
|
-
|
|
59445
|
-
|
|
59446
|
-
|
|
59447
|
-
|
|
59448
|
-
|
|
59449
|
-
constructor(errors2) {
|
|
59450
|
-
super("validation failed");
|
|
59451
|
-
this.errors = errors2;
|
|
59452
|
-
this.ajv = this.validation = true;
|
|
59453
|
-
}
|
|
59413
|
+
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
59414
|
+
class ValidationError extends Error {
|
|
59415
|
+
constructor(errors2) {
|
|
59416
|
+
super("validation failed");
|
|
59417
|
+
this.errors = errors2;
|
|
59418
|
+
this.ajv = this.validation = true;
|
|
59454
59419
|
}
|
|
59455
|
-
validation_error.default = ValidationError;
|
|
59456
|
-
return validation_error;
|
|
59457
59420
|
}
|
|
59421
|
+
validation_error.default = ValidationError;
|
|
59458
59422
|
var ref_error = {};
|
|
59459
59423
|
Object.defineProperty(ref_error, "__esModule", { value: true });
|
|
59460
59424
|
const resolve_1$1 = resolve$2;
|
|
@@ -59470,11 +59434,11 @@ var compile = {};
|
|
|
59470
59434
|
Object.defineProperty(compile, "__esModule", { value: true });
|
|
59471
59435
|
compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
|
|
59472
59436
|
const codegen_1$m = codegen;
|
|
59473
|
-
const validation_error_1 =
|
|
59437
|
+
const validation_error_1 = validation_error;
|
|
59474
59438
|
const names_1$2 = names$1;
|
|
59475
59439
|
const resolve_1 = resolve$2;
|
|
59476
59440
|
const util_1$l = util;
|
|
59477
|
-
const validate_1$1 =
|
|
59441
|
+
const validate_1$1 = validate;
|
|
59478
59442
|
class SchemaEnv {
|
|
59479
59443
|
constructor(env) {
|
|
59480
59444
|
var _a2;
|
|
@@ -60403,7 +60367,7 @@ uri$1.default = uri;
|
|
|
60403
60367
|
(function(exports$1) {
|
|
60404
60368
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
60405
60369
|
exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
|
|
60406
|
-
var validate_12 =
|
|
60370
|
+
var validate_12 = validate;
|
|
60407
60371
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
60408
60372
|
return validate_12.KeywordCxt;
|
|
60409
60373
|
} });
|
|
@@ -60426,7 +60390,7 @@ uri$1.default = uri;
|
|
|
60426
60390
|
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
60427
60391
|
return codegen_12.CodeGen;
|
|
60428
60392
|
} });
|
|
60429
|
-
const validation_error_12 =
|
|
60393
|
+
const validation_error_12 = validation_error;
|
|
60430
60394
|
const ref_error_12 = ref_error;
|
|
60431
60395
|
const rules_12 = rules;
|
|
60432
60396
|
const compile_12 = compile;
|
|
@@ -62014,7 +61978,7 @@ const def$a = {
|
|
|
62014
61978
|
additionalProperties.default = def$a;
|
|
62015
61979
|
var properties$1 = {};
|
|
62016
61980
|
Object.defineProperty(properties$1, "__esModule", { value: true });
|
|
62017
|
-
const validate_1 =
|
|
61981
|
+
const validate_1 = validate;
|
|
62018
61982
|
const code_1$2 = code;
|
|
62019
61983
|
const util_1$7 = util;
|
|
62020
61984
|
const additionalProperties_1$1 = additionalProperties;
|
|
@@ -62865,7 +62829,7 @@ const require$$3 = {
|
|
|
62865
62829
|
module.exports.Ajv = Ajv2;
|
|
62866
62830
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
62867
62831
|
exports$1.default = Ajv2;
|
|
62868
|
-
var validate_12 =
|
|
62832
|
+
var validate_12 = validate;
|
|
62869
62833
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
62870
62834
|
return validate_12.KeywordCxt;
|
|
62871
62835
|
} });
|
|
@@ -62888,7 +62852,7 @@ const require$$3 = {
|
|
|
62888
62852
|
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
62889
62853
|
return codegen_12.CodeGen;
|
|
62890
62854
|
} });
|
|
62891
|
-
var validation_error_12 =
|
|
62855
|
+
var validation_error_12 = validation_error;
|
|
62892
62856
|
Object.defineProperty(exports$1, "ValidationError", { enumerable: true, get: function() {
|
|
62893
62857
|
return validation_error_12.default;
|
|
62894
62858
|
} });
|
|
@@ -70865,7 +70829,7 @@ function App() {
|
|
|
70865
70829
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "#6aa3c8" }, children: "Spector" }),
|
|
70866
70830
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-2 text-[10px] font-normal opacity-50", children: [
|
|
70867
70831
|
"v",
|
|
70868
|
-
"0.3.
|
|
70832
|
+
"0.3.4"
|
|
70869
70833
|
] }),
|
|
70870
70834
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mx-2 opacity-30", children: "·" }),
|
|
70871
70835
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|