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