@opentiny/next-sdk 0.1.8 → 0.1.10
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/WebMcpClient.ts +9 -37
- package/agent/AgentModelProvider.ts +56 -43
- package/agent/type.ts +2 -2
- package/agent/utils/getAISDKTools.ts +2 -2
- package/dist/WebMcpClient.d.ts +1 -4
- package/dist/WebMcpClient.js +9 -33
- package/dist/agent/AgentModelProvider.d.ts +21 -16
- package/dist/agent/AgentModelProvider.js +72 -51
- package/dist/agent/type.d.ts +2 -2
- package/dist/agent/utils/getAISDKTools.d.ts +2 -2
- package/dist/agent/utils/getAISDKTools.js +2 -2
- package/dist/index.es.dev.js +56 -57
- package/dist/index.es.js +4076 -4070
- package/dist/index.umd.dev.js +56 -57
- package/dist/index.umd.js +27 -27
- package/dist/remoter/createRemoter.js +1 -1
- package/dist/webagent.dev.js +48 -28
- package/dist/webagent.es.dev.js +48 -28
- package/dist/webagent.es.js +1617 -1602
- package/dist/webagent.js +21 -21
- package/dist/webmcp-full.dev.js +930 -987
- package/dist/webmcp-full.es.dev.js +930 -987
- package/dist/webmcp-full.es.js +1388 -1397
- package/dist/webmcp-full.js +7 -7
- package/dist/webmcp.dev.js +8 -29
- package/dist/webmcp.es.dev.js +8 -29
- package/dist/webmcp.es.js +432 -441
- package/dist/webmcp.js +1 -1
- package/package.json +1 -1
- package/remoter/createRemoter.ts +1 -1
- package/runtime.html +21 -80
|
@@ -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$v = codegen;
|
|
1021
|
+
const code_1$a = 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$v._)`${schema}`;
|
|
1075
1075
|
}
|
|
1076
|
-
return (0, codegen_1$
|
|
1076
|
+
return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.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$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
|
|
1109
|
+
return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.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$v._)`${to} !== true && ${from} !== undefined`, () => {
|
|
1115
|
+
gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`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$v._)`${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$v._)`${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$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
|
|
1130
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${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$v._)`{}`);
|
|
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$v._)`${props}${(0, codegen_1$v.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$a._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$v.Name) {
|
|
1163
1163
|
const isNumber = dataPropType === Type.Num;
|
|
1164
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
1164
|
+
return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
1165
1165
|
}
|
|
1166
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
1166
|
+
return jsPropertySyntax ? (0, codegen_1$v.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$u = codegen;
|
|
1181
1181
|
const names = {
|
|
1182
1182
|
// validation function arguments
|
|
1183
|
-
data: new codegen_1$
|
|
1183
|
+
data: new codegen_1$u.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$u.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$u.Name("instancePath"),
|
|
1189
|
+
parentData: new codegen_1$u.Name("parentData"),
|
|
1190
|
+
parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
|
|
1191
|
+
rootData: new codegen_1$u.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$u.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$u.Name("vErrors"),
|
|
1197
1197
|
// null or array of validation errors
|
|
1198
|
-
errors: new codegen_1$
|
|
1198
|
+
errors: new codegen_1$u.Name("errors"),
|
|
1199
1199
|
// counter of validation errors
|
|
1200
|
-
this: new codegen_1$
|
|
1200
|
+
this: new codegen_1$u.Name("this"),
|
|
1201
1201
|
// "globals"
|
|
1202
|
-
self: new codegen_1$
|
|
1203
|
-
scope: new codegen_1$
|
|
1202
|
+
self: new codegen_1$u.Name("self"),
|
|
1203
|
+
scope: new codegen_1$u.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$u.Name("json"),
|
|
1206
|
+
jsonPos: new codegen_1$u.Name("jsonPos"),
|
|
1207
|
+
jsonLen: new codegen_1$u.Name("jsonLen"),
|
|
1208
|
+
jsonPart: new codegen_1$u.Name("jsonPart")
|
|
1209
1209
|
};
|
|
1210
1210
|
names$1.default = names;
|
|
1211
1211
|
(function(exports) {
|
|
@@ -1325,55 +1325,49 @@ 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
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
gen.return(names_12.default.data);
|
|
1346
|
-
} else {
|
|
1347
|
-
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
1348
|
-
gen.return(true);
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
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
|
-
}
|
|
1328
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
1329
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
1330
|
+
const errors_1$3 = errors;
|
|
1331
|
+
const codegen_1$t = codegen;
|
|
1332
|
+
const names_1$6 = names$1;
|
|
1333
|
+
const boolError = {
|
|
1334
|
+
message: "boolean schema is false"
|
|
1335
|
+
};
|
|
1336
|
+
function topBoolOrEmptySchema(it) {
|
|
1337
|
+
const { gen, schema, validateName } = it;
|
|
1338
|
+
if (schema === false) {
|
|
1339
|
+
falseSchemaError(it, false);
|
|
1340
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
1341
|
+
gen.return(names_1$6.default.data);
|
|
1342
|
+
} else {
|
|
1343
|
+
gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
|
|
1344
|
+
gen.return(true);
|
|
1360
1345
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
schemaValue: false,
|
|
1371
|
-
params: {},
|
|
1372
|
-
it
|
|
1373
|
-
};
|
|
1374
|
-
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
1346
|
+
}
|
|
1347
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
1348
|
+
function boolOrEmptySchema(it, valid) {
|
|
1349
|
+
const { gen, schema } = it;
|
|
1350
|
+
if (schema === false) {
|
|
1351
|
+
gen.var(valid, false);
|
|
1352
|
+
falseSchemaError(it);
|
|
1353
|
+
} else {
|
|
1354
|
+
gen.var(valid, true);
|
|
1375
1355
|
}
|
|
1376
|
-
|
|
1356
|
+
}
|
|
1357
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
1358
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
1359
|
+
const { gen, data: data2 } = it;
|
|
1360
|
+
const cxt = {
|
|
1361
|
+
gen,
|
|
1362
|
+
keyword: "false schema",
|
|
1363
|
+
data: data2,
|
|
1364
|
+
schema: false,
|
|
1365
|
+
schemaCode: false,
|
|
1366
|
+
schemaValue: false,
|
|
1367
|
+
params: {},
|
|
1368
|
+
it
|
|
1369
|
+
};
|
|
1370
|
+
(0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
1377
1371
|
}
|
|
1378
1372
|
var dataType = {};
|
|
1379
1373
|
var rules$2 = {};
|
|
@@ -1421,10 +1415,10 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
1421
1415
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
1422
1416
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
1423
1417
|
const rules_1 = rules$2;
|
|
1424
|
-
const applicability_1 = applicability;
|
|
1425
|
-
const errors_1 = errors;
|
|
1426
|
-
const codegen_1$
|
|
1427
|
-
const util_1$
|
|
1418
|
+
const applicability_1$1 = applicability;
|
|
1419
|
+
const errors_1$2 = errors;
|
|
1420
|
+
const codegen_1$s = codegen;
|
|
1421
|
+
const util_1$q = util$7;
|
|
1428
1422
|
var DataType;
|
|
1429
1423
|
(function(DataType2) {
|
|
1430
1424
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -1456,7 +1450,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
1456
1450
|
function coerceAndCheckDataType(it, types2) {
|
|
1457
1451
|
const { gen, data: data2, opts } = it;
|
|
1458
1452
|
const coerceTo = coerceToTypes$1(types2, opts.coerceTypes);
|
|
1459
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
1453
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
|
|
1460
1454
|
if (checkTypes) {
|
|
1461
1455
|
const wrongType = checkDataTypes$1(types2, data2, opts.strictNumbers, DataType.Wrong);
|
|
1462
1456
|
gen.if(wrongType, () => {
|
|
@@ -1475,12 +1469,12 @@ function coerceToTypes$1(types2, coerceTypes) {
|
|
|
1475
1469
|
}
|
|
1476
1470
|
function coerceData(it, types2, coerceTo) {
|
|
1477
1471
|
const { gen, data: data2, opts } = it;
|
|
1478
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
1479
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
1472
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data2}`);
|
|
1473
|
+
const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
|
|
1480
1474
|
if (opts.coerceTypes === "array") {
|
|
1481
|
-
gen.if((0, codegen_1$
|
|
1475
|
+
gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data2}) && ${data2}.length == 1`, () => gen.assign(data2, (0, codegen_1$s._)`${data2}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data2}`).if(checkDataTypes$1(types2, data2, opts.strictNumbers), () => gen.assign(coerced, data2)));
|
|
1482
1476
|
}
|
|
1483
|
-
gen.if((0, codegen_1$
|
|
1477
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
|
|
1484
1478
|
for (const t of coerceTo) {
|
|
1485
1479
|
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
|
|
1486
1480
|
coerceSpecificType(t);
|
|
@@ -1489,63 +1483,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
1489
1483
|
gen.else();
|
|
1490
1484
|
reportTypeError(it);
|
|
1491
1485
|
gen.endIf();
|
|
1492
|
-
gen.if((0, codegen_1$
|
|
1486
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
|
|
1493
1487
|
gen.assign(data2, coerced);
|
|
1494
1488
|
assignParentData(it, coerced);
|
|
1495
1489
|
});
|
|
1496
1490
|
function coerceSpecificType(t) {
|
|
1497
1491
|
switch (t) {
|
|
1498
1492
|
case "string":
|
|
1499
|
-
gen.elseIf((0, codegen_1$
|
|
1493
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data2}`).elseIf((0, codegen_1$s._)`${data2} === null`).assign(coerced, (0, codegen_1$s._)`""`);
|
|
1500
1494
|
return;
|
|
1501
1495
|
case "number":
|
|
1502
|
-
gen.elseIf((0, codegen_1$
|
|
1503
|
-
|| (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$
|
|
1496
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data2} === null
|
|
1497
|
+
|| (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
|
|
1504
1498
|
return;
|
|
1505
1499
|
case "integer":
|
|
1506
|
-
gen.elseIf((0, codegen_1$
|
|
1507
|
-
|| (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$
|
|
1500
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data2} === null
|
|
1501
|
+
|| (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
|
|
1508
1502
|
return;
|
|
1509
1503
|
case "boolean":
|
|
1510
|
-
gen.elseIf((0, codegen_1$
|
|
1504
|
+
gen.elseIf((0, codegen_1$s._)`${data2} === "false" || ${data2} === 0 || ${data2} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data2} === "true" || ${data2} === 1`).assign(coerced, true);
|
|
1511
1505
|
return;
|
|
1512
1506
|
case "null":
|
|
1513
|
-
gen.elseIf((0, codegen_1$
|
|
1507
|
+
gen.elseIf((0, codegen_1$s._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
|
|
1514
1508
|
gen.assign(coerced, null);
|
|
1515
1509
|
return;
|
|
1516
1510
|
case "array":
|
|
1517
|
-
gen.elseIf((0, codegen_1$
|
|
1518
|
-
|| ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$
|
|
1511
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
1512
|
+
|| ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$s._)`[${data2}]`);
|
|
1519
1513
|
}
|
|
1520
1514
|
}
|
|
1521
1515
|
}
|
|
1522
1516
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
1523
|
-
gen.if((0, codegen_1$
|
|
1517
|
+
gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
|
|
1524
1518
|
}
|
|
1525
1519
|
function checkDataType$1(dataType2, data2, strictNums, correct = DataType.Correct) {
|
|
1526
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
1520
|
+
const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
|
|
1527
1521
|
let cond;
|
|
1528
1522
|
switch (dataType2) {
|
|
1529
1523
|
case "null":
|
|
1530
|
-
return (0, codegen_1$
|
|
1524
|
+
return (0, codegen_1$s._)`${data2} ${EQ} null`;
|
|
1531
1525
|
case "array":
|
|
1532
|
-
cond = (0, codegen_1$
|
|
1526
|
+
cond = (0, codegen_1$s._)`Array.isArray(${data2})`;
|
|
1533
1527
|
break;
|
|
1534
1528
|
case "object":
|
|
1535
|
-
cond = (0, codegen_1$
|
|
1529
|
+
cond = (0, codegen_1$s._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
|
|
1536
1530
|
break;
|
|
1537
1531
|
case "integer":
|
|
1538
|
-
cond = numCond((0, codegen_1$
|
|
1532
|
+
cond = numCond((0, codegen_1$s._)`!(${data2} % 1) && !isNaN(${data2})`);
|
|
1539
1533
|
break;
|
|
1540
1534
|
case "number":
|
|
1541
1535
|
cond = numCond();
|
|
1542
1536
|
break;
|
|
1543
1537
|
default:
|
|
1544
|
-
return (0, codegen_1$
|
|
1538
|
+
return (0, codegen_1$s._)`typeof ${data2} ${EQ} ${dataType2}`;
|
|
1545
1539
|
}
|
|
1546
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
1547
|
-
function numCond(_cond = codegen_1$
|
|
1548
|
-
return (0, codegen_1$
|
|
1540
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
|
|
1541
|
+
function numCond(_cond = codegen_1$s.nil) {
|
|
1542
|
+
return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data2} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data2})` : codegen_1$s.nil);
|
|
1549
1543
|
}
|
|
1550
1544
|
}
|
|
1551
1545
|
dataType.checkDataType = checkDataType$1;
|
|
@@ -1554,35 +1548,35 @@ function checkDataTypes$1(dataTypes, data2, strictNums, correct) {
|
|
|
1554
1548
|
return checkDataType$1(dataTypes[0], data2, strictNums, correct);
|
|
1555
1549
|
}
|
|
1556
1550
|
let cond;
|
|
1557
|
-
const types2 = (0, util_1$
|
|
1551
|
+
const types2 = (0, util_1$q.toHash)(dataTypes);
|
|
1558
1552
|
if (types2.array && types2.object) {
|
|
1559
|
-
const notObj = (0, codegen_1$
|
|
1560
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
1553
|
+
const notObj = (0, codegen_1$s._)`typeof ${data2} != "object"`;
|
|
1554
|
+
cond = types2.null ? notObj : (0, codegen_1$s._)`!${data2} || ${notObj}`;
|
|
1561
1555
|
delete types2.null;
|
|
1562
1556
|
delete types2.array;
|
|
1563
1557
|
delete types2.object;
|
|
1564
1558
|
} else {
|
|
1565
|
-
cond = codegen_1$
|
|
1559
|
+
cond = codegen_1$s.nil;
|
|
1566
1560
|
}
|
|
1567
1561
|
if (types2.number)
|
|
1568
1562
|
delete types2.integer;
|
|
1569
1563
|
for (const t in types2)
|
|
1570
|
-
cond = (0, codegen_1$
|
|
1564
|
+
cond = (0, codegen_1$s.and)(cond, checkDataType$1(t, data2, strictNums, correct));
|
|
1571
1565
|
return cond;
|
|
1572
1566
|
}
|
|
1573
1567
|
dataType.checkDataTypes = checkDataTypes$1;
|
|
1574
1568
|
const typeError = {
|
|
1575
1569
|
message: ({ schema }) => `must be ${schema}`,
|
|
1576
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
1570
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
|
|
1577
1571
|
};
|
|
1578
1572
|
function reportTypeError(it) {
|
|
1579
1573
|
const cxt = getTypeErrorContext(it);
|
|
1580
|
-
(0, errors_1.reportError)(cxt, typeError);
|
|
1574
|
+
(0, errors_1$2.reportError)(cxt, typeError);
|
|
1581
1575
|
}
|
|
1582
1576
|
dataType.reportTypeError = reportTypeError;
|
|
1583
1577
|
function getTypeErrorContext(it) {
|
|
1584
1578
|
const { gen, data: data2, schema } = it;
|
|
1585
|
-
const schemaCode = (0, util_1$
|
|
1579
|
+
const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
|
|
1586
1580
|
return {
|
|
1587
1581
|
gen,
|
|
1588
1582
|
keyword: "type",
|
|
@@ -1596,376 +1590,352 @@ function getTypeErrorContext(it) {
|
|
|
1596
1590
|
};
|
|
1597
1591
|
}
|
|
1598
1592
|
var defaults = {};
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1593
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
1594
|
+
defaults.assignDefaults = void 0;
|
|
1595
|
+
const codegen_1$r = codegen;
|
|
1596
|
+
const util_1$p = util$7;
|
|
1597
|
+
function assignDefaults(it, ty) {
|
|
1598
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
1599
|
+
if (ty === "object" && properties2) {
|
|
1600
|
+
for (const key in properties2) {
|
|
1601
|
+
assignDefault(it, key, properties2[key].default);
|
|
1602
|
+
}
|
|
1603
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
1604
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
defaults.assignDefaults = assignDefaults;
|
|
1608
|
+
function assignDefault(it, prop, defaultValue) {
|
|
1609
|
+
const { gen, compositeRule, data: data2, opts } = it;
|
|
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;
|
|
1616
1616
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
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)}`);
|
|
1617
|
+
let condition = (0, codegen_1$r._)`${childData} === undefined`;
|
|
1618
|
+
if (opts.useDefaults === "empty") {
|
|
1619
|
+
condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
1632
1620
|
}
|
|
1633
|
-
|
|
1621
|
+
gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
|
|
1634
1622
|
}
|
|
1635
1623
|
var keyword$1 = {};
|
|
1636
1624
|
var code = {};
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
const
|
|
1645
|
-
|
|
1646
|
-
|
|
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);
|
|
1625
|
+
Object.defineProperty(code, "__esModule", { value: true });
|
|
1626
|
+
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;
|
|
1627
|
+
const codegen_1$q = codegen;
|
|
1628
|
+
const util_1$o = util$7;
|
|
1629
|
+
const names_1$5 = names$1;
|
|
1630
|
+
const util_2$1 = util$7;
|
|
1631
|
+
function checkReportMissingProp(cxt, prop) {
|
|
1632
|
+
const { gen, data: data2, it } = cxt;
|
|
1633
|
+
gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
|
|
1634
|
+
cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
|
|
1661
1635
|
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;
|
|
1662
1711
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
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})`
|
|
1712
|
+
gen.var(valid, true);
|
|
1713
|
+
validateItems(() => gen.break());
|
|
1714
|
+
return valid;
|
|
1715
|
+
function validateItems(notValid) {
|
|
1716
|
+
const len = gen.const("len", (0, codegen_1$q._)`${data2}.length`);
|
|
1717
|
+
gen.forRange("i", 0, len, (i) => {
|
|
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);
|
|
1717
1724
|
});
|
|
1718
1725
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1726
|
+
}
|
|
1727
|
+
code.validateArray = validateArray;
|
|
1728
|
+
function validateUnion(cxt) {
|
|
1729
|
+
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
1730
|
+
if (!Array.isArray(schema))
|
|
1731
|
+
throw new Error("ajv implementation error");
|
|
1732
|
+
const alwaysValid = schema.some((sch) => (0, util_1$o.alwaysValidSchema)(it, sch));
|
|
1733
|
+
if (alwaysValid && !it.opts.unevaluated)
|
|
1734
|
+
return;
|
|
1735
|
+
const valid = gen.let("valid", false);
|
|
1736
|
+
const schValid = gen.name("_valid");
|
|
1737
|
+
gen.block(() => schema.forEach((_sch, i) => {
|
|
1738
|
+
const schCxt = cxt.subschema({
|
|
1739
|
+
keyword: keyword2,
|
|
1740
|
+
schemaProp: i,
|
|
1741
|
+
compositeRule: true
|
|
1742
|
+
}, schValid);
|
|
1743
|
+
gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
|
|
1744
|
+
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
1745
|
+
if (!merged)
|
|
1746
|
+
gen.if((0, codegen_1$q.not)(valid));
|
|
1747
|
+
}));
|
|
1748
|
+
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
1749
|
+
}
|
|
1750
|
+
code.validateUnion = validateUnion;
|
|
1751
|
+
Object.defineProperty(keyword$1, "__esModule", { value: true });
|
|
1752
|
+
keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
|
|
1753
|
+
const codegen_1$p = codegen;
|
|
1754
|
+
const names_1$4 = names$1;
|
|
1755
|
+
const code_1$9 = code;
|
|
1756
|
+
const errors_1$1 = errors;
|
|
1757
|
+
function macroKeywordCode(cxt, def2) {
|
|
1758
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
1759
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
1760
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
1761
|
+
if (it.opts.validateSchema !== false)
|
|
1762
|
+
it.self.validateSchema(macroSchema, true);
|
|
1763
|
+
const valid = gen.name("valid");
|
|
1764
|
+
cxt.subschema({
|
|
1765
|
+
schema: macroSchema,
|
|
1766
|
+
schemaPath: codegen_1$p.nil,
|
|
1767
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
1768
|
+
topSchemaRef: schemaRef,
|
|
1769
|
+
compositeRule: true
|
|
1770
|
+
}, valid);
|
|
1771
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
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));
|
|
1741
1794
|
}
|
|
1742
1795
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
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));
|
|
1796
|
+
function validateAsync() {
|
|
1797
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
1798
|
+
gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
|
|
1799
|
+
return ruleErrs;
|
|
1765
1800
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
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));
|
|
1801
|
+
function validateSync() {
|
|
1802
|
+
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
1803
|
+
gen.assign(validateErrs, null);
|
|
1804
|
+
assignValid(codegen_1$p.nil);
|
|
1805
|
+
return validateErrs;
|
|
1794
1806
|
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
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
|
-
}
|
|
1807
|
+
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
1808
|
+
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
1809
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
1810
|
+
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
1838
1811
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
keyword$
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
}
|
|
1812
|
+
function reportErrs(errors2) {
|
|
1813
|
+
var _a2;
|
|
1814
|
+
gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
keyword$1.funcKeywordCode = funcKeywordCode;
|
|
1818
|
+
function modifyData(cxt) {
|
|
1819
|
+
const { gen, data: data2, it } = cxt;
|
|
1820
|
+
gen.if(it.parentData, () => gen.assign(data2, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
1821
|
+
}
|
|
1822
|
+
function addErrs(cxt, errs) {
|
|
1823
|
+
const { gen } = cxt;
|
|
1824
|
+
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
1825
|
+
gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
|
|
1826
|
+
(0, errors_1$1.extendErrors)(cxt);
|
|
1827
|
+
}, () => cxt.error());
|
|
1828
|
+
}
|
|
1829
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
1830
|
+
if (def2.async && !schemaEnv.$async)
|
|
1831
|
+
throw new Error("async keyword in sync schema");
|
|
1832
|
+
}
|
|
1833
|
+
function useKeyword(gen, keyword2, result) {
|
|
1834
|
+
if (result === void 0)
|
|
1835
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
1836
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
1837
|
+
}
|
|
1838
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
1839
|
+
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");
|
|
1840
|
+
}
|
|
1841
|
+
keyword$1.validSchemaType = validSchemaType;
|
|
1842
|
+
function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
|
|
1843
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
1844
|
+
throw new Error("ajv implementation error");
|
|
1845
|
+
}
|
|
1846
|
+
const deps = def2.dependencies;
|
|
1847
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
1848
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
1849
|
+
}
|
|
1850
|
+
if (def2.validateSchema) {
|
|
1851
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
1852
|
+
if (!valid) {
|
|
1853
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
|
|
1854
|
+
if (opts.validateSchema === "log")
|
|
1855
|
+
self2.logger.error(msg);
|
|
1856
|
+
else
|
|
1857
|
+
throw new Error(msg);
|
|
1881
1858
|
}
|
|
1882
1859
|
}
|
|
1883
|
-
keyword$1.validateKeywordUsage = validateKeywordUsage;
|
|
1884
|
-
return keyword$1;
|
|
1885
1860
|
}
|
|
1861
|
+
keyword$1.validateKeywordUsage = validateKeywordUsage;
|
|
1886
1862
|
var subschema = {};
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
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
|
-
};
|
|
1863
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
1864
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
1865
|
+
const codegen_1$o = codegen;
|
|
1866
|
+
const util_1$n = util$7;
|
|
1867
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
1868
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
1869
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
1870
|
+
}
|
|
1871
|
+
if (keyword2 !== void 0) {
|
|
1872
|
+
const sch = it.schema[keyword2];
|
|
1873
|
+
return schemaProp === void 0 ? {
|
|
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"');
|
|
1921
1886
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
subschema2.
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1887
|
+
return {
|
|
1888
|
+
schema,
|
|
1889
|
+
schemaPath,
|
|
1890
|
+
topSchemaRef,
|
|
1891
|
+
errSchemaPath
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
1895
|
+
}
|
|
1896
|
+
subschema.getSubschema = getSubschema;
|
|
1897
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
|
|
1898
|
+
if (data2 !== void 0 && dataProp !== void 0) {
|
|
1899
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
1900
|
+
}
|
|
1901
|
+
const { gen } = it;
|
|
1902
|
+
if (dataProp !== void 0) {
|
|
1903
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
1904
|
+
const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
|
|
1905
|
+
dataContextProps(nextData);
|
|
1906
|
+
subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$n.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
1907
|
+
subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
|
|
1908
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
1909
|
+
}
|
|
1910
|
+
if (data2 !== void 0) {
|
|
1911
|
+
const nextData = data2 instanceof codegen_1$o.Name ? data2 : gen.let("data", data2, true);
|
|
1912
|
+
dataContextProps(nextData);
|
|
1913
|
+
if (propertyName !== void 0)
|
|
1914
|
+
subschema2.propertyName = propertyName;
|
|
1915
|
+
}
|
|
1916
|
+
if (dataTypes)
|
|
1917
|
+
subschema2.dataTypes = dataTypes;
|
|
1918
|
+
function dataContextProps(_nextData) {
|
|
1919
|
+
subschema2.data = _nextData;
|
|
1920
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
1921
|
+
subschema2.dataTypes = [];
|
|
1922
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
1923
|
+
subschema2.parentData = it.data;
|
|
1924
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
1928
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
1929
|
+
if (compositeRule !== void 0)
|
|
1930
|
+
subschema2.compositeRule = compositeRule;
|
|
1931
|
+
if (createErrors !== void 0)
|
|
1932
|
+
subschema2.createErrors = createErrors;
|
|
1933
|
+
if (allErrors !== void 0)
|
|
1934
|
+
subschema2.allErrors = allErrors;
|
|
1935
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
1936
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
1937
|
+
}
|
|
1938
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
1969
1939
|
var resolve$6 = {};
|
|
1970
1940
|
var fastDeepEqual = function equal(a, b) {
|
|
1971
1941
|
if (a === b) return true;
|
|
@@ -2080,7 +2050,7 @@ function escapeJsonPtr$1(str) {
|
|
|
2080
2050
|
var jsonSchemaTraverseExports$1 = jsonSchemaTraverse$1.exports;
|
|
2081
2051
|
Object.defineProperty(resolve$6, "__esModule", { value: true });
|
|
2082
2052
|
resolve$6.getSchemaRefs = resolve$6.resolveUrl = resolve$6.normalizeId = resolve$6._getFullPath = resolve$6.getFullPath = resolve$6.inlineRef = void 0;
|
|
2083
|
-
const util_1$
|
|
2053
|
+
const util_1$m = util$7;
|
|
2084
2054
|
const equal$5 = fastDeepEqual;
|
|
2085
2055
|
const traverse$2 = jsonSchemaTraverseExports$1;
|
|
2086
2056
|
const SIMPLE_INLINED$1 = /* @__PURE__ */ new Set([
|
|
@@ -2139,7 +2109,7 @@ function countKeys$1(schema) {
|
|
|
2139
2109
|
if (SIMPLE_INLINED$1.has(key))
|
|
2140
2110
|
continue;
|
|
2141
2111
|
if (typeof schema[key] == "object") {
|
|
2142
|
-
(0, util_1$
|
|
2112
|
+
(0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
|
|
2143
2113
|
}
|
|
2144
2114
|
if (count === Infinity)
|
|
2145
2115
|
return Infinity;
|
|
@@ -2227,512 +2197,506 @@ function getSchemaRefs(schema, baseId) {
|
|
|
2227
2197
|
}
|
|
2228
2198
|
}
|
|
2229
2199
|
resolve$6.getSchemaRefs = getSchemaRefs;
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
checkKeywords(it);
|
|
2251
|
-
if (schemaCxtHasRules(it)) {
|
|
2252
|
-
topSchemaObjCode(it);
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2200
|
+
Object.defineProperty(validate$2, "__esModule", { value: true });
|
|
2201
|
+
validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
|
|
2202
|
+
const boolSchema_1 = boolSchema;
|
|
2203
|
+
const dataType_1$1 = dataType;
|
|
2204
|
+
const applicability_1 = applicability;
|
|
2205
|
+
const dataType_2 = dataType;
|
|
2206
|
+
const defaults_1 = defaults;
|
|
2207
|
+
const keyword_1 = keyword$1;
|
|
2208
|
+
const subschema_1 = subschema;
|
|
2209
|
+
const codegen_1$n = codegen;
|
|
2210
|
+
const names_1$3 = names$1;
|
|
2211
|
+
const resolve_1$3 = resolve$6;
|
|
2212
|
+
const util_1$l = util$7;
|
|
2213
|
+
const errors_1 = errors;
|
|
2214
|
+
function validateFunctionCode(it) {
|
|
2215
|
+
if (isSchemaObj(it)) {
|
|
2216
|
+
checkKeywords(it);
|
|
2217
|
+
if (schemaCxtHasRules(it)) {
|
|
2218
|
+
topSchemaObjCode(it);
|
|
2219
|
+
return;
|
|
2255
2220
|
}
|
|
2256
|
-
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2257
2221
|
}
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
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._)`{}`);
|
|
2222
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2223
|
+
}
|
|
2224
|
+
validate$2.validateFunctionCode = validateFunctionCode;
|
|
2225
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
2226
|
+
if (opts.code.es5) {
|
|
2227
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
|
|
2228
|
+
gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
2229
|
+
destructureValCxtES5(gen, opts);
|
|
2230
|
+
gen.code(body);
|
|
2288
2231
|
});
|
|
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
|
+
}
|
|
2289
2288
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2289
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
2290
|
+
}
|
|
2291
|
+
function schemaCxtHasRules({ schema, self: self2 }) {
|
|
2292
|
+
if (typeof schema == "boolean")
|
|
2293
|
+
return !schema;
|
|
2294
|
+
for (const key in schema)
|
|
2295
|
+
if (self2.RULES.all[key])
|
|
2296
|
+
return true;
|
|
2297
|
+
return false;
|
|
2298
|
+
}
|
|
2299
|
+
function isSchemaObj(it) {
|
|
2300
|
+
return typeof it.schema != "boolean";
|
|
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));
|
|
2303
2376
|
return;
|
|
2304
2377
|
}
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
if (
|
|
2319
|
-
|
|
2320
|
-
|
|
2378
|
+
if (!opts.jtd)
|
|
2379
|
+
checkStrictTypes(it, types2);
|
|
2380
|
+
gen.block(() => {
|
|
2381
|
+
for (const group of RULES.rules)
|
|
2382
|
+
groupKeywords(group);
|
|
2383
|
+
groupKeywords(RULES.post);
|
|
2384
|
+
});
|
|
2385
|
+
function groupKeywords(group) {
|
|
2386
|
+
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
2387
|
+
return;
|
|
2388
|
+
if (group.type) {
|
|
2389
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
|
|
2390
|
+
iterateKeywords(it, group);
|
|
2391
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
2392
|
+
gen.else();
|
|
2393
|
+
(0, dataType_2.reportTypeError)(it);
|
|
2321
2394
|
}
|
|
2395
|
+
gen.endIf();
|
|
2396
|
+
} else {
|
|
2397
|
+
iterateKeywords(it, group);
|
|
2322
2398
|
}
|
|
2323
|
-
|
|
2399
|
+
if (!allErrors)
|
|
2400
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
2324
2401
|
}
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2402
|
+
}
|
|
2403
|
+
function iterateKeywords(it, group) {
|
|
2404
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
2405
|
+
if (useDefaults)
|
|
2406
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
2407
|
+
gen.block(() => {
|
|
2408
|
+
for (const rule of group.rules) {
|
|
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;
|
|
2332
2429
|
}
|
|
2333
|
-
|
|
2334
|
-
|
|
2430
|
+
types2.forEach((t) => {
|
|
2431
|
+
if (!includesType(it.dataTypes, t)) {
|
|
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
|
+
}
|
|
2335
2501
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
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}`);
|
|
2502
|
+
result(condition, successAction, failAction) {
|
|
2503
|
+
this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
|
|
2345
2504
|
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2505
|
+
failResult(condition, successAction, failAction) {
|
|
2506
|
+
this.gen.if(condition);
|
|
2507
|
+
if (failAction)
|
|
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
|
+
}
|
|
2349
2522
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
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);
|
|
2523
|
+
pass(condition, failAction) {
|
|
2524
|
+
this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
|
|
2356
2525
|
}
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2526
|
+
fail(condition) {
|
|
2527
|
+
if (condition === void 0) {
|
|
2528
|
+
this.error();
|
|
2529
|
+
if (!this.allErrors)
|
|
2530
|
+
this.gen.if(false);
|
|
2531
|
+
return;
|
|
2361
2532
|
}
|
|
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)})`);
|
|
2362
2545
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2546
|
+
error(append, errorParams, errorPaths) {
|
|
2547
|
+
if (errorParams) {
|
|
2548
|
+
this.setParams(errorParams);
|
|
2549
|
+
this._error(append, errorPaths);
|
|
2550
|
+
this.setParams({});
|
|
2551
|
+
return;
|
|
2367
2552
|
}
|
|
2553
|
+
this._error(append, errorPaths);
|
|
2368
2554
|
}
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
if (schId)
|
|
2372
|
-
it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
2555
|
+
_error(append, errorPaths) {
|
|
2556
|
+
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
2373
2557
|
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
throw new Error("async schema in sync schema");
|
|
2558
|
+
$dataError() {
|
|
2559
|
+
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
2377
2560
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
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
|
-
}
|
|
2561
|
+
reset() {
|
|
2562
|
+
if (this.errsCount === void 0)
|
|
2563
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
2564
|
+
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
2387
2565
|
}
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
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
|
-
}
|
|
2566
|
+
ok(cond) {
|
|
2567
|
+
if (!this.allErrors)
|
|
2568
|
+
this.gen.if(cond);
|
|
2436
2569
|
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
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
|
-
}
|
|
2447
|
-
});
|
|
2570
|
+
setParams(obj, assign) {
|
|
2571
|
+
if (assign)
|
|
2572
|
+
Object.assign(this.params, obj);
|
|
2573
|
+
else
|
|
2574
|
+
this.params = obj;
|
|
2448
2575
|
}
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
checkMultipleTypes(it, types2);
|
|
2455
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
2576
|
+
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
2577
|
+
this.gen.block(() => {
|
|
2578
|
+
this.check$data(valid, $dataValid);
|
|
2579
|
+
codeBlock();
|
|
2580
|
+
});
|
|
2456
2581
|
}
|
|
2457
|
-
|
|
2458
|
-
if (!
|
|
2459
|
-
return;
|
|
2460
|
-
if (!it.dataTypes.length) {
|
|
2461
|
-
it.dataTypes = types2;
|
|
2582
|
+
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
2583
|
+
if (!this.$data)
|
|
2462
2584
|
return;
|
|
2585
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
2586
|
+
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
2587
|
+
if (valid !== codegen_1$n.nil)
|
|
2588
|
+
gen.assign(valid, true);
|
|
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);
|
|
2463
2594
|
}
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
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);
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
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();
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
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;
|
|
2595
|
+
gen.else();
|
|
2596
|
+
}
|
|
2597
|
+
invalid$data() {
|
|
2598
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
2599
|
+
return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
|
|
2600
|
+
function wrong$DataType() {
|
|
2601
|
+
if (schemaType.length) {
|
|
2602
|
+
if (!(schemaCode instanceof codegen_1$n.Name))
|
|
2603
|
+
throw new Error("ajv implementation error");
|
|
2604
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
2605
|
+
return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
2566
2606
|
}
|
|
2567
|
-
|
|
2568
|
-
this.error();
|
|
2569
|
-
if (this.allErrors)
|
|
2570
|
-
this.gen.endIf();
|
|
2571
|
-
else
|
|
2572
|
-
this.gen.else();
|
|
2607
|
+
return codegen_1$n.nil;
|
|
2573
2608
|
}
|
|
2574
|
-
|
|
2575
|
-
if (
|
|
2576
|
-
|
|
2577
|
-
|
|
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;
|
|
2609
|
+
function invalid$DataSchema() {
|
|
2610
|
+
if (def2.validateSchema) {
|
|
2611
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
2612
|
+
return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
|
|
2586
2613
|
}
|
|
2587
|
-
|
|
2588
|
-
}
|
|
2589
|
-
_error(append, errorPaths) {
|
|
2590
|
-
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
2591
|
-
}
|
|
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);
|
|
2614
|
+
return codegen_1$n.nil;
|
|
2603
2615
|
}
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2616
|
+
}
|
|
2617
|
+
subschema(appl, valid) {
|
|
2618
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
2619
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
2620
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
2621
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
2622
|
+
subschemaCode(nextContext, valid);
|
|
2623
|
+
return nextContext;
|
|
2624
|
+
}
|
|
2625
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
2626
|
+
const { it, gen } = this;
|
|
2627
|
+
if (!it.opts.unevaluated)
|
|
2628
|
+
return;
|
|
2629
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
2630
|
+
it.props = util_1$l.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
2609
2631
|
}
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
this.check$data(valid, $dataValid);
|
|
2613
|
-
codeBlock();
|
|
2614
|
-
});
|
|
2632
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
2633
|
+
it.items = util_1$l.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
2615
2634
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
gen.if(
|
|
2621
|
-
|
|
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
|
-
}
|
|
2635
|
+
}
|
|
2636
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
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;
|
|
2669
2641
|
}
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
validate$2.KeywordCxt = KeywordCxt;
|
|
2645
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
2646
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
2647
|
+
if ("code" in def2) {
|
|
2648
|
+
def2.code(cxt, ruleType);
|
|
2649
|
+
} else if (cxt.$data && def2.validate) {
|
|
2650
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2651
|
+
} else if ("macro" in def2) {
|
|
2652
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
2653
|
+
} else if (def2.compile || def2.validate) {
|
|
2654
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
const JSON_POINTER$2 = /^\/(?:[^~]|~0|~1)*$/;
|
|
2658
|
+
const RELATIVE_JSON_POINTER$2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2659
|
+
function getData$1($data, { dataLevel, dataNames, dataPathArr }) {
|
|
2660
|
+
let jsonPointer;
|
|
2661
|
+
let data2;
|
|
2662
|
+
if ($data === "")
|
|
2663
|
+
return names_1$3.default.rootData;
|
|
2664
|
+
if ($data[0] === "/") {
|
|
2665
|
+
if (!JSON_POINTER$2.test($data))
|
|
2666
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2667
|
+
jsonPointer = $data;
|
|
2668
|
+
data2 = names_1$3.default.rootData;
|
|
2669
|
+
} else {
|
|
2670
|
+
const matches = RELATIVE_JSON_POINTER$2.exec($data);
|
|
2671
|
+
if (!matches)
|
|
2672
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2673
|
+
const up = +matches[1];
|
|
2674
|
+
jsonPointer = matches[2];
|
|
2675
|
+
if (jsonPointer === "#") {
|
|
2676
|
+
if (up >= dataLevel)
|
|
2677
|
+
throw new Error(errorMsg("property/index", up));
|
|
2678
|
+
return dataPathArr[dataLevel - up];
|
|
2679
|
+
}
|
|
2680
|
+
if (up > dataLevel)
|
|
2681
|
+
throw new Error(errorMsg("data", up));
|
|
2682
|
+
data2 = dataNames[dataLevel - up];
|
|
2683
|
+
if (!jsonPointer)
|
|
2684
|
+
return data2;
|
|
2685
|
+
}
|
|
2686
|
+
let expr = data2;
|
|
2687
|
+
const segments = jsonPointer.split("/");
|
|
2688
|
+
for (const segment of segments) {
|
|
2689
|
+
if (segment) {
|
|
2690
|
+
data2 = (0, codegen_1$n._)`${data2}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(segment))}`;
|
|
2691
|
+
expr = (0, codegen_1$n._)`${expr} && ${data2}`;
|
|
2676
2692
|
}
|
|
2677
2693
|
}
|
|
2678
|
-
|
|
2679
|
-
function
|
|
2680
|
-
|
|
2681
|
-
|
|
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;
|
|
2694
|
+
return expr;
|
|
2695
|
+
function errorMsg(pointerType, up) {
|
|
2696
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
2697
|
+
}
|
|
2735
2698
|
}
|
|
2699
|
+
validate$2.getData = getData$1;
|
|
2736
2700
|
var validation_error = {};
|
|
2737
2701
|
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
2738
2702
|
let ValidationError$2 = class ValidationError extends Error {
|
|
@@ -2762,7 +2726,7 @@ const validation_error_1 = validation_error;
|
|
|
2762
2726
|
const names_1$2 = names$1;
|
|
2763
2727
|
const resolve_1$1 = resolve$6;
|
|
2764
2728
|
const util_1$k = util$7;
|
|
2765
|
-
const validate_1$1 =
|
|
2729
|
+
const validate_1$1 = validate$2;
|
|
2766
2730
|
class SchemaEnv {
|
|
2767
2731
|
constructor(env) {
|
|
2768
2732
|
var _a;
|
|
@@ -3649,7 +3613,7 @@ uri$2.default = uri$1;
|
|
|
3649
3613
|
(function(exports) {
|
|
3650
3614
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3651
3615
|
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
|
3652
|
-
var validate_12 =
|
|
3616
|
+
var validate_12 = validate$2;
|
|
3653
3617
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
3654
3618
|
return validate_12.KeywordCxt;
|
|
3655
3619
|
} });
|
|
@@ -4267,7 +4231,7 @@ var ref$1 = {};
|
|
|
4267
4231
|
Object.defineProperty(ref$1, "__esModule", { value: true });
|
|
4268
4232
|
ref$1.callRef = ref$1.getValidate = void 0;
|
|
4269
4233
|
const ref_error_1$1 = ref_error;
|
|
4270
|
-
const code_1$8 =
|
|
4234
|
+
const code_1$8 = code;
|
|
4271
4235
|
const codegen_1$l = codegen;
|
|
4272
4236
|
const names_1$1 = names$1;
|
|
4273
4237
|
const compile_1$2 = compile$2;
|
|
@@ -4490,7 +4454,7 @@ const def$o = {
|
|
|
4490
4454
|
limitLength.default = def$o;
|
|
4491
4455
|
var pattern$1 = {};
|
|
4492
4456
|
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4493
|
-
const code_1$7 =
|
|
4457
|
+
const code_1$7 = code;
|
|
4494
4458
|
const codegen_1$h = codegen;
|
|
4495
4459
|
const error$f = {
|
|
4496
4460
|
message: ({ schemaCode }) => (0, codegen_1$h.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4535,7 +4499,7 @@ const def$m = {
|
|
|
4535
4499
|
limitProperties.default = def$m;
|
|
4536
4500
|
var required$2 = {};
|
|
4537
4501
|
Object.defineProperty(required$2, "__esModule", { value: true });
|
|
4538
|
-
const code_1$6 =
|
|
4502
|
+
const code_1$6 = code;
|
|
4539
4503
|
const codegen_1$f = codegen;
|
|
4540
4504
|
const util_1$h = util$7;
|
|
4541
4505
|
const error$d = {
|
|
@@ -4849,7 +4813,7 @@ Object.defineProperty(items$1, "__esModule", { value: true });
|
|
|
4849
4813
|
items$1.validateTuple = void 0;
|
|
4850
4814
|
const codegen_1$9 = codegen;
|
|
4851
4815
|
const util_1$c = util$7;
|
|
4852
|
-
const code_1$5 =
|
|
4816
|
+
const code_1$5 = code;
|
|
4853
4817
|
const def$f = {
|
|
4854
4818
|
keyword: "items",
|
|
4855
4819
|
type: "array",
|
|
@@ -4909,7 +4873,7 @@ var items2020 = {};
|
|
|
4909
4873
|
Object.defineProperty(items2020, "__esModule", { value: true });
|
|
4910
4874
|
const codegen_1$8 = codegen;
|
|
4911
4875
|
const util_1$b = util$7;
|
|
4912
|
-
const code_1$4 =
|
|
4876
|
+
const code_1$4 = code;
|
|
4913
4877
|
const additionalItems_1$1 = additionalItems;
|
|
4914
4878
|
const error$7 = {
|
|
4915
4879
|
message: ({ params: { len } }) => (0, codegen_1$8.str)`must NOT have more than ${len} items`,
|
|
@@ -5028,7 +4992,7 @@ var dependencies$1 = {};
|
|
|
5028
4992
|
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
|
|
5029
4993
|
const codegen_12 = codegen;
|
|
5030
4994
|
const util_12 = util$7;
|
|
5031
|
-
const code_12 =
|
|
4995
|
+
const code_12 = code;
|
|
5032
4996
|
exports.error = {
|
|
5033
4997
|
message: ({ params: { property, depsCount, deps } }) => {
|
|
5034
4998
|
const property_ies = depsCount === 1 ? "property" : "properties";
|
|
@@ -5151,7 +5115,7 @@ const def$b = {
|
|
|
5151
5115
|
propertyNames$1.default = def$b;
|
|
5152
5116
|
var additionalProperties$1 = {};
|
|
5153
5117
|
Object.defineProperty(additionalProperties$1, "__esModule", { value: true });
|
|
5154
|
-
const code_1$3 =
|
|
5118
|
+
const code_1$3 = code;
|
|
5155
5119
|
const codegen_1$5 = codegen;
|
|
5156
5120
|
const names_1 = names$1;
|
|
5157
5121
|
const util_1$8 = util$7;
|
|
@@ -5251,8 +5215,8 @@ const def$a = {
|
|
|
5251
5215
|
additionalProperties$1.default = def$a;
|
|
5252
5216
|
var properties$4 = {};
|
|
5253
5217
|
Object.defineProperty(properties$4, "__esModule", { value: true });
|
|
5254
|
-
const validate_1 =
|
|
5255
|
-
const code_1$2 =
|
|
5218
|
+
const validate_1 = validate$2;
|
|
5219
|
+
const code_1$2 = code;
|
|
5256
5220
|
const util_1$7 = util$7;
|
|
5257
5221
|
const additionalProperties_1$1 = additionalProperties$1;
|
|
5258
5222
|
const def$9 = {
|
|
@@ -5303,7 +5267,7 @@ const def$9 = {
|
|
|
5303
5267
|
properties$4.default = def$9;
|
|
5304
5268
|
var patternProperties = {};
|
|
5305
5269
|
Object.defineProperty(patternProperties, "__esModule", { value: true });
|
|
5306
|
-
const code_1$1 =
|
|
5270
|
+
const code_1$1 = code;
|
|
5307
5271
|
const codegen_1$4 = codegen;
|
|
5308
5272
|
const util_1$6 = util$7;
|
|
5309
5273
|
const util_2 = util$7;
|
|
@@ -5396,7 +5360,7 @@ const def$7 = {
|
|
|
5396
5360
|
not$1.default = def$7;
|
|
5397
5361
|
var anyOf$1 = {};
|
|
5398
5362
|
Object.defineProperty(anyOf$1, "__esModule", { value: true });
|
|
5399
|
-
const code_1 =
|
|
5363
|
+
const code_1 = code;
|
|
5400
5364
|
const def$6 = {
|
|
5401
5365
|
keyword: "anyOf",
|
|
5402
5366
|
schemaType: "array",
|
|
@@ -6102,7 +6066,7 @@ const require$$3 = {
|
|
|
6102
6066
|
module.exports.Ajv = Ajv2;
|
|
6103
6067
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6104
6068
|
exports.default = Ajv2;
|
|
6105
|
-
var validate_12 =
|
|
6069
|
+
var validate_12 = validate$2;
|
|
6106
6070
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
6107
6071
|
return validate_12.KeywordCxt;
|
|
6108
6072
|
} });
|
|
@@ -13578,7 +13542,7 @@ function compile$1(schema, root, localRefs, baseId) {
|
|
|
13578
13542
|
util: util$2,
|
|
13579
13543
|
resolve: resolve$1,
|
|
13580
13544
|
resolveRef: resolveRef2,
|
|
13581
|
-
usePattern,
|
|
13545
|
+
usePattern: usePattern2,
|
|
13582
13546
|
useDefault,
|
|
13583
13547
|
useCustomRule,
|
|
13584
13548
|
opts,
|
|
@@ -13683,7 +13647,7 @@ function compile$1(schema, root, localRefs, baseId) {
|
|
|
13683
13647
|
function resolvedRef(refVal2, code2) {
|
|
13684
13648
|
return typeof refVal2 == "object" || typeof refVal2 == "boolean" ? { code: code2, schema: refVal2, inline: true } : { code: code2, $async: refVal2 && !!refVal2.$async };
|
|
13685
13649
|
}
|
|
13686
|
-
function
|
|
13650
|
+
function usePattern2(regexStr) {
|
|
13687
13651
|
var index = patternsHash[regexStr];
|
|
13688
13652
|
if (index === void 0) {
|
|
13689
13653
|
index = patternsHash[regexStr] = patterns.length;
|
|
@@ -22654,25 +22618,14 @@ class WebMcpClient {
|
|
|
22654
22618
|
await this.client.connect(this.transport);
|
|
22655
22619
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|
|
22656
22620
|
}
|
|
22657
|
-
const { url, token, sessionId,
|
|
22621
|
+
const { url, token, sessionId, type: type2, agent, onError } = options;
|
|
22658
22622
|
if (agent === true) {
|
|
22659
|
-
const proxyOptions = { client: this.client, url, token, sessionId
|
|
22660
|
-
let reconnect = false;
|
|
22623
|
+
const proxyOptions = { client: this.client, url, token, sessionId };
|
|
22661
22624
|
let response;
|
|
22662
22625
|
const connectProxy = async () => {
|
|
22663
22626
|
const { transport: transport2, sessionId: sessionId2 } = type2 === "sse" ? await createSseProxy(proxyOptions) : type2 === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
|
|
22664
22627
|
transport2.onerror = async (error2) => {
|
|
22665
22628
|
onError == null ? void 0 : onError(error2);
|
|
22666
|
-
if (error2.message === "Unauthorized" && !reconnect) {
|
|
22667
|
-
if (typeof onUnauthorized === "function") {
|
|
22668
|
-
await onUnauthorized(connectProxy);
|
|
22669
|
-
} else {
|
|
22670
|
-
reconnect = true;
|
|
22671
|
-
await connectProxy();
|
|
22672
|
-
reconnect = false;
|
|
22673
|
-
await (onReconnect == null ? void 0 : onReconnect());
|
|
22674
|
-
}
|
|
22675
|
-
}
|
|
22676
22629
|
};
|
|
22677
22630
|
response = { transport: transport2, sessionId: sessionId2 };
|
|
22678
22631
|
};
|
|
@@ -22686,14 +22639,9 @@ class WebMcpClient {
|
|
|
22686
22639
|
await this.client.connect(transport);
|
|
22687
22640
|
}
|
|
22688
22641
|
if (type2 === "sse") {
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
} else {
|
|
22693
|
-
const opts = sseOptions(token, sessionId);
|
|
22694
|
-
transport = new SSEClientTransport(endpoint, opts);
|
|
22695
|
-
await this.client.connect(transport);
|
|
22696
|
-
}
|
|
22642
|
+
const opts = sseOptions(token, sessionId);
|
|
22643
|
+
transport = new SSEClientTransport(endpoint, opts);
|
|
22644
|
+
await this.client.connect(transport);
|
|
22697
22645
|
}
|
|
22698
22646
|
if (type2 === "socket") {
|
|
22699
22647
|
transport = new WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
|
|
@@ -22701,14 +22649,9 @@ class WebMcpClient {
|
|
|
22701
22649
|
await this.client.connect(transport);
|
|
22702
22650
|
}
|
|
22703
22651
|
if (typeof transport === "undefined") {
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
} else {
|
|
22708
|
-
const opts = streamOptions(token, sessionId);
|
|
22709
|
-
transport = new StreamableHTTPClientTransport(endpoint, opts);
|
|
22710
|
-
await this.client.connect(transport);
|
|
22711
|
-
}
|
|
22652
|
+
const opts = streamOptions(token, sessionId);
|
|
22653
|
+
transport = new StreamableHTTPClientTransport(endpoint, opts);
|
|
22654
|
+
await this.client.connect(transport);
|
|
22712
22655
|
}
|
|
22713
22656
|
this.transport = transport;
|
|
22714
22657
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|