@youdotcom-oss/mcp 1.1.4 → 1.1.5

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.
Files changed (2) hide show
  1. package/dist/stdio.js +266 -4052
  2. package/package.json +1 -1
package/dist/stdio.js CHANGED
@@ -6195,7 +6195,7 @@ var require_ajv = __commonJS((exports, module) => {
6195
6195
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
6196
6196
  import process2 from "node:process";
6197
6197
 
6198
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/external.js
6198
+ // node_modules/zod/v3/external.js
6199
6199
  var exports_external = {};
6200
6200
  __export(exports_external, {
6201
6201
  void: () => voidType,
@@ -6307,7 +6307,7 @@ __export(exports_external, {
6307
6307
  BRAND: () => BRAND
6308
6308
  });
6309
6309
 
6310
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js
6310
+ // node_modules/zod/v3/helpers/util.js
6311
6311
  var util;
6312
6312
  (function(util2) {
6313
6313
  util2.assertEqual = (_) => {};
@@ -6438,7 +6438,7 @@ var getParsedType = (data) => {
6438
6438
  }
6439
6439
  };
6440
6440
 
6441
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js
6441
+ // node_modules/zod/v3/ZodError.js
6442
6442
  var ZodIssueCode = util.arrayToEnum([
6443
6443
  "invalid_type",
6444
6444
  "invalid_literal",
@@ -6557,7 +6557,7 @@ ZodError.create = (issues) => {
6557
6557
  return error;
6558
6558
  };
6559
6559
 
6560
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js
6560
+ // node_modules/zod/v3/locales/en.js
6561
6561
  var errorMap = (issue, _ctx) => {
6562
6562
  let message;
6563
6563
  switch (issue.code) {
@@ -6660,7 +6660,7 @@ var errorMap = (issue, _ctx) => {
6660
6660
  };
6661
6661
  var en_default = errorMap;
6662
6662
 
6663
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js
6663
+ // node_modules/zod/v3/errors.js
6664
6664
  var overrideErrorMap = en_default;
6665
6665
  function setErrorMap(map) {
6666
6666
  overrideErrorMap = map;
@@ -6668,7 +6668,7 @@ function setErrorMap(map) {
6668
6668
  function getErrorMap() {
6669
6669
  return overrideErrorMap;
6670
6670
  }
6671
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js
6671
+ // node_modules/zod/v3/helpers/parseUtil.js
6672
6672
  var makeIssue = (params) => {
6673
6673
  const { data, path, errorMaps, issueData } = params;
6674
6674
  const fullPath = [...path, ...issueData.path || []];
@@ -6774,14 +6774,14 @@ var isAborted = (x) => x.status === "aborted";
6774
6774
  var isDirty = (x) => x.status === "dirty";
6775
6775
  var isValid = (x) => x.status === "valid";
6776
6776
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
6777
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js
6777
+ // node_modules/zod/v3/helpers/errorUtil.js
6778
6778
  var errorUtil;
6779
6779
  (function(errorUtil2) {
6780
6780
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
6781
6781
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
6782
6782
  })(errorUtil || (errorUtil = {}));
6783
6783
 
6784
- // node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js
6784
+ // node_modules/zod/v3/types.js
6785
6785
  class ParseInputLazyPath {
6786
6786
  constructor(parent, value, path, key) {
6787
6787
  this._cachedPath = [];
@@ -10249,12 +10249,19 @@ var CancelledNotificationSchema = NotificationSchema.extend({
10249
10249
  reason: exports_external.string().optional()
10250
10250
  })
10251
10251
  });
10252
+ var IconSchema = exports_external.object({
10253
+ src: exports_external.string(),
10254
+ mimeType: exports_external.optional(exports_external.string()),
10255
+ sizes: exports_external.optional(exports_external.string())
10256
+ }).passthrough();
10252
10257
  var BaseMetadataSchema = exports_external.object({
10253
10258
  name: exports_external.string(),
10254
10259
  title: exports_external.optional(exports_external.string())
10255
10260
  }).passthrough();
10256
10261
  var ImplementationSchema = BaseMetadataSchema.extend({
10257
- version: exports_external.string()
10262
+ version: exports_external.string(),
10263
+ websiteUrl: exports_external.optional(exports_external.string()),
10264
+ icons: exports_external.optional(exports_external.array(IconSchema))
10258
10265
  });
10259
10266
  var ClientCapabilitiesSchema = exports_external.object({
10260
10267
  experimental: exports_external.optional(exports_external.object({}).passthrough()),
@@ -10341,6 +10348,7 @@ var ResourceSchema = BaseMetadataSchema.extend({
10341
10348
  uri: exports_external.string(),
10342
10349
  description: exports_external.optional(exports_external.string()),
10343
10350
  mimeType: exports_external.optional(exports_external.string()),
10351
+ icons: exports_external.optional(exports_external.array(IconSchema)),
10344
10352
  _meta: exports_external.optional(exports_external.object({}).passthrough())
10345
10353
  });
10346
10354
  var ResourceTemplateSchema = BaseMetadataSchema.extend({
@@ -10399,6 +10407,7 @@ var PromptArgumentSchema = exports_external.object({
10399
10407
  var PromptSchema = BaseMetadataSchema.extend({
10400
10408
  description: exports_external.optional(exports_external.string()),
10401
10409
  arguments: exports_external.optional(exports_external.array(PromptArgumentSchema)),
10410
+ icons: exports_external.optional(exports_external.array(IconSchema)),
10402
10411
  _meta: exports_external.optional(exports_external.object({}).passthrough())
10403
10412
  });
10404
10413
  var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
@@ -10477,6 +10486,7 @@ var ToolSchema = BaseMetadataSchema.extend({
10477
10486
  required: exports_external.optional(exports_external.array(exports_external.string()))
10478
10487
  }).passthrough()),
10479
10488
  annotations: exports_external.optional(ToolAnnotationsSchema),
10489
+ icons: exports_external.optional(exports_external.array(IconSchema)),
10480
10490
  _meta: exports_external.optional(exports_external.object({}).passthrough())
10481
10491
  });
10482
10492
  var ListToolsRequestSchema = PaginatedRequestSchema.extend({
@@ -11176,7 +11186,7 @@ class Server extends Protocol {
11176
11186
  const transportSessionId = extra.sessionId || ((_a2 = extra.requestInfo) === null || _a2 === undefined ? undefined : _a2.headers["mcp-session-id"]) || undefined;
11177
11187
  const { level } = request.params;
11178
11188
  const parseResult = LoggingLevelSchema.safeParse(level);
11179
- if (transportSessionId && parseResult.success) {
11189
+ if (parseResult.success) {
11180
11190
  this._loggingLevels.set(transportSessionId, parseResult.data);
11181
11191
  }
11182
11192
  return {};
@@ -11327,7 +11337,7 @@ class Server extends Protocol {
11327
11337
  }
11328
11338
  async sendLoggingMessage(params, sessionId) {
11329
11339
  if (this._capabilities.logging) {
11330
- if (!sessionId || !this.isMessageIgnored(params.level, sessionId)) {
11340
+ if (!this.isMessageIgnored(params.level, sessionId)) {
11331
11341
  return this.notification({ method: "notifications/message", params });
11332
11342
  }
11333
11343
  }
@@ -11427,3960 +11437,149 @@ var getRelativePath = (pathA, pathB) => {
11427
11437
  }
11428
11438
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
11429
11439
  };
11430
- // node_modules/zod/v3/helpers/util.js
11431
- var util3;
11432
- (function(util4) {
11433
- util4.assertEqual = (_) => {};
11434
- function assertIs(_arg) {}
11435
- util4.assertIs = assertIs;
11436
- function assertNever(_x) {
11437
- throw new Error;
11440
+ // node_modules/zod-to-json-schema/dist/esm/parsers/any.js
11441
+ function parseAnyDef(refs) {
11442
+ if (refs.target !== "openAi") {
11443
+ return {};
11438
11444
  }
11439
- util4.assertNever = assertNever;
11440
- util4.arrayToEnum = (items) => {
11441
- const obj = {};
11442
- for (const item of items) {
11443
- obj[item] = item;
11444
- }
11445
- return obj;
11445
+ const anyDefinitionPath = [
11446
+ ...refs.basePath,
11447
+ refs.definitionPath,
11448
+ refs.openAiAnyTypeName
11449
+ ];
11450
+ refs.flags.hasReferencedOpenAiAnyType = true;
11451
+ return {
11452
+ $ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
11446
11453
  };
11447
- util4.getValidEnumValues = (obj) => {
11448
- const validKeys = util4.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
11449
- const filtered = {};
11450
- for (const k of validKeys) {
11451
- filtered[k] = obj[k];
11452
- }
11453
- return util4.objectValues(filtered);
11454
+ }
11455
+
11456
+ // node_modules/zod-to-json-schema/dist/esm/parsers/array.js
11457
+ function parseArrayDef(def, refs) {
11458
+ const res = {
11459
+ type: "array"
11454
11460
  };
11455
- util4.objectValues = (obj) => {
11456
- return util4.objectKeys(obj).map(function(e) {
11457
- return obj[e];
11461
+ if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
11462
+ res.items = parseDef(def.type._def, {
11463
+ ...refs,
11464
+ currentPath: [...refs.currentPath, "items"]
11458
11465
  });
11466
+ }
11467
+ if (def.minLength) {
11468
+ setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
11469
+ }
11470
+ if (def.maxLength) {
11471
+ setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
11472
+ }
11473
+ if (def.exactLength) {
11474
+ setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
11475
+ setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
11476
+ }
11477
+ return res;
11478
+ }
11479
+
11480
+ // node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
11481
+ function parseBigintDef(def, refs) {
11482
+ const res = {
11483
+ type: "integer",
11484
+ format: "int64"
11459
11485
  };
11460
- util4.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
11461
- const keys = [];
11462
- for (const key in object) {
11463
- if (Object.prototype.hasOwnProperty.call(object, key)) {
11464
- keys.push(key);
11465
- }
11466
- }
11467
- return keys;
11468
- };
11469
- util4.find = (arr, checker) => {
11470
- for (const item of arr) {
11471
- if (checker(item))
11472
- return item;
11486
+ if (!def.checks)
11487
+ return res;
11488
+ for (const check of def.checks) {
11489
+ switch (check.kind) {
11490
+ case "min":
11491
+ if (refs.target === "jsonSchema7") {
11492
+ if (check.inclusive) {
11493
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
11494
+ } else {
11495
+ setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
11496
+ }
11497
+ } else {
11498
+ if (!check.inclusive) {
11499
+ res.exclusiveMinimum = true;
11500
+ }
11501
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
11502
+ }
11503
+ break;
11504
+ case "max":
11505
+ if (refs.target === "jsonSchema7") {
11506
+ if (check.inclusive) {
11507
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
11508
+ } else {
11509
+ setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
11510
+ }
11511
+ } else {
11512
+ if (!check.inclusive) {
11513
+ res.exclusiveMaximum = true;
11514
+ }
11515
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
11516
+ }
11517
+ break;
11518
+ case "multipleOf":
11519
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
11520
+ break;
11473
11521
  }
11474
- return;
11475
- };
11476
- util4.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
11477
- function joinValues(array, separator = " | ") {
11478
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
11479
11522
  }
11480
- util4.joinValues = joinValues;
11481
- util4.jsonStringifyReplacer = (_, value) => {
11482
- if (typeof value === "bigint") {
11483
- return value.toString();
11484
- }
11485
- return value;
11523
+ return res;
11524
+ }
11525
+
11526
+ // node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
11527
+ function parseBooleanDef() {
11528
+ return {
11529
+ type: "boolean"
11486
11530
  };
11487
- })(util3 || (util3 = {}));
11488
- var objectUtil2;
11489
- (function(objectUtil3) {
11490
- objectUtil3.mergeShapes = (first, second) => {
11531
+ }
11532
+
11533
+ // node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
11534
+ function parseBrandedDef(_def, refs) {
11535
+ return parseDef(_def.type._def, refs);
11536
+ }
11537
+
11538
+ // node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
11539
+ var parseCatchDef = (def, refs) => {
11540
+ return parseDef(def.innerType._def, refs);
11541
+ };
11542
+
11543
+ // node_modules/zod-to-json-schema/dist/esm/parsers/date.js
11544
+ function parseDateDef(def, refs, overrideDateStrategy) {
11545
+ const strategy = overrideDateStrategy ?? refs.dateStrategy;
11546
+ if (Array.isArray(strategy)) {
11491
11547
  return {
11492
- ...first,
11493
- ...second
11548
+ anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
11494
11549
  };
11495
- };
11496
- })(objectUtil2 || (objectUtil2 = {}));
11497
- var ZodParsedType2 = util3.arrayToEnum([
11498
- "string",
11499
- "nan",
11500
- "number",
11501
- "integer",
11502
- "float",
11503
- "boolean",
11504
- "date",
11505
- "bigint",
11506
- "symbol",
11507
- "function",
11508
- "undefined",
11509
- "null",
11510
- "array",
11511
- "object",
11512
- "unknown",
11513
- "promise",
11514
- "void",
11515
- "never",
11516
- "map",
11517
- "set"
11518
- ]);
11519
- var getParsedType2 = (data) => {
11520
- const t = typeof data;
11521
- switch (t) {
11522
- case "undefined":
11523
- return ZodParsedType2.undefined;
11550
+ }
11551
+ switch (strategy) {
11524
11552
  case "string":
11525
- return ZodParsedType2.string;
11526
- case "number":
11527
- return Number.isNaN(data) ? ZodParsedType2.nan : ZodParsedType2.number;
11528
- case "boolean":
11529
- return ZodParsedType2.boolean;
11530
- case "function":
11531
- return ZodParsedType2.function;
11532
- case "bigint":
11533
- return ZodParsedType2.bigint;
11534
- case "symbol":
11535
- return ZodParsedType2.symbol;
11536
- case "object":
11537
- if (Array.isArray(data)) {
11538
- return ZodParsedType2.array;
11539
- }
11540
- if (data === null) {
11541
- return ZodParsedType2.null;
11542
- }
11543
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
11544
- return ZodParsedType2.promise;
11545
- }
11546
- if (typeof Map !== "undefined" && data instanceof Map) {
11547
- return ZodParsedType2.map;
11548
- }
11549
- if (typeof Set !== "undefined" && data instanceof Set) {
11550
- return ZodParsedType2.set;
11551
- }
11552
- if (typeof Date !== "undefined" && data instanceof Date) {
11553
- return ZodParsedType2.date;
11554
- }
11555
- return ZodParsedType2.object;
11556
- default:
11557
- return ZodParsedType2.unknown;
11553
+ case "format:date-time":
11554
+ return {
11555
+ type: "string",
11556
+ format: "date-time"
11557
+ };
11558
+ case "format:date":
11559
+ return {
11560
+ type: "string",
11561
+ format: "date"
11562
+ };
11563
+ case "integer":
11564
+ return integerDateParser(def, refs);
11558
11565
  }
11559
- };
11560
-
11561
- // node_modules/zod/v3/ZodError.js
11562
- var ZodIssueCode2 = util3.arrayToEnum([
11563
- "invalid_type",
11564
- "invalid_literal",
11565
- "custom",
11566
- "invalid_union",
11567
- "invalid_union_discriminator",
11568
- "invalid_enum_value",
11569
- "unrecognized_keys",
11570
- "invalid_arguments",
11571
- "invalid_return_type",
11572
- "invalid_date",
11573
- "invalid_string",
11574
- "too_small",
11575
- "too_big",
11576
- "invalid_intersection_types",
11577
- "not_multiple_of",
11578
- "not_finite"
11579
- ]);
11580
- class ZodError3 extends Error {
11581
- get errors() {
11582
- return this.issues;
11566
+ }
11567
+ var integerDateParser = (def, refs) => {
11568
+ const res = {
11569
+ type: "integer",
11570
+ format: "unix-time"
11571
+ };
11572
+ if (refs.target === "openApi3") {
11573
+ return res;
11583
11574
  }
11584
- constructor(issues) {
11585
- super();
11586
- this.issues = [];
11587
- this.addIssue = (sub) => {
11588
- this.issues = [...this.issues, sub];
11589
- };
11590
- this.addIssues = (subs = []) => {
11591
- this.issues = [...this.issues, ...subs];
11592
- };
11593
- const actualProto = new.target.prototype;
11594
- if (Object.setPrototypeOf) {
11595
- Object.setPrototypeOf(this, actualProto);
11596
- } else {
11597
- this.__proto__ = actualProto;
11598
- }
11599
- this.name = "ZodError";
11600
- this.issues = issues;
11601
- }
11602
- format(_mapper) {
11603
- const mapper = _mapper || function(issue) {
11604
- return issue.message;
11605
- };
11606
- const fieldErrors = { _errors: [] };
11607
- const processError = (error) => {
11608
- for (const issue of error.issues) {
11609
- if (issue.code === "invalid_union") {
11610
- issue.unionErrors.map(processError);
11611
- } else if (issue.code === "invalid_return_type") {
11612
- processError(issue.returnTypeError);
11613
- } else if (issue.code === "invalid_arguments") {
11614
- processError(issue.argumentsError);
11615
- } else if (issue.path.length === 0) {
11616
- fieldErrors._errors.push(mapper(issue));
11617
- } else {
11618
- let curr = fieldErrors;
11619
- let i = 0;
11620
- while (i < issue.path.length) {
11621
- const el = issue.path[i];
11622
- const terminal = i === issue.path.length - 1;
11623
- if (!terminal) {
11624
- curr[el] = curr[el] || { _errors: [] };
11625
- } else {
11626
- curr[el] = curr[el] || { _errors: [] };
11627
- curr[el]._errors.push(mapper(issue));
11628
- }
11629
- curr = curr[el];
11630
- i++;
11631
- }
11632
- }
11633
- }
11634
- };
11635
- processError(this);
11636
- return fieldErrors;
11637
- }
11638
- static assert(value) {
11639
- if (!(value instanceof ZodError3)) {
11640
- throw new Error(`Not a ZodError: ${value}`);
11641
- }
11642
- }
11643
- toString() {
11644
- return this.message;
11645
- }
11646
- get message() {
11647
- return JSON.stringify(this.issues, util3.jsonStringifyReplacer, 2);
11648
- }
11649
- get isEmpty() {
11650
- return this.issues.length === 0;
11651
- }
11652
- flatten(mapper = (issue) => issue.message) {
11653
- const fieldErrors = {};
11654
- const formErrors = [];
11655
- for (const sub of this.issues) {
11656
- if (sub.path.length > 0) {
11657
- const firstEl = sub.path[0];
11658
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
11659
- fieldErrors[firstEl].push(mapper(sub));
11660
- } else {
11661
- formErrors.push(mapper(sub));
11662
- }
11663
- }
11664
- return { formErrors, fieldErrors };
11665
- }
11666
- get formErrors() {
11667
- return this.flatten();
11668
- }
11669
- }
11670
- ZodError3.create = (issues) => {
11671
- const error = new ZodError3(issues);
11672
- return error;
11673
- };
11674
-
11675
- // node_modules/zod/v3/locales/en.js
11676
- var errorMap2 = (issue, _ctx) => {
11677
- let message;
11678
- switch (issue.code) {
11679
- case ZodIssueCode2.invalid_type:
11680
- if (issue.received === ZodParsedType2.undefined) {
11681
- message = "Required";
11682
- } else {
11683
- message = `Expected ${issue.expected}, received ${issue.received}`;
11684
- }
11685
- break;
11686
- case ZodIssueCode2.invalid_literal:
11687
- message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util3.jsonStringifyReplacer)}`;
11688
- break;
11689
- case ZodIssueCode2.unrecognized_keys:
11690
- message = `Unrecognized key(s) in object: ${util3.joinValues(issue.keys, ", ")}`;
11691
- break;
11692
- case ZodIssueCode2.invalid_union:
11693
- message = `Invalid input`;
11694
- break;
11695
- case ZodIssueCode2.invalid_union_discriminator:
11696
- message = `Invalid discriminator value. Expected ${util3.joinValues(issue.options)}`;
11697
- break;
11698
- case ZodIssueCode2.invalid_enum_value:
11699
- message = `Invalid enum value. Expected ${util3.joinValues(issue.options)}, received '${issue.received}'`;
11700
- break;
11701
- case ZodIssueCode2.invalid_arguments:
11702
- message = `Invalid function arguments`;
11703
- break;
11704
- case ZodIssueCode2.invalid_return_type:
11705
- message = `Invalid function return type`;
11706
- break;
11707
- case ZodIssueCode2.invalid_date:
11708
- message = `Invalid date`;
11709
- break;
11710
- case ZodIssueCode2.invalid_string:
11711
- if (typeof issue.validation === "object") {
11712
- if ("includes" in issue.validation) {
11713
- message = `Invalid input: must include "${issue.validation.includes}"`;
11714
- if (typeof issue.validation.position === "number") {
11715
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
11716
- }
11717
- } else if ("startsWith" in issue.validation) {
11718
- message = `Invalid input: must start with "${issue.validation.startsWith}"`;
11719
- } else if ("endsWith" in issue.validation) {
11720
- message = `Invalid input: must end with "${issue.validation.endsWith}"`;
11721
- } else {
11722
- util3.assertNever(issue.validation);
11723
- }
11724
- } else if (issue.validation !== "regex") {
11725
- message = `Invalid ${issue.validation}`;
11726
- } else {
11727
- message = "Invalid";
11728
- }
11729
- break;
11730
- case ZodIssueCode2.too_small:
11731
- if (issue.type === "array")
11732
- message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
11733
- else if (issue.type === "string")
11734
- message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
11735
- else if (issue.type === "number")
11736
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
11737
- else if (issue.type === "bigint")
11738
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
11739
- else if (issue.type === "date")
11740
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
11741
- else
11742
- message = "Invalid input";
11743
- break;
11744
- case ZodIssueCode2.too_big:
11745
- if (issue.type === "array")
11746
- message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
11747
- else if (issue.type === "string")
11748
- message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
11749
- else if (issue.type === "number")
11750
- message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
11751
- else if (issue.type === "bigint")
11752
- message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
11753
- else if (issue.type === "date")
11754
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
11755
- else
11756
- message = "Invalid input";
11757
- break;
11758
- case ZodIssueCode2.custom:
11759
- message = `Invalid input`;
11760
- break;
11761
- case ZodIssueCode2.invalid_intersection_types:
11762
- message = `Intersection results could not be merged`;
11763
- break;
11764
- case ZodIssueCode2.not_multiple_of:
11765
- message = `Number must be a multiple of ${issue.multipleOf}`;
11766
- break;
11767
- case ZodIssueCode2.not_finite:
11768
- message = "Number must be finite";
11769
- break;
11770
- default:
11771
- message = _ctx.defaultError;
11772
- util3.assertNever(issue);
11773
- }
11774
- return { message };
11775
- };
11776
- var en_default2 = errorMap2;
11777
-
11778
- // node_modules/zod/v3/errors.js
11779
- var overrideErrorMap2 = en_default2;
11780
- function getErrorMap2() {
11781
- return overrideErrorMap2;
11782
- }
11783
-
11784
- // node_modules/zod/v3/helpers/parseUtil.js
11785
- var makeIssue2 = (params) => {
11786
- const { data, path, errorMaps, issueData } = params;
11787
- const fullPath = [...path, ...issueData.path || []];
11788
- const fullIssue = {
11789
- ...issueData,
11790
- path: fullPath
11791
- };
11792
- if (issueData.message !== undefined) {
11793
- return {
11794
- ...issueData,
11795
- path: fullPath,
11796
- message: issueData.message
11797
- };
11798
- }
11799
- let errorMessage = "";
11800
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
11801
- for (const map of maps) {
11802
- errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
11803
- }
11804
- return {
11805
- ...issueData,
11806
- path: fullPath,
11807
- message: errorMessage
11808
- };
11809
- };
11810
- function addIssueToContext2(ctx, issueData) {
11811
- const overrideMap = getErrorMap2();
11812
- const issue = makeIssue2({
11813
- issueData,
11814
- data: ctx.data,
11815
- path: ctx.path,
11816
- errorMaps: [
11817
- ctx.common.contextualErrorMap,
11818
- ctx.schemaErrorMap,
11819
- overrideMap,
11820
- overrideMap === en_default2 ? undefined : en_default2
11821
- ].filter((x) => !!x)
11822
- });
11823
- ctx.common.issues.push(issue);
11824
- }
11825
-
11826
- class ParseStatus2 {
11827
- constructor() {
11828
- this.value = "valid";
11829
- }
11830
- dirty() {
11831
- if (this.value === "valid")
11832
- this.value = "dirty";
11833
- }
11834
- abort() {
11835
- if (this.value !== "aborted")
11836
- this.value = "aborted";
11837
- }
11838
- static mergeArray(status, results) {
11839
- const arrayValue = [];
11840
- for (const s of results) {
11841
- if (s.status === "aborted")
11842
- return INVALID2;
11843
- if (s.status === "dirty")
11844
- status.dirty();
11845
- arrayValue.push(s.value);
11846
- }
11847
- return { status: status.value, value: arrayValue };
11848
- }
11849
- static async mergeObjectAsync(status, pairs) {
11850
- const syncPairs = [];
11851
- for (const pair of pairs) {
11852
- const key = await pair.key;
11853
- const value = await pair.value;
11854
- syncPairs.push({
11855
- key,
11856
- value
11857
- });
11858
- }
11859
- return ParseStatus2.mergeObjectSync(status, syncPairs);
11860
- }
11861
- static mergeObjectSync(status, pairs) {
11862
- const finalObject = {};
11863
- for (const pair of pairs) {
11864
- const { key, value } = pair;
11865
- if (key.status === "aborted")
11866
- return INVALID2;
11867
- if (value.status === "aborted")
11868
- return INVALID2;
11869
- if (key.status === "dirty")
11870
- status.dirty();
11871
- if (value.status === "dirty")
11872
- status.dirty();
11873
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
11874
- finalObject[key.value] = value.value;
11875
- }
11876
- }
11877
- return { status: status.value, value: finalObject };
11878
- }
11879
- }
11880
- var INVALID2 = Object.freeze({
11881
- status: "aborted"
11882
- });
11883
- var DIRTY2 = (value) => ({ status: "dirty", value });
11884
- var OK2 = (value) => ({ status: "valid", value });
11885
- var isAborted2 = (x) => x.status === "aborted";
11886
- var isDirty2 = (x) => x.status === "dirty";
11887
- var isValid2 = (x) => x.status === "valid";
11888
- var isAsync2 = (x) => typeof Promise !== "undefined" && x instanceof Promise;
11889
-
11890
- // node_modules/zod/v3/helpers/errorUtil.js
11891
- var errorUtil2;
11892
- (function(errorUtil3) {
11893
- errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
11894
- errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
11895
- })(errorUtil2 || (errorUtil2 = {}));
11896
-
11897
- // node_modules/zod/v3/types.js
11898
- class ParseInputLazyPath2 {
11899
- constructor(parent, value, path, key) {
11900
- this._cachedPath = [];
11901
- this.parent = parent;
11902
- this.data = value;
11903
- this._path = path;
11904
- this._key = key;
11905
- }
11906
- get path() {
11907
- if (!this._cachedPath.length) {
11908
- if (Array.isArray(this._key)) {
11909
- this._cachedPath.push(...this._path, ...this._key);
11910
- } else {
11911
- this._cachedPath.push(...this._path, this._key);
11912
- }
11913
- }
11914
- return this._cachedPath;
11915
- }
11916
- }
11917
- var handleResult2 = (ctx, result) => {
11918
- if (isValid2(result)) {
11919
- return { success: true, data: result.value };
11920
- } else {
11921
- if (!ctx.common.issues.length) {
11922
- throw new Error("Validation failed but no issues detected.");
11923
- }
11924
- return {
11925
- success: false,
11926
- get error() {
11927
- if (this._error)
11928
- return this._error;
11929
- const error = new ZodError3(ctx.common.issues);
11930
- this._error = error;
11931
- return this._error;
11932
- }
11933
- };
11934
- }
11935
- };
11936
- function processCreateParams2(params) {
11937
- if (!params)
11938
- return {};
11939
- const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
11940
- if (errorMap3 && (invalid_type_error || required_error)) {
11941
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
11942
- }
11943
- if (errorMap3)
11944
- return { errorMap: errorMap3, description };
11945
- const customMap = (iss, ctx) => {
11946
- const { message } = params;
11947
- if (iss.code === "invalid_enum_value") {
11948
- return { message: message ?? ctx.defaultError };
11949
- }
11950
- if (typeof ctx.data === "undefined") {
11951
- return { message: message ?? required_error ?? ctx.defaultError };
11952
- }
11953
- if (iss.code !== "invalid_type")
11954
- return { message: ctx.defaultError };
11955
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
11956
- };
11957
- return { errorMap: customMap, description };
11958
- }
11959
-
11960
- class ZodType2 {
11961
- get description() {
11962
- return this._def.description;
11963
- }
11964
- _getType(input) {
11965
- return getParsedType2(input.data);
11966
- }
11967
- _getOrReturnCtx(input, ctx) {
11968
- return ctx || {
11969
- common: input.parent.common,
11970
- data: input.data,
11971
- parsedType: getParsedType2(input.data),
11972
- schemaErrorMap: this._def.errorMap,
11973
- path: input.path,
11974
- parent: input.parent
11975
- };
11976
- }
11977
- _processInputParams(input) {
11978
- return {
11979
- status: new ParseStatus2,
11980
- ctx: {
11981
- common: input.parent.common,
11982
- data: input.data,
11983
- parsedType: getParsedType2(input.data),
11984
- schemaErrorMap: this._def.errorMap,
11985
- path: input.path,
11986
- parent: input.parent
11987
- }
11988
- };
11989
- }
11990
- _parseSync(input) {
11991
- const result = this._parse(input);
11992
- if (isAsync2(result)) {
11993
- throw new Error("Synchronous parse encountered promise.");
11994
- }
11995
- return result;
11996
- }
11997
- _parseAsync(input) {
11998
- const result = this._parse(input);
11999
- return Promise.resolve(result);
12000
- }
12001
- parse(data, params) {
12002
- const result = this.safeParse(data, params);
12003
- if (result.success)
12004
- return result.data;
12005
- throw result.error;
12006
- }
12007
- safeParse(data, params) {
12008
- const ctx = {
12009
- common: {
12010
- issues: [],
12011
- async: params?.async ?? false,
12012
- contextualErrorMap: params?.errorMap
12013
- },
12014
- path: params?.path || [],
12015
- schemaErrorMap: this._def.errorMap,
12016
- parent: null,
12017
- data,
12018
- parsedType: getParsedType2(data)
12019
- };
12020
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
12021
- return handleResult2(ctx, result);
12022
- }
12023
- "~validate"(data) {
12024
- const ctx = {
12025
- common: {
12026
- issues: [],
12027
- async: !!this["~standard"].async
12028
- },
12029
- path: [],
12030
- schemaErrorMap: this._def.errorMap,
12031
- parent: null,
12032
- data,
12033
- parsedType: getParsedType2(data)
12034
- };
12035
- if (!this["~standard"].async) {
12036
- try {
12037
- const result = this._parseSync({ data, path: [], parent: ctx });
12038
- return isValid2(result) ? {
12039
- value: result.value
12040
- } : {
12041
- issues: ctx.common.issues
12042
- };
12043
- } catch (err) {
12044
- if (err?.message?.toLowerCase()?.includes("encountered")) {
12045
- this["~standard"].async = true;
12046
- }
12047
- ctx.common = {
12048
- issues: [],
12049
- async: true
12050
- };
12051
- }
12052
- }
12053
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid2(result) ? {
12054
- value: result.value
12055
- } : {
12056
- issues: ctx.common.issues
12057
- });
12058
- }
12059
- async parseAsync(data, params) {
12060
- const result = await this.safeParseAsync(data, params);
12061
- if (result.success)
12062
- return result.data;
12063
- throw result.error;
12064
- }
12065
- async safeParseAsync(data, params) {
12066
- const ctx = {
12067
- common: {
12068
- issues: [],
12069
- contextualErrorMap: params?.errorMap,
12070
- async: true
12071
- },
12072
- path: params?.path || [],
12073
- schemaErrorMap: this._def.errorMap,
12074
- parent: null,
12075
- data,
12076
- parsedType: getParsedType2(data)
12077
- };
12078
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
12079
- const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
12080
- return handleResult2(ctx, result);
12081
- }
12082
- refine(check, message) {
12083
- const getIssueProperties = (val) => {
12084
- if (typeof message === "string" || typeof message === "undefined") {
12085
- return { message };
12086
- } else if (typeof message === "function") {
12087
- return message(val);
12088
- } else {
12089
- return message;
12090
- }
12091
- };
12092
- return this._refinement((val, ctx) => {
12093
- const result = check(val);
12094
- const setError = () => ctx.addIssue({
12095
- code: ZodIssueCode2.custom,
12096
- ...getIssueProperties(val)
12097
- });
12098
- if (typeof Promise !== "undefined" && result instanceof Promise) {
12099
- return result.then((data) => {
12100
- if (!data) {
12101
- setError();
12102
- return false;
12103
- } else {
12104
- return true;
12105
- }
12106
- });
12107
- }
12108
- if (!result) {
12109
- setError();
12110
- return false;
12111
- } else {
12112
- return true;
12113
- }
12114
- });
12115
- }
12116
- refinement(check, refinementData) {
12117
- return this._refinement((val, ctx) => {
12118
- if (!check(val)) {
12119
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
12120
- return false;
12121
- } else {
12122
- return true;
12123
- }
12124
- });
12125
- }
12126
- _refinement(refinement) {
12127
- return new ZodEffects2({
12128
- schema: this,
12129
- typeName: ZodFirstPartyTypeKind2.ZodEffects,
12130
- effect: { type: "refinement", refinement }
12131
- });
12132
- }
12133
- superRefine(refinement) {
12134
- return this._refinement(refinement);
12135
- }
12136
- constructor(def) {
12137
- this.spa = this.safeParseAsync;
12138
- this._def = def;
12139
- this.parse = this.parse.bind(this);
12140
- this.safeParse = this.safeParse.bind(this);
12141
- this.parseAsync = this.parseAsync.bind(this);
12142
- this.safeParseAsync = this.safeParseAsync.bind(this);
12143
- this.spa = this.spa.bind(this);
12144
- this.refine = this.refine.bind(this);
12145
- this.refinement = this.refinement.bind(this);
12146
- this.superRefine = this.superRefine.bind(this);
12147
- this.optional = this.optional.bind(this);
12148
- this.nullable = this.nullable.bind(this);
12149
- this.nullish = this.nullish.bind(this);
12150
- this.array = this.array.bind(this);
12151
- this.promise = this.promise.bind(this);
12152
- this.or = this.or.bind(this);
12153
- this.and = this.and.bind(this);
12154
- this.transform = this.transform.bind(this);
12155
- this.brand = this.brand.bind(this);
12156
- this.default = this.default.bind(this);
12157
- this.catch = this.catch.bind(this);
12158
- this.describe = this.describe.bind(this);
12159
- this.pipe = this.pipe.bind(this);
12160
- this.readonly = this.readonly.bind(this);
12161
- this.isNullable = this.isNullable.bind(this);
12162
- this.isOptional = this.isOptional.bind(this);
12163
- this["~standard"] = {
12164
- version: 1,
12165
- vendor: "zod",
12166
- validate: (data) => this["~validate"](data)
12167
- };
12168
- }
12169
- optional() {
12170
- return ZodOptional2.create(this, this._def);
12171
- }
12172
- nullable() {
12173
- return ZodNullable2.create(this, this._def);
12174
- }
12175
- nullish() {
12176
- return this.nullable().optional();
12177
- }
12178
- array() {
12179
- return ZodArray2.create(this);
12180
- }
12181
- promise() {
12182
- return ZodPromise2.create(this, this._def);
12183
- }
12184
- or(option) {
12185
- return ZodUnion2.create([this, option], this._def);
12186
- }
12187
- and(incoming) {
12188
- return ZodIntersection2.create(this, incoming, this._def);
12189
- }
12190
- transform(transform) {
12191
- return new ZodEffects2({
12192
- ...processCreateParams2(this._def),
12193
- schema: this,
12194
- typeName: ZodFirstPartyTypeKind2.ZodEffects,
12195
- effect: { type: "transform", transform }
12196
- });
12197
- }
12198
- default(def) {
12199
- const defaultValueFunc = typeof def === "function" ? def : () => def;
12200
- return new ZodDefault2({
12201
- ...processCreateParams2(this._def),
12202
- innerType: this,
12203
- defaultValue: defaultValueFunc,
12204
- typeName: ZodFirstPartyTypeKind2.ZodDefault
12205
- });
12206
- }
12207
- brand() {
12208
- return new ZodBranded2({
12209
- typeName: ZodFirstPartyTypeKind2.ZodBranded,
12210
- type: this,
12211
- ...processCreateParams2(this._def)
12212
- });
12213
- }
12214
- catch(def) {
12215
- const catchValueFunc = typeof def === "function" ? def : () => def;
12216
- return new ZodCatch2({
12217
- ...processCreateParams2(this._def),
12218
- innerType: this,
12219
- catchValue: catchValueFunc,
12220
- typeName: ZodFirstPartyTypeKind2.ZodCatch
12221
- });
12222
- }
12223
- describe(description) {
12224
- const This = this.constructor;
12225
- return new This({
12226
- ...this._def,
12227
- description
12228
- });
12229
- }
12230
- pipe(target) {
12231
- return ZodPipeline2.create(this, target);
12232
- }
12233
- readonly() {
12234
- return ZodReadonly2.create(this);
12235
- }
12236
- isOptional() {
12237
- return this.safeParse(undefined).success;
12238
- }
12239
- isNullable() {
12240
- return this.safeParse(null).success;
12241
- }
12242
- }
12243
- var cuidRegex2 = /^c[^\s-]{8,}$/i;
12244
- var cuid2Regex2 = /^[0-9a-z]+$/;
12245
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
12246
- 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;
12247
- var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
12248
- var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
12249
- 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)?)??$/;
12250
- var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
12251
- var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
12252
- var emojiRegex2;
12253
- 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])$/;
12254
- 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])$/;
12255
- 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]))$/;
12256
- 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])$/;
12257
- var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
12258
- var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
12259
- 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])))`;
12260
- var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
12261
- function timeRegexSource2(args) {
12262
- let secondsRegexSource = `[0-5]\\d`;
12263
- if (args.precision) {
12264
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
12265
- } else if (args.precision == null) {
12266
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
12267
- }
12268
- const secondsQuantifier = args.precision ? "+" : "?";
12269
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
12270
- }
12271
- function timeRegex2(args) {
12272
- return new RegExp(`^${timeRegexSource2(args)}$`);
12273
- }
12274
- function datetimeRegex2(args) {
12275
- let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
12276
- const opts = [];
12277
- opts.push(args.local ? `Z?` : `Z`);
12278
- if (args.offset)
12279
- opts.push(`([+-]\\d{2}:?\\d{2})`);
12280
- regex = `${regex}(${opts.join("|")})`;
12281
- return new RegExp(`^${regex}$`);
12282
- }
12283
- function isValidIP2(ip, version) {
12284
- if ((version === "v4" || !version) && ipv4Regex2.test(ip)) {
12285
- return true;
12286
- }
12287
- if ((version === "v6" || !version) && ipv6Regex2.test(ip)) {
12288
- return true;
12289
- }
12290
- return false;
12291
- }
12292
- function isValidJWT2(jwt, alg) {
12293
- if (!jwtRegex2.test(jwt))
12294
- return false;
12295
- try {
12296
- const [header] = jwt.split(".");
12297
- if (!header)
12298
- return false;
12299
- const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
12300
- const decoded = JSON.parse(atob(base64));
12301
- if (typeof decoded !== "object" || decoded === null)
12302
- return false;
12303
- if ("typ" in decoded && decoded?.typ !== "JWT")
12304
- return false;
12305
- if (!decoded.alg)
12306
- return false;
12307
- if (alg && decoded.alg !== alg)
12308
- return false;
12309
- return true;
12310
- } catch {
12311
- return false;
12312
- }
12313
- }
12314
- function isValidCidr2(ip, version) {
12315
- if ((version === "v4" || !version) && ipv4CidrRegex2.test(ip)) {
12316
- return true;
12317
- }
12318
- if ((version === "v6" || !version) && ipv6CidrRegex2.test(ip)) {
12319
- return true;
12320
- }
12321
- return false;
12322
- }
12323
-
12324
- class ZodString2 extends ZodType2 {
12325
- _parse(input) {
12326
- if (this._def.coerce) {
12327
- input.data = String(input.data);
12328
- }
12329
- const parsedType = this._getType(input);
12330
- if (parsedType !== ZodParsedType2.string) {
12331
- const ctx2 = this._getOrReturnCtx(input);
12332
- addIssueToContext2(ctx2, {
12333
- code: ZodIssueCode2.invalid_type,
12334
- expected: ZodParsedType2.string,
12335
- received: ctx2.parsedType
12336
- });
12337
- return INVALID2;
12338
- }
12339
- const status = new ParseStatus2;
12340
- let ctx = undefined;
12341
- for (const check of this._def.checks) {
12342
- if (check.kind === "min") {
12343
- if (input.data.length < check.value) {
12344
- ctx = this._getOrReturnCtx(input, ctx);
12345
- addIssueToContext2(ctx, {
12346
- code: ZodIssueCode2.too_small,
12347
- minimum: check.value,
12348
- type: "string",
12349
- inclusive: true,
12350
- exact: false,
12351
- message: check.message
12352
- });
12353
- status.dirty();
12354
- }
12355
- } else if (check.kind === "max") {
12356
- if (input.data.length > check.value) {
12357
- ctx = this._getOrReturnCtx(input, ctx);
12358
- addIssueToContext2(ctx, {
12359
- code: ZodIssueCode2.too_big,
12360
- maximum: check.value,
12361
- type: "string",
12362
- inclusive: true,
12363
- exact: false,
12364
- message: check.message
12365
- });
12366
- status.dirty();
12367
- }
12368
- } else if (check.kind === "length") {
12369
- const tooBig = input.data.length > check.value;
12370
- const tooSmall = input.data.length < check.value;
12371
- if (tooBig || tooSmall) {
12372
- ctx = this._getOrReturnCtx(input, ctx);
12373
- if (tooBig) {
12374
- addIssueToContext2(ctx, {
12375
- code: ZodIssueCode2.too_big,
12376
- maximum: check.value,
12377
- type: "string",
12378
- inclusive: true,
12379
- exact: true,
12380
- message: check.message
12381
- });
12382
- } else if (tooSmall) {
12383
- addIssueToContext2(ctx, {
12384
- code: ZodIssueCode2.too_small,
12385
- minimum: check.value,
12386
- type: "string",
12387
- inclusive: true,
12388
- exact: true,
12389
- message: check.message
12390
- });
12391
- }
12392
- status.dirty();
12393
- }
12394
- } else if (check.kind === "email") {
12395
- if (!emailRegex2.test(input.data)) {
12396
- ctx = this._getOrReturnCtx(input, ctx);
12397
- addIssueToContext2(ctx, {
12398
- validation: "email",
12399
- code: ZodIssueCode2.invalid_string,
12400
- message: check.message
12401
- });
12402
- status.dirty();
12403
- }
12404
- } else if (check.kind === "emoji") {
12405
- if (!emojiRegex2) {
12406
- emojiRegex2 = new RegExp(_emojiRegex2, "u");
12407
- }
12408
- if (!emojiRegex2.test(input.data)) {
12409
- ctx = this._getOrReturnCtx(input, ctx);
12410
- addIssueToContext2(ctx, {
12411
- validation: "emoji",
12412
- code: ZodIssueCode2.invalid_string,
12413
- message: check.message
12414
- });
12415
- status.dirty();
12416
- }
12417
- } else if (check.kind === "uuid") {
12418
- if (!uuidRegex2.test(input.data)) {
12419
- ctx = this._getOrReturnCtx(input, ctx);
12420
- addIssueToContext2(ctx, {
12421
- validation: "uuid",
12422
- code: ZodIssueCode2.invalid_string,
12423
- message: check.message
12424
- });
12425
- status.dirty();
12426
- }
12427
- } else if (check.kind === "nanoid") {
12428
- if (!nanoidRegex2.test(input.data)) {
12429
- ctx = this._getOrReturnCtx(input, ctx);
12430
- addIssueToContext2(ctx, {
12431
- validation: "nanoid",
12432
- code: ZodIssueCode2.invalid_string,
12433
- message: check.message
12434
- });
12435
- status.dirty();
12436
- }
12437
- } else if (check.kind === "cuid") {
12438
- if (!cuidRegex2.test(input.data)) {
12439
- ctx = this._getOrReturnCtx(input, ctx);
12440
- addIssueToContext2(ctx, {
12441
- validation: "cuid",
12442
- code: ZodIssueCode2.invalid_string,
12443
- message: check.message
12444
- });
12445
- status.dirty();
12446
- }
12447
- } else if (check.kind === "cuid2") {
12448
- if (!cuid2Regex2.test(input.data)) {
12449
- ctx = this._getOrReturnCtx(input, ctx);
12450
- addIssueToContext2(ctx, {
12451
- validation: "cuid2",
12452
- code: ZodIssueCode2.invalid_string,
12453
- message: check.message
12454
- });
12455
- status.dirty();
12456
- }
12457
- } else if (check.kind === "ulid") {
12458
- if (!ulidRegex2.test(input.data)) {
12459
- ctx = this._getOrReturnCtx(input, ctx);
12460
- addIssueToContext2(ctx, {
12461
- validation: "ulid",
12462
- code: ZodIssueCode2.invalid_string,
12463
- message: check.message
12464
- });
12465
- status.dirty();
12466
- }
12467
- } else if (check.kind === "url") {
12468
- try {
12469
- new URL(input.data);
12470
- } catch {
12471
- ctx = this._getOrReturnCtx(input, ctx);
12472
- addIssueToContext2(ctx, {
12473
- validation: "url",
12474
- code: ZodIssueCode2.invalid_string,
12475
- message: check.message
12476
- });
12477
- status.dirty();
12478
- }
12479
- } else if (check.kind === "regex") {
12480
- check.regex.lastIndex = 0;
12481
- const testResult = check.regex.test(input.data);
12482
- if (!testResult) {
12483
- ctx = this._getOrReturnCtx(input, ctx);
12484
- addIssueToContext2(ctx, {
12485
- validation: "regex",
12486
- code: ZodIssueCode2.invalid_string,
12487
- message: check.message
12488
- });
12489
- status.dirty();
12490
- }
12491
- } else if (check.kind === "trim") {
12492
- input.data = input.data.trim();
12493
- } else if (check.kind === "includes") {
12494
- if (!input.data.includes(check.value, check.position)) {
12495
- ctx = this._getOrReturnCtx(input, ctx);
12496
- addIssueToContext2(ctx, {
12497
- code: ZodIssueCode2.invalid_string,
12498
- validation: { includes: check.value, position: check.position },
12499
- message: check.message
12500
- });
12501
- status.dirty();
12502
- }
12503
- } else if (check.kind === "toLowerCase") {
12504
- input.data = input.data.toLowerCase();
12505
- } else if (check.kind === "toUpperCase") {
12506
- input.data = input.data.toUpperCase();
12507
- } else if (check.kind === "startsWith") {
12508
- if (!input.data.startsWith(check.value)) {
12509
- ctx = this._getOrReturnCtx(input, ctx);
12510
- addIssueToContext2(ctx, {
12511
- code: ZodIssueCode2.invalid_string,
12512
- validation: { startsWith: check.value },
12513
- message: check.message
12514
- });
12515
- status.dirty();
12516
- }
12517
- } else if (check.kind === "endsWith") {
12518
- if (!input.data.endsWith(check.value)) {
12519
- ctx = this._getOrReturnCtx(input, ctx);
12520
- addIssueToContext2(ctx, {
12521
- code: ZodIssueCode2.invalid_string,
12522
- validation: { endsWith: check.value },
12523
- message: check.message
12524
- });
12525
- status.dirty();
12526
- }
12527
- } else if (check.kind === "datetime") {
12528
- const regex = datetimeRegex2(check);
12529
- if (!regex.test(input.data)) {
12530
- ctx = this._getOrReturnCtx(input, ctx);
12531
- addIssueToContext2(ctx, {
12532
- code: ZodIssueCode2.invalid_string,
12533
- validation: "datetime",
12534
- message: check.message
12535
- });
12536
- status.dirty();
12537
- }
12538
- } else if (check.kind === "date") {
12539
- const regex = dateRegex2;
12540
- if (!regex.test(input.data)) {
12541
- ctx = this._getOrReturnCtx(input, ctx);
12542
- addIssueToContext2(ctx, {
12543
- code: ZodIssueCode2.invalid_string,
12544
- validation: "date",
12545
- message: check.message
12546
- });
12547
- status.dirty();
12548
- }
12549
- } else if (check.kind === "time") {
12550
- const regex = timeRegex2(check);
12551
- if (!regex.test(input.data)) {
12552
- ctx = this._getOrReturnCtx(input, ctx);
12553
- addIssueToContext2(ctx, {
12554
- code: ZodIssueCode2.invalid_string,
12555
- validation: "time",
12556
- message: check.message
12557
- });
12558
- status.dirty();
12559
- }
12560
- } else if (check.kind === "duration") {
12561
- if (!durationRegex2.test(input.data)) {
12562
- ctx = this._getOrReturnCtx(input, ctx);
12563
- addIssueToContext2(ctx, {
12564
- validation: "duration",
12565
- code: ZodIssueCode2.invalid_string,
12566
- message: check.message
12567
- });
12568
- status.dirty();
12569
- }
12570
- } else if (check.kind === "ip") {
12571
- if (!isValidIP2(input.data, check.version)) {
12572
- ctx = this._getOrReturnCtx(input, ctx);
12573
- addIssueToContext2(ctx, {
12574
- validation: "ip",
12575
- code: ZodIssueCode2.invalid_string,
12576
- message: check.message
12577
- });
12578
- status.dirty();
12579
- }
12580
- } else if (check.kind === "jwt") {
12581
- if (!isValidJWT2(input.data, check.alg)) {
12582
- ctx = this._getOrReturnCtx(input, ctx);
12583
- addIssueToContext2(ctx, {
12584
- validation: "jwt",
12585
- code: ZodIssueCode2.invalid_string,
12586
- message: check.message
12587
- });
12588
- status.dirty();
12589
- }
12590
- } else if (check.kind === "cidr") {
12591
- if (!isValidCidr2(input.data, check.version)) {
12592
- ctx = this._getOrReturnCtx(input, ctx);
12593
- addIssueToContext2(ctx, {
12594
- validation: "cidr",
12595
- code: ZodIssueCode2.invalid_string,
12596
- message: check.message
12597
- });
12598
- status.dirty();
12599
- }
12600
- } else if (check.kind === "base64") {
12601
- if (!base64Regex2.test(input.data)) {
12602
- ctx = this._getOrReturnCtx(input, ctx);
12603
- addIssueToContext2(ctx, {
12604
- validation: "base64",
12605
- code: ZodIssueCode2.invalid_string,
12606
- message: check.message
12607
- });
12608
- status.dirty();
12609
- }
12610
- } else if (check.kind === "base64url") {
12611
- if (!base64urlRegex2.test(input.data)) {
12612
- ctx = this._getOrReturnCtx(input, ctx);
12613
- addIssueToContext2(ctx, {
12614
- validation: "base64url",
12615
- code: ZodIssueCode2.invalid_string,
12616
- message: check.message
12617
- });
12618
- status.dirty();
12619
- }
12620
- } else {
12621
- util3.assertNever(check);
12622
- }
12623
- }
12624
- return { status: status.value, value: input.data };
12625
- }
12626
- _regex(regex, validation, message) {
12627
- return this.refinement((data) => regex.test(data), {
12628
- validation,
12629
- code: ZodIssueCode2.invalid_string,
12630
- ...errorUtil2.errToObj(message)
12631
- });
12632
- }
12633
- _addCheck(check) {
12634
- return new ZodString2({
12635
- ...this._def,
12636
- checks: [...this._def.checks, check]
12637
- });
12638
- }
12639
- email(message) {
12640
- return this._addCheck({ kind: "email", ...errorUtil2.errToObj(message) });
12641
- }
12642
- url(message) {
12643
- return this._addCheck({ kind: "url", ...errorUtil2.errToObj(message) });
12644
- }
12645
- emoji(message) {
12646
- return this._addCheck({ kind: "emoji", ...errorUtil2.errToObj(message) });
12647
- }
12648
- uuid(message) {
12649
- return this._addCheck({ kind: "uuid", ...errorUtil2.errToObj(message) });
12650
- }
12651
- nanoid(message) {
12652
- return this._addCheck({ kind: "nanoid", ...errorUtil2.errToObj(message) });
12653
- }
12654
- cuid(message) {
12655
- return this._addCheck({ kind: "cuid", ...errorUtil2.errToObj(message) });
12656
- }
12657
- cuid2(message) {
12658
- return this._addCheck({ kind: "cuid2", ...errorUtil2.errToObj(message) });
12659
- }
12660
- ulid(message) {
12661
- return this._addCheck({ kind: "ulid", ...errorUtil2.errToObj(message) });
12662
- }
12663
- base64(message) {
12664
- return this._addCheck({ kind: "base64", ...errorUtil2.errToObj(message) });
12665
- }
12666
- base64url(message) {
12667
- return this._addCheck({
12668
- kind: "base64url",
12669
- ...errorUtil2.errToObj(message)
12670
- });
12671
- }
12672
- jwt(options) {
12673
- return this._addCheck({ kind: "jwt", ...errorUtil2.errToObj(options) });
12674
- }
12675
- ip(options) {
12676
- return this._addCheck({ kind: "ip", ...errorUtil2.errToObj(options) });
12677
- }
12678
- cidr(options) {
12679
- return this._addCheck({ kind: "cidr", ...errorUtil2.errToObj(options) });
12680
- }
12681
- datetime(options) {
12682
- if (typeof options === "string") {
12683
- return this._addCheck({
12684
- kind: "datetime",
12685
- precision: null,
12686
- offset: false,
12687
- local: false,
12688
- message: options
12689
- });
12690
- }
12691
- return this._addCheck({
12692
- kind: "datetime",
12693
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
12694
- offset: options?.offset ?? false,
12695
- local: options?.local ?? false,
12696
- ...errorUtil2.errToObj(options?.message)
12697
- });
12698
- }
12699
- date(message) {
12700
- return this._addCheck({ kind: "date", message });
12701
- }
12702
- time(options) {
12703
- if (typeof options === "string") {
12704
- return this._addCheck({
12705
- kind: "time",
12706
- precision: null,
12707
- message: options
12708
- });
12709
- }
12710
- return this._addCheck({
12711
- kind: "time",
12712
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
12713
- ...errorUtil2.errToObj(options?.message)
12714
- });
12715
- }
12716
- duration(message) {
12717
- return this._addCheck({ kind: "duration", ...errorUtil2.errToObj(message) });
12718
- }
12719
- regex(regex, message) {
12720
- return this._addCheck({
12721
- kind: "regex",
12722
- regex,
12723
- ...errorUtil2.errToObj(message)
12724
- });
12725
- }
12726
- includes(value, options) {
12727
- return this._addCheck({
12728
- kind: "includes",
12729
- value,
12730
- position: options?.position,
12731
- ...errorUtil2.errToObj(options?.message)
12732
- });
12733
- }
12734
- startsWith(value, message) {
12735
- return this._addCheck({
12736
- kind: "startsWith",
12737
- value,
12738
- ...errorUtil2.errToObj(message)
12739
- });
12740
- }
12741
- endsWith(value, message) {
12742
- return this._addCheck({
12743
- kind: "endsWith",
12744
- value,
12745
- ...errorUtil2.errToObj(message)
12746
- });
12747
- }
12748
- min(minLength, message) {
12749
- return this._addCheck({
12750
- kind: "min",
12751
- value: minLength,
12752
- ...errorUtil2.errToObj(message)
12753
- });
12754
- }
12755
- max(maxLength, message) {
12756
- return this._addCheck({
12757
- kind: "max",
12758
- value: maxLength,
12759
- ...errorUtil2.errToObj(message)
12760
- });
12761
- }
12762
- length(len, message) {
12763
- return this._addCheck({
12764
- kind: "length",
12765
- value: len,
12766
- ...errorUtil2.errToObj(message)
12767
- });
12768
- }
12769
- nonempty(message) {
12770
- return this.min(1, errorUtil2.errToObj(message));
12771
- }
12772
- trim() {
12773
- return new ZodString2({
12774
- ...this._def,
12775
- checks: [...this._def.checks, { kind: "trim" }]
12776
- });
12777
- }
12778
- toLowerCase() {
12779
- return new ZodString2({
12780
- ...this._def,
12781
- checks: [...this._def.checks, { kind: "toLowerCase" }]
12782
- });
12783
- }
12784
- toUpperCase() {
12785
- return new ZodString2({
12786
- ...this._def,
12787
- checks: [...this._def.checks, { kind: "toUpperCase" }]
12788
- });
12789
- }
12790
- get isDatetime() {
12791
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
12792
- }
12793
- get isDate() {
12794
- return !!this._def.checks.find((ch) => ch.kind === "date");
12795
- }
12796
- get isTime() {
12797
- return !!this._def.checks.find((ch) => ch.kind === "time");
12798
- }
12799
- get isDuration() {
12800
- return !!this._def.checks.find((ch) => ch.kind === "duration");
12801
- }
12802
- get isEmail() {
12803
- return !!this._def.checks.find((ch) => ch.kind === "email");
12804
- }
12805
- get isURL() {
12806
- return !!this._def.checks.find((ch) => ch.kind === "url");
12807
- }
12808
- get isEmoji() {
12809
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
12810
- }
12811
- get isUUID() {
12812
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
12813
- }
12814
- get isNANOID() {
12815
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
12816
- }
12817
- get isCUID() {
12818
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
12819
- }
12820
- get isCUID2() {
12821
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
12822
- }
12823
- get isULID() {
12824
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
12825
- }
12826
- get isIP() {
12827
- return !!this._def.checks.find((ch) => ch.kind === "ip");
12828
- }
12829
- get isCIDR() {
12830
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
12831
- }
12832
- get isBase64() {
12833
- return !!this._def.checks.find((ch) => ch.kind === "base64");
12834
- }
12835
- get isBase64url() {
12836
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
12837
- }
12838
- get minLength() {
12839
- let min = null;
12840
- for (const ch of this._def.checks) {
12841
- if (ch.kind === "min") {
12842
- if (min === null || ch.value > min)
12843
- min = ch.value;
12844
- }
12845
- }
12846
- return min;
12847
- }
12848
- get maxLength() {
12849
- let max = null;
12850
- for (const ch of this._def.checks) {
12851
- if (ch.kind === "max") {
12852
- if (max === null || ch.value < max)
12853
- max = ch.value;
12854
- }
12855
- }
12856
- return max;
12857
- }
12858
- }
12859
- ZodString2.create = (params) => {
12860
- return new ZodString2({
12861
- checks: [],
12862
- typeName: ZodFirstPartyTypeKind2.ZodString,
12863
- coerce: params?.coerce ?? false,
12864
- ...processCreateParams2(params)
12865
- });
12866
- };
12867
- function floatSafeRemainder2(val, step) {
12868
- const valDecCount = (val.toString().split(".")[1] || "").length;
12869
- const stepDecCount = (step.toString().split(".")[1] || "").length;
12870
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
12871
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
12872
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
12873
- return valInt % stepInt / 10 ** decCount;
12874
- }
12875
-
12876
- class ZodNumber2 extends ZodType2 {
12877
- constructor() {
12878
- super(...arguments);
12879
- this.min = this.gte;
12880
- this.max = this.lte;
12881
- this.step = this.multipleOf;
12882
- }
12883
- _parse(input) {
12884
- if (this._def.coerce) {
12885
- input.data = Number(input.data);
12886
- }
12887
- const parsedType = this._getType(input);
12888
- if (parsedType !== ZodParsedType2.number) {
12889
- const ctx2 = this._getOrReturnCtx(input);
12890
- addIssueToContext2(ctx2, {
12891
- code: ZodIssueCode2.invalid_type,
12892
- expected: ZodParsedType2.number,
12893
- received: ctx2.parsedType
12894
- });
12895
- return INVALID2;
12896
- }
12897
- let ctx = undefined;
12898
- const status = new ParseStatus2;
12899
- for (const check of this._def.checks) {
12900
- if (check.kind === "int") {
12901
- if (!util3.isInteger(input.data)) {
12902
- ctx = this._getOrReturnCtx(input, ctx);
12903
- addIssueToContext2(ctx, {
12904
- code: ZodIssueCode2.invalid_type,
12905
- expected: "integer",
12906
- received: "float",
12907
- message: check.message
12908
- });
12909
- status.dirty();
12910
- }
12911
- } else if (check.kind === "min") {
12912
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
12913
- if (tooSmall) {
12914
- ctx = this._getOrReturnCtx(input, ctx);
12915
- addIssueToContext2(ctx, {
12916
- code: ZodIssueCode2.too_small,
12917
- minimum: check.value,
12918
- type: "number",
12919
- inclusive: check.inclusive,
12920
- exact: false,
12921
- message: check.message
12922
- });
12923
- status.dirty();
12924
- }
12925
- } else if (check.kind === "max") {
12926
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
12927
- if (tooBig) {
12928
- ctx = this._getOrReturnCtx(input, ctx);
12929
- addIssueToContext2(ctx, {
12930
- code: ZodIssueCode2.too_big,
12931
- maximum: check.value,
12932
- type: "number",
12933
- inclusive: check.inclusive,
12934
- exact: false,
12935
- message: check.message
12936
- });
12937
- status.dirty();
12938
- }
12939
- } else if (check.kind === "multipleOf") {
12940
- if (floatSafeRemainder2(input.data, check.value) !== 0) {
12941
- ctx = this._getOrReturnCtx(input, ctx);
12942
- addIssueToContext2(ctx, {
12943
- code: ZodIssueCode2.not_multiple_of,
12944
- multipleOf: check.value,
12945
- message: check.message
12946
- });
12947
- status.dirty();
12948
- }
12949
- } else if (check.kind === "finite") {
12950
- if (!Number.isFinite(input.data)) {
12951
- ctx = this._getOrReturnCtx(input, ctx);
12952
- addIssueToContext2(ctx, {
12953
- code: ZodIssueCode2.not_finite,
12954
- message: check.message
12955
- });
12956
- status.dirty();
12957
- }
12958
- } else {
12959
- util3.assertNever(check);
12960
- }
12961
- }
12962
- return { status: status.value, value: input.data };
12963
- }
12964
- gte(value, message) {
12965
- return this.setLimit("min", value, true, errorUtil2.toString(message));
12966
- }
12967
- gt(value, message) {
12968
- return this.setLimit("min", value, false, errorUtil2.toString(message));
12969
- }
12970
- lte(value, message) {
12971
- return this.setLimit("max", value, true, errorUtil2.toString(message));
12972
- }
12973
- lt(value, message) {
12974
- return this.setLimit("max", value, false, errorUtil2.toString(message));
12975
- }
12976
- setLimit(kind, value, inclusive, message) {
12977
- return new ZodNumber2({
12978
- ...this._def,
12979
- checks: [
12980
- ...this._def.checks,
12981
- {
12982
- kind,
12983
- value,
12984
- inclusive,
12985
- message: errorUtil2.toString(message)
12986
- }
12987
- ]
12988
- });
12989
- }
12990
- _addCheck(check) {
12991
- return new ZodNumber2({
12992
- ...this._def,
12993
- checks: [...this._def.checks, check]
12994
- });
12995
- }
12996
- int(message) {
12997
- return this._addCheck({
12998
- kind: "int",
12999
- message: errorUtil2.toString(message)
13000
- });
13001
- }
13002
- positive(message) {
13003
- return this._addCheck({
13004
- kind: "min",
13005
- value: 0,
13006
- inclusive: false,
13007
- message: errorUtil2.toString(message)
13008
- });
13009
- }
13010
- negative(message) {
13011
- return this._addCheck({
13012
- kind: "max",
13013
- value: 0,
13014
- inclusive: false,
13015
- message: errorUtil2.toString(message)
13016
- });
13017
- }
13018
- nonpositive(message) {
13019
- return this._addCheck({
13020
- kind: "max",
13021
- value: 0,
13022
- inclusive: true,
13023
- message: errorUtil2.toString(message)
13024
- });
13025
- }
13026
- nonnegative(message) {
13027
- return this._addCheck({
13028
- kind: "min",
13029
- value: 0,
13030
- inclusive: true,
13031
- message: errorUtil2.toString(message)
13032
- });
13033
- }
13034
- multipleOf(value, message) {
13035
- return this._addCheck({
13036
- kind: "multipleOf",
13037
- value,
13038
- message: errorUtil2.toString(message)
13039
- });
13040
- }
13041
- finite(message) {
13042
- return this._addCheck({
13043
- kind: "finite",
13044
- message: errorUtil2.toString(message)
13045
- });
13046
- }
13047
- safe(message) {
13048
- return this._addCheck({
13049
- kind: "min",
13050
- inclusive: true,
13051
- value: Number.MIN_SAFE_INTEGER,
13052
- message: errorUtil2.toString(message)
13053
- })._addCheck({
13054
- kind: "max",
13055
- inclusive: true,
13056
- value: Number.MAX_SAFE_INTEGER,
13057
- message: errorUtil2.toString(message)
13058
- });
13059
- }
13060
- get minValue() {
13061
- let min = null;
13062
- for (const ch of this._def.checks) {
13063
- if (ch.kind === "min") {
13064
- if (min === null || ch.value > min)
13065
- min = ch.value;
13066
- }
13067
- }
13068
- return min;
13069
- }
13070
- get maxValue() {
13071
- let max = null;
13072
- for (const ch of this._def.checks) {
13073
- if (ch.kind === "max") {
13074
- if (max === null || ch.value < max)
13075
- max = ch.value;
13076
- }
13077
- }
13078
- return max;
13079
- }
13080
- get isInt() {
13081
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util3.isInteger(ch.value));
13082
- }
13083
- get isFinite() {
13084
- let max = null;
13085
- let min = null;
13086
- for (const ch of this._def.checks) {
13087
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
13088
- return true;
13089
- } else if (ch.kind === "min") {
13090
- if (min === null || ch.value > min)
13091
- min = ch.value;
13092
- } else if (ch.kind === "max") {
13093
- if (max === null || ch.value < max)
13094
- max = ch.value;
13095
- }
13096
- }
13097
- return Number.isFinite(min) && Number.isFinite(max);
13098
- }
13099
- }
13100
- ZodNumber2.create = (params) => {
13101
- return new ZodNumber2({
13102
- checks: [],
13103
- typeName: ZodFirstPartyTypeKind2.ZodNumber,
13104
- coerce: params?.coerce || false,
13105
- ...processCreateParams2(params)
13106
- });
13107
- };
13108
-
13109
- class ZodBigInt2 extends ZodType2 {
13110
- constructor() {
13111
- super(...arguments);
13112
- this.min = this.gte;
13113
- this.max = this.lte;
13114
- }
13115
- _parse(input) {
13116
- if (this._def.coerce) {
13117
- try {
13118
- input.data = BigInt(input.data);
13119
- } catch {
13120
- return this._getInvalidInput(input);
13121
- }
13122
- }
13123
- const parsedType = this._getType(input);
13124
- if (parsedType !== ZodParsedType2.bigint) {
13125
- return this._getInvalidInput(input);
13126
- }
13127
- let ctx = undefined;
13128
- const status = new ParseStatus2;
13129
- for (const check of this._def.checks) {
13130
- if (check.kind === "min") {
13131
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
13132
- if (tooSmall) {
13133
- ctx = this._getOrReturnCtx(input, ctx);
13134
- addIssueToContext2(ctx, {
13135
- code: ZodIssueCode2.too_small,
13136
- type: "bigint",
13137
- minimum: check.value,
13138
- inclusive: check.inclusive,
13139
- message: check.message
13140
- });
13141
- status.dirty();
13142
- }
13143
- } else if (check.kind === "max") {
13144
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
13145
- if (tooBig) {
13146
- ctx = this._getOrReturnCtx(input, ctx);
13147
- addIssueToContext2(ctx, {
13148
- code: ZodIssueCode2.too_big,
13149
- type: "bigint",
13150
- maximum: check.value,
13151
- inclusive: check.inclusive,
13152
- message: check.message
13153
- });
13154
- status.dirty();
13155
- }
13156
- } else if (check.kind === "multipleOf") {
13157
- if (input.data % check.value !== BigInt(0)) {
13158
- ctx = this._getOrReturnCtx(input, ctx);
13159
- addIssueToContext2(ctx, {
13160
- code: ZodIssueCode2.not_multiple_of,
13161
- multipleOf: check.value,
13162
- message: check.message
13163
- });
13164
- status.dirty();
13165
- }
13166
- } else {
13167
- util3.assertNever(check);
13168
- }
13169
- }
13170
- return { status: status.value, value: input.data };
13171
- }
13172
- _getInvalidInput(input) {
13173
- const ctx = this._getOrReturnCtx(input);
13174
- addIssueToContext2(ctx, {
13175
- code: ZodIssueCode2.invalid_type,
13176
- expected: ZodParsedType2.bigint,
13177
- received: ctx.parsedType
13178
- });
13179
- return INVALID2;
13180
- }
13181
- gte(value, message) {
13182
- return this.setLimit("min", value, true, errorUtil2.toString(message));
13183
- }
13184
- gt(value, message) {
13185
- return this.setLimit("min", value, false, errorUtil2.toString(message));
13186
- }
13187
- lte(value, message) {
13188
- return this.setLimit("max", value, true, errorUtil2.toString(message));
13189
- }
13190
- lt(value, message) {
13191
- return this.setLimit("max", value, false, errorUtil2.toString(message));
13192
- }
13193
- setLimit(kind, value, inclusive, message) {
13194
- return new ZodBigInt2({
13195
- ...this._def,
13196
- checks: [
13197
- ...this._def.checks,
13198
- {
13199
- kind,
13200
- value,
13201
- inclusive,
13202
- message: errorUtil2.toString(message)
13203
- }
13204
- ]
13205
- });
13206
- }
13207
- _addCheck(check) {
13208
- return new ZodBigInt2({
13209
- ...this._def,
13210
- checks: [...this._def.checks, check]
13211
- });
13212
- }
13213
- positive(message) {
13214
- return this._addCheck({
13215
- kind: "min",
13216
- value: BigInt(0),
13217
- inclusive: false,
13218
- message: errorUtil2.toString(message)
13219
- });
13220
- }
13221
- negative(message) {
13222
- return this._addCheck({
13223
- kind: "max",
13224
- value: BigInt(0),
13225
- inclusive: false,
13226
- message: errorUtil2.toString(message)
13227
- });
13228
- }
13229
- nonpositive(message) {
13230
- return this._addCheck({
13231
- kind: "max",
13232
- value: BigInt(0),
13233
- inclusive: true,
13234
- message: errorUtil2.toString(message)
13235
- });
13236
- }
13237
- nonnegative(message) {
13238
- return this._addCheck({
13239
- kind: "min",
13240
- value: BigInt(0),
13241
- inclusive: true,
13242
- message: errorUtil2.toString(message)
13243
- });
13244
- }
13245
- multipleOf(value, message) {
13246
- return this._addCheck({
13247
- kind: "multipleOf",
13248
- value,
13249
- message: errorUtil2.toString(message)
13250
- });
13251
- }
13252
- get minValue() {
13253
- let min = null;
13254
- for (const ch of this._def.checks) {
13255
- if (ch.kind === "min") {
13256
- if (min === null || ch.value > min)
13257
- min = ch.value;
13258
- }
13259
- }
13260
- return min;
13261
- }
13262
- get maxValue() {
13263
- let max = null;
13264
- for (const ch of this._def.checks) {
13265
- if (ch.kind === "max") {
13266
- if (max === null || ch.value < max)
13267
- max = ch.value;
13268
- }
13269
- }
13270
- return max;
13271
- }
13272
- }
13273
- ZodBigInt2.create = (params) => {
13274
- return new ZodBigInt2({
13275
- checks: [],
13276
- typeName: ZodFirstPartyTypeKind2.ZodBigInt,
13277
- coerce: params?.coerce ?? false,
13278
- ...processCreateParams2(params)
13279
- });
13280
- };
13281
-
13282
- class ZodBoolean2 extends ZodType2 {
13283
- _parse(input) {
13284
- if (this._def.coerce) {
13285
- input.data = Boolean(input.data);
13286
- }
13287
- const parsedType = this._getType(input);
13288
- if (parsedType !== ZodParsedType2.boolean) {
13289
- const ctx = this._getOrReturnCtx(input);
13290
- addIssueToContext2(ctx, {
13291
- code: ZodIssueCode2.invalid_type,
13292
- expected: ZodParsedType2.boolean,
13293
- received: ctx.parsedType
13294
- });
13295
- return INVALID2;
13296
- }
13297
- return OK2(input.data);
13298
- }
13299
- }
13300
- ZodBoolean2.create = (params) => {
13301
- return new ZodBoolean2({
13302
- typeName: ZodFirstPartyTypeKind2.ZodBoolean,
13303
- coerce: params?.coerce || false,
13304
- ...processCreateParams2(params)
13305
- });
13306
- };
13307
-
13308
- class ZodDate2 extends ZodType2 {
13309
- _parse(input) {
13310
- if (this._def.coerce) {
13311
- input.data = new Date(input.data);
13312
- }
13313
- const parsedType = this._getType(input);
13314
- if (parsedType !== ZodParsedType2.date) {
13315
- const ctx2 = this._getOrReturnCtx(input);
13316
- addIssueToContext2(ctx2, {
13317
- code: ZodIssueCode2.invalid_type,
13318
- expected: ZodParsedType2.date,
13319
- received: ctx2.parsedType
13320
- });
13321
- return INVALID2;
13322
- }
13323
- if (Number.isNaN(input.data.getTime())) {
13324
- const ctx2 = this._getOrReturnCtx(input);
13325
- addIssueToContext2(ctx2, {
13326
- code: ZodIssueCode2.invalid_date
13327
- });
13328
- return INVALID2;
13329
- }
13330
- const status = new ParseStatus2;
13331
- let ctx = undefined;
13332
- for (const check of this._def.checks) {
13333
- if (check.kind === "min") {
13334
- if (input.data.getTime() < check.value) {
13335
- ctx = this._getOrReturnCtx(input, ctx);
13336
- addIssueToContext2(ctx, {
13337
- code: ZodIssueCode2.too_small,
13338
- message: check.message,
13339
- inclusive: true,
13340
- exact: false,
13341
- minimum: check.value,
13342
- type: "date"
13343
- });
13344
- status.dirty();
13345
- }
13346
- } else if (check.kind === "max") {
13347
- if (input.data.getTime() > check.value) {
13348
- ctx = this._getOrReturnCtx(input, ctx);
13349
- addIssueToContext2(ctx, {
13350
- code: ZodIssueCode2.too_big,
13351
- message: check.message,
13352
- inclusive: true,
13353
- exact: false,
13354
- maximum: check.value,
13355
- type: "date"
13356
- });
13357
- status.dirty();
13358
- }
13359
- } else {
13360
- util3.assertNever(check);
13361
- }
13362
- }
13363
- return {
13364
- status: status.value,
13365
- value: new Date(input.data.getTime())
13366
- };
13367
- }
13368
- _addCheck(check) {
13369
- return new ZodDate2({
13370
- ...this._def,
13371
- checks: [...this._def.checks, check]
13372
- });
13373
- }
13374
- min(minDate, message) {
13375
- return this._addCheck({
13376
- kind: "min",
13377
- value: minDate.getTime(),
13378
- message: errorUtil2.toString(message)
13379
- });
13380
- }
13381
- max(maxDate, message) {
13382
- return this._addCheck({
13383
- kind: "max",
13384
- value: maxDate.getTime(),
13385
- message: errorUtil2.toString(message)
13386
- });
13387
- }
13388
- get minDate() {
13389
- let min = null;
13390
- for (const ch of this._def.checks) {
13391
- if (ch.kind === "min") {
13392
- if (min === null || ch.value > min)
13393
- min = ch.value;
13394
- }
13395
- }
13396
- return min != null ? new Date(min) : null;
13397
- }
13398
- get maxDate() {
13399
- let max = null;
13400
- for (const ch of this._def.checks) {
13401
- if (ch.kind === "max") {
13402
- if (max === null || ch.value < max)
13403
- max = ch.value;
13404
- }
13405
- }
13406
- return max != null ? new Date(max) : null;
13407
- }
13408
- }
13409
- ZodDate2.create = (params) => {
13410
- return new ZodDate2({
13411
- checks: [],
13412
- coerce: params?.coerce || false,
13413
- typeName: ZodFirstPartyTypeKind2.ZodDate,
13414
- ...processCreateParams2(params)
13415
- });
13416
- };
13417
-
13418
- class ZodSymbol2 extends ZodType2 {
13419
- _parse(input) {
13420
- const parsedType = this._getType(input);
13421
- if (parsedType !== ZodParsedType2.symbol) {
13422
- const ctx = this._getOrReturnCtx(input);
13423
- addIssueToContext2(ctx, {
13424
- code: ZodIssueCode2.invalid_type,
13425
- expected: ZodParsedType2.symbol,
13426
- received: ctx.parsedType
13427
- });
13428
- return INVALID2;
13429
- }
13430
- return OK2(input.data);
13431
- }
13432
- }
13433
- ZodSymbol2.create = (params) => {
13434
- return new ZodSymbol2({
13435
- typeName: ZodFirstPartyTypeKind2.ZodSymbol,
13436
- ...processCreateParams2(params)
13437
- });
13438
- };
13439
-
13440
- class ZodUndefined2 extends ZodType2 {
13441
- _parse(input) {
13442
- const parsedType = this._getType(input);
13443
- if (parsedType !== ZodParsedType2.undefined) {
13444
- const ctx = this._getOrReturnCtx(input);
13445
- addIssueToContext2(ctx, {
13446
- code: ZodIssueCode2.invalid_type,
13447
- expected: ZodParsedType2.undefined,
13448
- received: ctx.parsedType
13449
- });
13450
- return INVALID2;
13451
- }
13452
- return OK2(input.data);
13453
- }
13454
- }
13455
- ZodUndefined2.create = (params) => {
13456
- return new ZodUndefined2({
13457
- typeName: ZodFirstPartyTypeKind2.ZodUndefined,
13458
- ...processCreateParams2(params)
13459
- });
13460
- };
13461
-
13462
- class ZodNull2 extends ZodType2 {
13463
- _parse(input) {
13464
- const parsedType = this._getType(input);
13465
- if (parsedType !== ZodParsedType2.null) {
13466
- const ctx = this._getOrReturnCtx(input);
13467
- addIssueToContext2(ctx, {
13468
- code: ZodIssueCode2.invalid_type,
13469
- expected: ZodParsedType2.null,
13470
- received: ctx.parsedType
13471
- });
13472
- return INVALID2;
13473
- }
13474
- return OK2(input.data);
13475
- }
13476
- }
13477
- ZodNull2.create = (params) => {
13478
- return new ZodNull2({
13479
- typeName: ZodFirstPartyTypeKind2.ZodNull,
13480
- ...processCreateParams2(params)
13481
- });
13482
- };
13483
-
13484
- class ZodAny2 extends ZodType2 {
13485
- constructor() {
13486
- super(...arguments);
13487
- this._any = true;
13488
- }
13489
- _parse(input) {
13490
- return OK2(input.data);
13491
- }
13492
- }
13493
- ZodAny2.create = (params) => {
13494
- return new ZodAny2({
13495
- typeName: ZodFirstPartyTypeKind2.ZodAny,
13496
- ...processCreateParams2(params)
13497
- });
13498
- };
13499
-
13500
- class ZodUnknown2 extends ZodType2 {
13501
- constructor() {
13502
- super(...arguments);
13503
- this._unknown = true;
13504
- }
13505
- _parse(input) {
13506
- return OK2(input.data);
13507
- }
13508
- }
13509
- ZodUnknown2.create = (params) => {
13510
- return new ZodUnknown2({
13511
- typeName: ZodFirstPartyTypeKind2.ZodUnknown,
13512
- ...processCreateParams2(params)
13513
- });
13514
- };
13515
-
13516
- class ZodNever2 extends ZodType2 {
13517
- _parse(input) {
13518
- const ctx = this._getOrReturnCtx(input);
13519
- addIssueToContext2(ctx, {
13520
- code: ZodIssueCode2.invalid_type,
13521
- expected: ZodParsedType2.never,
13522
- received: ctx.parsedType
13523
- });
13524
- return INVALID2;
13525
- }
13526
- }
13527
- ZodNever2.create = (params) => {
13528
- return new ZodNever2({
13529
- typeName: ZodFirstPartyTypeKind2.ZodNever,
13530
- ...processCreateParams2(params)
13531
- });
13532
- };
13533
-
13534
- class ZodVoid2 extends ZodType2 {
13535
- _parse(input) {
13536
- const parsedType = this._getType(input);
13537
- if (parsedType !== ZodParsedType2.undefined) {
13538
- const ctx = this._getOrReturnCtx(input);
13539
- addIssueToContext2(ctx, {
13540
- code: ZodIssueCode2.invalid_type,
13541
- expected: ZodParsedType2.void,
13542
- received: ctx.parsedType
13543
- });
13544
- return INVALID2;
13545
- }
13546
- return OK2(input.data);
13547
- }
13548
- }
13549
- ZodVoid2.create = (params) => {
13550
- return new ZodVoid2({
13551
- typeName: ZodFirstPartyTypeKind2.ZodVoid,
13552
- ...processCreateParams2(params)
13553
- });
13554
- };
13555
-
13556
- class ZodArray2 extends ZodType2 {
13557
- _parse(input) {
13558
- const { ctx, status } = this._processInputParams(input);
13559
- const def = this._def;
13560
- if (ctx.parsedType !== ZodParsedType2.array) {
13561
- addIssueToContext2(ctx, {
13562
- code: ZodIssueCode2.invalid_type,
13563
- expected: ZodParsedType2.array,
13564
- received: ctx.parsedType
13565
- });
13566
- return INVALID2;
13567
- }
13568
- if (def.exactLength !== null) {
13569
- const tooBig = ctx.data.length > def.exactLength.value;
13570
- const tooSmall = ctx.data.length < def.exactLength.value;
13571
- if (tooBig || tooSmall) {
13572
- addIssueToContext2(ctx, {
13573
- code: tooBig ? ZodIssueCode2.too_big : ZodIssueCode2.too_small,
13574
- minimum: tooSmall ? def.exactLength.value : undefined,
13575
- maximum: tooBig ? def.exactLength.value : undefined,
13576
- type: "array",
13577
- inclusive: true,
13578
- exact: true,
13579
- message: def.exactLength.message
13580
- });
13581
- status.dirty();
13582
- }
13583
- }
13584
- if (def.minLength !== null) {
13585
- if (ctx.data.length < def.minLength.value) {
13586
- addIssueToContext2(ctx, {
13587
- code: ZodIssueCode2.too_small,
13588
- minimum: def.minLength.value,
13589
- type: "array",
13590
- inclusive: true,
13591
- exact: false,
13592
- message: def.minLength.message
13593
- });
13594
- status.dirty();
13595
- }
13596
- }
13597
- if (def.maxLength !== null) {
13598
- if (ctx.data.length > def.maxLength.value) {
13599
- addIssueToContext2(ctx, {
13600
- code: ZodIssueCode2.too_big,
13601
- maximum: def.maxLength.value,
13602
- type: "array",
13603
- inclusive: true,
13604
- exact: false,
13605
- message: def.maxLength.message
13606
- });
13607
- status.dirty();
13608
- }
13609
- }
13610
- if (ctx.common.async) {
13611
- return Promise.all([...ctx.data].map((item, i) => {
13612
- return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
13613
- })).then((result2) => {
13614
- return ParseStatus2.mergeArray(status, result2);
13615
- });
13616
- }
13617
- const result = [...ctx.data].map((item, i) => {
13618
- return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
13619
- });
13620
- return ParseStatus2.mergeArray(status, result);
13621
- }
13622
- get element() {
13623
- return this._def.type;
13624
- }
13625
- min(minLength, message) {
13626
- return new ZodArray2({
13627
- ...this._def,
13628
- minLength: { value: minLength, message: errorUtil2.toString(message) }
13629
- });
13630
- }
13631
- max(maxLength, message) {
13632
- return new ZodArray2({
13633
- ...this._def,
13634
- maxLength: { value: maxLength, message: errorUtil2.toString(message) }
13635
- });
13636
- }
13637
- length(len, message) {
13638
- return new ZodArray2({
13639
- ...this._def,
13640
- exactLength: { value: len, message: errorUtil2.toString(message) }
13641
- });
13642
- }
13643
- nonempty(message) {
13644
- return this.min(1, message);
13645
- }
13646
- }
13647
- ZodArray2.create = (schema, params) => {
13648
- return new ZodArray2({
13649
- type: schema,
13650
- minLength: null,
13651
- maxLength: null,
13652
- exactLength: null,
13653
- typeName: ZodFirstPartyTypeKind2.ZodArray,
13654
- ...processCreateParams2(params)
13655
- });
13656
- };
13657
- function deepPartialify2(schema) {
13658
- if (schema instanceof ZodObject2) {
13659
- const newShape = {};
13660
- for (const key in schema.shape) {
13661
- const fieldSchema = schema.shape[key];
13662
- newShape[key] = ZodOptional2.create(deepPartialify2(fieldSchema));
13663
- }
13664
- return new ZodObject2({
13665
- ...schema._def,
13666
- shape: () => newShape
13667
- });
13668
- } else if (schema instanceof ZodArray2) {
13669
- return new ZodArray2({
13670
- ...schema._def,
13671
- type: deepPartialify2(schema.element)
13672
- });
13673
- } else if (schema instanceof ZodOptional2) {
13674
- return ZodOptional2.create(deepPartialify2(schema.unwrap()));
13675
- } else if (schema instanceof ZodNullable2) {
13676
- return ZodNullable2.create(deepPartialify2(schema.unwrap()));
13677
- } else if (schema instanceof ZodTuple2) {
13678
- return ZodTuple2.create(schema.items.map((item) => deepPartialify2(item)));
13679
- } else {
13680
- return schema;
13681
- }
13682
- }
13683
-
13684
- class ZodObject2 extends ZodType2 {
13685
- constructor() {
13686
- super(...arguments);
13687
- this._cached = null;
13688
- this.nonstrict = this.passthrough;
13689
- this.augment = this.extend;
13690
- }
13691
- _getCached() {
13692
- if (this._cached !== null)
13693
- return this._cached;
13694
- const shape = this._def.shape();
13695
- const keys = util3.objectKeys(shape);
13696
- this._cached = { shape, keys };
13697
- return this._cached;
13698
- }
13699
- _parse(input) {
13700
- const parsedType = this._getType(input);
13701
- if (parsedType !== ZodParsedType2.object) {
13702
- const ctx2 = this._getOrReturnCtx(input);
13703
- addIssueToContext2(ctx2, {
13704
- code: ZodIssueCode2.invalid_type,
13705
- expected: ZodParsedType2.object,
13706
- received: ctx2.parsedType
13707
- });
13708
- return INVALID2;
13709
- }
13710
- const { status, ctx } = this._processInputParams(input);
13711
- const { shape, keys: shapeKeys } = this._getCached();
13712
- const extraKeys = [];
13713
- if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
13714
- for (const key in ctx.data) {
13715
- if (!shapeKeys.includes(key)) {
13716
- extraKeys.push(key);
13717
- }
13718
- }
13719
- }
13720
- const pairs = [];
13721
- for (const key of shapeKeys) {
13722
- const keyValidator = shape[key];
13723
- const value = ctx.data[key];
13724
- pairs.push({
13725
- key: { status: "valid", value: key },
13726
- value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
13727
- alwaysSet: key in ctx.data
13728
- });
13729
- }
13730
- if (this._def.catchall instanceof ZodNever2) {
13731
- const unknownKeys = this._def.unknownKeys;
13732
- if (unknownKeys === "passthrough") {
13733
- for (const key of extraKeys) {
13734
- pairs.push({
13735
- key: { status: "valid", value: key },
13736
- value: { status: "valid", value: ctx.data[key] }
13737
- });
13738
- }
13739
- } else if (unknownKeys === "strict") {
13740
- if (extraKeys.length > 0) {
13741
- addIssueToContext2(ctx, {
13742
- code: ZodIssueCode2.unrecognized_keys,
13743
- keys: extraKeys
13744
- });
13745
- status.dirty();
13746
- }
13747
- } else if (unknownKeys === "strip") {} else {
13748
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
13749
- }
13750
- } else {
13751
- const catchall = this._def.catchall;
13752
- for (const key of extraKeys) {
13753
- const value = ctx.data[key];
13754
- pairs.push({
13755
- key: { status: "valid", value: key },
13756
- value: catchall._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
13757
- alwaysSet: key in ctx.data
13758
- });
13759
- }
13760
- }
13761
- if (ctx.common.async) {
13762
- return Promise.resolve().then(async () => {
13763
- const syncPairs = [];
13764
- for (const pair of pairs) {
13765
- const key = await pair.key;
13766
- const value = await pair.value;
13767
- syncPairs.push({
13768
- key,
13769
- value,
13770
- alwaysSet: pair.alwaysSet
13771
- });
13772
- }
13773
- return syncPairs;
13774
- }).then((syncPairs) => {
13775
- return ParseStatus2.mergeObjectSync(status, syncPairs);
13776
- });
13777
- } else {
13778
- return ParseStatus2.mergeObjectSync(status, pairs);
13779
- }
13780
- }
13781
- get shape() {
13782
- return this._def.shape();
13783
- }
13784
- strict(message) {
13785
- errorUtil2.errToObj;
13786
- return new ZodObject2({
13787
- ...this._def,
13788
- unknownKeys: "strict",
13789
- ...message !== undefined ? {
13790
- errorMap: (issue, ctx) => {
13791
- const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
13792
- if (issue.code === "unrecognized_keys")
13793
- return {
13794
- message: errorUtil2.errToObj(message).message ?? defaultError
13795
- };
13796
- return {
13797
- message: defaultError
13798
- };
13799
- }
13800
- } : {}
13801
- });
13802
- }
13803
- strip() {
13804
- return new ZodObject2({
13805
- ...this._def,
13806
- unknownKeys: "strip"
13807
- });
13808
- }
13809
- passthrough() {
13810
- return new ZodObject2({
13811
- ...this._def,
13812
- unknownKeys: "passthrough"
13813
- });
13814
- }
13815
- extend(augmentation) {
13816
- return new ZodObject2({
13817
- ...this._def,
13818
- shape: () => ({
13819
- ...this._def.shape(),
13820
- ...augmentation
13821
- })
13822
- });
13823
- }
13824
- merge(merging) {
13825
- const merged = new ZodObject2({
13826
- unknownKeys: merging._def.unknownKeys,
13827
- catchall: merging._def.catchall,
13828
- shape: () => ({
13829
- ...this._def.shape(),
13830
- ...merging._def.shape()
13831
- }),
13832
- typeName: ZodFirstPartyTypeKind2.ZodObject
13833
- });
13834
- return merged;
13835
- }
13836
- setKey(key, schema) {
13837
- return this.augment({ [key]: schema });
13838
- }
13839
- catchall(index) {
13840
- return new ZodObject2({
13841
- ...this._def,
13842
- catchall: index
13843
- });
13844
- }
13845
- pick(mask) {
13846
- const shape = {};
13847
- for (const key of util3.objectKeys(mask)) {
13848
- if (mask[key] && this.shape[key]) {
13849
- shape[key] = this.shape[key];
13850
- }
13851
- }
13852
- return new ZodObject2({
13853
- ...this._def,
13854
- shape: () => shape
13855
- });
13856
- }
13857
- omit(mask) {
13858
- const shape = {};
13859
- for (const key of util3.objectKeys(this.shape)) {
13860
- if (!mask[key]) {
13861
- shape[key] = this.shape[key];
13862
- }
13863
- }
13864
- return new ZodObject2({
13865
- ...this._def,
13866
- shape: () => shape
13867
- });
13868
- }
13869
- deepPartial() {
13870
- return deepPartialify2(this);
13871
- }
13872
- partial(mask) {
13873
- const newShape = {};
13874
- for (const key of util3.objectKeys(this.shape)) {
13875
- const fieldSchema = this.shape[key];
13876
- if (mask && !mask[key]) {
13877
- newShape[key] = fieldSchema;
13878
- } else {
13879
- newShape[key] = fieldSchema.optional();
13880
- }
13881
- }
13882
- return new ZodObject2({
13883
- ...this._def,
13884
- shape: () => newShape
13885
- });
13886
- }
13887
- required(mask) {
13888
- const newShape = {};
13889
- for (const key of util3.objectKeys(this.shape)) {
13890
- if (mask && !mask[key]) {
13891
- newShape[key] = this.shape[key];
13892
- } else {
13893
- const fieldSchema = this.shape[key];
13894
- let newField = fieldSchema;
13895
- while (newField instanceof ZodOptional2) {
13896
- newField = newField._def.innerType;
13897
- }
13898
- newShape[key] = newField;
13899
- }
13900
- }
13901
- return new ZodObject2({
13902
- ...this._def,
13903
- shape: () => newShape
13904
- });
13905
- }
13906
- keyof() {
13907
- return createZodEnum2(util3.objectKeys(this.shape));
13908
- }
13909
- }
13910
- ZodObject2.create = (shape, params) => {
13911
- return new ZodObject2({
13912
- shape: () => shape,
13913
- unknownKeys: "strip",
13914
- catchall: ZodNever2.create(),
13915
- typeName: ZodFirstPartyTypeKind2.ZodObject,
13916
- ...processCreateParams2(params)
13917
- });
13918
- };
13919
- ZodObject2.strictCreate = (shape, params) => {
13920
- return new ZodObject2({
13921
- shape: () => shape,
13922
- unknownKeys: "strict",
13923
- catchall: ZodNever2.create(),
13924
- typeName: ZodFirstPartyTypeKind2.ZodObject,
13925
- ...processCreateParams2(params)
13926
- });
13927
- };
13928
- ZodObject2.lazycreate = (shape, params) => {
13929
- return new ZodObject2({
13930
- shape,
13931
- unknownKeys: "strip",
13932
- catchall: ZodNever2.create(),
13933
- typeName: ZodFirstPartyTypeKind2.ZodObject,
13934
- ...processCreateParams2(params)
13935
- });
13936
- };
13937
-
13938
- class ZodUnion2 extends ZodType2 {
13939
- _parse(input) {
13940
- const { ctx } = this._processInputParams(input);
13941
- const options = this._def.options;
13942
- function handleResults(results) {
13943
- for (const result of results) {
13944
- if (result.result.status === "valid") {
13945
- return result.result;
13946
- }
13947
- }
13948
- for (const result of results) {
13949
- if (result.result.status === "dirty") {
13950
- ctx.common.issues.push(...result.ctx.common.issues);
13951
- return result.result;
13952
- }
13953
- }
13954
- const unionErrors = results.map((result) => new ZodError3(result.ctx.common.issues));
13955
- addIssueToContext2(ctx, {
13956
- code: ZodIssueCode2.invalid_union,
13957
- unionErrors
13958
- });
13959
- return INVALID2;
13960
- }
13961
- if (ctx.common.async) {
13962
- return Promise.all(options.map(async (option) => {
13963
- const childCtx = {
13964
- ...ctx,
13965
- common: {
13966
- ...ctx.common,
13967
- issues: []
13968
- },
13969
- parent: null
13970
- };
13971
- return {
13972
- result: await option._parseAsync({
13973
- data: ctx.data,
13974
- path: ctx.path,
13975
- parent: childCtx
13976
- }),
13977
- ctx: childCtx
13978
- };
13979
- })).then(handleResults);
13980
- } else {
13981
- let dirty = undefined;
13982
- const issues = [];
13983
- for (const option of options) {
13984
- const childCtx = {
13985
- ...ctx,
13986
- common: {
13987
- ...ctx.common,
13988
- issues: []
13989
- },
13990
- parent: null
13991
- };
13992
- const result = option._parseSync({
13993
- data: ctx.data,
13994
- path: ctx.path,
13995
- parent: childCtx
13996
- });
13997
- if (result.status === "valid") {
13998
- return result;
13999
- } else if (result.status === "dirty" && !dirty) {
14000
- dirty = { result, ctx: childCtx };
14001
- }
14002
- if (childCtx.common.issues.length) {
14003
- issues.push(childCtx.common.issues);
14004
- }
14005
- }
14006
- if (dirty) {
14007
- ctx.common.issues.push(...dirty.ctx.common.issues);
14008
- return dirty.result;
14009
- }
14010
- const unionErrors = issues.map((issues2) => new ZodError3(issues2));
14011
- addIssueToContext2(ctx, {
14012
- code: ZodIssueCode2.invalid_union,
14013
- unionErrors
14014
- });
14015
- return INVALID2;
14016
- }
14017
- }
14018
- get options() {
14019
- return this._def.options;
14020
- }
14021
- }
14022
- ZodUnion2.create = (types2, params) => {
14023
- return new ZodUnion2({
14024
- options: types2,
14025
- typeName: ZodFirstPartyTypeKind2.ZodUnion,
14026
- ...processCreateParams2(params)
14027
- });
14028
- };
14029
- var getDiscriminator2 = (type) => {
14030
- if (type instanceof ZodLazy2) {
14031
- return getDiscriminator2(type.schema);
14032
- } else if (type instanceof ZodEffects2) {
14033
- return getDiscriminator2(type.innerType());
14034
- } else if (type instanceof ZodLiteral2) {
14035
- return [type.value];
14036
- } else if (type instanceof ZodEnum2) {
14037
- return type.options;
14038
- } else if (type instanceof ZodNativeEnum2) {
14039
- return util3.objectValues(type.enum);
14040
- } else if (type instanceof ZodDefault2) {
14041
- return getDiscriminator2(type._def.innerType);
14042
- } else if (type instanceof ZodUndefined2) {
14043
- return [undefined];
14044
- } else if (type instanceof ZodNull2) {
14045
- return [null];
14046
- } else if (type instanceof ZodOptional2) {
14047
- return [undefined, ...getDiscriminator2(type.unwrap())];
14048
- } else if (type instanceof ZodNullable2) {
14049
- return [null, ...getDiscriminator2(type.unwrap())];
14050
- } else if (type instanceof ZodBranded2) {
14051
- return getDiscriminator2(type.unwrap());
14052
- } else if (type instanceof ZodReadonly2) {
14053
- return getDiscriminator2(type.unwrap());
14054
- } else if (type instanceof ZodCatch2) {
14055
- return getDiscriminator2(type._def.innerType);
14056
- } else {
14057
- return [];
14058
- }
14059
- };
14060
-
14061
- class ZodDiscriminatedUnion2 extends ZodType2 {
14062
- _parse(input) {
14063
- const { ctx } = this._processInputParams(input);
14064
- if (ctx.parsedType !== ZodParsedType2.object) {
14065
- addIssueToContext2(ctx, {
14066
- code: ZodIssueCode2.invalid_type,
14067
- expected: ZodParsedType2.object,
14068
- received: ctx.parsedType
14069
- });
14070
- return INVALID2;
14071
- }
14072
- const discriminator = this.discriminator;
14073
- const discriminatorValue = ctx.data[discriminator];
14074
- const option = this.optionsMap.get(discriminatorValue);
14075
- if (!option) {
14076
- addIssueToContext2(ctx, {
14077
- code: ZodIssueCode2.invalid_union_discriminator,
14078
- options: Array.from(this.optionsMap.keys()),
14079
- path: [discriminator]
14080
- });
14081
- return INVALID2;
14082
- }
14083
- if (ctx.common.async) {
14084
- return option._parseAsync({
14085
- data: ctx.data,
14086
- path: ctx.path,
14087
- parent: ctx
14088
- });
14089
- } else {
14090
- return option._parseSync({
14091
- data: ctx.data,
14092
- path: ctx.path,
14093
- parent: ctx
14094
- });
14095
- }
14096
- }
14097
- get discriminator() {
14098
- return this._def.discriminator;
14099
- }
14100
- get options() {
14101
- return this._def.options;
14102
- }
14103
- get optionsMap() {
14104
- return this._def.optionsMap;
14105
- }
14106
- static create(discriminator, options, params) {
14107
- const optionsMap = new Map;
14108
- for (const type of options) {
14109
- const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
14110
- if (!discriminatorValues.length) {
14111
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
14112
- }
14113
- for (const value of discriminatorValues) {
14114
- if (optionsMap.has(value)) {
14115
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
14116
- }
14117
- optionsMap.set(value, type);
14118
- }
14119
- }
14120
- return new ZodDiscriminatedUnion2({
14121
- typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
14122
- discriminator,
14123
- options,
14124
- optionsMap,
14125
- ...processCreateParams2(params)
14126
- });
14127
- }
14128
- }
14129
- function mergeValues2(a, b) {
14130
- const aType = getParsedType2(a);
14131
- const bType = getParsedType2(b);
14132
- if (a === b) {
14133
- return { valid: true, data: a };
14134
- } else if (aType === ZodParsedType2.object && bType === ZodParsedType2.object) {
14135
- const bKeys = util3.objectKeys(b);
14136
- const sharedKeys = util3.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
14137
- const newObj = { ...a, ...b };
14138
- for (const key of sharedKeys) {
14139
- const sharedValue = mergeValues2(a[key], b[key]);
14140
- if (!sharedValue.valid) {
14141
- return { valid: false };
14142
- }
14143
- newObj[key] = sharedValue.data;
14144
- }
14145
- return { valid: true, data: newObj };
14146
- } else if (aType === ZodParsedType2.array && bType === ZodParsedType2.array) {
14147
- if (a.length !== b.length) {
14148
- return { valid: false };
14149
- }
14150
- const newArray = [];
14151
- for (let index = 0;index < a.length; index++) {
14152
- const itemA = a[index];
14153
- const itemB = b[index];
14154
- const sharedValue = mergeValues2(itemA, itemB);
14155
- if (!sharedValue.valid) {
14156
- return { valid: false };
14157
- }
14158
- newArray.push(sharedValue.data);
14159
- }
14160
- return { valid: true, data: newArray };
14161
- } else if (aType === ZodParsedType2.date && bType === ZodParsedType2.date && +a === +b) {
14162
- return { valid: true, data: a };
14163
- } else {
14164
- return { valid: false };
14165
- }
14166
- }
14167
-
14168
- class ZodIntersection2 extends ZodType2 {
14169
- _parse(input) {
14170
- const { status, ctx } = this._processInputParams(input);
14171
- const handleParsed = (parsedLeft, parsedRight) => {
14172
- if (isAborted2(parsedLeft) || isAborted2(parsedRight)) {
14173
- return INVALID2;
14174
- }
14175
- const merged = mergeValues2(parsedLeft.value, parsedRight.value);
14176
- if (!merged.valid) {
14177
- addIssueToContext2(ctx, {
14178
- code: ZodIssueCode2.invalid_intersection_types
14179
- });
14180
- return INVALID2;
14181
- }
14182
- if (isDirty2(parsedLeft) || isDirty2(parsedRight)) {
14183
- status.dirty();
14184
- }
14185
- return { status: status.value, value: merged.data };
14186
- };
14187
- if (ctx.common.async) {
14188
- return Promise.all([
14189
- this._def.left._parseAsync({
14190
- data: ctx.data,
14191
- path: ctx.path,
14192
- parent: ctx
14193
- }),
14194
- this._def.right._parseAsync({
14195
- data: ctx.data,
14196
- path: ctx.path,
14197
- parent: ctx
14198
- })
14199
- ]).then(([left, right]) => handleParsed(left, right));
14200
- } else {
14201
- return handleParsed(this._def.left._parseSync({
14202
- data: ctx.data,
14203
- path: ctx.path,
14204
- parent: ctx
14205
- }), this._def.right._parseSync({
14206
- data: ctx.data,
14207
- path: ctx.path,
14208
- parent: ctx
14209
- }));
14210
- }
14211
- }
14212
- }
14213
- ZodIntersection2.create = (left, right, params) => {
14214
- return new ZodIntersection2({
14215
- left,
14216
- right,
14217
- typeName: ZodFirstPartyTypeKind2.ZodIntersection,
14218
- ...processCreateParams2(params)
14219
- });
14220
- };
14221
-
14222
- class ZodTuple2 extends ZodType2 {
14223
- _parse(input) {
14224
- const { status, ctx } = this._processInputParams(input);
14225
- if (ctx.parsedType !== ZodParsedType2.array) {
14226
- addIssueToContext2(ctx, {
14227
- code: ZodIssueCode2.invalid_type,
14228
- expected: ZodParsedType2.array,
14229
- received: ctx.parsedType
14230
- });
14231
- return INVALID2;
14232
- }
14233
- if (ctx.data.length < this._def.items.length) {
14234
- addIssueToContext2(ctx, {
14235
- code: ZodIssueCode2.too_small,
14236
- minimum: this._def.items.length,
14237
- inclusive: true,
14238
- exact: false,
14239
- type: "array"
14240
- });
14241
- return INVALID2;
14242
- }
14243
- const rest = this._def.rest;
14244
- if (!rest && ctx.data.length > this._def.items.length) {
14245
- addIssueToContext2(ctx, {
14246
- code: ZodIssueCode2.too_big,
14247
- maximum: this._def.items.length,
14248
- inclusive: true,
14249
- exact: false,
14250
- type: "array"
14251
- });
14252
- status.dirty();
14253
- }
14254
- const items = [...ctx.data].map((item, itemIndex) => {
14255
- const schema = this._def.items[itemIndex] || this._def.rest;
14256
- if (!schema)
14257
- return null;
14258
- return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex));
14259
- }).filter((x) => !!x);
14260
- if (ctx.common.async) {
14261
- return Promise.all(items).then((results) => {
14262
- return ParseStatus2.mergeArray(status, results);
14263
- });
14264
- } else {
14265
- return ParseStatus2.mergeArray(status, items);
14266
- }
14267
- }
14268
- get items() {
14269
- return this._def.items;
14270
- }
14271
- rest(rest) {
14272
- return new ZodTuple2({
14273
- ...this._def,
14274
- rest
14275
- });
14276
- }
14277
- }
14278
- ZodTuple2.create = (schemas, params) => {
14279
- if (!Array.isArray(schemas)) {
14280
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
14281
- }
14282
- return new ZodTuple2({
14283
- items: schemas,
14284
- typeName: ZodFirstPartyTypeKind2.ZodTuple,
14285
- rest: null,
14286
- ...processCreateParams2(params)
14287
- });
14288
- };
14289
-
14290
- class ZodRecord2 extends ZodType2 {
14291
- get keySchema() {
14292
- return this._def.keyType;
14293
- }
14294
- get valueSchema() {
14295
- return this._def.valueType;
14296
- }
14297
- _parse(input) {
14298
- const { status, ctx } = this._processInputParams(input);
14299
- if (ctx.parsedType !== ZodParsedType2.object) {
14300
- addIssueToContext2(ctx, {
14301
- code: ZodIssueCode2.invalid_type,
14302
- expected: ZodParsedType2.object,
14303
- received: ctx.parsedType
14304
- });
14305
- return INVALID2;
14306
- }
14307
- const pairs = [];
14308
- const keyType = this._def.keyType;
14309
- const valueType = this._def.valueType;
14310
- for (const key in ctx.data) {
14311
- pairs.push({
14312
- key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
14313
- value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
14314
- alwaysSet: key in ctx.data
14315
- });
14316
- }
14317
- if (ctx.common.async) {
14318
- return ParseStatus2.mergeObjectAsync(status, pairs);
14319
- } else {
14320
- return ParseStatus2.mergeObjectSync(status, pairs);
14321
- }
14322
- }
14323
- get element() {
14324
- return this._def.valueType;
14325
- }
14326
- static create(first, second, third) {
14327
- if (second instanceof ZodType2) {
14328
- return new ZodRecord2({
14329
- keyType: first,
14330
- valueType: second,
14331
- typeName: ZodFirstPartyTypeKind2.ZodRecord,
14332
- ...processCreateParams2(third)
14333
- });
14334
- }
14335
- return new ZodRecord2({
14336
- keyType: ZodString2.create(),
14337
- valueType: first,
14338
- typeName: ZodFirstPartyTypeKind2.ZodRecord,
14339
- ...processCreateParams2(second)
14340
- });
14341
- }
14342
- }
14343
-
14344
- class ZodMap2 extends ZodType2 {
14345
- get keySchema() {
14346
- return this._def.keyType;
14347
- }
14348
- get valueSchema() {
14349
- return this._def.valueType;
14350
- }
14351
- _parse(input) {
14352
- const { status, ctx } = this._processInputParams(input);
14353
- if (ctx.parsedType !== ZodParsedType2.map) {
14354
- addIssueToContext2(ctx, {
14355
- code: ZodIssueCode2.invalid_type,
14356
- expected: ZodParsedType2.map,
14357
- received: ctx.parsedType
14358
- });
14359
- return INVALID2;
14360
- }
14361
- const keyType = this._def.keyType;
14362
- const valueType = this._def.valueType;
14363
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
14364
- return {
14365
- key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])),
14366
- value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"]))
14367
- };
14368
- });
14369
- if (ctx.common.async) {
14370
- const finalMap = new Map;
14371
- return Promise.resolve().then(async () => {
14372
- for (const pair of pairs) {
14373
- const key = await pair.key;
14374
- const value = await pair.value;
14375
- if (key.status === "aborted" || value.status === "aborted") {
14376
- return INVALID2;
14377
- }
14378
- if (key.status === "dirty" || value.status === "dirty") {
14379
- status.dirty();
14380
- }
14381
- finalMap.set(key.value, value.value);
14382
- }
14383
- return { status: status.value, value: finalMap };
14384
- });
14385
- } else {
14386
- const finalMap = new Map;
14387
- for (const pair of pairs) {
14388
- const key = pair.key;
14389
- const value = pair.value;
14390
- if (key.status === "aborted" || value.status === "aborted") {
14391
- return INVALID2;
14392
- }
14393
- if (key.status === "dirty" || value.status === "dirty") {
14394
- status.dirty();
14395
- }
14396
- finalMap.set(key.value, value.value);
14397
- }
14398
- return { status: status.value, value: finalMap };
14399
- }
14400
- }
14401
- }
14402
- ZodMap2.create = (keyType, valueType, params) => {
14403
- return new ZodMap2({
14404
- valueType,
14405
- keyType,
14406
- typeName: ZodFirstPartyTypeKind2.ZodMap,
14407
- ...processCreateParams2(params)
14408
- });
14409
- };
14410
-
14411
- class ZodSet2 extends ZodType2 {
14412
- _parse(input) {
14413
- const { status, ctx } = this._processInputParams(input);
14414
- if (ctx.parsedType !== ZodParsedType2.set) {
14415
- addIssueToContext2(ctx, {
14416
- code: ZodIssueCode2.invalid_type,
14417
- expected: ZodParsedType2.set,
14418
- received: ctx.parsedType
14419
- });
14420
- return INVALID2;
14421
- }
14422
- const def = this._def;
14423
- if (def.minSize !== null) {
14424
- if (ctx.data.size < def.minSize.value) {
14425
- addIssueToContext2(ctx, {
14426
- code: ZodIssueCode2.too_small,
14427
- minimum: def.minSize.value,
14428
- type: "set",
14429
- inclusive: true,
14430
- exact: false,
14431
- message: def.minSize.message
14432
- });
14433
- status.dirty();
14434
- }
14435
- }
14436
- if (def.maxSize !== null) {
14437
- if (ctx.data.size > def.maxSize.value) {
14438
- addIssueToContext2(ctx, {
14439
- code: ZodIssueCode2.too_big,
14440
- maximum: def.maxSize.value,
14441
- type: "set",
14442
- inclusive: true,
14443
- exact: false,
14444
- message: def.maxSize.message
14445
- });
14446
- status.dirty();
14447
- }
14448
- }
14449
- const valueType = this._def.valueType;
14450
- function finalizeSet(elements2) {
14451
- const parsedSet = new Set;
14452
- for (const element of elements2) {
14453
- if (element.status === "aborted")
14454
- return INVALID2;
14455
- if (element.status === "dirty")
14456
- status.dirty();
14457
- parsedSet.add(element.value);
14458
- }
14459
- return { status: status.value, value: parsedSet };
14460
- }
14461
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i)));
14462
- if (ctx.common.async) {
14463
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
14464
- } else {
14465
- return finalizeSet(elements);
14466
- }
14467
- }
14468
- min(minSize, message) {
14469
- return new ZodSet2({
14470
- ...this._def,
14471
- minSize: { value: minSize, message: errorUtil2.toString(message) }
14472
- });
14473
- }
14474
- max(maxSize, message) {
14475
- return new ZodSet2({
14476
- ...this._def,
14477
- maxSize: { value: maxSize, message: errorUtil2.toString(message) }
14478
- });
14479
- }
14480
- size(size, message) {
14481
- return this.min(size, message).max(size, message);
14482
- }
14483
- nonempty(message) {
14484
- return this.min(1, message);
14485
- }
14486
- }
14487
- ZodSet2.create = (valueType, params) => {
14488
- return new ZodSet2({
14489
- valueType,
14490
- minSize: null,
14491
- maxSize: null,
14492
- typeName: ZodFirstPartyTypeKind2.ZodSet,
14493
- ...processCreateParams2(params)
14494
- });
14495
- };
14496
-
14497
- class ZodFunction2 extends ZodType2 {
14498
- constructor() {
14499
- super(...arguments);
14500
- this.validate = this.implement;
14501
- }
14502
- _parse(input) {
14503
- const { ctx } = this._processInputParams(input);
14504
- if (ctx.parsedType !== ZodParsedType2.function) {
14505
- addIssueToContext2(ctx, {
14506
- code: ZodIssueCode2.invalid_type,
14507
- expected: ZodParsedType2.function,
14508
- received: ctx.parsedType
14509
- });
14510
- return INVALID2;
14511
- }
14512
- function makeArgsIssue(args, error) {
14513
- return makeIssue2({
14514
- data: args,
14515
- path: ctx.path,
14516
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
14517
- issueData: {
14518
- code: ZodIssueCode2.invalid_arguments,
14519
- argumentsError: error
14520
- }
14521
- });
14522
- }
14523
- function makeReturnsIssue(returns, error) {
14524
- return makeIssue2({
14525
- data: returns,
14526
- path: ctx.path,
14527
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
14528
- issueData: {
14529
- code: ZodIssueCode2.invalid_return_type,
14530
- returnTypeError: error
14531
- }
14532
- });
14533
- }
14534
- const params = { errorMap: ctx.common.contextualErrorMap };
14535
- const fn = ctx.data;
14536
- if (this._def.returns instanceof ZodPromise2) {
14537
- const me = this;
14538
- return OK2(async function(...args) {
14539
- const error = new ZodError3([]);
14540
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
14541
- error.addIssue(makeArgsIssue(args, e));
14542
- throw error;
14543
- });
14544
- const result = await Reflect.apply(fn, this, parsedArgs);
14545
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
14546
- error.addIssue(makeReturnsIssue(result, e));
14547
- throw error;
14548
- });
14549
- return parsedReturns;
14550
- });
14551
- } else {
14552
- const me = this;
14553
- return OK2(function(...args) {
14554
- const parsedArgs = me._def.args.safeParse(args, params);
14555
- if (!parsedArgs.success) {
14556
- throw new ZodError3([makeArgsIssue(args, parsedArgs.error)]);
14557
- }
14558
- const result = Reflect.apply(fn, this, parsedArgs.data);
14559
- const parsedReturns = me._def.returns.safeParse(result, params);
14560
- if (!parsedReturns.success) {
14561
- throw new ZodError3([makeReturnsIssue(result, parsedReturns.error)]);
14562
- }
14563
- return parsedReturns.data;
14564
- });
14565
- }
14566
- }
14567
- parameters() {
14568
- return this._def.args;
14569
- }
14570
- returnType() {
14571
- return this._def.returns;
14572
- }
14573
- args(...items) {
14574
- return new ZodFunction2({
14575
- ...this._def,
14576
- args: ZodTuple2.create(items).rest(ZodUnknown2.create())
14577
- });
14578
- }
14579
- returns(returnType) {
14580
- return new ZodFunction2({
14581
- ...this._def,
14582
- returns: returnType
14583
- });
14584
- }
14585
- implement(func) {
14586
- const validatedFunc = this.parse(func);
14587
- return validatedFunc;
14588
- }
14589
- strictImplement(func) {
14590
- const validatedFunc = this.parse(func);
14591
- return validatedFunc;
14592
- }
14593
- static create(args, returns, params) {
14594
- return new ZodFunction2({
14595
- args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()),
14596
- returns: returns || ZodUnknown2.create(),
14597
- typeName: ZodFirstPartyTypeKind2.ZodFunction,
14598
- ...processCreateParams2(params)
14599
- });
14600
- }
14601
- }
14602
-
14603
- class ZodLazy2 extends ZodType2 {
14604
- get schema() {
14605
- return this._def.getter();
14606
- }
14607
- _parse(input) {
14608
- const { ctx } = this._processInputParams(input);
14609
- const lazySchema = this._def.getter();
14610
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
14611
- }
14612
- }
14613
- ZodLazy2.create = (getter, params) => {
14614
- return new ZodLazy2({
14615
- getter,
14616
- typeName: ZodFirstPartyTypeKind2.ZodLazy,
14617
- ...processCreateParams2(params)
14618
- });
14619
- };
14620
-
14621
- class ZodLiteral2 extends ZodType2 {
14622
- _parse(input) {
14623
- if (input.data !== this._def.value) {
14624
- const ctx = this._getOrReturnCtx(input);
14625
- addIssueToContext2(ctx, {
14626
- received: ctx.data,
14627
- code: ZodIssueCode2.invalid_literal,
14628
- expected: this._def.value
14629
- });
14630
- return INVALID2;
14631
- }
14632
- return { status: "valid", value: input.data };
14633
- }
14634
- get value() {
14635
- return this._def.value;
14636
- }
14637
- }
14638
- ZodLiteral2.create = (value, params) => {
14639
- return new ZodLiteral2({
14640
- value,
14641
- typeName: ZodFirstPartyTypeKind2.ZodLiteral,
14642
- ...processCreateParams2(params)
14643
- });
14644
- };
14645
- function createZodEnum2(values, params) {
14646
- return new ZodEnum2({
14647
- values,
14648
- typeName: ZodFirstPartyTypeKind2.ZodEnum,
14649
- ...processCreateParams2(params)
14650
- });
14651
- }
14652
-
14653
- class ZodEnum2 extends ZodType2 {
14654
- _parse(input) {
14655
- if (typeof input.data !== "string") {
14656
- const ctx = this._getOrReturnCtx(input);
14657
- const expectedValues = this._def.values;
14658
- addIssueToContext2(ctx, {
14659
- expected: util3.joinValues(expectedValues),
14660
- received: ctx.parsedType,
14661
- code: ZodIssueCode2.invalid_type
14662
- });
14663
- return INVALID2;
14664
- }
14665
- if (!this._cache) {
14666
- this._cache = new Set(this._def.values);
14667
- }
14668
- if (!this._cache.has(input.data)) {
14669
- const ctx = this._getOrReturnCtx(input);
14670
- const expectedValues = this._def.values;
14671
- addIssueToContext2(ctx, {
14672
- received: ctx.data,
14673
- code: ZodIssueCode2.invalid_enum_value,
14674
- options: expectedValues
14675
- });
14676
- return INVALID2;
14677
- }
14678
- return OK2(input.data);
14679
- }
14680
- get options() {
14681
- return this._def.values;
14682
- }
14683
- get enum() {
14684
- const enumValues = {};
14685
- for (const val of this._def.values) {
14686
- enumValues[val] = val;
14687
- }
14688
- return enumValues;
14689
- }
14690
- get Values() {
14691
- const enumValues = {};
14692
- for (const val of this._def.values) {
14693
- enumValues[val] = val;
14694
- }
14695
- return enumValues;
14696
- }
14697
- get Enum() {
14698
- const enumValues = {};
14699
- for (const val of this._def.values) {
14700
- enumValues[val] = val;
14701
- }
14702
- return enumValues;
14703
- }
14704
- extract(values, newDef = this._def) {
14705
- return ZodEnum2.create(values, {
14706
- ...this._def,
14707
- ...newDef
14708
- });
14709
- }
14710
- exclude(values, newDef = this._def) {
14711
- return ZodEnum2.create(this.options.filter((opt) => !values.includes(opt)), {
14712
- ...this._def,
14713
- ...newDef
14714
- });
14715
- }
14716
- }
14717
- ZodEnum2.create = createZodEnum2;
14718
-
14719
- class ZodNativeEnum2 extends ZodType2 {
14720
- _parse(input) {
14721
- const nativeEnumValues = util3.getValidEnumValues(this._def.values);
14722
- const ctx = this._getOrReturnCtx(input);
14723
- if (ctx.parsedType !== ZodParsedType2.string && ctx.parsedType !== ZodParsedType2.number) {
14724
- const expectedValues = util3.objectValues(nativeEnumValues);
14725
- addIssueToContext2(ctx, {
14726
- expected: util3.joinValues(expectedValues),
14727
- received: ctx.parsedType,
14728
- code: ZodIssueCode2.invalid_type
14729
- });
14730
- return INVALID2;
14731
- }
14732
- if (!this._cache) {
14733
- this._cache = new Set(util3.getValidEnumValues(this._def.values));
14734
- }
14735
- if (!this._cache.has(input.data)) {
14736
- const expectedValues = util3.objectValues(nativeEnumValues);
14737
- addIssueToContext2(ctx, {
14738
- received: ctx.data,
14739
- code: ZodIssueCode2.invalid_enum_value,
14740
- options: expectedValues
14741
- });
14742
- return INVALID2;
14743
- }
14744
- return OK2(input.data);
14745
- }
14746
- get enum() {
14747
- return this._def.values;
14748
- }
14749
- }
14750
- ZodNativeEnum2.create = (values, params) => {
14751
- return new ZodNativeEnum2({
14752
- values,
14753
- typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
14754
- ...processCreateParams2(params)
14755
- });
14756
- };
14757
-
14758
- class ZodPromise2 extends ZodType2 {
14759
- unwrap() {
14760
- return this._def.type;
14761
- }
14762
- _parse(input) {
14763
- const { ctx } = this._processInputParams(input);
14764
- if (ctx.parsedType !== ZodParsedType2.promise && ctx.common.async === false) {
14765
- addIssueToContext2(ctx, {
14766
- code: ZodIssueCode2.invalid_type,
14767
- expected: ZodParsedType2.promise,
14768
- received: ctx.parsedType
14769
- });
14770
- return INVALID2;
14771
- }
14772
- const promisified = ctx.parsedType === ZodParsedType2.promise ? ctx.data : Promise.resolve(ctx.data);
14773
- return OK2(promisified.then((data) => {
14774
- return this._def.type.parseAsync(data, {
14775
- path: ctx.path,
14776
- errorMap: ctx.common.contextualErrorMap
14777
- });
14778
- }));
14779
- }
14780
- }
14781
- ZodPromise2.create = (schema, params) => {
14782
- return new ZodPromise2({
14783
- type: schema,
14784
- typeName: ZodFirstPartyTypeKind2.ZodPromise,
14785
- ...processCreateParams2(params)
14786
- });
14787
- };
14788
-
14789
- class ZodEffects2 extends ZodType2 {
14790
- innerType() {
14791
- return this._def.schema;
14792
- }
14793
- sourceType() {
14794
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
14795
- }
14796
- _parse(input) {
14797
- const { status, ctx } = this._processInputParams(input);
14798
- const effect = this._def.effect || null;
14799
- const checkCtx = {
14800
- addIssue: (arg) => {
14801
- addIssueToContext2(ctx, arg);
14802
- if (arg.fatal) {
14803
- status.abort();
14804
- } else {
14805
- status.dirty();
14806
- }
14807
- },
14808
- get path() {
14809
- return ctx.path;
14810
- }
14811
- };
14812
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
14813
- if (effect.type === "preprocess") {
14814
- const processed = effect.transform(ctx.data, checkCtx);
14815
- if (ctx.common.async) {
14816
- return Promise.resolve(processed).then(async (processed2) => {
14817
- if (status.value === "aborted")
14818
- return INVALID2;
14819
- const result = await this._def.schema._parseAsync({
14820
- data: processed2,
14821
- path: ctx.path,
14822
- parent: ctx
14823
- });
14824
- if (result.status === "aborted")
14825
- return INVALID2;
14826
- if (result.status === "dirty")
14827
- return DIRTY2(result.value);
14828
- if (status.value === "dirty")
14829
- return DIRTY2(result.value);
14830
- return result;
14831
- });
14832
- } else {
14833
- if (status.value === "aborted")
14834
- return INVALID2;
14835
- const result = this._def.schema._parseSync({
14836
- data: processed,
14837
- path: ctx.path,
14838
- parent: ctx
14839
- });
14840
- if (result.status === "aborted")
14841
- return INVALID2;
14842
- if (result.status === "dirty")
14843
- return DIRTY2(result.value);
14844
- if (status.value === "dirty")
14845
- return DIRTY2(result.value);
14846
- return result;
14847
- }
14848
- }
14849
- if (effect.type === "refinement") {
14850
- const executeRefinement = (acc) => {
14851
- const result = effect.refinement(acc, checkCtx);
14852
- if (ctx.common.async) {
14853
- return Promise.resolve(result);
14854
- }
14855
- if (result instanceof Promise) {
14856
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
14857
- }
14858
- return acc;
14859
- };
14860
- if (ctx.common.async === false) {
14861
- const inner = this._def.schema._parseSync({
14862
- data: ctx.data,
14863
- path: ctx.path,
14864
- parent: ctx
14865
- });
14866
- if (inner.status === "aborted")
14867
- return INVALID2;
14868
- if (inner.status === "dirty")
14869
- status.dirty();
14870
- executeRefinement(inner.value);
14871
- return { status: status.value, value: inner.value };
14872
- } else {
14873
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
14874
- if (inner.status === "aborted")
14875
- return INVALID2;
14876
- if (inner.status === "dirty")
14877
- status.dirty();
14878
- return executeRefinement(inner.value).then(() => {
14879
- return { status: status.value, value: inner.value };
14880
- });
14881
- });
14882
- }
14883
- }
14884
- if (effect.type === "transform") {
14885
- if (ctx.common.async === false) {
14886
- const base = this._def.schema._parseSync({
14887
- data: ctx.data,
14888
- path: ctx.path,
14889
- parent: ctx
14890
- });
14891
- if (!isValid2(base))
14892
- return INVALID2;
14893
- const result = effect.transform(base.value, checkCtx);
14894
- if (result instanceof Promise) {
14895
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
14896
- }
14897
- return { status: status.value, value: result };
14898
- } else {
14899
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
14900
- if (!isValid2(base))
14901
- return INVALID2;
14902
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
14903
- status: status.value,
14904
- value: result
14905
- }));
14906
- });
14907
- }
14908
- }
14909
- util3.assertNever(effect);
14910
- }
14911
- }
14912
- ZodEffects2.create = (schema, effect, params) => {
14913
- return new ZodEffects2({
14914
- schema,
14915
- typeName: ZodFirstPartyTypeKind2.ZodEffects,
14916
- effect,
14917
- ...processCreateParams2(params)
14918
- });
14919
- };
14920
- ZodEffects2.createWithPreprocess = (preprocess, schema, params) => {
14921
- return new ZodEffects2({
14922
- schema,
14923
- effect: { type: "preprocess", transform: preprocess },
14924
- typeName: ZodFirstPartyTypeKind2.ZodEffects,
14925
- ...processCreateParams2(params)
14926
- });
14927
- };
14928
- class ZodOptional2 extends ZodType2 {
14929
- _parse(input) {
14930
- const parsedType = this._getType(input);
14931
- if (parsedType === ZodParsedType2.undefined) {
14932
- return OK2(undefined);
14933
- }
14934
- return this._def.innerType._parse(input);
14935
- }
14936
- unwrap() {
14937
- return this._def.innerType;
14938
- }
14939
- }
14940
- ZodOptional2.create = (type, params) => {
14941
- return new ZodOptional2({
14942
- innerType: type,
14943
- typeName: ZodFirstPartyTypeKind2.ZodOptional,
14944
- ...processCreateParams2(params)
14945
- });
14946
- };
14947
-
14948
- class ZodNullable2 extends ZodType2 {
14949
- _parse(input) {
14950
- const parsedType = this._getType(input);
14951
- if (parsedType === ZodParsedType2.null) {
14952
- return OK2(null);
14953
- }
14954
- return this._def.innerType._parse(input);
14955
- }
14956
- unwrap() {
14957
- return this._def.innerType;
14958
- }
14959
- }
14960
- ZodNullable2.create = (type, params) => {
14961
- return new ZodNullable2({
14962
- innerType: type,
14963
- typeName: ZodFirstPartyTypeKind2.ZodNullable,
14964
- ...processCreateParams2(params)
14965
- });
14966
- };
14967
-
14968
- class ZodDefault2 extends ZodType2 {
14969
- _parse(input) {
14970
- const { ctx } = this._processInputParams(input);
14971
- let data = ctx.data;
14972
- if (ctx.parsedType === ZodParsedType2.undefined) {
14973
- data = this._def.defaultValue();
14974
- }
14975
- return this._def.innerType._parse({
14976
- data,
14977
- path: ctx.path,
14978
- parent: ctx
14979
- });
14980
- }
14981
- removeDefault() {
14982
- return this._def.innerType;
14983
- }
14984
- }
14985
- ZodDefault2.create = (type, params) => {
14986
- return new ZodDefault2({
14987
- innerType: type,
14988
- typeName: ZodFirstPartyTypeKind2.ZodDefault,
14989
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
14990
- ...processCreateParams2(params)
14991
- });
14992
- };
14993
-
14994
- class ZodCatch2 extends ZodType2 {
14995
- _parse(input) {
14996
- const { ctx } = this._processInputParams(input);
14997
- const newCtx = {
14998
- ...ctx,
14999
- common: {
15000
- ...ctx.common,
15001
- issues: []
15002
- }
15003
- };
15004
- const result = this._def.innerType._parse({
15005
- data: newCtx.data,
15006
- path: newCtx.path,
15007
- parent: {
15008
- ...newCtx
15009
- }
15010
- });
15011
- if (isAsync2(result)) {
15012
- return result.then((result2) => {
15013
- return {
15014
- status: "valid",
15015
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
15016
- get error() {
15017
- return new ZodError3(newCtx.common.issues);
15018
- },
15019
- input: newCtx.data
15020
- })
15021
- };
15022
- });
15023
- } else {
15024
- return {
15025
- status: "valid",
15026
- value: result.status === "valid" ? result.value : this._def.catchValue({
15027
- get error() {
15028
- return new ZodError3(newCtx.common.issues);
15029
- },
15030
- input: newCtx.data
15031
- })
15032
- };
15033
- }
15034
- }
15035
- removeCatch() {
15036
- return this._def.innerType;
15037
- }
15038
- }
15039
- ZodCatch2.create = (type, params) => {
15040
- return new ZodCatch2({
15041
- innerType: type,
15042
- typeName: ZodFirstPartyTypeKind2.ZodCatch,
15043
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
15044
- ...processCreateParams2(params)
15045
- });
15046
- };
15047
-
15048
- class ZodNaN2 extends ZodType2 {
15049
- _parse(input) {
15050
- const parsedType = this._getType(input);
15051
- if (parsedType !== ZodParsedType2.nan) {
15052
- const ctx = this._getOrReturnCtx(input);
15053
- addIssueToContext2(ctx, {
15054
- code: ZodIssueCode2.invalid_type,
15055
- expected: ZodParsedType2.nan,
15056
- received: ctx.parsedType
15057
- });
15058
- return INVALID2;
15059
- }
15060
- return { status: "valid", value: input.data };
15061
- }
15062
- }
15063
- ZodNaN2.create = (params) => {
15064
- return new ZodNaN2({
15065
- typeName: ZodFirstPartyTypeKind2.ZodNaN,
15066
- ...processCreateParams2(params)
15067
- });
15068
- };
15069
- var BRAND2 = Symbol("zod_brand");
15070
-
15071
- class ZodBranded2 extends ZodType2 {
15072
- _parse(input) {
15073
- const { ctx } = this._processInputParams(input);
15074
- const data = ctx.data;
15075
- return this._def.type._parse({
15076
- data,
15077
- path: ctx.path,
15078
- parent: ctx
15079
- });
15080
- }
15081
- unwrap() {
15082
- return this._def.type;
15083
- }
15084
- }
15085
-
15086
- class ZodPipeline2 extends ZodType2 {
15087
- _parse(input) {
15088
- const { status, ctx } = this._processInputParams(input);
15089
- if (ctx.common.async) {
15090
- const handleAsync = async () => {
15091
- const inResult = await this._def.in._parseAsync({
15092
- data: ctx.data,
15093
- path: ctx.path,
15094
- parent: ctx
15095
- });
15096
- if (inResult.status === "aborted")
15097
- return INVALID2;
15098
- if (inResult.status === "dirty") {
15099
- status.dirty();
15100
- return DIRTY2(inResult.value);
15101
- } else {
15102
- return this._def.out._parseAsync({
15103
- data: inResult.value,
15104
- path: ctx.path,
15105
- parent: ctx
15106
- });
15107
- }
15108
- };
15109
- return handleAsync();
15110
- } else {
15111
- const inResult = this._def.in._parseSync({
15112
- data: ctx.data,
15113
- path: ctx.path,
15114
- parent: ctx
15115
- });
15116
- if (inResult.status === "aborted")
15117
- return INVALID2;
15118
- if (inResult.status === "dirty") {
15119
- status.dirty();
15120
- return {
15121
- status: "dirty",
15122
- value: inResult.value
15123
- };
15124
- } else {
15125
- return this._def.out._parseSync({
15126
- data: inResult.value,
15127
- path: ctx.path,
15128
- parent: ctx
15129
- });
15130
- }
15131
- }
15132
- }
15133
- static create(a, b) {
15134
- return new ZodPipeline2({
15135
- in: a,
15136
- out: b,
15137
- typeName: ZodFirstPartyTypeKind2.ZodPipeline
15138
- });
15139
- }
15140
- }
15141
-
15142
- class ZodReadonly2 extends ZodType2 {
15143
- _parse(input) {
15144
- const result = this._def.innerType._parse(input);
15145
- const freeze = (data) => {
15146
- if (isValid2(data)) {
15147
- data.value = Object.freeze(data.value);
15148
- }
15149
- return data;
15150
- };
15151
- return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
15152
- }
15153
- unwrap() {
15154
- return this._def.innerType;
15155
- }
15156
- }
15157
- ZodReadonly2.create = (type, params) => {
15158
- return new ZodReadonly2({
15159
- innerType: type,
15160
- typeName: ZodFirstPartyTypeKind2.ZodReadonly,
15161
- ...processCreateParams2(params)
15162
- });
15163
- };
15164
- var late2 = {
15165
- object: ZodObject2.lazycreate
15166
- };
15167
- var ZodFirstPartyTypeKind2;
15168
- (function(ZodFirstPartyTypeKind3) {
15169
- ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
15170
- ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
15171
- ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
15172
- ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
15173
- ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
15174
- ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
15175
- ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
15176
- ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
15177
- ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
15178
- ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
15179
- ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
15180
- ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
15181
- ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
15182
- ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
15183
- ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
15184
- ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
15185
- ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
15186
- ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
15187
- ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
15188
- ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
15189
- ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
15190
- ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
15191
- ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
15192
- ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
15193
- ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
15194
- ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
15195
- ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
15196
- ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
15197
- ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
15198
- ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
15199
- ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
15200
- ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
15201
- ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
15202
- ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
15203
- ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
15204
- ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
15205
- })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
15206
- var stringType2 = ZodString2.create;
15207
- var numberType2 = ZodNumber2.create;
15208
- var nanType2 = ZodNaN2.create;
15209
- var bigIntType2 = ZodBigInt2.create;
15210
- var booleanType2 = ZodBoolean2.create;
15211
- var dateType2 = ZodDate2.create;
15212
- var symbolType2 = ZodSymbol2.create;
15213
- var undefinedType2 = ZodUndefined2.create;
15214
- var nullType2 = ZodNull2.create;
15215
- var anyType2 = ZodAny2.create;
15216
- var unknownType2 = ZodUnknown2.create;
15217
- var neverType2 = ZodNever2.create;
15218
- var voidType2 = ZodVoid2.create;
15219
- var arrayType2 = ZodArray2.create;
15220
- var objectType2 = ZodObject2.create;
15221
- var strictObjectType2 = ZodObject2.strictCreate;
15222
- var unionType2 = ZodUnion2.create;
15223
- var discriminatedUnionType2 = ZodDiscriminatedUnion2.create;
15224
- var intersectionType2 = ZodIntersection2.create;
15225
- var tupleType2 = ZodTuple2.create;
15226
- var recordType2 = ZodRecord2.create;
15227
- var mapType2 = ZodMap2.create;
15228
- var setType2 = ZodSet2.create;
15229
- var functionType2 = ZodFunction2.create;
15230
- var lazyType2 = ZodLazy2.create;
15231
- var literalType2 = ZodLiteral2.create;
15232
- var enumType2 = ZodEnum2.create;
15233
- var nativeEnumType2 = ZodNativeEnum2.create;
15234
- var promiseType2 = ZodPromise2.create;
15235
- var effectsType2 = ZodEffects2.create;
15236
- var optionalType2 = ZodOptional2.create;
15237
- var nullableType2 = ZodNullable2.create;
15238
- var preprocessType2 = ZodEffects2.createWithPreprocess;
15239
- var pipelineType2 = ZodPipeline2.create;
15240
-
15241
- // node_modules/zod-to-json-schema/dist/esm/parsers/any.js
15242
- function parseAnyDef(refs) {
15243
- if (refs.target !== "openAi") {
15244
- return {};
15245
- }
15246
- const anyDefinitionPath = [
15247
- ...refs.basePath,
15248
- refs.definitionPath,
15249
- refs.openAiAnyTypeName
15250
- ];
15251
- refs.flags.hasReferencedOpenAiAnyType = true;
15252
- return {
15253
- $ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
15254
- };
15255
- }
15256
-
15257
- // node_modules/zod-to-json-schema/dist/esm/parsers/array.js
15258
- function parseArrayDef(def, refs) {
15259
- const res = {
15260
- type: "array"
15261
- };
15262
- if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind2.ZodAny) {
15263
- res.items = parseDef(def.type._def, {
15264
- ...refs,
15265
- currentPath: [...refs.currentPath, "items"]
15266
- });
15267
- }
15268
- if (def.minLength) {
15269
- setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
15270
- }
15271
- if (def.maxLength) {
15272
- setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
15273
- }
15274
- if (def.exactLength) {
15275
- setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
15276
- setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
15277
- }
15278
- return res;
15279
- }
15280
-
15281
- // node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
15282
- function parseBigintDef(def, refs) {
15283
- const res = {
15284
- type: "integer",
15285
- format: "int64"
15286
- };
15287
- if (!def.checks)
15288
- return res;
15289
- for (const check of def.checks) {
15290
- switch (check.kind) {
15291
- case "min":
15292
- if (refs.target === "jsonSchema7") {
15293
- if (check.inclusive) {
15294
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
15295
- } else {
15296
- setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
15297
- }
15298
- } else {
15299
- if (!check.inclusive) {
15300
- res.exclusiveMinimum = true;
15301
- }
15302
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
15303
- }
15304
- break;
15305
- case "max":
15306
- if (refs.target === "jsonSchema7") {
15307
- if (check.inclusive) {
15308
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
15309
- } else {
15310
- setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
15311
- }
15312
- } else {
15313
- if (!check.inclusive) {
15314
- res.exclusiveMaximum = true;
15315
- }
15316
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
15317
- }
15318
- break;
15319
- case "multipleOf":
15320
- setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
15321
- break;
15322
- }
15323
- }
15324
- return res;
15325
- }
15326
-
15327
- // node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
15328
- function parseBooleanDef() {
15329
- return {
15330
- type: "boolean"
15331
- };
15332
- }
15333
-
15334
- // node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
15335
- function parseBrandedDef(_def, refs) {
15336
- return parseDef(_def.type._def, refs);
15337
- }
15338
-
15339
- // node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
15340
- var parseCatchDef = (def, refs) => {
15341
- return parseDef(def.innerType._def, refs);
15342
- };
15343
-
15344
- // node_modules/zod-to-json-schema/dist/esm/parsers/date.js
15345
- function parseDateDef(def, refs, overrideDateStrategy) {
15346
- const strategy = overrideDateStrategy ?? refs.dateStrategy;
15347
- if (Array.isArray(strategy)) {
15348
- return {
15349
- anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
15350
- };
15351
- }
15352
- switch (strategy) {
15353
- case "string":
15354
- case "format:date-time":
15355
- return {
15356
- type: "string",
15357
- format: "date-time"
15358
- };
15359
- case "format:date":
15360
- return {
15361
- type: "string",
15362
- format: "date"
15363
- };
15364
- case "integer":
15365
- return integerDateParser(def, refs);
15366
- }
15367
- }
15368
- var integerDateParser = (def, refs) => {
15369
- const res = {
15370
- type: "integer",
15371
- format: "unix-time"
15372
- };
15373
- if (refs.target === "openApi3") {
15374
- return res;
15375
- }
15376
- for (const check of def.checks) {
15377
- switch (check.kind) {
15378
- case "min":
15379
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
15380
- break;
15381
- case "max":
15382
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
15383
- break;
11575
+ for (const check of def.checks) {
11576
+ switch (check.kind) {
11577
+ case "min":
11578
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
11579
+ break;
11580
+ case "max":
11581
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
11582
+ break;
15384
11583
  }
15385
11584
  }
15386
11585
  return res;
@@ -15470,17 +11669,17 @@ function parseLiteralDef(def, refs) {
15470
11669
  }
15471
11670
 
15472
11671
  // node_modules/zod-to-json-schema/dist/esm/parsers/string.js
15473
- var emojiRegex3 = undefined;
11672
+ var emojiRegex2 = undefined;
15474
11673
  var zodPatterns = {
15475
11674
  cuid: /^[cC][^\s-]{8,}$/,
15476
11675
  cuid2: /^[0-9a-z]+$/,
15477
11676
  ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
15478
11677
  email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
15479
11678
  emoji: () => {
15480
- if (emojiRegex3 === undefined) {
15481
- emojiRegex3 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
11679
+ if (emojiRegex2 === undefined) {
11680
+ emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
15482
11681
  }
15483
- return emojiRegex3;
11682
+ return emojiRegex2;
15484
11683
  },
15485
11684
  uuid: /^[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}$/,
15486
11685
  ipv4: /^(?:(?: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])$/,
@@ -15771,7 +11970,7 @@ function parseRecordDef(def, refs) {
15771
11970
  if (refs.target === "openAi") {
15772
11971
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
15773
11972
  }
15774
- if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind2.ZodEnum) {
11973
+ if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
15775
11974
  return {
15776
11975
  type: "object",
15777
11976
  required: def.keyType._def.values,
@@ -15795,20 +11994,20 @@ function parseRecordDef(def, refs) {
15795
11994
  if (refs.target === "openApi3") {
15796
11995
  return schema;
15797
11996
  }
15798
- if (def.keyType?._def.typeName === ZodFirstPartyTypeKind2.ZodString && def.keyType._def.checks?.length) {
11997
+ if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
15799
11998
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
15800
11999
  return {
15801
12000
  ...schema,
15802
12001
  propertyNames: keyType
15803
12002
  };
15804
- } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind2.ZodEnum) {
12003
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
15805
12004
  return {
15806
12005
  ...schema,
15807
12006
  propertyNames: {
15808
12007
  enum: def.keyType._def.values
15809
12008
  }
15810
12009
  };
15811
- } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind2.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind2.ZodString && def.keyType._def.type._def.checks?.length) {
12010
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
15812
12011
  const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
15813
12012
  return {
15814
12013
  ...schema,
@@ -16208,73 +12407,73 @@ var parseReadonlyDef = (def, refs) => {
16208
12407
  // node_modules/zod-to-json-schema/dist/esm/selectParser.js
16209
12408
  var selectParser = (def, typeName, refs) => {
16210
12409
  switch (typeName) {
16211
- case ZodFirstPartyTypeKind2.ZodString:
12410
+ case ZodFirstPartyTypeKind.ZodString:
16212
12411
  return parseStringDef(def, refs);
16213
- case ZodFirstPartyTypeKind2.ZodNumber:
12412
+ case ZodFirstPartyTypeKind.ZodNumber:
16214
12413
  return parseNumberDef(def, refs);
16215
- case ZodFirstPartyTypeKind2.ZodObject:
12414
+ case ZodFirstPartyTypeKind.ZodObject:
16216
12415
  return parseObjectDef(def, refs);
16217
- case ZodFirstPartyTypeKind2.ZodBigInt:
12416
+ case ZodFirstPartyTypeKind.ZodBigInt:
16218
12417
  return parseBigintDef(def, refs);
16219
- case ZodFirstPartyTypeKind2.ZodBoolean:
12418
+ case ZodFirstPartyTypeKind.ZodBoolean:
16220
12419
  return parseBooleanDef();
16221
- case ZodFirstPartyTypeKind2.ZodDate:
12420
+ case ZodFirstPartyTypeKind.ZodDate:
16222
12421
  return parseDateDef(def, refs);
16223
- case ZodFirstPartyTypeKind2.ZodUndefined:
12422
+ case ZodFirstPartyTypeKind.ZodUndefined:
16224
12423
  return parseUndefinedDef(refs);
16225
- case ZodFirstPartyTypeKind2.ZodNull:
12424
+ case ZodFirstPartyTypeKind.ZodNull:
16226
12425
  return parseNullDef(refs);
16227
- case ZodFirstPartyTypeKind2.ZodArray:
12426
+ case ZodFirstPartyTypeKind.ZodArray:
16228
12427
  return parseArrayDef(def, refs);
16229
- case ZodFirstPartyTypeKind2.ZodUnion:
16230
- case ZodFirstPartyTypeKind2.ZodDiscriminatedUnion:
12428
+ case ZodFirstPartyTypeKind.ZodUnion:
12429
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
16231
12430
  return parseUnionDef(def, refs);
16232
- case ZodFirstPartyTypeKind2.ZodIntersection:
12431
+ case ZodFirstPartyTypeKind.ZodIntersection:
16233
12432
  return parseIntersectionDef(def, refs);
16234
- case ZodFirstPartyTypeKind2.ZodTuple:
12433
+ case ZodFirstPartyTypeKind.ZodTuple:
16235
12434
  return parseTupleDef(def, refs);
16236
- case ZodFirstPartyTypeKind2.ZodRecord:
12435
+ case ZodFirstPartyTypeKind.ZodRecord:
16237
12436
  return parseRecordDef(def, refs);
16238
- case ZodFirstPartyTypeKind2.ZodLiteral:
12437
+ case ZodFirstPartyTypeKind.ZodLiteral:
16239
12438
  return parseLiteralDef(def, refs);
16240
- case ZodFirstPartyTypeKind2.ZodEnum:
12439
+ case ZodFirstPartyTypeKind.ZodEnum:
16241
12440
  return parseEnumDef(def);
16242
- case ZodFirstPartyTypeKind2.ZodNativeEnum:
12441
+ case ZodFirstPartyTypeKind.ZodNativeEnum:
16243
12442
  return parseNativeEnumDef(def);
16244
- case ZodFirstPartyTypeKind2.ZodNullable:
12443
+ case ZodFirstPartyTypeKind.ZodNullable:
16245
12444
  return parseNullableDef(def, refs);
16246
- case ZodFirstPartyTypeKind2.ZodOptional:
12445
+ case ZodFirstPartyTypeKind.ZodOptional:
16247
12446
  return parseOptionalDef(def, refs);
16248
- case ZodFirstPartyTypeKind2.ZodMap:
12447
+ case ZodFirstPartyTypeKind.ZodMap:
16249
12448
  return parseMapDef(def, refs);
16250
- case ZodFirstPartyTypeKind2.ZodSet:
12449
+ case ZodFirstPartyTypeKind.ZodSet:
16251
12450
  return parseSetDef(def, refs);
16252
- case ZodFirstPartyTypeKind2.ZodLazy:
12451
+ case ZodFirstPartyTypeKind.ZodLazy:
16253
12452
  return () => def.getter()._def;
16254
- case ZodFirstPartyTypeKind2.ZodPromise:
12453
+ case ZodFirstPartyTypeKind.ZodPromise:
16255
12454
  return parsePromiseDef(def, refs);
16256
- case ZodFirstPartyTypeKind2.ZodNaN:
16257
- case ZodFirstPartyTypeKind2.ZodNever:
12455
+ case ZodFirstPartyTypeKind.ZodNaN:
12456
+ case ZodFirstPartyTypeKind.ZodNever:
16258
12457
  return parseNeverDef(refs);
16259
- case ZodFirstPartyTypeKind2.ZodEffects:
12458
+ case ZodFirstPartyTypeKind.ZodEffects:
16260
12459
  return parseEffectsDef(def, refs);
16261
- case ZodFirstPartyTypeKind2.ZodAny:
12460
+ case ZodFirstPartyTypeKind.ZodAny:
16262
12461
  return parseAnyDef(refs);
16263
- case ZodFirstPartyTypeKind2.ZodUnknown:
12462
+ case ZodFirstPartyTypeKind.ZodUnknown:
16264
12463
  return parseUnknownDef(refs);
16265
- case ZodFirstPartyTypeKind2.ZodDefault:
12464
+ case ZodFirstPartyTypeKind.ZodDefault:
16266
12465
  return parseDefaultDef(def, refs);
16267
- case ZodFirstPartyTypeKind2.ZodBranded:
12466
+ case ZodFirstPartyTypeKind.ZodBranded:
16268
12467
  return parseBrandedDef(def, refs);
16269
- case ZodFirstPartyTypeKind2.ZodReadonly:
12468
+ case ZodFirstPartyTypeKind.ZodReadonly:
16270
12469
  return parseReadonlyDef(def, refs);
16271
- case ZodFirstPartyTypeKind2.ZodCatch:
12470
+ case ZodFirstPartyTypeKind.ZodCatch:
16272
12471
  return parseCatchDef(def, refs);
16273
- case ZodFirstPartyTypeKind2.ZodPipeline:
12472
+ case ZodFirstPartyTypeKind.ZodPipeline:
16274
12473
  return parsePipelineDef(def, refs);
16275
- case ZodFirstPartyTypeKind2.ZodFunction:
16276
- case ZodFirstPartyTypeKind2.ZodVoid:
16277
- case ZodFirstPartyTypeKind2.ZodSymbol:
12474
+ case ZodFirstPartyTypeKind.ZodFunction:
12475
+ case ZodFirstPartyTypeKind.ZodVoid:
12476
+ case ZodFirstPartyTypeKind.ZodSymbol:
16278
12477
  return;
16279
12478
  default:
16280
12479
  return ((_) => {
@@ -16423,18 +12622,18 @@ Completable.create = (type, params) => {
16423
12622
  type,
16424
12623
  typeName: McpZodTypeKind.Completable,
16425
12624
  complete: params.complete,
16426
- ...processCreateParams3(params)
12625
+ ...processCreateParams2(params)
16427
12626
  });
16428
12627
  };
16429
- function processCreateParams3(params) {
12628
+ function processCreateParams2(params) {
16430
12629
  if (!params)
16431
12630
  return {};
16432
- const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
16433
- if (errorMap3 && (invalid_type_error || required_error)) {
12631
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
12632
+ if (errorMap2 && (invalid_type_error || required_error)) {
16434
12633
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
16435
12634
  }
16436
- if (errorMap3)
16437
- return { errorMap: errorMap3, description };
12635
+ if (errorMap2)
12636
+ return { errorMap: errorMap2, description };
16438
12637
  const customMap = (iss, ctx) => {
16439
12638
  var _a, _b;
16440
12639
  const { message } = params;
@@ -16490,7 +12689,8 @@ class McpServer {
16490
12689
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
16491
12690
  strictUnions: true
16492
12691
  }) : EMPTY_OBJECT_JSON_SCHEMA,
16493
- annotations: tool.annotations
12692
+ annotations: tool.annotations,
12693
+ _meta: tool._meta
16494
12694
  };
16495
12695
  if (tool.outputSchema) {
16496
12696
  toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, { strictUnions: true });
@@ -16855,13 +13055,14 @@ class McpServer {
16855
13055
  this._registeredPrompts[name] = registeredPrompt;
16856
13056
  return registeredPrompt;
16857
13057
  }
16858
- _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, callback) {
13058
+ _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, callback) {
16859
13059
  const registeredTool = {
16860
13060
  title,
16861
13061
  description,
16862
13062
  inputSchema: inputSchema === undefined ? undefined : exports_external.object(inputSchema),
16863
13063
  outputSchema: outputSchema === undefined ? undefined : exports_external.object(outputSchema),
16864
13064
  annotations,
13065
+ _meta,
16865
13066
  callback,
16866
13067
  enabled: true,
16867
13068
  disable: () => registeredTool.update({ enabled: false }),
@@ -16883,6 +13084,8 @@ class McpServer {
16883
13084
  registeredTool.callback = updates.callback;
16884
13085
  if (typeof updates.annotations !== "undefined")
16885
13086
  registeredTool.annotations = updates.annotations;
13087
+ if (typeof updates._meta !== "undefined")
13088
+ registeredTool._meta = updates._meta;
16886
13089
  if (typeof updates.enabled !== "undefined")
16887
13090
  registeredTool.enabled = updates.enabled;
16888
13091
  this.sendToolListChanged();
@@ -16916,14 +13119,14 @@ class McpServer {
16916
13119
  }
16917
13120
  }
16918
13121
  const callback = rest[0];
16919
- return this._createRegisteredTool(name, undefined, description, inputSchema, outputSchema, annotations, callback);
13122
+ return this._createRegisteredTool(name, undefined, description, inputSchema, outputSchema, annotations, undefined, callback);
16920
13123
  }
16921
13124
  registerTool(name, config, cb) {
16922
13125
  if (this._registeredTools[name]) {
16923
13126
  throw new Error(`Tool ${name} is already registered`);
16924
13127
  }
16925
- const { title, description, inputSchema, outputSchema, annotations } = config;
16926
- return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, cb);
13128
+ const { title, description, inputSchema, outputSchema, annotations, _meta } = config;
13129
+ return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, cb);
16927
13130
  }
16928
13131
  prompt(name, ...rest) {
16929
13132
  if (this._registeredPrompts[name]) {
@@ -17013,7 +13216,7 @@ var EMPTY_COMPLETION_RESULT = {
17013
13216
  // package.json
17014
13217
  var package_default = {
17015
13218
  name: "@youdotcom-oss/mcp",
17016
- version: "1.1.2",
13219
+ version: "1.1.5",
17017
13220
  description: "You.com API Model Context Protocol Server",
17018
13221
  type: "module",
17019
13222
  bin: "bin/stdio",
@@ -17036,26 +13239,37 @@ var package_default = {
17036
13239
  ],
17037
13240
  author: "You.com (https://you.com)",
17038
13241
  license: "MIT",
13242
+ repository: {
13243
+ type: "git",
13244
+ url: "git+https://github.com/youdotcom-oss/youdotcom-mcp-server.git"
13245
+ },
13246
+ bugs: {
13247
+ url: "https://github.com/youdotcom-oss/youdotcom-mcp-server/issues"
13248
+ },
13249
+ homepage: "https://github.com/youdotcom-oss/youdotcom-mcp-server/tree/main#readme",
17039
13250
  files: [
17040
13251
  "bin/stdio",
17041
13252
  "dist"
17042
13253
  ],
13254
+ publishConfig: {
13255
+ access: "public"
13256
+ },
17043
13257
  engines: {
17044
13258
  node: ">=18",
17045
13259
  bun: ">= 1.2.21"
17046
13260
  },
17047
13261
  devDependencies: {
17048
- "@biomejs/biome": "2.2.2",
13262
+ "@biomejs/biome": "2.2.4",
17049
13263
  "@commitlint/cli": "^19.8.1",
17050
13264
  "@commitlint/config-conventional": "^19.8.1",
17051
- "@eslint/js": "9.34.0",
17052
- "@modelcontextprotocol/inspector": "0.16.6",
13265
+ "@eslint/js": "9.36.0",
13266
+ "@modelcontextprotocol/inspector": "0.16.8",
17053
13267
  "@types/bun": "latest",
17054
13268
  typescript: "5.9.2",
17055
- "lint-staged": "^16.1.6",
17056
- "@hono/mcp": "0.1.2",
17057
- "@modelcontextprotocol/sdk": "1.17.5",
17058
- hono: "^4.9.6",
13269
+ "lint-staged": "^16.2.0",
13270
+ "@hono/mcp": "0.1.4",
13271
+ "@modelcontextprotocol/sdk": "1.18.1",
13272
+ hono: "^4.9.8",
17059
13273
  neverthrow: "8.2.0",
17060
13274
  zod: "3.25.76"
17061
13275
  },
@@ -17079,18 +13293,18 @@ var getMCpServer = () => new McpServer({
17079
13293
  });
17080
13294
 
17081
13295
  // src/search/search.schemas.ts
17082
- var SearchQuerySchema = objectType2({
17083
- query: stringType2().min(1, "Query is required").describe(`The base search query to send to the You.com API.
13296
+ var SearchQuerySchema = objectType({
13297
+ query: stringType().min(1, "Query is required").describe(`The base search query to send to the You.com API.
17084
13298
  This will be combined with additional filters like site, fileType, and language to create the final search query.
17085
13299
  You can also use operators directly: + (exact term, e.g., "Enron +GAAP"), - (exclude term, e.g., "guitar -prs"), site: (domain, e.g., "site:uscourts.gov"), filetype: (e.g., "filetype:pdf"), lang: (e.g., "lang:es"). Use parentheses for multi-word phrases (e.g., "+(machine learning)", "-(social media)").`),
17086
- count: numberType2().int().min(1).max(20).optional().describe(`Specifies the maximum number of results to return per section.
13300
+ count: numberType().int().min(1).max(20).optional().describe(`Specifies the maximum number of results to return per section.
17087
13301
  Range 1 ≤ count ≤ 20.`),
17088
- freshness: enumType2(["day", "week", "month", "year"]).optional().describe("Specifies the freshness of the results to return."),
17089
- offset: numberType2().int().min(0).max(9).optional().describe(`Indicates the offset for pagination.
13302
+ freshness: enumType(["day", "week", "month", "year"]).optional().describe("Specifies the freshness of the results to return."),
13303
+ offset: numberType().int().min(0).max(9).optional().describe(`Indicates the offset for pagination.
17090
13304
  The offset is calculated in multiples of count.
17091
13305
  For example, if count = 5 and offset = 1, results 5–10 will be returned.
17092
13306
  Range 0 ≤ offset ≤ 9.`),
17093
- country: enumType2([
13307
+ country: enumType([
17094
13308
  "AR",
17095
13309
  "AU",
17096
13310
  "AT",
@@ -17128,86 +13342,86 @@ var SearchQuerySchema = objectType2({
17128
13342
  "GB",
17129
13343
  "US"
17130
13344
  ]).optional().describe("Specifies the Country Code for search"),
17131
- safesearch: enumType2(["off", "moderate", "strict"]).optional().describe(`Configures the safesearch filter for content moderation.
13345
+ safesearch: enumType(["off", "moderate", "strict"]).optional().describe(`Configures the safesearch filter for content moderation.
17132
13346
  * off - no filtering applied.
17133
13347
  * moderate - moderate content filtering (default).
17134
13348
  * strict - strict content filtering.`),
17135
- site: stringType2().optional().describe("Search within a specific website domain (e.g., 'github.com')"),
17136
- fileType: stringType2().optional().describe("Filter by a specific file type (e.g., 'pdf', 'doc', 'txt')"),
17137
- language: stringType2().optional().describe("Filter by a specific language using ISO 639-1 code (e.g., 'en', 'es', 'fr')"),
17138
- excludeTerms: stringType2().optional().describe("Terms to exclude with logical operators: 'spam AND|ads|NOT relevant' (pipe-separated, add AND/OR after terms, default OR)"),
17139
- exactTerms: stringType2().optional().describe("Exact terms with logical operators: 'python AND|tutorial|NOT beginner' (pipe-separated, add AND/OR after terms, default OR)")
13349
+ site: stringType().optional().describe("Search within a specific website domain (e.g., 'github.com')"),
13350
+ fileType: stringType().optional().describe("Filter by a specific file type (e.g., 'pdf', 'doc', 'txt')"),
13351
+ language: stringType().optional().describe("Filter by a specific language using ISO 639-1 code (e.g., 'en', 'es', 'fr')"),
13352
+ excludeTerms: stringType().optional().describe("Terms to exclude with logical operators: 'spam AND|ads|NOT relevant' (pipe-separated, add AND/OR after terms, default OR)"),
13353
+ exactTerms: stringType().optional().describe("Exact terms with logical operators: 'python AND|tutorial|NOT beginner' (pipe-separated, add AND/OR after terms, default OR)")
17140
13354
  });
17141
- var WebResultSchema = objectType2({
17142
- url: stringType2().describe("The URL of the specific search result."),
17143
- title: stringType2().describe(`
13355
+ var WebResultSchema = objectType({
13356
+ url: stringType().describe("The URL of the specific search result."),
13357
+ title: stringType().describe(`
17144
13358
  The title or name of the search result.
17145
13359
  Example: "The World's Greatest Search Engine!"
17146
13360
  `),
17147
- description: stringType2().describe(`
13361
+ description: stringType().describe(`
17148
13362
  A brief description of the content of the search result.
17149
13363
  Example: "Search on YDC"
17150
13364
  `),
17151
- snippets: arrayType2(stringType2()).describe("An array of text snippets from the search result, providing a preview of the content."),
17152
- thumbnail_url: stringType2().optional().describe(`
13365
+ snippets: arrayType(stringType()).describe("An array of text snippets from the search result, providing a preview of the content."),
13366
+ thumbnail_url: stringType().optional().describe(`
17153
13367
  URL of the thumbnail.
17154
13368
  Example: "https://www.somethumbnailsite.com/thumbnail.jpg"
17155
13369
  `),
17156
- original_thumbnail_url: stringType2().optional().describe(`
13370
+ original_thumbnail_url: stringType().optional().describe(`
17157
13371
  URL of the original thumbnail.
17158
13372
  Example: "https://www.somethumbnailsite.com/thumbnail.jpg"
17159
13373
  `),
17160
- page_age: stringType2().describe(`
13374
+ page_age: stringType().optional().describe(`
17161
13375
  The age of the search result.
17162
13376
  Example: "2025-06-25T11:41:00"
17163
13377
  `),
17164
- authors: arrayType2(stringType2()).optional().describe("An array of authors of the search result."),
17165
- favicon_url: stringType2().optional().describe(`
13378
+ authors: arrayType(stringType()).optional().describe("An array of authors of the search result."),
13379
+ favicon_url: stringType().optional().describe(`
17166
13380
  The URL of the favicon of the search result's domain.
17167
13381
  Example: "https://someurl.com/favicon"
17168
13382
  `)
17169
13383
  });
17170
- var NewsResultSchema = objectType2({
17171
- title: stringType2().describe(`
13384
+ var NewsResultSchema = objectType({
13385
+ title: stringType().describe(`
17172
13386
  The title of the news result.
17173
13387
  Example: "Exclusive | You.com becomes the backbone of the EU's AI strategy"
17174
13388
  `),
17175
- description: stringType2().describe(`
13389
+ description: stringType().describe(`
17176
13390
  A brief description of the content of the news result.
17177
13391
  Example: "As the EU's AI strategy is being debated, You.com becomes the backbone of the EU's AI strategy."
17178
13392
  `),
17179
- page_age: stringType2().describe(`
13393
+ page_age: stringType().describe(`
17180
13394
  UTC timestamp of the article's publication date.
17181
13395
  Example: "2025-06-25T11:41:00"
17182
13396
  `),
17183
- thumbnail_url: stringType2().optional().describe(`
13397
+ thumbnail_url: stringType().optional().describe(`
17184
13398
  URL of the thumbnail.
17185
13399
  Example: "https://www.somethumbnailsite.com/thumbnail.jpg"
17186
13400
  `),
17187
- original_thumbnail_url: stringType2().optional().describe(`
13401
+ original_thumbnail_url: stringType().optional().describe(`
17188
13402
  URL of the original thumbnail.
17189
13403
  Example: "https://www.somethumbnailsite.com/thumbnail.jpg"
17190
13404
  `),
17191
- url: stringType2().describe(`
13405
+ url: stringType().describe(`
17192
13406
  The URL of the news result.
17193
13407
  Example: "https://www.you.com/news/eu-ai-strategy-youcom"
17194
13408
  `)
17195
13409
  });
17196
- var MetadataSchema = objectType2({
17197
- request_uuid: stringType2().describe(`
13410
+ var MetadataSchema = objectType({
13411
+ request_uuid: stringType().describe(`
17198
13412
  The request id of the query sent to the You.com API
17199
13413
  Example: "942ccbdd-7705-4d9c-9d37-4ef386658e90"
17200
13414
  `).optional(),
17201
- query: stringType2().describe(`The query to sent to the You.com API
13415
+ query: stringType().describe(`The query to sent to the You.com API
17202
13416
  Example: "China"`),
17203
- latency: numberType2().describe(`
13417
+ latency: numberType().describe(`
17204
13418
  The latency of the query sent to the You.com API
17205
13419
  Example: 0.123`)
17206
13420
  });
17207
- var SearchResponseSchema = objectType2({
17208
- results: objectType2({
17209
- web: arrayType2(WebResultSchema).optional(),
17210
- news: arrayType2(NewsResultSchema).optional()
13421
+ var SearchResponseSchema = objectType({
13422
+ results: objectType({
13423
+ web: arrayType(WebResultSchema).optional(),
13424
+ news: arrayType(NewsResultSchema).optional()
17211
13425
  }),
17212
13426
  metadata: MetadataSchema.partial()
17213
13427
  });