agent-relay 6.0.2 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +10 -3
  2. package/dist/index.cjs +2024 -962
  3. package/dist/src/cli/commands/cloud.d.ts.map +1 -1
  4. package/dist/src/cli/commands/cloud.js +17 -144
  5. package/dist/src/cli/commands/cloud.js.map +1 -1
  6. package/dist/src/cli/commands/setup.d.ts +2 -39
  7. package/dist/src/cli/commands/setup.d.ts.map +1 -1
  8. package/dist/src/cli/commands/setup.js +4 -333
  9. package/dist/src/cli/commands/setup.js.map +1 -1
  10. package/dist/src/cli/lib/auth-ssh.d.ts +2 -33
  11. package/dist/src/cli/lib/auth-ssh.d.ts.map +1 -1
  12. package/dist/src/cli/lib/auth-ssh.js +3 -39
  13. package/dist/src/cli/lib/auth-ssh.js.map +1 -1
  14. package/dist/src/cli/lib/ssh-interactive.d.ts +4 -66
  15. package/dist/src/cli/lib/ssh-interactive.d.ts.map +1 -1
  16. package/dist/src/cli/lib/ssh-interactive.js +4 -436
  17. package/dist/src/cli/lib/ssh-interactive.js.map +1 -1
  18. package/node_modules/@relaycast/sdk/node_modules/zod/README.md +1 -1
  19. package/node_modules/@relaycast/sdk/node_modules/zod/locales/package.json +2 -1
  20. package/node_modules/@relaycast/sdk/node_modules/zod/mini/package.json +2 -1
  21. package/node_modules/@relaycast/sdk/node_modules/zod/package.json +1 -1
  22. package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
  23. package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/object.test.ts +5 -5
  24. package/node_modules/@relaycast/sdk/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
  25. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/errors.ts +2 -2
  26. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/external.ts +1 -0
  27. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
  28. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/parse.ts +6 -6
  29. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/schemas.ts +389 -148
  30. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/catch.test.ts +4 -2
  31. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
  32. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
  33. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
  34. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
  35. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
  36. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +31 -1
  37. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
  38. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
  39. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
  40. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
  41. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
  42. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
  43. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
  44. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
  45. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
  46. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
  47. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
  48. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/partial.test.ts +28 -2
  49. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
  50. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
  51. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
  52. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
  53. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
  54. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
  55. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +128 -14
  56. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
  57. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
  58. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
  59. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/api.ts +25 -2
  60. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/checks.ts +1 -1
  61. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/core.ts +17 -2
  62. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/errors.ts +31 -24
  63. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/json-schema-processors.ts +15 -17
  64. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/parse.ts +7 -7
  65. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/regexes.ts +8 -1
  66. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/schemas.ts +218 -66
  67. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
  68. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
  69. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
  70. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
  71. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
  72. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/to-json-schema.ts +9 -1
  73. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/util.ts +52 -35
  74. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/core/versions.ts +2 -2
  75. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/el.ts +121 -0
  76. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/en.ts +4 -0
  77. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/fr.ts +24 -8
  78. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/hr.ts +131 -0
  79. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/index.ts +3 -0
  80. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/it.ts +1 -1
  81. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ka.ts +8 -8
  82. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/ro.ts +129 -0
  83. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/locales/uz.ts +1 -0
  84. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/external.ts +1 -0
  85. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/schemas.ts +55 -24
  86. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
  87. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/index.test.ts +27 -2
  88. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
  89. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
  90. package/node_modules/@relaycast/sdk/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
  91. package/node_modules/@relaycast/sdk/node_modules/zod/v3/package.json +2 -1
  92. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/errors.js +2 -2
  93. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.cts +1 -0
  94. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/external.d.ts +1 -0
  95. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
  96. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/from-json-schema.js +31 -16
  97. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/package.json +2 -1
  98. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.cjs +346 -117
  99. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.cts +34 -12
  100. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.d.ts +34 -12
  101. package/node_modules/@relaycast/sdk/node_modules/zod/v4/classic/schemas.js +345 -117
  102. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.cjs +7 -2
  103. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.cts +20 -1
  104. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.d.ts +20 -1
  105. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/api.js +7 -2
  106. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.cts +1 -1
  107. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/checks.d.ts +1 -1
  108. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.cjs +3 -1
  109. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/core.js +4 -2
  110. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.cjs +26 -23
  111. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.cts +1 -0
  112. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.d.ts +1 -0
  113. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/errors.js +26 -23
  114. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.cjs +14 -19
  115. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/json-schema-processors.js +14 -19
  116. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/package.json +2 -1
  117. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.cjs +7 -7
  118. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/parse.js +7 -7
  119. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.cjs +9 -3
  120. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.cts +6 -0
  121. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.d.ts +6 -0
  122. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/regexes.js +7 -1
  123. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.cjs +196 -59
  124. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.cts +21 -1
  125. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.d.ts +21 -1
  126. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/schemas.js +196 -59
  127. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.cjs +10 -1
  128. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/to-json-schema.js +10 -1
  129. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.cjs +54 -30
  130. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.cts +1 -0
  131. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.d.ts +1 -0
  132. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/util.js +55 -32
  133. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.cjs +2 -2
  134. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.cts +1 -1
  135. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.d.ts +1 -1
  136. package/node_modules/@relaycast/sdk/node_modules/zod/v4/core/versions.js +2 -2
  137. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.cjs +136 -0
  138. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.cts +5 -0
  139. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.d.ts +4 -0
  140. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/el.js +109 -0
  141. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.cjs +4 -0
  142. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/en.js +4 -0
  143. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.cjs +24 -7
  144. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/fr.js +24 -7
  145. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.cjs +149 -0
  146. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.cts +5 -0
  147. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.d.ts +4 -0
  148. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/hr.js +122 -0
  149. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.cjs +8 -1
  150. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.cts +3 -0
  151. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.d.ts +3 -0
  152. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/index.js +3 -0
  153. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.cjs +1 -1
  154. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/it.js +1 -1
  155. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.cjs +8 -8
  156. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ka.js +8 -8
  157. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/package.json +2 -1
  158. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.cjs +146 -0
  159. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.cts +5 -0
  160. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.d.ts +4 -0
  161. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/ro.js +119 -0
  162. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.cjs +1 -0
  163. package/node_modules/@relaycast/sdk/node_modules/zod/v4/locales/uz.js +1 -0
  164. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.cts +1 -0
  165. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/external.d.ts +1 -0
  166. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/package.json +2 -1
  167. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.cjs +41 -4
  168. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.cts +27 -9
  169. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.d.ts +27 -9
  170. package/node_modules/@relaycast/sdk/node_modules/zod/v4/mini/schemas.js +40 -4
  171. package/node_modules/@relaycast/sdk/node_modules/zod/v4/package.json +2 -1
  172. package/node_modules/@relaycast/sdk/node_modules/zod/v4-mini/package.json +2 -1
  173. package/package.json +10 -10
@@ -246,8 +246,23 @@ export function _nanoid<T extends schemas.$ZodNanoID>(
246
246
  }
247
247
 
248
248
  // CUID
249
+ /**
250
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
251
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
252
+ * See https://github.com/paralleldrive/cuid.
253
+ */
249
254
  export type $ZodCUIDParams = StringFormatParams<schemas.$ZodCUID, "when">;
255
+ /**
256
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
257
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
258
+ * See https://github.com/paralleldrive/cuid.
259
+ */
250
260
  export type $ZodCheckCUIDParams = CheckStringFormatParams<schemas.$ZodCUID, "when">;
261
+ /**
262
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
263
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
264
+ * See https://github.com/paralleldrive/cuid.
265
+ */
251
266
  // @__NO_SIDE_EFFECTS__
252
267
  export function _cuid<T extends schemas.$ZodCUID>(
253
268
  Class: util.SchemaClass<T>,
@@ -1633,8 +1648,16 @@ export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
1633
1648
  addIssue(arg: string | $ZodSuperRefineIssue): void;
1634
1649
  }
1635
1650
 
1651
+ export interface $ZodSuperRefineParams {
1652
+ /** If provided, the refinement runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
1653
+ when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
1654
+ }
1655
+
1636
1656
  // @__NO_SIDE_EFFECTS__
1637
- export function _superRefine<T>(fn: (arg: T, payload: $RefinementCtx<T>) => void | Promise<void>): checks.$ZodCheck<T> {
1657
+ export function _superRefine<T>(
1658
+ fn: (arg: T, payload: $RefinementCtx<T>) => void | Promise<void>,
1659
+ params?: $ZodSuperRefineParams
1660
+ ): checks.$ZodCheck<T> {
1638
1661
  const ch = _check<T>((payload) => {
1639
1662
  (payload as $RefinementCtx).addIssue = (issue) => {
1640
1663
  if (typeof issue === "string") {
@@ -1652,7 +1675,7 @@ export function _superRefine<T>(fn: (arg: T, payload: $RefinementCtx<T>) => void
1652
1675
  };
1653
1676
 
1654
1677
  return fn(payload.value, payload as $RefinementCtx<T>);
1655
- });
1678
+ }, params);
1656
1679
  return ch;
1657
1680
  }
1658
1681
 
@@ -13,7 +13,7 @@ export interface $ZodCheckDef {
13
13
  error?: errors.$ZodErrorMap<never> | undefined;
14
14
  /** If true, no later checks will be executed if this check fails. Default `false`. */
15
15
  abort?: boolean | undefined;
16
- /** If provided, this check will only be executed if the function returns `true`. Defaults to `payload => z.util.isAborted(payload)`. */
16
+ /** If provided, the check runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
17
17
  when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
18
18
  }
19
19
 
@@ -10,7 +10,7 @@ export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
10
10
  }
11
11
 
12
12
  /** A special constant with type `never` */
13
- export const NEVER: never = Object.freeze({
13
+ export const NEVER: never = /*@__PURE__*/ Object.freeze({
14
14
  status: "aborted",
15
15
  }) as never;
16
16
 
@@ -130,7 +130,22 @@ export interface $ZodConfig {
130
130
  jitless?: boolean | undefined;
131
131
  }
132
132
 
133
- export const globalConfig: $ZodConfig = {};
133
+ interface GlobalThisWithConfig {
134
+ /**
135
+ * The globalConfig instance shared across both CommonJS and ESM builds.
136
+ * Attached to `globalThis` (mirroring `__zod_globalRegistry`) so that a
137
+ * single config object is used regardless of how Zod is loaded — CJS,
138
+ * ESM, multiple bundles in a monorepo, etc. This means `z.config(...)`
139
+ * applied against any one instance is observed by all of them, and
140
+ * pre-populating it before Zod loads (e.g. `globalThis.__zod_globalConfig
141
+ * = { jitless: true }` in an inline script) takes effect immediately on
142
+ * import.
143
+ */
144
+ __zod_globalConfig?: $ZodConfig;
145
+ }
146
+
147
+ (globalThis as GlobalThisWithConfig).__zod_globalConfig ??= {};
148
+ export const globalConfig: $ZodConfig = (globalThis as GlobalThisWithConfig).__zod_globalConfig!;
134
149
 
135
150
  export function config(newConfig?: Partial<$ZodConfig>): $ZodConfig {
136
151
  if (newConfig) Object.assign(globalConfig, newConfig);
@@ -91,6 +91,7 @@ interface $ZodIssueInvalidUnionNoMatch extends $ZodIssueBase {
91
91
  readonly errors: $ZodIssue[][];
92
92
  readonly input?: unknown;
93
93
  readonly discriminator?: string | undefined;
94
+ readonly options?: util.Primitive[];
94
95
  readonly inclusive?: true;
95
96
  }
96
97
 
@@ -291,32 +292,35 @@ export function formatError<T>(error: $ZodError<T>): $ZodFormattedError<T>;
291
292
  export function formatError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;
292
293
  export function formatError<T, U>(error: $ZodError<T>, mapper = (issue: $ZodIssue) => issue.message as U) {
293
294
  const fieldErrors: $ZodFormattedError<T> = { _errors: [] } as any;
294
- const processError = (error: { issues: $ZodIssue[] }) => {
295
+ const processError = (error: { issues: $ZodIssue[] }, path: PropertyKey[] = []) => {
295
296
  for (const issue of error.issues) {
296
297
  if (issue.code === "invalid_union" && issue.errors.length) {
297
- issue.errors.map((issues) => processError({ issues }));
298
+ issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
298
299
  } else if (issue.code === "invalid_key") {
299
- processError({ issues: issue.issues });
300
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
300
301
  } else if (issue.code === "invalid_element") {
301
- processError({ issues: issue.issues });
302
- } else if (issue.path.length === 0) {
303
- (fieldErrors as any)._errors.push(mapper(issue));
302
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
304
303
  } else {
305
- let curr: any = fieldErrors;
306
- let i = 0;
307
- while (i < issue.path.length) {
308
- const el = issue.path[i]!;
309
- const terminal = i === issue.path.length - 1;
310
-
311
- if (!terminal) {
312
- curr[el] = curr[el] || { _errors: [] };
313
- } else {
314
- curr[el] = curr[el] || { _errors: [] };
315
- curr[el]._errors.push(mapper(issue));
304
+ const fullpath = [...path, ...issue.path];
305
+ if (fullpath.length === 0) {
306
+ (fieldErrors as any)._errors.push(mapper(issue));
307
+ } else {
308
+ let curr: any = fieldErrors;
309
+ let i = 0;
310
+ while (i < fullpath.length) {
311
+ const el = fullpath[i]!;
312
+ const terminal = i === fullpath.length - 1;
313
+
314
+ if (!terminal) {
315
+ curr[el] = curr[el] || { _errors: [] };
316
+ } else {
317
+ curr[el] = curr[el] || { _errors: [] };
318
+ curr[el]._errors.push(mapper(issue));
319
+ }
320
+
321
+ curr = curr[el];
322
+ i++;
316
323
  }
317
-
318
- curr = curr[el];
319
- i++;
320
324
  }
321
325
  }
322
326
  }
@@ -332,7 +336,10 @@ export type $ZodErrorTree<T, U = string> = T extends util.Primitive
332
336
  : T extends any[]
333
337
  ? { errors: U[]; items?: Array<$ZodErrorTree<T[number], U>> }
334
338
  : T extends object
335
- ? { errors: U[]; properties?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }
339
+ ? {
340
+ errors: U[];
341
+ properties?: { [K in keyof T]?: $ZodErrorTree<T[K], U> };
342
+ }
336
343
  : { errors: U[] };
337
344
 
338
345
  export function treeifyError<T>(error: $ZodError<T>): $ZodErrorTree<T>;
@@ -343,11 +350,11 @@ export function treeifyError<T, U>(error: $ZodError<T>, mapper = (issue: $ZodIss
343
350
  for (const issue of error.issues) {
344
351
  if (issue.code === "invalid_union" && issue.errors.length) {
345
352
  // regular union error
346
- issue.errors.map((issues) => processError({ issues }, issue.path));
353
+ issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
347
354
  } else if (issue.code === "invalid_key") {
348
- processError({ issues: issue.issues }, issue.path);
355
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
349
356
  } else if (issue.code === "invalid_element") {
350
- processError({ issues: issue.issues }, issue.path);
357
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
351
358
  } else {
352
359
  const fullpath = [...path, ...issue.path];
353
360
  if (fullpath.length === 0) {
@@ -65,36 +65,31 @@ export const numberProcessor: Processor<schemas.$ZodNumber> = (schema, ctx, _jso
65
65
  if (typeof format === "string" && format.includes("int")) json.type = "integer";
66
66
  else json.type = "number";
67
67
 
68
- if (typeof exclusiveMinimum === "number") {
69
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
68
+ // when both minimum and exclusiveMinimum exist, pick the more restrictive one
69
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
70
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
71
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
72
+
73
+ if (exMin) {
74
+ if (legacy) {
70
75
  json.minimum = exclusiveMinimum;
71
76
  json.exclusiveMinimum = true;
72
77
  } else {
73
78
  json.exclusiveMinimum = exclusiveMinimum;
74
79
  }
75
- }
76
- if (typeof minimum === "number") {
80
+ } else if (typeof minimum === "number") {
77
81
  json.minimum = minimum;
78
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
79
- if (exclusiveMinimum >= minimum) delete json.minimum;
80
- else delete json.exclusiveMinimum;
81
- }
82
82
  }
83
83
 
84
- if (typeof exclusiveMaximum === "number") {
85
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
84
+ if (exMax) {
85
+ if (legacy) {
86
86
  json.maximum = exclusiveMaximum;
87
87
  json.exclusiveMaximum = true;
88
88
  } else {
89
89
  json.exclusiveMaximum = exclusiveMaximum;
90
90
  }
91
- }
92
- if (typeof maximum === "number") {
91
+ } else if (typeof maximum === "number") {
93
92
  json.maximum = maximum;
94
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
95
- if (exclusiveMaximum <= maximum) delete json.maximum;
96
- else delete json.exclusiveMaximum;
97
- }
98
93
  }
99
94
 
100
95
  if (typeof multipleOf === "number") json.multipleOf = multipleOf;
@@ -286,7 +281,10 @@ export const arrayProcessor: Processor<schemas.$ZodArray> = (schema, ctx, _json,
286
281
  if (typeof maximum === "number") json.maxItems = maximum;
287
282
 
288
283
  json.type = "array";
289
- json.items = process(def.element, ctx as any, { ...params, path: [...params.path, "items"] });
284
+ json.items = process(def.element, ctx as any, {
285
+ ...params,
286
+ path: [...params.path, "items"],
287
+ });
290
288
  };
291
289
 
292
290
  export const objectProcessor: Processor<schemas.$ZodObject> = (schema, ctx, _json, params) => {
@@ -14,7 +14,7 @@ export type $Parse = <T extends schemas.$ZodType>(
14
14
  ) => core.output<T>;
15
15
 
16
16
  export const _parse: (_Err: $ZodErrorClass) => $Parse = (_Err) => (schema, value, _ctx, _params) => {
17
- const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
17
+ const ctx: schemas.ParseContextInternal = _ctx ? { ..._ctx, async: false } : { async: false };
18
18
  const result = schema._zod.run({ value, issues: [] }, ctx);
19
19
  if (result instanceof Promise) {
20
20
  throw new core.$ZodAsyncError();
@@ -37,7 +37,7 @@ export type $ParseAsync = <T extends schemas.$ZodType>(
37
37
  ) => Promise<core.output<T>>;
38
38
 
39
39
  export const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync = (_Err) => async (schema, value, _ctx, params) => {
40
- const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
40
+ const ctx: schemas.ParseContextInternal = _ctx ? { ..._ctx, async: true } : { async: true };
41
41
  let result = schema._zod.run({ value, issues: [] }, ctx);
42
42
  if (result instanceof Promise) result = await result;
43
43
  if (result.issues.length) {
@@ -79,7 +79,7 @@ export type $SafeParseAsync = <T extends schemas.$ZodType>(
79
79
  ) => Promise<util.SafeParseResult<core.output<T>>>;
80
80
 
81
81
  export const _safeParseAsync: (_Err: $ZodErrorClass) => $SafeParseAsync = (_Err) => async (schema, value, _ctx) => {
82
- const ctx: schemas.ParseContextInternal = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
82
+ const ctx: schemas.ParseContextInternal = _ctx ? { ..._ctx, async: true } : { async: true };
83
83
  let result = schema._zod.run({ value, issues: [] }, ctx);
84
84
  if (result instanceof Promise) result = await result;
85
85
 
@@ -101,7 +101,7 @@ export type $Encode = <T extends schemas.$ZodType>(
101
101
  ) => core.input<T>;
102
102
 
103
103
  export const _encode: (_Err: $ZodErrorClass) => $Encode = (_Err) => (schema, value, _ctx) => {
104
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" as const }) : { direction: "backward" as const };
104
+ const ctx = _ctx ? { ..._ctx, direction: "backward" as const } : { direction: "backward" as const };
105
105
  return _parse(_Err)(schema, value, ctx as any) as any;
106
106
  };
107
107
 
@@ -126,7 +126,7 @@ export type $EncodeAsync = <T extends schemas.$ZodType>(
126
126
  ) => Promise<core.input<T>>;
127
127
 
128
128
  export const _encodeAsync: (_Err: $ZodErrorClass) => $EncodeAsync = (_Err) => async (schema, value, _ctx) => {
129
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" as const }) : { direction: "backward" as const };
129
+ const ctx = _ctx ? { ..._ctx, direction: "backward" as const } : { direction: "backward" as const };
130
130
  return _parseAsync(_Err)(schema, value, ctx as any) as any;
131
131
  };
132
132
 
@@ -151,7 +151,7 @@ export type $SafeEncode = <T extends schemas.$ZodType>(
151
151
  ) => util.SafeParseResult<core.input<T>>;
152
152
 
153
153
  export const _safeEncode: (_Err: $ZodErrorClass) => $SafeEncode = (_Err) => (schema, value, _ctx) => {
154
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" as const }) : { direction: "backward" as const };
154
+ const ctx = _ctx ? { ..._ctx, direction: "backward" as const } : { direction: "backward" as const };
155
155
  return _safeParse(_Err)(schema, value, ctx as any) as any;
156
156
  };
157
157
 
@@ -176,7 +176,7 @@ export type $SafeEncodeAsync = <T extends schemas.$ZodType>(
176
176
  ) => Promise<util.SafeParseResult<core.input<T>>>;
177
177
 
178
178
  export const _safeEncodeAsync: (_Err: $ZodErrorClass) => $SafeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
179
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" as const }) : { direction: "backward" as const };
179
+ const ctx = _ctx ? { ..._ctx, direction: "backward" as const } : { direction: "backward" as const };
180
180
  return _safeParseAsync(_Err)(schema, value, ctx as any) as any;
181
181
  };
182
182
 
@@ -1,6 +1,11 @@
1
1
  import * as util from "./util.js";
2
2
 
3
- export const cuid: RegExp = /^[cC][^\s-]{8,}$/;
3
+ /**
4
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
5
+ * (timestamps embedded in the id). Use {@link cuid2} instead.
6
+ * See https://github.com/paralleldrive/cuid.
7
+ */
8
+ export const cuid: RegExp = /^[cC][0-9a-z]{6,}$/;
4
9
  export const cuid2: RegExp = /^[0-9a-z]+$/;
5
10
  export const ulid: RegExp = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
6
11
  export const xid: RegExp = /^[0-9a-vA-V]{20}$/;
@@ -81,6 +86,8 @@ export const hostname: RegExp =
81
86
 
82
87
  export const domain: RegExp = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
83
88
 
89
+ export const httpProtocol: RegExp = /^https?$/;
90
+
84
91
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
85
92
  // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
86
93
  export const e164: RegExp = /^\+[1-9]\d{6,14}$/;