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