@settlemint/sdk-mcp 2.1.4-main8c2f241d → 2.1.4-main933472a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp.js +102 -4107
- package/dist/mcp.js.map +3 -4
- package/package.json +4 -4
package/dist/mcp.js
CHANGED
|
@@ -61129,7 +61129,7 @@ var {
|
|
|
61129
61129
|
var package_default = {
|
|
61130
61130
|
name: "@settlemint/sdk-mcp",
|
|
61131
61131
|
description: "MCP interface for SettleMint SDK, providing development tools and project management capabilities",
|
|
61132
|
-
version: "2.1.4-
|
|
61132
|
+
version: "2.1.4-main933472a6",
|
|
61133
61133
|
type: "module",
|
|
61134
61134
|
private: false,
|
|
61135
61135
|
license: "FSL-1.1-MIT",
|
|
@@ -61171,11 +61171,11 @@ var package_default = {
|
|
|
61171
61171
|
"@graphql-tools/load": "8.1.0",
|
|
61172
61172
|
"@graphql-tools/url-loader": "8.0.31",
|
|
61173
61173
|
"@modelcontextprotocol/sdk": "1.10.2",
|
|
61174
|
-
"@settlemint/sdk-js": "2.1.4-
|
|
61175
|
-
"@settlemint/sdk-utils": "2.1.4-
|
|
61174
|
+
"@settlemint/sdk-js": "2.1.4-main933472a6",
|
|
61175
|
+
"@settlemint/sdk-utils": "2.1.4-main933472a6",
|
|
61176
61176
|
"@commander-js/extra-typings": "11.1.0",
|
|
61177
61177
|
commander: "11.1.0",
|
|
61178
|
-
zod: "3.24.
|
|
61178
|
+
zod: "3.24.3"
|
|
61179
61179
|
},
|
|
61180
61180
|
devDependencies: {},
|
|
61181
61181
|
peerDependencies: {},
|
|
@@ -62064,4011 +62064,6 @@ ${fieldSDL}
|
|
|
62064
62064
|
${typeSDLs}`;
|
|
62065
62065
|
};
|
|
62066
62066
|
|
|
62067
|
-
// node_modules/zod/lib/index.mjs
|
|
62068
|
-
var util2;
|
|
62069
|
-
(function(util3) {
|
|
62070
|
-
util3.assertEqual = (val) => val;
|
|
62071
|
-
function assertIs(_arg) {}
|
|
62072
|
-
util3.assertIs = assertIs;
|
|
62073
|
-
function assertNever(_x) {
|
|
62074
|
-
throw new Error;
|
|
62075
|
-
}
|
|
62076
|
-
util3.assertNever = assertNever;
|
|
62077
|
-
util3.arrayToEnum = (items) => {
|
|
62078
|
-
const obj = {};
|
|
62079
|
-
for (const item of items) {
|
|
62080
|
-
obj[item] = item;
|
|
62081
|
-
}
|
|
62082
|
-
return obj;
|
|
62083
|
-
};
|
|
62084
|
-
util3.getValidEnumValues = (obj) => {
|
|
62085
|
-
const validKeys = util3.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
62086
|
-
const filtered = {};
|
|
62087
|
-
for (const k of validKeys) {
|
|
62088
|
-
filtered[k] = obj[k];
|
|
62089
|
-
}
|
|
62090
|
-
return util3.objectValues(filtered);
|
|
62091
|
-
};
|
|
62092
|
-
util3.objectValues = (obj) => {
|
|
62093
|
-
return util3.objectKeys(obj).map(function(e3) {
|
|
62094
|
-
return obj[e3];
|
|
62095
|
-
});
|
|
62096
|
-
};
|
|
62097
|
-
util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object2) => {
|
|
62098
|
-
const keys = [];
|
|
62099
|
-
for (const key in object2) {
|
|
62100
|
-
if (Object.prototype.hasOwnProperty.call(object2, key)) {
|
|
62101
|
-
keys.push(key);
|
|
62102
|
-
}
|
|
62103
|
-
}
|
|
62104
|
-
return keys;
|
|
62105
|
-
};
|
|
62106
|
-
util3.find = (arr, checker) => {
|
|
62107
|
-
for (const item of arr) {
|
|
62108
|
-
if (checker(item))
|
|
62109
|
-
return item;
|
|
62110
|
-
}
|
|
62111
|
-
return;
|
|
62112
|
-
};
|
|
62113
|
-
util3.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
62114
|
-
function joinValues(array2, separator = " | ") {
|
|
62115
|
-
return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
62116
|
-
}
|
|
62117
|
-
util3.joinValues = joinValues;
|
|
62118
|
-
util3.jsonStringifyReplacer = (_, value) => {
|
|
62119
|
-
if (typeof value === "bigint") {
|
|
62120
|
-
return value.toString();
|
|
62121
|
-
}
|
|
62122
|
-
return value;
|
|
62123
|
-
};
|
|
62124
|
-
})(util2 || (util2 = {}));
|
|
62125
|
-
var objectUtil2;
|
|
62126
|
-
(function(objectUtil3) {
|
|
62127
|
-
objectUtil3.mergeShapes = (first, second) => {
|
|
62128
|
-
return {
|
|
62129
|
-
...first,
|
|
62130
|
-
...second
|
|
62131
|
-
};
|
|
62132
|
-
};
|
|
62133
|
-
})(objectUtil2 || (objectUtil2 = {}));
|
|
62134
|
-
var ZodParsedType2 = util2.arrayToEnum([
|
|
62135
|
-
"string",
|
|
62136
|
-
"nan",
|
|
62137
|
-
"number",
|
|
62138
|
-
"integer",
|
|
62139
|
-
"float",
|
|
62140
|
-
"boolean",
|
|
62141
|
-
"date",
|
|
62142
|
-
"bigint",
|
|
62143
|
-
"symbol",
|
|
62144
|
-
"function",
|
|
62145
|
-
"undefined",
|
|
62146
|
-
"null",
|
|
62147
|
-
"array",
|
|
62148
|
-
"object",
|
|
62149
|
-
"unknown",
|
|
62150
|
-
"promise",
|
|
62151
|
-
"void",
|
|
62152
|
-
"never",
|
|
62153
|
-
"map",
|
|
62154
|
-
"set"
|
|
62155
|
-
]);
|
|
62156
|
-
var getParsedType2 = (data) => {
|
|
62157
|
-
const t2 = typeof data;
|
|
62158
|
-
switch (t2) {
|
|
62159
|
-
case "undefined":
|
|
62160
|
-
return ZodParsedType2.undefined;
|
|
62161
|
-
case "string":
|
|
62162
|
-
return ZodParsedType2.string;
|
|
62163
|
-
case "number":
|
|
62164
|
-
return isNaN(data) ? ZodParsedType2.nan : ZodParsedType2.number;
|
|
62165
|
-
case "boolean":
|
|
62166
|
-
return ZodParsedType2.boolean;
|
|
62167
|
-
case "function":
|
|
62168
|
-
return ZodParsedType2.function;
|
|
62169
|
-
case "bigint":
|
|
62170
|
-
return ZodParsedType2.bigint;
|
|
62171
|
-
case "symbol":
|
|
62172
|
-
return ZodParsedType2.symbol;
|
|
62173
|
-
case "object":
|
|
62174
|
-
if (Array.isArray(data)) {
|
|
62175
|
-
return ZodParsedType2.array;
|
|
62176
|
-
}
|
|
62177
|
-
if (data === null) {
|
|
62178
|
-
return ZodParsedType2.null;
|
|
62179
|
-
}
|
|
62180
|
-
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
62181
|
-
return ZodParsedType2.promise;
|
|
62182
|
-
}
|
|
62183
|
-
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
62184
|
-
return ZodParsedType2.map;
|
|
62185
|
-
}
|
|
62186
|
-
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
62187
|
-
return ZodParsedType2.set;
|
|
62188
|
-
}
|
|
62189
|
-
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
62190
|
-
return ZodParsedType2.date;
|
|
62191
|
-
}
|
|
62192
|
-
return ZodParsedType2.object;
|
|
62193
|
-
default:
|
|
62194
|
-
return ZodParsedType2.unknown;
|
|
62195
|
-
}
|
|
62196
|
-
};
|
|
62197
|
-
var ZodIssueCode2 = util2.arrayToEnum([
|
|
62198
|
-
"invalid_type",
|
|
62199
|
-
"invalid_literal",
|
|
62200
|
-
"custom",
|
|
62201
|
-
"invalid_union",
|
|
62202
|
-
"invalid_union_discriminator",
|
|
62203
|
-
"invalid_enum_value",
|
|
62204
|
-
"unrecognized_keys",
|
|
62205
|
-
"invalid_arguments",
|
|
62206
|
-
"invalid_return_type",
|
|
62207
|
-
"invalid_date",
|
|
62208
|
-
"invalid_string",
|
|
62209
|
-
"too_small",
|
|
62210
|
-
"too_big",
|
|
62211
|
-
"invalid_intersection_types",
|
|
62212
|
-
"not_multiple_of",
|
|
62213
|
-
"not_finite"
|
|
62214
|
-
]);
|
|
62215
|
-
var quotelessJson2 = (obj) => {
|
|
62216
|
-
const json = JSON.stringify(obj, null, 2);
|
|
62217
|
-
return json.replace(/"([^"]+)":/g, "$1:");
|
|
62218
|
-
};
|
|
62219
|
-
|
|
62220
|
-
class ZodError2 extends Error {
|
|
62221
|
-
get errors() {
|
|
62222
|
-
return this.issues;
|
|
62223
|
-
}
|
|
62224
|
-
constructor(issues) {
|
|
62225
|
-
super();
|
|
62226
|
-
this.issues = [];
|
|
62227
|
-
this.addIssue = (sub) => {
|
|
62228
|
-
this.issues = [...this.issues, sub];
|
|
62229
|
-
};
|
|
62230
|
-
this.addIssues = (subs = []) => {
|
|
62231
|
-
this.issues = [...this.issues, ...subs];
|
|
62232
|
-
};
|
|
62233
|
-
const actualProto = new.target.prototype;
|
|
62234
|
-
if (Object.setPrototypeOf) {
|
|
62235
|
-
Object.setPrototypeOf(this, actualProto);
|
|
62236
|
-
} else {
|
|
62237
|
-
this.__proto__ = actualProto;
|
|
62238
|
-
}
|
|
62239
|
-
this.name = "ZodError";
|
|
62240
|
-
this.issues = issues;
|
|
62241
|
-
}
|
|
62242
|
-
format(_mapper) {
|
|
62243
|
-
const mapper = _mapper || function(issue) {
|
|
62244
|
-
return issue.message;
|
|
62245
|
-
};
|
|
62246
|
-
const fieldErrors = { _errors: [] };
|
|
62247
|
-
const processError = (error) => {
|
|
62248
|
-
for (const issue of error.issues) {
|
|
62249
|
-
if (issue.code === "invalid_union") {
|
|
62250
|
-
issue.unionErrors.map(processError);
|
|
62251
|
-
} else if (issue.code === "invalid_return_type") {
|
|
62252
|
-
processError(issue.returnTypeError);
|
|
62253
|
-
} else if (issue.code === "invalid_arguments") {
|
|
62254
|
-
processError(issue.argumentsError);
|
|
62255
|
-
} else if (issue.path.length === 0) {
|
|
62256
|
-
fieldErrors._errors.push(mapper(issue));
|
|
62257
|
-
} else {
|
|
62258
|
-
let curr = fieldErrors;
|
|
62259
|
-
let i = 0;
|
|
62260
|
-
while (i < issue.path.length) {
|
|
62261
|
-
const el = issue.path[i];
|
|
62262
|
-
const terminal = i === issue.path.length - 1;
|
|
62263
|
-
if (!terminal) {
|
|
62264
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
62265
|
-
} else {
|
|
62266
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
62267
|
-
curr[el]._errors.push(mapper(issue));
|
|
62268
|
-
}
|
|
62269
|
-
curr = curr[el];
|
|
62270
|
-
i++;
|
|
62271
|
-
}
|
|
62272
|
-
}
|
|
62273
|
-
}
|
|
62274
|
-
};
|
|
62275
|
-
processError(this);
|
|
62276
|
-
return fieldErrors;
|
|
62277
|
-
}
|
|
62278
|
-
static assert(value) {
|
|
62279
|
-
if (!(value instanceof ZodError2)) {
|
|
62280
|
-
throw new Error(`Not a ZodError: ${value}`);
|
|
62281
|
-
}
|
|
62282
|
-
}
|
|
62283
|
-
toString() {
|
|
62284
|
-
return this.message;
|
|
62285
|
-
}
|
|
62286
|
-
get message() {
|
|
62287
|
-
return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
|
|
62288
|
-
}
|
|
62289
|
-
get isEmpty() {
|
|
62290
|
-
return this.issues.length === 0;
|
|
62291
|
-
}
|
|
62292
|
-
flatten(mapper = (issue) => issue.message) {
|
|
62293
|
-
const fieldErrors = {};
|
|
62294
|
-
const formErrors = [];
|
|
62295
|
-
for (const sub of this.issues) {
|
|
62296
|
-
if (sub.path.length > 0) {
|
|
62297
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
62298
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
62299
|
-
} else {
|
|
62300
|
-
formErrors.push(mapper(sub));
|
|
62301
|
-
}
|
|
62302
|
-
}
|
|
62303
|
-
return { formErrors, fieldErrors };
|
|
62304
|
-
}
|
|
62305
|
-
get formErrors() {
|
|
62306
|
-
return this.flatten();
|
|
62307
|
-
}
|
|
62308
|
-
}
|
|
62309
|
-
ZodError2.create = (issues) => {
|
|
62310
|
-
const error = new ZodError2(issues);
|
|
62311
|
-
return error;
|
|
62312
|
-
};
|
|
62313
|
-
var errorMap2 = (issue, _ctx) => {
|
|
62314
|
-
let message;
|
|
62315
|
-
switch (issue.code) {
|
|
62316
|
-
case ZodIssueCode2.invalid_type:
|
|
62317
|
-
if (issue.received === ZodParsedType2.undefined) {
|
|
62318
|
-
message = "Required";
|
|
62319
|
-
} else {
|
|
62320
|
-
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
62321
|
-
}
|
|
62322
|
-
break;
|
|
62323
|
-
case ZodIssueCode2.invalid_literal:
|
|
62324
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util2.jsonStringifyReplacer)}`;
|
|
62325
|
-
break;
|
|
62326
|
-
case ZodIssueCode2.unrecognized_keys:
|
|
62327
|
-
message = `Unrecognized key(s) in object: ${util2.joinValues(issue.keys, ", ")}`;
|
|
62328
|
-
break;
|
|
62329
|
-
case ZodIssueCode2.invalid_union:
|
|
62330
|
-
message = `Invalid input`;
|
|
62331
|
-
break;
|
|
62332
|
-
case ZodIssueCode2.invalid_union_discriminator:
|
|
62333
|
-
message = `Invalid discriminator value. Expected ${util2.joinValues(issue.options)}`;
|
|
62334
|
-
break;
|
|
62335
|
-
case ZodIssueCode2.invalid_enum_value:
|
|
62336
|
-
message = `Invalid enum value. Expected ${util2.joinValues(issue.options)}, received '${issue.received}'`;
|
|
62337
|
-
break;
|
|
62338
|
-
case ZodIssueCode2.invalid_arguments:
|
|
62339
|
-
message = `Invalid function arguments`;
|
|
62340
|
-
break;
|
|
62341
|
-
case ZodIssueCode2.invalid_return_type:
|
|
62342
|
-
message = `Invalid function return type`;
|
|
62343
|
-
break;
|
|
62344
|
-
case ZodIssueCode2.invalid_date:
|
|
62345
|
-
message = `Invalid date`;
|
|
62346
|
-
break;
|
|
62347
|
-
case ZodIssueCode2.invalid_string:
|
|
62348
|
-
if (typeof issue.validation === "object") {
|
|
62349
|
-
if ("includes" in issue.validation) {
|
|
62350
|
-
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
62351
|
-
if (typeof issue.validation.position === "number") {
|
|
62352
|
-
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
62353
|
-
}
|
|
62354
|
-
} else if ("startsWith" in issue.validation) {
|
|
62355
|
-
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
62356
|
-
} else if ("endsWith" in issue.validation) {
|
|
62357
|
-
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
62358
|
-
} else {
|
|
62359
|
-
util2.assertNever(issue.validation);
|
|
62360
|
-
}
|
|
62361
|
-
} else if (issue.validation !== "regex") {
|
|
62362
|
-
message = `Invalid ${issue.validation}`;
|
|
62363
|
-
} else {
|
|
62364
|
-
message = "Invalid";
|
|
62365
|
-
}
|
|
62366
|
-
break;
|
|
62367
|
-
case ZodIssueCode2.too_small:
|
|
62368
|
-
if (issue.type === "array")
|
|
62369
|
-
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
62370
|
-
else if (issue.type === "string")
|
|
62371
|
-
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
62372
|
-
else if (issue.type === "number")
|
|
62373
|
-
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
62374
|
-
else if (issue.type === "date")
|
|
62375
|
-
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
62376
|
-
else
|
|
62377
|
-
message = "Invalid input";
|
|
62378
|
-
break;
|
|
62379
|
-
case ZodIssueCode2.too_big:
|
|
62380
|
-
if (issue.type === "array")
|
|
62381
|
-
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
62382
|
-
else if (issue.type === "string")
|
|
62383
|
-
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
62384
|
-
else if (issue.type === "number")
|
|
62385
|
-
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
62386
|
-
else if (issue.type === "bigint")
|
|
62387
|
-
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
62388
|
-
else if (issue.type === "date")
|
|
62389
|
-
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
62390
|
-
else
|
|
62391
|
-
message = "Invalid input";
|
|
62392
|
-
break;
|
|
62393
|
-
case ZodIssueCode2.custom:
|
|
62394
|
-
message = `Invalid input`;
|
|
62395
|
-
break;
|
|
62396
|
-
case ZodIssueCode2.invalid_intersection_types:
|
|
62397
|
-
message = `Intersection results could not be merged`;
|
|
62398
|
-
break;
|
|
62399
|
-
case ZodIssueCode2.not_multiple_of:
|
|
62400
|
-
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
62401
|
-
break;
|
|
62402
|
-
case ZodIssueCode2.not_finite:
|
|
62403
|
-
message = "Number must be finite";
|
|
62404
|
-
break;
|
|
62405
|
-
default:
|
|
62406
|
-
message = _ctx.defaultError;
|
|
62407
|
-
util2.assertNever(issue);
|
|
62408
|
-
}
|
|
62409
|
-
return { message };
|
|
62410
|
-
};
|
|
62411
|
-
var overrideErrorMap2 = errorMap2;
|
|
62412
|
-
function setErrorMap2(map2) {
|
|
62413
|
-
overrideErrorMap2 = map2;
|
|
62414
|
-
}
|
|
62415
|
-
function getErrorMap2() {
|
|
62416
|
-
return overrideErrorMap2;
|
|
62417
|
-
}
|
|
62418
|
-
var makeIssue2 = (params) => {
|
|
62419
|
-
const { data, path: path2, errorMaps, issueData } = params;
|
|
62420
|
-
const fullPath = [...path2, ...issueData.path || []];
|
|
62421
|
-
const fullIssue = {
|
|
62422
|
-
...issueData,
|
|
62423
|
-
path: fullPath
|
|
62424
|
-
};
|
|
62425
|
-
if (issueData.message !== undefined) {
|
|
62426
|
-
return {
|
|
62427
|
-
...issueData,
|
|
62428
|
-
path: fullPath,
|
|
62429
|
-
message: issueData.message
|
|
62430
|
-
};
|
|
62431
|
-
}
|
|
62432
|
-
let errorMessage = "";
|
|
62433
|
-
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
62434
|
-
for (const map2 of maps) {
|
|
62435
|
-
errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
|
|
62436
|
-
}
|
|
62437
|
-
return {
|
|
62438
|
-
...issueData,
|
|
62439
|
-
path: fullPath,
|
|
62440
|
-
message: errorMessage
|
|
62441
|
-
};
|
|
62442
|
-
};
|
|
62443
|
-
var EMPTY_PATH2 = [];
|
|
62444
|
-
function addIssueToContext2(ctx, issueData) {
|
|
62445
|
-
const overrideMap = getErrorMap2();
|
|
62446
|
-
const issue = makeIssue2({
|
|
62447
|
-
issueData,
|
|
62448
|
-
data: ctx.data,
|
|
62449
|
-
path: ctx.path,
|
|
62450
|
-
errorMaps: [
|
|
62451
|
-
ctx.common.contextualErrorMap,
|
|
62452
|
-
ctx.schemaErrorMap,
|
|
62453
|
-
overrideMap,
|
|
62454
|
-
overrideMap === errorMap2 ? undefined : errorMap2
|
|
62455
|
-
].filter((x) => !!x)
|
|
62456
|
-
});
|
|
62457
|
-
ctx.common.issues.push(issue);
|
|
62458
|
-
}
|
|
62459
|
-
|
|
62460
|
-
class ParseStatus2 {
|
|
62461
|
-
constructor() {
|
|
62462
|
-
this.value = "valid";
|
|
62463
|
-
}
|
|
62464
|
-
dirty() {
|
|
62465
|
-
if (this.value === "valid")
|
|
62466
|
-
this.value = "dirty";
|
|
62467
|
-
}
|
|
62468
|
-
abort() {
|
|
62469
|
-
if (this.value !== "aborted")
|
|
62470
|
-
this.value = "aborted";
|
|
62471
|
-
}
|
|
62472
|
-
static mergeArray(status, results) {
|
|
62473
|
-
const arrayValue = [];
|
|
62474
|
-
for (const s of results) {
|
|
62475
|
-
if (s.status === "aborted")
|
|
62476
|
-
return INVALID2;
|
|
62477
|
-
if (s.status === "dirty")
|
|
62478
|
-
status.dirty();
|
|
62479
|
-
arrayValue.push(s.value);
|
|
62480
|
-
}
|
|
62481
|
-
return { status: status.value, value: arrayValue };
|
|
62482
|
-
}
|
|
62483
|
-
static async mergeObjectAsync(status, pairs) {
|
|
62484
|
-
const syncPairs = [];
|
|
62485
|
-
for (const pair of pairs) {
|
|
62486
|
-
const key = await pair.key;
|
|
62487
|
-
const value = await pair.value;
|
|
62488
|
-
syncPairs.push({
|
|
62489
|
-
key,
|
|
62490
|
-
value
|
|
62491
|
-
});
|
|
62492
|
-
}
|
|
62493
|
-
return ParseStatus2.mergeObjectSync(status, syncPairs);
|
|
62494
|
-
}
|
|
62495
|
-
static mergeObjectSync(status, pairs) {
|
|
62496
|
-
const finalObject = {};
|
|
62497
|
-
for (const pair of pairs) {
|
|
62498
|
-
const { key, value } = pair;
|
|
62499
|
-
if (key.status === "aborted")
|
|
62500
|
-
return INVALID2;
|
|
62501
|
-
if (value.status === "aborted")
|
|
62502
|
-
return INVALID2;
|
|
62503
|
-
if (key.status === "dirty")
|
|
62504
|
-
status.dirty();
|
|
62505
|
-
if (value.status === "dirty")
|
|
62506
|
-
status.dirty();
|
|
62507
|
-
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
62508
|
-
finalObject[key.value] = value.value;
|
|
62509
|
-
}
|
|
62510
|
-
}
|
|
62511
|
-
return { status: status.value, value: finalObject };
|
|
62512
|
-
}
|
|
62513
|
-
}
|
|
62514
|
-
var INVALID2 = Object.freeze({
|
|
62515
|
-
status: "aborted"
|
|
62516
|
-
});
|
|
62517
|
-
var DIRTY2 = (value) => ({ status: "dirty", value });
|
|
62518
|
-
var OK2 = (value) => ({ status: "valid", value });
|
|
62519
|
-
var isAborted2 = (x) => x.status === "aborted";
|
|
62520
|
-
var isDirty2 = (x) => x.status === "dirty";
|
|
62521
|
-
var isValid2 = (x) => x.status === "valid";
|
|
62522
|
-
var isAsync2 = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
62523
|
-
function __classPrivateFieldGet2(receiver, state, kind, f) {
|
|
62524
|
-
if (kind === "a" && !f)
|
|
62525
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
62526
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
62527
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
62528
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
62529
|
-
}
|
|
62530
|
-
function __classPrivateFieldSet2(receiver, state, value, kind, f) {
|
|
62531
|
-
if (kind === "m")
|
|
62532
|
-
throw new TypeError("Private method is not writable");
|
|
62533
|
-
if (kind === "a" && !f)
|
|
62534
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
62535
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
62536
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
62537
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
62538
|
-
}
|
|
62539
|
-
var errorUtil2;
|
|
62540
|
-
(function(errorUtil3) {
|
|
62541
|
-
errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
62542
|
-
errorUtil3.toString = (message) => typeof message === "string" ? message : message === null || message === undefined ? undefined : message.message;
|
|
62543
|
-
})(errorUtil2 || (errorUtil2 = {}));
|
|
62544
|
-
var _ZodEnum_cache2;
|
|
62545
|
-
var _ZodNativeEnum_cache2;
|
|
62546
|
-
|
|
62547
|
-
class ParseInputLazyPath2 {
|
|
62548
|
-
constructor(parent, value, path2, key) {
|
|
62549
|
-
this._cachedPath = [];
|
|
62550
|
-
this.parent = parent;
|
|
62551
|
-
this.data = value;
|
|
62552
|
-
this._path = path2;
|
|
62553
|
-
this._key = key;
|
|
62554
|
-
}
|
|
62555
|
-
get path() {
|
|
62556
|
-
if (!this._cachedPath.length) {
|
|
62557
|
-
if (this._key instanceof Array) {
|
|
62558
|
-
this._cachedPath.push(...this._path, ...this._key);
|
|
62559
|
-
} else {
|
|
62560
|
-
this._cachedPath.push(...this._path, this._key);
|
|
62561
|
-
}
|
|
62562
|
-
}
|
|
62563
|
-
return this._cachedPath;
|
|
62564
|
-
}
|
|
62565
|
-
}
|
|
62566
|
-
var handleResult3 = (ctx, result) => {
|
|
62567
|
-
if (isValid2(result)) {
|
|
62568
|
-
return { success: true, data: result.value };
|
|
62569
|
-
} else {
|
|
62570
|
-
if (!ctx.common.issues.length) {
|
|
62571
|
-
throw new Error("Validation failed but no issues detected.");
|
|
62572
|
-
}
|
|
62573
|
-
return {
|
|
62574
|
-
success: false,
|
|
62575
|
-
get error() {
|
|
62576
|
-
if (this._error)
|
|
62577
|
-
return this._error;
|
|
62578
|
-
const error = new ZodError2(ctx.common.issues);
|
|
62579
|
-
this._error = error;
|
|
62580
|
-
return this._error;
|
|
62581
|
-
}
|
|
62582
|
-
};
|
|
62583
|
-
}
|
|
62584
|
-
};
|
|
62585
|
-
function processCreateParams3(params) {
|
|
62586
|
-
if (!params)
|
|
62587
|
-
return {};
|
|
62588
|
-
const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
|
|
62589
|
-
if (errorMap3 && (invalid_type_error || required_error)) {
|
|
62590
|
-
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
62591
|
-
}
|
|
62592
|
-
if (errorMap3)
|
|
62593
|
-
return { errorMap: errorMap3, description };
|
|
62594
|
-
const customMap = (iss, ctx) => {
|
|
62595
|
-
var _a, _b;
|
|
62596
|
-
const { message } = params;
|
|
62597
|
-
if (iss.code === "invalid_enum_value") {
|
|
62598
|
-
return { message: message !== null && message !== undefined ? message : ctx.defaultError };
|
|
62599
|
-
}
|
|
62600
|
-
if (typeof ctx.data === "undefined") {
|
|
62601
|
-
return { message: (_a = message !== null && message !== undefined ? message : required_error) !== null && _a !== undefined ? _a : ctx.defaultError };
|
|
62602
|
-
}
|
|
62603
|
-
if (iss.code !== "invalid_type")
|
|
62604
|
-
return { message: ctx.defaultError };
|
|
62605
|
-
return { message: (_b = message !== null && message !== undefined ? message : invalid_type_error) !== null && _b !== undefined ? _b : ctx.defaultError };
|
|
62606
|
-
};
|
|
62607
|
-
return { errorMap: customMap, description };
|
|
62608
|
-
}
|
|
62609
|
-
|
|
62610
|
-
class ZodType2 {
|
|
62611
|
-
get description() {
|
|
62612
|
-
return this._def.description;
|
|
62613
|
-
}
|
|
62614
|
-
_getType(input) {
|
|
62615
|
-
return getParsedType2(input.data);
|
|
62616
|
-
}
|
|
62617
|
-
_getOrReturnCtx(input, ctx) {
|
|
62618
|
-
return ctx || {
|
|
62619
|
-
common: input.parent.common,
|
|
62620
|
-
data: input.data,
|
|
62621
|
-
parsedType: getParsedType2(input.data),
|
|
62622
|
-
schemaErrorMap: this._def.errorMap,
|
|
62623
|
-
path: input.path,
|
|
62624
|
-
parent: input.parent
|
|
62625
|
-
};
|
|
62626
|
-
}
|
|
62627
|
-
_processInputParams(input) {
|
|
62628
|
-
return {
|
|
62629
|
-
status: new ParseStatus2,
|
|
62630
|
-
ctx: {
|
|
62631
|
-
common: input.parent.common,
|
|
62632
|
-
data: input.data,
|
|
62633
|
-
parsedType: getParsedType2(input.data),
|
|
62634
|
-
schemaErrorMap: this._def.errorMap,
|
|
62635
|
-
path: input.path,
|
|
62636
|
-
parent: input.parent
|
|
62637
|
-
}
|
|
62638
|
-
};
|
|
62639
|
-
}
|
|
62640
|
-
_parseSync(input) {
|
|
62641
|
-
const result = this._parse(input);
|
|
62642
|
-
if (isAsync2(result)) {
|
|
62643
|
-
throw new Error("Synchronous parse encountered promise.");
|
|
62644
|
-
}
|
|
62645
|
-
return result;
|
|
62646
|
-
}
|
|
62647
|
-
_parseAsync(input) {
|
|
62648
|
-
const result = this._parse(input);
|
|
62649
|
-
return Promise.resolve(result);
|
|
62650
|
-
}
|
|
62651
|
-
parse(data, params) {
|
|
62652
|
-
const result = this.safeParse(data, params);
|
|
62653
|
-
if (result.success)
|
|
62654
|
-
return result.data;
|
|
62655
|
-
throw result.error;
|
|
62656
|
-
}
|
|
62657
|
-
safeParse(data, params) {
|
|
62658
|
-
var _a;
|
|
62659
|
-
const ctx = {
|
|
62660
|
-
common: {
|
|
62661
|
-
issues: [],
|
|
62662
|
-
async: (_a = params === null || params === undefined ? undefined : params.async) !== null && _a !== undefined ? _a : false,
|
|
62663
|
-
contextualErrorMap: params === null || params === undefined ? undefined : params.errorMap
|
|
62664
|
-
},
|
|
62665
|
-
path: (params === null || params === undefined ? undefined : params.path) || [],
|
|
62666
|
-
schemaErrorMap: this._def.errorMap,
|
|
62667
|
-
parent: null,
|
|
62668
|
-
data,
|
|
62669
|
-
parsedType: getParsedType2(data)
|
|
62670
|
-
};
|
|
62671
|
-
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
62672
|
-
return handleResult3(ctx, result);
|
|
62673
|
-
}
|
|
62674
|
-
"~validate"(data) {
|
|
62675
|
-
var _a, _b;
|
|
62676
|
-
const ctx = {
|
|
62677
|
-
common: {
|
|
62678
|
-
issues: [],
|
|
62679
|
-
async: !!this["~standard"].async
|
|
62680
|
-
},
|
|
62681
|
-
path: [],
|
|
62682
|
-
schemaErrorMap: this._def.errorMap,
|
|
62683
|
-
parent: null,
|
|
62684
|
-
data,
|
|
62685
|
-
parsedType: getParsedType2(data)
|
|
62686
|
-
};
|
|
62687
|
-
if (!this["~standard"].async) {
|
|
62688
|
-
try {
|
|
62689
|
-
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
62690
|
-
return isValid2(result) ? {
|
|
62691
|
-
value: result.value
|
|
62692
|
-
} : {
|
|
62693
|
-
issues: ctx.common.issues
|
|
62694
|
-
};
|
|
62695
|
-
} catch (err) {
|
|
62696
|
-
if ((_b = (_a = err === null || err === undefined ? undefined : err.message) === null || _a === undefined ? undefined : _a.toLowerCase()) === null || _b === undefined ? undefined : _b.includes("encountered")) {
|
|
62697
|
-
this["~standard"].async = true;
|
|
62698
|
-
}
|
|
62699
|
-
ctx.common = {
|
|
62700
|
-
issues: [],
|
|
62701
|
-
async: true
|
|
62702
|
-
};
|
|
62703
|
-
}
|
|
62704
|
-
}
|
|
62705
|
-
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid2(result) ? {
|
|
62706
|
-
value: result.value
|
|
62707
|
-
} : {
|
|
62708
|
-
issues: ctx.common.issues
|
|
62709
|
-
});
|
|
62710
|
-
}
|
|
62711
|
-
async parseAsync(data, params) {
|
|
62712
|
-
const result = await this.safeParseAsync(data, params);
|
|
62713
|
-
if (result.success)
|
|
62714
|
-
return result.data;
|
|
62715
|
-
throw result.error;
|
|
62716
|
-
}
|
|
62717
|
-
async safeParseAsync(data, params) {
|
|
62718
|
-
const ctx = {
|
|
62719
|
-
common: {
|
|
62720
|
-
issues: [],
|
|
62721
|
-
contextualErrorMap: params === null || params === undefined ? undefined : params.errorMap,
|
|
62722
|
-
async: true
|
|
62723
|
-
},
|
|
62724
|
-
path: (params === null || params === undefined ? undefined : params.path) || [],
|
|
62725
|
-
schemaErrorMap: this._def.errorMap,
|
|
62726
|
-
parent: null,
|
|
62727
|
-
data,
|
|
62728
|
-
parsedType: getParsedType2(data)
|
|
62729
|
-
};
|
|
62730
|
-
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
62731
|
-
const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
62732
|
-
return handleResult3(ctx, result);
|
|
62733
|
-
}
|
|
62734
|
-
refine(check, message) {
|
|
62735
|
-
const getIssueProperties = (val) => {
|
|
62736
|
-
if (typeof message === "string" || typeof message === "undefined") {
|
|
62737
|
-
return { message };
|
|
62738
|
-
} else if (typeof message === "function") {
|
|
62739
|
-
return message(val);
|
|
62740
|
-
} else {
|
|
62741
|
-
return message;
|
|
62742
|
-
}
|
|
62743
|
-
};
|
|
62744
|
-
return this._refinement((val, ctx) => {
|
|
62745
|
-
const result = check(val);
|
|
62746
|
-
const setError = () => ctx.addIssue({
|
|
62747
|
-
code: ZodIssueCode2.custom,
|
|
62748
|
-
...getIssueProperties(val)
|
|
62749
|
-
});
|
|
62750
|
-
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
62751
|
-
return result.then((data) => {
|
|
62752
|
-
if (!data) {
|
|
62753
|
-
setError();
|
|
62754
|
-
return false;
|
|
62755
|
-
} else {
|
|
62756
|
-
return true;
|
|
62757
|
-
}
|
|
62758
|
-
});
|
|
62759
|
-
}
|
|
62760
|
-
if (!result) {
|
|
62761
|
-
setError();
|
|
62762
|
-
return false;
|
|
62763
|
-
} else {
|
|
62764
|
-
return true;
|
|
62765
|
-
}
|
|
62766
|
-
});
|
|
62767
|
-
}
|
|
62768
|
-
refinement(check, refinementData) {
|
|
62769
|
-
return this._refinement((val, ctx) => {
|
|
62770
|
-
if (!check(val)) {
|
|
62771
|
-
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
|
|
62772
|
-
return false;
|
|
62773
|
-
} else {
|
|
62774
|
-
return true;
|
|
62775
|
-
}
|
|
62776
|
-
});
|
|
62777
|
-
}
|
|
62778
|
-
_refinement(refinement) {
|
|
62779
|
-
return new ZodEffects2({
|
|
62780
|
-
schema: this,
|
|
62781
|
-
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
62782
|
-
effect: { type: "refinement", refinement }
|
|
62783
|
-
});
|
|
62784
|
-
}
|
|
62785
|
-
superRefine(refinement) {
|
|
62786
|
-
return this._refinement(refinement);
|
|
62787
|
-
}
|
|
62788
|
-
constructor(def) {
|
|
62789
|
-
this.spa = this.safeParseAsync;
|
|
62790
|
-
this._def = def;
|
|
62791
|
-
this.parse = this.parse.bind(this);
|
|
62792
|
-
this.safeParse = this.safeParse.bind(this);
|
|
62793
|
-
this.parseAsync = this.parseAsync.bind(this);
|
|
62794
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
62795
|
-
this.spa = this.spa.bind(this);
|
|
62796
|
-
this.refine = this.refine.bind(this);
|
|
62797
|
-
this.refinement = this.refinement.bind(this);
|
|
62798
|
-
this.superRefine = this.superRefine.bind(this);
|
|
62799
|
-
this.optional = this.optional.bind(this);
|
|
62800
|
-
this.nullable = this.nullable.bind(this);
|
|
62801
|
-
this.nullish = this.nullish.bind(this);
|
|
62802
|
-
this.array = this.array.bind(this);
|
|
62803
|
-
this.promise = this.promise.bind(this);
|
|
62804
|
-
this.or = this.or.bind(this);
|
|
62805
|
-
this.and = this.and.bind(this);
|
|
62806
|
-
this.transform = this.transform.bind(this);
|
|
62807
|
-
this.brand = this.brand.bind(this);
|
|
62808
|
-
this.default = this.default.bind(this);
|
|
62809
|
-
this.catch = this.catch.bind(this);
|
|
62810
|
-
this.describe = this.describe.bind(this);
|
|
62811
|
-
this.pipe = this.pipe.bind(this);
|
|
62812
|
-
this.readonly = this.readonly.bind(this);
|
|
62813
|
-
this.isNullable = this.isNullable.bind(this);
|
|
62814
|
-
this.isOptional = this.isOptional.bind(this);
|
|
62815
|
-
this["~standard"] = {
|
|
62816
|
-
version: 1,
|
|
62817
|
-
vendor: "zod",
|
|
62818
|
-
validate: (data) => this["~validate"](data)
|
|
62819
|
-
};
|
|
62820
|
-
}
|
|
62821
|
-
optional() {
|
|
62822
|
-
return ZodOptional2.create(this, this._def);
|
|
62823
|
-
}
|
|
62824
|
-
nullable() {
|
|
62825
|
-
return ZodNullable2.create(this, this._def);
|
|
62826
|
-
}
|
|
62827
|
-
nullish() {
|
|
62828
|
-
return this.nullable().optional();
|
|
62829
|
-
}
|
|
62830
|
-
array() {
|
|
62831
|
-
return ZodArray2.create(this);
|
|
62832
|
-
}
|
|
62833
|
-
promise() {
|
|
62834
|
-
return ZodPromise2.create(this, this._def);
|
|
62835
|
-
}
|
|
62836
|
-
or(option) {
|
|
62837
|
-
return ZodUnion2.create([this, option], this._def);
|
|
62838
|
-
}
|
|
62839
|
-
and(incoming) {
|
|
62840
|
-
return ZodIntersection2.create(this, incoming, this._def);
|
|
62841
|
-
}
|
|
62842
|
-
transform(transform) {
|
|
62843
|
-
return new ZodEffects2({
|
|
62844
|
-
...processCreateParams3(this._def),
|
|
62845
|
-
schema: this,
|
|
62846
|
-
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
62847
|
-
effect: { type: "transform", transform }
|
|
62848
|
-
});
|
|
62849
|
-
}
|
|
62850
|
-
default(def) {
|
|
62851
|
-
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
62852
|
-
return new ZodDefault2({
|
|
62853
|
-
...processCreateParams3(this._def),
|
|
62854
|
-
innerType: this,
|
|
62855
|
-
defaultValue: defaultValueFunc,
|
|
62856
|
-
typeName: ZodFirstPartyTypeKind2.ZodDefault
|
|
62857
|
-
});
|
|
62858
|
-
}
|
|
62859
|
-
brand() {
|
|
62860
|
-
return new ZodBranded2({
|
|
62861
|
-
typeName: ZodFirstPartyTypeKind2.ZodBranded,
|
|
62862
|
-
type: this,
|
|
62863
|
-
...processCreateParams3(this._def)
|
|
62864
|
-
});
|
|
62865
|
-
}
|
|
62866
|
-
catch(def) {
|
|
62867
|
-
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
62868
|
-
return new ZodCatch2({
|
|
62869
|
-
...processCreateParams3(this._def),
|
|
62870
|
-
innerType: this,
|
|
62871
|
-
catchValue: catchValueFunc,
|
|
62872
|
-
typeName: ZodFirstPartyTypeKind2.ZodCatch
|
|
62873
|
-
});
|
|
62874
|
-
}
|
|
62875
|
-
describe(description) {
|
|
62876
|
-
const This = this.constructor;
|
|
62877
|
-
return new This({
|
|
62878
|
-
...this._def,
|
|
62879
|
-
description
|
|
62880
|
-
});
|
|
62881
|
-
}
|
|
62882
|
-
pipe(target) {
|
|
62883
|
-
return ZodPipeline2.create(this, target);
|
|
62884
|
-
}
|
|
62885
|
-
readonly() {
|
|
62886
|
-
return ZodReadonly2.create(this);
|
|
62887
|
-
}
|
|
62888
|
-
isOptional() {
|
|
62889
|
-
return this.safeParse(undefined).success;
|
|
62890
|
-
}
|
|
62891
|
-
isNullable() {
|
|
62892
|
-
return this.safeParse(null).success;
|
|
62893
|
-
}
|
|
62894
|
-
}
|
|
62895
|
-
var cuidRegex2 = /^c[^\s-]{8,}$/i;
|
|
62896
|
-
var cuid2Regex2 = /^[0-9a-z]+$/;
|
|
62897
|
-
var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
62898
|
-
var uuidRegex2 = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
62899
|
-
var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
|
|
62900
|
-
var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
62901
|
-
var durationRegex2 = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
62902
|
-
var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
62903
|
-
var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
62904
|
-
var emojiRegex3;
|
|
62905
|
-
var ipv4Regex2 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
62906
|
-
var ipv4CidrRegex2 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
|
|
62907
|
-
var ipv6Regex2 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
62908
|
-
var ipv6CidrRegex2 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
62909
|
-
var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
62910
|
-
var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
62911
|
-
var dateRegexSource2 = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
62912
|
-
var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
|
|
62913
|
-
function timeRegexSource2(args) {
|
|
62914
|
-
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
62915
|
-
if (args.precision) {
|
|
62916
|
-
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
62917
|
-
} else if (args.precision == null) {
|
|
62918
|
-
regex = `${regex}(\\.\\d+)?`;
|
|
62919
|
-
}
|
|
62920
|
-
return regex;
|
|
62921
|
-
}
|
|
62922
|
-
function timeRegex2(args) {
|
|
62923
|
-
return new RegExp(`^${timeRegexSource2(args)}$`);
|
|
62924
|
-
}
|
|
62925
|
-
function datetimeRegex2(args) {
|
|
62926
|
-
let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
|
|
62927
|
-
const opts = [];
|
|
62928
|
-
opts.push(args.local ? `Z?` : `Z`);
|
|
62929
|
-
if (args.offset)
|
|
62930
|
-
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
62931
|
-
regex = `${regex}(${opts.join("|")})`;
|
|
62932
|
-
return new RegExp(`^${regex}$`);
|
|
62933
|
-
}
|
|
62934
|
-
function isValidIP2(ip, version) {
|
|
62935
|
-
if ((version === "v4" || !version) && ipv4Regex2.test(ip)) {
|
|
62936
|
-
return true;
|
|
62937
|
-
}
|
|
62938
|
-
if ((version === "v6" || !version) && ipv6Regex2.test(ip)) {
|
|
62939
|
-
return true;
|
|
62940
|
-
}
|
|
62941
|
-
return false;
|
|
62942
|
-
}
|
|
62943
|
-
function isValidJWT2(jwt, alg) {
|
|
62944
|
-
if (!jwtRegex2.test(jwt))
|
|
62945
|
-
return false;
|
|
62946
|
-
try {
|
|
62947
|
-
const [header] = jwt.split(".");
|
|
62948
|
-
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
62949
|
-
const decoded = JSON.parse(atob(base64));
|
|
62950
|
-
if (typeof decoded !== "object" || decoded === null)
|
|
62951
|
-
return false;
|
|
62952
|
-
if (!decoded.typ || !decoded.alg)
|
|
62953
|
-
return false;
|
|
62954
|
-
if (alg && decoded.alg !== alg)
|
|
62955
|
-
return false;
|
|
62956
|
-
return true;
|
|
62957
|
-
} catch (_a) {
|
|
62958
|
-
return false;
|
|
62959
|
-
}
|
|
62960
|
-
}
|
|
62961
|
-
function isValidCidr2(ip, version) {
|
|
62962
|
-
if ((version === "v4" || !version) && ipv4CidrRegex2.test(ip)) {
|
|
62963
|
-
return true;
|
|
62964
|
-
}
|
|
62965
|
-
if ((version === "v6" || !version) && ipv6CidrRegex2.test(ip)) {
|
|
62966
|
-
return true;
|
|
62967
|
-
}
|
|
62968
|
-
return false;
|
|
62969
|
-
}
|
|
62970
|
-
|
|
62971
|
-
class ZodString2 extends ZodType2 {
|
|
62972
|
-
_parse(input) {
|
|
62973
|
-
if (this._def.coerce) {
|
|
62974
|
-
input.data = String(input.data);
|
|
62975
|
-
}
|
|
62976
|
-
const parsedType = this._getType(input);
|
|
62977
|
-
if (parsedType !== ZodParsedType2.string) {
|
|
62978
|
-
const ctx2 = this._getOrReturnCtx(input);
|
|
62979
|
-
addIssueToContext2(ctx2, {
|
|
62980
|
-
code: ZodIssueCode2.invalid_type,
|
|
62981
|
-
expected: ZodParsedType2.string,
|
|
62982
|
-
received: ctx2.parsedType
|
|
62983
|
-
});
|
|
62984
|
-
return INVALID2;
|
|
62985
|
-
}
|
|
62986
|
-
const status = new ParseStatus2;
|
|
62987
|
-
let ctx = undefined;
|
|
62988
|
-
for (const check of this._def.checks) {
|
|
62989
|
-
if (check.kind === "min") {
|
|
62990
|
-
if (input.data.length < check.value) {
|
|
62991
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
62992
|
-
addIssueToContext2(ctx, {
|
|
62993
|
-
code: ZodIssueCode2.too_small,
|
|
62994
|
-
minimum: check.value,
|
|
62995
|
-
type: "string",
|
|
62996
|
-
inclusive: true,
|
|
62997
|
-
exact: false,
|
|
62998
|
-
message: check.message
|
|
62999
|
-
});
|
|
63000
|
-
status.dirty();
|
|
63001
|
-
}
|
|
63002
|
-
} else if (check.kind === "max") {
|
|
63003
|
-
if (input.data.length > check.value) {
|
|
63004
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63005
|
-
addIssueToContext2(ctx, {
|
|
63006
|
-
code: ZodIssueCode2.too_big,
|
|
63007
|
-
maximum: check.value,
|
|
63008
|
-
type: "string",
|
|
63009
|
-
inclusive: true,
|
|
63010
|
-
exact: false,
|
|
63011
|
-
message: check.message
|
|
63012
|
-
});
|
|
63013
|
-
status.dirty();
|
|
63014
|
-
}
|
|
63015
|
-
} else if (check.kind === "length") {
|
|
63016
|
-
const tooBig = input.data.length > check.value;
|
|
63017
|
-
const tooSmall = input.data.length < check.value;
|
|
63018
|
-
if (tooBig || tooSmall) {
|
|
63019
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63020
|
-
if (tooBig) {
|
|
63021
|
-
addIssueToContext2(ctx, {
|
|
63022
|
-
code: ZodIssueCode2.too_big,
|
|
63023
|
-
maximum: check.value,
|
|
63024
|
-
type: "string",
|
|
63025
|
-
inclusive: true,
|
|
63026
|
-
exact: true,
|
|
63027
|
-
message: check.message
|
|
63028
|
-
});
|
|
63029
|
-
} else if (tooSmall) {
|
|
63030
|
-
addIssueToContext2(ctx, {
|
|
63031
|
-
code: ZodIssueCode2.too_small,
|
|
63032
|
-
minimum: check.value,
|
|
63033
|
-
type: "string",
|
|
63034
|
-
inclusive: true,
|
|
63035
|
-
exact: true,
|
|
63036
|
-
message: check.message
|
|
63037
|
-
});
|
|
63038
|
-
}
|
|
63039
|
-
status.dirty();
|
|
63040
|
-
}
|
|
63041
|
-
} else if (check.kind === "email") {
|
|
63042
|
-
if (!emailRegex2.test(input.data)) {
|
|
63043
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63044
|
-
addIssueToContext2(ctx, {
|
|
63045
|
-
validation: "email",
|
|
63046
|
-
code: ZodIssueCode2.invalid_string,
|
|
63047
|
-
message: check.message
|
|
63048
|
-
});
|
|
63049
|
-
status.dirty();
|
|
63050
|
-
}
|
|
63051
|
-
} else if (check.kind === "emoji") {
|
|
63052
|
-
if (!emojiRegex3) {
|
|
63053
|
-
emojiRegex3 = new RegExp(_emojiRegex2, "u");
|
|
63054
|
-
}
|
|
63055
|
-
if (!emojiRegex3.test(input.data)) {
|
|
63056
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63057
|
-
addIssueToContext2(ctx, {
|
|
63058
|
-
validation: "emoji",
|
|
63059
|
-
code: ZodIssueCode2.invalid_string,
|
|
63060
|
-
message: check.message
|
|
63061
|
-
});
|
|
63062
|
-
status.dirty();
|
|
63063
|
-
}
|
|
63064
|
-
} else if (check.kind === "uuid") {
|
|
63065
|
-
if (!uuidRegex2.test(input.data)) {
|
|
63066
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63067
|
-
addIssueToContext2(ctx, {
|
|
63068
|
-
validation: "uuid",
|
|
63069
|
-
code: ZodIssueCode2.invalid_string,
|
|
63070
|
-
message: check.message
|
|
63071
|
-
});
|
|
63072
|
-
status.dirty();
|
|
63073
|
-
}
|
|
63074
|
-
} else if (check.kind === "nanoid") {
|
|
63075
|
-
if (!nanoidRegex2.test(input.data)) {
|
|
63076
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63077
|
-
addIssueToContext2(ctx, {
|
|
63078
|
-
validation: "nanoid",
|
|
63079
|
-
code: ZodIssueCode2.invalid_string,
|
|
63080
|
-
message: check.message
|
|
63081
|
-
});
|
|
63082
|
-
status.dirty();
|
|
63083
|
-
}
|
|
63084
|
-
} else if (check.kind === "cuid") {
|
|
63085
|
-
if (!cuidRegex2.test(input.data)) {
|
|
63086
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63087
|
-
addIssueToContext2(ctx, {
|
|
63088
|
-
validation: "cuid",
|
|
63089
|
-
code: ZodIssueCode2.invalid_string,
|
|
63090
|
-
message: check.message
|
|
63091
|
-
});
|
|
63092
|
-
status.dirty();
|
|
63093
|
-
}
|
|
63094
|
-
} else if (check.kind === "cuid2") {
|
|
63095
|
-
if (!cuid2Regex2.test(input.data)) {
|
|
63096
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63097
|
-
addIssueToContext2(ctx, {
|
|
63098
|
-
validation: "cuid2",
|
|
63099
|
-
code: ZodIssueCode2.invalid_string,
|
|
63100
|
-
message: check.message
|
|
63101
|
-
});
|
|
63102
|
-
status.dirty();
|
|
63103
|
-
}
|
|
63104
|
-
} else if (check.kind === "ulid") {
|
|
63105
|
-
if (!ulidRegex2.test(input.data)) {
|
|
63106
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63107
|
-
addIssueToContext2(ctx, {
|
|
63108
|
-
validation: "ulid",
|
|
63109
|
-
code: ZodIssueCode2.invalid_string,
|
|
63110
|
-
message: check.message
|
|
63111
|
-
});
|
|
63112
|
-
status.dirty();
|
|
63113
|
-
}
|
|
63114
|
-
} else if (check.kind === "url") {
|
|
63115
|
-
try {
|
|
63116
|
-
new URL(input.data);
|
|
63117
|
-
} catch (_a) {
|
|
63118
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63119
|
-
addIssueToContext2(ctx, {
|
|
63120
|
-
validation: "url",
|
|
63121
|
-
code: ZodIssueCode2.invalid_string,
|
|
63122
|
-
message: check.message
|
|
63123
|
-
});
|
|
63124
|
-
status.dirty();
|
|
63125
|
-
}
|
|
63126
|
-
} else if (check.kind === "regex") {
|
|
63127
|
-
check.regex.lastIndex = 0;
|
|
63128
|
-
const testResult = check.regex.test(input.data);
|
|
63129
|
-
if (!testResult) {
|
|
63130
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63131
|
-
addIssueToContext2(ctx, {
|
|
63132
|
-
validation: "regex",
|
|
63133
|
-
code: ZodIssueCode2.invalid_string,
|
|
63134
|
-
message: check.message
|
|
63135
|
-
});
|
|
63136
|
-
status.dirty();
|
|
63137
|
-
}
|
|
63138
|
-
} else if (check.kind === "trim") {
|
|
63139
|
-
input.data = input.data.trim();
|
|
63140
|
-
} else if (check.kind === "includes") {
|
|
63141
|
-
if (!input.data.includes(check.value, check.position)) {
|
|
63142
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63143
|
-
addIssueToContext2(ctx, {
|
|
63144
|
-
code: ZodIssueCode2.invalid_string,
|
|
63145
|
-
validation: { includes: check.value, position: check.position },
|
|
63146
|
-
message: check.message
|
|
63147
|
-
});
|
|
63148
|
-
status.dirty();
|
|
63149
|
-
}
|
|
63150
|
-
} else if (check.kind === "toLowerCase") {
|
|
63151
|
-
input.data = input.data.toLowerCase();
|
|
63152
|
-
} else if (check.kind === "toUpperCase") {
|
|
63153
|
-
input.data = input.data.toUpperCase();
|
|
63154
|
-
} else if (check.kind === "startsWith") {
|
|
63155
|
-
if (!input.data.startsWith(check.value)) {
|
|
63156
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63157
|
-
addIssueToContext2(ctx, {
|
|
63158
|
-
code: ZodIssueCode2.invalid_string,
|
|
63159
|
-
validation: { startsWith: check.value },
|
|
63160
|
-
message: check.message
|
|
63161
|
-
});
|
|
63162
|
-
status.dirty();
|
|
63163
|
-
}
|
|
63164
|
-
} else if (check.kind === "endsWith") {
|
|
63165
|
-
if (!input.data.endsWith(check.value)) {
|
|
63166
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63167
|
-
addIssueToContext2(ctx, {
|
|
63168
|
-
code: ZodIssueCode2.invalid_string,
|
|
63169
|
-
validation: { endsWith: check.value },
|
|
63170
|
-
message: check.message
|
|
63171
|
-
});
|
|
63172
|
-
status.dirty();
|
|
63173
|
-
}
|
|
63174
|
-
} else if (check.kind === "datetime") {
|
|
63175
|
-
const regex = datetimeRegex2(check);
|
|
63176
|
-
if (!regex.test(input.data)) {
|
|
63177
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63178
|
-
addIssueToContext2(ctx, {
|
|
63179
|
-
code: ZodIssueCode2.invalid_string,
|
|
63180
|
-
validation: "datetime",
|
|
63181
|
-
message: check.message
|
|
63182
|
-
});
|
|
63183
|
-
status.dirty();
|
|
63184
|
-
}
|
|
63185
|
-
} else if (check.kind === "date") {
|
|
63186
|
-
const regex = dateRegex2;
|
|
63187
|
-
if (!regex.test(input.data)) {
|
|
63188
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63189
|
-
addIssueToContext2(ctx, {
|
|
63190
|
-
code: ZodIssueCode2.invalid_string,
|
|
63191
|
-
validation: "date",
|
|
63192
|
-
message: check.message
|
|
63193
|
-
});
|
|
63194
|
-
status.dirty();
|
|
63195
|
-
}
|
|
63196
|
-
} else if (check.kind === "time") {
|
|
63197
|
-
const regex = timeRegex2(check);
|
|
63198
|
-
if (!regex.test(input.data)) {
|
|
63199
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63200
|
-
addIssueToContext2(ctx, {
|
|
63201
|
-
code: ZodIssueCode2.invalid_string,
|
|
63202
|
-
validation: "time",
|
|
63203
|
-
message: check.message
|
|
63204
|
-
});
|
|
63205
|
-
status.dirty();
|
|
63206
|
-
}
|
|
63207
|
-
} else if (check.kind === "duration") {
|
|
63208
|
-
if (!durationRegex2.test(input.data)) {
|
|
63209
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63210
|
-
addIssueToContext2(ctx, {
|
|
63211
|
-
validation: "duration",
|
|
63212
|
-
code: ZodIssueCode2.invalid_string,
|
|
63213
|
-
message: check.message
|
|
63214
|
-
});
|
|
63215
|
-
status.dirty();
|
|
63216
|
-
}
|
|
63217
|
-
} else if (check.kind === "ip") {
|
|
63218
|
-
if (!isValidIP2(input.data, check.version)) {
|
|
63219
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63220
|
-
addIssueToContext2(ctx, {
|
|
63221
|
-
validation: "ip",
|
|
63222
|
-
code: ZodIssueCode2.invalid_string,
|
|
63223
|
-
message: check.message
|
|
63224
|
-
});
|
|
63225
|
-
status.dirty();
|
|
63226
|
-
}
|
|
63227
|
-
} else if (check.kind === "jwt") {
|
|
63228
|
-
if (!isValidJWT2(input.data, check.alg)) {
|
|
63229
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63230
|
-
addIssueToContext2(ctx, {
|
|
63231
|
-
validation: "jwt",
|
|
63232
|
-
code: ZodIssueCode2.invalid_string,
|
|
63233
|
-
message: check.message
|
|
63234
|
-
});
|
|
63235
|
-
status.dirty();
|
|
63236
|
-
}
|
|
63237
|
-
} else if (check.kind === "cidr") {
|
|
63238
|
-
if (!isValidCidr2(input.data, check.version)) {
|
|
63239
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63240
|
-
addIssueToContext2(ctx, {
|
|
63241
|
-
validation: "cidr",
|
|
63242
|
-
code: ZodIssueCode2.invalid_string,
|
|
63243
|
-
message: check.message
|
|
63244
|
-
});
|
|
63245
|
-
status.dirty();
|
|
63246
|
-
}
|
|
63247
|
-
} else if (check.kind === "base64") {
|
|
63248
|
-
if (!base64Regex2.test(input.data)) {
|
|
63249
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63250
|
-
addIssueToContext2(ctx, {
|
|
63251
|
-
validation: "base64",
|
|
63252
|
-
code: ZodIssueCode2.invalid_string,
|
|
63253
|
-
message: check.message
|
|
63254
|
-
});
|
|
63255
|
-
status.dirty();
|
|
63256
|
-
}
|
|
63257
|
-
} else if (check.kind === "base64url") {
|
|
63258
|
-
if (!base64urlRegex2.test(input.data)) {
|
|
63259
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63260
|
-
addIssueToContext2(ctx, {
|
|
63261
|
-
validation: "base64url",
|
|
63262
|
-
code: ZodIssueCode2.invalid_string,
|
|
63263
|
-
message: check.message
|
|
63264
|
-
});
|
|
63265
|
-
status.dirty();
|
|
63266
|
-
}
|
|
63267
|
-
} else {
|
|
63268
|
-
util2.assertNever(check);
|
|
63269
|
-
}
|
|
63270
|
-
}
|
|
63271
|
-
return { status: status.value, value: input.data };
|
|
63272
|
-
}
|
|
63273
|
-
_regex(regex, validation, message) {
|
|
63274
|
-
return this.refinement((data) => regex.test(data), {
|
|
63275
|
-
validation,
|
|
63276
|
-
code: ZodIssueCode2.invalid_string,
|
|
63277
|
-
...errorUtil2.errToObj(message)
|
|
63278
|
-
});
|
|
63279
|
-
}
|
|
63280
|
-
_addCheck(check) {
|
|
63281
|
-
return new ZodString2({
|
|
63282
|
-
...this._def,
|
|
63283
|
-
checks: [...this._def.checks, check]
|
|
63284
|
-
});
|
|
63285
|
-
}
|
|
63286
|
-
email(message) {
|
|
63287
|
-
return this._addCheck({ kind: "email", ...errorUtil2.errToObj(message) });
|
|
63288
|
-
}
|
|
63289
|
-
url(message) {
|
|
63290
|
-
return this._addCheck({ kind: "url", ...errorUtil2.errToObj(message) });
|
|
63291
|
-
}
|
|
63292
|
-
emoji(message) {
|
|
63293
|
-
return this._addCheck({ kind: "emoji", ...errorUtil2.errToObj(message) });
|
|
63294
|
-
}
|
|
63295
|
-
uuid(message) {
|
|
63296
|
-
return this._addCheck({ kind: "uuid", ...errorUtil2.errToObj(message) });
|
|
63297
|
-
}
|
|
63298
|
-
nanoid(message) {
|
|
63299
|
-
return this._addCheck({ kind: "nanoid", ...errorUtil2.errToObj(message) });
|
|
63300
|
-
}
|
|
63301
|
-
cuid(message) {
|
|
63302
|
-
return this._addCheck({ kind: "cuid", ...errorUtil2.errToObj(message) });
|
|
63303
|
-
}
|
|
63304
|
-
cuid2(message) {
|
|
63305
|
-
return this._addCheck({ kind: "cuid2", ...errorUtil2.errToObj(message) });
|
|
63306
|
-
}
|
|
63307
|
-
ulid(message) {
|
|
63308
|
-
return this._addCheck({ kind: "ulid", ...errorUtil2.errToObj(message) });
|
|
63309
|
-
}
|
|
63310
|
-
base64(message) {
|
|
63311
|
-
return this._addCheck({ kind: "base64", ...errorUtil2.errToObj(message) });
|
|
63312
|
-
}
|
|
63313
|
-
base64url(message) {
|
|
63314
|
-
return this._addCheck({
|
|
63315
|
-
kind: "base64url",
|
|
63316
|
-
...errorUtil2.errToObj(message)
|
|
63317
|
-
});
|
|
63318
|
-
}
|
|
63319
|
-
jwt(options) {
|
|
63320
|
-
return this._addCheck({ kind: "jwt", ...errorUtil2.errToObj(options) });
|
|
63321
|
-
}
|
|
63322
|
-
ip(options) {
|
|
63323
|
-
return this._addCheck({ kind: "ip", ...errorUtil2.errToObj(options) });
|
|
63324
|
-
}
|
|
63325
|
-
cidr(options) {
|
|
63326
|
-
return this._addCheck({ kind: "cidr", ...errorUtil2.errToObj(options) });
|
|
63327
|
-
}
|
|
63328
|
-
datetime(options) {
|
|
63329
|
-
var _a, _b;
|
|
63330
|
-
if (typeof options === "string") {
|
|
63331
|
-
return this._addCheck({
|
|
63332
|
-
kind: "datetime",
|
|
63333
|
-
precision: null,
|
|
63334
|
-
offset: false,
|
|
63335
|
-
local: false,
|
|
63336
|
-
message: options
|
|
63337
|
-
});
|
|
63338
|
-
}
|
|
63339
|
-
return this._addCheck({
|
|
63340
|
-
kind: "datetime",
|
|
63341
|
-
precision: typeof (options === null || options === undefined ? undefined : options.precision) === "undefined" ? null : options === null || options === undefined ? undefined : options.precision,
|
|
63342
|
-
offset: (_a = options === null || options === undefined ? undefined : options.offset) !== null && _a !== undefined ? _a : false,
|
|
63343
|
-
local: (_b = options === null || options === undefined ? undefined : options.local) !== null && _b !== undefined ? _b : false,
|
|
63344
|
-
...errorUtil2.errToObj(options === null || options === undefined ? undefined : options.message)
|
|
63345
|
-
});
|
|
63346
|
-
}
|
|
63347
|
-
date(message) {
|
|
63348
|
-
return this._addCheck({ kind: "date", message });
|
|
63349
|
-
}
|
|
63350
|
-
time(options) {
|
|
63351
|
-
if (typeof options === "string") {
|
|
63352
|
-
return this._addCheck({
|
|
63353
|
-
kind: "time",
|
|
63354
|
-
precision: null,
|
|
63355
|
-
message: options
|
|
63356
|
-
});
|
|
63357
|
-
}
|
|
63358
|
-
return this._addCheck({
|
|
63359
|
-
kind: "time",
|
|
63360
|
-
precision: typeof (options === null || options === undefined ? undefined : options.precision) === "undefined" ? null : options === null || options === undefined ? undefined : options.precision,
|
|
63361
|
-
...errorUtil2.errToObj(options === null || options === undefined ? undefined : options.message)
|
|
63362
|
-
});
|
|
63363
|
-
}
|
|
63364
|
-
duration(message) {
|
|
63365
|
-
return this._addCheck({ kind: "duration", ...errorUtil2.errToObj(message) });
|
|
63366
|
-
}
|
|
63367
|
-
regex(regex, message) {
|
|
63368
|
-
return this._addCheck({
|
|
63369
|
-
kind: "regex",
|
|
63370
|
-
regex,
|
|
63371
|
-
...errorUtil2.errToObj(message)
|
|
63372
|
-
});
|
|
63373
|
-
}
|
|
63374
|
-
includes(value, options) {
|
|
63375
|
-
return this._addCheck({
|
|
63376
|
-
kind: "includes",
|
|
63377
|
-
value,
|
|
63378
|
-
position: options === null || options === undefined ? undefined : options.position,
|
|
63379
|
-
...errorUtil2.errToObj(options === null || options === undefined ? undefined : options.message)
|
|
63380
|
-
});
|
|
63381
|
-
}
|
|
63382
|
-
startsWith(value, message) {
|
|
63383
|
-
return this._addCheck({
|
|
63384
|
-
kind: "startsWith",
|
|
63385
|
-
value,
|
|
63386
|
-
...errorUtil2.errToObj(message)
|
|
63387
|
-
});
|
|
63388
|
-
}
|
|
63389
|
-
endsWith(value, message) {
|
|
63390
|
-
return this._addCheck({
|
|
63391
|
-
kind: "endsWith",
|
|
63392
|
-
value,
|
|
63393
|
-
...errorUtil2.errToObj(message)
|
|
63394
|
-
});
|
|
63395
|
-
}
|
|
63396
|
-
min(minLength, message) {
|
|
63397
|
-
return this._addCheck({
|
|
63398
|
-
kind: "min",
|
|
63399
|
-
value: minLength,
|
|
63400
|
-
...errorUtil2.errToObj(message)
|
|
63401
|
-
});
|
|
63402
|
-
}
|
|
63403
|
-
max(maxLength, message) {
|
|
63404
|
-
return this._addCheck({
|
|
63405
|
-
kind: "max",
|
|
63406
|
-
value: maxLength,
|
|
63407
|
-
...errorUtil2.errToObj(message)
|
|
63408
|
-
});
|
|
63409
|
-
}
|
|
63410
|
-
length(len, message) {
|
|
63411
|
-
return this._addCheck({
|
|
63412
|
-
kind: "length",
|
|
63413
|
-
value: len,
|
|
63414
|
-
...errorUtil2.errToObj(message)
|
|
63415
|
-
});
|
|
63416
|
-
}
|
|
63417
|
-
nonempty(message) {
|
|
63418
|
-
return this.min(1, errorUtil2.errToObj(message));
|
|
63419
|
-
}
|
|
63420
|
-
trim() {
|
|
63421
|
-
return new ZodString2({
|
|
63422
|
-
...this._def,
|
|
63423
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
63424
|
-
});
|
|
63425
|
-
}
|
|
63426
|
-
toLowerCase() {
|
|
63427
|
-
return new ZodString2({
|
|
63428
|
-
...this._def,
|
|
63429
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
63430
|
-
});
|
|
63431
|
-
}
|
|
63432
|
-
toUpperCase() {
|
|
63433
|
-
return new ZodString2({
|
|
63434
|
-
...this._def,
|
|
63435
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
63436
|
-
});
|
|
63437
|
-
}
|
|
63438
|
-
get isDatetime() {
|
|
63439
|
-
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
63440
|
-
}
|
|
63441
|
-
get isDate() {
|
|
63442
|
-
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
63443
|
-
}
|
|
63444
|
-
get isTime() {
|
|
63445
|
-
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
63446
|
-
}
|
|
63447
|
-
get isDuration() {
|
|
63448
|
-
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
63449
|
-
}
|
|
63450
|
-
get isEmail() {
|
|
63451
|
-
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
63452
|
-
}
|
|
63453
|
-
get isURL() {
|
|
63454
|
-
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
63455
|
-
}
|
|
63456
|
-
get isEmoji() {
|
|
63457
|
-
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
63458
|
-
}
|
|
63459
|
-
get isUUID() {
|
|
63460
|
-
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
63461
|
-
}
|
|
63462
|
-
get isNANOID() {
|
|
63463
|
-
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
63464
|
-
}
|
|
63465
|
-
get isCUID() {
|
|
63466
|
-
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
63467
|
-
}
|
|
63468
|
-
get isCUID2() {
|
|
63469
|
-
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
63470
|
-
}
|
|
63471
|
-
get isULID() {
|
|
63472
|
-
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
63473
|
-
}
|
|
63474
|
-
get isIP() {
|
|
63475
|
-
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
63476
|
-
}
|
|
63477
|
-
get isCIDR() {
|
|
63478
|
-
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
63479
|
-
}
|
|
63480
|
-
get isBase64() {
|
|
63481
|
-
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
63482
|
-
}
|
|
63483
|
-
get isBase64url() {
|
|
63484
|
-
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
63485
|
-
}
|
|
63486
|
-
get minLength() {
|
|
63487
|
-
let min = null;
|
|
63488
|
-
for (const ch of this._def.checks) {
|
|
63489
|
-
if (ch.kind === "min") {
|
|
63490
|
-
if (min === null || ch.value > min)
|
|
63491
|
-
min = ch.value;
|
|
63492
|
-
}
|
|
63493
|
-
}
|
|
63494
|
-
return min;
|
|
63495
|
-
}
|
|
63496
|
-
get maxLength() {
|
|
63497
|
-
let max = null;
|
|
63498
|
-
for (const ch of this._def.checks) {
|
|
63499
|
-
if (ch.kind === "max") {
|
|
63500
|
-
if (max === null || ch.value < max)
|
|
63501
|
-
max = ch.value;
|
|
63502
|
-
}
|
|
63503
|
-
}
|
|
63504
|
-
return max;
|
|
63505
|
-
}
|
|
63506
|
-
}
|
|
63507
|
-
ZodString2.create = (params) => {
|
|
63508
|
-
var _a;
|
|
63509
|
-
return new ZodString2({
|
|
63510
|
-
checks: [],
|
|
63511
|
-
typeName: ZodFirstPartyTypeKind2.ZodString,
|
|
63512
|
-
coerce: (_a = params === null || params === undefined ? undefined : params.coerce) !== null && _a !== undefined ? _a : false,
|
|
63513
|
-
...processCreateParams3(params)
|
|
63514
|
-
});
|
|
63515
|
-
};
|
|
63516
|
-
function floatSafeRemainder2(val, step) {
|
|
63517
|
-
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
63518
|
-
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
63519
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
63520
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
63521
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
63522
|
-
return valInt % stepInt / Math.pow(10, decCount);
|
|
63523
|
-
}
|
|
63524
|
-
|
|
63525
|
-
class ZodNumber2 extends ZodType2 {
|
|
63526
|
-
constructor() {
|
|
63527
|
-
super(...arguments);
|
|
63528
|
-
this.min = this.gte;
|
|
63529
|
-
this.max = this.lte;
|
|
63530
|
-
this.step = this.multipleOf;
|
|
63531
|
-
}
|
|
63532
|
-
_parse(input) {
|
|
63533
|
-
if (this._def.coerce) {
|
|
63534
|
-
input.data = Number(input.data);
|
|
63535
|
-
}
|
|
63536
|
-
const parsedType = this._getType(input);
|
|
63537
|
-
if (parsedType !== ZodParsedType2.number) {
|
|
63538
|
-
const ctx2 = this._getOrReturnCtx(input);
|
|
63539
|
-
addIssueToContext2(ctx2, {
|
|
63540
|
-
code: ZodIssueCode2.invalid_type,
|
|
63541
|
-
expected: ZodParsedType2.number,
|
|
63542
|
-
received: ctx2.parsedType
|
|
63543
|
-
});
|
|
63544
|
-
return INVALID2;
|
|
63545
|
-
}
|
|
63546
|
-
let ctx = undefined;
|
|
63547
|
-
const status = new ParseStatus2;
|
|
63548
|
-
for (const check of this._def.checks) {
|
|
63549
|
-
if (check.kind === "int") {
|
|
63550
|
-
if (!util2.isInteger(input.data)) {
|
|
63551
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63552
|
-
addIssueToContext2(ctx, {
|
|
63553
|
-
code: ZodIssueCode2.invalid_type,
|
|
63554
|
-
expected: "integer",
|
|
63555
|
-
received: "float",
|
|
63556
|
-
message: check.message
|
|
63557
|
-
});
|
|
63558
|
-
status.dirty();
|
|
63559
|
-
}
|
|
63560
|
-
} else if (check.kind === "min") {
|
|
63561
|
-
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
63562
|
-
if (tooSmall) {
|
|
63563
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63564
|
-
addIssueToContext2(ctx, {
|
|
63565
|
-
code: ZodIssueCode2.too_small,
|
|
63566
|
-
minimum: check.value,
|
|
63567
|
-
type: "number",
|
|
63568
|
-
inclusive: check.inclusive,
|
|
63569
|
-
exact: false,
|
|
63570
|
-
message: check.message
|
|
63571
|
-
});
|
|
63572
|
-
status.dirty();
|
|
63573
|
-
}
|
|
63574
|
-
} else if (check.kind === "max") {
|
|
63575
|
-
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
63576
|
-
if (tooBig) {
|
|
63577
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63578
|
-
addIssueToContext2(ctx, {
|
|
63579
|
-
code: ZodIssueCode2.too_big,
|
|
63580
|
-
maximum: check.value,
|
|
63581
|
-
type: "number",
|
|
63582
|
-
inclusive: check.inclusive,
|
|
63583
|
-
exact: false,
|
|
63584
|
-
message: check.message
|
|
63585
|
-
});
|
|
63586
|
-
status.dirty();
|
|
63587
|
-
}
|
|
63588
|
-
} else if (check.kind === "multipleOf") {
|
|
63589
|
-
if (floatSafeRemainder2(input.data, check.value) !== 0) {
|
|
63590
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63591
|
-
addIssueToContext2(ctx, {
|
|
63592
|
-
code: ZodIssueCode2.not_multiple_of,
|
|
63593
|
-
multipleOf: check.value,
|
|
63594
|
-
message: check.message
|
|
63595
|
-
});
|
|
63596
|
-
status.dirty();
|
|
63597
|
-
}
|
|
63598
|
-
} else if (check.kind === "finite") {
|
|
63599
|
-
if (!Number.isFinite(input.data)) {
|
|
63600
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63601
|
-
addIssueToContext2(ctx, {
|
|
63602
|
-
code: ZodIssueCode2.not_finite,
|
|
63603
|
-
message: check.message
|
|
63604
|
-
});
|
|
63605
|
-
status.dirty();
|
|
63606
|
-
}
|
|
63607
|
-
} else {
|
|
63608
|
-
util2.assertNever(check);
|
|
63609
|
-
}
|
|
63610
|
-
}
|
|
63611
|
-
return { status: status.value, value: input.data };
|
|
63612
|
-
}
|
|
63613
|
-
gte(value, message) {
|
|
63614
|
-
return this.setLimit("min", value, true, errorUtil2.toString(message));
|
|
63615
|
-
}
|
|
63616
|
-
gt(value, message) {
|
|
63617
|
-
return this.setLimit("min", value, false, errorUtil2.toString(message));
|
|
63618
|
-
}
|
|
63619
|
-
lte(value, message) {
|
|
63620
|
-
return this.setLimit("max", value, true, errorUtil2.toString(message));
|
|
63621
|
-
}
|
|
63622
|
-
lt(value, message) {
|
|
63623
|
-
return this.setLimit("max", value, false, errorUtil2.toString(message));
|
|
63624
|
-
}
|
|
63625
|
-
setLimit(kind, value, inclusive, message) {
|
|
63626
|
-
return new ZodNumber2({
|
|
63627
|
-
...this._def,
|
|
63628
|
-
checks: [
|
|
63629
|
-
...this._def.checks,
|
|
63630
|
-
{
|
|
63631
|
-
kind,
|
|
63632
|
-
value,
|
|
63633
|
-
inclusive,
|
|
63634
|
-
message: errorUtil2.toString(message)
|
|
63635
|
-
}
|
|
63636
|
-
]
|
|
63637
|
-
});
|
|
63638
|
-
}
|
|
63639
|
-
_addCheck(check) {
|
|
63640
|
-
return new ZodNumber2({
|
|
63641
|
-
...this._def,
|
|
63642
|
-
checks: [...this._def.checks, check]
|
|
63643
|
-
});
|
|
63644
|
-
}
|
|
63645
|
-
int(message) {
|
|
63646
|
-
return this._addCheck({
|
|
63647
|
-
kind: "int",
|
|
63648
|
-
message: errorUtil2.toString(message)
|
|
63649
|
-
});
|
|
63650
|
-
}
|
|
63651
|
-
positive(message) {
|
|
63652
|
-
return this._addCheck({
|
|
63653
|
-
kind: "min",
|
|
63654
|
-
value: 0,
|
|
63655
|
-
inclusive: false,
|
|
63656
|
-
message: errorUtil2.toString(message)
|
|
63657
|
-
});
|
|
63658
|
-
}
|
|
63659
|
-
negative(message) {
|
|
63660
|
-
return this._addCheck({
|
|
63661
|
-
kind: "max",
|
|
63662
|
-
value: 0,
|
|
63663
|
-
inclusive: false,
|
|
63664
|
-
message: errorUtil2.toString(message)
|
|
63665
|
-
});
|
|
63666
|
-
}
|
|
63667
|
-
nonpositive(message) {
|
|
63668
|
-
return this._addCheck({
|
|
63669
|
-
kind: "max",
|
|
63670
|
-
value: 0,
|
|
63671
|
-
inclusive: true,
|
|
63672
|
-
message: errorUtil2.toString(message)
|
|
63673
|
-
});
|
|
63674
|
-
}
|
|
63675
|
-
nonnegative(message) {
|
|
63676
|
-
return this._addCheck({
|
|
63677
|
-
kind: "min",
|
|
63678
|
-
value: 0,
|
|
63679
|
-
inclusive: true,
|
|
63680
|
-
message: errorUtil2.toString(message)
|
|
63681
|
-
});
|
|
63682
|
-
}
|
|
63683
|
-
multipleOf(value, message) {
|
|
63684
|
-
return this._addCheck({
|
|
63685
|
-
kind: "multipleOf",
|
|
63686
|
-
value,
|
|
63687
|
-
message: errorUtil2.toString(message)
|
|
63688
|
-
});
|
|
63689
|
-
}
|
|
63690
|
-
finite(message) {
|
|
63691
|
-
return this._addCheck({
|
|
63692
|
-
kind: "finite",
|
|
63693
|
-
message: errorUtil2.toString(message)
|
|
63694
|
-
});
|
|
63695
|
-
}
|
|
63696
|
-
safe(message) {
|
|
63697
|
-
return this._addCheck({
|
|
63698
|
-
kind: "min",
|
|
63699
|
-
inclusive: true,
|
|
63700
|
-
value: Number.MIN_SAFE_INTEGER,
|
|
63701
|
-
message: errorUtil2.toString(message)
|
|
63702
|
-
})._addCheck({
|
|
63703
|
-
kind: "max",
|
|
63704
|
-
inclusive: true,
|
|
63705
|
-
value: Number.MAX_SAFE_INTEGER,
|
|
63706
|
-
message: errorUtil2.toString(message)
|
|
63707
|
-
});
|
|
63708
|
-
}
|
|
63709
|
-
get minValue() {
|
|
63710
|
-
let min = null;
|
|
63711
|
-
for (const ch of this._def.checks) {
|
|
63712
|
-
if (ch.kind === "min") {
|
|
63713
|
-
if (min === null || ch.value > min)
|
|
63714
|
-
min = ch.value;
|
|
63715
|
-
}
|
|
63716
|
-
}
|
|
63717
|
-
return min;
|
|
63718
|
-
}
|
|
63719
|
-
get maxValue() {
|
|
63720
|
-
let max = null;
|
|
63721
|
-
for (const ch of this._def.checks) {
|
|
63722
|
-
if (ch.kind === "max") {
|
|
63723
|
-
if (max === null || ch.value < max)
|
|
63724
|
-
max = ch.value;
|
|
63725
|
-
}
|
|
63726
|
-
}
|
|
63727
|
-
return max;
|
|
63728
|
-
}
|
|
63729
|
-
get isInt() {
|
|
63730
|
-
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util2.isInteger(ch.value));
|
|
63731
|
-
}
|
|
63732
|
-
get isFinite() {
|
|
63733
|
-
let max = null, min = null;
|
|
63734
|
-
for (const ch of this._def.checks) {
|
|
63735
|
-
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
63736
|
-
return true;
|
|
63737
|
-
} else if (ch.kind === "min") {
|
|
63738
|
-
if (min === null || ch.value > min)
|
|
63739
|
-
min = ch.value;
|
|
63740
|
-
} else if (ch.kind === "max") {
|
|
63741
|
-
if (max === null || ch.value < max)
|
|
63742
|
-
max = ch.value;
|
|
63743
|
-
}
|
|
63744
|
-
}
|
|
63745
|
-
return Number.isFinite(min) && Number.isFinite(max);
|
|
63746
|
-
}
|
|
63747
|
-
}
|
|
63748
|
-
ZodNumber2.create = (params) => {
|
|
63749
|
-
return new ZodNumber2({
|
|
63750
|
-
checks: [],
|
|
63751
|
-
typeName: ZodFirstPartyTypeKind2.ZodNumber,
|
|
63752
|
-
coerce: (params === null || params === undefined ? undefined : params.coerce) || false,
|
|
63753
|
-
...processCreateParams3(params)
|
|
63754
|
-
});
|
|
63755
|
-
};
|
|
63756
|
-
|
|
63757
|
-
class ZodBigInt2 extends ZodType2 {
|
|
63758
|
-
constructor() {
|
|
63759
|
-
super(...arguments);
|
|
63760
|
-
this.min = this.gte;
|
|
63761
|
-
this.max = this.lte;
|
|
63762
|
-
}
|
|
63763
|
-
_parse(input) {
|
|
63764
|
-
if (this._def.coerce) {
|
|
63765
|
-
try {
|
|
63766
|
-
input.data = BigInt(input.data);
|
|
63767
|
-
} catch (_a) {
|
|
63768
|
-
return this._getInvalidInput(input);
|
|
63769
|
-
}
|
|
63770
|
-
}
|
|
63771
|
-
const parsedType = this._getType(input);
|
|
63772
|
-
if (parsedType !== ZodParsedType2.bigint) {
|
|
63773
|
-
return this._getInvalidInput(input);
|
|
63774
|
-
}
|
|
63775
|
-
let ctx = undefined;
|
|
63776
|
-
const status = new ParseStatus2;
|
|
63777
|
-
for (const check of this._def.checks) {
|
|
63778
|
-
if (check.kind === "min") {
|
|
63779
|
-
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
63780
|
-
if (tooSmall) {
|
|
63781
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63782
|
-
addIssueToContext2(ctx, {
|
|
63783
|
-
code: ZodIssueCode2.too_small,
|
|
63784
|
-
type: "bigint",
|
|
63785
|
-
minimum: check.value,
|
|
63786
|
-
inclusive: check.inclusive,
|
|
63787
|
-
message: check.message
|
|
63788
|
-
});
|
|
63789
|
-
status.dirty();
|
|
63790
|
-
}
|
|
63791
|
-
} else if (check.kind === "max") {
|
|
63792
|
-
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
63793
|
-
if (tooBig) {
|
|
63794
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63795
|
-
addIssueToContext2(ctx, {
|
|
63796
|
-
code: ZodIssueCode2.too_big,
|
|
63797
|
-
type: "bigint",
|
|
63798
|
-
maximum: check.value,
|
|
63799
|
-
inclusive: check.inclusive,
|
|
63800
|
-
message: check.message
|
|
63801
|
-
});
|
|
63802
|
-
status.dirty();
|
|
63803
|
-
}
|
|
63804
|
-
} else if (check.kind === "multipleOf") {
|
|
63805
|
-
if (input.data % check.value !== BigInt(0)) {
|
|
63806
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63807
|
-
addIssueToContext2(ctx, {
|
|
63808
|
-
code: ZodIssueCode2.not_multiple_of,
|
|
63809
|
-
multipleOf: check.value,
|
|
63810
|
-
message: check.message
|
|
63811
|
-
});
|
|
63812
|
-
status.dirty();
|
|
63813
|
-
}
|
|
63814
|
-
} else {
|
|
63815
|
-
util2.assertNever(check);
|
|
63816
|
-
}
|
|
63817
|
-
}
|
|
63818
|
-
return { status: status.value, value: input.data };
|
|
63819
|
-
}
|
|
63820
|
-
_getInvalidInput(input) {
|
|
63821
|
-
const ctx = this._getOrReturnCtx(input);
|
|
63822
|
-
addIssueToContext2(ctx, {
|
|
63823
|
-
code: ZodIssueCode2.invalid_type,
|
|
63824
|
-
expected: ZodParsedType2.bigint,
|
|
63825
|
-
received: ctx.parsedType
|
|
63826
|
-
});
|
|
63827
|
-
return INVALID2;
|
|
63828
|
-
}
|
|
63829
|
-
gte(value, message) {
|
|
63830
|
-
return this.setLimit("min", value, true, errorUtil2.toString(message));
|
|
63831
|
-
}
|
|
63832
|
-
gt(value, message) {
|
|
63833
|
-
return this.setLimit("min", value, false, errorUtil2.toString(message));
|
|
63834
|
-
}
|
|
63835
|
-
lte(value, message) {
|
|
63836
|
-
return this.setLimit("max", value, true, errorUtil2.toString(message));
|
|
63837
|
-
}
|
|
63838
|
-
lt(value, message) {
|
|
63839
|
-
return this.setLimit("max", value, false, errorUtil2.toString(message));
|
|
63840
|
-
}
|
|
63841
|
-
setLimit(kind, value, inclusive, message) {
|
|
63842
|
-
return new ZodBigInt2({
|
|
63843
|
-
...this._def,
|
|
63844
|
-
checks: [
|
|
63845
|
-
...this._def.checks,
|
|
63846
|
-
{
|
|
63847
|
-
kind,
|
|
63848
|
-
value,
|
|
63849
|
-
inclusive,
|
|
63850
|
-
message: errorUtil2.toString(message)
|
|
63851
|
-
}
|
|
63852
|
-
]
|
|
63853
|
-
});
|
|
63854
|
-
}
|
|
63855
|
-
_addCheck(check) {
|
|
63856
|
-
return new ZodBigInt2({
|
|
63857
|
-
...this._def,
|
|
63858
|
-
checks: [...this._def.checks, check]
|
|
63859
|
-
});
|
|
63860
|
-
}
|
|
63861
|
-
positive(message) {
|
|
63862
|
-
return this._addCheck({
|
|
63863
|
-
kind: "min",
|
|
63864
|
-
value: BigInt(0),
|
|
63865
|
-
inclusive: false,
|
|
63866
|
-
message: errorUtil2.toString(message)
|
|
63867
|
-
});
|
|
63868
|
-
}
|
|
63869
|
-
negative(message) {
|
|
63870
|
-
return this._addCheck({
|
|
63871
|
-
kind: "max",
|
|
63872
|
-
value: BigInt(0),
|
|
63873
|
-
inclusive: false,
|
|
63874
|
-
message: errorUtil2.toString(message)
|
|
63875
|
-
});
|
|
63876
|
-
}
|
|
63877
|
-
nonpositive(message) {
|
|
63878
|
-
return this._addCheck({
|
|
63879
|
-
kind: "max",
|
|
63880
|
-
value: BigInt(0),
|
|
63881
|
-
inclusive: true,
|
|
63882
|
-
message: errorUtil2.toString(message)
|
|
63883
|
-
});
|
|
63884
|
-
}
|
|
63885
|
-
nonnegative(message) {
|
|
63886
|
-
return this._addCheck({
|
|
63887
|
-
kind: "min",
|
|
63888
|
-
value: BigInt(0),
|
|
63889
|
-
inclusive: true,
|
|
63890
|
-
message: errorUtil2.toString(message)
|
|
63891
|
-
});
|
|
63892
|
-
}
|
|
63893
|
-
multipleOf(value, message) {
|
|
63894
|
-
return this._addCheck({
|
|
63895
|
-
kind: "multipleOf",
|
|
63896
|
-
value,
|
|
63897
|
-
message: errorUtil2.toString(message)
|
|
63898
|
-
});
|
|
63899
|
-
}
|
|
63900
|
-
get minValue() {
|
|
63901
|
-
let min = null;
|
|
63902
|
-
for (const ch of this._def.checks) {
|
|
63903
|
-
if (ch.kind === "min") {
|
|
63904
|
-
if (min === null || ch.value > min)
|
|
63905
|
-
min = ch.value;
|
|
63906
|
-
}
|
|
63907
|
-
}
|
|
63908
|
-
return min;
|
|
63909
|
-
}
|
|
63910
|
-
get maxValue() {
|
|
63911
|
-
let max = null;
|
|
63912
|
-
for (const ch of this._def.checks) {
|
|
63913
|
-
if (ch.kind === "max") {
|
|
63914
|
-
if (max === null || ch.value < max)
|
|
63915
|
-
max = ch.value;
|
|
63916
|
-
}
|
|
63917
|
-
}
|
|
63918
|
-
return max;
|
|
63919
|
-
}
|
|
63920
|
-
}
|
|
63921
|
-
ZodBigInt2.create = (params) => {
|
|
63922
|
-
var _a;
|
|
63923
|
-
return new ZodBigInt2({
|
|
63924
|
-
checks: [],
|
|
63925
|
-
typeName: ZodFirstPartyTypeKind2.ZodBigInt,
|
|
63926
|
-
coerce: (_a = params === null || params === undefined ? undefined : params.coerce) !== null && _a !== undefined ? _a : false,
|
|
63927
|
-
...processCreateParams3(params)
|
|
63928
|
-
});
|
|
63929
|
-
};
|
|
63930
|
-
|
|
63931
|
-
class ZodBoolean2 extends ZodType2 {
|
|
63932
|
-
_parse(input) {
|
|
63933
|
-
if (this._def.coerce) {
|
|
63934
|
-
input.data = Boolean(input.data);
|
|
63935
|
-
}
|
|
63936
|
-
const parsedType = this._getType(input);
|
|
63937
|
-
if (parsedType !== ZodParsedType2.boolean) {
|
|
63938
|
-
const ctx = this._getOrReturnCtx(input);
|
|
63939
|
-
addIssueToContext2(ctx, {
|
|
63940
|
-
code: ZodIssueCode2.invalid_type,
|
|
63941
|
-
expected: ZodParsedType2.boolean,
|
|
63942
|
-
received: ctx.parsedType
|
|
63943
|
-
});
|
|
63944
|
-
return INVALID2;
|
|
63945
|
-
}
|
|
63946
|
-
return OK2(input.data);
|
|
63947
|
-
}
|
|
63948
|
-
}
|
|
63949
|
-
ZodBoolean2.create = (params) => {
|
|
63950
|
-
return new ZodBoolean2({
|
|
63951
|
-
typeName: ZodFirstPartyTypeKind2.ZodBoolean,
|
|
63952
|
-
coerce: (params === null || params === undefined ? undefined : params.coerce) || false,
|
|
63953
|
-
...processCreateParams3(params)
|
|
63954
|
-
});
|
|
63955
|
-
};
|
|
63956
|
-
|
|
63957
|
-
class ZodDate2 extends ZodType2 {
|
|
63958
|
-
_parse(input) {
|
|
63959
|
-
if (this._def.coerce) {
|
|
63960
|
-
input.data = new Date(input.data);
|
|
63961
|
-
}
|
|
63962
|
-
const parsedType = this._getType(input);
|
|
63963
|
-
if (parsedType !== ZodParsedType2.date) {
|
|
63964
|
-
const ctx2 = this._getOrReturnCtx(input);
|
|
63965
|
-
addIssueToContext2(ctx2, {
|
|
63966
|
-
code: ZodIssueCode2.invalid_type,
|
|
63967
|
-
expected: ZodParsedType2.date,
|
|
63968
|
-
received: ctx2.parsedType
|
|
63969
|
-
});
|
|
63970
|
-
return INVALID2;
|
|
63971
|
-
}
|
|
63972
|
-
if (isNaN(input.data.getTime())) {
|
|
63973
|
-
const ctx2 = this._getOrReturnCtx(input);
|
|
63974
|
-
addIssueToContext2(ctx2, {
|
|
63975
|
-
code: ZodIssueCode2.invalid_date
|
|
63976
|
-
});
|
|
63977
|
-
return INVALID2;
|
|
63978
|
-
}
|
|
63979
|
-
const status = new ParseStatus2;
|
|
63980
|
-
let ctx = undefined;
|
|
63981
|
-
for (const check of this._def.checks) {
|
|
63982
|
-
if (check.kind === "min") {
|
|
63983
|
-
if (input.data.getTime() < check.value) {
|
|
63984
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63985
|
-
addIssueToContext2(ctx, {
|
|
63986
|
-
code: ZodIssueCode2.too_small,
|
|
63987
|
-
message: check.message,
|
|
63988
|
-
inclusive: true,
|
|
63989
|
-
exact: false,
|
|
63990
|
-
minimum: check.value,
|
|
63991
|
-
type: "date"
|
|
63992
|
-
});
|
|
63993
|
-
status.dirty();
|
|
63994
|
-
}
|
|
63995
|
-
} else if (check.kind === "max") {
|
|
63996
|
-
if (input.data.getTime() > check.value) {
|
|
63997
|
-
ctx = this._getOrReturnCtx(input, ctx);
|
|
63998
|
-
addIssueToContext2(ctx, {
|
|
63999
|
-
code: ZodIssueCode2.too_big,
|
|
64000
|
-
message: check.message,
|
|
64001
|
-
inclusive: true,
|
|
64002
|
-
exact: false,
|
|
64003
|
-
maximum: check.value,
|
|
64004
|
-
type: "date"
|
|
64005
|
-
});
|
|
64006
|
-
status.dirty();
|
|
64007
|
-
}
|
|
64008
|
-
} else {
|
|
64009
|
-
util2.assertNever(check);
|
|
64010
|
-
}
|
|
64011
|
-
}
|
|
64012
|
-
return {
|
|
64013
|
-
status: status.value,
|
|
64014
|
-
value: new Date(input.data.getTime())
|
|
64015
|
-
};
|
|
64016
|
-
}
|
|
64017
|
-
_addCheck(check) {
|
|
64018
|
-
return new ZodDate2({
|
|
64019
|
-
...this._def,
|
|
64020
|
-
checks: [...this._def.checks, check]
|
|
64021
|
-
});
|
|
64022
|
-
}
|
|
64023
|
-
min(minDate, message) {
|
|
64024
|
-
return this._addCheck({
|
|
64025
|
-
kind: "min",
|
|
64026
|
-
value: minDate.getTime(),
|
|
64027
|
-
message: errorUtil2.toString(message)
|
|
64028
|
-
});
|
|
64029
|
-
}
|
|
64030
|
-
max(maxDate, message) {
|
|
64031
|
-
return this._addCheck({
|
|
64032
|
-
kind: "max",
|
|
64033
|
-
value: maxDate.getTime(),
|
|
64034
|
-
message: errorUtil2.toString(message)
|
|
64035
|
-
});
|
|
64036
|
-
}
|
|
64037
|
-
get minDate() {
|
|
64038
|
-
let min = null;
|
|
64039
|
-
for (const ch of this._def.checks) {
|
|
64040
|
-
if (ch.kind === "min") {
|
|
64041
|
-
if (min === null || ch.value > min)
|
|
64042
|
-
min = ch.value;
|
|
64043
|
-
}
|
|
64044
|
-
}
|
|
64045
|
-
return min != null ? new Date(min) : null;
|
|
64046
|
-
}
|
|
64047
|
-
get maxDate() {
|
|
64048
|
-
let max = null;
|
|
64049
|
-
for (const ch of this._def.checks) {
|
|
64050
|
-
if (ch.kind === "max") {
|
|
64051
|
-
if (max === null || ch.value < max)
|
|
64052
|
-
max = ch.value;
|
|
64053
|
-
}
|
|
64054
|
-
}
|
|
64055
|
-
return max != null ? new Date(max) : null;
|
|
64056
|
-
}
|
|
64057
|
-
}
|
|
64058
|
-
ZodDate2.create = (params) => {
|
|
64059
|
-
return new ZodDate2({
|
|
64060
|
-
checks: [],
|
|
64061
|
-
coerce: (params === null || params === undefined ? undefined : params.coerce) || false,
|
|
64062
|
-
typeName: ZodFirstPartyTypeKind2.ZodDate,
|
|
64063
|
-
...processCreateParams3(params)
|
|
64064
|
-
});
|
|
64065
|
-
};
|
|
64066
|
-
|
|
64067
|
-
class ZodSymbol2 extends ZodType2 {
|
|
64068
|
-
_parse(input) {
|
|
64069
|
-
const parsedType = this._getType(input);
|
|
64070
|
-
if (parsedType !== ZodParsedType2.symbol) {
|
|
64071
|
-
const ctx = this._getOrReturnCtx(input);
|
|
64072
|
-
addIssueToContext2(ctx, {
|
|
64073
|
-
code: ZodIssueCode2.invalid_type,
|
|
64074
|
-
expected: ZodParsedType2.symbol,
|
|
64075
|
-
received: ctx.parsedType
|
|
64076
|
-
});
|
|
64077
|
-
return INVALID2;
|
|
64078
|
-
}
|
|
64079
|
-
return OK2(input.data);
|
|
64080
|
-
}
|
|
64081
|
-
}
|
|
64082
|
-
ZodSymbol2.create = (params) => {
|
|
64083
|
-
return new ZodSymbol2({
|
|
64084
|
-
typeName: ZodFirstPartyTypeKind2.ZodSymbol,
|
|
64085
|
-
...processCreateParams3(params)
|
|
64086
|
-
});
|
|
64087
|
-
};
|
|
64088
|
-
|
|
64089
|
-
class ZodUndefined2 extends ZodType2 {
|
|
64090
|
-
_parse(input) {
|
|
64091
|
-
const parsedType = this._getType(input);
|
|
64092
|
-
if (parsedType !== ZodParsedType2.undefined) {
|
|
64093
|
-
const ctx = this._getOrReturnCtx(input);
|
|
64094
|
-
addIssueToContext2(ctx, {
|
|
64095
|
-
code: ZodIssueCode2.invalid_type,
|
|
64096
|
-
expected: ZodParsedType2.undefined,
|
|
64097
|
-
received: ctx.parsedType
|
|
64098
|
-
});
|
|
64099
|
-
return INVALID2;
|
|
64100
|
-
}
|
|
64101
|
-
return OK2(input.data);
|
|
64102
|
-
}
|
|
64103
|
-
}
|
|
64104
|
-
ZodUndefined2.create = (params) => {
|
|
64105
|
-
return new ZodUndefined2({
|
|
64106
|
-
typeName: ZodFirstPartyTypeKind2.ZodUndefined,
|
|
64107
|
-
...processCreateParams3(params)
|
|
64108
|
-
});
|
|
64109
|
-
};
|
|
64110
|
-
|
|
64111
|
-
class ZodNull2 extends ZodType2 {
|
|
64112
|
-
_parse(input) {
|
|
64113
|
-
const parsedType = this._getType(input);
|
|
64114
|
-
if (parsedType !== ZodParsedType2.null) {
|
|
64115
|
-
const ctx = this._getOrReturnCtx(input);
|
|
64116
|
-
addIssueToContext2(ctx, {
|
|
64117
|
-
code: ZodIssueCode2.invalid_type,
|
|
64118
|
-
expected: ZodParsedType2.null,
|
|
64119
|
-
received: ctx.parsedType
|
|
64120
|
-
});
|
|
64121
|
-
return INVALID2;
|
|
64122
|
-
}
|
|
64123
|
-
return OK2(input.data);
|
|
64124
|
-
}
|
|
64125
|
-
}
|
|
64126
|
-
ZodNull2.create = (params) => {
|
|
64127
|
-
return new ZodNull2({
|
|
64128
|
-
typeName: ZodFirstPartyTypeKind2.ZodNull,
|
|
64129
|
-
...processCreateParams3(params)
|
|
64130
|
-
});
|
|
64131
|
-
};
|
|
64132
|
-
|
|
64133
|
-
class ZodAny2 extends ZodType2 {
|
|
64134
|
-
constructor() {
|
|
64135
|
-
super(...arguments);
|
|
64136
|
-
this._any = true;
|
|
64137
|
-
}
|
|
64138
|
-
_parse(input) {
|
|
64139
|
-
return OK2(input.data);
|
|
64140
|
-
}
|
|
64141
|
-
}
|
|
64142
|
-
ZodAny2.create = (params) => {
|
|
64143
|
-
return new ZodAny2({
|
|
64144
|
-
typeName: ZodFirstPartyTypeKind2.ZodAny,
|
|
64145
|
-
...processCreateParams3(params)
|
|
64146
|
-
});
|
|
64147
|
-
};
|
|
64148
|
-
|
|
64149
|
-
class ZodUnknown2 extends ZodType2 {
|
|
64150
|
-
constructor() {
|
|
64151
|
-
super(...arguments);
|
|
64152
|
-
this._unknown = true;
|
|
64153
|
-
}
|
|
64154
|
-
_parse(input) {
|
|
64155
|
-
return OK2(input.data);
|
|
64156
|
-
}
|
|
64157
|
-
}
|
|
64158
|
-
ZodUnknown2.create = (params) => {
|
|
64159
|
-
return new ZodUnknown2({
|
|
64160
|
-
typeName: ZodFirstPartyTypeKind2.ZodUnknown,
|
|
64161
|
-
...processCreateParams3(params)
|
|
64162
|
-
});
|
|
64163
|
-
};
|
|
64164
|
-
|
|
64165
|
-
class ZodNever2 extends ZodType2 {
|
|
64166
|
-
_parse(input) {
|
|
64167
|
-
const ctx = this._getOrReturnCtx(input);
|
|
64168
|
-
addIssueToContext2(ctx, {
|
|
64169
|
-
code: ZodIssueCode2.invalid_type,
|
|
64170
|
-
expected: ZodParsedType2.never,
|
|
64171
|
-
received: ctx.parsedType
|
|
64172
|
-
});
|
|
64173
|
-
return INVALID2;
|
|
64174
|
-
}
|
|
64175
|
-
}
|
|
64176
|
-
ZodNever2.create = (params) => {
|
|
64177
|
-
return new ZodNever2({
|
|
64178
|
-
typeName: ZodFirstPartyTypeKind2.ZodNever,
|
|
64179
|
-
...processCreateParams3(params)
|
|
64180
|
-
});
|
|
64181
|
-
};
|
|
64182
|
-
|
|
64183
|
-
class ZodVoid2 extends ZodType2 {
|
|
64184
|
-
_parse(input) {
|
|
64185
|
-
const parsedType = this._getType(input);
|
|
64186
|
-
if (parsedType !== ZodParsedType2.undefined) {
|
|
64187
|
-
const ctx = this._getOrReturnCtx(input);
|
|
64188
|
-
addIssueToContext2(ctx, {
|
|
64189
|
-
code: ZodIssueCode2.invalid_type,
|
|
64190
|
-
expected: ZodParsedType2.void,
|
|
64191
|
-
received: ctx.parsedType
|
|
64192
|
-
});
|
|
64193
|
-
return INVALID2;
|
|
64194
|
-
}
|
|
64195
|
-
return OK2(input.data);
|
|
64196
|
-
}
|
|
64197
|
-
}
|
|
64198
|
-
ZodVoid2.create = (params) => {
|
|
64199
|
-
return new ZodVoid2({
|
|
64200
|
-
typeName: ZodFirstPartyTypeKind2.ZodVoid,
|
|
64201
|
-
...processCreateParams3(params)
|
|
64202
|
-
});
|
|
64203
|
-
};
|
|
64204
|
-
|
|
64205
|
-
class ZodArray2 extends ZodType2 {
|
|
64206
|
-
_parse(input) {
|
|
64207
|
-
const { ctx, status } = this._processInputParams(input);
|
|
64208
|
-
const def = this._def;
|
|
64209
|
-
if (ctx.parsedType !== ZodParsedType2.array) {
|
|
64210
|
-
addIssueToContext2(ctx, {
|
|
64211
|
-
code: ZodIssueCode2.invalid_type,
|
|
64212
|
-
expected: ZodParsedType2.array,
|
|
64213
|
-
received: ctx.parsedType
|
|
64214
|
-
});
|
|
64215
|
-
return INVALID2;
|
|
64216
|
-
}
|
|
64217
|
-
if (def.exactLength !== null) {
|
|
64218
|
-
const tooBig = ctx.data.length > def.exactLength.value;
|
|
64219
|
-
const tooSmall = ctx.data.length < def.exactLength.value;
|
|
64220
|
-
if (tooBig || tooSmall) {
|
|
64221
|
-
addIssueToContext2(ctx, {
|
|
64222
|
-
code: tooBig ? ZodIssueCode2.too_big : ZodIssueCode2.too_small,
|
|
64223
|
-
minimum: tooSmall ? def.exactLength.value : undefined,
|
|
64224
|
-
maximum: tooBig ? def.exactLength.value : undefined,
|
|
64225
|
-
type: "array",
|
|
64226
|
-
inclusive: true,
|
|
64227
|
-
exact: true,
|
|
64228
|
-
message: def.exactLength.message
|
|
64229
|
-
});
|
|
64230
|
-
status.dirty();
|
|
64231
|
-
}
|
|
64232
|
-
}
|
|
64233
|
-
if (def.minLength !== null) {
|
|
64234
|
-
if (ctx.data.length < def.minLength.value) {
|
|
64235
|
-
addIssueToContext2(ctx, {
|
|
64236
|
-
code: ZodIssueCode2.too_small,
|
|
64237
|
-
minimum: def.minLength.value,
|
|
64238
|
-
type: "array",
|
|
64239
|
-
inclusive: true,
|
|
64240
|
-
exact: false,
|
|
64241
|
-
message: def.minLength.message
|
|
64242
|
-
});
|
|
64243
|
-
status.dirty();
|
|
64244
|
-
}
|
|
64245
|
-
}
|
|
64246
|
-
if (def.maxLength !== null) {
|
|
64247
|
-
if (ctx.data.length > def.maxLength.value) {
|
|
64248
|
-
addIssueToContext2(ctx, {
|
|
64249
|
-
code: ZodIssueCode2.too_big,
|
|
64250
|
-
maximum: def.maxLength.value,
|
|
64251
|
-
type: "array",
|
|
64252
|
-
inclusive: true,
|
|
64253
|
-
exact: false,
|
|
64254
|
-
message: def.maxLength.message
|
|
64255
|
-
});
|
|
64256
|
-
status.dirty();
|
|
64257
|
-
}
|
|
64258
|
-
}
|
|
64259
|
-
if (ctx.common.async) {
|
|
64260
|
-
return Promise.all([...ctx.data].map((item, i) => {
|
|
64261
|
-
return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
|
|
64262
|
-
})).then((result2) => {
|
|
64263
|
-
return ParseStatus2.mergeArray(status, result2);
|
|
64264
|
-
});
|
|
64265
|
-
}
|
|
64266
|
-
const result = [...ctx.data].map((item, i) => {
|
|
64267
|
-
return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
|
|
64268
|
-
});
|
|
64269
|
-
return ParseStatus2.mergeArray(status, result);
|
|
64270
|
-
}
|
|
64271
|
-
get element() {
|
|
64272
|
-
return this._def.type;
|
|
64273
|
-
}
|
|
64274
|
-
min(minLength, message) {
|
|
64275
|
-
return new ZodArray2({
|
|
64276
|
-
...this._def,
|
|
64277
|
-
minLength: { value: minLength, message: errorUtil2.toString(message) }
|
|
64278
|
-
});
|
|
64279
|
-
}
|
|
64280
|
-
max(maxLength, message) {
|
|
64281
|
-
return new ZodArray2({
|
|
64282
|
-
...this._def,
|
|
64283
|
-
maxLength: { value: maxLength, message: errorUtil2.toString(message) }
|
|
64284
|
-
});
|
|
64285
|
-
}
|
|
64286
|
-
length(len, message) {
|
|
64287
|
-
return new ZodArray2({
|
|
64288
|
-
...this._def,
|
|
64289
|
-
exactLength: { value: len, message: errorUtil2.toString(message) }
|
|
64290
|
-
});
|
|
64291
|
-
}
|
|
64292
|
-
nonempty(message) {
|
|
64293
|
-
return this.min(1, message);
|
|
64294
|
-
}
|
|
64295
|
-
}
|
|
64296
|
-
ZodArray2.create = (schema, params) => {
|
|
64297
|
-
return new ZodArray2({
|
|
64298
|
-
type: schema,
|
|
64299
|
-
minLength: null,
|
|
64300
|
-
maxLength: null,
|
|
64301
|
-
exactLength: null,
|
|
64302
|
-
typeName: ZodFirstPartyTypeKind2.ZodArray,
|
|
64303
|
-
...processCreateParams3(params)
|
|
64304
|
-
});
|
|
64305
|
-
};
|
|
64306
|
-
function deepPartialify2(schema) {
|
|
64307
|
-
if (schema instanceof ZodObject2) {
|
|
64308
|
-
const newShape = {};
|
|
64309
|
-
for (const key in schema.shape) {
|
|
64310
|
-
const fieldSchema = schema.shape[key];
|
|
64311
|
-
newShape[key] = ZodOptional2.create(deepPartialify2(fieldSchema));
|
|
64312
|
-
}
|
|
64313
|
-
return new ZodObject2({
|
|
64314
|
-
...schema._def,
|
|
64315
|
-
shape: () => newShape
|
|
64316
|
-
});
|
|
64317
|
-
} else if (schema instanceof ZodArray2) {
|
|
64318
|
-
return new ZodArray2({
|
|
64319
|
-
...schema._def,
|
|
64320
|
-
type: deepPartialify2(schema.element)
|
|
64321
|
-
});
|
|
64322
|
-
} else if (schema instanceof ZodOptional2) {
|
|
64323
|
-
return ZodOptional2.create(deepPartialify2(schema.unwrap()));
|
|
64324
|
-
} else if (schema instanceof ZodNullable2) {
|
|
64325
|
-
return ZodNullable2.create(deepPartialify2(schema.unwrap()));
|
|
64326
|
-
} else if (schema instanceof ZodTuple2) {
|
|
64327
|
-
return ZodTuple2.create(schema.items.map((item) => deepPartialify2(item)));
|
|
64328
|
-
} else {
|
|
64329
|
-
return schema;
|
|
64330
|
-
}
|
|
64331
|
-
}
|
|
64332
|
-
|
|
64333
|
-
class ZodObject2 extends ZodType2 {
|
|
64334
|
-
constructor() {
|
|
64335
|
-
super(...arguments);
|
|
64336
|
-
this._cached = null;
|
|
64337
|
-
this.nonstrict = this.passthrough;
|
|
64338
|
-
this.augment = this.extend;
|
|
64339
|
-
}
|
|
64340
|
-
_getCached() {
|
|
64341
|
-
if (this._cached !== null)
|
|
64342
|
-
return this._cached;
|
|
64343
|
-
const shape = this._def.shape();
|
|
64344
|
-
const keys = util2.objectKeys(shape);
|
|
64345
|
-
return this._cached = { shape, keys };
|
|
64346
|
-
}
|
|
64347
|
-
_parse(input) {
|
|
64348
|
-
const parsedType = this._getType(input);
|
|
64349
|
-
if (parsedType !== ZodParsedType2.object) {
|
|
64350
|
-
const ctx2 = this._getOrReturnCtx(input);
|
|
64351
|
-
addIssueToContext2(ctx2, {
|
|
64352
|
-
code: ZodIssueCode2.invalid_type,
|
|
64353
|
-
expected: ZodParsedType2.object,
|
|
64354
|
-
received: ctx2.parsedType
|
|
64355
|
-
});
|
|
64356
|
-
return INVALID2;
|
|
64357
|
-
}
|
|
64358
|
-
const { status, ctx } = this._processInputParams(input);
|
|
64359
|
-
const { shape, keys: shapeKeys } = this._getCached();
|
|
64360
|
-
const extraKeys = [];
|
|
64361
|
-
if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
|
|
64362
|
-
for (const key in ctx.data) {
|
|
64363
|
-
if (!shapeKeys.includes(key)) {
|
|
64364
|
-
extraKeys.push(key);
|
|
64365
|
-
}
|
|
64366
|
-
}
|
|
64367
|
-
}
|
|
64368
|
-
const pairs = [];
|
|
64369
|
-
for (const key of shapeKeys) {
|
|
64370
|
-
const keyValidator = shape[key];
|
|
64371
|
-
const value = ctx.data[key];
|
|
64372
|
-
pairs.push({
|
|
64373
|
-
key: { status: "valid", value: key },
|
|
64374
|
-
value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
|
|
64375
|
-
alwaysSet: key in ctx.data
|
|
64376
|
-
});
|
|
64377
|
-
}
|
|
64378
|
-
if (this._def.catchall instanceof ZodNever2) {
|
|
64379
|
-
const unknownKeys = this._def.unknownKeys;
|
|
64380
|
-
if (unknownKeys === "passthrough") {
|
|
64381
|
-
for (const key of extraKeys) {
|
|
64382
|
-
pairs.push({
|
|
64383
|
-
key: { status: "valid", value: key },
|
|
64384
|
-
value: { status: "valid", value: ctx.data[key] }
|
|
64385
|
-
});
|
|
64386
|
-
}
|
|
64387
|
-
} else if (unknownKeys === "strict") {
|
|
64388
|
-
if (extraKeys.length > 0) {
|
|
64389
|
-
addIssueToContext2(ctx, {
|
|
64390
|
-
code: ZodIssueCode2.unrecognized_keys,
|
|
64391
|
-
keys: extraKeys
|
|
64392
|
-
});
|
|
64393
|
-
status.dirty();
|
|
64394
|
-
}
|
|
64395
|
-
} else if (unknownKeys === "strip")
|
|
64396
|
-
;
|
|
64397
|
-
else {
|
|
64398
|
-
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
64399
|
-
}
|
|
64400
|
-
} else {
|
|
64401
|
-
const catchall = this._def.catchall;
|
|
64402
|
-
for (const key of extraKeys) {
|
|
64403
|
-
const value = ctx.data[key];
|
|
64404
|
-
pairs.push({
|
|
64405
|
-
key: { status: "valid", value: key },
|
|
64406
|
-
value: catchall._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
|
|
64407
|
-
alwaysSet: key in ctx.data
|
|
64408
|
-
});
|
|
64409
|
-
}
|
|
64410
|
-
}
|
|
64411
|
-
if (ctx.common.async) {
|
|
64412
|
-
return Promise.resolve().then(async () => {
|
|
64413
|
-
const syncPairs = [];
|
|
64414
|
-
for (const pair of pairs) {
|
|
64415
|
-
const key = await pair.key;
|
|
64416
|
-
const value = await pair.value;
|
|
64417
|
-
syncPairs.push({
|
|
64418
|
-
key,
|
|
64419
|
-
value,
|
|
64420
|
-
alwaysSet: pair.alwaysSet
|
|
64421
|
-
});
|
|
64422
|
-
}
|
|
64423
|
-
return syncPairs;
|
|
64424
|
-
}).then((syncPairs) => {
|
|
64425
|
-
return ParseStatus2.mergeObjectSync(status, syncPairs);
|
|
64426
|
-
});
|
|
64427
|
-
} else {
|
|
64428
|
-
return ParseStatus2.mergeObjectSync(status, pairs);
|
|
64429
|
-
}
|
|
64430
|
-
}
|
|
64431
|
-
get shape() {
|
|
64432
|
-
return this._def.shape();
|
|
64433
|
-
}
|
|
64434
|
-
strict(message) {
|
|
64435
|
-
errorUtil2.errToObj;
|
|
64436
|
-
return new ZodObject2({
|
|
64437
|
-
...this._def,
|
|
64438
|
-
unknownKeys: "strict",
|
|
64439
|
-
...message !== undefined ? {
|
|
64440
|
-
errorMap: (issue, ctx) => {
|
|
64441
|
-
var _a, _b, _c, _d;
|
|
64442
|
-
const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === undefined ? undefined : _b.call(_a, issue, ctx).message) !== null && _c !== undefined ? _c : ctx.defaultError;
|
|
64443
|
-
if (issue.code === "unrecognized_keys")
|
|
64444
|
-
return {
|
|
64445
|
-
message: (_d = errorUtil2.errToObj(message).message) !== null && _d !== undefined ? _d : defaultError
|
|
64446
|
-
};
|
|
64447
|
-
return {
|
|
64448
|
-
message: defaultError
|
|
64449
|
-
};
|
|
64450
|
-
}
|
|
64451
|
-
} : {}
|
|
64452
|
-
});
|
|
64453
|
-
}
|
|
64454
|
-
strip() {
|
|
64455
|
-
return new ZodObject2({
|
|
64456
|
-
...this._def,
|
|
64457
|
-
unknownKeys: "strip"
|
|
64458
|
-
});
|
|
64459
|
-
}
|
|
64460
|
-
passthrough() {
|
|
64461
|
-
return new ZodObject2({
|
|
64462
|
-
...this._def,
|
|
64463
|
-
unknownKeys: "passthrough"
|
|
64464
|
-
});
|
|
64465
|
-
}
|
|
64466
|
-
extend(augmentation) {
|
|
64467
|
-
return new ZodObject2({
|
|
64468
|
-
...this._def,
|
|
64469
|
-
shape: () => ({
|
|
64470
|
-
...this._def.shape(),
|
|
64471
|
-
...augmentation
|
|
64472
|
-
})
|
|
64473
|
-
});
|
|
64474
|
-
}
|
|
64475
|
-
merge(merging) {
|
|
64476
|
-
const merged = new ZodObject2({
|
|
64477
|
-
unknownKeys: merging._def.unknownKeys,
|
|
64478
|
-
catchall: merging._def.catchall,
|
|
64479
|
-
shape: () => ({
|
|
64480
|
-
...this._def.shape(),
|
|
64481
|
-
...merging._def.shape()
|
|
64482
|
-
}),
|
|
64483
|
-
typeName: ZodFirstPartyTypeKind2.ZodObject
|
|
64484
|
-
});
|
|
64485
|
-
return merged;
|
|
64486
|
-
}
|
|
64487
|
-
setKey(key, schema) {
|
|
64488
|
-
return this.augment({ [key]: schema });
|
|
64489
|
-
}
|
|
64490
|
-
catchall(index) {
|
|
64491
|
-
return new ZodObject2({
|
|
64492
|
-
...this._def,
|
|
64493
|
-
catchall: index
|
|
64494
|
-
});
|
|
64495
|
-
}
|
|
64496
|
-
pick(mask) {
|
|
64497
|
-
const shape = {};
|
|
64498
|
-
util2.objectKeys(mask).forEach((key) => {
|
|
64499
|
-
if (mask[key] && this.shape[key]) {
|
|
64500
|
-
shape[key] = this.shape[key];
|
|
64501
|
-
}
|
|
64502
|
-
});
|
|
64503
|
-
return new ZodObject2({
|
|
64504
|
-
...this._def,
|
|
64505
|
-
shape: () => shape
|
|
64506
|
-
});
|
|
64507
|
-
}
|
|
64508
|
-
omit(mask) {
|
|
64509
|
-
const shape = {};
|
|
64510
|
-
util2.objectKeys(this.shape).forEach((key) => {
|
|
64511
|
-
if (!mask[key]) {
|
|
64512
|
-
shape[key] = this.shape[key];
|
|
64513
|
-
}
|
|
64514
|
-
});
|
|
64515
|
-
return new ZodObject2({
|
|
64516
|
-
...this._def,
|
|
64517
|
-
shape: () => shape
|
|
64518
|
-
});
|
|
64519
|
-
}
|
|
64520
|
-
deepPartial() {
|
|
64521
|
-
return deepPartialify2(this);
|
|
64522
|
-
}
|
|
64523
|
-
partial(mask) {
|
|
64524
|
-
const newShape = {};
|
|
64525
|
-
util2.objectKeys(this.shape).forEach((key) => {
|
|
64526
|
-
const fieldSchema = this.shape[key];
|
|
64527
|
-
if (mask && !mask[key]) {
|
|
64528
|
-
newShape[key] = fieldSchema;
|
|
64529
|
-
} else {
|
|
64530
|
-
newShape[key] = fieldSchema.optional();
|
|
64531
|
-
}
|
|
64532
|
-
});
|
|
64533
|
-
return new ZodObject2({
|
|
64534
|
-
...this._def,
|
|
64535
|
-
shape: () => newShape
|
|
64536
|
-
});
|
|
64537
|
-
}
|
|
64538
|
-
required(mask) {
|
|
64539
|
-
const newShape = {};
|
|
64540
|
-
util2.objectKeys(this.shape).forEach((key) => {
|
|
64541
|
-
if (mask && !mask[key]) {
|
|
64542
|
-
newShape[key] = this.shape[key];
|
|
64543
|
-
} else {
|
|
64544
|
-
const fieldSchema = this.shape[key];
|
|
64545
|
-
let newField = fieldSchema;
|
|
64546
|
-
while (newField instanceof ZodOptional2) {
|
|
64547
|
-
newField = newField._def.innerType;
|
|
64548
|
-
}
|
|
64549
|
-
newShape[key] = newField;
|
|
64550
|
-
}
|
|
64551
|
-
});
|
|
64552
|
-
return new ZodObject2({
|
|
64553
|
-
...this._def,
|
|
64554
|
-
shape: () => newShape
|
|
64555
|
-
});
|
|
64556
|
-
}
|
|
64557
|
-
keyof() {
|
|
64558
|
-
return createZodEnum2(util2.objectKeys(this.shape));
|
|
64559
|
-
}
|
|
64560
|
-
}
|
|
64561
|
-
ZodObject2.create = (shape, params) => {
|
|
64562
|
-
return new ZodObject2({
|
|
64563
|
-
shape: () => shape,
|
|
64564
|
-
unknownKeys: "strip",
|
|
64565
|
-
catchall: ZodNever2.create(),
|
|
64566
|
-
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
64567
|
-
...processCreateParams3(params)
|
|
64568
|
-
});
|
|
64569
|
-
};
|
|
64570
|
-
ZodObject2.strictCreate = (shape, params) => {
|
|
64571
|
-
return new ZodObject2({
|
|
64572
|
-
shape: () => shape,
|
|
64573
|
-
unknownKeys: "strict",
|
|
64574
|
-
catchall: ZodNever2.create(),
|
|
64575
|
-
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
64576
|
-
...processCreateParams3(params)
|
|
64577
|
-
});
|
|
64578
|
-
};
|
|
64579
|
-
ZodObject2.lazycreate = (shape, params) => {
|
|
64580
|
-
return new ZodObject2({
|
|
64581
|
-
shape,
|
|
64582
|
-
unknownKeys: "strip",
|
|
64583
|
-
catchall: ZodNever2.create(),
|
|
64584
|
-
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
64585
|
-
...processCreateParams3(params)
|
|
64586
|
-
});
|
|
64587
|
-
};
|
|
64588
|
-
|
|
64589
|
-
class ZodUnion2 extends ZodType2 {
|
|
64590
|
-
_parse(input) {
|
|
64591
|
-
const { ctx } = this._processInputParams(input);
|
|
64592
|
-
const options = this._def.options;
|
|
64593
|
-
function handleResults(results) {
|
|
64594
|
-
for (const result of results) {
|
|
64595
|
-
if (result.result.status === "valid") {
|
|
64596
|
-
return result.result;
|
|
64597
|
-
}
|
|
64598
|
-
}
|
|
64599
|
-
for (const result of results) {
|
|
64600
|
-
if (result.result.status === "dirty") {
|
|
64601
|
-
ctx.common.issues.push(...result.ctx.common.issues);
|
|
64602
|
-
return result.result;
|
|
64603
|
-
}
|
|
64604
|
-
}
|
|
64605
|
-
const unionErrors = results.map((result) => new ZodError2(result.ctx.common.issues));
|
|
64606
|
-
addIssueToContext2(ctx, {
|
|
64607
|
-
code: ZodIssueCode2.invalid_union,
|
|
64608
|
-
unionErrors
|
|
64609
|
-
});
|
|
64610
|
-
return INVALID2;
|
|
64611
|
-
}
|
|
64612
|
-
if (ctx.common.async) {
|
|
64613
|
-
return Promise.all(options.map(async (option) => {
|
|
64614
|
-
const childCtx = {
|
|
64615
|
-
...ctx,
|
|
64616
|
-
common: {
|
|
64617
|
-
...ctx.common,
|
|
64618
|
-
issues: []
|
|
64619
|
-
},
|
|
64620
|
-
parent: null
|
|
64621
|
-
};
|
|
64622
|
-
return {
|
|
64623
|
-
result: await option._parseAsync({
|
|
64624
|
-
data: ctx.data,
|
|
64625
|
-
path: ctx.path,
|
|
64626
|
-
parent: childCtx
|
|
64627
|
-
}),
|
|
64628
|
-
ctx: childCtx
|
|
64629
|
-
};
|
|
64630
|
-
})).then(handleResults);
|
|
64631
|
-
} else {
|
|
64632
|
-
let dirty = undefined;
|
|
64633
|
-
const issues = [];
|
|
64634
|
-
for (const option of options) {
|
|
64635
|
-
const childCtx = {
|
|
64636
|
-
...ctx,
|
|
64637
|
-
common: {
|
|
64638
|
-
...ctx.common,
|
|
64639
|
-
issues: []
|
|
64640
|
-
},
|
|
64641
|
-
parent: null
|
|
64642
|
-
};
|
|
64643
|
-
const result = option._parseSync({
|
|
64644
|
-
data: ctx.data,
|
|
64645
|
-
path: ctx.path,
|
|
64646
|
-
parent: childCtx
|
|
64647
|
-
});
|
|
64648
|
-
if (result.status === "valid") {
|
|
64649
|
-
return result;
|
|
64650
|
-
} else if (result.status === "dirty" && !dirty) {
|
|
64651
|
-
dirty = { result, ctx: childCtx };
|
|
64652
|
-
}
|
|
64653
|
-
if (childCtx.common.issues.length) {
|
|
64654
|
-
issues.push(childCtx.common.issues);
|
|
64655
|
-
}
|
|
64656
|
-
}
|
|
64657
|
-
if (dirty) {
|
|
64658
|
-
ctx.common.issues.push(...dirty.ctx.common.issues);
|
|
64659
|
-
return dirty.result;
|
|
64660
|
-
}
|
|
64661
|
-
const unionErrors = issues.map((issues2) => new ZodError2(issues2));
|
|
64662
|
-
addIssueToContext2(ctx, {
|
|
64663
|
-
code: ZodIssueCode2.invalid_union,
|
|
64664
|
-
unionErrors
|
|
64665
|
-
});
|
|
64666
|
-
return INVALID2;
|
|
64667
|
-
}
|
|
64668
|
-
}
|
|
64669
|
-
get options() {
|
|
64670
|
-
return this._def.options;
|
|
64671
|
-
}
|
|
64672
|
-
}
|
|
64673
|
-
ZodUnion2.create = (types5, params) => {
|
|
64674
|
-
return new ZodUnion2({
|
|
64675
|
-
options: types5,
|
|
64676
|
-
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
64677
|
-
...processCreateParams3(params)
|
|
64678
|
-
});
|
|
64679
|
-
};
|
|
64680
|
-
var getDiscriminator2 = (type) => {
|
|
64681
|
-
if (type instanceof ZodLazy2) {
|
|
64682
|
-
return getDiscriminator2(type.schema);
|
|
64683
|
-
} else if (type instanceof ZodEffects2) {
|
|
64684
|
-
return getDiscriminator2(type.innerType());
|
|
64685
|
-
} else if (type instanceof ZodLiteral2) {
|
|
64686
|
-
return [type.value];
|
|
64687
|
-
} else if (type instanceof ZodEnum2) {
|
|
64688
|
-
return type.options;
|
|
64689
|
-
} else if (type instanceof ZodNativeEnum2) {
|
|
64690
|
-
return util2.objectValues(type.enum);
|
|
64691
|
-
} else if (type instanceof ZodDefault2) {
|
|
64692
|
-
return getDiscriminator2(type._def.innerType);
|
|
64693
|
-
} else if (type instanceof ZodUndefined2) {
|
|
64694
|
-
return [undefined];
|
|
64695
|
-
} else if (type instanceof ZodNull2) {
|
|
64696
|
-
return [null];
|
|
64697
|
-
} else if (type instanceof ZodOptional2) {
|
|
64698
|
-
return [undefined, ...getDiscriminator2(type.unwrap())];
|
|
64699
|
-
} else if (type instanceof ZodNullable2) {
|
|
64700
|
-
return [null, ...getDiscriminator2(type.unwrap())];
|
|
64701
|
-
} else if (type instanceof ZodBranded2) {
|
|
64702
|
-
return getDiscriminator2(type.unwrap());
|
|
64703
|
-
} else if (type instanceof ZodReadonly2) {
|
|
64704
|
-
return getDiscriminator2(type.unwrap());
|
|
64705
|
-
} else if (type instanceof ZodCatch2) {
|
|
64706
|
-
return getDiscriminator2(type._def.innerType);
|
|
64707
|
-
} else {
|
|
64708
|
-
return [];
|
|
64709
|
-
}
|
|
64710
|
-
};
|
|
64711
|
-
|
|
64712
|
-
class ZodDiscriminatedUnion2 extends ZodType2 {
|
|
64713
|
-
_parse(input) {
|
|
64714
|
-
const { ctx } = this._processInputParams(input);
|
|
64715
|
-
if (ctx.parsedType !== ZodParsedType2.object) {
|
|
64716
|
-
addIssueToContext2(ctx, {
|
|
64717
|
-
code: ZodIssueCode2.invalid_type,
|
|
64718
|
-
expected: ZodParsedType2.object,
|
|
64719
|
-
received: ctx.parsedType
|
|
64720
|
-
});
|
|
64721
|
-
return INVALID2;
|
|
64722
|
-
}
|
|
64723
|
-
const discriminator = this.discriminator;
|
|
64724
|
-
const discriminatorValue = ctx.data[discriminator];
|
|
64725
|
-
const option = this.optionsMap.get(discriminatorValue);
|
|
64726
|
-
if (!option) {
|
|
64727
|
-
addIssueToContext2(ctx, {
|
|
64728
|
-
code: ZodIssueCode2.invalid_union_discriminator,
|
|
64729
|
-
options: Array.from(this.optionsMap.keys()),
|
|
64730
|
-
path: [discriminator]
|
|
64731
|
-
});
|
|
64732
|
-
return INVALID2;
|
|
64733
|
-
}
|
|
64734
|
-
if (ctx.common.async) {
|
|
64735
|
-
return option._parseAsync({
|
|
64736
|
-
data: ctx.data,
|
|
64737
|
-
path: ctx.path,
|
|
64738
|
-
parent: ctx
|
|
64739
|
-
});
|
|
64740
|
-
} else {
|
|
64741
|
-
return option._parseSync({
|
|
64742
|
-
data: ctx.data,
|
|
64743
|
-
path: ctx.path,
|
|
64744
|
-
parent: ctx
|
|
64745
|
-
});
|
|
64746
|
-
}
|
|
64747
|
-
}
|
|
64748
|
-
get discriminator() {
|
|
64749
|
-
return this._def.discriminator;
|
|
64750
|
-
}
|
|
64751
|
-
get options() {
|
|
64752
|
-
return this._def.options;
|
|
64753
|
-
}
|
|
64754
|
-
get optionsMap() {
|
|
64755
|
-
return this._def.optionsMap;
|
|
64756
|
-
}
|
|
64757
|
-
static create(discriminator, options, params) {
|
|
64758
|
-
const optionsMap = new Map;
|
|
64759
|
-
for (const type of options) {
|
|
64760
|
-
const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
|
|
64761
|
-
if (!discriminatorValues.length) {
|
|
64762
|
-
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
64763
|
-
}
|
|
64764
|
-
for (const value of discriminatorValues) {
|
|
64765
|
-
if (optionsMap.has(value)) {
|
|
64766
|
-
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
64767
|
-
}
|
|
64768
|
-
optionsMap.set(value, type);
|
|
64769
|
-
}
|
|
64770
|
-
}
|
|
64771
|
-
return new ZodDiscriminatedUnion2({
|
|
64772
|
-
typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
|
|
64773
|
-
discriminator,
|
|
64774
|
-
options,
|
|
64775
|
-
optionsMap,
|
|
64776
|
-
...processCreateParams3(params)
|
|
64777
|
-
});
|
|
64778
|
-
}
|
|
64779
|
-
}
|
|
64780
|
-
function mergeValues2(a, b) {
|
|
64781
|
-
const aType = getParsedType2(a);
|
|
64782
|
-
const bType = getParsedType2(b);
|
|
64783
|
-
if (a === b) {
|
|
64784
|
-
return { valid: true, data: a };
|
|
64785
|
-
} else if (aType === ZodParsedType2.object && bType === ZodParsedType2.object) {
|
|
64786
|
-
const bKeys = util2.objectKeys(b);
|
|
64787
|
-
const sharedKeys = util2.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
64788
|
-
const newObj = { ...a, ...b };
|
|
64789
|
-
for (const key of sharedKeys) {
|
|
64790
|
-
const sharedValue = mergeValues2(a[key], b[key]);
|
|
64791
|
-
if (!sharedValue.valid) {
|
|
64792
|
-
return { valid: false };
|
|
64793
|
-
}
|
|
64794
|
-
newObj[key] = sharedValue.data;
|
|
64795
|
-
}
|
|
64796
|
-
return { valid: true, data: newObj };
|
|
64797
|
-
} else if (aType === ZodParsedType2.array && bType === ZodParsedType2.array) {
|
|
64798
|
-
if (a.length !== b.length) {
|
|
64799
|
-
return { valid: false };
|
|
64800
|
-
}
|
|
64801
|
-
const newArray = [];
|
|
64802
|
-
for (let index = 0;index < a.length; index++) {
|
|
64803
|
-
const itemA = a[index];
|
|
64804
|
-
const itemB = b[index];
|
|
64805
|
-
const sharedValue = mergeValues2(itemA, itemB);
|
|
64806
|
-
if (!sharedValue.valid) {
|
|
64807
|
-
return { valid: false };
|
|
64808
|
-
}
|
|
64809
|
-
newArray.push(sharedValue.data);
|
|
64810
|
-
}
|
|
64811
|
-
return { valid: true, data: newArray };
|
|
64812
|
-
} else if (aType === ZodParsedType2.date && bType === ZodParsedType2.date && +a === +b) {
|
|
64813
|
-
return { valid: true, data: a };
|
|
64814
|
-
} else {
|
|
64815
|
-
return { valid: false };
|
|
64816
|
-
}
|
|
64817
|
-
}
|
|
64818
|
-
|
|
64819
|
-
class ZodIntersection2 extends ZodType2 {
|
|
64820
|
-
_parse(input) {
|
|
64821
|
-
const { status, ctx } = this._processInputParams(input);
|
|
64822
|
-
const handleParsed = (parsedLeft, parsedRight) => {
|
|
64823
|
-
if (isAborted2(parsedLeft) || isAborted2(parsedRight)) {
|
|
64824
|
-
return INVALID2;
|
|
64825
|
-
}
|
|
64826
|
-
const merged = mergeValues2(parsedLeft.value, parsedRight.value);
|
|
64827
|
-
if (!merged.valid) {
|
|
64828
|
-
addIssueToContext2(ctx, {
|
|
64829
|
-
code: ZodIssueCode2.invalid_intersection_types
|
|
64830
|
-
});
|
|
64831
|
-
return INVALID2;
|
|
64832
|
-
}
|
|
64833
|
-
if (isDirty2(parsedLeft) || isDirty2(parsedRight)) {
|
|
64834
|
-
status.dirty();
|
|
64835
|
-
}
|
|
64836
|
-
return { status: status.value, value: merged.data };
|
|
64837
|
-
};
|
|
64838
|
-
if (ctx.common.async) {
|
|
64839
|
-
return Promise.all([
|
|
64840
|
-
this._def.left._parseAsync({
|
|
64841
|
-
data: ctx.data,
|
|
64842
|
-
path: ctx.path,
|
|
64843
|
-
parent: ctx
|
|
64844
|
-
}),
|
|
64845
|
-
this._def.right._parseAsync({
|
|
64846
|
-
data: ctx.data,
|
|
64847
|
-
path: ctx.path,
|
|
64848
|
-
parent: ctx
|
|
64849
|
-
})
|
|
64850
|
-
]).then(([left, right]) => handleParsed(left, right));
|
|
64851
|
-
} else {
|
|
64852
|
-
return handleParsed(this._def.left._parseSync({
|
|
64853
|
-
data: ctx.data,
|
|
64854
|
-
path: ctx.path,
|
|
64855
|
-
parent: ctx
|
|
64856
|
-
}), this._def.right._parseSync({
|
|
64857
|
-
data: ctx.data,
|
|
64858
|
-
path: ctx.path,
|
|
64859
|
-
parent: ctx
|
|
64860
|
-
}));
|
|
64861
|
-
}
|
|
64862
|
-
}
|
|
64863
|
-
}
|
|
64864
|
-
ZodIntersection2.create = (left, right, params) => {
|
|
64865
|
-
return new ZodIntersection2({
|
|
64866
|
-
left,
|
|
64867
|
-
right,
|
|
64868
|
-
typeName: ZodFirstPartyTypeKind2.ZodIntersection,
|
|
64869
|
-
...processCreateParams3(params)
|
|
64870
|
-
});
|
|
64871
|
-
};
|
|
64872
|
-
|
|
64873
|
-
class ZodTuple2 extends ZodType2 {
|
|
64874
|
-
_parse(input) {
|
|
64875
|
-
const { status, ctx } = this._processInputParams(input);
|
|
64876
|
-
if (ctx.parsedType !== ZodParsedType2.array) {
|
|
64877
|
-
addIssueToContext2(ctx, {
|
|
64878
|
-
code: ZodIssueCode2.invalid_type,
|
|
64879
|
-
expected: ZodParsedType2.array,
|
|
64880
|
-
received: ctx.parsedType
|
|
64881
|
-
});
|
|
64882
|
-
return INVALID2;
|
|
64883
|
-
}
|
|
64884
|
-
if (ctx.data.length < this._def.items.length) {
|
|
64885
|
-
addIssueToContext2(ctx, {
|
|
64886
|
-
code: ZodIssueCode2.too_small,
|
|
64887
|
-
minimum: this._def.items.length,
|
|
64888
|
-
inclusive: true,
|
|
64889
|
-
exact: false,
|
|
64890
|
-
type: "array"
|
|
64891
|
-
});
|
|
64892
|
-
return INVALID2;
|
|
64893
|
-
}
|
|
64894
|
-
const rest = this._def.rest;
|
|
64895
|
-
if (!rest && ctx.data.length > this._def.items.length) {
|
|
64896
|
-
addIssueToContext2(ctx, {
|
|
64897
|
-
code: ZodIssueCode2.too_big,
|
|
64898
|
-
maximum: this._def.items.length,
|
|
64899
|
-
inclusive: true,
|
|
64900
|
-
exact: false,
|
|
64901
|
-
type: "array"
|
|
64902
|
-
});
|
|
64903
|
-
status.dirty();
|
|
64904
|
-
}
|
|
64905
|
-
const items = [...ctx.data].map((item, itemIndex) => {
|
|
64906
|
-
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
64907
|
-
if (!schema)
|
|
64908
|
-
return null;
|
|
64909
|
-
return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex));
|
|
64910
|
-
}).filter((x) => !!x);
|
|
64911
|
-
if (ctx.common.async) {
|
|
64912
|
-
return Promise.all(items).then((results) => {
|
|
64913
|
-
return ParseStatus2.mergeArray(status, results);
|
|
64914
|
-
});
|
|
64915
|
-
} else {
|
|
64916
|
-
return ParseStatus2.mergeArray(status, items);
|
|
64917
|
-
}
|
|
64918
|
-
}
|
|
64919
|
-
get items() {
|
|
64920
|
-
return this._def.items;
|
|
64921
|
-
}
|
|
64922
|
-
rest(rest) {
|
|
64923
|
-
return new ZodTuple2({
|
|
64924
|
-
...this._def,
|
|
64925
|
-
rest
|
|
64926
|
-
});
|
|
64927
|
-
}
|
|
64928
|
-
}
|
|
64929
|
-
ZodTuple2.create = (schemas, params) => {
|
|
64930
|
-
if (!Array.isArray(schemas)) {
|
|
64931
|
-
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
64932
|
-
}
|
|
64933
|
-
return new ZodTuple2({
|
|
64934
|
-
items: schemas,
|
|
64935
|
-
typeName: ZodFirstPartyTypeKind2.ZodTuple,
|
|
64936
|
-
rest: null,
|
|
64937
|
-
...processCreateParams3(params)
|
|
64938
|
-
});
|
|
64939
|
-
};
|
|
64940
|
-
|
|
64941
|
-
class ZodRecord2 extends ZodType2 {
|
|
64942
|
-
get keySchema() {
|
|
64943
|
-
return this._def.keyType;
|
|
64944
|
-
}
|
|
64945
|
-
get valueSchema() {
|
|
64946
|
-
return this._def.valueType;
|
|
64947
|
-
}
|
|
64948
|
-
_parse(input) {
|
|
64949
|
-
const { status, ctx } = this._processInputParams(input);
|
|
64950
|
-
if (ctx.parsedType !== ZodParsedType2.object) {
|
|
64951
|
-
addIssueToContext2(ctx, {
|
|
64952
|
-
code: ZodIssueCode2.invalid_type,
|
|
64953
|
-
expected: ZodParsedType2.object,
|
|
64954
|
-
received: ctx.parsedType
|
|
64955
|
-
});
|
|
64956
|
-
return INVALID2;
|
|
64957
|
-
}
|
|
64958
|
-
const pairs = [];
|
|
64959
|
-
const keyType = this._def.keyType;
|
|
64960
|
-
const valueType = this._def.valueType;
|
|
64961
|
-
for (const key in ctx.data) {
|
|
64962
|
-
pairs.push({
|
|
64963
|
-
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
|
|
64964
|
-
value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
|
|
64965
|
-
alwaysSet: key in ctx.data
|
|
64966
|
-
});
|
|
64967
|
-
}
|
|
64968
|
-
if (ctx.common.async) {
|
|
64969
|
-
return ParseStatus2.mergeObjectAsync(status, pairs);
|
|
64970
|
-
} else {
|
|
64971
|
-
return ParseStatus2.mergeObjectSync(status, pairs);
|
|
64972
|
-
}
|
|
64973
|
-
}
|
|
64974
|
-
get element() {
|
|
64975
|
-
return this._def.valueType;
|
|
64976
|
-
}
|
|
64977
|
-
static create(first, second, third) {
|
|
64978
|
-
if (second instanceof ZodType2) {
|
|
64979
|
-
return new ZodRecord2({
|
|
64980
|
-
keyType: first,
|
|
64981
|
-
valueType: second,
|
|
64982
|
-
typeName: ZodFirstPartyTypeKind2.ZodRecord,
|
|
64983
|
-
...processCreateParams3(third)
|
|
64984
|
-
});
|
|
64985
|
-
}
|
|
64986
|
-
return new ZodRecord2({
|
|
64987
|
-
keyType: ZodString2.create(),
|
|
64988
|
-
valueType: first,
|
|
64989
|
-
typeName: ZodFirstPartyTypeKind2.ZodRecord,
|
|
64990
|
-
...processCreateParams3(second)
|
|
64991
|
-
});
|
|
64992
|
-
}
|
|
64993
|
-
}
|
|
64994
|
-
|
|
64995
|
-
class ZodMap2 extends ZodType2 {
|
|
64996
|
-
get keySchema() {
|
|
64997
|
-
return this._def.keyType;
|
|
64998
|
-
}
|
|
64999
|
-
get valueSchema() {
|
|
65000
|
-
return this._def.valueType;
|
|
65001
|
-
}
|
|
65002
|
-
_parse(input) {
|
|
65003
|
-
const { status, ctx } = this._processInputParams(input);
|
|
65004
|
-
if (ctx.parsedType !== ZodParsedType2.map) {
|
|
65005
|
-
addIssueToContext2(ctx, {
|
|
65006
|
-
code: ZodIssueCode2.invalid_type,
|
|
65007
|
-
expected: ZodParsedType2.map,
|
|
65008
|
-
received: ctx.parsedType
|
|
65009
|
-
});
|
|
65010
|
-
return INVALID2;
|
|
65011
|
-
}
|
|
65012
|
-
const keyType = this._def.keyType;
|
|
65013
|
-
const valueType = this._def.valueType;
|
|
65014
|
-
const pairs = [...ctx.data.entries()].map(([key, value], index) => {
|
|
65015
|
-
return {
|
|
65016
|
-
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])),
|
|
65017
|
-
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"]))
|
|
65018
|
-
};
|
|
65019
|
-
});
|
|
65020
|
-
if (ctx.common.async) {
|
|
65021
|
-
const finalMap = new Map;
|
|
65022
|
-
return Promise.resolve().then(async () => {
|
|
65023
|
-
for (const pair of pairs) {
|
|
65024
|
-
const key = await pair.key;
|
|
65025
|
-
const value = await pair.value;
|
|
65026
|
-
if (key.status === "aborted" || value.status === "aborted") {
|
|
65027
|
-
return INVALID2;
|
|
65028
|
-
}
|
|
65029
|
-
if (key.status === "dirty" || value.status === "dirty") {
|
|
65030
|
-
status.dirty();
|
|
65031
|
-
}
|
|
65032
|
-
finalMap.set(key.value, value.value);
|
|
65033
|
-
}
|
|
65034
|
-
return { status: status.value, value: finalMap };
|
|
65035
|
-
});
|
|
65036
|
-
} else {
|
|
65037
|
-
const finalMap = new Map;
|
|
65038
|
-
for (const pair of pairs) {
|
|
65039
|
-
const key = pair.key;
|
|
65040
|
-
const value = pair.value;
|
|
65041
|
-
if (key.status === "aborted" || value.status === "aborted") {
|
|
65042
|
-
return INVALID2;
|
|
65043
|
-
}
|
|
65044
|
-
if (key.status === "dirty" || value.status === "dirty") {
|
|
65045
|
-
status.dirty();
|
|
65046
|
-
}
|
|
65047
|
-
finalMap.set(key.value, value.value);
|
|
65048
|
-
}
|
|
65049
|
-
return { status: status.value, value: finalMap };
|
|
65050
|
-
}
|
|
65051
|
-
}
|
|
65052
|
-
}
|
|
65053
|
-
ZodMap2.create = (keyType, valueType, params) => {
|
|
65054
|
-
return new ZodMap2({
|
|
65055
|
-
valueType,
|
|
65056
|
-
keyType,
|
|
65057
|
-
typeName: ZodFirstPartyTypeKind2.ZodMap,
|
|
65058
|
-
...processCreateParams3(params)
|
|
65059
|
-
});
|
|
65060
|
-
};
|
|
65061
|
-
|
|
65062
|
-
class ZodSet2 extends ZodType2 {
|
|
65063
|
-
_parse(input) {
|
|
65064
|
-
const { status, ctx } = this._processInputParams(input);
|
|
65065
|
-
if (ctx.parsedType !== ZodParsedType2.set) {
|
|
65066
|
-
addIssueToContext2(ctx, {
|
|
65067
|
-
code: ZodIssueCode2.invalid_type,
|
|
65068
|
-
expected: ZodParsedType2.set,
|
|
65069
|
-
received: ctx.parsedType
|
|
65070
|
-
});
|
|
65071
|
-
return INVALID2;
|
|
65072
|
-
}
|
|
65073
|
-
const def = this._def;
|
|
65074
|
-
if (def.minSize !== null) {
|
|
65075
|
-
if (ctx.data.size < def.minSize.value) {
|
|
65076
|
-
addIssueToContext2(ctx, {
|
|
65077
|
-
code: ZodIssueCode2.too_small,
|
|
65078
|
-
minimum: def.minSize.value,
|
|
65079
|
-
type: "set",
|
|
65080
|
-
inclusive: true,
|
|
65081
|
-
exact: false,
|
|
65082
|
-
message: def.minSize.message
|
|
65083
|
-
});
|
|
65084
|
-
status.dirty();
|
|
65085
|
-
}
|
|
65086
|
-
}
|
|
65087
|
-
if (def.maxSize !== null) {
|
|
65088
|
-
if (ctx.data.size > def.maxSize.value) {
|
|
65089
|
-
addIssueToContext2(ctx, {
|
|
65090
|
-
code: ZodIssueCode2.too_big,
|
|
65091
|
-
maximum: def.maxSize.value,
|
|
65092
|
-
type: "set",
|
|
65093
|
-
inclusive: true,
|
|
65094
|
-
exact: false,
|
|
65095
|
-
message: def.maxSize.message
|
|
65096
|
-
});
|
|
65097
|
-
status.dirty();
|
|
65098
|
-
}
|
|
65099
|
-
}
|
|
65100
|
-
const valueType = this._def.valueType;
|
|
65101
|
-
function finalizeSet(elements2) {
|
|
65102
|
-
const parsedSet = new Set;
|
|
65103
|
-
for (const element of elements2) {
|
|
65104
|
-
if (element.status === "aborted")
|
|
65105
|
-
return INVALID2;
|
|
65106
|
-
if (element.status === "dirty")
|
|
65107
|
-
status.dirty();
|
|
65108
|
-
parsedSet.add(element.value);
|
|
65109
|
-
}
|
|
65110
|
-
return { status: status.value, value: parsedSet };
|
|
65111
|
-
}
|
|
65112
|
-
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i)));
|
|
65113
|
-
if (ctx.common.async) {
|
|
65114
|
-
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
|
65115
|
-
} else {
|
|
65116
|
-
return finalizeSet(elements);
|
|
65117
|
-
}
|
|
65118
|
-
}
|
|
65119
|
-
min(minSize, message) {
|
|
65120
|
-
return new ZodSet2({
|
|
65121
|
-
...this._def,
|
|
65122
|
-
minSize: { value: minSize, message: errorUtil2.toString(message) }
|
|
65123
|
-
});
|
|
65124
|
-
}
|
|
65125
|
-
max(maxSize, message) {
|
|
65126
|
-
return new ZodSet2({
|
|
65127
|
-
...this._def,
|
|
65128
|
-
maxSize: { value: maxSize, message: errorUtil2.toString(message) }
|
|
65129
|
-
});
|
|
65130
|
-
}
|
|
65131
|
-
size(size, message) {
|
|
65132
|
-
return this.min(size, message).max(size, message);
|
|
65133
|
-
}
|
|
65134
|
-
nonempty(message) {
|
|
65135
|
-
return this.min(1, message);
|
|
65136
|
-
}
|
|
65137
|
-
}
|
|
65138
|
-
ZodSet2.create = (valueType, params) => {
|
|
65139
|
-
return new ZodSet2({
|
|
65140
|
-
valueType,
|
|
65141
|
-
minSize: null,
|
|
65142
|
-
maxSize: null,
|
|
65143
|
-
typeName: ZodFirstPartyTypeKind2.ZodSet,
|
|
65144
|
-
...processCreateParams3(params)
|
|
65145
|
-
});
|
|
65146
|
-
};
|
|
65147
|
-
|
|
65148
|
-
class ZodFunction2 extends ZodType2 {
|
|
65149
|
-
constructor() {
|
|
65150
|
-
super(...arguments);
|
|
65151
|
-
this.validate = this.implement;
|
|
65152
|
-
}
|
|
65153
|
-
_parse(input) {
|
|
65154
|
-
const { ctx } = this._processInputParams(input);
|
|
65155
|
-
if (ctx.parsedType !== ZodParsedType2.function) {
|
|
65156
|
-
addIssueToContext2(ctx, {
|
|
65157
|
-
code: ZodIssueCode2.invalid_type,
|
|
65158
|
-
expected: ZodParsedType2.function,
|
|
65159
|
-
received: ctx.parsedType
|
|
65160
|
-
});
|
|
65161
|
-
return INVALID2;
|
|
65162
|
-
}
|
|
65163
|
-
function makeArgsIssue(args, error) {
|
|
65164
|
-
return makeIssue2({
|
|
65165
|
-
data: args,
|
|
65166
|
-
path: ctx.path,
|
|
65167
|
-
errorMaps: [
|
|
65168
|
-
ctx.common.contextualErrorMap,
|
|
65169
|
-
ctx.schemaErrorMap,
|
|
65170
|
-
getErrorMap2(),
|
|
65171
|
-
errorMap2
|
|
65172
|
-
].filter((x) => !!x),
|
|
65173
|
-
issueData: {
|
|
65174
|
-
code: ZodIssueCode2.invalid_arguments,
|
|
65175
|
-
argumentsError: error
|
|
65176
|
-
}
|
|
65177
|
-
});
|
|
65178
|
-
}
|
|
65179
|
-
function makeReturnsIssue(returns, error) {
|
|
65180
|
-
return makeIssue2({
|
|
65181
|
-
data: returns,
|
|
65182
|
-
path: ctx.path,
|
|
65183
|
-
errorMaps: [
|
|
65184
|
-
ctx.common.contextualErrorMap,
|
|
65185
|
-
ctx.schemaErrorMap,
|
|
65186
|
-
getErrorMap2(),
|
|
65187
|
-
errorMap2
|
|
65188
|
-
].filter((x) => !!x),
|
|
65189
|
-
issueData: {
|
|
65190
|
-
code: ZodIssueCode2.invalid_return_type,
|
|
65191
|
-
returnTypeError: error
|
|
65192
|
-
}
|
|
65193
|
-
});
|
|
65194
|
-
}
|
|
65195
|
-
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
65196
|
-
const fn = ctx.data;
|
|
65197
|
-
if (this._def.returns instanceof ZodPromise2) {
|
|
65198
|
-
const me = this;
|
|
65199
|
-
return OK2(async function(...args) {
|
|
65200
|
-
const error = new ZodError2([]);
|
|
65201
|
-
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e3) => {
|
|
65202
|
-
error.addIssue(makeArgsIssue(args, e3));
|
|
65203
|
-
throw error;
|
|
65204
|
-
});
|
|
65205
|
-
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
65206
|
-
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e3) => {
|
|
65207
|
-
error.addIssue(makeReturnsIssue(result, e3));
|
|
65208
|
-
throw error;
|
|
65209
|
-
});
|
|
65210
|
-
return parsedReturns;
|
|
65211
|
-
});
|
|
65212
|
-
} else {
|
|
65213
|
-
const me = this;
|
|
65214
|
-
return OK2(function(...args) {
|
|
65215
|
-
const parsedArgs = me._def.args.safeParse(args, params);
|
|
65216
|
-
if (!parsedArgs.success) {
|
|
65217
|
-
throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]);
|
|
65218
|
-
}
|
|
65219
|
-
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
65220
|
-
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
65221
|
-
if (!parsedReturns.success) {
|
|
65222
|
-
throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]);
|
|
65223
|
-
}
|
|
65224
|
-
return parsedReturns.data;
|
|
65225
|
-
});
|
|
65226
|
-
}
|
|
65227
|
-
}
|
|
65228
|
-
parameters() {
|
|
65229
|
-
return this._def.args;
|
|
65230
|
-
}
|
|
65231
|
-
returnType() {
|
|
65232
|
-
return this._def.returns;
|
|
65233
|
-
}
|
|
65234
|
-
args(...items) {
|
|
65235
|
-
return new ZodFunction2({
|
|
65236
|
-
...this._def,
|
|
65237
|
-
args: ZodTuple2.create(items).rest(ZodUnknown2.create())
|
|
65238
|
-
});
|
|
65239
|
-
}
|
|
65240
|
-
returns(returnType) {
|
|
65241
|
-
return new ZodFunction2({
|
|
65242
|
-
...this._def,
|
|
65243
|
-
returns: returnType
|
|
65244
|
-
});
|
|
65245
|
-
}
|
|
65246
|
-
implement(func) {
|
|
65247
|
-
const validatedFunc = this.parse(func);
|
|
65248
|
-
return validatedFunc;
|
|
65249
|
-
}
|
|
65250
|
-
strictImplement(func) {
|
|
65251
|
-
const validatedFunc = this.parse(func);
|
|
65252
|
-
return validatedFunc;
|
|
65253
|
-
}
|
|
65254
|
-
static create(args, returns, params) {
|
|
65255
|
-
return new ZodFunction2({
|
|
65256
|
-
args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()),
|
|
65257
|
-
returns: returns || ZodUnknown2.create(),
|
|
65258
|
-
typeName: ZodFirstPartyTypeKind2.ZodFunction,
|
|
65259
|
-
...processCreateParams3(params)
|
|
65260
|
-
});
|
|
65261
|
-
}
|
|
65262
|
-
}
|
|
65263
|
-
|
|
65264
|
-
class ZodLazy2 extends ZodType2 {
|
|
65265
|
-
get schema() {
|
|
65266
|
-
return this._def.getter();
|
|
65267
|
-
}
|
|
65268
|
-
_parse(input) {
|
|
65269
|
-
const { ctx } = this._processInputParams(input);
|
|
65270
|
-
const lazySchema = this._def.getter();
|
|
65271
|
-
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
65272
|
-
}
|
|
65273
|
-
}
|
|
65274
|
-
ZodLazy2.create = (getter, params) => {
|
|
65275
|
-
return new ZodLazy2({
|
|
65276
|
-
getter,
|
|
65277
|
-
typeName: ZodFirstPartyTypeKind2.ZodLazy,
|
|
65278
|
-
...processCreateParams3(params)
|
|
65279
|
-
});
|
|
65280
|
-
};
|
|
65281
|
-
|
|
65282
|
-
class ZodLiteral2 extends ZodType2 {
|
|
65283
|
-
_parse(input) {
|
|
65284
|
-
if (input.data !== this._def.value) {
|
|
65285
|
-
const ctx = this._getOrReturnCtx(input);
|
|
65286
|
-
addIssueToContext2(ctx, {
|
|
65287
|
-
received: ctx.data,
|
|
65288
|
-
code: ZodIssueCode2.invalid_literal,
|
|
65289
|
-
expected: this._def.value
|
|
65290
|
-
});
|
|
65291
|
-
return INVALID2;
|
|
65292
|
-
}
|
|
65293
|
-
return { status: "valid", value: input.data };
|
|
65294
|
-
}
|
|
65295
|
-
get value() {
|
|
65296
|
-
return this._def.value;
|
|
65297
|
-
}
|
|
65298
|
-
}
|
|
65299
|
-
ZodLiteral2.create = (value, params) => {
|
|
65300
|
-
return new ZodLiteral2({
|
|
65301
|
-
value,
|
|
65302
|
-
typeName: ZodFirstPartyTypeKind2.ZodLiteral,
|
|
65303
|
-
...processCreateParams3(params)
|
|
65304
|
-
});
|
|
65305
|
-
};
|
|
65306
|
-
function createZodEnum2(values, params) {
|
|
65307
|
-
return new ZodEnum2({
|
|
65308
|
-
values,
|
|
65309
|
-
typeName: ZodFirstPartyTypeKind2.ZodEnum,
|
|
65310
|
-
...processCreateParams3(params)
|
|
65311
|
-
});
|
|
65312
|
-
}
|
|
65313
|
-
|
|
65314
|
-
class ZodEnum2 extends ZodType2 {
|
|
65315
|
-
constructor() {
|
|
65316
|
-
super(...arguments);
|
|
65317
|
-
_ZodEnum_cache2.set(this, undefined);
|
|
65318
|
-
}
|
|
65319
|
-
_parse(input) {
|
|
65320
|
-
if (typeof input.data !== "string") {
|
|
65321
|
-
const ctx = this._getOrReturnCtx(input);
|
|
65322
|
-
const expectedValues = this._def.values;
|
|
65323
|
-
addIssueToContext2(ctx, {
|
|
65324
|
-
expected: util2.joinValues(expectedValues),
|
|
65325
|
-
received: ctx.parsedType,
|
|
65326
|
-
code: ZodIssueCode2.invalid_type
|
|
65327
|
-
});
|
|
65328
|
-
return INVALID2;
|
|
65329
|
-
}
|
|
65330
|
-
if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f")) {
|
|
65331
|
-
__classPrivateFieldSet2(this, _ZodEnum_cache2, new Set(this._def.values), "f");
|
|
65332
|
-
}
|
|
65333
|
-
if (!__classPrivateFieldGet2(this, _ZodEnum_cache2, "f").has(input.data)) {
|
|
65334
|
-
const ctx = this._getOrReturnCtx(input);
|
|
65335
|
-
const expectedValues = this._def.values;
|
|
65336
|
-
addIssueToContext2(ctx, {
|
|
65337
|
-
received: ctx.data,
|
|
65338
|
-
code: ZodIssueCode2.invalid_enum_value,
|
|
65339
|
-
options: expectedValues
|
|
65340
|
-
});
|
|
65341
|
-
return INVALID2;
|
|
65342
|
-
}
|
|
65343
|
-
return OK2(input.data);
|
|
65344
|
-
}
|
|
65345
|
-
get options() {
|
|
65346
|
-
return this._def.values;
|
|
65347
|
-
}
|
|
65348
|
-
get enum() {
|
|
65349
|
-
const enumValues = {};
|
|
65350
|
-
for (const val of this._def.values) {
|
|
65351
|
-
enumValues[val] = val;
|
|
65352
|
-
}
|
|
65353
|
-
return enumValues;
|
|
65354
|
-
}
|
|
65355
|
-
get Values() {
|
|
65356
|
-
const enumValues = {};
|
|
65357
|
-
for (const val of this._def.values) {
|
|
65358
|
-
enumValues[val] = val;
|
|
65359
|
-
}
|
|
65360
|
-
return enumValues;
|
|
65361
|
-
}
|
|
65362
|
-
get Enum() {
|
|
65363
|
-
const enumValues = {};
|
|
65364
|
-
for (const val of this._def.values) {
|
|
65365
|
-
enumValues[val] = val;
|
|
65366
|
-
}
|
|
65367
|
-
return enumValues;
|
|
65368
|
-
}
|
|
65369
|
-
extract(values, newDef = this._def) {
|
|
65370
|
-
return ZodEnum2.create(values, {
|
|
65371
|
-
...this._def,
|
|
65372
|
-
...newDef
|
|
65373
|
-
});
|
|
65374
|
-
}
|
|
65375
|
-
exclude(values, newDef = this._def) {
|
|
65376
|
-
return ZodEnum2.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
65377
|
-
...this._def,
|
|
65378
|
-
...newDef
|
|
65379
|
-
});
|
|
65380
|
-
}
|
|
65381
|
-
}
|
|
65382
|
-
_ZodEnum_cache2 = new WeakMap;
|
|
65383
|
-
ZodEnum2.create = createZodEnum2;
|
|
65384
|
-
|
|
65385
|
-
class ZodNativeEnum2 extends ZodType2 {
|
|
65386
|
-
constructor() {
|
|
65387
|
-
super(...arguments);
|
|
65388
|
-
_ZodNativeEnum_cache2.set(this, undefined);
|
|
65389
|
-
}
|
|
65390
|
-
_parse(input) {
|
|
65391
|
-
const nativeEnumValues = util2.getValidEnumValues(this._def.values);
|
|
65392
|
-
const ctx = this._getOrReturnCtx(input);
|
|
65393
|
-
if (ctx.parsedType !== ZodParsedType2.string && ctx.parsedType !== ZodParsedType2.number) {
|
|
65394
|
-
const expectedValues = util2.objectValues(nativeEnumValues);
|
|
65395
|
-
addIssueToContext2(ctx, {
|
|
65396
|
-
expected: util2.joinValues(expectedValues),
|
|
65397
|
-
received: ctx.parsedType,
|
|
65398
|
-
code: ZodIssueCode2.invalid_type
|
|
65399
|
-
});
|
|
65400
|
-
return INVALID2;
|
|
65401
|
-
}
|
|
65402
|
-
if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f")) {
|
|
65403
|
-
__classPrivateFieldSet2(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
|
|
65404
|
-
}
|
|
65405
|
-
if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
|
|
65406
|
-
const expectedValues = util2.objectValues(nativeEnumValues);
|
|
65407
|
-
addIssueToContext2(ctx, {
|
|
65408
|
-
received: ctx.data,
|
|
65409
|
-
code: ZodIssueCode2.invalid_enum_value,
|
|
65410
|
-
options: expectedValues
|
|
65411
|
-
});
|
|
65412
|
-
return INVALID2;
|
|
65413
|
-
}
|
|
65414
|
-
return OK2(input.data);
|
|
65415
|
-
}
|
|
65416
|
-
get enum() {
|
|
65417
|
-
return this._def.values;
|
|
65418
|
-
}
|
|
65419
|
-
}
|
|
65420
|
-
_ZodNativeEnum_cache2 = new WeakMap;
|
|
65421
|
-
ZodNativeEnum2.create = (values, params) => {
|
|
65422
|
-
return new ZodNativeEnum2({
|
|
65423
|
-
values,
|
|
65424
|
-
typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
|
|
65425
|
-
...processCreateParams3(params)
|
|
65426
|
-
});
|
|
65427
|
-
};
|
|
65428
|
-
|
|
65429
|
-
class ZodPromise2 extends ZodType2 {
|
|
65430
|
-
unwrap() {
|
|
65431
|
-
return this._def.type;
|
|
65432
|
-
}
|
|
65433
|
-
_parse(input) {
|
|
65434
|
-
const { ctx } = this._processInputParams(input);
|
|
65435
|
-
if (ctx.parsedType !== ZodParsedType2.promise && ctx.common.async === false) {
|
|
65436
|
-
addIssueToContext2(ctx, {
|
|
65437
|
-
code: ZodIssueCode2.invalid_type,
|
|
65438
|
-
expected: ZodParsedType2.promise,
|
|
65439
|
-
received: ctx.parsedType
|
|
65440
|
-
});
|
|
65441
|
-
return INVALID2;
|
|
65442
|
-
}
|
|
65443
|
-
const promisified = ctx.parsedType === ZodParsedType2.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
65444
|
-
return OK2(promisified.then((data) => {
|
|
65445
|
-
return this._def.type.parseAsync(data, {
|
|
65446
|
-
path: ctx.path,
|
|
65447
|
-
errorMap: ctx.common.contextualErrorMap
|
|
65448
|
-
});
|
|
65449
|
-
}));
|
|
65450
|
-
}
|
|
65451
|
-
}
|
|
65452
|
-
ZodPromise2.create = (schema, params) => {
|
|
65453
|
-
return new ZodPromise2({
|
|
65454
|
-
type: schema,
|
|
65455
|
-
typeName: ZodFirstPartyTypeKind2.ZodPromise,
|
|
65456
|
-
...processCreateParams3(params)
|
|
65457
|
-
});
|
|
65458
|
-
};
|
|
65459
|
-
|
|
65460
|
-
class ZodEffects2 extends ZodType2 {
|
|
65461
|
-
innerType() {
|
|
65462
|
-
return this._def.schema;
|
|
65463
|
-
}
|
|
65464
|
-
sourceType() {
|
|
65465
|
-
return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
65466
|
-
}
|
|
65467
|
-
_parse(input) {
|
|
65468
|
-
const { status, ctx } = this._processInputParams(input);
|
|
65469
|
-
const effect = this._def.effect || null;
|
|
65470
|
-
const checkCtx = {
|
|
65471
|
-
addIssue: (arg) => {
|
|
65472
|
-
addIssueToContext2(ctx, arg);
|
|
65473
|
-
if (arg.fatal) {
|
|
65474
|
-
status.abort();
|
|
65475
|
-
} else {
|
|
65476
|
-
status.dirty();
|
|
65477
|
-
}
|
|
65478
|
-
},
|
|
65479
|
-
get path() {
|
|
65480
|
-
return ctx.path;
|
|
65481
|
-
}
|
|
65482
|
-
};
|
|
65483
|
-
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
65484
|
-
if (effect.type === "preprocess") {
|
|
65485
|
-
const processed = effect.transform(ctx.data, checkCtx);
|
|
65486
|
-
if (ctx.common.async) {
|
|
65487
|
-
return Promise.resolve(processed).then(async (processed2) => {
|
|
65488
|
-
if (status.value === "aborted")
|
|
65489
|
-
return INVALID2;
|
|
65490
|
-
const result = await this._def.schema._parseAsync({
|
|
65491
|
-
data: processed2,
|
|
65492
|
-
path: ctx.path,
|
|
65493
|
-
parent: ctx
|
|
65494
|
-
});
|
|
65495
|
-
if (result.status === "aborted")
|
|
65496
|
-
return INVALID2;
|
|
65497
|
-
if (result.status === "dirty")
|
|
65498
|
-
return DIRTY2(result.value);
|
|
65499
|
-
if (status.value === "dirty")
|
|
65500
|
-
return DIRTY2(result.value);
|
|
65501
|
-
return result;
|
|
65502
|
-
});
|
|
65503
|
-
} else {
|
|
65504
|
-
if (status.value === "aborted")
|
|
65505
|
-
return INVALID2;
|
|
65506
|
-
const result = this._def.schema._parseSync({
|
|
65507
|
-
data: processed,
|
|
65508
|
-
path: ctx.path,
|
|
65509
|
-
parent: ctx
|
|
65510
|
-
});
|
|
65511
|
-
if (result.status === "aborted")
|
|
65512
|
-
return INVALID2;
|
|
65513
|
-
if (result.status === "dirty")
|
|
65514
|
-
return DIRTY2(result.value);
|
|
65515
|
-
if (status.value === "dirty")
|
|
65516
|
-
return DIRTY2(result.value);
|
|
65517
|
-
return result;
|
|
65518
|
-
}
|
|
65519
|
-
}
|
|
65520
|
-
if (effect.type === "refinement") {
|
|
65521
|
-
const executeRefinement = (acc) => {
|
|
65522
|
-
const result = effect.refinement(acc, checkCtx);
|
|
65523
|
-
if (ctx.common.async) {
|
|
65524
|
-
return Promise.resolve(result);
|
|
65525
|
-
}
|
|
65526
|
-
if (result instanceof Promise) {
|
|
65527
|
-
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
65528
|
-
}
|
|
65529
|
-
return acc;
|
|
65530
|
-
};
|
|
65531
|
-
if (ctx.common.async === false) {
|
|
65532
|
-
const inner = this._def.schema._parseSync({
|
|
65533
|
-
data: ctx.data,
|
|
65534
|
-
path: ctx.path,
|
|
65535
|
-
parent: ctx
|
|
65536
|
-
});
|
|
65537
|
-
if (inner.status === "aborted")
|
|
65538
|
-
return INVALID2;
|
|
65539
|
-
if (inner.status === "dirty")
|
|
65540
|
-
status.dirty();
|
|
65541
|
-
executeRefinement(inner.value);
|
|
65542
|
-
return { status: status.value, value: inner.value };
|
|
65543
|
-
} else {
|
|
65544
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
65545
|
-
if (inner.status === "aborted")
|
|
65546
|
-
return INVALID2;
|
|
65547
|
-
if (inner.status === "dirty")
|
|
65548
|
-
status.dirty();
|
|
65549
|
-
return executeRefinement(inner.value).then(() => {
|
|
65550
|
-
return { status: status.value, value: inner.value };
|
|
65551
|
-
});
|
|
65552
|
-
});
|
|
65553
|
-
}
|
|
65554
|
-
}
|
|
65555
|
-
if (effect.type === "transform") {
|
|
65556
|
-
if (ctx.common.async === false) {
|
|
65557
|
-
const base = this._def.schema._parseSync({
|
|
65558
|
-
data: ctx.data,
|
|
65559
|
-
path: ctx.path,
|
|
65560
|
-
parent: ctx
|
|
65561
|
-
});
|
|
65562
|
-
if (!isValid2(base))
|
|
65563
|
-
return base;
|
|
65564
|
-
const result = effect.transform(base.value, checkCtx);
|
|
65565
|
-
if (result instanceof Promise) {
|
|
65566
|
-
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
65567
|
-
}
|
|
65568
|
-
return { status: status.value, value: result };
|
|
65569
|
-
} else {
|
|
65570
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
65571
|
-
if (!isValid2(base))
|
|
65572
|
-
return base;
|
|
65573
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
|
|
65574
|
-
});
|
|
65575
|
-
}
|
|
65576
|
-
}
|
|
65577
|
-
util2.assertNever(effect);
|
|
65578
|
-
}
|
|
65579
|
-
}
|
|
65580
|
-
ZodEffects2.create = (schema, effect, params) => {
|
|
65581
|
-
return new ZodEffects2({
|
|
65582
|
-
schema,
|
|
65583
|
-
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
65584
|
-
effect,
|
|
65585
|
-
...processCreateParams3(params)
|
|
65586
|
-
});
|
|
65587
|
-
};
|
|
65588
|
-
ZodEffects2.createWithPreprocess = (preprocess, schema, params) => {
|
|
65589
|
-
return new ZodEffects2({
|
|
65590
|
-
schema,
|
|
65591
|
-
effect: { type: "preprocess", transform: preprocess },
|
|
65592
|
-
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
65593
|
-
...processCreateParams3(params)
|
|
65594
|
-
});
|
|
65595
|
-
};
|
|
65596
|
-
|
|
65597
|
-
class ZodOptional2 extends ZodType2 {
|
|
65598
|
-
_parse(input) {
|
|
65599
|
-
const parsedType = this._getType(input);
|
|
65600
|
-
if (parsedType === ZodParsedType2.undefined) {
|
|
65601
|
-
return OK2(undefined);
|
|
65602
|
-
}
|
|
65603
|
-
return this._def.innerType._parse(input);
|
|
65604
|
-
}
|
|
65605
|
-
unwrap() {
|
|
65606
|
-
return this._def.innerType;
|
|
65607
|
-
}
|
|
65608
|
-
}
|
|
65609
|
-
ZodOptional2.create = (type, params) => {
|
|
65610
|
-
return new ZodOptional2({
|
|
65611
|
-
innerType: type,
|
|
65612
|
-
typeName: ZodFirstPartyTypeKind2.ZodOptional,
|
|
65613
|
-
...processCreateParams3(params)
|
|
65614
|
-
});
|
|
65615
|
-
};
|
|
65616
|
-
|
|
65617
|
-
class ZodNullable2 extends ZodType2 {
|
|
65618
|
-
_parse(input) {
|
|
65619
|
-
const parsedType = this._getType(input);
|
|
65620
|
-
if (parsedType === ZodParsedType2.null) {
|
|
65621
|
-
return OK2(null);
|
|
65622
|
-
}
|
|
65623
|
-
return this._def.innerType._parse(input);
|
|
65624
|
-
}
|
|
65625
|
-
unwrap() {
|
|
65626
|
-
return this._def.innerType;
|
|
65627
|
-
}
|
|
65628
|
-
}
|
|
65629
|
-
ZodNullable2.create = (type, params) => {
|
|
65630
|
-
return new ZodNullable2({
|
|
65631
|
-
innerType: type,
|
|
65632
|
-
typeName: ZodFirstPartyTypeKind2.ZodNullable,
|
|
65633
|
-
...processCreateParams3(params)
|
|
65634
|
-
});
|
|
65635
|
-
};
|
|
65636
|
-
|
|
65637
|
-
class ZodDefault2 extends ZodType2 {
|
|
65638
|
-
_parse(input) {
|
|
65639
|
-
const { ctx } = this._processInputParams(input);
|
|
65640
|
-
let data = ctx.data;
|
|
65641
|
-
if (ctx.parsedType === ZodParsedType2.undefined) {
|
|
65642
|
-
data = this._def.defaultValue();
|
|
65643
|
-
}
|
|
65644
|
-
return this._def.innerType._parse({
|
|
65645
|
-
data,
|
|
65646
|
-
path: ctx.path,
|
|
65647
|
-
parent: ctx
|
|
65648
|
-
});
|
|
65649
|
-
}
|
|
65650
|
-
removeDefault() {
|
|
65651
|
-
return this._def.innerType;
|
|
65652
|
-
}
|
|
65653
|
-
}
|
|
65654
|
-
ZodDefault2.create = (type, params) => {
|
|
65655
|
-
return new ZodDefault2({
|
|
65656
|
-
innerType: type,
|
|
65657
|
-
typeName: ZodFirstPartyTypeKind2.ZodDefault,
|
|
65658
|
-
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
65659
|
-
...processCreateParams3(params)
|
|
65660
|
-
});
|
|
65661
|
-
};
|
|
65662
|
-
|
|
65663
|
-
class ZodCatch2 extends ZodType2 {
|
|
65664
|
-
_parse(input) {
|
|
65665
|
-
const { ctx } = this._processInputParams(input);
|
|
65666
|
-
const newCtx = {
|
|
65667
|
-
...ctx,
|
|
65668
|
-
common: {
|
|
65669
|
-
...ctx.common,
|
|
65670
|
-
issues: []
|
|
65671
|
-
}
|
|
65672
|
-
};
|
|
65673
|
-
const result = this._def.innerType._parse({
|
|
65674
|
-
data: newCtx.data,
|
|
65675
|
-
path: newCtx.path,
|
|
65676
|
-
parent: {
|
|
65677
|
-
...newCtx
|
|
65678
|
-
}
|
|
65679
|
-
});
|
|
65680
|
-
if (isAsync2(result)) {
|
|
65681
|
-
return result.then((result2) => {
|
|
65682
|
-
return {
|
|
65683
|
-
status: "valid",
|
|
65684
|
-
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
65685
|
-
get error() {
|
|
65686
|
-
return new ZodError2(newCtx.common.issues);
|
|
65687
|
-
},
|
|
65688
|
-
input: newCtx.data
|
|
65689
|
-
})
|
|
65690
|
-
};
|
|
65691
|
-
});
|
|
65692
|
-
} else {
|
|
65693
|
-
return {
|
|
65694
|
-
status: "valid",
|
|
65695
|
-
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
65696
|
-
get error() {
|
|
65697
|
-
return new ZodError2(newCtx.common.issues);
|
|
65698
|
-
},
|
|
65699
|
-
input: newCtx.data
|
|
65700
|
-
})
|
|
65701
|
-
};
|
|
65702
|
-
}
|
|
65703
|
-
}
|
|
65704
|
-
removeCatch() {
|
|
65705
|
-
return this._def.innerType;
|
|
65706
|
-
}
|
|
65707
|
-
}
|
|
65708
|
-
ZodCatch2.create = (type, params) => {
|
|
65709
|
-
return new ZodCatch2({
|
|
65710
|
-
innerType: type,
|
|
65711
|
-
typeName: ZodFirstPartyTypeKind2.ZodCatch,
|
|
65712
|
-
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
65713
|
-
...processCreateParams3(params)
|
|
65714
|
-
});
|
|
65715
|
-
};
|
|
65716
|
-
|
|
65717
|
-
class ZodNaN2 extends ZodType2 {
|
|
65718
|
-
_parse(input) {
|
|
65719
|
-
const parsedType = this._getType(input);
|
|
65720
|
-
if (parsedType !== ZodParsedType2.nan) {
|
|
65721
|
-
const ctx = this._getOrReturnCtx(input);
|
|
65722
|
-
addIssueToContext2(ctx, {
|
|
65723
|
-
code: ZodIssueCode2.invalid_type,
|
|
65724
|
-
expected: ZodParsedType2.nan,
|
|
65725
|
-
received: ctx.parsedType
|
|
65726
|
-
});
|
|
65727
|
-
return INVALID2;
|
|
65728
|
-
}
|
|
65729
|
-
return { status: "valid", value: input.data };
|
|
65730
|
-
}
|
|
65731
|
-
}
|
|
65732
|
-
ZodNaN2.create = (params) => {
|
|
65733
|
-
return new ZodNaN2({
|
|
65734
|
-
typeName: ZodFirstPartyTypeKind2.ZodNaN,
|
|
65735
|
-
...processCreateParams3(params)
|
|
65736
|
-
});
|
|
65737
|
-
};
|
|
65738
|
-
var BRAND2 = Symbol("zod_brand");
|
|
65739
|
-
|
|
65740
|
-
class ZodBranded2 extends ZodType2 {
|
|
65741
|
-
_parse(input) {
|
|
65742
|
-
const { ctx } = this._processInputParams(input);
|
|
65743
|
-
const data = ctx.data;
|
|
65744
|
-
return this._def.type._parse({
|
|
65745
|
-
data,
|
|
65746
|
-
path: ctx.path,
|
|
65747
|
-
parent: ctx
|
|
65748
|
-
});
|
|
65749
|
-
}
|
|
65750
|
-
unwrap() {
|
|
65751
|
-
return this._def.type;
|
|
65752
|
-
}
|
|
65753
|
-
}
|
|
65754
|
-
|
|
65755
|
-
class ZodPipeline2 extends ZodType2 {
|
|
65756
|
-
_parse(input) {
|
|
65757
|
-
const { status, ctx } = this._processInputParams(input);
|
|
65758
|
-
if (ctx.common.async) {
|
|
65759
|
-
const handleAsync = async () => {
|
|
65760
|
-
const inResult = await this._def.in._parseAsync({
|
|
65761
|
-
data: ctx.data,
|
|
65762
|
-
path: ctx.path,
|
|
65763
|
-
parent: ctx
|
|
65764
|
-
});
|
|
65765
|
-
if (inResult.status === "aborted")
|
|
65766
|
-
return INVALID2;
|
|
65767
|
-
if (inResult.status === "dirty") {
|
|
65768
|
-
status.dirty();
|
|
65769
|
-
return DIRTY2(inResult.value);
|
|
65770
|
-
} else {
|
|
65771
|
-
return this._def.out._parseAsync({
|
|
65772
|
-
data: inResult.value,
|
|
65773
|
-
path: ctx.path,
|
|
65774
|
-
parent: ctx
|
|
65775
|
-
});
|
|
65776
|
-
}
|
|
65777
|
-
};
|
|
65778
|
-
return handleAsync();
|
|
65779
|
-
} else {
|
|
65780
|
-
const inResult = this._def.in._parseSync({
|
|
65781
|
-
data: ctx.data,
|
|
65782
|
-
path: ctx.path,
|
|
65783
|
-
parent: ctx
|
|
65784
|
-
});
|
|
65785
|
-
if (inResult.status === "aborted")
|
|
65786
|
-
return INVALID2;
|
|
65787
|
-
if (inResult.status === "dirty") {
|
|
65788
|
-
status.dirty();
|
|
65789
|
-
return {
|
|
65790
|
-
status: "dirty",
|
|
65791
|
-
value: inResult.value
|
|
65792
|
-
};
|
|
65793
|
-
} else {
|
|
65794
|
-
return this._def.out._parseSync({
|
|
65795
|
-
data: inResult.value,
|
|
65796
|
-
path: ctx.path,
|
|
65797
|
-
parent: ctx
|
|
65798
|
-
});
|
|
65799
|
-
}
|
|
65800
|
-
}
|
|
65801
|
-
}
|
|
65802
|
-
static create(a, b) {
|
|
65803
|
-
return new ZodPipeline2({
|
|
65804
|
-
in: a,
|
|
65805
|
-
out: b,
|
|
65806
|
-
typeName: ZodFirstPartyTypeKind2.ZodPipeline
|
|
65807
|
-
});
|
|
65808
|
-
}
|
|
65809
|
-
}
|
|
65810
|
-
|
|
65811
|
-
class ZodReadonly2 extends ZodType2 {
|
|
65812
|
-
_parse(input) {
|
|
65813
|
-
const result = this._def.innerType._parse(input);
|
|
65814
|
-
const freeze = (data) => {
|
|
65815
|
-
if (isValid2(data)) {
|
|
65816
|
-
data.value = Object.freeze(data.value);
|
|
65817
|
-
}
|
|
65818
|
-
return data;
|
|
65819
|
-
};
|
|
65820
|
-
return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
65821
|
-
}
|
|
65822
|
-
unwrap() {
|
|
65823
|
-
return this._def.innerType;
|
|
65824
|
-
}
|
|
65825
|
-
}
|
|
65826
|
-
ZodReadonly2.create = (type, params) => {
|
|
65827
|
-
return new ZodReadonly2({
|
|
65828
|
-
innerType: type,
|
|
65829
|
-
typeName: ZodFirstPartyTypeKind2.ZodReadonly,
|
|
65830
|
-
...processCreateParams3(params)
|
|
65831
|
-
});
|
|
65832
|
-
};
|
|
65833
|
-
function cleanParams2(params, data) {
|
|
65834
|
-
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
65835
|
-
const p2 = typeof p === "string" ? { message: p } : p;
|
|
65836
|
-
return p2;
|
|
65837
|
-
}
|
|
65838
|
-
function custom2(check, _params = {}, fatal) {
|
|
65839
|
-
if (check)
|
|
65840
|
-
return ZodAny2.create().superRefine((data, ctx) => {
|
|
65841
|
-
var _a, _b;
|
|
65842
|
-
const r = check(data);
|
|
65843
|
-
if (r instanceof Promise) {
|
|
65844
|
-
return r.then((r2) => {
|
|
65845
|
-
var _a2, _b2;
|
|
65846
|
-
if (!r2) {
|
|
65847
|
-
const params = cleanParams2(_params, data);
|
|
65848
|
-
const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== undefined ? _a2 : fatal) !== null && _b2 !== undefined ? _b2 : true;
|
|
65849
|
-
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
65850
|
-
}
|
|
65851
|
-
});
|
|
65852
|
-
}
|
|
65853
|
-
if (!r) {
|
|
65854
|
-
const params = cleanParams2(_params, data);
|
|
65855
|
-
const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
|
|
65856
|
-
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
65857
|
-
}
|
|
65858
|
-
return;
|
|
65859
|
-
});
|
|
65860
|
-
return ZodAny2.create();
|
|
65861
|
-
}
|
|
65862
|
-
var late2 = {
|
|
65863
|
-
object: ZodObject2.lazycreate
|
|
65864
|
-
};
|
|
65865
|
-
var ZodFirstPartyTypeKind2;
|
|
65866
|
-
(function(ZodFirstPartyTypeKind3) {
|
|
65867
|
-
ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
|
|
65868
|
-
ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
|
|
65869
|
-
ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
|
|
65870
|
-
ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
|
|
65871
|
-
ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
|
|
65872
|
-
ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
|
|
65873
|
-
ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
|
|
65874
|
-
ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
|
|
65875
|
-
ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
|
|
65876
|
-
ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
|
|
65877
|
-
ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
|
|
65878
|
-
ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
|
|
65879
|
-
ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
|
|
65880
|
-
ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
|
|
65881
|
-
ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
|
|
65882
|
-
ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
|
|
65883
|
-
ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
65884
|
-
ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
|
|
65885
|
-
ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
|
|
65886
|
-
ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
|
|
65887
|
-
ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
|
|
65888
|
-
ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
|
|
65889
|
-
ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
|
|
65890
|
-
ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
|
|
65891
|
-
ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
|
|
65892
|
-
ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
|
|
65893
|
-
ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
|
|
65894
|
-
ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
|
|
65895
|
-
ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
|
|
65896
|
-
ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
|
|
65897
|
-
ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
|
|
65898
|
-
ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
|
|
65899
|
-
ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
|
|
65900
|
-
ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
|
|
65901
|
-
ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
|
|
65902
|
-
ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
|
|
65903
|
-
})(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
|
|
65904
|
-
var instanceOfType2 = (cls, params = {
|
|
65905
|
-
message: `Input not instance of ${cls.name}`
|
|
65906
|
-
}) => custom2((data) => data instanceof cls, params);
|
|
65907
|
-
var stringType2 = ZodString2.create;
|
|
65908
|
-
var numberType2 = ZodNumber2.create;
|
|
65909
|
-
var nanType2 = ZodNaN2.create;
|
|
65910
|
-
var bigIntType2 = ZodBigInt2.create;
|
|
65911
|
-
var booleanType2 = ZodBoolean2.create;
|
|
65912
|
-
var dateType2 = ZodDate2.create;
|
|
65913
|
-
var symbolType2 = ZodSymbol2.create;
|
|
65914
|
-
var undefinedType2 = ZodUndefined2.create;
|
|
65915
|
-
var nullType2 = ZodNull2.create;
|
|
65916
|
-
var anyType2 = ZodAny2.create;
|
|
65917
|
-
var unknownType2 = ZodUnknown2.create;
|
|
65918
|
-
var neverType2 = ZodNever2.create;
|
|
65919
|
-
var voidType2 = ZodVoid2.create;
|
|
65920
|
-
var arrayType2 = ZodArray2.create;
|
|
65921
|
-
var objectType2 = ZodObject2.create;
|
|
65922
|
-
var strictObjectType2 = ZodObject2.strictCreate;
|
|
65923
|
-
var unionType2 = ZodUnion2.create;
|
|
65924
|
-
var discriminatedUnionType2 = ZodDiscriminatedUnion2.create;
|
|
65925
|
-
var intersectionType2 = ZodIntersection2.create;
|
|
65926
|
-
var tupleType2 = ZodTuple2.create;
|
|
65927
|
-
var recordType2 = ZodRecord2.create;
|
|
65928
|
-
var mapType2 = ZodMap2.create;
|
|
65929
|
-
var setType2 = ZodSet2.create;
|
|
65930
|
-
var functionType2 = ZodFunction2.create;
|
|
65931
|
-
var lazyType2 = ZodLazy2.create;
|
|
65932
|
-
var literalType2 = ZodLiteral2.create;
|
|
65933
|
-
var enumType2 = ZodEnum2.create;
|
|
65934
|
-
var nativeEnumType2 = ZodNativeEnum2.create;
|
|
65935
|
-
var promiseType2 = ZodPromise2.create;
|
|
65936
|
-
var effectsType2 = ZodEffects2.create;
|
|
65937
|
-
var optionalType2 = ZodOptional2.create;
|
|
65938
|
-
var nullableType2 = ZodNullable2.create;
|
|
65939
|
-
var preprocessType2 = ZodEffects2.createWithPreprocess;
|
|
65940
|
-
var pipelineType2 = ZodPipeline2.create;
|
|
65941
|
-
var ostring2 = () => stringType2().optional();
|
|
65942
|
-
var onumber2 = () => numberType2().optional();
|
|
65943
|
-
var oboolean2 = () => booleanType2().optional();
|
|
65944
|
-
var coerce2 = {
|
|
65945
|
-
string: (arg) => ZodString2.create({ ...arg, coerce: true }),
|
|
65946
|
-
number: (arg) => ZodNumber2.create({ ...arg, coerce: true }),
|
|
65947
|
-
boolean: (arg) => ZodBoolean2.create({
|
|
65948
|
-
...arg,
|
|
65949
|
-
coerce: true
|
|
65950
|
-
}),
|
|
65951
|
-
bigint: (arg) => ZodBigInt2.create({ ...arg, coerce: true }),
|
|
65952
|
-
date: (arg) => ZodDate2.create({ ...arg, coerce: true })
|
|
65953
|
-
};
|
|
65954
|
-
var NEVER2 = INVALID2;
|
|
65955
|
-
var z2 = /* @__PURE__ */ Object.freeze({
|
|
65956
|
-
__proto__: null,
|
|
65957
|
-
defaultErrorMap: errorMap2,
|
|
65958
|
-
setErrorMap: setErrorMap2,
|
|
65959
|
-
getErrorMap: getErrorMap2,
|
|
65960
|
-
makeIssue: makeIssue2,
|
|
65961
|
-
EMPTY_PATH: EMPTY_PATH2,
|
|
65962
|
-
addIssueToContext: addIssueToContext2,
|
|
65963
|
-
ParseStatus: ParseStatus2,
|
|
65964
|
-
INVALID: INVALID2,
|
|
65965
|
-
DIRTY: DIRTY2,
|
|
65966
|
-
OK: OK2,
|
|
65967
|
-
isAborted: isAborted2,
|
|
65968
|
-
isDirty: isDirty2,
|
|
65969
|
-
isValid: isValid2,
|
|
65970
|
-
isAsync: isAsync2,
|
|
65971
|
-
get util() {
|
|
65972
|
-
return util2;
|
|
65973
|
-
},
|
|
65974
|
-
get objectUtil() {
|
|
65975
|
-
return objectUtil2;
|
|
65976
|
-
},
|
|
65977
|
-
ZodParsedType: ZodParsedType2,
|
|
65978
|
-
getParsedType: getParsedType2,
|
|
65979
|
-
ZodType: ZodType2,
|
|
65980
|
-
datetimeRegex: datetimeRegex2,
|
|
65981
|
-
ZodString: ZodString2,
|
|
65982
|
-
ZodNumber: ZodNumber2,
|
|
65983
|
-
ZodBigInt: ZodBigInt2,
|
|
65984
|
-
ZodBoolean: ZodBoolean2,
|
|
65985
|
-
ZodDate: ZodDate2,
|
|
65986
|
-
ZodSymbol: ZodSymbol2,
|
|
65987
|
-
ZodUndefined: ZodUndefined2,
|
|
65988
|
-
ZodNull: ZodNull2,
|
|
65989
|
-
ZodAny: ZodAny2,
|
|
65990
|
-
ZodUnknown: ZodUnknown2,
|
|
65991
|
-
ZodNever: ZodNever2,
|
|
65992
|
-
ZodVoid: ZodVoid2,
|
|
65993
|
-
ZodArray: ZodArray2,
|
|
65994
|
-
ZodObject: ZodObject2,
|
|
65995
|
-
ZodUnion: ZodUnion2,
|
|
65996
|
-
ZodDiscriminatedUnion: ZodDiscriminatedUnion2,
|
|
65997
|
-
ZodIntersection: ZodIntersection2,
|
|
65998
|
-
ZodTuple: ZodTuple2,
|
|
65999
|
-
ZodRecord: ZodRecord2,
|
|
66000
|
-
ZodMap: ZodMap2,
|
|
66001
|
-
ZodSet: ZodSet2,
|
|
66002
|
-
ZodFunction: ZodFunction2,
|
|
66003
|
-
ZodLazy: ZodLazy2,
|
|
66004
|
-
ZodLiteral: ZodLiteral2,
|
|
66005
|
-
ZodEnum: ZodEnum2,
|
|
66006
|
-
ZodNativeEnum: ZodNativeEnum2,
|
|
66007
|
-
ZodPromise: ZodPromise2,
|
|
66008
|
-
ZodEffects: ZodEffects2,
|
|
66009
|
-
ZodTransformer: ZodEffects2,
|
|
66010
|
-
ZodOptional: ZodOptional2,
|
|
66011
|
-
ZodNullable: ZodNullable2,
|
|
66012
|
-
ZodDefault: ZodDefault2,
|
|
66013
|
-
ZodCatch: ZodCatch2,
|
|
66014
|
-
ZodNaN: ZodNaN2,
|
|
66015
|
-
BRAND: BRAND2,
|
|
66016
|
-
ZodBranded: ZodBranded2,
|
|
66017
|
-
ZodPipeline: ZodPipeline2,
|
|
66018
|
-
ZodReadonly: ZodReadonly2,
|
|
66019
|
-
custom: custom2,
|
|
66020
|
-
Schema: ZodType2,
|
|
66021
|
-
ZodSchema: ZodType2,
|
|
66022
|
-
late: late2,
|
|
66023
|
-
get ZodFirstPartyTypeKind() {
|
|
66024
|
-
return ZodFirstPartyTypeKind2;
|
|
66025
|
-
},
|
|
66026
|
-
coerce: coerce2,
|
|
66027
|
-
any: anyType2,
|
|
66028
|
-
array: arrayType2,
|
|
66029
|
-
bigint: bigIntType2,
|
|
66030
|
-
boolean: booleanType2,
|
|
66031
|
-
date: dateType2,
|
|
66032
|
-
discriminatedUnion: discriminatedUnionType2,
|
|
66033
|
-
effect: effectsType2,
|
|
66034
|
-
enum: enumType2,
|
|
66035
|
-
function: functionType2,
|
|
66036
|
-
instanceof: instanceOfType2,
|
|
66037
|
-
intersection: intersectionType2,
|
|
66038
|
-
lazy: lazyType2,
|
|
66039
|
-
literal: literalType2,
|
|
66040
|
-
map: mapType2,
|
|
66041
|
-
nan: nanType2,
|
|
66042
|
-
nativeEnum: nativeEnumType2,
|
|
66043
|
-
never: neverType2,
|
|
66044
|
-
null: nullType2,
|
|
66045
|
-
nullable: nullableType2,
|
|
66046
|
-
number: numberType2,
|
|
66047
|
-
object: objectType2,
|
|
66048
|
-
oboolean: oboolean2,
|
|
66049
|
-
onumber: onumber2,
|
|
66050
|
-
optional: optionalType2,
|
|
66051
|
-
ostring: ostring2,
|
|
66052
|
-
pipeline: pipelineType2,
|
|
66053
|
-
preprocess: preprocessType2,
|
|
66054
|
-
promise: promiseType2,
|
|
66055
|
-
record: recordType2,
|
|
66056
|
-
set: setType2,
|
|
66057
|
-
strictObject: strictObjectType2,
|
|
66058
|
-
string: stringType2,
|
|
66059
|
-
symbol: symbolType2,
|
|
66060
|
-
transformer: effectsType2,
|
|
66061
|
-
tuple: tupleType2,
|
|
66062
|
-
undefined: undefinedType2,
|
|
66063
|
-
union: unionType2,
|
|
66064
|
-
unknown: unknownType2,
|
|
66065
|
-
void: voidType2,
|
|
66066
|
-
NEVER: NEVER2,
|
|
66067
|
-
ZodIssueCode: ZodIssueCode2,
|
|
66068
|
-
quotelessJson: quotelessJson2,
|
|
66069
|
-
ZodError: ZodError2
|
|
66070
|
-
});
|
|
66071
|
-
|
|
66072
62067
|
// src/tools/hasura/mutation.ts
|
|
66073
62068
|
var hasuraMutation = (server, env3) => {
|
|
66074
62069
|
const hasuraEndpoint = env3.SETTLEMINT_HASURA_ENDPOINT;
|
|
@@ -66083,7 +62078,7 @@ var hasuraMutation = (server, env3) => {
|
|
|
66083
62078
|
if (!accessToken) {
|
|
66084
62079
|
throw new Error("Access token not found in environment variables. Please set SETTLEMINT_ACCESS_TOKEN.");
|
|
66085
62080
|
}
|
|
66086
|
-
server.tool("hasura-mutation", { mutationName:
|
|
62081
|
+
server.tool("hasura-mutation", { mutationName: z.string() }, async ({ mutationName }) => {
|
|
66087
62082
|
try {
|
|
66088
62083
|
if (!mutationName) {
|
|
66089
62084
|
return {
|
|
@@ -66244,7 +62239,7 @@ var hasuraQuery = (server, env3) => {
|
|
|
66244
62239
|
if (!accessToken) {
|
|
66245
62240
|
throw new Error("Access token not found in environment variables. Please set SETTLEMINT_ACCESS_TOKEN.");
|
|
66246
62241
|
}
|
|
66247
|
-
server.tool("hasura-query", { queryName:
|
|
62242
|
+
server.tool("hasura-query", { queryName: z.string() }, async ({ queryName }) => {
|
|
66248
62243
|
try {
|
|
66249
62244
|
if (!queryName) {
|
|
66250
62245
|
return {
|
|
@@ -69114,7 +65109,7 @@ var platformApplicationList = (server, env3, pat) => {
|
|
|
69114
65109
|
instance
|
|
69115
65110
|
});
|
|
69116
65111
|
server.tool("platform-application-list", {
|
|
69117
|
-
workspaceUniqueName:
|
|
65112
|
+
workspaceUniqueName: z.string().describe("Unique name of the workspace to list applications from")
|
|
69118
65113
|
}, async (params) => {
|
|
69119
65114
|
const applications = await client.application.list(params.workspaceUniqueName);
|
|
69120
65115
|
return {
|
|
@@ -69142,7 +65137,7 @@ var platformApplicationRead = (server, env3, pat) => {
|
|
|
69142
65137
|
instance
|
|
69143
65138
|
});
|
|
69144
65139
|
server.tool("platform-application-read", {
|
|
69145
|
-
applicationUniqueName:
|
|
65140
|
+
applicationUniqueName: z.string().describe("Unique name of the application to read")
|
|
69146
65141
|
}, async (params) => {
|
|
69147
65142
|
const application = await client.application.read(params.applicationUniqueName);
|
|
69148
65143
|
return {
|
|
@@ -69170,14 +65165,14 @@ var platformBlockchainNetworkCreate = (server, env3, pat) => {
|
|
|
69170
65165
|
instance
|
|
69171
65166
|
});
|
|
69172
65167
|
server.tool("platform-blockchain-network-create", {
|
|
69173
|
-
applicationUniqueName:
|
|
69174
|
-
name:
|
|
69175
|
-
type:
|
|
69176
|
-
size:
|
|
69177
|
-
provider:
|
|
69178
|
-
region:
|
|
69179
|
-
nodeName:
|
|
69180
|
-
consensusAlgorithm:
|
|
65168
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the network in").optional(),
|
|
65169
|
+
name: z.string().describe("Name of the blockchain network"),
|
|
65170
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the blockchain network (DEDICATED or SHARED)"),
|
|
65171
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the blockchain network"),
|
|
65172
|
+
provider: z.string().describe("Provider for the blockchain network"),
|
|
65173
|
+
region: z.string().describe("Region for the blockchain network"),
|
|
65174
|
+
nodeName: z.string().describe("Name for the initial node"),
|
|
65175
|
+
consensusAlgorithm: z.enum([
|
|
69181
65176
|
"ARBITRUM",
|
|
69182
65177
|
"ARBITRUM_GOERLI",
|
|
69183
65178
|
"ARBITRUM_SEPOLIA",
|
|
@@ -69230,7 +65225,7 @@ var platformBlockchainNetworkList = (server, env3, pat) => {
|
|
|
69230
65225
|
instance
|
|
69231
65226
|
});
|
|
69232
65227
|
server.tool("platform-blockchain-network-list", {
|
|
69233
|
-
applicationUniqueName:
|
|
65228
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list blockchain networks from").optional()
|
|
69234
65229
|
}, async (params) => {
|
|
69235
65230
|
const applicationUniqueName = env3.SETTLEMINT_APPLICATION || params.applicationUniqueName;
|
|
69236
65231
|
if (!applicationUniqueName) {
|
|
@@ -69262,7 +65257,7 @@ var platformBlockchainNetworkRead = (server, env3, pat) => {
|
|
|
69262
65257
|
instance
|
|
69263
65258
|
});
|
|
69264
65259
|
server.tool("platform-blockchain-network-read", {
|
|
69265
|
-
blockchainNetworkUniqueName:
|
|
65260
|
+
blockchainNetworkUniqueName: z.string().describe("Unique name of the blockchain network to read").optional()
|
|
69266
65261
|
}, async (params) => {
|
|
69267
65262
|
const blockchainNetworkUniqueName = env3.SETTLEMINT_BLOCKCHAIN_NETWORK || params.blockchainNetworkUniqueName;
|
|
69268
65263
|
if (!blockchainNetworkUniqueName) {
|
|
@@ -69294,7 +65289,7 @@ var platformBlockchainNetworkRestart = (server, env3, pat) => {
|
|
|
69294
65289
|
instance
|
|
69295
65290
|
});
|
|
69296
65291
|
server.tool("platform-blockchain-network-restart", {
|
|
69297
|
-
networkUniqueName:
|
|
65292
|
+
networkUniqueName: z.string().describe("Unique name of the blockchain network to restart").optional()
|
|
69298
65293
|
}, async (params) => {
|
|
69299
65294
|
const networkUniqueName = env3.SETTLEMINT_BLOCKCHAIN_NETWORK || params.networkUniqueName;
|
|
69300
65295
|
if (!networkUniqueName) {
|
|
@@ -69326,14 +65321,14 @@ var platformBlockchainNodeCreate = (server, env3, pat) => {
|
|
|
69326
65321
|
instance
|
|
69327
65322
|
});
|
|
69328
65323
|
server.tool("platform-blockchain-node-create", {
|
|
69329
|
-
applicationUniqueName:
|
|
69330
|
-
blockchainNetworkUniqueName:
|
|
69331
|
-
name:
|
|
69332
|
-
type:
|
|
69333
|
-
size:
|
|
69334
|
-
nodeType:
|
|
69335
|
-
provider:
|
|
69336
|
-
region:
|
|
65324
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the node in"),
|
|
65325
|
+
blockchainNetworkUniqueName: z.string().describe("Unique name of the blockchain network for the node"),
|
|
65326
|
+
name: z.string().describe("Name of the blockchain node"),
|
|
65327
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the blockchain node (DEDICATED or SHARED)"),
|
|
65328
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the blockchain node"),
|
|
65329
|
+
nodeType: z.enum(["NON_VALIDATOR", "NOTARY", "ORDERER", "PEER", "UNSPECIFIED", "VALIDATOR"]).describe("The type of the blockchain node (NON_VALIDATOR, NOTARY, ORDERER, PEER, UNSPECIFIED, or VALIDATOR)").optional(),
|
|
65330
|
+
provider: z.string().describe("Provider for the blockchain node"),
|
|
65331
|
+
region: z.string().describe("Region for the blockchain node")
|
|
69337
65332
|
}, async (params) => {
|
|
69338
65333
|
const node = await client.blockchainNode.create({
|
|
69339
65334
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -69370,7 +65365,7 @@ var platformBlockchainNodeList = (server, env3, pat) => {
|
|
|
69370
65365
|
instance
|
|
69371
65366
|
});
|
|
69372
65367
|
server.tool("platform-blockchain-node-list", {
|
|
69373
|
-
applicationUniqueName:
|
|
65368
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list blockchain nodes from")
|
|
69374
65369
|
}, async (params) => {
|
|
69375
65370
|
const nodes = await client.blockchainNode.list(params.applicationUniqueName);
|
|
69376
65371
|
return {
|
|
@@ -69398,7 +65393,7 @@ var platformBlockchainNodeRead = (server, env3, pat) => {
|
|
|
69398
65393
|
instance
|
|
69399
65394
|
});
|
|
69400
65395
|
server.tool("platform-blockchain-node-read", {
|
|
69401
|
-
blockchainNodeUniqueName:
|
|
65396
|
+
blockchainNodeUniqueName: z.string().describe("Unique name of the blockchain node to read")
|
|
69402
65397
|
}, async (params) => {
|
|
69403
65398
|
const node = await client.blockchainNode.read(params.blockchainNodeUniqueName);
|
|
69404
65399
|
return {
|
|
@@ -69426,7 +65421,7 @@ var platformBlockchainNodeRestart = (server, env3, pat) => {
|
|
|
69426
65421
|
instance
|
|
69427
65422
|
});
|
|
69428
65423
|
server.tool("platform-blockchain-node-restart", {
|
|
69429
|
-
nodeUniqueName:
|
|
65424
|
+
nodeUniqueName: z.string().describe("Unique name of the blockchain node to restart")
|
|
69430
65425
|
}, async (params) => {
|
|
69431
65426
|
const node = await client.blockchainNode.restart(params.nodeUniqueName);
|
|
69432
65427
|
return {
|
|
@@ -69454,17 +65449,17 @@ var platformCustomDeploymentCreate = (server, env3, pat) => {
|
|
|
69454
65449
|
instance
|
|
69455
65450
|
});
|
|
69456
65451
|
server.tool("platform-custom-deployment-create", {
|
|
69457
|
-
applicationUniqueName:
|
|
69458
|
-
name:
|
|
69459
|
-
imageTag:
|
|
69460
|
-
imageName:
|
|
69461
|
-
imageRepository:
|
|
69462
|
-
port:
|
|
69463
|
-
environmentVariables:
|
|
69464
|
-
provider:
|
|
69465
|
-
region:
|
|
69466
|
-
type:
|
|
69467
|
-
size:
|
|
65452
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the custom deployment in"),
|
|
65453
|
+
name: z.string().describe("Name of the custom deployment"),
|
|
65454
|
+
imageTag: z.string().describe("The tag of the Docker image"),
|
|
65455
|
+
imageName: z.string().describe("The name of the Docker image"),
|
|
65456
|
+
imageRepository: z.string().describe("The repository of the Docker image"),
|
|
65457
|
+
port: z.number().describe("The port number for the custom deployment"),
|
|
65458
|
+
environmentVariables: z.record(z.string(), z.any()).optional().describe("Environment variables for the custom deployment"),
|
|
65459
|
+
provider: z.string().describe("Provider for the custom deployment"),
|
|
65460
|
+
region: z.string().describe("Region for the custom deployment"),
|
|
65461
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the custom deployment (DEDICATED or SHARED)"),
|
|
65462
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the custom deployment")
|
|
69468
65463
|
}, async (params) => {
|
|
69469
65464
|
const customDeployment = await client.customDeployment.create({
|
|
69470
65465
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -69504,8 +65499,8 @@ var platformCustomDeploymentEdit = (server, env3, pat) => {
|
|
|
69504
65499
|
instance
|
|
69505
65500
|
});
|
|
69506
65501
|
server.tool("platform-custom-deployment-edit", {
|
|
69507
|
-
customDeploymentUniqueName:
|
|
69508
|
-
imageTag:
|
|
65502
|
+
customDeploymentUniqueName: z.string().describe("Unique name of the custom deployment to edit"),
|
|
65503
|
+
imageTag: z.string().describe("The new tag of the Docker image")
|
|
69509
65504
|
}, async (params) => {
|
|
69510
65505
|
const customDeployment = await client.customDeployment.update(params.customDeploymentUniqueName, params.imageTag);
|
|
69511
65506
|
return {
|
|
@@ -69533,7 +65528,7 @@ var platformCustomDeploymentList = (server, env3, pat) => {
|
|
|
69533
65528
|
instance
|
|
69534
65529
|
});
|
|
69535
65530
|
server.tool("platform-custom-deployment-list", {
|
|
69536
|
-
applicationUniqueName:
|
|
65531
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list custom deployments from")
|
|
69537
65532
|
}, async (params) => {
|
|
69538
65533
|
const customDeployments = await client.customDeployment.list(params.applicationUniqueName);
|
|
69539
65534
|
return {
|
|
@@ -69561,7 +65556,7 @@ var platformCustomDeploymentRead = (server, env3, pat) => {
|
|
|
69561
65556
|
instance
|
|
69562
65557
|
});
|
|
69563
65558
|
server.tool("platform-custom-deployment-read", {
|
|
69564
|
-
customDeploymentUniqueName:
|
|
65559
|
+
customDeploymentUniqueName: z.string().describe("Unique name of the custom deployment to read")
|
|
69565
65560
|
}, async (params) => {
|
|
69566
65561
|
const customDeployment = await client.customDeployment.read(params.customDeploymentUniqueName);
|
|
69567
65562
|
return {
|
|
@@ -69589,7 +65584,7 @@ var platformCustomDeploymentRestart = (server, env3, pat) => {
|
|
|
69589
65584
|
instance
|
|
69590
65585
|
});
|
|
69591
65586
|
server.tool("platform-custom-deployment-restart", {
|
|
69592
|
-
customDeploymentUniqueName:
|
|
65587
|
+
customDeploymentUniqueName: z.string().describe("Unique name of the custom deployment to restart")
|
|
69593
65588
|
}, async (params) => {
|
|
69594
65589
|
const customDeployment = await client.customDeployment.restart(params.customDeploymentUniqueName);
|
|
69595
65590
|
return {
|
|
@@ -69617,14 +65612,14 @@ var platformInsightsCreate = (server, env3, pat) => {
|
|
|
69617
65612
|
instance
|
|
69618
65613
|
});
|
|
69619
65614
|
server.tool("platform-insights-create", {
|
|
69620
|
-
applicationUniqueName:
|
|
69621
|
-
name:
|
|
69622
|
-
type:
|
|
69623
|
-
size:
|
|
69624
|
-
provider:
|
|
69625
|
-
region:
|
|
69626
|
-
insightsCategory:
|
|
69627
|
-
blockchainNodeUniqueName:
|
|
65615
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the insights in"),
|
|
65616
|
+
name: z.string().describe("Name of the insights"),
|
|
65617
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the insights (DEDICATED or SHARED)"),
|
|
65618
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the insights"),
|
|
65619
|
+
provider: z.string().describe("Provider for the insights"),
|
|
65620
|
+
region: z.string().describe("Region for the insights"),
|
|
65621
|
+
insightsCategory: z.enum(["BLOCKCHAIN_EXPLORER", "HYPERLEDGER_EXPLORER", "OTTERSCAN_BLOCKCHAIN_EXPLORER"]).describe("Category of insights"),
|
|
65622
|
+
blockchainNodeUniqueName: z.string().optional().describe("Unique name of the blockchain node to connect to")
|
|
69628
65623
|
}, async (params) => {
|
|
69629
65624
|
const insights = await client.insights.create({
|
|
69630
65625
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -69661,7 +65656,7 @@ var platformInsightsList = (server, env3, pat) => {
|
|
|
69661
65656
|
instance
|
|
69662
65657
|
});
|
|
69663
65658
|
server.tool("platform-insights-list", {
|
|
69664
|
-
applicationUniqueName:
|
|
65659
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list insights from")
|
|
69665
65660
|
}, async (params) => {
|
|
69666
65661
|
const insightsList2 = await client.insights.list(params.applicationUniqueName);
|
|
69667
65662
|
return {
|
|
@@ -69689,7 +65684,7 @@ var platformInsightsRead = (server, env3, pat) => {
|
|
|
69689
65684
|
instance
|
|
69690
65685
|
});
|
|
69691
65686
|
server.tool("platform-insights-read", {
|
|
69692
|
-
insightsUniqueName:
|
|
65687
|
+
insightsUniqueName: z.string().describe("Unique name of the insights to read")
|
|
69693
65688
|
}, async (params) => {
|
|
69694
65689
|
const insights = await client.insights.read(params.insightsUniqueName);
|
|
69695
65690
|
return {
|
|
@@ -69717,7 +65712,7 @@ var platformInsightsRestart = (server, env3, pat) => {
|
|
|
69717
65712
|
instance
|
|
69718
65713
|
});
|
|
69719
65714
|
server.tool("platform-insights-restart", {
|
|
69720
|
-
insightsUniqueName:
|
|
65715
|
+
insightsUniqueName: z.string().describe("Unique name of the insights to restart")
|
|
69721
65716
|
}, async (params) => {
|
|
69722
65717
|
const insights = await client.insights.restart(params.insightsUniqueName);
|
|
69723
65718
|
return {
|
|
@@ -69745,13 +65740,13 @@ var platformIntegrationToolCreate = (server, env3, pat) => {
|
|
|
69745
65740
|
instance
|
|
69746
65741
|
});
|
|
69747
65742
|
server.tool("platform-integration-tool-create", {
|
|
69748
|
-
applicationUniqueName:
|
|
69749
|
-
name:
|
|
69750
|
-
type:
|
|
69751
|
-
size:
|
|
69752
|
-
provider:
|
|
69753
|
-
region:
|
|
69754
|
-
integrationType:
|
|
65743
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the integration tool in"),
|
|
65744
|
+
name: z.string().describe("Name of the integration tool"),
|
|
65745
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the integration tool (DEDICATED or SHARED)"),
|
|
65746
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the integration tool"),
|
|
65747
|
+
provider: z.string().describe("Provider for the integration tool"),
|
|
65748
|
+
region: z.string().describe("Region for the integration tool"),
|
|
65749
|
+
integrationType: z.enum(["CHAINLINK", "HASURA", "INTEGRATION_STUDIO"]).describe("Type of integration")
|
|
69755
65750
|
}, async (params) => {
|
|
69756
65751
|
const integrationTool = await client.integrationTool.create({
|
|
69757
65752
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -69787,7 +65782,7 @@ var platformIntegrationToolList = (server, env3, pat) => {
|
|
|
69787
65782
|
instance
|
|
69788
65783
|
});
|
|
69789
65784
|
server.tool("platform-integration-tool-list", {
|
|
69790
|
-
applicationUniqueName:
|
|
65785
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list integration tools from")
|
|
69791
65786
|
}, async (params) => {
|
|
69792
65787
|
const integrationTools = await client.integrationTool.list(params.applicationUniqueName);
|
|
69793
65788
|
return {
|
|
@@ -69815,7 +65810,7 @@ var platformIntegrationToolRead = (server, env3, pat) => {
|
|
|
69815
65810
|
instance
|
|
69816
65811
|
});
|
|
69817
65812
|
server.tool("platform-integration-tool-read", {
|
|
69818
|
-
integrationToolUniqueName:
|
|
65813
|
+
integrationToolUniqueName: z.string().describe("Unique name of the integration tool to read")
|
|
69819
65814
|
}, async (params) => {
|
|
69820
65815
|
const integrationTool = await client.integrationTool.read(params.integrationToolUniqueName);
|
|
69821
65816
|
return {
|
|
@@ -69843,7 +65838,7 @@ var platformIntegrationToolRestart = (server, env3, pat) => {
|
|
|
69843
65838
|
instance
|
|
69844
65839
|
});
|
|
69845
65840
|
server.tool("platform-integration-tool-restart", {
|
|
69846
|
-
integrationToolUniqueName:
|
|
65841
|
+
integrationToolUniqueName: z.string().describe("Unique name of the integration tool to restart")
|
|
69847
65842
|
}, async (params) => {
|
|
69848
65843
|
const integrationTool = await client.integrationTool.restart(params.integrationToolUniqueName);
|
|
69849
65844
|
return {
|
|
@@ -69871,14 +65866,14 @@ var platformMiddlewareCreate = (server, env3, pat) => {
|
|
|
69871
65866
|
instance
|
|
69872
65867
|
});
|
|
69873
65868
|
server.tool("platform-middleware-create", {
|
|
69874
|
-
applicationUniqueName:
|
|
69875
|
-
name:
|
|
69876
|
-
type:
|
|
69877
|
-
size:
|
|
69878
|
-
provider:
|
|
69879
|
-
region:
|
|
69880
|
-
interface:
|
|
69881
|
-
blockchainNodeUniqueName:
|
|
65869
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the middleware in"),
|
|
65870
|
+
name: z.string().describe("Name of the middleware"),
|
|
65871
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the middleware (DEDICATED or SHARED)"),
|
|
65872
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the middleware"),
|
|
65873
|
+
provider: z.string().describe("Provider for the middleware"),
|
|
65874
|
+
region: z.string().describe("Region for the middleware"),
|
|
65875
|
+
interface: z.enum(["ATTESTATION_INDEXER", "BESU", "FIREFLY_FABCONNECT", "GRAPH", "HA_GRAPH", "SMART_CONTRACT_PORTAL"]).describe("Interface type for the middleware"),
|
|
65876
|
+
blockchainNodeUniqueName: z.string().optional().describe("Unique name of the blockchain node to connect to")
|
|
69882
65877
|
}, async (params) => {
|
|
69883
65878
|
const middleware = await client.middleware.create({
|
|
69884
65879
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -69915,7 +65910,7 @@ var platformMiddlewareList = (server, env3, pat) => {
|
|
|
69915
65910
|
instance
|
|
69916
65911
|
});
|
|
69917
65912
|
server.tool("platform-middleware-list", {
|
|
69918
|
-
applicationUniqueName:
|
|
65913
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list middleware from")
|
|
69919
65914
|
}, async (params) => {
|
|
69920
65915
|
const middlewareList2 = await client.middleware.list(params.applicationUniqueName);
|
|
69921
65916
|
return {
|
|
@@ -69943,7 +65938,7 @@ var platformMiddlewareRead = (server, env3, pat) => {
|
|
|
69943
65938
|
instance
|
|
69944
65939
|
});
|
|
69945
65940
|
server.tool("platform-middleware-read", {
|
|
69946
|
-
middlewareUniqueName:
|
|
65941
|
+
middlewareUniqueName: z.string().describe("Unique name of the middleware to read")
|
|
69947
65942
|
}, async (params) => {
|
|
69948
65943
|
const middleware = await client.middleware.read(params.middlewareUniqueName);
|
|
69949
65944
|
return {
|
|
@@ -69971,7 +65966,7 @@ var platformMiddlewareRestart = (server, env3, pat) => {
|
|
|
69971
65966
|
instance
|
|
69972
65967
|
});
|
|
69973
65968
|
server.tool("platform-middleware-restart", {
|
|
69974
|
-
middlewareUniqueName:
|
|
65969
|
+
middlewareUniqueName: z.string().describe("Unique name of the middleware to restart")
|
|
69975
65970
|
}, async (params) => {
|
|
69976
65971
|
const middleware = await client.middleware.restart(params.middlewareUniqueName);
|
|
69977
65972
|
return {
|
|
@@ -69999,10 +65994,10 @@ var platformPrivateKeyCreate = (server, env3, pat) => {
|
|
|
69999
65994
|
instance
|
|
70000
65995
|
});
|
|
70001
65996
|
server.tool("platform-private-key-create", {
|
|
70002
|
-
applicationUniqueName:
|
|
70003
|
-
name:
|
|
70004
|
-
privateKeyType:
|
|
70005
|
-
blockchainNodeUniqueNames:
|
|
65997
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the private key in"),
|
|
65998
|
+
name: z.string().describe("Name of the private key"),
|
|
65999
|
+
privateKeyType: z.enum(["ACCESSIBLE_ECDSA_P256", "HD_ECDSA_P256", "HSM_ECDSA_P256"]).describe("Type of private key"),
|
|
66000
|
+
blockchainNodeUniqueNames: z.array(z.string()).optional().describe("Unique names of blockchain nodes to associate with the private key")
|
|
70006
66001
|
}, async (params) => {
|
|
70007
66002
|
const privateKey = await client.privateKey.create({
|
|
70008
66003
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -70035,7 +66030,7 @@ var platformPrivateKeyList = (server, env3, pat) => {
|
|
|
70035
66030
|
instance
|
|
70036
66031
|
});
|
|
70037
66032
|
server.tool("platform-private-key-list", {
|
|
70038
|
-
applicationUniqueName:
|
|
66033
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list private keys from")
|
|
70039
66034
|
}, async (params) => {
|
|
70040
66035
|
const privateKeys = await client.privateKey.list(params.applicationUniqueName);
|
|
70041
66036
|
return {
|
|
@@ -70063,7 +66058,7 @@ var platformPrivateKeyRead = (server, env3, pat) => {
|
|
|
70063
66058
|
instance
|
|
70064
66059
|
});
|
|
70065
66060
|
server.tool("platform-private-key-read", {
|
|
70066
|
-
privateKeyUniqueName:
|
|
66061
|
+
privateKeyUniqueName: z.string().describe("Unique name of the private key to read")
|
|
70067
66062
|
}, async (params) => {
|
|
70068
66063
|
const privateKey = await client.privateKey.read(params.privateKeyUniqueName);
|
|
70069
66064
|
return {
|
|
@@ -70091,7 +66086,7 @@ var platformPrivateKeyRestart = (server, env3, pat) => {
|
|
|
70091
66086
|
instance
|
|
70092
66087
|
});
|
|
70093
66088
|
server.tool("platform-private-key-restart", {
|
|
70094
|
-
privateKeyUniqueName:
|
|
66089
|
+
privateKeyUniqueName: z.string().describe("Unique name of the private key to restart")
|
|
70095
66090
|
}, async (params) => {
|
|
70096
66091
|
const privateKey = await client.privateKey.restart(params.privateKeyUniqueName);
|
|
70097
66092
|
return {
|
|
@@ -70119,13 +66114,13 @@ var platformStorageCreate = (server, env3, pat) => {
|
|
|
70119
66114
|
instance
|
|
70120
66115
|
});
|
|
70121
66116
|
server.tool("platform-storage-create", {
|
|
70122
|
-
applicationUniqueName:
|
|
70123
|
-
name:
|
|
70124
|
-
type:
|
|
70125
|
-
size:
|
|
70126
|
-
provider:
|
|
70127
|
-
region:
|
|
70128
|
-
storageProtocol:
|
|
66117
|
+
applicationUniqueName: z.string().describe("Unique name of the application to create the storage in"),
|
|
66118
|
+
name: z.string().describe("Name of the storage"),
|
|
66119
|
+
type: z.enum(["DEDICATED", "SHARED"]).describe("Type of the storage (DEDICATED or SHARED)"),
|
|
66120
|
+
size: z.enum(["SMALL", "MEDIUM", "LARGE"]).describe("Size of the storage"),
|
|
66121
|
+
provider: z.string().describe("Provider for the storage"),
|
|
66122
|
+
region: z.string().describe("Region for the storage"),
|
|
66123
|
+
storageProtocol: z.enum(["IPFS", "MINIO"]).describe("Storage protocol (IPFS or MINIO)")
|
|
70129
66124
|
}, async (params) => {
|
|
70130
66125
|
const storage = await client.storage.create({
|
|
70131
66126
|
applicationUniqueName: params.applicationUniqueName,
|
|
@@ -70161,7 +66156,7 @@ var platformStorageList = (server, env3, pat) => {
|
|
|
70161
66156
|
instance
|
|
70162
66157
|
});
|
|
70163
66158
|
server.tool("platform-storage-list", {
|
|
70164
|
-
applicationUniqueName:
|
|
66159
|
+
applicationUniqueName: z.string().describe("Unique name of the application to list storage from")
|
|
70165
66160
|
}, async (params) => {
|
|
70166
66161
|
const storageList2 = await client.storage.list(params.applicationUniqueName);
|
|
70167
66162
|
return {
|
|
@@ -70189,7 +66184,7 @@ var platformStorageRead = (server, env3, pat) => {
|
|
|
70189
66184
|
instance
|
|
70190
66185
|
});
|
|
70191
66186
|
server.tool("platform-storage-read", {
|
|
70192
|
-
storageUniqueName:
|
|
66187
|
+
storageUniqueName: z.string().describe("Unique name of the storage to read")
|
|
70193
66188
|
}, async (params) => {
|
|
70194
66189
|
const storage = await client.storage.read(params.storageUniqueName);
|
|
70195
66190
|
return {
|
|
@@ -70217,7 +66212,7 @@ var platformStorageRestart = (server, env3, pat) => {
|
|
|
70217
66212
|
instance
|
|
70218
66213
|
});
|
|
70219
66214
|
server.tool("platform-storage-restart", {
|
|
70220
|
-
storageUniqueName:
|
|
66215
|
+
storageUniqueName: z.string().describe("Unique name of the storage to restart")
|
|
70221
66216
|
}, async (params) => {
|
|
70222
66217
|
const storage = await client.storage.restart(params.storageUniqueName);
|
|
70223
66218
|
return {
|
|
@@ -70271,7 +66266,7 @@ var platformWorkspaceRead = (server, env3, pat) => {
|
|
|
70271
66266
|
instance
|
|
70272
66267
|
});
|
|
70273
66268
|
server.tool("platform-workspace-read", {
|
|
70274
|
-
workspaceUniqueName:
|
|
66269
|
+
workspaceUniqueName: z.string().describe("Unique name of the workspace to read")
|
|
70275
66270
|
}, async (params) => {
|
|
70276
66271
|
const workspace = await client.workspace.read(params.workspaceUniqueName);
|
|
70277
66272
|
return {
|
|
@@ -70298,7 +66293,7 @@ var portalMutation = (server, env3) => {
|
|
|
70298
66293
|
if (!accessToken) {
|
|
70299
66294
|
throw new Error("Access token not found in environment variables. Please set SETTLEMINT_ACCESS_TOKEN.");
|
|
70300
66295
|
}
|
|
70301
|
-
server.tool("portal-mutation", { mutationName:
|
|
66296
|
+
server.tool("portal-mutation", { mutationName: z.string() }, async ({ mutationName }) => {
|
|
70302
66297
|
try {
|
|
70303
66298
|
if (!mutationName) {
|
|
70304
66299
|
return {
|
|
@@ -70408,7 +66403,7 @@ var portalQuery = (server, env3) => {
|
|
|
70408
66403
|
if (!accessToken) {
|
|
70409
66404
|
throw new Error("Access token not found in environment variables. Please set SETTLEMINT_ACCESS_TOKEN.");
|
|
70410
66405
|
}
|
|
70411
|
-
server.tool("portal-query", { queryName:
|
|
66406
|
+
server.tool("portal-query", { queryName: z.string() }, async ({ queryName }) => {
|
|
70412
66407
|
try {
|
|
70413
66408
|
if (!queryName) {
|
|
70414
66409
|
return {
|
|
@@ -70475,8 +66470,8 @@ import path2 from "node:path";
|
|
|
70475
66470
|
var __dirname = "/home/runner/work/sdk/sdk/sdk/mcp/src/tools/prompts";
|
|
70476
66471
|
var promptsGet = (server, _env) => {
|
|
70477
66472
|
server.tool("prompts-get", {
|
|
70478
|
-
category:
|
|
70479
|
-
name:
|
|
66473
|
+
category: z.string().describe("The prompt category (e.g., hasura, portal, thegraph, tool-usage)"),
|
|
66474
|
+
name: z.string().describe("The name of the prompt file without extension")
|
|
70480
66475
|
}, async ({ category, name: name2 }) => {
|
|
70481
66476
|
try {
|
|
70482
66477
|
const promptsDir = path2.resolve(__dirname, "../../prompts");
|
|
@@ -70594,7 +66589,7 @@ import path4 from "node:path";
|
|
|
70594
66589
|
var __dirname = "/home/runner/work/sdk/sdk/sdk/mcp/src/tools/resources";
|
|
70595
66590
|
var resourcesGet = (server, _env) => {
|
|
70596
66591
|
server.tool("resources-get", {
|
|
70597
|
-
name:
|
|
66592
|
+
name: z.string().describe("The name of the resource file without extension")
|
|
70598
66593
|
}, async ({ name: name2 }) => {
|
|
70599
66594
|
try {
|
|
70600
66595
|
const resourcesDir = path4.resolve(__dirname, "../../resources");
|
|
@@ -70773,4 +66768,4 @@ await main().catch((error2) => {
|
|
|
70773
66768
|
process.exit(1);
|
|
70774
66769
|
});
|
|
70775
66770
|
|
|
70776
|
-
//# debugId=
|
|
66771
|
+
//# debugId=2D5C15578BB7E08B64756E2164756E21
|