@elysiajs/openapi 1.4.14 → 1.4.15

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.
@@ -4157,6 +4157,7 @@ __export(util_exports, {
4157
4157
  objectClone: () => objectClone,
4158
4158
  omit: () => omit,
4159
4159
  optionalKeys: () => optionalKeys,
4160
+ parsedType: () => parsedType,
4160
4161
  partial: () => partial,
4161
4162
  pick: () => pick,
4162
4163
  prefixIssues: () => prefixIssues,
@@ -4489,6 +4490,11 @@ var BIGINT_FORMAT_RANGES = {
4489
4490
  };
4490
4491
  function pick(schema, mask) {
4491
4492
  const currDef = schema._zod.def;
4493
+ const checks = currDef.checks;
4494
+ const hasChecks = checks && checks.length > 0;
4495
+ if (hasChecks) {
4496
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
4497
+ }
4492
4498
  const def = mergeDefs(schema._zod.def, {
4493
4499
  get shape() {
4494
4500
  const newShape = {};
@@ -4509,6 +4515,11 @@ function pick(schema, mask) {
4509
4515
  }
4510
4516
  function omit(schema, mask) {
4511
4517
  const currDef = schema._zod.def;
4518
+ const checks = currDef.checks;
4519
+ const hasChecks = checks && checks.length > 0;
4520
+ if (hasChecks) {
4521
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
4522
+ }
4512
4523
  const def = mergeDefs(schema._zod.def, {
4513
4524
  get shape() {
4514
4525
  const newShape = { ...schema._zod.def.shape };
@@ -4534,15 +4545,19 @@ function extend(schema, shape) {
4534
4545
  const checks = schema._zod.def.checks;
4535
4546
  const hasChecks = checks && checks.length > 0;
4536
4547
  if (hasChecks) {
4537
- throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
4548
+ const existingShape = schema._zod.def.shape;
4549
+ for (const key in shape) {
4550
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
4551
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
4552
+ }
4553
+ }
4538
4554
  }
4539
4555
  const def = mergeDefs(schema._zod.def, {
4540
4556
  get shape() {
4541
4557
  const _shape = { ...schema._zod.def.shape, ...shape };
4542
4558
  assignProp(this, "shape", _shape);
4543
4559
  return _shape;
4544
- },
4545
- checks: []
4560
+ }
4546
4561
  });
4547
4562
  return clone(schema, def);
4548
4563
  }
@@ -4550,15 +4565,13 @@ function safeExtend(schema, shape) {
4550
4565
  if (!isPlainObject(shape)) {
4551
4566
  throw new Error("Invalid input to safeExtend: expected a plain object");
4552
4567
  }
4553
- const def = {
4554
- ...schema._zod.def,
4568
+ const def = mergeDefs(schema._zod.def, {
4555
4569
  get shape() {
4556
4570
  const _shape = { ...schema._zod.def.shape, ...shape };
4557
4571
  assignProp(this, "shape", _shape);
4558
4572
  return _shape;
4559
- },
4560
- checks: schema._zod.def.checks
4561
- };
4573
+ }
4574
+ });
4562
4575
  return clone(schema, def);
4563
4576
  }
4564
4577
  function merge(a, b) {
@@ -4577,6 +4590,12 @@ function merge(a, b) {
4577
4590
  return clone(a, def);
4578
4591
  }
4579
4592
  function partial(Class2, schema, mask) {
4593
+ const currDef = schema._zod.def;
4594
+ const checks = currDef.checks;
4595
+ const hasChecks = checks && checks.length > 0;
4596
+ if (hasChecks) {
4597
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
4598
+ }
4580
4599
  const def = mergeDefs(schema._zod.def, {
4581
4600
  get shape() {
4582
4601
  const oldShape = schema._zod.def.shape;
@@ -4635,8 +4654,7 @@ function required(Class2, schema, mask) {
4635
4654
  }
4636
4655
  assignProp(this, "shape", shape);
4637
4656
  return shape;
4638
- },
4639
- checks: []
4657
+ }
4640
4658
  });
4641
4659
  return clone(schema, def);
4642
4660
  }
@@ -4690,6 +4708,27 @@ function getLengthableOrigin(input) {
4690
4708
  return "string";
4691
4709
  return "unknown";
4692
4710
  }
4711
+ function parsedType(data) {
4712
+ const t = typeof data;
4713
+ switch (t) {
4714
+ case "number": {
4715
+ return Number.isNaN(data) ? "nan" : "number";
4716
+ }
4717
+ case "object": {
4718
+ if (data === null) {
4719
+ return "null";
4720
+ }
4721
+ if (Array.isArray(data)) {
4722
+ return "array";
4723
+ }
4724
+ const obj = data;
4725
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
4726
+ return obj.constructor.name;
4727
+ }
4728
+ }
4729
+ }
4730
+ return t;
4731
+ }
4693
4732
  function issue(...args) {
4694
4733
  const [iss, input, inst] = args;
4695
4734
  if (typeof iss === "string") {
@@ -4918,7 +4957,7 @@ var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]
4918
4957
  var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
4919
4958
  var base642 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
4920
4959
  var base64url = /^[A-Za-z0-9_-]*$/;
4921
- var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
4960
+ var e164 = /^\+[1-9]\d{6,14}$/;
4922
4961
  var dateSource = `(?:(?:\\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])))`;
4923
4962
  var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
4924
4963
  function timeSource(args) {
@@ -4945,7 +4984,7 @@ var string2 = (params) => {
4945
4984
  };
4946
4985
  var bigint = /^-?\d+n?$/;
4947
4986
  var integer = /^-?\d+$/;
4948
- var number = /^-?\d+(?:\.\d+)?/;
4987
+ var number = /^-?\d+(?:\.\d+)?$/;
4949
4988
  var boolean = /^(?:true|false)$/i;
4950
4989
  var _null = /^null$/i;
4951
4990
  var _undefined = /^undefined$/i;
@@ -4984,7 +5023,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
4984
5023
  payload.issues.push({
4985
5024
  origin,
4986
5025
  code: "too_big",
4987
- maximum: def.value,
5026
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
4988
5027
  input: payload.value,
4989
5028
  inclusive: def.inclusive,
4990
5029
  inst,
@@ -5012,7 +5051,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
5012
5051
  payload.issues.push({
5013
5052
  origin,
5014
5053
  code: "too_small",
5015
- minimum: def.value,
5054
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
5016
5055
  input: payload.value,
5017
5056
  inclusive: def.inclusive,
5018
5057
  inst,
@@ -5079,6 +5118,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
5079
5118
  note: "Integers must be within the safe integer range.",
5080
5119
  inst,
5081
5120
  origin,
5121
+ inclusive: true,
5082
5122
  continue: !def.abort
5083
5123
  });
5084
5124
  } else {
@@ -5089,6 +5129,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
5089
5129
  note: "Integers must be within the safe integer range.",
5090
5130
  inst,
5091
5131
  origin,
5132
+ inclusive: true,
5092
5133
  continue: !def.abort
5093
5134
  });
5094
5135
  }
@@ -5112,7 +5153,9 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
5112
5153
  input,
5113
5154
  code: "too_big",
5114
5155
  maximum,
5115
- inst
5156
+ inclusive: true,
5157
+ inst,
5158
+ continue: !def.abort
5116
5159
  });
5117
5160
  }
5118
5161
  };
@@ -5377,8 +5420,8 @@ var Doc = class {
5377
5420
  // node_modules/zod/v4/core/versions.js
5378
5421
  var version = {
5379
5422
  major: 4,
5380
- minor: 2,
5381
- patch: 1
5423
+ minor: 3,
5424
+ patch: 6
5382
5425
  };
5383
5426
 
5384
5427
  // node_modules/zod/v4/core/schemas.js
@@ -5478,7 +5521,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
5478
5521
  return runChecks(result, checks, ctx);
5479
5522
  };
5480
5523
  }
5481
- inst["~standard"] = {
5524
+ defineLazy(inst, "~standard", () => ({
5482
5525
  validate: (value) => {
5483
5526
  try {
5484
5527
  const r = safeParse2(inst, value);
@@ -5489,7 +5532,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
5489
5532
  },
5490
5533
  vendor: "zod",
5491
5534
  version: 1
5492
- };
5535
+ }));
5493
5536
  });
5494
5537
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
5495
5538
  $ZodType.init(inst, def);
@@ -6000,8 +6043,11 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
6000
6043
  return payload;
6001
6044
  };
6002
6045
  });
6003
- function handlePropertyResult(result, final, key, input) {
6046
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
6004
6047
  if (result.issues.length) {
6048
+ if (isOptionalOut && !(key in input)) {
6049
+ return;
6050
+ }
6005
6051
  final.issues.push(...prefixIssues(key, result.issues));
6006
6052
  }
6007
6053
  if (result.value === void 0) {
@@ -6033,6 +6079,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
6033
6079
  const keySet = def.keySet;
6034
6080
  const _catchall = def.catchall._zod;
6035
6081
  const t = _catchall.def.type;
6082
+ const isOptionalOut = _catchall.optout === "optional";
6036
6083
  for (const key in input) {
6037
6084
  if (keySet.has(key))
6038
6085
  continue;
@@ -6042,9 +6089,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
6042
6089
  }
6043
6090
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
6044
6091
  if (r instanceof Promise) {
6045
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
6092
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
6046
6093
  } else {
6047
- handlePropertyResult(r, payload, key, input);
6094
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
6048
6095
  }
6049
6096
  }
6050
6097
  if (unrecognized.length) {
@@ -6110,11 +6157,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
6110
6157
  const shape = value.shape;
6111
6158
  for (const key of value.keys) {
6112
6159
  const el = shape[key];
6160
+ const isOptionalOut = el._zod.optout === "optional";
6113
6161
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
6114
6162
  if (r instanceof Promise) {
6115
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
6163
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
6116
6164
  } else {
6117
- handlePropertyResult(r, payload, key, input);
6165
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
6118
6166
  }
6119
6167
  }
6120
6168
  if (!catchall) {
@@ -6144,8 +6192,31 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
6144
6192
  for (const key of normalized.keys) {
6145
6193
  const id = ids[key];
6146
6194
  const k = esc(key);
6195
+ const schema = shape[key];
6196
+ const isOptionalOut = schema?._zod?.optout === "optional";
6147
6197
  doc.write(`const ${id} = ${parseStr(key)};`);
6148
- doc.write(`
6198
+ if (isOptionalOut) {
6199
+ doc.write(`
6200
+ if (${id}.issues.length) {
6201
+ if (${k} in input) {
6202
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
6203
+ ...iss,
6204
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
6205
+ })));
6206
+ }
6207
+ }
6208
+
6209
+ if (${id}.value === undefined) {
6210
+ if (${k} in input) {
6211
+ newResult[${k}] = undefined;
6212
+ }
6213
+ } else {
6214
+ newResult[${k}] = ${id}.value;
6215
+ }
6216
+
6217
+ `);
6218
+ } else {
6219
+ doc.write(`
6149
6220
  if (${id}.issues.length) {
6150
6221
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
6151
6222
  ...iss,
@@ -6153,7 +6224,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
6153
6224
  })));
6154
6225
  }
6155
6226
 
6156
-
6157
6227
  if (${id}.value === undefined) {
6158
6228
  if (${k} in input) {
6159
6229
  newResult[${k}] = undefined;
@@ -6163,6 +6233,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
6163
6233
  }
6164
6234
 
6165
6235
  `);
6236
+ }
6166
6237
  }
6167
6238
  doc.write(`payload.value = newResult;`);
6168
6239
  doc.write(`return payload;`);
@@ -6391,11 +6462,34 @@ function mergeValues(a, b) {
6391
6462
  return { valid: false, mergeErrorPath: [] };
6392
6463
  }
6393
6464
  function handleIntersectionResults(result, left, right) {
6394
- if (left.issues.length) {
6395
- result.issues.push(...left.issues);
6465
+ const unrecKeys = /* @__PURE__ */ new Map();
6466
+ let unrecIssue;
6467
+ for (const iss of left.issues) {
6468
+ if (iss.code === "unrecognized_keys") {
6469
+ unrecIssue ?? (unrecIssue = iss);
6470
+ for (const k of iss.keys) {
6471
+ if (!unrecKeys.has(k))
6472
+ unrecKeys.set(k, {});
6473
+ unrecKeys.get(k).l = true;
6474
+ }
6475
+ } else {
6476
+ result.issues.push(iss);
6477
+ }
6478
+ }
6479
+ for (const iss of right.issues) {
6480
+ if (iss.code === "unrecognized_keys") {
6481
+ for (const k of iss.keys) {
6482
+ if (!unrecKeys.has(k))
6483
+ unrecKeys.set(k, {});
6484
+ unrecKeys.get(k).r = true;
6485
+ }
6486
+ } else {
6487
+ result.issues.push(iss);
6488
+ }
6396
6489
  }
6397
- if (right.issues.length) {
6398
- result.issues.push(...right.issues);
6490
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
6491
+ if (bothKeys.length && unrecIssue) {
6492
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
6399
6493
  }
6400
6494
  if (aborted(result))
6401
6495
  return result;
@@ -6429,7 +6523,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
6429
6523
  const tooSmall = input.length < optStart - 1;
6430
6524
  if (tooBig || tooSmall) {
6431
6525
  payload.issues.push({
6432
- ...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
6526
+ ...tooBig ? { code: "too_big", maximum: items.length, inclusive: true } : { code: "too_small", minimum: items.length },
6433
6527
  input,
6434
6528
  inst,
6435
6529
  origin: "array"
@@ -6537,10 +6631,20 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
6537
6631
  for (const key of Reflect.ownKeys(input)) {
6538
6632
  if (key === "__proto__")
6539
6633
  continue;
6540
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
6634
+ let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
6541
6635
  if (keyResult instanceof Promise) {
6542
6636
  throw new Error("Async schemas not supported in object keys currently");
6543
6637
  }
6638
+ const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
6639
+ if (checkNumericKey) {
6640
+ const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
6641
+ if (retryResult instanceof Promise) {
6642
+ throw new Error("Async schemas not supported in object keys currently");
6643
+ }
6644
+ if (retryResult.issues.length === 0) {
6645
+ keyResult = retryResult;
6646
+ }
6647
+ }
6544
6648
  if (keyResult.issues.length) {
6545
6649
  if (def.mode === "loose") {
6546
6650
  payload.value[key] = input[key];
@@ -6671,6 +6775,14 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
6671
6775
  return def.innerType._zod.run(payload, ctx);
6672
6776
  };
6673
6777
  });
6778
+ var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
6779
+ $ZodOptional.init(inst, def);
6780
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
6781
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
6782
+ inst._zod.parse = (payload, ctx) => {
6783
+ return def.innerType._zod.run(payload, ctx);
6784
+ };
6785
+ });
6674
6786
  var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
6675
6787
  $ZodType.init(inst, def);
6676
6788
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -6892,9 +7004,6 @@ var $ZodRegistry = class {
6892
7004
  const meta2 = _meta[0];
6893
7005
  this._map.set(schema, meta2);
6894
7006
  if (meta2 && typeof meta2 === "object" && "id" in meta2) {
6895
- if (this._idmap.has(meta2.id)) {
6896
- throw new Error(`ID ${meta2.id} already exists in the registry`);
6897
- }
6898
7007
  this._idmap.set(meta2.id, schema);
6899
7008
  }
6900
7009
  return this;
@@ -6933,12 +7042,14 @@ function registry() {
6933
7042
  var globalRegistry = globalThis.__zod_globalRegistry;
6934
7043
 
6935
7044
  // node_modules/zod/v4/core/api.js
7045
+ // @__NO_SIDE_EFFECTS__
6936
7046
  function _string(Class2, params) {
6937
7047
  return new Class2({
6938
7048
  type: "string",
6939
7049
  ...normalizeParams(params)
6940
7050
  });
6941
7051
  }
7052
+ // @__NO_SIDE_EFFECTS__
6942
7053
  function _email(Class2, params) {
6943
7054
  return new Class2({
6944
7055
  type: "string",
@@ -6948,6 +7059,7 @@ function _email(Class2, params) {
6948
7059
  ...normalizeParams(params)
6949
7060
  });
6950
7061
  }
7062
+ // @__NO_SIDE_EFFECTS__
6951
7063
  function _guid(Class2, params) {
6952
7064
  return new Class2({
6953
7065
  type: "string",
@@ -6957,6 +7069,7 @@ function _guid(Class2, params) {
6957
7069
  ...normalizeParams(params)
6958
7070
  });
6959
7071
  }
7072
+ // @__NO_SIDE_EFFECTS__
6960
7073
  function _uuid(Class2, params) {
6961
7074
  return new Class2({
6962
7075
  type: "string",
@@ -6966,6 +7079,7 @@ function _uuid(Class2, params) {
6966
7079
  ...normalizeParams(params)
6967
7080
  });
6968
7081
  }
7082
+ // @__NO_SIDE_EFFECTS__
6969
7083
  function _uuidv4(Class2, params) {
6970
7084
  return new Class2({
6971
7085
  type: "string",
@@ -6976,6 +7090,7 @@ function _uuidv4(Class2, params) {
6976
7090
  ...normalizeParams(params)
6977
7091
  });
6978
7092
  }
7093
+ // @__NO_SIDE_EFFECTS__
6979
7094
  function _uuidv6(Class2, params) {
6980
7095
  return new Class2({
6981
7096
  type: "string",
@@ -6986,6 +7101,7 @@ function _uuidv6(Class2, params) {
6986
7101
  ...normalizeParams(params)
6987
7102
  });
6988
7103
  }
7104
+ // @__NO_SIDE_EFFECTS__
6989
7105
  function _uuidv7(Class2, params) {
6990
7106
  return new Class2({
6991
7107
  type: "string",
@@ -6996,6 +7112,7 @@ function _uuidv7(Class2, params) {
6996
7112
  ...normalizeParams(params)
6997
7113
  });
6998
7114
  }
7115
+ // @__NO_SIDE_EFFECTS__
6999
7116
  function _url(Class2, params) {
7000
7117
  return new Class2({
7001
7118
  type: "string",
@@ -7005,6 +7122,7 @@ function _url(Class2, params) {
7005
7122
  ...normalizeParams(params)
7006
7123
  });
7007
7124
  }
7125
+ // @__NO_SIDE_EFFECTS__
7008
7126
  function _emoji2(Class2, params) {
7009
7127
  return new Class2({
7010
7128
  type: "string",
@@ -7014,6 +7132,7 @@ function _emoji2(Class2, params) {
7014
7132
  ...normalizeParams(params)
7015
7133
  });
7016
7134
  }
7135
+ // @__NO_SIDE_EFFECTS__
7017
7136
  function _nanoid(Class2, params) {
7018
7137
  return new Class2({
7019
7138
  type: "string",
@@ -7023,6 +7142,7 @@ function _nanoid(Class2, params) {
7023
7142
  ...normalizeParams(params)
7024
7143
  });
7025
7144
  }
7145
+ // @__NO_SIDE_EFFECTS__
7026
7146
  function _cuid(Class2, params) {
7027
7147
  return new Class2({
7028
7148
  type: "string",
@@ -7032,6 +7152,7 @@ function _cuid(Class2, params) {
7032
7152
  ...normalizeParams(params)
7033
7153
  });
7034
7154
  }
7155
+ // @__NO_SIDE_EFFECTS__
7035
7156
  function _cuid2(Class2, params) {
7036
7157
  return new Class2({
7037
7158
  type: "string",
@@ -7041,6 +7162,7 @@ function _cuid2(Class2, params) {
7041
7162
  ...normalizeParams(params)
7042
7163
  });
7043
7164
  }
7165
+ // @__NO_SIDE_EFFECTS__
7044
7166
  function _ulid(Class2, params) {
7045
7167
  return new Class2({
7046
7168
  type: "string",
@@ -7050,6 +7172,7 @@ function _ulid(Class2, params) {
7050
7172
  ...normalizeParams(params)
7051
7173
  });
7052
7174
  }
7175
+ // @__NO_SIDE_EFFECTS__
7053
7176
  function _xid(Class2, params) {
7054
7177
  return new Class2({
7055
7178
  type: "string",
@@ -7059,6 +7182,7 @@ function _xid(Class2, params) {
7059
7182
  ...normalizeParams(params)
7060
7183
  });
7061
7184
  }
7185
+ // @__NO_SIDE_EFFECTS__
7062
7186
  function _ksuid(Class2, params) {
7063
7187
  return new Class2({
7064
7188
  type: "string",
@@ -7068,6 +7192,7 @@ function _ksuid(Class2, params) {
7068
7192
  ...normalizeParams(params)
7069
7193
  });
7070
7194
  }
7195
+ // @__NO_SIDE_EFFECTS__
7071
7196
  function _ipv4(Class2, params) {
7072
7197
  return new Class2({
7073
7198
  type: "string",
@@ -7077,6 +7202,7 @@ function _ipv4(Class2, params) {
7077
7202
  ...normalizeParams(params)
7078
7203
  });
7079
7204
  }
7205
+ // @__NO_SIDE_EFFECTS__
7080
7206
  function _ipv6(Class2, params) {
7081
7207
  return new Class2({
7082
7208
  type: "string",
@@ -7086,6 +7212,7 @@ function _ipv6(Class2, params) {
7086
7212
  ...normalizeParams(params)
7087
7213
  });
7088
7214
  }
7215
+ // @__NO_SIDE_EFFECTS__
7089
7216
  function _cidrv4(Class2, params) {
7090
7217
  return new Class2({
7091
7218
  type: "string",
@@ -7095,6 +7222,7 @@ function _cidrv4(Class2, params) {
7095
7222
  ...normalizeParams(params)
7096
7223
  });
7097
7224
  }
7225
+ // @__NO_SIDE_EFFECTS__
7098
7226
  function _cidrv6(Class2, params) {
7099
7227
  return new Class2({
7100
7228
  type: "string",
@@ -7104,6 +7232,7 @@ function _cidrv6(Class2, params) {
7104
7232
  ...normalizeParams(params)
7105
7233
  });
7106
7234
  }
7235
+ // @__NO_SIDE_EFFECTS__
7107
7236
  function _base64(Class2, params) {
7108
7237
  return new Class2({
7109
7238
  type: "string",
@@ -7113,6 +7242,7 @@ function _base64(Class2, params) {
7113
7242
  ...normalizeParams(params)
7114
7243
  });
7115
7244
  }
7245
+ // @__NO_SIDE_EFFECTS__
7116
7246
  function _base64url(Class2, params) {
7117
7247
  return new Class2({
7118
7248
  type: "string",
@@ -7122,6 +7252,7 @@ function _base64url(Class2, params) {
7122
7252
  ...normalizeParams(params)
7123
7253
  });
7124
7254
  }
7255
+ // @__NO_SIDE_EFFECTS__
7125
7256
  function _e164(Class2, params) {
7126
7257
  return new Class2({
7127
7258
  type: "string",
@@ -7131,6 +7262,7 @@ function _e164(Class2, params) {
7131
7262
  ...normalizeParams(params)
7132
7263
  });
7133
7264
  }
7265
+ // @__NO_SIDE_EFFECTS__
7134
7266
  function _jwt(Class2, params) {
7135
7267
  return new Class2({
7136
7268
  type: "string",
@@ -7140,6 +7272,7 @@ function _jwt(Class2, params) {
7140
7272
  ...normalizeParams(params)
7141
7273
  });
7142
7274
  }
7275
+ // @__NO_SIDE_EFFECTS__
7143
7276
  function _isoDateTime(Class2, params) {
7144
7277
  return new Class2({
7145
7278
  type: "string",
@@ -7151,6 +7284,7 @@ function _isoDateTime(Class2, params) {
7151
7284
  ...normalizeParams(params)
7152
7285
  });
7153
7286
  }
7287
+ // @__NO_SIDE_EFFECTS__
7154
7288
  function _isoDate(Class2, params) {
7155
7289
  return new Class2({
7156
7290
  type: "string",
@@ -7159,6 +7293,7 @@ function _isoDate(Class2, params) {
7159
7293
  ...normalizeParams(params)
7160
7294
  });
7161
7295
  }
7296
+ // @__NO_SIDE_EFFECTS__
7162
7297
  function _isoTime(Class2, params) {
7163
7298
  return new Class2({
7164
7299
  type: "string",
@@ -7168,6 +7303,7 @@ function _isoTime(Class2, params) {
7168
7303
  ...normalizeParams(params)
7169
7304
  });
7170
7305
  }
7306
+ // @__NO_SIDE_EFFECTS__
7171
7307
  function _isoDuration(Class2, params) {
7172
7308
  return new Class2({
7173
7309
  type: "string",
@@ -7176,6 +7312,7 @@ function _isoDuration(Class2, params) {
7176
7312
  ...normalizeParams(params)
7177
7313
  });
7178
7314
  }
7315
+ // @__NO_SIDE_EFFECTS__
7179
7316
  function _int(Class2, params) {
7180
7317
  return new Class2({
7181
7318
  type: "number",
@@ -7185,17 +7322,20 @@ function _int(Class2, params) {
7185
7322
  ...normalizeParams(params)
7186
7323
  });
7187
7324
  }
7325
+ // @__NO_SIDE_EFFECTS__
7188
7326
  function _unknown(Class2) {
7189
7327
  return new Class2({
7190
7328
  type: "unknown"
7191
7329
  });
7192
7330
  }
7331
+ // @__NO_SIDE_EFFECTS__
7193
7332
  function _never(Class2, params) {
7194
7333
  return new Class2({
7195
7334
  type: "never",
7196
7335
  ...normalizeParams(params)
7197
7336
  });
7198
7337
  }
7338
+ // @__NO_SIDE_EFFECTS__
7199
7339
  function _lt(value, params) {
7200
7340
  return new $ZodCheckLessThan({
7201
7341
  check: "less_than",
@@ -7204,6 +7344,7 @@ function _lt(value, params) {
7204
7344
  inclusive: false
7205
7345
  });
7206
7346
  }
7347
+ // @__NO_SIDE_EFFECTS__
7207
7348
  function _lte(value, params) {
7208
7349
  return new $ZodCheckLessThan({
7209
7350
  check: "less_than",
@@ -7212,6 +7353,7 @@ function _lte(value, params) {
7212
7353
  inclusive: true
7213
7354
  });
7214
7355
  }
7356
+ // @__NO_SIDE_EFFECTS__
7215
7357
  function _gt(value, params) {
7216
7358
  return new $ZodCheckGreaterThan({
7217
7359
  check: "greater_than",
@@ -7220,6 +7362,7 @@ function _gt(value, params) {
7220
7362
  inclusive: false
7221
7363
  });
7222
7364
  }
7365
+ // @__NO_SIDE_EFFECTS__
7223
7366
  function _gte(value, params) {
7224
7367
  return new $ZodCheckGreaterThan({
7225
7368
  check: "greater_than",
@@ -7228,6 +7371,7 @@ function _gte(value, params) {
7228
7371
  inclusive: true
7229
7372
  });
7230
7373
  }
7374
+ // @__NO_SIDE_EFFECTS__
7231
7375
  function _multipleOf(value, params) {
7232
7376
  return new $ZodCheckMultipleOf({
7233
7377
  check: "multiple_of",
@@ -7235,6 +7379,7 @@ function _multipleOf(value, params) {
7235
7379
  value
7236
7380
  });
7237
7381
  }
7382
+ // @__NO_SIDE_EFFECTS__
7238
7383
  function _maxLength(maximum, params) {
7239
7384
  const ch = new $ZodCheckMaxLength({
7240
7385
  check: "max_length",
@@ -7243,6 +7388,7 @@ function _maxLength(maximum, params) {
7243
7388
  });
7244
7389
  return ch;
7245
7390
  }
7391
+ // @__NO_SIDE_EFFECTS__
7246
7392
  function _minLength(minimum, params) {
7247
7393
  return new $ZodCheckMinLength({
7248
7394
  check: "min_length",
@@ -7250,6 +7396,7 @@ function _minLength(minimum, params) {
7250
7396
  minimum
7251
7397
  });
7252
7398
  }
7399
+ // @__NO_SIDE_EFFECTS__
7253
7400
  function _length(length, params) {
7254
7401
  return new $ZodCheckLengthEquals({
7255
7402
  check: "length_equals",
@@ -7257,6 +7404,7 @@ function _length(length, params) {
7257
7404
  length
7258
7405
  });
7259
7406
  }
7407
+ // @__NO_SIDE_EFFECTS__
7260
7408
  function _regex(pattern, params) {
7261
7409
  return new $ZodCheckRegex({
7262
7410
  check: "string_format",
@@ -7265,6 +7413,7 @@ function _regex(pattern, params) {
7265
7413
  pattern
7266
7414
  });
7267
7415
  }
7416
+ // @__NO_SIDE_EFFECTS__
7268
7417
  function _lowercase(params) {
7269
7418
  return new $ZodCheckLowerCase({
7270
7419
  check: "string_format",
@@ -7272,6 +7421,7 @@ function _lowercase(params) {
7272
7421
  ...normalizeParams(params)
7273
7422
  });
7274
7423
  }
7424
+ // @__NO_SIDE_EFFECTS__
7275
7425
  function _uppercase(params) {
7276
7426
  return new $ZodCheckUpperCase({
7277
7427
  check: "string_format",
@@ -7279,6 +7429,7 @@ function _uppercase(params) {
7279
7429
  ...normalizeParams(params)
7280
7430
  });
7281
7431
  }
7432
+ // @__NO_SIDE_EFFECTS__
7282
7433
  function _includes(includes, params) {
7283
7434
  return new $ZodCheckIncludes({
7284
7435
  check: "string_format",
@@ -7287,6 +7438,7 @@ function _includes(includes, params) {
7287
7438
  includes
7288
7439
  });
7289
7440
  }
7441
+ // @__NO_SIDE_EFFECTS__
7290
7442
  function _startsWith(prefix, params) {
7291
7443
  return new $ZodCheckStartsWith({
7292
7444
  check: "string_format",
@@ -7295,6 +7447,7 @@ function _startsWith(prefix, params) {
7295
7447
  prefix
7296
7448
  });
7297
7449
  }
7450
+ // @__NO_SIDE_EFFECTS__
7298
7451
  function _endsWith(suffix, params) {
7299
7452
  return new $ZodCheckEndsWith({
7300
7453
  check: "string_format",
@@ -7303,27 +7456,34 @@ function _endsWith(suffix, params) {
7303
7456
  suffix
7304
7457
  });
7305
7458
  }
7459
+ // @__NO_SIDE_EFFECTS__
7306
7460
  function _overwrite(tx) {
7307
7461
  return new $ZodCheckOverwrite({
7308
7462
  check: "overwrite",
7309
7463
  tx
7310
7464
  });
7311
7465
  }
7466
+ // @__NO_SIDE_EFFECTS__
7312
7467
  function _normalize(form) {
7313
- return _overwrite((input) => input.normalize(form));
7468
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
7314
7469
  }
7470
+ // @__NO_SIDE_EFFECTS__
7315
7471
  function _trim() {
7316
- return _overwrite((input) => input.trim());
7472
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
7317
7473
  }
7474
+ // @__NO_SIDE_EFFECTS__
7318
7475
  function _toLowerCase() {
7319
- return _overwrite((input) => input.toLowerCase());
7476
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
7320
7477
  }
7478
+ // @__NO_SIDE_EFFECTS__
7321
7479
  function _toUpperCase() {
7322
- return _overwrite((input) => input.toUpperCase());
7480
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
7323
7481
  }
7482
+ // @__NO_SIDE_EFFECTS__
7324
7483
  function _slugify() {
7325
- return _overwrite((input) => slugify(input));
7484
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
7326
7485
  }
7486
+ // @__NO_SIDE_EFFECTS__
7327
7487
  function _array(Class2, element, params) {
7328
7488
  return new Class2({
7329
7489
  type: "array",
@@ -7334,6 +7494,7 @@ function _array(Class2, element, params) {
7334
7494
  ...normalizeParams(params)
7335
7495
  });
7336
7496
  }
7497
+ // @__NO_SIDE_EFFECTS__
7337
7498
  function _refine(Class2, fn, _params) {
7338
7499
  const schema = new Class2({
7339
7500
  type: "custom",
@@ -7343,8 +7504,9 @@ function _refine(Class2, fn, _params) {
7343
7504
  });
7344
7505
  return schema;
7345
7506
  }
7507
+ // @__NO_SIDE_EFFECTS__
7346
7508
  function _superRefine(fn) {
7347
- const ch = _check((payload) => {
7509
+ const ch = /* @__PURE__ */ _check((payload) => {
7348
7510
  payload.addIssue = (issue2) => {
7349
7511
  if (typeof issue2 === "string") {
7350
7512
  payload.issues.push(issue(issue2, payload.value, ch._zod.def));
@@ -7363,6 +7525,7 @@ function _superRefine(fn) {
7363
7525
  });
7364
7526
  return ch;
7365
7527
  }
7528
+ // @__NO_SIDE_EFFECTS__
7366
7529
  function _check(fn, params) {
7367
7530
  const ch = new $ZodCheck({
7368
7531
  check: "custom",
@@ -7417,12 +7580,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
7417
7580
  schemaPath: [..._params.schemaPath, schema],
7418
7581
  path: _params.path
7419
7582
  };
7420
- const parent = schema._zod.parent;
7421
- if (parent) {
7422
- result.ref = parent;
7423
- process2(parent, ctx, params);
7424
- ctx.seen.get(parent).isParent = true;
7425
- } else if (schema._zod.processJSONSchema) {
7583
+ if (schema._zod.processJSONSchema) {
7426
7584
  schema._zod.processJSONSchema(ctx, result.schema, params);
7427
7585
  } else {
7428
7586
  const _json = result.schema;
@@ -7432,6 +7590,13 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
7432
7590
  }
7433
7591
  processor(schema, ctx, _json, params);
7434
7592
  }
7593
+ const parent = schema._zod.parent;
7594
+ if (parent) {
7595
+ if (!result.ref)
7596
+ result.ref = parent;
7597
+ process2(parent, ctx, params);
7598
+ ctx.seen.get(parent).isParent = true;
7599
+ }
7435
7600
  }
7436
7601
  const meta2 = ctx.metadataRegistry.get(schema);
7437
7602
  if (meta2)
@@ -7450,6 +7615,17 @@ function extractDefs(ctx, schema) {
7450
7615
  const root = ctx.seen.get(schema);
7451
7616
  if (!root)
7452
7617
  throw new Error("Unprocessed schema. This is a bug in Zod.");
7618
+ const idToSchema = /* @__PURE__ */ new Map();
7619
+ for (const entry of ctx.seen.entries()) {
7620
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
7621
+ if (id) {
7622
+ const existing = idToSchema.get(id);
7623
+ if (existing && existing !== entry[0]) {
7624
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
7625
+ }
7626
+ idToSchema.set(id, entry[0]);
7627
+ }
7628
+ }
7453
7629
  const makeURI = (entry) => {
7454
7630
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
7455
7631
  if (ctx.external) {
@@ -7531,30 +7707,65 @@ function finalize(ctx, schema) {
7531
7707
  throw new Error("Unprocessed schema. This is a bug in Zod.");
7532
7708
  const flattenRef = (zodSchema) => {
7533
7709
  const seen = ctx.seen.get(zodSchema);
7710
+ if (seen.ref === null)
7711
+ return;
7534
7712
  const schema2 = seen.def ?? seen.schema;
7535
7713
  const _cached = { ...schema2 };
7536
- if (seen.ref === null) {
7537
- return;
7538
- }
7539
7714
  const ref = seen.ref;
7540
7715
  seen.ref = null;
7541
7716
  if (ref) {
7542
7717
  flattenRef(ref);
7543
- const refSchema = ctx.seen.get(ref).schema;
7718
+ const refSeen = ctx.seen.get(ref);
7719
+ const refSchema = refSeen.schema;
7544
7720
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
7545
7721
  schema2.allOf = schema2.allOf ?? [];
7546
7722
  schema2.allOf.push(refSchema);
7547
7723
  } else {
7548
7724
  Object.assign(schema2, refSchema);
7549
- Object.assign(schema2, _cached);
7725
+ }
7726
+ Object.assign(schema2, _cached);
7727
+ const isParentRef = zodSchema._zod.parent === ref;
7728
+ if (isParentRef) {
7729
+ for (const key in schema2) {
7730
+ if (key === "$ref" || key === "allOf")
7731
+ continue;
7732
+ if (!(key in _cached)) {
7733
+ delete schema2[key];
7734
+ }
7735
+ }
7736
+ }
7737
+ if (refSchema.$ref && refSeen.def) {
7738
+ for (const key in schema2) {
7739
+ if (key === "$ref" || key === "allOf")
7740
+ continue;
7741
+ if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
7742
+ delete schema2[key];
7743
+ }
7744
+ }
7550
7745
  }
7551
7746
  }
7552
- if (!seen.isParent)
7553
- ctx.override({
7554
- zodSchema,
7555
- jsonSchema: schema2,
7556
- path: seen.path ?? []
7557
- });
7747
+ const parent = zodSchema._zod.parent;
7748
+ if (parent && parent !== ref) {
7749
+ flattenRef(parent);
7750
+ const parentSeen = ctx.seen.get(parent);
7751
+ if (parentSeen?.schema.$ref) {
7752
+ schema2.$ref = parentSeen.schema.$ref;
7753
+ if (parentSeen.def) {
7754
+ for (const key in schema2) {
7755
+ if (key === "$ref" || key === "allOf")
7756
+ continue;
7757
+ if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
7758
+ delete schema2[key];
7759
+ }
7760
+ }
7761
+ }
7762
+ }
7763
+ }
7764
+ ctx.override({
7765
+ zodSchema,
7766
+ jsonSchema: schema2,
7767
+ path: seen.path ?? []
7768
+ });
7558
7769
  };
7559
7770
  for (const entry of [...ctx.seen.entries()].reverse()) {
7560
7771
  flattenRef(entry[0]);
@@ -7599,8 +7810,8 @@ function finalize(ctx, schema) {
7599
7810
  value: {
7600
7811
  ...schema["~standard"],
7601
7812
  jsonSchema: {
7602
- input: createStandardJSONSchemaMethod(schema, "input"),
7603
- output: createStandardJSONSchemaMethod(schema, "output")
7813
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
7814
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
7604
7815
  }
7605
7816
  },
7606
7817
  enumerable: false,
@@ -7668,9 +7879,9 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
7668
7879
  extractDefs(ctx, schema);
7669
7880
  return finalize(ctx, schema);
7670
7881
  };
7671
- var createStandardJSONSchemaMethod = (schema, io) => (params) => {
7882
+ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
7672
7883
  const { libraryOptions, target } = params ?? {};
7673
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors: {} });
7884
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
7674
7885
  process2(schema, ctx);
7675
7886
  extractDefs(ctx, schema);
7676
7887
  return finalize(ctx, schema);
@@ -7697,6 +7908,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
7697
7908
  json.format = formatMap[format] ?? format;
7698
7909
  if (json.format === "")
7699
7910
  delete json.format;
7911
+ if (format === "time") {
7912
+ delete json.format;
7913
+ }
7700
7914
  }
7701
7915
  if (contentEncoding)
7702
7916
  json.contentEncoding = contentEncoding;
@@ -7984,16 +8198,37 @@ var recordProcessor = (schema, ctx, _json, params) => {
7984
8198
  const json = _json;
7985
8199
  const def = schema._zod.def;
7986
8200
  json.type = "object";
7987
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
7988
- json.propertyNames = process2(def.keyType, ctx, {
8201
+ const keyType = def.keyType;
8202
+ const keyBag = keyType._zod.bag;
8203
+ const patterns = keyBag?.patterns;
8204
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
8205
+ const valueSchema = process2(def.valueType, ctx, {
8206
+ ...params,
8207
+ path: [...params.path, "patternProperties", "*"]
8208
+ });
8209
+ json.patternProperties = {};
8210
+ for (const pattern of patterns) {
8211
+ json.patternProperties[pattern.source] = valueSchema;
8212
+ }
8213
+ } else {
8214
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
8215
+ json.propertyNames = process2(def.keyType, ctx, {
8216
+ ...params,
8217
+ path: [...params.path, "propertyNames"]
8218
+ });
8219
+ }
8220
+ json.additionalProperties = process2(def.valueType, ctx, {
7989
8221
  ...params,
7990
- path: [...params.path, "propertyNames"]
8222
+ path: [...params.path, "additionalProperties"]
7991
8223
  });
7992
8224
  }
7993
- json.additionalProperties = process2(def.valueType, ctx, {
7994
- ...params,
7995
- path: [...params.path, "additionalProperties"]
7996
- });
8225
+ const keyValues = keyType._zod.values;
8226
+ if (keyValues) {
8227
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
8228
+ if (validKeyValues.length > 0) {
8229
+ json.required = validKeyValues;
8230
+ }
8231
+ }
7997
8232
  };
7998
8233
  var nullableProcessor = (schema, ctx, json, params) => {
7999
8234
  const def = schema._zod.def;
@@ -8170,8 +8405,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
8170
8405
  ...def.checks ?? [],
8171
8406
  ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
8172
8407
  ]
8173
- }));
8408
+ }), {
8409
+ parent: true
8410
+ });
8174
8411
  };
8412
+ inst.with = inst.check;
8175
8413
  inst.clone = (def2, params) => clone(inst, def2, params);
8176
8414
  inst.brand = () => inst;
8177
8415
  inst.register = ((reg, meta2) => {
@@ -8195,6 +8433,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
8195
8433
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
8196
8434
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
8197
8435
  inst.optional = () => optional(inst);
8436
+ inst.exactOptional = () => exactOptional(inst);
8198
8437
  inst.nullable = () => nullable(inst);
8199
8438
  inst.nullish = () => optional(nullable(inst));
8200
8439
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -8228,6 +8467,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
8228
8467
  };
8229
8468
  inst.isOptional = () => inst.safeParse(void 0).success;
8230
8469
  inst.isNullable = () => inst.safeParse(null).success;
8470
+ inst.apply = (fn) => fn(inst);
8231
8471
  return inst;
8232
8472
  });
8233
8473
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
@@ -8673,6 +8913,18 @@ function optional(innerType) {
8673
8913
  innerType
8674
8914
  });
8675
8915
  }
8916
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
8917
+ $ZodExactOptional.init(inst, def);
8918
+ ZodType.init(inst, def);
8919
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
8920
+ inst.unwrap = () => inst._zod.def.innerType;
8921
+ });
8922
+ function exactOptional(innerType) {
8923
+ return new ZodExactOptional({
8924
+ type: "optional",
8925
+ innerType
8926
+ });
8927
+ }
8676
8928
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
8677
8929
  $ZodNullable.init(inst, def);
8678
8930
  ZodType.init(inst, def);