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