@kevisual/router 0.0.51 → 0.0.53

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.
@@ -270,6 +270,7 @@ class Route {
270
270
  }
271
271
  }
272
272
  class QueryRouter {
273
+ appId = '';
273
274
  routes;
274
275
  maxNextRoute = 40;
275
276
  context = {}; // default context for call
@@ -620,6 +621,21 @@ class QueryRouter {
620
621
  hasRoute(path, key = '') {
621
622
  return this.routes.find((r) => r.path === path && r.key === key);
622
623
  }
624
+ findRoute(opts) {
625
+ const { path, key, id } = opts || {};
626
+ return this.routes.find((r) => {
627
+ if (id) {
628
+ return r.id === id;
629
+ }
630
+ if (path) {
631
+ if (key !== undefined) {
632
+ return r.path === path && r.key === key;
633
+ }
634
+ return r.path === path;
635
+ }
636
+ return false;
637
+ });
638
+ }
623
639
  createRouteList(force = false, filter) {
624
640
  const hasListRoute = this.hasRoute('router', 'list');
625
641
  if (!hasListRoute || force) {
@@ -627,7 +643,7 @@ class QueryRouter {
627
643
  description: '列出当前应用下的所有的路由信息',
628
644
  run: async (ctx) => {
629
645
  const list = this.getList(filter);
630
- ctx.body = list;
646
+ ctx.body = { list };
631
647
  },
632
648
  });
633
649
  this.add(listRoute);
@@ -659,6 +675,12 @@ class QueryRouterServer extends QueryRouter {
659
675
  super();
660
676
  this.handle = this.getHandle(this, opts?.handleFn, opts?.context);
661
677
  this.setContext({ needSerialize: false, ...opts?.context });
678
+ if (opts?.appId) {
679
+ this.appId = opts.appId;
680
+ }
681
+ else {
682
+ this.appId = nanoid$1(16);
683
+ }
662
684
  }
663
685
  setHandle(wrapperFn, ctx) {
664
686
  this.handle = this.getHandle(this, wrapperFn, ctx);
@@ -969,6 +991,11 @@ const NUMBER_FORMAT_RANGES = {
969
991
  };
970
992
  function pick(schema, mask) {
971
993
  const currDef = schema._zod.def;
994
+ const checks = currDef.checks;
995
+ const hasChecks = checks && checks.length > 0;
996
+ if (hasChecks) {
997
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
998
+ }
972
999
  const def = mergeDefs(schema._zod.def, {
973
1000
  get shape() {
974
1001
  const newShape = {};
@@ -989,6 +1016,11 @@ function pick(schema, mask) {
989
1016
  }
990
1017
  function omit(schema, mask) {
991
1018
  const currDef = schema._zod.def;
1019
+ const checks = currDef.checks;
1020
+ const hasChecks = checks && checks.length > 0;
1021
+ if (hasChecks) {
1022
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
1023
+ }
992
1024
  const def = mergeDefs(schema._zod.def, {
993
1025
  get shape() {
994
1026
  const newShape = { ...schema._zod.def.shape };
@@ -1014,7 +1046,14 @@ function extend(schema, shape) {
1014
1046
  const checks = schema._zod.def.checks;
1015
1047
  const hasChecks = checks && checks.length > 0;
1016
1048
  if (hasChecks) {
1017
- throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
1049
+ // Only throw if new shape overlaps with existing shape
1050
+ // Use getOwnPropertyDescriptor to check key existence without accessing values
1051
+ const existingShape = schema._zod.def.shape;
1052
+ for (const key in shape) {
1053
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
1054
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
1055
+ }
1056
+ }
1018
1057
  }
1019
1058
  const def = mergeDefs(schema._zod.def, {
1020
1059
  get shape() {
@@ -1022,7 +1061,6 @@ function extend(schema, shape) {
1022
1061
  assignProp(this, "shape", _shape); // self-caching
1023
1062
  return _shape;
1024
1063
  },
1025
- checks: [],
1026
1064
  });
1027
1065
  return clone(schema, def);
1028
1066
  }
@@ -1030,15 +1068,13 @@ function safeExtend(schema, shape) {
1030
1068
  if (!isPlainObject(shape)) {
1031
1069
  throw new Error("Invalid input to safeExtend: expected a plain object");
1032
1070
  }
1033
- const def = {
1034
- ...schema._zod.def,
1071
+ const def = mergeDefs(schema._zod.def, {
1035
1072
  get shape() {
1036
1073
  const _shape = { ...schema._zod.def.shape, ...shape };
1037
1074
  assignProp(this, "shape", _shape); // self-caching
1038
1075
  return _shape;
1039
1076
  },
1040
- checks: schema._zod.def.checks,
1041
- };
1077
+ });
1042
1078
  return clone(schema, def);
1043
1079
  }
1044
1080
  function merge(a, b) {
@@ -1056,6 +1092,12 @@ function merge(a, b) {
1056
1092
  return clone(a, def);
1057
1093
  }
1058
1094
  function partial(Class, schema, mask) {
1095
+ const currDef = schema._zod.def;
1096
+ const checks = currDef.checks;
1097
+ const hasChecks = checks && checks.length > 0;
1098
+ if (hasChecks) {
1099
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
1100
+ }
1059
1101
  const def = mergeDefs(schema._zod.def, {
1060
1102
  get shape() {
1061
1103
  const oldShape = schema._zod.def.shape;
@@ -1125,7 +1167,6 @@ function required(Class, schema, mask) {
1125
1167
  assignProp(this, "shape", shape); // self-caching
1126
1168
  return shape;
1127
1169
  },
1128
- checks: [],
1129
1170
  });
1130
1171
  return clone(schema, def);
1131
1172
  }
@@ -1375,7 +1416,8 @@ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?:
1375
1416
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1376
1417
  const base64url = /^[A-Za-z0-9_-]*$/;
1377
1418
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
1378
- const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
1419
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
1420
+ const e164 = /^\+[1-9]\d{6,14}$/;
1379
1421
  // const 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])))`;
1380
1422
  const 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])))`;
1381
1423
  const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
@@ -1410,7 +1452,7 @@ const string$1 = (params) => {
1410
1452
  return new RegExp(`^${regex}$`);
1411
1453
  };
1412
1454
  const integer = /^-?\d+$/;
1413
- const number$1 = /^-?\d+(?:\.\d+)?/;
1455
+ const number$1 = /^-?\d+(?:\.\d+)?$/;
1414
1456
  const boolean$1 = /^(?:true|false)$/i;
1415
1457
  // regex for string with no uppercase letters
1416
1458
  const lowercase = /^[^A-Z]*$/;
@@ -1449,7 +1491,7 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
1449
1491
  payload.issues.push({
1450
1492
  origin,
1451
1493
  code: "too_big",
1452
- maximum: def.value,
1494
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
1453
1495
  input: payload.value,
1454
1496
  inclusive: def.inclusive,
1455
1497
  inst,
@@ -1477,7 +1519,7 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
1477
1519
  payload.issues.push({
1478
1520
  origin,
1479
1521
  code: "too_small",
1480
- minimum: def.value,
1522
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
1481
1523
  input: payload.value,
1482
1524
  inclusive: def.inclusive,
1483
1525
  inst,
@@ -1565,6 +1607,7 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
1565
1607
  note: "Integers must be within the safe integer range.",
1566
1608
  inst,
1567
1609
  origin,
1610
+ inclusive: true,
1568
1611
  continue: !def.abort,
1569
1612
  });
1570
1613
  }
@@ -1577,6 +1620,7 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
1577
1620
  note: "Integers must be within the safe integer range.",
1578
1621
  inst,
1579
1622
  origin,
1623
+ inclusive: true,
1580
1624
  continue: !def.abort,
1581
1625
  });
1582
1626
  }
@@ -1600,7 +1644,9 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
1600
1644
  input,
1601
1645
  code: "too_big",
1602
1646
  maximum,
1647
+ inclusive: true,
1603
1648
  inst,
1649
+ continue: !def.abort,
1604
1650
  });
1605
1651
  }
1606
1652
  };
@@ -1863,8 +1909,8 @@ class Doc {
1863
1909
 
1864
1910
  const version = {
1865
1911
  major: 4,
1866
- minor: 2,
1867
- patch: 1,
1912
+ minor: 3,
1913
+ patch: 5,
1868
1914
  };
1869
1915
 
1870
1916
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
@@ -1974,7 +2020,8 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1974
2020
  return runChecks(result, checks, ctx);
1975
2021
  };
1976
2022
  }
1977
- inst["~standard"] = {
2023
+ // Lazy initialize ~standard to avoid creating objects for every schema
2024
+ defineLazy(inst, "~standard", () => ({
1978
2025
  validate: (value) => {
1979
2026
  try {
1980
2027
  const r = safeParse$1(inst, value);
@@ -1986,7 +2033,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1986
2033
  },
1987
2034
  vendor: "zod",
1988
2035
  version: 1,
1989
- };
2036
+ }));
1990
2037
  });
1991
2038
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1992
2039
  $ZodType.init(inst, def);
@@ -2415,8 +2462,12 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
2415
2462
  return payload; //handleArrayResultsAsync(parseResults, final);
2416
2463
  };
2417
2464
  });
2418
- function handlePropertyResult(result, final, key, input) {
2465
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
2419
2466
  if (result.issues.length) {
2467
+ // For optional-out schemas, ignore errors on absent keys
2468
+ if (isOptionalOut && !(key in input)) {
2469
+ return;
2470
+ }
2420
2471
  final.issues.push(...prefixIssues(key, result.issues));
2421
2472
  }
2422
2473
  if (result.value === undefined) {
@@ -2450,6 +2501,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
2450
2501
  const keySet = def.keySet;
2451
2502
  const _catchall = def.catchall._zod;
2452
2503
  const t = _catchall.def.type;
2504
+ const isOptionalOut = _catchall.optout === "optional";
2453
2505
  for (const key in input) {
2454
2506
  if (keySet.has(key))
2455
2507
  continue;
@@ -2459,10 +2511,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
2459
2511
  }
2460
2512
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
2461
2513
  if (r instanceof Promise) {
2462
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
2514
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
2463
2515
  }
2464
2516
  else {
2465
- handlePropertyResult(r, payload, key, input);
2517
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
2466
2518
  }
2467
2519
  }
2468
2520
  if (unrecognized.length) {
@@ -2530,12 +2582,13 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
2530
2582
  const shape = value.shape;
2531
2583
  for (const key of value.keys) {
2532
2584
  const el = shape[key];
2585
+ const isOptionalOut = el._zod.optout === "optional";
2533
2586
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
2534
2587
  if (r instanceof Promise) {
2535
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
2588
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
2536
2589
  }
2537
2590
  else {
2538
- handlePropertyResult(r, payload, key, input);
2591
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
2539
2592
  }
2540
2593
  }
2541
2594
  if (!catchall) {
@@ -2567,8 +2620,33 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
2567
2620
  for (const key of normalized.keys) {
2568
2621
  const id = ids[key];
2569
2622
  const k = esc(key);
2623
+ const schema = shape[key];
2624
+ const isOptionalOut = schema?._zod?.optout === "optional";
2570
2625
  doc.write(`const ${id} = ${parseStr(key)};`);
2571
- doc.write(`
2626
+ if (isOptionalOut) {
2627
+ // For optional-out schemas, ignore errors on absent keys
2628
+ doc.write(`
2629
+ if (${id}.issues.length) {
2630
+ if (${k} in input) {
2631
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2632
+ ...iss,
2633
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2634
+ })));
2635
+ }
2636
+ }
2637
+
2638
+ if (${id}.value === undefined) {
2639
+ if (${k} in input) {
2640
+ newResult[${k}] = undefined;
2641
+ }
2642
+ } else {
2643
+ newResult[${k}] = ${id}.value;
2644
+ }
2645
+
2646
+ `);
2647
+ }
2648
+ else {
2649
+ doc.write(`
2572
2650
  if (${id}.issues.length) {
2573
2651
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2574
2652
  ...iss,
@@ -2576,7 +2654,6 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
2576
2654
  })));
2577
2655
  }
2578
2656
 
2579
-
2580
2657
  if (${id}.value === undefined) {
2581
2658
  if (${k} in input) {
2582
2659
  newResult[${k}] = undefined;
@@ -2586,6 +2663,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
2586
2663
  }
2587
2664
 
2588
2665
  `);
2666
+ }
2589
2667
  }
2590
2668
  doc.write(`payload.value = newResult;`);
2591
2669
  doc.write(`return payload;`);
@@ -2752,11 +2830,38 @@ function mergeValues(a, b) {
2752
2830
  return { valid: false, mergeErrorPath: [] };
2753
2831
  }
2754
2832
  function handleIntersectionResults(result, left, right) {
2755
- if (left.issues.length) {
2756
- result.issues.push(...left.issues);
2833
+ // Track which side(s) report each key as unrecognized
2834
+ const unrecKeys = new Map();
2835
+ let unrecIssue;
2836
+ for (const iss of left.issues) {
2837
+ if (iss.code === "unrecognized_keys") {
2838
+ unrecIssue ?? (unrecIssue = iss);
2839
+ for (const k of iss.keys) {
2840
+ if (!unrecKeys.has(k))
2841
+ unrecKeys.set(k, {});
2842
+ unrecKeys.get(k).l = true;
2843
+ }
2844
+ }
2845
+ else {
2846
+ result.issues.push(iss);
2847
+ }
2757
2848
  }
2758
- if (right.issues.length) {
2759
- result.issues.push(...right.issues);
2849
+ for (const iss of right.issues) {
2850
+ if (iss.code === "unrecognized_keys") {
2851
+ for (const k of iss.keys) {
2852
+ if (!unrecKeys.has(k))
2853
+ unrecKeys.set(k, {});
2854
+ unrecKeys.get(k).r = true;
2855
+ }
2856
+ }
2857
+ else {
2858
+ result.issues.push(iss);
2859
+ }
2860
+ }
2861
+ // Report only keys unrecognized by BOTH sides
2862
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2863
+ if (bothKeys.length && unrecIssue) {
2864
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
2760
2865
  }
2761
2866
  if (aborted(result))
2762
2867
  return result;
@@ -2841,6 +2946,17 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2841
2946
  return def.innerType._zod.run(payload, ctx);
2842
2947
  };
2843
2948
  });
2949
+ const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2950
+ // Call parent init - inherits optin/optout = "optional"
2951
+ $ZodOptional.init(inst, def);
2952
+ // Override values/pattern to NOT add undefined
2953
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2954
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2955
+ // Override parse to just delegate (no undefined handling)
2956
+ inst._zod.parse = (payload, ctx) => {
2957
+ return def.innerType._zod.run(payload, ctx);
2958
+ };
2959
+ });
2844
2960
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2845
2961
  $ZodType.init(inst, def);
2846
2962
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -3063,9 +3179,6 @@ class $ZodRegistry {
3063
3179
  const meta = _meta[0];
3064
3180
  this._map.set(schema, meta);
3065
3181
  if (meta && typeof meta === "object" && "id" in meta) {
3066
- if (this._idmap.has(meta.id)) {
3067
- throw new Error(`ID ${meta.id} already exists in the registry`);
3068
- }
3069
3182
  this._idmap.set(meta.id, schema);
3070
3183
  }
3071
3184
  return this;
@@ -3106,12 +3219,14 @@ function registry() {
3106
3219
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
3107
3220
  const globalRegistry = globalThis.__zod_globalRegistry;
3108
3221
 
3222
+ // @__NO_SIDE_EFFECTS__
3109
3223
  function _string(Class, params) {
3110
3224
  return new Class({
3111
3225
  type: "string",
3112
3226
  ...normalizeParams(params),
3113
3227
  });
3114
3228
  }
3229
+ // @__NO_SIDE_EFFECTS__
3115
3230
  function _email(Class, params) {
3116
3231
  return new Class({
3117
3232
  type: "string",
@@ -3121,6 +3236,7 @@ function _email(Class, params) {
3121
3236
  ...normalizeParams(params),
3122
3237
  });
3123
3238
  }
3239
+ // @__NO_SIDE_EFFECTS__
3124
3240
  function _guid(Class, params) {
3125
3241
  return new Class({
3126
3242
  type: "string",
@@ -3130,6 +3246,7 @@ function _guid(Class, params) {
3130
3246
  ...normalizeParams(params),
3131
3247
  });
3132
3248
  }
3249
+ // @__NO_SIDE_EFFECTS__
3133
3250
  function _uuid(Class, params) {
3134
3251
  return new Class({
3135
3252
  type: "string",
@@ -3139,6 +3256,7 @@ function _uuid(Class, params) {
3139
3256
  ...normalizeParams(params),
3140
3257
  });
3141
3258
  }
3259
+ // @__NO_SIDE_EFFECTS__
3142
3260
  function _uuidv4(Class, params) {
3143
3261
  return new Class({
3144
3262
  type: "string",
@@ -3149,6 +3267,7 @@ function _uuidv4(Class, params) {
3149
3267
  ...normalizeParams(params),
3150
3268
  });
3151
3269
  }
3270
+ // @__NO_SIDE_EFFECTS__
3152
3271
  function _uuidv6(Class, params) {
3153
3272
  return new Class({
3154
3273
  type: "string",
@@ -3159,6 +3278,7 @@ function _uuidv6(Class, params) {
3159
3278
  ...normalizeParams(params),
3160
3279
  });
3161
3280
  }
3281
+ // @__NO_SIDE_EFFECTS__
3162
3282
  function _uuidv7(Class, params) {
3163
3283
  return new Class({
3164
3284
  type: "string",
@@ -3169,6 +3289,7 @@ function _uuidv7(Class, params) {
3169
3289
  ...normalizeParams(params),
3170
3290
  });
3171
3291
  }
3292
+ // @__NO_SIDE_EFFECTS__
3172
3293
  function _url(Class, params) {
3173
3294
  return new Class({
3174
3295
  type: "string",
@@ -3178,6 +3299,7 @@ function _url(Class, params) {
3178
3299
  ...normalizeParams(params),
3179
3300
  });
3180
3301
  }
3302
+ // @__NO_SIDE_EFFECTS__
3181
3303
  function _emoji(Class, params) {
3182
3304
  return new Class({
3183
3305
  type: "string",
@@ -3187,6 +3309,7 @@ function _emoji(Class, params) {
3187
3309
  ...normalizeParams(params),
3188
3310
  });
3189
3311
  }
3312
+ // @__NO_SIDE_EFFECTS__
3190
3313
  function _nanoid(Class, params) {
3191
3314
  return new Class({
3192
3315
  type: "string",
@@ -3196,6 +3319,7 @@ function _nanoid(Class, params) {
3196
3319
  ...normalizeParams(params),
3197
3320
  });
3198
3321
  }
3322
+ // @__NO_SIDE_EFFECTS__
3199
3323
  function _cuid(Class, params) {
3200
3324
  return new Class({
3201
3325
  type: "string",
@@ -3205,6 +3329,7 @@ function _cuid(Class, params) {
3205
3329
  ...normalizeParams(params),
3206
3330
  });
3207
3331
  }
3332
+ // @__NO_SIDE_EFFECTS__
3208
3333
  function _cuid2(Class, params) {
3209
3334
  return new Class({
3210
3335
  type: "string",
@@ -3214,6 +3339,7 @@ function _cuid2(Class, params) {
3214
3339
  ...normalizeParams(params),
3215
3340
  });
3216
3341
  }
3342
+ // @__NO_SIDE_EFFECTS__
3217
3343
  function _ulid(Class, params) {
3218
3344
  return new Class({
3219
3345
  type: "string",
@@ -3223,6 +3349,7 @@ function _ulid(Class, params) {
3223
3349
  ...normalizeParams(params),
3224
3350
  });
3225
3351
  }
3352
+ // @__NO_SIDE_EFFECTS__
3226
3353
  function _xid(Class, params) {
3227
3354
  return new Class({
3228
3355
  type: "string",
@@ -3232,6 +3359,7 @@ function _xid(Class, params) {
3232
3359
  ...normalizeParams(params),
3233
3360
  });
3234
3361
  }
3362
+ // @__NO_SIDE_EFFECTS__
3235
3363
  function _ksuid(Class, params) {
3236
3364
  return new Class({
3237
3365
  type: "string",
@@ -3241,6 +3369,7 @@ function _ksuid(Class, params) {
3241
3369
  ...normalizeParams(params),
3242
3370
  });
3243
3371
  }
3372
+ // @__NO_SIDE_EFFECTS__
3244
3373
  function _ipv4(Class, params) {
3245
3374
  return new Class({
3246
3375
  type: "string",
@@ -3250,6 +3379,7 @@ function _ipv4(Class, params) {
3250
3379
  ...normalizeParams(params),
3251
3380
  });
3252
3381
  }
3382
+ // @__NO_SIDE_EFFECTS__
3253
3383
  function _ipv6(Class, params) {
3254
3384
  return new Class({
3255
3385
  type: "string",
@@ -3259,6 +3389,7 @@ function _ipv6(Class, params) {
3259
3389
  ...normalizeParams(params),
3260
3390
  });
3261
3391
  }
3392
+ // @__NO_SIDE_EFFECTS__
3262
3393
  function _cidrv4(Class, params) {
3263
3394
  return new Class({
3264
3395
  type: "string",
@@ -3268,6 +3399,7 @@ function _cidrv4(Class, params) {
3268
3399
  ...normalizeParams(params),
3269
3400
  });
3270
3401
  }
3402
+ // @__NO_SIDE_EFFECTS__
3271
3403
  function _cidrv6(Class, params) {
3272
3404
  return new Class({
3273
3405
  type: "string",
@@ -3277,6 +3409,7 @@ function _cidrv6(Class, params) {
3277
3409
  ...normalizeParams(params),
3278
3410
  });
3279
3411
  }
3412
+ // @__NO_SIDE_EFFECTS__
3280
3413
  function _base64(Class, params) {
3281
3414
  return new Class({
3282
3415
  type: "string",
@@ -3286,6 +3419,7 @@ function _base64(Class, params) {
3286
3419
  ...normalizeParams(params),
3287
3420
  });
3288
3421
  }
3422
+ // @__NO_SIDE_EFFECTS__
3289
3423
  function _base64url(Class, params) {
3290
3424
  return new Class({
3291
3425
  type: "string",
@@ -3295,6 +3429,7 @@ function _base64url(Class, params) {
3295
3429
  ...normalizeParams(params),
3296
3430
  });
3297
3431
  }
3432
+ // @__NO_SIDE_EFFECTS__
3298
3433
  function _e164(Class, params) {
3299
3434
  return new Class({
3300
3435
  type: "string",
@@ -3304,6 +3439,7 @@ function _e164(Class, params) {
3304
3439
  ...normalizeParams(params),
3305
3440
  });
3306
3441
  }
3442
+ // @__NO_SIDE_EFFECTS__
3307
3443
  function _jwt(Class, params) {
3308
3444
  return new Class({
3309
3445
  type: "string",
@@ -3313,6 +3449,7 @@ function _jwt(Class, params) {
3313
3449
  ...normalizeParams(params),
3314
3450
  });
3315
3451
  }
3452
+ // @__NO_SIDE_EFFECTS__
3316
3453
  function _isoDateTime(Class, params) {
3317
3454
  return new Class({
3318
3455
  type: "string",
@@ -3324,6 +3461,7 @@ function _isoDateTime(Class, params) {
3324
3461
  ...normalizeParams(params),
3325
3462
  });
3326
3463
  }
3464
+ // @__NO_SIDE_EFFECTS__
3327
3465
  function _isoDate(Class, params) {
3328
3466
  return new Class({
3329
3467
  type: "string",
@@ -3332,6 +3470,7 @@ function _isoDate(Class, params) {
3332
3470
  ...normalizeParams(params),
3333
3471
  });
3334
3472
  }
3473
+ // @__NO_SIDE_EFFECTS__
3335
3474
  function _isoTime(Class, params) {
3336
3475
  return new Class({
3337
3476
  type: "string",
@@ -3341,6 +3480,7 @@ function _isoTime(Class, params) {
3341
3480
  ...normalizeParams(params),
3342
3481
  });
3343
3482
  }
3483
+ // @__NO_SIDE_EFFECTS__
3344
3484
  function _isoDuration(Class, params) {
3345
3485
  return new Class({
3346
3486
  type: "string",
@@ -3349,6 +3489,7 @@ function _isoDuration(Class, params) {
3349
3489
  ...normalizeParams(params),
3350
3490
  });
3351
3491
  }
3492
+ // @__NO_SIDE_EFFECTS__
3352
3493
  function _number(Class, params) {
3353
3494
  return new Class({
3354
3495
  type: "number",
@@ -3356,6 +3497,7 @@ function _number(Class, params) {
3356
3497
  ...normalizeParams(params),
3357
3498
  });
3358
3499
  }
3500
+ // @__NO_SIDE_EFFECTS__
3359
3501
  function _int(Class, params) {
3360
3502
  return new Class({
3361
3503
  type: "number",
@@ -3365,28 +3507,33 @@ function _int(Class, params) {
3365
3507
  ...normalizeParams(params),
3366
3508
  });
3367
3509
  }
3510
+ // @__NO_SIDE_EFFECTS__
3368
3511
  function _boolean(Class, params) {
3369
3512
  return new Class({
3370
3513
  type: "boolean",
3371
3514
  ...normalizeParams(params),
3372
3515
  });
3373
3516
  }
3517
+ // @__NO_SIDE_EFFECTS__
3374
3518
  function _any(Class) {
3375
3519
  return new Class({
3376
3520
  type: "any",
3377
3521
  });
3378
3522
  }
3523
+ // @__NO_SIDE_EFFECTS__
3379
3524
  function _unknown(Class) {
3380
3525
  return new Class({
3381
3526
  type: "unknown",
3382
3527
  });
3383
3528
  }
3529
+ // @__NO_SIDE_EFFECTS__
3384
3530
  function _never(Class, params) {
3385
3531
  return new Class({
3386
3532
  type: "never",
3387
3533
  ...normalizeParams(params),
3388
3534
  });
3389
3535
  }
3536
+ // @__NO_SIDE_EFFECTS__
3390
3537
  function _lt(value, params) {
3391
3538
  return new $ZodCheckLessThan({
3392
3539
  check: "less_than",
@@ -3395,6 +3542,7 @@ function _lt(value, params) {
3395
3542
  inclusive: false,
3396
3543
  });
3397
3544
  }
3545
+ // @__NO_SIDE_EFFECTS__
3398
3546
  function _lte(value, params) {
3399
3547
  return new $ZodCheckLessThan({
3400
3548
  check: "less_than",
@@ -3403,6 +3551,7 @@ function _lte(value, params) {
3403
3551
  inclusive: true,
3404
3552
  });
3405
3553
  }
3554
+ // @__NO_SIDE_EFFECTS__
3406
3555
  function _gt(value, params) {
3407
3556
  return new $ZodCheckGreaterThan({
3408
3557
  check: "greater_than",
@@ -3411,6 +3560,7 @@ function _gt(value, params) {
3411
3560
  inclusive: false,
3412
3561
  });
3413
3562
  }
3563
+ // @__NO_SIDE_EFFECTS__
3414
3564
  function _gte(value, params) {
3415
3565
  return new $ZodCheckGreaterThan({
3416
3566
  check: "greater_than",
@@ -3419,6 +3569,7 @@ function _gte(value, params) {
3419
3569
  inclusive: true,
3420
3570
  });
3421
3571
  }
3572
+ // @__NO_SIDE_EFFECTS__
3422
3573
  function _multipleOf(value, params) {
3423
3574
  return new $ZodCheckMultipleOf({
3424
3575
  check: "multiple_of",
@@ -3426,6 +3577,7 @@ function _multipleOf(value, params) {
3426
3577
  value,
3427
3578
  });
3428
3579
  }
3580
+ // @__NO_SIDE_EFFECTS__
3429
3581
  function _maxLength(maximum, params) {
3430
3582
  const ch = new $ZodCheckMaxLength({
3431
3583
  check: "max_length",
@@ -3434,6 +3586,7 @@ function _maxLength(maximum, params) {
3434
3586
  });
3435
3587
  return ch;
3436
3588
  }
3589
+ // @__NO_SIDE_EFFECTS__
3437
3590
  function _minLength(minimum, params) {
3438
3591
  return new $ZodCheckMinLength({
3439
3592
  check: "min_length",
@@ -3441,6 +3594,7 @@ function _minLength(minimum, params) {
3441
3594
  minimum,
3442
3595
  });
3443
3596
  }
3597
+ // @__NO_SIDE_EFFECTS__
3444
3598
  function _length(length, params) {
3445
3599
  return new $ZodCheckLengthEquals({
3446
3600
  check: "length_equals",
@@ -3448,6 +3602,7 @@ function _length(length, params) {
3448
3602
  length,
3449
3603
  });
3450
3604
  }
3605
+ // @__NO_SIDE_EFFECTS__
3451
3606
  function _regex(pattern, params) {
3452
3607
  return new $ZodCheckRegex({
3453
3608
  check: "string_format",
@@ -3456,6 +3611,7 @@ function _regex(pattern, params) {
3456
3611
  pattern,
3457
3612
  });
3458
3613
  }
3614
+ // @__NO_SIDE_EFFECTS__
3459
3615
  function _lowercase(params) {
3460
3616
  return new $ZodCheckLowerCase({
3461
3617
  check: "string_format",
@@ -3463,6 +3619,7 @@ function _lowercase(params) {
3463
3619
  ...normalizeParams(params),
3464
3620
  });
3465
3621
  }
3622
+ // @__NO_SIDE_EFFECTS__
3466
3623
  function _uppercase(params) {
3467
3624
  return new $ZodCheckUpperCase({
3468
3625
  check: "string_format",
@@ -3470,6 +3627,7 @@ function _uppercase(params) {
3470
3627
  ...normalizeParams(params),
3471
3628
  });
3472
3629
  }
3630
+ // @__NO_SIDE_EFFECTS__
3473
3631
  function _includes(includes, params) {
3474
3632
  return new $ZodCheckIncludes({
3475
3633
  check: "string_format",
@@ -3478,6 +3636,7 @@ function _includes(includes, params) {
3478
3636
  includes,
3479
3637
  });
3480
3638
  }
3639
+ // @__NO_SIDE_EFFECTS__
3481
3640
  function _startsWith(prefix, params) {
3482
3641
  return new $ZodCheckStartsWith({
3483
3642
  check: "string_format",
@@ -3486,6 +3645,7 @@ function _startsWith(prefix, params) {
3486
3645
  prefix,
3487
3646
  });
3488
3647
  }
3648
+ // @__NO_SIDE_EFFECTS__
3489
3649
  function _endsWith(suffix, params) {
3490
3650
  return new $ZodCheckEndsWith({
3491
3651
  check: "string_format",
@@ -3494,6 +3654,7 @@ function _endsWith(suffix, params) {
3494
3654
  suffix,
3495
3655
  });
3496
3656
  }
3657
+ // @__NO_SIDE_EFFECTS__
3497
3658
  function _overwrite(tx) {
3498
3659
  return new $ZodCheckOverwrite({
3499
3660
  check: "overwrite",
@@ -3501,25 +3662,31 @@ function _overwrite(tx) {
3501
3662
  });
3502
3663
  }
3503
3664
  // normalize
3665
+ // @__NO_SIDE_EFFECTS__
3504
3666
  function _normalize(form) {
3505
3667
  return _overwrite((input) => input.normalize(form));
3506
3668
  }
3507
3669
  // trim
3670
+ // @__NO_SIDE_EFFECTS__
3508
3671
  function _trim() {
3509
3672
  return _overwrite((input) => input.trim());
3510
3673
  }
3511
3674
  // toLowerCase
3675
+ // @__NO_SIDE_EFFECTS__
3512
3676
  function _toLowerCase() {
3513
3677
  return _overwrite((input) => input.toLowerCase());
3514
3678
  }
3515
3679
  // toUpperCase
3680
+ // @__NO_SIDE_EFFECTS__
3516
3681
  function _toUpperCase() {
3517
3682
  return _overwrite((input) => input.toUpperCase());
3518
3683
  }
3519
3684
  // slugify
3685
+ // @__NO_SIDE_EFFECTS__
3520
3686
  function _slugify() {
3521
3687
  return _overwrite((input) => slugify(input));
3522
3688
  }
3689
+ // @__NO_SIDE_EFFECTS__
3523
3690
  function _array(Class, element, params) {
3524
3691
  return new Class({
3525
3692
  type: "array",
@@ -3531,6 +3698,7 @@ function _array(Class, element, params) {
3531
3698
  });
3532
3699
  }
3533
3700
  // same as _custom but defaults to abort:false
3701
+ // @__NO_SIDE_EFFECTS__
3534
3702
  function _refine(Class, fn, _params) {
3535
3703
  const schema = new Class({
3536
3704
  type: "custom",
@@ -3540,6 +3708,7 @@ function _refine(Class, fn, _params) {
3540
3708
  });
3541
3709
  return schema;
3542
3710
  }
3711
+ // @__NO_SIDE_EFFECTS__
3543
3712
  function _superRefine(fn) {
3544
3713
  const ch = _check((payload) => {
3545
3714
  payload.addIssue = (issue$1) => {
@@ -3562,6 +3731,7 @@ function _superRefine(fn) {
3562
3731
  });
3563
3732
  return ch;
3564
3733
  }
3734
+ // @__NO_SIDE_EFFECTS__
3565
3735
  function _check(fn, params) {
3566
3736
  const ch = new $ZodCheck({
3567
3737
  check: "custom",
@@ -3628,14 +3798,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
3628
3798
  schemaPath: [..._params.schemaPath, schema],
3629
3799
  path: _params.path,
3630
3800
  };
3631
- const parent = schema._zod.parent;
3632
- if (parent) {
3633
- // schema was cloned from another schema
3634
- result.ref = parent;
3635
- process$1(parent, ctx, params);
3636
- ctx.seen.get(parent).isParent = true;
3637
- }
3638
- else if (schema._zod.processJSONSchema) {
3801
+ if (schema._zod.processJSONSchema) {
3639
3802
  schema._zod.processJSONSchema(ctx, result.schema, params);
3640
3803
  }
3641
3804
  else {
@@ -3646,6 +3809,14 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
3646
3809
  }
3647
3810
  processor(schema, ctx, _json, params);
3648
3811
  }
3812
+ const parent = schema._zod.parent;
3813
+ if (parent) {
3814
+ // Also set ref if processor didn't (for inheritance)
3815
+ if (!result.ref)
3816
+ result.ref = parent;
3817
+ process$1(parent, ctx, params);
3818
+ ctx.seen.get(parent).isParent = true;
3819
+ }
3649
3820
  }
3650
3821
  // metadata
3651
3822
  const meta = ctx.metadataRegistry.get(schema);
@@ -3671,6 +3842,18 @@ function extractDefs(ctx, schema
3671
3842
  const root = ctx.seen.get(schema);
3672
3843
  if (!root)
3673
3844
  throw new Error("Unprocessed schema. This is a bug in Zod.");
3845
+ // Track ids to detect duplicates across different schemas
3846
+ const idToSchema = new Map();
3847
+ for (const entry of ctx.seen.entries()) {
3848
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3849
+ if (id) {
3850
+ const existing = idToSchema.get(id);
3851
+ if (existing && existing !== entry[0]) {
3852
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3853
+ }
3854
+ idToSchema.set(id, entry[0]);
3855
+ }
3856
+ }
3674
3857
  // returns a ref to the schema
3675
3858
  // defId will be empty if the ref points to an external schema (or #)
3676
3859
  const makeURI = (entry) => {
@@ -3772,43 +3955,84 @@ function extractDefs(ctx, schema
3772
3955
  }
3773
3956
  }
3774
3957
  function finalize(ctx, schema) {
3775
- //
3776
- // iterate over seen map;
3777
3958
  const root = ctx.seen.get(schema);
3778
3959
  if (!root)
3779
3960
  throw new Error("Unprocessed schema. This is a bug in Zod.");
3780
- // flatten _refs
3961
+ // flatten refs - inherit properties from parent schemas
3781
3962
  const flattenRef = (zodSchema) => {
3782
3963
  const seen = ctx.seen.get(zodSchema);
3964
+ // already processed
3965
+ if (seen.ref === null)
3966
+ return;
3783
3967
  const schema = seen.def ?? seen.schema;
3784
3968
  const _cached = { ...schema };
3785
- // already seen
3786
- if (seen.ref === null) {
3787
- return;
3788
- }
3789
- // flatten ref if defined
3790
3969
  const ref = seen.ref;
3791
- seen.ref = null; // prevent recursion
3970
+ seen.ref = null; // prevent infinite recursion
3792
3971
  if (ref) {
3793
3972
  flattenRef(ref);
3973
+ const refSeen = ctx.seen.get(ref);
3974
+ const refSchema = refSeen.schema;
3794
3975
  // merge referenced schema into current
3795
- const refSchema = ctx.seen.get(ref).schema;
3796
3976
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3977
+ // older drafts can't combine $ref with other properties
3797
3978
  schema.allOf = schema.allOf ?? [];
3798
3979
  schema.allOf.push(refSchema);
3799
3980
  }
3800
3981
  else {
3801
3982
  Object.assign(schema, refSchema);
3802
- Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
3983
+ }
3984
+ // restore child's own properties (child wins)
3985
+ Object.assign(schema, _cached);
3986
+ const isParentRef = zodSchema._zod.parent === ref;
3987
+ // For parent chain, child is a refinement - remove parent-only properties
3988
+ if (isParentRef) {
3989
+ for (const key in schema) {
3990
+ if (key === "$ref" || key === "allOf")
3991
+ continue;
3992
+ if (!(key in _cached)) {
3993
+ delete schema[key];
3994
+ }
3995
+ }
3996
+ }
3997
+ // When ref was extracted to $defs, remove properties that match the definition
3998
+ if (refSchema.$ref) {
3999
+ for (const key in schema) {
4000
+ if (key === "$ref" || key === "allOf")
4001
+ continue;
4002
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
4003
+ delete schema[key];
4004
+ }
4005
+ }
4006
+ }
4007
+ }
4008
+ // If parent was extracted (has $ref), propagate $ref to this schema
4009
+ // This handles cases like: readonly().meta({id}).describe()
4010
+ // where processor sets ref to innerType but parent should be referenced
4011
+ const parent = zodSchema._zod.parent;
4012
+ if (parent && parent !== ref) {
4013
+ // Ensure parent is processed first so its def has inherited properties
4014
+ flattenRef(parent);
4015
+ const parentSeen = ctx.seen.get(parent);
4016
+ if (parentSeen?.schema.$ref) {
4017
+ schema.$ref = parentSeen.schema.$ref;
4018
+ // De-duplicate with parent's definition
4019
+ if (parentSeen.def) {
4020
+ for (const key in schema) {
4021
+ if (key === "$ref" || key === "allOf")
4022
+ continue;
4023
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
4024
+ delete schema[key];
4025
+ }
4026
+ }
4027
+ }
3803
4028
  }
3804
4029
  }
3805
4030
  // execute overrides
3806
- if (!seen.isParent)
3807
- ctx.override({
3808
- zodSchema: zodSchema,
3809
- jsonSchema: schema,
3810
- path: seen.path ?? [],
3811
- });
4031
+ ctx.override({
4032
+ zodSchema: zodSchema,
4033
+ jsonSchema: schema,
4034
+ path: seen.path ?? [],
4035
+ });
3812
4036
  };
3813
4037
  for (const entry of [...ctx.seen.entries()].reverse()) {
3814
4038
  flattenRef(entry[0]);
@@ -3861,8 +4085,8 @@ function finalize(ctx, schema) {
3861
4085
  value: {
3862
4086
  ...schema["~standard"],
3863
4087
  jsonSchema: {
3864
- input: createStandardJSONSchemaMethod(schema, "input"),
3865
- output: createStandardJSONSchemaMethod(schema, "output"),
4088
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
4089
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors),
3866
4090
  },
3867
4091
  },
3868
4092
  enumerable: false,
@@ -3941,9 +4165,9 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3941
4165
  extractDefs(ctx, schema);
3942
4166
  return finalize(ctx, schema);
3943
4167
  };
3944
- const createStandardJSONSchemaMethod = (schema, io) => (params) => {
4168
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3945
4169
  const { libraryOptions, target } = params ?? {};
3946
- const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors: {} });
4170
+ const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
3947
4171
  process$1(schema, ctx);
3948
4172
  extractDefs(ctx, schema);
3949
4173
  return finalize(ctx, schema);
@@ -3971,6 +4195,11 @@ const stringProcessor = (schema, ctx, _json, _params) => {
3971
4195
  json.format = formatMap[format] ?? format;
3972
4196
  if (json.format === "")
3973
4197
  delete json.format; // empty format is not valid
4198
+ // JSON Schema format: "time" requires a full time with offset or Z
4199
+ // z.iso.time() does not include timezone information, so format: "time" should never be used
4200
+ if (format === "time") {
4201
+ delete json.format;
4202
+ }
3974
4203
  }
3975
4204
  if (contentEncoding)
3976
4205
  json.contentEncoding = contentEncoding;
@@ -4332,8 +4561,11 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4332
4561
  ...(def.checks ?? []),
4333
4562
  ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
4334
4563
  ],
4335
- }));
4564
+ }), {
4565
+ parent: true,
4566
+ });
4336
4567
  };
4568
+ inst.with = inst.check;
4337
4569
  inst.clone = (def, params) => clone(inst, def, params);
4338
4570
  inst.brand = () => inst;
4339
4571
  inst.register = ((reg, meta) => {
@@ -4361,6 +4593,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4361
4593
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
4362
4594
  // wrappers
4363
4595
  inst.optional = () => optional(inst);
4596
+ inst.exactOptional = () => exactOptional(inst);
4364
4597
  inst.nullable = () => nullable(inst);
4365
4598
  inst.nullish = () => optional(nullable(inst));
4366
4599
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -4397,6 +4630,7 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4397
4630
  // helpers
4398
4631
  inst.isOptional = () => inst.safeParse(undefined).success;
4399
4632
  inst.isNullable = () => inst.safeParse(null).success;
4633
+ inst.apply = (fn) => fn(inst);
4400
4634
  return inst;
4401
4635
  });
4402
4636
  /** @internal */
@@ -4802,6 +5036,18 @@ function optional(innerType) {
4802
5036
  innerType: innerType,
4803
5037
  });
4804
5038
  }
5039
+ const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
5040
+ $ZodExactOptional.init(inst, def);
5041
+ ZodType.init(inst, def);
5042
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
5043
+ inst.unwrap = () => inst._zod.def.innerType;
5044
+ });
5045
+ function exactOptional(innerType) {
5046
+ return new ZodExactOptional({
5047
+ type: "optional",
5048
+ innerType: innerType,
5049
+ });
5050
+ }
4805
5051
  const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
4806
5052
  $ZodNullable.init(inst, def);
4807
5053
  ZodType.init(inst, def);