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