@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
package/dist/webmcp-full.dev.js
CHANGED
|
@@ -1021,8 +1021,8 @@
|
|
|
1021
1021
|
var util$7 = {};
|
|
1022
1022
|
Object.defineProperty(util$7, "__esModule", { value: true });
|
|
1023
1023
|
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;
|
|
1024
|
-
const codegen_1$
|
|
1025
|
-
const code_1$
|
|
1024
|
+
const codegen_1$v = codegen;
|
|
1025
|
+
const code_1$a = code$1;
|
|
1026
1026
|
function toHash$2(arr) {
|
|
1027
1027
|
const hash = {};
|
|
1028
1028
|
for (const item of arr)
|
|
@@ -1075,9 +1075,9 @@
|
|
|
1075
1075
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
1076
1076
|
return schema;
|
|
1077
1077
|
if (typeof schema == "string")
|
|
1078
|
-
return (0, codegen_1$
|
|
1078
|
+
return (0, codegen_1$v._)`${schema}`;
|
|
1079
1079
|
}
|
|
1080
|
-
return (0, codegen_1$
|
|
1080
|
+
return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
|
|
1081
1081
|
}
|
|
1082
1082
|
util$7.schemaRefOrVal = schemaRefOrVal;
|
|
1083
1083
|
function unescapeFragment$1(str) {
|
|
@@ -1109,20 +1109,20 @@
|
|
|
1109
1109
|
util$7.eachItem = eachItem;
|
|
1110
1110
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
|
|
1111
1111
|
return (gen, from, to, toName) => {
|
|
1112
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
1113
|
-
return toName === codegen_1$
|
|
1112
|
+
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);
|
|
1113
|
+
return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
|
|
1114
1114
|
};
|
|
1115
1115
|
}
|
|
1116
1116
|
util$7.mergeEvaluated = {
|
|
1117
1117
|
props: makeMergeEvaluated({
|
|
1118
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
1119
|
-
gen.if((0, codegen_1$
|
|
1118
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
|
|
1119
|
+
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})`));
|
|
1120
1120
|
}),
|
|
1121
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
1121
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
|
|
1122
1122
|
if (from === true) {
|
|
1123
1123
|
gen.assign(to, true);
|
|
1124
1124
|
} else {
|
|
1125
|
-
gen.assign(to, (0, codegen_1$
|
|
1125
|
+
gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
|
|
1126
1126
|
setEvaluated(gen, to, from);
|
|
1127
1127
|
}
|
|
1128
1128
|
}),
|
|
@@ -1130,8 +1130,8 @@
|
|
|
1130
1130
|
resultToName: evaluatedPropsToName
|
|
1131
1131
|
}),
|
|
1132
1132
|
items: makeMergeEvaluated({
|
|
1133
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
1134
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
1133
|
+
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}`)),
|
|
1134
|
+
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}`)),
|
|
1135
1135
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
1136
1136
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
1137
1137
|
})
|
|
@@ -1139,21 +1139,21 @@
|
|
|
1139
1139
|
function evaluatedPropsToName(gen, ps) {
|
|
1140
1140
|
if (ps === true)
|
|
1141
1141
|
return gen.var("props", true);
|
|
1142
|
-
const props = gen.var("props", (0, codegen_1$
|
|
1142
|
+
const props = gen.var("props", (0, codegen_1$v._)`{}`);
|
|
1143
1143
|
if (ps !== void 0)
|
|
1144
1144
|
setEvaluated(gen, props, ps);
|
|
1145
1145
|
return props;
|
|
1146
1146
|
}
|
|
1147
1147
|
util$7.evaluatedPropsToName = evaluatedPropsToName;
|
|
1148
1148
|
function setEvaluated(gen, props, ps) {
|
|
1149
|
-
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$
|
|
1149
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
|
|
1150
1150
|
}
|
|
1151
1151
|
util$7.setEvaluated = setEvaluated;
|
|
1152
1152
|
const snippets = {};
|
|
1153
1153
|
function useFunc(gen, f) {
|
|
1154
1154
|
return gen.scopeValue("func", {
|
|
1155
1155
|
ref: f,
|
|
1156
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
1156
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
|
|
1157
1157
|
});
|
|
1158
1158
|
}
|
|
1159
1159
|
util$7.useFunc = useFunc;
|
|
@@ -1163,11 +1163,11 @@
|
|
|
1163
1163
|
Type2[Type2["Str"] = 1] = "Str";
|
|
1164
1164
|
})(Type || (util$7.Type = Type = {}));
|
|
1165
1165
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
1166
|
-
if (dataProp instanceof codegen_1$
|
|
1166
|
+
if (dataProp instanceof codegen_1$v.Name) {
|
|
1167
1167
|
const isNumber = dataPropType === Type.Num;
|
|
1168
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
1168
|
+
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")`;
|
|
1169
1169
|
}
|
|
1170
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
1170
|
+
return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer$1(dataProp);
|
|
1171
1171
|
}
|
|
1172
1172
|
util$7.getErrorPath = getErrorPath;
|
|
1173
1173
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -1181,35 +1181,35 @@
|
|
|
1181
1181
|
util$7.checkStrictMode = checkStrictMode;
|
|
1182
1182
|
var names$1 = {};
|
|
1183
1183
|
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
1184
|
-
const codegen_1$
|
|
1184
|
+
const codegen_1$u = codegen;
|
|
1185
1185
|
const names = {
|
|
1186
1186
|
// validation function arguments
|
|
1187
|
-
data: new codegen_1$
|
|
1187
|
+
data: new codegen_1$u.Name("data"),
|
|
1188
1188
|
// data passed to validation function
|
|
1189
1189
|
// args passed from referencing schema
|
|
1190
|
-
valCxt: new codegen_1$
|
|
1190
|
+
valCxt: new codegen_1$u.Name("valCxt"),
|
|
1191
1191
|
// validation/data context - should not be used directly, it is destructured to the names below
|
|
1192
|
-
instancePath: new codegen_1$
|
|
1193
|
-
parentData: new codegen_1$
|
|
1194
|
-
parentDataProperty: new codegen_1$
|
|
1195
|
-
rootData: new codegen_1$
|
|
1192
|
+
instancePath: new codegen_1$u.Name("instancePath"),
|
|
1193
|
+
parentData: new codegen_1$u.Name("parentData"),
|
|
1194
|
+
parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
|
|
1195
|
+
rootData: new codegen_1$u.Name("rootData"),
|
|
1196
1196
|
// root data - same as the data passed to the first/top validation function
|
|
1197
|
-
dynamicAnchors: new codegen_1$
|
|
1197
|
+
dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
|
|
1198
1198
|
// used to support recursiveRef and dynamicRef
|
|
1199
1199
|
// function scoped variables
|
|
1200
|
-
vErrors: new codegen_1$
|
|
1200
|
+
vErrors: new codegen_1$u.Name("vErrors"),
|
|
1201
1201
|
// null or array of validation errors
|
|
1202
|
-
errors: new codegen_1$
|
|
1202
|
+
errors: new codegen_1$u.Name("errors"),
|
|
1203
1203
|
// counter of validation errors
|
|
1204
|
-
this: new codegen_1$
|
|
1204
|
+
this: new codegen_1$u.Name("this"),
|
|
1205
1205
|
// "globals"
|
|
1206
|
-
self: new codegen_1$
|
|
1207
|
-
scope: new codegen_1$
|
|
1206
|
+
self: new codegen_1$u.Name("self"),
|
|
1207
|
+
scope: new codegen_1$u.Name("scope"),
|
|
1208
1208
|
// JTD serialize/parse name for JSON string and position
|
|
1209
|
-
json: new codegen_1$
|
|
1210
|
-
jsonPos: new codegen_1$
|
|
1211
|
-
jsonLen: new codegen_1$
|
|
1212
|
-
jsonPart: new codegen_1$
|
|
1209
|
+
json: new codegen_1$u.Name("json"),
|
|
1210
|
+
jsonPos: new codegen_1$u.Name("jsonPos"),
|
|
1211
|
+
jsonLen: new codegen_1$u.Name("jsonLen"),
|
|
1212
|
+
jsonPart: new codegen_1$u.Name("jsonPart")
|
|
1213
1213
|
};
|
|
1214
1214
|
names$1.default = names;
|
|
1215
1215
|
(function(exports3) {
|
|
@@ -1329,55 +1329,49 @@
|
|
|
1329
1329
|
keyValues.push([E.propertyName, propertyName]);
|
|
1330
1330
|
}
|
|
1331
1331
|
})(errors);
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
gen.return(names_12.default.data);
|
|
1350
|
-
} else {
|
|
1351
|
-
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
1352
|
-
gen.return(true);
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
1356
|
-
function boolOrEmptySchema(it, valid) {
|
|
1357
|
-
const { gen, schema } = it;
|
|
1358
|
-
if (schema === false) {
|
|
1359
|
-
gen.var(valid, false);
|
|
1360
|
-
falseSchemaError(it);
|
|
1361
|
-
} else {
|
|
1362
|
-
gen.var(valid, true);
|
|
1363
|
-
}
|
|
1332
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
1333
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
1334
|
+
const errors_1$3 = errors;
|
|
1335
|
+
const codegen_1$t = codegen;
|
|
1336
|
+
const names_1$6 = names$1;
|
|
1337
|
+
const boolError = {
|
|
1338
|
+
message: "boolean schema is false"
|
|
1339
|
+
};
|
|
1340
|
+
function topBoolOrEmptySchema(it) {
|
|
1341
|
+
const { gen, schema, validateName } = it;
|
|
1342
|
+
if (schema === false) {
|
|
1343
|
+
falseSchemaError(it, false);
|
|
1344
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
1345
|
+
gen.return(names_1$6.default.data);
|
|
1346
|
+
} else {
|
|
1347
|
+
gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
|
|
1348
|
+
gen.return(true);
|
|
1364
1349
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
schemaValue: false,
|
|
1375
|
-
params: {},
|
|
1376
|
-
it
|
|
1377
|
-
};
|
|
1378
|
-
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
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);
|
|
1379
1359
|
}
|
|
1380
|
-
|
|
1360
|
+
}
|
|
1361
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
1362
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
1363
|
+
const { gen, data: data2 } = it;
|
|
1364
|
+
const cxt = {
|
|
1365
|
+
gen,
|
|
1366
|
+
keyword: "false schema",
|
|
1367
|
+
data: data2,
|
|
1368
|
+
schema: false,
|
|
1369
|
+
schemaCode: false,
|
|
1370
|
+
schemaValue: false,
|
|
1371
|
+
params: {},
|
|
1372
|
+
it
|
|
1373
|
+
};
|
|
1374
|
+
(0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
1381
1375
|
}
|
|
1382
1376
|
var dataType = {};
|
|
1383
1377
|
var rules$2 = {};
|
|
@@ -1425,10 +1419,10 @@
|
|
|
1425
1419
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
1426
1420
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
1427
1421
|
const rules_1 = rules$2;
|
|
1428
|
-
const applicability_1 = applicability;
|
|
1429
|
-
const errors_1 = errors;
|
|
1430
|
-
const codegen_1$
|
|
1431
|
-
const util_1$
|
|
1422
|
+
const applicability_1$1 = applicability;
|
|
1423
|
+
const errors_1$2 = errors;
|
|
1424
|
+
const codegen_1$s = codegen;
|
|
1425
|
+
const util_1$q = util$7;
|
|
1432
1426
|
var DataType;
|
|
1433
1427
|
(function(DataType2) {
|
|
1434
1428
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -1460,7 +1454,7 @@
|
|
|
1460
1454
|
function coerceAndCheckDataType(it, types2) {
|
|
1461
1455
|
const { gen, data: data2, opts } = it;
|
|
1462
1456
|
const coerceTo = coerceToTypes$1(types2, opts.coerceTypes);
|
|
1463
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
1457
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
|
|
1464
1458
|
if (checkTypes) {
|
|
1465
1459
|
const wrongType = checkDataTypes$1(types2, data2, opts.strictNumbers, DataType.Wrong);
|
|
1466
1460
|
gen.if(wrongType, () => {
|
|
@@ -1479,12 +1473,12 @@
|
|
|
1479
1473
|
}
|
|
1480
1474
|
function coerceData(it, types2, coerceTo) {
|
|
1481
1475
|
const { gen, data: data2, opts } = it;
|
|
1482
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
1483
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
1476
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data2}`);
|
|
1477
|
+
const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
|
|
1484
1478
|
if (opts.coerceTypes === "array") {
|
|
1485
|
-
gen.if((0, codegen_1$
|
|
1479
|
+
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)));
|
|
1486
1480
|
}
|
|
1487
|
-
gen.if((0, codegen_1$
|
|
1481
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
|
|
1488
1482
|
for (const t of coerceTo) {
|
|
1489
1483
|
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
|
|
1490
1484
|
coerceSpecificType(t);
|
|
@@ -1493,63 +1487,63 @@
|
|
|
1493
1487
|
gen.else();
|
|
1494
1488
|
reportTypeError(it);
|
|
1495
1489
|
gen.endIf();
|
|
1496
|
-
gen.if((0, codegen_1$
|
|
1490
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
|
|
1497
1491
|
gen.assign(data2, coerced);
|
|
1498
1492
|
assignParentData(it, coerced);
|
|
1499
1493
|
});
|
|
1500
1494
|
function coerceSpecificType(t) {
|
|
1501
1495
|
switch (t) {
|
|
1502
1496
|
case "string":
|
|
1503
|
-
gen.elseIf((0, codegen_1$
|
|
1497
|
+
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._)`""`);
|
|
1504
1498
|
return;
|
|
1505
1499
|
case "number":
|
|
1506
|
-
gen.elseIf((0, codegen_1$
|
|
1507
|
-
|| (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$
|
|
1500
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data2} === null
|
|
1501
|
+
|| (${dataType2} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
|
|
1508
1502
|
return;
|
|
1509
1503
|
case "integer":
|
|
1510
|
-
gen.elseIf((0, codegen_1$
|
|
1511
|
-
|| (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$
|
|
1504
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data2} === null
|
|
1505
|
+
|| (${dataType2} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data2}`);
|
|
1512
1506
|
return;
|
|
1513
1507
|
case "boolean":
|
|
1514
|
-
gen.elseIf((0, codegen_1$
|
|
1508
|
+
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);
|
|
1515
1509
|
return;
|
|
1516
1510
|
case "null":
|
|
1517
|
-
gen.elseIf((0, codegen_1$
|
|
1511
|
+
gen.elseIf((0, codegen_1$s._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
|
|
1518
1512
|
gen.assign(coerced, null);
|
|
1519
1513
|
return;
|
|
1520
1514
|
case "array":
|
|
1521
|
-
gen.elseIf((0, codegen_1$
|
|
1522
|
-
|| ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$
|
|
1515
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
1516
|
+
|| ${dataType2} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1$s._)`[${data2}]`);
|
|
1523
1517
|
}
|
|
1524
1518
|
}
|
|
1525
1519
|
}
|
|
1526
1520
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
1527
|
-
gen.if((0, codegen_1$
|
|
1521
|
+
gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
|
|
1528
1522
|
}
|
|
1529
1523
|
function checkDataType$1(dataType2, data2, strictNums, correct = DataType.Correct) {
|
|
1530
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
1524
|
+
const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
|
|
1531
1525
|
let cond;
|
|
1532
1526
|
switch (dataType2) {
|
|
1533
1527
|
case "null":
|
|
1534
|
-
return (0, codegen_1$
|
|
1528
|
+
return (0, codegen_1$s._)`${data2} ${EQ} null`;
|
|
1535
1529
|
case "array":
|
|
1536
|
-
cond = (0, codegen_1$
|
|
1530
|
+
cond = (0, codegen_1$s._)`Array.isArray(${data2})`;
|
|
1537
1531
|
break;
|
|
1538
1532
|
case "object":
|
|
1539
|
-
cond = (0, codegen_1$
|
|
1533
|
+
cond = (0, codegen_1$s._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
|
|
1540
1534
|
break;
|
|
1541
1535
|
case "integer":
|
|
1542
|
-
cond = numCond((0, codegen_1$
|
|
1536
|
+
cond = numCond((0, codegen_1$s._)`!(${data2} % 1) && !isNaN(${data2})`);
|
|
1543
1537
|
break;
|
|
1544
1538
|
case "number":
|
|
1545
1539
|
cond = numCond();
|
|
1546
1540
|
break;
|
|
1547
1541
|
default:
|
|
1548
|
-
return (0, codegen_1$
|
|
1542
|
+
return (0, codegen_1$s._)`typeof ${data2} ${EQ} ${dataType2}`;
|
|
1549
1543
|
}
|
|
1550
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
1551
|
-
function numCond(_cond = codegen_1$
|
|
1552
|
-
return (0, codegen_1$
|
|
1544
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
|
|
1545
|
+
function numCond(_cond = codegen_1$s.nil) {
|
|
1546
|
+
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);
|
|
1553
1547
|
}
|
|
1554
1548
|
}
|
|
1555
1549
|
dataType.checkDataType = checkDataType$1;
|
|
@@ -1558,35 +1552,35 @@
|
|
|
1558
1552
|
return checkDataType$1(dataTypes[0], data2, strictNums, correct);
|
|
1559
1553
|
}
|
|
1560
1554
|
let cond;
|
|
1561
|
-
const types2 = (0, util_1$
|
|
1555
|
+
const types2 = (0, util_1$q.toHash)(dataTypes);
|
|
1562
1556
|
if (types2.array && types2.object) {
|
|
1563
|
-
const notObj = (0, codegen_1$
|
|
1564
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
1557
|
+
const notObj = (0, codegen_1$s._)`typeof ${data2} != "object"`;
|
|
1558
|
+
cond = types2.null ? notObj : (0, codegen_1$s._)`!${data2} || ${notObj}`;
|
|
1565
1559
|
delete types2.null;
|
|
1566
1560
|
delete types2.array;
|
|
1567
1561
|
delete types2.object;
|
|
1568
1562
|
} else {
|
|
1569
|
-
cond = codegen_1$
|
|
1563
|
+
cond = codegen_1$s.nil;
|
|
1570
1564
|
}
|
|
1571
1565
|
if (types2.number)
|
|
1572
1566
|
delete types2.integer;
|
|
1573
1567
|
for (const t in types2)
|
|
1574
|
-
cond = (0, codegen_1$
|
|
1568
|
+
cond = (0, codegen_1$s.and)(cond, checkDataType$1(t, data2, strictNums, correct));
|
|
1575
1569
|
return cond;
|
|
1576
1570
|
}
|
|
1577
1571
|
dataType.checkDataTypes = checkDataTypes$1;
|
|
1578
1572
|
const typeError = {
|
|
1579
1573
|
message: ({ schema }) => `must be ${schema}`,
|
|
1580
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
1574
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
|
|
1581
1575
|
};
|
|
1582
1576
|
function reportTypeError(it) {
|
|
1583
1577
|
const cxt = getTypeErrorContext(it);
|
|
1584
|
-
(0, errors_1.reportError)(cxt, typeError);
|
|
1578
|
+
(0, errors_1$2.reportError)(cxt, typeError);
|
|
1585
1579
|
}
|
|
1586
1580
|
dataType.reportTypeError = reportTypeError;
|
|
1587
1581
|
function getTypeErrorContext(it) {
|
|
1588
1582
|
const { gen, data: data2, schema } = it;
|
|
1589
|
-
const schemaCode = (0, util_1$
|
|
1583
|
+
const schemaCode = (0, util_1$q.schemaRefOrVal)(it, schema, "type");
|
|
1590
1584
|
return {
|
|
1591
1585
|
gen,
|
|
1592
1586
|
keyword: "type",
|
|
@@ -1600,376 +1594,352 @@
|
|
|
1600
1594
|
};
|
|
1601
1595
|
}
|
|
1602
1596
|
var defaults = {};
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1597
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
1598
|
+
defaults.assignDefaults = void 0;
|
|
1599
|
+
const codegen_1$r = codegen;
|
|
1600
|
+
const util_1$p = util$7;
|
|
1601
|
+
function assignDefaults(it, ty) {
|
|
1602
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
1603
|
+
if (ty === "object" && properties2) {
|
|
1604
|
+
for (const key in properties2) {
|
|
1605
|
+
assignDefault(it, key, properties2[key].default);
|
|
1606
|
+
}
|
|
1607
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
1608
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
defaults.assignDefaults = assignDefaults;
|
|
1612
|
+
function assignDefault(it, prop, defaultValue) {
|
|
1613
|
+
const { gen, compositeRule, data: data2, opts } = it;
|
|
1614
|
+
if (defaultValue === void 0)
|
|
1615
|
+
return;
|
|
1616
|
+
const childData = (0, codegen_1$r._)`${data2}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
1617
|
+
if (compositeRule) {
|
|
1618
|
+
(0, util_1$p.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1619
|
+
return;
|
|
1620
1620
|
}
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
if (defaultValue === void 0)
|
|
1625
|
-
return;
|
|
1626
|
-
const childData = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(prop)}`;
|
|
1627
|
-
if (compositeRule) {
|
|
1628
|
-
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1629
|
-
return;
|
|
1630
|
-
}
|
|
1631
|
-
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
1632
|
-
if (opts.useDefaults === "empty") {
|
|
1633
|
-
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
1634
|
-
}
|
|
1635
|
-
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
1621
|
+
let condition = (0, codegen_1$r._)`${childData} === undefined`;
|
|
1622
|
+
if (opts.useDefaults === "empty") {
|
|
1623
|
+
condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
1636
1624
|
}
|
|
1637
|
-
|
|
1625
|
+
gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
|
|
1638
1626
|
}
|
|
1639
1627
|
var keyword$1 = {};
|
|
1640
1628
|
var code = {};
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
function checkReportMissingProp(cxt, prop) {
|
|
1652
|
-
const { gen, data: data2, it } = cxt;
|
|
1653
|
-
gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
|
|
1654
|
-
cxt.setParams({ missingProperty: (0, codegen_12._)`${prop}` }, true);
|
|
1655
|
-
cxt.error();
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
code.checkReportMissingProp = checkReportMissingProp;
|
|
1659
|
-
function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
|
|
1660
|
-
return (0, codegen_12.or)(...properties2.map((prop) => (0, codegen_12.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_12._)`${missing} = ${prop}`)));
|
|
1661
|
-
}
|
|
1662
|
-
code.checkMissingProp = checkMissingProp;
|
|
1663
|
-
function reportMissingProp(cxt, missing) {
|
|
1664
|
-
cxt.setParams({ missingProperty: missing }, true);
|
|
1629
|
+
Object.defineProperty(code, "__esModule", { value: true });
|
|
1630
|
+
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;
|
|
1631
|
+
const codegen_1$q = codegen;
|
|
1632
|
+
const util_1$o = util$7;
|
|
1633
|
+
const names_1$5 = names$1;
|
|
1634
|
+
const util_2$1 = util$7;
|
|
1635
|
+
function checkReportMissingProp(cxt, prop) {
|
|
1636
|
+
const { gen, data: data2, it } = cxt;
|
|
1637
|
+
gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
|
|
1638
|
+
cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
|
|
1665
1639
|
cxt.error();
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
code.checkReportMissingProp = checkReportMissingProp;
|
|
1643
|
+
function checkMissingProp({ gen, data: data2, it: { opts } }, properties2, missing) {
|
|
1644
|
+
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}`)));
|
|
1645
|
+
}
|
|
1646
|
+
code.checkMissingProp = checkMissingProp;
|
|
1647
|
+
function reportMissingProp(cxt, missing) {
|
|
1648
|
+
cxt.setParams({ missingProperty: missing }, true);
|
|
1649
|
+
cxt.error();
|
|
1650
|
+
}
|
|
1651
|
+
code.reportMissingProp = reportMissingProp;
|
|
1652
|
+
function hasPropFunc(gen) {
|
|
1653
|
+
return gen.scopeValue("func", {
|
|
1654
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1655
|
+
ref: Object.prototype.hasOwnProperty,
|
|
1656
|
+
code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
code.hasPropFunc = hasPropFunc;
|
|
1660
|
+
function isOwnProperty(gen, data2, property) {
|
|
1661
|
+
return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
|
|
1662
|
+
}
|
|
1663
|
+
code.isOwnProperty = isOwnProperty;
|
|
1664
|
+
function propertyInData(gen, data2, property, ownProperties) {
|
|
1665
|
+
const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
|
|
1666
|
+
return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
|
|
1667
|
+
}
|
|
1668
|
+
code.propertyInData = propertyInData;
|
|
1669
|
+
function noPropertyInData(gen, data2, property, ownProperties) {
|
|
1670
|
+
const cond = (0, codegen_1$q._)`${data2}${(0, codegen_1$q.getProperty)(property)} === undefined`;
|
|
1671
|
+
return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data2, property))) : cond;
|
|
1672
|
+
}
|
|
1673
|
+
code.noPropertyInData = noPropertyInData;
|
|
1674
|
+
function allSchemaProperties(schemaMap) {
|
|
1675
|
+
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
|
|
1676
|
+
}
|
|
1677
|
+
code.allSchemaProperties = allSchemaProperties;
|
|
1678
|
+
function schemaProperties(it, schemaMap) {
|
|
1679
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$o.alwaysValidSchema)(it, schemaMap[p]));
|
|
1680
|
+
}
|
|
1681
|
+
code.schemaProperties = schemaProperties;
|
|
1682
|
+
function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
1683
|
+
const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
|
|
1684
|
+
const valCxt = [
|
|
1685
|
+
[names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
|
|
1686
|
+
[names_1$5.default.parentData, it.parentData],
|
|
1687
|
+
[names_1$5.default.parentDataProperty, it.parentDataProperty],
|
|
1688
|
+
[names_1$5.default.rootData, names_1$5.default.rootData]
|
|
1689
|
+
];
|
|
1690
|
+
if (it.opts.dynamicRef)
|
|
1691
|
+
valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
|
|
1692
|
+
const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
1693
|
+
return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
|
|
1694
|
+
}
|
|
1695
|
+
code.callValidateCode = callValidateCode;
|
|
1696
|
+
const newRegExp = (0, codegen_1$q._)`new RegExp`;
|
|
1697
|
+
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
1698
|
+
const u = opts.unicodeRegExp ? "u" : "";
|
|
1699
|
+
const { regExp } = opts.code;
|
|
1700
|
+
const rx = regExp(pattern2, u);
|
|
1701
|
+
return gen.scopeValue("pattern", {
|
|
1702
|
+
key: rx.toString(),
|
|
1703
|
+
ref: rx,
|
|
1704
|
+
code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
code.usePattern = usePattern;
|
|
1708
|
+
function validateArray(cxt) {
|
|
1709
|
+
const { gen, data: data2, keyword: keyword2, it } = cxt;
|
|
1710
|
+
const valid = gen.name("valid");
|
|
1711
|
+
if (it.allErrors) {
|
|
1712
|
+
const validArr = gen.let("valid", true);
|
|
1713
|
+
validateItems(() => gen.assign(validArr, false));
|
|
1714
|
+
return validArr;
|
|
1666
1715
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
code.isOwnProperty = isOwnProperty;
|
|
1680
|
-
function propertyInData(gen, data2, property, ownProperties) {
|
|
1681
|
-
const cond = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(property)} !== undefined`;
|
|
1682
|
-
return ownProperties ? (0, codegen_12._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
|
|
1683
|
-
}
|
|
1684
|
-
code.propertyInData = propertyInData;
|
|
1685
|
-
function noPropertyInData(gen, data2, property, ownProperties) {
|
|
1686
|
-
const cond = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)(property)} === undefined`;
|
|
1687
|
-
return ownProperties ? (0, codegen_12.or)(cond, (0, codegen_12.not)(isOwnProperty(gen, data2, property))) : cond;
|
|
1688
|
-
}
|
|
1689
|
-
code.noPropertyInData = noPropertyInData;
|
|
1690
|
-
function allSchemaProperties(schemaMap) {
|
|
1691
|
-
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
|
|
1692
|
-
}
|
|
1693
|
-
code.allSchemaProperties = allSchemaProperties;
|
|
1694
|
-
function schemaProperties(it, schemaMap) {
|
|
1695
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_12.alwaysValidSchema)(it, schemaMap[p]));
|
|
1696
|
-
}
|
|
1697
|
-
code.schemaProperties = schemaProperties;
|
|
1698
|
-
function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
1699
|
-
const dataAndSchema = passSchema ? (0, codegen_12._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
|
|
1700
|
-
const valCxt = [
|
|
1701
|
-
[names_12.default.instancePath, (0, codegen_12.strConcat)(names_12.default.instancePath, errorPath)],
|
|
1702
|
-
[names_12.default.parentData, it.parentData],
|
|
1703
|
-
[names_12.default.parentDataProperty, it.parentDataProperty],
|
|
1704
|
-
[names_12.default.rootData, names_12.default.rootData]
|
|
1705
|
-
];
|
|
1706
|
-
if (it.opts.dynamicRef)
|
|
1707
|
-
valCxt.push([names_12.default.dynamicAnchors, names_12.default.dynamicAnchors]);
|
|
1708
|
-
const args = (0, codegen_12._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
1709
|
-
return context !== codegen_12.nil ? (0, codegen_12._)`${func}.call(${context}, ${args})` : (0, codegen_12._)`${func}(${args})`;
|
|
1710
|
-
}
|
|
1711
|
-
code.callValidateCode = callValidateCode;
|
|
1712
|
-
const newRegExp = (0, codegen_12._)`new RegExp`;
|
|
1713
|
-
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
1714
|
-
const u = opts.unicodeRegExp ? "u" : "";
|
|
1715
|
-
const { regExp } = opts.code;
|
|
1716
|
-
const rx = regExp(pattern2, u);
|
|
1717
|
-
return gen.scopeValue("pattern", {
|
|
1718
|
-
key: rx.toString(),
|
|
1719
|
-
ref: rx,
|
|
1720
|
-
code: (0, codegen_12._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_22.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
1716
|
+
gen.var(valid, true);
|
|
1717
|
+
validateItems(() => gen.break());
|
|
1718
|
+
return valid;
|
|
1719
|
+
function validateItems(notValid) {
|
|
1720
|
+
const len = gen.const("len", (0, codegen_1$q._)`${data2}.length`);
|
|
1721
|
+
gen.forRange("i", 0, len, (i) => {
|
|
1722
|
+
cxt.subschema({
|
|
1723
|
+
keyword: keyword2,
|
|
1724
|
+
dataProp: i,
|
|
1725
|
+
dataPropType: util_1$o.Type.Num
|
|
1726
|
+
}, valid);
|
|
1727
|
+
gen.if((0, codegen_1$q.not)(valid), notValid);
|
|
1721
1728
|
});
|
|
1722
1729
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1730
|
+
}
|
|
1731
|
+
code.validateArray = validateArray;
|
|
1732
|
+
function validateUnion(cxt) {
|
|
1733
|
+
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
1734
|
+
if (!Array.isArray(schema))
|
|
1735
|
+
throw new Error("ajv implementation error");
|
|
1736
|
+
const alwaysValid = schema.some((sch) => (0, util_1$o.alwaysValidSchema)(it, sch));
|
|
1737
|
+
if (alwaysValid && !it.opts.unevaluated)
|
|
1738
|
+
return;
|
|
1739
|
+
const valid = gen.let("valid", false);
|
|
1740
|
+
const schValid = gen.name("_valid");
|
|
1741
|
+
gen.block(() => schema.forEach((_sch, i) => {
|
|
1742
|
+
const schCxt = cxt.subschema({
|
|
1743
|
+
keyword: keyword2,
|
|
1744
|
+
schemaProp: i,
|
|
1745
|
+
compositeRule: true
|
|
1746
|
+
}, schValid);
|
|
1747
|
+
gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
|
|
1748
|
+
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
1749
|
+
if (!merged)
|
|
1750
|
+
gen.if((0, codegen_1$q.not)(valid));
|
|
1751
|
+
}));
|
|
1752
|
+
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
1753
|
+
}
|
|
1754
|
+
code.validateUnion = validateUnion;
|
|
1755
|
+
Object.defineProperty(keyword$1, "__esModule", { value: true });
|
|
1756
|
+
keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
|
|
1757
|
+
const codegen_1$p = codegen;
|
|
1758
|
+
const names_1$4 = names$1;
|
|
1759
|
+
const code_1$9 = code;
|
|
1760
|
+
const errors_1$1 = errors;
|
|
1761
|
+
function macroKeywordCode(cxt, def2) {
|
|
1762
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
1763
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
1764
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
1765
|
+
if (it.opts.validateSchema !== false)
|
|
1766
|
+
it.self.validateSchema(macroSchema, true);
|
|
1767
|
+
const valid = gen.name("valid");
|
|
1768
|
+
cxt.subschema({
|
|
1769
|
+
schema: macroSchema,
|
|
1770
|
+
schemaPath: codegen_1$p.nil,
|
|
1771
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
1772
|
+
topSchemaRef: schemaRef,
|
|
1773
|
+
compositeRule: true
|
|
1774
|
+
}, valid);
|
|
1775
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
1776
|
+
}
|
|
1777
|
+
keyword$1.macroKeywordCode = macroKeywordCode;
|
|
1778
|
+
function funcKeywordCode(cxt, def2) {
|
|
1779
|
+
var _a;
|
|
1780
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
1781
|
+
checkAsyncKeyword(it, def2);
|
|
1782
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
1783
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
1784
|
+
const valid = gen.let("valid");
|
|
1785
|
+
cxt.block$data(valid, validateKeyword2);
|
|
1786
|
+
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
1787
|
+
function validateKeyword2() {
|
|
1788
|
+
if (def2.errors === false) {
|
|
1789
|
+
assignValid();
|
|
1790
|
+
if (def2.modifying)
|
|
1791
|
+
modifyData(cxt);
|
|
1792
|
+
reportErrs(() => cxt.error());
|
|
1793
|
+
} else {
|
|
1794
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
1795
|
+
if (def2.modifying)
|
|
1796
|
+
modifyData(cxt);
|
|
1797
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
1745
1798
|
}
|
|
1746
1799
|
}
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
throw new Error("ajv implementation error");
|
|
1752
|
-
const alwaysValid = schema.some((sch) => (0, util_12.alwaysValidSchema)(it, sch));
|
|
1753
|
-
if (alwaysValid && !it.opts.unevaluated)
|
|
1754
|
-
return;
|
|
1755
|
-
const valid = gen.let("valid", false);
|
|
1756
|
-
const schValid = gen.name("_valid");
|
|
1757
|
-
gen.block(() => schema.forEach((_sch, i) => {
|
|
1758
|
-
const schCxt = cxt.subschema({
|
|
1759
|
-
keyword: keyword2,
|
|
1760
|
-
schemaProp: i,
|
|
1761
|
-
compositeRule: true
|
|
1762
|
-
}, schValid);
|
|
1763
|
-
gen.assign(valid, (0, codegen_12._)`${valid} || ${schValid}`);
|
|
1764
|
-
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
1765
|
-
if (!merged)
|
|
1766
|
-
gen.if((0, codegen_12.not)(valid));
|
|
1767
|
-
}));
|
|
1768
|
-
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
1800
|
+
function validateAsync() {
|
|
1801
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
1802
|
+
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)));
|
|
1803
|
+
return ruleErrs;
|
|
1769
1804
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
if (hasRequiredKeyword) return keyword$1;
|
|
1776
|
-
hasRequiredKeyword = 1;
|
|
1777
|
-
Object.defineProperty(keyword$1, "__esModule", { value: true });
|
|
1778
|
-
keyword$1.validateKeywordUsage = keyword$1.validSchemaType = keyword$1.funcKeywordCode = keyword$1.macroKeywordCode = void 0;
|
|
1779
|
-
const codegen_12 = codegen;
|
|
1780
|
-
const names_12 = names$1;
|
|
1781
|
-
const code_12 = requireCode();
|
|
1782
|
-
const errors_12 = errors;
|
|
1783
|
-
function macroKeywordCode(cxt, def2) {
|
|
1784
|
-
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
1785
|
-
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
1786
|
-
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
1787
|
-
if (it.opts.validateSchema !== false)
|
|
1788
|
-
it.self.validateSchema(macroSchema, true);
|
|
1789
|
-
const valid = gen.name("valid");
|
|
1790
|
-
cxt.subschema({
|
|
1791
|
-
schema: macroSchema,
|
|
1792
|
-
schemaPath: codegen_12.nil,
|
|
1793
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
1794
|
-
topSchemaRef: schemaRef,
|
|
1795
|
-
compositeRule: true
|
|
1796
|
-
}, valid);
|
|
1797
|
-
cxt.pass(valid, () => cxt.error(true));
|
|
1805
|
+
function validateSync() {
|
|
1806
|
+
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
1807
|
+
gen.assign(validateErrs, null);
|
|
1808
|
+
assignValid(codegen_1$p.nil);
|
|
1809
|
+
return validateErrs;
|
|
1798
1810
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
checkAsyncKeyword(it, def2);
|
|
1804
|
-
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
1805
|
-
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
1806
|
-
const valid = gen.let("valid");
|
|
1807
|
-
cxt.block$data(valid, validateKeyword2);
|
|
1808
|
-
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
1809
|
-
function validateKeyword2() {
|
|
1810
|
-
if (def2.errors === false) {
|
|
1811
|
-
assignValid();
|
|
1812
|
-
if (def2.modifying)
|
|
1813
|
-
modifyData(cxt);
|
|
1814
|
-
reportErrs(() => cxt.error());
|
|
1815
|
-
} else {
|
|
1816
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
1817
|
-
if (def2.modifying)
|
|
1818
|
-
modifyData(cxt);
|
|
1819
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
function validateAsync() {
|
|
1823
|
-
const ruleErrs = gen.let("ruleErrs", null);
|
|
1824
|
-
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)));
|
|
1825
|
-
return ruleErrs;
|
|
1826
|
-
}
|
|
1827
|
-
function validateSync() {
|
|
1828
|
-
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
1829
|
-
gen.assign(validateErrs, null);
|
|
1830
|
-
assignValid(codegen_12.nil);
|
|
1831
|
-
return validateErrs;
|
|
1832
|
-
}
|
|
1833
|
-
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
1834
|
-
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
1835
|
-
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
1836
|
-
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
1837
|
-
}
|
|
1838
|
-
function reportErrs(errors2) {
|
|
1839
|
-
var _a2;
|
|
1840
|
-
gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
1841
|
-
}
|
|
1811
|
+
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
1812
|
+
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
1813
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
1814
|
+
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
1842
1815
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
keyword$
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
}
|
|
1816
|
+
function reportErrs(errors2) {
|
|
1817
|
+
var _a2;
|
|
1818
|
+
gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
keyword$1.funcKeywordCode = funcKeywordCode;
|
|
1822
|
+
function modifyData(cxt) {
|
|
1823
|
+
const { gen, data: data2, it } = cxt;
|
|
1824
|
+
gen.if(it.parentData, () => gen.assign(data2, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
1825
|
+
}
|
|
1826
|
+
function addErrs(cxt, errs) {
|
|
1827
|
+
const { gen } = cxt;
|
|
1828
|
+
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
1829
|
+
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`);
|
|
1830
|
+
(0, errors_1$1.extendErrors)(cxt);
|
|
1831
|
+
}, () => cxt.error());
|
|
1832
|
+
}
|
|
1833
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
1834
|
+
if (def2.async && !schemaEnv.$async)
|
|
1835
|
+
throw new Error("async keyword in sync schema");
|
|
1836
|
+
}
|
|
1837
|
+
function useKeyword(gen, keyword2, result) {
|
|
1838
|
+
if (result === void 0)
|
|
1839
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
1840
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
1841
|
+
}
|
|
1842
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
1843
|
+
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");
|
|
1844
|
+
}
|
|
1845
|
+
keyword$1.validSchemaType = validSchemaType;
|
|
1846
|
+
function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
|
|
1847
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
1848
|
+
throw new Error("ajv implementation error");
|
|
1849
|
+
}
|
|
1850
|
+
const deps = def2.dependencies;
|
|
1851
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
1852
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
1853
|
+
}
|
|
1854
|
+
if (def2.validateSchema) {
|
|
1855
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
1856
|
+
if (!valid) {
|
|
1857
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
|
|
1858
|
+
if (opts.validateSchema === "log")
|
|
1859
|
+
self2.logger.error(msg);
|
|
1860
|
+
else
|
|
1861
|
+
throw new Error(msg);
|
|
1885
1862
|
}
|
|
1886
1863
|
}
|
|
1887
|
-
keyword$1.validateKeywordUsage = validateKeywordUsage;
|
|
1888
|
-
return keyword$1;
|
|
1889
1864
|
}
|
|
1865
|
+
keyword$1.validateKeywordUsage = validateKeywordUsage;
|
|
1890
1866
|
var subschema = {};
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
if (schema !== void 0) {
|
|
1916
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
1917
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
1918
|
-
}
|
|
1919
|
-
return {
|
|
1920
|
-
schema,
|
|
1921
|
-
schemaPath,
|
|
1922
|
-
topSchemaRef,
|
|
1923
|
-
errSchemaPath
|
|
1924
|
-
};
|
|
1867
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
1868
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
1869
|
+
const codegen_1$o = codegen;
|
|
1870
|
+
const util_1$n = util$7;
|
|
1871
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
1872
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
1873
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
1874
|
+
}
|
|
1875
|
+
if (keyword2 !== void 0) {
|
|
1876
|
+
const sch = it.schema[keyword2];
|
|
1877
|
+
return schemaProp === void 0 ? {
|
|
1878
|
+
schema: sch,
|
|
1879
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
1880
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
1881
|
+
} : {
|
|
1882
|
+
schema: sch[schemaProp],
|
|
1883
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
1884
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$n.escapeFragment)(schemaProp)}`
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
if (schema !== void 0) {
|
|
1888
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
1889
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
1925
1890
|
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
subschema2.
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1891
|
+
return {
|
|
1892
|
+
schema,
|
|
1893
|
+
schemaPath,
|
|
1894
|
+
topSchemaRef,
|
|
1895
|
+
errSchemaPath
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
1899
|
+
}
|
|
1900
|
+
subschema.getSubschema = getSubschema;
|
|
1901
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
|
|
1902
|
+
if (data2 !== void 0 && dataProp !== void 0) {
|
|
1903
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
1904
|
+
}
|
|
1905
|
+
const { gen } = it;
|
|
1906
|
+
if (dataProp !== void 0) {
|
|
1907
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
1908
|
+
const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
|
|
1909
|
+
dataContextProps(nextData);
|
|
1910
|
+
subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$n.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
1911
|
+
subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
|
|
1912
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
1913
|
+
}
|
|
1914
|
+
if (data2 !== void 0) {
|
|
1915
|
+
const nextData = data2 instanceof codegen_1$o.Name ? data2 : gen.let("data", data2, true);
|
|
1916
|
+
dataContextProps(nextData);
|
|
1917
|
+
if (propertyName !== void 0)
|
|
1918
|
+
subschema2.propertyName = propertyName;
|
|
1919
|
+
}
|
|
1920
|
+
if (dataTypes)
|
|
1921
|
+
subschema2.dataTypes = dataTypes;
|
|
1922
|
+
function dataContextProps(_nextData) {
|
|
1923
|
+
subschema2.data = _nextData;
|
|
1924
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
1925
|
+
subschema2.dataTypes = [];
|
|
1926
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
1927
|
+
subschema2.parentData = it.data;
|
|
1928
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
1932
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
1933
|
+
if (compositeRule !== void 0)
|
|
1934
|
+
subschema2.compositeRule = compositeRule;
|
|
1935
|
+
if (createErrors !== void 0)
|
|
1936
|
+
subschema2.createErrors = createErrors;
|
|
1937
|
+
if (allErrors !== void 0)
|
|
1938
|
+
subschema2.allErrors = allErrors;
|
|
1939
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
1940
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
1941
|
+
}
|
|
1942
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
1973
1943
|
var resolve$6 = {};
|
|
1974
1944
|
var fastDeepEqual = function equal2(a, b) {
|
|
1975
1945
|
if (a === b) return true;
|
|
@@ -2084,7 +2054,7 @@
|
|
|
2084
2054
|
var jsonSchemaTraverseExports$1 = jsonSchemaTraverse$1.exports;
|
|
2085
2055
|
Object.defineProperty(resolve$6, "__esModule", { value: true });
|
|
2086
2056
|
resolve$6.getSchemaRefs = resolve$6.resolveUrl = resolve$6.normalizeId = resolve$6._getFullPath = resolve$6.getFullPath = resolve$6.inlineRef = void 0;
|
|
2087
|
-
const util_1$
|
|
2057
|
+
const util_1$m = util$7;
|
|
2088
2058
|
const equal$5 = fastDeepEqual;
|
|
2089
2059
|
const traverse$2 = jsonSchemaTraverseExports$1;
|
|
2090
2060
|
const SIMPLE_INLINED$1 = /* @__PURE__ */ new Set([
|
|
@@ -2143,7 +2113,7 @@
|
|
|
2143
2113
|
if (SIMPLE_INLINED$1.has(key))
|
|
2144
2114
|
continue;
|
|
2145
2115
|
if (typeof schema[key] == "object") {
|
|
2146
|
-
(0, util_1$
|
|
2116
|
+
(0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys$1(sch));
|
|
2147
2117
|
}
|
|
2148
2118
|
if (count === Infinity)
|
|
2149
2119
|
return Infinity;
|
|
@@ -2231,512 +2201,506 @@
|
|
|
2231
2201
|
}
|
|
2232
2202
|
}
|
|
2233
2203
|
resolve$6.getSchemaRefs = getSchemaRefs;
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
checkKeywords(it);
|
|
2255
|
-
if (schemaCxtHasRules(it)) {
|
|
2256
|
-
topSchemaObjCode(it);
|
|
2257
|
-
return;
|
|
2258
|
-
}
|
|
2204
|
+
Object.defineProperty(validate$2, "__esModule", { value: true });
|
|
2205
|
+
validate$2.getData = validate$2.KeywordCxt = validate$2.validateFunctionCode = void 0;
|
|
2206
|
+
const boolSchema_1 = boolSchema;
|
|
2207
|
+
const dataType_1$1 = dataType;
|
|
2208
|
+
const applicability_1 = applicability;
|
|
2209
|
+
const dataType_2 = dataType;
|
|
2210
|
+
const defaults_1 = defaults;
|
|
2211
|
+
const keyword_1 = keyword$1;
|
|
2212
|
+
const subschema_1 = subschema;
|
|
2213
|
+
const codegen_1$n = codegen;
|
|
2214
|
+
const names_1$3 = names$1;
|
|
2215
|
+
const resolve_1$3 = resolve$6;
|
|
2216
|
+
const util_1$l = util$7;
|
|
2217
|
+
const errors_1 = errors;
|
|
2218
|
+
function validateFunctionCode(it) {
|
|
2219
|
+
if (isSchemaObj(it)) {
|
|
2220
|
+
checkKeywords(it);
|
|
2221
|
+
if (schemaCxtHasRules(it)) {
|
|
2222
|
+
topSchemaObjCode(it);
|
|
2223
|
+
return;
|
|
2259
2224
|
}
|
|
2260
|
-
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2261
2225
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
function destructureValCxt(opts) {
|
|
2275
|
-
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}}={}`;
|
|
2276
|
-
}
|
|
2277
|
-
function destructureValCxtES5(gen, opts) {
|
|
2278
|
-
gen.if(names_12.default.valCxt, () => {
|
|
2279
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
2280
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
2281
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
2282
|
-
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
2283
|
-
if (opts.dynamicRef)
|
|
2284
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
2285
|
-
}, () => {
|
|
2286
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
2287
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
2288
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
2289
|
-
gen.var(names_12.default.rootData, names_12.default.data);
|
|
2290
|
-
if (opts.dynamicRef)
|
|
2291
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
2226
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2227
|
+
}
|
|
2228
|
+
validate$2.validateFunctionCode = validateFunctionCode;
|
|
2229
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
2230
|
+
if (opts.code.es5) {
|
|
2231
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
|
|
2232
|
+
gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
2233
|
+
destructureValCxtES5(gen, opts);
|
|
2234
|
+
gen.code(body);
|
|
2292
2235
|
});
|
|
2236
|
+
} else {
|
|
2237
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
function destructureValCxt(opts) {
|
|
2241
|
+
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}}={}`;
|
|
2242
|
+
}
|
|
2243
|
+
function destructureValCxtES5(gen, opts) {
|
|
2244
|
+
gen.if(names_1$3.default.valCxt, () => {
|
|
2245
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
|
|
2246
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
|
|
2247
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
|
|
2248
|
+
gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
|
|
2249
|
+
if (opts.dynamicRef)
|
|
2250
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
|
|
2251
|
+
}, () => {
|
|
2252
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
|
|
2253
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
|
|
2254
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
|
|
2255
|
+
gen.var(names_1$3.default.rootData, names_1$3.default.data);
|
|
2256
|
+
if (opts.dynamicRef)
|
|
2257
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
function topSchemaObjCode(it) {
|
|
2261
|
+
const { schema, opts, gen } = it;
|
|
2262
|
+
validateFunction(it, () => {
|
|
2263
|
+
if (opts.$comment && schema.$comment)
|
|
2264
|
+
commentKeyword(it);
|
|
2265
|
+
checkNoDefault(it);
|
|
2266
|
+
gen.let(names_1$3.default.vErrors, null);
|
|
2267
|
+
gen.let(names_1$3.default.errors, 0);
|
|
2268
|
+
if (opts.unevaluated)
|
|
2269
|
+
resetEvaluated(it);
|
|
2270
|
+
typeAndKeywords(it);
|
|
2271
|
+
returnResults(it);
|
|
2272
|
+
});
|
|
2273
|
+
return;
|
|
2274
|
+
}
|
|
2275
|
+
function resetEvaluated(it) {
|
|
2276
|
+
const { gen, validateName } = it;
|
|
2277
|
+
it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
|
|
2278
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
|
|
2279
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
|
|
2280
|
+
}
|
|
2281
|
+
function funcSourceUrl(schema, opts) {
|
|
2282
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
2283
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
|
|
2284
|
+
}
|
|
2285
|
+
function subschemaCode(it, valid) {
|
|
2286
|
+
if (isSchemaObj(it)) {
|
|
2287
|
+
checkKeywords(it);
|
|
2288
|
+
if (schemaCxtHasRules(it)) {
|
|
2289
|
+
subSchemaObjCode(it, valid);
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2293
2292
|
}
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2293
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
2294
|
+
}
|
|
2295
|
+
function schemaCxtHasRules({ schema, self: self2 }) {
|
|
2296
|
+
if (typeof schema == "boolean")
|
|
2297
|
+
return !schema;
|
|
2298
|
+
for (const key in schema)
|
|
2299
|
+
if (self2.RULES.all[key])
|
|
2300
|
+
return true;
|
|
2301
|
+
return false;
|
|
2302
|
+
}
|
|
2303
|
+
function isSchemaObj(it) {
|
|
2304
|
+
return typeof it.schema != "boolean";
|
|
2305
|
+
}
|
|
2306
|
+
function subSchemaObjCode(it, valid) {
|
|
2307
|
+
const { schema, gen, opts } = it;
|
|
2308
|
+
if (opts.$comment && schema.$comment)
|
|
2309
|
+
commentKeyword(it);
|
|
2310
|
+
updateContext(it);
|
|
2311
|
+
checkAsyncSchema(it);
|
|
2312
|
+
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
2313
|
+
typeAndKeywords(it, errsCount);
|
|
2314
|
+
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
2315
|
+
}
|
|
2316
|
+
function checkKeywords(it) {
|
|
2317
|
+
(0, util_1$l.checkUnknownRules)(it);
|
|
2318
|
+
checkRefsAndKeywords(it);
|
|
2319
|
+
}
|
|
2320
|
+
function typeAndKeywords(it, errsCount) {
|
|
2321
|
+
if (it.opts.jtd)
|
|
2322
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
2323
|
+
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
2324
|
+
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
2325
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
2326
|
+
}
|
|
2327
|
+
function checkRefsAndKeywords(it) {
|
|
2328
|
+
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
2329
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$l.schemaHasRulesButRef)(schema, self2.RULES)) {
|
|
2330
|
+
self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
function checkNoDefault(it) {
|
|
2334
|
+
const { schema, opts } = it;
|
|
2335
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
2336
|
+
(0, util_1$l.checkStrictMode)(it, "default is ignored in the schema root");
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
function updateContext(it) {
|
|
2340
|
+
const schId = it.schema[it.opts.schemaId];
|
|
2341
|
+
if (schId)
|
|
2342
|
+
it.baseId = (0, resolve_1$3.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
2343
|
+
}
|
|
2344
|
+
function checkAsyncSchema(it) {
|
|
2345
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
2346
|
+
throw new Error("async schema in sync schema");
|
|
2347
|
+
}
|
|
2348
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
2349
|
+
const msg = schema.$comment;
|
|
2350
|
+
if (opts.$comment === true) {
|
|
2351
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
2352
|
+
} else if (typeof opts.$comment == "function") {
|
|
2353
|
+
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
2354
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
2355
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
function returnResults(it) {
|
|
2359
|
+
const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
|
|
2360
|
+
if (schemaEnv.$async) {
|
|
2361
|
+
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 ${ValidationError2}(${names_1$3.default.vErrors})`));
|
|
2362
|
+
} else {
|
|
2363
|
+
gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
|
|
2364
|
+
if (opts.unevaluated)
|
|
2365
|
+
assignEvaluated(it);
|
|
2366
|
+
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
2370
|
+
if (props instanceof codegen_1$n.Name)
|
|
2371
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
|
|
2372
|
+
if (items2 instanceof codegen_1$n.Name)
|
|
2373
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
2374
|
+
}
|
|
2375
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
2376
|
+
const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
|
|
2377
|
+
const { RULES } = self2;
|
|
2378
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(schema, RULES))) {
|
|
2379
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2307
2380
|
return;
|
|
2308
2381
|
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
if (
|
|
2323
|
-
|
|
2324
|
-
|
|
2382
|
+
if (!opts.jtd)
|
|
2383
|
+
checkStrictTypes(it, types2);
|
|
2384
|
+
gen.block(() => {
|
|
2385
|
+
for (const group of RULES.rules)
|
|
2386
|
+
groupKeywords(group);
|
|
2387
|
+
groupKeywords(RULES.post);
|
|
2388
|
+
});
|
|
2389
|
+
function groupKeywords(group) {
|
|
2390
|
+
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
2391
|
+
return;
|
|
2392
|
+
if (group.type) {
|
|
2393
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
|
|
2394
|
+
iterateKeywords(it, group);
|
|
2395
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
2396
|
+
gen.else();
|
|
2397
|
+
(0, dataType_2.reportTypeError)(it);
|
|
2325
2398
|
}
|
|
2399
|
+
gen.endIf();
|
|
2400
|
+
} else {
|
|
2401
|
+
iterateKeywords(it, group);
|
|
2326
2402
|
}
|
|
2327
|
-
|
|
2403
|
+
if (!allErrors)
|
|
2404
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
2328
2405
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2406
|
+
}
|
|
2407
|
+
function iterateKeywords(it, group) {
|
|
2408
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
2409
|
+
if (useDefaults)
|
|
2410
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
2411
|
+
gen.block(() => {
|
|
2412
|
+
for (const rule of group.rules) {
|
|
2413
|
+
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
|
2414
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
function checkStrictTypes(it, types2) {
|
|
2420
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
2421
|
+
return;
|
|
2422
|
+
checkContextTypes(it, types2);
|
|
2423
|
+
if (!it.opts.allowUnionTypes)
|
|
2424
|
+
checkMultipleTypes(it, types2);
|
|
2425
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
2426
|
+
}
|
|
2427
|
+
function checkContextTypes(it, types2) {
|
|
2428
|
+
if (!types2.length)
|
|
2429
|
+
return;
|
|
2430
|
+
if (!it.dataTypes.length) {
|
|
2431
|
+
it.dataTypes = types2;
|
|
2432
|
+
return;
|
|
2336
2433
|
}
|
|
2337
|
-
|
|
2338
|
-
|
|
2434
|
+
types2.forEach((t) => {
|
|
2435
|
+
if (!includesType(it.dataTypes, t)) {
|
|
2436
|
+
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
2437
|
+
}
|
|
2438
|
+
});
|
|
2439
|
+
narrowSchemaTypes(it, types2);
|
|
2440
|
+
}
|
|
2441
|
+
function checkMultipleTypes(it, ts) {
|
|
2442
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
2443
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
function checkKeywordTypes(it, ts) {
|
|
2447
|
+
const rules2 = it.self.RULES.all;
|
|
2448
|
+
for (const keyword2 in rules2) {
|
|
2449
|
+
const rule = rules2[keyword2];
|
|
2450
|
+
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
|
2451
|
+
const { type: type2 } = rule.definition;
|
|
2452
|
+
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
2453
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
function hasApplicableType(schTs, kwdT) {
|
|
2459
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
2460
|
+
}
|
|
2461
|
+
function includesType(ts, t) {
|
|
2462
|
+
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
2463
|
+
}
|
|
2464
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
2465
|
+
const ts = [];
|
|
2466
|
+
for (const t of it.dataTypes) {
|
|
2467
|
+
if (includesType(withTypes, t))
|
|
2468
|
+
ts.push(t);
|
|
2469
|
+
else if (withTypes.includes("integer") && t === "number")
|
|
2470
|
+
ts.push("integer");
|
|
2471
|
+
}
|
|
2472
|
+
it.dataTypes = ts;
|
|
2473
|
+
}
|
|
2474
|
+
function strictTypesError(it, msg) {
|
|
2475
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
2476
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
2477
|
+
(0, util_1$l.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
2478
|
+
}
|
|
2479
|
+
class KeywordCxt {
|
|
2480
|
+
constructor(it, def2, keyword2) {
|
|
2481
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
2482
|
+
this.gen = it.gen;
|
|
2483
|
+
this.allErrors = it.allErrors;
|
|
2484
|
+
this.keyword = keyword2;
|
|
2485
|
+
this.data = it.data;
|
|
2486
|
+
this.schema = it.schema[keyword2];
|
|
2487
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
2488
|
+
this.schemaValue = (0, util_1$l.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
2489
|
+
this.schemaType = def2.schemaType;
|
|
2490
|
+
this.parentSchema = it.schema;
|
|
2491
|
+
this.params = {};
|
|
2492
|
+
this.it = it;
|
|
2493
|
+
this.def = def2;
|
|
2494
|
+
if (this.$data) {
|
|
2495
|
+
this.schemaCode = it.gen.const("vSchema", getData$1(this.$data, it));
|
|
2496
|
+
} else {
|
|
2497
|
+
this.schemaCode = this.schemaValue;
|
|
2498
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
2499
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
2503
|
+
this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
|
|
2504
|
+
}
|
|
2339
2505
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
if (opts.$comment && schema.$comment)
|
|
2343
|
-
commentKeyword(it);
|
|
2344
|
-
updateContext(it);
|
|
2345
|
-
checkAsyncSchema(it);
|
|
2346
|
-
const errsCount = gen.const("_errs", names_12.default.errors);
|
|
2347
|
-
typeAndKeywords(it, errsCount);
|
|
2348
|
-
gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
|
|
2506
|
+
result(condition, successAction, failAction) {
|
|
2507
|
+
this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
|
|
2349
2508
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2509
|
+
failResult(condition, successAction, failAction) {
|
|
2510
|
+
this.gen.if(condition);
|
|
2511
|
+
if (failAction)
|
|
2512
|
+
failAction();
|
|
2513
|
+
else
|
|
2514
|
+
this.error();
|
|
2515
|
+
if (successAction) {
|
|
2516
|
+
this.gen.else();
|
|
2517
|
+
successAction();
|
|
2518
|
+
if (this.allErrors)
|
|
2519
|
+
this.gen.endIf();
|
|
2520
|
+
} else {
|
|
2521
|
+
if (this.allErrors)
|
|
2522
|
+
this.gen.endIf();
|
|
2523
|
+
else
|
|
2524
|
+
this.gen.else();
|
|
2525
|
+
}
|
|
2353
2526
|
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
return schemaKeywords(it, [], false, errsCount);
|
|
2357
|
-
const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
|
|
2358
|
-
const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
|
|
2359
|
-
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
2527
|
+
pass(condition, failAction) {
|
|
2528
|
+
this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
|
|
2360
2529
|
}
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2530
|
+
fail(condition) {
|
|
2531
|
+
if (condition === void 0) {
|
|
2532
|
+
this.error();
|
|
2533
|
+
if (!this.allErrors)
|
|
2534
|
+
this.gen.if(false);
|
|
2535
|
+
return;
|
|
2365
2536
|
}
|
|
2537
|
+
this.gen.if(condition);
|
|
2538
|
+
this.error();
|
|
2539
|
+
if (this.allErrors)
|
|
2540
|
+
this.gen.endIf();
|
|
2541
|
+
else
|
|
2542
|
+
this.gen.else();
|
|
2543
|
+
}
|
|
2544
|
+
fail$data(condition) {
|
|
2545
|
+
if (!this.$data)
|
|
2546
|
+
return this.fail(condition);
|
|
2547
|
+
const { schemaCode } = this;
|
|
2548
|
+
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
2366
2549
|
}
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2550
|
+
error(append, errorParams, errorPaths) {
|
|
2551
|
+
if (errorParams) {
|
|
2552
|
+
this.setParams(errorParams);
|
|
2553
|
+
this._error(append, errorPaths);
|
|
2554
|
+
this.setParams({});
|
|
2555
|
+
return;
|
|
2371
2556
|
}
|
|
2557
|
+
this._error(append, errorPaths);
|
|
2372
2558
|
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
if (schId)
|
|
2376
|
-
it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
2559
|
+
_error(append, errorPaths) {
|
|
2560
|
+
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
2377
2561
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
throw new Error("async schema in sync schema");
|
|
2562
|
+
$dataError() {
|
|
2563
|
+
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
2381
2564
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
} else if (typeof opts.$comment == "function") {
|
|
2387
|
-
const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
|
|
2388
|
-
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
2389
|
-
gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
2390
|
-
}
|
|
2565
|
+
reset() {
|
|
2566
|
+
if (this.errsCount === void 0)
|
|
2567
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
2568
|
+
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
2391
2569
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError2}(${names_12.default.vErrors})`));
|
|
2396
|
-
} else {
|
|
2397
|
-
gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
|
|
2398
|
-
if (opts.unevaluated)
|
|
2399
|
-
assignEvaluated(it);
|
|
2400
|
-
gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
2404
|
-
if (props instanceof codegen_12.Name)
|
|
2405
|
-
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
2406
|
-
if (items2 instanceof codegen_12.Name)
|
|
2407
|
-
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
2408
|
-
}
|
|
2409
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
2410
|
-
const { gen, schema, data: data2, allErrors, opts, self: self2 } = it;
|
|
2411
|
-
const { RULES } = self2;
|
|
2412
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
2413
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
2414
|
-
return;
|
|
2415
|
-
}
|
|
2416
|
-
if (!opts.jtd)
|
|
2417
|
-
checkStrictTypes(it, types2);
|
|
2418
|
-
gen.block(() => {
|
|
2419
|
-
for (const group of RULES.rules)
|
|
2420
|
-
groupKeywords(group);
|
|
2421
|
-
groupKeywords(RULES.post);
|
|
2422
|
-
});
|
|
2423
|
-
function groupKeywords(group) {
|
|
2424
|
-
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
2425
|
-
return;
|
|
2426
|
-
if (group.type) {
|
|
2427
|
-
gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
|
|
2428
|
-
iterateKeywords(it, group);
|
|
2429
|
-
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
2430
|
-
gen.else();
|
|
2431
|
-
(0, dataType_2.reportTypeError)(it);
|
|
2432
|
-
}
|
|
2433
|
-
gen.endIf();
|
|
2434
|
-
} else {
|
|
2435
|
-
iterateKeywords(it, group);
|
|
2436
|
-
}
|
|
2437
|
-
if (!allErrors)
|
|
2438
|
-
gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
|
|
2439
|
-
}
|
|
2570
|
+
ok(cond) {
|
|
2571
|
+
if (!this.allErrors)
|
|
2572
|
+
this.gen.if(cond);
|
|
2440
2573
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
for (const rule of group.rules) {
|
|
2447
|
-
if ((0, applicability_12.shouldUseRule)(schema, rule)) {
|
|
2448
|
-
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
2451
|
-
});
|
|
2574
|
+
setParams(obj, assign) {
|
|
2575
|
+
if (assign)
|
|
2576
|
+
Object.assign(this.params, obj);
|
|
2577
|
+
else
|
|
2578
|
+
this.params = obj;
|
|
2452
2579
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
checkMultipleTypes(it, types2);
|
|
2459
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
2580
|
+
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
2581
|
+
this.gen.block(() => {
|
|
2582
|
+
this.check$data(valid, $dataValid);
|
|
2583
|
+
codeBlock();
|
|
2584
|
+
});
|
|
2460
2585
|
}
|
|
2461
|
-
|
|
2462
|
-
if (!
|
|
2463
|
-
return;
|
|
2464
|
-
if (!it.dataTypes.length) {
|
|
2465
|
-
it.dataTypes = types2;
|
|
2586
|
+
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
2587
|
+
if (!this.$data)
|
|
2466
2588
|
return;
|
|
2589
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
2590
|
+
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
2591
|
+
if (valid !== codegen_1$n.nil)
|
|
2592
|
+
gen.assign(valid, true);
|
|
2593
|
+
if (schemaType.length || def2.validateSchema) {
|
|
2594
|
+
gen.elseIf(this.invalid$data());
|
|
2595
|
+
this.$dataError();
|
|
2596
|
+
if (valid !== codegen_1$n.nil)
|
|
2597
|
+
gen.assign(valid, false);
|
|
2467
2598
|
}
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
}
|
|
2480
|
-
function checkKeywordTypes(it, ts) {
|
|
2481
|
-
const rules2 = it.self.RULES.all;
|
|
2482
|
-
for (const keyword2 in rules2) {
|
|
2483
|
-
const rule = rules2[keyword2];
|
|
2484
|
-
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
2485
|
-
const { type: type2 } = rule.definition;
|
|
2486
|
-
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
2487
|
-
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
}
|
|
2492
|
-
function hasApplicableType(schTs, kwdT) {
|
|
2493
|
-
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
2494
|
-
}
|
|
2495
|
-
function includesType(ts, t) {
|
|
2496
|
-
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
2497
|
-
}
|
|
2498
|
-
function narrowSchemaTypes(it, withTypes) {
|
|
2499
|
-
const ts = [];
|
|
2500
|
-
for (const t of it.dataTypes) {
|
|
2501
|
-
if (includesType(withTypes, t))
|
|
2502
|
-
ts.push(t);
|
|
2503
|
-
else if (withTypes.includes("integer") && t === "number")
|
|
2504
|
-
ts.push("integer");
|
|
2505
|
-
}
|
|
2506
|
-
it.dataTypes = ts;
|
|
2507
|
-
}
|
|
2508
|
-
function strictTypesError(it, msg) {
|
|
2509
|
-
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
2510
|
-
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
2511
|
-
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
2512
|
-
}
|
|
2513
|
-
class KeywordCxt {
|
|
2514
|
-
constructor(it, def2, keyword2) {
|
|
2515
|
-
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
2516
|
-
this.gen = it.gen;
|
|
2517
|
-
this.allErrors = it.allErrors;
|
|
2518
|
-
this.keyword = keyword2;
|
|
2519
|
-
this.data = it.data;
|
|
2520
|
-
this.schema = it.schema[keyword2];
|
|
2521
|
-
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
2522
|
-
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
2523
|
-
this.schemaType = def2.schemaType;
|
|
2524
|
-
this.parentSchema = it.schema;
|
|
2525
|
-
this.params = {};
|
|
2526
|
-
this.it = it;
|
|
2527
|
-
this.def = def2;
|
|
2528
|
-
if (this.$data) {
|
|
2529
|
-
this.schemaCode = it.gen.const("vSchema", getData2(this.$data, it));
|
|
2530
|
-
} else {
|
|
2531
|
-
this.schemaCode = this.schemaValue;
|
|
2532
|
-
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
2533
|
-
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
2537
|
-
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
result(condition, successAction, failAction) {
|
|
2541
|
-
this.failResult((0, codegen_12.not)(condition), successAction, failAction);
|
|
2542
|
-
}
|
|
2543
|
-
failResult(condition, successAction, failAction) {
|
|
2544
|
-
this.gen.if(condition);
|
|
2545
|
-
if (failAction)
|
|
2546
|
-
failAction();
|
|
2547
|
-
else
|
|
2548
|
-
this.error();
|
|
2549
|
-
if (successAction) {
|
|
2550
|
-
this.gen.else();
|
|
2551
|
-
successAction();
|
|
2552
|
-
if (this.allErrors)
|
|
2553
|
-
this.gen.endIf();
|
|
2554
|
-
} else {
|
|
2555
|
-
if (this.allErrors)
|
|
2556
|
-
this.gen.endIf();
|
|
2557
|
-
else
|
|
2558
|
-
this.gen.else();
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
pass(condition, failAction) {
|
|
2562
|
-
this.failResult((0, codegen_12.not)(condition), void 0, failAction);
|
|
2563
|
-
}
|
|
2564
|
-
fail(condition) {
|
|
2565
|
-
if (condition === void 0) {
|
|
2566
|
-
this.error();
|
|
2567
|
-
if (!this.allErrors)
|
|
2568
|
-
this.gen.if(false);
|
|
2569
|
-
return;
|
|
2599
|
+
gen.else();
|
|
2600
|
+
}
|
|
2601
|
+
invalid$data() {
|
|
2602
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
2603
|
+
return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
|
|
2604
|
+
function wrong$DataType() {
|
|
2605
|
+
if (schemaType.length) {
|
|
2606
|
+
if (!(schemaCode instanceof codegen_1$n.Name))
|
|
2607
|
+
throw new Error("ajv implementation error");
|
|
2608
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
2609
|
+
return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
2570
2610
|
}
|
|
2571
|
-
|
|
2572
|
-
this.error();
|
|
2573
|
-
if (this.allErrors)
|
|
2574
|
-
this.gen.endIf();
|
|
2575
|
-
else
|
|
2576
|
-
this.gen.else();
|
|
2611
|
+
return codegen_1$n.nil;
|
|
2577
2612
|
}
|
|
2578
|
-
|
|
2579
|
-
if (
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
|
|
2583
|
-
}
|
|
2584
|
-
error(append, errorParams, errorPaths) {
|
|
2585
|
-
if (errorParams) {
|
|
2586
|
-
this.setParams(errorParams);
|
|
2587
|
-
this._error(append, errorPaths);
|
|
2588
|
-
this.setParams({});
|
|
2589
|
-
return;
|
|
2613
|
+
function invalid$DataSchema() {
|
|
2614
|
+
if (def2.validateSchema) {
|
|
2615
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
2616
|
+
return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
|
|
2590
2617
|
}
|
|
2591
|
-
|
|
2592
|
-
}
|
|
2593
|
-
_error(append, errorPaths) {
|
|
2594
|
-
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
2595
|
-
}
|
|
2596
|
-
$dataError() {
|
|
2597
|
-
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
2598
|
-
}
|
|
2599
|
-
reset() {
|
|
2600
|
-
if (this.errsCount === void 0)
|
|
2601
|
-
throw new Error('add "trackErrors" to keyword definition');
|
|
2602
|
-
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
2603
|
-
}
|
|
2604
|
-
ok(cond) {
|
|
2605
|
-
if (!this.allErrors)
|
|
2606
|
-
this.gen.if(cond);
|
|
2618
|
+
return codegen_1$n.nil;
|
|
2607
2619
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2620
|
+
}
|
|
2621
|
+
subschema(appl, valid) {
|
|
2622
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
2623
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
2624
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
2625
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
2626
|
+
subschemaCode(nextContext, valid);
|
|
2627
|
+
return nextContext;
|
|
2628
|
+
}
|
|
2629
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
2630
|
+
const { it, gen } = this;
|
|
2631
|
+
if (!it.opts.unevaluated)
|
|
2632
|
+
return;
|
|
2633
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
2634
|
+
it.props = util_1$l.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
2613
2635
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
this.check$data(valid, $dataValid);
|
|
2617
|
-
codeBlock();
|
|
2618
|
-
});
|
|
2636
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
2637
|
+
it.items = util_1$l.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
2619
2638
|
}
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
gen.if(
|
|
2625
|
-
|
|
2626
|
-
gen.assign(valid, true);
|
|
2627
|
-
if (schemaType.length || def2.validateSchema) {
|
|
2628
|
-
gen.elseIf(this.invalid$data());
|
|
2629
|
-
this.$dataError();
|
|
2630
|
-
if (valid !== codegen_12.nil)
|
|
2631
|
-
gen.assign(valid, false);
|
|
2632
|
-
}
|
|
2633
|
-
gen.else();
|
|
2634
|
-
}
|
|
2635
|
-
invalid$data() {
|
|
2636
|
-
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
2637
|
-
return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
|
|
2638
|
-
function wrong$DataType() {
|
|
2639
|
-
if (schemaType.length) {
|
|
2640
|
-
if (!(schemaCode instanceof codegen_12.Name))
|
|
2641
|
-
throw new Error("ajv implementation error");
|
|
2642
|
-
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
2643
|
-
return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
2644
|
-
}
|
|
2645
|
-
return codegen_12.nil;
|
|
2646
|
-
}
|
|
2647
|
-
function invalid$DataSchema() {
|
|
2648
|
-
if (def2.validateSchema) {
|
|
2649
|
-
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
2650
|
-
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
2651
|
-
}
|
|
2652
|
-
return codegen_12.nil;
|
|
2653
|
-
}
|
|
2654
|
-
}
|
|
2655
|
-
subschema(appl, valid) {
|
|
2656
|
-
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
2657
|
-
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
2658
|
-
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
2659
|
-
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
2660
|
-
subschemaCode(nextContext, valid);
|
|
2661
|
-
return nextContext;
|
|
2662
|
-
}
|
|
2663
|
-
mergeEvaluated(schemaCxt, toName) {
|
|
2664
|
-
const { it, gen } = this;
|
|
2665
|
-
if (!it.opts.unevaluated)
|
|
2666
|
-
return;
|
|
2667
|
-
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
2668
|
-
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
2669
|
-
}
|
|
2670
|
-
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
2671
|
-
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
2672
|
-
}
|
|
2639
|
+
}
|
|
2640
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
2641
|
+
const { it, gen } = this;
|
|
2642
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
2643
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
|
|
2644
|
+
return true;
|
|
2673
2645
|
}
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
validate$2.KeywordCxt = KeywordCxt;
|
|
2649
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
2650
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
2651
|
+
if ("code" in def2) {
|
|
2652
|
+
def2.code(cxt, ruleType);
|
|
2653
|
+
} else if (cxt.$data && def2.validate) {
|
|
2654
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2655
|
+
} else if ("macro" in def2) {
|
|
2656
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
2657
|
+
} else if (def2.compile || def2.validate) {
|
|
2658
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
const JSON_POINTER$2 = /^\/(?:[^~]|~0|~1)*$/;
|
|
2662
|
+
const RELATIVE_JSON_POINTER$2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2663
|
+
function getData$1($data, { dataLevel, dataNames, dataPathArr }) {
|
|
2664
|
+
let jsonPointer;
|
|
2665
|
+
let data2;
|
|
2666
|
+
if ($data === "")
|
|
2667
|
+
return names_1$3.default.rootData;
|
|
2668
|
+
if ($data[0] === "/") {
|
|
2669
|
+
if (!JSON_POINTER$2.test($data))
|
|
2670
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2671
|
+
jsonPointer = $data;
|
|
2672
|
+
data2 = names_1$3.default.rootData;
|
|
2673
|
+
} else {
|
|
2674
|
+
const matches = RELATIVE_JSON_POINTER$2.exec($data);
|
|
2675
|
+
if (!matches)
|
|
2676
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2677
|
+
const up = +matches[1];
|
|
2678
|
+
jsonPointer = matches[2];
|
|
2679
|
+
if (jsonPointer === "#") {
|
|
2680
|
+
if (up >= dataLevel)
|
|
2681
|
+
throw new Error(errorMsg("property/index", up));
|
|
2682
|
+
return dataPathArr[dataLevel - up];
|
|
2683
|
+
}
|
|
2684
|
+
if (up > dataLevel)
|
|
2685
|
+
throw new Error(errorMsg("data", up));
|
|
2686
|
+
data2 = dataNames[dataLevel - up];
|
|
2687
|
+
if (!jsonPointer)
|
|
2688
|
+
return data2;
|
|
2689
|
+
}
|
|
2690
|
+
let expr = data2;
|
|
2691
|
+
const segments = jsonPointer.split("/");
|
|
2692
|
+
for (const segment of segments) {
|
|
2693
|
+
if (segment) {
|
|
2694
|
+
data2 = (0, codegen_1$n._)`${data2}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(segment))}`;
|
|
2695
|
+
expr = (0, codegen_1$n._)`${expr} && ${data2}`;
|
|
2680
2696
|
}
|
|
2681
2697
|
}
|
|
2682
|
-
|
|
2683
|
-
function
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
def2.code(cxt, ruleType);
|
|
2687
|
-
} else if (cxt.$data && def2.validate) {
|
|
2688
|
-
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2689
|
-
} else if ("macro" in def2) {
|
|
2690
|
-
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
2691
|
-
} else if (def2.compile || def2.validate) {
|
|
2692
|
-
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
const JSON_POINTER2 = /^\/(?:[^~]|~0|~1)*$/;
|
|
2696
|
-
const RELATIVE_JSON_POINTER2 = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2697
|
-
function getData2($data, { dataLevel, dataNames, dataPathArr }) {
|
|
2698
|
-
let jsonPointer;
|
|
2699
|
-
let data2;
|
|
2700
|
-
if ($data === "")
|
|
2701
|
-
return names_12.default.rootData;
|
|
2702
|
-
if ($data[0] === "/") {
|
|
2703
|
-
if (!JSON_POINTER2.test($data))
|
|
2704
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2705
|
-
jsonPointer = $data;
|
|
2706
|
-
data2 = names_12.default.rootData;
|
|
2707
|
-
} else {
|
|
2708
|
-
const matches = RELATIVE_JSON_POINTER2.exec($data);
|
|
2709
|
-
if (!matches)
|
|
2710
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2711
|
-
const up = +matches[1];
|
|
2712
|
-
jsonPointer = matches[2];
|
|
2713
|
-
if (jsonPointer === "#") {
|
|
2714
|
-
if (up >= dataLevel)
|
|
2715
|
-
throw new Error(errorMsg("property/index", up));
|
|
2716
|
-
return dataPathArr[dataLevel - up];
|
|
2717
|
-
}
|
|
2718
|
-
if (up > dataLevel)
|
|
2719
|
-
throw new Error(errorMsg("data", up));
|
|
2720
|
-
data2 = dataNames[dataLevel - up];
|
|
2721
|
-
if (!jsonPointer)
|
|
2722
|
-
return data2;
|
|
2723
|
-
}
|
|
2724
|
-
let expr = data2;
|
|
2725
|
-
const segments = jsonPointer.split("/");
|
|
2726
|
-
for (const segment of segments) {
|
|
2727
|
-
if (segment) {
|
|
2728
|
-
data2 = (0, codegen_12._)`${data2}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
|
|
2729
|
-
expr = (0, codegen_12._)`${expr} && ${data2}`;
|
|
2730
|
-
}
|
|
2731
|
-
}
|
|
2732
|
-
return expr;
|
|
2733
|
-
function errorMsg(pointerType, up) {
|
|
2734
|
-
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2737
|
-
validate$2.getData = getData2;
|
|
2738
|
-
return validate$2;
|
|
2698
|
+
return expr;
|
|
2699
|
+
function errorMsg(pointerType, up) {
|
|
2700
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
2701
|
+
}
|
|
2739
2702
|
}
|
|
2703
|
+
validate$2.getData = getData$1;
|
|
2740
2704
|
var validation_error = {};
|
|
2741
2705
|
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
2742
2706
|
let ValidationError$2 = class ValidationError extends Error {
|
|
@@ -2766,7 +2730,7 @@
|
|
|
2766
2730
|
const names_1$2 = names$1;
|
|
2767
2731
|
const resolve_1$1 = resolve$6;
|
|
2768
2732
|
const util_1$k = util$7;
|
|
2769
|
-
const validate_1$1 =
|
|
2733
|
+
const validate_1$1 = validate$2;
|
|
2770
2734
|
class SchemaEnv {
|
|
2771
2735
|
constructor(env) {
|
|
2772
2736
|
var _a;
|
|
@@ -3653,7 +3617,7 @@
|
|
|
3653
3617
|
(function(exports3) {
|
|
3654
3618
|
Object.defineProperty(exports3, "__esModule", { value: true });
|
|
3655
3619
|
exports3.CodeGen = exports3.Name = exports3.nil = exports3.stringify = exports3.str = exports3._ = exports3.KeywordCxt = void 0;
|
|
3656
|
-
var validate_12 =
|
|
3620
|
+
var validate_12 = validate$2;
|
|
3657
3621
|
Object.defineProperty(exports3, "KeywordCxt", { enumerable: true, get: function() {
|
|
3658
3622
|
return validate_12.KeywordCxt;
|
|
3659
3623
|
} });
|
|
@@ -4271,7 +4235,7 @@
|
|
|
4271
4235
|
Object.defineProperty(ref$1, "__esModule", { value: true });
|
|
4272
4236
|
ref$1.callRef = ref$1.getValidate = void 0;
|
|
4273
4237
|
const ref_error_1$1 = ref_error;
|
|
4274
|
-
const code_1$8 =
|
|
4238
|
+
const code_1$8 = code;
|
|
4275
4239
|
const codegen_1$l = codegen;
|
|
4276
4240
|
const names_1$1 = names$1;
|
|
4277
4241
|
const compile_1$2 = compile$2;
|
|
@@ -4494,7 +4458,7 @@
|
|
|
4494
4458
|
limitLength.default = def$o;
|
|
4495
4459
|
var pattern$1 = {};
|
|
4496
4460
|
Object.defineProperty(pattern$1, "__esModule", { value: true });
|
|
4497
|
-
const code_1$7 =
|
|
4461
|
+
const code_1$7 = code;
|
|
4498
4462
|
const codegen_1$h = codegen;
|
|
4499
4463
|
const error$f = {
|
|
4500
4464
|
message: ({ schemaCode }) => (0, codegen_1$h.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4539,7 +4503,7 @@
|
|
|
4539
4503
|
limitProperties.default = def$m;
|
|
4540
4504
|
var required$2 = {};
|
|
4541
4505
|
Object.defineProperty(required$2, "__esModule", { value: true });
|
|
4542
|
-
const code_1$6 =
|
|
4506
|
+
const code_1$6 = code;
|
|
4543
4507
|
const codegen_1$f = codegen;
|
|
4544
4508
|
const util_1$h = util$7;
|
|
4545
4509
|
const error$d = {
|
|
@@ -4853,7 +4817,7 @@
|
|
|
4853
4817
|
items$1.validateTuple = void 0;
|
|
4854
4818
|
const codegen_1$9 = codegen;
|
|
4855
4819
|
const util_1$c = util$7;
|
|
4856
|
-
const code_1$5 =
|
|
4820
|
+
const code_1$5 = code;
|
|
4857
4821
|
const def$f = {
|
|
4858
4822
|
keyword: "items",
|
|
4859
4823
|
type: "array",
|
|
@@ -4913,7 +4877,7 @@
|
|
|
4913
4877
|
Object.defineProperty(items2020, "__esModule", { value: true });
|
|
4914
4878
|
const codegen_1$8 = codegen;
|
|
4915
4879
|
const util_1$b = util$7;
|
|
4916
|
-
const code_1$4 =
|
|
4880
|
+
const code_1$4 = code;
|
|
4917
4881
|
const additionalItems_1$1 = additionalItems;
|
|
4918
4882
|
const error$7 = {
|
|
4919
4883
|
message: ({ params: { len } }) => (0, codegen_1$8.str)`must NOT have more than ${len} items`,
|
|
@@ -5032,7 +4996,7 @@
|
|
|
5032
4996
|
exports3.validateSchemaDeps = exports3.validatePropertyDeps = exports3.error = void 0;
|
|
5033
4997
|
const codegen_12 = codegen;
|
|
5034
4998
|
const util_12 = util$7;
|
|
5035
|
-
const code_12 =
|
|
4999
|
+
const code_12 = code;
|
|
5036
5000
|
exports3.error = {
|
|
5037
5001
|
message: ({ params: { property, depsCount, deps } }) => {
|
|
5038
5002
|
const property_ies = depsCount === 1 ? "property" : "properties";
|
|
@@ -5155,7 +5119,7 @@
|
|
|
5155
5119
|
propertyNames$1.default = def$b;
|
|
5156
5120
|
var additionalProperties$1 = {};
|
|
5157
5121
|
Object.defineProperty(additionalProperties$1, "__esModule", { value: true });
|
|
5158
|
-
const code_1$3 =
|
|
5122
|
+
const code_1$3 = code;
|
|
5159
5123
|
const codegen_1$5 = codegen;
|
|
5160
5124
|
const names_1 = names$1;
|
|
5161
5125
|
const util_1$8 = util$7;
|
|
@@ -5255,8 +5219,8 @@
|
|
|
5255
5219
|
additionalProperties$1.default = def$a;
|
|
5256
5220
|
var properties$4 = {};
|
|
5257
5221
|
Object.defineProperty(properties$4, "__esModule", { value: true });
|
|
5258
|
-
const validate_1 =
|
|
5259
|
-
const code_1$2 =
|
|
5222
|
+
const validate_1 = validate$2;
|
|
5223
|
+
const code_1$2 = code;
|
|
5260
5224
|
const util_1$7 = util$7;
|
|
5261
5225
|
const additionalProperties_1$1 = additionalProperties$1;
|
|
5262
5226
|
const def$9 = {
|
|
@@ -5307,7 +5271,7 @@
|
|
|
5307
5271
|
properties$4.default = def$9;
|
|
5308
5272
|
var patternProperties = {};
|
|
5309
5273
|
Object.defineProperty(patternProperties, "__esModule", { value: true });
|
|
5310
|
-
const code_1$1 =
|
|
5274
|
+
const code_1$1 = code;
|
|
5311
5275
|
const codegen_1$4 = codegen;
|
|
5312
5276
|
const util_1$6 = util$7;
|
|
5313
5277
|
const util_2 = util$7;
|
|
@@ -5400,7 +5364,7 @@
|
|
|
5400
5364
|
not$1.default = def$7;
|
|
5401
5365
|
var anyOf$1 = {};
|
|
5402
5366
|
Object.defineProperty(anyOf$1, "__esModule", { value: true });
|
|
5403
|
-
const code_1 =
|
|
5367
|
+
const code_1 = code;
|
|
5404
5368
|
const def$6 = {
|
|
5405
5369
|
keyword: "anyOf",
|
|
5406
5370
|
schemaType: "array",
|
|
@@ -6106,7 +6070,7 @@
|
|
|
6106
6070
|
module2.exports.Ajv = Ajv2;
|
|
6107
6071
|
Object.defineProperty(exports3, "__esModule", { value: true });
|
|
6108
6072
|
exports3.default = Ajv2;
|
|
6109
|
-
var validate_12 =
|
|
6073
|
+
var validate_12 = validate$2;
|
|
6110
6074
|
Object.defineProperty(exports3, "KeywordCxt", { enumerable: true, get: function() {
|
|
6111
6075
|
return validate_12.KeywordCxt;
|
|
6112
6076
|
} });
|
|
@@ -13582,7 +13546,7 @@
|
|
|
13582
13546
|
util: util$2,
|
|
13583
13547
|
resolve: resolve$1,
|
|
13584
13548
|
resolveRef: resolveRef2,
|
|
13585
|
-
usePattern,
|
|
13549
|
+
usePattern: usePattern2,
|
|
13586
13550
|
useDefault,
|
|
13587
13551
|
useCustomRule,
|
|
13588
13552
|
opts,
|
|
@@ -13687,7 +13651,7 @@
|
|
|
13687
13651
|
function resolvedRef(refVal2, code2) {
|
|
13688
13652
|
return typeof refVal2 == "object" || typeof refVal2 == "boolean" ? { code: code2, schema: refVal2, inline: true } : { code: code2, $async: refVal2 && !!refVal2.$async };
|
|
13689
13653
|
}
|
|
13690
|
-
function
|
|
13654
|
+
function usePattern2(regexStr) {
|
|
13691
13655
|
var index = patternsHash[regexStr];
|
|
13692
13656
|
if (index === void 0) {
|
|
13693
13657
|
index = patternsHash[regexStr] = patterns.length;
|
|
@@ -22658,25 +22622,14 @@
|
|
|
22658
22622
|
await this.client.connect(this.transport);
|
|
22659
22623
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|
|
22660
22624
|
}
|
|
22661
|
-
const { url, token, sessionId,
|
|
22625
|
+
const { url, token, sessionId, type: type2, agent, onError } = options;
|
|
22662
22626
|
if (agent === true) {
|
|
22663
|
-
const proxyOptions = { client: this.client, url, token, sessionId
|
|
22664
|
-
let reconnect = false;
|
|
22627
|
+
const proxyOptions = { client: this.client, url, token, sessionId };
|
|
22665
22628
|
let response;
|
|
22666
22629
|
const connectProxy = async () => {
|
|
22667
22630
|
const { transport: transport2, sessionId: sessionId2 } = type2 === "sse" ? await createSseProxy(proxyOptions) : type2 === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
|
|
22668
22631
|
transport2.onerror = async (error2) => {
|
|
22669
22632
|
onError == null ? void 0 : onError(error2);
|
|
22670
|
-
if (error2.message === "Unauthorized" && !reconnect) {
|
|
22671
|
-
if (typeof onUnauthorized === "function") {
|
|
22672
|
-
await onUnauthorized(connectProxy);
|
|
22673
|
-
} else {
|
|
22674
|
-
reconnect = true;
|
|
22675
|
-
await connectProxy();
|
|
22676
|
-
reconnect = false;
|
|
22677
|
-
await (onReconnect == null ? void 0 : onReconnect());
|
|
22678
|
-
}
|
|
22679
|
-
}
|
|
22680
22633
|
};
|
|
22681
22634
|
response = { transport: transport2, sessionId: sessionId2 };
|
|
22682
22635
|
};
|
|
@@ -22690,14 +22643,9 @@
|
|
|
22690
22643
|
await this.client.connect(transport);
|
|
22691
22644
|
}
|
|
22692
22645
|
if (type2 === "sse") {
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
} else {
|
|
22697
|
-
const opts = sseOptions(token, sessionId);
|
|
22698
|
-
transport = new SSEClientTransport(endpoint, opts);
|
|
22699
|
-
await this.client.connect(transport);
|
|
22700
|
-
}
|
|
22646
|
+
const opts = sseOptions(token, sessionId);
|
|
22647
|
+
transport = new SSEClientTransport(endpoint, opts);
|
|
22648
|
+
await this.client.connect(transport);
|
|
22701
22649
|
}
|
|
22702
22650
|
if (type2 === "socket") {
|
|
22703
22651
|
transport = new WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
|
|
@@ -22705,14 +22653,9 @@
|
|
|
22705
22653
|
await this.client.connect(transport);
|
|
22706
22654
|
}
|
|
22707
22655
|
if (typeof transport === "undefined") {
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
} else {
|
|
22712
|
-
const opts = streamOptions(token, sessionId);
|
|
22713
|
-
transport = new StreamableHTTPClientTransport(endpoint, opts);
|
|
22714
|
-
await this.client.connect(transport);
|
|
22715
|
-
}
|
|
22656
|
+
const opts = streamOptions(token, sessionId);
|
|
22657
|
+
transport = new StreamableHTTPClientTransport(endpoint, opts);
|
|
22658
|
+
await this.client.connect(transport);
|
|
22716
22659
|
}
|
|
22717
22660
|
this.transport = transport;
|
|
22718
22661
|
return { transport: this.transport, sessionId: this.transport.sessionId };
|