@shuttl-io/core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (802) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +3 -0
  3. package/dist/Server.d.ts +5 -0
  4. package/dist/Server.js +3 -0
  5. package/dist/Triggers.d.ts +0 -0
  6. package/dist/Triggers.js +2 -0
  7. package/dist/agent.d.ts +49 -0
  8. package/dist/agent.js +251 -0
  9. package/dist/app.d.ts +17 -0
  10. package/dist/app.js +46 -0
  11. package/dist/index.d.ts +12 -0
  12. package/dist/index.js +29 -0
  13. package/dist/model.d.ts +6 -0
  14. package/dist/model.js +16 -0
  15. package/dist/models/openAi.d.ts +40 -0
  16. package/dist/models/openAi.js +346 -0
  17. package/dist/models/types.d.ts +102 -0
  18. package/dist/models/types.js +27 -0
  19. package/dist/outcomes/CombinationOutcome.d.ts +9 -0
  20. package/dist/outcomes/CombinationOutcome.js +41 -0
  21. package/dist/outcomes/IOutcomes.d.ts +9 -0
  22. package/dist/outcomes/IOutcomes.js +19 -0
  23. package/dist/outcomes/StreamingOutcome.d.ts +6 -0
  24. package/dist/outcomes/StreamingOutcome.js +30 -0
  25. package/dist/outcomes/index.d.ts +3 -0
  26. package/dist/outcomes/index.js +20 -0
  27. package/dist/secrets.d.ts +19 -0
  28. package/dist/secrets.js +34 -0
  29. package/dist/server/http.d.ts +68 -0
  30. package/dist/server/http.js +654 -0
  31. package/dist/server/index.d.ts +1 -0
  32. package/dist/server/index.js +18 -0
  33. package/dist/src/Server.d.ts +5 -0
  34. package/dist/src/Server.js +3 -0
  35. package/dist/src/Triggers.d.ts +0 -0
  36. package/dist/src/Triggers.js +2 -0
  37. package/dist/src/agent.d.ts +49 -0
  38. package/dist/src/agent.js +251 -0
  39. package/dist/src/app.d.ts +17 -0
  40. package/dist/src/app.js +46 -0
  41. package/dist/src/index.d.ts +12 -0
  42. package/dist/src/index.js +29 -0
  43. package/dist/src/model.d.ts +6 -0
  44. package/dist/src/model.js +16 -0
  45. package/dist/src/models/openAi.d.ts +38 -0
  46. package/dist/src/models/openAi.js +344 -0
  47. package/dist/src/models/types.d.ts +101 -0
  48. package/dist/src/models/types.js +27 -0
  49. package/dist/src/outcomes/CombinationOutcome.d.ts +9 -0
  50. package/dist/src/outcomes/CombinationOutcome.js +41 -0
  51. package/dist/src/outcomes/IOutcomes.d.ts +9 -0
  52. package/dist/src/outcomes/IOutcomes.js +19 -0
  53. package/dist/src/outcomes/StreamingOutcome.d.ts +6 -0
  54. package/dist/src/outcomes/StreamingOutcome.js +30 -0
  55. package/dist/src/outcomes/index.d.ts +3 -0
  56. package/dist/src/outcomes/index.js +20 -0
  57. package/dist/src/secrets.d.ts +19 -0
  58. package/dist/src/secrets.js +34 -0
  59. package/dist/src/server/http.d.ts +68 -0
  60. package/dist/src/server/http.js +654 -0
  61. package/dist/src/server/index.d.ts +1 -0
  62. package/dist/src/server/index.js +18 -0
  63. package/dist/src/tools/tool.d.ts +33 -0
  64. package/dist/src/tools/tool.js +49 -0
  65. package/dist/src/tools/toolkit.d.ts +13 -0
  66. package/dist/src/tools/toolkit.js +19 -0
  67. package/dist/src/trigger/ApiTrigger.d.ts +37 -0
  68. package/dist/src/trigger/ApiTrigger.js +106 -0
  69. package/dist/src/trigger/EmailTrigger.d.ts +15 -0
  70. package/dist/src/trigger/EmailTrigger.js +22 -0
  71. package/dist/src/trigger/FileTrigger.d.ts +14 -0
  72. package/dist/src/trigger/FileTrigger.js +37 -0
  73. package/dist/src/trigger/ITrigger.d.ts +89 -0
  74. package/dist/src/trigger/ITrigger.js +35 -0
  75. package/dist/src/trigger/RateTrigger.d.ts +23 -0
  76. package/dist/src/trigger/RateTrigger.js +58 -0
  77. package/dist/src/trigger/index.d.ts +5 -0
  78. package/dist/src/trigger/index.js +22 -0
  79. package/dist/tests/agent.test.d.ts +1 -0
  80. package/dist/tests/agent.test.js +388 -0
  81. package/dist/tests/agentStreamer.test.d.ts +1 -0
  82. package/dist/tests/agentStreamer.test.js +530 -0
  83. package/dist/tests/app.test.d.ts +1 -0
  84. package/dist/tests/app.test.js +423 -0
  85. package/dist/tests/model.test.d.ts +1 -0
  86. package/dist/tests/model.test.js +310 -0
  87. package/dist/tests/openAi.test.d.ts +1 -0
  88. package/dist/tests/openAi.test.js +701 -0
  89. package/dist/tests/outcomes.test.d.ts +1 -0
  90. package/dist/tests/outcomes.test.js +257 -0
  91. package/dist/tests/secrets.test.d.ts +1 -0
  92. package/dist/tests/secrets.test.js +263 -0
  93. package/dist/tests/server/http.test.d.ts +1 -0
  94. package/dist/tests/server/http.test.js +553 -0
  95. package/dist/tests/tool.test.d.ts +1 -0
  96. package/dist/tests/tool.test.js +315 -0
  97. package/dist/tests/toolkit.test.d.ts +1 -0
  98. package/dist/tests/toolkit.test.js +189 -0
  99. package/dist/tests/triggers.test.d.ts +1 -0
  100. package/dist/tests/triggers.test.js +203 -0
  101. package/dist/tests/types.test.d.ts +1 -0
  102. package/dist/tests/types.test.js +429 -0
  103. package/dist/tools/tool.d.ts +33 -0
  104. package/dist/tools/tool.js +49 -0
  105. package/dist/tools/toolkit.d.ts +13 -0
  106. package/dist/tools/toolkit.js +19 -0
  107. package/dist/trigger/ApiTrigger.d.ts +37 -0
  108. package/dist/trigger/ApiTrigger.js +106 -0
  109. package/dist/trigger/EmailTrigger.d.ts +15 -0
  110. package/dist/trigger/EmailTrigger.js +22 -0
  111. package/dist/trigger/FileTrigger.d.ts +14 -0
  112. package/dist/trigger/FileTrigger.js +37 -0
  113. package/dist/trigger/ITrigger.d.ts +90 -0
  114. package/dist/trigger/ITrigger.js +38 -0
  115. package/dist/trigger/RateTrigger.d.ts +23 -0
  116. package/dist/trigger/RateTrigger.js +58 -0
  117. package/dist/trigger/index.d.ts +5 -0
  118. package/dist/trigger/index.js +22 -0
  119. package/jest.config.js +20 -0
  120. package/node_modules/zod/LICENSE +21 -0
  121. package/node_modules/zod/README.md +208 -0
  122. package/node_modules/zod/index.cjs +33 -0
  123. package/node_modules/zod/index.d.cts +4 -0
  124. package/node_modules/zod/index.d.ts +4 -0
  125. package/node_modules/zod/index.js +4 -0
  126. package/node_modules/zod/locales/index.cjs +17 -0
  127. package/node_modules/zod/locales/index.d.cts +1 -0
  128. package/node_modules/zod/locales/index.d.ts +1 -0
  129. package/node_modules/zod/locales/index.js +1 -0
  130. package/node_modules/zod/locales/package.json +6 -0
  131. package/node_modules/zod/mini/index.cjs +17 -0
  132. package/node_modules/zod/mini/index.d.cts +1 -0
  133. package/node_modules/zod/mini/index.d.ts +1 -0
  134. package/node_modules/zod/mini/index.js +1 -0
  135. package/node_modules/zod/mini/package.json +6 -0
  136. package/node_modules/zod/package.json +135 -0
  137. package/node_modules/zod/src/index.ts +4 -0
  138. package/node_modules/zod/src/locales/index.ts +1 -0
  139. package/node_modules/zod/src/mini/index.ts +1 -0
  140. package/node_modules/zod/src/v3/ZodError.ts +330 -0
  141. package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  142. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  143. package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  144. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  145. package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  146. package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  147. package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  148. package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  149. package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  150. package/node_modules/zod/src/v3/errors.ts +13 -0
  151. package/node_modules/zod/src/v3/external.ts +6 -0
  152. package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  153. package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  154. package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  155. package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  156. package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  157. package/node_modules/zod/src/v3/helpers/util.ts +224 -0
  158. package/node_modules/zod/src/v3/index.ts +4 -0
  159. package/node_modules/zod/src/v3/locales/en.ts +124 -0
  160. package/node_modules/zod/src/v3/standard-schema.ts +113 -0
  161. package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
  162. package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  163. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  164. package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
  165. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  166. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  167. package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
  168. package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  169. package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
  170. package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
  171. package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  172. package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
  173. package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
  174. package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
  175. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  176. package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
  177. package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
  178. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  179. package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
  180. package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
  181. package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  182. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  183. package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
  184. package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
  185. package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  186. package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  187. package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  188. package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  189. package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
  190. package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
  191. package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
  192. package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  193. package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
  194. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  195. package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  196. package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
  197. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  198. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  199. package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
  200. package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
  201. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
  202. package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
  203. package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
  204. package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
  205. package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
  206. package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
  207. package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
  208. package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
  209. package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
  210. package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
  211. package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
  212. package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
  213. package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
  214. package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
  215. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
  216. package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
  217. package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
  218. package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
  219. package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
  220. package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
  221. package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
  222. package/node_modules/zod/src/v3/types.ts +5138 -0
  223. package/node_modules/zod/src/v4/classic/checks.ts +32 -0
  224. package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
  225. package/node_modules/zod/src/v4/classic/compat.ts +70 -0
  226. package/node_modules/zod/src/v4/classic/errors.ts +82 -0
  227. package/node_modules/zod/src/v4/classic/external.ts +51 -0
  228. package/node_modules/zod/src/v4/classic/from-json-schema.ts +536 -0
  229. package/node_modules/zod/src/v4/classic/index.ts +5 -0
  230. package/node_modules/zod/src/v4/classic/iso.ts +90 -0
  231. package/node_modules/zod/src/v4/classic/parse.ts +82 -0
  232. package/node_modules/zod/src/v4/classic/schemas.ts +2352 -0
  233. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
  234. package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
  235. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +210 -0
  236. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
  237. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
  238. package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
  239. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
  240. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +63 -0
  241. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +276 -0
  242. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
  243. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
  244. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +562 -0
  245. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
  246. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
  247. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
  248. package/node_modules/zod/src/v4/classic/tests/date.test.ts +31 -0
  249. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
  250. package/node_modules/zod/src/v4/classic/tests/default.test.ts +365 -0
  251. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
  252. package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
  253. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +661 -0
  254. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
  255. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +595 -0
  256. package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
  257. package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
  258. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
  259. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
  260. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +537 -0
  261. package/node_modules/zod/src/v4/classic/tests/function.test.ts +308 -0
  262. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
  263. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
  264. package/node_modules/zod/src/v4/classic/tests/index.test.ts +898 -0
  265. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +34 -0
  266. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +171 -0
  267. package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
  268. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
  269. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
  270. package/node_modules/zod/src/v4/classic/tests/map.test.ts +196 -0
  271. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  272. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  273. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
  274. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  275. package/node_modules/zod/src/v4/classic/tests/number.test.ts +270 -0
  276. package/node_modules/zod/src/v4/classic/tests/object.test.ts +609 -0
  277. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +136 -0
  278. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +340 -0
  279. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
  280. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
  281. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
  282. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +282 -0
  283. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  284. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  285. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  286. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  287. package/node_modules/zod/src/v4/classic/tests/record.test.ts +525 -0
  288. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +582 -0
  289. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +605 -0
  290. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +208 -0
  291. package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
  292. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
  293. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
  294. package/node_modules/zod/src/v4/classic/tests/string.test.ts +1152 -0
  295. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
  296. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
  297. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
  298. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2755 -0
  299. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +361 -0
  300. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +181 -0
  301. package/node_modules/zod/src/v4/classic/tests/union.test.ts +219 -0
  302. package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
  303. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  304. package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  305. package/node_modules/zod/src/v4/core/api.ts +1681 -0
  306. package/node_modules/zod/src/v4/core/checks.ts +1287 -0
  307. package/node_modules/zod/src/v4/core/config.ts +15 -0
  308. package/node_modules/zod/src/v4/core/core.ts +128 -0
  309. package/node_modules/zod/src/v4/core/doc.ts +44 -0
  310. package/node_modules/zod/src/v4/core/errors.ts +424 -0
  311. package/node_modules/zod/src/v4/core/index.ts +16 -0
  312. package/node_modules/zod/src/v4/core/json-schema-generator.ts +124 -0
  313. package/node_modules/zod/src/v4/core/json-schema-processors.ts +630 -0
  314. package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
  315. package/node_modules/zod/src/v4/core/parse.ts +195 -0
  316. package/node_modules/zod/src/v4/core/regexes.ts +182 -0
  317. package/node_modules/zod/src/v4/core/registries.ts +108 -0
  318. package/node_modules/zod/src/v4/core/schemas.ts +4418 -0
  319. package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
  320. package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
  321. package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  322. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  323. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  324. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
  325. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
  326. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
  327. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  328. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  329. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +67 -0
  330. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
  331. package/node_modules/zod/src/v4/core/to-json-schema.ts +554 -0
  332. package/node_modules/zod/src/v4/core/util.ts +921 -0
  333. package/node_modules/zod/src/v4/core/versions.ts +5 -0
  334. package/node_modules/zod/src/v4/core/zsf.ts +323 -0
  335. package/node_modules/zod/src/v4/index.ts +4 -0
  336. package/node_modules/zod/src/v4/locales/ar.ts +125 -0
  337. package/node_modules/zod/src/v4/locales/az.ts +121 -0
  338. package/node_modules/zod/src/v4/locales/be.ts +184 -0
  339. package/node_modules/zod/src/v4/locales/bg.ts +136 -0
  340. package/node_modules/zod/src/v4/locales/ca.ts +127 -0
  341. package/node_modules/zod/src/v4/locales/cs.ts +142 -0
  342. package/node_modules/zod/src/v4/locales/da.ts +141 -0
  343. package/node_modules/zod/src/v4/locales/de.ts +124 -0
  344. package/node_modules/zod/src/v4/locales/en.ts +128 -0
  345. package/node_modules/zod/src/v4/locales/eo.ts +125 -0
  346. package/node_modules/zod/src/v4/locales/es.ts +159 -0
  347. package/node_modules/zod/src/v4/locales/fa.ts +134 -0
  348. package/node_modules/zod/src/v4/locales/fi.ts +131 -0
  349. package/node_modules/zod/src/v4/locales/fr-CA.ts +126 -0
  350. package/node_modules/zod/src/v4/locales/fr.ts +124 -0
  351. package/node_modules/zod/src/v4/locales/he.ts +256 -0
  352. package/node_modules/zod/src/v4/locales/hu.ts +126 -0
  353. package/node_modules/zod/src/v4/locales/id.ts +125 -0
  354. package/node_modules/zod/src/v4/locales/index.ts +47 -0
  355. package/node_modules/zod/src/v4/locales/is.ts +127 -0
  356. package/node_modules/zod/src/v4/locales/it.ts +125 -0
  357. package/node_modules/zod/src/v4/locales/ja.ts +122 -0
  358. package/node_modules/zod/src/v4/locales/ka.ts +138 -0
  359. package/node_modules/zod/src/v4/locales/kh.ts +7 -0
  360. package/node_modules/zod/src/v4/locales/km.ts +126 -0
  361. package/node_modules/zod/src/v4/locales/ko.ts +131 -0
  362. package/node_modules/zod/src/v4/locales/lt.ts +265 -0
  363. package/node_modules/zod/src/v4/locales/mk.ts +127 -0
  364. package/node_modules/zod/src/v4/locales/ms.ts +124 -0
  365. package/node_modules/zod/src/v4/locales/nl.ts +126 -0
  366. package/node_modules/zod/src/v4/locales/no.ts +124 -0
  367. package/node_modules/zod/src/v4/locales/ota.ts +125 -0
  368. package/node_modules/zod/src/v4/locales/pl.ts +126 -0
  369. package/node_modules/zod/src/v4/locales/ps.ts +133 -0
  370. package/node_modules/zod/src/v4/locales/pt.ts +123 -0
  371. package/node_modules/zod/src/v4/locales/ru.ts +184 -0
  372. package/node_modules/zod/src/v4/locales/sl.ts +126 -0
  373. package/node_modules/zod/src/v4/locales/sv.ts +127 -0
  374. package/node_modules/zod/src/v4/locales/ta.ts +125 -0
  375. package/node_modules/zod/src/v4/locales/th.ts +126 -0
  376. package/node_modules/zod/src/v4/locales/tr.ts +121 -0
  377. package/node_modules/zod/src/v4/locales/ua.ts +7 -0
  378. package/node_modules/zod/src/v4/locales/uk.ts +126 -0
  379. package/node_modules/zod/src/v4/locales/ur.ts +126 -0
  380. package/node_modules/zod/src/v4/locales/vi.ts +125 -0
  381. package/node_modules/zod/src/v4/locales/yo.ts +131 -0
  382. package/node_modules/zod/src/v4/locales/zh-CN.ts +123 -0
  383. package/node_modules/zod/src/v4/locales/zh-TW.ts +125 -0
  384. package/node_modules/zod/src/v4/mini/checks.ts +32 -0
  385. package/node_modules/zod/src/v4/mini/coerce.ts +22 -0
  386. package/node_modules/zod/src/v4/mini/external.ts +40 -0
  387. package/node_modules/zod/src/v4/mini/index.ts +3 -0
  388. package/node_modules/zod/src/v4/mini/iso.ts +62 -0
  389. package/node_modules/zod/src/v4/mini/parse.ts +14 -0
  390. package/node_modules/zod/src/v4/mini/schemas.ts +1781 -0
  391. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
  392. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +51 -0
  393. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
  394. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +529 -0
  395. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
  396. package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
  397. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
  398. package/node_modules/zod/src/v4/mini/tests/index.test.ts +922 -0
  399. package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
  400. package/node_modules/zod/src/v4/mini/tests/object.test.ts +200 -0
  401. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
  402. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
  403. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +17 -0
  404. package/node_modules/zod/src/v4/mini/tests/string.test.ts +347 -0
  405. package/node_modules/zod/src/v4-mini/index.ts +1 -0
  406. package/node_modules/zod/v3/ZodError.cjs +138 -0
  407. package/node_modules/zod/v3/ZodError.d.cts +164 -0
  408. package/node_modules/zod/v3/ZodError.d.ts +164 -0
  409. package/node_modules/zod/v3/ZodError.js +133 -0
  410. package/node_modules/zod/v3/errors.cjs +17 -0
  411. package/node_modules/zod/v3/errors.d.cts +5 -0
  412. package/node_modules/zod/v3/errors.d.ts +5 -0
  413. package/node_modules/zod/v3/errors.js +9 -0
  414. package/node_modules/zod/v3/external.cjs +22 -0
  415. package/node_modules/zod/v3/external.d.cts +6 -0
  416. package/node_modules/zod/v3/external.d.ts +6 -0
  417. package/node_modules/zod/v3/external.js +6 -0
  418. package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
  419. package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  420. package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  421. package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
  422. package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
  423. package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  424. package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  425. package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
  426. package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
  427. package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  428. package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  429. package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
  430. package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
  431. package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  432. package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  433. package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
  434. package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
  435. package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  436. package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  437. package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  438. package/node_modules/zod/v3/helpers/util.cjs +137 -0
  439. package/node_modules/zod/v3/helpers/util.d.cts +85 -0
  440. package/node_modules/zod/v3/helpers/util.d.ts +85 -0
  441. package/node_modules/zod/v3/helpers/util.js +133 -0
  442. package/node_modules/zod/v3/index.cjs +33 -0
  443. package/node_modules/zod/v3/index.d.cts +4 -0
  444. package/node_modules/zod/v3/index.d.ts +4 -0
  445. package/node_modules/zod/v3/index.js +4 -0
  446. package/node_modules/zod/v3/locales/en.cjs +112 -0
  447. package/node_modules/zod/v3/locales/en.d.cts +3 -0
  448. package/node_modules/zod/v3/locales/en.d.ts +3 -0
  449. package/node_modules/zod/v3/locales/en.js +109 -0
  450. package/node_modules/zod/v3/package.json +6 -0
  451. package/node_modules/zod/v3/standard-schema.cjs +2 -0
  452. package/node_modules/zod/v3/standard-schema.d.cts +102 -0
  453. package/node_modules/zod/v3/standard-schema.d.ts +102 -0
  454. package/node_modules/zod/v3/standard-schema.js +1 -0
  455. package/node_modules/zod/v3/types.cjs +3777 -0
  456. package/node_modules/zod/v3/types.d.cts +1034 -0
  457. package/node_modules/zod/v3/types.d.ts +1034 -0
  458. package/node_modules/zod/v3/types.js +3695 -0
  459. package/node_modules/zod/v4/classic/checks.cjs +33 -0
  460. package/node_modules/zod/v4/classic/checks.d.cts +1 -0
  461. package/node_modules/zod/v4/classic/checks.d.ts +1 -0
  462. package/node_modules/zod/v4/classic/checks.js +1 -0
  463. package/node_modules/zod/v4/classic/coerce.cjs +47 -0
  464. package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
  465. package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
  466. package/node_modules/zod/v4/classic/coerce.js +17 -0
  467. package/node_modules/zod/v4/classic/compat.cjs +61 -0
  468. package/node_modules/zod/v4/classic/compat.d.cts +50 -0
  469. package/node_modules/zod/v4/classic/compat.d.ts +50 -0
  470. package/node_modules/zod/v4/classic/compat.js +31 -0
  471. package/node_modules/zod/v4/classic/errors.cjs +74 -0
  472. package/node_modules/zod/v4/classic/errors.d.cts +30 -0
  473. package/node_modules/zod/v4/classic/errors.d.ts +30 -0
  474. package/node_modules/zod/v4/classic/errors.js +48 -0
  475. package/node_modules/zod/v4/classic/external.cjs +73 -0
  476. package/node_modules/zod/v4/classic/external.d.cts +15 -0
  477. package/node_modules/zod/v4/classic/external.d.ts +15 -0
  478. package/node_modules/zod/v4/classic/external.js +20 -0
  479. package/node_modules/zod/v4/classic/from-json-schema.cjs +511 -0
  480. package/node_modules/zod/v4/classic/from-json-schema.d.cts +10 -0
  481. package/node_modules/zod/v4/classic/from-json-schema.d.ts +10 -0
  482. package/node_modules/zod/v4/classic/from-json-schema.js +485 -0
  483. package/node_modules/zod/v4/classic/index.cjs +33 -0
  484. package/node_modules/zod/v4/classic/index.d.cts +4 -0
  485. package/node_modules/zod/v4/classic/index.d.ts +4 -0
  486. package/node_modules/zod/v4/classic/index.js +4 -0
  487. package/node_modules/zod/v4/classic/iso.cjs +60 -0
  488. package/node_modules/zod/v4/classic/iso.d.cts +22 -0
  489. package/node_modules/zod/v4/classic/iso.d.ts +22 -0
  490. package/node_modules/zod/v4/classic/iso.js +30 -0
  491. package/node_modules/zod/v4/classic/package.json +6 -0
  492. package/node_modules/zod/v4/classic/parse.cjs +41 -0
  493. package/node_modules/zod/v4/classic/parse.d.cts +31 -0
  494. package/node_modules/zod/v4/classic/parse.d.ts +31 -0
  495. package/node_modules/zod/v4/classic/parse.js +15 -0
  496. package/node_modules/zod/v4/classic/schemas.cjs +1240 -0
  497. package/node_modules/zod/v4/classic/schemas.d.cts +726 -0
  498. package/node_modules/zod/v4/classic/schemas.d.ts +726 -0
  499. package/node_modules/zod/v4/classic/schemas.js +1126 -0
  500. package/node_modules/zod/v4/core/api.cjs +1109 -0
  501. package/node_modules/zod/v4/core/api.d.cts +304 -0
  502. package/node_modules/zod/v4/core/api.d.ts +304 -0
  503. package/node_modules/zod/v4/core/api.js +969 -0
  504. package/node_modules/zod/v4/core/checks.cjs +595 -0
  505. package/node_modules/zod/v4/core/checks.d.cts +278 -0
  506. package/node_modules/zod/v4/core/checks.d.ts +278 -0
  507. package/node_modules/zod/v4/core/checks.js +569 -0
  508. package/node_modules/zod/v4/core/core.cjs +83 -0
  509. package/node_modules/zod/v4/core/core.d.cts +52 -0
  510. package/node_modules/zod/v4/core/core.d.ts +52 -0
  511. package/node_modules/zod/v4/core/core.js +76 -0
  512. package/node_modules/zod/v4/core/doc.cjs +39 -0
  513. package/node_modules/zod/v4/core/doc.d.cts +14 -0
  514. package/node_modules/zod/v4/core/doc.d.ts +14 -0
  515. package/node_modules/zod/v4/core/doc.js +35 -0
  516. package/node_modules/zod/v4/core/errors.cjs +213 -0
  517. package/node_modules/zod/v4/core/errors.d.cts +219 -0
  518. package/node_modules/zod/v4/core/errors.d.ts +219 -0
  519. package/node_modules/zod/v4/core/errors.js +182 -0
  520. package/node_modules/zod/v4/core/index.cjs +47 -0
  521. package/node_modules/zod/v4/core/index.d.cts +16 -0
  522. package/node_modules/zod/v4/core/index.d.ts +16 -0
  523. package/node_modules/zod/v4/core/index.js +16 -0
  524. package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
  525. package/node_modules/zod/v4/core/json-schema-generator.d.cts +64 -0
  526. package/node_modules/zod/v4/core/json-schema-generator.d.ts +64 -0
  527. package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
  528. package/node_modules/zod/v4/core/json-schema-processors.cjs +617 -0
  529. package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
  530. package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
  531. package/node_modules/zod/v4/core/json-schema-processors.js +574 -0
  532. package/node_modules/zod/v4/core/json-schema.cjs +2 -0
  533. package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
  534. package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
  535. package/node_modules/zod/v4/core/json-schema.js +1 -0
  536. package/node_modules/zod/v4/core/package.json +6 -0
  537. package/node_modules/zod/v4/core/parse.cjs +131 -0
  538. package/node_modules/zod/v4/core/parse.d.cts +49 -0
  539. package/node_modules/zod/v4/core/parse.d.ts +49 -0
  540. package/node_modules/zod/v4/core/parse.js +93 -0
  541. package/node_modules/zod/v4/core/regexes.cjs +165 -0
  542. package/node_modules/zod/v4/core/regexes.d.cts +79 -0
  543. package/node_modules/zod/v4/core/regexes.d.ts +79 -0
  544. package/node_modules/zod/v4/core/regexes.js +132 -0
  545. package/node_modules/zod/v4/core/registries.cjs +59 -0
  546. package/node_modules/zod/v4/core/registries.d.cts +35 -0
  547. package/node_modules/zod/v4/core/registries.d.ts +35 -0
  548. package/node_modules/zod/v4/core/registries.js +54 -0
  549. package/node_modules/zod/v4/core/schemas.cjs +2040 -0
  550. package/node_modules/zod/v4/core/schemas.d.cts +1135 -0
  551. package/node_modules/zod/v4/core/schemas.d.ts +1135 -0
  552. package/node_modules/zod/v4/core/schemas.js +2009 -0
  553. package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
  554. package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
  555. package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
  556. package/node_modules/zod/v4/core/standard-schema.js +1 -0
  557. package/node_modules/zod/v4/core/to-json-schema.cjs +392 -0
  558. package/node_modules/zod/v4/core/to-json-schema.d.cts +113 -0
  559. package/node_modules/zod/v4/core/to-json-schema.d.ts +113 -0
  560. package/node_modules/zod/v4/core/to-json-schema.js +383 -0
  561. package/node_modules/zod/v4/core/util.cjs +669 -0
  562. package/node_modules/zod/v4/core/util.d.cts +198 -0
  563. package/node_modules/zod/v4/core/util.d.ts +198 -0
  564. package/node_modules/zod/v4/core/util.js +611 -0
  565. package/node_modules/zod/v4/core/versions.cjs +8 -0
  566. package/node_modules/zod/v4/core/versions.d.cts +5 -0
  567. package/node_modules/zod/v4/core/versions.d.ts +5 -0
  568. package/node_modules/zod/v4/core/versions.js +5 -0
  569. package/node_modules/zod/v4/index.cjs +22 -0
  570. package/node_modules/zod/v4/index.d.cts +3 -0
  571. package/node_modules/zod/v4/index.d.ts +3 -0
  572. package/node_modules/zod/v4/index.js +3 -0
  573. package/node_modules/zod/v4/locales/ar.cjs +143 -0
  574. package/node_modules/zod/v4/locales/ar.d.cts +5 -0
  575. package/node_modules/zod/v4/locales/ar.d.ts +4 -0
  576. package/node_modules/zod/v4/locales/ar.js +116 -0
  577. package/node_modules/zod/v4/locales/az.cjs +142 -0
  578. package/node_modules/zod/v4/locales/az.d.cts +5 -0
  579. package/node_modules/zod/v4/locales/az.d.ts +4 -0
  580. package/node_modules/zod/v4/locales/az.js +115 -0
  581. package/node_modules/zod/v4/locales/be.cjs +191 -0
  582. package/node_modules/zod/v4/locales/be.d.cts +5 -0
  583. package/node_modules/zod/v4/locales/be.d.ts +4 -0
  584. package/node_modules/zod/v4/locales/be.js +164 -0
  585. package/node_modules/zod/v4/locales/bg.cjs +156 -0
  586. package/node_modules/zod/v4/locales/bg.d.cts +5 -0
  587. package/node_modules/zod/v4/locales/bg.d.ts +5 -0
  588. package/node_modules/zod/v4/locales/bg.js +128 -0
  589. package/node_modules/zod/v4/locales/ca.cjs +145 -0
  590. package/node_modules/zod/v4/locales/ca.d.cts +5 -0
  591. package/node_modules/zod/v4/locales/ca.d.ts +4 -0
  592. package/node_modules/zod/v4/locales/ca.js +118 -0
  593. package/node_modules/zod/v4/locales/cs.cjs +162 -0
  594. package/node_modules/zod/v4/locales/cs.d.cts +5 -0
  595. package/node_modules/zod/v4/locales/cs.d.ts +4 -0
  596. package/node_modules/zod/v4/locales/cs.js +135 -0
  597. package/node_modules/zod/v4/locales/da.cjs +158 -0
  598. package/node_modules/zod/v4/locales/da.d.cts +5 -0
  599. package/node_modules/zod/v4/locales/da.d.ts +4 -0
  600. package/node_modules/zod/v4/locales/da.js +131 -0
  601. package/node_modules/zod/v4/locales/de.cjs +143 -0
  602. package/node_modules/zod/v4/locales/de.d.cts +5 -0
  603. package/node_modules/zod/v4/locales/de.d.ts +4 -0
  604. package/node_modules/zod/v4/locales/de.js +116 -0
  605. package/node_modules/zod/v4/locales/en.cjs +146 -0
  606. package/node_modules/zod/v4/locales/en.d.cts +5 -0
  607. package/node_modules/zod/v4/locales/en.d.ts +5 -0
  608. package/node_modules/zod/v4/locales/en.js +118 -0
  609. package/node_modules/zod/v4/locales/eo.cjs +144 -0
  610. package/node_modules/zod/v4/locales/eo.d.cts +5 -0
  611. package/node_modules/zod/v4/locales/eo.d.ts +5 -0
  612. package/node_modules/zod/v4/locales/eo.js +116 -0
  613. package/node_modules/zod/v4/locales/es.cjs +176 -0
  614. package/node_modules/zod/v4/locales/es.d.cts +5 -0
  615. package/node_modules/zod/v4/locales/es.d.ts +4 -0
  616. package/node_modules/zod/v4/locales/es.js +149 -0
  617. package/node_modules/zod/v4/locales/fa.cjs +149 -0
  618. package/node_modules/zod/v4/locales/fa.d.cts +5 -0
  619. package/node_modules/zod/v4/locales/fa.d.ts +4 -0
  620. package/node_modules/zod/v4/locales/fa.js +122 -0
  621. package/node_modules/zod/v4/locales/fi.cjs +149 -0
  622. package/node_modules/zod/v4/locales/fi.d.cts +5 -0
  623. package/node_modules/zod/v4/locales/fi.d.ts +4 -0
  624. package/node_modules/zod/v4/locales/fi.js +122 -0
  625. package/node_modules/zod/v4/locales/fr-CA.cjs +144 -0
  626. package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  627. package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  628. package/node_modules/zod/v4/locales/fr-CA.js +117 -0
  629. package/node_modules/zod/v4/locales/fr.cjs +143 -0
  630. package/node_modules/zod/v4/locales/fr.d.cts +5 -0
  631. package/node_modules/zod/v4/locales/fr.d.ts +4 -0
  632. package/node_modules/zod/v4/locales/fr.js +116 -0
  633. package/node_modules/zod/v4/locales/he.cjs +255 -0
  634. package/node_modules/zod/v4/locales/he.d.cts +5 -0
  635. package/node_modules/zod/v4/locales/he.d.ts +4 -0
  636. package/node_modules/zod/v4/locales/he.js +228 -0
  637. package/node_modules/zod/v4/locales/hu.cjs +144 -0
  638. package/node_modules/zod/v4/locales/hu.d.cts +5 -0
  639. package/node_modules/zod/v4/locales/hu.d.ts +4 -0
  640. package/node_modules/zod/v4/locales/hu.js +117 -0
  641. package/node_modules/zod/v4/locales/id.cjs +143 -0
  642. package/node_modules/zod/v4/locales/id.d.cts +5 -0
  643. package/node_modules/zod/v4/locales/id.d.ts +4 -0
  644. package/node_modules/zod/v4/locales/id.js +116 -0
  645. package/node_modules/zod/v4/locales/index.cjs +100 -0
  646. package/node_modules/zod/v4/locales/index.d.cts +47 -0
  647. package/node_modules/zod/v4/locales/index.d.ts +47 -0
  648. package/node_modules/zod/v4/locales/index.js +47 -0
  649. package/node_modules/zod/v4/locales/is.cjs +145 -0
  650. package/node_modules/zod/v4/locales/is.d.cts +5 -0
  651. package/node_modules/zod/v4/locales/is.d.ts +5 -0
  652. package/node_modules/zod/v4/locales/is.js +117 -0
  653. package/node_modules/zod/v4/locales/it.cjs +144 -0
  654. package/node_modules/zod/v4/locales/it.d.cts +5 -0
  655. package/node_modules/zod/v4/locales/it.d.ts +4 -0
  656. package/node_modules/zod/v4/locales/it.js +117 -0
  657. package/node_modules/zod/v4/locales/ja.cjs +142 -0
  658. package/node_modules/zod/v4/locales/ja.d.cts +5 -0
  659. package/node_modules/zod/v4/locales/ja.d.ts +4 -0
  660. package/node_modules/zod/v4/locales/ja.js +115 -0
  661. package/node_modules/zod/v4/locales/ka.cjs +153 -0
  662. package/node_modules/zod/v4/locales/ka.d.cts +5 -0
  663. package/node_modules/zod/v4/locales/ka.d.ts +5 -0
  664. package/node_modules/zod/v4/locales/ka.js +125 -0
  665. package/node_modules/zod/v4/locales/kh.cjs +12 -0
  666. package/node_modules/zod/v4/locales/kh.d.cts +5 -0
  667. package/node_modules/zod/v4/locales/kh.d.ts +5 -0
  668. package/node_modules/zod/v4/locales/kh.js +5 -0
  669. package/node_modules/zod/v4/locales/km.cjs +144 -0
  670. package/node_modules/zod/v4/locales/km.d.cts +5 -0
  671. package/node_modules/zod/v4/locales/km.d.ts +4 -0
  672. package/node_modules/zod/v4/locales/km.js +117 -0
  673. package/node_modules/zod/v4/locales/ko.cjs +148 -0
  674. package/node_modules/zod/v4/locales/ko.d.cts +5 -0
  675. package/node_modules/zod/v4/locales/ko.d.ts +4 -0
  676. package/node_modules/zod/v4/locales/ko.js +121 -0
  677. package/node_modules/zod/v4/locales/lt.cjs +258 -0
  678. package/node_modules/zod/v4/locales/lt.d.cts +5 -0
  679. package/node_modules/zod/v4/locales/lt.d.ts +5 -0
  680. package/node_modules/zod/v4/locales/lt.js +230 -0
  681. package/node_modules/zod/v4/locales/mk.cjs +145 -0
  682. package/node_modules/zod/v4/locales/mk.d.cts +5 -0
  683. package/node_modules/zod/v4/locales/mk.d.ts +4 -0
  684. package/node_modules/zod/v4/locales/mk.js +118 -0
  685. package/node_modules/zod/v4/locales/ms.cjs +143 -0
  686. package/node_modules/zod/v4/locales/ms.d.cts +5 -0
  687. package/node_modules/zod/v4/locales/ms.d.ts +4 -0
  688. package/node_modules/zod/v4/locales/ms.js +116 -0
  689. package/node_modules/zod/v4/locales/nl.cjs +144 -0
  690. package/node_modules/zod/v4/locales/nl.d.cts +5 -0
  691. package/node_modules/zod/v4/locales/nl.d.ts +4 -0
  692. package/node_modules/zod/v4/locales/nl.js +117 -0
  693. package/node_modules/zod/v4/locales/no.cjs +143 -0
  694. package/node_modules/zod/v4/locales/no.d.cts +5 -0
  695. package/node_modules/zod/v4/locales/no.d.ts +4 -0
  696. package/node_modules/zod/v4/locales/no.js +116 -0
  697. package/node_modules/zod/v4/locales/ota.cjs +144 -0
  698. package/node_modules/zod/v4/locales/ota.d.cts +5 -0
  699. package/node_modules/zod/v4/locales/ota.d.ts +4 -0
  700. package/node_modules/zod/v4/locales/ota.js +117 -0
  701. package/node_modules/zod/v4/locales/package.json +6 -0
  702. package/node_modules/zod/v4/locales/pl.cjs +144 -0
  703. package/node_modules/zod/v4/locales/pl.d.cts +5 -0
  704. package/node_modules/zod/v4/locales/pl.d.ts +4 -0
  705. package/node_modules/zod/v4/locales/pl.js +117 -0
  706. package/node_modules/zod/v4/locales/ps.cjs +149 -0
  707. package/node_modules/zod/v4/locales/ps.d.cts +5 -0
  708. package/node_modules/zod/v4/locales/ps.d.ts +4 -0
  709. package/node_modules/zod/v4/locales/ps.js +122 -0
  710. package/node_modules/zod/v4/locales/pt.cjs +143 -0
  711. package/node_modules/zod/v4/locales/pt.d.cts +5 -0
  712. package/node_modules/zod/v4/locales/pt.d.ts +4 -0
  713. package/node_modules/zod/v4/locales/pt.js +116 -0
  714. package/node_modules/zod/v4/locales/ru.cjs +191 -0
  715. package/node_modules/zod/v4/locales/ru.d.cts +5 -0
  716. package/node_modules/zod/v4/locales/ru.d.ts +4 -0
  717. package/node_modules/zod/v4/locales/ru.js +164 -0
  718. package/node_modules/zod/v4/locales/sl.cjs +144 -0
  719. package/node_modules/zod/v4/locales/sl.d.cts +5 -0
  720. package/node_modules/zod/v4/locales/sl.d.ts +4 -0
  721. package/node_modules/zod/v4/locales/sl.js +117 -0
  722. package/node_modules/zod/v4/locales/sv.cjs +145 -0
  723. package/node_modules/zod/v4/locales/sv.d.cts +5 -0
  724. package/node_modules/zod/v4/locales/sv.d.ts +4 -0
  725. package/node_modules/zod/v4/locales/sv.js +118 -0
  726. package/node_modules/zod/v4/locales/ta.cjs +144 -0
  727. package/node_modules/zod/v4/locales/ta.d.cts +5 -0
  728. package/node_modules/zod/v4/locales/ta.d.ts +4 -0
  729. package/node_modules/zod/v4/locales/ta.js +117 -0
  730. package/node_modules/zod/v4/locales/th.cjs +144 -0
  731. package/node_modules/zod/v4/locales/th.d.cts +5 -0
  732. package/node_modules/zod/v4/locales/th.d.ts +4 -0
  733. package/node_modules/zod/v4/locales/th.js +117 -0
  734. package/node_modules/zod/v4/locales/tr.cjs +143 -0
  735. package/node_modules/zod/v4/locales/tr.d.cts +5 -0
  736. package/node_modules/zod/v4/locales/tr.d.ts +5 -0
  737. package/node_modules/zod/v4/locales/tr.js +115 -0
  738. package/node_modules/zod/v4/locales/ua.cjs +12 -0
  739. package/node_modules/zod/v4/locales/ua.d.cts +5 -0
  740. package/node_modules/zod/v4/locales/ua.d.ts +5 -0
  741. package/node_modules/zod/v4/locales/ua.js +5 -0
  742. package/node_modules/zod/v4/locales/uk.cjs +144 -0
  743. package/node_modules/zod/v4/locales/uk.d.cts +5 -0
  744. package/node_modules/zod/v4/locales/uk.d.ts +4 -0
  745. package/node_modules/zod/v4/locales/uk.js +117 -0
  746. package/node_modules/zod/v4/locales/ur.cjs +144 -0
  747. package/node_modules/zod/v4/locales/ur.d.cts +5 -0
  748. package/node_modules/zod/v4/locales/ur.d.ts +4 -0
  749. package/node_modules/zod/v4/locales/ur.js +117 -0
  750. package/node_modules/zod/v4/locales/vi.cjs +143 -0
  751. package/node_modules/zod/v4/locales/vi.d.cts +5 -0
  752. package/node_modules/zod/v4/locales/vi.d.ts +4 -0
  753. package/node_modules/zod/v4/locales/vi.js +116 -0
  754. package/node_modules/zod/v4/locales/yo.cjs +142 -0
  755. package/node_modules/zod/v4/locales/yo.d.cts +5 -0
  756. package/node_modules/zod/v4/locales/yo.d.ts +4 -0
  757. package/node_modules/zod/v4/locales/yo.js +115 -0
  758. package/node_modules/zod/v4/locales/zh-CN.cjs +143 -0
  759. package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  760. package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  761. package/node_modules/zod/v4/locales/zh-CN.js +116 -0
  762. package/node_modules/zod/v4/locales/zh-TW.cjs +144 -0
  763. package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  764. package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  765. package/node_modules/zod/v4/locales/zh-TW.js +117 -0
  766. package/node_modules/zod/v4/mini/checks.cjs +34 -0
  767. package/node_modules/zod/v4/mini/checks.d.cts +1 -0
  768. package/node_modules/zod/v4/mini/checks.d.ts +1 -0
  769. package/node_modules/zod/v4/mini/checks.js +1 -0
  770. package/node_modules/zod/v4/mini/coerce.cjs +47 -0
  771. package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
  772. package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
  773. package/node_modules/zod/v4/mini/coerce.js +17 -0
  774. package/node_modules/zod/v4/mini/external.cjs +63 -0
  775. package/node_modules/zod/v4/mini/external.d.cts +12 -0
  776. package/node_modules/zod/v4/mini/external.d.ts +12 -0
  777. package/node_modules/zod/v4/mini/external.js +14 -0
  778. package/node_modules/zod/v4/mini/index.cjs +32 -0
  779. package/node_modules/zod/v4/mini/index.d.cts +3 -0
  780. package/node_modules/zod/v4/mini/index.d.ts +3 -0
  781. package/node_modules/zod/v4/mini/index.js +3 -0
  782. package/node_modules/zod/v4/mini/iso.cjs +60 -0
  783. package/node_modules/zod/v4/mini/iso.d.cts +22 -0
  784. package/node_modules/zod/v4/mini/iso.d.ts +22 -0
  785. package/node_modules/zod/v4/mini/iso.js +30 -0
  786. package/node_modules/zod/v4/mini/package.json +6 -0
  787. package/node_modules/zod/v4/mini/parse.cjs +16 -0
  788. package/node_modules/zod/v4/mini/parse.d.cts +1 -0
  789. package/node_modules/zod/v4/mini/parse.d.ts +1 -0
  790. package/node_modules/zod/v4/mini/parse.js +1 -0
  791. package/node_modules/zod/v4/mini/schemas.cjs +929 -0
  792. package/node_modules/zod/v4/mini/schemas.d.cts +421 -0
  793. package/node_modules/zod/v4/mini/schemas.d.ts +421 -0
  794. package/node_modules/zod/v4/mini/schemas.js +809 -0
  795. package/node_modules/zod/v4/package.json +6 -0
  796. package/node_modules/zod/v4-mini/index.cjs +17 -0
  797. package/node_modules/zod/v4-mini/index.d.cts +1 -0
  798. package/node_modules/zod/v4-mini/index.d.ts +1 -0
  799. package/node_modules/zod/v4-mini/index.js +1 -0
  800. package/node_modules/zod/v4-mini/package.json +6 -0
  801. package/package.json +93 -0
  802. package/publish.sh +449 -0
@@ -0,0 +1,2040 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = exports.$ZodObject = exports.$ZodArray = exports.$ZodDate = exports.$ZodVoid = exports.$ZodNever = exports.$ZodUnknown = exports.$ZodAny = exports.$ZodNull = exports.$ZodUndefined = exports.$ZodSymbol = exports.$ZodBigIntFormat = exports.$ZodBigInt = exports.$ZodBoolean = exports.$ZodNumberFormat = exports.$ZodNumber = exports.$ZodCustomStringFormat = exports.$ZodJWT = exports.$ZodE164 = exports.$ZodBase64URL = exports.$ZodBase64 = exports.$ZodCIDRv6 = exports.$ZodCIDRv4 = exports.$ZodMAC = exports.$ZodIPv6 = exports.$ZodIPv4 = exports.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
27
+ exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = void 0;
28
+ exports.isValidBase64 = isValidBase64;
29
+ exports.isValidBase64URL = isValidBase64URL;
30
+ exports.isValidJWT = isValidJWT;
31
+ const checks = __importStar(require("./checks.cjs"));
32
+ const core = __importStar(require("./core.cjs"));
33
+ const doc_js_1 = require("./doc.cjs");
34
+ const parse_js_1 = require("./parse.cjs");
35
+ const regexes = __importStar(require("./regexes.cjs"));
36
+ const util = __importStar(require("./util.cjs"));
37
+ const versions_js_1 = require("./versions.cjs");
38
+ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
39
+ var _a;
40
+ inst ?? (inst = {});
41
+ inst._zod.def = def; // set _def property
42
+ inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
43
+ inst._zod.version = versions_js_1.version;
44
+ const checks = [...(inst._zod.def.checks ?? [])];
45
+ // if inst is itself a checks.$ZodCheck, run it as a check
46
+ if (inst._zod.traits.has("$ZodCheck")) {
47
+ checks.unshift(inst);
48
+ }
49
+ for (const ch of checks) {
50
+ for (const fn of ch._zod.onattach) {
51
+ fn(inst);
52
+ }
53
+ }
54
+ if (checks.length === 0) {
55
+ // deferred initializer
56
+ // inst._zod.parse is not yet defined
57
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
58
+ inst._zod.deferred?.push(() => {
59
+ inst._zod.run = inst._zod.parse;
60
+ });
61
+ }
62
+ else {
63
+ const runChecks = (payload, checks, ctx) => {
64
+ let isAborted = util.aborted(payload);
65
+ let asyncResult;
66
+ for (const ch of checks) {
67
+ if (ch._zod.def.when) {
68
+ const shouldRun = ch._zod.def.when(payload);
69
+ if (!shouldRun)
70
+ continue;
71
+ }
72
+ else if (isAborted) {
73
+ continue;
74
+ }
75
+ const currLen = payload.issues.length;
76
+ const _ = ch._zod.check(payload);
77
+ if (_ instanceof Promise && ctx?.async === false) {
78
+ throw new core.$ZodAsyncError();
79
+ }
80
+ if (asyncResult || _ instanceof Promise) {
81
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
82
+ await _;
83
+ const nextLen = payload.issues.length;
84
+ if (nextLen === currLen)
85
+ return;
86
+ if (!isAborted)
87
+ isAborted = util.aborted(payload, currLen);
88
+ });
89
+ }
90
+ else {
91
+ const nextLen = payload.issues.length;
92
+ if (nextLen === currLen)
93
+ continue;
94
+ if (!isAborted)
95
+ isAborted = util.aborted(payload, currLen);
96
+ }
97
+ }
98
+ if (asyncResult) {
99
+ return asyncResult.then(() => {
100
+ return payload;
101
+ });
102
+ }
103
+ return payload;
104
+ };
105
+ const handleCanaryResult = (canary, payload, ctx) => {
106
+ // abort if the canary is aborted
107
+ if (util.aborted(canary)) {
108
+ canary.aborted = true;
109
+ return canary;
110
+ }
111
+ // run checks first, then
112
+ const checkResult = runChecks(payload, checks, ctx);
113
+ if (checkResult instanceof Promise) {
114
+ if (ctx.async === false)
115
+ throw new core.$ZodAsyncError();
116
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
117
+ }
118
+ return inst._zod.parse(checkResult, ctx);
119
+ };
120
+ inst._zod.run = (payload, ctx) => {
121
+ if (ctx.skipChecks) {
122
+ return inst._zod.parse(payload, ctx);
123
+ }
124
+ if (ctx.direction === "backward") {
125
+ // run canary
126
+ // initial pass (no checks)
127
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
128
+ if (canary instanceof Promise) {
129
+ return canary.then((canary) => {
130
+ return handleCanaryResult(canary, payload, ctx);
131
+ });
132
+ }
133
+ return handleCanaryResult(canary, payload, ctx);
134
+ }
135
+ // forward
136
+ const result = inst._zod.parse(payload, ctx);
137
+ if (result instanceof Promise) {
138
+ if (ctx.async === false)
139
+ throw new core.$ZodAsyncError();
140
+ return result.then((result) => runChecks(result, checks, ctx));
141
+ }
142
+ return runChecks(result, checks, ctx);
143
+ };
144
+ }
145
+ inst["~standard"] = {
146
+ validate: (value) => {
147
+ try {
148
+ const r = (0, parse_js_1.safeParse)(inst, value);
149
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
150
+ }
151
+ catch (_) {
152
+ return (0, parse_js_1.safeParseAsync)(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
153
+ }
154
+ },
155
+ vendor: "zod",
156
+ version: 1,
157
+ };
158
+ });
159
+ var util_js_1 = require("./util.cjs");
160
+ Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
161
+ exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
162
+ exports.$ZodType.init(inst, def);
163
+ inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
164
+ inst._zod.parse = (payload, _) => {
165
+ if (def.coerce)
166
+ try {
167
+ payload.value = String(payload.value);
168
+ }
169
+ catch (_) { }
170
+ if (typeof payload.value === "string")
171
+ return payload;
172
+ payload.issues.push({
173
+ expected: "string",
174
+ code: "invalid_type",
175
+ input: payload.value,
176
+ inst,
177
+ });
178
+ return payload;
179
+ };
180
+ });
181
+ exports.$ZodStringFormat = core.$constructor("$ZodStringFormat", (inst, def) => {
182
+ // check initialization must come first
183
+ checks.$ZodCheckStringFormat.init(inst, def);
184
+ exports.$ZodString.init(inst, def);
185
+ });
186
+ exports.$ZodGUID = core.$constructor("$ZodGUID", (inst, def) => {
187
+ def.pattern ?? (def.pattern = regexes.guid);
188
+ exports.$ZodStringFormat.init(inst, def);
189
+ });
190
+ exports.$ZodUUID = core.$constructor("$ZodUUID", (inst, def) => {
191
+ if (def.version) {
192
+ const versionMap = {
193
+ v1: 1,
194
+ v2: 2,
195
+ v3: 3,
196
+ v4: 4,
197
+ v5: 5,
198
+ v6: 6,
199
+ v7: 7,
200
+ v8: 8,
201
+ };
202
+ const v = versionMap[def.version];
203
+ if (v === undefined)
204
+ throw new Error(`Invalid UUID version: "${def.version}"`);
205
+ def.pattern ?? (def.pattern = regexes.uuid(v));
206
+ }
207
+ else
208
+ def.pattern ?? (def.pattern = regexes.uuid());
209
+ exports.$ZodStringFormat.init(inst, def);
210
+ });
211
+ exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
212
+ def.pattern ?? (def.pattern = regexes.email);
213
+ exports.$ZodStringFormat.init(inst, def);
214
+ });
215
+ exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
216
+ exports.$ZodStringFormat.init(inst, def);
217
+ inst._zod.check = (payload) => {
218
+ try {
219
+ // Trim whitespace from input
220
+ const trimmed = payload.value.trim();
221
+ // @ts-ignore
222
+ const url = new URL(trimmed);
223
+ if (def.hostname) {
224
+ def.hostname.lastIndex = 0;
225
+ if (!def.hostname.test(url.hostname)) {
226
+ payload.issues.push({
227
+ code: "invalid_format",
228
+ format: "url",
229
+ note: "Invalid hostname",
230
+ pattern: def.hostname.source,
231
+ input: payload.value,
232
+ inst,
233
+ continue: !def.abort,
234
+ });
235
+ }
236
+ }
237
+ if (def.protocol) {
238
+ def.protocol.lastIndex = 0;
239
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
240
+ payload.issues.push({
241
+ code: "invalid_format",
242
+ format: "url",
243
+ note: "Invalid protocol",
244
+ pattern: def.protocol.source,
245
+ input: payload.value,
246
+ inst,
247
+ continue: !def.abort,
248
+ });
249
+ }
250
+ }
251
+ // Set the output value based on normalize flag
252
+ if (def.normalize) {
253
+ // Use normalized URL
254
+ payload.value = url.href;
255
+ }
256
+ else {
257
+ // Preserve the original input (trimmed)
258
+ payload.value = trimmed;
259
+ }
260
+ return;
261
+ }
262
+ catch (_) {
263
+ payload.issues.push({
264
+ code: "invalid_format",
265
+ format: "url",
266
+ input: payload.value,
267
+ inst,
268
+ continue: !def.abort,
269
+ });
270
+ }
271
+ };
272
+ });
273
+ exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
274
+ def.pattern ?? (def.pattern = regexes.emoji());
275
+ exports.$ZodStringFormat.init(inst, def);
276
+ });
277
+ exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
278
+ def.pattern ?? (def.pattern = regexes.nanoid);
279
+ exports.$ZodStringFormat.init(inst, def);
280
+ });
281
+ exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
282
+ def.pattern ?? (def.pattern = regexes.cuid);
283
+ exports.$ZodStringFormat.init(inst, def);
284
+ });
285
+ exports.$ZodCUID2 = core.$constructor("$ZodCUID2", (inst, def) => {
286
+ def.pattern ?? (def.pattern = regexes.cuid2);
287
+ exports.$ZodStringFormat.init(inst, def);
288
+ });
289
+ exports.$ZodULID = core.$constructor("$ZodULID", (inst, def) => {
290
+ def.pattern ?? (def.pattern = regexes.ulid);
291
+ exports.$ZodStringFormat.init(inst, def);
292
+ });
293
+ exports.$ZodXID = core.$constructor("$ZodXID", (inst, def) => {
294
+ def.pattern ?? (def.pattern = regexes.xid);
295
+ exports.$ZodStringFormat.init(inst, def);
296
+ });
297
+ exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
298
+ def.pattern ?? (def.pattern = regexes.ksuid);
299
+ exports.$ZodStringFormat.init(inst, def);
300
+ });
301
+ exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
302
+ def.pattern ?? (def.pattern = regexes.datetime(def));
303
+ exports.$ZodStringFormat.init(inst, def);
304
+ });
305
+ exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
306
+ def.pattern ?? (def.pattern = regexes.date);
307
+ exports.$ZodStringFormat.init(inst, def);
308
+ });
309
+ exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => {
310
+ def.pattern ?? (def.pattern = regexes.time(def));
311
+ exports.$ZodStringFormat.init(inst, def);
312
+ });
313
+ exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
314
+ def.pattern ?? (def.pattern = regexes.duration);
315
+ exports.$ZodStringFormat.init(inst, def);
316
+ });
317
+ exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
318
+ def.pattern ?? (def.pattern = regexes.ipv4);
319
+ exports.$ZodStringFormat.init(inst, def);
320
+ inst._zod.bag.format = `ipv4`;
321
+ });
322
+ exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
323
+ def.pattern ?? (def.pattern = regexes.ipv6);
324
+ exports.$ZodStringFormat.init(inst, def);
325
+ inst._zod.bag.format = `ipv6`;
326
+ inst._zod.check = (payload) => {
327
+ try {
328
+ // @ts-ignore
329
+ new URL(`http://[${payload.value}]`);
330
+ // return;
331
+ }
332
+ catch {
333
+ payload.issues.push({
334
+ code: "invalid_format",
335
+ format: "ipv6",
336
+ input: payload.value,
337
+ inst,
338
+ continue: !def.abort,
339
+ });
340
+ }
341
+ };
342
+ });
343
+ exports.$ZodMAC = core.$constructor("$ZodMAC", (inst, def) => {
344
+ def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
345
+ exports.$ZodStringFormat.init(inst, def);
346
+ inst._zod.bag.format = `mac`;
347
+ });
348
+ exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
349
+ def.pattern ?? (def.pattern = regexes.cidrv4);
350
+ exports.$ZodStringFormat.init(inst, def);
351
+ });
352
+ exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
353
+ def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
354
+ exports.$ZodStringFormat.init(inst, def);
355
+ inst._zod.check = (payload) => {
356
+ const parts = payload.value.split("/");
357
+ try {
358
+ if (parts.length !== 2)
359
+ throw new Error();
360
+ const [address, prefix] = parts;
361
+ if (!prefix)
362
+ throw new Error();
363
+ const prefixNum = Number(prefix);
364
+ if (`${prefixNum}` !== prefix)
365
+ throw new Error();
366
+ if (prefixNum < 0 || prefixNum > 128)
367
+ throw new Error();
368
+ // @ts-ignore
369
+ new URL(`http://[${address}]`);
370
+ }
371
+ catch {
372
+ payload.issues.push({
373
+ code: "invalid_format",
374
+ format: "cidrv6",
375
+ input: payload.value,
376
+ inst,
377
+ continue: !def.abort,
378
+ });
379
+ }
380
+ };
381
+ });
382
+ ////////////////////////////// ZodBase64 //////////////////////////////
383
+ function isValidBase64(data) {
384
+ if (data === "")
385
+ return true;
386
+ if (data.length % 4 !== 0)
387
+ return false;
388
+ try {
389
+ // @ts-ignore
390
+ atob(data);
391
+ return true;
392
+ }
393
+ catch {
394
+ return false;
395
+ }
396
+ }
397
+ exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
398
+ def.pattern ?? (def.pattern = regexes.base64);
399
+ exports.$ZodStringFormat.init(inst, def);
400
+ inst._zod.bag.contentEncoding = "base64";
401
+ inst._zod.check = (payload) => {
402
+ if (isValidBase64(payload.value))
403
+ return;
404
+ payload.issues.push({
405
+ code: "invalid_format",
406
+ format: "base64",
407
+ input: payload.value,
408
+ inst,
409
+ continue: !def.abort,
410
+ });
411
+ };
412
+ });
413
+ ////////////////////////////// ZodBase64 //////////////////////////////
414
+ function isValidBase64URL(data) {
415
+ if (!regexes.base64url.test(data))
416
+ return false;
417
+ const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
418
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
419
+ return isValidBase64(padded);
420
+ }
421
+ exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
422
+ def.pattern ?? (def.pattern = regexes.base64url);
423
+ exports.$ZodStringFormat.init(inst, def);
424
+ inst._zod.bag.contentEncoding = "base64url";
425
+ inst._zod.check = (payload) => {
426
+ if (isValidBase64URL(payload.value))
427
+ return;
428
+ payload.issues.push({
429
+ code: "invalid_format",
430
+ format: "base64url",
431
+ input: payload.value,
432
+ inst,
433
+ continue: !def.abort,
434
+ });
435
+ };
436
+ });
437
+ exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
438
+ def.pattern ?? (def.pattern = regexes.e164);
439
+ exports.$ZodStringFormat.init(inst, def);
440
+ });
441
+ ////////////////////////////// ZodJWT //////////////////////////////
442
+ function isValidJWT(token, algorithm = null) {
443
+ try {
444
+ const tokensParts = token.split(".");
445
+ if (tokensParts.length !== 3)
446
+ return false;
447
+ const [header] = tokensParts;
448
+ if (!header)
449
+ return false;
450
+ // @ts-ignore
451
+ const parsedHeader = JSON.parse(atob(header));
452
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
453
+ return false;
454
+ if (!parsedHeader.alg)
455
+ return false;
456
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
457
+ return false;
458
+ return true;
459
+ }
460
+ catch {
461
+ return false;
462
+ }
463
+ }
464
+ exports.$ZodJWT = core.$constructor("$ZodJWT", (inst, def) => {
465
+ exports.$ZodStringFormat.init(inst, def);
466
+ inst._zod.check = (payload) => {
467
+ if (isValidJWT(payload.value, def.alg))
468
+ return;
469
+ payload.issues.push({
470
+ code: "invalid_format",
471
+ format: "jwt",
472
+ input: payload.value,
473
+ inst,
474
+ continue: !def.abort,
475
+ });
476
+ };
477
+ });
478
+ exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (inst, def) => {
479
+ exports.$ZodStringFormat.init(inst, def);
480
+ inst._zod.check = (payload) => {
481
+ if (def.fn(payload.value))
482
+ return;
483
+ payload.issues.push({
484
+ code: "invalid_format",
485
+ format: def.format,
486
+ input: payload.value,
487
+ inst,
488
+ continue: !def.abort,
489
+ });
490
+ };
491
+ });
492
+ exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
493
+ exports.$ZodType.init(inst, def);
494
+ inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
495
+ inst._zod.parse = (payload, _ctx) => {
496
+ if (def.coerce)
497
+ try {
498
+ payload.value = Number(payload.value);
499
+ }
500
+ catch (_) { }
501
+ const input = payload.value;
502
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
503
+ return payload;
504
+ }
505
+ const received = typeof input === "number"
506
+ ? Number.isNaN(input)
507
+ ? "NaN"
508
+ : !Number.isFinite(input)
509
+ ? "Infinity"
510
+ : undefined
511
+ : undefined;
512
+ payload.issues.push({
513
+ expected: "number",
514
+ code: "invalid_type",
515
+ input,
516
+ inst,
517
+ ...(received ? { received } : {}),
518
+ });
519
+ return payload;
520
+ };
521
+ });
522
+ exports.$ZodNumberFormat = core.$constructor("$ZodNumberFormat", (inst, def) => {
523
+ checks.$ZodCheckNumberFormat.init(inst, def);
524
+ exports.$ZodNumber.init(inst, def); // no format checks
525
+ });
526
+ exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => {
527
+ exports.$ZodType.init(inst, def);
528
+ inst._zod.pattern = regexes.boolean;
529
+ inst._zod.parse = (payload, _ctx) => {
530
+ if (def.coerce)
531
+ try {
532
+ payload.value = Boolean(payload.value);
533
+ }
534
+ catch (_) { }
535
+ const input = payload.value;
536
+ if (typeof input === "boolean")
537
+ return payload;
538
+ payload.issues.push({
539
+ expected: "boolean",
540
+ code: "invalid_type",
541
+ input,
542
+ inst,
543
+ });
544
+ return payload;
545
+ };
546
+ });
547
+ exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
548
+ exports.$ZodType.init(inst, def);
549
+ inst._zod.pattern = regexes.bigint;
550
+ inst._zod.parse = (payload, _ctx) => {
551
+ if (def.coerce)
552
+ try {
553
+ payload.value = BigInt(payload.value);
554
+ }
555
+ catch (_) { }
556
+ if (typeof payload.value === "bigint")
557
+ return payload;
558
+ payload.issues.push({
559
+ expected: "bigint",
560
+ code: "invalid_type",
561
+ input: payload.value,
562
+ inst,
563
+ });
564
+ return payload;
565
+ };
566
+ });
567
+ exports.$ZodBigIntFormat = core.$constructor("$ZodBigIntFormat", (inst, def) => {
568
+ checks.$ZodCheckBigIntFormat.init(inst, def);
569
+ exports.$ZodBigInt.init(inst, def); // no format checks
570
+ });
571
+ exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => {
572
+ exports.$ZodType.init(inst, def);
573
+ inst._zod.parse = (payload, _ctx) => {
574
+ const input = payload.value;
575
+ if (typeof input === "symbol")
576
+ return payload;
577
+ payload.issues.push({
578
+ expected: "symbol",
579
+ code: "invalid_type",
580
+ input,
581
+ inst,
582
+ });
583
+ return payload;
584
+ };
585
+ });
586
+ exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
587
+ exports.$ZodType.init(inst, def);
588
+ inst._zod.pattern = regexes.undefined;
589
+ inst._zod.values = new Set([undefined]);
590
+ inst._zod.optin = "optional";
591
+ inst._zod.optout = "optional";
592
+ inst._zod.parse = (payload, _ctx) => {
593
+ const input = payload.value;
594
+ if (typeof input === "undefined")
595
+ return payload;
596
+ payload.issues.push({
597
+ expected: "undefined",
598
+ code: "invalid_type",
599
+ input,
600
+ inst,
601
+ });
602
+ return payload;
603
+ };
604
+ });
605
+ exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => {
606
+ exports.$ZodType.init(inst, def);
607
+ inst._zod.pattern = regexes.null;
608
+ inst._zod.values = new Set([null]);
609
+ inst._zod.parse = (payload, _ctx) => {
610
+ const input = payload.value;
611
+ if (input === null)
612
+ return payload;
613
+ payload.issues.push({
614
+ expected: "null",
615
+ code: "invalid_type",
616
+ input,
617
+ inst,
618
+ });
619
+ return payload;
620
+ };
621
+ });
622
+ exports.$ZodAny = core.$constructor("$ZodAny", (inst, def) => {
623
+ exports.$ZodType.init(inst, def);
624
+ inst._zod.parse = (payload) => payload;
625
+ });
626
+ exports.$ZodUnknown = core.$constructor("$ZodUnknown", (inst, def) => {
627
+ exports.$ZodType.init(inst, def);
628
+ inst._zod.parse = (payload) => payload;
629
+ });
630
+ exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => {
631
+ exports.$ZodType.init(inst, def);
632
+ inst._zod.parse = (payload, _ctx) => {
633
+ payload.issues.push({
634
+ expected: "never",
635
+ code: "invalid_type",
636
+ input: payload.value,
637
+ inst,
638
+ });
639
+ return payload;
640
+ };
641
+ });
642
+ exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => {
643
+ exports.$ZodType.init(inst, def);
644
+ inst._zod.parse = (payload, _ctx) => {
645
+ const input = payload.value;
646
+ if (typeof input === "undefined")
647
+ return payload;
648
+ payload.issues.push({
649
+ expected: "void",
650
+ code: "invalid_type",
651
+ input,
652
+ inst,
653
+ });
654
+ return payload;
655
+ };
656
+ });
657
+ exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
658
+ exports.$ZodType.init(inst, def);
659
+ inst._zod.parse = (payload, _ctx) => {
660
+ if (def.coerce) {
661
+ try {
662
+ payload.value = new Date(payload.value);
663
+ }
664
+ catch (_err) { }
665
+ }
666
+ const input = payload.value;
667
+ const isDate = input instanceof Date;
668
+ const isValidDate = isDate && !Number.isNaN(input.getTime());
669
+ if (isValidDate)
670
+ return payload;
671
+ payload.issues.push({
672
+ expected: "date",
673
+ code: "invalid_type",
674
+ input,
675
+ ...(isDate ? { received: "Invalid Date" } : {}),
676
+ inst,
677
+ });
678
+ return payload;
679
+ };
680
+ });
681
+ function handleArrayResult(result, final, index) {
682
+ if (result.issues.length) {
683
+ final.issues.push(...util.prefixIssues(index, result.issues));
684
+ }
685
+ final.value[index] = result.value;
686
+ }
687
+ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
688
+ exports.$ZodType.init(inst, def);
689
+ inst._zod.parse = (payload, ctx) => {
690
+ const input = payload.value;
691
+ if (!Array.isArray(input)) {
692
+ payload.issues.push({
693
+ expected: "array",
694
+ code: "invalid_type",
695
+ input,
696
+ inst,
697
+ });
698
+ return payload;
699
+ }
700
+ payload.value = Array(input.length);
701
+ const proms = [];
702
+ for (let i = 0; i < input.length; i++) {
703
+ const item = input[i];
704
+ const result = def.element._zod.run({
705
+ value: item,
706
+ issues: [],
707
+ }, ctx);
708
+ if (result instanceof Promise) {
709
+ proms.push(result.then((result) => handleArrayResult(result, payload, i)));
710
+ }
711
+ else {
712
+ handleArrayResult(result, payload, i);
713
+ }
714
+ }
715
+ if (proms.length) {
716
+ return Promise.all(proms).then(() => payload);
717
+ }
718
+ return payload; //handleArrayResultsAsync(parseResults, final);
719
+ };
720
+ });
721
+ function handlePropertyResult(result, final, key, input) {
722
+ if (result.issues.length) {
723
+ final.issues.push(...util.prefixIssues(key, result.issues));
724
+ }
725
+ if (result.value === undefined) {
726
+ if (key in input) {
727
+ final.value[key] = undefined;
728
+ }
729
+ }
730
+ else {
731
+ final.value[key] = result.value;
732
+ }
733
+ }
734
+ function normalizeDef(def) {
735
+ const keys = Object.keys(def.shape);
736
+ for (const k of keys) {
737
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
738
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
739
+ }
740
+ }
741
+ const okeys = util.optionalKeys(def.shape);
742
+ return {
743
+ ...def,
744
+ keys,
745
+ keySet: new Set(keys),
746
+ numKeys: keys.length,
747
+ optionalKeys: new Set(okeys),
748
+ };
749
+ }
750
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
751
+ const unrecognized = [];
752
+ // iterate over input keys
753
+ const keySet = def.keySet;
754
+ const _catchall = def.catchall._zod;
755
+ const t = _catchall.def.type;
756
+ for (const key in input) {
757
+ if (keySet.has(key))
758
+ continue;
759
+ if (t === "never") {
760
+ unrecognized.push(key);
761
+ continue;
762
+ }
763
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
764
+ if (r instanceof Promise) {
765
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
766
+ }
767
+ else {
768
+ handlePropertyResult(r, payload, key, input);
769
+ }
770
+ }
771
+ if (unrecognized.length) {
772
+ payload.issues.push({
773
+ code: "unrecognized_keys",
774
+ keys: unrecognized,
775
+ input,
776
+ inst,
777
+ });
778
+ }
779
+ if (!proms.length)
780
+ return payload;
781
+ return Promise.all(proms).then(() => {
782
+ return payload;
783
+ });
784
+ }
785
+ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
786
+ // requires cast because technically $ZodObject doesn't extend
787
+ exports.$ZodType.init(inst, def);
788
+ // const sh = def.shape;
789
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
790
+ if (!desc?.get) {
791
+ const sh = def.shape;
792
+ Object.defineProperty(def, "shape", {
793
+ get: () => {
794
+ const newSh = { ...sh };
795
+ Object.defineProperty(def, "shape", {
796
+ value: newSh,
797
+ });
798
+ return newSh;
799
+ },
800
+ });
801
+ }
802
+ const _normalized = util.cached(() => normalizeDef(def));
803
+ util.defineLazy(inst._zod, "propValues", () => {
804
+ const shape = def.shape;
805
+ const propValues = {};
806
+ for (const key in shape) {
807
+ const field = shape[key]._zod;
808
+ if (field.values) {
809
+ propValues[key] ?? (propValues[key] = new Set());
810
+ for (const v of field.values)
811
+ propValues[key].add(v);
812
+ }
813
+ }
814
+ return propValues;
815
+ });
816
+ const isObject = util.isObject;
817
+ const catchall = def.catchall;
818
+ let value;
819
+ inst._zod.parse = (payload, ctx) => {
820
+ value ?? (value = _normalized.value);
821
+ const input = payload.value;
822
+ if (!isObject(input)) {
823
+ payload.issues.push({
824
+ expected: "object",
825
+ code: "invalid_type",
826
+ input,
827
+ inst,
828
+ });
829
+ return payload;
830
+ }
831
+ payload.value = {};
832
+ const proms = [];
833
+ const shape = value.shape;
834
+ for (const key of value.keys) {
835
+ const el = shape[key];
836
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
837
+ if (r instanceof Promise) {
838
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
839
+ }
840
+ else {
841
+ handlePropertyResult(r, payload, key, input);
842
+ }
843
+ }
844
+ if (!catchall) {
845
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
846
+ }
847
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
848
+ };
849
+ });
850
+ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
851
+ // requires cast because technically $ZodObject doesn't extend
852
+ exports.$ZodObject.init(inst, def);
853
+ const superParse = inst._zod.parse;
854
+ const _normalized = util.cached(() => normalizeDef(def));
855
+ const generateFastpass = (shape) => {
856
+ const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
857
+ const normalized = _normalized.value;
858
+ const parseStr = (key) => {
859
+ const k = util.esc(key);
860
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
861
+ };
862
+ doc.write(`const input = payload.value;`);
863
+ const ids = Object.create(null);
864
+ let counter = 0;
865
+ for (const key of normalized.keys) {
866
+ ids[key] = `key_${counter++}`;
867
+ }
868
+ // A: preserve key order {
869
+ doc.write(`const newResult = {};`);
870
+ for (const key of normalized.keys) {
871
+ const id = ids[key];
872
+ const k = util.esc(key);
873
+ doc.write(`const ${id} = ${parseStr(key)};`);
874
+ doc.write(`
875
+ if (${id}.issues.length) {
876
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
877
+ ...iss,
878
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
879
+ })));
880
+ }
881
+
882
+
883
+ if (${id}.value === undefined) {
884
+ if (${k} in input) {
885
+ newResult[${k}] = undefined;
886
+ }
887
+ } else {
888
+ newResult[${k}] = ${id}.value;
889
+ }
890
+
891
+ `);
892
+ }
893
+ doc.write(`payload.value = newResult;`);
894
+ doc.write(`return payload;`);
895
+ const fn = doc.compile();
896
+ return (payload, ctx) => fn(shape, payload, ctx);
897
+ };
898
+ let fastpass;
899
+ const isObject = util.isObject;
900
+ const jit = !core.globalConfig.jitless;
901
+ const allowsEval = util.allowsEval;
902
+ const fastEnabled = jit && allowsEval.value; // && !def.catchall;
903
+ const catchall = def.catchall;
904
+ let value;
905
+ inst._zod.parse = (payload, ctx) => {
906
+ value ?? (value = _normalized.value);
907
+ const input = payload.value;
908
+ if (!isObject(input)) {
909
+ payload.issues.push({
910
+ expected: "object",
911
+ code: "invalid_type",
912
+ input,
913
+ inst,
914
+ });
915
+ return payload;
916
+ }
917
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
918
+ // always synchronous
919
+ if (!fastpass)
920
+ fastpass = generateFastpass(def.shape);
921
+ payload = fastpass(payload, ctx);
922
+ if (!catchall)
923
+ return payload;
924
+ return handleCatchall([], input, payload, ctx, value, inst);
925
+ }
926
+ return superParse(payload, ctx);
927
+ };
928
+ });
929
+ function handleUnionResults(results, final, inst, ctx) {
930
+ for (const result of results) {
931
+ if (result.issues.length === 0) {
932
+ final.value = result.value;
933
+ return final;
934
+ }
935
+ }
936
+ const nonaborted = results.filter((r) => !util.aborted(r));
937
+ if (nonaborted.length === 1) {
938
+ final.value = nonaborted[0].value;
939
+ return nonaborted[0];
940
+ }
941
+ final.issues.push({
942
+ code: "invalid_union",
943
+ input: final.value,
944
+ inst,
945
+ errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
946
+ });
947
+ return final;
948
+ }
949
+ exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
950
+ exports.$ZodType.init(inst, def);
951
+ util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
952
+ util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
953
+ util.defineLazy(inst._zod, "values", () => {
954
+ if (def.options.every((o) => o._zod.values)) {
955
+ return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
956
+ }
957
+ return undefined;
958
+ });
959
+ util.defineLazy(inst._zod, "pattern", () => {
960
+ if (def.options.every((o) => o._zod.pattern)) {
961
+ const patterns = def.options.map((o) => o._zod.pattern);
962
+ return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
963
+ }
964
+ return undefined;
965
+ });
966
+ const single = def.options.length === 1;
967
+ const first = def.options[0]._zod.run;
968
+ inst._zod.parse = (payload, ctx) => {
969
+ if (single) {
970
+ return first(payload, ctx);
971
+ }
972
+ let async = false;
973
+ const results = [];
974
+ for (const option of def.options) {
975
+ const result = option._zod.run({
976
+ value: payload.value,
977
+ issues: [],
978
+ }, ctx);
979
+ if (result instanceof Promise) {
980
+ results.push(result);
981
+ async = true;
982
+ }
983
+ else {
984
+ if (result.issues.length === 0)
985
+ return result;
986
+ results.push(result);
987
+ }
988
+ }
989
+ if (!async)
990
+ return handleUnionResults(results, payload, inst, ctx);
991
+ return Promise.all(results).then((results) => {
992
+ return handleUnionResults(results, payload, inst, ctx);
993
+ });
994
+ };
995
+ });
996
+ function handleExclusiveUnionResults(results, final, inst, ctx) {
997
+ const successes = results.filter((r) => r.issues.length === 0);
998
+ if (successes.length === 1) {
999
+ final.value = successes[0].value;
1000
+ return final;
1001
+ }
1002
+ if (successes.length === 0) {
1003
+ // No matches - same as regular union
1004
+ final.issues.push({
1005
+ code: "invalid_union",
1006
+ input: final.value,
1007
+ inst,
1008
+ errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1009
+ });
1010
+ }
1011
+ else {
1012
+ // Multiple matches - exclusive union failure
1013
+ final.issues.push({
1014
+ code: "invalid_union",
1015
+ input: final.value,
1016
+ inst,
1017
+ errors: [],
1018
+ inclusive: false,
1019
+ });
1020
+ }
1021
+ return final;
1022
+ }
1023
+ exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
1024
+ exports.$ZodUnion.init(inst, def);
1025
+ def.inclusive = false;
1026
+ const single = def.options.length === 1;
1027
+ const first = def.options[0]._zod.run;
1028
+ inst._zod.parse = (payload, ctx) => {
1029
+ if (single) {
1030
+ return first(payload, ctx);
1031
+ }
1032
+ let async = false;
1033
+ const results = [];
1034
+ for (const option of def.options) {
1035
+ const result = option._zod.run({
1036
+ value: payload.value,
1037
+ issues: [],
1038
+ }, ctx);
1039
+ if (result instanceof Promise) {
1040
+ results.push(result);
1041
+ async = true;
1042
+ }
1043
+ else {
1044
+ results.push(result);
1045
+ }
1046
+ }
1047
+ if (!async)
1048
+ return handleExclusiveUnionResults(results, payload, inst, ctx);
1049
+ return Promise.all(results).then((results) => {
1050
+ return handleExclusiveUnionResults(results, payload, inst, ctx);
1051
+ });
1052
+ };
1053
+ });
1054
+ exports.$ZodDiscriminatedUnion =
1055
+ /*@__PURE__*/
1056
+ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1057
+ def.inclusive = false;
1058
+ exports.$ZodUnion.init(inst, def);
1059
+ const _super = inst._zod.parse;
1060
+ util.defineLazy(inst._zod, "propValues", () => {
1061
+ const propValues = {};
1062
+ for (const option of def.options) {
1063
+ const pv = option._zod.propValues;
1064
+ if (!pv || Object.keys(pv).length === 0)
1065
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1066
+ for (const [k, v] of Object.entries(pv)) {
1067
+ if (!propValues[k])
1068
+ propValues[k] = new Set();
1069
+ for (const val of v) {
1070
+ propValues[k].add(val);
1071
+ }
1072
+ }
1073
+ }
1074
+ return propValues;
1075
+ });
1076
+ const disc = util.cached(() => {
1077
+ const opts = def.options;
1078
+ const map = new Map();
1079
+ for (const o of opts) {
1080
+ const values = o._zod.propValues?.[def.discriminator];
1081
+ if (!values || values.size === 0)
1082
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1083
+ for (const v of values) {
1084
+ if (map.has(v)) {
1085
+ throw new Error(`Duplicate discriminator value "${String(v)}"`);
1086
+ }
1087
+ map.set(v, o);
1088
+ }
1089
+ }
1090
+ return map;
1091
+ });
1092
+ inst._zod.parse = (payload, ctx) => {
1093
+ const input = payload.value;
1094
+ if (!util.isObject(input)) {
1095
+ payload.issues.push({
1096
+ code: "invalid_type",
1097
+ expected: "object",
1098
+ input,
1099
+ inst,
1100
+ });
1101
+ return payload;
1102
+ }
1103
+ const opt = disc.value.get(input?.[def.discriminator]);
1104
+ if (opt) {
1105
+ return opt._zod.run(payload, ctx);
1106
+ }
1107
+ if (def.unionFallback) {
1108
+ return _super(payload, ctx);
1109
+ }
1110
+ // no matching discriminator
1111
+ payload.issues.push({
1112
+ code: "invalid_union",
1113
+ errors: [],
1114
+ note: "No matching discriminator",
1115
+ discriminator: def.discriminator,
1116
+ input,
1117
+ path: [def.discriminator],
1118
+ inst,
1119
+ });
1120
+ return payload;
1121
+ };
1122
+ });
1123
+ exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => {
1124
+ exports.$ZodType.init(inst, def);
1125
+ inst._zod.parse = (payload, ctx) => {
1126
+ const input = payload.value;
1127
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1128
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1129
+ const async = left instanceof Promise || right instanceof Promise;
1130
+ if (async) {
1131
+ return Promise.all([left, right]).then(([left, right]) => {
1132
+ return handleIntersectionResults(payload, left, right);
1133
+ });
1134
+ }
1135
+ return handleIntersectionResults(payload, left, right);
1136
+ };
1137
+ });
1138
+ function mergeValues(a, b) {
1139
+ // const aType = parse.t(a);
1140
+ // const bType = parse.t(b);
1141
+ if (a === b) {
1142
+ return { valid: true, data: a };
1143
+ }
1144
+ if (a instanceof Date && b instanceof Date && +a === +b) {
1145
+ return { valid: true, data: a };
1146
+ }
1147
+ if (util.isPlainObject(a) && util.isPlainObject(b)) {
1148
+ const bKeys = Object.keys(b);
1149
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1150
+ const newObj = { ...a, ...b };
1151
+ for (const key of sharedKeys) {
1152
+ const sharedValue = mergeValues(a[key], b[key]);
1153
+ if (!sharedValue.valid) {
1154
+ return {
1155
+ valid: false,
1156
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
1157
+ };
1158
+ }
1159
+ newObj[key] = sharedValue.data;
1160
+ }
1161
+ return { valid: true, data: newObj };
1162
+ }
1163
+ if (Array.isArray(a) && Array.isArray(b)) {
1164
+ if (a.length !== b.length) {
1165
+ return { valid: false, mergeErrorPath: [] };
1166
+ }
1167
+ const newArray = [];
1168
+ for (let index = 0; index < a.length; index++) {
1169
+ const itemA = a[index];
1170
+ const itemB = b[index];
1171
+ const sharedValue = mergeValues(itemA, itemB);
1172
+ if (!sharedValue.valid) {
1173
+ return {
1174
+ valid: false,
1175
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
1176
+ };
1177
+ }
1178
+ newArray.push(sharedValue.data);
1179
+ }
1180
+ return { valid: true, data: newArray };
1181
+ }
1182
+ return { valid: false, mergeErrorPath: [] };
1183
+ }
1184
+ function handleIntersectionResults(result, left, right) {
1185
+ if (left.issues.length) {
1186
+ result.issues.push(...left.issues);
1187
+ }
1188
+ if (right.issues.length) {
1189
+ result.issues.push(...right.issues);
1190
+ }
1191
+ if (util.aborted(result))
1192
+ return result;
1193
+ const merged = mergeValues(left.value, right.value);
1194
+ if (!merged.valid) {
1195
+ throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1196
+ }
1197
+ result.value = merged.data;
1198
+ return result;
1199
+ }
1200
+ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1201
+ exports.$ZodType.init(inst, def);
1202
+ const items = def.items;
1203
+ inst._zod.parse = (payload, ctx) => {
1204
+ const input = payload.value;
1205
+ if (!Array.isArray(input)) {
1206
+ payload.issues.push({
1207
+ input,
1208
+ inst,
1209
+ expected: "tuple",
1210
+ code: "invalid_type",
1211
+ });
1212
+ return payload;
1213
+ }
1214
+ payload.value = [];
1215
+ const proms = [];
1216
+ const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
1217
+ const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
1218
+ if (!def.rest) {
1219
+ const tooBig = input.length > items.length;
1220
+ const tooSmall = input.length < optStart - 1;
1221
+ if (tooBig || tooSmall) {
1222
+ payload.issues.push({
1223
+ ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
1224
+ input,
1225
+ inst,
1226
+ origin: "array",
1227
+ });
1228
+ return payload;
1229
+ }
1230
+ }
1231
+ let i = -1;
1232
+ for (const item of items) {
1233
+ i++;
1234
+ if (i >= input.length)
1235
+ if (i >= optStart)
1236
+ continue;
1237
+ const result = item._zod.run({
1238
+ value: input[i],
1239
+ issues: [],
1240
+ }, ctx);
1241
+ if (result instanceof Promise) {
1242
+ proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1243
+ }
1244
+ else {
1245
+ handleTupleResult(result, payload, i);
1246
+ }
1247
+ }
1248
+ if (def.rest) {
1249
+ const rest = input.slice(items.length);
1250
+ for (const el of rest) {
1251
+ i++;
1252
+ const result = def.rest._zod.run({
1253
+ value: el,
1254
+ issues: [],
1255
+ }, ctx);
1256
+ if (result instanceof Promise) {
1257
+ proms.push(result.then((result) => handleTupleResult(result, payload, i)));
1258
+ }
1259
+ else {
1260
+ handleTupleResult(result, payload, i);
1261
+ }
1262
+ }
1263
+ }
1264
+ if (proms.length)
1265
+ return Promise.all(proms).then(() => payload);
1266
+ return payload;
1267
+ };
1268
+ });
1269
+ function handleTupleResult(result, final, index) {
1270
+ if (result.issues.length) {
1271
+ final.issues.push(...util.prefixIssues(index, result.issues));
1272
+ }
1273
+ final.value[index] = result.value;
1274
+ }
1275
+ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1276
+ exports.$ZodType.init(inst, def);
1277
+ inst._zod.parse = (payload, ctx) => {
1278
+ const input = payload.value;
1279
+ if (!util.isPlainObject(input)) {
1280
+ payload.issues.push({
1281
+ expected: "record",
1282
+ code: "invalid_type",
1283
+ input,
1284
+ inst,
1285
+ });
1286
+ return payload;
1287
+ }
1288
+ const proms = [];
1289
+ const values = def.keyType._zod.values;
1290
+ if (values) {
1291
+ payload.value = {};
1292
+ const recordKeys = new Set();
1293
+ for (const key of values) {
1294
+ if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1295
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
1296
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1297
+ if (result instanceof Promise) {
1298
+ proms.push(result.then((result) => {
1299
+ if (result.issues.length) {
1300
+ payload.issues.push(...util.prefixIssues(key, result.issues));
1301
+ }
1302
+ payload.value[key] = result.value;
1303
+ }));
1304
+ }
1305
+ else {
1306
+ if (result.issues.length) {
1307
+ payload.issues.push(...util.prefixIssues(key, result.issues));
1308
+ }
1309
+ payload.value[key] = result.value;
1310
+ }
1311
+ }
1312
+ }
1313
+ let unrecognized;
1314
+ for (const key in input) {
1315
+ if (!recordKeys.has(key)) {
1316
+ unrecognized = unrecognized ?? [];
1317
+ unrecognized.push(key);
1318
+ }
1319
+ }
1320
+ if (unrecognized && unrecognized.length > 0) {
1321
+ payload.issues.push({
1322
+ code: "unrecognized_keys",
1323
+ input,
1324
+ inst,
1325
+ keys: unrecognized,
1326
+ });
1327
+ }
1328
+ }
1329
+ else {
1330
+ payload.value = {};
1331
+ for (const key of Reflect.ownKeys(input)) {
1332
+ if (key === "__proto__")
1333
+ continue;
1334
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1335
+ if (keyResult instanceof Promise) {
1336
+ throw new Error("Async schemas not supported in object keys currently");
1337
+ }
1338
+ if (keyResult.issues.length) {
1339
+ if (def.mode === "loose") {
1340
+ // Pass through unchanged
1341
+ payload.value[key] = input[key];
1342
+ }
1343
+ else {
1344
+ // Default "strict" behavior: error on invalid key
1345
+ payload.issues.push({
1346
+ code: "invalid_key",
1347
+ origin: "record",
1348
+ issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1349
+ input: key,
1350
+ path: [key],
1351
+ inst,
1352
+ });
1353
+ }
1354
+ continue;
1355
+ }
1356
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1357
+ if (result instanceof Promise) {
1358
+ proms.push(result.then((result) => {
1359
+ if (result.issues.length) {
1360
+ payload.issues.push(...util.prefixIssues(key, result.issues));
1361
+ }
1362
+ payload.value[keyResult.value] = result.value;
1363
+ }));
1364
+ }
1365
+ else {
1366
+ if (result.issues.length) {
1367
+ payload.issues.push(...util.prefixIssues(key, result.issues));
1368
+ }
1369
+ payload.value[keyResult.value] = result.value;
1370
+ }
1371
+ }
1372
+ }
1373
+ if (proms.length) {
1374
+ return Promise.all(proms).then(() => payload);
1375
+ }
1376
+ return payload;
1377
+ };
1378
+ });
1379
+ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
1380
+ exports.$ZodType.init(inst, def);
1381
+ inst._zod.parse = (payload, ctx) => {
1382
+ const input = payload.value;
1383
+ if (!(input instanceof Map)) {
1384
+ payload.issues.push({
1385
+ expected: "map",
1386
+ code: "invalid_type",
1387
+ input,
1388
+ inst,
1389
+ });
1390
+ return payload;
1391
+ }
1392
+ const proms = [];
1393
+ payload.value = new Map();
1394
+ for (const [key, value] of input) {
1395
+ const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1396
+ const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1397
+ if (keyResult instanceof Promise || valueResult instanceof Promise) {
1398
+ proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
1399
+ handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1400
+ }));
1401
+ }
1402
+ else {
1403
+ handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1404
+ }
1405
+ }
1406
+ if (proms.length)
1407
+ return Promise.all(proms).then(() => payload);
1408
+ return payload;
1409
+ };
1410
+ });
1411
+ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1412
+ if (keyResult.issues.length) {
1413
+ if (util.propertyKeyTypes.has(typeof key)) {
1414
+ final.issues.push(...util.prefixIssues(key, keyResult.issues));
1415
+ }
1416
+ else {
1417
+ final.issues.push({
1418
+ code: "invalid_key",
1419
+ origin: "map",
1420
+ input,
1421
+ inst,
1422
+ issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1423
+ });
1424
+ }
1425
+ }
1426
+ if (valueResult.issues.length) {
1427
+ if (util.propertyKeyTypes.has(typeof key)) {
1428
+ final.issues.push(...util.prefixIssues(key, valueResult.issues));
1429
+ }
1430
+ else {
1431
+ final.issues.push({
1432
+ origin: "map",
1433
+ code: "invalid_element",
1434
+ input,
1435
+ inst,
1436
+ key: key,
1437
+ issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1438
+ });
1439
+ }
1440
+ }
1441
+ final.value.set(keyResult.value, valueResult.value);
1442
+ }
1443
+ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
1444
+ exports.$ZodType.init(inst, def);
1445
+ inst._zod.parse = (payload, ctx) => {
1446
+ const input = payload.value;
1447
+ if (!(input instanceof Set)) {
1448
+ payload.issues.push({
1449
+ input,
1450
+ inst,
1451
+ expected: "set",
1452
+ code: "invalid_type",
1453
+ });
1454
+ return payload;
1455
+ }
1456
+ const proms = [];
1457
+ payload.value = new Set();
1458
+ for (const item of input) {
1459
+ const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
1460
+ if (result instanceof Promise) {
1461
+ proms.push(result.then((result) => handleSetResult(result, payload)));
1462
+ }
1463
+ else
1464
+ handleSetResult(result, payload);
1465
+ }
1466
+ if (proms.length)
1467
+ return Promise.all(proms).then(() => payload);
1468
+ return payload;
1469
+ };
1470
+ });
1471
+ function handleSetResult(result, final) {
1472
+ if (result.issues.length) {
1473
+ final.issues.push(...result.issues);
1474
+ }
1475
+ final.value.add(result.value);
1476
+ }
1477
+ exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
1478
+ exports.$ZodType.init(inst, def);
1479
+ const values = util.getEnumValues(def.entries);
1480
+ const valuesSet = new Set(values);
1481
+ inst._zod.values = valuesSet;
1482
+ inst._zod.pattern = new RegExp(`^(${values
1483
+ .filter((k) => util.propertyKeyTypes.has(typeof k))
1484
+ .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
1485
+ .join("|")})$`);
1486
+ inst._zod.parse = (payload, _ctx) => {
1487
+ const input = payload.value;
1488
+ if (valuesSet.has(input)) {
1489
+ return payload;
1490
+ }
1491
+ payload.issues.push({
1492
+ code: "invalid_value",
1493
+ values,
1494
+ input,
1495
+ inst,
1496
+ });
1497
+ return payload;
1498
+ };
1499
+ });
1500
+ exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
1501
+ exports.$ZodType.init(inst, def);
1502
+ if (def.values.length === 0) {
1503
+ throw new Error("Cannot create literal schema with no valid values");
1504
+ }
1505
+ const values = new Set(def.values);
1506
+ inst._zod.values = values;
1507
+ inst._zod.pattern = new RegExp(`^(${def.values
1508
+ .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
1509
+ .join("|")})$`);
1510
+ inst._zod.parse = (payload, _ctx) => {
1511
+ const input = payload.value;
1512
+ if (values.has(input)) {
1513
+ return payload;
1514
+ }
1515
+ payload.issues.push({
1516
+ code: "invalid_value",
1517
+ values: def.values,
1518
+ input,
1519
+ inst,
1520
+ });
1521
+ return payload;
1522
+ };
1523
+ });
1524
+ exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
1525
+ exports.$ZodType.init(inst, def);
1526
+ inst._zod.parse = (payload, _ctx) => {
1527
+ const input = payload.value;
1528
+ // @ts-ignore
1529
+ if (input instanceof File)
1530
+ return payload;
1531
+ payload.issues.push({
1532
+ expected: "file",
1533
+ code: "invalid_type",
1534
+ input,
1535
+ inst,
1536
+ });
1537
+ return payload;
1538
+ };
1539
+ });
1540
+ exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
1541
+ exports.$ZodType.init(inst, def);
1542
+ inst._zod.parse = (payload, ctx) => {
1543
+ if (ctx.direction === "backward") {
1544
+ throw new core.$ZodEncodeError(inst.constructor.name);
1545
+ }
1546
+ const _out = def.transform(payload.value, payload);
1547
+ if (ctx.async) {
1548
+ const output = _out instanceof Promise ? _out : Promise.resolve(_out);
1549
+ return output.then((output) => {
1550
+ payload.value = output;
1551
+ return payload;
1552
+ });
1553
+ }
1554
+ if (_out instanceof Promise) {
1555
+ throw new core.$ZodAsyncError();
1556
+ }
1557
+ payload.value = _out;
1558
+ return payload;
1559
+ };
1560
+ });
1561
+ function handleOptionalResult(result, input) {
1562
+ if (result.issues.length && input === undefined) {
1563
+ return { issues: [], value: undefined };
1564
+ }
1565
+ return result;
1566
+ }
1567
+ exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
1568
+ exports.$ZodType.init(inst, def);
1569
+ inst._zod.optin = "optional";
1570
+ inst._zod.optout = "optional";
1571
+ util.defineLazy(inst._zod, "values", () => {
1572
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
1573
+ });
1574
+ util.defineLazy(inst._zod, "pattern", () => {
1575
+ const pattern = def.innerType._zod.pattern;
1576
+ return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
1577
+ });
1578
+ inst._zod.parse = (payload, ctx) => {
1579
+ if (def.innerType._zod.optin === "optional") {
1580
+ const result = def.innerType._zod.run(payload, ctx);
1581
+ if (result instanceof Promise)
1582
+ return result.then((r) => handleOptionalResult(r, payload.value));
1583
+ return handleOptionalResult(result, payload.value);
1584
+ }
1585
+ if (payload.value === undefined) {
1586
+ return payload;
1587
+ }
1588
+ return def.innerType._zod.run(payload, ctx);
1589
+ };
1590
+ });
1591
+ exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
1592
+ exports.$ZodType.init(inst, def);
1593
+ util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1594
+ util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1595
+ util.defineLazy(inst._zod, "pattern", () => {
1596
+ const pattern = def.innerType._zod.pattern;
1597
+ return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
1598
+ });
1599
+ util.defineLazy(inst._zod, "values", () => {
1600
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
1601
+ });
1602
+ inst._zod.parse = (payload, ctx) => {
1603
+ // Forward direction (decode): allow null to pass through
1604
+ if (payload.value === null)
1605
+ return payload;
1606
+ return def.innerType._zod.run(payload, ctx);
1607
+ };
1608
+ });
1609
+ exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
1610
+ exports.$ZodType.init(inst, def);
1611
+ // inst._zod.qin = "true";
1612
+ inst._zod.optin = "optional";
1613
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1614
+ inst._zod.parse = (payload, ctx) => {
1615
+ if (ctx.direction === "backward") {
1616
+ return def.innerType._zod.run(payload, ctx);
1617
+ }
1618
+ // Forward direction (decode): apply defaults for undefined input
1619
+ if (payload.value === undefined) {
1620
+ payload.value = def.defaultValue;
1621
+ /**
1622
+ * $ZodDefault returns the default value immediately in forward direction.
1623
+ * 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. */
1624
+ return payload;
1625
+ }
1626
+ // Forward direction: continue with default handling
1627
+ const result = def.innerType._zod.run(payload, ctx);
1628
+ if (result instanceof Promise) {
1629
+ return result.then((result) => handleDefaultResult(result, def));
1630
+ }
1631
+ return handleDefaultResult(result, def);
1632
+ };
1633
+ });
1634
+ function handleDefaultResult(payload, def) {
1635
+ if (payload.value === undefined) {
1636
+ payload.value = def.defaultValue;
1637
+ }
1638
+ return payload;
1639
+ }
1640
+ exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
1641
+ exports.$ZodType.init(inst, def);
1642
+ inst._zod.optin = "optional";
1643
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1644
+ inst._zod.parse = (payload, ctx) => {
1645
+ if (ctx.direction === "backward") {
1646
+ return def.innerType._zod.run(payload, ctx);
1647
+ }
1648
+ // Forward direction (decode): apply prefault for undefined input
1649
+ if (payload.value === undefined) {
1650
+ payload.value = def.defaultValue;
1651
+ }
1652
+ return def.innerType._zod.run(payload, ctx);
1653
+ };
1654
+ });
1655
+ exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
1656
+ exports.$ZodType.init(inst, def);
1657
+ util.defineLazy(inst._zod, "values", () => {
1658
+ const v = def.innerType._zod.values;
1659
+ return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
1660
+ });
1661
+ inst._zod.parse = (payload, ctx) => {
1662
+ const result = def.innerType._zod.run(payload, ctx);
1663
+ if (result instanceof Promise) {
1664
+ return result.then((result) => handleNonOptionalResult(result, inst));
1665
+ }
1666
+ return handleNonOptionalResult(result, inst);
1667
+ };
1668
+ });
1669
+ function handleNonOptionalResult(payload, inst) {
1670
+ if (!payload.issues.length && payload.value === undefined) {
1671
+ payload.issues.push({
1672
+ code: "invalid_type",
1673
+ expected: "nonoptional",
1674
+ input: payload.value,
1675
+ inst,
1676
+ });
1677
+ }
1678
+ return payload;
1679
+ }
1680
+ exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
1681
+ exports.$ZodType.init(inst, def);
1682
+ inst._zod.parse = (payload, ctx) => {
1683
+ if (ctx.direction === "backward") {
1684
+ throw new core.$ZodEncodeError("ZodSuccess");
1685
+ }
1686
+ const result = def.innerType._zod.run(payload, ctx);
1687
+ if (result instanceof Promise) {
1688
+ return result.then((result) => {
1689
+ payload.value = result.issues.length === 0;
1690
+ return payload;
1691
+ });
1692
+ }
1693
+ payload.value = result.issues.length === 0;
1694
+ return payload;
1695
+ };
1696
+ });
1697
+ exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
1698
+ exports.$ZodType.init(inst, def);
1699
+ util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1700
+ util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1701
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1702
+ inst._zod.parse = (payload, ctx) => {
1703
+ if (ctx.direction === "backward") {
1704
+ return def.innerType._zod.run(payload, ctx);
1705
+ }
1706
+ // Forward direction (decode): apply catch logic
1707
+ const result = def.innerType._zod.run(payload, ctx);
1708
+ if (result instanceof Promise) {
1709
+ return result.then((result) => {
1710
+ payload.value = result.value;
1711
+ if (result.issues.length) {
1712
+ payload.value = def.catchValue({
1713
+ ...payload,
1714
+ error: {
1715
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1716
+ },
1717
+ input: payload.value,
1718
+ });
1719
+ payload.issues = [];
1720
+ }
1721
+ return payload;
1722
+ });
1723
+ }
1724
+ payload.value = result.value;
1725
+ if (result.issues.length) {
1726
+ payload.value = def.catchValue({
1727
+ ...payload,
1728
+ error: {
1729
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1730
+ },
1731
+ input: payload.value,
1732
+ });
1733
+ payload.issues = [];
1734
+ }
1735
+ return payload;
1736
+ };
1737
+ });
1738
+ exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
1739
+ exports.$ZodType.init(inst, def);
1740
+ inst._zod.parse = (payload, _ctx) => {
1741
+ if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
1742
+ payload.issues.push({
1743
+ input: payload.value,
1744
+ inst,
1745
+ expected: "nan",
1746
+ code: "invalid_type",
1747
+ });
1748
+ return payload;
1749
+ }
1750
+ return payload;
1751
+ };
1752
+ });
1753
+ exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
1754
+ exports.$ZodType.init(inst, def);
1755
+ util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1756
+ util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1757
+ util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1758
+ util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1759
+ inst._zod.parse = (payload, ctx) => {
1760
+ if (ctx.direction === "backward") {
1761
+ const right = def.out._zod.run(payload, ctx);
1762
+ if (right instanceof Promise) {
1763
+ return right.then((right) => handlePipeResult(right, def.in, ctx));
1764
+ }
1765
+ return handlePipeResult(right, def.in, ctx);
1766
+ }
1767
+ const left = def.in._zod.run(payload, ctx);
1768
+ if (left instanceof Promise) {
1769
+ return left.then((left) => handlePipeResult(left, def.out, ctx));
1770
+ }
1771
+ return handlePipeResult(left, def.out, ctx);
1772
+ };
1773
+ });
1774
+ function handlePipeResult(left, next, ctx) {
1775
+ if (left.issues.length) {
1776
+ // prevent further checks
1777
+ left.aborted = true;
1778
+ return left;
1779
+ }
1780
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
1781
+ }
1782
+ exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
1783
+ exports.$ZodType.init(inst, def);
1784
+ util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1785
+ util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1786
+ util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1787
+ util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1788
+ inst._zod.parse = (payload, ctx) => {
1789
+ const direction = ctx.direction || "forward";
1790
+ if (direction === "forward") {
1791
+ const left = def.in._zod.run(payload, ctx);
1792
+ if (left instanceof Promise) {
1793
+ return left.then((left) => handleCodecAResult(left, def, ctx));
1794
+ }
1795
+ return handleCodecAResult(left, def, ctx);
1796
+ }
1797
+ else {
1798
+ const right = def.out._zod.run(payload, ctx);
1799
+ if (right instanceof Promise) {
1800
+ return right.then((right) => handleCodecAResult(right, def, ctx));
1801
+ }
1802
+ return handleCodecAResult(right, def, ctx);
1803
+ }
1804
+ };
1805
+ });
1806
+ function handleCodecAResult(result, def, ctx) {
1807
+ if (result.issues.length) {
1808
+ // prevent further checks
1809
+ result.aborted = true;
1810
+ return result;
1811
+ }
1812
+ const direction = ctx.direction || "forward";
1813
+ if (direction === "forward") {
1814
+ const transformed = def.transform(result.value, result);
1815
+ if (transformed instanceof Promise) {
1816
+ return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
1817
+ }
1818
+ return handleCodecTxResult(result, transformed, def.out, ctx);
1819
+ }
1820
+ else {
1821
+ const transformed = def.reverseTransform(result.value, result);
1822
+ if (transformed instanceof Promise) {
1823
+ return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
1824
+ }
1825
+ return handleCodecTxResult(result, transformed, def.in, ctx);
1826
+ }
1827
+ }
1828
+ function handleCodecTxResult(left, value, nextSchema, ctx) {
1829
+ // Check if transform added any issues
1830
+ if (left.issues.length) {
1831
+ left.aborted = true;
1832
+ return left;
1833
+ }
1834
+ return nextSchema._zod.run({ value, issues: left.issues }, ctx);
1835
+ }
1836
+ exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
1837
+ exports.$ZodType.init(inst, def);
1838
+ util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1839
+ util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1840
+ util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
1841
+ util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
1842
+ inst._zod.parse = (payload, ctx) => {
1843
+ if (ctx.direction === "backward") {
1844
+ return def.innerType._zod.run(payload, ctx);
1845
+ }
1846
+ const result = def.innerType._zod.run(payload, ctx);
1847
+ if (result instanceof Promise) {
1848
+ return result.then(handleReadonlyResult);
1849
+ }
1850
+ return handleReadonlyResult(result);
1851
+ };
1852
+ });
1853
+ function handleReadonlyResult(payload) {
1854
+ payload.value = Object.freeze(payload.value);
1855
+ return payload;
1856
+ }
1857
+ exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
1858
+ exports.$ZodType.init(inst, def);
1859
+ const regexParts = [];
1860
+ for (const part of def.parts) {
1861
+ if (typeof part === "object" && part !== null) {
1862
+ // is Zod schema
1863
+ if (!part._zod.pattern) {
1864
+ // if (!source)
1865
+ throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
1866
+ }
1867
+ const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
1868
+ if (!source)
1869
+ throw new Error(`Invalid template literal part: ${part._zod.traits}`);
1870
+ const start = source.startsWith("^") ? 1 : 0;
1871
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
1872
+ regexParts.push(source.slice(start, end));
1873
+ }
1874
+ else if (part === null || util.primitiveTypes.has(typeof part)) {
1875
+ regexParts.push(util.escapeRegex(`${part}`));
1876
+ }
1877
+ else {
1878
+ throw new Error(`Invalid template literal part: ${part}`);
1879
+ }
1880
+ }
1881
+ inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
1882
+ inst._zod.parse = (payload, _ctx) => {
1883
+ if (typeof payload.value !== "string") {
1884
+ payload.issues.push({
1885
+ input: payload.value,
1886
+ inst,
1887
+ expected: "template_literal",
1888
+ code: "invalid_type",
1889
+ });
1890
+ return payload;
1891
+ }
1892
+ inst._zod.pattern.lastIndex = 0;
1893
+ if (!inst._zod.pattern.test(payload.value)) {
1894
+ payload.issues.push({
1895
+ input: payload.value,
1896
+ inst,
1897
+ code: "invalid_format",
1898
+ format: def.format ?? "template_literal",
1899
+ pattern: inst._zod.pattern.source,
1900
+ });
1901
+ return payload;
1902
+ }
1903
+ return payload;
1904
+ };
1905
+ });
1906
+ exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
1907
+ exports.$ZodType.init(inst, def);
1908
+ inst._def = def;
1909
+ inst._zod.def = def;
1910
+ inst.implement = (func) => {
1911
+ if (typeof func !== "function") {
1912
+ throw new Error("implement() must be called with a function");
1913
+ }
1914
+ return function (...args) {
1915
+ const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
1916
+ const result = Reflect.apply(func, this, parsedArgs);
1917
+ if (inst._def.output) {
1918
+ return (0, parse_js_1.parse)(inst._def.output, result);
1919
+ }
1920
+ return result;
1921
+ };
1922
+ };
1923
+ inst.implementAsync = (func) => {
1924
+ if (typeof func !== "function") {
1925
+ throw new Error("implementAsync() must be called with a function");
1926
+ }
1927
+ return async function (...args) {
1928
+ const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
1929
+ const result = await Reflect.apply(func, this, parsedArgs);
1930
+ if (inst._def.output) {
1931
+ return await (0, parse_js_1.parseAsync)(inst._def.output, result);
1932
+ }
1933
+ return result;
1934
+ };
1935
+ };
1936
+ inst._zod.parse = (payload, _ctx) => {
1937
+ if (typeof payload.value !== "function") {
1938
+ payload.issues.push({
1939
+ code: "invalid_type",
1940
+ expected: "function",
1941
+ input: payload.value,
1942
+ inst,
1943
+ });
1944
+ return payload;
1945
+ }
1946
+ // Check if output is a promise type to determine if we should use async implementation
1947
+ const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
1948
+ if (hasPromiseOutput) {
1949
+ payload.value = inst.implementAsync(payload.value);
1950
+ }
1951
+ else {
1952
+ payload.value = inst.implement(payload.value);
1953
+ }
1954
+ return payload;
1955
+ };
1956
+ inst.input = (...args) => {
1957
+ const F = inst.constructor;
1958
+ if (Array.isArray(args[0])) {
1959
+ return new F({
1960
+ type: "function",
1961
+ input: new exports.$ZodTuple({
1962
+ type: "tuple",
1963
+ items: args[0],
1964
+ rest: args[1],
1965
+ }),
1966
+ output: inst._def.output,
1967
+ });
1968
+ }
1969
+ return new F({
1970
+ type: "function",
1971
+ input: args[0],
1972
+ output: inst._def.output,
1973
+ });
1974
+ };
1975
+ inst.output = (output) => {
1976
+ const F = inst.constructor;
1977
+ return new F({
1978
+ type: "function",
1979
+ input: inst._def.input,
1980
+ output,
1981
+ });
1982
+ };
1983
+ return inst;
1984
+ });
1985
+ exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
1986
+ exports.$ZodType.init(inst, def);
1987
+ inst._zod.parse = (payload, ctx) => {
1988
+ return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
1989
+ };
1990
+ });
1991
+ exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
1992
+ exports.$ZodType.init(inst, def);
1993
+ // let _innerType!: any;
1994
+ // util.defineLazy(def, "getter", () => {
1995
+ // if (!_innerType) {
1996
+ // _innerType = def.getter();
1997
+ // }
1998
+ // return () => _innerType;
1999
+ // });
2000
+ util.defineLazy(inst._zod, "innerType", () => def.getter());
2001
+ util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2002
+ util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2003
+ util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
2004
+ util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
2005
+ inst._zod.parse = (payload, ctx) => {
2006
+ const inner = inst._zod.innerType;
2007
+ return inner._zod.run(payload, ctx);
2008
+ };
2009
+ });
2010
+ exports.$ZodCustom = core.$constructor("$ZodCustom", (inst, def) => {
2011
+ checks.$ZodCheck.init(inst, def);
2012
+ exports.$ZodType.init(inst, def);
2013
+ inst._zod.parse = (payload, _) => {
2014
+ return payload;
2015
+ };
2016
+ inst._zod.check = (payload) => {
2017
+ const input = payload.value;
2018
+ const r = def.fn(input);
2019
+ if (r instanceof Promise) {
2020
+ return r.then((r) => handleRefineResult(r, payload, input, inst));
2021
+ }
2022
+ handleRefineResult(r, payload, input, inst);
2023
+ return;
2024
+ };
2025
+ });
2026
+ function handleRefineResult(result, payload, input, inst) {
2027
+ if (!result) {
2028
+ const _iss = {
2029
+ code: "custom",
2030
+ input,
2031
+ inst, // incorporates params.error into issue reporting
2032
+ path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
2033
+ continue: !inst._zod.def.abort,
2034
+ // params: inst._zod.def.params,
2035
+ };
2036
+ if (inst._zod.def.params)
2037
+ _iss.params = inst._zod.def.params;
2038
+ payload.issues.push(util.issue(_iss));
2039
+ }
2040
+ }