@rpcbase/server 0.558.0 → 0.560.0

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.
@@ -1,3 +1,4 @@
1
+ var _a$1;
1
2
  function $constructor(name, initializer2, params) {
2
3
  function init(inst, def) {
3
4
  if (!inst._zod) {
@@ -60,7 +61,8 @@ class $ZodEncodeError extends Error {
60
61
  this.name = "ZodEncodeError";
61
62
  }
62
63
  }
63
- const globalConfig = {};
64
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
65
+ const globalConfig = globalThis.__zod_globalConfig;
64
66
  function config(newConfig) {
65
67
  return globalConfig;
66
68
  }
@@ -94,19 +96,12 @@ function cleanRegex(source) {
94
96
  return source.slice(start, end);
95
97
  }
96
98
  function floatSafeRemainder(val, step) {
97
- const valDecCount = (val.toString().split(".")[1] || "").length;
98
- const stepString = step.toString();
99
- let stepDecCount = (stepString.split(".")[1] || "").length;
100
- if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
101
- const match = stepString.match(/\d?e-(\d?)/);
102
- if (match?.[1]) {
103
- stepDecCount = Number.parseInt(match[1]);
104
- }
105
- }
106
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
107
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
108
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
109
- return valInt % stepInt / 10 ** decCount;
99
+ const ratio = val / step;
100
+ const roundedRatio = Math.round(ratio);
101
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
102
+ if (Math.abs(ratio - roundedRatio) < tolerance)
103
+ return 0;
104
+ return ratio - roundedRatio;
110
105
  }
111
106
  const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
112
107
  function defineLazy(object2, key, getter) {
@@ -158,7 +153,10 @@ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace
158
153
  function isObject(data) {
159
154
  return typeof data === "object" && data !== null && !Array.isArray(data);
160
155
  }
161
- const allowsEval = cached(() => {
156
+ const allowsEval = /* @__PURE__ */ cached(() => {
157
+ if (globalConfig.jitless) {
158
+ return false;
159
+ }
162
160
  if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
163
161
  return false;
164
162
  }
@@ -191,6 +189,10 @@ function shallowClone(o) {
191
189
  return { ...o };
192
190
  if (Array.isArray(o))
193
191
  return [...o];
192
+ if (o instanceof Map)
193
+ return new Map(o);
194
+ if (o instanceof Set)
195
+ return new Set(o);
194
196
  return o;
195
197
  }
196
198
  const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
@@ -318,6 +320,9 @@ function safeExtend(schema, shape) {
318
320
  return clone(schema, def);
319
321
  }
320
322
  function merge(a, b) {
323
+ if (a._zod.def.checks?.length) {
324
+ throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
325
+ }
321
326
  const def = mergeDefs(a._zod.def, {
322
327
  get shape() {
323
328
  const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
@@ -327,8 +332,7 @@ function merge(a, b) {
327
332
  get catchall() {
328
333
  return b._zod.def.catchall;
329
334
  },
330
- checks: []
331
- // delete existing checks
335
+ checks: b._zod.def.checks ?? []
332
336
  });
333
337
  return clone(a, def);
334
338
  }
@@ -411,6 +415,16 @@ function aborted(x, startIndex = 0) {
411
415
  }
412
416
  return false;
413
417
  }
418
+ function explicitlyAborted(x, startIndex = 0) {
419
+ if (x.aborted === true)
420
+ return true;
421
+ for (let i = startIndex; i < x.issues.length; i++) {
422
+ if (x.issues[i]?.continue === false) {
423
+ return true;
424
+ }
425
+ }
426
+ return false;
427
+ }
414
428
  function prefixIssues(path, issues) {
415
429
  return issues.map((iss) => {
416
430
  var _a2;
@@ -423,17 +437,14 @@ function unwrapMessage(message) {
423
437
  return typeof message === "string" ? message : message?.message;
424
438
  }
425
439
  function finalizeIssue(iss, ctx, config2) {
426
- const full = { ...iss, path: iss.path ?? [] };
427
- if (!iss.message) {
428
- const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
429
- full.message = message;
430
- }
431
- delete full.inst;
432
- delete full.continue;
433
- if (!ctx?.reportInput) {
434
- delete full.input;
440
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
441
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
442
+ rest.path ?? (rest.path = []);
443
+ rest.message = message;
444
+ if (ctx?.reportInput) {
445
+ rest.input = _input;
435
446
  }
436
- return full;
447
+ return rest;
437
448
  }
438
449
  function getLengthableOrigin(input) {
439
450
  if (Array.isArray(input))
@@ -487,30 +498,33 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
487
498
  }
488
499
  function formatError(error, mapper = (issue2) => issue2.message) {
489
500
  const fieldErrors = { _errors: [] };
490
- const processError = (error2) => {
501
+ const processError = (error2, path = []) => {
491
502
  for (const issue2 of error2.issues) {
492
503
  if (issue2.code === "invalid_union" && issue2.errors.length) {
493
- issue2.errors.map((issues) => processError({ issues }));
504
+ issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
494
505
  } else if (issue2.code === "invalid_key") {
495
- processError({ issues: issue2.issues });
506
+ processError({ issues: issue2.issues }, [...path, ...issue2.path]);
496
507
  } else if (issue2.code === "invalid_element") {
497
- processError({ issues: issue2.issues });
498
- } else if (issue2.path.length === 0) {
499
- fieldErrors._errors.push(mapper(issue2));
508
+ processError({ issues: issue2.issues }, [...path, ...issue2.path]);
500
509
  } else {
501
- let curr = fieldErrors;
502
- let i = 0;
503
- while (i < issue2.path.length) {
504
- const el = issue2.path[i];
505
- const terminal = i === issue2.path.length - 1;
506
- if (!terminal) {
507
- curr[el] = curr[el] || { _errors: [] };
508
- } else {
509
- curr[el] = curr[el] || { _errors: [] };
510
- curr[el]._errors.push(mapper(issue2));
510
+ const fullpath = [...path, ...issue2.path];
511
+ if (fullpath.length === 0) {
512
+ fieldErrors._errors.push(mapper(issue2));
513
+ } else {
514
+ let curr = fieldErrors;
515
+ let i = 0;
516
+ while (i < fullpath.length) {
517
+ const el = fullpath[i];
518
+ const terminal = i === fullpath.length - 1;
519
+ if (!terminal) {
520
+ curr[el] = curr[el] || { _errors: [] };
521
+ } else {
522
+ curr[el] = curr[el] || { _errors: [] };
523
+ curr[el]._errors.push(mapper(issue2));
524
+ }
525
+ curr = curr[el];
526
+ i++;
511
527
  }
512
- curr = curr[el];
513
- i++;
514
528
  }
515
529
  }
516
530
  }
@@ -519,7 +533,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
519
533
  return fieldErrors;
520
534
  }
521
535
  const _parse = (_Err) => (schema, value, _ctx, _params) => {
522
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
536
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
523
537
  const result = schema._zod.run({ value, issues: [] }, ctx);
524
538
  if (result instanceof Promise) {
525
539
  throw new $ZodAsyncError();
@@ -532,7 +546,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
532
546
  return result.value;
533
547
  };
534
548
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
535
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
549
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
536
550
  let result = schema._zod.run({ value, issues: [] }, ctx);
537
551
  if (result instanceof Promise)
538
552
  result = await result;
@@ -556,7 +570,7 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
556
570
  };
557
571
  const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
558
572
  const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
559
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
573
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
560
574
  let result = schema._zod.run({ value, issues: [] }, ctx);
561
575
  if (result instanceof Promise)
562
576
  result = await result;
@@ -567,34 +581,34 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
567
581
  };
568
582
  const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
569
583
  const _encode = (_Err) => (schema, value, _ctx) => {
570
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
584
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
571
585
  return _parse(_Err)(schema, value, ctx);
572
586
  };
573
587
  const _decode = (_Err) => (schema, value, _ctx) => {
574
588
  return _parse(_Err)(schema, value, _ctx);
575
589
  };
576
590
  const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
577
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
591
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
578
592
  return _parseAsync(_Err)(schema, value, ctx);
579
593
  };
580
594
  const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
581
595
  return _parseAsync(_Err)(schema, value, _ctx);
582
596
  };
583
597
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
584
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
598
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
585
599
  return _safeParse(_Err)(schema, value, ctx);
586
600
  };
587
601
  const _safeDecode = (_Err) => (schema, value, _ctx) => {
588
602
  return _safeParse(_Err)(schema, value, _ctx);
589
603
  };
590
604
  const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
591
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
605
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
592
606
  return _safeParseAsync(_Err)(schema, value, ctx);
593
607
  };
594
608
  const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
595
609
  return _safeParseAsync(_Err)(schema, value, _ctx);
596
610
  };
597
- const cuid = /^[cC][^\s-]{8,}$/;
611
+ const cuid = /^[cC][0-9a-z]{6,}$/;
598
612
  const cuid2 = /^[0-9a-z]+$/;
599
613
  const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
600
614
  const xid = /^[0-9a-vA-V]{20}$/;
@@ -618,6 +632,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
618
632
  const 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])$/;
619
633
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
620
634
  const base64url = /^[A-Za-z0-9_-]*$/;
635
+ const httpProtocol = /^https?$/;
621
636
  const e164 = /^\+[1-9]\d{6,14}$/;
622
637
  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])))`;
623
638
  const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
@@ -1072,8 +1087,8 @@ class Doc {
1072
1087
  }
1073
1088
  const version = {
1074
1089
  major: 4,
1075
- minor: 3,
1076
- patch: 6
1090
+ minor: 4,
1091
+ patch: 3
1077
1092
  };
1078
1093
  const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1079
1094
  var _a2;
@@ -1101,6 +1116,8 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1101
1116
  let asyncResult;
1102
1117
  for (const ch of checks2) {
1103
1118
  if (ch._zod.def.when) {
1119
+ if (explicitlyAborted(payload))
1120
+ continue;
1104
1121
  const shouldRun = ch._zod.def.when(payload);
1105
1122
  if (!shouldRun)
1106
1123
  continue;
@@ -1241,6 +1258,19 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1241
1258
  inst._zod.check = (payload) => {
1242
1259
  try {
1243
1260
  const trimmed = payload.value.trim();
1261
+ if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1262
+ if (!/^https?:\/\//i.test(trimmed)) {
1263
+ payload.issues.push({
1264
+ code: "invalid_format",
1265
+ format: "url",
1266
+ note: "Invalid URL format",
1267
+ input: payload.value,
1268
+ inst,
1269
+ continue: !def.abort
1270
+ });
1271
+ return;
1272
+ }
1273
+ }
1244
1274
  const url = new URL(trimmed);
1245
1275
  if (def.hostname) {
1246
1276
  def.hostname.lastIndex = 0;
@@ -1389,6 +1419,8 @@ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1389
1419
  function isValidBase64(data) {
1390
1420
  if (data === "")
1391
1421
  return true;
1422
+ if (/\s/.test(data))
1423
+ return false;
1392
1424
  if (data.length % 4 !== 0)
1393
1425
  return false;
1394
1426
  try {
@@ -1579,15 +1611,27 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1579
1611
  return payload;
1580
1612
  };
1581
1613
  });
1582
- function handlePropertyResult(result, final, key, input, isOptionalOut) {
1614
+ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1615
+ const isPresent = key in input;
1583
1616
  if (result.issues.length) {
1584
- if (isOptionalOut && !(key in input)) {
1617
+ if (isOptionalIn && isOptionalOut && !isPresent) {
1585
1618
  return;
1586
1619
  }
1587
1620
  final.issues.push(...prefixIssues(key, result.issues));
1588
1621
  }
1622
+ if (!isPresent && !isOptionalIn) {
1623
+ if (!result.issues.length) {
1624
+ final.issues.push({
1625
+ code: "invalid_type",
1626
+ expected: "nonoptional",
1627
+ input: void 0,
1628
+ path: [key]
1629
+ });
1630
+ }
1631
+ return;
1632
+ }
1589
1633
  if (result.value === void 0) {
1590
- if (key in input) {
1634
+ if (isPresent) {
1591
1635
  final.value[key] = void 0;
1592
1636
  }
1593
1637
  } else {
@@ -1615,8 +1659,11 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1615
1659
  const keySet = def.keySet;
1616
1660
  const _catchall = def.catchall._zod;
1617
1661
  const t = _catchall.def.type;
1662
+ const isOptionalIn = _catchall.optin === "optional";
1618
1663
  const isOptionalOut = _catchall.optout === "optional";
1619
1664
  for (const key in input) {
1665
+ if (key === "__proto__")
1666
+ continue;
1620
1667
  if (keySet.has(key))
1621
1668
  continue;
1622
1669
  if (t === "never") {
@@ -1625,9 +1672,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1625
1672
  }
1626
1673
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1627
1674
  if (r instanceof Promise) {
1628
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1675
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
1629
1676
  } else {
1630
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1677
+ handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1631
1678
  }
1632
1679
  }
1633
1680
  if (unrecognized.length) {
@@ -1693,12 +1740,13 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1693
1740
  const shape = value.shape;
1694
1741
  for (const key of value.keys) {
1695
1742
  const el = shape[key];
1743
+ const isOptionalIn = el._zod.optin === "optional";
1696
1744
  const isOptionalOut = el._zod.optout === "optional";
1697
1745
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1698
1746
  if (r instanceof Promise) {
1699
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1747
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
1700
1748
  } else {
1701
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1749
+ handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1702
1750
  }
1703
1751
  }
1704
1752
  if (!catchall) {
@@ -1729,9 +1777,10 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
1729
1777
  const id = ids[key];
1730
1778
  const k = esc(key);
1731
1779
  const schema = shape[key];
1780
+ const isOptionalIn = schema?._zod?.optin === "optional";
1732
1781
  const isOptionalOut = schema?._zod?.optout === "optional";
1733
1782
  doc.write(`const ${id} = ${parseStr(key)};`);
1734
- if (isOptionalOut) {
1783
+ if (isOptionalIn && isOptionalOut) {
1735
1784
  doc.write(`
1736
1785
  if (${id}.issues.length) {
1737
1786
  if (${k} in input) {
@@ -1750,6 +1799,33 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
1750
1799
  newResult[${k}] = ${id}.value;
1751
1800
  }
1752
1801
 
1802
+ `);
1803
+ } else if (!isOptionalIn) {
1804
+ doc.write(`
1805
+ const ${id}_present = ${k} in input;
1806
+ if (${id}.issues.length) {
1807
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1808
+ ...iss,
1809
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1810
+ })));
1811
+ }
1812
+ if (!${id}_present && !${id}.issues.length) {
1813
+ payload.issues.push({
1814
+ code: "invalid_type",
1815
+ expected: "nonoptional",
1816
+ input: undefined,
1817
+ path: [${k}]
1818
+ });
1819
+ }
1820
+
1821
+ if (${id}_present) {
1822
+ if (${id}.value === undefined) {
1823
+ newResult[${k}] = undefined;
1824
+ } else {
1825
+ newResult[${k}] = ${id}.value;
1826
+ }
1827
+ }
1828
+
1753
1829
  `);
1754
1830
  } else {
1755
1831
  doc.write(`
@@ -1843,10 +1919,9 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1843
1919
  }
1844
1920
  return void 0;
1845
1921
  });
1846
- const single = def.options.length === 1;
1847
- const first = def.options[0]._zod.run;
1922
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1848
1923
  inst._zod.parse = (payload, ctx) => {
1849
- if (single) {
1924
+ if (first) {
1850
1925
  return first(payload, ctx);
1851
1926
  }
1852
1927
  let async = false;
@@ -1991,19 +2066,35 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
1991
2066
  for (const key of values) {
1992
2067
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1993
2068
  recordKeys.add(typeof key === "number" ? key.toString() : key);
2069
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2070
+ if (keyResult instanceof Promise) {
2071
+ throw new Error("Async schemas not supported in object keys currently");
2072
+ }
2073
+ if (keyResult.issues.length) {
2074
+ payload.issues.push({
2075
+ code: "invalid_key",
2076
+ origin: "record",
2077
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2078
+ input: key,
2079
+ path: [key],
2080
+ inst
2081
+ });
2082
+ continue;
2083
+ }
2084
+ const outKey = keyResult.value;
1994
2085
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1995
2086
  if (result instanceof Promise) {
1996
2087
  proms.push(result.then((result2) => {
1997
2088
  if (result2.issues.length) {
1998
2089
  payload.issues.push(...prefixIssues(key, result2.issues));
1999
2090
  }
2000
- payload.value[key] = result2.value;
2091
+ payload.value[outKey] = result2.value;
2001
2092
  }));
2002
2093
  } else {
2003
2094
  if (result.issues.length) {
2004
2095
  payload.issues.push(...prefixIssues(key, result.issues));
2005
2096
  }
2006
- payload.value[key] = result.value;
2097
+ payload.value[outKey] = result.value;
2007
2098
  }
2008
2099
  }
2009
2100
  }
@@ -2027,6 +2118,8 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2027
2118
  for (const key of Reflect.ownKeys(input)) {
2028
2119
  if (key === "__proto__")
2029
2120
  continue;
2121
+ if (!Object.prototype.propertyIsEnumerable.call(input, key))
2122
+ continue;
2030
2123
  let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2031
2124
  if (keyResult instanceof Promise) {
2032
2125
  throw new Error("Async schemas not supported in object keys currently");
@@ -2100,6 +2193,7 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2100
2193
  });
2101
2194
  const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2102
2195
  $ZodType.init(inst, def);
2196
+ inst._zod.optin = "optional";
2103
2197
  inst._zod.parse = (payload, ctx) => {
2104
2198
  if (ctx.direction === "backward") {
2105
2199
  throw new $ZodEncodeError(inst.constructor.name);
@@ -2109,6 +2203,7 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
2109
2203
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2110
2204
  return output.then((output2) => {
2111
2205
  payload.value = output2;
2206
+ payload.fallback = true;
2112
2207
  return payload;
2113
2208
  });
2114
2209
  }
@@ -2116,11 +2211,12 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
2116
2211
  throw new $ZodAsyncError();
2117
2212
  }
2118
2213
  payload.value = _out;
2214
+ payload.fallback = true;
2119
2215
  return payload;
2120
2216
  };
2121
2217
  });
2122
2218
  function handleOptionalResult(result, input) {
2123
- if (result.issues.length && input === void 0) {
2219
+ if (input === void 0 && (result.issues.length || result.fallback)) {
2124
2220
  return { issues: [], value: void 0 };
2125
2221
  }
2126
2222
  return result;
@@ -2138,10 +2234,11 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
2138
2234
  });
2139
2235
  inst._zod.parse = (payload, ctx) => {
2140
2236
  if (def.innerType._zod.optin === "optional") {
2237
+ const input = payload.value;
2141
2238
  const result = def.innerType._zod.run(payload, ctx);
2142
2239
  if (result instanceof Promise)
2143
- return result.then((r) => handleOptionalResult(r, payload.value));
2144
- return handleOptionalResult(result, payload.value);
2240
+ return result.then((r) => handleOptionalResult(r, input));
2241
+ return handleOptionalResult(result, input);
2145
2242
  }
2146
2243
  if (payload.value === void 0) {
2147
2244
  return payload;
@@ -2240,7 +2337,7 @@ function handleNonOptionalResult(payload, inst) {
2240
2337
  }
2241
2338
  const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2242
2339
  $ZodType.init(inst, def);
2243
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2340
+ inst._zod.optin = "optional";
2244
2341
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2245
2342
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2246
2343
  inst._zod.parse = (payload, ctx) => {
@@ -2260,6 +2357,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2260
2357
  input: payload.value
2261
2358
  });
2262
2359
  payload.issues = [];
2360
+ payload.fallback = true;
2263
2361
  }
2264
2362
  return payload;
2265
2363
  });
@@ -2274,6 +2372,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2274
2372
  input: payload.value
2275
2373
  });
2276
2374
  payload.issues = [];
2375
+ payload.fallback = true;
2277
2376
  }
2278
2377
  return payload;
2279
2378
  };
@@ -2304,7 +2403,7 @@ function handlePipeResult(left, next, ctx) {
2304
2403
  left.aborted = true;
2305
2404
  return left;
2306
2405
  }
2307
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2406
+ return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
2308
2407
  }
2309
2408
  const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2310
2409
  $ZodType.init(inst, def);
@@ -2884,7 +2983,7 @@ function _refine(Class, fn, _params) {
2884
2983
  return schema;
2885
2984
  }
2886
2985
  // @__NO_SIDE_EFFECTS__
2887
- function _superRefine(fn) {
2986
+ function _superRefine(fn, params) {
2888
2987
  const ch = /* @__PURE__ */ _check((payload) => {
2889
2988
  payload.addIssue = (issue$1) => {
2890
2989
  if (typeof issue$1 === "string") {
@@ -2901,7 +3000,7 @@ function _superRefine(fn) {
2901
3000
  }
2902
3001
  };
2903
3002
  return fn(payload.value, payload);
2904
- });
3003
+ }, params);
2905
3004
  return ch;
2906
3005
  }
2907
3006
  // @__NO_SIDE_EFFECTS__
@@ -2982,7 +3081,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
2982
3081
  delete result.schema.examples;
2983
3082
  delete result.schema.default;
2984
3083
  }
2985
- if (ctx.io === "input" && result.schema._prefault)
3084
+ if (ctx.io === "input" && "_prefault" in result.schema)
2986
3085
  (_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
2987
3086
  delete result.schema._prefault;
2988
3087
  const _result = ctx.seen.get(schema);
@@ -3163,10 +3262,15 @@ function finalize(ctx, schema) {
3163
3262
  result.$id = ctx.external.uri(id);
3164
3263
  }
3165
3264
  Object.assign(result, root.def ?? root.schema);
3265
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
3266
+ if (rootMetaId !== void 0 && result.id === rootMetaId)
3267
+ delete result.id;
3166
3268
  const defs = ctx.external?.defs ?? {};
3167
3269
  for (const entry of ctx.seen.entries()) {
3168
3270
  const seen = entry[1];
3169
3271
  if (seen.def && seen.defId) {
3272
+ if (seen.def.id === seen.defId)
3273
+ delete seen.def.id;
3170
3274
  defs[seen.defId] = seen.def;
3171
3275
  }
3172
3276
  }
@@ -3222,6 +3326,8 @@ function isTransforming(_schema, _ctx) {
3222
3326
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3223
3327
  }
3224
3328
  if (def.type === "pipe") {
3329
+ if (_schema._zod.traits.has("$ZodCodec"))
3330
+ return true;
3225
3331
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3226
3332
  }
3227
3333
  if (def.type === "object") {
@@ -3309,39 +3415,28 @@ const numberProcessor = (schema, ctx, _json, _params) => {
3309
3415
  json.type = "integer";
3310
3416
  else
3311
3417
  json.type = "number";
3312
- if (typeof exclusiveMinimum === "number") {
3313
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3418
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3419
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3420
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3421
+ if (exMin) {
3422
+ if (legacy) {
3314
3423
  json.minimum = exclusiveMinimum;
3315
3424
  json.exclusiveMinimum = true;
3316
3425
  } else {
3317
3426
  json.exclusiveMinimum = exclusiveMinimum;
3318
3427
  }
3319
- }
3320
- if (typeof minimum === "number") {
3428
+ } else if (typeof minimum === "number") {
3321
3429
  json.minimum = minimum;
3322
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
3323
- if (exclusiveMinimum >= minimum)
3324
- delete json.minimum;
3325
- else
3326
- delete json.exclusiveMinimum;
3327
- }
3328
3430
  }
3329
- if (typeof exclusiveMaximum === "number") {
3330
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3431
+ if (exMax) {
3432
+ if (legacy) {
3331
3433
  json.maximum = exclusiveMaximum;
3332
3434
  json.exclusiveMaximum = true;
3333
3435
  } else {
3334
3436
  json.exclusiveMaximum = exclusiveMaximum;
3335
3437
  }
3336
- }
3337
- if (typeof maximum === "number") {
3438
+ } else if (typeof maximum === "number") {
3338
3439
  json.maximum = maximum;
3339
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
3340
- if (exclusiveMaximum <= maximum)
3341
- delete json.maximum;
3342
- else
3343
- delete json.exclusiveMaximum;
3344
- }
3345
3440
  }
3346
3441
  if (typeof multipleOf === "number")
3347
3442
  json.multipleOf = multipleOf;
@@ -3382,7 +3477,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
3382
3477
  if (typeof maximum === "number")
3383
3478
  json.maxItems = maximum;
3384
3479
  json.type = "array";
3385
- json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
3480
+ json.items = process(def.element, ctx, {
3481
+ ...params,
3482
+ path: [...params.path, "items"]
3483
+ });
3386
3484
  };
3387
3485
  const objectProcessor = (schema, ctx, _json, params) => {
3388
3486
  const json = _json;
@@ -3533,7 +3631,8 @@ const catchProcessor = (schema, ctx, json, params) => {
3533
3631
  };
3534
3632
  const pipeProcessor = (schema, ctx, _json, params) => {
3535
3633
  const def = schema._zod.def;
3536
- const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3634
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3635
+ const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3537
3636
  process(innerType, ctx, params);
3538
3637
  const seen = ctx.seen.get(schema);
3539
3638
  seen.ref = innerType;
@@ -3613,7 +3712,7 @@ const initializer = (inst, issues) => {
3613
3712
  }
3614
3713
  });
3615
3714
  };
3616
- const ZodRealError = $constructor("ZodError", initializer, {
3715
+ const ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, {
3617
3716
  Parent: Error
3618
3717
  });
3619
3718
  const parse = /* @__PURE__ */ _parse(ZodRealError);
@@ -3628,6 +3727,43 @@ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3628
3727
  const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3629
3728
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3630
3729
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3730
+ const _installedGroups = /* @__PURE__ */ new WeakMap();
3731
+ function _installLazyMethods(inst, group, methods) {
3732
+ const proto = Object.getPrototypeOf(inst);
3733
+ let installed = _installedGroups.get(proto);
3734
+ if (!installed) {
3735
+ installed = /* @__PURE__ */ new Set();
3736
+ _installedGroups.set(proto, installed);
3737
+ }
3738
+ if (installed.has(group))
3739
+ return;
3740
+ installed.add(group);
3741
+ for (const key in methods) {
3742
+ const fn = methods[key];
3743
+ Object.defineProperty(proto, key, {
3744
+ configurable: true,
3745
+ enumerable: false,
3746
+ get() {
3747
+ const bound = fn.bind(this);
3748
+ Object.defineProperty(this, key, {
3749
+ configurable: true,
3750
+ writable: true,
3751
+ enumerable: true,
3752
+ value: bound
3753
+ });
3754
+ return bound;
3755
+ },
3756
+ set(v) {
3757
+ Object.defineProperty(this, key, {
3758
+ configurable: true,
3759
+ writable: true,
3760
+ enumerable: true,
3761
+ value: v
3762
+ });
3763
+ }
3764
+ });
3765
+ }
3766
+ }
3631
3767
  const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3632
3768
  $ZodType.init(inst, def);
3633
3769
  Object.assign(inst["~standard"], {
@@ -3640,23 +3776,6 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3640
3776
  inst.def = def;
3641
3777
  inst.type = def.type;
3642
3778
  Object.defineProperty(inst, "_def", { value: def });
3643
- inst.check = (...checks) => {
3644
- return inst.clone(mergeDefs(def, {
3645
- checks: [
3646
- ...def.checks ?? [],
3647
- ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3648
- ]
3649
- }), {
3650
- parent: true
3651
- });
3652
- };
3653
- inst.with = inst.check;
3654
- inst.clone = (def2, params) => clone(inst, def2, params);
3655
- inst.brand = () => inst;
3656
- inst.register = ((reg, meta) => {
3657
- reg.add(inst, meta);
3658
- return inst;
3659
- });
3660
3779
  inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3661
3780
  inst.safeParse = (data, params) => safeParse(inst, data, params);
3662
3781
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
@@ -3670,45 +3789,108 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3670
3789
  inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3671
3790
  inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3672
3791
  inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3673
- inst.refine = (check, params) => inst.check(refine(check, params));
3674
- inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3675
- inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
3676
- inst.optional = () => optional(inst);
3677
- inst.exactOptional = () => exactOptional(inst);
3678
- inst.nullable = () => nullable(inst);
3679
- inst.nullish = () => optional(nullable(inst));
3680
- inst.nonoptional = (params) => nonoptional(inst, params);
3681
- inst.array = () => array(inst);
3682
- inst.or = (arg) => union([inst, arg]);
3683
- inst.and = (arg) => intersection(inst, arg);
3684
- inst.transform = (tx) => pipe(inst, transform(tx));
3685
- inst.default = (def2) => _default(inst, def2);
3686
- inst.prefault = (def2) => prefault(inst, def2);
3687
- inst.catch = (params) => _catch(inst, params);
3688
- inst.pipe = (target) => pipe(inst, target);
3689
- inst.readonly = () => readonly(inst);
3690
- inst.describe = (description) => {
3691
- const cl = inst.clone();
3692
- globalRegistry.add(cl, { description });
3693
- return cl;
3694
- };
3792
+ _installLazyMethods(inst, "ZodType", {
3793
+ check(...chks) {
3794
+ const def2 = this.def;
3795
+ return this.clone(mergeDefs(def2, {
3796
+ checks: [
3797
+ ...def2.checks ?? [],
3798
+ ...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3799
+ ]
3800
+ }), { parent: true });
3801
+ },
3802
+ with(...chks) {
3803
+ return this.check(...chks);
3804
+ },
3805
+ clone(def2, params) {
3806
+ return clone(this, def2, params);
3807
+ },
3808
+ brand() {
3809
+ return this;
3810
+ },
3811
+ register(reg, meta) {
3812
+ reg.add(this, meta);
3813
+ return this;
3814
+ },
3815
+ refine(check, params) {
3816
+ return this.check(refine(check, params));
3817
+ },
3818
+ superRefine(refinement, params) {
3819
+ return this.check(superRefine(refinement, params));
3820
+ },
3821
+ overwrite(fn) {
3822
+ return this.check(/* @__PURE__ */ _overwrite(fn));
3823
+ },
3824
+ optional() {
3825
+ return optional(this);
3826
+ },
3827
+ exactOptional() {
3828
+ return exactOptional(this);
3829
+ },
3830
+ nullable() {
3831
+ return nullable(this);
3832
+ },
3833
+ nullish() {
3834
+ return optional(nullable(this));
3835
+ },
3836
+ nonoptional(params) {
3837
+ return nonoptional(this, params);
3838
+ },
3839
+ array() {
3840
+ return array(this);
3841
+ },
3842
+ or(arg) {
3843
+ return union([this, arg]);
3844
+ },
3845
+ and(arg) {
3846
+ return intersection(this, arg);
3847
+ },
3848
+ transform(tx) {
3849
+ return pipe(this, transform(tx));
3850
+ },
3851
+ default(d) {
3852
+ return _default(this, d);
3853
+ },
3854
+ prefault(d) {
3855
+ return prefault(this, d);
3856
+ },
3857
+ catch(params) {
3858
+ return _catch(this, params);
3859
+ },
3860
+ pipe(target) {
3861
+ return pipe(this, target);
3862
+ },
3863
+ readonly() {
3864
+ return readonly(this);
3865
+ },
3866
+ describe(description) {
3867
+ const cl = this.clone();
3868
+ globalRegistry.add(cl, { description });
3869
+ return cl;
3870
+ },
3871
+ meta(...args) {
3872
+ if (args.length === 0)
3873
+ return globalRegistry.get(this);
3874
+ const cl = this.clone();
3875
+ globalRegistry.add(cl, args[0]);
3876
+ return cl;
3877
+ },
3878
+ isOptional() {
3879
+ return this.safeParse(void 0).success;
3880
+ },
3881
+ isNullable() {
3882
+ return this.safeParse(null).success;
3883
+ },
3884
+ apply(fn) {
3885
+ return fn(this);
3886
+ }
3887
+ });
3695
3888
  Object.defineProperty(inst, "description", {
3696
3889
  get() {
3697
3890
  return globalRegistry.get(inst)?.description;
3698
3891
  },
3699
3892
  configurable: true
3700
3893
  });
3701
- inst.meta = (...args) => {
3702
- if (args.length === 0) {
3703
- return globalRegistry.get(inst);
3704
- }
3705
- const cl = inst.clone();
3706
- globalRegistry.add(cl, args[0]);
3707
- return cl;
3708
- };
3709
- inst.isOptional = () => inst.safeParse(void 0).success;
3710
- inst.isNullable = () => inst.safeParse(null).success;
3711
- inst.apply = (fn) => fn(inst);
3712
3894
  return inst;
3713
3895
  });
3714
3896
  const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
@@ -3719,21 +3901,53 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
3719
3901
  inst.format = bag.format ?? null;
3720
3902
  inst.minLength = bag.minimum ?? null;
3721
3903
  inst.maxLength = bag.maximum ?? null;
3722
- inst.regex = (...args) => inst.check(/* @__PURE__ */ _regex(...args));
3723
- inst.includes = (...args) => inst.check(/* @__PURE__ */ _includes(...args));
3724
- inst.startsWith = (...args) => inst.check(/* @__PURE__ */ _startsWith(...args));
3725
- inst.endsWith = (...args) => inst.check(/* @__PURE__ */ _endsWith(...args));
3726
- inst.min = (...args) => inst.check(/* @__PURE__ */ _minLength(...args));
3727
- inst.max = (...args) => inst.check(/* @__PURE__ */ _maxLength(...args));
3728
- inst.length = (...args) => inst.check(/* @__PURE__ */ _length(...args));
3729
- inst.nonempty = (...args) => inst.check(/* @__PURE__ */ _minLength(1, ...args));
3730
- inst.lowercase = (params) => inst.check(/* @__PURE__ */ _lowercase(params));
3731
- inst.uppercase = (params) => inst.check(/* @__PURE__ */ _uppercase(params));
3732
- inst.trim = () => inst.check(/* @__PURE__ */ _trim());
3733
- inst.normalize = (...args) => inst.check(/* @__PURE__ */ _normalize(...args));
3734
- inst.toLowerCase = () => inst.check(/* @__PURE__ */ _toLowerCase());
3735
- inst.toUpperCase = () => inst.check(/* @__PURE__ */ _toUpperCase());
3736
- inst.slugify = () => inst.check(/* @__PURE__ */ _slugify());
3904
+ _installLazyMethods(inst, "_ZodString", {
3905
+ regex(...args) {
3906
+ return this.check(/* @__PURE__ */ _regex(...args));
3907
+ },
3908
+ includes(...args) {
3909
+ return this.check(/* @__PURE__ */ _includes(...args));
3910
+ },
3911
+ startsWith(...args) {
3912
+ return this.check(/* @__PURE__ */ _startsWith(...args));
3913
+ },
3914
+ endsWith(...args) {
3915
+ return this.check(/* @__PURE__ */ _endsWith(...args));
3916
+ },
3917
+ min(...args) {
3918
+ return this.check(/* @__PURE__ */ _minLength(...args));
3919
+ },
3920
+ max(...args) {
3921
+ return this.check(/* @__PURE__ */ _maxLength(...args));
3922
+ },
3923
+ length(...args) {
3924
+ return this.check(/* @__PURE__ */ _length(...args));
3925
+ },
3926
+ nonempty(...args) {
3927
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
3928
+ },
3929
+ lowercase(params) {
3930
+ return this.check(/* @__PURE__ */ _lowercase(params));
3931
+ },
3932
+ uppercase(params) {
3933
+ return this.check(/* @__PURE__ */ _uppercase(params));
3934
+ },
3935
+ trim() {
3936
+ return this.check(/* @__PURE__ */ _trim());
3937
+ },
3938
+ normalize(...args) {
3939
+ return this.check(/* @__PURE__ */ _normalize(...args));
3940
+ },
3941
+ toLowerCase() {
3942
+ return this.check(/* @__PURE__ */ _toLowerCase());
3943
+ },
3944
+ toUpperCase() {
3945
+ return this.check(/* @__PURE__ */ _toUpperCase());
3946
+ },
3947
+ slugify() {
3948
+ return this.check(/* @__PURE__ */ _slugify());
3949
+ }
3950
+ });
3737
3951
  });
3738
3952
  const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
3739
3953
  $ZodString.init(inst, def);
@@ -3853,21 +4067,53 @@ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
3853
4067
  $ZodNumber.init(inst, def);
3854
4068
  ZodType.init(inst, def);
3855
4069
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
3856
- inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
3857
- inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
3858
- inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
3859
- inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
3860
- inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
3861
- inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
3862
- inst.int = (params) => inst.check(int(params));
3863
- inst.safe = (params) => inst.check(int(params));
3864
- inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(0, params));
3865
- inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(0, params));
3866
- inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(0, params));
3867
- inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(0, params));
3868
- inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
3869
- inst.step = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
3870
- inst.finite = () => inst;
4070
+ _installLazyMethods(inst, "ZodNumber", {
4071
+ gt(value, params) {
4072
+ return this.check(/* @__PURE__ */ _gt(value, params));
4073
+ },
4074
+ gte(value, params) {
4075
+ return this.check(/* @__PURE__ */ _gte(value, params));
4076
+ },
4077
+ min(value, params) {
4078
+ return this.check(/* @__PURE__ */ _gte(value, params));
4079
+ },
4080
+ lt(value, params) {
4081
+ return this.check(/* @__PURE__ */ _lt(value, params));
4082
+ },
4083
+ lte(value, params) {
4084
+ return this.check(/* @__PURE__ */ _lte(value, params));
4085
+ },
4086
+ max(value, params) {
4087
+ return this.check(/* @__PURE__ */ _lte(value, params));
4088
+ },
4089
+ int(params) {
4090
+ return this.check(int(params));
4091
+ },
4092
+ safe(params) {
4093
+ return this.check(int(params));
4094
+ },
4095
+ positive(params) {
4096
+ return this.check(/* @__PURE__ */ _gt(0, params));
4097
+ },
4098
+ nonnegative(params) {
4099
+ return this.check(/* @__PURE__ */ _gte(0, params));
4100
+ },
4101
+ negative(params) {
4102
+ return this.check(/* @__PURE__ */ _lt(0, params));
4103
+ },
4104
+ nonpositive(params) {
4105
+ return this.check(/* @__PURE__ */ _lte(0, params));
4106
+ },
4107
+ multipleOf(value, params) {
4108
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4109
+ },
4110
+ step(value, params) {
4111
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4112
+ },
4113
+ finite() {
4114
+ return this;
4115
+ }
4116
+ });
3871
4117
  const bag = inst._zod.bag;
3872
4118
  inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3873
4119
  inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
@@ -3914,11 +4160,23 @@ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
3914
4160
  ZodType.init(inst, def);
3915
4161
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3916
4162
  inst.element = def.element;
3917
- inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
3918
- inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
3919
- inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
3920
- inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
3921
- inst.unwrap = () => inst.element;
4163
+ _installLazyMethods(inst, "ZodArray", {
4164
+ min(n, params) {
4165
+ return this.check(/* @__PURE__ */ _minLength(n, params));
4166
+ },
4167
+ nonempty(params) {
4168
+ return this.check(/* @__PURE__ */ _minLength(1, params));
4169
+ },
4170
+ max(n, params) {
4171
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
4172
+ },
4173
+ length(n, params) {
4174
+ return this.check(/* @__PURE__ */ _length(n, params));
4175
+ },
4176
+ unwrap() {
4177
+ return this.element;
4178
+ }
4179
+ });
3922
4180
  });
3923
4181
  function array(element, params) {
3924
4182
  return /* @__PURE__ */ _array(ZodArray, element, params);
@@ -3930,23 +4188,47 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
3930
4188
  defineLazy(inst, "shape", () => {
3931
4189
  return def.shape;
3932
4190
  });
3933
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
3934
- inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
3935
- inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
3936
- inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
3937
- inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
3938
- inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
3939
- inst.extend = (incoming) => {
3940
- return extend(inst, incoming);
3941
- };
3942
- inst.safeExtend = (incoming) => {
3943
- return safeExtend(inst, incoming);
3944
- };
3945
- inst.merge = (other) => merge(inst, other);
3946
- inst.pick = (mask) => pick(inst, mask);
3947
- inst.omit = (mask) => omit(inst, mask);
3948
- inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
3949
- inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4191
+ _installLazyMethods(inst, "ZodObject", {
4192
+ keyof() {
4193
+ return _enum(Object.keys(this._zod.def.shape));
4194
+ },
4195
+ catchall(catchall) {
4196
+ return this.clone({ ...this._zod.def, catchall });
4197
+ },
4198
+ passthrough() {
4199
+ return this.clone({ ...this._zod.def, catchall: unknown() });
4200
+ },
4201
+ loose() {
4202
+ return this.clone({ ...this._zod.def, catchall: unknown() });
4203
+ },
4204
+ strict() {
4205
+ return this.clone({ ...this._zod.def, catchall: never() });
4206
+ },
4207
+ strip() {
4208
+ return this.clone({ ...this._zod.def, catchall: void 0 });
4209
+ },
4210
+ extend(incoming) {
4211
+ return extend(this, incoming);
4212
+ },
4213
+ safeExtend(incoming) {
4214
+ return safeExtend(this, incoming);
4215
+ },
4216
+ merge(other) {
4217
+ return merge(this, other);
4218
+ },
4219
+ pick(mask) {
4220
+ return pick(this, mask);
4221
+ },
4222
+ omit(mask) {
4223
+ return omit(this, mask);
4224
+ },
4225
+ partial(...args) {
4226
+ return partial(ZodOptional, this, args[0]);
4227
+ },
4228
+ required(...args) {
4229
+ return required(ZodNonOptional, this, args[0]);
4230
+ }
4231
+ });
3950
4232
  });
3951
4233
  function object(shape, params) {
3952
4234
  const def = {
@@ -3989,6 +4271,14 @@ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
3989
4271
  inst.valueType = def.valueType;
3990
4272
  });
3991
4273
  function record(keyType, valueType, params) {
4274
+ if (!valueType || !valueType._zod) {
4275
+ return new ZodRecord({
4276
+ type: "record",
4277
+ keyType: string(),
4278
+ valueType: keyType,
4279
+ ...normalizeParams(valueType)
4280
+ });
4281
+ }
3992
4282
  return new ZodRecord({
3993
4283
  type: "record",
3994
4284
  keyType,
@@ -4067,10 +4357,12 @@ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) =>
4067
4357
  if (output instanceof Promise) {
4068
4358
  return output.then((output2) => {
4069
4359
  payload.value = output2;
4360
+ payload.fallback = true;
4070
4361
  return payload;
4071
4362
  });
4072
4363
  }
4073
4364
  payload.value = output;
4365
+ payload.fallback = true;
4074
4366
  return payload;
4075
4367
  };
4076
4368
  });
@@ -4209,8 +4501,8 @@ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4209
4501
  function refine(fn, _params = {}) {
4210
4502
  return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4211
4503
  }
4212
- function superRefine(fn) {
4213
- return /* @__PURE__ */ _superRefine(fn);
4504
+ function superRefine(fn, params) {
4505
+ return /* @__PURE__ */ _superRefine(fn, params);
4214
4506
  }
4215
4507
  export {
4216
4508
  _enum as _,
@@ -4222,4 +4514,4 @@ export {
4222
4514
  string as s,
4223
4515
  unknown as u
4224
4516
  };
4225
- //# sourceMappingURL=schemas-Cjdjgehl.js.map
4517
+ //# sourceMappingURL=schemas-Drf83ni9.js.map