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