fullstacked 0.12.0-1173 → 0.12.0-1184

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 (500) hide show
  1. package/fullstacked_modules/@fullstacked/ai-agent/README.md +1 -0
  2. package/fullstacked_modules/@fullstacked/ai-agent/chat.json +1 -0
  3. package/fullstacked_modules/@fullstacked/ai-agent/index.scss +15 -0
  4. package/fullstacked_modules/@fullstacked/ai-agent/index.ts +92 -0
  5. package/fullstacked_modules/@fullstacked/ai-agent/lock.json +726 -0
  6. package/fullstacked_modules/@fullstacked/ai-agent/package.json +15 -0
  7. package/fullstacked_modules/@fullstacked/ai-agent/src/conversation.ts +169 -0
  8. package/fullstacked_modules/@fullstacked/ai-agent/src/default.scss +23 -0
  9. package/fullstacked_modules/@fullstacked/ai-agent/src/index.ts +3 -0
  10. package/fullstacked_modules/@fullstacked/ai-agent/src/input.ts +36 -0
  11. package/fullstacked_modules/@fullstacked/ai-agent/src/markdown.ts +46 -0
  12. package/fullstacked_modules/@fullstacked/ai-agent/src/providers/interface.ts +6 -0
  13. package/fullstacked_modules/@fullstacked/ai-agent/src/providers/ollama.ts +42 -0
  14. package/fullstacked_modules/@fullstacked/ai-agent/src/providers/openai.ts +33 -0
  15. package/fullstacked_modules/@fullstacked/ai-agent/story.txt +7 -0
  16. package/fullstacked_modules/ai/index.d.ts +2 -0
  17. package/fullstacked_modules/ai/index.js +88268 -0
  18. package/fullstacked_modules/ai/index.ts +14 -0
  19. package/fullstacked_modules/ai/package.json +5 -0
  20. package/fullstacked_modules/ai/tools/fs.ts +60 -0
  21. package/{lib → fullstacked_modules}/archive/archive.ts +140 -140
  22. package/fullstacked_modules/archive/index.d.ts +2 -0
  23. package/{lib → fullstacked_modules}/archive/index.ts +4 -4
  24. package/{lib → fullstacked_modules}/base64.ts +144 -144
  25. package/fullstacked_modules/bridge/index.ts +120 -0
  26. package/{lib → fullstacked_modules}/bridge/platform/android.ts +18 -18
  27. package/{lib → fullstacked_modules}/bridge/platform/apple.ts +46 -46
  28. package/{lib → fullstacked_modules}/bridge/platform/electron.ts +14 -14
  29. package/{lib → fullstacked_modules}/bridge/platform/linux-gtk.ts +48 -48
  30. package/{lib → fullstacked_modules}/bridge/platform/linux-qt.ts +68 -68
  31. package/{lib → fullstacked_modules}/bridge/platform/node.ts +32 -32
  32. package/{lib → fullstacked_modules}/bridge/platform/wasm.ts +17 -17
  33. package/{lib → fullstacked_modules}/bridge/platform/windows.ts +49 -49
  34. package/{lib → fullstacked_modules}/bridge/serialization.ts +153 -153
  35. package/{lib → fullstacked_modules}/components/snackbar.ts +60 -60
  36. package/fullstacked_modules/config/config.ts +33 -0
  37. package/fullstacked_modules/config/index.ts +3 -0
  38. package/fullstacked_modules/connect/index.d.ts +2 -0
  39. package/{lib → fullstacked_modules}/connect/index.ts +125 -125
  40. package/{lib → fullstacked_modules}/core_message/core_message.ts +57 -76
  41. package/{lib → fullstacked_modules}/core_message/index.ts +3 -3
  42. package/fullstacked_modules/core_open.ts +9 -0
  43. package/fullstacked_modules/esbuild/esbuild.ts +101 -0
  44. package/fullstacked_modules/esbuild/index.ts +3 -0
  45. package/fullstacked_modules/esbuild/sass.ts +103 -0
  46. package/fullstacked_modules/fetch/index.d.ts +2 -0
  47. package/{lib → fullstacked_modules}/fetch/index.ts +332 -318
  48. package/{lib → fullstacked_modules}/fs/fs.ts +157 -157
  49. package/fullstacked_modules/fs/index.d.ts +2 -0
  50. package/{lib → fullstacked_modules}/fs/index.ts +3 -3
  51. package/fullstacked_modules/git/git.ts +238 -0
  52. package/fullstacked_modules/git/index.ts +3 -0
  53. package/fullstacked_modules/packages/index.ts +3 -0
  54. package/fullstacked_modules/packages/packages.ts +143 -0
  55. package/fullstacked_modules/platform/index.d.ts +2 -0
  56. package/{lib → fullstacked_modules}/platform/index.ts +14 -14
  57. package/fullstacked_modules/zod/LICENSE +21 -0
  58. package/fullstacked_modules/zod/README.md +208 -0
  59. package/fullstacked_modules/zod/index.d.cts +4 -0
  60. package/fullstacked_modules/zod/index.d.ts +4 -0
  61. package/fullstacked_modules/zod/locales/index.d.cts +1 -0
  62. package/fullstacked_modules/zod/locales/index.d.ts +1 -0
  63. package/fullstacked_modules/zod/mini/index.d.cts +1 -0
  64. package/fullstacked_modules/zod/mini/index.d.ts +1 -0
  65. package/fullstacked_modules/zod/package.json +134 -0
  66. package/fullstacked_modules/zod/src/index.ts +4 -0
  67. package/fullstacked_modules/zod/src/locales/index.ts +1 -0
  68. package/fullstacked_modules/zod/src/mini/index.ts +1 -0
  69. package/fullstacked_modules/zod/src/v3/ZodError.ts +330 -0
  70. package/fullstacked_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  71. package/fullstacked_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  72. package/fullstacked_modules/zod/src/v3/benchmarks/index.ts +59 -0
  73. package/fullstacked_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  74. package/fullstacked_modules/zod/src/v3/benchmarks/object.ts +69 -0
  75. package/fullstacked_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  76. package/fullstacked_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  77. package/fullstacked_modules/zod/src/v3/benchmarks/string.ts +55 -0
  78. package/fullstacked_modules/zod/src/v3/benchmarks/union.ts +80 -0
  79. package/fullstacked_modules/zod/src/v3/errors.ts +13 -0
  80. package/fullstacked_modules/zod/src/v3/external.ts +6 -0
  81. package/fullstacked_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  82. package/fullstacked_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  83. package/fullstacked_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  84. package/fullstacked_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  85. package/fullstacked_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  86. package/fullstacked_modules/zod/src/v3/helpers/util.ts +224 -0
  87. package/fullstacked_modules/zod/src/v3/index.ts +4 -0
  88. package/fullstacked_modules/zod/src/v3/locales/en.ts +124 -0
  89. package/fullstacked_modules/zod/src/v3/standard-schema.ts +113 -0
  90. package/fullstacked_modules/zod/src/v3/tests/Mocker.ts +54 -0
  91. package/fullstacked_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  92. package/fullstacked_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  93. package/fullstacked_modules/zod/src/v3/tests/array.test.ts +71 -0
  94. package/fullstacked_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  95. package/fullstacked_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  96. package/fullstacked_modules/zod/src/v3/tests/base.test.ts +29 -0
  97. package/fullstacked_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  98. package/fullstacked_modules/zod/src/v3/tests/branded.test.ts +53 -0
  99. package/fullstacked_modules/zod/src/v3/tests/catch.test.ts +220 -0
  100. package/fullstacked_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  101. package/fullstacked_modules/zod/src/v3/tests/complex.test.ts +56 -0
  102. package/fullstacked_modules/zod/src/v3/tests/custom.test.ts +31 -0
  103. package/fullstacked_modules/zod/src/v3/tests/date.test.ts +32 -0
  104. package/fullstacked_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  105. package/fullstacked_modules/zod/src/v3/tests/default.test.ts +112 -0
  106. package/fullstacked_modules/zod/src/v3/tests/description.test.ts +33 -0
  107. package/fullstacked_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  108. package/fullstacked_modules/zod/src/v3/tests/enum.test.ts +80 -0
  109. package/fullstacked_modules/zod/src/v3/tests/error.test.ts +551 -0
  110. package/fullstacked_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  111. package/fullstacked_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  112. package/fullstacked_modules/zod/src/v3/tests/function.test.ts +257 -0
  113. package/fullstacked_modules/zod/src/v3/tests/generics.test.ts +48 -0
  114. package/fullstacked_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  115. package/fullstacked_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  116. package/fullstacked_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  117. package/fullstacked_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  118. package/fullstacked_modules/zod/src/v3/tests/literal.test.ts +36 -0
  119. package/fullstacked_modules/zod/src/v3/tests/map.test.ts +110 -0
  120. package/fullstacked_modules/zod/src/v3/tests/masking.test.ts +4 -0
  121. package/fullstacked_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  122. package/fullstacked_modules/zod/src/v3/tests/nan.test.ts +21 -0
  123. package/fullstacked_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  124. package/fullstacked_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  125. package/fullstacked_modules/zod/src/v3/tests/number.test.ts +176 -0
  126. package/fullstacked_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  127. package/fullstacked_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  128. package/fullstacked_modules/zod/src/v3/tests/object.test.ts +434 -0
  129. package/fullstacked_modules/zod/src/v3/tests/optional.test.ts +42 -0
  130. package/fullstacked_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
  131. package/fullstacked_modules/zod/src/v3/tests/parser.test.ts +41 -0
  132. package/fullstacked_modules/zod/src/v3/tests/partials.test.ts +243 -0
  133. package/fullstacked_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
  134. package/fullstacked_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
  135. package/fullstacked_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
  136. package/fullstacked_modules/zod/src/v3/tests/primitive.test.ts +440 -0
  137. package/fullstacked_modules/zod/src/v3/tests/promise.test.ts +90 -0
  138. package/fullstacked_modules/zod/src/v3/tests/readonly.test.ts +194 -0
  139. package/fullstacked_modules/zod/src/v3/tests/record.test.ts +171 -0
  140. package/fullstacked_modules/zod/src/v3/tests/recursive.test.ts +197 -0
  141. package/fullstacked_modules/zod/src/v3/tests/refine.test.ts +313 -0
  142. package/fullstacked_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
  143. package/fullstacked_modules/zod/src/v3/tests/set.test.ts +142 -0
  144. package/fullstacked_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
  145. package/fullstacked_modules/zod/src/v3/tests/string.test.ts +916 -0
  146. package/fullstacked_modules/zod/src/v3/tests/transformer.test.ts +233 -0
  147. package/fullstacked_modules/zod/src/v3/tests/tuple.test.ts +90 -0
  148. package/fullstacked_modules/zod/src/v3/tests/unions.test.ts +57 -0
  149. package/fullstacked_modules/zod/src/v3/tests/validations.test.ts +133 -0
  150. package/fullstacked_modules/zod/src/v3/tests/void.test.ts +15 -0
  151. package/fullstacked_modules/zod/src/v3/types.ts +5138 -0
  152. package/fullstacked_modules/zod/src/v4/classic/checks.ts +31 -0
  153. package/fullstacked_modules/zod/src/v4/classic/coerce.ts +27 -0
  154. package/fullstacked_modules/zod/src/v4/classic/compat.ts +70 -0
  155. package/fullstacked_modules/zod/src/v4/classic/errors.ts +82 -0
  156. package/fullstacked_modules/zod/src/v4/classic/external.ts +50 -0
  157. package/fullstacked_modules/zod/src/v4/classic/index.ts +5 -0
  158. package/fullstacked_modules/zod/src/v4/classic/iso.ts +90 -0
  159. package/fullstacked_modules/zod/src/v4/classic/parse.ts +33 -0
  160. package/fullstacked_modules/zod/src/v4/classic/schemas.ts +2031 -0
  161. package/fullstacked_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
  162. package/fullstacked_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
  163. package/fullstacked_modules/zod/src/v4/classic/tests/assignability.test.ts +210 -0
  164. package/fullstacked_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
  165. package/fullstacked_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
  166. package/fullstacked_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
  167. package/fullstacked_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
  168. package/fullstacked_modules/zod/src/v4/classic/tests/brand.test.ts +63 -0
  169. package/fullstacked_modules/zod/src/v4/classic/tests/catch.test.ts +251 -0
  170. package/fullstacked_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
  171. package/fullstacked_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
  172. package/fullstacked_modules/zod/src/v4/classic/tests/continuability.test.ts +352 -0
  173. package/fullstacked_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
  174. package/fullstacked_modules/zod/src/v4/classic/tests/date.test.ts +31 -0
  175. package/fullstacked_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
  176. package/fullstacked_modules/zod/src/v4/classic/tests/default.test.ts +313 -0
  177. package/fullstacked_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
  178. package/fullstacked_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +661 -0
  179. package/fullstacked_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
  180. package/fullstacked_modules/zod/src/v4/classic/tests/error-utils.test.ts +595 -0
  181. package/fullstacked_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
  182. package/fullstacked_modules/zod/src/v4/classic/tests/file.test.ts +94 -0
  183. package/fullstacked_modules/zod/src/v4/classic/tests/firstparty.test.ts +175 -0
  184. package/fullstacked_modules/zod/src/v4/classic/tests/function.test.ts +268 -0
  185. package/fullstacked_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
  186. package/fullstacked_modules/zod/src/v4/classic/tests/index.test.ts +829 -0
  187. package/fullstacked_modules/zod/src/v4/classic/tests/instanceof.test.ts +34 -0
  188. package/fullstacked_modules/zod/src/v4/classic/tests/intersection.test.ts +171 -0
  189. package/fullstacked_modules/zod/src/v4/classic/tests/json.test.ts +108 -0
  190. package/fullstacked_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
  191. package/fullstacked_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
  192. package/fullstacked_modules/zod/src/v4/classic/tests/map.test.ts +196 -0
  193. package/fullstacked_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  194. package/fullstacked_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  195. package/fullstacked_modules/zod/src/v4/classic/tests/nonoptional.test.ts +86 -0
  196. package/fullstacked_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  197. package/fullstacked_modules/zod/src/v4/classic/tests/number.test.ts +270 -0
  198. package/fullstacked_modules/zod/src/v4/classic/tests/object.test.ts +563 -0
  199. package/fullstacked_modules/zod/src/v4/classic/tests/optional.test.ts +136 -0
  200. package/fullstacked_modules/zod/src/v4/classic/tests/partial.test.ts +340 -0
  201. package/fullstacked_modules/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
  202. package/fullstacked_modules/zod/src/v4/classic/tests/pipe.test.ts +81 -0
  203. package/fullstacked_modules/zod/src/v4/classic/tests/prefault.test.ts +37 -0
  204. package/fullstacked_modules/zod/src/v4/classic/tests/preprocess.test.ts +287 -0
  205. package/fullstacked_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  206. package/fullstacked_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  207. package/fullstacked_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  208. package/fullstacked_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  209. package/fullstacked_modules/zod/src/v4/classic/tests/record.test.ts +356 -0
  210. package/fullstacked_modules/zod/src/v4/classic/tests/recursive-types.test.ts +477 -0
  211. package/fullstacked_modules/zod/src/v4/classic/tests/refine.test.ts +532 -0
  212. package/fullstacked_modules/zod/src/v4/classic/tests/registries.test.ts +204 -0
  213. package/fullstacked_modules/zod/src/v4/classic/tests/set.test.ts +179 -0
  214. package/fullstacked_modules/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
  215. package/fullstacked_modules/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
  216. package/fullstacked_modules/zod/src/v4/classic/tests/string.test.ts +996 -0
  217. package/fullstacked_modules/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
  218. package/fullstacked_modules/zod/src/v4/classic/tests/template-literal.test.ts +761 -0
  219. package/fullstacked_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2341 -0
  220. package/fullstacked_modules/zod/src/v4/classic/tests/transform.test.ts +354 -0
  221. package/fullstacked_modules/zod/src/v4/classic/tests/tuple.test.ts +163 -0
  222. package/fullstacked_modules/zod/src/v4/classic/tests/union.test.ts +181 -0
  223. package/fullstacked_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  224. package/fullstacked_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  225. package/fullstacked_modules/zod/src/v4/core/api.ts +1628 -0
  226. package/fullstacked_modules/zod/src/v4/core/checks.ts +1285 -0
  227. package/fullstacked_modules/zod/src/v4/core/config.ts +15 -0
  228. package/fullstacked_modules/zod/src/v4/core/core.ts +134 -0
  229. package/fullstacked_modules/zod/src/v4/core/doc.ts +44 -0
  230. package/fullstacked_modules/zod/src/v4/core/errors.ts +423 -0
  231. package/fullstacked_modules/zod/src/v4/core/function.ts +176 -0
  232. package/fullstacked_modules/zod/src/v4/core/index.ts +15 -0
  233. package/fullstacked_modules/zod/src/v4/core/json-schema.ts +146 -0
  234. package/fullstacked_modules/zod/src/v4/core/parse.ts +94 -0
  235. package/fullstacked_modules/zod/src/v4/core/regexes.ts +138 -0
  236. package/fullstacked_modules/zod/src/v4/core/registries.ts +97 -0
  237. package/fullstacked_modules/zod/src/v4/core/schemas.ts +3900 -0
  238. package/fullstacked_modules/zod/src/v4/core/standard-schema.ts +64 -0
  239. package/fullstacked_modules/zod/src/v4/core/tests/extend.test.ts +18 -0
  240. package/fullstacked_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  241. package/fullstacked_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  242. package/fullstacked_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  243. package/fullstacked_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  244. package/fullstacked_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  245. package/fullstacked_modules/zod/src/v4/core/to-json-schema.ts +1004 -0
  246. package/fullstacked_modules/zod/src/v4/core/util.ts +827 -0
  247. package/fullstacked_modules/zod/src/v4/core/versions.ts +5 -0
  248. package/fullstacked_modules/zod/src/v4/core/zsf.ts +323 -0
  249. package/fullstacked_modules/zod/src/v4/index.ts +4 -0
  250. package/fullstacked_modules/zod/src/v4/locales/ar.ts +125 -0
  251. package/fullstacked_modules/zod/src/v4/locales/az.ts +121 -0
  252. package/fullstacked_modules/zod/src/v4/locales/be.ts +184 -0
  253. package/fullstacked_modules/zod/src/v4/locales/bg.ts +136 -0
  254. package/fullstacked_modules/zod/src/v4/locales/ca.ts +127 -0
  255. package/fullstacked_modules/zod/src/v4/locales/cs.ts +142 -0
  256. package/fullstacked_modules/zod/src/v4/locales/da.ts +141 -0
  257. package/fullstacked_modules/zod/src/v4/locales/de.ts +124 -0
  258. package/fullstacked_modules/zod/src/v4/locales/en.ts +127 -0
  259. package/fullstacked_modules/zod/src/v4/locales/eo.ts +125 -0
  260. package/fullstacked_modules/zod/src/v4/locales/es.ts +125 -0
  261. package/fullstacked_modules/zod/src/v4/locales/fa.ts +134 -0
  262. package/fullstacked_modules/zod/src/v4/locales/fi.ts +131 -0
  263. package/fullstacked_modules/zod/src/v4/locales/fr-CA.ts +126 -0
  264. package/fullstacked_modules/zod/src/v4/locales/fr.ts +124 -0
  265. package/fullstacked_modules/zod/src/v4/locales/he.ts +125 -0
  266. package/fullstacked_modules/zod/src/v4/locales/hu.ts +126 -0
  267. package/fullstacked_modules/zod/src/v4/locales/id.ts +125 -0
  268. package/fullstacked_modules/zod/src/v4/locales/index.ts +42 -0
  269. package/fullstacked_modules/zod/src/v4/locales/is.ts +127 -0
  270. package/fullstacked_modules/zod/src/v4/locales/it.ts +125 -0
  271. package/fullstacked_modules/zod/src/v4/locales/ja.ts +122 -0
  272. package/fullstacked_modules/zod/src/v4/locales/kh.ts +126 -0
  273. package/fullstacked_modules/zod/src/v4/locales/ko.ts +131 -0
  274. package/fullstacked_modules/zod/src/v4/locales/mk.ts +127 -0
  275. package/fullstacked_modules/zod/src/v4/locales/ms.ts +124 -0
  276. package/fullstacked_modules/zod/src/v4/locales/nl.ts +126 -0
  277. package/fullstacked_modules/zod/src/v4/locales/no.ts +124 -0
  278. package/fullstacked_modules/zod/src/v4/locales/ota.ts +125 -0
  279. package/fullstacked_modules/zod/src/v4/locales/pl.ts +126 -0
  280. package/fullstacked_modules/zod/src/v4/locales/ps.ts +133 -0
  281. package/fullstacked_modules/zod/src/v4/locales/pt.ts +123 -0
  282. package/fullstacked_modules/zod/src/v4/locales/ru.ts +184 -0
  283. package/fullstacked_modules/zod/src/v4/locales/sl.ts +126 -0
  284. package/fullstacked_modules/zod/src/v4/locales/sv.ts +127 -0
  285. package/fullstacked_modules/zod/src/v4/locales/ta.ts +125 -0
  286. package/fullstacked_modules/zod/src/v4/locales/th.ts +126 -0
  287. package/fullstacked_modules/zod/src/v4/locales/tr.ts +121 -0
  288. package/fullstacked_modules/zod/src/v4/locales/ua.ts +126 -0
  289. package/fullstacked_modules/zod/src/v4/locales/ur.ts +126 -0
  290. package/fullstacked_modules/zod/src/v4/locales/vi.ts +125 -0
  291. package/fullstacked_modules/zod/src/v4/locales/yo.ts +131 -0
  292. package/fullstacked_modules/zod/src/v4/locales/zh-CN.ts +123 -0
  293. package/fullstacked_modules/zod/src/v4/locales/zh-TW.ts +125 -0
  294. package/fullstacked_modules/zod/src/v4/mini/checks.ts +32 -0
  295. package/fullstacked_modules/zod/src/v4/mini/coerce.ts +22 -0
  296. package/fullstacked_modules/zod/src/v4/mini/external.ts +40 -0
  297. package/fullstacked_modules/zod/src/v4/mini/index.ts +3 -0
  298. package/fullstacked_modules/zod/src/v4/mini/iso.ts +62 -0
  299. package/fullstacked_modules/zod/src/v4/mini/parse.ts +1 -0
  300. package/fullstacked_modules/zod/src/v4/mini/schemas.ts +1592 -0
  301. package/fullstacked_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
  302. package/fullstacked_modules/zod/src/v4/mini/tests/brand.test.ts +51 -0
  303. package/fullstacked_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
  304. package/fullstacked_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
  305. package/fullstacked_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
  306. package/fullstacked_modules/zod/src/v4/mini/tests/functions.test.ts +43 -0
  307. package/fullstacked_modules/zod/src/v4/mini/tests/index.test.ts +871 -0
  308. package/fullstacked_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
  309. package/fullstacked_modules/zod/src/v4/mini/tests/object.test.ts +185 -0
  310. package/fullstacked_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
  311. package/fullstacked_modules/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
  312. package/fullstacked_modules/zod/src/v4/mini/tests/string.test.ts +299 -0
  313. package/fullstacked_modules/zod/src/v4-mini/index.ts +1 -0
  314. package/fullstacked_modules/zod/v3/ZodError.d.cts +164 -0
  315. package/fullstacked_modules/zod/v3/ZodError.d.ts +164 -0
  316. package/fullstacked_modules/zod/v3/errors.d.cts +5 -0
  317. package/fullstacked_modules/zod/v3/errors.d.ts +5 -0
  318. package/fullstacked_modules/zod/v3/external.d.cts +6 -0
  319. package/fullstacked_modules/zod/v3/external.d.ts +6 -0
  320. package/fullstacked_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  321. package/fullstacked_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  322. package/fullstacked_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  323. package/fullstacked_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  324. package/fullstacked_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  325. package/fullstacked_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  326. package/fullstacked_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  327. package/fullstacked_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  328. package/fullstacked_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  329. package/fullstacked_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  330. package/fullstacked_modules/zod/v3/helpers/util.d.cts +85 -0
  331. package/fullstacked_modules/zod/v3/helpers/util.d.ts +85 -0
  332. package/fullstacked_modules/zod/v3/index.d.cts +4 -0
  333. package/fullstacked_modules/zod/v3/index.d.ts +4 -0
  334. package/fullstacked_modules/zod/v3/locales/en.d.cts +3 -0
  335. package/fullstacked_modules/zod/v3/locales/en.d.ts +3 -0
  336. package/fullstacked_modules/zod/v3/standard-schema.d.cts +102 -0
  337. package/fullstacked_modules/zod/v3/standard-schema.d.ts +102 -0
  338. package/fullstacked_modules/zod/v3/types.d.cts +1034 -0
  339. package/fullstacked_modules/zod/v3/types.d.ts +1034 -0
  340. package/fullstacked_modules/zod/v4/classic/checks.d.cts +1 -0
  341. package/fullstacked_modules/zod/v4/classic/checks.d.ts +1 -0
  342. package/fullstacked_modules/zod/v4/classic/coerce.d.cts +17 -0
  343. package/fullstacked_modules/zod/v4/classic/coerce.d.ts +17 -0
  344. package/fullstacked_modules/zod/v4/classic/compat.d.cts +50 -0
  345. package/fullstacked_modules/zod/v4/classic/compat.d.ts +50 -0
  346. package/fullstacked_modules/zod/v4/classic/errors.d.cts +30 -0
  347. package/fullstacked_modules/zod/v4/classic/errors.d.ts +30 -0
  348. package/fullstacked_modules/zod/v4/classic/external.d.cts +13 -0
  349. package/fullstacked_modules/zod/v4/classic/external.d.ts +13 -0
  350. package/fullstacked_modules/zod/v4/classic/index.d.cts +4 -0
  351. package/fullstacked_modules/zod/v4/classic/index.d.ts +4 -0
  352. package/fullstacked_modules/zod/v4/classic/iso.d.cts +22 -0
  353. package/fullstacked_modules/zod/v4/classic/iso.d.ts +22 -0
  354. package/fullstacked_modules/zod/v4/classic/parse.d.cts +23 -0
  355. package/fullstacked_modules/zod/v4/classic/parse.d.ts +23 -0
  356. package/fullstacked_modules/zod/v4/classic/schemas.d.cts +619 -0
  357. package/fullstacked_modules/zod/v4/classic/schemas.d.ts +619 -0
  358. package/fullstacked_modules/zod/v4/core/api.d.cts +296 -0
  359. package/fullstacked_modules/zod/v4/core/api.d.ts +296 -0
  360. package/fullstacked_modules/zod/v4/core/checks.d.cts +278 -0
  361. package/fullstacked_modules/zod/v4/core/checks.d.ts +278 -0
  362. package/fullstacked_modules/zod/v4/core/core.d.cts +49 -0
  363. package/fullstacked_modules/zod/v4/core/core.d.ts +49 -0
  364. package/fullstacked_modules/zod/v4/core/doc.d.cts +14 -0
  365. package/fullstacked_modules/zod/v4/core/doc.d.ts +14 -0
  366. package/fullstacked_modules/zod/v4/core/errors.d.cts +210 -0
  367. package/fullstacked_modules/zod/v4/core/errors.d.ts +210 -0
  368. package/fullstacked_modules/zod/v4/core/function.d.cts +52 -0
  369. package/fullstacked_modules/zod/v4/core/function.d.ts +52 -0
  370. package/fullstacked_modules/zod/v4/core/index.d.cts +15 -0
  371. package/fullstacked_modules/zod/v4/core/index.d.ts +15 -0
  372. package/fullstacked_modules/zod/v4/core/json-schema.d.cts +87 -0
  373. package/fullstacked_modules/zod/v4/core/json-schema.d.ts +87 -0
  374. package/fullstacked_modules/zod/v4/core/parse.d.cts +25 -0
  375. package/fullstacked_modules/zod/v4/core/parse.d.ts +25 -0
  376. package/fullstacked_modules/zod/v4/core/regexes.d.cts +62 -0
  377. package/fullstacked_modules/zod/v4/core/regexes.d.ts +62 -0
  378. package/fullstacked_modules/zod/v4/core/registries.d.cts +35 -0
  379. package/fullstacked_modules/zod/v4/core/registries.d.ts +35 -0
  380. package/fullstacked_modules/zod/v4/core/schemas.d.cts +1055 -0
  381. package/fullstacked_modules/zod/v4/core/schemas.d.ts +1055 -0
  382. package/fullstacked_modules/zod/v4/core/standard-schema.d.cts +55 -0
  383. package/fullstacked_modules/zod/v4/core/standard-schema.d.ts +55 -0
  384. package/fullstacked_modules/zod/v4/core/to-json-schema.d.cts +89 -0
  385. package/fullstacked_modules/zod/v4/core/to-json-schema.d.ts +89 -0
  386. package/fullstacked_modules/zod/v4/core/util.d.cts +185 -0
  387. package/fullstacked_modules/zod/v4/core/util.d.ts +185 -0
  388. package/fullstacked_modules/zod/v4/core/versions.d.cts +5 -0
  389. package/fullstacked_modules/zod/v4/core/versions.d.ts +5 -0
  390. package/fullstacked_modules/zod/v4/index.d.cts +3 -0
  391. package/fullstacked_modules/zod/v4/index.d.ts +3 -0
  392. package/fullstacked_modules/zod/v4/locales/ar.d.cts +5 -0
  393. package/fullstacked_modules/zod/v4/locales/ar.d.ts +4 -0
  394. package/fullstacked_modules/zod/v4/locales/az.d.cts +5 -0
  395. package/fullstacked_modules/zod/v4/locales/az.d.ts +4 -0
  396. package/fullstacked_modules/zod/v4/locales/be.d.cts +5 -0
  397. package/fullstacked_modules/zod/v4/locales/be.d.ts +4 -0
  398. package/fullstacked_modules/zod/v4/locales/bg.d.cts +5 -0
  399. package/fullstacked_modules/zod/v4/locales/bg.d.ts +5 -0
  400. package/fullstacked_modules/zod/v4/locales/ca.d.cts +5 -0
  401. package/fullstacked_modules/zod/v4/locales/ca.d.ts +4 -0
  402. package/fullstacked_modules/zod/v4/locales/cs.d.cts +5 -0
  403. package/fullstacked_modules/zod/v4/locales/cs.d.ts +4 -0
  404. package/fullstacked_modules/zod/v4/locales/da.d.cts +5 -0
  405. package/fullstacked_modules/zod/v4/locales/da.d.ts +4 -0
  406. package/fullstacked_modules/zod/v4/locales/de.d.cts +5 -0
  407. package/fullstacked_modules/zod/v4/locales/de.d.ts +4 -0
  408. package/fullstacked_modules/zod/v4/locales/en.d.cts +5 -0
  409. package/fullstacked_modules/zod/v4/locales/en.d.ts +5 -0
  410. package/fullstacked_modules/zod/v4/locales/eo.d.cts +5 -0
  411. package/fullstacked_modules/zod/v4/locales/eo.d.ts +5 -0
  412. package/fullstacked_modules/zod/v4/locales/es.d.cts +5 -0
  413. package/fullstacked_modules/zod/v4/locales/es.d.ts +4 -0
  414. package/fullstacked_modules/zod/v4/locales/fa.d.cts +5 -0
  415. package/fullstacked_modules/zod/v4/locales/fa.d.ts +4 -0
  416. package/fullstacked_modules/zod/v4/locales/fi.d.cts +5 -0
  417. package/fullstacked_modules/zod/v4/locales/fi.d.ts +4 -0
  418. package/fullstacked_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  419. package/fullstacked_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  420. package/fullstacked_modules/zod/v4/locales/fr.d.cts +5 -0
  421. package/fullstacked_modules/zod/v4/locales/fr.d.ts +4 -0
  422. package/fullstacked_modules/zod/v4/locales/he.d.cts +5 -0
  423. package/fullstacked_modules/zod/v4/locales/he.d.ts +4 -0
  424. package/fullstacked_modules/zod/v4/locales/hu.d.cts +5 -0
  425. package/fullstacked_modules/zod/v4/locales/hu.d.ts +4 -0
  426. package/fullstacked_modules/zod/v4/locales/id.d.cts +5 -0
  427. package/fullstacked_modules/zod/v4/locales/id.d.ts +4 -0
  428. package/fullstacked_modules/zod/v4/locales/index.d.cts +42 -0
  429. package/fullstacked_modules/zod/v4/locales/index.d.ts +42 -0
  430. package/fullstacked_modules/zod/v4/locales/is.d.cts +5 -0
  431. package/fullstacked_modules/zod/v4/locales/is.d.ts +5 -0
  432. package/fullstacked_modules/zod/v4/locales/it.d.cts +5 -0
  433. package/fullstacked_modules/zod/v4/locales/it.d.ts +4 -0
  434. package/fullstacked_modules/zod/v4/locales/ja.d.cts +5 -0
  435. package/fullstacked_modules/zod/v4/locales/ja.d.ts +4 -0
  436. package/fullstacked_modules/zod/v4/locales/kh.d.cts +5 -0
  437. package/fullstacked_modules/zod/v4/locales/kh.d.ts +4 -0
  438. package/fullstacked_modules/zod/v4/locales/ko.d.cts +5 -0
  439. package/fullstacked_modules/zod/v4/locales/ko.d.ts +4 -0
  440. package/fullstacked_modules/zod/v4/locales/mk.d.cts +5 -0
  441. package/fullstacked_modules/zod/v4/locales/mk.d.ts +4 -0
  442. package/fullstacked_modules/zod/v4/locales/ms.d.cts +5 -0
  443. package/fullstacked_modules/zod/v4/locales/ms.d.ts +4 -0
  444. package/fullstacked_modules/zod/v4/locales/nl.d.cts +5 -0
  445. package/fullstacked_modules/zod/v4/locales/nl.d.ts +4 -0
  446. package/fullstacked_modules/zod/v4/locales/no.d.cts +5 -0
  447. package/fullstacked_modules/zod/v4/locales/no.d.ts +4 -0
  448. package/fullstacked_modules/zod/v4/locales/ota.d.cts +5 -0
  449. package/fullstacked_modules/zod/v4/locales/ota.d.ts +4 -0
  450. package/fullstacked_modules/zod/v4/locales/pl.d.cts +5 -0
  451. package/fullstacked_modules/zod/v4/locales/pl.d.ts +4 -0
  452. package/fullstacked_modules/zod/v4/locales/ps.d.cts +5 -0
  453. package/fullstacked_modules/zod/v4/locales/ps.d.ts +4 -0
  454. package/fullstacked_modules/zod/v4/locales/pt.d.cts +5 -0
  455. package/fullstacked_modules/zod/v4/locales/pt.d.ts +4 -0
  456. package/fullstacked_modules/zod/v4/locales/ru.d.cts +5 -0
  457. package/fullstacked_modules/zod/v4/locales/ru.d.ts +4 -0
  458. package/fullstacked_modules/zod/v4/locales/sl.d.cts +5 -0
  459. package/fullstacked_modules/zod/v4/locales/sl.d.ts +4 -0
  460. package/fullstacked_modules/zod/v4/locales/sv.d.cts +5 -0
  461. package/fullstacked_modules/zod/v4/locales/sv.d.ts +4 -0
  462. package/fullstacked_modules/zod/v4/locales/ta.d.cts +5 -0
  463. package/fullstacked_modules/zod/v4/locales/ta.d.ts +4 -0
  464. package/fullstacked_modules/zod/v4/locales/th.d.cts +5 -0
  465. package/fullstacked_modules/zod/v4/locales/th.d.ts +4 -0
  466. package/fullstacked_modules/zod/v4/locales/tr.d.cts +5 -0
  467. package/fullstacked_modules/zod/v4/locales/tr.d.ts +5 -0
  468. package/fullstacked_modules/zod/v4/locales/ua.d.cts +5 -0
  469. package/fullstacked_modules/zod/v4/locales/ua.d.ts +4 -0
  470. package/fullstacked_modules/zod/v4/locales/ur.d.cts +5 -0
  471. package/fullstacked_modules/zod/v4/locales/ur.d.ts +4 -0
  472. package/fullstacked_modules/zod/v4/locales/vi.d.cts +5 -0
  473. package/fullstacked_modules/zod/v4/locales/vi.d.ts +4 -0
  474. package/fullstacked_modules/zod/v4/locales/yo.d.cts +5 -0
  475. package/fullstacked_modules/zod/v4/locales/yo.d.ts +4 -0
  476. package/fullstacked_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  477. package/fullstacked_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  478. package/fullstacked_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  479. package/fullstacked_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  480. package/fullstacked_modules/zod/v4/mini/checks.d.cts +1 -0
  481. package/fullstacked_modules/zod/v4/mini/checks.d.ts +1 -0
  482. package/fullstacked_modules/zod/v4/mini/coerce.d.cts +7 -0
  483. package/fullstacked_modules/zod/v4/mini/coerce.d.ts +7 -0
  484. package/fullstacked_modules/zod/v4/mini/external.d.cts +11 -0
  485. package/fullstacked_modules/zod/v4/mini/external.d.ts +11 -0
  486. package/fullstacked_modules/zod/v4/mini/index.d.cts +3 -0
  487. package/fullstacked_modules/zod/v4/mini/index.d.ts +3 -0
  488. package/fullstacked_modules/zod/v4/mini/iso.d.cts +22 -0
  489. package/fullstacked_modules/zod/v4/mini/iso.d.ts +22 -0
  490. package/fullstacked_modules/zod/v4/mini/parse.d.cts +1 -0
  491. package/fullstacked_modules/zod/v4/mini/parse.d.ts +1 -0
  492. package/fullstacked_modules/zod/v4/mini/schemas.d.cts +358 -0
  493. package/fullstacked_modules/zod/v4/mini/schemas.d.ts +358 -0
  494. package/fullstacked_modules/zod/v4-mini/index.d.cts +1 -0
  495. package/fullstacked_modules/zod/v4-mini/index.d.ts +1 -0
  496. package/index.js +17 -12
  497. package/package.json +1 -1
  498. package/lib/bridge/index.ts +0 -53
  499. package/lib/fullstacked.d.ts +0 -208
  500. /package/{lib → fullstacked_modules}/components/snackbar.css +0 -0
@@ -0,0 +1,3900 @@
1
+ import type { $ZodTypeDiscriminable } from "./api.js";
2
+ import * as checks from "./checks.js";
3
+ import * as core from "./core.js";
4
+ import { Doc } from "./doc.js";
5
+ import type * as errors from "./errors.js";
6
+ import { safeParse, safeParseAsync } from "./parse.js";
7
+ import * as regexes from "./regexes.js";
8
+ import type { StandardSchemaV1 } from "./standard-schema.js";
9
+ import * as util from "./util.js";
10
+ import { version } from "./versions.js";
11
+
12
+ ///////////////////////////// PARSE //////////////////////////////
13
+
14
+ export interface ParseContext<T extends errors.$ZodIssueBase = never> {
15
+ /** Customize error messages. */
16
+ readonly error?: errors.$ZodErrorMap<T>;
17
+ /** Include the `input` field in issue objects. Default `false`. */
18
+ readonly reportInput?: boolean;
19
+ /** Skip eval-based fast path. Default `false`. */
20
+ readonly jitless?: boolean;
21
+ /** Abort validation after the first error. Default `false`. */
22
+ // readonly abortEarly?: boolean;
23
+ }
24
+
25
+ /** @internal */
26
+ export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
27
+ readonly async?: boolean | undefined;
28
+ }
29
+
30
+ export interface ParsePayload<T = unknown> {
31
+ value: T;
32
+ issues: errors.$ZodRawIssue[];
33
+ }
34
+
35
+ export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
36
+
37
+ ///////////////////////////// SCHEMAS //////////////////////////////
38
+
39
+ export interface $ZodTypeDef {
40
+ type:
41
+ | "string"
42
+ | "number"
43
+ | "int"
44
+ | "boolean"
45
+ | "bigint"
46
+ | "symbol"
47
+ | "null"
48
+ | "undefined"
49
+ | "void" // merge with undefined?
50
+ | "never"
51
+ | "any"
52
+ | "unknown"
53
+ | "date"
54
+ | "object"
55
+ | "record"
56
+ | "file"
57
+ | "array"
58
+ | "tuple"
59
+ | "union"
60
+ | "intersection"
61
+ | "map"
62
+ | "set"
63
+ | "enum"
64
+ | "literal"
65
+ | "nullable"
66
+ | "optional"
67
+ | "nonoptional"
68
+ | "success"
69
+ | "transform"
70
+ | "default"
71
+ | "prefault"
72
+ | "catch"
73
+ | "nan"
74
+ | "pipe"
75
+ | "readonly"
76
+ | "template_literal"
77
+ | "promise"
78
+ | "lazy"
79
+ | "custom";
80
+ error?: errors.$ZodErrorMap<never> | undefined;
81
+ checks?: checks.$ZodCheck<never>[];
82
+ }
83
+
84
+ export interface _$ZodTypeInternals {
85
+ /** The `@zod/core` version of this schema */
86
+ version: typeof version;
87
+
88
+ /** Schema definition. */
89
+ def: $ZodTypeDef;
90
+ // types: Types;
91
+
92
+ /** @internal Randomly generated ID for this schema. */
93
+ // id: string;
94
+
95
+ /** @internal List of deferred initializers. */
96
+ deferred: util.AnyFunc[] | undefined;
97
+
98
+ /** @internal Parses input and runs all checks (refinements). */
99
+ run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
100
+
101
+ /** @internal Parses input, doesn't run checks. */
102
+ parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
103
+
104
+ /** @internal Stores identifiers for the set of traits implemented by this schema. */
105
+ traits: Set<string>;
106
+
107
+ /** @internal Indicates that a schema output type should be considered optional inside objects.
108
+ * @default Required
109
+ */
110
+
111
+ /** @internal */
112
+ optin?: "optional" | undefined;
113
+ /** @internal */
114
+ optout?: "optional" | undefined;
115
+
116
+ /** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
117
+ *
118
+ * Defined on: enum, const, literal, null, undefined
119
+ * Passthrough: optional, nullable, branded, default, catch, pipe
120
+ * Todo: unions?
121
+ */
122
+ values?: util.PrimitiveSet | undefined;
123
+
124
+ /** Default value bubbled up from */
125
+ // default?: unknown | undefined;
126
+
127
+ /** @internal A set of literal discriminators used for the fast path in discriminated unions. */
128
+ propValues?: util.PropValues | undefined;
129
+
130
+ /** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
131
+ pattern: RegExp | undefined;
132
+
133
+ /** @internal The constructor function of this schema. */
134
+ constr: new (
135
+ def: any
136
+ ) => $ZodType;
137
+
138
+ /** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
139
+ bag: Record<string, unknown>;
140
+
141
+ /** @internal The set of issues this schema might throw during type checking. */
142
+ isst: errors.$ZodIssueBase;
143
+
144
+ /** An optional method used to override `toJSONSchema` logic. */
145
+ toJSONSchema?: () => unknown;
146
+
147
+ /** @internal The parent of this schema. Only set during certain clone operations. */
148
+ parent?: $ZodType | undefined;
149
+ }
150
+ /** @internal */
151
+ export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
152
+ /** @internal The inferred output type */
153
+ output: O; //extends { $out: infer O } ? O : Out;
154
+ /** @internal The inferred input type */
155
+ input: I; //extends { $in: infer I } ? I : In;
156
+ }
157
+
158
+ export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
159
+
160
+ export type SomeType = { _zod: _$ZodTypeInternals };
161
+
162
+ export interface $ZodType<
163
+ O = unknown,
164
+ I = unknown,
165
+ Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>,
166
+ > {
167
+ _zod: Internals;
168
+ "~standard": $ZodStandardSchema<this>;
169
+ }
170
+ export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals>
171
+ extends $ZodType<T["output"], T["input"], T> {
172
+ // _zod: T;
173
+ }
174
+
175
+ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
176
+ inst ??= {} as any;
177
+
178
+ inst._zod.def = def; // set _def property
179
+ inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
180
+ inst._zod.version = version;
181
+
182
+ const checks = [...(inst._zod.def.checks ?? [])];
183
+
184
+ // if inst is itself a checks.$ZodCheck, run it as a check
185
+ if (inst._zod.traits.has("$ZodCheck")) {
186
+ checks.unshift(inst as any);
187
+ }
188
+ //
189
+
190
+ for (const ch of checks) {
191
+ for (const fn of ch._zod.onattach) {
192
+ fn(inst);
193
+ }
194
+ }
195
+
196
+ if (checks.length === 0) {
197
+ // deferred initializer
198
+ // inst._zod.parse is not yet defined
199
+ inst._zod.deferred ??= [];
200
+ inst._zod.deferred?.push(() => {
201
+ inst._zod.run = inst._zod.parse;
202
+ });
203
+ } else {
204
+ const runChecks = (
205
+ payload: ParsePayload,
206
+ checks: checks.$ZodCheck<never>[],
207
+ ctx?: ParseContextInternal | undefined
208
+ ): util.MaybeAsync<ParsePayload> => {
209
+ let isAborted = util.aborted(payload);
210
+
211
+ let asyncResult!: Promise<unknown> | undefined;
212
+ for (const ch of checks) {
213
+ if (ch._zod.def.when) {
214
+ const shouldRun = ch._zod.def.when(payload);
215
+ if (!shouldRun) continue;
216
+ } else if (isAborted) {
217
+ continue;
218
+ }
219
+ const currLen = payload.issues.length;
220
+ const _ = ch._zod.check(payload as any) as any as ParsePayload;
221
+
222
+ if (_ instanceof Promise && ctx?.async === false) {
223
+ throw new core.$ZodAsyncError();
224
+ }
225
+ if (asyncResult || _ instanceof Promise) {
226
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
227
+ await _;
228
+ const nextLen = payload.issues.length;
229
+ if (nextLen === currLen) return;
230
+ if (!isAborted) isAborted = util.aborted(payload, currLen);
231
+ });
232
+ } else {
233
+ const nextLen = payload.issues.length;
234
+ if (nextLen === currLen) continue;
235
+ if (!isAborted) isAborted = util.aborted(payload, currLen);
236
+ }
237
+ }
238
+
239
+ if (asyncResult) {
240
+ return asyncResult.then(() => {
241
+ return payload;
242
+ });
243
+ }
244
+ return payload;
245
+ };
246
+
247
+ inst._zod.run = (payload, ctx) => {
248
+ const result = inst._zod.parse(payload, ctx);
249
+
250
+ if (result instanceof Promise) {
251
+ if (ctx.async === false) throw new core.$ZodAsyncError();
252
+ return result.then((result) => runChecks(result, checks, ctx));
253
+ }
254
+
255
+ return runChecks(result, checks, ctx);
256
+ };
257
+ }
258
+
259
+ inst["~standard"] = {
260
+ validate: (value: unknown) => {
261
+ try {
262
+ const r = safeParse(inst, value);
263
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
264
+ } catch (_) {
265
+ return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
266
+ }
267
+ },
268
+ vendor: "zod",
269
+ version: 1 as const,
270
+ };
271
+ });
272
+
273
+ export { clone } from "./util.js";
274
+
275
+ //////////////////////////////////////////
276
+ //////////////////////////////////////////
277
+ ////////// //////////
278
+ ////////// $ZodString //////////
279
+ ////////// //////////
280
+ //////////////////////////////////////////
281
+ //////////////////////////////////////////
282
+ export interface $ZodStringDef extends $ZodTypeDef {
283
+ type: "string";
284
+ coerce?: boolean;
285
+ checks?: checks.$ZodCheck<string>[];
286
+ }
287
+
288
+ export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
289
+ def: $ZodStringDef;
290
+ /** @deprecated Internal API, use with caution (not deprecated) */
291
+ pattern: RegExp;
292
+
293
+ /** @deprecated Internal API, use with caution (not deprecated) */
294
+ isst: errors.$ZodIssueInvalidType;
295
+ bag: util.LoosePartial<{
296
+ minimum: number;
297
+ maximum: number;
298
+ patterns: Set<RegExp>;
299
+ format: string;
300
+ contentEncoding: string;
301
+ }>;
302
+ }
303
+
304
+ export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
305
+ // _zod: $ZodStringInternals<Input>;
306
+ }
307
+
308
+ export const $ZodString: core.$constructor<$ZodString> = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
309
+ $ZodType.init(inst, def);
310
+ inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
311
+ inst._zod.parse = (payload, _) => {
312
+ if (def.coerce)
313
+ try {
314
+ payload.value = String(payload.value);
315
+ } catch (_) {}
316
+
317
+ if (typeof payload.value === "string") return payload;
318
+
319
+ payload.issues.push({
320
+ expected: "string",
321
+ code: "invalid_type",
322
+
323
+ input: payload.value,
324
+ inst,
325
+ });
326
+ return payload;
327
+ };
328
+ });
329
+
330
+ ////////////////////////////// ZodStringFormat //////////////////////////////
331
+
332
+ export interface $ZodStringFormatDef<Format extends string = string>
333
+ extends $ZodStringDef,
334
+ checks.$ZodCheckStringFormatDef<Format> {}
335
+
336
+ export interface $ZodStringFormatInternals<Format extends string = string>
337
+ extends $ZodStringInternals<string>,
338
+ checks.$ZodCheckStringFormatInternals {
339
+ def: $ZodStringFormatDef<Format>;
340
+ }
341
+ export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
342
+ _zod: $ZodStringFormatInternals<Format>;
343
+ }
344
+
345
+ export const $ZodStringFormat: core.$constructor<$ZodStringFormat> = /*@__PURE__*/ core.$constructor(
346
+ "$ZodStringFormat",
347
+ (inst, def): void => {
348
+ // check initialization must come first
349
+ checks.$ZodCheckStringFormat.init(inst, def);
350
+ $ZodString.init(inst, def);
351
+ }
352
+ );
353
+
354
+ ////////////////////////////// ZodGUID //////////////////////////////
355
+ export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {}
356
+ export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {}
357
+
358
+ export interface $ZodGUID extends $ZodType {
359
+ _zod: $ZodGUIDInternals;
360
+ }
361
+
362
+ export const $ZodGUID: core.$constructor<$ZodGUID> = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def): void => {
363
+ def.pattern ??= regexes.guid;
364
+ $ZodStringFormat.init(inst, def);
365
+ });
366
+
367
+ ////////////////////////////// ZodUUID //////////////////////////////
368
+
369
+ export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
370
+ version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
371
+ }
372
+
373
+ export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
374
+ def: $ZodUUIDDef;
375
+ }
376
+
377
+ export interface $ZodUUID extends $ZodType {
378
+ _zod: $ZodUUIDInternals;
379
+ }
380
+
381
+ export const $ZodUUID: core.$constructor<$ZodUUID> = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def): void => {
382
+ if (def.version) {
383
+ const versionMap: Record<string, number> = {
384
+ v1: 1,
385
+ v2: 2,
386
+ v3: 3,
387
+ v4: 4,
388
+ v5: 5,
389
+ v6: 6,
390
+ v7: 7,
391
+ v8: 8,
392
+ };
393
+ const v = versionMap[def.version];
394
+ if (v === undefined) throw new Error(`Invalid UUID version: "${def.version}"`);
395
+ def.pattern ??= regexes.uuid(v);
396
+ } else def.pattern ??= regexes.uuid();
397
+ $ZodStringFormat.init(inst, def);
398
+ });
399
+
400
+ ////////////////////////////// ZodEmail //////////////////////////////
401
+
402
+ export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {}
403
+ export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {}
404
+ export interface $ZodEmail extends $ZodType {
405
+ _zod: $ZodEmailInternals;
406
+ }
407
+
408
+ export const $ZodEmail: core.$constructor<$ZodEmail> = /*@__PURE__*/ core.$constructor(
409
+ "$ZodEmail",
410
+ (inst, def): void => {
411
+ def.pattern ??= regexes.email;
412
+ $ZodStringFormat.init(inst, def);
413
+ }
414
+ );
415
+
416
+ ////////////////////////////// ZodURL //////////////////////////////
417
+
418
+ export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
419
+ hostname?: RegExp | undefined;
420
+ protocol?: RegExp | undefined;
421
+ normalize?: boolean | undefined;
422
+ }
423
+ export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
424
+ def: $ZodURLDef;
425
+ }
426
+
427
+ export interface $ZodURL extends $ZodType {
428
+ _zod: $ZodURLInternals;
429
+ }
430
+
431
+ export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
432
+ $ZodStringFormat.init(inst, def);
433
+ inst._zod.check = (payload) => {
434
+ try {
435
+ // Trim whitespace from input
436
+ const trimmed = payload.value.trim();
437
+ // @ts-ignore
438
+ const url = new URL(trimmed);
439
+
440
+ if (def.hostname) {
441
+ def.hostname.lastIndex = 0;
442
+ if (!def.hostname.test(url.hostname)) {
443
+ payload.issues.push({
444
+ code: "invalid_format",
445
+ format: "url",
446
+ note: "Invalid hostname",
447
+ pattern: regexes.hostname.source,
448
+ input: payload.value,
449
+ inst,
450
+ continue: !def.abort,
451
+ });
452
+ }
453
+ }
454
+
455
+ if (def.protocol) {
456
+ def.protocol.lastIndex = 0;
457
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
458
+ payload.issues.push({
459
+ code: "invalid_format",
460
+ format: "url",
461
+ note: "Invalid protocol",
462
+ pattern: def.protocol.source,
463
+ input: payload.value,
464
+ inst,
465
+ continue: !def.abort,
466
+ });
467
+ }
468
+ }
469
+
470
+ // Set the output value based on normalize flag
471
+ if (def.normalize) {
472
+ // Use normalized URL
473
+ payload.value = url.href;
474
+ } else {
475
+ // Preserve the original input (trimmed)
476
+ payload.value = trimmed;
477
+ }
478
+
479
+ return;
480
+ } catch (_) {
481
+ payload.issues.push({
482
+ code: "invalid_format",
483
+ format: "url",
484
+ input: payload.value,
485
+ inst,
486
+ continue: !def.abort,
487
+ });
488
+ }
489
+ };
490
+ });
491
+
492
+ ////////////////////////////// ZodEmoji //////////////////////////////
493
+
494
+ export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {}
495
+ export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {}
496
+
497
+ export interface $ZodEmoji extends $ZodType {
498
+ _zod: $ZodEmojiInternals;
499
+ }
500
+
501
+ export const $ZodEmoji: core.$constructor<$ZodEmoji> = /*@__PURE__*/ core.$constructor(
502
+ "$ZodEmoji",
503
+ (inst, def): void => {
504
+ def.pattern ??= regexes.emoji();
505
+ $ZodStringFormat.init(inst, def);
506
+ }
507
+ );
508
+
509
+ ////////////////////////////// ZodNanoID //////////////////////////////
510
+
511
+ export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {}
512
+ export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {}
513
+
514
+ export interface $ZodNanoID extends $ZodType {
515
+ _zod: $ZodNanoIDInternals;
516
+ }
517
+
518
+ export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$constructor(
519
+ "$ZodNanoID",
520
+ (inst, def): void => {
521
+ def.pattern ??= regexes.nanoid;
522
+ $ZodStringFormat.init(inst, def);
523
+ }
524
+ );
525
+
526
+ ////////////////////////////// ZodCUID //////////////////////////////
527
+
528
+ export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {}
529
+ export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {}
530
+
531
+ export interface $ZodCUID extends $ZodType {
532
+ _zod: $ZodCUIDInternals;
533
+ }
534
+
535
+ export const $ZodCUID: core.$constructor<$ZodCUID> = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def): void => {
536
+ def.pattern ??= regexes.cuid;
537
+ $ZodStringFormat.init(inst, def);
538
+ });
539
+
540
+ ////////////////////////////// ZodCUID2 //////////////////////////////
541
+
542
+ export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {}
543
+ export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {}
544
+
545
+ export interface $ZodCUID2 extends $ZodType {
546
+ _zod: $ZodCUID2Internals;
547
+ }
548
+
549
+ export const $ZodCUID2: core.$constructor<$ZodCUID2> = /*@__PURE__*/ core.$constructor(
550
+ "$ZodCUID2",
551
+ (inst, def): void => {
552
+ def.pattern ??= regexes.cuid2;
553
+ $ZodStringFormat.init(inst, def);
554
+ }
555
+ );
556
+
557
+ ////////////////////////////// ZodULID //////////////////////////////
558
+
559
+ export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {}
560
+ export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {}
561
+
562
+ export interface $ZodULID extends $ZodType {
563
+ _zod: $ZodULIDInternals;
564
+ }
565
+
566
+ export const $ZodULID: core.$constructor<$ZodULID> = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def): void => {
567
+ def.pattern ??= regexes.ulid;
568
+ $ZodStringFormat.init(inst, def);
569
+ });
570
+
571
+ ////////////////////////////// ZodXID //////////////////////////////
572
+
573
+ export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {}
574
+ export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {}
575
+
576
+ export interface $ZodXID extends $ZodType {
577
+ _zod: $ZodXIDInternals;
578
+ }
579
+
580
+ export const $ZodXID: core.$constructor<$ZodXID> = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def): void => {
581
+ def.pattern ??= regexes.xid;
582
+ $ZodStringFormat.init(inst, def);
583
+ });
584
+
585
+ ////////////////////////////// ZodKSUID //////////////////////////////
586
+
587
+ export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {}
588
+ export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {}
589
+
590
+ export interface $ZodKSUID extends $ZodType {
591
+ _zod: $ZodKSUIDInternals;
592
+ }
593
+
594
+ export const $ZodKSUID: core.$constructor<$ZodKSUID> = /*@__PURE__*/ core.$constructor(
595
+ "$ZodKSUID",
596
+ (inst, def): void => {
597
+ def.pattern ??= regexes.ksuid;
598
+ $ZodStringFormat.init(inst, def);
599
+ }
600
+ );
601
+
602
+ ////////////////////////////// ZodISODateTime //////////////////////////////
603
+
604
+ export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
605
+ precision: number | null;
606
+ offset: boolean;
607
+ local: boolean;
608
+ }
609
+
610
+ export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
611
+ def: $ZodISODateTimeDef;
612
+ }
613
+
614
+ export interface $ZodISODateTime extends $ZodType {
615
+ _zod: $ZodISODateTimeInternals;
616
+ }
617
+
618
+ export const $ZodISODateTime: core.$constructor<$ZodISODateTime> = /*@__PURE__*/ core.$constructor(
619
+ "$ZodISODateTime",
620
+ (inst, def): void => {
621
+ def.pattern ??= regexes.datetime(def);
622
+ $ZodStringFormat.init(inst, def);
623
+ }
624
+ );
625
+
626
+ ////////////////////////////// ZodISODate //////////////////////////////
627
+
628
+ export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {}
629
+ export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {}
630
+
631
+ export interface $ZodISODate extends $ZodType {
632
+ _zod: $ZodISODateInternals;
633
+ }
634
+
635
+ export const $ZodISODate: core.$constructor<$ZodISODate> = /*@__PURE__*/ core.$constructor(
636
+ "$ZodISODate",
637
+ (inst, def): void => {
638
+ def.pattern ??= regexes.date;
639
+ $ZodStringFormat.init(inst, def);
640
+ }
641
+ );
642
+
643
+ ////////////////////////////// ZodISOTime //////////////////////////////
644
+
645
+ export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
646
+ precision?: number | null;
647
+ }
648
+
649
+ export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
650
+ def: $ZodISOTimeDef;
651
+ }
652
+
653
+ export interface $ZodISOTime extends $ZodType {
654
+ _zod: $ZodISOTimeInternals;
655
+ }
656
+
657
+ export const $ZodISOTime: core.$constructor<$ZodISOTime> = /*@__PURE__*/ core.$constructor(
658
+ "$ZodISOTime",
659
+ (inst, def): void => {
660
+ def.pattern ??= regexes.time(def);
661
+ $ZodStringFormat.init(inst, def);
662
+ }
663
+ );
664
+
665
+ ////////////////////////////// ZodISODuration //////////////////////////////
666
+
667
+ export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {}
668
+ export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {}
669
+
670
+ export interface $ZodISODuration extends $ZodType {
671
+ _zod: $ZodISODurationInternals;
672
+ }
673
+
674
+ export const $ZodISODuration: core.$constructor<$ZodISODuration> = /*@__PURE__*/ core.$constructor(
675
+ "$ZodISODuration",
676
+ (inst, def): void => {
677
+ def.pattern ??= regexes.duration;
678
+ $ZodStringFormat.init(inst, def);
679
+ }
680
+ );
681
+
682
+ ////////////////////////////// ZodIPv4 //////////////////////////////
683
+
684
+ export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
685
+ version?: "v4";
686
+ }
687
+
688
+ export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
689
+ def: $ZodIPv4Def;
690
+ }
691
+
692
+ export interface $ZodIPv4 extends $ZodType {
693
+ _zod: $ZodIPv4Internals;
694
+ }
695
+
696
+ export const $ZodIPv4: core.$constructor<$ZodIPv4> = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def): void => {
697
+ def.pattern ??= regexes.ipv4;
698
+ $ZodStringFormat.init(inst, def);
699
+ inst._zod.onattach.push((inst) => {
700
+ const bag = inst._zod.bag as $ZodStringInternals<unknown>["bag"];
701
+ bag.format = `ipv4`;
702
+ });
703
+ });
704
+
705
+ ////////////////////////////// ZodIPv6 //////////////////////////////
706
+
707
+ export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
708
+ version?: "v6";
709
+ }
710
+
711
+ export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
712
+ def: $ZodIPv6Def;
713
+ }
714
+
715
+ export interface $ZodIPv6 extends $ZodType {
716
+ _zod: $ZodIPv6Internals;
717
+ }
718
+
719
+ export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def): void => {
720
+ def.pattern ??= regexes.ipv6;
721
+ $ZodStringFormat.init(inst, def);
722
+
723
+ inst._zod.onattach.push((inst) => {
724
+ const bag = inst._zod.bag as $ZodStringInternals<unknown>["bag"];
725
+ bag.format = `ipv6`;
726
+ });
727
+
728
+ inst._zod.check = (payload) => {
729
+ try {
730
+ // @ts-ignore
731
+ new URL(`http://[${payload.value}]`);
732
+ // return;
733
+ } catch {
734
+ payload.issues.push({
735
+ code: "invalid_format",
736
+ format: "ipv6",
737
+ input: payload.value,
738
+ inst,
739
+ continue: !def.abort,
740
+ });
741
+ }
742
+ };
743
+ });
744
+
745
+ ////////////////////////////// ZodCIDRv4 //////////////////////////////
746
+
747
+ export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
748
+ version?: "v4";
749
+ }
750
+
751
+ export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
752
+ def: $ZodCIDRv4Def;
753
+ }
754
+
755
+ export interface $ZodCIDRv4 extends $ZodType {
756
+ _zod: $ZodCIDRv4Internals;
757
+ }
758
+
759
+ export const $ZodCIDRv4: core.$constructor<$ZodCIDRv4> = /*@__PURE__*/ core.$constructor(
760
+ "$ZodCIDRv4",
761
+ (inst, def): void => {
762
+ def.pattern ??= regexes.cidrv4;
763
+ $ZodStringFormat.init(inst, def);
764
+ }
765
+ );
766
+
767
+ ////////////////////////////// ZodCIDRv6 //////////////////////////////
768
+
769
+ export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
770
+ version?: "v6";
771
+ }
772
+
773
+ export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
774
+ def: $ZodCIDRv6Def;
775
+ }
776
+
777
+ export interface $ZodCIDRv6 extends $ZodType {
778
+ _zod: $ZodCIDRv6Internals;
779
+ }
780
+
781
+ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$constructor(
782
+ "$ZodCIDRv6",
783
+ (inst, def): void => {
784
+ def.pattern ??= regexes.cidrv6; // not used for validation
785
+ $ZodStringFormat.init(inst, def);
786
+
787
+ inst._zod.check = (payload) => {
788
+ const [address, prefix] = payload.value.split("/");
789
+ try {
790
+ if (!prefix) throw new Error();
791
+ const prefixNum = Number(prefix);
792
+ if (`${prefixNum}` !== prefix) throw new Error();
793
+ if (prefixNum < 0 || prefixNum > 128) throw new Error();
794
+ // @ts-ignore
795
+ new URL(`http://[${address}]`);
796
+ } catch {
797
+ payload.issues.push({
798
+ code: "invalid_format",
799
+ format: "cidrv6",
800
+ input: payload.value,
801
+ inst,
802
+ continue: !def.abort,
803
+ });
804
+ }
805
+ };
806
+ }
807
+ );
808
+
809
+ ////////////////////////////// ZodBase64 //////////////////////////////
810
+ export function isValidBase64(data: string): boolean {
811
+ if (data === "") return true;
812
+ if (data.length % 4 !== 0) return false;
813
+ try {
814
+ // @ts-ignore
815
+ atob(data);
816
+ return true;
817
+ } catch {
818
+ return false;
819
+ }
820
+ }
821
+
822
+ export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {}
823
+ export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {}
824
+
825
+ export interface $ZodBase64 extends $ZodType {
826
+ _zod: $ZodBase64Internals;
827
+ }
828
+
829
+ export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$constructor(
830
+ "$ZodBase64",
831
+ (inst, def): void => {
832
+ def.pattern ??= regexes.base64;
833
+ $ZodStringFormat.init(inst, def);
834
+
835
+ inst._zod.onattach.push((inst) => {
836
+ inst._zod.bag.contentEncoding = "base64";
837
+ });
838
+
839
+ inst._zod.check = (payload) => {
840
+ if (isValidBase64(payload.value)) return;
841
+
842
+ payload.issues.push({
843
+ code: "invalid_format",
844
+ format: "base64",
845
+ input: payload.value,
846
+ inst,
847
+ continue: !def.abort,
848
+ });
849
+ };
850
+ }
851
+ );
852
+
853
+ ////////////////////////////// ZodBase64 //////////////////////////////
854
+ export function isValidBase64URL(data: string): boolean {
855
+ if (!regexes.base64url.test(data)) return false;
856
+ const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
857
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
858
+ return isValidBase64(padded);
859
+ }
860
+
861
+ export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {}
862
+ export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {}
863
+
864
+ export interface $ZodBase64URL extends $ZodType {
865
+ _zod: $ZodBase64URLInternals;
866
+ }
867
+
868
+ export const $ZodBase64URL: core.$constructor<$ZodBase64URL> = /*@__PURE__*/ core.$constructor(
869
+ "$ZodBase64URL",
870
+ (inst, def): void => {
871
+ def.pattern ??= regexes.base64url;
872
+ $ZodStringFormat.init(inst, def);
873
+
874
+ inst._zod.onattach.push((inst) => {
875
+ inst._zod.bag.contentEncoding = "base64url";
876
+ });
877
+
878
+ inst._zod.check = (payload) => {
879
+ if (isValidBase64URL(payload.value)) return;
880
+
881
+ payload.issues.push({
882
+ code: "invalid_format",
883
+ format: "base64url",
884
+ input: payload.value,
885
+ inst,
886
+ continue: !def.abort,
887
+ });
888
+ };
889
+ }
890
+ );
891
+
892
+ ////////////////////////////// ZodE164 //////////////////////////////
893
+
894
+ export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {}
895
+ export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {}
896
+
897
+ export interface $ZodE164 extends $ZodType {
898
+ _zod: $ZodE164Internals;
899
+ }
900
+
901
+ export const $ZodE164: core.$constructor<$ZodE164> = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def): void => {
902
+ def.pattern ??= regexes.e164;
903
+ $ZodStringFormat.init(inst, def);
904
+ });
905
+
906
+ ////////////////////////////// ZodJWT //////////////////////////////
907
+
908
+ export function isValidJWT(token: string, algorithm: util.JWTAlgorithm | null = null): boolean {
909
+ try {
910
+ const tokensParts = token.split(".");
911
+ if (tokensParts.length !== 3) return false;
912
+ const [header] = tokensParts;
913
+ if (!header) return false;
914
+ // @ts-ignore
915
+ const parsedHeader = JSON.parse(atob(header));
916
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
917
+ if (!parsedHeader.alg) return false;
918
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
919
+ return true;
920
+ } catch {
921
+ return false;
922
+ }
923
+ }
924
+
925
+ export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
926
+ alg?: util.JWTAlgorithm | undefined;
927
+ }
928
+
929
+ export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
930
+ def: $ZodJWTDef;
931
+ }
932
+
933
+ export interface $ZodJWT extends $ZodType {
934
+ _zod: $ZodJWTInternals;
935
+ }
936
+
937
+ export const $ZodJWT: core.$constructor<$ZodJWT> = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def): void => {
938
+ $ZodStringFormat.init(inst, def);
939
+ inst._zod.check = (payload) => {
940
+ if (isValidJWT(payload.value, def.alg)) return;
941
+
942
+ payload.issues.push({
943
+ code: "invalid_format",
944
+ format: "jwt",
945
+ input: payload.value,
946
+ inst,
947
+ continue: !def.abort,
948
+ });
949
+ };
950
+ });
951
+
952
+ ////////////////////////////// ZodCustomStringFormat //////////////////////////////
953
+
954
+ export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
955
+ fn: (val: string) => unknown;
956
+ }
957
+
958
+ export interface $ZodCustomStringFormatInternals<Format extends string = string>
959
+ extends $ZodStringFormatInternals<Format> {
960
+ def: $ZodCustomStringFormatDef<Format>;
961
+ }
962
+
963
+ export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
964
+ _zod: $ZodCustomStringFormatInternals<Format>;
965
+ }
966
+
967
+ export const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat> = /*@__PURE__*/ core.$constructor(
968
+ "$ZodCustomStringFormat",
969
+ (inst, def): void => {
970
+ $ZodStringFormat.init(inst, def);
971
+ inst._zod.check = (payload) => {
972
+ if (def.fn(payload.value)) return;
973
+
974
+ payload.issues.push({
975
+ code: "invalid_format",
976
+ format: def.format,
977
+ input: payload.value,
978
+ inst,
979
+ continue: !def.abort,
980
+ });
981
+ };
982
+ }
983
+ );
984
+
985
+ /////////////////////////////////////////
986
+ /////////////////////////////////////////
987
+ ////////// //////////
988
+ ////////// ZodNumber //////////
989
+ ////////// //////////
990
+ /////////////////////////////////////////
991
+ /////////////////////////////////////////
992
+
993
+ export interface $ZodNumberDef extends $ZodTypeDef {
994
+ type: "number";
995
+ coerce?: boolean;
996
+ // checks: checks.$ZodCheck<number>[];
997
+ }
998
+
999
+ export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
1000
+ def: $ZodNumberDef;
1001
+ /** @deprecated Internal API, use with caution (not deprecated) */
1002
+ pattern: RegExp;
1003
+ /** @deprecated Internal API, use with caution (not deprecated) */
1004
+ isst: errors.$ZodIssueInvalidType;
1005
+ bag: util.LoosePartial<{
1006
+ minimum: number;
1007
+ maximum: number;
1008
+ exclusiveMinimum: number;
1009
+ exclusiveMaximum: number;
1010
+ format: string;
1011
+ pattern: RegExp;
1012
+ }>;
1013
+ }
1014
+
1015
+ export interface $ZodNumber<Input = unknown> extends $ZodType {
1016
+ _zod: $ZodNumberInternals<Input>;
1017
+ }
1018
+
1019
+ export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
1020
+ $ZodType.init(inst, def);
1021
+ inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
1022
+
1023
+ inst._zod.parse = (payload, _ctx) => {
1024
+ if (def.coerce)
1025
+ try {
1026
+ payload.value = Number(payload.value);
1027
+ } catch (_) {}
1028
+ const input = payload.value;
1029
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
1030
+ return payload;
1031
+ }
1032
+
1033
+ const received =
1034
+ typeof input === "number"
1035
+ ? Number.isNaN(input)
1036
+ ? "NaN"
1037
+ : !Number.isFinite(input)
1038
+ ? "Infinity"
1039
+ : undefined
1040
+ : undefined;
1041
+
1042
+ payload.issues.push({
1043
+ expected: "number",
1044
+ code: "invalid_type",
1045
+
1046
+ input,
1047
+ inst,
1048
+ ...(received ? { received } : {}),
1049
+ });
1050
+ return payload;
1051
+ };
1052
+ });
1053
+
1054
+ ///////////////////////////////////////////////
1055
+ ////////// ZodNumberFormat //////////
1056
+ ///////////////////////////////////////////////
1057
+ export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {}
1058
+
1059
+ export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
1060
+ def: $ZodNumberFormatDef;
1061
+ isst: errors.$ZodIssueInvalidType;
1062
+ }
1063
+
1064
+ export interface $ZodNumberFormat extends $ZodType {
1065
+ _zod: $ZodNumberFormatInternals;
1066
+ }
1067
+
1068
+ export const $ZodNumberFormat: core.$constructor<$ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
1069
+ "$ZodNumber",
1070
+ (inst, def) => {
1071
+ checks.$ZodCheckNumberFormat.init(inst, def);
1072
+ $ZodNumber.init(inst, def); // no format checksp
1073
+ }
1074
+ );
1075
+
1076
+ ///////////////////////////////////////////
1077
+ ///////////////////////////////////////////
1078
+ ////////// ///////////
1079
+ ////////// $ZodBoolean //////////
1080
+ ////////// ///////////
1081
+ ///////////////////////////////////////////
1082
+ ///////////////////////////////////////////
1083
+
1084
+ export interface $ZodBooleanDef extends $ZodTypeDef {
1085
+ type: "boolean";
1086
+ coerce?: boolean;
1087
+ checks?: checks.$ZodCheck<boolean>[];
1088
+ }
1089
+
1090
+ export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
1091
+ pattern: RegExp;
1092
+ def: $ZodBooleanDef;
1093
+ isst: errors.$ZodIssueInvalidType;
1094
+ }
1095
+
1096
+ export interface $ZodBoolean<T = unknown> extends $ZodType {
1097
+ _zod: $ZodBooleanInternals<T>;
1098
+ }
1099
+
1100
+ export const $ZodBoolean: core.$constructor<$ZodBoolean> = /*@__PURE__*/ core.$constructor(
1101
+ "$ZodBoolean",
1102
+ (inst, def) => {
1103
+ $ZodType.init(inst, def);
1104
+ inst._zod.pattern = regexes.boolean;
1105
+
1106
+ inst._zod.parse = (payload, _ctx) => {
1107
+ if (def.coerce)
1108
+ try {
1109
+ payload.value = Boolean(payload.value);
1110
+ } catch (_) {}
1111
+ const input = payload.value;
1112
+ if (typeof input === "boolean") return payload;
1113
+ payload.issues.push({
1114
+ expected: "boolean",
1115
+ code: "invalid_type",
1116
+
1117
+ input,
1118
+ inst,
1119
+ });
1120
+ return payload;
1121
+ };
1122
+ }
1123
+ );
1124
+
1125
+ //////////////////////////////////////////
1126
+ //////////////////////////////////////////
1127
+ ////////// //////////
1128
+ ////////// $ZodBigInt //////////
1129
+ ////////// //////////
1130
+ //////////////////////////////////////////
1131
+ //////////////////////////////////////////
1132
+
1133
+ export interface $ZodBigIntDef extends $ZodTypeDef {
1134
+ type: "bigint";
1135
+ coerce?: boolean;
1136
+ // checks: checks.$ZodCheck<bigint>[];
1137
+ }
1138
+
1139
+ export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
1140
+ pattern: RegExp;
1141
+ /** @internal Internal API, use with caution */
1142
+ def: $ZodBigIntDef;
1143
+ isst: errors.$ZodIssueInvalidType;
1144
+ bag: util.LoosePartial<{
1145
+ minimum: bigint;
1146
+ maximum: bigint;
1147
+ format: string;
1148
+ }>;
1149
+ }
1150
+
1151
+ export interface $ZodBigInt<T = unknown> extends $ZodType {
1152
+ _zod: $ZodBigIntInternals<T>;
1153
+ }
1154
+
1155
+ export const $ZodBigInt: core.$constructor<$ZodBigInt> = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
1156
+ $ZodType.init(inst, def);
1157
+ inst._zod.pattern = regexes.bigint;
1158
+
1159
+ inst._zod.parse = (payload, _ctx) => {
1160
+ if (def.coerce)
1161
+ try {
1162
+ payload.value = BigInt(payload.value);
1163
+ } catch (_) {}
1164
+
1165
+ if (typeof payload.value === "bigint") return payload;
1166
+ payload.issues.push({
1167
+ expected: "bigint",
1168
+ code: "invalid_type",
1169
+
1170
+ input: payload.value,
1171
+ inst,
1172
+ });
1173
+ return payload;
1174
+ };
1175
+ });
1176
+
1177
+ ///////////////////////////////////////////////
1178
+ ////////// ZodBigIntFormat //////////
1179
+ ///////////////////////////////////////////////
1180
+ export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
1181
+ check: "bigint_format";
1182
+ }
1183
+
1184
+ export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
1185
+ def: $ZodBigIntFormatDef;
1186
+ }
1187
+
1188
+ export interface $ZodBigIntFormat extends $ZodType {
1189
+ _zod: $ZodBigIntFormatInternals;
1190
+ }
1191
+
1192
+ export const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
1193
+ "$ZodBigInt",
1194
+ (inst, def) => {
1195
+ checks.$ZodCheckBigIntFormat.init(inst, def);
1196
+ $ZodBigInt.init(inst, def); // no format checks
1197
+ }
1198
+ );
1199
+
1200
+ ////////////////////////////////////////////
1201
+ ////////////////////////////////////////////
1202
+ ////////// //////////
1203
+ ////////// $ZodSymbol //////////
1204
+ ////////// //////////
1205
+ ////////////////////////////////////////////
1206
+ ////////////////////////////////////////////
1207
+ export interface $ZodSymbolDef extends $ZodTypeDef {
1208
+ type: "symbol";
1209
+ }
1210
+
1211
+ export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
1212
+ def: $ZodSymbolDef;
1213
+ isst: errors.$ZodIssueInvalidType;
1214
+ }
1215
+
1216
+ export interface $ZodSymbol extends $ZodType {
1217
+ _zod: $ZodSymbolInternals;
1218
+ }
1219
+
1220
+ export const $ZodSymbol: core.$constructor<$ZodSymbol> = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
1221
+ $ZodType.init(inst, def);
1222
+
1223
+ inst._zod.parse = (payload, _ctx) => {
1224
+ const input = payload.value;
1225
+ if (typeof input === "symbol") return payload;
1226
+ payload.issues.push({
1227
+ expected: "symbol",
1228
+ code: "invalid_type",
1229
+
1230
+ input,
1231
+ inst,
1232
+ });
1233
+ return payload;
1234
+ };
1235
+ });
1236
+
1237
+ ////////////////////////////////////////////
1238
+ ////////////////////////////////////////////
1239
+ ////////// //////////
1240
+ ////////// $ZodUndefined //////////
1241
+ ////////// //////////
1242
+ ////////////////////////////////////////////
1243
+ ////////////////////////////////////////////
1244
+ export interface $ZodUndefinedDef extends $ZodTypeDef {
1245
+ type: "undefined";
1246
+ }
1247
+
1248
+ export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
1249
+ pattern: RegExp;
1250
+ def: $ZodUndefinedDef;
1251
+ values: util.PrimitiveSet;
1252
+ isst: errors.$ZodIssueInvalidType;
1253
+ }
1254
+
1255
+ export interface $ZodUndefined extends $ZodType {
1256
+ _zod: $ZodUndefinedInternals;
1257
+ }
1258
+
1259
+ export const $ZodUndefined: core.$constructor<$ZodUndefined> = /*@__PURE__*/ core.$constructor(
1260
+ "$ZodUndefined",
1261
+ (inst, def) => {
1262
+ $ZodType.init(inst, def);
1263
+ inst._zod.pattern = regexes.undefined;
1264
+ inst._zod.values = new Set([undefined]);
1265
+ inst._zod.optin = "optional";
1266
+ inst._zod.optout = "optional";
1267
+
1268
+ inst._zod.parse = (payload, _ctx) => {
1269
+ const input = payload.value;
1270
+ if (typeof input === "undefined") return payload;
1271
+ payload.issues.push({
1272
+ expected: "undefined",
1273
+ code: "invalid_type",
1274
+
1275
+ input,
1276
+ inst,
1277
+ });
1278
+ return payload;
1279
+ };
1280
+ }
1281
+ );
1282
+
1283
+ ///////////////////////////////////////
1284
+ ///////////////////////////////////////
1285
+ ////////// //////////
1286
+ ////////// $ZodNull /////////
1287
+ ////////// //////////
1288
+ ///////////////////////////////////////
1289
+ ///////////////////////////////////////
1290
+
1291
+ export interface $ZodNullDef extends $ZodTypeDef {
1292
+ type: "null";
1293
+ }
1294
+
1295
+ export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
1296
+ pattern: RegExp;
1297
+ def: $ZodNullDef;
1298
+ values: util.PrimitiveSet;
1299
+ isst: errors.$ZodIssueInvalidType;
1300
+ }
1301
+
1302
+ export interface $ZodNull extends $ZodType {
1303
+ _zod: $ZodNullInternals;
1304
+ }
1305
+
1306
+ export const $ZodNull: core.$constructor<$ZodNull> = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
1307
+ $ZodType.init(inst, def);
1308
+ inst._zod.pattern = regexes.null;
1309
+ inst._zod.values = new Set([null]);
1310
+
1311
+ inst._zod.parse = (payload, _ctx) => {
1312
+ const input = payload.value;
1313
+ if (input === null) return payload;
1314
+ payload.issues.push({
1315
+ expected: "null",
1316
+ code: "invalid_type",
1317
+
1318
+ input,
1319
+ inst,
1320
+ });
1321
+ return payload;
1322
+ };
1323
+ });
1324
+
1325
+ //////////////////////////////////////
1326
+ //////////////////////////////////////
1327
+ ////////// //////////
1328
+ ////////// $ZodAny //////////
1329
+ ////////// //////////
1330
+ //////////////////////////////////////
1331
+ //////////////////////////////////////
1332
+
1333
+ export interface $ZodAnyDef extends $ZodTypeDef {
1334
+ type: "any";
1335
+ }
1336
+
1337
+ export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
1338
+ def: $ZodAnyDef;
1339
+ isst: never;
1340
+ }
1341
+
1342
+ export interface $ZodAny extends $ZodType {
1343
+ _zod: $ZodAnyInternals;
1344
+ }
1345
+
1346
+ export const $ZodAny: core.$constructor<$ZodAny> = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
1347
+ $ZodType.init(inst, def);
1348
+
1349
+ inst._zod.parse = (payload) => payload;
1350
+ });
1351
+
1352
+ //////////////////////////////////////////
1353
+ //////////////////////////////////////////
1354
+ ////////// //////////
1355
+ ////////// $ZodUnknown //////////
1356
+ ////////// //////////
1357
+ //////////////////////////////////////////
1358
+ //////////////////////////////////////////
1359
+
1360
+ export interface $ZodUnknownDef extends $ZodTypeDef {
1361
+ type: "unknown";
1362
+ }
1363
+
1364
+ export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
1365
+ def: $ZodUnknownDef;
1366
+ isst: never;
1367
+ }
1368
+
1369
+ export interface $ZodUnknown extends $ZodType {
1370
+ _zod: $ZodUnknownInternals;
1371
+ }
1372
+
1373
+ export const $ZodUnknown: core.$constructor<$ZodUnknown> = /*@__PURE__*/ core.$constructor(
1374
+ "$ZodUnknown",
1375
+ (inst, def) => {
1376
+ $ZodType.init(inst, def);
1377
+
1378
+ inst._zod.parse = (payload) => payload;
1379
+ }
1380
+ );
1381
+
1382
+ /////////////////////////////////////////
1383
+ /////////////////////////////////////////
1384
+ ////////// //////////
1385
+ ////////// $ZodNever //////////
1386
+ ////////// //////////
1387
+ /////////////////////////////////////////
1388
+ /////////////////////////////////////////
1389
+
1390
+ export interface $ZodNeverDef extends $ZodTypeDef {
1391
+ type: "never";
1392
+ }
1393
+
1394
+ export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
1395
+ def: $ZodNeverDef;
1396
+ isst: errors.$ZodIssueInvalidType;
1397
+ }
1398
+
1399
+ export interface $ZodNever extends $ZodType {
1400
+ _zod: $ZodNeverInternals;
1401
+ }
1402
+
1403
+ export const $ZodNever: core.$constructor<$ZodNever> = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
1404
+ $ZodType.init(inst, def);
1405
+ inst._zod.parse = (payload, _ctx) => {
1406
+ payload.issues.push({
1407
+ expected: "never",
1408
+ code: "invalid_type",
1409
+
1410
+ input: payload.value,
1411
+ inst,
1412
+ });
1413
+ return payload;
1414
+ };
1415
+ });
1416
+
1417
+ ////////////////////////////////////////
1418
+ ////////////////////////////////////////
1419
+ ////////// //////////
1420
+ ////////// $ZodVoid //////////
1421
+ ////////// //////////
1422
+ ////////////////////////////////////////
1423
+ ////////////////////////////////////////
1424
+
1425
+ export interface $ZodVoidDef extends $ZodTypeDef {
1426
+ type: "void";
1427
+ }
1428
+
1429
+ export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
1430
+ def: $ZodVoidDef;
1431
+ isst: errors.$ZodIssueInvalidType;
1432
+ }
1433
+
1434
+ export interface $ZodVoid extends $ZodType {
1435
+ _zod: $ZodVoidInternals;
1436
+ }
1437
+
1438
+ export const $ZodVoid: core.$constructor<$ZodVoid> = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
1439
+ $ZodType.init(inst, def);
1440
+
1441
+ inst._zod.parse = (payload, _ctx) => {
1442
+ const input = payload.value;
1443
+ if (typeof input === "undefined") return payload;
1444
+ payload.issues.push({
1445
+ expected: "void",
1446
+ code: "invalid_type",
1447
+
1448
+ input,
1449
+ inst,
1450
+ });
1451
+ return payload;
1452
+ };
1453
+ });
1454
+
1455
+ ///////////////////////////////////////
1456
+ ///////////////////////////////////////
1457
+ ////////// ////////
1458
+ ////////// $ZodDate ////////
1459
+ ////////// ////////
1460
+ ///////////////////////////////////////
1461
+ ///////////////////////////////////////
1462
+ export interface $ZodDateDef extends $ZodTypeDef {
1463
+ type: "date";
1464
+ coerce?: boolean;
1465
+ }
1466
+
1467
+ export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
1468
+ def: $ZodDateDef;
1469
+ isst: errors.$ZodIssueInvalidType; // | errors.$ZodIssueInvalidDate;
1470
+ bag: util.LoosePartial<{
1471
+ minimum: Date;
1472
+ maximum: Date;
1473
+ format: string;
1474
+ }>;
1475
+ }
1476
+
1477
+ export interface $ZodDate<T = unknown> extends $ZodType {
1478
+ _zod: $ZodDateInternals<T>;
1479
+ }
1480
+
1481
+ export const $ZodDate: core.$constructor<$ZodDate> = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
1482
+ $ZodType.init(inst, def);
1483
+
1484
+ inst._zod.parse = (payload, _ctx) => {
1485
+ if (def.coerce) {
1486
+ try {
1487
+ payload.value = new Date(payload.value as string | number | Date);
1488
+ } catch (_err: any) {}
1489
+ }
1490
+ const input = payload.value;
1491
+
1492
+ const isDate = input instanceof Date;
1493
+ const isValidDate = isDate && !Number.isNaN(input.getTime());
1494
+ if (isValidDate) return payload;
1495
+ payload.issues.push({
1496
+ expected: "date",
1497
+ code: "invalid_type",
1498
+
1499
+ input,
1500
+ ...(isDate ? { received: "Invalid Date" } : {}),
1501
+ inst,
1502
+ });
1503
+
1504
+ return payload;
1505
+ };
1506
+ });
1507
+
1508
+ /////////////////////////////////////////
1509
+ /////////////////////////////////////////
1510
+ ////////// //////////
1511
+ ////////// $ZodArray //////////
1512
+ ////////// //////////
1513
+ /////////////////////////////////////////
1514
+ /////////////////////////////////////////
1515
+
1516
+ export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
1517
+ type: "array";
1518
+ element: T;
1519
+ }
1520
+
1521
+ export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
1522
+ //$ZodTypeInternals<core.output<T>[], core.input<T>[]> {
1523
+ def: $ZodArrayDef<T>;
1524
+ isst: errors.$ZodIssueInvalidType;
1525
+ output: core.output<T>[];
1526
+ input: core.input<T>[];
1527
+ }
1528
+
1529
+ export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
1530
+
1531
+ function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
1532
+ if (result.issues.length) {
1533
+ final.issues.push(...util.prefixIssues(index, result.issues));
1534
+ }
1535
+ final.value[index] = result.value;
1536
+ }
1537
+
1538
+ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
1539
+ $ZodType.init(inst, def);
1540
+
1541
+ inst._zod.parse = (payload, ctx) => {
1542
+ const input = payload.value;
1543
+
1544
+ if (!Array.isArray(input)) {
1545
+ payload.issues.push({
1546
+ expected: "array",
1547
+ code: "invalid_type",
1548
+
1549
+ input,
1550
+ inst,
1551
+ });
1552
+ return payload;
1553
+ }
1554
+
1555
+ payload.value = Array(input.length);
1556
+ const proms: Promise<any>[] = [];
1557
+ for (let i = 0; i < input.length; i++) {
1558
+ const item = input[i];
1559
+ const result = def.element._zod.run(
1560
+ {
1561
+ value: item,
1562
+ issues: [],
1563
+ },
1564
+ ctx
1565
+ );
1566
+
1567
+ if (result instanceof Promise) {
1568
+ proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1569
+ } else {
1570
+ handleArrayResult(result, payload, i);
1571
+ }
1572
+ }
1573
+
1574
+ if (proms.length) {
1575
+ return Promise.all(proms).then(() => payload);
1576
+ }
1577
+
1578
+ return payload; //handleArrayResultsAsync(parseResults, final);
1579
+ };
1580
+ });
1581
+
1582
+ //////////////////////////////////////////
1583
+ //////////////////////////////////////////
1584
+ ////////// //////////
1585
+ ////////// $ZodObject //////////
1586
+ ////////// //////////
1587
+ //////////////////////////////////////////
1588
+ //////////////////////////////////////////
1589
+
1590
+ type OptionalOutSchema = { _zod: { optout: "optional" } };
1591
+ type OptionalInSchema = { _zod: { optin: "optional" } };
1592
+
1593
+ export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1594
+ ? util.IsAny<T[keyof T]> extends true
1595
+ ? Record<string, unknown>
1596
+ : Record<string, core.output<T[keyof T]>>
1597
+ : keyof (T & Extra) extends never
1598
+ ? Record<string, never>
1599
+ : util.Prettify<
1600
+ {
1601
+ -readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
1602
+ } & {
1603
+ -readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
1604
+ } & Extra
1605
+ >;
1606
+
1607
+ // experimental
1608
+ // export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = keyof (T &
1609
+ // Extra) extends never
1610
+ // ? Record<string, never>
1611
+ // : string extends keyof T
1612
+ // ? util.Prettify<
1613
+ // {
1614
+ // [k: string]: util.IsAny<T[string]["_zod"]["output"]> extends true ? unknown : T[string]["_zod"]["output"];
1615
+ // } & $InferObjectOutputNoIndex<util.OmitIndexSignature<T>, Extra>
1616
+ // >
1617
+ // : util.Prettify<$InferObjectOutputNoIndex<T, Extra>>;
1618
+
1619
+ // export type $InferObjectOutputNoIndex<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = {
1620
+ // [k in keyof T as string extends k
1621
+ // ? never
1622
+ // : k extends string
1623
+ // ? T[k] extends OptionalOutSchema
1624
+ // ? never
1625
+ // : k
1626
+ // : never]: T[k]["_zod"]["output"];
1627
+ // } & {
1628
+ // [k in keyof T as string extends k
1629
+ // ? never
1630
+ // : k extends string
1631
+ // ? T[k] extends OptionalOutSchema
1632
+ // ? k
1633
+ // : never
1634
+ // : never]?: T[k]["_zod"]["output"];
1635
+ // } & Extra;
1636
+
1637
+ export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1638
+ ? util.IsAny<T[keyof T]> extends true
1639
+ ? Record<string, unknown>
1640
+ : Record<string, core.input<T[keyof T]>>
1641
+ : keyof (T & Extra) extends never
1642
+ ? Record<string, never>
1643
+ : util.Prettify<
1644
+ {
1645
+ -readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
1646
+ } & {
1647
+ -readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
1648
+ } & Extra
1649
+ >;
1650
+
1651
+ function handlePropertyResult(result: ParsePayload, final: ParsePayload, key: PropertyKey, input: any) {
1652
+ if (result.issues.length) {
1653
+ final.issues.push(...util.prefixIssues(key, result.issues));
1654
+ }
1655
+
1656
+ if (result.value === undefined) {
1657
+ if (key in input) {
1658
+ (final.value as any)[key] = undefined;
1659
+ }
1660
+ } else {
1661
+ (final.value as any)[key] = result.value;
1662
+ }
1663
+ }
1664
+
1665
+ export type $ZodObjectConfig = { out: Record<string, unknown>; in: Record<string, unknown> };
1666
+
1667
+ export type $loose = {
1668
+ out: Record<string, unknown>;
1669
+ in: Record<string, unknown>;
1670
+ };
1671
+ export type $strict = {
1672
+ out: {};
1673
+ in: {};
1674
+ };
1675
+ export type $strip = {
1676
+ out: {};
1677
+ in: {};
1678
+ };
1679
+
1680
+ export type $catchall<T extends SomeType> = {
1681
+ out: { [k: string]: core.output<T> };
1682
+ in: { [k: string]: core.input<T> };
1683
+ };
1684
+
1685
+ export type $ZodShape = Readonly<{ [k: string]: $ZodType }>;
1686
+
1687
+ export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
1688
+ type: "object";
1689
+ shape: Shape;
1690
+ catchall?: $ZodType | undefined;
1691
+ }
1692
+
1693
+ export interface $ZodObjectInternals<
1694
+ /** @ts-ignore Cast variance */
1695
+ out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>,
1696
+ out Config extends $ZodObjectConfig = $ZodObjectConfig,
1697
+ > extends _$ZodTypeInternals {
1698
+ def: $ZodObjectDef<Shape>;
1699
+ config: Config;
1700
+ isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
1701
+ propValues: util.PropValues;
1702
+ output: $InferObjectOutput<Shape, Config["out"]>;
1703
+ input: $InferObjectInput<Shape, Config["in"]>;
1704
+ optin?: "optional" | undefined;
1705
+ optout?: "optional" | undefined;
1706
+ }
1707
+ export type $ZodLooseShape = Record<string, any>;
1708
+
1709
+ export interface $ZodObject<
1710
+ /** @ts-ignore Cast variance */
1711
+ out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>,
1712
+ out Params extends $ZodObjectConfig = $ZodObjectConfig,
1713
+ > extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {
1714
+ "~standard": $ZodStandardSchema<this>;
1715
+ }
1716
+
1717
+ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
1718
+ // requires cast because technically $ZodObject doesn't extend
1719
+ $ZodType.init(inst, def);
1720
+
1721
+ const _normalized = util.cached(() => {
1722
+ const keys = Object.keys(def.shape);
1723
+ for (const k of keys) {
1724
+ if (!(def.shape[k] instanceof $ZodType)) {
1725
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1726
+ }
1727
+ }
1728
+ const okeys = util.optionalKeys(def.shape);
1729
+
1730
+ return {
1731
+ shape: def.shape,
1732
+ keys,
1733
+ keySet: new Set(keys),
1734
+ numKeys: keys.length,
1735
+ optionalKeys: new Set(okeys),
1736
+ };
1737
+ });
1738
+
1739
+ util.defineLazy(inst._zod, "propValues", () => {
1740
+ const shape = def.shape;
1741
+ const propValues: util.PropValues = {};
1742
+ for (const key in shape) {
1743
+ const field = shape[key]!._zod;
1744
+ if (field.values) {
1745
+ propValues[key] ??= new Set();
1746
+ for (const v of field.values) propValues[key].add(v);
1747
+ }
1748
+ }
1749
+ return propValues;
1750
+ });
1751
+
1752
+ const generateFastpass = (shape: any) => {
1753
+ const doc = new Doc(["shape", "payload", "ctx"]);
1754
+ const normalized = _normalized.value;
1755
+
1756
+ const parseStr = (key: string) => {
1757
+ const k = util.esc(key);
1758
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1759
+ };
1760
+
1761
+ doc.write(`const input = payload.value;`);
1762
+
1763
+ const ids: any = Object.create(null);
1764
+ let counter = 0;
1765
+ for (const key of normalized.keys) {
1766
+ ids[key] = `key_${counter++}`;
1767
+ }
1768
+
1769
+ // A: preserve key order {
1770
+ doc.write(`const newResult = {}`);
1771
+ for (const key of normalized.keys) {
1772
+ const id = ids[key];
1773
+ const k = util.esc(key);
1774
+ doc.write(`const ${id} = ${parseStr(key)};`);
1775
+ doc.write(`
1776
+ if (${id}.issues.length) {
1777
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1778
+ ...iss,
1779
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1780
+ })));
1781
+ }
1782
+
1783
+ if (${id}.value === undefined) {
1784
+ if (${k} in input) {
1785
+ newResult[${k}] = undefined;
1786
+ }
1787
+ } else {
1788
+ newResult[${k}] = ${id}.value;
1789
+ }
1790
+ `);
1791
+ }
1792
+
1793
+ doc.write(`payload.value = newResult;`);
1794
+ doc.write(`return payload;`);
1795
+ const fn = doc.compile();
1796
+ return (payload: any, ctx: any) => fn(shape, payload, ctx);
1797
+ };
1798
+
1799
+ let fastpass!: ReturnType<typeof generateFastpass>;
1800
+
1801
+ const isObject = util.isObject;
1802
+ const jit = !core.globalConfig.jitless;
1803
+ const allowsEval = util.allowsEval;
1804
+
1805
+ const fastEnabled = jit && allowsEval.value; // && !def.catchall;
1806
+ const catchall = def.catchall;
1807
+
1808
+ let value!: typeof _normalized.value;
1809
+
1810
+ inst._zod.parse = (payload, ctx) => {
1811
+ value ??= _normalized.value;
1812
+ const input = payload.value;
1813
+ if (!isObject(input)) {
1814
+ payload.issues.push({
1815
+ expected: "object",
1816
+ code: "invalid_type",
1817
+
1818
+ input,
1819
+ inst,
1820
+ });
1821
+ return payload;
1822
+ }
1823
+
1824
+ const proms: Promise<any>[] = [];
1825
+
1826
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1827
+ // always synchronous
1828
+ if (!fastpass) fastpass = generateFastpass(def.shape);
1829
+ payload = fastpass(payload, ctx);
1830
+ } else {
1831
+ payload.value = {};
1832
+
1833
+ const shape = value.shape;
1834
+ for (const key of value.keys) {
1835
+ const el = shape[key]!;
1836
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1837
+ if (r instanceof Promise) {
1838
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1839
+ } else {
1840
+ handlePropertyResult(r, payload, key, input);
1841
+ }
1842
+ }
1843
+ }
1844
+
1845
+ if (!catchall) {
1846
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
1847
+ }
1848
+ const unrecognized: string[] = [];
1849
+ // iterate over input keys
1850
+ const keySet = value.keySet;
1851
+ const _catchall = catchall._zod;
1852
+ const t = _catchall.def.type;
1853
+ for (const key of Object.keys(input)) {
1854
+ if (keySet.has(key)) continue;
1855
+ if (t === "never") {
1856
+ unrecognized.push(key);
1857
+ continue;
1858
+ }
1859
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1860
+
1861
+ if (r instanceof Promise) {
1862
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1863
+ } else {
1864
+ handlePropertyResult(r, payload, key, input);
1865
+ }
1866
+ }
1867
+
1868
+ if (unrecognized.length) {
1869
+ payload.issues.push({
1870
+ code: "unrecognized_keys",
1871
+
1872
+ keys: unrecognized,
1873
+ input,
1874
+ inst,
1875
+ });
1876
+ }
1877
+
1878
+ if (!proms.length) return payload;
1879
+ return Promise.all(proms).then(() => {
1880
+ return payload;
1881
+ });
1882
+ };
1883
+ });
1884
+
1885
+ /////////////////////////////////////////
1886
+ /////////////////////////////////////////
1887
+ ////////// ///////////
1888
+ ////////// $ZodUnion //////////
1889
+ ////////// ///////////
1890
+ /////////////////////////////////////////
1891
+ /////////////////////////////////////////
1892
+ // use generic to distribute union types
1893
+ export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
1894
+ export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
1895
+ export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
1896
+ type: "union";
1897
+ options: Options;
1898
+ }
1899
+
1900
+ type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
1901
+ type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
1902
+
1903
+ export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
1904
+ def: $ZodUnionDef<T>;
1905
+ isst: errors.$ZodIssueInvalidUnion;
1906
+ pattern: T[number]["_zod"]["pattern"];
1907
+ values: T[number]["_zod"]["values"]; //GetValues<T[number]>;
1908
+ output: $InferUnionOutput<T[number]>;
1909
+ input: $InferUnionInput<T[number]>;
1910
+ // if any element in the union is optional, then the union is optional
1911
+ optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
1912
+ optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
1913
+ }
1914
+
1915
+ export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]>
1916
+ extends $ZodType<any, any, $ZodUnionInternals<T>> {
1917
+ _zod: $ZodUnionInternals<T>;
1918
+ }
1919
+
1920
+ function handleUnionResults(results: ParsePayload[], final: ParsePayload, inst: $ZodUnion, ctx?: ParseContext) {
1921
+ for (const result of results) {
1922
+ if (result.issues.length === 0) {
1923
+ final.value = result.value;
1924
+ return final;
1925
+ }
1926
+ }
1927
+
1928
+ const nonaborted = results.filter((r) => !util.aborted(r));
1929
+ if (nonaborted.length === 1) {
1930
+ final.value = nonaborted[0].value;
1931
+ return nonaborted[0];
1932
+ }
1933
+
1934
+ final.issues.push({
1935
+ code: "invalid_union",
1936
+
1937
+ input: final.value,
1938
+ inst,
1939
+ errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1940
+ });
1941
+
1942
+ return final;
1943
+ }
1944
+
1945
+ export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
1946
+ $ZodType.init(inst, def);
1947
+
1948
+ util.defineLazy(inst._zod, "optin", () =>
1949
+ def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined
1950
+ );
1951
+
1952
+ util.defineLazy(inst._zod, "optout", () =>
1953
+ def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
1954
+ );
1955
+
1956
+ util.defineLazy(inst._zod, "values", () => {
1957
+ if (def.options.every((o) => o._zod.values)) {
1958
+ return new Set<util.Primitive>(def.options.flatMap((option) => Array.from(option._zod.values!)));
1959
+ }
1960
+ return undefined;
1961
+ });
1962
+
1963
+ util.defineLazy(inst._zod, "pattern", () => {
1964
+ if (def.options.every((o) => o._zod.pattern)) {
1965
+ const patterns = def.options.map((o) => o._zod.pattern);
1966
+ return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p!.source)).join("|")})$`);
1967
+ }
1968
+ return undefined;
1969
+ });
1970
+
1971
+ const single = def.options.length === 1;
1972
+ const first = def.options[0]._zod.run;
1973
+
1974
+ inst._zod.parse = (payload, ctx) => {
1975
+ if (single) {
1976
+ return first(payload, ctx);
1977
+ }
1978
+ let async = false;
1979
+
1980
+ const results: util.MaybeAsync<ParsePayload>[] = [];
1981
+ for (const option of def.options) {
1982
+ const result = option._zod.run(
1983
+ {
1984
+ value: payload.value,
1985
+ issues: [],
1986
+ },
1987
+ ctx
1988
+ );
1989
+ if (result instanceof Promise) {
1990
+ results.push(result);
1991
+ async = true;
1992
+ } else {
1993
+ if (result.issues.length === 0) return result;
1994
+ results.push(result);
1995
+ }
1996
+ }
1997
+
1998
+ if (!async) return handleUnionResults(results as ParsePayload[], payload, inst, ctx);
1999
+ return Promise.all(results).then((results) => {
2000
+ return handleUnionResults(results as ParsePayload[], payload, inst, ctx);
2001
+ });
2002
+ };
2003
+ });
2004
+
2005
+ //////////////////////////////////////////////////////
2006
+ //////////////////////////////////////////////////////
2007
+ ////////// //////////
2008
+ ////////// $ZodDiscriminatedUnion //////////
2009
+ ////////// //////////
2010
+ //////////////////////////////////////////////////////
2011
+ //////////////////////////////////////////////////////
2012
+
2013
+ export interface $ZodDiscriminatedUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]>
2014
+ extends $ZodUnionDef<Options> {
2015
+ discriminator: string;
2016
+ unionFallback?: boolean;
2017
+ }
2018
+
2019
+ export interface $ZodDiscriminatedUnionInternals<Options extends readonly SomeType[] = readonly $ZodType[]>
2020
+ extends $ZodUnionInternals<Options> {
2021
+ def: $ZodDiscriminatedUnionDef<Options>;
2022
+ propValues: util.PropValues;
2023
+ }
2024
+
2025
+ export interface $ZodDiscriminatedUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType {
2026
+ _zod: $ZodDiscriminatedUnionInternals<T>;
2027
+ }
2028
+
2029
+ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2030
+ /*@__PURE__*/
2031
+ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
2032
+ $ZodUnion.init(inst, def);
2033
+
2034
+ const _super = inst._zod.parse;
2035
+ util.defineLazy(inst._zod, "propValues", () => {
2036
+ const propValues: util.PropValues = {};
2037
+ for (const option of def.options) {
2038
+ const pv = option._zod.propValues;
2039
+ if (!pv || Object.keys(pv).length === 0)
2040
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2041
+ for (const [k, v] of Object.entries(pv!)) {
2042
+ if (!propValues[k]) propValues[k] = new Set();
2043
+ for (const val of v) {
2044
+ propValues[k].add(val);
2045
+ }
2046
+ }
2047
+ }
2048
+ return propValues;
2049
+ });
2050
+
2051
+ const disc = util.cached(() => {
2052
+ const opts = def.options as $ZodTypeDiscriminable[];
2053
+ const map: Map<util.Primitive, $ZodType> = new Map();
2054
+ for (const o of opts) {
2055
+ const values = o._zod.propValues?.[def.discriminator];
2056
+ if (!values || values.size === 0)
2057
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
2058
+ for (const v of values) {
2059
+ if (map.has(v)) {
2060
+ throw new Error(`Duplicate discriminator value "${String(v)}"`);
2061
+ }
2062
+ map.set(v, o);
2063
+ }
2064
+ }
2065
+ return map;
2066
+ });
2067
+
2068
+ inst._zod.parse = (payload, ctx) => {
2069
+ const input = payload.value;
2070
+ if (!util.isObject(input)) {
2071
+ payload.issues.push({
2072
+ code: "invalid_type",
2073
+
2074
+ expected: "object",
2075
+ input,
2076
+ inst,
2077
+ });
2078
+ return payload;
2079
+ }
2080
+
2081
+ const opt = disc.value.get(input?.[def.discriminator] as any);
2082
+ if (opt) {
2083
+ return opt._zod.run(payload, ctx) as any;
2084
+ }
2085
+
2086
+ if (def.unionFallback) {
2087
+ return _super(payload, ctx);
2088
+ }
2089
+
2090
+ // no matching discriminator
2091
+ payload.issues.push({
2092
+ code: "invalid_union",
2093
+
2094
+ errors: [],
2095
+ note: "No matching discriminator",
2096
+ discriminator: def.discriminator,
2097
+ input,
2098
+ path: [def.discriminator],
2099
+ inst,
2100
+ });
2101
+
2102
+ return payload;
2103
+ };
2104
+ });
2105
+
2106
+ ////////////////////////////////////////////////
2107
+ ////////////////////////////////////////////////
2108
+ ////////// //////////
2109
+ ////////// $ZodIntersection //////////
2110
+ ////////// //////////
2111
+ ////////////////////////////////////////////////
2112
+ ////////////////////////////////////////////////
2113
+
2114
+ export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType>
2115
+ extends $ZodTypeDef {
2116
+ type: "intersection";
2117
+ left: Left;
2118
+ right: Right;
2119
+ }
2120
+
2121
+ export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
2122
+ extends _$ZodTypeInternals {
2123
+ // $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>>
2124
+ def: $ZodIntersectionDef<A, B>;
2125
+ isst: never;
2126
+ optin: A["_zod"]["optin"] | B["_zod"]["optin"];
2127
+ optout: A["_zod"]["optout"] | B["_zod"]["optout"];
2128
+ output: core.output<A> & core.output<B>;
2129
+ input: core.input<A> & core.input<B>;
2130
+ }
2131
+
2132
+ export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
2133
+ _zod: $ZodIntersectionInternals<A, B>;
2134
+ }
2135
+
2136
+ export const $ZodIntersection: core.$constructor<$ZodIntersection> = /*@__PURE__*/ core.$constructor(
2137
+ "$ZodIntersection",
2138
+ (inst, def) => {
2139
+ $ZodType.init(inst, def);
2140
+
2141
+ inst._zod.parse = (payload, ctx) => {
2142
+ const input = payload.value;
2143
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
2144
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
2145
+ const async = left instanceof Promise || right instanceof Promise;
2146
+
2147
+ if (async) {
2148
+ return Promise.all([left, right]).then(([left, right]) => {
2149
+ return handleIntersectionResults(payload, left, right);
2150
+ });
2151
+ }
2152
+
2153
+ return handleIntersectionResults(payload, left, right);
2154
+ };
2155
+ }
2156
+ );
2157
+
2158
+ function mergeValues(
2159
+ a: any,
2160
+ b: any
2161
+ ): { valid: true; data: any } | { valid: false; mergeErrorPath: (string | number)[] } {
2162
+ // const aType = parse.t(a);
2163
+ // const bType = parse.t(b);
2164
+
2165
+ if (a === b) {
2166
+ return { valid: true, data: a };
2167
+ }
2168
+ if (a instanceof Date && b instanceof Date && +a === +b) {
2169
+ return { valid: true, data: a };
2170
+ }
2171
+ if (util.isPlainObject(a) && util.isPlainObject(b)) {
2172
+ const bKeys = Object.keys(b);
2173
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2174
+
2175
+ const newObj: any = { ...a, ...b };
2176
+ for (const key of sharedKeys) {
2177
+ const sharedValue = mergeValues(a[key], b[key]);
2178
+ if (!sharedValue.valid) {
2179
+ return {
2180
+ valid: false,
2181
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
2182
+ };
2183
+ }
2184
+ newObj[key] = sharedValue.data;
2185
+ }
2186
+
2187
+ return { valid: true, data: newObj };
2188
+ }
2189
+ if (Array.isArray(a) && Array.isArray(b)) {
2190
+ if (a.length !== b.length) {
2191
+ return { valid: false, mergeErrorPath: [] };
2192
+ }
2193
+
2194
+ const newArray: unknown[] = [];
2195
+ for (let index = 0; index < a.length; index++) {
2196
+ const itemA = a[index];
2197
+ const itemB = b[index];
2198
+ const sharedValue = mergeValues(itemA, itemB);
2199
+
2200
+ if (!sharedValue.valid) {
2201
+ return {
2202
+ valid: false,
2203
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
2204
+ };
2205
+ }
2206
+
2207
+ newArray.push(sharedValue.data);
2208
+ }
2209
+
2210
+ return { valid: true, data: newArray };
2211
+ }
2212
+
2213
+ return { valid: false, mergeErrorPath: [] };
2214
+ }
2215
+
2216
+ function handleIntersectionResults(result: ParsePayload, left: ParsePayload, right: ParsePayload): ParsePayload {
2217
+ if (left.issues.length) {
2218
+ result.issues.push(...left.issues);
2219
+ }
2220
+ if (right.issues.length) {
2221
+ result.issues.push(...right.issues);
2222
+ }
2223
+ if (util.aborted(result)) return result;
2224
+
2225
+ const merged = mergeValues(left.value, right.value);
2226
+
2227
+ if (!merged.valid) {
2228
+ throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
2229
+ }
2230
+
2231
+ result.value = merged.data;
2232
+ return result;
2233
+ }
2234
+
2235
+ /////////////////////////////////////////
2236
+ /////////////////////////////////////////
2237
+ ////////// //////////
2238
+ ////////// $ZodTuple //////////
2239
+ ////////// //////////
2240
+ /////////////////////////////////////////
2241
+ /////////////////////////////////////////
2242
+
2243
+ export interface $ZodTupleDef<
2244
+ T extends util.TupleItems = readonly $ZodType[],
2245
+ Rest extends SomeType | null = $ZodType | null,
2246
+ > extends $ZodTypeDef {
2247
+ type: "tuple";
2248
+ items: T;
2249
+ rest: Rest;
2250
+ }
2251
+
2252
+ export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
2253
+ ...TupleInputTypeWithOptionals<T>,
2254
+ ...(Rest extends SomeType ? core.input<Rest>[] : []),
2255
+ ];
2256
+ type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
2257
+ [k in keyof T]: core.input<T[k]>;
2258
+ };
2259
+ type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
2260
+ ...infer Prefix extends SomeType[],
2261
+ infer Tail extends SomeType,
2262
+ ]
2263
+ ? Tail["_zod"]["optin"] extends "optional"
2264
+ ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?]
2265
+ : TupleInputTypeNoOptionals<T>
2266
+ : [];
2267
+
2268
+ export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
2269
+ ...TupleOutputTypeWithOptionals<T>,
2270
+ ...(Rest extends SomeType ? core.output<Rest>[] : []),
2271
+ ];
2272
+ type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
2273
+ [k in keyof T]: core.output<T[k]>;
2274
+ };
2275
+ type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
2276
+ ...infer Prefix extends SomeType[],
2277
+ infer Tail extends SomeType,
2278
+ ]
2279
+ ? Tail["_zod"]["optout"] extends "optional"
2280
+ ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?]
2281
+ : TupleOutputTypeNoOptionals<T>
2282
+ : [];
2283
+
2284
+ export interface $ZodTupleInternals<
2285
+ T extends util.TupleItems = readonly $ZodType[],
2286
+ Rest extends SomeType | null = $ZodType | null,
2287
+ > extends _$ZodTypeInternals {
2288
+ def: $ZodTupleDef<T, Rest>;
2289
+ isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
2290
+ // $ZodTypeInternals<$InferTupleOutputType<T, Rest>, $InferTupleInputType<T, Rest>>
2291
+ output: $InferTupleOutputType<T, Rest>;
2292
+ input: $InferTupleInputType<T, Rest>;
2293
+ }
2294
+
2295
+ export interface $ZodTuple<
2296
+ T extends util.TupleItems = readonly $ZodType[],
2297
+ Rest extends SomeType | null = $ZodType | null,
2298
+ > extends $ZodType {
2299
+ _zod: $ZodTupleInternals<T, Rest>;
2300
+ }
2301
+
2302
+ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
2303
+ $ZodType.init(inst, def);
2304
+ const items = def.items;
2305
+ const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
2306
+
2307
+ inst._zod.parse = (payload, ctx) => {
2308
+ const input = payload.value;
2309
+ if (!Array.isArray(input)) {
2310
+ payload.issues.push({
2311
+ input,
2312
+ inst,
2313
+ expected: "tuple",
2314
+ code: "invalid_type",
2315
+ });
2316
+ return payload;
2317
+ }
2318
+
2319
+ payload.value = [];
2320
+ const proms: Promise<any>[] = [];
2321
+
2322
+ if (!def.rest) {
2323
+ const tooBig = input.length > items.length;
2324
+ const tooSmall = input.length < optStart - 1;
2325
+ if (tooBig || tooSmall) {
2326
+ payload.issues.push({
2327
+ ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
2328
+
2329
+ input,
2330
+ inst,
2331
+ origin: "array" as const,
2332
+ });
2333
+ return payload;
2334
+ }
2335
+ }
2336
+
2337
+ let i = -1;
2338
+ for (const item of items) {
2339
+ i++;
2340
+ if (i >= input.length) if (i >= optStart) continue;
2341
+ const result = item._zod.run(
2342
+ {
2343
+ value: input[i],
2344
+ issues: [],
2345
+ },
2346
+ ctx
2347
+ );
2348
+
2349
+ if (result instanceof Promise) {
2350
+ proms.push(result.then((result) => handleTupleResult(result, payload, i)));
2351
+ } else {
2352
+ handleTupleResult(result, payload, i);
2353
+ }
2354
+ }
2355
+
2356
+ if (def.rest) {
2357
+ const rest = input.slice(items.length);
2358
+ for (const el of rest) {
2359
+ i++;
2360
+ const result = def.rest._zod.run(
2361
+ {
2362
+ value: el,
2363
+ issues: [],
2364
+ },
2365
+ ctx
2366
+ );
2367
+
2368
+ if (result instanceof Promise) {
2369
+ proms.push(result.then((result) => handleTupleResult(result, payload, i)));
2370
+ } else {
2371
+ handleTupleResult(result, payload, i);
2372
+ }
2373
+ }
2374
+ }
2375
+
2376
+ if (proms.length) return Promise.all(proms).then(() => payload);
2377
+ return payload;
2378
+ };
2379
+ });
2380
+
2381
+ function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, index: number) {
2382
+ if (result.issues.length) {
2383
+ final.issues.push(...util.prefixIssues(index, result.issues));
2384
+ }
2385
+ final.value[index] = result.value;
2386
+ }
2387
+
2388
+ //////////////////////////////////////////
2389
+ //////////////////////////////////////////
2390
+ ////////// //////////
2391
+ ////////// $ZodRecord //////////
2392
+ ////////// //////////
2393
+ //////////////////////////////////////////
2394
+ //////////////////////////////////////////
2395
+
2396
+ export type $ZodRecordKey = $ZodType<string | number | symbol, string | number | symbol>; // $HasValues | $HasPattern;
2397
+ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2398
+ extends $ZodTypeDef {
2399
+ type: "record";
2400
+ keyType: Key;
2401
+ valueType: Value;
2402
+ }
2403
+
2404
+ // export type $InferZodRecordOutput<
2405
+ // Key extends $ZodRecordKey = $ZodRecordKey,
2406
+ // Value extends SomeType = $ZodType,
2407
+ // > = undefined extends Key["_zod"]["values"]
2408
+ // ? string extends core.output<Key>
2409
+ // ? Record<core.output<Key>, core.output<Value>>
2410
+ // : number extends core.output<Key>
2411
+ // ? Record<core.output<Key>, core.output<Value>>
2412
+ // : symbol extends core.output<Key>
2413
+ // ? Record<core.output<Key>, core.output<Value>>
2414
+ // : Record<core.output<Key>, core.output<Value>>
2415
+ // : Record<core.output<Key>, core.output<Value>>;
2416
+ export type $InferZodRecordOutput<
2417
+ Key extends $ZodRecordKey = $ZodRecordKey,
2418
+ Value extends SomeType = $ZodType,
2419
+ > = Key extends $partial
2420
+ ? Partial<Record<core.output<Key>, core.output<Value>>>
2421
+ : Record<core.output<Key>, core.output<Value>>;
2422
+
2423
+ // export type $InferZodRecordInput<
2424
+ // Key extends $ZodRecordKey = $ZodRecordKey,
2425
+ // Value extends SomeType = $ZodType,
2426
+ // > = undefined extends Key["_zod"]["values"]
2427
+ // ? string extends core.input<Key>
2428
+ // ? Record<core.input<Key>, core.input<Value>>
2429
+ // : number extends core.input<Key>
2430
+ // ? Record<core.input<Key>, core.input<Value>>
2431
+ // : symbol extends core.input<Key>
2432
+ // ? Record<core.input<Key>, core.input<Value>>
2433
+ // : Record<core.input<Key>, core.input<Value>>
2434
+ // : Record<core.input<Key>, core.input<Value>>;
2435
+ export type $InferZodRecordInput<
2436
+ Key extends $ZodRecordKey = $ZodRecordKey,
2437
+ Value extends SomeType = $ZodType,
2438
+ > = Key extends $partial
2439
+ ? Partial<Record<core.input<Key>, core.input<Value>>>
2440
+ : Record<core.input<Key>, core.input<Value>>;
2441
+
2442
+ export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2443
+ extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
2444
+ def: $ZodRecordDef<Key, Value>;
2445
+ isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
2446
+ optin?: "optional" | undefined;
2447
+ optout?: "optional" | undefined;
2448
+ }
2449
+
2450
+ export type $partial = { "~~partial": true };
2451
+ export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2452
+ extends $ZodType {
2453
+ _zod: $ZodRecordInternals<Key, Value>;
2454
+ }
2455
+
2456
+ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
2457
+ $ZodType.init(inst, def);
2458
+
2459
+ inst._zod.parse = (payload, ctx) => {
2460
+ const input = payload.value;
2461
+
2462
+ if (!util.isPlainObject(input)) {
2463
+ payload.issues.push({
2464
+ expected: "record",
2465
+ code: "invalid_type",
2466
+
2467
+ input,
2468
+ inst,
2469
+ });
2470
+ return payload;
2471
+ }
2472
+
2473
+ const proms: Promise<any>[] = [];
2474
+
2475
+ if (def.keyType._zod.values) {
2476
+ const values = def.keyType._zod.values!;
2477
+ payload.value = {};
2478
+ for (const key of values) {
2479
+ if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2480
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2481
+
2482
+ if (result instanceof Promise) {
2483
+ proms.push(
2484
+ result.then((result) => {
2485
+ if (result.issues.length) {
2486
+ payload.issues.push(...util.prefixIssues(key, result.issues));
2487
+ }
2488
+ payload.value[key] = result.value;
2489
+ })
2490
+ );
2491
+ } else {
2492
+ if (result.issues.length) {
2493
+ payload.issues.push(...util.prefixIssues(key, result.issues));
2494
+ }
2495
+ payload.value[key] = result.value;
2496
+ }
2497
+ }
2498
+ }
2499
+
2500
+ let unrecognized!: string[];
2501
+ for (const key in input) {
2502
+ if (!values.has(key)) {
2503
+ unrecognized = unrecognized ?? [];
2504
+ unrecognized.push(key);
2505
+ }
2506
+ }
2507
+ if (unrecognized && unrecognized.length > 0) {
2508
+ payload.issues.push({
2509
+ code: "unrecognized_keys",
2510
+
2511
+ input,
2512
+ inst,
2513
+ keys: unrecognized,
2514
+ });
2515
+ }
2516
+ } else {
2517
+ payload.value = {};
2518
+ for (const key of Reflect.ownKeys(input)) {
2519
+ if (key === "__proto__") continue;
2520
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2521
+
2522
+ if (keyResult instanceof Promise) {
2523
+ throw new Error("Async schemas not supported in object keys currently");
2524
+ }
2525
+
2526
+ if (keyResult.issues.length) {
2527
+ payload.issues.push({
2528
+ code: "invalid_key",
2529
+
2530
+ origin: "record",
2531
+ issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2532
+ input: key,
2533
+ path: [key],
2534
+ inst,
2535
+ });
2536
+ payload.value[keyResult.value as PropertyKey] = keyResult.value;
2537
+ continue;
2538
+ }
2539
+
2540
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2541
+
2542
+ if (result instanceof Promise) {
2543
+ proms.push(
2544
+ result.then((result) => {
2545
+ if (result.issues.length) {
2546
+ payload.issues.push(...util.prefixIssues(key, result.issues));
2547
+ }
2548
+ payload.value[keyResult.value as PropertyKey] = result.value;
2549
+ })
2550
+ );
2551
+ } else {
2552
+ if (result.issues.length) {
2553
+ payload.issues.push(...util.prefixIssues(key, result.issues));
2554
+ }
2555
+ payload.value[keyResult.value as PropertyKey] = result.value;
2556
+ }
2557
+ }
2558
+ }
2559
+
2560
+ if (proms.length) {
2561
+ return Promise.all(proms).then(() => payload);
2562
+ }
2563
+ return payload;
2564
+ };
2565
+ });
2566
+
2567
+ ///////////////////////////////////////
2568
+ ///////////////////////////////////////
2569
+ ////////// //////////
2570
+ ////////// $ZodMap //////////
2571
+ ////////// //////////
2572
+ ///////////////////////////////////////
2573
+ ///////////////////////////////////////
2574
+ export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
2575
+ type: "map";
2576
+ keyType: Key;
2577
+ valueType: Value;
2578
+ }
2579
+
2580
+ export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType>
2581
+ extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
2582
+ def: $ZodMapDef<Key, Value>;
2583
+ isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
2584
+ optin?: "optional" | undefined;
2585
+ optout?: "optional" | undefined;
2586
+ }
2587
+
2588
+ export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
2589
+ _zod: $ZodMapInternals<Key, Value>;
2590
+ }
2591
+
2592
+ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
2593
+ $ZodType.init(inst, def);
2594
+
2595
+ inst._zod.parse = (payload, ctx) => {
2596
+ const input = payload.value;
2597
+ if (!(input instanceof Map)) {
2598
+ payload.issues.push({
2599
+ expected: "map",
2600
+ code: "invalid_type",
2601
+
2602
+ input,
2603
+ inst,
2604
+ });
2605
+ return payload;
2606
+ }
2607
+
2608
+ const proms: Promise<any>[] = [];
2609
+ payload.value = new Map();
2610
+
2611
+ for (const [key, value] of input) {
2612
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2613
+ const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
2614
+
2615
+ if (keyResult instanceof Promise || valueResult instanceof Promise) {
2616
+ proms.push(
2617
+ Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
2618
+ handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
2619
+ })
2620
+ );
2621
+ } else {
2622
+ handleMapResult(keyResult as ParsePayload, valueResult as ParsePayload, payload, key, input, inst, ctx);
2623
+ }
2624
+ }
2625
+
2626
+ if (proms.length) return Promise.all(proms).then(() => payload);
2627
+ return payload;
2628
+ };
2629
+ });
2630
+
2631
+ function handleMapResult(
2632
+ keyResult: ParsePayload,
2633
+ valueResult: ParsePayload,
2634
+ final: ParsePayload<Map<unknown, unknown>>,
2635
+ key: unknown,
2636
+ input: Map<any, any>,
2637
+ inst: $ZodMap,
2638
+ ctx?: ParseContext | undefined
2639
+ ): void {
2640
+ if (keyResult.issues.length) {
2641
+ if (util.propertyKeyTypes.has(typeof key)) {
2642
+ final.issues.push(...util.prefixIssues(key as PropertyKey, keyResult.issues));
2643
+ } else {
2644
+ final.issues.push({
2645
+ code: "invalid_key",
2646
+
2647
+ origin: "map",
2648
+ input,
2649
+ inst,
2650
+ issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2651
+ });
2652
+ }
2653
+ }
2654
+ if (valueResult.issues.length) {
2655
+ if (util.propertyKeyTypes.has(typeof key)) {
2656
+ final.issues.push(...util.prefixIssues(key as PropertyKey, valueResult.issues));
2657
+ } else {
2658
+ final.issues.push({
2659
+ origin: "map",
2660
+ code: "invalid_element",
2661
+
2662
+ input,
2663
+ inst,
2664
+ key: key,
2665
+ issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2666
+ });
2667
+ }
2668
+ }
2669
+ final.value.set(keyResult.value, valueResult.value);
2670
+ }
2671
+
2672
+ ///////////////////////////////////////
2673
+ ///////////////////////////////////////
2674
+ ////////// //////////
2675
+ ////////// $ZodSet //////////
2676
+ ////////// //////////
2677
+ ///////////////////////////////////////
2678
+ ///////////////////////////////////////
2679
+ export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
2680
+ type: "set";
2681
+ valueType: T;
2682
+ }
2683
+
2684
+ export interface $ZodSetInternals<T extends SomeType = $ZodType>
2685
+ extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
2686
+ def: $ZodSetDef<T>;
2687
+ isst: errors.$ZodIssueInvalidType;
2688
+ optin?: "optional" | undefined;
2689
+ optout?: "optional" | undefined;
2690
+ }
2691
+
2692
+ export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
2693
+ _zod: $ZodSetInternals<T>;
2694
+ }
2695
+
2696
+ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
2697
+ $ZodType.init(inst, def);
2698
+
2699
+ inst._zod.parse = (payload, ctx) => {
2700
+ const input = payload.value;
2701
+ if (!(input instanceof Set)) {
2702
+ payload.issues.push({
2703
+ input,
2704
+ inst,
2705
+ expected: "set",
2706
+ code: "invalid_type",
2707
+ });
2708
+ return payload;
2709
+ }
2710
+
2711
+ const proms: Promise<any>[] = [];
2712
+ payload.value = new Set();
2713
+ for (const item of input) {
2714
+ const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
2715
+ if (result instanceof Promise) {
2716
+ proms.push(result.then((result) => handleSetResult(result, payload)));
2717
+ } else handleSetResult(result, payload);
2718
+ }
2719
+
2720
+ if (proms.length) return Promise.all(proms).then(() => payload);
2721
+ return payload;
2722
+ };
2723
+ });
2724
+
2725
+ function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
2726
+ if (result.issues.length) {
2727
+ final.issues.push(...result.issues);
2728
+ }
2729
+ final.value.add(result.value);
2730
+ }
2731
+
2732
+ ////////////////////////////////////////
2733
+ ////////////////////////////////////////
2734
+ ////////// //////////
2735
+ ////////// $ZodEnum //////////
2736
+ ////////// //////////
2737
+ ////////////////////////////////////////
2738
+ ////////////////////////////////////////
2739
+ export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
2740
+ export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
2741
+
2742
+ export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
2743
+ type: "enum";
2744
+ entries: T;
2745
+ }
2746
+
2747
+ export interface $ZodEnumInternals<
2748
+ /** @ts-ignore Cast variance */
2749
+ out T extends util.EnumLike = util.EnumLike,
2750
+ > extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
2751
+ // enum: T;
2752
+
2753
+ def: $ZodEnumDef<T>;
2754
+ /** @deprecated Internal API, use with caution (not deprecated) */
2755
+ values: util.PrimitiveSet;
2756
+ /** @deprecated Internal API, use with caution (not deprecated) */
2757
+ pattern: RegExp;
2758
+ isst: errors.$ZodIssueInvalidValue;
2759
+ }
2760
+
2761
+ export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
2762
+ _zod: $ZodEnumInternals<T>;
2763
+ }
2764
+
2765
+ export const $ZodEnum: core.$constructor<$ZodEnum> = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
2766
+ $ZodType.init(inst, def);
2767
+
2768
+ const values = util.getEnumValues(def.entries);
2769
+ const valuesSet = new Set<util.Primitive>(values);
2770
+ inst._zod.values = valuesSet;
2771
+
2772
+ inst._zod.pattern = new RegExp(
2773
+ `^(${values
2774
+ .filter((k) => util.propertyKeyTypes.has(typeof k))
2775
+ .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
2776
+ .join("|")})$`
2777
+ );
2778
+
2779
+ inst._zod.parse = (payload, _ctx) => {
2780
+ const input = payload.value;
2781
+ if (valuesSet.has(input)) {
2782
+ return payload;
2783
+ }
2784
+ payload.issues.push({
2785
+ code: "invalid_value",
2786
+
2787
+ values,
2788
+ input,
2789
+ inst,
2790
+ });
2791
+ return payload;
2792
+ };
2793
+ });
2794
+
2795
+ ////////////////////////////////////////
2796
+ ////////////////////////////////////////
2797
+ ////////// //////////
2798
+ ////////// $ZodLiteral //////////
2799
+ ////////// //////////
2800
+ ////////////////////////////////////////
2801
+ ////////////////////////////////////////
2802
+
2803
+ export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
2804
+ type: "literal";
2805
+ values: T[];
2806
+ }
2807
+
2808
+ export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
2809
+ def: $ZodLiteralDef<T>;
2810
+ values: Set<T>;
2811
+ pattern: RegExp;
2812
+ isst: errors.$ZodIssueInvalidValue;
2813
+ }
2814
+
2815
+ export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
2816
+ _zod: $ZodLiteralInternals<T>;
2817
+ }
2818
+
2819
+ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$constructor(
2820
+ "$ZodLiteral",
2821
+ (inst, def) => {
2822
+ $ZodType.init(inst, def);
2823
+ if (def.values.length === 0) {
2824
+ throw new Error("Cannot create literal schema with no valid values");
2825
+ }
2826
+
2827
+ inst._zod.values = new Set<util.Literal>(def.values);
2828
+ inst._zod.pattern = new RegExp(
2829
+ `^(${def.values
2830
+
2831
+ .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
2832
+ .join("|")})$`
2833
+ );
2834
+
2835
+ inst._zod.parse = (payload, _ctx) => {
2836
+ const input = payload.value;
2837
+ if (inst._zod.values.has(input)) {
2838
+ return payload;
2839
+ }
2840
+ payload.issues.push({
2841
+ code: "invalid_value",
2842
+
2843
+ values: def.values,
2844
+ input,
2845
+ inst,
2846
+ });
2847
+ return payload;
2848
+ };
2849
+ }
2850
+ );
2851
+
2852
+ ////////////////////////////////////////
2853
+ ////////////////////////////////////////
2854
+ ////////// //////////
2855
+ ////////// $ZodConst //////////
2856
+ ////////// //////////
2857
+ ////////////////////////////////////////
2858
+ ////////////////////////////////////////
2859
+
2860
+ // export interface $ZodConstDef extends $ZodTypeDef {
2861
+ // type: "const";
2862
+ // value: unknown;
2863
+ // }
2864
+
2865
+ // export _interface $ZodConstInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
2866
+ // _def: $ZodConstDef;
2867
+ // _values: util.PrimitiveSet;
2868
+ // _pattern: RegExp;
2869
+ // _isst: errors.$ZodIssueInvalidValue;
2870
+ // }
2871
+
2872
+ // export const $ZodConst: core.$constructor<{_zod: $ZodConstInternals}> = /*@__PURE__*/ core.$constructor("$ZodConst", (inst, def) => {
2873
+ // $ZodType.init(inst, def);
2874
+
2875
+ // if (util.primitiveTypes.has(typeof def.value) || def.value === null) {
2876
+ // inst._zod.values = new Set<util.Primitive>(def.value as any);
2877
+ // }
2878
+
2879
+ // if (util.propertyKeyTypes.has(typeof def.value)) {
2880
+ // inst._zod.pattern = new RegExp(
2881
+ // `^(${typeof def.value === "string" ? util.escapeRegex(def.value) : (def.value as any).toString()})$`
2882
+ // );
2883
+ // } else {
2884
+ // throw new Error("Const value cannot be converted to regex");
2885
+ // }
2886
+
2887
+ // inst._zod.parse = (payload, _ctx) => {
2888
+ // payload.value = def.value; // always override
2889
+ // return payload;
2890
+ // };
2891
+ // });
2892
+
2893
+ //////////////////////////////////////////
2894
+ //////////////////////////////////////////
2895
+ ////////// //////////
2896
+ ////////// $ZodFile //////////
2897
+ ////////// //////////
2898
+ //////////////////////////////////////////
2899
+ //////////////////////////////////////////
2900
+
2901
+ // provide a fallback in case the File interface isn't provided in the environment
2902
+ type _File = typeof globalThis extends { File: infer F extends new (...args: any[]) => any } ? InstanceType<F> : {};
2903
+ /** Do not reference this directly. */
2904
+ export interface File extends _File {
2905
+ readonly type: string;
2906
+ readonly size: number;
2907
+ }
2908
+
2909
+ export interface $ZodFileDef extends $ZodTypeDef {
2910
+ type: "file";
2911
+ }
2912
+
2913
+ export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
2914
+ def: $ZodFileDef;
2915
+ isst: errors.$ZodIssueInvalidType;
2916
+ bag: util.LoosePartial<{
2917
+ minimum: number;
2918
+ maximum: number;
2919
+ mime: util.MimeTypes[];
2920
+ }>;
2921
+ }
2922
+
2923
+ export interface $ZodFile extends $ZodType {
2924
+ _zod: $ZodFileInternals;
2925
+ }
2926
+
2927
+ export const $ZodFile: core.$constructor<$ZodFile> = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
2928
+ $ZodType.init(inst, def);
2929
+
2930
+ inst._zod.parse = (payload, _ctx) => {
2931
+ const input = payload.value;
2932
+ // @ts-ignore
2933
+ if (input instanceof File) return payload;
2934
+ payload.issues.push({
2935
+ expected: "file",
2936
+ code: "invalid_type",
2937
+
2938
+ input,
2939
+ inst,
2940
+ });
2941
+ return payload;
2942
+ };
2943
+ });
2944
+
2945
+ //////////////////////////////////////////////
2946
+ //////////////////////////////////////////////
2947
+ ////////// //////////
2948
+ ////////// $ZodTransform //////////
2949
+ ////////// //////////
2950
+ //////////////////////////////////////////////
2951
+ //////////////////////////////////////////////
2952
+ export interface $ZodTransformDef extends $ZodTypeDef {
2953
+ type: "transform";
2954
+ transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
2955
+ }
2956
+ export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
2957
+ def: $ZodTransformDef;
2958
+ isst: never;
2959
+ }
2960
+
2961
+ export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
2962
+ _zod: $ZodTransformInternals<O, I>;
2963
+ }
2964
+
2965
+ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ core.$constructor(
2966
+ "$ZodTransform",
2967
+ (inst, def) => {
2968
+ $ZodType.init(inst, def);
2969
+ inst._zod.parse = (payload, _ctx) => {
2970
+ const _out = def.transform(payload.value, payload);
2971
+ if (_ctx.async) {
2972
+ const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2973
+ return output.then((output) => {
2974
+ payload.value = output;
2975
+ return payload;
2976
+ });
2977
+ }
2978
+
2979
+ if (_out instanceof Promise) {
2980
+ throw new core.$ZodAsyncError();
2981
+ }
2982
+
2983
+ payload.value = _out;
2984
+ return payload;
2985
+ };
2986
+ }
2987
+ );
2988
+
2989
+ ////////////////////////////////////////////
2990
+ ////////////////////////////////////////////
2991
+ ////////// //////////
2992
+ ////////// $ZodOptional //////////
2993
+ ////////// //////////
2994
+ ////////////////////////////////////////////
2995
+ ////////////////////////////////////////////
2996
+ export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
2997
+ type: "optional";
2998
+ innerType: T;
2999
+ }
3000
+
3001
+ export interface $ZodOptionalInternals<T extends SomeType = $ZodType>
3002
+ extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
3003
+ def: $ZodOptionalDef<T>;
3004
+ optin: "optional";
3005
+ optout: "optional";
3006
+ isst: never;
3007
+ values: T["_zod"]["values"];
3008
+ pattern: T["_zod"]["pattern"];
3009
+ }
3010
+
3011
+ export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
3012
+ _zod: $ZodOptionalInternals<T>;
3013
+ }
3014
+
3015
+ function handleOptionalResult(result: ParsePayload, input: unknown) {
3016
+ if (result.issues.length && input === undefined) {
3017
+ return { issues: [], value: undefined };
3018
+ }
3019
+ return result;
3020
+ }
3021
+
3022
+ export const $ZodOptional: core.$constructor<$ZodOptional> = /*@__PURE__*/ core.$constructor(
3023
+ "$ZodOptional",
3024
+ (inst, def) => {
3025
+ $ZodType.init(inst, def);
3026
+ inst._zod.optin = "optional";
3027
+ inst._zod.optout = "optional";
3028
+
3029
+ util.defineLazy(inst._zod, "values", () => {
3030
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
3031
+ });
3032
+ util.defineLazy(inst._zod, "pattern", () => {
3033
+ const pattern = def.innerType._zod.pattern;
3034
+ return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
3035
+ });
3036
+
3037
+ inst._zod.parse = (payload, ctx) => {
3038
+ if (def.innerType._zod.optin === "optional") {
3039
+ const result = def.innerType._zod.run(payload, ctx);
3040
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
3041
+ return handleOptionalResult(result, payload.value);
3042
+ }
3043
+ if (payload.value === undefined) {
3044
+ return payload;
3045
+ }
3046
+ return def.innerType._zod.run(payload, ctx);
3047
+ };
3048
+ }
3049
+ );
3050
+
3051
+ ////////////////////////////////////////////
3052
+ ////////////////////////////////////////////
3053
+ ////////// //////////
3054
+ ////////// $ZodNullable //////////
3055
+ ////////// //////////
3056
+ ////////////////////////////////////////////
3057
+ ////////////////////////////////////////////
3058
+ export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3059
+ type: "nullable";
3060
+ innerType: T;
3061
+ }
3062
+
3063
+ export interface $ZodNullableInternals<T extends SomeType = $ZodType>
3064
+ extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
3065
+ def: $ZodNullableDef<T>;
3066
+ optin: T["_zod"]["optin"];
3067
+ optout: T["_zod"]["optout"];
3068
+ isst: never;
3069
+ values: T["_zod"]["values"];
3070
+ pattern: T["_zod"]["pattern"];
3071
+ }
3072
+
3073
+ export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
3074
+ _zod: $ZodNullableInternals<T>;
3075
+ }
3076
+
3077
+ export const $ZodNullable: core.$constructor<$ZodNullable> = /*@__PURE__*/ core.$constructor(
3078
+ "$ZodNullable",
3079
+ (inst, def) => {
3080
+ $ZodType.init(inst, def);
3081
+ util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3082
+ util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3083
+
3084
+ util.defineLazy(inst._zod, "pattern", () => {
3085
+ const pattern = def.innerType._zod.pattern;
3086
+ return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
3087
+ });
3088
+
3089
+ util.defineLazy(inst._zod, "values", () => {
3090
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
3091
+ });
3092
+
3093
+ inst._zod.parse = (payload, ctx) => {
3094
+ if (payload.value === null) return payload;
3095
+ return def.innerType._zod.run(payload, ctx);
3096
+ };
3097
+ }
3098
+ );
3099
+ // );
3100
+
3101
+ ////////////////////////////////////////////
3102
+ ////////////////////////////////////////////
3103
+ ////////// //////////
3104
+ ////////// $ZodDefault //////////
3105
+ ////////// //////////
3106
+ ////////////////////////////////////////////
3107
+ ////////////////////////////////////////////
3108
+ export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3109
+ type: "default";
3110
+ innerType: T;
3111
+ /** The default value. May be a getter. */
3112
+ defaultValue: util.NoUndefined<core.output<T>>;
3113
+ }
3114
+
3115
+ export interface $ZodDefaultInternals<T extends SomeType = $ZodType>
3116
+ extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3117
+ def: $ZodDefaultDef<T>;
3118
+ optin: "optional";
3119
+ optout?: "optional" | undefined; // required
3120
+ isst: never;
3121
+ values: T["_zod"]["values"];
3122
+ }
3123
+
3124
+ export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
3125
+ _zod: $ZodDefaultInternals<T>;
3126
+ }
3127
+
3128
+ export const $ZodDefault: core.$constructor<$ZodDefault> = /*@__PURE__*/ core.$constructor(
3129
+ "$ZodDefault",
3130
+ (inst, def) => {
3131
+ $ZodType.init(inst, def);
3132
+
3133
+ // inst._zod.qin = "true";
3134
+ inst._zod.optin = "optional";
3135
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3136
+
3137
+ inst._zod.parse = (payload, ctx) => {
3138
+ if (payload.value === undefined) {
3139
+ payload.value = def.defaultValue;
3140
+ /**
3141
+ * $ZodDefault always returns the default value immediately.
3142
+ * 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. */
3143
+ return payload;
3144
+ }
3145
+ const result = def.innerType._zod.run(payload, ctx);
3146
+ if (result instanceof Promise) {
3147
+ return result.then((result) => handleDefaultResult(result, def));
3148
+ }
3149
+ return handleDefaultResult(result, def);
3150
+ };
3151
+ }
3152
+ );
3153
+
3154
+ function handleDefaultResult(payload: ParsePayload, def: $ZodDefaultDef) {
3155
+ if (payload.value === undefined) {
3156
+ payload.value = def.defaultValue;
3157
+ }
3158
+ return payload;
3159
+ }
3160
+
3161
+ ////////////////////////////////////////////
3162
+ ////////////////////////////////////////////
3163
+ ////////// //////////
3164
+ ////////// $ZodPrefault //////////
3165
+ ////////// //////////
3166
+ ////////////////////////////////////////////
3167
+ ////////////////////////////////////////////
3168
+
3169
+ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3170
+ type: "prefault";
3171
+ innerType: T;
3172
+ /** The default value. May be a getter. */
3173
+ defaultValue: core.input<T>;
3174
+ }
3175
+
3176
+ export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
3177
+ extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3178
+ def: $ZodPrefaultDef<T>;
3179
+ optin: "optional";
3180
+ optout?: "optional" | undefined;
3181
+ isst: never;
3182
+ values: T["_zod"]["values"];
3183
+ }
3184
+
3185
+ export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
3186
+ _zod: $ZodPrefaultInternals<T>;
3187
+ }
3188
+
3189
+ export const $ZodPrefault: core.$constructor<$ZodPrefault> = /*@__PURE__*/ core.$constructor(
3190
+ "$ZodPrefault",
3191
+ (inst, def) => {
3192
+ $ZodType.init(inst, def);
3193
+
3194
+ inst._zod.optin = "optional";
3195
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3196
+
3197
+ inst._zod.parse = (payload, ctx) => {
3198
+ if (payload.value === undefined) {
3199
+ payload.value = def.defaultValue;
3200
+ }
3201
+ return def.innerType._zod.run(payload, ctx);
3202
+ };
3203
+ }
3204
+ );
3205
+
3206
+ ///////////////////////////////////////////////
3207
+ ///////////////////////////////////////////////
3208
+ ////////// //////////
3209
+ ////////// $ZodNonOptional //////////
3210
+ ////////// //////////
3211
+ ///////////////////////////////////////////////
3212
+ ///////////////////////////////////////////////
3213
+ export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3214
+ type: "nonoptional";
3215
+ innerType: T;
3216
+ }
3217
+
3218
+ export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType>
3219
+ extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
3220
+ def: $ZodNonOptionalDef<T>;
3221
+ isst: errors.$ZodIssueInvalidType;
3222
+ values: T["_zod"]["values"];
3223
+ optin: "optional" | undefined;
3224
+ optout: "optional" | undefined;
3225
+ }
3226
+
3227
+ export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
3228
+ _zod: $ZodNonOptionalInternals<T>;
3229
+ }
3230
+
3231
+ export const $ZodNonOptional: core.$constructor<$ZodNonOptional> = /*@__PURE__*/ core.$constructor(
3232
+ "$ZodNonOptional",
3233
+ (inst, def) => {
3234
+ $ZodType.init(inst, def);
3235
+
3236
+ util.defineLazy(inst._zod, "values", () => {
3237
+ const v = def.innerType._zod.values;
3238
+ return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
3239
+ });
3240
+
3241
+ inst._zod.parse = (payload, ctx) => {
3242
+ const result = def.innerType._zod.run(payload, ctx);
3243
+ if (result instanceof Promise) {
3244
+ return result.then((result) => handleNonOptionalResult(result, inst));
3245
+ }
3246
+ return handleNonOptionalResult(result, inst);
3247
+ };
3248
+ }
3249
+ );
3250
+
3251
+ function handleNonOptionalResult(payload: ParsePayload, inst: $ZodNonOptional) {
3252
+ if (!payload.issues.length && payload.value === undefined) {
3253
+ payload.issues.push({
3254
+ code: "invalid_type",
3255
+
3256
+ expected: "nonoptional",
3257
+ input: payload.value,
3258
+ inst,
3259
+ });
3260
+ }
3261
+ return payload;
3262
+ }
3263
+
3264
+ ////////////////////////////////////////////
3265
+ ////////////////////////////////////////////
3266
+ ////////// //////////
3267
+ ////////// $ZodCoalesce //////////
3268
+ ////////// //////////
3269
+ ////////////////////////////////////////////
3270
+ ////////////////////////////////////////////
3271
+ // export interface $ZodCoalesceDef<T extends $ZodType = $ZodType> extends $ZodTypeDef {
3272
+ // type: "coalesce";
3273
+ // innerType: T;
3274
+ // defaultValue: () => NonNullable<T['_zod']["output"]>;
3275
+ // }
3276
+
3277
+ // export _interface $ZodCoalesceInternals<T extends $ZodType = $ZodType>
3278
+ // extends $ZodTypeInternals<NonNullable<T['_zod']["output"]>, T['_zod']["input"] | undefined | null> {
3279
+ // _def: $ZodCoalesceDef<T>;
3280
+ // _isst: errors.$ZodIssueInvalidType;
3281
+ // _qin: "true";
3282
+ // }
3283
+
3284
+ // function handleCoalesceResult(payload: ParsePayload, def: $ZodCoalesceDef) {
3285
+ // payload.value ??= def.defaultValue();
3286
+ // return payload;
3287
+ // }
3288
+
3289
+ // export const $ZodCoalesce: core.$constructor<{_zod: $ZodCoalesceInternals}> = /*@__PURE__*/ core.$constructor(
3290
+ // "$ZodCoalesce",
3291
+ // (inst, def) => {
3292
+ // $ZodType.init(inst, def);
3293
+ // inst._zod.qin = "true";
3294
+ // inst._zod.parse = (payload, ctx) => {
3295
+ // const result = def.innerType._zod.run(payload, ctx);
3296
+ // if (result instanceof Promise) {
3297
+ // return result.then((result) => handleCoalesceResult(result, def));
3298
+ // }
3299
+ // return handleCoalesceResult(result, def);
3300
+ // };
3301
+ // }
3302
+ // );
3303
+
3304
+ /////////////////////////////////////////////
3305
+ /////////////////////////////////////////////
3306
+ ////////// //////////
3307
+ ////////// $ZodSuccess //////////
3308
+ ////////// //////////
3309
+ /////////////////////////////////////////////
3310
+ /////////////////////////////////////////////
3311
+ export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3312
+ type: "success";
3313
+ innerType: T;
3314
+ }
3315
+
3316
+ export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
3317
+ def: $ZodSuccessDef<T>;
3318
+ isst: never;
3319
+ optin: T["_zod"]["optin"];
3320
+ optout: "optional" | undefined;
3321
+ }
3322
+
3323
+ export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
3324
+ _zod: $ZodSuccessInternals<T>;
3325
+ }
3326
+
3327
+ export const $ZodSuccess: core.$constructor<$ZodSuccess> = /*@__PURE__*/ core.$constructor(
3328
+ "$ZodSuccess",
3329
+ (inst, def) => {
3330
+ $ZodType.init(inst, def);
3331
+
3332
+ inst._zod.parse = (payload, ctx) => {
3333
+ const result = def.innerType._zod.run(payload, ctx);
3334
+ if (result instanceof Promise) {
3335
+ return result.then((result) => {
3336
+ payload.value = result.issues.length === 0;
3337
+ return payload;
3338
+ });
3339
+ }
3340
+ payload.value = result.issues.length === 0;
3341
+ return payload;
3342
+ };
3343
+ }
3344
+ );
3345
+
3346
+ ////////////////////////////////////////////
3347
+ ////////////////////////////////////////////
3348
+ ////////// //////////
3349
+ ////////// $ZodCatch //////////
3350
+ ////////// //////////
3351
+ ////////////////////////////////////////////
3352
+ ////////////////////////////////////////////
3353
+ export interface $ZodCatchCtx extends ParsePayload {
3354
+ /** @deprecated Use `ctx.issues` */
3355
+ error: { issues: errors.$ZodIssue[] };
3356
+ /** @deprecated Use `ctx.value` */
3357
+ input: unknown;
3358
+ }
3359
+ export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3360
+ type: "catch";
3361
+ innerType: T;
3362
+ catchValue: (ctx: $ZodCatchCtx) => unknown;
3363
+ }
3364
+
3365
+ export interface $ZodCatchInternals<T extends SomeType = $ZodType>
3366
+ extends $ZodTypeInternals<core.output<T>, core.input<T>> {
3367
+ def: $ZodCatchDef<T>;
3368
+ optin: T["_zod"]["optin"];
3369
+ optout: T["_zod"]["optout"];
3370
+ isst: never;
3371
+ values: T["_zod"]["values"];
3372
+ }
3373
+
3374
+ export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
3375
+ _zod: $ZodCatchInternals<T>;
3376
+ }
3377
+
3378
+ export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
3379
+ $ZodType.init(inst, def);
3380
+ util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3381
+ util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3382
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3383
+
3384
+ inst._zod.parse = (payload, ctx) => {
3385
+ const result = def.innerType._zod.run(payload, ctx);
3386
+ if (result instanceof Promise) {
3387
+ return result.then((result) => {
3388
+ payload.value = result.value;
3389
+ if (result.issues.length) {
3390
+ payload.value = def.catchValue({
3391
+ ...payload,
3392
+ error: {
3393
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3394
+ },
3395
+ input: payload.value,
3396
+ });
3397
+ payload.issues = [];
3398
+ }
3399
+
3400
+ return payload;
3401
+ });
3402
+ }
3403
+
3404
+ payload.value = result.value;
3405
+ if (result.issues.length) {
3406
+ payload.value = def.catchValue({
3407
+ ...payload,
3408
+ error: {
3409
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3410
+ },
3411
+ input: payload.value,
3412
+ });
3413
+
3414
+ payload.issues = [];
3415
+ }
3416
+
3417
+ return payload;
3418
+ };
3419
+ });
3420
+
3421
+ ////////////////////////////////////////////
3422
+ ////////////////////////////////////////////
3423
+ ////////// //////////
3424
+ ////////// $ZodNaN //////////
3425
+ ////////// //////////
3426
+ ////////////////////////////////////////////
3427
+ ////////////////////////////////////////////
3428
+ export interface $ZodNaNDef extends $ZodTypeDef {
3429
+ type: "nan";
3430
+ }
3431
+
3432
+ export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
3433
+ def: $ZodNaNDef;
3434
+ isst: errors.$ZodIssueInvalidType;
3435
+ }
3436
+
3437
+ export interface $ZodNaN extends $ZodType {
3438
+ _zod: $ZodNaNInternals;
3439
+ }
3440
+
3441
+ export const $ZodNaN: core.$constructor<$ZodNaN> = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
3442
+ $ZodType.init(inst, def);
3443
+
3444
+ inst._zod.parse = (payload, _ctx) => {
3445
+ if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
3446
+ payload.issues.push({
3447
+ input: payload.value,
3448
+ inst,
3449
+ expected: "nan",
3450
+ code: "invalid_type",
3451
+ });
3452
+ return payload;
3453
+ }
3454
+ return payload;
3455
+ };
3456
+ });
3457
+
3458
+ ////////////////////////////////////////////
3459
+ ////////////////////////////////////////////
3460
+ ////////// //////////
3461
+ ////////// $ZodPipe //////////
3462
+ ////////// //////////
3463
+ ////////////////////////////////////////////
3464
+ ////////////////////////////////////////////
3465
+ export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
3466
+ type: "pipe";
3467
+ in: A;
3468
+ out: B;
3469
+ }
3470
+
3471
+ export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
3472
+ extends $ZodTypeInternals<core.output<B>, core.input<A>> {
3473
+ def: $ZodPipeDef<A, B>;
3474
+ isst: never;
3475
+ values: A["_zod"]["values"];
3476
+ optin: A["_zod"]["optin"];
3477
+ optout: B["_zod"]["optout"];
3478
+ propValues: A["_zod"]["propValues"];
3479
+ }
3480
+
3481
+ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
3482
+ _zod: $ZodPipeInternals<A, B>;
3483
+ }
3484
+
3485
+ export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
3486
+ $ZodType.init(inst, def);
3487
+ util.defineLazy(inst._zod, "values", () => def.in._zod.values);
3488
+ util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
3489
+ util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
3490
+ util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3491
+
3492
+ inst._zod.parse = (payload, ctx) => {
3493
+ const left = def.in._zod.run(payload, ctx);
3494
+ if (left instanceof Promise) {
3495
+ return left.then((left) => handlePipeResult(left, def, ctx));
3496
+ }
3497
+ return handlePipeResult(left, def, ctx);
3498
+ };
3499
+ });
3500
+
3501
+ function handlePipeResult(left: ParsePayload, def: $ZodPipeDef, ctx: ParseContext) {
3502
+ if (left.issues.length) {
3503
+ return left;
3504
+ }
3505
+ return def.out._zod.run({ value: left.value, issues: left.issues }, ctx);
3506
+ }
3507
+
3508
+ ////////////////////////////////////////////
3509
+ ////////////////////////////////////////////
3510
+ ////////// //////////
3511
+ ////////// $ZodReadonly //////////
3512
+ ////////// //////////
3513
+ ////////////////////////////////////////////
3514
+ ////////////////////////////////////////////
3515
+
3516
+ export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3517
+ type: "readonly";
3518
+ innerType: T;
3519
+ }
3520
+
3521
+ export interface $ZodReadonlyInternals<T extends SomeType = $ZodType>
3522
+ extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
3523
+ def: $ZodReadonlyDef<T>;
3524
+ optin: T["_zod"]["optin"];
3525
+ optout: T["_zod"]["optout"];
3526
+ isst: never;
3527
+ propValues: T["_zod"]["propValues"];
3528
+ values: T["_zod"]["values"];
3529
+ }
3530
+
3531
+ export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
3532
+ _zod: $ZodReadonlyInternals<T>;
3533
+ }
3534
+
3535
+ export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.$constructor(
3536
+ "$ZodReadonly",
3537
+ (inst, def) => {
3538
+ $ZodType.init(inst, def);
3539
+ util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
3540
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3541
+ util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3542
+ util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3543
+
3544
+ inst._zod.parse = (payload, ctx) => {
3545
+ const result = def.innerType._zod.run(payload, ctx);
3546
+ if (result instanceof Promise) {
3547
+ return result.then(handleReadonlyResult);
3548
+ }
3549
+ return handleReadonlyResult(result);
3550
+ };
3551
+ }
3552
+ );
3553
+
3554
+ function handleReadonlyResult(payload: ParsePayload): ParsePayload {
3555
+ payload.value = Object.freeze(payload.value);
3556
+ return payload;
3557
+ }
3558
+
3559
+ /////////////////////////////////////////////
3560
+ /////////////////////////////////////////////
3561
+ ////////// //////////
3562
+ ////////// $ZodTemplateLiteral //////////
3563
+ ////////// //////////
3564
+ /////////////////////////////////////////////
3565
+ /////////////////////////////////////////////
3566
+
3567
+ export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
3568
+ type: "template_literal";
3569
+ parts: $ZodTemplateLiteralPart[];
3570
+ format?: string | undefined;
3571
+ }
3572
+ export interface $ZodTemplateLiteralInternals<Template extends string = string>
3573
+ extends $ZodTypeInternals<Template, Template> {
3574
+ pattern: RegExp;
3575
+ def: $ZodTemplateLiteralDef;
3576
+ isst: errors.$ZodIssueInvalidType;
3577
+ }
3578
+
3579
+ export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
3580
+ _zod: $ZodTemplateLiteralInternals<Template>;
3581
+ }
3582
+
3583
+ type LiteralPart = Exclude<util.Literal, symbol>; //string | number | boolean | null | undefined;
3584
+ interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
3585
+ pattern: RegExp;
3586
+ }
3587
+ interface SchemaPart extends $ZodType {
3588
+ _zod: SchemaPartInternals;
3589
+ }
3590
+ export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
3591
+
3592
+ type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
3593
+ type AppendToTemplateLiteral<
3594
+ Template extends string,
3595
+ Suffix extends LiteralPart | $ZodType,
3596
+ > = Suffix extends LiteralPart
3597
+ ? `${Template}${UndefinedToEmptyString<Suffix>}`
3598
+ : Suffix extends $ZodType
3599
+ ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}`
3600
+ : never;
3601
+
3602
+ export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
3603
+ infer First extends string,
3604
+ ...infer Rest extends string[],
3605
+ ]
3606
+ ? Rest extends string[]
3607
+ ? First extends ""
3608
+ ? ConcatenateTupleOfStrings<Rest>
3609
+ : `${First}${ConcatenateTupleOfStrings<Rest>}`
3610
+ : never
3611
+ : "";
3612
+ export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
3613
+ [K in keyof Parts]: Parts[K] extends LiteralPart
3614
+ ? `${UndefinedToEmptyString<Parts[K]>}`
3615
+ : Parts[K] extends $ZodType
3616
+ ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}`
3617
+ : never;
3618
+ };
3619
+
3620
+ export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<
3621
+ ConvertPartsToStringTuple<Parts>
3622
+ >;
3623
+ // type lkjasd = ConcatenateTupleOfStrings<["Hello", " ", "World", "!"]>; // "Hello World!"
3624
+ export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts
3625
+ ? ``
3626
+ : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart]
3627
+ ? Rest extends $ZodTemplateLiteralPart[]
3628
+ ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last>
3629
+ : never
3630
+ : never;
3631
+
3632
+ export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
3633
+ "$ZodTemplateLiteral",
3634
+ (inst, def) => {
3635
+ $ZodType.init(inst, def);
3636
+ const regexParts: string[] = [];
3637
+ for (const part of def.parts) {
3638
+ if (part instanceof $ZodType) {
3639
+ if (!part._zod.pattern) {
3640
+ // if (!source)
3641
+ throw new Error(`Invalid template literal part, no pattern found: ${[...(part as any)._zod.traits].shift()}`);
3642
+ }
3643
+
3644
+ const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
3645
+
3646
+ if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
3647
+
3648
+ const start = source.startsWith("^") ? 1 : 0;
3649
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
3650
+ regexParts.push(source.slice(start, end));
3651
+ } else if (part === null || util.primitiveTypes.has(typeof part)) {
3652
+ regexParts.push(util.escapeRegex(`${part}`));
3653
+ } else {
3654
+ throw new Error(`Invalid template literal part: ${part}`);
3655
+ }
3656
+ }
3657
+ inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
3658
+
3659
+ inst._zod.parse = (payload, _ctx) => {
3660
+ if (typeof payload.value !== "string") {
3661
+ payload.issues.push({
3662
+ input: payload.value,
3663
+ inst,
3664
+ expected: "template_literal",
3665
+ code: "invalid_type",
3666
+ });
3667
+ return payload;
3668
+ }
3669
+
3670
+ inst._zod.pattern.lastIndex = 0;
3671
+
3672
+ if (!inst._zod.pattern.test(payload.value)) {
3673
+ payload.issues.push({
3674
+ input: payload.value,
3675
+ inst,
3676
+
3677
+ code: "invalid_format",
3678
+ format: def.format ?? "template_literal",
3679
+ pattern: inst._zod.pattern.source,
3680
+ });
3681
+ return payload;
3682
+ }
3683
+
3684
+ return payload;
3685
+ };
3686
+ }
3687
+ );
3688
+
3689
+ /////////////////////////////////////////
3690
+ /////////////////////////////////////////
3691
+ ////////// //////////
3692
+ ////////// $ZodPromise //////////
3693
+ ////////// //////////
3694
+ /////////////////////////////////////////
3695
+ /////////////////////////////////////////
3696
+ export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3697
+ type: "promise";
3698
+ innerType: T;
3699
+ }
3700
+
3701
+ export interface $ZodPromiseInternals<T extends SomeType = $ZodType>
3702
+ extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
3703
+ def: $ZodPromiseDef<T>;
3704
+ isst: never;
3705
+ }
3706
+
3707
+ export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
3708
+ _zod: $ZodPromiseInternals<T>;
3709
+ }
3710
+
3711
+ export const $ZodPromise: core.$constructor<$ZodPromise> = /*@__PURE__*/ core.$constructor(
3712
+ "$ZodPromise",
3713
+ (inst, def) => {
3714
+ $ZodType.init(inst, def);
3715
+
3716
+ inst._zod.parse = (payload, ctx) => {
3717
+ return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
3718
+ };
3719
+ }
3720
+ );
3721
+
3722
+ //////////////////////////////////////////
3723
+ //////////////////////////////////////////
3724
+ ////////// //////////
3725
+ ////////// $ZodLazy //////////
3726
+ ////////// //////////
3727
+ //////////////////////////////////////////
3728
+ //////////////////////////////////////////
3729
+
3730
+ export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3731
+ type: "lazy";
3732
+ getter: () => T;
3733
+ }
3734
+
3735
+ export interface $ZodLazyInternals<T extends SomeType = $ZodType>
3736
+ extends $ZodTypeInternals<core.output<T>, core.input<T>> {
3737
+ def: $ZodLazyDef<T>;
3738
+ isst: never;
3739
+ /** Auto-cached way to retrieve the inner schema */
3740
+ innerType: T;
3741
+ pattern: T["_zod"]["pattern"];
3742
+ propValues: T["_zod"]["propValues"];
3743
+ optin: T["_zod"]["optin"];
3744
+ optout: T["_zod"]["optout"];
3745
+ }
3746
+
3747
+ export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
3748
+ _zod: $ZodLazyInternals<T>;
3749
+ }
3750
+
3751
+ export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
3752
+ $ZodType.init(inst, def);
3753
+
3754
+ // let _innerType!: any;
3755
+ // util.defineLazy(def, "getter", () => {
3756
+ // if (!_innerType) {
3757
+ // _innerType = def.getter();
3758
+ // }
3759
+ // return () => _innerType;
3760
+ // });
3761
+ util.defineLazy(inst._zod, "innerType", () => def.getter() as $ZodType);
3762
+ util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
3763
+ util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
3764
+ util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin ?? undefined);
3765
+ util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout ?? undefined);
3766
+ inst._zod.parse = (payload, ctx) => {
3767
+ const inner = inst._zod.innerType;
3768
+ return inner._zod.run(payload, ctx);
3769
+ };
3770
+ });
3771
+
3772
+ ////////////////////////////////////////
3773
+ ////////////////////////////////////////
3774
+ ////////// //////////
3775
+ ////////// $ZodCustom //////////
3776
+ ////////// //////////
3777
+ ////////////////////////////////////////
3778
+ ////////////////////////////////////////
3779
+ export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
3780
+ type: "custom";
3781
+ check: "custom";
3782
+ path?: PropertyKey[] | undefined;
3783
+ error?: errors.$ZodErrorMap | undefined;
3784
+ params?: Record<string, any> | undefined;
3785
+ fn: (arg: O) => unknown;
3786
+ }
3787
+
3788
+ export interface $ZodCustomInternals<O = unknown, I = unknown>
3789
+ extends $ZodTypeInternals<O, I>,
3790
+ checks.$ZodCheckInternals<O> {
3791
+ def: $ZodCustomDef;
3792
+ issc: errors.$ZodIssue;
3793
+ isst: never;
3794
+ bag: util.LoosePartial<{
3795
+ Class: typeof util.Class;
3796
+ }>;
3797
+ }
3798
+
3799
+ export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
3800
+ _zod: $ZodCustomInternals<O, I>;
3801
+ }
3802
+
3803
+ export const $ZodCustom: core.$constructor<$ZodCustom> = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
3804
+ checks.$ZodCheck.init(inst, def);
3805
+ $ZodType.init(inst, def);
3806
+
3807
+ inst._zod.parse = (payload, _) => {
3808
+ return payload;
3809
+ };
3810
+
3811
+ inst._zod.check = (payload) => {
3812
+ const input = payload.value;
3813
+ const r = def.fn(input as any);
3814
+ if (r instanceof Promise) {
3815
+ return r.then((r) => handleRefineResult(r, payload, input, inst));
3816
+ }
3817
+ handleRefineResult(r, payload, input, inst);
3818
+ return;
3819
+ };
3820
+ });
3821
+
3822
+ function handleRefineResult(result: unknown, payload: ParsePayload, input: unknown, inst: $ZodCustom): void {
3823
+ if (!result) {
3824
+ const _iss: any = {
3825
+ code: "custom",
3826
+ input,
3827
+ inst, // incorporates params.error into issue reporting
3828
+ path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
3829
+ continue: !inst._zod.def.abort,
3830
+ // params: inst._zod.def.params,
3831
+ };
3832
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
3833
+ payload.issues.push(util.issue(_iss));
3834
+ }
3835
+ }
3836
+
3837
+ export type $ZodTypes =
3838
+ | $ZodString
3839
+ | $ZodNumber
3840
+ | $ZodBigInt
3841
+ | $ZodBoolean
3842
+ | $ZodDate
3843
+ | $ZodSymbol
3844
+ | $ZodUndefined
3845
+ | $ZodNullable
3846
+ | $ZodNull
3847
+ | $ZodAny
3848
+ | $ZodUnknown
3849
+ | $ZodNever
3850
+ | $ZodVoid
3851
+ | $ZodArray
3852
+ | $ZodObject
3853
+ | $ZodUnion
3854
+ | $ZodIntersection
3855
+ | $ZodTuple
3856
+ | $ZodRecord
3857
+ | $ZodMap
3858
+ | $ZodSet
3859
+ | $ZodLiteral
3860
+ | $ZodEnum
3861
+ | $ZodPromise
3862
+ | $ZodLazy
3863
+ | $ZodOptional
3864
+ | $ZodDefault
3865
+ | $ZodPrefault
3866
+ | $ZodTemplateLiteral
3867
+ | $ZodCustom
3868
+ | $ZodTransform
3869
+ | $ZodNonOptional
3870
+ | $ZodReadonly
3871
+ | $ZodNaN
3872
+ | $ZodPipe
3873
+ | $ZodSuccess
3874
+ | $ZodCatch
3875
+ | $ZodFile;
3876
+
3877
+ export type $ZodStringFormatTypes =
3878
+ | $ZodGUID
3879
+ | $ZodUUID
3880
+ | $ZodEmail
3881
+ | $ZodURL
3882
+ | $ZodEmoji
3883
+ | $ZodNanoID
3884
+ | $ZodCUID
3885
+ | $ZodCUID2
3886
+ | $ZodULID
3887
+ | $ZodXID
3888
+ | $ZodKSUID
3889
+ | $ZodISODateTime
3890
+ | $ZodISODate
3891
+ | $ZodISOTime
3892
+ | $ZodISODuration
3893
+ | $ZodIPv4
3894
+ | $ZodIPv6
3895
+ | $ZodCIDRv4
3896
+ | $ZodCIDRv6
3897
+ | $ZodBase64
3898
+ | $ZodBase64URL
3899
+ | $ZodE164
3900
+ | $ZodJWT;