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