page-schema-enginer-shun 1.0.18 → 1.0.20
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/dist/index.cjs.js +888 -846
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +890 -848
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +888 -846
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +4 -4
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -93,12 +93,11 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
93
93
|
});
|
|
94
94
|
return (_ctx, _cache) => {
|
|
95
95
|
var _a, _b;
|
|
96
|
-
const _component_el_input = vue.resolveComponent("el-input");
|
|
97
96
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$b, [
|
|
98
97
|
vue.createElementVNode("div", _hoisted_2$5, [
|
|
99
98
|
vue.createElementVNode("span", _hoisted_3$4, vue.toDisplayString((_a = __props.schema) == null ? void 0 : _a.label), 1),
|
|
100
99
|
((_b = __props.schema.option) == null ? void 0 : _b.required) ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_4$2, "*")) : vue.createCommentVNode("", true),
|
|
101
|
-
vue.createVNode(
|
|
100
|
+
vue.createVNode(vue.unref(elementPlus.ElInput), vue.mergeProps({
|
|
102
101
|
modelValue: dataValue.value,
|
|
103
102
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dataValue.value = $event)
|
|
104
103
|
}, __props.schema.option, {
|
|
@@ -118,7 +117,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
118
117
|
}
|
|
119
118
|
return target;
|
|
120
119
|
};
|
|
121
|
-
const input = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-
|
|
120
|
+
const input = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-d323ff77"]]);
|
|
122
121
|
const _hoisted_1$a = { class: "schema-form-radio-container" };
|
|
123
122
|
const _hoisted_2$4 = { class: "schema-form-radio" };
|
|
124
123
|
const _hoisted_3$3 = { class: "schema-form-radio-label" };
|
|
@@ -1348,8 +1347,8 @@ var scope = {};
|
|
|
1348
1347
|
var util = {};
|
|
1349
1348
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
1350
1349
|
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;
|
|
1351
|
-
const codegen_1$
|
|
1352
|
-
const code_1$
|
|
1350
|
+
const codegen_1$p = codegen;
|
|
1351
|
+
const code_1$9 = code$1;
|
|
1353
1352
|
function toHash(arr) {
|
|
1354
1353
|
const hash = {};
|
|
1355
1354
|
for (const item of arr)
|
|
@@ -1402,9 +1401,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
|
|
|
1402
1401
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
1403
1402
|
return schema;
|
|
1404
1403
|
if (typeof schema == "string")
|
|
1405
|
-
return (0, codegen_1$
|
|
1404
|
+
return (0, codegen_1$p._)`${schema}`;
|
|
1406
1405
|
}
|
|
1407
|
-
return (0, codegen_1$
|
|
1406
|
+
return (0, codegen_1$p._)`${topSchemaRef}${schemaPath}${(0, codegen_1$p.getProperty)(keyword2)}`;
|
|
1408
1407
|
}
|
|
1409
1408
|
util.schemaRefOrVal = schemaRefOrVal;
|
|
1410
1409
|
function unescapeFragment(str) {
|
|
@@ -1436,20 +1435,20 @@ function eachItem(xs, f) {
|
|
|
1436
1435
|
util.eachItem = eachItem;
|
|
1437
1436
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
|
|
1438
1437
|
return (gen, from, to, toName) => {
|
|
1439
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
1440
|
-
return toName === codegen_1$
|
|
1438
|
+
const res = to === void 0 ? from : to instanceof codegen_1$p.Name ? (from instanceof codegen_1$p.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$p.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
|
|
1439
|
+
return toName === codegen_1$p.Name && !(res instanceof codegen_1$p.Name) ? resultToName(gen, res) : res;
|
|
1441
1440
|
};
|
|
1442
1441
|
}
|
|
1443
1442
|
util.mergeEvaluated = {
|
|
1444
1443
|
props: makeMergeEvaluated({
|
|
1445
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
1446
|
-
gen.if((0, codegen_1$
|
|
1444
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true && ${from} !== undefined`, () => {
|
|
1445
|
+
gen.if((0, codegen_1$p._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$p._)`${to} || {}`).code((0, codegen_1$p._)`Object.assign(${to}, ${from})`));
|
|
1447
1446
|
}),
|
|
1448
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
1447
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true`, () => {
|
|
1449
1448
|
if (from === true) {
|
|
1450
1449
|
gen.assign(to, true);
|
|
1451
1450
|
} else {
|
|
1452
|
-
gen.assign(to, (0, codegen_1$
|
|
1451
|
+
gen.assign(to, (0, codegen_1$p._)`${to} || {}`);
|
|
1453
1452
|
setEvaluated(gen, to, from);
|
|
1454
1453
|
}
|
|
1455
1454
|
}),
|
|
@@ -1457,8 +1456,8 @@ util.mergeEvaluated = {
|
|
|
1457
1456
|
resultToName: evaluatedPropsToName
|
|
1458
1457
|
}),
|
|
1459
1458
|
items: makeMergeEvaluated({
|
|
1460
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
1461
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
1459
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$p._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
|
|
1460
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$p._)`${to} > ${from} ? ${to} : ${from}`)),
|
|
1462
1461
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
1463
1462
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
1464
1463
|
})
|
|
@@ -1466,21 +1465,21 @@ util.mergeEvaluated = {
|
|
|
1466
1465
|
function evaluatedPropsToName(gen, ps) {
|
|
1467
1466
|
if (ps === true)
|
|
1468
1467
|
return gen.var("props", true);
|
|
1469
|
-
const props = gen.var("props", (0, codegen_1$
|
|
1468
|
+
const props = gen.var("props", (0, codegen_1$p._)`{}`);
|
|
1470
1469
|
if (ps !== void 0)
|
|
1471
1470
|
setEvaluated(gen, props, ps);
|
|
1472
1471
|
return props;
|
|
1473
1472
|
}
|
|
1474
1473
|
util.evaluatedPropsToName = evaluatedPropsToName;
|
|
1475
1474
|
function setEvaluated(gen, props, ps) {
|
|
1476
|
-
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$
|
|
1475
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$p._)`${props}${(0, codegen_1$p.getProperty)(p)}`, true));
|
|
1477
1476
|
}
|
|
1478
1477
|
util.setEvaluated = setEvaluated;
|
|
1479
1478
|
const snippets = {};
|
|
1480
1479
|
function useFunc(gen, f) {
|
|
1481
1480
|
return gen.scopeValue("func", {
|
|
1482
1481
|
ref: f,
|
|
1483
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
1482
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
|
|
1484
1483
|
});
|
|
1485
1484
|
}
|
|
1486
1485
|
util.useFunc = useFunc;
|
|
@@ -1490,11 +1489,11 @@ var Type;
|
|
|
1490
1489
|
Type2[Type2["Str"] = 1] = "Str";
|
|
1491
1490
|
})(Type || (util.Type = Type = {}));
|
|
1492
1491
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
1493
|
-
if (dataProp instanceof codegen_1$
|
|
1492
|
+
if (dataProp instanceof codegen_1$p.Name) {
|
|
1494
1493
|
const isNumber = dataPropType === Type.Num;
|
|
1495
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
1494
|
+
return jsPropertySyntax ? isNumber ? (0, codegen_1$p._)`"[" + ${dataProp} + "]"` : (0, codegen_1$p._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$p._)`"/" + ${dataProp}` : (0, codegen_1$p._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
1496
1495
|
}
|
|
1497
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
1496
|
+
return jsPropertySyntax ? (0, codegen_1$p.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
|
1498
1497
|
}
|
|
1499
1498
|
util.getErrorPath = getErrorPath;
|
|
1500
1499
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -1506,45 +1505,51 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
|
1506
1505
|
it.self.logger.warn(msg);
|
|
1507
1506
|
}
|
|
1508
1507
|
util.checkStrictMode = checkStrictMode;
|
|
1509
|
-
var names
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1508
|
+
var names = {};
|
|
1509
|
+
var hasRequiredNames;
|
|
1510
|
+
function requireNames() {
|
|
1511
|
+
if (hasRequiredNames) return names;
|
|
1512
|
+
hasRequiredNames = 1;
|
|
1513
|
+
Object.defineProperty(names, "__esModule", { value: true });
|
|
1514
|
+
const codegen_12 = codegen;
|
|
1515
|
+
const names$1 = {
|
|
1516
|
+
// validation function arguments
|
|
1517
|
+
data: new codegen_12.Name("data"),
|
|
1518
|
+
// data passed to validation function
|
|
1519
|
+
// args passed from referencing schema
|
|
1520
|
+
valCxt: new codegen_12.Name("valCxt"),
|
|
1521
|
+
// validation/data context - should not be used directly, it is destructured to the names below
|
|
1522
|
+
instancePath: new codegen_12.Name("instancePath"),
|
|
1523
|
+
parentData: new codegen_12.Name("parentData"),
|
|
1524
|
+
parentDataProperty: new codegen_12.Name("parentDataProperty"),
|
|
1525
|
+
rootData: new codegen_12.Name("rootData"),
|
|
1526
|
+
// root data - same as the data passed to the first/top validation function
|
|
1527
|
+
dynamicAnchors: new codegen_12.Name("dynamicAnchors"),
|
|
1528
|
+
// used to support recursiveRef and dynamicRef
|
|
1529
|
+
// function scoped variables
|
|
1530
|
+
vErrors: new codegen_12.Name("vErrors"),
|
|
1531
|
+
// null or array of validation errors
|
|
1532
|
+
errors: new codegen_12.Name("errors"),
|
|
1533
|
+
// counter of validation errors
|
|
1534
|
+
this: new codegen_12.Name("this"),
|
|
1535
|
+
// "globals"
|
|
1536
|
+
self: new codegen_12.Name("self"),
|
|
1537
|
+
scope: new codegen_12.Name("scope"),
|
|
1538
|
+
// JTD serialize/parse name for JSON string and position
|
|
1539
|
+
json: new codegen_12.Name("json"),
|
|
1540
|
+
jsonPos: new codegen_12.Name("jsonPos"),
|
|
1541
|
+
jsonLen: new codegen_12.Name("jsonLen"),
|
|
1542
|
+
jsonPart: new codegen_12.Name("jsonPart")
|
|
1543
|
+
};
|
|
1544
|
+
names.default = names$1;
|
|
1545
|
+
return names;
|
|
1546
|
+
}
|
|
1542
1547
|
(function(exports$1) {
|
|
1543
1548
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1544
1549
|
exports$1.extendErrors = exports$1.resetErrorsCount = exports$1.reportExtraError = exports$1.reportError = exports$1.keyword$DataError = exports$1.keywordError = void 0;
|
|
1545
1550
|
const codegen_12 = codegen;
|
|
1546
1551
|
const util_12 = util;
|
|
1547
|
-
const names_12 =
|
|
1552
|
+
const names_12 = requireNames();
|
|
1548
1553
|
exports$1.keywordError = {
|
|
1549
1554
|
message: ({ keyword: keyword2 }) => (0, codegen_12.str)`must pass "${keyword2}" keyword validation`
|
|
1550
1555
|
};
|
|
@@ -1656,49 +1661,55 @@ names$1.default = names;
|
|
|
1656
1661
|
keyValues.push([E.propertyName, propertyName]);
|
|
1657
1662
|
}
|
|
1658
1663
|
})(errors);
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
gen
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1664
|
+
var hasRequiredBoolSchema;
|
|
1665
|
+
function requireBoolSchema() {
|
|
1666
|
+
if (hasRequiredBoolSchema) return boolSchema;
|
|
1667
|
+
hasRequiredBoolSchema = 1;
|
|
1668
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
1669
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
1670
|
+
const errors_12 = errors;
|
|
1671
|
+
const codegen_12 = codegen;
|
|
1672
|
+
const names_12 = requireNames();
|
|
1673
|
+
const boolError = {
|
|
1674
|
+
message: "boolean schema is false"
|
|
1675
|
+
};
|
|
1676
|
+
function topBoolOrEmptySchema(it) {
|
|
1677
|
+
const { gen, schema, validateName } = it;
|
|
1678
|
+
if (schema === false) {
|
|
1679
|
+
falseSchemaError(it, false);
|
|
1680
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
1681
|
+
gen.return(names_12.default.data);
|
|
1682
|
+
} else {
|
|
1683
|
+
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
1684
|
+
gen.return(true);
|
|
1685
|
+
}
|
|
1676
1686
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1687
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
1688
|
+
function boolOrEmptySchema(it, valid) {
|
|
1689
|
+
const { gen, schema } = it;
|
|
1690
|
+
if (schema === false) {
|
|
1691
|
+
gen.var(valid, false);
|
|
1692
|
+
falseSchemaError(it);
|
|
1693
|
+
} else {
|
|
1694
|
+
gen.var(valid, true);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
1698
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
1699
|
+
const { gen, data } = it;
|
|
1700
|
+
const cxt = {
|
|
1701
|
+
gen,
|
|
1702
|
+
keyword: "false schema",
|
|
1703
|
+
data,
|
|
1704
|
+
schema: false,
|
|
1705
|
+
schemaCode: false,
|
|
1706
|
+
schemaValue: false,
|
|
1707
|
+
params: {},
|
|
1708
|
+
it
|
|
1709
|
+
};
|
|
1710
|
+
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
1686
1711
|
}
|
|
1687
|
-
|
|
1688
|
-
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
1689
|
-
function falseSchemaError(it, overrideAllErrors) {
|
|
1690
|
-
const { gen, data } = it;
|
|
1691
|
-
const cxt = {
|
|
1692
|
-
gen,
|
|
1693
|
-
keyword: "false schema",
|
|
1694
|
-
data,
|
|
1695
|
-
schema: false,
|
|
1696
|
-
schemaCode: false,
|
|
1697
|
-
schemaValue: false,
|
|
1698
|
-
params: {},
|
|
1699
|
-
it
|
|
1700
|
-
};
|
|
1701
|
-
(0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
1712
|
+
return boolSchema;
|
|
1702
1713
|
}
|
|
1703
1714
|
var dataType = {};
|
|
1704
1715
|
var rules = {};
|
|
@@ -1746,10 +1757,10 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
1746
1757
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
1747
1758
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
1748
1759
|
const rules_1 = rules;
|
|
1749
|
-
const applicability_1
|
|
1750
|
-
const errors_1
|
|
1751
|
-
const codegen_1$
|
|
1752
|
-
const util_1$
|
|
1760
|
+
const applicability_1 = applicability;
|
|
1761
|
+
const errors_1 = errors;
|
|
1762
|
+
const codegen_1$o = codegen;
|
|
1763
|
+
const util_1$n = util;
|
|
1753
1764
|
var DataType;
|
|
1754
1765
|
(function(DataType2) {
|
|
1755
1766
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -1781,7 +1792,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
1781
1792
|
function coerceAndCheckDataType(it, types2) {
|
|
1782
1793
|
const { gen, data, opts } = it;
|
|
1783
1794
|
const coerceTo = coerceToTypes(types2, opts.coerceTypes);
|
|
1784
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1
|
|
1795
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
1785
1796
|
if (checkTypes) {
|
|
1786
1797
|
const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
|
|
1787
1798
|
gen.if(wrongType, () => {
|
|
@@ -1800,12 +1811,12 @@ function coerceToTypes(types2, coerceTypes) {
|
|
|
1800
1811
|
}
|
|
1801
1812
|
function coerceData(it, types2, coerceTo) {
|
|
1802
1813
|
const { gen, data, opts } = it;
|
|
1803
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
1804
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
1814
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
|
|
1815
|
+
const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
|
|
1805
1816
|
if (opts.coerceTypes === "array") {
|
|
1806
|
-
gen.if((0, codegen_1$
|
|
1817
|
+
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)));
|
|
1807
1818
|
}
|
|
1808
|
-
gen.if((0, codegen_1$
|
|
1819
|
+
gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
|
|
1809
1820
|
for (const t of coerceTo) {
|
|
1810
1821
|
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
|
|
1811
1822
|
coerceSpecificType(t);
|
|
@@ -1814,63 +1825,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
1814
1825
|
gen.else();
|
|
1815
1826
|
reportTypeError(it);
|
|
1816
1827
|
gen.endIf();
|
|
1817
|
-
gen.if((0, codegen_1$
|
|
1828
|
+
gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
|
|
1818
1829
|
gen.assign(data, coerced);
|
|
1819
1830
|
assignParentData(it, coerced);
|
|
1820
1831
|
});
|
|
1821
1832
|
function coerceSpecificType(t) {
|
|
1822
1833
|
switch (t) {
|
|
1823
1834
|
case "string":
|
|
1824
|
-
gen.elseIf((0, codegen_1$
|
|
1835
|
+
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._)`""`);
|
|
1825
1836
|
return;
|
|
1826
1837
|
case "number":
|
|
1827
|
-
gen.elseIf((0, codegen_1$
|
|
1828
|
-
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$
|
|
1838
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
|
|
1839
|
+
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
|
|
1829
1840
|
return;
|
|
1830
1841
|
case "integer":
|
|
1831
|
-
gen.elseIf((0, codegen_1$
|
|
1832
|
-
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$
|
|
1842
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
|
|
1843
|
+
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
|
|
1833
1844
|
return;
|
|
1834
1845
|
case "boolean":
|
|
1835
|
-
gen.elseIf((0, codegen_1$
|
|
1846
|
+
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);
|
|
1836
1847
|
return;
|
|
1837
1848
|
case "null":
|
|
1838
|
-
gen.elseIf((0, codegen_1$
|
|
1849
|
+
gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
|
|
1839
1850
|
gen.assign(coerced, null);
|
|
1840
1851
|
return;
|
|
1841
1852
|
case "array":
|
|
1842
|
-
gen.elseIf((0, codegen_1$
|
|
1843
|
-
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$
|
|
1853
|
+
gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
1854
|
+
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
|
|
1844
1855
|
}
|
|
1845
1856
|
}
|
|
1846
1857
|
}
|
|
1847
1858
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
1848
|
-
gen.if((0, codegen_1$
|
|
1859
|
+
gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
|
|
1849
1860
|
}
|
|
1850
1861
|
function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
|
|
1851
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
1862
|
+
const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
|
|
1852
1863
|
let cond;
|
|
1853
1864
|
switch (dataType2) {
|
|
1854
1865
|
case "null":
|
|
1855
|
-
return (0, codegen_1$
|
|
1866
|
+
return (0, codegen_1$o._)`${data} ${EQ} null`;
|
|
1856
1867
|
case "array":
|
|
1857
|
-
cond = (0, codegen_1$
|
|
1868
|
+
cond = (0, codegen_1$o._)`Array.isArray(${data})`;
|
|
1858
1869
|
break;
|
|
1859
1870
|
case "object":
|
|
1860
|
-
cond = (0, codegen_1$
|
|
1871
|
+
cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
|
|
1861
1872
|
break;
|
|
1862
1873
|
case "integer":
|
|
1863
|
-
cond = numCond((0, codegen_1$
|
|
1874
|
+
cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
|
|
1864
1875
|
break;
|
|
1865
1876
|
case "number":
|
|
1866
1877
|
cond = numCond();
|
|
1867
1878
|
break;
|
|
1868
1879
|
default:
|
|
1869
|
-
return (0, codegen_1$
|
|
1880
|
+
return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
|
|
1870
1881
|
}
|
|
1871
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
1872
|
-
function numCond(_cond = codegen_1$
|
|
1873
|
-
return (0, codegen_1$
|
|
1882
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
|
|
1883
|
+
function numCond(_cond = codegen_1$o.nil) {
|
|
1884
|
+
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);
|
|
1874
1885
|
}
|
|
1875
1886
|
}
|
|
1876
1887
|
dataType.checkDataType = checkDataType;
|
|
@@ -1879,35 +1890,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
|
1879
1890
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
1880
1891
|
}
|
|
1881
1892
|
let cond;
|
|
1882
|
-
const types2 = (0, util_1$
|
|
1893
|
+
const types2 = (0, util_1$n.toHash)(dataTypes);
|
|
1883
1894
|
if (types2.array && types2.object) {
|
|
1884
|
-
const notObj = (0, codegen_1$
|
|
1885
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
1895
|
+
const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
|
|
1896
|
+
cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
|
|
1886
1897
|
delete types2.null;
|
|
1887
1898
|
delete types2.array;
|
|
1888
1899
|
delete types2.object;
|
|
1889
1900
|
} else {
|
|
1890
|
-
cond = codegen_1$
|
|
1901
|
+
cond = codegen_1$o.nil;
|
|
1891
1902
|
}
|
|
1892
1903
|
if (types2.number)
|
|
1893
1904
|
delete types2.integer;
|
|
1894
1905
|
for (const t in types2)
|
|
1895
|
-
cond = (0, codegen_1$
|
|
1906
|
+
cond = (0, codegen_1$o.and)(cond, checkDataType(t, data, strictNums, correct));
|
|
1896
1907
|
return cond;
|
|
1897
1908
|
}
|
|
1898
1909
|
dataType.checkDataTypes = checkDataTypes;
|
|
1899
1910
|
const typeError = {
|
|
1900
1911
|
message: ({ schema }) => `must be ${schema}`,
|
|
1901
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
1912
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
|
|
1902
1913
|
};
|
|
1903
1914
|
function reportTypeError(it) {
|
|
1904
1915
|
const cxt = getTypeErrorContext(it);
|
|
1905
|
-
(0, errors_1
|
|
1916
|
+
(0, errors_1.reportError)(cxt, typeError);
|
|
1906
1917
|
}
|
|
1907
1918
|
dataType.reportTypeError = reportTypeError;
|
|
1908
1919
|
function getTypeErrorContext(it) {
|
|
1909
1920
|
const { gen, data, schema } = it;
|
|
1910
|
-
const schemaCode = (0, util_1$
|
|
1921
|
+
const schemaCode = (0, util_1$n.schemaRefOrVal)(it, schema, "type");
|
|
1911
1922
|
return {
|
|
1912
1923
|
gen,
|
|
1913
1924
|
keyword: "type",
|
|
@@ -1921,54 +1932,60 @@ function getTypeErrorContext(it) {
|
|
|
1921
1932
|
};
|
|
1922
1933
|
}
|
|
1923
1934
|
var defaults = {};
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
if (defaultValue === void 0)
|
|
1942
|
-
return;
|
|
1943
|
-
const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
1944
|
-
if (compositeRule) {
|
|
1945
|
-
(0, util_1$p.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1946
|
-
return;
|
|
1935
|
+
var hasRequiredDefaults;
|
|
1936
|
+
function requireDefaults() {
|
|
1937
|
+
if (hasRequiredDefaults) return defaults;
|
|
1938
|
+
hasRequiredDefaults = 1;
|
|
1939
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
1940
|
+
defaults.assignDefaults = void 0;
|
|
1941
|
+
const codegen_12 = codegen;
|
|
1942
|
+
const util_12 = util;
|
|
1943
|
+
function assignDefaults(it, ty) {
|
|
1944
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
1945
|
+
if (ty === "object" && properties2) {
|
|
1946
|
+
for (const key in properties2) {
|
|
1947
|
+
assignDefault(it, key, properties2[key].default);
|
|
1948
|
+
}
|
|
1949
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
1950
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
1951
|
+
}
|
|
1947
1952
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1953
|
+
defaults.assignDefaults = assignDefaults;
|
|
1954
|
+
function assignDefault(it, prop, defaultValue) {
|
|
1955
|
+
const { gen, compositeRule, data, opts } = it;
|
|
1956
|
+
if (defaultValue === void 0)
|
|
1957
|
+
return;
|
|
1958
|
+
const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
|
|
1959
|
+
if (compositeRule) {
|
|
1960
|
+
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
1964
|
+
if (opts.useDefaults === "empty") {
|
|
1965
|
+
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
1966
|
+
}
|
|
1967
|
+
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
1951
1968
|
}
|
|
1952
|
-
|
|
1969
|
+
return defaults;
|
|
1953
1970
|
}
|
|
1954
1971
|
var keyword = {};
|
|
1955
1972
|
var code = {};
|
|
1956
1973
|
Object.defineProperty(code, "__esModule", { value: true });
|
|
1957
1974
|
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;
|
|
1958
|
-
const codegen_1$
|
|
1959
|
-
const util_1$
|
|
1960
|
-
const names_1$
|
|
1975
|
+
const codegen_1$n = codegen;
|
|
1976
|
+
const util_1$m = util;
|
|
1977
|
+
const names_1$3 = requireNames();
|
|
1961
1978
|
const util_2$1 = util;
|
|
1962
1979
|
function checkReportMissingProp(cxt, prop) {
|
|
1963
1980
|
const { gen, data, it } = cxt;
|
|
1964
1981
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
1965
|
-
cxt.setParams({ missingProperty: (0, codegen_1$
|
|
1982
|
+
cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
|
|
1966
1983
|
cxt.error();
|
|
1967
1984
|
});
|
|
1968
1985
|
}
|
|
1969
1986
|
code.checkReportMissingProp = checkReportMissingProp;
|
|
1970
1987
|
function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
|
|
1971
|
-
return (0, codegen_1$
|
|
1988
|
+
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}`)));
|
|
1972
1989
|
}
|
|
1973
1990
|
code.checkMissingProp = checkMissingProp;
|
|
1974
1991
|
function reportMissingProp(cxt, missing) {
|
|
@@ -1980,22 +1997,22 @@ function hasPropFunc(gen) {
|
|
|
1980
1997
|
return gen.scopeValue("func", {
|
|
1981
1998
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1982
1999
|
ref: Object.prototype.hasOwnProperty,
|
|
1983
|
-
code: (0, codegen_1$
|
|
2000
|
+
code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
|
|
1984
2001
|
});
|
|
1985
2002
|
}
|
|
1986
2003
|
code.hasPropFunc = hasPropFunc;
|
|
1987
2004
|
function isOwnProperty(gen, data, property) {
|
|
1988
|
-
return (0, codegen_1$
|
|
2005
|
+
return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
|
|
1989
2006
|
}
|
|
1990
2007
|
code.isOwnProperty = isOwnProperty;
|
|
1991
2008
|
function propertyInData(gen, data, property, ownProperties) {
|
|
1992
|
-
const cond = (0, codegen_1$
|
|
1993
|
-
return ownProperties ? (0, codegen_1$
|
|
2009
|
+
const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
|
|
2010
|
+
return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
|
|
1994
2011
|
}
|
|
1995
2012
|
code.propertyInData = propertyInData;
|
|
1996
2013
|
function noPropertyInData(gen, data, property, ownProperties) {
|
|
1997
|
-
const cond = (0, codegen_1$
|
|
1998
|
-
return ownProperties ? (0, codegen_1$
|
|
2014
|
+
const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
|
|
2015
|
+
return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
|
|
1999
2016
|
}
|
|
2000
2017
|
code.noPropertyInData = noPropertyInData;
|
|
2001
2018
|
function allSchemaProperties(schemaMap) {
|
|
@@ -2003,24 +2020,24 @@ function allSchemaProperties(schemaMap) {
|
|
|
2003
2020
|
}
|
|
2004
2021
|
code.allSchemaProperties = allSchemaProperties;
|
|
2005
2022
|
function schemaProperties(it, schemaMap) {
|
|
2006
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$
|
|
2023
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$m.alwaysValidSchema)(it, schemaMap[p]));
|
|
2007
2024
|
}
|
|
2008
2025
|
code.schemaProperties = schemaProperties;
|
|
2009
2026
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
2010
|
-
const dataAndSchema = passSchema ? (0, codegen_1$
|
|
2027
|
+
const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
|
|
2011
2028
|
const valCxt = [
|
|
2012
|
-
[names_1$
|
|
2013
|
-
[names_1$
|
|
2014
|
-
[names_1$
|
|
2015
|
-
[names_1$
|
|
2029
|
+
[names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
|
|
2030
|
+
[names_1$3.default.parentData, it.parentData],
|
|
2031
|
+
[names_1$3.default.parentDataProperty, it.parentDataProperty],
|
|
2032
|
+
[names_1$3.default.rootData, names_1$3.default.rootData]
|
|
2016
2033
|
];
|
|
2017
2034
|
if (it.opts.dynamicRef)
|
|
2018
|
-
valCxt.push([names_1$
|
|
2019
|
-
const args = (0, codegen_1$
|
|
2020
|
-
return context !== codegen_1$
|
|
2035
|
+
valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
|
|
2036
|
+
const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
2037
|
+
return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
|
|
2021
2038
|
}
|
|
2022
2039
|
code.callValidateCode = callValidateCode;
|
|
2023
|
-
const newRegExp = (0, codegen_1$
|
|
2040
|
+
const newRegExp = (0, codegen_1$n._)`new RegExp`;
|
|
2024
2041
|
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
2025
2042
|
const u = opts.unicodeRegExp ? "u" : "";
|
|
2026
2043
|
const { regExp } = opts.code;
|
|
@@ -2028,7 +2045,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
|
|
|
2028
2045
|
return gen.scopeValue("pattern", {
|
|
2029
2046
|
key: rx.toString(),
|
|
2030
2047
|
ref: rx,
|
|
2031
|
-
code: (0, codegen_1$
|
|
2048
|
+
code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
2032
2049
|
});
|
|
2033
2050
|
}
|
|
2034
2051
|
code.usePattern = usePattern;
|
|
@@ -2044,14 +2061,14 @@ function validateArray(cxt) {
|
|
|
2044
2061
|
validateItems(() => gen.break());
|
|
2045
2062
|
return valid;
|
|
2046
2063
|
function validateItems(notValid) {
|
|
2047
|
-
const len = gen.const("len", (0, codegen_1$
|
|
2064
|
+
const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
|
|
2048
2065
|
gen.forRange("i", 0, len, (i) => {
|
|
2049
2066
|
cxt.subschema({
|
|
2050
2067
|
keyword: keyword2,
|
|
2051
2068
|
dataProp: i,
|
|
2052
|
-
dataPropType: util_1$
|
|
2069
|
+
dataPropType: util_1$m.Type.Num
|
|
2053
2070
|
}, valid);
|
|
2054
|
-
gen.if((0, codegen_1$
|
|
2071
|
+
gen.if((0, codegen_1$n.not)(valid), notValid);
|
|
2055
2072
|
});
|
|
2056
2073
|
}
|
|
2057
2074
|
}
|
|
@@ -2060,7 +2077,7 @@ function validateUnion(cxt) {
|
|
|
2060
2077
|
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
2061
2078
|
if (!Array.isArray(schema))
|
|
2062
2079
|
throw new Error("ajv implementation error");
|
|
2063
|
-
const alwaysValid = schema.some((sch) => (0, util_1$
|
|
2080
|
+
const alwaysValid = schema.some((sch) => (0, util_1$m.alwaysValidSchema)(it, sch));
|
|
2064
2081
|
if (alwaysValid && !it.opts.unevaluated)
|
|
2065
2082
|
return;
|
|
2066
2083
|
const valid = gen.let("valid", false);
|
|
@@ -2071,202 +2088,214 @@ function validateUnion(cxt) {
|
|
|
2071
2088
|
schemaProp: i,
|
|
2072
2089
|
compositeRule: true
|
|
2073
2090
|
}, schValid);
|
|
2074
|
-
gen.assign(valid, (0, codegen_1$
|
|
2091
|
+
gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
|
|
2075
2092
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
2076
2093
|
if (!merged)
|
|
2077
|
-
gen.if((0, codegen_1$
|
|
2094
|
+
gen.if((0, codegen_1$n.not)(valid));
|
|
2078
2095
|
}));
|
|
2079
2096
|
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
2080
2097
|
}
|
|
2081
2098
|
code.validateUnion = validateUnion;
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
const
|
|
2090
|
-
const
|
|
2091
|
-
const
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
2108
|
-
checkAsyncKeyword(it, def2);
|
|
2109
|
-
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
2110
|
-
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
2111
|
-
const valid = gen.let("valid");
|
|
2112
|
-
cxt.block$data(valid, validateKeyword);
|
|
2113
|
-
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
2114
|
-
function validateKeyword() {
|
|
2115
|
-
if (def2.errors === false) {
|
|
2116
|
-
assignValid();
|
|
2117
|
-
if (def2.modifying)
|
|
2118
|
-
modifyData(cxt);
|
|
2119
|
-
reportErrs(() => cxt.error());
|
|
2120
|
-
} else {
|
|
2121
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
2122
|
-
if (def2.modifying)
|
|
2123
|
-
modifyData(cxt);
|
|
2124
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
function validateAsync() {
|
|
2128
|
-
const ruleErrs = gen.let("ruleErrs", null);
|
|
2129
|
-
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)));
|
|
2130
|
-
return ruleErrs;
|
|
2131
|
-
}
|
|
2132
|
-
function validateSync() {
|
|
2133
|
-
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
2134
|
-
gen.assign(validateErrs, null);
|
|
2135
|
-
assignValid(codegen_1$p.nil);
|
|
2136
|
-
return validateErrs;
|
|
2137
|
-
}
|
|
2138
|
-
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
2139
|
-
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
2140
|
-
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
2141
|
-
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
2142
|
-
}
|
|
2143
|
-
function reportErrs(errors2) {
|
|
2144
|
-
var _a2;
|
|
2145
|
-
gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
keyword.funcKeywordCode = funcKeywordCode;
|
|
2149
|
-
function modifyData(cxt) {
|
|
2150
|
-
const { gen, data, it } = cxt;
|
|
2151
|
-
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
2152
|
-
}
|
|
2153
|
-
function addErrs(cxt, errs) {
|
|
2154
|
-
const { gen } = cxt;
|
|
2155
|
-
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
2156
|
-
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`);
|
|
2157
|
-
(0, errors_1$1.extendErrors)(cxt);
|
|
2158
|
-
}, () => cxt.error());
|
|
2159
|
-
}
|
|
2160
|
-
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
2161
|
-
if (def2.async && !schemaEnv.$async)
|
|
2162
|
-
throw new Error("async keyword in sync schema");
|
|
2163
|
-
}
|
|
2164
|
-
function useKeyword(gen, keyword2, result) {
|
|
2165
|
-
if (result === void 0)
|
|
2166
|
-
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
2167
|
-
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
2168
|
-
}
|
|
2169
|
-
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
2170
|
-
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");
|
|
2171
|
-
}
|
|
2172
|
-
keyword.validSchemaType = validSchemaType;
|
|
2173
|
-
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
|
|
2174
|
-
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
2175
|
-
throw new Error("ajv implementation error");
|
|
2099
|
+
var hasRequiredKeyword;
|
|
2100
|
+
function requireKeyword() {
|
|
2101
|
+
if (hasRequiredKeyword) return keyword;
|
|
2102
|
+
hasRequiredKeyword = 1;
|
|
2103
|
+
Object.defineProperty(keyword, "__esModule", { value: true });
|
|
2104
|
+
keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
|
|
2105
|
+
const codegen_12 = codegen;
|
|
2106
|
+
const names_12 = requireNames();
|
|
2107
|
+
const code_12 = code;
|
|
2108
|
+
const errors_12 = errors;
|
|
2109
|
+
function macroKeywordCode(cxt, def2) {
|
|
2110
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
2111
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
2112
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
2113
|
+
if (it.opts.validateSchema !== false)
|
|
2114
|
+
it.self.validateSchema(macroSchema, true);
|
|
2115
|
+
const valid = gen.name("valid");
|
|
2116
|
+
cxt.subschema({
|
|
2117
|
+
schema: macroSchema,
|
|
2118
|
+
schemaPath: codegen_12.nil,
|
|
2119
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
2120
|
+
topSchemaRef: schemaRef,
|
|
2121
|
+
compositeRule: true
|
|
2122
|
+
}, valid);
|
|
2123
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
2176
2124
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2125
|
+
keyword.macroKeywordCode = macroKeywordCode;
|
|
2126
|
+
function funcKeywordCode(cxt, def2) {
|
|
2127
|
+
var _a;
|
|
2128
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
2129
|
+
checkAsyncKeyword(it, def2);
|
|
2130
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
2131
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
2132
|
+
const valid = gen.let("valid");
|
|
2133
|
+
cxt.block$data(valid, validateKeyword);
|
|
2134
|
+
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
2135
|
+
function validateKeyword() {
|
|
2136
|
+
if (def2.errors === false) {
|
|
2137
|
+
assignValid();
|
|
2138
|
+
if (def2.modifying)
|
|
2139
|
+
modifyData(cxt);
|
|
2140
|
+
reportErrs(() => cxt.error());
|
|
2141
|
+
} else {
|
|
2142
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
2143
|
+
if (def2.modifying)
|
|
2144
|
+
modifyData(cxt);
|
|
2145
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
function validateAsync() {
|
|
2149
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
2150
|
+
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)));
|
|
2151
|
+
return ruleErrs;
|
|
2152
|
+
}
|
|
2153
|
+
function validateSync() {
|
|
2154
|
+
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
2155
|
+
gen.assign(validateErrs, null);
|
|
2156
|
+
assignValid(codegen_12.nil);
|
|
2157
|
+
return validateErrs;
|
|
2158
|
+
}
|
|
2159
|
+
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
2160
|
+
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
2161
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
2162
|
+
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
2163
|
+
}
|
|
2164
|
+
function reportErrs(errors2) {
|
|
2165
|
+
var _a2;
|
|
2166
|
+
gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
2167
|
+
}
|
|
2180
2168
|
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2169
|
+
keyword.funcKeywordCode = funcKeywordCode;
|
|
2170
|
+
function modifyData(cxt) {
|
|
2171
|
+
const { gen, data, it } = cxt;
|
|
2172
|
+
gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
2173
|
+
}
|
|
2174
|
+
function addErrs(cxt, errs) {
|
|
2175
|
+
const { gen } = cxt;
|
|
2176
|
+
gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
|
|
2177
|
+
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`);
|
|
2178
|
+
(0, errors_12.extendErrors)(cxt);
|
|
2179
|
+
}, () => cxt.error());
|
|
2180
|
+
}
|
|
2181
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
2182
|
+
if (def2.async && !schemaEnv.$async)
|
|
2183
|
+
throw new Error("async keyword in sync schema");
|
|
2184
|
+
}
|
|
2185
|
+
function useKeyword(gen, keyword2, result) {
|
|
2186
|
+
if (result === void 0)
|
|
2187
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
2188
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
|
|
2189
|
+
}
|
|
2190
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
2191
|
+
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");
|
|
2192
|
+
}
|
|
2193
|
+
keyword.validSchemaType = validSchemaType;
|
|
2194
|
+
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def2, keyword2) {
|
|
2195
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
2196
|
+
throw new Error("ajv implementation error");
|
|
2197
|
+
}
|
|
2198
|
+
const deps = def2.dependencies;
|
|
2199
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
2200
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
2201
|
+
}
|
|
2202
|
+
if (def2.validateSchema) {
|
|
2203
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
2204
|
+
if (!valid) {
|
|
2205
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def2.validateSchema.errors);
|
|
2206
|
+
if (opts.validateSchema === "log")
|
|
2207
|
+
self.logger.error(msg);
|
|
2208
|
+
else
|
|
2209
|
+
throw new Error(msg);
|
|
2210
|
+
}
|
|
2189
2211
|
}
|
|
2190
2212
|
}
|
|
2213
|
+
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
2214
|
+
return keyword;
|
|
2191
2215
|
}
|
|
2192
|
-
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
2193
2216
|
var subschema = {};
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
schema: sch,
|
|
2206
|
-
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
2207
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
2208
|
-
} : {
|
|
2209
|
-
schema: sch[schemaProp],
|
|
2210
|
-
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
2211
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$n.escapeFragment)(schemaProp)}`
|
|
2212
|
-
};
|
|
2213
|
-
}
|
|
2214
|
-
if (schema !== void 0) {
|
|
2215
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
2216
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
2217
|
+
var hasRequiredSubschema;
|
|
2218
|
+
function requireSubschema() {
|
|
2219
|
+
if (hasRequiredSubschema) return subschema;
|
|
2220
|
+
hasRequiredSubschema = 1;
|
|
2221
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
2222
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
2223
|
+
const codegen_12 = codegen;
|
|
2224
|
+
const util_12 = util;
|
|
2225
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
2226
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
2227
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
2217
2228
|
}
|
|
2218
|
-
|
|
2219
|
-
schema
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2229
|
+
if (keyword2 !== void 0) {
|
|
2230
|
+
const sch = it.schema[keyword2];
|
|
2231
|
+
return schemaProp === void 0 ? {
|
|
2232
|
+
schema: sch,
|
|
2233
|
+
schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
|
|
2234
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
2235
|
+
} : {
|
|
2236
|
+
schema: sch[schemaProp],
|
|
2237
|
+
schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
|
|
2238
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
|
|
2239
|
+
};
|
|
2240
|
+
}
|
|
2241
|
+
if (schema !== void 0) {
|
|
2242
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
2243
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
2244
|
+
}
|
|
2245
|
+
return {
|
|
2246
|
+
schema,
|
|
2247
|
+
schemaPath,
|
|
2248
|
+
topSchemaRef,
|
|
2249
|
+
errSchemaPath
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
2253
|
+
}
|
|
2254
|
+
subschema.getSubschema = getSubschema;
|
|
2255
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
|
|
2256
|
+
if (data !== void 0 && dataProp !== void 0) {
|
|
2257
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
2258
|
+
}
|
|
2259
|
+
const { gen } = it;
|
|
2260
|
+
if (dataProp !== void 0) {
|
|
2261
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
2262
|
+
const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
|
|
2263
|
+
dataContextProps(nextData);
|
|
2264
|
+
subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
2265
|
+
subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
|
|
2266
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
2267
|
+
}
|
|
2268
|
+
if (data !== void 0) {
|
|
2269
|
+
const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
|
|
2270
|
+
dataContextProps(nextData);
|
|
2271
|
+
if (propertyName !== void 0)
|
|
2272
|
+
subschema2.propertyName = propertyName;
|
|
2273
|
+
}
|
|
2274
|
+
if (dataTypes)
|
|
2275
|
+
subschema2.dataTypes = dataTypes;
|
|
2276
|
+
function dataContextProps(_nextData) {
|
|
2277
|
+
subschema2.data = _nextData;
|
|
2278
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
2279
|
+
subschema2.dataTypes = [];
|
|
2280
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
2281
|
+
subschema2.parentData = it.data;
|
|
2282
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
2286
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
2287
|
+
if (compositeRule !== void 0)
|
|
2288
|
+
subschema2.compositeRule = compositeRule;
|
|
2289
|
+
if (createErrors !== void 0)
|
|
2290
|
+
subschema2.createErrors = createErrors;
|
|
2291
|
+
if (allErrors !== void 0)
|
|
2292
|
+
subschema2.allErrors = allErrors;
|
|
2293
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
2294
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
2295
|
+
}
|
|
2296
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
2297
|
+
return subschema;
|
|
2268
2298
|
}
|
|
2269
|
-
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
2270
2299
|
var resolve$2 = {};
|
|
2271
2300
|
var fastDeepEqual = function equal(a, b) {
|
|
2272
2301
|
if (a === b) return true;
|
|
@@ -2381,7 +2410,7 @@ function escapeJsonPtr(str) {
|
|
|
2381
2410
|
var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
|
|
2382
2411
|
Object.defineProperty(resolve$2, "__esModule", { value: true });
|
|
2383
2412
|
resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
|
|
2384
|
-
const util_1$
|
|
2413
|
+
const util_1$l = util;
|
|
2385
2414
|
const equal$3 = fastDeepEqual;
|
|
2386
2415
|
const traverse = jsonSchemaTraverseExports;
|
|
2387
2416
|
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
@@ -2440,7 +2469,7 @@ function countKeys(schema) {
|
|
|
2440
2469
|
if (SIMPLE_INLINED.has(key))
|
|
2441
2470
|
continue;
|
|
2442
2471
|
if (typeof schema[key] == "object") {
|
|
2443
|
-
(0, util_1$
|
|
2472
|
+
(0, util_1$l.eachItem)(schema[key], (sch) => count += countKeys(sch));
|
|
2444
2473
|
}
|
|
2445
2474
|
if (count === Infinity)
|
|
2446
2475
|
return Infinity;
|
|
@@ -2528,516 +2557,528 @@ function getSchemaRefs(schema, baseId) {
|
|
|
2528
2557
|
}
|
|
2529
2558
|
}
|
|
2530
2559
|
resolve$2.getSchemaRefs = getSchemaRefs;
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
const
|
|
2538
|
-
const
|
|
2539
|
-
const
|
|
2540
|
-
const
|
|
2541
|
-
const
|
|
2542
|
-
const
|
|
2543
|
-
const
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2560
|
+
var hasRequiredValidate;
|
|
2561
|
+
function requireValidate() {
|
|
2562
|
+
if (hasRequiredValidate) return validate;
|
|
2563
|
+
hasRequiredValidate = 1;
|
|
2564
|
+
Object.defineProperty(validate, "__esModule", { value: true });
|
|
2565
|
+
validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
|
|
2566
|
+
const boolSchema_1 = requireBoolSchema();
|
|
2567
|
+
const dataType_12 = dataType;
|
|
2568
|
+
const applicability_12 = applicability;
|
|
2569
|
+
const dataType_2 = dataType;
|
|
2570
|
+
const defaults_1 = requireDefaults();
|
|
2571
|
+
const keyword_1 = requireKeyword();
|
|
2572
|
+
const subschema_1 = requireSubschema();
|
|
2573
|
+
const codegen_12 = codegen;
|
|
2574
|
+
const names_12 = requireNames();
|
|
2575
|
+
const resolve_12 = resolve$2;
|
|
2576
|
+
const util_12 = util;
|
|
2577
|
+
const errors_12 = errors;
|
|
2578
|
+
function validateFunctionCode(it) {
|
|
2579
|
+
if (isSchemaObj(it)) {
|
|
2580
|
+
checkKeywords(it);
|
|
2581
|
+
if (schemaCxtHasRules(it)) {
|
|
2582
|
+
topSchemaObjCode(it);
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2551
2585
|
}
|
|
2586
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2552
2587
|
}
|
|
2553
|
-
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2588
|
+
validate.validateFunctionCode = validateFunctionCode;
|
|
2589
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
2590
|
+
if (opts.code.es5) {
|
|
2591
|
+
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
|
|
2592
|
+
gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
2593
|
+
destructureValCxtES5(gen, opts);
|
|
2594
|
+
gen.code(body);
|
|
2595
|
+
});
|
|
2596
|
+
} else {
|
|
2597
|
+
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
function destructureValCxt(opts) {
|
|
2601
|
+
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}}={}`;
|
|
2602
|
+
}
|
|
2603
|
+
function destructureValCxtES5(gen, opts) {
|
|
2604
|
+
gen.if(names_12.default.valCxt, () => {
|
|
2605
|
+
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
2606
|
+
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
2607
|
+
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
2608
|
+
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
2609
|
+
if (opts.dynamicRef)
|
|
2610
|
+
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
2611
|
+
}, () => {
|
|
2612
|
+
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
2613
|
+
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
2614
|
+
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
2615
|
+
gen.var(names_12.default.rootData, names_12.default.data);
|
|
2616
|
+
if (opts.dynamicRef)
|
|
2617
|
+
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
2562
2618
|
});
|
|
2563
|
-
} else {
|
|
2564
|
-
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
2565
2619
|
}
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
gen
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
}
|
|
2587
|
-
function
|
|
2588
|
-
|
|
2589
|
-
|
|
2620
|
+
function topSchemaObjCode(it) {
|
|
2621
|
+
const { schema, opts, gen } = it;
|
|
2622
|
+
validateFunction(it, () => {
|
|
2623
|
+
if (opts.$comment && schema.$comment)
|
|
2624
|
+
commentKeyword(it);
|
|
2625
|
+
checkNoDefault(it);
|
|
2626
|
+
gen.let(names_12.default.vErrors, null);
|
|
2627
|
+
gen.let(names_12.default.errors, 0);
|
|
2628
|
+
if (opts.unevaluated)
|
|
2629
|
+
resetEvaluated(it);
|
|
2630
|
+
typeAndKeywords(it);
|
|
2631
|
+
returnResults(it);
|
|
2632
|
+
});
|
|
2633
|
+
return;
|
|
2634
|
+
}
|
|
2635
|
+
function resetEvaluated(it) {
|
|
2636
|
+
const { gen, validateName } = it;
|
|
2637
|
+
it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
|
|
2638
|
+
gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
|
|
2639
|
+
gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
|
|
2640
|
+
}
|
|
2641
|
+
function funcSourceUrl(schema, opts) {
|
|
2642
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
2643
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
|
|
2644
|
+
}
|
|
2645
|
+
function subschemaCode(it, valid) {
|
|
2646
|
+
if (isSchemaObj(it)) {
|
|
2647
|
+
checkKeywords(it);
|
|
2648
|
+
if (schemaCxtHasRules(it)) {
|
|
2649
|
+
subSchemaObjCode(it, valid);
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
2654
|
+
}
|
|
2655
|
+
function schemaCxtHasRules({ schema, self }) {
|
|
2656
|
+
if (typeof schema == "boolean")
|
|
2657
|
+
return !schema;
|
|
2658
|
+
for (const key in schema)
|
|
2659
|
+
if (self.RULES.all[key])
|
|
2660
|
+
return true;
|
|
2661
|
+
return false;
|
|
2662
|
+
}
|
|
2663
|
+
function isSchemaObj(it) {
|
|
2664
|
+
return typeof it.schema != "boolean";
|
|
2665
|
+
}
|
|
2666
|
+
function subSchemaObjCode(it, valid) {
|
|
2667
|
+
const { schema, gen, opts } = it;
|
|
2590
2668
|
if (opts.$comment && schema.$comment)
|
|
2591
2669
|
commentKeyword(it);
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
gen.
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
typeAndKeywords(it);
|
|
2598
|
-
returnResults(it);
|
|
2599
|
-
});
|
|
2600
|
-
return;
|
|
2601
|
-
}
|
|
2602
|
-
function resetEvaluated(it) {
|
|
2603
|
-
const { gen, validateName } = it;
|
|
2604
|
-
it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
|
|
2605
|
-
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
|
|
2606
|
-
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
|
|
2607
|
-
}
|
|
2608
|
-
function funcSourceUrl(schema, opts) {
|
|
2609
|
-
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
2610
|
-
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
|
|
2611
|
-
}
|
|
2612
|
-
function subschemaCode(it, valid) {
|
|
2613
|
-
if (isSchemaObj(it)) {
|
|
2614
|
-
checkKeywords(it);
|
|
2615
|
-
if (schemaCxtHasRules(it)) {
|
|
2616
|
-
subSchemaObjCode(it, valid);
|
|
2617
|
-
return;
|
|
2618
|
-
}
|
|
2670
|
+
updateContext(it);
|
|
2671
|
+
checkAsyncSchema(it);
|
|
2672
|
+
const errsCount = gen.const("_errs", names_12.default.errors);
|
|
2673
|
+
typeAndKeywords(it, errsCount);
|
|
2674
|
+
gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
|
|
2619
2675
|
}
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
if (typeof schema == "boolean")
|
|
2624
|
-
return !schema;
|
|
2625
|
-
for (const key in schema)
|
|
2626
|
-
if (self.RULES.all[key])
|
|
2627
|
-
return true;
|
|
2628
|
-
return false;
|
|
2629
|
-
}
|
|
2630
|
-
function isSchemaObj(it) {
|
|
2631
|
-
return typeof it.schema != "boolean";
|
|
2632
|
-
}
|
|
2633
|
-
function subSchemaObjCode(it, valid) {
|
|
2634
|
-
const { schema, gen, opts } = it;
|
|
2635
|
-
if (opts.$comment && schema.$comment)
|
|
2636
|
-
commentKeyword(it);
|
|
2637
|
-
updateContext(it);
|
|
2638
|
-
checkAsyncSchema(it);
|
|
2639
|
-
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
2640
|
-
typeAndKeywords(it, errsCount);
|
|
2641
|
-
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
2642
|
-
}
|
|
2643
|
-
function checkKeywords(it) {
|
|
2644
|
-
(0, util_1$l.checkUnknownRules)(it);
|
|
2645
|
-
checkRefsAndKeywords(it);
|
|
2646
|
-
}
|
|
2647
|
-
function typeAndKeywords(it, errsCount) {
|
|
2648
|
-
if (it.opts.jtd)
|
|
2649
|
-
return schemaKeywords(it, [], false, errsCount);
|
|
2650
|
-
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
2651
|
-
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
2652
|
-
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
2653
|
-
}
|
|
2654
|
-
function checkRefsAndKeywords(it) {
|
|
2655
|
-
const { schema, errSchemaPath, opts, self } = it;
|
|
2656
|
-
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$l.schemaHasRulesButRef)(schema, self.RULES)) {
|
|
2657
|
-
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
2676
|
+
function checkKeywords(it) {
|
|
2677
|
+
(0, util_12.checkUnknownRules)(it);
|
|
2678
|
+
checkRefsAndKeywords(it);
|
|
2658
2679
|
}
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
(0,
|
|
2680
|
+
function typeAndKeywords(it, errsCount) {
|
|
2681
|
+
if (it.opts.jtd)
|
|
2682
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
2683
|
+
const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
|
|
2684
|
+
const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
|
|
2685
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
2664
2686
|
}
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
}
|
|
2671
|
-
function checkAsyncSchema(it) {
|
|
2672
|
-
if (it.schema.$async && !it.schemaEnv.$async)
|
|
2673
|
-
throw new Error("async schema in sync schema");
|
|
2674
|
-
}
|
|
2675
|
-
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
2676
|
-
const msg = schema.$comment;
|
|
2677
|
-
if (opts.$comment === true) {
|
|
2678
|
-
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
2679
|
-
} else if (typeof opts.$comment == "function") {
|
|
2680
|
-
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
2681
|
-
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
2682
|
-
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
2687
|
+
function checkRefsAndKeywords(it) {
|
|
2688
|
+
const { schema, errSchemaPath, opts, self } = it;
|
|
2689
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self.RULES)) {
|
|
2690
|
+
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
2691
|
+
}
|
|
2683
2692
|
}
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
} else {
|
|
2690
|
-
gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
|
|
2691
|
-
if (opts.unevaluated)
|
|
2692
|
-
assignEvaluated(it);
|
|
2693
|
-
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
2693
|
+
function checkNoDefault(it) {
|
|
2694
|
+
const { schema, opts } = it;
|
|
2695
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
2696
|
+
(0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
|
|
2697
|
+
}
|
|
2694
2698
|
}
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
if (items2 instanceof codegen_1$n.Name)
|
|
2700
|
-
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
2701
|
-
}
|
|
2702
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
2703
|
-
const { gen, schema, data, allErrors, opts, self } = it;
|
|
2704
|
-
const { RULES } = self;
|
|
2705
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(schema, RULES))) {
|
|
2706
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2707
|
-
return;
|
|
2699
|
+
function updateContext(it) {
|
|
2700
|
+
const schId = it.schema[it.opts.schemaId];
|
|
2701
|
+
if (schId)
|
|
2702
|
+
it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
2708
2703
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
if (
|
|
2704
|
+
function checkAsyncSchema(it) {
|
|
2705
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
2706
|
+
throw new Error("async schema in sync schema");
|
|
2707
|
+
}
|
|
2708
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
2709
|
+
const msg = schema.$comment;
|
|
2710
|
+
if (opts.$comment === true) {
|
|
2711
|
+
gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
|
|
2712
|
+
} else if (typeof opts.$comment == "function") {
|
|
2713
|
+
const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
|
|
2714
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
2715
|
+
gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
function returnResults(it) {
|
|
2719
|
+
const { gen, schemaEnv, validateName, ValidationError, opts } = it;
|
|
2720
|
+
if (schemaEnv.$async) {
|
|
2721
|
+
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})`));
|
|
2722
|
+
} else {
|
|
2723
|
+
gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
|
|
2724
|
+
if (opts.unevaluated)
|
|
2725
|
+
assignEvaluated(it);
|
|
2726
|
+
gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
2730
|
+
if (props instanceof codegen_12.Name)
|
|
2731
|
+
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
2732
|
+
if (items2 instanceof codegen_12.Name)
|
|
2733
|
+
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
2734
|
+
}
|
|
2735
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
2736
|
+
const { gen, schema, data, allErrors, opts, self } = it;
|
|
2737
|
+
const { RULES } = self;
|
|
2738
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
2739
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2718
2740
|
return;
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
(
|
|
2741
|
+
}
|
|
2742
|
+
if (!opts.jtd)
|
|
2743
|
+
checkStrictTypes(it, types2);
|
|
2744
|
+
gen.block(() => {
|
|
2745
|
+
for (const group of RULES.rules)
|
|
2746
|
+
groupKeywords(group);
|
|
2747
|
+
groupKeywords(RULES.post);
|
|
2748
|
+
});
|
|
2749
|
+
function groupKeywords(group) {
|
|
2750
|
+
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
2751
|
+
return;
|
|
2752
|
+
if (group.type) {
|
|
2753
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
2754
|
+
iterateKeywords(it, group);
|
|
2755
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
2756
|
+
gen.else();
|
|
2757
|
+
(0, dataType_2.reportTypeError)(it);
|
|
2758
|
+
}
|
|
2759
|
+
gen.endIf();
|
|
2760
|
+
} else {
|
|
2761
|
+
iterateKeywords(it, group);
|
|
2725
2762
|
}
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
iterateKeywords(it, group);
|
|
2763
|
+
if (!allErrors)
|
|
2764
|
+
gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
|
|
2729
2765
|
}
|
|
2730
|
-
if (!allErrors)
|
|
2731
|
-
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
2732
2766
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
(
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2767
|
+
function iterateKeywords(it, group) {
|
|
2768
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
2769
|
+
if (useDefaults)
|
|
2770
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
2771
|
+
gen.block(() => {
|
|
2772
|
+
for (const rule of group.rules) {
|
|
2773
|
+
if ((0, applicability_12.shouldUseRule)(schema, rule)) {
|
|
2774
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
2775
|
+
}
|
|
2742
2776
|
}
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
function checkStrictTypes(it, types2) {
|
|
2780
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
2781
|
+
return;
|
|
2782
|
+
checkContextTypes(it, types2);
|
|
2783
|
+
if (!it.opts.allowUnionTypes)
|
|
2784
|
+
checkMultipleTypes(it, types2);
|
|
2785
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
2786
|
+
}
|
|
2787
|
+
function checkContextTypes(it, types2) {
|
|
2788
|
+
if (!types2.length)
|
|
2789
|
+
return;
|
|
2790
|
+
if (!it.dataTypes.length) {
|
|
2791
|
+
it.dataTypes = types2;
|
|
2792
|
+
return;
|
|
2743
2793
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
if (!it.opts.allowUnionTypes)
|
|
2751
|
-
checkMultipleTypes(it, types2);
|
|
2752
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
2753
|
-
}
|
|
2754
|
-
function checkContextTypes(it, types2) {
|
|
2755
|
-
if (!types2.length)
|
|
2756
|
-
return;
|
|
2757
|
-
if (!it.dataTypes.length) {
|
|
2758
|
-
it.dataTypes = types2;
|
|
2759
|
-
return;
|
|
2794
|
+
types2.forEach((t) => {
|
|
2795
|
+
if (!includesType(it.dataTypes, t)) {
|
|
2796
|
+
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2799
|
+
narrowSchemaTypes(it, types2);
|
|
2760
2800
|
}
|
|
2761
|
-
|
|
2762
|
-
if (!
|
|
2763
|
-
strictTypesError(it,
|
|
2801
|
+
function checkMultipleTypes(it, ts) {
|
|
2802
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
2803
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
2764
2804
|
}
|
|
2765
|
-
});
|
|
2766
|
-
narrowSchemaTypes(it, types2);
|
|
2767
|
-
}
|
|
2768
|
-
function checkMultipleTypes(it, ts) {
|
|
2769
|
-
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
2770
|
-
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
2771
2805
|
}
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2806
|
+
function checkKeywordTypes(it, ts) {
|
|
2807
|
+
const rules2 = it.self.RULES.all;
|
|
2808
|
+
for (const keyword2 in rules2) {
|
|
2809
|
+
const rule = rules2[keyword2];
|
|
2810
|
+
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
2811
|
+
const { type: type2 } = rule.definition;
|
|
2812
|
+
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
2813
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
2814
|
+
}
|
|
2781
2815
|
}
|
|
2782
2816
|
}
|
|
2783
2817
|
}
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2818
|
+
function hasApplicableType(schTs, kwdT) {
|
|
2819
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
2820
|
+
}
|
|
2821
|
+
function includesType(ts, t) {
|
|
2822
|
+
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
2823
|
+
}
|
|
2824
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
2825
|
+
const ts = [];
|
|
2826
|
+
for (const t of it.dataTypes) {
|
|
2827
|
+
if (includesType(withTypes, t))
|
|
2828
|
+
ts.push(t);
|
|
2829
|
+
else if (withTypes.includes("integer") && t === "number")
|
|
2830
|
+
ts.push("integer");
|
|
2831
|
+
}
|
|
2832
|
+
it.dataTypes = ts;
|
|
2833
|
+
}
|
|
2834
|
+
function strictTypesError(it, msg) {
|
|
2835
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
2836
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
2837
|
+
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
2838
|
+
}
|
|
2839
|
+
class KeywordCxt {
|
|
2840
|
+
constructor(it, def2, keyword2) {
|
|
2841
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
2842
|
+
this.gen = it.gen;
|
|
2843
|
+
this.allErrors = it.allErrors;
|
|
2844
|
+
this.keyword = keyword2;
|
|
2845
|
+
this.data = it.data;
|
|
2846
|
+
this.schema = it.schema[keyword2];
|
|
2847
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
2848
|
+
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
2849
|
+
this.schemaType = def2.schemaType;
|
|
2850
|
+
this.parentSchema = it.schema;
|
|
2851
|
+
this.params = {};
|
|
2852
|
+
this.it = it;
|
|
2853
|
+
this.def = def2;
|
|
2854
|
+
if (this.$data) {
|
|
2855
|
+
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
2856
|
+
} else {
|
|
2857
|
+
this.schemaCode = this.schemaValue;
|
|
2858
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
2859
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
2863
|
+
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
2827
2864
|
}
|
|
2828
2865
|
}
|
|
2829
|
-
|
|
2830
|
-
this.
|
|
2866
|
+
result(condition, successAction, failAction) {
|
|
2867
|
+
this.failResult((0, codegen_12.not)(condition), successAction, failAction);
|
|
2831
2868
|
}
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2869
|
+
failResult(condition, successAction, failAction) {
|
|
2870
|
+
this.gen.if(condition);
|
|
2871
|
+
if (failAction)
|
|
2872
|
+
failAction();
|
|
2873
|
+
else
|
|
2874
|
+
this.error();
|
|
2875
|
+
if (successAction) {
|
|
2876
|
+
this.gen.else();
|
|
2877
|
+
successAction();
|
|
2878
|
+
if (this.allErrors)
|
|
2879
|
+
this.gen.endIf();
|
|
2880
|
+
} else {
|
|
2881
|
+
if (this.allErrors)
|
|
2882
|
+
this.gen.endIf();
|
|
2883
|
+
else
|
|
2884
|
+
this.gen.else();
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
pass(condition, failAction) {
|
|
2888
|
+
this.failResult((0, codegen_12.not)(condition), void 0, failAction);
|
|
2889
|
+
}
|
|
2890
|
+
fail(condition) {
|
|
2891
|
+
if (condition === void 0) {
|
|
2892
|
+
this.error();
|
|
2893
|
+
if (!this.allErrors)
|
|
2894
|
+
this.gen.if(false);
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2897
|
+
this.gen.if(condition);
|
|
2841
2898
|
this.error();
|
|
2842
|
-
if (successAction) {
|
|
2843
|
-
this.gen.else();
|
|
2844
|
-
successAction();
|
|
2845
|
-
if (this.allErrors)
|
|
2846
|
-
this.gen.endIf();
|
|
2847
|
-
} else {
|
|
2848
2899
|
if (this.allErrors)
|
|
2849
2900
|
this.gen.endIf();
|
|
2850
2901
|
else
|
|
2851
2902
|
this.gen.else();
|
|
2852
2903
|
}
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2904
|
+
fail$data(condition) {
|
|
2905
|
+
if (!this.$data)
|
|
2906
|
+
return this.fail(condition);
|
|
2907
|
+
const { schemaCode } = this;
|
|
2908
|
+
this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
|
|
2909
|
+
}
|
|
2910
|
+
error(append, errorParams, errorPaths) {
|
|
2911
|
+
if (errorParams) {
|
|
2912
|
+
this.setParams(errorParams);
|
|
2913
|
+
this._error(append, errorPaths);
|
|
2914
|
+
this.setParams({});
|
|
2915
|
+
return;
|
|
2916
|
+
}
|
|
2917
|
+
this._error(append, errorPaths);
|
|
2918
|
+
}
|
|
2919
|
+
_error(append, errorPaths) {
|
|
2920
|
+
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
2921
|
+
}
|
|
2922
|
+
$dataError() {
|
|
2923
|
+
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
2924
|
+
}
|
|
2925
|
+
reset() {
|
|
2926
|
+
if (this.errsCount === void 0)
|
|
2927
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
2928
|
+
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
2929
|
+
}
|
|
2930
|
+
ok(cond) {
|
|
2860
2931
|
if (!this.allErrors)
|
|
2861
|
-
this.gen.if(
|
|
2862
|
-
return;
|
|
2932
|
+
this.gen.if(cond);
|
|
2863
2933
|
}
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
this.gen.else();
|
|
2870
|
-
}
|
|
2871
|
-
fail$data(condition) {
|
|
2872
|
-
if (!this.$data)
|
|
2873
|
-
return this.fail(condition);
|
|
2874
|
-
const { schemaCode } = this;
|
|
2875
|
-
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
2876
|
-
}
|
|
2877
|
-
error(append, errorParams, errorPaths) {
|
|
2878
|
-
if (errorParams) {
|
|
2879
|
-
this.setParams(errorParams);
|
|
2880
|
-
this._error(append, errorPaths);
|
|
2881
|
-
this.setParams({});
|
|
2882
|
-
return;
|
|
2934
|
+
setParams(obj, assign) {
|
|
2935
|
+
if (assign)
|
|
2936
|
+
Object.assign(this.params, obj);
|
|
2937
|
+
else
|
|
2938
|
+
this.params = obj;
|
|
2883
2939
|
}
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
$dataError() {
|
|
2890
|
-
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
2891
|
-
}
|
|
2892
|
-
reset() {
|
|
2893
|
-
if (this.errsCount === void 0)
|
|
2894
|
-
throw new Error('add "trackErrors" to keyword definition');
|
|
2895
|
-
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
2896
|
-
}
|
|
2897
|
-
ok(cond) {
|
|
2898
|
-
if (!this.allErrors)
|
|
2899
|
-
this.gen.if(cond);
|
|
2900
|
-
}
|
|
2901
|
-
setParams(obj, assign) {
|
|
2902
|
-
if (assign)
|
|
2903
|
-
Object.assign(this.params, obj);
|
|
2904
|
-
else
|
|
2905
|
-
this.params = obj;
|
|
2906
|
-
}
|
|
2907
|
-
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
2908
|
-
this.gen.block(() => {
|
|
2909
|
-
this.check$data(valid, $dataValid);
|
|
2910
|
-
codeBlock();
|
|
2911
|
-
});
|
|
2912
|
-
}
|
|
2913
|
-
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
2914
|
-
if (!this.$data)
|
|
2915
|
-
return;
|
|
2916
|
-
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
2917
|
-
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
2918
|
-
if (valid !== codegen_1$n.nil)
|
|
2919
|
-
gen.assign(valid, true);
|
|
2920
|
-
if (schemaType.length || def2.validateSchema) {
|
|
2921
|
-
gen.elseIf(this.invalid$data());
|
|
2922
|
-
this.$dataError();
|
|
2923
|
-
if (valid !== codegen_1$n.nil)
|
|
2924
|
-
gen.assign(valid, false);
|
|
2940
|
+
block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
|
|
2941
|
+
this.gen.block(() => {
|
|
2942
|
+
this.check$data(valid, $dataValid);
|
|
2943
|
+
codeBlock();
|
|
2944
|
+
});
|
|
2925
2945
|
}
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2946
|
+
check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
|
|
2947
|
+
if (!this.$data)
|
|
2948
|
+
return;
|
|
2949
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
2950
|
+
gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
|
|
2951
|
+
if (valid !== codegen_12.nil)
|
|
2952
|
+
gen.assign(valid, true);
|
|
2953
|
+
if (schemaType.length || def2.validateSchema) {
|
|
2954
|
+
gen.elseIf(this.invalid$data());
|
|
2955
|
+
this.$dataError();
|
|
2956
|
+
if (valid !== codegen_12.nil)
|
|
2957
|
+
gen.assign(valid, false);
|
|
2937
2958
|
}
|
|
2938
|
-
|
|
2959
|
+
gen.else();
|
|
2939
2960
|
}
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2961
|
+
invalid$data() {
|
|
2962
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
2963
|
+
return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
|
|
2964
|
+
function wrong$DataType() {
|
|
2965
|
+
if (schemaType.length) {
|
|
2966
|
+
if (!(schemaCode instanceof codegen_12.Name))
|
|
2967
|
+
throw new Error("ajv implementation error");
|
|
2968
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
2969
|
+
return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
2970
|
+
}
|
|
2971
|
+
return codegen_12.nil;
|
|
2972
|
+
}
|
|
2973
|
+
function invalid$DataSchema() {
|
|
2974
|
+
if (def2.validateSchema) {
|
|
2975
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
2976
|
+
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
2977
|
+
}
|
|
2978
|
+
return codegen_12.nil;
|
|
2944
2979
|
}
|
|
2945
|
-
return codegen_1$n.nil;
|
|
2946
2980
|
}
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
return nextContext;
|
|
2955
|
-
}
|
|
2956
|
-
mergeEvaluated(schemaCxt, toName) {
|
|
2957
|
-
const { it, gen } = this;
|
|
2958
|
-
if (!it.opts.unevaluated)
|
|
2959
|
-
return;
|
|
2960
|
-
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
2961
|
-
it.props = util_1$l.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
2981
|
+
subschema(appl, valid) {
|
|
2982
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
2983
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
2984
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
2985
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
2986
|
+
subschemaCode(nextContext, valid);
|
|
2987
|
+
return nextContext;
|
|
2962
2988
|
}
|
|
2963
|
-
|
|
2964
|
-
|
|
2989
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
2990
|
+
const { it, gen } = this;
|
|
2991
|
+
if (!it.opts.unevaluated)
|
|
2992
|
+
return;
|
|
2993
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
2994
|
+
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
2995
|
+
}
|
|
2996
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
2997
|
+
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
2998
|
+
}
|
|
2965
2999
|
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3000
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
3001
|
+
const { it, gen } = this;
|
|
3002
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
3003
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
|
|
3004
|
+
return true;
|
|
3005
|
+
}
|
|
2972
3006
|
}
|
|
2973
3007
|
}
|
|
3008
|
+
validate.KeywordCxt = KeywordCxt;
|
|
3009
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
3010
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
3011
|
+
if ("code" in def2) {
|
|
3012
|
+
def2.code(cxt, ruleType);
|
|
3013
|
+
} else if (cxt.$data && def2.validate) {
|
|
3014
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
3015
|
+
} else if ("macro" in def2) {
|
|
3016
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
3017
|
+
} else if (def2.compile || def2.validate) {
|
|
3018
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
3022
|
+
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
3023
|
+
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
3024
|
+
let jsonPointer;
|
|
3025
|
+
let data;
|
|
3026
|
+
if ($data === "")
|
|
3027
|
+
return names_12.default.rootData;
|
|
3028
|
+
if ($data[0] === "/") {
|
|
3029
|
+
if (!JSON_POINTER.test($data))
|
|
3030
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
3031
|
+
jsonPointer = $data;
|
|
3032
|
+
data = names_12.default.rootData;
|
|
3033
|
+
} else {
|
|
3034
|
+
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
3035
|
+
if (!matches)
|
|
3036
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
3037
|
+
const up = +matches[1];
|
|
3038
|
+
jsonPointer = matches[2];
|
|
3039
|
+
if (jsonPointer === "#") {
|
|
3040
|
+
if (up >= dataLevel)
|
|
3041
|
+
throw new Error(errorMsg("property/index", up));
|
|
3042
|
+
return dataPathArr[dataLevel - up];
|
|
3043
|
+
}
|
|
3044
|
+
if (up > dataLevel)
|
|
3045
|
+
throw new Error(errorMsg("data", up));
|
|
3046
|
+
data = dataNames[dataLevel - up];
|
|
3047
|
+
if (!jsonPointer)
|
|
3048
|
+
return data;
|
|
3049
|
+
}
|
|
3050
|
+
let expr = data;
|
|
3051
|
+
const segments = jsonPointer.split("/");
|
|
3052
|
+
for (const segment of segments) {
|
|
3053
|
+
if (segment) {
|
|
3054
|
+
data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
|
|
3055
|
+
expr = (0, codegen_12._)`${expr} && ${data}`;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
return expr;
|
|
3059
|
+
function errorMsg(pointerType, up) {
|
|
3060
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
validate.getData = getData;
|
|
3064
|
+
return validate;
|
|
2974
3065
|
}
|
|
2975
|
-
validate.KeywordCxt = KeywordCxt;
|
|
2976
|
-
function keywordCode(it, keyword2, def2, ruleType) {
|
|
2977
|
-
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
2978
|
-
if ("code" in def2) {
|
|
2979
|
-
def2.code(cxt, ruleType);
|
|
2980
|
-
} else if (cxt.$data && def2.validate) {
|
|
2981
|
-
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2982
|
-
} else if ("macro" in def2) {
|
|
2983
|
-
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
2984
|
-
} else if (def2.compile || def2.validate) {
|
|
2985
|
-
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2986
|
-
}
|
|
2987
|
-
}
|
|
2988
|
-
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
2989
|
-
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2990
|
-
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
2991
|
-
let jsonPointer;
|
|
2992
|
-
let data;
|
|
2993
|
-
if ($data === "")
|
|
2994
|
-
return names_1$3.default.rootData;
|
|
2995
|
-
if ($data[0] === "/") {
|
|
2996
|
-
if (!JSON_POINTER.test($data))
|
|
2997
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2998
|
-
jsonPointer = $data;
|
|
2999
|
-
data = names_1$3.default.rootData;
|
|
3000
|
-
} else {
|
|
3001
|
-
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
3002
|
-
if (!matches)
|
|
3003
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
3004
|
-
const up = +matches[1];
|
|
3005
|
-
jsonPointer = matches[2];
|
|
3006
|
-
if (jsonPointer === "#") {
|
|
3007
|
-
if (up >= dataLevel)
|
|
3008
|
-
throw new Error(errorMsg("property/index", up));
|
|
3009
|
-
return dataPathArr[dataLevel - up];
|
|
3010
|
-
}
|
|
3011
|
-
if (up > dataLevel)
|
|
3012
|
-
throw new Error(errorMsg("data", up));
|
|
3013
|
-
data = dataNames[dataLevel - up];
|
|
3014
|
-
if (!jsonPointer)
|
|
3015
|
-
return data;
|
|
3016
|
-
}
|
|
3017
|
-
let expr = data;
|
|
3018
|
-
const segments = jsonPointer.split("/");
|
|
3019
|
-
for (const segment of segments) {
|
|
3020
|
-
if (segment) {
|
|
3021
|
-
data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(segment))}`;
|
|
3022
|
-
expr = (0, codegen_1$n._)`${expr} && ${data}`;
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
return expr;
|
|
3026
|
-
function errorMsg(pointerType, up) {
|
|
3027
|
-
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
validate.getData = getData;
|
|
3031
3066
|
var validation_error = {};
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3067
|
+
var hasRequiredValidation_error;
|
|
3068
|
+
function requireValidation_error() {
|
|
3069
|
+
if (hasRequiredValidation_error) return validation_error;
|
|
3070
|
+
hasRequiredValidation_error = 1;
|
|
3071
|
+
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
3072
|
+
class ValidationError extends Error {
|
|
3073
|
+
constructor(errors2) {
|
|
3074
|
+
super("validation failed");
|
|
3075
|
+
this.errors = errors2;
|
|
3076
|
+
this.ajv = this.validation = true;
|
|
3077
|
+
}
|
|
3038
3078
|
}
|
|
3079
|
+
validation_error.default = ValidationError;
|
|
3080
|
+
return validation_error;
|
|
3039
3081
|
}
|
|
3040
|
-
validation_error.default = ValidationError;
|
|
3041
3082
|
var ref_error = {};
|
|
3042
3083
|
Object.defineProperty(ref_error, "__esModule", { value: true });
|
|
3043
3084
|
const resolve_1$1 = resolve$2;
|
|
@@ -3053,11 +3094,11 @@ var compile = {};
|
|
|
3053
3094
|
Object.defineProperty(compile, "__esModule", { value: true });
|
|
3054
3095
|
compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
|
|
3055
3096
|
const codegen_1$m = codegen;
|
|
3056
|
-
const validation_error_1 =
|
|
3057
|
-
const names_1$2 =
|
|
3097
|
+
const validation_error_1 = requireValidation_error();
|
|
3098
|
+
const names_1$2 = requireNames();
|
|
3058
3099
|
const resolve_1 = resolve$2;
|
|
3059
3100
|
const util_1$k = util;
|
|
3060
|
-
const validate_1$1 =
|
|
3101
|
+
const validate_1$1 = requireValidate();
|
|
3061
3102
|
class SchemaEnv {
|
|
3062
3103
|
constructor(env) {
|
|
3063
3104
|
var _a;
|
|
@@ -3986,7 +4027,7 @@ uri$1.default = uri;
|
|
|
3986
4027
|
(function(exports$1) {
|
|
3987
4028
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
3988
4029
|
exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
|
|
3989
|
-
var validate_12 =
|
|
4030
|
+
var validate_12 = requireValidate();
|
|
3990
4031
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
3991
4032
|
return validate_12.KeywordCxt;
|
|
3992
4033
|
} });
|
|
@@ -4009,7 +4050,7 @@ uri$1.default = uri;
|
|
|
4009
4050
|
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
4010
4051
|
return codegen_12.CodeGen;
|
|
4011
4052
|
} });
|
|
4012
|
-
const validation_error_12 =
|
|
4053
|
+
const validation_error_12 = requireValidation_error();
|
|
4013
4054
|
const ref_error_12 = ref_error;
|
|
4014
4055
|
const rules_12 = rules;
|
|
4015
4056
|
const compile_12 = compile;
|
|
@@ -4606,7 +4647,7 @@ ref.callRef = ref.getValidate = void 0;
|
|
|
4606
4647
|
const ref_error_1$1 = ref_error;
|
|
4607
4648
|
const code_1$8 = code;
|
|
4608
4649
|
const codegen_1$l = codegen;
|
|
4609
|
-
const names_1$1 =
|
|
4650
|
+
const names_1$1 = requireNames();
|
|
4610
4651
|
const compile_1$1 = compile;
|
|
4611
4652
|
const util_1$j = util;
|
|
4612
4653
|
const def$r = {
|
|
@@ -5490,7 +5531,7 @@ var additionalProperties = {};
|
|
|
5490
5531
|
Object.defineProperty(additionalProperties, "__esModule", { value: true });
|
|
5491
5532
|
const code_1$3 = code;
|
|
5492
5533
|
const codegen_1$5 = codegen;
|
|
5493
|
-
const names_1 =
|
|
5534
|
+
const names_1 = requireNames();
|
|
5494
5535
|
const util_1$8 = util;
|
|
5495
5536
|
const error$4 = {
|
|
5496
5537
|
message: "must NOT have additional properties",
|
|
@@ -5588,7 +5629,7 @@ const def$a = {
|
|
|
5588
5629
|
additionalProperties.default = def$a;
|
|
5589
5630
|
var properties$1 = {};
|
|
5590
5631
|
Object.defineProperty(properties$1, "__esModule", { value: true });
|
|
5591
|
-
const validate_1 =
|
|
5632
|
+
const validate_1 = requireValidate();
|
|
5592
5633
|
const code_1$2 = code;
|
|
5593
5634
|
const util_1$7 = util;
|
|
5594
5635
|
const additionalProperties_1$1 = additionalProperties;
|
|
@@ -6439,7 +6480,7 @@ const require$$3 = {
|
|
|
6439
6480
|
module2.exports.Ajv = Ajv;
|
|
6440
6481
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
6441
6482
|
exports$1.default = Ajv;
|
|
6442
|
-
var validate_12 =
|
|
6483
|
+
var validate_12 = requireValidate();
|
|
6443
6484
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
6444
6485
|
return validate_12.KeywordCxt;
|
|
6445
6486
|
} });
|
|
@@ -6462,7 +6503,7 @@ const require$$3 = {
|
|
|
6462
6503
|
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
6463
6504
|
return codegen_12.CodeGen;
|
|
6464
6505
|
} });
|
|
6465
|
-
var validation_error_12 =
|
|
6506
|
+
var validation_error_12 = requireValidation_error();
|
|
6466
6507
|
Object.defineProperty(exports$1, "ValidationError", { enumerable: true, get: function() {
|
|
6467
6508
|
return validation_error_12.default;
|
|
6468
6509
|
} });
|
|
@@ -7152,15 +7193,16 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
7152
7193
|
var _a2;
|
|
7153
7194
|
return [
|
|
7154
7195
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList((_a2 = vue.unref(tableConfig2)) == null ? void 0 : _a2.headerButtons, (buttonItem) => {
|
|
7155
|
-
return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElButton), {
|
|
7156
|
-
key: buttonItem.eventKey
|
|
7196
|
+
return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElButton), vue.mergeProps({
|
|
7197
|
+
key: buttonItem.eventKey
|
|
7198
|
+
}, { ref_for: true }, buttonItem == null ? void 0 : buttonItem.eventOption, {
|
|
7157
7199
|
onClick: ($event) => onOperate({ btnConfig: buttonItem })
|
|
7158
|
-
}, {
|
|
7200
|
+
}), {
|
|
7159
7201
|
default: vue.withCtx(() => [
|
|
7160
7202
|
vue.createTextVNode(vue.toDisplayString(buttonItem.label), 1)
|
|
7161
7203
|
]),
|
|
7162
7204
|
_: 2
|
|
7163
|
-
},
|
|
7205
|
+
}, 1040, ["onClick"]);
|
|
7164
7206
|
}), 128))
|
|
7165
7207
|
];
|
|
7166
7208
|
}),
|
|
@@ -7185,7 +7227,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
7185
7227
|
};
|
|
7186
7228
|
}
|
|
7187
7229
|
});
|
|
7188
|
-
const tablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
7230
|
+
const tablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2f2f7b58"]]);
|
|
7189
7231
|
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
7190
7232
|
__name: "input",
|
|
7191
7233
|
props: {
|