@spooky-sync/cli 0.0.1-canary.370 → 0.0.1-canary.372
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/devtools-mcp/index.js +881 -839
- package/package.json +6 -6
package/devtools-mcp/index.js
CHANGED
|
@@ -16369,8 +16369,8 @@ var scope = {};
|
|
|
16369
16369
|
var util = {};
|
|
16370
16370
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
16371
16371
|
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;
|
|
16372
|
-
const codegen_1$
|
|
16373
|
-
const code_1$
|
|
16372
|
+
const codegen_1$q = codegen;
|
|
16373
|
+
const code_1$9 = code$1;
|
|
16374
16374
|
function toHash(arr) {
|
|
16375
16375
|
const hash = {};
|
|
16376
16376
|
for (const item of arr)
|
|
@@ -16423,9 +16423,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
|
|
|
16423
16423
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
16424
16424
|
return schema;
|
|
16425
16425
|
if (typeof schema == "string")
|
|
16426
|
-
return (0, codegen_1$
|
|
16426
|
+
return (0, codegen_1$q._)`${schema}`;
|
|
16427
16427
|
}
|
|
16428
|
-
return (0, codegen_1$
|
|
16428
|
+
return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
|
|
16429
16429
|
}
|
|
16430
16430
|
util.schemaRefOrVal = schemaRefOrVal;
|
|
16431
16431
|
function unescapeFragment(str) {
|
|
@@ -16457,20 +16457,20 @@ function eachItem(xs, f) {
|
|
|
16457
16457
|
util.eachItem = eachItem;
|
|
16458
16458
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
|
|
16459
16459
|
return (gen, from, to, toName) => {
|
|
16460
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
16461
|
-
return toName === codegen_1$
|
|
16460
|
+
const res = to === void 0 ? from : to instanceof codegen_1$q.Name ? (from instanceof codegen_1$q.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$q.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
|
|
16461
|
+
return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
|
|
16462
16462
|
};
|
|
16463
16463
|
}
|
|
16464
16464
|
util.mergeEvaluated = {
|
|
16465
16465
|
props: makeMergeEvaluated({
|
|
16466
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
16467
|
-
gen.if((0, codegen_1$
|
|
16466
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
|
|
16467
|
+
gen.if((0, codegen_1$q._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$q._)`${to} || {}`).code((0, codegen_1$q._)`Object.assign(${to}, ${from})`));
|
|
16468
16468
|
}),
|
|
16469
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
16469
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
|
|
16470
16470
|
if (from === true) {
|
|
16471
16471
|
gen.assign(to, true);
|
|
16472
16472
|
} else {
|
|
16473
|
-
gen.assign(to, (0, codegen_1$
|
|
16473
|
+
gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
|
|
16474
16474
|
setEvaluated(gen, to, from);
|
|
16475
16475
|
}
|
|
16476
16476
|
}),
|
|
@@ -16478,8 +16478,8 @@ util.mergeEvaluated = {
|
|
|
16478
16478
|
resultToName: evaluatedPropsToName
|
|
16479
16479
|
}),
|
|
16480
16480
|
items: makeMergeEvaluated({
|
|
16481
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
16482
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
16481
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$q._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
|
|
16482
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$q._)`${to} > ${from} ? ${to} : ${from}`)),
|
|
16483
16483
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
16484
16484
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
16485
16485
|
})
|
|
@@ -16487,21 +16487,21 @@ util.mergeEvaluated = {
|
|
|
16487
16487
|
function evaluatedPropsToName(gen, ps) {
|
|
16488
16488
|
if (ps === true)
|
|
16489
16489
|
return gen.var("props", true);
|
|
16490
|
-
const props = gen.var("props", (0, codegen_1$
|
|
16490
|
+
const props = gen.var("props", (0, codegen_1$q._)`{}`);
|
|
16491
16491
|
if (ps !== void 0)
|
|
16492
16492
|
setEvaluated(gen, props, ps);
|
|
16493
16493
|
return props;
|
|
16494
16494
|
}
|
|
16495
16495
|
util.evaluatedPropsToName = evaluatedPropsToName;
|
|
16496
16496
|
function setEvaluated(gen, props, ps) {
|
|
16497
|
-
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$
|
|
16497
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p)}`, true));
|
|
16498
16498
|
}
|
|
16499
16499
|
util.setEvaluated = setEvaluated;
|
|
16500
16500
|
const snippets = {};
|
|
16501
16501
|
function useFunc(gen, f) {
|
|
16502
16502
|
return gen.scopeValue("func", {
|
|
16503
16503
|
ref: f,
|
|
16504
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
16504
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
|
|
16505
16505
|
});
|
|
16506
16506
|
}
|
|
16507
16507
|
util.useFunc = useFunc;
|
|
@@ -16511,11 +16511,11 @@ var Type;
|
|
|
16511
16511
|
Type2[Type2["Str"] = 1] = "Str";
|
|
16512
16512
|
})(Type || (util.Type = Type = {}));
|
|
16513
16513
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
16514
|
-
if (dataProp instanceof codegen_1$
|
|
16514
|
+
if (dataProp instanceof codegen_1$q.Name) {
|
|
16515
16515
|
const isNumber = dataPropType === Type.Num;
|
|
16516
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
16516
|
+
return jsPropertySyntax ? isNumber ? (0, codegen_1$q._)`"[" + ${dataProp} + "]"` : (0, codegen_1$q._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$q._)`"/" + ${dataProp}` : (0, codegen_1$q._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
16517
16517
|
}
|
|
16518
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
16518
|
+
return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
|
16519
16519
|
}
|
|
16520
16520
|
util.getErrorPath = getErrorPath;
|
|
16521
16521
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -16529,35 +16529,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
|
16529
16529
|
util.checkStrictMode = checkStrictMode;
|
|
16530
16530
|
var names$1 = {};
|
|
16531
16531
|
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
16532
|
-
const codegen_1$
|
|
16532
|
+
const codegen_1$p = codegen;
|
|
16533
16533
|
const names = {
|
|
16534
16534
|
// validation function arguments
|
|
16535
|
-
data: new codegen_1$
|
|
16535
|
+
data: new codegen_1$p.Name("data"),
|
|
16536
16536
|
// data passed to validation function
|
|
16537
16537
|
// args passed from referencing schema
|
|
16538
|
-
valCxt: new codegen_1$
|
|
16538
|
+
valCxt: new codegen_1$p.Name("valCxt"),
|
|
16539
16539
|
// validation/data context - should not be used directly, it is destructured to the names below
|
|
16540
|
-
instancePath: new codegen_1$
|
|
16541
|
-
parentData: new codegen_1$
|
|
16542
|
-
parentDataProperty: new codegen_1$
|
|
16543
|
-
rootData: new codegen_1$
|
|
16540
|
+
instancePath: new codegen_1$p.Name("instancePath"),
|
|
16541
|
+
parentData: new codegen_1$p.Name("parentData"),
|
|
16542
|
+
parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
|
|
16543
|
+
rootData: new codegen_1$p.Name("rootData"),
|
|
16544
16544
|
// root data - same as the data passed to the first/top validation function
|
|
16545
|
-
dynamicAnchors: new codegen_1$
|
|
16545
|
+
dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
|
|
16546
16546
|
// used to support recursiveRef and dynamicRef
|
|
16547
16547
|
// function scoped variables
|
|
16548
|
-
vErrors: new codegen_1$
|
|
16548
|
+
vErrors: new codegen_1$p.Name("vErrors"),
|
|
16549
16549
|
// null or array of validation errors
|
|
16550
|
-
errors: new codegen_1$
|
|
16550
|
+
errors: new codegen_1$p.Name("errors"),
|
|
16551
16551
|
// counter of validation errors
|
|
16552
|
-
this: new codegen_1$
|
|
16552
|
+
this: new codegen_1$p.Name("this"),
|
|
16553
16553
|
// "globals"
|
|
16554
|
-
self: new codegen_1$
|
|
16555
|
-
scope: new codegen_1$
|
|
16554
|
+
self: new codegen_1$p.Name("self"),
|
|
16555
|
+
scope: new codegen_1$p.Name("scope"),
|
|
16556
16556
|
// JTD serialize/parse name for JSON string and position
|
|
16557
|
-
json: new codegen_1$
|
|
16558
|
-
jsonPos: new codegen_1$
|
|
16559
|
-
jsonLen: new codegen_1$
|
|
16560
|
-
jsonPart: new codegen_1$
|
|
16557
|
+
json: new codegen_1$p.Name("json"),
|
|
16558
|
+
jsonPos: new codegen_1$p.Name("jsonPos"),
|
|
16559
|
+
jsonLen: new codegen_1$p.Name("jsonLen"),
|
|
16560
|
+
jsonPart: new codegen_1$p.Name("jsonPart")
|
|
16561
16561
|
};
|
|
16562
16562
|
names$1.default = names;
|
|
16563
16563
|
(function(exports) {
|
|
@@ -16677,49 +16677,55 @@ names$1.default = names;
|
|
|
16677
16677
|
keyValues.push([E.propertyName, propertyName]);
|
|
16678
16678
|
}
|
|
16679
16679
|
})(errors);
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
const
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
gen
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16680
|
+
var hasRequiredBoolSchema;
|
|
16681
|
+
function requireBoolSchema() {
|
|
16682
|
+
if (hasRequiredBoolSchema) return boolSchema;
|
|
16683
|
+
hasRequiredBoolSchema = 1;
|
|
16684
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
16685
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
16686
|
+
const errors_12 = errors;
|
|
16687
|
+
const codegen_12 = codegen;
|
|
16688
|
+
const names_12 = names$1;
|
|
16689
|
+
const boolError = {
|
|
16690
|
+
message: "boolean schema is false"
|
|
16691
|
+
};
|
|
16692
|
+
function topBoolOrEmptySchema(it) {
|
|
16693
|
+
const { gen, schema, validateName } = it;
|
|
16694
|
+
if (schema === false) {
|
|
16695
|
+
falseSchemaError(it, false);
|
|
16696
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
16697
|
+
gen.return(names_12.default.data);
|
|
16698
|
+
} else {
|
|
16699
|
+
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
16700
|
+
gen.return(true);
|
|
16701
|
+
}
|
|
16697
16702
|
}
|
|
16698
|
-
|
|
16699
|
-
|
|
16700
|
-
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
16703
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
16704
|
+
function boolOrEmptySchema(it, valid) {
|
|
16705
|
+
const { gen, schema } = it;
|
|
16706
|
+
if (schema === false) {
|
|
16707
|
+
gen.var(valid, false);
|
|
16708
|
+
falseSchemaError(it);
|
|
16709
|
+
} else {
|
|
16710
|
+
gen.var(valid, true);
|
|
16711
|
+
}
|
|
16707
16712
|
}
|
|
16708
|
-
|
|
16709
|
-
|
|
16710
|
-
|
|
16711
|
-
|
|
16712
|
-
|
|
16713
|
-
|
|
16714
|
-
|
|
16715
|
-
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
16719
|
-
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16713
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
16714
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
16715
|
+
const { gen, data } = it;
|
|
16716
|
+
const cxt = {
|
|
16717
|
+
gen,
|
|
16718
|
+
keyword: "false schema",
|
|
16719
|
+
data,
|
|
16720
|
+
schema: false,
|
|
16721
|
+
schemaCode: false,
|
|
16722
|
+
schemaValue: false,
|
|
16723
|
+
params: {},
|
|
16724
|
+
it
|
|
16725
|
+
};
|
|
16726
|
+
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
16727
|
+
}
|
|
16728
|
+
return boolSchema;
|
|
16723
16729
|
}
|
|
16724
16730
|
var dataType = {};
|
|
16725
16731
|
var rules = {};
|
|
@@ -16748,29 +16754,35 @@ function getRules() {
|
|
|
16748
16754
|
}
|
|
16749
16755
|
rules.getRules = getRules;
|
|
16750
16756
|
var applicability = {};
|
|
16751
|
-
|
|
16752
|
-
|
|
16753
|
-
|
|
16754
|
-
|
|
16755
|
-
|
|
16756
|
-
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
}
|
|
16761
|
-
applicability.
|
|
16762
|
-
function
|
|
16763
|
-
|
|
16764
|
-
|
|
16757
|
+
var hasRequiredApplicability;
|
|
16758
|
+
function requireApplicability() {
|
|
16759
|
+
if (hasRequiredApplicability) return applicability;
|
|
16760
|
+
hasRequiredApplicability = 1;
|
|
16761
|
+
Object.defineProperty(applicability, "__esModule", { value: true });
|
|
16762
|
+
applicability.shouldUseRule = applicability.shouldUseGroup = applicability.schemaHasRulesForType = void 0;
|
|
16763
|
+
function schemaHasRulesForType({ schema, self }, type2) {
|
|
16764
|
+
const group = self.RULES.types[type2];
|
|
16765
|
+
return group && group !== true && shouldUseGroup(schema, group);
|
|
16766
|
+
}
|
|
16767
|
+
applicability.schemaHasRulesForType = schemaHasRulesForType;
|
|
16768
|
+
function shouldUseGroup(schema, group) {
|
|
16769
|
+
return group.rules.some((rule) => shouldUseRule(schema, rule));
|
|
16770
|
+
}
|
|
16771
|
+
applicability.shouldUseGroup = shouldUseGroup;
|
|
16772
|
+
function shouldUseRule(schema, rule) {
|
|
16773
|
+
var _a;
|
|
16774
|
+
return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
|
|
16775
|
+
}
|
|
16776
|
+
applicability.shouldUseRule = shouldUseRule;
|
|
16777
|
+
return applicability;
|
|
16765
16778
|
}
|
|
16766
|
-
applicability.shouldUseRule = shouldUseRule;
|
|
16767
16779
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
16768
16780
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
16769
16781
|
const rules_1 = rules;
|
|
16770
|
-
const applicability_1
|
|
16771
|
-
const errors_1
|
|
16772
|
-
const codegen_1$
|
|
16773
|
-
const util_1$
|
|
16782
|
+
const applicability_1 = requireApplicability();
|
|
16783
|
+
const errors_1 = errors;
|
|
16784
|
+
const codegen_1$o = codegen;
|
|
16785
|
+
const util_1$o = util;
|
|
16774
16786
|
var DataType;
|
|
16775
16787
|
(function(DataType2) {
|
|
16776
16788
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -16802,7 +16814,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
16802
16814
|
function coerceAndCheckDataType(it, types2) {
|
|
16803
16815
|
const { gen, data, opts } = it;
|
|
16804
16816
|
const coerceTo = coerceToTypes(types2, opts.coerceTypes);
|
|
16805
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1
|
|
16817
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
16806
16818
|
if (checkTypes) {
|
|
16807
16819
|
const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
|
|
16808
16820
|
gen.if(wrongType, () => {
|
|
@@ -16821,12 +16833,12 @@ function coerceToTypes(types2, coerceTypes) {
|
|
|
16821
16833
|
}
|
|
16822
16834
|
function coerceData(it, types2, coerceTo) {
|
|
16823
16835
|
const { gen, data, opts } = it;
|
|
16824
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
16825
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
16836
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
|
|
16837
|
+
const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
|
|
16826
16838
|
if (opts.coerceTypes === "array") {
|
|
16827
|
-
gen.if((0, codegen_1$
|
|
16839
|
+
gen.if((0, codegen_1$o._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$o._)`${data}[0]`).assign(dataType2, (0, codegen_1$o._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
16828
16840
|
}
|
|
16829
|
-
gen.if((0, codegen_1$
|
|
16841
|
+
gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
|
|
16830
16842
|
for (const t of coerceTo) {
|
|
16831
16843
|
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
|
|
16832
16844
|
coerceSpecificType(t);
|
|
@@ -16835,63 +16847,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
16835
16847
|
gen.else();
|
|
16836
16848
|
reportTypeError(it);
|
|
16837
16849
|
gen.endIf();
|
|
16838
|
-
gen.if((0, codegen_1$
|
|
16850
|
+
gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
|
|
16839
16851
|
gen.assign(data, coerced);
|
|
16840
16852
|
assignParentData(it, coerced);
|
|
16841
16853
|
});
|
|
16842
16854
|
function coerceSpecificType(t) {
|
|
16843
16855
|
switch (t) {
|
|
16844
16856
|
case "string":
|
|
16845
|
-
gen.elseIf((0, codegen_1$
|
|
16857
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$o._)`"" + ${data}`).elseIf((0, codegen_1$o._)`${data} === null`).assign(coerced, (0, codegen_1$o._)`""`);
|
|
16846
16858
|
return;
|
|
16847
16859
|
case "number":
|
|
16848
|
-
gen.elseIf((0, codegen_1$
|
|
16849
|
-
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$
|
|
16860
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
|
|
16861
|
+
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
|
|
16850
16862
|
return;
|
|
16851
16863
|
case "integer":
|
|
16852
|
-
gen.elseIf((0, codegen_1$
|
|
16853
|
-
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$
|
|
16864
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
|
|
16865
|
+
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
|
|
16854
16866
|
return;
|
|
16855
16867
|
case "boolean":
|
|
16856
|
-
gen.elseIf((0, codegen_1$
|
|
16868
|
+
gen.elseIf((0, codegen_1$o._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$o._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
|
|
16857
16869
|
return;
|
|
16858
16870
|
case "null":
|
|
16859
|
-
gen.elseIf((0, codegen_1$
|
|
16871
|
+
gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
|
|
16860
16872
|
gen.assign(coerced, null);
|
|
16861
16873
|
return;
|
|
16862
16874
|
case "array":
|
|
16863
|
-
gen.elseIf((0, codegen_1$
|
|
16864
|
-
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$
|
|
16875
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
16876
|
+
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
|
|
16865
16877
|
}
|
|
16866
16878
|
}
|
|
16867
16879
|
}
|
|
16868
16880
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
16869
|
-
gen.if((0, codegen_1$
|
|
16881
|
+
gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
|
|
16870
16882
|
}
|
|
16871
16883
|
function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
|
|
16872
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
16884
|
+
const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
|
|
16873
16885
|
let cond;
|
|
16874
16886
|
switch (dataType2) {
|
|
16875
16887
|
case "null":
|
|
16876
|
-
return (0, codegen_1$
|
|
16888
|
+
return (0, codegen_1$o._)`${data} ${EQ} null`;
|
|
16877
16889
|
case "array":
|
|
16878
|
-
cond = (0, codegen_1$
|
|
16890
|
+
cond = (0, codegen_1$o._)`Array.isArray(${data})`;
|
|
16879
16891
|
break;
|
|
16880
16892
|
case "object":
|
|
16881
|
-
cond = (0, codegen_1$
|
|
16893
|
+
cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
|
|
16882
16894
|
break;
|
|
16883
16895
|
case "integer":
|
|
16884
|
-
cond = numCond((0, codegen_1$
|
|
16896
|
+
cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
|
|
16885
16897
|
break;
|
|
16886
16898
|
case "number":
|
|
16887
16899
|
cond = numCond();
|
|
16888
16900
|
break;
|
|
16889
16901
|
default:
|
|
16890
|
-
return (0, codegen_1$
|
|
16902
|
+
return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
|
|
16891
16903
|
}
|
|
16892
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
16893
|
-
function numCond(_cond = codegen_1$
|
|
16894
|
-
return (0, codegen_1$
|
|
16904
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
|
|
16905
|
+
function numCond(_cond = codegen_1$o.nil) {
|
|
16906
|
+
return (0, codegen_1$o.and)((0, codegen_1$o._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$o._)`isFinite(${data})` : codegen_1$o.nil);
|
|
16895
16907
|
}
|
|
16896
16908
|
}
|
|
16897
16909
|
dataType.checkDataType = checkDataType;
|
|
@@ -16900,35 +16912,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
|
16900
16912
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
16901
16913
|
}
|
|
16902
16914
|
let cond;
|
|
16903
|
-
const types2 = (0, util_1$
|
|
16915
|
+
const types2 = (0, util_1$o.toHash)(dataTypes);
|
|
16904
16916
|
if (types2.array && types2.object) {
|
|
16905
|
-
const notObj = (0, codegen_1$
|
|
16906
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
16917
|
+
const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
|
|
16918
|
+
cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
|
|
16907
16919
|
delete types2.null;
|
|
16908
16920
|
delete types2.array;
|
|
16909
16921
|
delete types2.object;
|
|
16910
16922
|
} else {
|
|
16911
|
-
cond = codegen_1$
|
|
16923
|
+
cond = codegen_1$o.nil;
|
|
16912
16924
|
}
|
|
16913
16925
|
if (types2.number)
|
|
16914
16926
|
delete types2.integer;
|
|
16915
16927
|
for (const t in types2)
|
|
16916
|
-
cond = (0, codegen_1$
|
|
16928
|
+
cond = (0, codegen_1$o.and)(cond, checkDataType(t, data, strictNums, correct));
|
|
16917
16929
|
return cond;
|
|
16918
16930
|
}
|
|
16919
16931
|
dataType.checkDataTypes = checkDataTypes;
|
|
16920
16932
|
const typeError = {
|
|
16921
16933
|
message: ({ schema }) => `must be ${schema}`,
|
|
16922
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
16934
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
|
|
16923
16935
|
};
|
|
16924
16936
|
function reportTypeError(it) {
|
|
16925
16937
|
const cxt = getTypeErrorContext(it);
|
|
16926
|
-
(0, errors_1
|
|
16938
|
+
(0, errors_1.reportError)(cxt, typeError);
|
|
16927
16939
|
}
|
|
16928
16940
|
dataType.reportTypeError = reportTypeError;
|
|
16929
16941
|
function getTypeErrorContext(it) {
|
|
16930
16942
|
const { gen, data, schema } = it;
|
|
16931
|
-
const schemaCode = (0, util_1$
|
|
16943
|
+
const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
|
|
16932
16944
|
return {
|
|
16933
16945
|
gen,
|
|
16934
16946
|
keyword: "type",
|
|
@@ -16942,54 +16954,60 @@ function getTypeErrorContext(it) {
|
|
|
16942
16954
|
};
|
|
16943
16955
|
}
|
|
16944
16956
|
var defaults = {};
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
}
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
|
|
16958
|
-
}
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
if (defaultValue === void 0)
|
|
16963
|
-
return;
|
|
16964
|
-
const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
16965
|
-
if (compositeRule) {
|
|
16966
|
-
(0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
16967
|
-
return;
|
|
16957
|
+
var hasRequiredDefaults;
|
|
16958
|
+
function requireDefaults() {
|
|
16959
|
+
if (hasRequiredDefaults) return defaults;
|
|
16960
|
+
hasRequiredDefaults = 1;
|
|
16961
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
16962
|
+
defaults.assignDefaults = void 0;
|
|
16963
|
+
const codegen_12 = codegen;
|
|
16964
|
+
const util_12 = util;
|
|
16965
|
+
function assignDefaults(it, ty) {
|
|
16966
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
16967
|
+
if (ty === "object" && properties2) {
|
|
16968
|
+
for (const key in properties2) {
|
|
16969
|
+
assignDefault(it, key, properties2[key].default);
|
|
16970
|
+
}
|
|
16971
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
16972
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
16973
|
+
}
|
|
16968
16974
|
}
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16975
|
+
defaults.assignDefaults = assignDefaults;
|
|
16976
|
+
function assignDefault(it, prop, defaultValue) {
|
|
16977
|
+
const { gen, compositeRule, data, opts } = it;
|
|
16978
|
+
if (defaultValue === void 0)
|
|
16979
|
+
return;
|
|
16980
|
+
const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
|
|
16981
|
+
if (compositeRule) {
|
|
16982
|
+
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
16983
|
+
return;
|
|
16984
|
+
}
|
|
16985
|
+
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
16986
|
+
if (opts.useDefaults === "empty") {
|
|
16987
|
+
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
16988
|
+
}
|
|
16989
|
+
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
16972
16990
|
}
|
|
16973
|
-
|
|
16991
|
+
return defaults;
|
|
16974
16992
|
}
|
|
16975
16993
|
var keyword = {};
|
|
16976
16994
|
var code = {};
|
|
16977
16995
|
Object.defineProperty(code, "__esModule", { value: true });
|
|
16978
16996
|
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;
|
|
16979
|
-
const codegen_1$
|
|
16980
|
-
const util_1$
|
|
16981
|
-
const names_1$
|
|
16997
|
+
const codegen_1$n = codegen;
|
|
16998
|
+
const util_1$n = util;
|
|
16999
|
+
const names_1$3 = names$1;
|
|
16982
17000
|
const util_2$1 = util;
|
|
16983
17001
|
function checkReportMissingProp(cxt, prop) {
|
|
16984
17002
|
const { gen, data, it } = cxt;
|
|
16985
17003
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
16986
|
-
cxt.setParams({ missingProperty: (0, codegen_1$
|
|
17004
|
+
cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
|
|
16987
17005
|
cxt.error();
|
|
16988
17006
|
});
|
|
16989
17007
|
}
|
|
16990
17008
|
code.checkReportMissingProp = checkReportMissingProp;
|
|
16991
17009
|
function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
|
|
16992
|
-
return (0, codegen_1$
|
|
17010
|
+
return (0, codegen_1$n.or)(...properties2.map((prop) => (0, codegen_1$n.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$n._)`${missing} = ${prop}`)));
|
|
16993
17011
|
}
|
|
16994
17012
|
code.checkMissingProp = checkMissingProp;
|
|
16995
17013
|
function reportMissingProp(cxt, missing) {
|
|
@@ -17001,22 +17019,22 @@ function hasPropFunc(gen) {
|
|
|
17001
17019
|
return gen.scopeValue("func", {
|
|
17002
17020
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
17003
17021
|
ref: Object.prototype.hasOwnProperty,
|
|
17004
|
-
code: (0, codegen_1$
|
|
17022
|
+
code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
|
|
17005
17023
|
});
|
|
17006
17024
|
}
|
|
17007
17025
|
code.hasPropFunc = hasPropFunc;
|
|
17008
17026
|
function isOwnProperty(gen, data, property) {
|
|
17009
|
-
return (0, codegen_1$
|
|
17027
|
+
return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
|
|
17010
17028
|
}
|
|
17011
17029
|
code.isOwnProperty = isOwnProperty;
|
|
17012
17030
|
function propertyInData(gen, data, property, ownProperties) {
|
|
17013
|
-
const cond = (0, codegen_1$
|
|
17014
|
-
return ownProperties ? (0, codegen_1$
|
|
17031
|
+
const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
|
|
17032
|
+
return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
|
|
17015
17033
|
}
|
|
17016
17034
|
code.propertyInData = propertyInData;
|
|
17017
17035
|
function noPropertyInData(gen, data, property, ownProperties) {
|
|
17018
|
-
const cond = (0, codegen_1$
|
|
17019
|
-
return ownProperties ? (0, codegen_1$
|
|
17036
|
+
const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
|
|
17037
|
+
return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
|
|
17020
17038
|
}
|
|
17021
17039
|
code.noPropertyInData = noPropertyInData;
|
|
17022
17040
|
function allSchemaProperties(schemaMap) {
|
|
@@ -17024,24 +17042,24 @@ function allSchemaProperties(schemaMap) {
|
|
|
17024
17042
|
}
|
|
17025
17043
|
code.allSchemaProperties = allSchemaProperties;
|
|
17026
17044
|
function schemaProperties(it, schemaMap) {
|
|
17027
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$
|
|
17045
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$n.alwaysValidSchema)(it, schemaMap[p]));
|
|
17028
17046
|
}
|
|
17029
17047
|
code.schemaProperties = schemaProperties;
|
|
17030
17048
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
17031
|
-
const dataAndSchema = passSchema ? (0, codegen_1$
|
|
17049
|
+
const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
|
|
17032
17050
|
const valCxt = [
|
|
17033
|
-
[names_1$
|
|
17034
|
-
[names_1$
|
|
17035
|
-
[names_1$
|
|
17036
|
-
[names_1$
|
|
17051
|
+
[names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
|
|
17052
|
+
[names_1$3.default.parentData, it.parentData],
|
|
17053
|
+
[names_1$3.default.parentDataProperty, it.parentDataProperty],
|
|
17054
|
+
[names_1$3.default.rootData, names_1$3.default.rootData]
|
|
17037
17055
|
];
|
|
17038
17056
|
if (it.opts.dynamicRef)
|
|
17039
|
-
valCxt.push([names_1$
|
|
17040
|
-
const args = (0, codegen_1$
|
|
17041
|
-
return context !== codegen_1$
|
|
17057
|
+
valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
|
|
17058
|
+
const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
17059
|
+
return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
|
|
17042
17060
|
}
|
|
17043
17061
|
code.callValidateCode = callValidateCode;
|
|
17044
|
-
const newRegExp = (0, codegen_1$
|
|
17062
|
+
const newRegExp = (0, codegen_1$n._)`new RegExp`;
|
|
17045
17063
|
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
17046
17064
|
const u = opts.unicodeRegExp ? "u" : "";
|
|
17047
17065
|
const { regExp } = opts.code;
|
|
@@ -17049,7 +17067,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
|
|
|
17049
17067
|
return gen.scopeValue("pattern", {
|
|
17050
17068
|
key: rx.toString(),
|
|
17051
17069
|
ref: rx,
|
|
17052
|
-
code: (0, codegen_1$
|
|
17070
|
+
code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
17053
17071
|
});
|
|
17054
17072
|
}
|
|
17055
17073
|
code.usePattern = usePattern;
|
|
@@ -17065,14 +17083,14 @@ function validateArray(cxt) {
|
|
|
17065
17083
|
validateItems(() => gen.break());
|
|
17066
17084
|
return valid;
|
|
17067
17085
|
function validateItems(notValid) {
|
|
17068
|
-
const len = gen.const("len", (0, codegen_1$
|
|
17086
|
+
const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
|
|
17069
17087
|
gen.forRange("i", 0, len, (i) => {
|
|
17070
17088
|
cxt.subschema({
|
|
17071
17089
|
keyword: keyword2,
|
|
17072
17090
|
dataProp: i,
|
|
17073
|
-
dataPropType: util_1$
|
|
17091
|
+
dataPropType: util_1$n.Type.Num
|
|
17074
17092
|
}, valid);
|
|
17075
|
-
gen.if((0, codegen_1$
|
|
17093
|
+
gen.if((0, codegen_1$n.not)(valid), notValid);
|
|
17076
17094
|
});
|
|
17077
17095
|
}
|
|
17078
17096
|
}
|
|
@@ -17081,7 +17099,7 @@ function validateUnion(cxt) {
|
|
|
17081
17099
|
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
17082
17100
|
if (!Array.isArray(schema))
|
|
17083
17101
|
throw new Error("ajv implementation error");
|
|
17084
|
-
const alwaysValid = schema.some((sch) => (0, util_1$
|
|
17102
|
+
const alwaysValid = schema.some((sch) => (0, util_1$n.alwaysValidSchema)(it, sch));
|
|
17085
17103
|
if (alwaysValid && !it.opts.unevaluated)
|
|
17086
17104
|
return;
|
|
17087
17105
|
const valid = gen.let("valid", false);
|
|
@@ -17092,202 +17110,214 @@ function validateUnion(cxt) {
|
|
|
17092
17110
|
schemaProp: i,
|
|
17093
17111
|
compositeRule: true
|
|
17094
17112
|
}, schValid);
|
|
17095
|
-
gen.assign(valid, (0, codegen_1$
|
|
17113
|
+
gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
|
|
17096
17114
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
17097
17115
|
if (!merged)
|
|
17098
|
-
gen.if((0, codegen_1$
|
|
17116
|
+
gen.if((0, codegen_1$n.not)(valid));
|
|
17099
17117
|
}));
|
|
17100
17118
|
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
17101
17119
|
}
|
|
17102
17120
|
code.validateUnion = validateUnion;
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
const
|
|
17111
|
-
const
|
|
17112
|
-
const
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17118
|
-
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
|
|
17122
|
-
|
|
17123
|
-
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
|
|
17128
|
-
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
17129
|
-
checkAsyncKeyword(it, def2);
|
|
17130
|
-
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
17131
|
-
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
17132
|
-
const valid = gen.let("valid");
|
|
17133
|
-
cxt.block$data(valid, validateKeyword);
|
|
17134
|
-
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
17135
|
-
function validateKeyword() {
|
|
17136
|
-
if (def2.errors === false) {
|
|
17137
|
-
assignValid();
|
|
17138
|
-
if (def2.modifying)
|
|
17139
|
-
modifyData(cxt);
|
|
17140
|
-
reportErrs(() => cxt.error());
|
|
17141
|
-
} else {
|
|
17142
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
17143
|
-
if (def2.modifying)
|
|
17144
|
-
modifyData(cxt);
|
|
17145
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
17146
|
-
}
|
|
17147
|
-
}
|
|
17148
|
-
function validateAsync() {
|
|
17149
|
-
const ruleErrs = gen.let("ruleErrs", null);
|
|
17150
|
-
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)));
|
|
17151
|
-
return ruleErrs;
|
|
17152
|
-
}
|
|
17153
|
-
function validateSync() {
|
|
17154
|
-
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
17155
|
-
gen.assign(validateErrs, null);
|
|
17156
|
-
assignValid(codegen_1$p.nil);
|
|
17157
|
-
return validateErrs;
|
|
17158
|
-
}
|
|
17159
|
-
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
17160
|
-
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
17161
|
-
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
17162
|
-
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
17163
|
-
}
|
|
17164
|
-
function reportErrs(errors2) {
|
|
17165
|
-
var _a2;
|
|
17166
|
-
gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
17167
|
-
}
|
|
17168
|
-
}
|
|
17169
|
-
keyword.funcKeywordCode = funcKeywordCode;
|
|
17170
|
-
function modifyData(cxt) {
|
|
17171
|
-
const { gen, data, it } = cxt;
|
|
17172
|
-
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
17173
|
-
}
|
|
17174
|
-
function addErrs(cxt, errs) {
|
|
17175
|
-
const { gen } = cxt;
|
|
17176
|
-
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
17177
|
-
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`);
|
|
17178
|
-
(0, errors_1$1.extendErrors)(cxt);
|
|
17179
|
-
}, () => cxt.error());
|
|
17180
|
-
}
|
|
17181
|
-
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
17182
|
-
if (def2.async && !schemaEnv.$async)
|
|
17183
|
-
throw new Error("async keyword in sync schema");
|
|
17184
|
-
}
|
|
17185
|
-
function useKeyword(gen, keyword2, result) {
|
|
17186
|
-
if (result === void 0)
|
|
17187
|
-
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
17188
|
-
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
17189
|
-
}
|
|
17190
|
-
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
17191
|
-
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");
|
|
17192
|
-
}
|
|
17193
|
-
keyword.validSchemaType = validSchemaType;
|
|
17194
|
-
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
|
|
17195
|
-
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
17196
|
-
throw new Error("ajv implementation error");
|
|
17121
|
+
var hasRequiredKeyword;
|
|
17122
|
+
function requireKeyword() {
|
|
17123
|
+
if (hasRequiredKeyword) return keyword;
|
|
17124
|
+
hasRequiredKeyword = 1;
|
|
17125
|
+
Object.defineProperty(keyword, "__esModule", { value: true });
|
|
17126
|
+
keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
|
|
17127
|
+
const codegen_12 = codegen;
|
|
17128
|
+
const names_12 = names$1;
|
|
17129
|
+
const code_12 = code;
|
|
17130
|
+
const errors_12 = errors;
|
|
17131
|
+
function macroKeywordCode(cxt, def2) {
|
|
17132
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
17133
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
17134
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
17135
|
+
if (it.opts.validateSchema !== false)
|
|
17136
|
+
it.self.validateSchema(macroSchema, true);
|
|
17137
|
+
const valid = gen.name("valid");
|
|
17138
|
+
cxt.subschema({
|
|
17139
|
+
schema: macroSchema,
|
|
17140
|
+
schemaPath: codegen_12.nil,
|
|
17141
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
17142
|
+
topSchemaRef: schemaRef,
|
|
17143
|
+
compositeRule: true
|
|
17144
|
+
}, valid);
|
|
17145
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
17197
17146
|
}
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17147
|
+
keyword.macroKeywordCode = macroKeywordCode;
|
|
17148
|
+
function funcKeywordCode(cxt, def2) {
|
|
17149
|
+
var _a;
|
|
17150
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
17151
|
+
checkAsyncKeyword(it, def2);
|
|
17152
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
17153
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
17154
|
+
const valid = gen.let("valid");
|
|
17155
|
+
cxt.block$data(valid, validateKeyword);
|
|
17156
|
+
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
17157
|
+
function validateKeyword() {
|
|
17158
|
+
if (def2.errors === false) {
|
|
17159
|
+
assignValid();
|
|
17160
|
+
if (def2.modifying)
|
|
17161
|
+
modifyData(cxt);
|
|
17162
|
+
reportErrs(() => cxt.error());
|
|
17163
|
+
} else {
|
|
17164
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
17165
|
+
if (def2.modifying)
|
|
17166
|
+
modifyData(cxt);
|
|
17167
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
17168
|
+
}
|
|
17169
|
+
}
|
|
17170
|
+
function validateAsync() {
|
|
17171
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
17172
|
+
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)));
|
|
17173
|
+
return ruleErrs;
|
|
17174
|
+
}
|
|
17175
|
+
function validateSync() {
|
|
17176
|
+
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
17177
|
+
gen.assign(validateErrs, null);
|
|
17178
|
+
assignValid(codegen_12.nil);
|
|
17179
|
+
return validateErrs;
|
|
17180
|
+
}
|
|
17181
|
+
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
17182
|
+
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
17183
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
17184
|
+
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
17185
|
+
}
|
|
17186
|
+
function reportErrs(errors2) {
|
|
17187
|
+
var _a2;
|
|
17188
|
+
gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
17189
|
+
}
|
|
17201
17190
|
}
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
17191
|
+
keyword.funcKeywordCode = funcKeywordCode;
|
|
17192
|
+
function modifyData(cxt) {
|
|
17193
|
+
const { gen, data, it } = cxt;
|
|
17194
|
+
gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
17195
|
+
}
|
|
17196
|
+
function addErrs(cxt, errs) {
|
|
17197
|
+
const { gen } = cxt;
|
|
17198
|
+
gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
|
|
17199
|
+
gen.assign(names_12.default.vErrors, (0, codegen_12._)`${names_12.default.vErrors} === null ? ${errs} : ${names_12.default.vErrors}.concat(${errs})`).assign(names_12.default.errors, (0, codegen_12._)`${names_12.default.vErrors}.length`);
|
|
17200
|
+
(0, errors_12.extendErrors)(cxt);
|
|
17201
|
+
}, () => cxt.error());
|
|
17202
|
+
}
|
|
17203
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
17204
|
+
if (def2.async && !schemaEnv.$async)
|
|
17205
|
+
throw new Error("async keyword in sync schema");
|
|
17206
|
+
}
|
|
17207
|
+
function useKeyword(gen, keyword2, result) {
|
|
17208
|
+
if (result === void 0)
|
|
17209
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
17210
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
|
|
17211
|
+
}
|
|
17212
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
17213
|
+
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");
|
|
17214
|
+
}
|
|
17215
|
+
keyword.validSchemaType = validSchemaType;
|
|
17216
|
+
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
|
|
17217
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
17218
|
+
throw new Error("ajv implementation error");
|
|
17219
|
+
}
|
|
17220
|
+
const deps = def2.dependencies;
|
|
17221
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
17222
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
17223
|
+
}
|
|
17224
|
+
if (def2.validateSchema) {
|
|
17225
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
17226
|
+
if (!valid) {
|
|
17227
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
|
|
17228
|
+
if (opts.validateSchema === "log")
|
|
17229
|
+
self.logger.error(msg);
|
|
17230
|
+
else
|
|
17231
|
+
throw new Error(msg);
|
|
17232
|
+
}
|
|
17210
17233
|
}
|
|
17211
17234
|
}
|
|
17235
|
+
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
17236
|
+
return keyword;
|
|
17212
17237
|
}
|
|
17213
|
-
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
17214
17238
|
var subschema = {};
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
schema: sch,
|
|
17227
|
-
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
17228
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
17229
|
-
} : {
|
|
17230
|
-
schema: sch[schemaProp],
|
|
17231
|
-
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
17232
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
|
|
17233
|
-
};
|
|
17234
|
-
}
|
|
17235
|
-
if (schema !== void 0) {
|
|
17236
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
17237
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
17239
|
+
var hasRequiredSubschema;
|
|
17240
|
+
function requireSubschema() {
|
|
17241
|
+
if (hasRequiredSubschema) return subschema;
|
|
17242
|
+
hasRequiredSubschema = 1;
|
|
17243
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
17244
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
17245
|
+
const codegen_12 = codegen;
|
|
17246
|
+
const util_12 = util;
|
|
17247
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
17248
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
17249
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
17238
17250
|
}
|
|
17239
|
-
|
|
17240
|
-
schema
|
|
17241
|
-
|
|
17242
|
-
|
|
17243
|
-
|
|
17244
|
-
|
|
17245
|
-
|
|
17246
|
-
|
|
17247
|
-
}
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
|
|
17257
|
-
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
|
|
17286
|
-
|
|
17287
|
-
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17251
|
+
if (keyword2 !== void 0) {
|
|
17252
|
+
const sch = it.schema[keyword2];
|
|
17253
|
+
return schemaProp === void 0 ? {
|
|
17254
|
+
schema: sch,
|
|
17255
|
+
schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
|
|
17256
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
17257
|
+
} : {
|
|
17258
|
+
schema: sch[schemaProp],
|
|
17259
|
+
schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
|
|
17260
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
|
|
17261
|
+
};
|
|
17262
|
+
}
|
|
17263
|
+
if (schema !== void 0) {
|
|
17264
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
17265
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
17266
|
+
}
|
|
17267
|
+
return {
|
|
17268
|
+
schema,
|
|
17269
|
+
schemaPath,
|
|
17270
|
+
topSchemaRef,
|
|
17271
|
+
errSchemaPath
|
|
17272
|
+
};
|
|
17273
|
+
}
|
|
17274
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
17275
|
+
}
|
|
17276
|
+
subschema.getSubschema = getSubschema;
|
|
17277
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
|
|
17278
|
+
if (data !== void 0 && dataProp !== void 0) {
|
|
17279
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
17280
|
+
}
|
|
17281
|
+
const { gen } = it;
|
|
17282
|
+
if (dataProp !== void 0) {
|
|
17283
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
17284
|
+
const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
|
|
17285
|
+
dataContextProps(nextData);
|
|
17286
|
+
subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
17287
|
+
subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
|
|
17288
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
17289
|
+
}
|
|
17290
|
+
if (data !== void 0) {
|
|
17291
|
+
const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
|
|
17292
|
+
dataContextProps(nextData);
|
|
17293
|
+
if (propertyName !== void 0)
|
|
17294
|
+
subschema2.propertyName = propertyName;
|
|
17295
|
+
}
|
|
17296
|
+
if (dataTypes)
|
|
17297
|
+
subschema2.dataTypes = dataTypes;
|
|
17298
|
+
function dataContextProps(_nextData) {
|
|
17299
|
+
subschema2.data = _nextData;
|
|
17300
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
17301
|
+
subschema2.dataTypes = [];
|
|
17302
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
17303
|
+
subschema2.parentData = it.data;
|
|
17304
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
17305
|
+
}
|
|
17306
|
+
}
|
|
17307
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
17308
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
17309
|
+
if (compositeRule !== void 0)
|
|
17310
|
+
subschema2.compositeRule = compositeRule;
|
|
17311
|
+
if (createErrors !== void 0)
|
|
17312
|
+
subschema2.createErrors = createErrors;
|
|
17313
|
+
if (allErrors !== void 0)
|
|
17314
|
+
subschema2.allErrors = allErrors;
|
|
17315
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
17316
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
17317
|
+
}
|
|
17318
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
17319
|
+
return subschema;
|
|
17320
|
+
}
|
|
17291
17321
|
var resolve$2 = {};
|
|
17292
17322
|
var fastDeepEqual = function equal(a, b) {
|
|
17293
17323
|
if (a === b) return true;
|
|
@@ -17402,7 +17432,7 @@ function escapeJsonPtr(str) {
|
|
|
17402
17432
|
var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
|
|
17403
17433
|
Object.defineProperty(resolve$2, "__esModule", { value: true });
|
|
17404
17434
|
resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
|
|
17405
|
-
const util_1$
|
|
17435
|
+
const util_1$m = util;
|
|
17406
17436
|
const equal$3 = fastDeepEqual;
|
|
17407
17437
|
const traverse = jsonSchemaTraverseExports;
|
|
17408
17438
|
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
@@ -17461,7 +17491,7 @@ function countKeys(schema) {
|
|
|
17461
17491
|
if (SIMPLE_INLINED.has(key))
|
|
17462
17492
|
continue;
|
|
17463
17493
|
if (typeof schema[key] == "object") {
|
|
17464
|
-
(0, util_1$
|
|
17494
|
+
(0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
|
|
17465
17495
|
}
|
|
17466
17496
|
if (count === Infinity)
|
|
17467
17497
|
return Infinity;
|
|
@@ -17549,516 +17579,528 @@ function getSchemaRefs(schema, baseId) {
|
|
|
17549
17579
|
}
|
|
17550
17580
|
}
|
|
17551
17581
|
resolve$2.getSchemaRefs = getSchemaRefs;
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
const
|
|
17559
|
-
const
|
|
17560
|
-
const
|
|
17561
|
-
const
|
|
17562
|
-
const
|
|
17563
|
-
const
|
|
17564
|
-
const
|
|
17565
|
-
const
|
|
17566
|
-
|
|
17567
|
-
|
|
17568
|
-
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
17582
|
+
var hasRequiredValidate;
|
|
17583
|
+
function requireValidate() {
|
|
17584
|
+
if (hasRequiredValidate) return validate;
|
|
17585
|
+
hasRequiredValidate = 1;
|
|
17586
|
+
Object.defineProperty(validate, "__esModule", { value: true });
|
|
17587
|
+
validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
|
|
17588
|
+
const boolSchema_1 = requireBoolSchema();
|
|
17589
|
+
const dataType_12 = dataType;
|
|
17590
|
+
const applicability_12 = requireApplicability();
|
|
17591
|
+
const dataType_2 = dataType;
|
|
17592
|
+
const defaults_1 = requireDefaults();
|
|
17593
|
+
const keyword_1 = requireKeyword();
|
|
17594
|
+
const subschema_1 = requireSubschema();
|
|
17595
|
+
const codegen_12 = codegen;
|
|
17596
|
+
const names_12 = names$1;
|
|
17597
|
+
const resolve_12 = resolve$2;
|
|
17598
|
+
const util_12 = util;
|
|
17599
|
+
const errors_12 = errors;
|
|
17600
|
+
function validateFunctionCode(it) {
|
|
17601
|
+
if (isSchemaObj(it)) {
|
|
17602
|
+
checkKeywords(it);
|
|
17603
|
+
if (schemaCxtHasRules(it)) {
|
|
17604
|
+
topSchemaObjCode(it);
|
|
17605
|
+
return;
|
|
17606
|
+
}
|
|
17572
17607
|
}
|
|
17608
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
17573
17609
|
}
|
|
17574
|
-
|
|
17575
|
-
}
|
|
17576
|
-
|
|
17577
|
-
|
|
17578
|
-
|
|
17579
|
-
|
|
17580
|
-
|
|
17581
|
-
|
|
17582
|
-
|
|
17610
|
+
validate.validateFunctionCode = validateFunctionCode;
|
|
17611
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
17612
|
+
if (opts.code.es5) {
|
|
17613
|
+
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
|
|
17614
|
+
gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
17615
|
+
destructureValCxtES5(gen, opts);
|
|
17616
|
+
gen.code(body);
|
|
17617
|
+
});
|
|
17618
|
+
} else {
|
|
17619
|
+
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
17620
|
+
}
|
|
17621
|
+
}
|
|
17622
|
+
function destructureValCxt(opts) {
|
|
17623
|
+
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}}={}`;
|
|
17624
|
+
}
|
|
17625
|
+
function destructureValCxtES5(gen, opts) {
|
|
17626
|
+
gen.if(names_12.default.valCxt, () => {
|
|
17627
|
+
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
17628
|
+
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
17629
|
+
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
17630
|
+
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
17631
|
+
if (opts.dynamicRef)
|
|
17632
|
+
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
17633
|
+
}, () => {
|
|
17634
|
+
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
17635
|
+
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
17636
|
+
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
17637
|
+
gen.var(names_12.default.rootData, names_12.default.data);
|
|
17638
|
+
if (opts.dynamicRef)
|
|
17639
|
+
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
17583
17640
|
});
|
|
17584
|
-
}
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
|
|
17589
|
-
|
|
17590
|
-
|
|
17591
|
-
|
|
17592
|
-
|
|
17593
|
-
|
|
17594
|
-
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
|
|
17599
|
-
}
|
|
17600
|
-
|
|
17601
|
-
gen
|
|
17602
|
-
gen.
|
|
17603
|
-
gen.
|
|
17604
|
-
if (
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
17610
|
-
|
|
17641
|
+
}
|
|
17642
|
+
function topSchemaObjCode(it) {
|
|
17643
|
+
const { schema, opts, gen } = it;
|
|
17644
|
+
validateFunction(it, () => {
|
|
17645
|
+
if (opts.$comment && schema.$comment)
|
|
17646
|
+
commentKeyword(it);
|
|
17647
|
+
checkNoDefault(it);
|
|
17648
|
+
gen.let(names_12.default.vErrors, null);
|
|
17649
|
+
gen.let(names_12.default.errors, 0);
|
|
17650
|
+
if (opts.unevaluated)
|
|
17651
|
+
resetEvaluated(it);
|
|
17652
|
+
typeAndKeywords(it);
|
|
17653
|
+
returnResults(it);
|
|
17654
|
+
});
|
|
17655
|
+
return;
|
|
17656
|
+
}
|
|
17657
|
+
function resetEvaluated(it) {
|
|
17658
|
+
const { gen, validateName } = it;
|
|
17659
|
+
it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
|
|
17660
|
+
gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
|
|
17661
|
+
gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
|
|
17662
|
+
}
|
|
17663
|
+
function funcSourceUrl(schema, opts) {
|
|
17664
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
17665
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
|
|
17666
|
+
}
|
|
17667
|
+
function subschemaCode(it, valid) {
|
|
17668
|
+
if (isSchemaObj(it)) {
|
|
17669
|
+
checkKeywords(it);
|
|
17670
|
+
if (schemaCxtHasRules(it)) {
|
|
17671
|
+
subSchemaObjCode(it, valid);
|
|
17672
|
+
return;
|
|
17673
|
+
}
|
|
17674
|
+
}
|
|
17675
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
17676
|
+
}
|
|
17677
|
+
function schemaCxtHasRules({ schema, self }) {
|
|
17678
|
+
if (typeof schema == "boolean")
|
|
17679
|
+
return !schema;
|
|
17680
|
+
for (const key in schema)
|
|
17681
|
+
if (self.RULES.all[key])
|
|
17682
|
+
return true;
|
|
17683
|
+
return false;
|
|
17684
|
+
}
|
|
17685
|
+
function isSchemaObj(it) {
|
|
17686
|
+
return typeof it.schema != "boolean";
|
|
17687
|
+
}
|
|
17688
|
+
function subSchemaObjCode(it, valid) {
|
|
17689
|
+
const { schema, gen, opts } = it;
|
|
17611
17690
|
if (opts.$comment && schema.$comment)
|
|
17612
17691
|
commentKeyword(it);
|
|
17613
|
-
|
|
17614
|
-
|
|
17615
|
-
gen.
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
}
|
|
17623
|
-
function
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17692
|
+
updateContext(it);
|
|
17693
|
+
checkAsyncSchema(it);
|
|
17694
|
+
const errsCount = gen.const("_errs", names_12.default.errors);
|
|
17695
|
+
typeAndKeywords(it, errsCount);
|
|
17696
|
+
gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
|
|
17697
|
+
}
|
|
17698
|
+
function checkKeywords(it) {
|
|
17699
|
+
(0, util_12.checkUnknownRules)(it);
|
|
17700
|
+
checkRefsAndKeywords(it);
|
|
17701
|
+
}
|
|
17702
|
+
function typeAndKeywords(it, errsCount) {
|
|
17703
|
+
if (it.opts.jtd)
|
|
17704
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
17705
|
+
const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
|
|
17706
|
+
const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
|
|
17707
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
17708
|
+
}
|
|
17709
|
+
function checkRefsAndKeywords(it) {
|
|
17710
|
+
const { schema, errSchemaPath, opts, self } = it;
|
|
17711
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self.RULES)) {
|
|
17712
|
+
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
17713
|
+
}
|
|
17714
|
+
}
|
|
17715
|
+
function checkNoDefault(it) {
|
|
17716
|
+
const { schema, opts } = it;
|
|
17717
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
17718
|
+
(0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
|
|
17719
|
+
}
|
|
17720
|
+
}
|
|
17721
|
+
function updateContext(it) {
|
|
17722
|
+
const schId = it.schema[it.opts.schemaId];
|
|
17723
|
+
if (schId)
|
|
17724
|
+
it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
17725
|
+
}
|
|
17726
|
+
function checkAsyncSchema(it) {
|
|
17727
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
17728
|
+
throw new Error("async schema in sync schema");
|
|
17729
|
+
}
|
|
17730
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
17731
|
+
const msg = schema.$comment;
|
|
17732
|
+
if (opts.$comment === true) {
|
|
17733
|
+
gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
|
|
17734
|
+
} else if (typeof opts.$comment == "function") {
|
|
17735
|
+
const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
|
|
17736
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
17737
|
+
gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
17738
|
+
}
|
|
17739
|
+
}
|
|
17740
|
+
function returnResults(it) {
|
|
17741
|
+
const { gen, schemaEnv, validateName, ValidationError, opts } = it;
|
|
17742
|
+
if (schemaEnv.$async) {
|
|
17743
|
+
gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError}(${names_12.default.vErrors})`));
|
|
17744
|
+
} else {
|
|
17745
|
+
gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
|
|
17746
|
+
if (opts.unevaluated)
|
|
17747
|
+
assignEvaluated(it);
|
|
17748
|
+
gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
|
|
17749
|
+
}
|
|
17750
|
+
}
|
|
17751
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
17752
|
+
if (props instanceof codegen_12.Name)
|
|
17753
|
+
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
17754
|
+
if (items2 instanceof codegen_12.Name)
|
|
17755
|
+
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
17756
|
+
}
|
|
17757
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
17758
|
+
const { gen, schema, data, allErrors, opts, self } = it;
|
|
17759
|
+
const { RULES } = self;
|
|
17760
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
17761
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
17638
17762
|
return;
|
|
17639
17763
|
}
|
|
17764
|
+
if (!opts.jtd)
|
|
17765
|
+
checkStrictTypes(it, types2);
|
|
17766
|
+
gen.block(() => {
|
|
17767
|
+
for (const group of RULES.rules)
|
|
17768
|
+
groupKeywords(group);
|
|
17769
|
+
groupKeywords(RULES.post);
|
|
17770
|
+
});
|
|
17771
|
+
function groupKeywords(group) {
|
|
17772
|
+
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
17773
|
+
return;
|
|
17774
|
+
if (group.type) {
|
|
17775
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
17776
|
+
iterateKeywords(it, group);
|
|
17777
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
17778
|
+
gen.else();
|
|
17779
|
+
(0, dataType_2.reportTypeError)(it);
|
|
17780
|
+
}
|
|
17781
|
+
gen.endIf();
|
|
17782
|
+
} else {
|
|
17783
|
+
iterateKeywords(it, group);
|
|
17784
|
+
}
|
|
17785
|
+
if (!allErrors)
|
|
17786
|
+
gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
|
|
17787
|
+
}
|
|
17640
17788
|
}
|
|
17641
|
-
|
|
17642
|
-
}
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
}
|
|
17651
|
-
|
|
17652
|
-
return typeof it.schema != "boolean";
|
|
17653
|
-
}
|
|
17654
|
-
function subSchemaObjCode(it, valid) {
|
|
17655
|
-
const { schema, gen, opts } = it;
|
|
17656
|
-
if (opts.$comment && schema.$comment)
|
|
17657
|
-
commentKeyword(it);
|
|
17658
|
-
updateContext(it);
|
|
17659
|
-
checkAsyncSchema(it);
|
|
17660
|
-
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
17661
|
-
typeAndKeywords(it, errsCount);
|
|
17662
|
-
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
17663
|
-
}
|
|
17664
|
-
function checkKeywords(it) {
|
|
17665
|
-
(0, util_1$m.checkUnknownRules)(it);
|
|
17666
|
-
checkRefsAndKeywords(it);
|
|
17667
|
-
}
|
|
17668
|
-
function typeAndKeywords(it, errsCount) {
|
|
17669
|
-
if (it.opts.jtd)
|
|
17670
|
-
return schemaKeywords(it, [], false, errsCount);
|
|
17671
|
-
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
17672
|
-
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
17673
|
-
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
17674
|
-
}
|
|
17675
|
-
function checkRefsAndKeywords(it) {
|
|
17676
|
-
const { schema, errSchemaPath, opts, self } = it;
|
|
17677
|
-
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self.RULES)) {
|
|
17678
|
-
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
17679
|
-
}
|
|
17680
|
-
}
|
|
17681
|
-
function checkNoDefault(it) {
|
|
17682
|
-
const { schema, opts } = it;
|
|
17683
|
-
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
17684
|
-
(0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
|
|
17685
|
-
}
|
|
17686
|
-
}
|
|
17687
|
-
function updateContext(it) {
|
|
17688
|
-
const schId = it.schema[it.opts.schemaId];
|
|
17689
|
-
if (schId)
|
|
17690
|
-
it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
17691
|
-
}
|
|
17692
|
-
function checkAsyncSchema(it) {
|
|
17693
|
-
if (it.schema.$async && !it.schemaEnv.$async)
|
|
17694
|
-
throw new Error("async schema in sync schema");
|
|
17695
|
-
}
|
|
17696
|
-
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
17697
|
-
const msg = schema.$comment;
|
|
17698
|
-
if (opts.$comment === true) {
|
|
17699
|
-
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
17700
|
-
} else if (typeof opts.$comment == "function") {
|
|
17701
|
-
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
17702
|
-
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
17703
|
-
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
17704
|
-
}
|
|
17705
|
-
}
|
|
17706
|
-
function returnResults(it) {
|
|
17707
|
-
const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
|
|
17708
|
-
if (schemaEnv.$async) {
|
|
17709
|
-
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})`));
|
|
17710
|
-
} else {
|
|
17711
|
-
gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
|
|
17712
|
-
if (opts.unevaluated)
|
|
17713
|
-
assignEvaluated(it);
|
|
17714
|
-
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
17715
|
-
}
|
|
17716
|
-
}
|
|
17717
|
-
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
17718
|
-
if (props instanceof codegen_1$n.Name)
|
|
17719
|
-
gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
|
|
17720
|
-
if (items2 instanceof codegen_1$n.Name)
|
|
17721
|
-
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
17722
|
-
}
|
|
17723
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
17724
|
-
const { gen, schema, data, allErrors, opts, self } = it;
|
|
17725
|
-
const { RULES } = self;
|
|
17726
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
|
|
17727
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
17728
|
-
return;
|
|
17789
|
+
function iterateKeywords(it, group) {
|
|
17790
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
17791
|
+
if (useDefaults)
|
|
17792
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
17793
|
+
gen.block(() => {
|
|
17794
|
+
for (const rule of group.rules) {
|
|
17795
|
+
if ((0, applicability_12.shouldUseRule)(schema, rule)) {
|
|
17796
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
17797
|
+
}
|
|
17798
|
+
}
|
|
17799
|
+
});
|
|
17729
17800
|
}
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
gen.block(() => {
|
|
17733
|
-
for (const group of RULES.rules)
|
|
17734
|
-
groupKeywords(group);
|
|
17735
|
-
groupKeywords(RULES.post);
|
|
17736
|
-
});
|
|
17737
|
-
function groupKeywords(group) {
|
|
17738
|
-
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
17801
|
+
function checkStrictTypes(it, types2) {
|
|
17802
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
17739
17803
|
return;
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
17804
|
+
checkContextTypes(it, types2);
|
|
17805
|
+
if (!it.opts.allowUnionTypes)
|
|
17806
|
+
checkMultipleTypes(it, types2);
|
|
17807
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
17808
|
+
}
|
|
17809
|
+
function checkContextTypes(it, types2) {
|
|
17810
|
+
if (!types2.length)
|
|
17811
|
+
return;
|
|
17812
|
+
if (!it.dataTypes.length) {
|
|
17813
|
+
it.dataTypes = types2;
|
|
17814
|
+
return;
|
|
17815
|
+
}
|
|
17816
|
+
types2.forEach((t) => {
|
|
17817
|
+
if (!includesType(it.dataTypes, t)) {
|
|
17818
|
+
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
17746
17819
|
}
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17820
|
+
});
|
|
17821
|
+
narrowSchemaTypes(it, types2);
|
|
17822
|
+
}
|
|
17823
|
+
function checkMultipleTypes(it, ts) {
|
|
17824
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
17825
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
17750
17826
|
}
|
|
17751
|
-
if (!allErrors)
|
|
17752
|
-
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
17753
17827
|
}
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17828
|
+
function checkKeywordTypes(it, ts) {
|
|
17829
|
+
const rules2 = it.self.RULES.all;
|
|
17830
|
+
for (const keyword2 in rules2) {
|
|
17831
|
+
const rule = rules2[keyword2];
|
|
17832
|
+
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
17833
|
+
const { type: type2 } = rule.definition;
|
|
17834
|
+
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
17835
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
17836
|
+
}
|
|
17763
17837
|
}
|
|
17764
17838
|
}
|
|
17765
|
-
});
|
|
17766
|
-
}
|
|
17767
|
-
function checkStrictTypes(it, types2) {
|
|
17768
|
-
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
17769
|
-
return;
|
|
17770
|
-
checkContextTypes(it, types2);
|
|
17771
|
-
if (!it.opts.allowUnionTypes)
|
|
17772
|
-
checkMultipleTypes(it, types2);
|
|
17773
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
17774
|
-
}
|
|
17775
|
-
function checkContextTypes(it, types2) {
|
|
17776
|
-
if (!types2.length)
|
|
17777
|
-
return;
|
|
17778
|
-
if (!it.dataTypes.length) {
|
|
17779
|
-
it.dataTypes = types2;
|
|
17780
|
-
return;
|
|
17781
17839
|
}
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17840
|
+
function hasApplicableType(schTs, kwdT) {
|
|
17841
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
17842
|
+
}
|
|
17843
|
+
function includesType(ts, t) {
|
|
17844
|
+
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
17845
|
+
}
|
|
17846
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
17847
|
+
const ts = [];
|
|
17848
|
+
for (const t of it.dataTypes) {
|
|
17849
|
+
if (includesType(withTypes, t))
|
|
17850
|
+
ts.push(t);
|
|
17851
|
+
else if (withTypes.includes("integer") && t === "number")
|
|
17852
|
+
ts.push("integer");
|
|
17853
|
+
}
|
|
17854
|
+
it.dataTypes = ts;
|
|
17855
|
+
}
|
|
17856
|
+
function strictTypesError(it, msg) {
|
|
17857
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
17858
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
17859
|
+
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
17860
|
+
}
|
|
17861
|
+
class KeywordCxt {
|
|
17862
|
+
constructor(it, def2, keyword2) {
|
|
17863
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
17864
|
+
this.gen = it.gen;
|
|
17865
|
+
this.allErrors = it.allErrors;
|
|
17866
|
+
this.keyword = keyword2;
|
|
17867
|
+
this.data = it.data;
|
|
17868
|
+
this.schema = it.schema[keyword2];
|
|
17869
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
17870
|
+
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
17871
|
+
this.schemaType = def2.schemaType;
|
|
17872
|
+
this.parentSchema = it.schema;
|
|
17873
|
+
this.params = {};
|
|
17874
|
+
this.it = it;
|
|
17875
|
+
this.def = def2;
|
|
17876
|
+
if (this.$data) {
|
|
17877
|
+
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
17878
|
+
} else {
|
|
17879
|
+
this.schemaCode = this.schemaValue;
|
|
17880
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
17881
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
17882
|
+
}
|
|
17883
|
+
}
|
|
17884
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
17885
|
+
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
17886
|
+
}
|
|
17785
17887
|
}
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
}
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
}
|
|
17806
|
-
function hasApplicableType(schTs, kwdT) {
|
|
17807
|
-
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
17808
|
-
}
|
|
17809
|
-
function includesType(ts, t) {
|
|
17810
|
-
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
17811
|
-
}
|
|
17812
|
-
function narrowSchemaTypes(it, withTypes) {
|
|
17813
|
-
const ts = [];
|
|
17814
|
-
for (const t of it.dataTypes) {
|
|
17815
|
-
if (includesType(withTypes, t))
|
|
17816
|
-
ts.push(t);
|
|
17817
|
-
else if (withTypes.includes("integer") && t === "number")
|
|
17818
|
-
ts.push("integer");
|
|
17819
|
-
}
|
|
17820
|
-
it.dataTypes = ts;
|
|
17821
|
-
}
|
|
17822
|
-
function strictTypesError(it, msg) {
|
|
17823
|
-
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
17824
|
-
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
17825
|
-
(0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
17826
|
-
}
|
|
17827
|
-
class KeywordCxt {
|
|
17828
|
-
constructor(it, def2, keyword2) {
|
|
17829
|
-
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
17830
|
-
this.gen = it.gen;
|
|
17831
|
-
this.allErrors = it.allErrors;
|
|
17832
|
-
this.keyword = keyword2;
|
|
17833
|
-
this.data = it.data;
|
|
17834
|
-
this.schema = it.schema[keyword2];
|
|
17835
|
-
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
17836
|
-
this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
17837
|
-
this.schemaType = def2.schemaType;
|
|
17838
|
-
this.parentSchema = it.schema;
|
|
17839
|
-
this.params = {};
|
|
17840
|
-
this.it = it;
|
|
17841
|
-
this.def = def2;
|
|
17842
|
-
if (this.$data) {
|
|
17843
|
-
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
17844
|
-
} else {
|
|
17845
|
-
this.schemaCode = this.schemaValue;
|
|
17846
|
-
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
17847
|
-
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
17888
|
+
result(condition, successAction, failAction) {
|
|
17889
|
+
this.failResult((0, codegen_12.not)(condition), successAction, failAction);
|
|
17890
|
+
}
|
|
17891
|
+
failResult(condition, successAction, failAction) {
|
|
17892
|
+
this.gen.if(condition);
|
|
17893
|
+
if (failAction)
|
|
17894
|
+
failAction();
|
|
17895
|
+
else
|
|
17896
|
+
this.error();
|
|
17897
|
+
if (successAction) {
|
|
17898
|
+
this.gen.else();
|
|
17899
|
+
successAction();
|
|
17900
|
+
if (this.allErrors)
|
|
17901
|
+
this.gen.endIf();
|
|
17902
|
+
} else {
|
|
17903
|
+
if (this.allErrors)
|
|
17904
|
+
this.gen.endIf();
|
|
17905
|
+
else
|
|
17906
|
+
this.gen.else();
|
|
17848
17907
|
}
|
|
17849
17908
|
}
|
|
17850
|
-
|
|
17851
|
-
this.
|
|
17909
|
+
pass(condition, failAction) {
|
|
17910
|
+
this.failResult((0, codegen_12.not)(condition), void 0, failAction);
|
|
17852
17911
|
}
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
else
|
|
17912
|
+
fail(condition) {
|
|
17913
|
+
if (condition === void 0) {
|
|
17914
|
+
this.error();
|
|
17915
|
+
if (!this.allErrors)
|
|
17916
|
+
this.gen.if(false);
|
|
17917
|
+
return;
|
|
17918
|
+
}
|
|
17919
|
+
this.gen.if(condition);
|
|
17862
17920
|
this.error();
|
|
17863
|
-
if (successAction) {
|
|
17864
|
-
this.gen.else();
|
|
17865
|
-
successAction();
|
|
17866
|
-
if (this.allErrors)
|
|
17867
|
-
this.gen.endIf();
|
|
17868
|
-
} else {
|
|
17869
17921
|
if (this.allErrors)
|
|
17870
17922
|
this.gen.endIf();
|
|
17871
17923
|
else
|
|
17872
17924
|
this.gen.else();
|
|
17873
17925
|
}
|
|
17874
|
-
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
|
|
17926
|
+
fail$data(condition) {
|
|
17927
|
+
if (!this.$data)
|
|
17928
|
+
return this.fail(condition);
|
|
17929
|
+
const { schemaCode } = this;
|
|
17930
|
+
this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
|
|
17931
|
+
}
|
|
17932
|
+
error(append, errorParams, errorPaths) {
|
|
17933
|
+
if (errorParams) {
|
|
17934
|
+
this.setParams(errorParams);
|
|
17935
|
+
this._error(append, errorPaths);
|
|
17936
|
+
this.setParams({});
|
|
17937
|
+
return;
|
|
17938
|
+
}
|
|
17939
|
+
this._error(append, errorPaths);
|
|
17940
|
+
}
|
|
17941
|
+
_error(append, errorPaths) {
|
|
17942
|
+
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
17943
|
+
}
|
|
17944
|
+
$dataError() {
|
|
17945
|
+
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
17946
|
+
}
|
|
17947
|
+
reset() {
|
|
17948
|
+
if (this.errsCount === void 0)
|
|
17949
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
17950
|
+
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
17951
|
+
}
|
|
17952
|
+
ok(cond) {
|
|
17881
17953
|
if (!this.allErrors)
|
|
17882
|
-
this.gen.if(
|
|
17883
|
-
return;
|
|
17954
|
+
this.gen.if(cond);
|
|
17884
17955
|
}
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
this.gen.else();
|
|
17891
|
-
}
|
|
17892
|
-
fail$data(condition) {
|
|
17893
|
-
if (!this.$data)
|
|
17894
|
-
return this.fail(condition);
|
|
17895
|
-
const { schemaCode } = this;
|
|
17896
|
-
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
17897
|
-
}
|
|
17898
|
-
error(append, errorParams, errorPaths) {
|
|
17899
|
-
if (errorParams) {
|
|
17900
|
-
this.setParams(errorParams);
|
|
17901
|
-
this._error(append, errorPaths);
|
|
17902
|
-
this.setParams({});
|
|
17903
|
-
return;
|
|
17956
|
+
setParams(obj, assign) {
|
|
17957
|
+
if (assign)
|
|
17958
|
+
Object.assign(this.params, obj);
|
|
17959
|
+
else
|
|
17960
|
+
this.params = obj;
|
|
17904
17961
|
}
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
$dataError() {
|
|
17911
|
-
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
17912
|
-
}
|
|
17913
|
-
reset() {
|
|
17914
|
-
if (this.errsCount === void 0)
|
|
17915
|
-
throw new Error('add "trackErrors" to keyword definition');
|
|
17916
|
-
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
17917
|
-
}
|
|
17918
|
-
ok(cond) {
|
|
17919
|
-
if (!this.allErrors)
|
|
17920
|
-
this.gen.if(cond);
|
|
17921
|
-
}
|
|
17922
|
-
setParams(obj, assign) {
|
|
17923
|
-
if (assign)
|
|
17924
|
-
Object.assign(this.params, obj);
|
|
17925
|
-
else
|
|
17926
|
-
this.params = obj;
|
|
17927
|
-
}
|
|
17928
|
-
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
17929
|
-
this.gen.block(() => {
|
|
17930
|
-
this.check$data(valid, $dataValid);
|
|
17931
|
-
codeBlock();
|
|
17932
|
-
});
|
|
17933
|
-
}
|
|
17934
|
-
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
17935
|
-
if (!this.$data)
|
|
17936
|
-
return;
|
|
17937
|
-
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
17938
|
-
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
17939
|
-
if (valid !== codegen_1$n.nil)
|
|
17940
|
-
gen.assign(valid, true);
|
|
17941
|
-
if (schemaType.length || def2.validateSchema) {
|
|
17942
|
-
gen.elseIf(this.invalid$data());
|
|
17943
|
-
this.$dataError();
|
|
17944
|
-
if (valid !== codegen_1$n.nil)
|
|
17945
|
-
gen.assign(valid, false);
|
|
17962
|
+
block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
|
|
17963
|
+
this.gen.block(() => {
|
|
17964
|
+
this.check$data(valid, $dataValid);
|
|
17965
|
+
codeBlock();
|
|
17966
|
+
});
|
|
17946
17967
|
}
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17968
|
+
check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
|
|
17969
|
+
if (!this.$data)
|
|
17970
|
+
return;
|
|
17971
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
17972
|
+
gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
|
|
17973
|
+
if (valid !== codegen_12.nil)
|
|
17974
|
+
gen.assign(valid, true);
|
|
17975
|
+
if (schemaType.length || def2.validateSchema) {
|
|
17976
|
+
gen.elseIf(this.invalid$data());
|
|
17977
|
+
this.$dataError();
|
|
17978
|
+
if (valid !== codegen_12.nil)
|
|
17979
|
+
gen.assign(valid, false);
|
|
17958
17980
|
}
|
|
17959
|
-
|
|
17981
|
+
gen.else();
|
|
17960
17982
|
}
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17983
|
+
invalid$data() {
|
|
17984
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
17985
|
+
return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
|
|
17986
|
+
function wrong$DataType() {
|
|
17987
|
+
if (schemaType.length) {
|
|
17988
|
+
if (!(schemaCode instanceof codegen_12.Name))
|
|
17989
|
+
throw new Error("ajv implementation error");
|
|
17990
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
17991
|
+
return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
17992
|
+
}
|
|
17993
|
+
return codegen_12.nil;
|
|
17994
|
+
}
|
|
17995
|
+
function invalid$DataSchema() {
|
|
17996
|
+
if (def2.validateSchema) {
|
|
17997
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
17998
|
+
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
17999
|
+
}
|
|
18000
|
+
return codegen_12.nil;
|
|
17965
18001
|
}
|
|
17966
|
-
return codegen_1$n.nil;
|
|
17967
18002
|
}
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
return nextContext;
|
|
17976
|
-
}
|
|
17977
|
-
mergeEvaluated(schemaCxt, toName) {
|
|
17978
|
-
const { it, gen } = this;
|
|
17979
|
-
if (!it.opts.unevaluated)
|
|
17980
|
-
return;
|
|
17981
|
-
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
17982
|
-
it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
18003
|
+
subschema(appl, valid) {
|
|
18004
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
18005
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
18006
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
18007
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
18008
|
+
subschemaCode(nextContext, valid);
|
|
18009
|
+
return nextContext;
|
|
17983
18010
|
}
|
|
17984
|
-
|
|
17985
|
-
|
|
18011
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
18012
|
+
const { it, gen } = this;
|
|
18013
|
+
if (!it.opts.unevaluated)
|
|
18014
|
+
return;
|
|
18015
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
18016
|
+
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
18017
|
+
}
|
|
18018
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
18019
|
+
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
18020
|
+
}
|
|
17986
18021
|
}
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
18022
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
18023
|
+
const { it, gen } = this;
|
|
18024
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
18025
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
|
|
18026
|
+
return true;
|
|
18027
|
+
}
|
|
17993
18028
|
}
|
|
17994
18029
|
}
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
(
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
}
|
|
18008
|
-
|
|
18009
|
-
const
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
|
|
18033
|
-
|
|
18034
|
-
|
|
18035
|
-
|
|
18036
|
-
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18043
|
-
|
|
18030
|
+
validate.KeywordCxt = KeywordCxt;
|
|
18031
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
18032
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
18033
|
+
if ("code" in def2) {
|
|
18034
|
+
def2.code(cxt, ruleType);
|
|
18035
|
+
} else if (cxt.$data && def2.validate) {
|
|
18036
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
18037
|
+
} else if ("macro" in def2) {
|
|
18038
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
18039
|
+
} else if (def2.compile || def2.validate) {
|
|
18040
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
18041
|
+
}
|
|
18042
|
+
}
|
|
18043
|
+
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
18044
|
+
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
18045
|
+
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
18046
|
+
let jsonPointer;
|
|
18047
|
+
let data;
|
|
18048
|
+
if ($data === "")
|
|
18049
|
+
return names_12.default.rootData;
|
|
18050
|
+
if ($data[0] === "/") {
|
|
18051
|
+
if (!JSON_POINTER.test($data))
|
|
18052
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
18053
|
+
jsonPointer = $data;
|
|
18054
|
+
data = names_12.default.rootData;
|
|
18055
|
+
} else {
|
|
18056
|
+
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
18057
|
+
if (!matches)
|
|
18058
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
18059
|
+
const up = +matches[1];
|
|
18060
|
+
jsonPointer = matches[2];
|
|
18061
|
+
if (jsonPointer === "#") {
|
|
18062
|
+
if (up >= dataLevel)
|
|
18063
|
+
throw new Error(errorMsg("property/index", up));
|
|
18064
|
+
return dataPathArr[dataLevel - up];
|
|
18065
|
+
}
|
|
18066
|
+
if (up > dataLevel)
|
|
18067
|
+
throw new Error(errorMsg("data", up));
|
|
18068
|
+
data = dataNames[dataLevel - up];
|
|
18069
|
+
if (!jsonPointer)
|
|
18070
|
+
return data;
|
|
18071
|
+
}
|
|
18072
|
+
let expr = data;
|
|
18073
|
+
const segments = jsonPointer.split("/");
|
|
18074
|
+
for (const segment of segments) {
|
|
18075
|
+
if (segment) {
|
|
18076
|
+
data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
|
|
18077
|
+
expr = (0, codegen_12._)`${expr} && ${data}`;
|
|
18078
|
+
}
|
|
18079
|
+
}
|
|
18080
|
+
return expr;
|
|
18081
|
+
function errorMsg(pointerType, up) {
|
|
18082
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
18044
18083
|
}
|
|
18045
18084
|
}
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
18049
|
-
}
|
|
18085
|
+
validate.getData = getData;
|
|
18086
|
+
return validate;
|
|
18050
18087
|
}
|
|
18051
|
-
validate.getData = getData;
|
|
18052
18088
|
var validation_error = {};
|
|
18053
|
-
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
18058
|
-
|
|
18089
|
+
var hasRequiredValidation_error;
|
|
18090
|
+
function requireValidation_error() {
|
|
18091
|
+
if (hasRequiredValidation_error) return validation_error;
|
|
18092
|
+
hasRequiredValidation_error = 1;
|
|
18093
|
+
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
18094
|
+
class ValidationError extends Error {
|
|
18095
|
+
constructor(errors2) {
|
|
18096
|
+
super("validation failed");
|
|
18097
|
+
this.errors = errors2;
|
|
18098
|
+
this.ajv = this.validation = true;
|
|
18099
|
+
}
|
|
18059
18100
|
}
|
|
18101
|
+
validation_error.default = ValidationError;
|
|
18102
|
+
return validation_error;
|
|
18060
18103
|
}
|
|
18061
|
-
validation_error.default = ValidationError;
|
|
18062
18104
|
var ref_error = {};
|
|
18063
18105
|
Object.defineProperty(ref_error, "__esModule", { value: true });
|
|
18064
18106
|
const resolve_1$1 = resolve$2;
|
|
@@ -18074,11 +18116,11 @@ var compile = {};
|
|
|
18074
18116
|
Object.defineProperty(compile, "__esModule", { value: true });
|
|
18075
18117
|
compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
|
|
18076
18118
|
const codegen_1$m = codegen;
|
|
18077
|
-
const validation_error_1 =
|
|
18119
|
+
const validation_error_1 = requireValidation_error();
|
|
18078
18120
|
const names_1$2 = names$1;
|
|
18079
18121
|
const resolve_1 = resolve$2;
|
|
18080
18122
|
const util_1$l = util;
|
|
18081
|
-
const validate_1$1 =
|
|
18123
|
+
const validate_1$1 = requireValidate();
|
|
18082
18124
|
class SchemaEnv {
|
|
18083
18125
|
constructor(env) {
|
|
18084
18126
|
var _a;
|
|
@@ -19007,7 +19049,7 @@ uri$1.default = uri;
|
|
|
19007
19049
|
(function(exports) {
|
|
19008
19050
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19009
19051
|
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
|
19010
|
-
var validate_12 =
|
|
19052
|
+
var validate_12 = requireValidate();
|
|
19011
19053
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
19012
19054
|
return validate_12.KeywordCxt;
|
|
19013
19055
|
} });
|
|
@@ -19030,7 +19072,7 @@ uri$1.default = uri;
|
|
|
19030
19072
|
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
|
|
19031
19073
|
return codegen_12.CodeGen;
|
|
19032
19074
|
} });
|
|
19033
|
-
const validation_error_12 =
|
|
19075
|
+
const validation_error_12 = requireValidation_error();
|
|
19034
19076
|
const ref_error_12 = ref_error;
|
|
19035
19077
|
const rules_12 = rules;
|
|
19036
19078
|
const compile_12 = compile;
|
|
@@ -20618,7 +20660,7 @@ const def$a = {
|
|
|
20618
20660
|
additionalProperties.default = def$a;
|
|
20619
20661
|
var properties$1 = {};
|
|
20620
20662
|
Object.defineProperty(properties$1, "__esModule", { value: true });
|
|
20621
|
-
const validate_1 =
|
|
20663
|
+
const validate_1 = requireValidate();
|
|
20622
20664
|
const code_1$2 = code;
|
|
20623
20665
|
const util_1$7 = util;
|
|
20624
20666
|
const additionalProperties_1$1 = additionalProperties;
|
|
@@ -21469,7 +21511,7 @@ const require$$3 = {
|
|
|
21469
21511
|
module.exports.Ajv = Ajv2;
|
|
21470
21512
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21471
21513
|
exports.default = Ajv2;
|
|
21472
|
-
var validate_12 =
|
|
21514
|
+
var validate_12 = requireValidate();
|
|
21473
21515
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
21474
21516
|
return validate_12.KeywordCxt;
|
|
21475
21517
|
} });
|
|
@@ -21492,7 +21534,7 @@ const require$$3 = {
|
|
|
21492
21534
|
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
|
|
21493
21535
|
return codegen_12.CodeGen;
|
|
21494
21536
|
} });
|
|
21495
|
-
var validation_error_12 =
|
|
21537
|
+
var validation_error_12 = requireValidation_error();
|
|
21496
21538
|
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
|
|
21497
21539
|
return validation_error_12.default;
|
|
21498
21540
|
} });
|