@opentiny/next-sdk 0.1.7 → 0.1.8
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/agent/AgentModelProvider.ts +9 -11
- package/dist/agent/AgentModelProvider.d.ts +3 -9
- package/dist/agent/AgentModelProvider.js +6 -9
- package/dist/index.es.dev.js +14 -14
- package/dist/index.es.js +2630 -2629
- package/dist/index.umd.dev.js +14 -14
- package/dist/index.umd.js +24 -24
- package/dist/mcpsdk@1.17.0.es.js +6297 -6312
- package/dist/mcpsdk@1.17.0.js +16 -16
- package/dist/remoter/createRemoter.d.ts +2 -0
- package/dist/remoter/createRemoter.js +7 -5
- package/dist/webagent.dev.js +14 -14
- package/dist/webagent.es.dev.js +14 -14
- package/dist/webagent.es.js +1596 -1595
- package/dist/webagent.js +22 -22
- package/dist/webmcp-full.dev.js +958 -922
- package/dist/webmcp-full.es.dev.js +958 -922
- package/package.json +1 -1
- package/remoter/createRemoter.ts +12 -6
|
@@ -1017,8 +1017,8 @@ var scope = {};
|
|
|
1017
1017
|
var util$7 = {};
|
|
1018
1018
|
Object.defineProperty(util$7, "__esModule", { value: true });
|
|
1019
1019
|
util$7.checkStrictMode = util$7.getErrorPath = util$7.Type = util$7.useFunc = util$7.setEvaluated = util$7.evaluatedPropsToName = util$7.mergeEvaluated = util$7.eachItem = util$7.unescapeJsonPointer = util$7.escapeJsonPointer = util$7.escapeFragment = util$7.unescapeFragment = util$7.schemaRefOrVal = util$7.schemaHasRulesButRef = util$7.schemaHasRules = util$7.checkUnknownRules = util$7.alwaysValidSchema = util$7.toHash = void 0;
|
|
1020
|
-
const codegen_1$
|
|
1021
|
-
const code_1$
|
|
1020
|
+
const codegen_1$p = codegen;
|
|
1021
|
+
const code_1$9 = code$1;
|
|
1022
1022
|
function toHash$2(arr) {
|
|
1023
1023
|
const hash = {};
|
|
1024
1024
|
for (const item of arr)
|
|
@@ -1071,9 +1071,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
|
|
|
1071
1071
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
1072
1072
|
return schema;
|
|
1073
1073
|
if (typeof schema == "string")
|
|
1074
|
-
return (0, codegen_1$
|
|
1074
|
+
return (0, codegen_1$p._)`${schema}`;
|
|
1075
1075
|
}
|
|
1076
|
-
return (0, codegen_1$
|
|
1076
|
+
return (0, codegen_1$p._)`${topSchemaRef}${schemaPath}${(0, codegen_1$p.getProperty)(keyword2)}`;
|
|
1077
1077
|
}
|
|
1078
1078
|
util$7.schemaRefOrVal = schemaRefOrVal;
|
|
1079
1079
|
function unescapeFragment$1(str) {
|
|
@@ -1105,20 +1105,20 @@ function eachItem(xs, f) {
|
|
|
1105
1105
|
util$7.eachItem = eachItem;
|
|
1106
1106
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
|
|
1107
1107
|
return (gen, from, to, toName) => {
|
|
1108
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
1109
|
-
return toName === codegen_1$
|
|
1108
|
+
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) : mergeValues2(from, to);
|
|
1109
|
+
return toName === codegen_1$p.Name && !(res instanceof codegen_1$p.Name) ? resultToName(gen, res) : res;
|
|
1110
1110
|
};
|
|
1111
1111
|
}
|
|
1112
1112
|
util$7.mergeEvaluated = {
|
|
1113
1113
|
props: makeMergeEvaluated({
|
|
1114
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
1115
|
-
gen.if((0, codegen_1$
|
|
1114
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true && ${from} !== undefined`, () => {
|
|
1115
|
+
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})`));
|
|
1116
1116
|
}),
|
|
1117
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
1117
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$p._)`${to} !== true`, () => {
|
|
1118
1118
|
if (from === true) {
|
|
1119
1119
|
gen.assign(to, true);
|
|
1120
1120
|
} else {
|
|
1121
|
-
gen.assign(to, (0, codegen_1$
|
|
1121
|
+
gen.assign(to, (0, codegen_1$p._)`${to} || {}`);
|
|
1122
1122
|
setEvaluated(gen, to, from);
|
|
1123
1123
|
}
|
|
1124
1124
|
}),
|
|
@@ -1126,8 +1126,8 @@ util$7.mergeEvaluated = {
|
|
|
1126
1126
|
resultToName: evaluatedPropsToName
|
|
1127
1127
|
}),
|
|
1128
1128
|
items: makeMergeEvaluated({
|
|
1129
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
1130
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
1129
|
+
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}`)),
|
|
1130
|
+
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}`)),
|
|
1131
1131
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
1132
1132
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
1133
1133
|
})
|
|
@@ -1135,21 +1135,21 @@ util$7.mergeEvaluated = {
|
|
|
1135
1135
|
function evaluatedPropsToName(gen, ps) {
|
|
1136
1136
|
if (ps === true)
|
|
1137
1137
|
return gen.var("props", true);
|
|
1138
|
-
const props = gen.var("props", (0, codegen_1$
|
|
1138
|
+
const props = gen.var("props", (0, codegen_1$p._)`{}`);
|
|
1139
1139
|
if (ps !== void 0)
|
|
1140
1140
|
setEvaluated(gen, props, ps);
|
|
1141
1141
|
return props;
|
|
1142
1142
|
}
|
|
1143
1143
|
util$7.evaluatedPropsToName = evaluatedPropsToName;
|
|
1144
1144
|
function setEvaluated(gen, props, ps) {
|
|
1145
|
-
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$
|
|
1145
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$p._)`${props}${(0, codegen_1$p.getProperty)(p)}`, true));
|
|
1146
1146
|
}
|
|
1147
1147
|
util$7.setEvaluated = setEvaluated;
|
|
1148
1148
|
const snippets = {};
|
|
1149
1149
|
function useFunc(gen, f) {
|
|
1150
1150
|
return gen.scopeValue("func", {
|
|
1151
1151
|
ref: f,
|
|
1152
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
1152
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
|
|
1153
1153
|
});
|
|
1154
1154
|
}
|
|
1155
1155
|
util$7.useFunc = useFunc;
|
|
@@ -1159,11 +1159,11 @@ var Type;
|
|
|
1159
1159
|
Type2[Type2["Str"] = 1] = "Str";
|
|
1160
1160
|
})(Type || (util$7.Type = Type = {}));
|
|
1161
1161
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
1162
|
-
if (dataProp instanceof codegen_1$
|
|
1162
|
+
if (dataProp instanceof codegen_1$p.Name) {
|
|
1163
1163
|
const isNumber = dataPropType === Type.Num;
|
|
1164
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
1164
|
+
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")`;
|
|
1165
1165
|
}
|
|
1166
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
1166
|
+
return jsPropertySyntax ? (0, codegen_1$p.getProperty)(dataProp).toString() : "/" + escapeJsonPointer$1(dataProp);
|
|
1167
1167
|
}
|
|
1168
1168
|
util$7.getErrorPath = getErrorPath;
|
|
1169
1169
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -1177,35 +1177,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
|
1177
1177
|
util$7.checkStrictMode = checkStrictMode;
|
|
1178
1178
|
var names$1 = {};
|
|
1179
1179
|
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
1180
|
-
const codegen_1$
|
|
1180
|
+
const codegen_1$o = codegen;
|
|
1181
1181
|
const names = {
|
|
1182
1182
|
// validation function arguments
|
|
1183
|
-
data: new codegen_1$
|
|
1183
|
+
data: new codegen_1$o.Name("data"),
|
|
1184
1184
|
// data passed to validation function
|
|
1185
1185
|
// args passed from referencing schema
|
|
1186
|
-
valCxt: new codegen_1$
|
|
1186
|
+
valCxt: new codegen_1$o.Name("valCxt"),
|
|
1187
1187
|
// validation/data context - should not be used directly, it is destructured to the names below
|
|
1188
|
-
instancePath: new codegen_1$
|
|
1189
|
-
parentData: new codegen_1$
|
|
1190
|
-
parentDataProperty: new codegen_1$
|
|
1191
|
-
rootData: new codegen_1$
|
|
1188
|
+
instancePath: new codegen_1$o.Name("instancePath"),
|
|
1189
|
+
parentData: new codegen_1$o.Name("parentData"),
|
|
1190
|
+
parentDataProperty: new codegen_1$o.Name("parentDataProperty"),
|
|
1191
|
+
rootData: new codegen_1$o.Name("rootData"),
|
|
1192
1192
|
// root data - same as the data passed to the first/top validation function
|
|
1193
|
-
dynamicAnchors: new codegen_1$
|
|
1193
|
+
dynamicAnchors: new codegen_1$o.Name("dynamicAnchors"),
|
|
1194
1194
|
// used to support recursiveRef and dynamicRef
|
|
1195
1195
|
// function scoped variables
|
|
1196
|
-
vErrors: new codegen_1$
|
|
1196
|
+
vErrors: new codegen_1$o.Name("vErrors"),
|
|
1197
1197
|
// null or array of validation errors
|
|
1198
|
-
errors: new codegen_1$
|
|
1198
|
+
errors: new codegen_1$o.Name("errors"),
|
|
1199
1199
|
// counter of validation errors
|
|
1200
|
-
this: new codegen_1$
|
|
1200
|
+
this: new codegen_1$o.Name("this"),
|
|
1201
1201
|
// "globals"
|
|
1202
|
-
self: new codegen_1$
|
|
1203
|
-
scope: new codegen_1$
|
|
1202
|
+
self: new codegen_1$o.Name("self"),
|
|
1203
|
+
scope: new codegen_1$o.Name("scope"),
|
|
1204
1204
|
// JTD serialize/parse name for JSON string and position
|
|
1205
|
-
json: new codegen_1$
|
|
1206
|
-
jsonPos: new codegen_1$
|
|
1207
|
-
jsonLen: new codegen_1$
|
|
1208
|
-
jsonPart: new codegen_1$
|
|
1205
|
+
json: new codegen_1$o.Name("json"),
|
|
1206
|
+
jsonPos: new codegen_1$o.Name("jsonPos"),
|
|
1207
|
+
jsonLen: new codegen_1$o.Name("jsonLen"),
|
|
1208
|
+
jsonPart: new codegen_1$o.Name("jsonPart")
|
|
1209
1209
|
};
|
|
1210
1210
|
names$1.default = names;
|
|
1211
1211
|
(function(exports) {
|
|
@@ -1325,49 +1325,55 @@ names$1.default = names;
|
|
|
1325
1325
|
keyValues.push([E.propertyName, propertyName]);
|
|
1326
1326
|
}
|
|
1327
1327
|
})(errors);
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
gen
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1328
|
+
var hasRequiredBoolSchema;
|
|
1329
|
+
function requireBoolSchema() {
|
|
1330
|
+
if (hasRequiredBoolSchema) return boolSchema;
|
|
1331
|
+
hasRequiredBoolSchema = 1;
|
|
1332
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
1333
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
1334
|
+
const errors_12 = errors;
|
|
1335
|
+
const codegen_12 = codegen;
|
|
1336
|
+
const names_12 = names$1;
|
|
1337
|
+
const boolError = {
|
|
1338
|
+
message: "boolean schema is false"
|
|
1339
|
+
};
|
|
1340
|
+
function topBoolOrEmptySchema(it) {
|
|
1341
|
+
const { gen, schema, validateName } = it;
|
|
1342
|
+
if (schema === false) {
|
|
1343
|
+
falseSchemaError(it, false);
|
|
1344
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
1345
|
+
gen.return(names_12.default.data);
|
|
1346
|
+
} else {
|
|
1347
|
+
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
1348
|
+
gen.return(true);
|
|
1349
|
+
}
|
|
1345
1350
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1351
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
1352
|
+
function boolOrEmptySchema(it, valid) {
|
|
1353
|
+
const { gen, schema } = it;
|
|
1354
|
+
if (schema === false) {
|
|
1355
|
+
gen.var(valid, false);
|
|
1356
|
+
falseSchemaError(it);
|
|
1357
|
+
} else {
|
|
1358
|
+
gen.var(valid, true);
|
|
1359
|
+
}
|
|
1355
1360
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1361
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
1362
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
1363
|
+
const { gen, data: data2 } = it;
|
|
1364
|
+
const cxt = {
|
|
1365
|
+
gen,
|
|
1366
|
+
keyword: "false schema",
|
|
1367
|
+
data: data2,
|
|
1368
|
+
schema: false,
|
|
1369
|
+
schemaCode: false,
|
|
1370
|
+
schemaValue: false,
|
|
1371
|
+
params: {},
|
|
1372
|
+
it
|
|
1373
|
+
};
|
|
1374
|
+
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
1375
|
+
}
|
|
1376
|
+
return boolSchema;
|
|
1371
1377
|
}
|
|
1372
1378
|
var dataType = {};
|
|
1373
1379
|
var rules$2 = {};
|
|
@@ -1415,10 +1421,10 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
1415
1421
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
1416
1422
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
1417
1423
|
const rules_1 = rules$2;
|
|
1418
|
-
const applicability_1
|
|
1419
|
-
const errors_1
|
|
1420
|
-
const codegen_1$
|
|
1421
|
-
const util_1$
|
|
1424
|
+
const applicability_1 = applicability;
|
|
1425
|
+
const errors_1 = errors;
|
|
1426
|
+
const codegen_1$n = codegen;
|
|
1427
|
+
const util_1$m = util$7;
|
|
1422
1428
|
var DataType;
|
|
1423
1429
|
(function(DataType2) {
|
|
1424
1430
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -1450,7 +1456,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
1450
1456
|
function coerceAndCheckDataType(it, types2) {
|
|
1451
1457
|
const { gen, data: data2, opts } = it;
|
|
1452
1458
|
const coerceTo = coerceToTypes$1(types2, opts.coerceTypes);
|
|
1453
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1
|
|
1459
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
1454
1460
|
if (checkTypes) {
|
|
1455
1461
|
const wrongType = checkDataTypes$1(types2, data2, opts.strictNumbers, DataType.Wrong);
|
|
1456
1462
|
gen.if(wrongType, () => {
|
|
@@ -1469,12 +1475,12 @@ function coerceToTypes$1(types2, coerceTypes) {
|
|
|
1469
1475
|
}
|
|
1470
1476
|
function coerceData(it, types2, coerceTo) {
|
|
1471
1477
|
const { gen, data: data2, opts } = it;
|
|
1472
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
1473
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
1478
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$n._)`typeof ${data2}`);
|
|
1479
|
+
const coerced = gen.let("coerced", (0, codegen_1$n._)`undefined`);
|
|
1474
1480
|
if (opts.coerceTypes === "array") {
|
|
1475
|
-
gen.if((0, codegen_1$
|
|
1481
|
+
gen.if((0, codegen_1$n._)`${dataType2} == 'object' && Array.isArray(${data2}) && ${data2}.length == 1`, () => gen.assign(data2, (0, codegen_1$n._)`${data2}[0]`).assign(dataType2, (0, codegen_1$n._)`typeof ${data2}`).if(checkDataTypes$1(types2, data2, opts.strictNumbers), () => gen.assign(coerced, data2)));
|
|
1476
1482
|
}
|
|
1477
|
-
gen.if((0, codegen_1$
|
|
1483
|
+
gen.if((0, codegen_1$n._)`${coerced} !== undefined`);
|
|
1478
1484
|
for (const t of coerceTo) {
|
|
1479
1485
|
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
|
|
1480
1486
|
coerceSpecificType(t);
|
|
@@ -1483,63 +1489,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
1483
1489
|
gen.else();
|
|
1484
1490
|
reportTypeError(it);
|
|
1485
1491
|
gen.endIf();
|
|
1486
|
-
gen.if((0, codegen_1$
|
|
1492
|
+
gen.if((0, codegen_1$n._)`${coerced} !== undefined`, () => {
|
|
1487
1493
|
gen.assign(data2, coerced);
|
|
1488
1494
|
assignParentData(it, coerced);
|
|
1489
1495
|
});
|
|
1490
1496
|
function coerceSpecificType(t) {
|
|
1491
1497
|
switch (t) {
|
|
1492
1498
|
case "string":
|
|
1493
|
-
gen.elseIf((0, codegen_1$
|
|
1499
|
+
gen.elseIf((0, codegen_1$n._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$n._)`"" + ${data2}`).elseIf((0, codegen_1$n._)`${data2} === null`).assign(coerced, (0, codegen_1$n._)`""`);
|
|
1494
1500
|
return;
|
|
1495
1501
|
case "number":
|
|
1496
|
-
gen.elseIf((0, codegen_1$
|
|
1497
|
-
|| (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$
|
|
1502
|
+
gen.elseIf((0, codegen_1$n._)`${dataType2} == "boolean" || ${data2} === null
|
|
1503
|
+
|| (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$n._)`+${data2}`);
|
|
1498
1504
|
return;
|
|
1499
1505
|
case "integer":
|
|
1500
|
-
gen.elseIf((0, codegen_1$
|
|
1501
|
-
|| (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$
|
|
1506
|
+
gen.elseIf((0, codegen_1$n._)`${dataType2} === "boolean" || ${data2} === null
|
|
1507
|
+
|| (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$n._)`+${data2}`);
|
|
1502
1508
|
return;
|
|
1503
1509
|
case "boolean":
|
|
1504
|
-
gen.elseIf((0, codegen_1$
|
|
1510
|
+
gen.elseIf((0, codegen_1$n._)`${data2} === "false" || ${data2} === 0 || ${data2} === null`).assign(coerced, false).elseIf((0, codegen_1$n._)`${data2} === "true" || ${data2} === 1`).assign(coerced, true);
|
|
1505
1511
|
return;
|
|
1506
1512
|
case "null":
|
|
1507
|
-
gen.elseIf((0, codegen_1$
|
|
1513
|
+
gen.elseIf((0, codegen_1$n._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
|
|
1508
1514
|
gen.assign(coerced, null);
|
|
1509
1515
|
return;
|
|
1510
1516
|
case "array":
|
|
1511
|
-
gen.elseIf((0, codegen_1$
|
|
1512
|
-
|| ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$
|
|
1517
|
+
gen.elseIf((0, codegen_1$n._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
1518
|
+
|| ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$n._)`[${data2}]`);
|
|
1513
1519
|
}
|
|
1514
1520
|
}
|
|
1515
1521
|
}
|
|
1516
1522
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
1517
|
-
gen.if((0, codegen_1$
|
|
1523
|
+
gen.if((0, codegen_1$n._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$n._)`${parentData}[${parentDataProperty}]`, expr));
|
|
1518
1524
|
}
|
|
1519
1525
|
function checkDataType$1(dataType2, data2, strictNums, correct = DataType.Correct) {
|
|
1520
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
1526
|
+
const EQ = correct === DataType.Correct ? codegen_1$n.operators.EQ : codegen_1$n.operators.NEQ;
|
|
1521
1527
|
let cond;
|
|
1522
1528
|
switch (dataType2) {
|
|
1523
1529
|
case "null":
|
|
1524
|
-
return (0, codegen_1$
|
|
1530
|
+
return (0, codegen_1$n._)`${data2} ${EQ} null`;
|
|
1525
1531
|
case "array":
|
|
1526
|
-
cond = (0, codegen_1$
|
|
1532
|
+
cond = (0, codegen_1$n._)`Array.isArray(${data2})`;
|
|
1527
1533
|
break;
|
|
1528
1534
|
case "object":
|
|
1529
|
-
cond = (0, codegen_1$
|
|
1535
|
+
cond = (0, codegen_1$n._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
|
|
1530
1536
|
break;
|
|
1531
1537
|
case "integer":
|
|
1532
|
-
cond = numCond((0, codegen_1$
|
|
1538
|
+
cond = numCond((0, codegen_1$n._)`!(${data2} % 1) && !isNaN(${data2})`);
|
|
1533
1539
|
break;
|
|
1534
1540
|
case "number":
|
|
1535
1541
|
cond = numCond();
|
|
1536
1542
|
break;
|
|
1537
1543
|
default:
|
|
1538
|
-
return (0, codegen_1$
|
|
1544
|
+
return (0, codegen_1$n._)`typeof ${data2} ${EQ} ${dataType2}`;
|
|
1539
1545
|
}
|
|
1540
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
1541
|
-
function numCond(_cond = codegen_1$
|
|
1542
|
-
return (0, codegen_1$
|
|
1546
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$n.not)(cond);
|
|
1547
|
+
function numCond(_cond = codegen_1$n.nil) {
|
|
1548
|
+
return (0, codegen_1$n.and)((0, codegen_1$n._)`typeof ${data2} == "number"`, _cond, strictNums ? (0, codegen_1$n._)`isFinite(${data2})` : codegen_1$n.nil);
|
|
1543
1549
|
}
|
|
1544
1550
|
}
|
|
1545
1551
|
dataType.checkDataType = checkDataType$1;
|
|
@@ -1548,35 +1554,35 @@ function checkDataTypes$1(dataTypes, data2, strictNums, correct) {
|
|
|
1548
1554
|
return checkDataType$1(dataTypes[0], data2, strictNums, correct);
|
|
1549
1555
|
}
|
|
1550
1556
|
let cond;
|
|
1551
|
-
const types2 = (0, util_1$
|
|
1557
|
+
const types2 = (0, util_1$m.toHash)(dataTypes);
|
|
1552
1558
|
if (types2.array && types2.object) {
|
|
1553
|
-
const notObj = (0, codegen_1$
|
|
1554
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
1559
|
+
const notObj = (0, codegen_1$n._)`typeof ${data2} != "object"`;
|
|
1560
|
+
cond = types2.null ? notObj : (0, codegen_1$n._)`!${data2} || ${notObj}`;
|
|
1555
1561
|
delete types2.null;
|
|
1556
1562
|
delete types2.array;
|
|
1557
1563
|
delete types2.object;
|
|
1558
1564
|
} else {
|
|
1559
|
-
cond = codegen_1$
|
|
1565
|
+
cond = codegen_1$n.nil;
|
|
1560
1566
|
}
|
|
1561
1567
|
if (types2.number)
|
|
1562
1568
|
delete types2.integer;
|
|
1563
1569
|
for (const t in types2)
|
|
1564
|
-
cond = (0, codegen_1$
|
|
1570
|
+
cond = (0, codegen_1$n.and)(cond, checkDataType$1(t, data2, strictNums, correct));
|
|
1565
1571
|
return cond;
|
|
1566
1572
|
}
|
|
1567
1573
|
dataType.checkDataTypes = checkDataTypes$1;
|
|
1568
1574
|
const typeError = {
|
|
1569
1575
|
message: ({ schema }) => `must be ${schema}`,
|
|
1570
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
1576
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$n._)`{type: ${schema}}` : (0, codegen_1$n._)`{type: ${schemaValue}}`
|
|
1571
1577
|
};
|
|
1572
1578
|
function reportTypeError(it) {
|
|
1573
1579
|
const cxt = getTypeErrorContext(it);
|
|
1574
|
-
(0, errors_1
|
|
1580
|
+
(0, errors_1.reportError)(cxt, typeError);
|
|
1575
1581
|
}
|
|
1576
1582
|
dataType.reportTypeError = reportTypeError;
|
|
1577
1583
|
function getTypeErrorContext(it) {
|
|
1578
1584
|
const { gen, data: data2, schema } = it;
|
|
1579
|
-
const schemaCode = (0, util_1$
|
|
1585
|
+
const schemaCode = (0, util_1$m.schemaRefOrVal)(it, schema, "type");
|
|
1580
1586
|
return {
|
|
1581
1587
|
gen,
|
|
1582
1588
|
keyword: "type",
|
|
@@ -1590,352 +1596,376 @@ function getTypeErrorContext(it) {
|
|
|
1590
1596
|
};
|
|
1591
1597
|
}
|
|
1592
1598
|
var defaults = {};
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
if (defaultValue === void 0)
|
|
1611
|
-
return;
|
|
1612
|
-
const childData = (0, codegen_1$r._)`${data2}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
1613
|
-
if (compositeRule) {
|
|
1614
|
-
(0, util_1$p.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1615
|
-
return;
|
|
1599
|
+
var hasRequiredDefaults;
|
|
1600
|
+
function requireDefaults() {
|
|
1601
|
+
if (hasRequiredDefaults) return defaults;
|
|
1602
|
+
hasRequiredDefaults = 1;
|
|
1603
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
1604
|
+
defaults.assignDefaults = void 0;
|
|
1605
|
+
const codegen_12 = codegen;
|
|
1606
|
+
const util_12 = util$7;
|
|
1607
|
+
function assignDefaults(it, ty) {
|
|
1608
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
1609
|
+
if (ty === "object" && properties2) {
|
|
1610
|
+
for (const key in properties2) {
|
|
1611
|
+
assignDefault(it, key, properties2[key].default);
|
|
1612
|
+
}
|
|
1613
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
1614
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
1615
|
+
}
|
|
1616
1616
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1617
|
+
defaults.assignDefaults = assignDefaults;
|
|
1618
|
+
function assignDefault(it, prop, defaultValue) {
|
|
1619
|
+
const { gen, compositeRule, data: data2, opts } = it;
|
|
1620
|
+
if (defaultValue === void 0)
|
|
1621
|
+
return;
|
|
1622
|
+
const childData = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(prop)}`;
|
|
1623
|
+
if (compositeRule) {
|
|
1624
|
+
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
1627
|
+
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
1628
|
+
if (opts.useDefaults === "empty") {
|
|
1629
|
+
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
1630
|
+
}
|
|
1631
|
+
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
1620
1632
|
}
|
|
1621
|
-
|
|
1633
|
+
return defaults;
|
|
1622
1634
|
}
|
|
1623
1635
|
var keyword$1 = {};
|
|
1624
1636
|
var code = {};
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1634
|
-
|
|
1637
|
+
var hasRequiredCode;
|
|
1638
|
+
function requireCode() {
|
|
1639
|
+
if (hasRequiredCode) return code;
|
|
1640
|
+
hasRequiredCode = 1;
|
|
1641
|
+
Object.defineProperty(code, "__esModule", { value: true });
|
|
1642
|
+
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;
|
|
1643
|
+
const codegen_12 = codegen;
|
|
1644
|
+
const util_12 = util$7;
|
|
1645
|
+
const names_12 = names$1;
|
|
1646
|
+
const util_22 = util$7;
|
|
1647
|
+
function checkReportMissingProp(cxt, prop) {
|
|
1648
|
+
const { gen, data: data2, it } = cxt;
|
|
1649
|
+
gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
|
|
1650
|
+
cxt.setParams({ missingProperty: (0, codegen_12._)`${prop}` }, true);
|
|
1651
|
+
cxt.error();
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
code.checkReportMissingProp = checkReportMissingProp;
|
|
1655
|
+
function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
|
|
1656
|
+
return (0, codegen_12.or)(...properties2.map((prop) => (0, codegen_12.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_12._)`${missing} = ${prop}`)));
|
|
1657
|
+
}
|
|
1658
|
+
code.checkMissingProp = checkMissingProp;
|
|
1659
|
+
function reportMissingProp(cxt, missing) {
|
|
1660
|
+
cxt.setParams({ missingProperty: missing }, true);
|
|
1635
1661
|
cxt.error();
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
code.checkReportMissingProp = checkReportMissingProp;
|
|
1639
|
-
function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
|
|
1640
|
-
return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
|
|
1641
|
-
}
|
|
1642
|
-
code.checkMissingProp = checkMissingProp;
|
|
1643
|
-
function reportMissingProp(cxt, missing) {
|
|
1644
|
-
cxt.setParams({ missingProperty: missing }, true);
|
|
1645
|
-
cxt.error();
|
|
1646
|
-
}
|
|
1647
|
-
code.reportMissingProp = reportMissingProp;
|
|
1648
|
-
function hasPropFunc(gen) {
|
|
1649
|
-
return gen.scopeValue("func", {
|
|
1650
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1651
|
-
ref: Object.prototype.hasOwnProperty,
|
|
1652
|
-
code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
|
|
1653
|
-
});
|
|
1654
|
-
}
|
|
1655
|
-
code.hasPropFunc = hasPropFunc;
|
|
1656
|
-
function isOwnProperty(gen, data2, property) {
|
|
1657
|
-
return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
|
|
1658
|
-
}
|
|
1659
|
-
code.isOwnProperty = isOwnProperty;
|
|
1660
|
-
function propertyInData(gen, data2, property, ownProperties) {
|
|
1661
|
-
const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
|
|
1662
|
-
return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
|
|
1663
|
-
}
|
|
1664
|
-
code.propertyInData = propertyInData;
|
|
1665
|
-
function noPropertyInData(gen, data2, property, ownProperties) {
|
|
1666
|
-
const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} === undefined`;
|
|
1667
|
-
return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data2, property))) : cond;
|
|
1668
|
-
}
|
|
1669
|
-
code.noPropertyInData = noPropertyInData;
|
|
1670
|
-
function allSchemaProperties(schemaMap) {
|
|
1671
|
-
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
|
|
1672
|
-
}
|
|
1673
|
-
code.allSchemaProperties = allSchemaProperties;
|
|
1674
|
-
function schemaProperties(it, schemaMap) {
|
|
1675
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$o.alwaysValidSchema)(it, schemaMap[p]));
|
|
1676
|
-
}
|
|
1677
|
-
code.schemaProperties = schemaProperties;
|
|
1678
|
-
function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
1679
|
-
const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
|
|
1680
|
-
const valCxt = [
|
|
1681
|
-
[names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
|
|
1682
|
-
[names_1$5.default.parentData, it.parentData],
|
|
1683
|
-
[names_1$5.default.parentDataProperty, it.parentDataProperty],
|
|
1684
|
-
[names_1$5.default.rootData, names_1$5.default.rootData]
|
|
1685
|
-
];
|
|
1686
|
-
if (it.opts.dynamicRef)
|
|
1687
|
-
valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
|
|
1688
|
-
const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
1689
|
-
return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
|
|
1690
|
-
}
|
|
1691
|
-
code.callValidateCode = callValidateCode;
|
|
1692
|
-
const newRegExp = (0, codegen_1$q._)`new RegExp`;
|
|
1693
|
-
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
1694
|
-
const u = opts.unicodeRegExp ? "u" : "";
|
|
1695
|
-
const { regExp } = opts.code;
|
|
1696
|
-
const rx = regExp(pattern2, u);
|
|
1697
|
-
return gen.scopeValue("pattern", {
|
|
1698
|
-
key: rx.toString(),
|
|
1699
|
-
ref: rx,
|
|
1700
|
-
code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
code.usePattern = usePattern;
|
|
1704
|
-
function validateArray(cxt) {
|
|
1705
|
-
const { gen, data: data2, keyword: keyword2, it } = cxt;
|
|
1706
|
-
const valid = gen.name("valid");
|
|
1707
|
-
if (it.allErrors) {
|
|
1708
|
-
const validArr = gen.let("valid", true);
|
|
1709
|
-
validateItems(() => gen.assign(validArr, false));
|
|
1710
|
-
return validArr;
|
|
1711
1662
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
cxt.subschema({
|
|
1719
|
-
keyword: keyword2,
|
|
1720
|
-
dataProp: i,
|
|
1721
|
-
dataPropType: util_1$o.Type.Num
|
|
1722
|
-
}, valid);
|
|
1723
|
-
gen.if((0, codegen_1$q.not)(valid), notValid);
|
|
1663
|
+
code.reportMissingProp = reportMissingProp;
|
|
1664
|
+
function hasPropFunc(gen) {
|
|
1665
|
+
return gen.scopeValue("func", {
|
|
1666
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1667
|
+
ref: Object.prototype.hasOwnProperty,
|
|
1668
|
+
code: (0, codegen_12._)`Object.prototype.hasOwnProperty`
|
|
1724
1669
|
});
|
|
1725
1670
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1773
|
-
keyword$1.macroKeywordCode = macroKeywordCode;
|
|
1774
|
-
function funcKeywordCode(cxt, def2) {
|
|
1775
|
-
var _a;
|
|
1776
|
-
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
1777
|
-
checkAsyncKeyword(it, def2);
|
|
1778
|
-
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
1779
|
-
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
1780
|
-
const valid = gen.let("valid");
|
|
1781
|
-
cxt.block$data(valid, validateKeyword2);
|
|
1782
|
-
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
1783
|
-
function validateKeyword2() {
|
|
1784
|
-
if (def2.errors === false) {
|
|
1785
|
-
assignValid();
|
|
1786
|
-
if (def2.modifying)
|
|
1787
|
-
modifyData(cxt);
|
|
1788
|
-
reportErrs(() => cxt.error());
|
|
1789
|
-
} else {
|
|
1790
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
1791
|
-
if (def2.modifying)
|
|
1792
|
-
modifyData(cxt);
|
|
1793
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
1794
|
-
}
|
|
1671
|
+
code.hasPropFunc = hasPropFunc;
|
|
1672
|
+
function isOwnProperty(gen, data2, property) {
|
|
1673
|
+
return (0, codegen_12._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
|
|
1674
|
+
}
|
|
1675
|
+
code.isOwnProperty = isOwnProperty;
|
|
1676
|
+
function propertyInData(gen, data2, property, ownProperties) {
|
|
1677
|
+
const cond = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(property)} !== undefined`;
|
|
1678
|
+
return ownProperties ? (0, codegen_12._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
|
|
1679
|
+
}
|
|
1680
|
+
code.propertyInData = propertyInData;
|
|
1681
|
+
function noPropertyInData(gen, data2, property, ownProperties) {
|
|
1682
|
+
const cond = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(property)} === undefined`;
|
|
1683
|
+
return ownProperties ? (0, codegen_12.or)(cond, (0, codegen_12.not)(isOwnProperty(gen, data2, property))) : cond;
|
|
1684
|
+
}
|
|
1685
|
+
code.noPropertyInData = noPropertyInData;
|
|
1686
|
+
function allSchemaProperties(schemaMap) {
|
|
1687
|
+
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
|
|
1688
|
+
}
|
|
1689
|
+
code.allSchemaProperties = allSchemaProperties;
|
|
1690
|
+
function schemaProperties(it, schemaMap) {
|
|
1691
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_12.alwaysValidSchema)(it, schemaMap[p]));
|
|
1692
|
+
}
|
|
1693
|
+
code.schemaProperties = schemaProperties;
|
|
1694
|
+
function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
1695
|
+
const dataAndSchema = passSchema ? (0, codegen_12._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
|
|
1696
|
+
const valCxt = [
|
|
1697
|
+
[names_12.default.instancePath, (0, codegen_12.strConcat)(names_12.default.instancePath, errorPath)],
|
|
1698
|
+
[names_12.default.parentData, it.parentData],
|
|
1699
|
+
[names_12.default.parentDataProperty, it.parentDataProperty],
|
|
1700
|
+
[names_12.default.rootData, names_12.default.rootData]
|
|
1701
|
+
];
|
|
1702
|
+
if (it.opts.dynamicRef)
|
|
1703
|
+
valCxt.push([names_12.default.dynamicAnchors, names_12.default.dynamicAnchors]);
|
|
1704
|
+
const args = (0, codegen_12._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
1705
|
+
return context !== codegen_12.nil ? (0, codegen_12._)`${func}.call(${context}, ${args})` : (0, codegen_12._)`${func}(${args})`;
|
|
1706
|
+
}
|
|
1707
|
+
code.callValidateCode = callValidateCode;
|
|
1708
|
+
const newRegExp = (0, codegen_12._)`new RegExp`;
|
|
1709
|
+
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
1710
|
+
const u = opts.unicodeRegExp ? "u" : "";
|
|
1711
|
+
const { regExp } = opts.code;
|
|
1712
|
+
const rx = regExp(pattern2, u);
|
|
1713
|
+
return gen.scopeValue("pattern", {
|
|
1714
|
+
key: rx.toString(),
|
|
1715
|
+
ref: rx,
|
|
1716
|
+
code: (0, codegen_12._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_22.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
1717
|
+
});
|
|
1795
1718
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1719
|
+
code.usePattern = usePattern;
|
|
1720
|
+
function validateArray(cxt) {
|
|
1721
|
+
const { gen, data: data2, keyword: keyword2, it } = cxt;
|
|
1722
|
+
const valid = gen.name("valid");
|
|
1723
|
+
if (it.allErrors) {
|
|
1724
|
+
const validArr = gen.let("valid", true);
|
|
1725
|
+
validateItems(() => gen.assign(validArr, false));
|
|
1726
|
+
return validArr;
|
|
1727
|
+
}
|
|
1728
|
+
gen.var(valid, true);
|
|
1729
|
+
validateItems(() => gen.break());
|
|
1730
|
+
return valid;
|
|
1731
|
+
function validateItems(notValid) {
|
|
1732
|
+
const len = gen.const("len", (0, codegen_12._)`${data2}.length`);
|
|
1733
|
+
gen.forRange("i", 0, len, (i) => {
|
|
1734
|
+
cxt.subschema({
|
|
1735
|
+
keyword: keyword2,
|
|
1736
|
+
dataProp: i,
|
|
1737
|
+
dataPropType: util_12.Type.Num
|
|
1738
|
+
}, valid);
|
|
1739
|
+
gen.if((0, codegen_12.not)(valid), notValid);
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1800
1742
|
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
gen
|
|
1804
|
-
|
|
1805
|
-
|
|
1743
|
+
code.validateArray = validateArray;
|
|
1744
|
+
function validateUnion(cxt) {
|
|
1745
|
+
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
1746
|
+
if (!Array.isArray(schema))
|
|
1747
|
+
throw new Error("ajv implementation error");
|
|
1748
|
+
const alwaysValid = schema.some((sch) => (0, util_12.alwaysValidSchema)(it, sch));
|
|
1749
|
+
if (alwaysValid && !it.opts.unevaluated)
|
|
1750
|
+
return;
|
|
1751
|
+
const valid = gen.let("valid", false);
|
|
1752
|
+
const schValid = gen.name("_valid");
|
|
1753
|
+
gen.block(() => schema.forEach((_sch, i) => {
|
|
1754
|
+
const schCxt = cxt.subschema({
|
|
1755
|
+
keyword: keyword2,
|
|
1756
|
+
schemaProp: i,
|
|
1757
|
+
compositeRule: true
|
|
1758
|
+
}, schValid);
|
|
1759
|
+
gen.assign(valid, (0, codegen_12._)`${valid} || ${schValid}`);
|
|
1760
|
+
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
1761
|
+
if (!merged)
|
|
1762
|
+
gen.if((0, codegen_12.not)(valid));
|
|
1763
|
+
}));
|
|
1764
|
+
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
1806
1765
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1766
|
+
code.validateUnion = validateUnion;
|
|
1767
|
+
return code;
|
|
1768
|
+
}
|
|
1769
|
+
var hasRequiredKeyword;
|
|
1770
|
+
function requireKeyword() {
|
|
1771
|
+
if (hasRequiredKeyword) return keyword$1;
|
|
1772
|
+
hasRequiredKeyword = 1;
|
|
1773
|
+
Object.defineProperty(keyword$1, "__esModule", { value: true });
|
|
1774
|
+
keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
|
|
1775
|
+
const codegen_12 = codegen;
|
|
1776
|
+
const names_12 = names$1;
|
|
1777
|
+
const code_12 = requireCode();
|
|
1778
|
+
const errors_12 = errors;
|
|
1779
|
+
function macroKeywordCode(cxt, def2) {
|
|
1780
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
1781
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
1782
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
1783
|
+
if (it.opts.validateSchema !== false)
|
|
1784
|
+
it.self.validateSchema(macroSchema, true);
|
|
1785
|
+
const valid = gen.name("valid");
|
|
1786
|
+
cxt.subschema({
|
|
1787
|
+
schema: macroSchema,
|
|
1788
|
+
schemaPath: codegen_12.nil,
|
|
1789
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
1790
|
+
topSchemaRef: schemaRef,
|
|
1791
|
+
compositeRule: true
|
|
1792
|
+
}, valid);
|
|
1793
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
1811
1794
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1795
|
+
keyword$1.macroKeywordCode = macroKeywordCode;
|
|
1796
|
+
function funcKeywordCode(cxt, def2) {
|
|
1797
|
+
var _a;
|
|
1798
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
1799
|
+
checkAsyncKeyword(it, def2);
|
|
1800
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
1801
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
1802
|
+
const valid = gen.let("valid");
|
|
1803
|
+
cxt.block$data(valid, validateKeyword2);
|
|
1804
|
+
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
1805
|
+
function validateKeyword2() {
|
|
1806
|
+
if (def2.errors === false) {
|
|
1807
|
+
assignValid();
|
|
1808
|
+
if (def2.modifying)
|
|
1809
|
+
modifyData(cxt);
|
|
1810
|
+
reportErrs(() => cxt.error());
|
|
1811
|
+
} else {
|
|
1812
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
1813
|
+
if (def2.modifying)
|
|
1814
|
+
modifyData(cxt);
|
|
1815
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
function validateAsync() {
|
|
1819
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
1820
|
+
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)));
|
|
1821
|
+
return ruleErrs;
|
|
1822
|
+
}
|
|
1823
|
+
function validateSync() {
|
|
1824
|
+
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
1825
|
+
gen.assign(validateErrs, null);
|
|
1826
|
+
assignValid(codegen_12.nil);
|
|
1827
|
+
return validateErrs;
|
|
1828
|
+
}
|
|
1829
|
+
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
1830
|
+
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
1831
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
1832
|
+
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
1833
|
+
}
|
|
1834
|
+
function reportErrs(errors2) {
|
|
1835
|
+
var _a2;
|
|
1836
|
+
gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
1837
|
+
}
|
|
1815
1838
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1839
|
+
keyword$1.funcKeywordCode = funcKeywordCode;
|
|
1840
|
+
function modifyData(cxt) {
|
|
1841
|
+
const { gen, data: data2, it } = cxt;
|
|
1842
|
+
gen.if(it.parentData, () => gen.assign(data2, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
1843
|
+
}
|
|
1844
|
+
function addErrs(cxt, errs) {
|
|
1845
|
+
const { gen } = cxt;
|
|
1846
|
+
gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
|
|
1847
|
+
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`);
|
|
1848
|
+
(0, errors_12.extendErrors)(cxt);
|
|
1849
|
+
}, () => cxt.error());
|
|
1850
|
+
}
|
|
1851
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
1852
|
+
if (def2.async && !schemaEnv.$async)
|
|
1853
|
+
throw new Error("async keyword in sync schema");
|
|
1854
|
+
}
|
|
1855
|
+
function useKeyword(gen, keyword2, result) {
|
|
1856
|
+
if (result === void 0)
|
|
1857
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
1858
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
|
|
1859
|
+
}
|
|
1860
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
1861
|
+
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");
|
|
1862
|
+
}
|
|
1863
|
+
keyword$1.validSchemaType = validSchemaType;
|
|
1864
|
+
function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
|
|
1865
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
1866
|
+
throw new Error("ajv implementation error");
|
|
1867
|
+
}
|
|
1868
|
+
const deps = def2.dependencies;
|
|
1869
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
1870
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
1871
|
+
}
|
|
1872
|
+
if (def2.validateSchema) {
|
|
1873
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
1874
|
+
if (!valid) {
|
|
1875
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
|
|
1876
|
+
if (opts.validateSchema === "log")
|
|
1877
|
+
self2.logger.error(msg);
|
|
1878
|
+
else
|
|
1879
|
+
throw new Error(msg);
|
|
1880
|
+
}
|
|
1858
1881
|
}
|
|
1859
1882
|
}
|
|
1883
|
+
keyword$1.validateKeywordUsage = validateKeywordUsage;
|
|
1884
|
+
return keyword$1;
|
|
1860
1885
|
}
|
|
1861
|
-
keyword$1.validateKeywordUsage = validateKeywordUsage;
|
|
1862
1886
|
var subschema = {};
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
schema: sch,
|
|
1875
|
-
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
1876
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
1877
|
-
} : {
|
|
1878
|
-
schema: sch[schemaProp],
|
|
1879
|
-
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
1880
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$n.escapeFragment)(schemaProp)}`
|
|
1881
|
-
};
|
|
1882
|
-
}
|
|
1883
|
-
if (schema !== void 0) {
|
|
1884
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
1885
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
1887
|
+
var hasRequiredSubschema;
|
|
1888
|
+
function requireSubschema() {
|
|
1889
|
+
if (hasRequiredSubschema) return subschema;
|
|
1890
|
+
hasRequiredSubschema = 1;
|
|
1891
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
1892
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
1893
|
+
const codegen_12 = codegen;
|
|
1894
|
+
const util_12 = util$7;
|
|
1895
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
1896
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
1897
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
1886
1898
|
}
|
|
1887
|
-
|
|
1888
|
-
schema
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1899
|
+
if (keyword2 !== void 0) {
|
|
1900
|
+
const sch = it.schema[keyword2];
|
|
1901
|
+
return schemaProp === void 0 ? {
|
|
1902
|
+
schema: sch,
|
|
1903
|
+
schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
|
|
1904
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
1905
|
+
} : {
|
|
1906
|
+
schema: sch[schemaProp],
|
|
1907
|
+
schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
|
|
1908
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
if (schema !== void 0) {
|
|
1912
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
1913
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
1914
|
+
}
|
|
1915
|
+
return {
|
|
1916
|
+
schema,
|
|
1917
|
+
schemaPath,
|
|
1918
|
+
topSchemaRef,
|
|
1919
|
+
errSchemaPath
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
1923
|
+
}
|
|
1924
|
+
subschema.getSubschema = getSubschema;
|
|
1925
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
|
|
1926
|
+
if (data2 !== void 0 && dataProp !== void 0) {
|
|
1927
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
1928
|
+
}
|
|
1929
|
+
const { gen } = it;
|
|
1930
|
+
if (dataProp !== void 0) {
|
|
1931
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
1932
|
+
const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
|
|
1933
|
+
dataContextProps(nextData);
|
|
1934
|
+
subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
1935
|
+
subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
|
|
1936
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
1937
|
+
}
|
|
1938
|
+
if (data2 !== void 0) {
|
|
1939
|
+
const nextData = data2 instanceof codegen_12.Name ? data2 : gen.let("data", data2, true);
|
|
1940
|
+
dataContextProps(nextData);
|
|
1941
|
+
if (propertyName !== void 0)
|
|
1942
|
+
subschema2.propertyName = propertyName;
|
|
1943
|
+
}
|
|
1944
|
+
if (dataTypes)
|
|
1945
|
+
subschema2.dataTypes = dataTypes;
|
|
1946
|
+
function dataContextProps(_nextData) {
|
|
1947
|
+
subschema2.data = _nextData;
|
|
1948
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
1949
|
+
subschema2.dataTypes = [];
|
|
1950
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
1951
|
+
subschema2.parentData = it.data;
|
|
1952
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
1956
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
1957
|
+
if (compositeRule !== void 0)
|
|
1958
|
+
subschema2.compositeRule = compositeRule;
|
|
1959
|
+
if (createErrors !== void 0)
|
|
1960
|
+
subschema2.createErrors = createErrors;
|
|
1961
|
+
if (allErrors !== void 0)
|
|
1962
|
+
subschema2.allErrors = allErrors;
|
|
1963
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
1964
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
1965
|
+
}
|
|
1966
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
1967
|
+
return subschema;
|
|
1968
|
+
}
|
|
1939
1969
|
var resolve$6 = {};
|
|
1940
1970
|
var fastDeepEqual = function equal(a, b) {
|
|
1941
1971
|
if (a === b) return true;
|
|
@@ -2050,7 +2080,7 @@ function escapeJsonPtr$1(str) {
|
|
|
2050
2080
|
var jsonSchemaTraverseExports$1 = jsonSchemaTraverse$1.exports;
|
|
2051
2081
|
Object.defineProperty(resolve$6, "__esModule", { value: true });
|
|
2052
2082
|
resolve$6.getSchemaRefs = resolve$6.resolveUrl = resolve$6.normalizeId = resolve$6._getFullPath = resolve$6.getFullPath = resolve$6.inlineRef = void 0;
|
|
2053
|
-
const util_1$
|
|
2083
|
+
const util_1$l = util$7;
|
|
2054
2084
|
const equal$5 = fastDeepEqual;
|
|
2055
2085
|
const traverse$2 = jsonSchemaTraverseExports$1;
|
|
2056
2086
|
const SIMPLE_INLINED$1 = /* @__PURE__ */ new Set([
|
|
@@ -2109,7 +2139,7 @@ function countKeys$1(schema) {
|
|
|
2109
2139
|
if (SIMPLE_INLINED$1.has(key))
|
|
2110
2140
|
continue;
|
|
2111
2141
|
if (typeof schema[key] == "object") {
|
|
2112
|
-
(0, util_1$
|
|
2142
|
+
(0, util_1$l.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
|
|
2113
2143
|
}
|
|
2114
2144
|
if (count === Infinity)
|
|
2115
2145
|
return Infinity;
|
|
@@ -2197,506 +2227,512 @@ function getSchemaRefs(schema, baseId) {
|
|
|
2197
2227
|
}
|
|
2198
2228
|
}
|
|
2199
2229
|
resolve$6.getSchemaRefs = getSchemaRefs;
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
const
|
|
2207
|
-
const
|
|
2208
|
-
const
|
|
2209
|
-
const
|
|
2210
|
-
const
|
|
2211
|
-
const
|
|
2212
|
-
const
|
|
2213
|
-
const
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2230
|
+
var hasRequiredValidate;
|
|
2231
|
+
function requireValidate() {
|
|
2232
|
+
if (hasRequiredValidate) return validate$2;
|
|
2233
|
+
hasRequiredValidate = 1;
|
|
2234
|
+
Object.defineProperty(validate$2, "__esModule", { value: true });
|
|
2235
|
+
validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
|
|
2236
|
+
const boolSchema_1 = requireBoolSchema();
|
|
2237
|
+
const dataType_12 = dataType;
|
|
2238
|
+
const applicability_12 = applicability;
|
|
2239
|
+
const dataType_2 = dataType;
|
|
2240
|
+
const defaults_1 = requireDefaults();
|
|
2241
|
+
const keyword_1 = requireKeyword();
|
|
2242
|
+
const subschema_1 = requireSubschema();
|
|
2243
|
+
const codegen_12 = codegen;
|
|
2244
|
+
const names_12 = names$1;
|
|
2245
|
+
const resolve_12 = resolve$6;
|
|
2246
|
+
const util_12 = util$7;
|
|
2247
|
+
const errors_12 = errors;
|
|
2248
|
+
function validateFunctionCode(it) {
|
|
2249
|
+
if (isSchemaObj(it)) {
|
|
2250
|
+
checkKeywords(it);
|
|
2251
|
+
if (schemaCxtHasRules(it)) {
|
|
2252
|
+
topSchemaObjCode(it);
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2220
2255
|
}
|
|
2256
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2221
2257
|
}
|
|
2222
|
-
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2258
|
+
validate$2.validateFunctionCode = validateFunctionCode;
|
|
2259
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
2260
|
+
if (opts.code.es5) {
|
|
2261
|
+
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
|
|
2262
|
+
gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
2263
|
+
destructureValCxtES5(gen, opts);
|
|
2264
|
+
gen.code(body);
|
|
2265
|
+
});
|
|
2266
|
+
} else {
|
|
2267
|
+
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
function destructureValCxt(opts) {
|
|
2271
|
+
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}}={}`;
|
|
2272
|
+
}
|
|
2273
|
+
function destructureValCxtES5(gen, opts) {
|
|
2274
|
+
gen.if(names_12.default.valCxt, () => {
|
|
2275
|
+
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
2276
|
+
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
2277
|
+
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
2278
|
+
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
2279
|
+
if (opts.dynamicRef)
|
|
2280
|
+
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
2281
|
+
}, () => {
|
|
2282
|
+
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
2283
|
+
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
2284
|
+
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
2285
|
+
gen.var(names_12.default.rootData, names_12.default.data);
|
|
2286
|
+
if (opts.dynamicRef)
|
|
2287
|
+
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
2231
2288
|
});
|
|
2232
|
-
} else {
|
|
2233
|
-
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
function destructureValCxt(opts) {
|
|
2237
|
-
return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
|
|
2238
|
-
}
|
|
2239
|
-
function destructureValCxtES5(gen, opts) {
|
|
2240
|
-
gen.if(names_1$3.default.valCxt, () => {
|
|
2241
|
-
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
|
|
2242
|
-
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
|
|
2243
|
-
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
|
|
2244
|
-
gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
|
|
2245
|
-
if (opts.dynamicRef)
|
|
2246
|
-
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
|
|
2247
|
-
}, () => {
|
|
2248
|
-
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
|
|
2249
|
-
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
|
|
2250
|
-
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
|
|
2251
|
-
gen.var(names_1$3.default.rootData, names_1$3.default.data);
|
|
2252
|
-
if (opts.dynamicRef)
|
|
2253
|
-
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
|
|
2254
|
-
});
|
|
2255
|
-
}
|
|
2256
|
-
function topSchemaObjCode(it) {
|
|
2257
|
-
const { schema, opts, gen } = it;
|
|
2258
|
-
validateFunction(it, () => {
|
|
2259
|
-
if (opts.$comment && schema.$comment)
|
|
2260
|
-
commentKeyword(it);
|
|
2261
|
-
checkNoDefault(it);
|
|
2262
|
-
gen.let(names_1$3.default.vErrors, null);
|
|
2263
|
-
gen.let(names_1$3.default.errors, 0);
|
|
2264
|
-
if (opts.unevaluated)
|
|
2265
|
-
resetEvaluated(it);
|
|
2266
|
-
typeAndKeywords(it);
|
|
2267
|
-
returnResults(it);
|
|
2268
|
-
});
|
|
2269
|
-
return;
|
|
2270
|
-
}
|
|
2271
|
-
function resetEvaluated(it) {
|
|
2272
|
-
const { gen, validateName } = it;
|
|
2273
|
-
it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
|
|
2274
|
-
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
|
|
2275
|
-
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
|
|
2276
|
-
}
|
|
2277
|
-
function funcSourceUrl(schema, opts) {
|
|
2278
|
-
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
2279
|
-
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
|
|
2280
|
-
}
|
|
2281
|
-
function subschemaCode(it, valid) {
|
|
2282
|
-
if (isSchemaObj(it)) {
|
|
2283
|
-
checkKeywords(it);
|
|
2284
|
-
if (schemaCxtHasRules(it)) {
|
|
2285
|
-
subSchemaObjCode(it, valid);
|
|
2286
|
-
return;
|
|
2287
|
-
}
|
|
2288
2289
|
}
|
|
2289
|
-
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
}
|
|
2302
|
-
function subSchemaObjCode(it, valid) {
|
|
2303
|
-
const { schema, gen, opts } = it;
|
|
2304
|
-
if (opts.$comment && schema.$comment)
|
|
2305
|
-
commentKeyword(it);
|
|
2306
|
-
updateContext(it);
|
|
2307
|
-
checkAsyncSchema(it);
|
|
2308
|
-
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
2309
|
-
typeAndKeywords(it, errsCount);
|
|
2310
|
-
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
2311
|
-
}
|
|
2312
|
-
function checkKeywords(it) {
|
|
2313
|
-
(0, util_1$l.checkUnknownRules)(it);
|
|
2314
|
-
checkRefsAndKeywords(it);
|
|
2315
|
-
}
|
|
2316
|
-
function typeAndKeywords(it, errsCount) {
|
|
2317
|
-
if (it.opts.jtd)
|
|
2318
|
-
return schemaKeywords(it, [], false, errsCount);
|
|
2319
|
-
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
2320
|
-
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
2321
|
-
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
2322
|
-
}
|
|
2323
|
-
function checkRefsAndKeywords(it) {
|
|
2324
|
-
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
2325
|
-
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$l.schemaHasRulesButRef)(schema, self2.RULES)) {
|
|
2326
|
-
self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
function checkNoDefault(it) {
|
|
2330
|
-
const { schema, opts } = it;
|
|
2331
|
-
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
2332
|
-
(0, util_1$l.checkStrictMode)(it, "default is ignored in the schema root");
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
function updateContext(it) {
|
|
2336
|
-
const schId = it.schema[it.opts.schemaId];
|
|
2337
|
-
if (schId)
|
|
2338
|
-
it.baseId = (0, resolve_1$3.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
2339
|
-
}
|
|
2340
|
-
function checkAsyncSchema(it) {
|
|
2341
|
-
if (it.schema.$async && !it.schemaEnv.$async)
|
|
2342
|
-
throw new Error("async schema in sync schema");
|
|
2343
|
-
}
|
|
2344
|
-
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
2345
|
-
const msg = schema.$comment;
|
|
2346
|
-
if (opts.$comment === true) {
|
|
2347
|
-
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
2348
|
-
} else if (typeof opts.$comment == "function") {
|
|
2349
|
-
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
2350
|
-
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
2351
|
-
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
function returnResults(it) {
|
|
2355
|
-
const { gen, schemaEnv, validateName, ValidationError: ValidationError3, opts } = it;
|
|
2356
|
-
if (schemaEnv.$async) {
|
|
2357
|
-
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError3}(${names_1$3.default.vErrors})`));
|
|
2358
|
-
} else {
|
|
2359
|
-
gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
|
|
2360
|
-
if (opts.unevaluated)
|
|
2361
|
-
assignEvaluated(it);
|
|
2362
|
-
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
2366
|
-
if (props instanceof codegen_1$n.Name)
|
|
2367
|
-
gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
|
|
2368
|
-
if (items2 instanceof codegen_1$n.Name)
|
|
2369
|
-
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
2370
|
-
}
|
|
2371
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
2372
|
-
const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
|
|
2373
|
-
const { RULES } = self2;
|
|
2374
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(schema, RULES))) {
|
|
2375
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2290
|
+
function topSchemaObjCode(it) {
|
|
2291
|
+
const { schema, opts, gen } = it;
|
|
2292
|
+
validateFunction(it, () => {
|
|
2293
|
+
if (opts.$comment && schema.$comment)
|
|
2294
|
+
commentKeyword(it);
|
|
2295
|
+
checkNoDefault(it);
|
|
2296
|
+
gen.let(names_12.default.vErrors, null);
|
|
2297
|
+
gen.let(names_12.default.errors, 0);
|
|
2298
|
+
if (opts.unevaluated)
|
|
2299
|
+
resetEvaluated(it);
|
|
2300
|
+
typeAndKeywords(it);
|
|
2301
|
+
returnResults(it);
|
|
2302
|
+
});
|
|
2376
2303
|
return;
|
|
2377
2304
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
if (
|
|
2392
|
-
|
|
2393
|
-
|
|
2305
|
+
function resetEvaluated(it) {
|
|
2306
|
+
const { gen, validateName } = it;
|
|
2307
|
+
it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
|
|
2308
|
+
gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
|
|
2309
|
+
gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
|
|
2310
|
+
}
|
|
2311
|
+
function funcSourceUrl(schema, opts) {
|
|
2312
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
2313
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
|
|
2314
|
+
}
|
|
2315
|
+
function subschemaCode(it, valid) {
|
|
2316
|
+
if (isSchemaObj(it)) {
|
|
2317
|
+
checkKeywords(it);
|
|
2318
|
+
if (schemaCxtHasRules(it)) {
|
|
2319
|
+
subSchemaObjCode(it, valid);
|
|
2320
|
+
return;
|
|
2394
2321
|
}
|
|
2395
|
-
gen.endIf();
|
|
2396
|
-
} else {
|
|
2397
|
-
iterateKeywords(it, group);
|
|
2398
2322
|
}
|
|
2399
|
-
|
|
2400
|
-
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
2323
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
2401
2324
|
}
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
|
2410
|
-
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
function checkStrictTypes(it, types2) {
|
|
2416
|
-
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
2417
|
-
return;
|
|
2418
|
-
checkContextTypes(it, types2);
|
|
2419
|
-
if (!it.opts.allowUnionTypes)
|
|
2420
|
-
checkMultipleTypes(it, types2);
|
|
2421
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
2422
|
-
}
|
|
2423
|
-
function checkContextTypes(it, types2) {
|
|
2424
|
-
if (!types2.length)
|
|
2425
|
-
return;
|
|
2426
|
-
if (!it.dataTypes.length) {
|
|
2427
|
-
it.dataTypes = types2;
|
|
2428
|
-
return;
|
|
2325
|
+
function schemaCxtHasRules({ schema, self: self2 }) {
|
|
2326
|
+
if (typeof schema == "boolean")
|
|
2327
|
+
return !schema;
|
|
2328
|
+
for (const key in schema)
|
|
2329
|
+
if (self2.RULES.all[key])
|
|
2330
|
+
return true;
|
|
2331
|
+
return false;
|
|
2429
2332
|
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
2433
|
-
}
|
|
2434
|
-
});
|
|
2435
|
-
narrowSchemaTypes(it, types2);
|
|
2436
|
-
}
|
|
2437
|
-
function checkMultipleTypes(it, ts) {
|
|
2438
|
-
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
2439
|
-
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
2440
|
-
}
|
|
2441
|
-
}
|
|
2442
|
-
function checkKeywordTypes(it, ts) {
|
|
2443
|
-
const rules3 = it.self.RULES.all;
|
|
2444
|
-
for (const keyword2 in rules3) {
|
|
2445
|
-
const rule = rules3[keyword2];
|
|
2446
|
-
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
|
2447
|
-
const { type: type2 } = rule.definition;
|
|
2448
|
-
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
2449
|
-
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
function hasApplicableType(schTs, kwdT) {
|
|
2455
|
-
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
2456
|
-
}
|
|
2457
|
-
function includesType(ts, t) {
|
|
2458
|
-
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
2459
|
-
}
|
|
2460
|
-
function narrowSchemaTypes(it, withTypes) {
|
|
2461
|
-
const ts = [];
|
|
2462
|
-
for (const t of it.dataTypes) {
|
|
2463
|
-
if (includesType(withTypes, t))
|
|
2464
|
-
ts.push(t);
|
|
2465
|
-
else if (withTypes.includes("integer") && t === "number")
|
|
2466
|
-
ts.push("integer");
|
|
2467
|
-
}
|
|
2468
|
-
it.dataTypes = ts;
|
|
2469
|
-
}
|
|
2470
|
-
function strictTypesError(it, msg) {
|
|
2471
|
-
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
2472
|
-
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
2473
|
-
(0, util_1$l.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
2474
|
-
}
|
|
2475
|
-
class KeywordCxt {
|
|
2476
|
-
constructor(it, def2, keyword2) {
|
|
2477
|
-
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
2478
|
-
this.gen = it.gen;
|
|
2479
|
-
this.allErrors = it.allErrors;
|
|
2480
|
-
this.keyword = keyword2;
|
|
2481
|
-
this.data = it.data;
|
|
2482
|
-
this.schema = it.schema[keyword2];
|
|
2483
|
-
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
2484
|
-
this.schemaValue = (0, util_1$l.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
2485
|
-
this.schemaType = def2.schemaType;
|
|
2486
|
-
this.parentSchema = it.schema;
|
|
2487
|
-
this.params = {};
|
|
2488
|
-
this.it = it;
|
|
2489
|
-
this.def = def2;
|
|
2490
|
-
if (this.$data) {
|
|
2491
|
-
this.schemaCode = it.gen.const("vSchema", getData$1(this.$data, it));
|
|
2492
|
-
} else {
|
|
2493
|
-
this.schemaCode = this.schemaValue;
|
|
2494
|
-
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
2495
|
-
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
2499
|
-
this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
|
|
2500
|
-
}
|
|
2333
|
+
function isSchemaObj(it) {
|
|
2334
|
+
return typeof it.schema != "boolean";
|
|
2501
2335
|
}
|
|
2502
|
-
|
|
2503
|
-
|
|
2336
|
+
function subSchemaObjCode(it, valid) {
|
|
2337
|
+
const { schema, gen, opts } = it;
|
|
2338
|
+
if (opts.$comment && schema.$comment)
|
|
2339
|
+
commentKeyword(it);
|
|
2340
|
+
updateContext(it);
|
|
2341
|
+
checkAsyncSchema(it);
|
|
2342
|
+
const errsCount = gen.const("_errs", names_12.default.errors);
|
|
2343
|
+
typeAndKeywords(it, errsCount);
|
|
2344
|
+
gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
|
|
2504
2345
|
}
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
failAction();
|
|
2509
|
-
else
|
|
2510
|
-
this.error();
|
|
2511
|
-
if (successAction) {
|
|
2512
|
-
this.gen.else();
|
|
2513
|
-
successAction();
|
|
2514
|
-
if (this.allErrors)
|
|
2515
|
-
this.gen.endIf();
|
|
2516
|
-
} else {
|
|
2517
|
-
if (this.allErrors)
|
|
2518
|
-
this.gen.endIf();
|
|
2519
|
-
else
|
|
2520
|
-
this.gen.else();
|
|
2521
|
-
}
|
|
2346
|
+
function checkKeywords(it) {
|
|
2347
|
+
(0, util_12.checkUnknownRules)(it);
|
|
2348
|
+
checkRefsAndKeywords(it);
|
|
2522
2349
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2350
|
+
function typeAndKeywords(it, errsCount) {
|
|
2351
|
+
if (it.opts.jtd)
|
|
2352
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
2353
|
+
const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
|
|
2354
|
+
const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
|
|
2355
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
2525
2356
|
}
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
this.gen.if(false);
|
|
2531
|
-
return;
|
|
2357
|
+
function checkRefsAndKeywords(it) {
|
|
2358
|
+
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
2359
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self2.RULES)) {
|
|
2360
|
+
self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
2532
2361
|
}
|
|
2533
|
-
this.gen.if(condition);
|
|
2534
|
-
this.error();
|
|
2535
|
-
if (this.allErrors)
|
|
2536
|
-
this.gen.endIf();
|
|
2537
|
-
else
|
|
2538
|
-
this.gen.else();
|
|
2539
|
-
}
|
|
2540
|
-
fail$data(condition) {
|
|
2541
|
-
if (!this.$data)
|
|
2542
|
-
return this.fail(condition);
|
|
2543
|
-
const { schemaCode } = this;
|
|
2544
|
-
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
2545
2362
|
}
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
this.setParams({});
|
|
2551
|
-
return;
|
|
2363
|
+
function checkNoDefault(it) {
|
|
2364
|
+
const { schema, opts } = it;
|
|
2365
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
2366
|
+
(0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
|
|
2552
2367
|
}
|
|
2553
|
-
this._error(append, errorPaths);
|
|
2554
|
-
}
|
|
2555
|
-
_error(append, errorPaths) {
|
|
2556
|
-
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
2557
2368
|
}
|
|
2558
|
-
|
|
2559
|
-
|
|
2369
|
+
function updateContext(it) {
|
|
2370
|
+
const schId = it.schema[it.opts.schemaId];
|
|
2371
|
+
if (schId)
|
|
2372
|
+
it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
2560
2373
|
}
|
|
2561
|
-
|
|
2562
|
-
if (
|
|
2563
|
-
throw new Error(
|
|
2564
|
-
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
2374
|
+
function checkAsyncSchema(it) {
|
|
2375
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
2376
|
+
throw new Error("async schema in sync schema");
|
|
2565
2377
|
}
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2378
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
2379
|
+
const msg = schema.$comment;
|
|
2380
|
+
if (opts.$comment === true) {
|
|
2381
|
+
gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
|
|
2382
|
+
} else if (typeof opts.$comment == "function") {
|
|
2383
|
+
const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
|
|
2384
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
2385
|
+
gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
2386
|
+
}
|
|
2569
2387
|
}
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2388
|
+
function returnResults(it) {
|
|
2389
|
+
const { gen, schemaEnv, validateName, ValidationError: ValidationError3, opts } = it;
|
|
2390
|
+
if (schemaEnv.$async) {
|
|
2391
|
+
gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError3}(${names_12.default.vErrors})`));
|
|
2392
|
+
} else {
|
|
2393
|
+
gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
|
|
2394
|
+
if (opts.unevaluated)
|
|
2395
|
+
assignEvaluated(it);
|
|
2396
|
+
gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
2400
|
+
if (props instanceof codegen_12.Name)
|
|
2401
|
+
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
2402
|
+
if (items2 instanceof codegen_12.Name)
|
|
2403
|
+
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
2404
|
+
}
|
|
2405
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
2406
|
+
const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
|
|
2407
|
+
const { RULES } = self2;
|
|
2408
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
2409
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
if (!opts.jtd)
|
|
2413
|
+
checkStrictTypes(it, types2);
|
|
2414
|
+
gen.block(() => {
|
|
2415
|
+
for (const group of RULES.rules)
|
|
2416
|
+
groupKeywords(group);
|
|
2417
|
+
groupKeywords(RULES.post);
|
|
2418
|
+
});
|
|
2419
|
+
function groupKeywords(group) {
|
|
2420
|
+
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
2421
|
+
return;
|
|
2422
|
+
if (group.type) {
|
|
2423
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
|
|
2424
|
+
iterateKeywords(it, group);
|
|
2425
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
2426
|
+
gen.else();
|
|
2427
|
+
(0, dataType_2.reportTypeError)(it);
|
|
2428
|
+
}
|
|
2429
|
+
gen.endIf();
|
|
2430
|
+
} else {
|
|
2431
|
+
iterateKeywords(it, group);
|
|
2432
|
+
}
|
|
2433
|
+
if (!allErrors)
|
|
2434
|
+
gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
|
|
2435
|
+
}
|
|
2575
2436
|
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2437
|
+
function iterateKeywords(it, group) {
|
|
2438
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
2439
|
+
if (useDefaults)
|
|
2440
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
2441
|
+
gen.block(() => {
|
|
2442
|
+
for (const rule of group.rules) {
|
|
2443
|
+
if ((0, applicability_12.shouldUseRule)(schema, rule)) {
|
|
2444
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2580
2447
|
});
|
|
2581
2448
|
}
|
|
2582
|
-
|
|
2583
|
-
if (!
|
|
2449
|
+
function checkStrictTypes(it, types2) {
|
|
2450
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
2584
2451
|
return;
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
if (schemaType.length || def2.validateSchema) {
|
|
2590
|
-
gen.elseIf(this.invalid$data());
|
|
2591
|
-
this.$dataError();
|
|
2592
|
-
if (valid !== codegen_1$n.nil)
|
|
2593
|
-
gen.assign(valid, false);
|
|
2594
|
-
}
|
|
2595
|
-
gen.else();
|
|
2452
|
+
checkContextTypes(it, types2);
|
|
2453
|
+
if (!it.opts.allowUnionTypes)
|
|
2454
|
+
checkMultipleTypes(it, types2);
|
|
2455
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
2596
2456
|
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2457
|
+
function checkContextTypes(it, types2) {
|
|
2458
|
+
if (!types2.length)
|
|
2459
|
+
return;
|
|
2460
|
+
if (!it.dataTypes.length) {
|
|
2461
|
+
it.dataTypes = types2;
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
types2.forEach((t) => {
|
|
2465
|
+
if (!includesType(it.dataTypes, t)) {
|
|
2466
|
+
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
2467
|
+
}
|
|
2468
|
+
});
|
|
2469
|
+
narrowSchemaTypes(it, types2);
|
|
2470
|
+
}
|
|
2471
|
+
function checkMultipleTypes(it, ts) {
|
|
2472
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
2473
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
function checkKeywordTypes(it, ts) {
|
|
2477
|
+
const rules3 = it.self.RULES.all;
|
|
2478
|
+
for (const keyword2 in rules3) {
|
|
2479
|
+
const rule = rules3[keyword2];
|
|
2480
|
+
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
2481
|
+
const { type: type2 } = rule.definition;
|
|
2482
|
+
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
2483
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
function hasApplicableType(schTs, kwdT) {
|
|
2489
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
2490
|
+
}
|
|
2491
|
+
function includesType(ts, t) {
|
|
2492
|
+
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
2493
|
+
}
|
|
2494
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
2495
|
+
const ts = [];
|
|
2496
|
+
for (const t of it.dataTypes) {
|
|
2497
|
+
if (includesType(withTypes, t))
|
|
2498
|
+
ts.push(t);
|
|
2499
|
+
else if (withTypes.includes("integer") && t === "number")
|
|
2500
|
+
ts.push("integer");
|
|
2501
|
+
}
|
|
2502
|
+
it.dataTypes = ts;
|
|
2503
|
+
}
|
|
2504
|
+
function strictTypesError(it, msg) {
|
|
2505
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
2506
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
2507
|
+
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
2508
|
+
}
|
|
2509
|
+
class KeywordCxt {
|
|
2510
|
+
constructor(it, def2, keyword2) {
|
|
2511
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
2512
|
+
this.gen = it.gen;
|
|
2513
|
+
this.allErrors = it.allErrors;
|
|
2514
|
+
this.keyword = keyword2;
|
|
2515
|
+
this.data = it.data;
|
|
2516
|
+
this.schema = it.schema[keyword2];
|
|
2517
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
2518
|
+
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
2519
|
+
this.schemaType = def2.schemaType;
|
|
2520
|
+
this.parentSchema = it.schema;
|
|
2521
|
+
this.params = {};
|
|
2522
|
+
this.it = it;
|
|
2523
|
+
this.def = def2;
|
|
2524
|
+
if (this.$data) {
|
|
2525
|
+
this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
|
|
2526
|
+
} else {
|
|
2527
|
+
this.schemaCode = this.schemaValue;
|
|
2528
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
2529
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
2533
|
+
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
2606
2534
|
}
|
|
2607
|
-
return codegen_1$n.nil;
|
|
2608
2535
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2536
|
+
result(condition, successAction, failAction) {
|
|
2537
|
+
this.failResult((0, codegen_12.not)(condition), successAction, failAction);
|
|
2538
|
+
}
|
|
2539
|
+
failResult(condition, successAction, failAction) {
|
|
2540
|
+
this.gen.if(condition);
|
|
2541
|
+
if (failAction)
|
|
2542
|
+
failAction();
|
|
2543
|
+
else
|
|
2544
|
+
this.error();
|
|
2545
|
+
if (successAction) {
|
|
2546
|
+
this.gen.else();
|
|
2547
|
+
successAction();
|
|
2548
|
+
if (this.allErrors)
|
|
2549
|
+
this.gen.endIf();
|
|
2550
|
+
} else {
|
|
2551
|
+
if (this.allErrors)
|
|
2552
|
+
this.gen.endIf();
|
|
2553
|
+
else
|
|
2554
|
+
this.gen.else();
|
|
2613
2555
|
}
|
|
2614
|
-
return codegen_1$n.nil;
|
|
2615
2556
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
(
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2557
|
+
pass(condition, failAction) {
|
|
2558
|
+
this.failResult((0, codegen_12.not)(condition), void 0, failAction);
|
|
2559
|
+
}
|
|
2560
|
+
fail(condition) {
|
|
2561
|
+
if (condition === void 0) {
|
|
2562
|
+
this.error();
|
|
2563
|
+
if (!this.allErrors)
|
|
2564
|
+
this.gen.if(false);
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
this.gen.if(condition);
|
|
2568
|
+
this.error();
|
|
2569
|
+
if (this.allErrors)
|
|
2570
|
+
this.gen.endIf();
|
|
2571
|
+
else
|
|
2572
|
+
this.gen.else();
|
|
2631
2573
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2574
|
+
fail$data(condition) {
|
|
2575
|
+
if (!this.$data)
|
|
2576
|
+
return this.fail(condition);
|
|
2577
|
+
const { schemaCode } = this;
|
|
2578
|
+
this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
|
|
2579
|
+
}
|
|
2580
|
+
error(append, errorParams, errorPaths) {
|
|
2581
|
+
if (errorParams) {
|
|
2582
|
+
this.setParams(errorParams);
|
|
2583
|
+
this._error(append, errorPaths);
|
|
2584
|
+
this.setParams({});
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2587
|
+
this._error(append, errorPaths);
|
|
2634
2588
|
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
const { it, gen } = this;
|
|
2638
|
-
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
2639
|
-
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
|
|
2640
|
-
return true;
|
|
2589
|
+
_error(append, errorPaths) {
|
|
2590
|
+
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
2641
2591
|
}
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
(
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
(
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2592
|
+
$dataError() {
|
|
2593
|
+
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
2594
|
+
}
|
|
2595
|
+
reset() {
|
|
2596
|
+
if (this.errsCount === void 0)
|
|
2597
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
2598
|
+
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
2599
|
+
}
|
|
2600
|
+
ok(cond) {
|
|
2601
|
+
if (!this.allErrors)
|
|
2602
|
+
this.gen.if(cond);
|
|
2603
|
+
}
|
|
2604
|
+
setParams(obj, assign) {
|
|
2605
|
+
if (assign)
|
|
2606
|
+
Object.assign(this.params, obj);
|
|
2607
|
+
else
|
|
2608
|
+
this.params = obj;
|
|
2609
|
+
}
|
|
2610
|
+
block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
|
|
2611
|
+
this.gen.block(() => {
|
|
2612
|
+
this.check$data(valid, $dataValid);
|
|
2613
|
+
codeBlock();
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
|
|
2617
|
+
if (!this.$data)
|
|
2618
|
+
return;
|
|
2619
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
2620
|
+
gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
|
|
2621
|
+
if (valid !== codegen_12.nil)
|
|
2622
|
+
gen.assign(valid, true);
|
|
2623
|
+
if (schemaType.length || def2.validateSchema) {
|
|
2624
|
+
gen.elseIf(this.invalid$data());
|
|
2625
|
+
this.$dataError();
|
|
2626
|
+
if (valid !== codegen_12.nil)
|
|
2627
|
+
gen.assign(valid, false);
|
|
2628
|
+
}
|
|
2629
|
+
gen.else();
|
|
2630
|
+
}
|
|
2631
|
+
invalid$data() {
|
|
2632
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
2633
|
+
return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
|
|
2634
|
+
function wrong$DataType() {
|
|
2635
|
+
if (schemaType.length) {
|
|
2636
|
+
if (!(schemaCode instanceof codegen_12.Name))
|
|
2637
|
+
throw new Error("ajv implementation error");
|
|
2638
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
2639
|
+
return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
2640
|
+
}
|
|
2641
|
+
return codegen_12.nil;
|
|
2642
|
+
}
|
|
2643
|
+
function invalid$DataSchema() {
|
|
2644
|
+
if (def2.validateSchema) {
|
|
2645
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
2646
|
+
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
2647
|
+
}
|
|
2648
|
+
return codegen_12.nil;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
subschema(appl, valid) {
|
|
2652
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
2653
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
2654
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
2655
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
2656
|
+
subschemaCode(nextContext, valid);
|
|
2657
|
+
return nextContext;
|
|
2658
|
+
}
|
|
2659
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
2660
|
+
const { it, gen } = this;
|
|
2661
|
+
if (!it.opts.unevaluated)
|
|
2662
|
+
return;
|
|
2663
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
2664
|
+
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
2665
|
+
}
|
|
2666
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
2667
|
+
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
2671
|
+
const { it, gen } = this;
|
|
2672
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
2673
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
|
|
2674
|
+
return true;
|
|
2675
|
+
}
|
|
2692
2676
|
}
|
|
2693
2677
|
}
|
|
2694
|
-
|
|
2695
|
-
function
|
|
2696
|
-
|
|
2697
|
-
|
|
2678
|
+
validate$2.KeywordCxt = KeywordCxt;
|
|
2679
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
2680
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
2681
|
+
if ("code" in def2) {
|
|
2682
|
+
def2.code(cxt, ruleType);
|
|
2683
|
+
} else if (cxt.$data && def2.validate) {
|
|
2684
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2685
|
+
} else if ("macro" in def2) {
|
|
2686
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
2687
|
+
} else if (def2.compile || def2.validate) {
|
|
2688
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
const JSON_POINTER2 = /^\/(?:[^~]|~0|~1)*$/;
|
|
2692
|
+
const RELATIVE_JSON_POINTER2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2693
|
+
function getData2($data, { dataLevel, dataNames, dataPathArr }) {
|
|
2694
|
+
let jsonPointer;
|
|
2695
|
+
let data2;
|
|
2696
|
+
if ($data === "")
|
|
2697
|
+
return names_12.default.rootData;
|
|
2698
|
+
if ($data[0] === "/") {
|
|
2699
|
+
if (!JSON_POINTER2.test($data))
|
|
2700
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2701
|
+
jsonPointer = $data;
|
|
2702
|
+
data2 = names_12.default.rootData;
|
|
2703
|
+
} else {
|
|
2704
|
+
const matches = RELATIVE_JSON_POINTER2.exec($data);
|
|
2705
|
+
if (!matches)
|
|
2706
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2707
|
+
const up = +matches[1];
|
|
2708
|
+
jsonPointer = matches[2];
|
|
2709
|
+
if (jsonPointer === "#") {
|
|
2710
|
+
if (up >= dataLevel)
|
|
2711
|
+
throw new Error(errorMsg("property/index", up));
|
|
2712
|
+
return dataPathArr[dataLevel - up];
|
|
2713
|
+
}
|
|
2714
|
+
if (up > dataLevel)
|
|
2715
|
+
throw new Error(errorMsg("data", up));
|
|
2716
|
+
data2 = dataNames[dataLevel - up];
|
|
2717
|
+
if (!jsonPointer)
|
|
2718
|
+
return data2;
|
|
2719
|
+
}
|
|
2720
|
+
let expr = data2;
|
|
2721
|
+
const segments = jsonPointer.split("/");
|
|
2722
|
+
for (const segment of segments) {
|
|
2723
|
+
if (segment) {
|
|
2724
|
+
data2 = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
|
|
2725
|
+
expr = (0, codegen_12._)`${expr} && ${data2}`;
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
return expr;
|
|
2729
|
+
function errorMsg(pointerType, up) {
|
|
2730
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
validate$2.getData = getData2;
|
|
2734
|
+
return validate$2;
|
|
2698
2735
|
}
|
|
2699
|
-
validate$2.getData = getData$1;
|
|
2700
2736
|
var validation_error = {};
|
|
2701
2737
|
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
2702
2738
|
let ValidationError$2 = class ValidationError extends Error {
|
|
@@ -2726,7 +2762,7 @@ const validation_error_1 = validation_error;
|
|
|
2726
2762
|
const names_1$2 = names$1;
|
|
2727
2763
|
const resolve_1$1 = resolve$6;
|
|
2728
2764
|
const util_1$k = util$7;
|
|
2729
|
-
const validate_1$1 =
|
|
2765
|
+
const validate_1$1 = requireValidate();
|
|
2730
2766
|
class SchemaEnv {
|
|
2731
2767
|
constructor(env) {
|
|
2732
2768
|
var _a;
|
|
@@ -3613,7 +3649,7 @@ uri$2.default = uri$1;
|
|
|
3613
3649
|
(function(exports) {
|
|
3614
3650
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3615
3651
|
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
|
3616
|
-
var validate_12 =
|
|
3652
|
+
var validate_12 = requireValidate();
|
|
3617
3653
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
3618
3654
|
return validate_12.KeywordCxt;
|
|
3619
3655
|
} });
|
|
@@ -4231,7 +4267,7 @@ var ref$1 = {};
|
|
|
4231
4267
|
Object.defineProperty(ref$1, "__esModule", { value: true });
|
|
4232
4268
|
ref$1.callRef = ref$1.getValidate = void 0;
|
|
4233
4269
|
const ref_error_1$1 = ref_error;
|
|
4234
|
-
const code_1$8 =
|
|
4270
|
+
const code_1$8 = requireCode();
|
|
4235
4271
|
const codegen_1$l = codegen;
|
|
4236
4272
|
const names_1$1 = names$1;
|
|
4237
4273
|
const compile_1$2 = compile$2;
|
|
@@ -4454,7 +4490,7 @@ const def$o = {
|
|
|
4454
4490
|
limitLength.default = def$o;
|
|
4455
4491
|
var pattern$1 = {};
|
|
4456
4492
|
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4457
|
-
const code_1$7 =
|
|
4493
|
+
const code_1$7 = requireCode();
|
|
4458
4494
|
const codegen_1$h = codegen;
|
|
4459
4495
|
const error$f = {
|
|
4460
4496
|
message: ({ schemaCode }) => (0, codegen_1$h.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4499,7 +4535,7 @@ const def$m = {
|
|
|
4499
4535
|
limitProperties.default = def$m;
|
|
4500
4536
|
var required$2 = {};
|
|
4501
4537
|
Object.defineProperty(required$2, "__esModule", { value: true });
|
|
4502
|
-
const code_1$6 =
|
|
4538
|
+
const code_1$6 = requireCode();
|
|
4503
4539
|
const codegen_1$f = codegen;
|
|
4504
4540
|
const util_1$h = util$7;
|
|
4505
4541
|
const error$d = {
|
|
@@ -4813,7 +4849,7 @@ Object.defineProperty(items$1, "__esModule", { value: true });
|
|
|
4813
4849
|
items$1.validateTuple = void 0;
|
|
4814
4850
|
const codegen_1$9 = codegen;
|
|
4815
4851
|
const util_1$c = util$7;
|
|
4816
|
-
const code_1$5 =
|
|
4852
|
+
const code_1$5 = requireCode();
|
|
4817
4853
|
const def$f = {
|
|
4818
4854
|
keyword: "items",
|
|
4819
4855
|
type: "array",
|
|
@@ -4873,7 +4909,7 @@ var items2020 = {};
|
|
|
4873
4909
|
Object.defineProperty(items2020, "__esModule", { value: true });
|
|
4874
4910
|
const codegen_1$8 = codegen;
|
|
4875
4911
|
const util_1$b = util$7;
|
|
4876
|
-
const code_1$4 =
|
|
4912
|
+
const code_1$4 = requireCode();
|
|
4877
4913
|
const additionalItems_1$1 = additionalItems;
|
|
4878
4914
|
const error$7 = {
|
|
4879
4915
|
message: ({ params: { len } }) => (0, codegen_1$8.str)`must NOT have more than ${len} items`,
|
|
@@ -4992,7 +5028,7 @@ var dependencies$1 = {};
|
|
|
4992
5028
|
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
|
|
4993
5029
|
const codegen_12 = codegen;
|
|
4994
5030
|
const util_12 = util$7;
|
|
4995
|
-
const code_12 =
|
|
5031
|
+
const code_12 = requireCode();
|
|
4996
5032
|
exports.error = {
|
|
4997
5033
|
message: ({ params: { property, depsCount, deps } }) => {
|
|
4998
5034
|
const property_ies = depsCount === 1 ? "property" : "properties";
|
|
@@ -5115,7 +5151,7 @@ const def$b = {
|
|
|
5115
5151
|
propertyNames$1.default = def$b;
|
|
5116
5152
|
var additionalProperties$1 = {};
|
|
5117
5153
|
Object.defineProperty(additionalProperties$1, "__esModule", { value: true });
|
|
5118
|
-
const code_1$3 =
|
|
5154
|
+
const code_1$3 = requireCode();
|
|
5119
5155
|
const codegen_1$5 = codegen;
|
|
5120
5156
|
const names_1 = names$1;
|
|
5121
5157
|
const util_1$8 = util$7;
|
|
@@ -5215,8 +5251,8 @@ const def$a = {
|
|
|
5215
5251
|
additionalProperties$1.default = def$a;
|
|
5216
5252
|
var properties$4 = {};
|
|
5217
5253
|
Object.defineProperty(properties$4, "__esModule", { value: true });
|
|
5218
|
-
const validate_1 =
|
|
5219
|
-
const code_1$2 =
|
|
5254
|
+
const validate_1 = requireValidate();
|
|
5255
|
+
const code_1$2 = requireCode();
|
|
5220
5256
|
const util_1$7 = util$7;
|
|
5221
5257
|
const additionalProperties_1$1 = additionalProperties$1;
|
|
5222
5258
|
const def$9 = {
|
|
@@ -5267,7 +5303,7 @@ const def$9 = {
|
|
|
5267
5303
|
properties$4.default = def$9;
|
|
5268
5304
|
var patternProperties = {};
|
|
5269
5305
|
Object.defineProperty(patternProperties, "__esModule", { value: true });
|
|
5270
|
-
const code_1$1 =
|
|
5306
|
+
const code_1$1 = requireCode();
|
|
5271
5307
|
const codegen_1$4 = codegen;
|
|
5272
5308
|
const util_1$6 = util$7;
|
|
5273
5309
|
const util_2 = util$7;
|
|
@@ -5360,7 +5396,7 @@ const def$7 = {
|
|
|
5360
5396
|
not$1.default = def$7;
|
|
5361
5397
|
var anyOf$1 = {};
|
|
5362
5398
|
Object.defineProperty(anyOf$1, "__esModule", { value: true });
|
|
5363
|
-
const code_1 =
|
|
5399
|
+
const code_1 = requireCode();
|
|
5364
5400
|
const def$6 = {
|
|
5365
5401
|
keyword: "anyOf",
|
|
5366
5402
|
schemaType: "array",
|
|
@@ -6066,7 +6102,7 @@ const require$$3 = {
|
|
|
6066
6102
|
module.exports.Ajv = Ajv2;
|
|
6067
6103
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6068
6104
|
exports.default = Ajv2;
|
|
6069
|
-
var validate_12 =
|
|
6105
|
+
var validate_12 = requireValidate();
|
|
6070
6106
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
6071
6107
|
return validate_12.KeywordCxt;
|
|
6072
6108
|
} });
|
|
@@ -13542,7 +13578,7 @@ function compile$1(schema, root, localRefs, baseId) {
|
|
|
13542
13578
|
util: util$2,
|
|
13543
13579
|
resolve: resolve$1,
|
|
13544
13580
|
resolveRef: resolveRef2,
|
|
13545
|
-
usePattern
|
|
13581
|
+
usePattern,
|
|
13546
13582
|
useDefault,
|
|
13547
13583
|
useCustomRule,
|
|
13548
13584
|
opts,
|
|
@@ -13647,7 +13683,7 @@ function compile$1(schema, root, localRefs, baseId) {
|
|
|
13647
13683
|
function resolvedRef(refVal2, code2) {
|
|
13648
13684
|
return typeof refVal2 == "object" || typeof refVal2 == "boolean" ? { code: code2, schema: refVal2, inline: true } : { code: code2, $async: refVal2 && !!refVal2.$async };
|
|
13649
13685
|
}
|
|
13650
|
-
function
|
|
13686
|
+
function usePattern(regexStr) {
|
|
13651
13687
|
var index = patternsHash[regexStr];
|
|
13652
13688
|
if (index === void 0) {
|
|
13653
13689
|
index = patternsHash[regexStr] = patterns.length;
|