@xenosystem/agent-cli 0.5.189 → 0.5.190

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 (865) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +2530 -2530
  3. package/dist/metafile-esm.json +1 -1
  4. package/dist/sdk-build-identity.json +12 -12
  5. package/native/xeno-pty/prebuilds/win32-x64/manifest.json +18 -18
  6. package/package.json +94 -94
  7. package/node_modules/@xeno-corporation/account/LICENSE +0 -39
  8. package/node_modules/@xeno-corporation/account/README.md +0 -266
  9. package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs +0 -60
  10. package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs.map +0 -1
  11. package/node_modules/@xeno-corporation/account/dist/client-D7OSWGkE.d.mts +0 -2337
  12. package/node_modules/@xeno-corporation/account/dist/client-D7OSWGkE.d.ts +0 -2337
  13. package/node_modules/@xeno-corporation/account/dist/index.d.mts +0 -110
  14. package/node_modules/@xeno-corporation/account/dist/index.d.ts +0 -110
  15. package/node_modules/@xeno-corporation/account/dist/index.js +0 -4116
  16. package/node_modules/@xeno-corporation/account/dist/index.js.map +0 -1
  17. package/node_modules/@xeno-corporation/account/dist/index.mjs +0 -3968
  18. package/node_modules/@xeno-corporation/account/dist/index.mjs.map +0 -1
  19. package/node_modules/@xeno-corporation/account/dist/node.d.mts +0 -109
  20. package/node_modules/@xeno-corporation/account/dist/node.d.ts +0 -109
  21. package/node_modules/@xeno-corporation/account/dist/node.js +0 -1453
  22. package/node_modules/@xeno-corporation/account/dist/node.js.map +0 -1
  23. package/node_modules/@xeno-corporation/account/dist/node.mjs +0 -1379
  24. package/node_modules/@xeno-corporation/account/dist/node.mjs.map +0 -1
  25. package/node_modules/@xeno-corporation/account/package.json +0 -62
  26. package/node_modules/zod/LICENSE +0 -21
  27. package/node_modules/zod/README.md +0 -218
  28. package/node_modules/zod/compile.cjs +0 -96
  29. package/node_modules/zod/compile.d.cts +0 -1
  30. package/node_modules/zod/compile.d.ts +0 -1
  31. package/node_modules/zod/compile.js +0 -52
  32. package/node_modules/zod/index.cjs +0 -52
  33. package/node_modules/zod/index.d.cts +0 -3
  34. package/node_modules/zod/index.d.ts +0 -3
  35. package/node_modules/zod/index.js +0 -7
  36. package/node_modules/zod/locales/index.cjs +0 -36
  37. package/node_modules/zod/locales/index.d.cts +0 -1
  38. package/node_modules/zod/locales/index.d.ts +0 -1
  39. package/node_modules/zod/locales/index.js +0 -1
  40. package/node_modules/zod/locales/package.json +0 -7
  41. package/node_modules/zod/mini/index.cjs +0 -51
  42. package/node_modules/zod/mini/index.d.cts +0 -3
  43. package/node_modules/zod/mini/index.d.ts +0 -3
  44. package/node_modules/zod/mini/index.js +0 -3
  45. package/node_modules/zod/mini/package.json +0 -7
  46. package/node_modules/zod/package.json +0 -147
  47. package/node_modules/zod/src/compile.ts +0 -56
  48. package/node_modules/zod/src/index.ts +0 -7
  49. package/node_modules/zod/src/locales/index.ts +0 -1
  50. package/node_modules/zod/src/mini/index.ts +0 -3
  51. package/node_modules/zod/src/v3/ZodError.ts +0 -340
  52. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  53. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  54. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  55. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  56. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  57. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  58. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  59. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  60. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  61. package/node_modules/zod/src/v3/errors.ts +0 -13
  62. package/node_modules/zod/src/v3/external.ts +0 -6
  63. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  64. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  65. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  66. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  67. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  68. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  69. package/node_modules/zod/src/v3/index.ts +0 -4
  70. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  71. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  72. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  73. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  74. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  75. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  76. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  77. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  78. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  79. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  80. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  81. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  82. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  83. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  84. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  85. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  86. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  87. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  88. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  89. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  90. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  91. package/node_modules/zod/src/v3/tests/error.test.ts +0 -586
  92. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  93. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  94. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  95. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  96. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  97. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -128
  98. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  99. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -206
  100. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  101. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  102. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  103. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  104. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  105. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  106. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  107. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  108. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  109. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  110. package/node_modules/zod/src/v3/tests/object.test.ts +0 -431
  111. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  112. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  113. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  114. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  115. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  116. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  117. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  118. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  119. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  120. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -114
  121. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  122. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  123. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  124. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  125. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  126. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  127. package/node_modules/zod/src/v3/tests/string.test.ts +0 -922
  128. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  129. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  130. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  131. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  132. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  133. package/node_modules/zod/src/v3/types.ts +0 -5138
  134. package/node_modules/zod/src/v4/classic/checks.ts +0 -33
  135. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  136. package/node_modules/zod/src/v4/classic/compat.ts +0 -78
  137. package/node_modules/zod/src/v4/classic/deep-partial.ts +0 -76
  138. package/node_modules/zod/src/v4/classic/errors.ts +0 -97
  139. package/node_modules/zod/src/v4/classic/external.ts +0 -57
  140. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -944
  141. package/node_modules/zod/src/v4/classic/in-out.ts +0 -45
  142. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  143. package/node_modules/zod/src/v4/classic/iso.ts +0 -20
  144. package/node_modules/zod/src/v4/classic/parse.ts +0 -88
  145. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2937
  146. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  147. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -86
  148. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -291
  149. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -402
  150. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  151. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  152. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  153. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -89
  154. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  155. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -604
  156. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  157. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -572
  158. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -704
  159. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  160. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  161. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +0 -76
  162. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  163. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +0 -985
  164. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -92
  165. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -316
  166. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +0 -380
  167. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +0 -32
  168. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -455
  169. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  170. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  171. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -221
  172. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -942
  173. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -305
  174. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -917
  175. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -1108
  176. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  177. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  178. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  179. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -1467
  180. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -391
  181. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  182. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -32
  183. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -67
  184. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +0 -81
  185. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +0 -159
  186. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -958
  187. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +0 -319
  188. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -127
  189. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -334
  190. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +0 -215
  191. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -39
  192. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  193. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -262
  194. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -128
  195. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  196. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  197. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -349
  198. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  199. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  200. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  201. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  202. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -401
  203. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -1006
  204. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +0 -235
  205. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -366
  206. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -497
  207. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  208. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  209. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -144
  210. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -44
  211. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  212. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  213. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  214. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +0 -141
  215. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  216. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -184
  217. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -885
  218. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -707
  219. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +0 -68
  220. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -693
  221. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  222. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -196
  223. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -153
  224. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  225. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1440
  226. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -124
  227. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -812
  228. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  229. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -4733
  230. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  231. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -511
  232. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -310
  233. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  234. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +0 -645
  235. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  236. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  237. package/node_modules/zod/src/v4/core/api.ts +0 -1875
  238. package/node_modules/zod/src/v4/core/checks.ts +0 -1266
  239. package/node_modules/zod/src/v4/core/compile.ts +0 -2322
  240. package/node_modules/zod/src/v4/core/core.ts +0 -230
  241. package/node_modules/zod/src/v4/core/doc.ts +0 -52
  242. package/node_modules/zod/src/v4/core/errors.ts +0 -543
  243. package/node_modules/zod/src/v4/core/index.ts +0 -19
  244. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -131
  245. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -934
  246. package/node_modules/zod/src/v4/core/json-schema.ts +0 -148
  247. package/node_modules/zod/src/v4/core/memoizer.ts +0 -331
  248. package/node_modules/zod/src/v4/core/parse.ts +0 -309
  249. package/node_modules/zod/src/v4/core/regexes.ts +0 -217
  250. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  251. package/node_modules/zod/src/v4/core/schemas.ts +0 -5226
  252. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  253. package/node_modules/zod/src/v4/core/tests/cached.test.ts +0 -54
  254. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +0 -1004
  255. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +0 -445
  256. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +0 -89
  257. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +0 -26
  258. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +0 -34
  259. package/node_modules/zod/src/v4/core/tests/compile.test.ts +0 -2036
  260. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +0 -140
  261. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  262. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  263. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  264. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -214
  265. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  266. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -180
  267. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  268. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  269. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  270. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  271. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +0 -42
  272. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  273. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +0 -85
  274. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +0 -69
  275. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  276. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  277. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +0 -46
  278. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  279. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  280. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +0 -51
  281. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +0 -133
  282. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -857
  283. package/node_modules/zod/src/v4/core/util.ts +0 -1293
  284. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  285. package/node_modules/zod/src/v4/core/visit.ts +0 -193
  286. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  287. package/node_modules/zod/src/v4/index.ts +0 -4
  288. package/node_modules/zod/src/v4/locales/ar.ts +0 -120
  289. package/node_modules/zod/src/v4/locales/az.ts +0 -116
  290. package/node_modules/zod/src/v4/locales/be.ts +0 -188
  291. package/node_modules/zod/src/v4/locales/bg.ts +0 -133
  292. package/node_modules/zod/src/v4/locales/bn.ts +0 -123
  293. package/node_modules/zod/src/v4/locales/ca.ts +0 -121
  294. package/node_modules/zod/src/v4/locales/ckb.ts +0 -140
  295. package/node_modules/zod/src/v4/locales/cs.ts +0 -123
  296. package/node_modules/zod/src/v4/locales/da.ts +0 -128
  297. package/node_modules/zod/src/v4/locales/de.ts +0 -121
  298. package/node_modules/zod/src/v4/locales/el.ts +0 -124
  299. package/node_modules/zod/src/v4/locales/en.ts +0 -136
  300. package/node_modules/zod/src/v4/locales/eo.ts +0 -123
  301. package/node_modules/zod/src/v4/locales/es.ts +0 -145
  302. package/node_modules/zod/src/v4/locales/fa.ts +0 -131
  303. package/node_modules/zod/src/v4/locales/fi.ts +0 -126
  304. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -121
  305. package/node_modules/zod/src/v4/locales/fr.ts +0 -139
  306. package/node_modules/zod/src/v4/locales/gu.ts +0 -123
  307. package/node_modules/zod/src/v4/locales/he.ts +0 -253
  308. package/node_modules/zod/src/v4/locales/hi.ts +0 -126
  309. package/node_modules/zod/src/v4/locales/hr.ts +0 -135
  310. package/node_modules/zod/src/v4/locales/hu.ts +0 -122
  311. package/node_modules/zod/src/v4/locales/hy.ts +0 -175
  312. package/node_modules/zod/src/v4/locales/id.ts +0 -120
  313. package/node_modules/zod/src/v4/locales/index.ts +0 -63
  314. package/node_modules/zod/src/v4/locales/is.ts +0 -124
  315. package/node_modules/zod/src/v4/locales/it.ts +0 -121
  316. package/node_modules/zod/src/v4/locales/ja.ts +0 -119
  317. package/node_modules/zod/src/v4/locales/ka.ts +0 -128
  318. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  319. package/node_modules/zod/src/v4/locales/km.ts +0 -124
  320. package/node_modules/zod/src/v4/locales/kn.ts +0 -126
  321. package/node_modules/zod/src/v4/locales/ko.ts +0 -126
  322. package/node_modules/zod/src/v4/locales/lt.ts +0 -243
  323. package/node_modules/zod/src/v4/locales/mk.ts +0 -123
  324. package/node_modules/zod/src/v4/locales/ms.ts +0 -120
  325. package/node_modules/zod/src/v4/locales/ne.ts +0 -128
  326. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  327. package/node_modules/zod/src/v4/locales/nn.ts +0 -121
  328. package/node_modules/zod/src/v4/locales/no.ts +0 -121
  329. package/node_modules/zod/src/v4/locales/ota.ts +0 -122
  330. package/node_modules/zod/src/v4/locales/pl.ts +0 -123
  331. package/node_modules/zod/src/v4/locales/ps.ts +0 -131
  332. package/node_modules/zod/src/v4/locales/pt-BR.ts +0 -161
  333. package/node_modules/zod/src/v4/locales/pt.ts +0 -159
  334. package/node_modules/zod/src/v4/locales/ro.ts +0 -132
  335. package/node_modules/zod/src/v4/locales/ru.ts +0 -188
  336. package/node_modules/zod/src/v4/locales/sk.ts +0 -123
  337. package/node_modules/zod/src/v4/locales/sl.ts +0 -123
  338. package/node_modules/zod/src/v4/locales/sv.ts +0 -124
  339. package/node_modules/zod/src/v4/locales/ta.ts +0 -123
  340. package/node_modules/zod/src/v4/locales/tg.ts +0 -135
  341. package/node_modules/zod/src/v4/locales/th.ts +0 -124
  342. package/node_modules/zod/src/v4/locales/tk.ts +0 -113
  343. package/node_modules/zod/src/v4/locales/tr.ts +0 -116
  344. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  345. package/node_modules/zod/src/v4/locales/uk.ts +0 -122
  346. package/node_modules/zod/src/v4/locales/ur.ts +0 -124
  347. package/node_modules/zod/src/v4/locales/uz.ts +0 -120
  348. package/node_modules/zod/src/v4/locales/vi.ts +0 -122
  349. package/node_modules/zod/src/v4/locales/yo.ts +0 -129
  350. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -121
  351. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -120
  352. package/node_modules/zod/src/v4/mini/checks.ts +0 -33
  353. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  354. package/node_modules/zod/src/v4/mini/deep-partial.ts +0 -73
  355. package/node_modules/zod/src/v4/mini/external.ts +0 -52
  356. package/node_modules/zod/src/v4/mini/in-out.ts +0 -45
  357. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  358. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  359. package/node_modules/zod/src/v4/mini/parse.ts +0 -16
  360. package/node_modules/zod/src/v4/mini/schemas.ts +0 -2051
  361. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -57
  362. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -190
  363. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  364. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -158
  365. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -582
  366. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -30
  367. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +0 -84
  368. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +0 -54
  369. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -41
  370. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -14
  371. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -1146
  372. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -109
  373. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -292
  374. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  375. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -341
  376. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  377. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -396
  378. package/node_modules/zod/src/v4-mini/index.ts +0 -3
  379. package/node_modules/zod/v3/ZodError.cjs +0 -167
  380. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  381. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  382. package/node_modules/zod/v3/ZodError.js +0 -143
  383. package/node_modules/zod/v3/errors.cjs +0 -36
  384. package/node_modules/zod/v3/errors.d.cts +0 -5
  385. package/node_modules/zod/v3/errors.d.ts +0 -5
  386. package/node_modules/zod/v3/errors.js +0 -9
  387. package/node_modules/zod/v3/external.cjs +0 -41
  388. package/node_modules/zod/v3/external.d.cts +0 -6
  389. package/node_modules/zod/v3/external.d.ts +0 -6
  390. package/node_modules/zod/v3/external.js +0 -6
  391. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -21
  392. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  393. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  394. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  395. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -28
  396. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  397. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  398. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  399. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -143
  400. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  401. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  402. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  403. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -21
  404. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  405. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  406. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  407. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -21
  408. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  409. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  410. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  411. package/node_modules/zod/v3/helpers/util.cjs +0 -156
  412. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  413. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  414. package/node_modules/zod/v3/helpers/util.js +0 -133
  415. package/node_modules/zod/v3/index.cjs +0 -52
  416. package/node_modules/zod/v3/index.d.cts +0 -4
  417. package/node_modules/zod/v3/index.d.ts +0 -4
  418. package/node_modules/zod/v3/index.js +0 -4
  419. package/node_modules/zod/v3/locales/en.cjs +0 -112
  420. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  421. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  422. package/node_modules/zod/v3/locales/en.js +0 -109
  423. package/node_modules/zod/v3/package.json +0 -7
  424. package/node_modules/zod/v3/standard-schema.cjs +0 -21
  425. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  426. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  427. package/node_modules/zod/v3/standard-schema.js +0 -1
  428. package/node_modules/zod/v3/types.cjs +0 -3798
  429. package/node_modules/zod/v3/types.d.cts +0 -1034
  430. package/node_modules/zod/v3/types.d.ts +0 -1034
  431. package/node_modules/zod/v3/types.js +0 -3697
  432. package/node_modules/zod/v4/classic/checks.cjs +0 -53
  433. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  434. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  435. package/node_modules/zod/v4/classic/checks.js +0 -1
  436. package/node_modules/zod/v4/classic/coerce.cjs +0 -66
  437. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  438. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  439. package/node_modules/zod/v4/classic/coerce.js +0 -17
  440. package/node_modules/zod/v4/classic/compat.cjs +0 -80
  441. package/node_modules/zod/v4/classic/compat.d.cts +0 -48
  442. package/node_modules/zod/v4/classic/compat.d.ts +0 -48
  443. package/node_modules/zod/v4/classic/compat.js +0 -31
  444. package/node_modules/zod/v4/classic/deep-partial.cjs +0 -58
  445. package/node_modules/zod/v4/classic/deep-partial.d.cts +0 -14
  446. package/node_modules/zod/v4/classic/deep-partial.d.ts +0 -14
  447. package/node_modules/zod/v4/classic/deep-partial.js +0 -13
  448. package/node_modules/zod/v4/classic/errors.cjs +0 -102
  449. package/node_modules/zod/v4/classic/errors.d.cts +0 -29
  450. package/node_modules/zod/v4/classic/errors.d.ts +0 -29
  451. package/node_modules/zod/v4/classic/errors.js +0 -57
  452. package/node_modules/zod/v4/classic/external.cjs +0 -97
  453. package/node_modules/zod/v4/classic/external.d.cts +0 -19
  454. package/node_modules/zod/v4/classic/external.d.ts +0 -19
  455. package/node_modules/zod/v4/classic/external.js +0 -17
  456. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -926
  457. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  458. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  459. package/node_modules/zod/v4/classic/from-json-schema.js +0 -881
  460. package/node_modules/zod/v4/classic/in-out.cjs +0 -82
  461. package/node_modules/zod/v4/classic/in-out.d.cts +0 -8
  462. package/node_modules/zod/v4/classic/in-out.d.ts +0 -8
  463. package/node_modules/zod/v4/classic/in-out.js +0 -36
  464. package/node_modules/zod/v4/classic/index.cjs +0 -52
  465. package/node_modules/zod/v4/classic/index.d.cts +0 -3
  466. package/node_modules/zod/v4/classic/index.d.ts +0 -3
  467. package/node_modules/zod/v4/classic/index.js +0 -4
  468. package/node_modules/zod/v4/classic/iso.cjs +0 -68
  469. package/node_modules/zod/v4/classic/iso.d.cts +0 -7
  470. package/node_modules/zod/v4/classic/iso.d.ts +0 -7
  471. package/node_modules/zod/v4/classic/iso.js +0 -15
  472. package/node_modules/zod/v4/classic/package.json +0 -7
  473. package/node_modules/zod/v4/classic/parse.cjs +0 -63
  474. package/node_modules/zod/v4/classic/parse.d.cts +0 -44
  475. package/node_modules/zod/v4/classic/parse.d.ts +0 -44
  476. package/node_modules/zod/v4/classic/parse.js +0 -16
  477. package/node_modules/zod/v4/classic/schemas.cjs +0 -1676
  478. package/node_modules/zod/v4/classic/schemas.d.cts +0 -816
  479. package/node_modules/zod/v4/classic/schemas.d.ts +0 -816
  480. package/node_modules/zod/v4/classic/schemas.js +0 -1535
  481. package/node_modules/zod/v4/core/api.cjs +0 -1269
  482. package/node_modules/zod/v4/core/api.d.cts +0 -335
  483. package/node_modules/zod/v4/core/api.d.ts +0 -335
  484. package/node_modules/zod/v4/core/api.js +0 -1107
  485. package/node_modules/zod/v4/core/checks.cjs +0 -561
  486. package/node_modules/zod/v4/core/checks.d.cts +0 -294
  487. package/node_modules/zod/v4/core/checks.d.ts +0 -294
  488. package/node_modules/zod/v4/core/checks.js +0 -516
  489. package/node_modules/zod/v4/core/compile.cjs +0 -1916
  490. package/node_modules/zod/v4/core/compile.d.cts +0 -65
  491. package/node_modules/zod/v4/core/compile.d.ts +0 -65
  492. package/node_modules/zod/v4/core/compile.js +0 -1866
  493. package/node_modules/zod/v4/core/core.cjs +0 -167
  494. package/node_modules/zod/v4/core/core.d.cts +0 -82
  495. package/node_modules/zod/v4/core/core.d.ts +0 -82
  496. package/node_modules/zod/v4/core/core.js +0 -141
  497. package/node_modules/zod/v4/core/doc.cjs +0 -61
  498. package/node_modules/zod/v4/core/doc.d.cts +0 -16
  499. package/node_modules/zod/v4/core/doc.d.ts +0 -16
  500. package/node_modules/zod/v4/core/doc.js +0 -38
  501. package/node_modules/zod/v4/core/errors.cjs +0 -317
  502. package/node_modules/zod/v4/core/errors.d.cts +0 -225
  503. package/node_modules/zod/v4/core/errors.d.ts +0 -225
  504. package/node_modules/zod/v4/core/errors.js +0 -267
  505. package/node_modules/zod/v4/core/index.cjs +0 -70
  506. package/node_modules/zod/v4/core/index.d.cts +0 -19
  507. package/node_modules/zod/v4/core/index.d.ts +0 -19
  508. package/node_modules/zod/v4/core/index.js +0 -19
  509. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -122
  510. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  511. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  512. package/node_modules/zod/v4/core/json-schema-generator.js +0 -99
  513. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -929
  514. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -65
  515. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -65
  516. package/node_modules/zod/v4/core/json-schema-processors.js +0 -843
  517. package/node_modules/zod/v4/core/json-schema.cjs +0 -21
  518. package/node_modules/zod/v4/core/json-schema.d.cts +0 -89
  519. package/node_modules/zod/v4/core/json-schema.d.ts +0 -89
  520. package/node_modules/zod/v4/core/json-schema.js +0 -1
  521. package/node_modules/zod/v4/core/memoizer.cjs +0 -360
  522. package/node_modules/zod/v4/core/memoizer.d.cts +0 -15
  523. package/node_modules/zod/v4/core/memoizer.d.ts +0 -15
  524. package/node_modules/zod/v4/core/memoizer.js +0 -311
  525. package/node_modules/zod/v4/core/package.json +0 -7
  526. package/node_modules/zod/v4/core/parse.cjs +0 -233
  527. package/node_modules/zod/v4/core/parse.d.cts +0 -52
  528. package/node_modules/zod/v4/core/parse.d.ts +0 -52
  529. package/node_modules/zod/v4/core/parse.js +0 -175
  530. package/node_modules/zod/v4/core/regexes.cjs +0 -209
  531. package/node_modules/zod/v4/core/regexes.d.cts +0 -90
  532. package/node_modules/zod/v4/core/regexes.d.ts +0 -90
  533. package/node_modules/zod/v4/core/regexes.js +0 -156
  534. package/node_modules/zod/v4/core/registries.cjs +0 -75
  535. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  536. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  537. package/node_modules/zod/v4/core/registries.js +0 -51
  538. package/node_modules/zod/v4/core/schemas.cjs +0 -2699
  539. package/node_modules/zod/v4/core/schemas.d.cts +0 -1275
  540. package/node_modules/zod/v4/core/schemas.d.ts +0 -1275
  541. package/node_modules/zod/v4/core/schemas.js +0 -2636
  542. package/node_modules/zod/v4/core/standard-schema.cjs +0 -21
  543. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  544. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  545. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  546. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -681
  547. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -154
  548. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -154
  549. package/node_modules/zod/v4/core/to-json-schema.js +0 -651
  550. package/node_modules/zod/v4/core/util.cjs +0 -964
  551. package/node_modules/zod/v4/core/util.d.cts +0 -280
  552. package/node_modules/zod/v4/core/util.d.ts +0 -280
  553. package/node_modules/zod/v4/core/util.js +0 -873
  554. package/node_modules/zod/v4/core/versions.cjs +0 -27
  555. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  556. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  557. package/node_modules/zod/v4/core/versions.js +0 -5
  558. package/node_modules/zod/v4/core/visit.cjs +0 -214
  559. package/node_modules/zod/v4/core/visit.d.cts +0 -30
  560. package/node_modules/zod/v4/core/visit.d.ts +0 -30
  561. package/node_modules/zod/v4/core/visit.js +0 -169
  562. package/node_modules/zod/v4/index.cjs +0 -51
  563. package/node_modules/zod/v4/index.d.cts +0 -3
  564. package/node_modules/zod/v4/index.d.ts +0 -3
  565. package/node_modules/zod/v4/index.js +0 -4
  566. package/node_modules/zod/v4/locales/ar.cjs +0 -138
  567. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  568. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  569. package/node_modules/zod/v4/locales/ar.js +0 -111
  570. package/node_modules/zod/v4/locales/az.cjs +0 -137
  571. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  572. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  573. package/node_modules/zod/v4/locales/az.js +0 -110
  574. package/node_modules/zod/v4/locales/be.cjs +0 -195
  575. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  576. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  577. package/node_modules/zod/v4/locales/be.js +0 -168
  578. package/node_modules/zod/v4/locales/bg.cjs +0 -152
  579. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  580. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  581. package/node_modules/zod/v4/locales/bg.js +0 -125
  582. package/node_modules/zod/v4/locales/bn.cjs +0 -140
  583. package/node_modules/zod/v4/locales/bn.d.cts +0 -5
  584. package/node_modules/zod/v4/locales/bn.d.ts +0 -4
  585. package/node_modules/zod/v4/locales/bn.js +0 -113
  586. package/node_modules/zod/v4/locales/ca.cjs +0 -139
  587. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  588. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  589. package/node_modules/zod/v4/locales/ca.js +0 -112
  590. package/node_modules/zod/v4/locales/ckb.cjs +0 -160
  591. package/node_modules/zod/v4/locales/ckb.d.cts +0 -5
  592. package/node_modules/zod/v4/locales/ckb.d.ts +0 -4
  593. package/node_modules/zod/v4/locales/ckb.js +0 -133
  594. package/node_modules/zod/v4/locales/cs.cjs +0 -143
  595. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  596. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  597. package/node_modules/zod/v4/locales/cs.js +0 -116
  598. package/node_modules/zod/v4/locales/da.cjs +0 -147
  599. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  600. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  601. package/node_modules/zod/v4/locales/da.js +0 -120
  602. package/node_modules/zod/v4/locales/de.cjs +0 -140
  603. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  604. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  605. package/node_modules/zod/v4/locales/de.js +0 -113
  606. package/node_modules/zod/v4/locales/el.cjs +0 -139
  607. package/node_modules/zod/v4/locales/el.d.cts +0 -5
  608. package/node_modules/zod/v4/locales/el.d.ts +0 -4
  609. package/node_modules/zod/v4/locales/el.js +0 -112
  610. package/node_modules/zod/v4/locales/en.cjs +0 -152
  611. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  612. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  613. package/node_modules/zod/v4/locales/en.js +0 -125
  614. package/node_modules/zod/v4/locales/eo.cjs +0 -141
  615. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  616. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  617. package/node_modules/zod/v4/locales/eo.js +0 -114
  618. package/node_modules/zod/v4/locales/es.cjs +0 -163
  619. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  620. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  621. package/node_modules/zod/v4/locales/es.js +0 -136
  622. package/node_modules/zod/v4/locales/fa.cjs +0 -146
  623. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  624. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  625. package/node_modules/zod/v4/locales/fa.js +0 -119
  626. package/node_modules/zod/v4/locales/fi.cjs +0 -144
  627. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  628. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  629. package/node_modules/zod/v4/locales/fi.js +0 -117
  630. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -139
  631. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  632. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  633. package/node_modules/zod/v4/locales/fr-CA.js +0 -112
  634. package/node_modules/zod/v4/locales/fr.cjs +0 -156
  635. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  636. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  637. package/node_modules/zod/v4/locales/fr.js +0 -129
  638. package/node_modules/zod/v4/locales/gu.cjs +0 -140
  639. package/node_modules/zod/v4/locales/gu.d.cts +0 -5
  640. package/node_modules/zod/v4/locales/gu.d.ts +0 -4
  641. package/node_modules/zod/v4/locales/gu.js +0 -113
  642. package/node_modules/zod/v4/locales/he.cjs +0 -248
  643. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  644. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  645. package/node_modules/zod/v4/locales/he.js +0 -221
  646. package/node_modules/zod/v4/locales/hi.cjs +0 -138
  647. package/node_modules/zod/v4/locales/hi.d.cts +0 -5
  648. package/node_modules/zod/v4/locales/hi.d.ts +0 -4
  649. package/node_modules/zod/v4/locales/hi.js +0 -111
  650. package/node_modules/zod/v4/locales/hr.cjs +0 -153
  651. package/node_modules/zod/v4/locales/hr.d.cts +0 -5
  652. package/node_modules/zod/v4/locales/hr.d.ts +0 -4
  653. package/node_modules/zod/v4/locales/hr.js +0 -126
  654. package/node_modules/zod/v4/locales/hu.cjs +0 -140
  655. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  656. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  657. package/node_modules/zod/v4/locales/hu.js +0 -113
  658. package/node_modules/zod/v4/locales/hy.cjs +0 -185
  659. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  660. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  661. package/node_modules/zod/v4/locales/hy.js +0 -158
  662. package/node_modules/zod/v4/locales/id.cjs +0 -138
  663. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  664. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  665. package/node_modules/zod/v4/locales/id.js +0 -111
  666. package/node_modules/zod/v4/locales/index.cjs +0 -152
  667. package/node_modules/zod/v4/locales/index.d.cts +0 -63
  668. package/node_modules/zod/v4/locales/index.d.ts +0 -63
  669. package/node_modules/zod/v4/locales/index.js +0 -63
  670. package/node_modules/zod/v4/locales/is.cjs +0 -141
  671. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  672. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  673. package/node_modules/zod/v4/locales/is.js +0 -114
  674. package/node_modules/zod/v4/locales/it.cjs +0 -140
  675. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  676. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  677. package/node_modules/zod/v4/locales/it.js +0 -113
  678. package/node_modules/zod/v4/locales/ja.cjs +0 -139
  679. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  680. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  681. package/node_modules/zod/v4/locales/ja.js +0 -112
  682. package/node_modules/zod/v4/locales/ka.cjs +0 -144
  683. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  684. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  685. package/node_modules/zod/v4/locales/ka.js +0 -117
  686. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  687. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  688. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  689. package/node_modules/zod/v4/locales/kh.js +0 -5
  690. package/node_modules/zod/v4/locales/km.cjs +0 -142
  691. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  692. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  693. package/node_modules/zod/v4/locales/km.js +0 -115
  694. package/node_modules/zod/v4/locales/kn.cjs +0 -143
  695. package/node_modules/zod/v4/locales/kn.d.cts +0 -5
  696. package/node_modules/zod/v4/locales/kn.d.ts +0 -4
  697. package/node_modules/zod/v4/locales/kn.js +0 -116
  698. package/node_modules/zod/v4/locales/ko.cjs +0 -143
  699. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  700. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  701. package/node_modules/zod/v4/locales/ko.js +0 -116
  702. package/node_modules/zod/v4/locales/lt.cjs +0 -234
  703. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  704. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  705. package/node_modules/zod/v4/locales/lt.js +0 -207
  706. package/node_modules/zod/v4/locales/mk.cjs +0 -141
  707. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  708. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  709. package/node_modules/zod/v4/locales/mk.js +0 -114
  710. package/node_modules/zod/v4/locales/ms.cjs +0 -139
  711. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  712. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  713. package/node_modules/zod/v4/locales/ms.js +0 -112
  714. package/node_modules/zod/v4/locales/ne.cjs +0 -138
  715. package/node_modules/zod/v4/locales/ne.d.cts +0 -5
  716. package/node_modules/zod/v4/locales/ne.d.ts +0 -4
  717. package/node_modules/zod/v4/locales/ne.js +0 -111
  718. package/node_modules/zod/v4/locales/nl.cjs +0 -142
  719. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  720. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  721. package/node_modules/zod/v4/locales/nl.js +0 -115
  722. package/node_modules/zod/v4/locales/nn.cjs +0 -140
  723. package/node_modules/zod/v4/locales/nn.d.cts +0 -5
  724. package/node_modules/zod/v4/locales/nn.d.ts +0 -4
  725. package/node_modules/zod/v4/locales/nn.js +0 -113
  726. package/node_modules/zod/v4/locales/no.cjs +0 -140
  727. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  728. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  729. package/node_modules/zod/v4/locales/no.js +0 -113
  730. package/node_modules/zod/v4/locales/ota.cjs +0 -141
  731. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  732. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  733. package/node_modules/zod/v4/locales/ota.js +0 -114
  734. package/node_modules/zod/v4/locales/package.json +0 -7
  735. package/node_modules/zod/v4/locales/pl.cjs +0 -141
  736. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  737. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  738. package/node_modules/zod/v4/locales/pl.js +0 -114
  739. package/node_modules/zod/v4/locales/ps.cjs +0 -146
  740. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  741. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  742. package/node_modules/zod/v4/locales/ps.js +0 -119
  743. package/node_modules/zod/v4/locales/pt-BR.cjs +0 -170
  744. package/node_modules/zod/v4/locales/pt-BR.d.cts +0 -5
  745. package/node_modules/zod/v4/locales/pt-BR.d.ts +0 -4
  746. package/node_modules/zod/v4/locales/pt-BR.js +0 -143
  747. package/node_modules/zod/v4/locales/pt.cjs +0 -169
  748. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  749. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  750. package/node_modules/zod/v4/locales/pt.js +0 -142
  751. package/node_modules/zod/v4/locales/ro.cjs +0 -149
  752. package/node_modules/zod/v4/locales/ro.d.cts +0 -5
  753. package/node_modules/zod/v4/locales/ro.d.ts +0 -4
  754. package/node_modules/zod/v4/locales/ro.js +0 -122
  755. package/node_modules/zod/v4/locales/ru.cjs +0 -195
  756. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  757. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  758. package/node_modules/zod/v4/locales/ru.js +0 -168
  759. package/node_modules/zod/v4/locales/sk.cjs +0 -143
  760. package/node_modules/zod/v4/locales/sk.d.cts +0 -5
  761. package/node_modules/zod/v4/locales/sk.d.ts +0 -4
  762. package/node_modules/zod/v4/locales/sk.js +0 -116
  763. package/node_modules/zod/v4/locales/sl.cjs +0 -141
  764. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  765. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  766. package/node_modules/zod/v4/locales/sl.js +0 -114
  767. package/node_modules/zod/v4/locales/sv.cjs +0 -142
  768. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  769. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  770. package/node_modules/zod/v4/locales/sv.js +0 -115
  771. package/node_modules/zod/v4/locales/ta.cjs +0 -142
  772. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  773. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  774. package/node_modules/zod/v4/locales/ta.js +0 -115
  775. package/node_modules/zod/v4/locales/tg.cjs +0 -144
  776. package/node_modules/zod/v4/locales/tg.d.cts +0 -5
  777. package/node_modules/zod/v4/locales/tg.d.ts +0 -4
  778. package/node_modules/zod/v4/locales/tg.js +0 -117
  779. package/node_modules/zod/v4/locales/th.cjs +0 -142
  780. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  781. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  782. package/node_modules/zod/v4/locales/th.js +0 -115
  783. package/node_modules/zod/v4/locales/tk.cjs +0 -134
  784. package/node_modules/zod/v4/locales/tk.d.cts +0 -5
  785. package/node_modules/zod/v4/locales/tk.d.ts +0 -4
  786. package/node_modules/zod/v4/locales/tk.js +0 -107
  787. package/node_modules/zod/v4/locales/tr.cjs +0 -137
  788. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  789. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  790. package/node_modules/zod/v4/locales/tr.js +0 -110
  791. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  792. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  793. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  794. package/node_modules/zod/v4/locales/ua.js +0 -5
  795. package/node_modules/zod/v4/locales/uk.cjs +0 -140
  796. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  797. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  798. package/node_modules/zod/v4/locales/uk.js +0 -113
  799. package/node_modules/zod/v4/locales/ur.cjs +0 -142
  800. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  801. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  802. package/node_modules/zod/v4/locales/ur.js +0 -115
  803. package/node_modules/zod/v4/locales/uz.cjs +0 -140
  804. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  805. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  806. package/node_modules/zod/v4/locales/uz.js +0 -113
  807. package/node_modules/zod/v4/locales/vi.cjs +0 -140
  808. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  809. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  810. package/node_modules/zod/v4/locales/vi.js +0 -113
  811. package/node_modules/zod/v4/locales/yo.cjs +0 -139
  812. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  813. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  814. package/node_modules/zod/v4/locales/yo.js +0 -112
  815. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -141
  816. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  817. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  818. package/node_modules/zod/v4/locales/zh-CN.js +0 -114
  819. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -139
  820. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  821. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  822. package/node_modules/zod/v4/locales/zh-TW.js +0 -112
  823. package/node_modules/zod/v4/mini/checks.cjs +0 -54
  824. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  825. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  826. package/node_modules/zod/v4/mini/checks.js +0 -1
  827. package/node_modules/zod/v4/mini/coerce.cjs +0 -71
  828. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  829. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  830. package/node_modules/zod/v4/mini/coerce.js +0 -22
  831. package/node_modules/zod/v4/mini/deep-partial.cjs +0 -58
  832. package/node_modules/zod/v4/mini/deep-partial.d.cts +0 -14
  833. package/node_modules/zod/v4/mini/deep-partial.d.ts +0 -14
  834. package/node_modules/zod/v4/mini/deep-partial.js +0 -13
  835. package/node_modules/zod/v4/mini/external.cjs +0 -95
  836. package/node_modules/zod/v4/mini/external.d.cts +0 -16
  837. package/node_modules/zod/v4/mini/external.d.ts +0 -16
  838. package/node_modules/zod/v4/mini/external.js +0 -16
  839. package/node_modules/zod/v4/mini/in-out.cjs +0 -82
  840. package/node_modules/zod/v4/mini/in-out.d.cts +0 -8
  841. package/node_modules/zod/v4/mini/in-out.d.ts +0 -8
  842. package/node_modules/zod/v4/mini/in-out.js +0 -36
  843. package/node_modules/zod/v4/mini/index.cjs +0 -51
  844. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  845. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  846. package/node_modules/zod/v4/mini/index.js +0 -3
  847. package/node_modules/zod/v4/mini/iso.cjs +0 -83
  848. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  849. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  850. package/node_modules/zod/v4/mini/iso.js +0 -34
  851. package/node_modules/zod/v4/mini/package.json +0 -7
  852. package/node_modules/zod/v4/mini/parse.cjs +0 -37
  853. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  854. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  855. package/node_modules/zod/v4/mini/parse.js +0 -1
  856. package/node_modules/zod/v4/mini/schemas.cjs +0 -1147
  857. package/node_modules/zod/v4/mini/schemas.d.cts +0 -480
  858. package/node_modules/zod/v4/mini/schemas.d.ts +0 -480
  859. package/node_modules/zod/v4/mini/schemas.js +0 -1002
  860. package/node_modules/zod/v4/package.json +0 -7
  861. package/node_modules/zod/v4-mini/index.cjs +0 -51
  862. package/node_modules/zod/v4-mini/index.d.cts +0 -3
  863. package/node_modules/zod/v4-mini/index.d.ts +0 -3
  864. package/node_modules/zod/v4-mini/index.js +0 -3
  865. package/node_modules/zod/v4-mini/package.json +0 -7
@@ -1,2636 +0,0 @@
1
- import * as checks from "./checks.js";
2
- import * as core from "./core.js";
3
- import { Doc } from "./doc.js";
4
- import { parse, parseAsync } from "./parse.js";
5
- import * as regexes from "./regexes.js";
6
- import * as util from "./util.js";
7
- import { version } from "./versions.js";
8
- export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
9
- var _a;
10
- inst ?? (inst = {});
11
- inst._zod.def = def; // set _def property
12
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
13
- inst._zod.version = version;
14
- const defChecks = inst._zod.def.checks;
15
- // if inst is itself a checks.$ZodCheck, run it as a check
16
- const checks = inst._zod.traits.has("$ZodCheck")
17
- ? [inst, ...(defChecks ?? [])]
18
- : defChecks?.length
19
- ? [...defChecks]
20
- : [];
21
- for (const ch of checks) {
22
- for (const fn of ch._zod.onattach) {
23
- fn(inst);
24
- }
25
- }
26
- if (checks.length === 0) {
27
- // deferred initializer inst._zod.parse is not yet defined
28
- (_a = inst._zod).deferred ?? (_a.deferred = []);
29
- inst._zod.deferred?.push(() => {
30
- inst._zod.run = inst._zod.parse;
31
- });
32
- }
33
- else {
34
- const runChecks = (payload, checks, ctx) => {
35
- if (payload.memo)
36
- return payload;
37
- let isAborted = util.aborted(payload);
38
- let asyncResult;
39
- for (const ch of checks) {
40
- if (ch._zod.def.when) {
41
- if (util.explicitlyAborted(payload))
42
- continue;
43
- const shouldRun = ch._zod.def.when(payload);
44
- if (!shouldRun)
45
- continue;
46
- }
47
- else if (isAborted) {
48
- continue;
49
- }
50
- const currLen = payload.issues.length;
51
- const _ = ch._zod.check(payload);
52
- if (_ instanceof Promise && ctx?.async === false) {
53
- throw new core.$ZodAsyncError();
54
- }
55
- if (asyncResult || _ instanceof Promise) {
56
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
57
- await _;
58
- const nextLen = payload.issues.length;
59
- if (nextLen === currLen)
60
- return;
61
- util.attachSchema(payload.issues, currLen, inst);
62
- if (!isAborted)
63
- isAborted = util.aborted(payload, currLen);
64
- });
65
- }
66
- else {
67
- const nextLen = payload.issues.length;
68
- if (nextLen === currLen)
69
- continue;
70
- util.attachSchema(payload.issues, currLen, inst);
71
- if (!isAborted)
72
- isAborted = util.aborted(payload, currLen);
73
- }
74
- }
75
- if (asyncResult) {
76
- return asyncResult.then(() => {
77
- return payload;
78
- });
79
- }
80
- return payload;
81
- };
82
- const handleCanaryResult = (canary, payload, ctx) => {
83
- // abort if the canary is aborted
84
- if (util.aborted(canary)) {
85
- canary.aborted = true;
86
- return canary;
87
- }
88
- // run checks first, then
89
- const checkResult = runChecks(payload, checks, ctx);
90
- if (checkResult instanceof Promise) {
91
- if (ctx.async === false)
92
- throw new core.$ZodAsyncError();
93
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
94
- }
95
- return inst._zod.parse(checkResult, ctx);
96
- };
97
- inst._zod.run = (payload, ctx) => {
98
- if (ctx.skipChecks) {
99
- return inst._zod.parse(payload, ctx);
100
- }
101
- if (ctx.direction === "backward") {
102
- // run canary initial pass (no checks)
103
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
104
- if (canary instanceof Promise) {
105
- return canary.then((canary) => {
106
- return handleCanaryResult(canary, payload, ctx);
107
- });
108
- }
109
- return handleCanaryResult(canary, payload, ctx);
110
- }
111
- // forward
112
- const result = inst._zod.parse(payload, ctx);
113
- if (result instanceof Promise) {
114
- if (ctx.async === false)
115
- throw new core.$ZodAsyncError();
116
- return result.then((result) => runChecks(result, checks, ctx));
117
- }
118
- return runChecks(result, checks, ctx);
119
- };
120
- }
121
- }, {
122
- // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
123
- get "~standard"() {
124
- return util.hide(this, "~standard", standardProps(this));
125
- },
126
- set "~standard"(value) {
127
- util.own(this, "~standard", value);
128
- },
129
- });
130
- /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
131
- // a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
132
- const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
133
- async function validateAsync(inst, value) {
134
- const ctx = { async: true };
135
- return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
136
- }
137
- export function standardProps(inst) {
138
- return {
139
- validate: (value) => {
140
- const ctx = { async: false };
141
- try {
142
- const r = inst._zod.run({ value, issues: [] }, ctx);
143
- if (!(r instanceof Promise))
144
- return toStandardResult(r, ctx);
145
- }
146
- catch (_) { }
147
- // async function so a synchronously throwing check rejects instead of escaping validate
148
- return validateAsync(inst, value);
149
- },
150
- vendor: "zod",
151
- version: 1,
152
- };
153
- }
154
- export { clone } from "./util.js";
155
- export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
156
- $ZodType.init(inst, def);
157
- // a format's own pattern, else unbounded; a template literal derives the check-aware form itself
158
- inst._zod.pattern = def.pattern ?? regexes.anyString;
159
- inst._zod.parse = (payload, _) => {
160
- if (def.coerce)
161
- try {
162
- payload.value = String(payload.value);
163
- }
164
- catch (_) { }
165
- if (typeof payload.value === "string")
166
- return payload;
167
- payload.issues.push({
168
- expected: "string",
169
- code: "invalid_type",
170
- input: payload.value,
171
- inst,
172
- });
173
- return payload;
174
- };
175
- });
176
- export const $ZodStringFormat = /*@__PURE__*/ core.$constructor("$ZodStringFormat", (inst, def) => {
177
- // check initialization must come first
178
- checks.$ZodCheckStringFormat.init(inst, def);
179
- $ZodString.init(inst, def);
180
- });
181
- export const $ZodGUID = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def) => {
182
- def.pattern ?? (def.pattern = regexes.guid);
183
- $ZodStringFormat.init(inst, def);
184
- });
185
- export const $ZodUUID = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def) => {
186
- if (def.version) {
187
- const versionMap = {
188
- v1: 1,
189
- v2: 2,
190
- v3: 3,
191
- v4: 4,
192
- v5: 5,
193
- v6: 6,
194
- v7: 7,
195
- v8: 8,
196
- };
197
- const v = versionMap[def.version];
198
- if (v === undefined)
199
- throw new Error(`Invalid UUID version: "${def.version}"`);
200
- def.pattern ?? (def.pattern = regexes.uuid(v));
201
- }
202
- else
203
- def.pattern ?? (def.pattern = regexes.uuid());
204
- $ZodStringFormat.init(inst, def);
205
- });
206
- export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def) => {
207
- def.pattern ?? (def.pattern = regexes.email);
208
- $ZodStringFormat.init(inst, def);
209
- });
210
- /** The `://` guard rejected the input before the URL constructor saw it. */
211
- export const URL_BAD_FORMAT = 1;
212
- /** The URL parser rejected the input. */
213
- export const URL_UNPARSEABLE = 2;
214
- export function canParseURL(input) {
215
- try {
216
- if (typeof URL !== "undefined" && typeof URL.canParse === "function")
217
- return URL.canParse(input);
218
- new URL(input);
219
- return true;
220
- }
221
- catch {
222
- return false;
223
- }
224
- }
225
- export function validateURL(trimmed, def) {
226
- if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
227
- return canParseURL(trimmed) || URL_UNPARSEABLE;
228
- }
229
- return parseURLObject(trimmed, def);
230
- }
231
- /** Parses a URL while preserving the non-normalizing HTTP guard. */
232
- export function parseURLObject(trimmed, def) {
233
- // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
234
- if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
235
- return URL_BAD_FORMAT;
236
- }
237
- try {
238
- if (typeof URL !== "undefined") {
239
- const URLStatic = URL;
240
- if (typeof URLStatic.parse === "function")
241
- return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
242
- }
243
- // @ts-ignore
244
- return new URL(trimmed);
245
- }
246
- catch {
247
- return URL_UNPARSEABLE;
248
- }
249
- }
250
- const asciiTabOrNewline = /[\t\n\r]/g;
251
- /** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
252
- export function stripTabAndNewline(value) {
253
- return value.replace(asciiTabOrNewline, "");
254
- }
255
- export function urlHostnameOk(url, hostname) {
256
- hostname.lastIndex = 0;
257
- return hostname.test(url.hostname);
258
- }
259
- export function urlProtocolOk(url, protocol) {
260
- protocol.lastIndex = 0;
261
- return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
262
- }
263
- export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
264
- $ZodStringFormat.init(inst, def);
265
- inst._zod.check = (payload) => {
266
- try {
267
- // Trim whitespace from input
268
- const trimmed = payload.value.trim();
269
- const url = validateURL(trimmed, def);
270
- if (url === URL_BAD_FORMAT) {
271
- payload.issues.push({
272
- code: "invalid_format",
273
- format: "url",
274
- note: "Invalid URL format",
275
- input: payload.value,
276
- inst,
277
- continue: !def.abort,
278
- });
279
- return;
280
- }
281
- if (url === URL_UNPARSEABLE) {
282
- payload.issues.push({
283
- code: "invalid_format",
284
- format: "url",
285
- input: payload.value,
286
- inst,
287
- continue: !def.abort,
288
- });
289
- return;
290
- }
291
- if (url === true) {
292
- payload.value = stripTabAndNewline(trimmed);
293
- return;
294
- }
295
- if (def.hostname && !urlHostnameOk(url, def.hostname)) {
296
- payload.issues.push({
297
- code: "invalid_format",
298
- format: "url",
299
- note: "Invalid hostname",
300
- pattern: def.hostname.source,
301
- input: payload.value,
302
- inst,
303
- continue: !def.abort,
304
- });
305
- }
306
- if (def.protocol && !urlProtocolOk(url, def.protocol)) {
307
- payload.issues.push({
308
- code: "invalid_format",
309
- format: "url",
310
- note: "Invalid protocol",
311
- pattern: def.protocol.source,
312
- input: payload.value,
313
- inst,
314
- continue: !def.abort,
315
- });
316
- }
317
- // Set the output value based on normalize flag
318
- payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
319
- return;
320
- }
321
- catch (_) {
322
- payload.issues.push({
323
- code: "invalid_format",
324
- format: "url",
325
- input: payload.value,
326
- inst,
327
- continue: !def.abort,
328
- });
329
- }
330
- };
331
- });
332
- export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def) => {
333
- def.pattern ?? (def.pattern = regexes.emoji());
334
- $ZodStringFormat.init(inst, def);
335
- });
336
- export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
337
- if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
338
- throw new Error(`Invalid nanoid length: ${def.length}`);
339
- def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
340
- $ZodStringFormat.init(inst, def);
341
- });
342
- /**
343
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
344
- * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
345
- * See https://github.com/paralleldrive/cuid.
346
- */
347
- export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
348
- def.pattern ?? (def.pattern = regexes.cuid);
349
- $ZodStringFormat.init(inst, def);
350
- });
351
- export const $ZodCUID2 = /*@__PURE__*/ core.$constructor("$ZodCUID2", (inst, def) => {
352
- def.pattern ?? (def.pattern = regexes.cuid2);
353
- $ZodStringFormat.init(inst, def);
354
- });
355
- export const $ZodULID = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def) => {
356
- def.pattern ?? (def.pattern = regexes.ulid);
357
- $ZodStringFormat.init(inst, def);
358
- });
359
- export const $ZodXID = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def) => {
360
- def.pattern ?? (def.pattern = regexes.xid);
361
- $ZodStringFormat.init(inst, def);
362
- });
363
- export const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def) => {
364
- def.pattern ?? (def.pattern = regexes.ksuid);
365
- $ZodStringFormat.init(inst, def);
366
- });
367
- export const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
368
- def.pattern ?? (def.pattern = regexes.datetime(def));
369
- $ZodStringFormat.init(inst, def);
370
- });
371
- export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
372
- def.pattern ?? (def.pattern = regexes.date);
373
- $ZodStringFormat.init(inst, def);
374
- });
375
- export const $ZodISOTime = /*@__PURE__*/ core.$constructor("$ZodISOTime", (inst, def) => {
376
- def.pattern ?? (def.pattern = regexes.time(def));
377
- $ZodStringFormat.init(inst, def);
378
- });
379
- export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration", (inst, def) => {
380
- def.pattern ?? (def.pattern = regexes.duration);
381
- $ZodStringFormat.init(inst, def);
382
- });
383
- export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
384
- def.pattern ?? (def.pattern = regexes.ipv4);
385
- $ZodStringFormat.init(inst, def);
386
- });
387
- /** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
388
- const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
389
- export function isValidIPv6(value) {
390
- if (!ipv6Alphabet.test(value))
391
- return false;
392
- return canParseURL(`http://[${value}]`);
393
- }
394
- export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
395
- def.pattern ?? (def.pattern = regexes.ipv6);
396
- $ZodStringFormat.init(inst, def);
397
- inst._zod.check = (payload) => {
398
- if (!isValidIPv6(payload.value)) {
399
- payload.issues.push({
400
- code: "invalid_format",
401
- format: "ipv6",
402
- input: payload.value,
403
- inst,
404
- continue: !def.abort,
405
- });
406
- }
407
- };
408
- });
409
- export const $ZodMAC = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def) => {
410
- def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
411
- $ZodStringFormat.init(inst, def);
412
- });
413
- export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
414
- def.pattern ?? (def.pattern = regexes.cidrv4);
415
- $ZodStringFormat.init(inst, def);
416
- });
417
- export function isValidCIDRv6(value) {
418
- const parts = value.split("/");
419
- if (parts.length !== 2)
420
- return false;
421
- const [address, prefix] = parts;
422
- if (!prefix)
423
- return false;
424
- const prefixNum = Number(prefix);
425
- if (`${prefixNum}` !== prefix)
426
- return false;
427
- if (prefixNum < 0 || prefixNum > 128)
428
- return false;
429
- return isValidIPv6(address);
430
- }
431
- export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
432
- def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
433
- $ZodStringFormat.init(inst, def);
434
- inst._zod.check = (payload) => {
435
- if (!isValidCIDRv6(payload.value)) {
436
- payload.issues.push({
437
- code: "invalid_format",
438
- format: "cidrv6",
439
- input: payload.value,
440
- inst,
441
- continue: !def.abort,
442
- });
443
- }
444
- };
445
- });
446
- ////////////////////////////// ZodBase64 //////////////////////////////
447
- export function isValidBase64(data) {
448
- if (data === "")
449
- return true;
450
- // atob ignores whitespace, so reject it up front.
451
- if (/\s/.test(data))
452
- return false;
453
- if (data.length % 4 !== 0)
454
- return false;
455
- try {
456
- // @ts-ignore
457
- atob(data);
458
- return true;
459
- }
460
- catch {
461
- return false;
462
- }
463
- }
464
- // lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
465
- export const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
466
- export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
467
- def.pattern ?? (def.pattern = base64Charset);
468
- $ZodStringFormat.init(inst, def);
469
- inst._zod.check = (payload) => {
470
- if (isValidBase64(payload.value))
471
- return;
472
- payload.issues.push({
473
- code: "invalid_format",
474
- format: "base64",
475
- input: payload.value,
476
- inst,
477
- continue: !def.abort,
478
- });
479
- };
480
- });
481
- ////////////////////////////// ZodBase64URL //////////////////////////////
482
- // lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
483
- export const base64urlCharset = /^[A-Za-z0-9_-]*$/;
484
- export function isValidBase64URL(data) {
485
- if (!base64urlCharset.test(data))
486
- return false;
487
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
488
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
489
- return isValidBase64(padded);
490
- }
491
- export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
492
- def.pattern ?? (def.pattern = base64urlCharset);
493
- $ZodStringFormat.init(inst, def);
494
- inst._zod.check = (payload) => {
495
- if (isValidBase64URL(payload.value))
496
- return;
497
- payload.issues.push({
498
- code: "invalid_format",
499
- format: "base64url",
500
- input: payload.value,
501
- inst,
502
- continue: !def.abort,
503
- });
504
- };
505
- });
506
- export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def) => {
507
- def.pattern ?? (def.pattern = regexes.e164);
508
- $ZodStringFormat.init(inst, def);
509
- });
510
- ////////////////////////////// ZodCreditCard //////////////////////////////
511
- const CC_SANITIZE = /[- ]/g;
512
- /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
513
- function isLuhnAlgo(digits) {
514
- let length = digits.length;
515
- let bit = 1;
516
- let sum = 0;
517
- while (length) {
518
- const value = digits.charCodeAt(--length) - 48;
519
- bit ^= 1;
520
- sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
521
- }
522
- return sum % 10 === 0;
523
- }
524
- export function isValidCreditCard(input) {
525
- if (!regexes.creditCard.test(input))
526
- return false;
527
- return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
528
- }
529
- export const $ZodCreditCard = /*@__PURE__*/ core.$constructor("$ZodCreditCard", (inst, def) => {
530
- // Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
531
- def.pattern ?? (def.pattern = regexes.creditCard);
532
- $ZodStringFormat.init(inst, def);
533
- inst._zod.check = (payload) => {
534
- if (isValidCreditCard(payload.value))
535
- return;
536
- payload.issues.push({
537
- code: "invalid_format",
538
- format: "credit_card",
539
- input: payload.value,
540
- inst,
541
- continue: !def.abort,
542
- });
543
- };
544
- });
545
- ////////////////////////////// ZodIBAN //////////////////////////////
546
- // iso 7064 mod 97-10 checksum without BigInt
547
- function isIso7064Mod97(iban) {
548
- let remainder = 0;
549
- const len = iban.length;
550
- for (let i = 4; i < len; i++) {
551
- const code = iban.charCodeAt(i);
552
- remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
553
- }
554
- for (let i = 0; i < 4; i++) {
555
- const code = iban.charCodeAt(i);
556
- remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
557
- }
558
- return remainder === 1;
559
- }
560
- export function isValidIBAN(input) {
561
- if (!regexes.iban.test(input))
562
- return false;
563
- return isIso7064Mod97(input);
564
- }
565
- export const $ZodIBAN = /*@__PURE__*/ core.$constructor("$ZodIBAN", (inst, def) => {
566
- // shape only — checksum is not expressible as a pattern
567
- def.pattern ?? (def.pattern = regexes.iban);
568
- $ZodStringFormat.init(inst, def);
569
- inst._zod.check = (payload) => {
570
- if (isValidIBAN(payload.value))
571
- return;
572
- payload.issues.push({
573
- code: "invalid_format",
574
- format: "iban",
575
- input: payload.value,
576
- inst,
577
- continue: !def.abort,
578
- });
579
- };
580
- });
581
- ////////////////////////////// ZodJWT //////////////////////////////
582
- export function isValidJWT(token, algorithm = null) {
583
- try {
584
- const tokensParts = token.split(".");
585
- if (tokensParts.length !== 3)
586
- return false;
587
- const [header] = tokensParts;
588
- if (!header)
589
- return false;
590
- // @ts-ignore
591
- const parsedHeader = JSON.parse(atob(header));
592
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
593
- return false;
594
- if (!parsedHeader.alg)
595
- return false;
596
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
597
- return false;
598
- return true;
599
- }
600
- catch {
601
- return false;
602
- }
603
- }
604
- export const $ZodJWT = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def) => {
605
- $ZodStringFormat.init(inst, def);
606
- inst._zod.check = (payload) => {
607
- if (isValidJWT(payload.value, def.alg))
608
- return;
609
- payload.issues.push({
610
- code: "invalid_format",
611
- format: "jwt",
612
- input: payload.value,
613
- inst,
614
- continue: !def.abort,
615
- });
616
- };
617
- });
618
- export const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCustomStringFormat", (inst, def) => {
619
- $ZodStringFormat.init(inst, def);
620
- inst._zod.check = (payload) => {
621
- if (def.fn(payload.value))
622
- return;
623
- payload.issues.push({
624
- code: "invalid_format",
625
- format: def.format,
626
- input: payload.value,
627
- inst,
628
- continue: !def.abort,
629
- });
630
- };
631
- });
632
- export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
633
- $ZodType.init(inst, def);
634
- inst._zod.pattern = regexes.number;
635
- inst._zod.parse = (payload, _ctx) => {
636
- if (def.coerce)
637
- try {
638
- payload.value = Number(payload.value);
639
- }
640
- catch (_) { }
641
- const input = payload.value;
642
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
643
- return payload;
644
- }
645
- const received = typeof input === "number"
646
- ? Number.isNaN(input)
647
- ? "NaN"
648
- : !Number.isFinite(input)
649
- ? String(input)
650
- : undefined
651
- : undefined;
652
- payload.issues.push({
653
- expected: "number",
654
- code: "invalid_type",
655
- input,
656
- inst,
657
- ...(received ? { received } : {}),
658
- });
659
- return payload;
660
- };
661
- });
662
- export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumberFormat", (inst, def) => {
663
- checks.$ZodCheckNumberFormat.init(inst, def);
664
- $ZodNumber.init(inst, def); // no format checks
665
- });
666
- export const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
667
- $ZodType.init(inst, def);
668
- inst._zod.pattern = regexes.boolean;
669
- inst._zod.parse = (payload, _ctx) => {
670
- if (def.coerce)
671
- try {
672
- payload.value = Boolean(payload.value);
673
- }
674
- catch (_) { }
675
- const input = payload.value;
676
- if (typeof input === "boolean")
677
- return payload;
678
- payload.issues.push({
679
- expected: "boolean",
680
- code: "invalid_type",
681
- input,
682
- inst,
683
- });
684
- return payload;
685
- };
686
- });
687
- export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
688
- $ZodType.init(inst, def);
689
- inst._zod.pattern = regexes.bigint;
690
- inst._zod.parse = (payload, _ctx) => {
691
- if (def.coerce)
692
- try {
693
- payload.value = BigInt(payload.value);
694
- }
695
- catch (_) { }
696
- if (typeof payload.value === "bigint")
697
- return payload;
698
- payload.issues.push({
699
- expected: "bigint",
700
- code: "invalid_type",
701
- input: payload.value,
702
- inst,
703
- });
704
- return payload;
705
- };
706
- });
707
- export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigIntFormat", (inst, def) => {
708
- checks.$ZodCheckBigIntFormat.init(inst, def);
709
- $ZodBigInt.init(inst, def); // no format checks
710
- });
711
- export const $ZodSymbol = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
712
- $ZodType.init(inst, def);
713
- inst._zod.parse = (payload, _ctx) => {
714
- const input = payload.value;
715
- if (typeof input === "symbol")
716
- return payload;
717
- payload.issues.push({
718
- expected: "symbol",
719
- code: "invalid_type",
720
- input,
721
- inst,
722
- });
723
- return payload;
724
- };
725
- });
726
- export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (inst, def) => {
727
- $ZodType.init(inst, def);
728
- inst._zod.pattern = regexes.undefined;
729
- inst._zod.values = new Set([undefined]);
730
- inst._zod.parse = (payload, _ctx) => {
731
- const input = payload.value;
732
- if (typeof input === "undefined")
733
- return payload;
734
- payload.issues.push({
735
- expected: "undefined",
736
- code: "invalid_type",
737
- input,
738
- inst,
739
- });
740
- return payload;
741
- };
742
- });
743
- export const $ZodNull = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
744
- $ZodType.init(inst, def);
745
- inst._zod.pattern = regexes.null;
746
- inst._zod.values = new Set([null]);
747
- inst._zod.parse = (payload, _ctx) => {
748
- const input = payload.value;
749
- if (input === null)
750
- return payload;
751
- payload.issues.push({
752
- expected: "null",
753
- code: "invalid_type",
754
- input,
755
- inst,
756
- });
757
- return payload;
758
- };
759
- });
760
- export const $ZodAny = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
761
- $ZodType.init(inst, def);
762
- inst._zod.parse = (payload) => payload;
763
- });
764
- export const $ZodUnknown = /*@__PURE__*/ core.$constructor("$ZodUnknown", (inst, def) => {
765
- $ZodType.init(inst, def);
766
- inst._zod.parse = (payload) => payload;
767
- });
768
- export const $ZodNever = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
769
- $ZodType.init(inst, def);
770
- inst._zod.parse = (payload, _ctx) => {
771
- payload.issues.push({
772
- expected: "never",
773
- code: "invalid_type",
774
- input: payload.value,
775
- inst,
776
- });
777
- return payload;
778
- };
779
- });
780
- export const $ZodVoid = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
781
- $ZodType.init(inst, def);
782
- inst._zod.parse = (payload, _ctx) => {
783
- const input = payload.value;
784
- if (typeof input === "undefined")
785
- return payload;
786
- payload.issues.push({
787
- expected: "void",
788
- code: "invalid_type",
789
- input,
790
- inst,
791
- });
792
- return payload;
793
- };
794
- });
795
- export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
796
- $ZodType.init(inst, def);
797
- inst._zod.parse = (payload, _ctx) => {
798
- if (def.coerce) {
799
- try {
800
- payload.value = new Date(payload.value);
801
- }
802
- catch (_err) { }
803
- }
804
- const input = payload.value;
805
- const isDate = input instanceof Date;
806
- const isValidDate = isDate && !Number.isNaN(input.getTime());
807
- if (isValidDate)
808
- return payload;
809
- payload.issues.push({
810
- expected: "date",
811
- code: "invalid_type",
812
- input,
813
- ...(isDate ? { received: "Invalid Date" } : {}),
814
- inst,
815
- });
816
- return payload;
817
- };
818
- });
819
- // an oversized container fails its leading size checks before any element is parsed
820
- function capSize(inst, size) {
821
- const caps = util.sizeCaps(inst._zod.def.checks);
822
- if (!caps.length)
823
- return;
824
- const cap = Math.min(...caps.map((c) => c[0]));
825
- const parse = inst._zod.parse;
826
- inst._zod.parse = (payload, ctx) => {
827
- const n = size(payload.value);
828
- if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
829
- for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
830
- if (n > max && ch._zod.def.when(payload)) {
831
- const start = payload.issues.length;
832
- ch._zod.check(payload);
833
- // the value is still the raw input, so no later check may read it
834
- payload.issues[start].continue = false;
835
- util.attachSchema(payload.issues, start, inst);
836
- return payload;
837
- }
838
- }
839
- }
840
- return parse(payload, ctx);
841
- };
842
- }
843
- const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
844
- const mapSize = (input) => (input instanceof Map ? input.size : -1);
845
- const setSize = (input) => (input instanceof Set ? input.size : -1);
846
- function handleArrayResult(result, final, index) {
847
- if (result.issues.length) {
848
- final.issues.push(...util.prefixIssues(index, result.issues));
849
- }
850
- final.value[index] = result.value;
851
- }
852
- export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
853
- $ZodType.init(inst, def);
854
- const memo = core.globalConfig.memoizer;
855
- memo?.attach(inst);
856
- inst._zod.parse = (payload, ctx) => {
857
- const input = payload.value;
858
- if (!Array.isArray(input)) {
859
- payload.issues.push({
860
- expected: "array",
861
- code: "invalid_type",
862
- input,
863
- inst,
864
- });
865
- return payload;
866
- }
867
- payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
868
- const proms = [];
869
- const abortEarly = ctx?.abortEarly;
870
- for (let i = 0; i < input.length; i++) {
871
- const item = input[i];
872
- const result = def.element._zod.run({
873
- value: item,
874
- issues: [],
875
- }, ctx);
876
- if (result instanceof Promise) {
877
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
878
- }
879
- else {
880
- handleArrayResult(result, payload, i);
881
- // the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
882
- if (abortEarly && result.issues.length !== 0 && util.aborted(result))
883
- break;
884
- }
885
- }
886
- if (proms.length) {
887
- return Promise.all(proms).then(() => payload);
888
- }
889
- return payload; //handleArrayResultsAsync(parseResults, final);
890
- };
891
- capSize(inst, arraySize);
892
- });
893
- function handlePropertyResult(result, final, key, input, optin, optout) {
894
- const isPresent = key in input;
895
- const isOptionalOut = optout === "optional";
896
- // The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
897
- if (!isPresent && isOptionalOut && optin === "optional") {
898
- return;
899
- }
900
- if (result.issues.length) {
901
- // For optional-in/out schemas, ignore errors on absent keys.
902
- if (optin !== undefined && isOptionalOut && !isPresent) {
903
- return;
904
- }
905
- final.issues.push(...util.prefixIssues(key, result.issues));
906
- }
907
- if (!isPresent && optin === undefined) {
908
- if (!result.issues.length) {
909
- final.issues.push({
910
- code: "invalid_type",
911
- expected: "nonoptional",
912
- input: undefined,
913
- path: [key],
914
- });
915
- }
916
- return;
917
- }
918
- if (result.value === undefined) {
919
- if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
920
- final.value[key] = undefined;
921
- }
922
- }
923
- else {
924
- final.value[key] = result.value;
925
- }
926
- }
927
- // one shared instance; a fresh [] per schema cost 56 bytes retained
928
- const NO_SYMBOL_KEYS = [];
929
- function normalizeDef(def) {
930
- const keys = Object.keys(def.shape);
931
- const ownSymbols = Object.getOwnPropertySymbols(def.shape);
932
- const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
933
- // aliases `keys` when there are no symbols, so a string-only shape keeps one array
934
- const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
935
- for (const k of allKeys) {
936
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
937
- throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
938
- }
939
- }
940
- const okeys = util.optionalKeys(def.shape);
941
- return {
942
- ...def,
943
- allKeys,
944
- symbolKeys,
945
- // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
946
- keySet: new Set(keys),
947
- numKeys: keys.length,
948
- optionalKeys: new Set(okeys),
949
- };
950
- }
951
- function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
952
- const unrecognized = [];
953
- const keySet = def.keySet;
954
- const _catchall = def.catchall._zod;
955
- const t = _catchall.def.type;
956
- const optin = _catchall.optin;
957
- const optout = _catchall.optout;
958
- // starts at 0, not the current length: the shape phase already ran and may have aborted
959
- let seen = 0;
960
- for (const key in input) {
961
- if (abortEarly && payload.issues.length !== seen) {
962
- if (util.aborted(payload, seen))
963
- break;
964
- seen = payload.issues.length;
965
- }
966
- // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
967
- if (keySet.has(key))
968
- continue;
969
- // Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
970
- if (key === "__proto__") {
971
- if (t === "never")
972
- unrecognized.push(key);
973
- continue;
974
- }
975
- if (t === "never") {
976
- unrecognized.push(key);
977
- continue;
978
- }
979
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
980
- if (r instanceof Promise) {
981
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
982
- }
983
- else {
984
- handlePropertyResult(r, payload, key, input, optin, optout);
985
- }
986
- }
987
- if (unrecognized.length) {
988
- payload.issues.push({
989
- code: "unrecognized_keys",
990
- keys: unrecognized,
991
- input,
992
- inst,
993
- // Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
994
- continue: true,
995
- });
996
- }
997
- if (!proms.length)
998
- return payload;
999
- return Promise.all(proms).then(() => {
1000
- return payload;
1001
- });
1002
- }
1003
- export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
1004
- // requires cast because technically $ZodObject doesn't extend
1005
- $ZodType.init(inst, def);
1006
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1007
- // a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
1008
- const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
1009
- if (sh) {
1010
- // Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
1011
- const get = () => {
1012
- const newSh = { ...sh };
1013
- Object.defineProperty(def, "shape", { value: newSh });
1014
- get.raw = newSh;
1015
- return newSh;
1016
- };
1017
- get.raw = sh;
1018
- Object.defineProperty(def, "shape", { get });
1019
- }
1020
- const _normalized = util.cached(() => normalizeDef(def));
1021
- util.defineLazyInternal(inst, "propValues", (zod) => {
1022
- const shape = zod.def.shape;
1023
- const propValues = {};
1024
- for (const key in shape) {
1025
- const field = shape[key]._zod;
1026
- if (field.values) {
1027
- if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
1028
- util.assignProp(propValues, key, new Set());
1029
- }
1030
- for (const v of field.values)
1031
- propValues[key].add(v);
1032
- // An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
1033
- if (field.optin !== undefined)
1034
- propValues[key].add(undefined);
1035
- }
1036
- }
1037
- return propValues;
1038
- });
1039
- const isObject = util.isObject;
1040
- const catchall = def.catchall;
1041
- let value;
1042
- const memo = core.globalConfig.memoizer;
1043
- memo?.attach(inst);
1044
- inst._zod.parse = (payload, ctx) => {
1045
- value ?? (value = _normalized.value);
1046
- const input = payload.value;
1047
- if (!isObject(input)) {
1048
- payload.issues.push({
1049
- expected: "object",
1050
- code: "invalid_type",
1051
- input,
1052
- inst,
1053
- });
1054
- return payload;
1055
- }
1056
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1057
- const proms = [];
1058
- const shape = value.shape;
1059
- const abortEarly = ctx?.abortEarly;
1060
- let seen = payload.issues.length;
1061
- for (const key of value.allKeys) {
1062
- if (abortEarly && payload.issues.length !== seen) {
1063
- if (util.aborted(payload, seen))
1064
- break;
1065
- seen = payload.issues.length;
1066
- }
1067
- if (key === "__proto__")
1068
- continue;
1069
- const el = shape[key];
1070
- const optin = el._zod.optin;
1071
- const optout = el._zod.optout;
1072
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1073
- if (r instanceof Promise) {
1074
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1075
- }
1076
- else {
1077
- handlePropertyResult(r, payload, key, input, optin, optout);
1078
- }
1079
- }
1080
- if (!catchall) {
1081
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1082
- }
1083
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1084
- };
1085
- });
1086
- export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (inst, def) => {
1087
- // requires cast because technically $ZodObject doesn't extend
1088
- $ZodObject.init(inst, def);
1089
- const superParse = inst._zod.parse;
1090
- const _normalized = util.cached(() => normalizeDef(def));
1091
- const memo = core.globalConfig.memoizer;
1092
- const generateFastpass = (shape) => {
1093
- const normalized = _normalized.value;
1094
- const syms = normalized.symbolKeys;
1095
- // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
1096
- const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
1097
- const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1098
- // prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
1099
- const prefixStr = (id, k) => `
1100
- let ${id}_ab = false;
1101
- for (let i = 0; i < ${id}.issues.length; i++) {
1102
- const iss = ${id}.issues[i];
1103
- iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
1104
- payload.issues.push(iss);
1105
- if (iss.continue !== true) ${id}_ab = true;
1106
- }
1107
- if (${id}_ab && ctx && ctx.abortEarly) {
1108
- payload.value = newResult;
1109
- return payload;
1110
- }`;
1111
- doc.write(`const input = payload.value;`);
1112
- const ids = Object.create(null);
1113
- let counter = 0;
1114
- for (const key of normalized.allKeys) {
1115
- ids[key] = `key_${counter++}`;
1116
- }
1117
- // A: preserve key order {
1118
- doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
1119
- for (const key of normalized.allKeys) {
1120
- if (key === "__proto__")
1121
- continue;
1122
- const id = ids[key];
1123
- const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
1124
- const isPresent = `${k} in input`;
1125
- const schema = shape[key];
1126
- const optin = schema?._zod?.optin;
1127
- const isOptionalIn = optin !== undefined;
1128
- const isOptionalOut = schema?._zod?.optout === "optional";
1129
- doc.write(`const ${id} = ${parseStr(k)};`);
1130
- if (isOptionalIn && isOptionalOut) {
1131
- // For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
1132
- const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
1133
- doc.write(`
1134
- const ${id}_present = ${isPresent};
1135
- if (!${id}.issues.length || ${id}_present) {
1136
- if (${id}.issues.length) {${prefixStr(id, k)}
1137
- }
1138
-
1139
- if (${assign}) {
1140
- newResult[${k}] = ${id}.value;
1141
- }
1142
- }
1143
-
1144
- `);
1145
- }
1146
- else if (!isOptionalIn) {
1147
- doc.write(`
1148
- const ${id}_present = ${isPresent};
1149
- if (${id}.issues.length) {${prefixStr(id, k)}
1150
- }
1151
- if (!${id}_present && !${id}.issues.length) {
1152
- payload.issues.push({
1153
- code: "invalid_type",
1154
- expected: "nonoptional",
1155
- input: undefined,
1156
- path: [${k}]
1157
- });
1158
- if (ctx && ctx.abortEarly) {
1159
- payload.value = newResult;
1160
- return payload;
1161
- }
1162
- }
1163
-
1164
- if (${id}_present) {
1165
- newResult[${k}] = ${id}.value;
1166
- }
1167
-
1168
- `);
1169
- }
1170
- else {
1171
- doc.write(`
1172
- if (${id}.issues.length) {${prefixStr(id, k)}
1173
- }
1174
- `);
1175
- if (optin === "defaulted") {
1176
- doc.write(`newResult[${k}] = ${id}.value;`);
1177
- }
1178
- else {
1179
- doc.write(`
1180
- if (${id}.value !== undefined || ${isPresent}) {
1181
- newResult[${k}] = ${id}.value;
1182
- }
1183
- `);
1184
- }
1185
- }
1186
- }
1187
- doc.write(`payload.value = newResult;`);
1188
- doc.write(`return payload;`);
1189
- // closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
1190
- return doc.compile();
1191
- };
1192
- let fastpass;
1193
- const isObject = util.isObject;
1194
- const jit = !core.globalConfig.jitless;
1195
- const allowsEval = util.allowsEval;
1196
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
1197
- const catchall = def.catchall;
1198
- let value;
1199
- inst._zod.parse = (payload, ctx) => {
1200
- value ?? (value = _normalized.value);
1201
- const input = payload.value;
1202
- if (!isObject(input)) {
1203
- payload.issues.push({
1204
- expected: "object",
1205
- code: "invalid_type",
1206
- input,
1207
- inst,
1208
- });
1209
- return payload;
1210
- }
1211
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1212
- // always synchronous
1213
- if (!fastpass)
1214
- fastpass = generateFastpass(def.shape);
1215
- payload = fastpass(payload, ctx);
1216
- if (!catchall)
1217
- return payload;
1218
- return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1219
- }
1220
- return superParse(payload, ctx);
1221
- };
1222
- });
1223
- function handleUnionResults(results, final, inst, ctx) {
1224
- for (const result of results) {
1225
- if (result.issues.length === 0) {
1226
- final.value = result.value;
1227
- return final;
1228
- }
1229
- }
1230
- const nonaborted = results.filter((r) => !util.aborted(r));
1231
- if (nonaborted.length === 1) {
1232
- final.value = nonaborted[0].value;
1233
- return nonaborted[0];
1234
- }
1235
- final.issues.push({
1236
- code: "invalid_union",
1237
- input: final.value,
1238
- inst,
1239
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1240
- });
1241
- return final;
1242
- }
1243
- export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
1244
- $ZodType.init(inst, def);
1245
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
1246
- ? "defaulted"
1247
- : zod.def.options.some((o) => o._zod.optin !== undefined)
1248
- ? "optional"
1249
- : undefined);
1250
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1251
- util.defineLazyInternal(inst, "values", (zod) => {
1252
- if (zod.def.options.every((o) => o._zod.values)) {
1253
- return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1254
- }
1255
- return undefined;
1256
- });
1257
- util.defineLazyInternal(inst, "pattern", (zod) => {
1258
- if (zod.def.options.every((o) => o._zod.pattern)) {
1259
- const patterns = zod.def.options.map((o) => o._zod.pattern);
1260
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
1261
- }
1262
- return undefined;
1263
- });
1264
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1265
- inst._zod.parse = (payload, ctx) => {
1266
- if (first) {
1267
- return first(payload, ctx);
1268
- }
1269
- let async = false;
1270
- const results = [];
1271
- for (const option of def.options) {
1272
- const result = option._zod.run({
1273
- value: payload.value,
1274
- issues: [],
1275
- }, ctx);
1276
- if (result instanceof Promise) {
1277
- results.push(result);
1278
- async = true;
1279
- }
1280
- else {
1281
- if (result.issues.length === 0)
1282
- return result;
1283
- results.push(result);
1284
- }
1285
- }
1286
- if (!async)
1287
- return handleUnionResults(results, payload, inst, ctx);
1288
- return Promise.all(results).then((results) => {
1289
- return handleUnionResults(results, payload, inst, ctx);
1290
- });
1291
- };
1292
- });
1293
- function handleExclusiveUnionResults(results, final, inst, ctx) {
1294
- const matches = [];
1295
- for (let i = 0; i < results.length; i++) {
1296
- if (results[i].issues.length === 0)
1297
- matches.push(i);
1298
- }
1299
- if (matches.length === 1) {
1300
- final.value = results[matches[0]].value;
1301
- return final;
1302
- }
1303
- if (matches.length === 0) {
1304
- // No matches - same as regular union
1305
- final.issues.push({
1306
- code: "invalid_union",
1307
- input: final.value,
1308
- inst,
1309
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1310
- });
1311
- }
1312
- else {
1313
- // Multiple matches - exclusive union failure
1314
- final.issues.push({
1315
- code: "invalid_union",
1316
- input: final.value,
1317
- inst,
1318
- errors: [],
1319
- inclusive: false,
1320
- matches,
1321
- });
1322
- }
1323
- return final;
1324
- }
1325
- export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
1326
- $ZodUnion.init(inst, def);
1327
- def.inclusive = false;
1328
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1329
- inst._zod.parse = (payload, ctx) => {
1330
- if (first) {
1331
- return first(payload, ctx);
1332
- }
1333
- let async = false;
1334
- const results = [];
1335
- for (const option of def.options) {
1336
- const result = option._zod.run({
1337
- value: payload.value,
1338
- issues: [],
1339
- }, ctx);
1340
- if (result instanceof Promise) {
1341
- results.push(result);
1342
- async = true;
1343
- }
1344
- else {
1345
- results.push(result);
1346
- }
1347
- }
1348
- if (!async)
1349
- return handleExclusiveUnionResults(results, payload, inst, ctx);
1350
- return Promise.all(results).then((results) => {
1351
- return handleExclusiveUnionResults(results, payload, inst, ctx);
1352
- });
1353
- };
1354
- });
1355
- /** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
1356
- export function getDiscriminatedOption(union, value) {
1357
- const internals = union._zod;
1358
- let map = internals.bag.optionsMap;
1359
- if (!map) {
1360
- map = discriminatorMap(internals.def);
1361
- internals.bag.optionsMap = map;
1362
- }
1363
- const option = map.get(value);
1364
- if (option === null)
1365
- throw new Error(`Ambiguous discriminator value "${String(value)}"`);
1366
- return option;
1367
- }
1368
- function discriminatorMap(def) {
1369
- const map = new Map();
1370
- for (const option of def.options) {
1371
- const values = option._zod.propValues?.[def.discriminator];
1372
- if (!values || values.size === 0)
1373
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1374
- for (const value of values) {
1375
- if (map.has(value)) {
1376
- if (value !== undefined)
1377
- throw new Error(`Duplicate discriminator value "${String(value)}"`);
1378
- // keep the collision marked so a later member cannot reclaim it
1379
- map.set(value, null);
1380
- }
1381
- else {
1382
- map.set(value, option);
1383
- }
1384
- }
1385
- }
1386
- return map;
1387
- }
1388
- export const $ZodDiscriminatedUnion =
1389
- /*@__PURE__*/
1390
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1391
- def.inclusive = false;
1392
- $ZodUnion.init(inst, def);
1393
- const _super = inst._zod.parse;
1394
- util.defineLazyInternal(inst, "propValues", (zod) => {
1395
- const propValues = {};
1396
- let undefinedCount = 0;
1397
- for (const option of zod.def.options) {
1398
- const pv = option._zod.propValues;
1399
- if (!pv || Object.keys(pv).length === 0)
1400
- throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
1401
- if (pv[zod.def.discriminator]?.has(undefined))
1402
- undefinedCount++;
1403
- for (const [k, v] of Object.entries(pv)) {
1404
- if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
1405
- util.assignProp(propValues, k, new Set());
1406
- }
1407
- for (const val of v) {
1408
- propValues[k].add(val);
1409
- }
1410
- }
1411
- }
1412
- if (!zod.def.unionFallback && undefinedCount > 1)
1413
- propValues[zod.def.discriminator]?.delete(undefined);
1414
- return propValues;
1415
- });
1416
- // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
1417
- def.options.forEach((option, i) => {
1418
- const propShape = util.rawShape(option._zod.def);
1419
- if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
1420
- throw new Error(`Invalid discriminated union option at index "${i}"`);
1421
- }
1422
- });
1423
- const disc = util.cached(() => discriminatorMap(def));
1424
- inst._zod.parse = (payload, ctx) => {
1425
- const input = payload.value;
1426
- if (!util.isObject(input)) {
1427
- payload.issues.push({
1428
- code: "invalid_type",
1429
- expected: "object",
1430
- input,
1431
- inst,
1432
- });
1433
- return payload;
1434
- }
1435
- const value = input?.[def.discriminator];
1436
- const opt = disc.value.get(value);
1437
- // forward metadata cannot choose an encoder for an absent tag
1438
- if (opt && (value !== undefined || ctx.direction !== "backward")) {
1439
- return opt._zod.run(payload, ctx);
1440
- }
1441
- // Fall back to union matching when the fast discriminator path fails:
1442
- // - explicitly enabled via unionFallback, or
1443
- // - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
1444
- if (def.unionFallback || ctx.direction === "backward") {
1445
- return _super(payload, ctx);
1446
- }
1447
- // no matching discriminator
1448
- payload.issues.push({
1449
- code: "invalid_union",
1450
- errors: [],
1451
- note: "No matching discriminator",
1452
- discriminator: def.discriminator,
1453
- options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
1454
- input,
1455
- path: [def.discriminator],
1456
- inst,
1457
- });
1458
- return payload;
1459
- };
1460
- });
1461
- export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersection", (inst, def) => {
1462
- $ZodType.init(inst, def);
1463
- inst._zod.parse = (payload, ctx) => {
1464
- const input = payload.value;
1465
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1466
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1467
- const async = left instanceof Promise || right instanceof Promise;
1468
- if (async) {
1469
- return Promise.all([left, right]).then(([left, right]) => {
1470
- return handleIntersectionResults(payload, left, right);
1471
- });
1472
- }
1473
- return handleIntersectionResults(payload, left, right);
1474
- };
1475
- });
1476
- export function mergeValues(a, b) {
1477
- // const aType = parse.t(a);
1478
- // const bType = parse.t(b);
1479
- if (a === b) {
1480
- return { valid: true, data: a };
1481
- }
1482
- if (a instanceof Date && b instanceof Date && +a === +b) {
1483
- return { valid: true, data: a };
1484
- }
1485
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
1486
- const bKeys = Object.keys(b);
1487
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1488
- const newObj = { ...a, ...b };
1489
- if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
1490
- delete newObj.__proto__;
1491
- for (const key of sharedKeys) {
1492
- if (key === "__proto__")
1493
- continue;
1494
- const sharedValue = mergeValues(a[key], b[key]);
1495
- if (!sharedValue.valid) {
1496
- return {
1497
- valid: false,
1498
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
1499
- };
1500
- }
1501
- newObj[key] = sharedValue.data;
1502
- }
1503
- return { valid: true, data: newObj };
1504
- }
1505
- if (Array.isArray(a) && Array.isArray(b)) {
1506
- if (a.length !== b.length) {
1507
- return { valid: false, mergeErrorPath: [] };
1508
- }
1509
- const newArray = [];
1510
- for (let index = 0; index < a.length; index++) {
1511
- const itemA = a[index];
1512
- const itemB = b[index];
1513
- const sharedValue = mergeValues(itemA, itemB);
1514
- if (!sharedValue.valid) {
1515
- return {
1516
- valid: false,
1517
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
1518
- };
1519
- }
1520
- newArray.push(sharedValue.data);
1521
- }
1522
- return { valid: true, data: newArray };
1523
- }
1524
- return { valid: false, mergeErrorPath: [] };
1525
- }
1526
- function handleIntersectionResults(result, left, right) {
1527
- // Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
1528
- const unrecKeys = new Map();
1529
- let unrecIssue;
1530
- const keyIssues = new Map();
1531
- const collect = (iss, side) => {
1532
- let keys;
1533
- if (iss.code === "unrecognized_keys" && !iss.path?.length) {
1534
- unrecIssue ?? (unrecIssue = iss);
1535
- keys = iss.keys;
1536
- }
1537
- else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
1538
- const k = String(iss.path[0]);
1539
- if (!keyIssues.has(k))
1540
- keyIssues.set(k, iss);
1541
- keys = [k];
1542
- }
1543
- else {
1544
- return false;
1545
- }
1546
- for (const k of keys) {
1547
- if (!unrecKeys.has(k))
1548
- unrecKeys.set(k, {});
1549
- unrecKeys.get(k)[side] = true;
1550
- }
1551
- return true;
1552
- };
1553
- for (const iss of left.issues) {
1554
- if (!collect(iss, "l"))
1555
- result.issues.push(iss);
1556
- }
1557
- for (const iss of right.issues) {
1558
- if (!collect(iss, "r"))
1559
- result.issues.push(iss);
1560
- }
1561
- // Report only keys rejected by BOTH sides
1562
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1563
- if (bothKeys.length) {
1564
- const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
1565
- if (aggregated.length)
1566
- result.issues.push({ ...unrecIssue, keys: aggregated });
1567
- for (const k of bothKeys) {
1568
- if (!aggregated.includes(k) && keyIssues.has(k))
1569
- result.issues.push(keyIssues.get(k));
1570
- }
1571
- }
1572
- const merged = mergeValues(left.value, right.value);
1573
- if (!merged.valid) {
1574
- if (util.aborted(result))
1575
- return result;
1576
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1577
- }
1578
- result.value = merged.data;
1579
- return result;
1580
- }
1581
- export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
1582
- $ZodType.init(inst, def);
1583
- const items = def.items;
1584
- const memo = core.globalConfig.memoizer;
1585
- memo?.attach(inst);
1586
- inst._zod.parse = (payload, ctx) => {
1587
- const input = payload.value;
1588
- if (!Array.isArray(input)) {
1589
- payload.issues.push({
1590
- input,
1591
- inst,
1592
- expected: "tuple",
1593
- code: "invalid_type",
1594
- });
1595
- return payload;
1596
- }
1597
- payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
1598
- const proms = [];
1599
- const optinStart = getTupleOptStart(items, "optin");
1600
- const optoutStart = getTupleOptStart(items, "optout");
1601
- if (!def.rest) {
1602
- if (input.length < optinStart) {
1603
- payload.issues.push({
1604
- code: "too_small",
1605
- minimum: optinStart,
1606
- inclusive: true,
1607
- input,
1608
- inst,
1609
- origin: "array",
1610
- });
1611
- return payload;
1612
- }
1613
- if (input.length > items.length) {
1614
- payload.issues.push({
1615
- code: "too_big",
1616
- maximum: items.length,
1617
- inclusive: true,
1618
- input,
1619
- inst,
1620
- origin: "array",
1621
- });
1622
- }
1623
- }
1624
- // Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
1625
- const itemResults = new Array(items.length);
1626
- // only tracked when there is a rest loop to skip
1627
- const abortEarly = def.rest ? ctx?.abortEarly : undefined;
1628
- let itemAborted = false;
1629
- for (let i = 0; i < items.length; i++) {
1630
- const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
1631
- if (r instanceof Promise) {
1632
- proms.push(r.then((rr) => {
1633
- itemResults[i] = rr;
1634
- }));
1635
- }
1636
- else {
1637
- itemResults[i] = r;
1638
- if (abortEarly && !itemAborted && r.issues.length)
1639
- itemAborted = util.aborted(r);
1640
- }
1641
- }
1642
- // sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
1643
- if (def.rest && !itemAborted) {
1644
- let i = items.length - 1;
1645
- const rest = input.slice(items.length);
1646
- let seen = payload.issues.length;
1647
- for (const el of rest) {
1648
- if (abortEarly && payload.issues.length !== seen) {
1649
- if (util.aborted(payload, seen))
1650
- break;
1651
- seen = payload.issues.length;
1652
- }
1653
- i++;
1654
- const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
1655
- if (result instanceof Promise) {
1656
- proms.push(result.then((r) => handleTupleResult(r, payload, i)));
1657
- }
1658
- else {
1659
- handleTupleResult(result, payload, i);
1660
- }
1661
- }
1662
- }
1663
- if (proms.length) {
1664
- return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
1665
- }
1666
- return handleTupleResults(itemResults, payload, items, input, optoutStart);
1667
- };
1668
- });
1669
- function getTupleOptStart(items, key) {
1670
- for (let i = items.length - 1; i >= 0; i--) {
1671
- // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1672
- const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
1673
- if (!omittable)
1674
- return i + 1;
1675
- }
1676
- return 0;
1677
- }
1678
- function handleTupleResult(result, final, index) {
1679
- if (result.issues.length) {
1680
- final.issues.push(...util.prefixIssues(index, result.issues));
1681
- }
1682
- final.value[index] = result.value;
1683
- }
1684
- function handleTupleResults(itemResults, final, items, input, optoutStart) {
1685
- // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
1686
- for (let i = 0; i < items.length; i++) {
1687
- const r = itemResults[i];
1688
- const isPresent = i < input.length;
1689
- // The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
1690
- if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
1691
- final.value.length = i;
1692
- break;
1693
- }
1694
- if (r.issues.length) {
1695
- if (!isPresent && i >= optoutStart) {
1696
- final.value.length = i;
1697
- break;
1698
- }
1699
- final.issues.push(...util.prefixIssues(i, r.issues));
1700
- }
1701
- final.value[i] = r.value;
1702
- }
1703
- // Drop trailing slots that produced `undefined` for absent input
1704
- // (the array analog of an absent optional key on an object). The
1705
- // `i >= input.length` floor is critical: an explicit `undefined`
1706
- // *inside* the input must be preserved even when the schema is
1707
- // optional-out (e.g. `z.string().or(z.undefined())` accepting an
1708
- // explicit undefined value).
1709
- for (let i = final.value.length - 1; i >= input.length; i--) {
1710
- if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
1711
- final.value.length = i;
1712
- }
1713
- else {
1714
- break;
1715
- }
1716
- }
1717
- return final;
1718
- }
1719
- export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
1720
- $ZodType.init(inst, def);
1721
- const memo = core.globalConfig.memoizer;
1722
- memo?.attach(inst);
1723
- inst._zod.parse = (payload, ctx) => {
1724
- const input = payload.value;
1725
- if (!util.isPlainObject(input)) {
1726
- payload.issues.push({
1727
- expected: "record",
1728
- code: "invalid_type",
1729
- input,
1730
- inst,
1731
- });
1732
- return payload;
1733
- }
1734
- // no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
1735
- const proms = [];
1736
- const values = def.keyType._zod.values;
1737
- if (values && !def.partial) {
1738
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1739
- const recordKeys = new Set();
1740
- for (const key of values) {
1741
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1742
- recordKeys.add(typeof key === "number" ? key.toString() : key);
1743
- // A declared __proto__ is stripped but is not an unrecognized key.
1744
- if (key === "__proto__")
1745
- continue;
1746
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1747
- if (keyResult instanceof Promise) {
1748
- throw new Error("Async schemas not supported in object keys currently");
1749
- }
1750
- if (keyResult.issues.length) {
1751
- payload.issues.push({
1752
- code: "invalid_key",
1753
- origin: "record",
1754
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1755
- input: key,
1756
- path: [key],
1757
- inst,
1758
- });
1759
- continue;
1760
- }
1761
- const outKey = keyResult.value;
1762
- if (outKey === "__proto__")
1763
- continue;
1764
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1765
- if (result instanceof Promise) {
1766
- proms.push(result.then((result) => {
1767
- if (result.issues.length) {
1768
- payload.issues.push(...util.prefixIssues(key, result.issues));
1769
- }
1770
- payload.value[outKey] = result.value;
1771
- }));
1772
- }
1773
- else {
1774
- if (result.issues.length) {
1775
- payload.issues.push(...util.prefixIssues(key, result.issues));
1776
- }
1777
- payload.value[outKey] = result.value;
1778
- }
1779
- }
1780
- }
1781
- let unrecognized;
1782
- for (const key in input) {
1783
- if (!recordKeys.has(key)) {
1784
- if (def.mode === "loose") {
1785
- // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
1786
- if (key === "__proto__")
1787
- continue;
1788
- payload.value[key] = input[key];
1789
- }
1790
- else {
1791
- unrecognized = unrecognized ?? [];
1792
- unrecognized.push(key);
1793
- }
1794
- }
1795
- }
1796
- if (unrecognized && unrecognized.length > 0) {
1797
- payload.issues.push({
1798
- code: "unrecognized_keys",
1799
- input,
1800
- inst,
1801
- keys: unrecognized,
1802
- continue: true,
1803
- });
1804
- }
1805
- }
1806
- else {
1807
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1808
- // An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
1809
- let unrecognized;
1810
- // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
1811
- for (const key of Reflect.ownKeys(input)) {
1812
- if (key === "__proto__")
1813
- continue;
1814
- if (!Object.prototype.propertyIsEnumerable.call(input, key))
1815
- continue;
1816
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1817
- if (keyResult instanceof Promise) {
1818
- throw new Error("Async schemas not supported in object keys currently");
1819
- }
1820
- // Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
1821
- const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
1822
- if (checkNumericKey) {
1823
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
1824
- if (retryResult instanceof Promise) {
1825
- throw new Error("Async schemas not supported in object keys currently");
1826
- }
1827
- if (retryResult.issues.length === 0) {
1828
- keyResult = retryResult;
1829
- }
1830
- }
1831
- if (keyResult.issues.length) {
1832
- if (def.mode === "loose") {
1833
- // Pass through unchanged
1834
- payload.value[key] = input[key];
1835
- }
1836
- else if (values) {
1837
- unrecognized = unrecognized ?? [];
1838
- unrecognized.push(key);
1839
- }
1840
- else {
1841
- // Default "strict" behavior: error on invalid key
1842
- payload.issues.push({
1843
- code: "invalid_key",
1844
- origin: "record",
1845
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1846
- input: key,
1847
- path: [key],
1848
- inst,
1849
- });
1850
- }
1851
- continue;
1852
- }
1853
- // the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
1854
- const outKey = keyResult.value;
1855
- if (outKey === "__proto__")
1856
- continue;
1857
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1858
- if (result instanceof Promise) {
1859
- proms.push(result.then((result) => {
1860
- if (result.issues.length) {
1861
- payload.issues.push(...util.prefixIssues(key, result.issues));
1862
- }
1863
- payload.value[outKey] = result.value;
1864
- }));
1865
- }
1866
- else {
1867
- if (result.issues.length) {
1868
- payload.issues.push(...util.prefixIssues(key, result.issues));
1869
- }
1870
- payload.value[outKey] = result.value;
1871
- }
1872
- }
1873
- if (unrecognized && unrecognized.length > 0) {
1874
- payload.issues.push({
1875
- code: "unrecognized_keys",
1876
- input,
1877
- inst,
1878
- keys: unrecognized,
1879
- continue: true,
1880
- });
1881
- }
1882
- }
1883
- if (proms.length) {
1884
- return Promise.all(proms).then(() => payload);
1885
- }
1886
- return payload;
1887
- };
1888
- });
1889
- export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
1890
- $ZodType.init(inst, def);
1891
- const memo = core.globalConfig.memoizer;
1892
- memo?.attach(inst);
1893
- inst._zod.parse = (payload, ctx) => {
1894
- const input = payload.value;
1895
- if (!(input instanceof Map)) {
1896
- payload.issues.push({
1897
- expected: "map",
1898
- code: "invalid_type",
1899
- input,
1900
- inst,
1901
- });
1902
- return payload;
1903
- }
1904
- const proms = [];
1905
- payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
1906
- const abortEarly = ctx?.abortEarly;
1907
- let seen = payload.issues.length;
1908
- for (const [key, value] of input) {
1909
- if (abortEarly && payload.issues.length !== seen) {
1910
- if (util.aborted(payload, seen))
1911
- break;
1912
- seen = payload.issues.length;
1913
- }
1914
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1915
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1916
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
1917
- proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
1918
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1919
- }));
1920
- }
1921
- else {
1922
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1923
- }
1924
- }
1925
- if (proms.length)
1926
- return Promise.all(proms).then(() => payload);
1927
- return payload;
1928
- };
1929
- capSize(inst, mapSize);
1930
- });
1931
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1932
- if (keyResult.issues.length) {
1933
- if (util.propertyKeyTypes.has(typeof key)) {
1934
- final.issues.push(...util.prefixIssues(key, keyResult.issues));
1935
- }
1936
- else {
1937
- final.issues.push({
1938
- code: "invalid_key",
1939
- origin: "map",
1940
- input,
1941
- inst,
1942
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1943
- });
1944
- }
1945
- }
1946
- if (valueResult.issues.length) {
1947
- if (util.propertyKeyTypes.has(typeof key)) {
1948
- final.issues.push(...util.prefixIssues(key, valueResult.issues));
1949
- }
1950
- else {
1951
- final.issues.push({
1952
- origin: "map",
1953
- code: "invalid_element",
1954
- input,
1955
- inst,
1956
- key: key,
1957
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1958
- });
1959
- }
1960
- }
1961
- final.value.set(keyResult.value, valueResult.value);
1962
- }
1963
- export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
1964
- $ZodType.init(inst, def);
1965
- const memo = core.globalConfig.memoizer;
1966
- memo?.attach(inst);
1967
- inst._zod.parse = (payload, ctx) => {
1968
- const input = payload.value;
1969
- if (!(input instanceof Set)) {
1970
- payload.issues.push({
1971
- input,
1972
- inst,
1973
- expected: "set",
1974
- code: "invalid_type",
1975
- });
1976
- return payload;
1977
- }
1978
- const proms = [];
1979
- payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
1980
- const abortEarly = ctx?.abortEarly;
1981
- let seen = payload.issues.length;
1982
- for (const item of input) {
1983
- if (abortEarly && payload.issues.length !== seen) {
1984
- if (util.aborted(payload, seen))
1985
- break;
1986
- seen = payload.issues.length;
1987
- }
1988
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
1989
- if (result instanceof Promise) {
1990
- proms.push(result.then((result) => handleSetResult(result, payload)));
1991
- }
1992
- else
1993
- handleSetResult(result, payload);
1994
- }
1995
- if (proms.length)
1996
- return Promise.all(proms).then(() => payload);
1997
- return payload;
1998
- };
1999
- capSize(inst, setSize);
2000
- });
2001
- function handleSetResult(result, final) {
2002
- if (result.issues.length) {
2003
- final.issues.push(...result.issues);
2004
- }
2005
- final.value.add(result.value);
2006
- }
2007
- export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
2008
- $ZodType.init(inst, def);
2009
- const values = util.getEnumValues(def.entries);
2010
- const valuesSet = new Set(values);
2011
- inst._zod.values = valuesSet;
2012
- util.defineLazyInternal(inst, "pattern", (zod) => {
2013
- const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
2014
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2015
- return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2016
- });
2017
- inst._zod.parse = (payload, _ctx) => {
2018
- const input = payload.value;
2019
- if (valuesSet.has(input)) {
2020
- return payload;
2021
- }
2022
- payload.issues.push({
2023
- code: "invalid_value",
2024
- values,
2025
- input,
2026
- inst,
2027
- });
2028
- return payload;
2029
- };
2030
- });
2031
- export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
2032
- $ZodType.init(inst, def);
2033
- const values = new Set(def.values);
2034
- inst._zod.values = values;
2035
- util.defineLazyInternal(inst, "pattern", (zod) => {
2036
- const vals = zod.def.values;
2037
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2038
- return new RegExp(vals.length
2039
- ? `^(${vals
2040
- .map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
2041
- .join("|")})$`
2042
- : "^[^\\s\\S]$");
2043
- });
2044
- inst._zod.parse = (payload, _ctx) => {
2045
- const input = payload.value;
2046
- if (values.has(input)) {
2047
- return payload;
2048
- }
2049
- payload.issues.push({
2050
- code: "invalid_value",
2051
- values: def.values,
2052
- input,
2053
- inst,
2054
- });
2055
- return payload;
2056
- };
2057
- });
2058
- export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
2059
- $ZodType.init(inst, def);
2060
- inst._zod.parse = (payload, _ctx) => {
2061
- const input = payload.value;
2062
- // @ts-ignore
2063
- if (input instanceof File)
2064
- return payload;
2065
- payload.issues.push({
2066
- expected: "file",
2067
- code: "invalid_type",
2068
- input,
2069
- inst,
2070
- });
2071
- return payload;
2072
- };
2073
- });
2074
- export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
2075
- $ZodType.init(inst, def);
2076
- inst._zod.optin = "optional";
2077
- core.globalConfig.memoizer?.guard(inst);
2078
- inst._zod.parse = (payload, ctx) => {
2079
- if (ctx.direction === "backward") {
2080
- throw new core.$ZodEncodeError(inst.constructor.name);
2081
- }
2082
- const _out = def.transform(payload.value, payload);
2083
- if (ctx.async) {
2084
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2085
- return output.then((output) => {
2086
- payload.value = output;
2087
- return payload;
2088
- });
2089
- }
2090
- if (_out instanceof Promise) {
2091
- throw new core.$ZodAsyncError();
2092
- }
2093
- payload.value = _out;
2094
- return payload;
2095
- };
2096
- });
2097
- function handleOptionalResult(payload, result) {
2098
- // A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
2099
- payload.value = result.issues.length ? undefined : result.value;
2100
- return payload;
2101
- }
2102
- export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
2103
- $ZodType.init(inst, def);
2104
- // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
2105
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2106
- inst._zod.optout = "optional";
2107
- util.defineLazyInternal(inst, "values", (zod) => {
2108
- const values = zod.def.innerType._zod.values;
2109
- return values ? new Set([...values, undefined]) : undefined;
2110
- });
2111
- util.defineLazyInternal(inst, "pattern", (zod) => {
2112
- const pattern = zod.def.innerType._zod.pattern;
2113
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
2114
- });
2115
- inst._zod.parse = (payload, ctx) => {
2116
- if (payload.value === undefined) {
2117
- // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
2118
- if (def.innerType._zod.optin !== "defaulted")
2119
- return payload;
2120
- // Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
2121
- const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2122
- if (result instanceof Promise)
2123
- return result.then((result) => handleOptionalResult(payload, result));
2124
- return handleOptionalResult(payload, result);
2125
- }
2126
- return def.innerType._zod.run(payload, ctx);
2127
- };
2128
- });
2129
- export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptional", (inst, def) => {
2130
- // Call parent init - inherits optin/optout = "optional"
2131
- $ZodOptional.init(inst, def);
2132
- // Override values/pattern to NOT add undefined
2133
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2134
- util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2135
- // Override parse to just delegate (no undefined handling)
2136
- inst._zod.parse = (payload, ctx) => {
2137
- return def.innerType._zod.run(payload, ctx);
2138
- };
2139
- });
2140
- export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
2141
- $ZodType.init(inst, def);
2142
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2143
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2144
- util.defineLazyInternal(inst, "pattern", (zod) => {
2145
- const pattern = zod.def.innerType._zod.pattern;
2146
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
2147
- });
2148
- util.defineLazyInternal(inst, "values", (zod) => {
2149
- return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
2150
- });
2151
- inst._zod.parse = (payload, ctx) => {
2152
- // Forward direction (decode): allow null to pass through
2153
- if (payload.value === null)
2154
- return payload;
2155
- return def.innerType._zod.run(payload, ctx);
2156
- };
2157
- });
2158
- export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
2159
- $ZodType.init(inst, def);
2160
- // inst._zod.qin = "true";
2161
- inst._zod.optin = "defaulted";
2162
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2163
- inst._zod.parse = (payload, ctx) => {
2164
- if (ctx.direction === "backward") {
2165
- return def.innerType._zod.run(payload, ctx);
2166
- }
2167
- // Forward direction (decode): apply defaults for undefined input
2168
- if (payload.value === undefined) {
2169
- payload.value = def.defaultValue;
2170
- /**
2171
- * $ZodDefault returns the default value immediately in forward direction.
2172
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2173
- return payload;
2174
- }
2175
- // Forward direction: continue with default handling
2176
- const result = def.innerType._zod.run(payload, ctx);
2177
- if (result instanceof Promise) {
2178
- return result.then((result) => handleDefaultResult(result, def));
2179
- }
2180
- return handleDefaultResult(result, def);
2181
- };
2182
- });
2183
- function handleDefaultResult(payload, def) {
2184
- if (payload.value === undefined) {
2185
- payload.value = def.defaultValue;
2186
- }
2187
- return payload;
2188
- }
2189
- export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
2190
- $ZodType.init(inst, def);
2191
- inst._zod.optin = "defaulted";
2192
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2193
- inst._zod.parse = (payload, ctx) => {
2194
- if (ctx.direction === "backward") {
2195
- return def.innerType._zod.run(payload, ctx);
2196
- }
2197
- // Forward direction (decode): apply prefault for undefined input
2198
- if (payload.value === undefined) {
2199
- payload.value = def.defaultValue;
2200
- }
2201
- return def.innerType._zod.run(payload, ctx);
2202
- };
2203
- });
2204
- export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
2205
- $ZodType.init(inst, def);
2206
- util.defineLazyInternal(inst, "values", (zod) => {
2207
- const v = zod.def.innerType._zod.values;
2208
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
2209
- });
2210
- inst._zod.parse = (payload, ctx) => {
2211
- const result = def.innerType._zod.run(payload, ctx);
2212
- if (result instanceof Promise) {
2213
- return result.then((result) => handleNonOptionalResult(result, inst));
2214
- }
2215
- return handleNonOptionalResult(result, inst);
2216
- };
2217
- });
2218
- function handleNonOptionalResult(payload, inst) {
2219
- if (!payload.issues.length && payload.value === undefined) {
2220
- payload.issues.push({
2221
- code: "invalid_type",
2222
- expected: "nonoptional",
2223
- input: payload.value,
2224
- inst,
2225
- });
2226
- }
2227
- return payload;
2228
- }
2229
- export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst, def) => {
2230
- $ZodType.init(inst, def);
2231
- inst._zod.parse = (payload, ctx) => {
2232
- if (ctx.direction === "backward") {
2233
- throw new core.$ZodEncodeError("ZodSuccess");
2234
- }
2235
- const result = def.innerType._zod.run(payload, ctx);
2236
- if (result instanceof Promise) {
2237
- return result.then((result) => {
2238
- payload.value = result.issues.length === 0;
2239
- return payload;
2240
- });
2241
- }
2242
- payload.value = result.issues.length === 0;
2243
- return payload;
2244
- };
2245
- });
2246
- function handleCatchResult(payload, result, def, ctx) {
2247
- if (!result.issues.length) {
2248
- payload.value = result.value;
2249
- // The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
2250
- if (result.memo)
2251
- payload.memo = true;
2252
- return payload;
2253
- }
2254
- // Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
2255
- payload.value = def.catchValue({
2256
- ...result,
2257
- value: payload.value,
2258
- error: {
2259
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2260
- },
2261
- input: payload.value,
2262
- });
2263
- return payload;
2264
- }
2265
- export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
2266
- $ZodType.init(inst, def);
2267
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2268
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2269
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2270
- inst._zod.parse = (payload, ctx) => {
2271
- if (ctx.direction === "backward") {
2272
- return def.innerType._zod.run(payload, ctx);
2273
- }
2274
- // Forward direction (decode): apply catch logic
2275
- const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2276
- if (result instanceof Promise) {
2277
- return result.then((result) => handleCatchResult(payload, result, def, ctx));
2278
- }
2279
- return handleCatchResult(payload, result, def, ctx);
2280
- };
2281
- });
2282
- export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
2283
- $ZodType.init(inst, def);
2284
- inst._zod.parse = (payload, _ctx) => {
2285
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
2286
- payload.issues.push({
2287
- input: payload.value,
2288
- inst,
2289
- expected: "nan",
2290
- code: "invalid_type",
2291
- });
2292
- return payload;
2293
- }
2294
- return payload;
2295
- };
2296
- });
2297
- export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
2298
- $ZodType.init(inst, def);
2299
- util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2300
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2301
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2302
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2303
- inst._zod.parse = (payload, ctx) => {
2304
- if (ctx.direction === "backward") {
2305
- const right = def.out._zod.run(payload, ctx);
2306
- if (right instanceof Promise) {
2307
- return right.then((right) => handlePipeResult(right, def.in, ctx));
2308
- }
2309
- return handlePipeResult(right, def.in, ctx);
2310
- }
2311
- const left = def.in._zod.run(payload, ctx);
2312
- if (left instanceof Promise) {
2313
- return left.then((left) => handlePipeResult(left, def.out, ctx));
2314
- }
2315
- return handlePipeResult(left, def.out, ctx);
2316
- };
2317
- });
2318
- function handlePipeResult(left, next, ctx) {
2319
- // Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
2320
- if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2321
- // prevent further checks
2322
- left.aborted = true;
2323
- return left;
2324
- }
2325
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2326
- }
2327
- export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
2328
- $ZodType.init(inst, def);
2329
- util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2330
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2331
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2332
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2333
- inst._zod.parse = (payload, ctx) => {
2334
- const direction = ctx.direction || "forward";
2335
- if (direction === "forward") {
2336
- const left = def.in._zod.run(payload, ctx);
2337
- if (left instanceof Promise) {
2338
- return left.then((left) => handleCodecAResult(left, def, ctx));
2339
- }
2340
- return handleCodecAResult(left, def, ctx);
2341
- }
2342
- else {
2343
- const right = def.out._zod.run(payload, ctx);
2344
- if (right instanceof Promise) {
2345
- return right.then((right) => handleCodecAResult(right, def, ctx));
2346
- }
2347
- return handleCodecAResult(right, def, ctx);
2348
- }
2349
- };
2350
- });
2351
- function handleCodecAResult(result, def, ctx) {
2352
- if (result.issues.length) {
2353
- // prevent further checks
2354
- result.aborted = true;
2355
- return result;
2356
- }
2357
- const direction = ctx.direction || "forward";
2358
- if (direction === "forward") {
2359
- const transformed = def.transform(result.value, result);
2360
- if (transformed instanceof Promise) {
2361
- return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
2362
- }
2363
- return handleCodecTxResult(result, transformed, def.out, ctx);
2364
- }
2365
- else {
2366
- const transformed = def.reverseTransform(result.value, result);
2367
- if (transformed instanceof Promise) {
2368
- return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
2369
- }
2370
- return handleCodecTxResult(result, transformed, def.in, ctx);
2371
- }
2372
- }
2373
- function handleCodecTxResult(left, value, nextSchema, ctx) {
2374
- // Check if transform added any issues
2375
- if (left.issues.length) {
2376
- left.aborted = true;
2377
- return left;
2378
- }
2379
- return nextSchema._zod.run({ value, issues: left.issues }, ctx);
2380
- }
2381
- export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess", (inst, def) => {
2382
- $ZodPipe.init(inst, def);
2383
- });
2384
- export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
2385
- $ZodType.init(inst, def);
2386
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2387
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2388
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2389
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2390
- inst._zod.parse = (payload, ctx) => {
2391
- if (ctx.direction === "backward") {
2392
- return def.innerType._zod.run(payload, ctx);
2393
- }
2394
- const result = def.innerType._zod.run(payload, ctx);
2395
- if (result instanceof Promise) {
2396
- return result.then(handleReadonlyResult);
2397
- }
2398
- return handleReadonlyResult(result);
2399
- };
2400
- });
2401
- function handleReadonlyResult(payload) {
2402
- // A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
2403
- if (!payload.memo)
2404
- payload.value = Object.freeze(payload.value);
2405
- return payload;
2406
- }
2407
- // a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
2408
- function leafPattern(schema) {
2409
- const def = schema._zod.def;
2410
- let pattern = def.pattern;
2411
- let isInt = !!def.format?.includes("int");
2412
- let minimum;
2413
- let maximum;
2414
- for (const ch of def.checks ?? []) {
2415
- const d = ch._zod.def;
2416
- if (d.pattern)
2417
- pattern = d.pattern;
2418
- isInt || (isInt = !!d.format?.includes("int"));
2419
- const lo = d.minimum ?? d.length;
2420
- const hi = d.maximum ?? d.length;
2421
- if (lo !== undefined && (minimum === undefined || lo > minimum))
2422
- minimum = lo;
2423
- if (hi !== undefined && (maximum === undefined || hi < maximum))
2424
- maximum = hi;
2425
- }
2426
- if (pattern)
2427
- return pattern.source;
2428
- // an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
2429
- if (minimum !== undefined && maximum !== undefined && minimum > maximum)
2430
- return "(?!)";
2431
- if (minimum !== undefined || maximum !== undefined)
2432
- return regexes.string({ minimum, maximum }).source;
2433
- const own = schema._zod.pattern;
2434
- return (isInt && own === regexes.number ? regexes.integer : own)?.source;
2435
- }
2436
- // a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
2437
- function partPattern(schema) {
2438
- const def = schema._zod.def;
2439
- const own = schema._zod.pattern?.source;
2440
- // lazy resolves its inner on the internals, not the def
2441
- const inner = def.innerType ?? schema._zod.innerType;
2442
- if (inner) {
2443
- const before = inner._zod.pattern?.source;
2444
- const after = partPattern(inner);
2445
- if (own && before && after && after !== before) {
2446
- return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
2447
- }
2448
- return own;
2449
- }
2450
- if (def.options) {
2451
- const sources = def.options.map(partPattern);
2452
- if (sources.every(Boolean))
2453
- return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
2454
- }
2455
- return leafPattern(schema);
2456
- }
2457
- export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
2458
- $ZodType.init(inst, def);
2459
- const regexParts = [];
2460
- for (const part of def.parts) {
2461
- if (typeof part === "object" && part !== null) {
2462
- // is Zod schema
2463
- const source = partPattern(part);
2464
- if (!source) {
2465
- throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
2466
- }
2467
- regexParts.push(util.cleanRegex(source));
2468
- }
2469
- else if (part === null || util.primitiveTypes.has(typeof part)) {
2470
- regexParts.push(util.escapeRegex(`${part}`));
2471
- }
2472
- else {
2473
- throw new Error(`Invalid template literal part: ${part}`);
2474
- }
2475
- }
2476
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
2477
- inst._zod.parse = (payload, _ctx) => {
2478
- if (typeof payload.value !== "string") {
2479
- payload.issues.push({
2480
- input: payload.value,
2481
- inst,
2482
- expected: "string",
2483
- code: "invalid_type",
2484
- });
2485
- return payload;
2486
- }
2487
- inst._zod.pattern.lastIndex = 0;
2488
- if (!inst._zod.pattern.test(payload.value)) {
2489
- payload.issues.push({
2490
- input: payload.value,
2491
- inst,
2492
- code: "invalid_format",
2493
- format: def.format ?? "template_literal",
2494
- pattern: inst._zod.pattern.source,
2495
- });
2496
- return payload;
2497
- }
2498
- return payload;
2499
- };
2500
- });
2501
- export const $ZodFunction = /*@__PURE__*/ core.$constructor("$ZodFunction", (inst, def) => {
2502
- $ZodType.init(inst, def);
2503
- // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
2504
- Object.defineProperty(inst, "_def", { value: def });
2505
- inst._zod.def = def;
2506
- inst.implement = (func) => {
2507
- if (typeof func !== "function") {
2508
- throw new Error("implement() must be called with a function");
2509
- }
2510
- // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
2511
- return Object.defineProperty(function (...args) {
2512
- const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
2513
- const result = Reflect.apply(func, this, parsedArgs);
2514
- if (inst._def.output) {
2515
- return parse(inst._def.output, result);
2516
- }
2517
- return result;
2518
- }, "_zod", { value: inst._zod, enumerable: false });
2519
- };
2520
- inst.implementAsync = (func) => {
2521
- if (typeof func !== "function") {
2522
- throw new Error("implementAsync() must be called with a function");
2523
- }
2524
- return Object.defineProperty(async function (...args) {
2525
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
2526
- const result = await Reflect.apply(func, this, parsedArgs);
2527
- if (inst._def.output) {
2528
- return await parseAsync(inst._def.output, result);
2529
- }
2530
- return result;
2531
- }, "_zod", { value: inst._zod, enumerable: false });
2532
- };
2533
- inst._zod.parse = (payload, _ctx) => {
2534
- if (typeof payload.value !== "function") {
2535
- payload.issues.push({
2536
- code: "invalid_type",
2537
- expected: "function",
2538
- input: payload.value,
2539
- inst,
2540
- });
2541
- return payload;
2542
- }
2543
- // Check if output is a promise type to determine if we should use async implementation
2544
- const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
2545
- if (hasPromiseOutput) {
2546
- payload.value = inst.implementAsync(payload.value);
2547
- }
2548
- else {
2549
- payload.value = inst.implement(payload.value);
2550
- }
2551
- return payload;
2552
- };
2553
- inst.input = (...args) => {
2554
- const F = inst.constructor;
2555
- if (Array.isArray(args[0])) {
2556
- return new F({
2557
- type: "function",
2558
- input: new $ZodTuple({
2559
- type: "tuple",
2560
- items: args[0],
2561
- rest: args[1],
2562
- }),
2563
- output: inst._def.output,
2564
- });
2565
- }
2566
- return new F({
2567
- type: "function",
2568
- input: args[0],
2569
- output: inst._def.output,
2570
- });
2571
- };
2572
- inst.output = (output) => {
2573
- const F = inst.constructor;
2574
- return new F({
2575
- type: "function",
2576
- input: inst._def.input,
2577
- output,
2578
- });
2579
- };
2580
- return inst;
2581
- });
2582
- export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst, def) => {
2583
- $ZodType.init(inst, def);
2584
- inst._zod.parse = (payload, ctx) => {
2585
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
2586
- };
2587
- });
2588
- export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
2589
- $ZodType.init(inst, def);
2590
- // Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
2591
- util.defineLazy(inst._zod, "innerType", () => {
2592
- const d = def;
2593
- if (!d._cachedInner)
2594
- d._cachedInner = def.getter();
2595
- return d._cachedInner;
2596
- });
2597
- util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
2598
- util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
2599
- util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
2600
- util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
2601
- inst._zod.parse = (payload, ctx) => {
2602
- const inner = inst._zod.innerType;
2603
- return inner._zod.run(payload, ctx);
2604
- };
2605
- });
2606
- export const $ZodCustom = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
2607
- checks.$ZodCheck.init(inst, def);
2608
- $ZodType.init(inst, def);
2609
- inst._zod.parse = (payload, _) => {
2610
- return payload;
2611
- };
2612
- inst._zod.check = (payload) => {
2613
- const input = payload.value;
2614
- const r = def.fn(input);
2615
- if (r instanceof Promise) {
2616
- return r.then((r) => handleRefineResult(r, payload, input, inst));
2617
- }
2618
- handleRefineResult(r, payload, input, inst);
2619
- return;
2620
- };
2621
- });
2622
- function handleRefineResult(result, payload, input, inst) {
2623
- if (!result) {
2624
- const _iss = {
2625
- code: "custom",
2626
- input,
2627
- inst, // incorporates params.error into issue reporting
2628
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
2629
- continue: !inst._zod.def.abort,
2630
- // params: inst._zod.def.params,
2631
- };
2632
- if (inst._zod.def.params)
2633
- _iss.params = inst._zod.def.params;
2634
- payload.issues.push(util.issue(_iss));
2635
- }
2636
- }