@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.
package/dist/cjs/index.js CHANGED
@@ -131,29 +131,30 @@ var SwaggerUIRender = (info, config2) => {
131
131
 
132
132
  // src/scalar/index.ts
133
133
  var elysiaCSS = `.light-mode {
134
- --scalar-color-1: #2a2f45;
135
- --scalar-color-2: #757575;
136
- --scalar-color-3: #8e8e8e;
137
- --scalar-color-accent: #f06292;
134
+ --scalar-color-1: oklch(43.5% 0.029 321.78);
135
+ --scalar-color-2: oklch(54.2% 0.034 322.5);
136
+ --scalar-color-3: oklch(71.1% 0.019 323.02);
137
+ --scalar-color-accent: oklch(71.2% 0.194 13.428);
138
138
 
139
- --scalar-background-1: #fff;
140
- --scalar-background-2: #f6f6f6;
141
- --scalar-background-3: #e7e7e7;
139
+ --scalar-background-1: oklch(98.5% 0 0);
140
+ --scalar-background-2: oklch(96% 0.003 325.6);
141
+ --scalar-background-3: oklch(92.2% 0.005 325.62);
142
142
 
143
- --scalar-border-color: rgba(0, 0, 0, 0.1);
143
+ --scalar-border-color: oklch(92.2% 0.005 325.62);
144
144
  }
145
+
145
146
  .dark-mode {
146
- --scalar-color-1: rgba(255, 255, 255, 0.9);
147
- --scalar-color-2: rgba(156, 163, 175, 1);
148
- --scalar-color-3: rgba(255, 255, 255, 0.44);
149
- --scalar-color-accent: #f06292;
147
+ --scalar-color-1: oklch(98.5% 0 0);
148
+ --scalar-color-2: oklch(71.1% 0.019 323.02);
149
+ --scalar-color-3: oklch(86.5% 0.012 325.68);
150
+ --scalar-color-accent: oklch(89.2% 0.058 10.001);
150
151
 
151
- --scalar-background-1: #111728;
152
- --scalar-background-2: #1e293b;
153
- --scalar-background-3: #334155;
154
- --scalar-background-accent: #f062921f;
152
+ --scalar-background-1: oklch(21.2% 0.019 322.12);
153
+ --scalar-background-2: oklch(26.3% 0.024 320.12);
154
+ --scalar-background-3: oklch(36.4% 0.029 323.89);
155
+ --scalar-background-accent: oklch(43.5% 0.029 321.78);
155
156
 
156
- --scalar-border-color: rgba(255, 255, 255, 0.1);
157
+ --scalar-border-color: oklch(36.4% 0.029 323.89);
157
158
  }
158
159
 
159
160
  /* Document Sidebar */
@@ -5129,6 +5130,7 @@ __export(util_exports, {
5129
5130
  objectClone: () => objectClone,
5130
5131
  omit: () => omit,
5131
5132
  optionalKeys: () => optionalKeys,
5133
+ parsedType: () => parsedType,
5132
5134
  partial: () => partial,
5133
5135
  pick: () => pick,
5134
5136
  prefixIssues: () => prefixIssues,
@@ -5461,6 +5463,11 @@ var BIGINT_FORMAT_RANGES = {
5461
5463
  };
5462
5464
  function pick(schema, mask) {
5463
5465
  const currDef = schema._zod.def;
5466
+ const checks = currDef.checks;
5467
+ const hasChecks = checks && checks.length > 0;
5468
+ if (hasChecks) {
5469
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
5470
+ }
5464
5471
  const def = mergeDefs(schema._zod.def, {
5465
5472
  get shape() {
5466
5473
  const newShape = {};
@@ -5481,6 +5488,11 @@ function pick(schema, mask) {
5481
5488
  }
5482
5489
  function omit(schema, mask) {
5483
5490
  const currDef = schema._zod.def;
5491
+ const checks = currDef.checks;
5492
+ const hasChecks = checks && checks.length > 0;
5493
+ if (hasChecks) {
5494
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
5495
+ }
5484
5496
  const def = mergeDefs(schema._zod.def, {
5485
5497
  get shape() {
5486
5498
  const newShape = { ...schema._zod.def.shape };
@@ -5506,15 +5518,19 @@ function extend(schema, shape) {
5506
5518
  const checks = schema._zod.def.checks;
5507
5519
  const hasChecks = checks && checks.length > 0;
5508
5520
  if (hasChecks) {
5509
- throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
5521
+ const existingShape = schema._zod.def.shape;
5522
+ for (const key in shape) {
5523
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
5524
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
5525
+ }
5526
+ }
5510
5527
  }
5511
5528
  const def = mergeDefs(schema._zod.def, {
5512
5529
  get shape() {
5513
5530
  const _shape = { ...schema._zod.def.shape, ...shape };
5514
5531
  assignProp(this, "shape", _shape);
5515
5532
  return _shape;
5516
- },
5517
- checks: []
5533
+ }
5518
5534
  });
5519
5535
  return clone(schema, def);
5520
5536
  }
@@ -5522,15 +5538,13 @@ function safeExtend(schema, shape) {
5522
5538
  if (!isPlainObject(shape)) {
5523
5539
  throw new Error("Invalid input to safeExtend: expected a plain object");
5524
5540
  }
5525
- const def = {
5526
- ...schema._zod.def,
5541
+ const def = mergeDefs(schema._zod.def, {
5527
5542
  get shape() {
5528
5543
  const _shape = { ...schema._zod.def.shape, ...shape };
5529
5544
  assignProp(this, "shape", _shape);
5530
5545
  return _shape;
5531
- },
5532
- checks: schema._zod.def.checks
5533
- };
5546
+ }
5547
+ });
5534
5548
  return clone(schema, def);
5535
5549
  }
5536
5550
  function merge(a, b) {
@@ -5549,6 +5563,12 @@ function merge(a, b) {
5549
5563
  return clone(a, def);
5550
5564
  }
5551
5565
  function partial(Class2, schema, mask) {
5566
+ const currDef = schema._zod.def;
5567
+ const checks = currDef.checks;
5568
+ const hasChecks = checks && checks.length > 0;
5569
+ if (hasChecks) {
5570
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
5571
+ }
5552
5572
  const def = mergeDefs(schema._zod.def, {
5553
5573
  get shape() {
5554
5574
  const oldShape = schema._zod.def.shape;
@@ -5607,8 +5627,7 @@ function required(Class2, schema, mask) {
5607
5627
  }
5608
5628
  assignProp(this, "shape", shape);
5609
5629
  return shape;
5610
- },
5611
- checks: []
5630
+ }
5612
5631
  });
5613
5632
  return clone(schema, def);
5614
5633
  }
@@ -5662,6 +5681,27 @@ function getLengthableOrigin(input) {
5662
5681
  return "string";
5663
5682
  return "unknown";
5664
5683
  }
5684
+ function parsedType(data) {
5685
+ const t2 = typeof data;
5686
+ switch (t2) {
5687
+ case "number": {
5688
+ return Number.isNaN(data) ? "nan" : "number";
5689
+ }
5690
+ case "object": {
5691
+ if (data === null) {
5692
+ return "null";
5693
+ }
5694
+ if (Array.isArray(data)) {
5695
+ return "array";
5696
+ }
5697
+ const obj = data;
5698
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
5699
+ return obj.constructor.name;
5700
+ }
5701
+ }
5702
+ }
5703
+ return t2;
5704
+ }
5665
5705
  function issue(...args) {
5666
5706
  const [iss, input, inst] = args;
5667
5707
  if (typeof iss === "string") {
@@ -5890,7 +5930,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]
5890
5930
  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])$/;
5891
5931
  var base642 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
5892
5932
  var base64url = /^[A-Za-z0-9_-]*$/;
5893
- var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
5933
+ var e164 = /^\+[1-9]\d{6,14}$/;
5894
5934
  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])))`;
5895
5935
  var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
5896
5936
  function timeSource(args) {
@@ -5917,7 +5957,7 @@ var string2 = (params) => {
5917
5957
  };
5918
5958
  var bigint = /^-?\d+n?$/;
5919
5959
  var integer = /^-?\d+$/;
5920
- var number = /^-?\d+(?:\.\d+)?/;
5960
+ var number = /^-?\d+(?:\.\d+)?$/;
5921
5961
  var boolean = /^(?:true|false)$/i;
5922
5962
  var _null = /^null$/i;
5923
5963
  var _undefined = /^undefined$/i;
@@ -5956,7 +5996,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
5956
5996
  payload.issues.push({
5957
5997
  origin,
5958
5998
  code: "too_big",
5959
- maximum: def.value,
5999
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
5960
6000
  input: payload.value,
5961
6001
  inclusive: def.inclusive,
5962
6002
  inst,
@@ -5984,7 +6024,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
5984
6024
  payload.issues.push({
5985
6025
  origin,
5986
6026
  code: "too_small",
5987
- minimum: def.value,
6027
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
5988
6028
  input: payload.value,
5989
6029
  inclusive: def.inclusive,
5990
6030
  inst,
@@ -6051,6 +6091,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
6051
6091
  note: "Integers must be within the safe integer range.",
6052
6092
  inst,
6053
6093
  origin,
6094
+ inclusive: true,
6054
6095
  continue: !def.abort
6055
6096
  });
6056
6097
  } else {
@@ -6061,6 +6102,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
6061
6102
  note: "Integers must be within the safe integer range.",
6062
6103
  inst,
6063
6104
  origin,
6105
+ inclusive: true,
6064
6106
  continue: !def.abort
6065
6107
  });
6066
6108
  }
@@ -6084,7 +6126,9 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
6084
6126
  input,
6085
6127
  code: "too_big",
6086
6128
  maximum,
6087
- inst
6129
+ inclusive: true,
6130
+ inst,
6131
+ continue: !def.abort
6088
6132
  });
6089
6133
  }
6090
6134
  };
@@ -6349,8 +6393,8 @@ var Doc = class {
6349
6393
  // node_modules/zod/v4/core/versions.js
6350
6394
  var version = {
6351
6395
  major: 4,
6352
- minor: 2,
6353
- patch: 1
6396
+ minor: 3,
6397
+ patch: 6
6354
6398
  };
6355
6399
 
6356
6400
  // node_modules/zod/v4/core/schemas.js
@@ -6450,7 +6494,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
6450
6494
  return runChecks(result, checks, ctx);
6451
6495
  };
6452
6496
  }
6453
- inst["~standard"] = {
6497
+ defineLazy(inst, "~standard", () => ({
6454
6498
  validate: (value) => {
6455
6499
  try {
6456
6500
  const r = safeParse2(inst, value);
@@ -6461,7 +6505,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
6461
6505
  },
6462
6506
  vendor: "zod",
6463
6507
  version: 1
6464
- };
6508
+ }));
6465
6509
  });
6466
6510
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
6467
6511
  $ZodType.init(inst, def);
@@ -6972,8 +7016,11 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
6972
7016
  return payload;
6973
7017
  };
6974
7018
  });
6975
- function handlePropertyResult(result, final, key, input) {
7019
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
6976
7020
  if (result.issues.length) {
7021
+ if (isOptionalOut && !(key in input)) {
7022
+ return;
7023
+ }
6977
7024
  final.issues.push(...prefixIssues(key, result.issues));
6978
7025
  }
6979
7026
  if (result.value === void 0) {
@@ -7005,6 +7052,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
7005
7052
  const keySet = def.keySet;
7006
7053
  const _catchall = def.catchall._zod;
7007
7054
  const t2 = _catchall.def.type;
7055
+ const isOptionalOut = _catchall.optout === "optional";
7008
7056
  for (const key in input) {
7009
7057
  if (keySet.has(key))
7010
7058
  continue;
@@ -7014,9 +7062,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
7014
7062
  }
7015
7063
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
7016
7064
  if (r instanceof Promise) {
7017
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
7065
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
7018
7066
  } else {
7019
- handlePropertyResult(r, payload, key, input);
7067
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
7020
7068
  }
7021
7069
  }
7022
7070
  if (unrecognized.length) {
@@ -7082,11 +7130,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7082
7130
  const shape = value.shape;
7083
7131
  for (const key of value.keys) {
7084
7132
  const el = shape[key];
7133
+ const isOptionalOut = el._zod.optout === "optional";
7085
7134
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
7086
7135
  if (r instanceof Promise) {
7087
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
7136
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
7088
7137
  } else {
7089
- handlePropertyResult(r, payload, key, input);
7138
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
7090
7139
  }
7091
7140
  }
7092
7141
  if (!catchall) {
@@ -7116,8 +7165,31 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7116
7165
  for (const key of normalized.keys) {
7117
7166
  const id = ids[key];
7118
7167
  const k = esc(key);
7168
+ const schema = shape[key];
7169
+ const isOptionalOut = schema?._zod?.optout === "optional";
7119
7170
  doc.write(`const ${id} = ${parseStr(key)};`);
7120
- doc.write(`
7171
+ if (isOptionalOut) {
7172
+ doc.write(`
7173
+ if (${id}.issues.length) {
7174
+ if (${k} in input) {
7175
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7176
+ ...iss,
7177
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
7178
+ })));
7179
+ }
7180
+ }
7181
+
7182
+ if (${id}.value === undefined) {
7183
+ if (${k} in input) {
7184
+ newResult[${k}] = undefined;
7185
+ }
7186
+ } else {
7187
+ newResult[${k}] = ${id}.value;
7188
+ }
7189
+
7190
+ `);
7191
+ } else {
7192
+ doc.write(`
7121
7193
  if (${id}.issues.length) {
7122
7194
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7123
7195
  ...iss,
@@ -7125,7 +7197,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7125
7197
  })));
7126
7198
  }
7127
7199
 
7128
-
7129
7200
  if (${id}.value === undefined) {
7130
7201
  if (${k} in input) {
7131
7202
  newResult[${k}] = undefined;
@@ -7135,6 +7206,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7135
7206
  }
7136
7207
 
7137
7208
  `);
7209
+ }
7138
7210
  }
7139
7211
  doc.write(`payload.value = newResult;`);
7140
7212
  doc.write(`return payload;`);
@@ -7363,11 +7435,34 @@ function mergeValues(a, b) {
7363
7435
  return { valid: false, mergeErrorPath: [] };
7364
7436
  }
7365
7437
  function handleIntersectionResults(result, left, right) {
7366
- if (left.issues.length) {
7367
- result.issues.push(...left.issues);
7438
+ const unrecKeys = /* @__PURE__ */ new Map();
7439
+ let unrecIssue;
7440
+ for (const iss of left.issues) {
7441
+ if (iss.code === "unrecognized_keys") {
7442
+ unrecIssue ?? (unrecIssue = iss);
7443
+ for (const k of iss.keys) {
7444
+ if (!unrecKeys.has(k))
7445
+ unrecKeys.set(k, {});
7446
+ unrecKeys.get(k).l = true;
7447
+ }
7448
+ } else {
7449
+ result.issues.push(iss);
7450
+ }
7451
+ }
7452
+ for (const iss of right.issues) {
7453
+ if (iss.code === "unrecognized_keys") {
7454
+ for (const k of iss.keys) {
7455
+ if (!unrecKeys.has(k))
7456
+ unrecKeys.set(k, {});
7457
+ unrecKeys.get(k).r = true;
7458
+ }
7459
+ } else {
7460
+ result.issues.push(iss);
7461
+ }
7368
7462
  }
7369
- if (right.issues.length) {
7370
- result.issues.push(...right.issues);
7463
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
7464
+ if (bothKeys.length && unrecIssue) {
7465
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
7371
7466
  }
7372
7467
  if (aborted(result))
7373
7468
  return result;
@@ -7401,7 +7496,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
7401
7496
  const tooSmall = input.length < optStart - 1;
7402
7497
  if (tooBig || tooSmall) {
7403
7498
  payload.issues.push({
7404
- ...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
7499
+ ...tooBig ? { code: "too_big", maximum: items.length, inclusive: true } : { code: "too_small", minimum: items.length },
7405
7500
  input,
7406
7501
  inst,
7407
7502
  origin: "array"
@@ -7509,10 +7604,20 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
7509
7604
  for (const key of Reflect.ownKeys(input)) {
7510
7605
  if (key === "__proto__")
7511
7606
  continue;
7512
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
7607
+ let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
7513
7608
  if (keyResult instanceof Promise) {
7514
7609
  throw new Error("Async schemas not supported in object keys currently");
7515
7610
  }
7611
+ const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
7612
+ if (checkNumericKey) {
7613
+ const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
7614
+ if (retryResult instanceof Promise) {
7615
+ throw new Error("Async schemas not supported in object keys currently");
7616
+ }
7617
+ if (retryResult.issues.length === 0) {
7618
+ keyResult = retryResult;
7619
+ }
7620
+ }
7516
7621
  if (keyResult.issues.length) {
7517
7622
  if (def.mode === "loose") {
7518
7623
  payload.value[key] = input[key];
@@ -7643,6 +7748,14 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
7643
7748
  return def.innerType._zod.run(payload, ctx);
7644
7749
  };
7645
7750
  });
7751
+ var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
7752
+ $ZodOptional.init(inst, def);
7753
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
7754
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
7755
+ inst._zod.parse = (payload, ctx) => {
7756
+ return def.innerType._zod.run(payload, ctx);
7757
+ };
7758
+ });
7646
7759
  var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
7647
7760
  $ZodType.init(inst, def);
7648
7761
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -7864,9 +7977,6 @@ var $ZodRegistry = class {
7864
7977
  const meta2 = _meta[0];
7865
7978
  this._map.set(schema, meta2);
7866
7979
  if (meta2 && typeof meta2 === "object" && "id" in meta2) {
7867
- if (this._idmap.has(meta2.id)) {
7868
- throw new Error(`ID ${meta2.id} already exists in the registry`);
7869
- }
7870
7980
  this._idmap.set(meta2.id, schema);
7871
7981
  }
7872
7982
  return this;
@@ -7905,12 +8015,14 @@ function registry() {
7905
8015
  var globalRegistry = globalThis.__zod_globalRegistry;
7906
8016
 
7907
8017
  // node_modules/zod/v4/core/api.js
8018
+ // @__NO_SIDE_EFFECTS__
7908
8019
  function _string(Class2, params) {
7909
8020
  return new Class2({
7910
8021
  type: "string",
7911
8022
  ...normalizeParams(params)
7912
8023
  });
7913
8024
  }
8025
+ // @__NO_SIDE_EFFECTS__
7914
8026
  function _email(Class2, params) {
7915
8027
  return new Class2({
7916
8028
  type: "string",
@@ -7920,6 +8032,7 @@ function _email(Class2, params) {
7920
8032
  ...normalizeParams(params)
7921
8033
  });
7922
8034
  }
8035
+ // @__NO_SIDE_EFFECTS__
7923
8036
  function _guid(Class2, params) {
7924
8037
  return new Class2({
7925
8038
  type: "string",
@@ -7929,6 +8042,7 @@ function _guid(Class2, params) {
7929
8042
  ...normalizeParams(params)
7930
8043
  });
7931
8044
  }
8045
+ // @__NO_SIDE_EFFECTS__
7932
8046
  function _uuid(Class2, params) {
7933
8047
  return new Class2({
7934
8048
  type: "string",
@@ -7938,6 +8052,7 @@ function _uuid(Class2, params) {
7938
8052
  ...normalizeParams(params)
7939
8053
  });
7940
8054
  }
8055
+ // @__NO_SIDE_EFFECTS__
7941
8056
  function _uuidv4(Class2, params) {
7942
8057
  return new Class2({
7943
8058
  type: "string",
@@ -7948,6 +8063,7 @@ function _uuidv4(Class2, params) {
7948
8063
  ...normalizeParams(params)
7949
8064
  });
7950
8065
  }
8066
+ // @__NO_SIDE_EFFECTS__
7951
8067
  function _uuidv6(Class2, params) {
7952
8068
  return new Class2({
7953
8069
  type: "string",
@@ -7958,6 +8074,7 @@ function _uuidv6(Class2, params) {
7958
8074
  ...normalizeParams(params)
7959
8075
  });
7960
8076
  }
8077
+ // @__NO_SIDE_EFFECTS__
7961
8078
  function _uuidv7(Class2, params) {
7962
8079
  return new Class2({
7963
8080
  type: "string",
@@ -7968,6 +8085,7 @@ function _uuidv7(Class2, params) {
7968
8085
  ...normalizeParams(params)
7969
8086
  });
7970
8087
  }
8088
+ // @__NO_SIDE_EFFECTS__
7971
8089
  function _url(Class2, params) {
7972
8090
  return new Class2({
7973
8091
  type: "string",
@@ -7977,6 +8095,7 @@ function _url(Class2, params) {
7977
8095
  ...normalizeParams(params)
7978
8096
  });
7979
8097
  }
8098
+ // @__NO_SIDE_EFFECTS__
7980
8099
  function _emoji2(Class2, params) {
7981
8100
  return new Class2({
7982
8101
  type: "string",
@@ -7986,6 +8105,7 @@ function _emoji2(Class2, params) {
7986
8105
  ...normalizeParams(params)
7987
8106
  });
7988
8107
  }
8108
+ // @__NO_SIDE_EFFECTS__
7989
8109
  function _nanoid(Class2, params) {
7990
8110
  return new Class2({
7991
8111
  type: "string",
@@ -7995,6 +8115,7 @@ function _nanoid(Class2, params) {
7995
8115
  ...normalizeParams(params)
7996
8116
  });
7997
8117
  }
8118
+ // @__NO_SIDE_EFFECTS__
7998
8119
  function _cuid(Class2, params) {
7999
8120
  return new Class2({
8000
8121
  type: "string",
@@ -8004,6 +8125,7 @@ function _cuid(Class2, params) {
8004
8125
  ...normalizeParams(params)
8005
8126
  });
8006
8127
  }
8128
+ // @__NO_SIDE_EFFECTS__
8007
8129
  function _cuid2(Class2, params) {
8008
8130
  return new Class2({
8009
8131
  type: "string",
@@ -8013,6 +8135,7 @@ function _cuid2(Class2, params) {
8013
8135
  ...normalizeParams(params)
8014
8136
  });
8015
8137
  }
8138
+ // @__NO_SIDE_EFFECTS__
8016
8139
  function _ulid(Class2, params) {
8017
8140
  return new Class2({
8018
8141
  type: "string",
@@ -8022,6 +8145,7 @@ function _ulid(Class2, params) {
8022
8145
  ...normalizeParams(params)
8023
8146
  });
8024
8147
  }
8148
+ // @__NO_SIDE_EFFECTS__
8025
8149
  function _xid(Class2, params) {
8026
8150
  return new Class2({
8027
8151
  type: "string",
@@ -8031,6 +8155,7 @@ function _xid(Class2, params) {
8031
8155
  ...normalizeParams(params)
8032
8156
  });
8033
8157
  }
8158
+ // @__NO_SIDE_EFFECTS__
8034
8159
  function _ksuid(Class2, params) {
8035
8160
  return new Class2({
8036
8161
  type: "string",
@@ -8040,6 +8165,7 @@ function _ksuid(Class2, params) {
8040
8165
  ...normalizeParams(params)
8041
8166
  });
8042
8167
  }
8168
+ // @__NO_SIDE_EFFECTS__
8043
8169
  function _ipv4(Class2, params) {
8044
8170
  return new Class2({
8045
8171
  type: "string",
@@ -8049,6 +8175,7 @@ function _ipv4(Class2, params) {
8049
8175
  ...normalizeParams(params)
8050
8176
  });
8051
8177
  }
8178
+ // @__NO_SIDE_EFFECTS__
8052
8179
  function _ipv6(Class2, params) {
8053
8180
  return new Class2({
8054
8181
  type: "string",
@@ -8058,6 +8185,7 @@ function _ipv6(Class2, params) {
8058
8185
  ...normalizeParams(params)
8059
8186
  });
8060
8187
  }
8188
+ // @__NO_SIDE_EFFECTS__
8061
8189
  function _cidrv4(Class2, params) {
8062
8190
  return new Class2({
8063
8191
  type: "string",
@@ -8067,6 +8195,7 @@ function _cidrv4(Class2, params) {
8067
8195
  ...normalizeParams(params)
8068
8196
  });
8069
8197
  }
8198
+ // @__NO_SIDE_EFFECTS__
8070
8199
  function _cidrv6(Class2, params) {
8071
8200
  return new Class2({
8072
8201
  type: "string",
@@ -8076,6 +8205,7 @@ function _cidrv6(Class2, params) {
8076
8205
  ...normalizeParams(params)
8077
8206
  });
8078
8207
  }
8208
+ // @__NO_SIDE_EFFECTS__
8079
8209
  function _base64(Class2, params) {
8080
8210
  return new Class2({
8081
8211
  type: "string",
@@ -8085,6 +8215,7 @@ function _base64(Class2, params) {
8085
8215
  ...normalizeParams(params)
8086
8216
  });
8087
8217
  }
8218
+ // @__NO_SIDE_EFFECTS__
8088
8219
  function _base64url(Class2, params) {
8089
8220
  return new Class2({
8090
8221
  type: "string",
@@ -8094,6 +8225,7 @@ function _base64url(Class2, params) {
8094
8225
  ...normalizeParams(params)
8095
8226
  });
8096
8227
  }
8228
+ // @__NO_SIDE_EFFECTS__
8097
8229
  function _e164(Class2, params) {
8098
8230
  return new Class2({
8099
8231
  type: "string",
@@ -8103,6 +8235,7 @@ function _e164(Class2, params) {
8103
8235
  ...normalizeParams(params)
8104
8236
  });
8105
8237
  }
8238
+ // @__NO_SIDE_EFFECTS__
8106
8239
  function _jwt(Class2, params) {
8107
8240
  return new Class2({
8108
8241
  type: "string",
@@ -8112,6 +8245,7 @@ function _jwt(Class2, params) {
8112
8245
  ...normalizeParams(params)
8113
8246
  });
8114
8247
  }
8248
+ // @__NO_SIDE_EFFECTS__
8115
8249
  function _isoDateTime(Class2, params) {
8116
8250
  return new Class2({
8117
8251
  type: "string",
@@ -8123,6 +8257,7 @@ function _isoDateTime(Class2, params) {
8123
8257
  ...normalizeParams(params)
8124
8258
  });
8125
8259
  }
8260
+ // @__NO_SIDE_EFFECTS__
8126
8261
  function _isoDate(Class2, params) {
8127
8262
  return new Class2({
8128
8263
  type: "string",
@@ -8131,6 +8266,7 @@ function _isoDate(Class2, params) {
8131
8266
  ...normalizeParams(params)
8132
8267
  });
8133
8268
  }
8269
+ // @__NO_SIDE_EFFECTS__
8134
8270
  function _isoTime(Class2, params) {
8135
8271
  return new Class2({
8136
8272
  type: "string",
@@ -8140,6 +8276,7 @@ function _isoTime(Class2, params) {
8140
8276
  ...normalizeParams(params)
8141
8277
  });
8142
8278
  }
8279
+ // @__NO_SIDE_EFFECTS__
8143
8280
  function _isoDuration(Class2, params) {
8144
8281
  return new Class2({
8145
8282
  type: "string",
@@ -8148,6 +8285,7 @@ function _isoDuration(Class2, params) {
8148
8285
  ...normalizeParams(params)
8149
8286
  });
8150
8287
  }
8288
+ // @__NO_SIDE_EFFECTS__
8151
8289
  function _int(Class2, params) {
8152
8290
  return new Class2({
8153
8291
  type: "number",
@@ -8157,17 +8295,20 @@ function _int(Class2, params) {
8157
8295
  ...normalizeParams(params)
8158
8296
  });
8159
8297
  }
8298
+ // @__NO_SIDE_EFFECTS__
8160
8299
  function _unknown(Class2) {
8161
8300
  return new Class2({
8162
8301
  type: "unknown"
8163
8302
  });
8164
8303
  }
8304
+ // @__NO_SIDE_EFFECTS__
8165
8305
  function _never(Class2, params) {
8166
8306
  return new Class2({
8167
8307
  type: "never",
8168
8308
  ...normalizeParams(params)
8169
8309
  });
8170
8310
  }
8311
+ // @__NO_SIDE_EFFECTS__
8171
8312
  function _lt(value, params) {
8172
8313
  return new $ZodCheckLessThan({
8173
8314
  check: "less_than",
@@ -8176,6 +8317,7 @@ function _lt(value, params) {
8176
8317
  inclusive: false
8177
8318
  });
8178
8319
  }
8320
+ // @__NO_SIDE_EFFECTS__
8179
8321
  function _lte(value, params) {
8180
8322
  return new $ZodCheckLessThan({
8181
8323
  check: "less_than",
@@ -8184,6 +8326,7 @@ function _lte(value, params) {
8184
8326
  inclusive: true
8185
8327
  });
8186
8328
  }
8329
+ // @__NO_SIDE_EFFECTS__
8187
8330
  function _gt(value, params) {
8188
8331
  return new $ZodCheckGreaterThan({
8189
8332
  check: "greater_than",
@@ -8192,6 +8335,7 @@ function _gt(value, params) {
8192
8335
  inclusive: false
8193
8336
  });
8194
8337
  }
8338
+ // @__NO_SIDE_EFFECTS__
8195
8339
  function _gte(value, params) {
8196
8340
  return new $ZodCheckGreaterThan({
8197
8341
  check: "greater_than",
@@ -8200,6 +8344,7 @@ function _gte(value, params) {
8200
8344
  inclusive: true
8201
8345
  });
8202
8346
  }
8347
+ // @__NO_SIDE_EFFECTS__
8203
8348
  function _multipleOf(value, params) {
8204
8349
  return new $ZodCheckMultipleOf({
8205
8350
  check: "multiple_of",
@@ -8207,6 +8352,7 @@ function _multipleOf(value, params) {
8207
8352
  value
8208
8353
  });
8209
8354
  }
8355
+ // @__NO_SIDE_EFFECTS__
8210
8356
  function _maxLength(maximum, params) {
8211
8357
  const ch = new $ZodCheckMaxLength({
8212
8358
  check: "max_length",
@@ -8215,6 +8361,7 @@ function _maxLength(maximum, params) {
8215
8361
  });
8216
8362
  return ch;
8217
8363
  }
8364
+ // @__NO_SIDE_EFFECTS__
8218
8365
  function _minLength(minimum, params) {
8219
8366
  return new $ZodCheckMinLength({
8220
8367
  check: "min_length",
@@ -8222,6 +8369,7 @@ function _minLength(minimum, params) {
8222
8369
  minimum
8223
8370
  });
8224
8371
  }
8372
+ // @__NO_SIDE_EFFECTS__
8225
8373
  function _length(length, params) {
8226
8374
  return new $ZodCheckLengthEquals({
8227
8375
  check: "length_equals",
@@ -8229,6 +8377,7 @@ function _length(length, params) {
8229
8377
  length
8230
8378
  });
8231
8379
  }
8380
+ // @__NO_SIDE_EFFECTS__
8232
8381
  function _regex(pattern, params) {
8233
8382
  return new $ZodCheckRegex({
8234
8383
  check: "string_format",
@@ -8237,6 +8386,7 @@ function _regex(pattern, params) {
8237
8386
  pattern
8238
8387
  });
8239
8388
  }
8389
+ // @__NO_SIDE_EFFECTS__
8240
8390
  function _lowercase(params) {
8241
8391
  return new $ZodCheckLowerCase({
8242
8392
  check: "string_format",
@@ -8244,6 +8394,7 @@ function _lowercase(params) {
8244
8394
  ...normalizeParams(params)
8245
8395
  });
8246
8396
  }
8397
+ // @__NO_SIDE_EFFECTS__
8247
8398
  function _uppercase(params) {
8248
8399
  return new $ZodCheckUpperCase({
8249
8400
  check: "string_format",
@@ -8251,6 +8402,7 @@ function _uppercase(params) {
8251
8402
  ...normalizeParams(params)
8252
8403
  });
8253
8404
  }
8405
+ // @__NO_SIDE_EFFECTS__
8254
8406
  function _includes(includes, params) {
8255
8407
  return new $ZodCheckIncludes({
8256
8408
  check: "string_format",
@@ -8259,6 +8411,7 @@ function _includes(includes, params) {
8259
8411
  includes
8260
8412
  });
8261
8413
  }
8414
+ // @__NO_SIDE_EFFECTS__
8262
8415
  function _startsWith(prefix, params) {
8263
8416
  return new $ZodCheckStartsWith({
8264
8417
  check: "string_format",
@@ -8267,6 +8420,7 @@ function _startsWith(prefix, params) {
8267
8420
  prefix
8268
8421
  });
8269
8422
  }
8423
+ // @__NO_SIDE_EFFECTS__
8270
8424
  function _endsWith(suffix, params) {
8271
8425
  return new $ZodCheckEndsWith({
8272
8426
  check: "string_format",
@@ -8275,27 +8429,34 @@ function _endsWith(suffix, params) {
8275
8429
  suffix
8276
8430
  });
8277
8431
  }
8432
+ // @__NO_SIDE_EFFECTS__
8278
8433
  function _overwrite(tx) {
8279
8434
  return new $ZodCheckOverwrite({
8280
8435
  check: "overwrite",
8281
8436
  tx
8282
8437
  });
8283
8438
  }
8439
+ // @__NO_SIDE_EFFECTS__
8284
8440
  function _normalize(form) {
8285
- return _overwrite((input) => input.normalize(form));
8441
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
8286
8442
  }
8443
+ // @__NO_SIDE_EFFECTS__
8287
8444
  function _trim() {
8288
- return _overwrite((input) => input.trim());
8445
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
8289
8446
  }
8447
+ // @__NO_SIDE_EFFECTS__
8290
8448
  function _toLowerCase() {
8291
- return _overwrite((input) => input.toLowerCase());
8449
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
8292
8450
  }
8451
+ // @__NO_SIDE_EFFECTS__
8293
8452
  function _toUpperCase() {
8294
- return _overwrite((input) => input.toUpperCase());
8453
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
8295
8454
  }
8455
+ // @__NO_SIDE_EFFECTS__
8296
8456
  function _slugify() {
8297
- return _overwrite((input) => slugify(input));
8457
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
8298
8458
  }
8459
+ // @__NO_SIDE_EFFECTS__
8299
8460
  function _array(Class2, element, params) {
8300
8461
  return new Class2({
8301
8462
  type: "array",
@@ -8306,6 +8467,7 @@ function _array(Class2, element, params) {
8306
8467
  ...normalizeParams(params)
8307
8468
  });
8308
8469
  }
8470
+ // @__NO_SIDE_EFFECTS__
8309
8471
  function _refine(Class2, fn, _params) {
8310
8472
  const schema = new Class2({
8311
8473
  type: "custom",
@@ -8315,8 +8477,9 @@ function _refine(Class2, fn, _params) {
8315
8477
  });
8316
8478
  return schema;
8317
8479
  }
8480
+ // @__NO_SIDE_EFFECTS__
8318
8481
  function _superRefine(fn) {
8319
- const ch = _check((payload) => {
8482
+ const ch = /* @__PURE__ */ _check((payload) => {
8320
8483
  payload.addIssue = (issue2) => {
8321
8484
  if (typeof issue2 === "string") {
8322
8485
  payload.issues.push(issue(issue2, payload.value, ch._zod.def));
@@ -8335,6 +8498,7 @@ function _superRefine(fn) {
8335
8498
  });
8336
8499
  return ch;
8337
8500
  }
8501
+ // @__NO_SIDE_EFFECTS__
8338
8502
  function _check(fn, params) {
8339
8503
  const ch = new $ZodCheck({
8340
8504
  check: "custom",
@@ -8389,12 +8553,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
8389
8553
  schemaPath: [..._params.schemaPath, schema],
8390
8554
  path: _params.path
8391
8555
  };
8392
- const parent = schema._zod.parent;
8393
- if (parent) {
8394
- result.ref = parent;
8395
- process2(parent, ctx, params);
8396
- ctx.seen.get(parent).isParent = true;
8397
- } else if (schema._zod.processJSONSchema) {
8556
+ if (schema._zod.processJSONSchema) {
8398
8557
  schema._zod.processJSONSchema(ctx, result.schema, params);
8399
8558
  } else {
8400
8559
  const _json = result.schema;
@@ -8404,6 +8563,13 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
8404
8563
  }
8405
8564
  processor(schema, ctx, _json, params);
8406
8565
  }
8566
+ const parent = schema._zod.parent;
8567
+ if (parent) {
8568
+ if (!result.ref)
8569
+ result.ref = parent;
8570
+ process2(parent, ctx, params);
8571
+ ctx.seen.get(parent).isParent = true;
8572
+ }
8407
8573
  }
8408
8574
  const meta2 = ctx.metadataRegistry.get(schema);
8409
8575
  if (meta2)
@@ -8422,6 +8588,17 @@ function extractDefs(ctx, schema) {
8422
8588
  const root = ctx.seen.get(schema);
8423
8589
  if (!root)
8424
8590
  throw new Error("Unprocessed schema. This is a bug in Zod.");
8591
+ const idToSchema = /* @__PURE__ */ new Map();
8592
+ for (const entry of ctx.seen.entries()) {
8593
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
8594
+ if (id) {
8595
+ const existing = idToSchema.get(id);
8596
+ if (existing && existing !== entry[0]) {
8597
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
8598
+ }
8599
+ idToSchema.set(id, entry[0]);
8600
+ }
8601
+ }
8425
8602
  const makeURI = (entry) => {
8426
8603
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
8427
8604
  if (ctx.external) {
@@ -8503,30 +8680,65 @@ function finalize(ctx, schema) {
8503
8680
  throw new Error("Unprocessed schema. This is a bug in Zod.");
8504
8681
  const flattenRef = (zodSchema) => {
8505
8682
  const seen = ctx.seen.get(zodSchema);
8683
+ if (seen.ref === null)
8684
+ return;
8506
8685
  const schema2 = seen.def ?? seen.schema;
8507
8686
  const _cached = { ...schema2 };
8508
- if (seen.ref === null) {
8509
- return;
8510
- }
8511
8687
  const ref = seen.ref;
8512
8688
  seen.ref = null;
8513
8689
  if (ref) {
8514
8690
  flattenRef(ref);
8515
- const refSchema = ctx.seen.get(ref).schema;
8691
+ const refSeen = ctx.seen.get(ref);
8692
+ const refSchema = refSeen.schema;
8516
8693
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
8517
8694
  schema2.allOf = schema2.allOf ?? [];
8518
8695
  schema2.allOf.push(refSchema);
8519
8696
  } else {
8520
8697
  Object.assign(schema2, refSchema);
8521
- Object.assign(schema2, _cached);
8698
+ }
8699
+ Object.assign(schema2, _cached);
8700
+ const isParentRef = zodSchema._zod.parent === ref;
8701
+ if (isParentRef) {
8702
+ for (const key in schema2) {
8703
+ if (key === "$ref" || key === "allOf")
8704
+ continue;
8705
+ if (!(key in _cached)) {
8706
+ delete schema2[key];
8707
+ }
8708
+ }
8709
+ }
8710
+ if (refSchema.$ref && refSeen.def) {
8711
+ for (const key in schema2) {
8712
+ if (key === "$ref" || key === "allOf")
8713
+ continue;
8714
+ if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
8715
+ delete schema2[key];
8716
+ }
8717
+ }
8522
8718
  }
8523
8719
  }
8524
- if (!seen.isParent)
8525
- ctx.override({
8526
- zodSchema,
8527
- jsonSchema: schema2,
8528
- path: seen.path ?? []
8529
- });
8720
+ const parent = zodSchema._zod.parent;
8721
+ if (parent && parent !== ref) {
8722
+ flattenRef(parent);
8723
+ const parentSeen = ctx.seen.get(parent);
8724
+ if (parentSeen?.schema.$ref) {
8725
+ schema2.$ref = parentSeen.schema.$ref;
8726
+ if (parentSeen.def) {
8727
+ for (const key in schema2) {
8728
+ if (key === "$ref" || key === "allOf")
8729
+ continue;
8730
+ if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
8731
+ delete schema2[key];
8732
+ }
8733
+ }
8734
+ }
8735
+ }
8736
+ }
8737
+ ctx.override({
8738
+ zodSchema,
8739
+ jsonSchema: schema2,
8740
+ path: seen.path ?? []
8741
+ });
8530
8742
  };
8531
8743
  for (const entry of [...ctx.seen.entries()].reverse()) {
8532
8744
  flattenRef(entry[0]);
@@ -8571,8 +8783,8 @@ function finalize(ctx, schema) {
8571
8783
  value: {
8572
8784
  ...schema["~standard"],
8573
8785
  jsonSchema: {
8574
- input: createStandardJSONSchemaMethod(schema, "input"),
8575
- output: createStandardJSONSchemaMethod(schema, "output")
8786
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
8787
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
8576
8788
  }
8577
8789
  },
8578
8790
  enumerable: false,
@@ -8640,9 +8852,9 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
8640
8852
  extractDefs(ctx, schema);
8641
8853
  return finalize(ctx, schema);
8642
8854
  };
8643
- var createStandardJSONSchemaMethod = (schema, io) => (params) => {
8855
+ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
8644
8856
  const { libraryOptions, target } = params ?? {};
8645
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors: {} });
8857
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
8646
8858
  process2(schema, ctx);
8647
8859
  extractDefs(ctx, schema);
8648
8860
  return finalize(ctx, schema);
@@ -8669,6 +8881,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
8669
8881
  json.format = formatMap[format] ?? format;
8670
8882
  if (json.format === "")
8671
8883
  delete json.format;
8884
+ if (format === "time") {
8885
+ delete json.format;
8886
+ }
8672
8887
  }
8673
8888
  if (contentEncoding)
8674
8889
  json.contentEncoding = contentEncoding;
@@ -8956,16 +9171,37 @@ var recordProcessor = (schema, ctx, _json, params) => {
8956
9171
  const json = _json;
8957
9172
  const def = schema._zod.def;
8958
9173
  json.type = "object";
8959
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
8960
- json.propertyNames = process2(def.keyType, ctx, {
9174
+ const keyType = def.keyType;
9175
+ const keyBag = keyType._zod.bag;
9176
+ const patterns = keyBag?.patterns;
9177
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
9178
+ const valueSchema = process2(def.valueType, ctx, {
9179
+ ...params,
9180
+ path: [...params.path, "patternProperties", "*"]
9181
+ });
9182
+ json.patternProperties = {};
9183
+ for (const pattern of patterns) {
9184
+ json.patternProperties[pattern.source] = valueSchema;
9185
+ }
9186
+ } else {
9187
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
9188
+ json.propertyNames = process2(def.keyType, ctx, {
9189
+ ...params,
9190
+ path: [...params.path, "propertyNames"]
9191
+ });
9192
+ }
9193
+ json.additionalProperties = process2(def.valueType, ctx, {
8961
9194
  ...params,
8962
- path: [...params.path, "propertyNames"]
9195
+ path: [...params.path, "additionalProperties"]
8963
9196
  });
8964
9197
  }
8965
- json.additionalProperties = process2(def.valueType, ctx, {
8966
- ...params,
8967
- path: [...params.path, "additionalProperties"]
8968
- });
9198
+ const keyValues = keyType._zod.values;
9199
+ if (keyValues) {
9200
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
9201
+ if (validKeyValues.length > 0) {
9202
+ json.required = validKeyValues;
9203
+ }
9204
+ }
8969
9205
  };
8970
9206
  var nullableProcessor = (schema, ctx, json, params) => {
8971
9207
  const def = schema._zod.def;
@@ -9142,8 +9378,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
9142
9378
  ...def.checks ?? [],
9143
9379
  ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
9144
9380
  ]
9145
- }));
9381
+ }), {
9382
+ parent: true
9383
+ });
9146
9384
  };
9385
+ inst.with = inst.check;
9147
9386
  inst.clone = (def2, params) => clone(inst, def2, params);
9148
9387
  inst.brand = () => inst;
9149
9388
  inst.register = ((reg, meta2) => {
@@ -9167,6 +9406,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
9167
9406
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
9168
9407
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
9169
9408
  inst.optional = () => optional(inst);
9409
+ inst.exactOptional = () => exactOptional(inst);
9170
9410
  inst.nullable = () => nullable(inst);
9171
9411
  inst.nullish = () => optional(nullable(inst));
9172
9412
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -9200,6 +9440,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
9200
9440
  };
9201
9441
  inst.isOptional = () => inst.safeParse(void 0).success;
9202
9442
  inst.isNullable = () => inst.safeParse(null).success;
9443
+ inst.apply = (fn) => fn(inst);
9203
9444
  return inst;
9204
9445
  });
9205
9446
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
@@ -9645,6 +9886,18 @@ function optional(innerType) {
9645
9886
  innerType
9646
9887
  });
9647
9888
  }
9889
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
9890
+ $ZodExactOptional.init(inst, def);
9891
+ ZodType.init(inst, def);
9892
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
9893
+ inst.unwrap = () => inst._zod.def.innerType;
9894
+ });
9895
+ function exactOptional(innerType) {
9896
+ return new ZodExactOptional({
9897
+ type: "optional",
9898
+ innerType
9899
+ });
9900
+ }
9648
9901
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
9649
9902
  $ZodNullable.init(inst, def);
9650
9903
  ZodType.init(inst, def);