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