claude-scope 0.1.4 → 0.1.6

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 (695) hide show
  1. package/node_modules/zod/LICENSE +21 -0
  2. package/node_modules/zod/README.md +208 -0
  3. package/node_modules/zod/index.cjs +33 -0
  4. package/node_modules/zod/index.d.cts +4 -0
  5. package/node_modules/zod/index.d.ts +4 -0
  6. package/node_modules/zod/index.js +4 -0
  7. package/node_modules/zod/locales/index.cjs +17 -0
  8. package/node_modules/zod/locales/index.d.cts +1 -0
  9. package/node_modules/zod/locales/index.d.ts +1 -0
  10. package/node_modules/zod/locales/index.js +1 -0
  11. package/node_modules/zod/locales/package.json +6 -0
  12. package/node_modules/zod/mini/index.cjs +17 -0
  13. package/node_modules/zod/mini/index.d.cts +1 -0
  14. package/node_modules/zod/mini/index.d.ts +1 -0
  15. package/node_modules/zod/mini/index.js +1 -0
  16. package/node_modules/zod/mini/package.json +6 -0
  17. package/node_modules/zod/package.json +135 -0
  18. package/node_modules/zod/src/index.ts +4 -0
  19. package/node_modules/zod/src/locales/index.ts +1 -0
  20. package/node_modules/zod/src/mini/index.ts +1 -0
  21. package/node_modules/zod/src/v3/ZodError.ts +330 -0
  22. package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  23. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  24. package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  25. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  26. package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  27. package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  28. package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  29. package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  30. package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  31. package/node_modules/zod/src/v3/errors.ts +13 -0
  32. package/node_modules/zod/src/v3/external.ts +6 -0
  33. package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  34. package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  35. package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  36. package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  37. package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  38. package/node_modules/zod/src/v3/helpers/util.ts +224 -0
  39. package/node_modules/zod/src/v3/index.ts +4 -0
  40. package/node_modules/zod/src/v3/locales/en.ts +124 -0
  41. package/node_modules/zod/src/v3/standard-schema.ts +113 -0
  42. package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
  43. package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  44. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  45. package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
  46. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  47. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  48. package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
  49. package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  50. package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
  51. package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
  52. package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  53. package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
  54. package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
  55. package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
  56. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  57. package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
  58. package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
  59. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  60. package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
  61. package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
  62. package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  63. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  64. package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
  65. package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
  66. package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  67. package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  68. package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  69. package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  70. package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
  71. package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
  72. package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
  73. package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  74. package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
  75. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  76. package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  77. package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
  78. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  79. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  80. package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
  81. package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
  82. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
  83. package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
  84. package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
  85. package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
  86. package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
  87. package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
  88. package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
  89. package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
  90. package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
  91. package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
  92. package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
  93. package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
  94. package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
  95. package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
  96. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
  97. package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
  98. package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
  99. package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
  100. package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
  101. package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
  102. package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
  103. package/node_modules/zod/src/v3/types.ts +5138 -0
  104. package/node_modules/zod/src/v4/classic/checks.ts +32 -0
  105. package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
  106. package/node_modules/zod/src/v4/classic/compat.ts +70 -0
  107. package/node_modules/zod/src/v4/classic/errors.ts +82 -0
  108. package/node_modules/zod/src/v4/classic/external.ts +51 -0
  109. package/node_modules/zod/src/v4/classic/from-json-schema.ts +643 -0
  110. package/node_modules/zod/src/v4/classic/index.ts +5 -0
  111. package/node_modules/zod/src/v4/classic/iso.ts +90 -0
  112. package/node_modules/zod/src/v4/classic/parse.ts +82 -0
  113. package/node_modules/zod/src/v4/classic/schemas.ts +2409 -0
  114. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
  115. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
  116. package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
  117. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +210 -0
  118. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
  119. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
  120. package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
  121. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
  122. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
  123. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +276 -0
  124. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
  125. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
  126. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +562 -0
  127. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
  128. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
  129. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
  130. package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
  131. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
  132. package/node_modules/zod/src/v4/classic/tests/default.test.ts +365 -0
  133. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
  134. package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
  135. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +661 -0
  136. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
  137. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +595 -0
  138. package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
  139. package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
  140. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
  141. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
  142. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +734 -0
  143. package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
  144. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
  145. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
  146. package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
  147. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
  148. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
  149. package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
  150. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
  151. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
  152. package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
  153. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  154. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  155. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
  156. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  157. package/node_modules/zod/src/v4/classic/tests/number.test.ts +270 -0
  158. package/node_modules/zod/src/v4/classic/tests/object.test.ts +640 -0
  159. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +223 -0
  160. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +427 -0
  161. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
  162. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
  163. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
  164. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +282 -0
  165. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  166. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  167. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  168. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  169. package/node_modules/zod/src/v4/classic/tests/record.test.ts +600 -0
  170. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +582 -0
  171. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +570 -0
  172. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
  173. package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
  174. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
  175. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
  176. package/node_modules/zod/src/v4/classic/tests/string.test.ts +1175 -0
  177. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
  178. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
  179. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
  180. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2975 -0
  181. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +361 -0
  182. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +183 -0
  183. package/node_modules/zod/src/v4/classic/tests/union.test.ts +219 -0
  184. package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
  185. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  186. package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  187. package/node_modules/zod/src/v4/core/api.ts +1798 -0
  188. package/node_modules/zod/src/v4/core/checks.ts +1293 -0
  189. package/node_modules/zod/src/v4/core/config.ts +15 -0
  190. package/node_modules/zod/src/v4/core/core.ts +138 -0
  191. package/node_modules/zod/src/v4/core/doc.ts +44 -0
  192. package/node_modules/zod/src/v4/core/errors.ts +448 -0
  193. package/node_modules/zod/src/v4/core/index.ts +16 -0
  194. package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
  195. package/node_modules/zod/src/v4/core/json-schema-processors.ts +667 -0
  196. package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
  197. package/node_modules/zod/src/v4/core/parse.ts +195 -0
  198. package/node_modules/zod/src/v4/core/regexes.ts +183 -0
  199. package/node_modules/zod/src/v4/core/registries.ts +105 -0
  200. package/node_modules/zod/src/v4/core/schemas.ts +4543 -0
  201. package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
  202. package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
  203. package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  204. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  205. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  206. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
  207. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
  208. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
  209. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  210. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  211. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +83 -0
  212. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +67 -0
  213. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
  214. package/node_modules/zod/src/v4/core/to-json-schema.ts +613 -0
  215. package/node_modules/zod/src/v4/core/util.ts +966 -0
  216. package/node_modules/zod/src/v4/core/versions.ts +5 -0
  217. package/node_modules/zod/src/v4/core/zsf.ts +323 -0
  218. package/node_modules/zod/src/v4/index.ts +4 -0
  219. package/node_modules/zod/src/v4/locales/ar.ts +115 -0
  220. package/node_modules/zod/src/v4/locales/az.ts +111 -0
  221. package/node_modules/zod/src/v4/locales/be.ts +176 -0
  222. package/node_modules/zod/src/v4/locales/bg.ts +128 -0
  223. package/node_modules/zod/src/v4/locales/ca.ts +116 -0
  224. package/node_modules/zod/src/v4/locales/cs.ts +118 -0
  225. package/node_modules/zod/src/v4/locales/da.ts +123 -0
  226. package/node_modules/zod/src/v4/locales/de.ts +116 -0
  227. package/node_modules/zod/src/v4/locales/en.ts +119 -0
  228. package/node_modules/zod/src/v4/locales/eo.ts +118 -0
  229. package/node_modules/zod/src/v4/locales/es.ts +141 -0
  230. package/node_modules/zod/src/v4/locales/fa.ts +126 -0
  231. package/node_modules/zod/src/v4/locales/fi.ts +121 -0
  232. package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
  233. package/node_modules/zod/src/v4/locales/fr.ts +116 -0
  234. package/node_modules/zod/src/v4/locales/he.ts +246 -0
  235. package/node_modules/zod/src/v4/locales/hu.ts +117 -0
  236. package/node_modules/zod/src/v4/locales/hy.ts +164 -0
  237. package/node_modules/zod/src/v4/locales/id.ts +115 -0
  238. package/node_modules/zod/src/v4/locales/index.ts +49 -0
  239. package/node_modules/zod/src/v4/locales/is.ts +119 -0
  240. package/node_modules/zod/src/v4/locales/it.ts +116 -0
  241. package/node_modules/zod/src/v4/locales/ja.ts +114 -0
  242. package/node_modules/zod/src/v4/locales/ka.ts +123 -0
  243. package/node_modules/zod/src/v4/locales/kh.ts +7 -0
  244. package/node_modules/zod/src/v4/locales/km.ts +119 -0
  245. package/node_modules/zod/src/v4/locales/ko.ts +121 -0
  246. package/node_modules/zod/src/v4/locales/lt.ts +239 -0
  247. package/node_modules/zod/src/v4/locales/mk.ts +118 -0
  248. package/node_modules/zod/src/v4/locales/ms.ts +115 -0
  249. package/node_modules/zod/src/v4/locales/nl.ts +121 -0
  250. package/node_modules/zod/src/v4/locales/no.ts +116 -0
  251. package/node_modules/zod/src/v4/locales/ota.ts +117 -0
  252. package/node_modules/zod/src/v4/locales/pl.ts +118 -0
  253. package/node_modules/zod/src/v4/locales/ps.ts +126 -0
  254. package/node_modules/zod/src/v4/locales/pt.ts +116 -0
  255. package/node_modules/zod/src/v4/locales/ru.ts +176 -0
  256. package/node_modules/zod/src/v4/locales/sl.ts +118 -0
  257. package/node_modules/zod/src/v4/locales/sv.ts +119 -0
  258. package/node_modules/zod/src/v4/locales/ta.ts +118 -0
  259. package/node_modules/zod/src/v4/locales/th.ts +119 -0
  260. package/node_modules/zod/src/v4/locales/tr.ts +111 -0
  261. package/node_modules/zod/src/v4/locales/ua.ts +7 -0
  262. package/node_modules/zod/src/v4/locales/uk.ts +117 -0
  263. package/node_modules/zod/src/v4/locales/ur.ts +119 -0
  264. package/node_modules/zod/src/v4/locales/uz.ts +116 -0
  265. package/node_modules/zod/src/v4/locales/vi.ts +117 -0
  266. package/node_modules/zod/src/v4/locales/yo.ts +124 -0
  267. package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
  268. package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
  269. package/node_modules/zod/src/v4/mini/checks.ts +32 -0
  270. package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
  271. package/node_modules/zod/src/v4/mini/external.ts +40 -0
  272. package/node_modules/zod/src/v4/mini/index.ts +3 -0
  273. package/node_modules/zod/src/v4/mini/iso.ts +66 -0
  274. package/node_modules/zod/src/v4/mini/parse.ts +14 -0
  275. package/node_modules/zod/src/v4/mini/schemas.ts +1916 -0
  276. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
  277. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
  278. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
  279. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
  280. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +529 -0
  281. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
  282. package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
  283. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
  284. package/node_modules/zod/src/v4/mini/tests/index.test.ts +963 -0
  285. package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
  286. package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
  287. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
  288. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
  289. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
  290. package/node_modules/zod/src/v4/mini/tests/string.test.ts +347 -0
  291. package/node_modules/zod/src/v4-mini/index.ts +1 -0
  292. package/node_modules/zod/v3/ZodError.cjs +138 -0
  293. package/node_modules/zod/v3/ZodError.d.cts +164 -0
  294. package/node_modules/zod/v3/ZodError.d.ts +164 -0
  295. package/node_modules/zod/v3/ZodError.js +133 -0
  296. package/node_modules/zod/v3/errors.cjs +17 -0
  297. package/node_modules/zod/v3/errors.d.cts +5 -0
  298. package/node_modules/zod/v3/errors.d.ts +5 -0
  299. package/node_modules/zod/v3/errors.js +9 -0
  300. package/node_modules/zod/v3/external.cjs +22 -0
  301. package/node_modules/zod/v3/external.d.cts +6 -0
  302. package/node_modules/zod/v3/external.d.ts +6 -0
  303. package/node_modules/zod/v3/external.js +6 -0
  304. package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
  305. package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  306. package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  307. package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
  308. package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
  309. package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  310. package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  311. package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
  312. package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
  313. package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  314. package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  315. package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
  316. package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
  317. package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  318. package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  319. package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
  320. package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
  321. package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  322. package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  323. package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  324. package/node_modules/zod/v3/helpers/util.cjs +137 -0
  325. package/node_modules/zod/v3/helpers/util.d.cts +85 -0
  326. package/node_modules/zod/v3/helpers/util.d.ts +85 -0
  327. package/node_modules/zod/v3/helpers/util.js +133 -0
  328. package/node_modules/zod/v3/index.cjs +33 -0
  329. package/node_modules/zod/v3/index.d.cts +4 -0
  330. package/node_modules/zod/v3/index.d.ts +4 -0
  331. package/node_modules/zod/v3/index.js +4 -0
  332. package/node_modules/zod/v3/locales/en.cjs +112 -0
  333. package/node_modules/zod/v3/locales/en.d.cts +3 -0
  334. package/node_modules/zod/v3/locales/en.d.ts +3 -0
  335. package/node_modules/zod/v3/locales/en.js +109 -0
  336. package/node_modules/zod/v3/package.json +6 -0
  337. package/node_modules/zod/v3/standard-schema.cjs +2 -0
  338. package/node_modules/zod/v3/standard-schema.d.cts +102 -0
  339. package/node_modules/zod/v3/standard-schema.d.ts +102 -0
  340. package/node_modules/zod/v3/standard-schema.js +1 -0
  341. package/node_modules/zod/v3/types.cjs +3777 -0
  342. package/node_modules/zod/v3/types.d.cts +1034 -0
  343. package/node_modules/zod/v3/types.d.ts +1034 -0
  344. package/node_modules/zod/v3/types.js +3695 -0
  345. package/node_modules/zod/v4/classic/checks.cjs +33 -0
  346. package/node_modules/zod/v4/classic/checks.d.cts +1 -0
  347. package/node_modules/zod/v4/classic/checks.d.ts +1 -0
  348. package/node_modules/zod/v4/classic/checks.js +1 -0
  349. package/node_modules/zod/v4/classic/coerce.cjs +47 -0
  350. package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
  351. package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
  352. package/node_modules/zod/v4/classic/coerce.js +17 -0
  353. package/node_modules/zod/v4/classic/compat.cjs +61 -0
  354. package/node_modules/zod/v4/classic/compat.d.cts +50 -0
  355. package/node_modules/zod/v4/classic/compat.d.ts +50 -0
  356. package/node_modules/zod/v4/classic/compat.js +31 -0
  357. package/node_modules/zod/v4/classic/errors.cjs +74 -0
  358. package/node_modules/zod/v4/classic/errors.d.cts +30 -0
  359. package/node_modules/zod/v4/classic/errors.d.ts +30 -0
  360. package/node_modules/zod/v4/classic/errors.js +48 -0
  361. package/node_modules/zod/v4/classic/external.cjs +73 -0
  362. package/node_modules/zod/v4/classic/external.d.cts +15 -0
  363. package/node_modules/zod/v4/classic/external.d.ts +15 -0
  364. package/node_modules/zod/v4/classic/external.js +20 -0
  365. package/node_modules/zod/v4/classic/from-json-schema.cjs +610 -0
  366. package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
  367. package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
  368. package/node_modules/zod/v4/classic/from-json-schema.js +584 -0
  369. package/node_modules/zod/v4/classic/index.cjs +33 -0
  370. package/node_modules/zod/v4/classic/index.d.cts +4 -0
  371. package/node_modules/zod/v4/classic/index.d.ts +4 -0
  372. package/node_modules/zod/v4/classic/index.js +4 -0
  373. package/node_modules/zod/v4/classic/iso.cjs +60 -0
  374. package/node_modules/zod/v4/classic/iso.d.cts +22 -0
  375. package/node_modules/zod/v4/classic/iso.d.ts +22 -0
  376. package/node_modules/zod/v4/classic/iso.js +30 -0
  377. package/node_modules/zod/v4/classic/package.json +6 -0
  378. package/node_modules/zod/v4/classic/parse.cjs +41 -0
  379. package/node_modules/zod/v4/classic/parse.d.cts +31 -0
  380. package/node_modules/zod/v4/classic/parse.d.ts +31 -0
  381. package/node_modules/zod/v4/classic/parse.js +15 -0
  382. package/node_modules/zod/v4/classic/schemas.cjs +1272 -0
  383. package/node_modules/zod/v4/classic/schemas.d.cts +739 -0
  384. package/node_modules/zod/v4/classic/schemas.d.ts +739 -0
  385. package/node_modules/zod/v4/classic/schemas.js +1157 -0
  386. package/node_modules/zod/v4/core/api.cjs +1222 -0
  387. package/node_modules/zod/v4/core/api.d.cts +304 -0
  388. package/node_modules/zod/v4/core/api.d.ts +304 -0
  389. package/node_modules/zod/v4/core/api.js +1082 -0
  390. package/node_modules/zod/v4/core/checks.cjs +601 -0
  391. package/node_modules/zod/v4/core/checks.d.cts +278 -0
  392. package/node_modules/zod/v4/core/checks.d.ts +278 -0
  393. package/node_modules/zod/v4/core/checks.js +575 -0
  394. package/node_modules/zod/v4/core/core.cjs +83 -0
  395. package/node_modules/zod/v4/core/core.d.cts +70 -0
  396. package/node_modules/zod/v4/core/core.d.ts +70 -0
  397. package/node_modules/zod/v4/core/core.js +76 -0
  398. package/node_modules/zod/v4/core/doc.cjs +39 -0
  399. package/node_modules/zod/v4/core/doc.d.cts +14 -0
  400. package/node_modules/zod/v4/core/doc.d.ts +14 -0
  401. package/node_modules/zod/v4/core/doc.js +35 -0
  402. package/node_modules/zod/v4/core/errors.cjs +213 -0
  403. package/node_modules/zod/v4/core/errors.d.cts +220 -0
  404. package/node_modules/zod/v4/core/errors.d.ts +220 -0
  405. package/node_modules/zod/v4/core/errors.js +182 -0
  406. package/node_modules/zod/v4/core/index.cjs +47 -0
  407. package/node_modules/zod/v4/core/index.d.cts +16 -0
  408. package/node_modules/zod/v4/core/index.d.ts +16 -0
  409. package/node_modules/zod/v4/core/index.js +16 -0
  410. package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
  411. package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
  412. package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
  413. package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
  414. package/node_modules/zod/v4/core/json-schema-processors.cjs +648 -0
  415. package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
  416. package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
  417. package/node_modules/zod/v4/core/json-schema-processors.js +605 -0
  418. package/node_modules/zod/v4/core/json-schema.cjs +2 -0
  419. package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
  420. package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
  421. package/node_modules/zod/v4/core/json-schema.js +1 -0
  422. package/node_modules/zod/v4/core/package.json +6 -0
  423. package/node_modules/zod/v4/core/parse.cjs +131 -0
  424. package/node_modules/zod/v4/core/parse.d.cts +49 -0
  425. package/node_modules/zod/v4/core/parse.d.ts +49 -0
  426. package/node_modules/zod/v4/core/parse.js +93 -0
  427. package/node_modules/zod/v4/core/regexes.cjs +166 -0
  428. package/node_modules/zod/v4/core/regexes.d.cts +79 -0
  429. package/node_modules/zod/v4/core/regexes.d.ts +79 -0
  430. package/node_modules/zod/v4/core/regexes.js +133 -0
  431. package/node_modules/zod/v4/core/registries.cjs +56 -0
  432. package/node_modules/zod/v4/core/registries.d.cts +35 -0
  433. package/node_modules/zod/v4/core/registries.d.ts +35 -0
  434. package/node_modules/zod/v4/core/registries.js +51 -0
  435. package/node_modules/zod/v4/core/schemas.cjs +2126 -0
  436. package/node_modules/zod/v4/core/schemas.d.cts +1146 -0
  437. package/node_modules/zod/v4/core/schemas.d.ts +1146 -0
  438. package/node_modules/zod/v4/core/schemas.js +2095 -0
  439. package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
  440. package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
  441. package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
  442. package/node_modules/zod/v4/core/standard-schema.js +1 -0
  443. package/node_modules/zod/v4/core/to-json-schema.cjs +446 -0
  444. package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
  445. package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
  446. package/node_modules/zod/v4/core/to-json-schema.js +437 -0
  447. package/node_modules/zod/v4/core/util.cjs +710 -0
  448. package/node_modules/zod/v4/core/util.d.cts +199 -0
  449. package/node_modules/zod/v4/core/util.d.ts +199 -0
  450. package/node_modules/zod/v4/core/util.js +651 -0
  451. package/node_modules/zod/v4/core/versions.cjs +8 -0
  452. package/node_modules/zod/v4/core/versions.d.cts +5 -0
  453. package/node_modules/zod/v4/core/versions.d.ts +5 -0
  454. package/node_modules/zod/v4/core/versions.js +5 -0
  455. package/node_modules/zod/v4/index.cjs +22 -0
  456. package/node_modules/zod/v4/index.d.cts +3 -0
  457. package/node_modules/zod/v4/index.d.ts +3 -0
  458. package/node_modules/zod/v4/index.js +3 -0
  459. package/node_modules/zod/v4/locales/ar.cjs +133 -0
  460. package/node_modules/zod/v4/locales/ar.d.cts +5 -0
  461. package/node_modules/zod/v4/locales/ar.d.ts +4 -0
  462. package/node_modules/zod/v4/locales/ar.js +106 -0
  463. package/node_modules/zod/v4/locales/az.cjs +132 -0
  464. package/node_modules/zod/v4/locales/az.d.cts +5 -0
  465. package/node_modules/zod/v4/locales/az.d.ts +4 -0
  466. package/node_modules/zod/v4/locales/az.js +105 -0
  467. package/node_modules/zod/v4/locales/be.cjs +183 -0
  468. package/node_modules/zod/v4/locales/be.d.cts +5 -0
  469. package/node_modules/zod/v4/locales/be.d.ts +4 -0
  470. package/node_modules/zod/v4/locales/be.js +156 -0
  471. package/node_modules/zod/v4/locales/bg.cjs +147 -0
  472. package/node_modules/zod/v4/locales/bg.d.cts +5 -0
  473. package/node_modules/zod/v4/locales/bg.d.ts +4 -0
  474. package/node_modules/zod/v4/locales/bg.js +120 -0
  475. package/node_modules/zod/v4/locales/ca.cjs +134 -0
  476. package/node_modules/zod/v4/locales/ca.d.cts +5 -0
  477. package/node_modules/zod/v4/locales/ca.d.ts +4 -0
  478. package/node_modules/zod/v4/locales/ca.js +107 -0
  479. package/node_modules/zod/v4/locales/cs.cjs +138 -0
  480. package/node_modules/zod/v4/locales/cs.d.cts +5 -0
  481. package/node_modules/zod/v4/locales/cs.d.ts +4 -0
  482. package/node_modules/zod/v4/locales/cs.js +111 -0
  483. package/node_modules/zod/v4/locales/da.cjs +142 -0
  484. package/node_modules/zod/v4/locales/da.d.cts +5 -0
  485. package/node_modules/zod/v4/locales/da.d.ts +4 -0
  486. package/node_modules/zod/v4/locales/da.js +115 -0
  487. package/node_modules/zod/v4/locales/de.cjs +135 -0
  488. package/node_modules/zod/v4/locales/de.d.cts +5 -0
  489. package/node_modules/zod/v4/locales/de.d.ts +4 -0
  490. package/node_modules/zod/v4/locales/de.js +108 -0
  491. package/node_modules/zod/v4/locales/en.cjs +136 -0
  492. package/node_modules/zod/v4/locales/en.d.cts +5 -0
  493. package/node_modules/zod/v4/locales/en.d.ts +4 -0
  494. package/node_modules/zod/v4/locales/en.js +109 -0
  495. package/node_modules/zod/v4/locales/eo.cjs +136 -0
  496. package/node_modules/zod/v4/locales/eo.d.cts +5 -0
  497. package/node_modules/zod/v4/locales/eo.d.ts +4 -0
  498. package/node_modules/zod/v4/locales/eo.js +109 -0
  499. package/node_modules/zod/v4/locales/es.cjs +159 -0
  500. package/node_modules/zod/v4/locales/es.d.cts +5 -0
  501. package/node_modules/zod/v4/locales/es.d.ts +4 -0
  502. package/node_modules/zod/v4/locales/es.js +132 -0
  503. package/node_modules/zod/v4/locales/fa.cjs +141 -0
  504. package/node_modules/zod/v4/locales/fa.d.cts +5 -0
  505. package/node_modules/zod/v4/locales/fa.d.ts +4 -0
  506. package/node_modules/zod/v4/locales/fa.js +114 -0
  507. package/node_modules/zod/v4/locales/fi.cjs +139 -0
  508. package/node_modules/zod/v4/locales/fi.d.cts +5 -0
  509. package/node_modules/zod/v4/locales/fi.d.ts +4 -0
  510. package/node_modules/zod/v4/locales/fi.js +112 -0
  511. package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
  512. package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  513. package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  514. package/node_modules/zod/v4/locales/fr-CA.js +107 -0
  515. package/node_modules/zod/v4/locales/fr.cjs +135 -0
  516. package/node_modules/zod/v4/locales/fr.d.cts +5 -0
  517. package/node_modules/zod/v4/locales/fr.d.ts +4 -0
  518. package/node_modules/zod/v4/locales/fr.js +108 -0
  519. package/node_modules/zod/v4/locales/he.cjs +241 -0
  520. package/node_modules/zod/v4/locales/he.d.cts +5 -0
  521. package/node_modules/zod/v4/locales/he.d.ts +4 -0
  522. package/node_modules/zod/v4/locales/he.js +214 -0
  523. package/node_modules/zod/v4/locales/hu.cjs +135 -0
  524. package/node_modules/zod/v4/locales/hu.d.cts +5 -0
  525. package/node_modules/zod/v4/locales/hu.d.ts +4 -0
  526. package/node_modules/zod/v4/locales/hu.js +108 -0
  527. package/node_modules/zod/v4/locales/hy.cjs +174 -0
  528. package/node_modules/zod/v4/locales/hy.d.cts +5 -0
  529. package/node_modules/zod/v4/locales/hy.d.ts +4 -0
  530. package/node_modules/zod/v4/locales/hy.js +147 -0
  531. package/node_modules/zod/v4/locales/id.cjs +133 -0
  532. package/node_modules/zod/v4/locales/id.d.cts +5 -0
  533. package/node_modules/zod/v4/locales/id.d.ts +4 -0
  534. package/node_modules/zod/v4/locales/id.js +106 -0
  535. package/node_modules/zod/v4/locales/index.cjs +104 -0
  536. package/node_modules/zod/v4/locales/index.d.cts +49 -0
  537. package/node_modules/zod/v4/locales/index.d.ts +49 -0
  538. package/node_modules/zod/v4/locales/index.js +49 -0
  539. package/node_modules/zod/v4/locales/is.cjs +136 -0
  540. package/node_modules/zod/v4/locales/is.d.cts +5 -0
  541. package/node_modules/zod/v4/locales/is.d.ts +4 -0
  542. package/node_modules/zod/v4/locales/is.js +109 -0
  543. package/node_modules/zod/v4/locales/it.cjs +135 -0
  544. package/node_modules/zod/v4/locales/it.d.cts +5 -0
  545. package/node_modules/zod/v4/locales/it.d.ts +4 -0
  546. package/node_modules/zod/v4/locales/it.js +108 -0
  547. package/node_modules/zod/v4/locales/ja.cjs +134 -0
  548. package/node_modules/zod/v4/locales/ja.d.cts +5 -0
  549. package/node_modules/zod/v4/locales/ja.d.ts +4 -0
  550. package/node_modules/zod/v4/locales/ja.js +107 -0
  551. package/node_modules/zod/v4/locales/ka.cjs +139 -0
  552. package/node_modules/zod/v4/locales/ka.d.cts +5 -0
  553. package/node_modules/zod/v4/locales/ka.d.ts +4 -0
  554. package/node_modules/zod/v4/locales/ka.js +112 -0
  555. package/node_modules/zod/v4/locales/kh.cjs +12 -0
  556. package/node_modules/zod/v4/locales/kh.d.cts +5 -0
  557. package/node_modules/zod/v4/locales/kh.d.ts +5 -0
  558. package/node_modules/zod/v4/locales/kh.js +5 -0
  559. package/node_modules/zod/v4/locales/km.cjs +137 -0
  560. package/node_modules/zod/v4/locales/km.d.cts +5 -0
  561. package/node_modules/zod/v4/locales/km.d.ts +4 -0
  562. package/node_modules/zod/v4/locales/km.js +110 -0
  563. package/node_modules/zod/v4/locales/ko.cjs +138 -0
  564. package/node_modules/zod/v4/locales/ko.d.cts +5 -0
  565. package/node_modules/zod/v4/locales/ko.d.ts +4 -0
  566. package/node_modules/zod/v4/locales/ko.js +111 -0
  567. package/node_modules/zod/v4/locales/lt.cjs +230 -0
  568. package/node_modules/zod/v4/locales/lt.d.cts +5 -0
  569. package/node_modules/zod/v4/locales/lt.d.ts +4 -0
  570. package/node_modules/zod/v4/locales/lt.js +203 -0
  571. package/node_modules/zod/v4/locales/mk.cjs +136 -0
  572. package/node_modules/zod/v4/locales/mk.d.cts +5 -0
  573. package/node_modules/zod/v4/locales/mk.d.ts +4 -0
  574. package/node_modules/zod/v4/locales/mk.js +109 -0
  575. package/node_modules/zod/v4/locales/ms.cjs +134 -0
  576. package/node_modules/zod/v4/locales/ms.d.cts +5 -0
  577. package/node_modules/zod/v4/locales/ms.d.ts +4 -0
  578. package/node_modules/zod/v4/locales/ms.js +107 -0
  579. package/node_modules/zod/v4/locales/nl.cjs +137 -0
  580. package/node_modules/zod/v4/locales/nl.d.cts +5 -0
  581. package/node_modules/zod/v4/locales/nl.d.ts +4 -0
  582. package/node_modules/zod/v4/locales/nl.js +110 -0
  583. package/node_modules/zod/v4/locales/no.cjs +135 -0
  584. package/node_modules/zod/v4/locales/no.d.cts +5 -0
  585. package/node_modules/zod/v4/locales/no.d.ts +4 -0
  586. package/node_modules/zod/v4/locales/no.js +108 -0
  587. package/node_modules/zod/v4/locales/ota.cjs +136 -0
  588. package/node_modules/zod/v4/locales/ota.d.cts +5 -0
  589. package/node_modules/zod/v4/locales/ota.d.ts +4 -0
  590. package/node_modules/zod/v4/locales/ota.js +109 -0
  591. package/node_modules/zod/v4/locales/package.json +6 -0
  592. package/node_modules/zod/v4/locales/pl.cjs +136 -0
  593. package/node_modules/zod/v4/locales/pl.d.cts +5 -0
  594. package/node_modules/zod/v4/locales/pl.d.ts +4 -0
  595. package/node_modules/zod/v4/locales/pl.js +109 -0
  596. package/node_modules/zod/v4/locales/ps.cjs +141 -0
  597. package/node_modules/zod/v4/locales/ps.d.cts +5 -0
  598. package/node_modules/zod/v4/locales/ps.d.ts +4 -0
  599. package/node_modules/zod/v4/locales/ps.js +114 -0
  600. package/node_modules/zod/v4/locales/pt.cjs +135 -0
  601. package/node_modules/zod/v4/locales/pt.d.cts +5 -0
  602. package/node_modules/zod/v4/locales/pt.d.ts +4 -0
  603. package/node_modules/zod/v4/locales/pt.js +108 -0
  604. package/node_modules/zod/v4/locales/ru.cjs +183 -0
  605. package/node_modules/zod/v4/locales/ru.d.cts +5 -0
  606. package/node_modules/zod/v4/locales/ru.d.ts +4 -0
  607. package/node_modules/zod/v4/locales/ru.js +156 -0
  608. package/node_modules/zod/v4/locales/sl.cjs +136 -0
  609. package/node_modules/zod/v4/locales/sl.d.cts +5 -0
  610. package/node_modules/zod/v4/locales/sl.d.ts +4 -0
  611. package/node_modules/zod/v4/locales/sl.js +109 -0
  612. package/node_modules/zod/v4/locales/sv.cjs +137 -0
  613. package/node_modules/zod/v4/locales/sv.d.cts +5 -0
  614. package/node_modules/zod/v4/locales/sv.d.ts +4 -0
  615. package/node_modules/zod/v4/locales/sv.js +110 -0
  616. package/node_modules/zod/v4/locales/ta.cjs +137 -0
  617. package/node_modules/zod/v4/locales/ta.d.cts +5 -0
  618. package/node_modules/zod/v4/locales/ta.d.ts +4 -0
  619. package/node_modules/zod/v4/locales/ta.js +110 -0
  620. package/node_modules/zod/v4/locales/th.cjs +137 -0
  621. package/node_modules/zod/v4/locales/th.d.cts +5 -0
  622. package/node_modules/zod/v4/locales/th.d.ts +4 -0
  623. package/node_modules/zod/v4/locales/th.js +110 -0
  624. package/node_modules/zod/v4/locales/tr.cjs +132 -0
  625. package/node_modules/zod/v4/locales/tr.d.cts +5 -0
  626. package/node_modules/zod/v4/locales/tr.d.ts +4 -0
  627. package/node_modules/zod/v4/locales/tr.js +105 -0
  628. package/node_modules/zod/v4/locales/ua.cjs +12 -0
  629. package/node_modules/zod/v4/locales/ua.d.cts +5 -0
  630. package/node_modules/zod/v4/locales/ua.d.ts +5 -0
  631. package/node_modules/zod/v4/locales/ua.js +5 -0
  632. package/node_modules/zod/v4/locales/uk.cjs +135 -0
  633. package/node_modules/zod/v4/locales/uk.d.cts +5 -0
  634. package/node_modules/zod/v4/locales/uk.d.ts +4 -0
  635. package/node_modules/zod/v4/locales/uk.js +108 -0
  636. package/node_modules/zod/v4/locales/ur.cjs +137 -0
  637. package/node_modules/zod/v4/locales/ur.d.cts +5 -0
  638. package/node_modules/zod/v4/locales/ur.d.ts +4 -0
  639. package/node_modules/zod/v4/locales/ur.js +110 -0
  640. package/node_modules/zod/v4/locales/uz.cjs +136 -0
  641. package/node_modules/zod/v4/locales/uz.d.cts +5 -0
  642. package/node_modules/zod/v4/locales/uz.d.ts +4 -0
  643. package/node_modules/zod/v4/locales/uz.js +109 -0
  644. package/node_modules/zod/v4/locales/vi.cjs +135 -0
  645. package/node_modules/zod/v4/locales/vi.d.cts +5 -0
  646. package/node_modules/zod/v4/locales/vi.d.ts +4 -0
  647. package/node_modules/zod/v4/locales/vi.js +108 -0
  648. package/node_modules/zod/v4/locales/yo.cjs +134 -0
  649. package/node_modules/zod/v4/locales/yo.d.cts +5 -0
  650. package/node_modules/zod/v4/locales/yo.d.ts +4 -0
  651. package/node_modules/zod/v4/locales/yo.js +107 -0
  652. package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
  653. package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  654. package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  655. package/node_modules/zod/v4/locales/zh-CN.js +109 -0
  656. package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
  657. package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  658. package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  659. package/node_modules/zod/v4/locales/zh-TW.js +107 -0
  660. package/node_modules/zod/v4/mini/checks.cjs +34 -0
  661. package/node_modules/zod/v4/mini/checks.d.cts +1 -0
  662. package/node_modules/zod/v4/mini/checks.d.ts +1 -0
  663. package/node_modules/zod/v4/mini/checks.js +1 -0
  664. package/node_modules/zod/v4/mini/coerce.cjs +52 -0
  665. package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
  666. package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
  667. package/node_modules/zod/v4/mini/coerce.js +22 -0
  668. package/node_modules/zod/v4/mini/external.cjs +63 -0
  669. package/node_modules/zod/v4/mini/external.d.cts +12 -0
  670. package/node_modules/zod/v4/mini/external.d.ts +12 -0
  671. package/node_modules/zod/v4/mini/external.js +14 -0
  672. package/node_modules/zod/v4/mini/index.cjs +32 -0
  673. package/node_modules/zod/v4/mini/index.d.cts +3 -0
  674. package/node_modules/zod/v4/mini/index.d.ts +3 -0
  675. package/node_modules/zod/v4/mini/index.js +3 -0
  676. package/node_modules/zod/v4/mini/iso.cjs +64 -0
  677. package/node_modules/zod/v4/mini/iso.d.cts +22 -0
  678. package/node_modules/zod/v4/mini/iso.d.ts +22 -0
  679. package/node_modules/zod/v4/mini/iso.js +34 -0
  680. package/node_modules/zod/v4/mini/package.json +6 -0
  681. package/node_modules/zod/v4/mini/parse.cjs +16 -0
  682. package/node_modules/zod/v4/mini/parse.d.cts +1 -0
  683. package/node_modules/zod/v4/mini/parse.d.ts +1 -0
  684. package/node_modules/zod/v4/mini/parse.js +1 -0
  685. package/node_modules/zod/v4/mini/schemas.cjs +1046 -0
  686. package/node_modules/zod/v4/mini/schemas.d.cts +427 -0
  687. package/node_modules/zod/v4/mini/schemas.d.ts +427 -0
  688. package/node_modules/zod/v4/mini/schemas.js +925 -0
  689. package/node_modules/zod/v4/package.json +6 -0
  690. package/node_modules/zod/v4-mini/index.cjs +17 -0
  691. package/node_modules/zod/v4-mini/index.d.cts +1 -0
  692. package/node_modules/zod/v4-mini/index.d.ts +1 -0
  693. package/node_modules/zod/v4-mini/index.js +1 -0
  694. package/node_modules/zod/v4-mini/package.json +6 -0
  695. package/package.json +5 -4
@@ -0,0 +1,2975 @@
1
+ import { Validator } from "@seriousme/openapi-schema-validator";
2
+ import { describe, expect, test } from "vitest";
3
+ import * as z from "zod";
4
+ // import * as zCore from "zod/v4/core";
5
+
6
+ const openAPI30Validator = new Validator();
7
+ /** @see https://github.com/colinhacks/zod/issues/5147 */
8
+ const validateOpenAPI30Schema = async (zodJSONSchema: Record<string, unknown>): Promise<true> => {
9
+ const res = await openAPI30Validator.validate({
10
+ openapi: "3.0.0",
11
+ info: {
12
+ title: "SampleApi",
13
+ description: "Sample backend service",
14
+ version: "1.0.0",
15
+ },
16
+ components: { schemas: { test: zodJSONSchema } },
17
+ paths: {},
18
+ });
19
+
20
+ if (!res.valid) {
21
+ // `console.error` should make `vitest` trow an unhandled error
22
+ // printing the validation messages in consoles
23
+ console.error(
24
+ `OpenAPI schema is not valid against ${openAPI30Validator.version}`,
25
+ JSON.stringify(res.errors, null, 2)
26
+ );
27
+ }
28
+
29
+ return true;
30
+ };
31
+
32
+ describe("toJSONSchema", () => {
33
+ test("primitive types", () => {
34
+ expect(z.toJSONSchema(z.string())).toMatchInlineSnapshot(`
35
+ {
36
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
37
+ "type": "string",
38
+ }
39
+ `);
40
+ expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
41
+ {
42
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
43
+ "type": "number",
44
+ }
45
+ `);
46
+ expect(z.toJSONSchema(z.boolean())).toMatchInlineSnapshot(`
47
+ {
48
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
49
+ "type": "boolean",
50
+ }
51
+ `);
52
+ expect(z.toJSONSchema(z.null())).toMatchInlineSnapshot(`
53
+ {
54
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
55
+ "type": "null",
56
+ }
57
+ `);
58
+ expect(z.toJSONSchema(z.undefined(), { unrepresentable: "any" })).toMatchInlineSnapshot(`
59
+ {
60
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
61
+ }
62
+ `);
63
+ expect(z.toJSONSchema(z.any())).toMatchInlineSnapshot(`
64
+ {
65
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
66
+ }
67
+ `);
68
+ expect(z.toJSONSchema(z.unknown())).toMatchInlineSnapshot(`
69
+ {
70
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
71
+ }
72
+ `);
73
+ expect(z.toJSONSchema(z.never())).toMatchInlineSnapshot(`
74
+ {
75
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
76
+ "not": {},
77
+ }
78
+ `);
79
+ expect(z.toJSONSchema(z.email())).toMatchInlineSnapshot(`
80
+ {
81
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
82
+ "format": "email",
83
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
84
+ "type": "string",
85
+ }
86
+ `);
87
+ expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
88
+ {
89
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
90
+ "format": "date-time",
91
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
92
+ "type": "string",
93
+ }
94
+ `);
95
+ expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
96
+ {
97
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
98
+ "format": "date",
99
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
100
+ "type": "string",
101
+ }
102
+ `);
103
+ expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
104
+ {
105
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
106
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
107
+ "type": "string",
108
+ }
109
+ `);
110
+ expect(z.toJSONSchema(z.iso.time({ precision: -1 }))).toMatchInlineSnapshot(`
111
+ {
112
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
113
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d$",
114
+ "type": "string",
115
+ }
116
+ `);
117
+ expect(z.toJSONSchema(z.iso.time({ precision: 0 }))).toMatchInlineSnapshot(`
118
+ {
119
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
120
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$",
121
+ "type": "string",
122
+ }
123
+ `);
124
+ expect(z.toJSONSchema(z.iso.time({ precision: 3 }))).toMatchInlineSnapshot(`
125
+ {
126
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
127
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}$",
128
+ "type": "string",
129
+ }
130
+ `);
131
+ expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
132
+ {
133
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
134
+ "format": "duration",
135
+ "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
136
+ "type": "string",
137
+ }
138
+ `);
139
+ expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
140
+ {
141
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
142
+ "format": "ipv4",
143
+ "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
144
+ "type": "string",
145
+ }
146
+ `);
147
+ expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
148
+ {
149
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
150
+ "format": "ipv6",
151
+ "pattern": "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$",
152
+ "type": "string",
153
+ }
154
+ `);
155
+ expect(z.toJSONSchema(z.mac())).toMatchInlineSnapshot(`
156
+ {
157
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
158
+ "format": "mac",
159
+ "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
160
+ "type": "string",
161
+ }
162
+ `);
163
+ expect(z.toJSONSchema(z.mac({ delimiter: ":" }))).toMatchInlineSnapshot(`
164
+ {
165
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
166
+ "format": "mac",
167
+ "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
168
+ "type": "string",
169
+ }
170
+ `);
171
+ expect(z.toJSONSchema(z.mac({ delimiter: "-" }))).toMatchInlineSnapshot(`
172
+ {
173
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
174
+ "format": "mac",
175
+ "pattern": "^(?:[0-9A-F]{2}-){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}-){5}[0-9a-f]{2}$",
176
+ "type": "string",
177
+ }
178
+ `);
179
+ expect(z.toJSONSchema(z.uuid())).toMatchInlineSnapshot(`
180
+ {
181
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
182
+ "format": "uuid",
183
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
184
+ "type": "string",
185
+ }
186
+ `);
187
+ expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
188
+ {
189
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
190
+ "format": "uuid",
191
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
192
+ "type": "string",
193
+ }
194
+ `);
195
+ expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
196
+ {
197
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
198
+ "format": "uri",
199
+ "type": "string",
200
+ }
201
+ `);
202
+ expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
203
+ {
204
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
205
+ "contentEncoding": "base64",
206
+ "format": "base64",
207
+ "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
208
+ "type": "string",
209
+ }
210
+ `);
211
+ expect(z.toJSONSchema(z.cuid())).toMatchInlineSnapshot(`
212
+ {
213
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
214
+ "format": "cuid",
215
+ "pattern": "^[cC][^\\s-]{8,}$",
216
+ "type": "string",
217
+ }
218
+ `);
219
+ // expect(z.toJSONSchema(z.regex(/asdf/))).toMatchInlineSnapshot();
220
+ expect(z.toJSONSchema(z.emoji())).toMatchInlineSnapshot(`
221
+ {
222
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
223
+ "format": "emoji",
224
+ "pattern": "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
225
+ "type": "string",
226
+ }
227
+ `);
228
+ expect(z.toJSONSchema(z.nanoid())).toMatchInlineSnapshot(`
229
+ {
230
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
231
+ "format": "nanoid",
232
+ "pattern": "^[a-zA-Z0-9_-]{21}$",
233
+ "type": "string",
234
+ }
235
+ `);
236
+ expect(z.toJSONSchema(z.cuid2())).toMatchInlineSnapshot(`
237
+ {
238
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
239
+ "format": "cuid2",
240
+ "pattern": "^[0-9a-z]+$",
241
+ "type": "string",
242
+ }
243
+ `);
244
+ expect(z.toJSONSchema(z.ulid())).toMatchInlineSnapshot(`
245
+ {
246
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
247
+ "format": "ulid",
248
+ "pattern": "^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$",
249
+ "type": "string",
250
+ }
251
+ `);
252
+ // expect(z.toJSONSchema(z.cidr())).toMatchInlineSnapshot();
253
+ expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
254
+ {
255
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
256
+ "type": "number",
257
+ }
258
+ `);
259
+ expect(z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
260
+ {
261
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
262
+ "maximum": 9007199254740991,
263
+ "minimum": -9007199254740991,
264
+ "type": "integer",
265
+ }
266
+ `);
267
+ expect(z.toJSONSchema(z.int32())).toMatchInlineSnapshot(`
268
+ {
269
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
270
+ "maximum": 2147483647,
271
+ "minimum": -2147483648,
272
+ "type": "integer",
273
+ }
274
+ `);
275
+ expect(z.toJSONSchema(z.float32())).toMatchInlineSnapshot(`
276
+ {
277
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
278
+ "maximum": 3.4028234663852886e+38,
279
+ "minimum": -3.4028234663852886e+38,
280
+ "type": "number",
281
+ }
282
+ `);
283
+ expect(z.toJSONSchema(z.float64())).toMatchInlineSnapshot(`
284
+ {
285
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
286
+ "maximum": 1.7976931348623157e+308,
287
+ "minimum": -1.7976931348623157e+308,
288
+ "type": "number",
289
+ }
290
+ `);
291
+ expect(z.toJSONSchema(z.jwt())).toMatchInlineSnapshot(`
292
+ {
293
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
294
+ "format": "jwt",
295
+ "type": "string",
296
+ }
297
+ `);
298
+ });
299
+
300
+ test("unsupported schema types", () => {
301
+ expect(() => z.toJSONSchema(z.bigint())).toThrow("BigInt cannot be represented in JSON Schema");
302
+ expect(() => z.toJSONSchema(z.int64())).toThrow("BigInt cannot be represented in JSON Schema");
303
+ expect(() => z.toJSONSchema(z.symbol())).toThrow("Symbols cannot be represented in JSON Schema");
304
+ expect(() => z.toJSONSchema(z.void())).toThrow("Void cannot be represented in JSON Schema");
305
+ expect(() => z.toJSONSchema(z.undefined())).toThrow("Undefined cannot be represented in JSON Schema");
306
+ expect(() => z.toJSONSchema(z.date())).toThrow("Date cannot be represented in JSON Schema");
307
+ expect(() => z.toJSONSchema(z.map(z.string(), z.number()))).toThrow("Map cannot be represented in JSON Schema");
308
+ expect(() => z.toJSONSchema(z.set(z.string()))).toThrow("Set cannot be represented in JSON Schema");
309
+ expect(() => z.toJSONSchema(z.custom(() => true))).toThrow("Custom types cannot be represented in JSON Schema");
310
+
311
+ // Transform
312
+ const transformSchema = z.string().transform((val) => Number.parseInt(val));
313
+ expect(() => z.toJSONSchema(transformSchema)).toThrow("Transforms cannot be represented in JSON Schema");
314
+
315
+ // Static catch values
316
+ const staticCatchSchema = z.string().catch(() => "sup");
317
+ expect(z.toJSONSchema(staticCatchSchema)).toMatchInlineSnapshot(`
318
+ {
319
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
320
+ "default": "sup",
321
+ "type": "string",
322
+ }
323
+ `);
324
+
325
+ // Dynamic catch values
326
+ const dynamicCatchSchema = z.string().catch((ctx) => `${ctx.issues.length}`);
327
+ expect(() => z.toJSONSchema(dynamicCatchSchema)).toThrow("Dynamic catch values are not supported in JSON Schema");
328
+ });
329
+
330
+ test("string formats", () => {
331
+ expect(z.toJSONSchema(z.string().email())).toMatchInlineSnapshot(`
332
+ {
333
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
334
+ "format": "email",
335
+ "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
336
+ "type": "string",
337
+ }
338
+ `);
339
+ expect(z.toJSONSchema(z.string().uuid())).toMatchInlineSnapshot(`
340
+ {
341
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
342
+ "format": "uuid",
343
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
344
+ "type": "string",
345
+ }
346
+ `);
347
+ expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
348
+ {
349
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
350
+ "format": "date-time",
351
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
352
+ "type": "string",
353
+ }
354
+ `);
355
+
356
+ expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
357
+ {
358
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
359
+ "format": "date",
360
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$",
361
+ "type": "string",
362
+ }
363
+ `);
364
+ expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
365
+ {
366
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
367
+ "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
368
+ "type": "string",
369
+ }
370
+ `);
371
+ expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
372
+ {
373
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
374
+ "format": "duration",
375
+ "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
376
+ "type": "string",
377
+ }
378
+ `);
379
+ // expect(z.toJSONSchema(z.string().ip())).toMatchInlineSnapshot(`
380
+ // {
381
+ // "pattern": /\\(\\^\\(\\?:\\(\\?:25\\[0-5\\]\\|2\\[0-4\\]\\[0-9\\]\\|1\\[0-9\\]\\[0-9\\]\\|\\[1-9\\]\\[0-9\\]\\|\\[0-9\\]\\)\\\\\\.\\)\\{3\\}\\(\\?:25\\[0-5\\]\\|2\\[0-4\\]\\[0-9\\]\\|1\\[0-9\\]\\[0-9\\]\\|\\[1-9\\]\\[0-9\\]\\|\\[0-9\\]\\)\\$\\)\\|\\(\\^\\(\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{7\\}\\|::\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,6\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{1\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,5\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{2\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,4\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{3\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,3\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{4\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,2\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{5\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,1\\}\\)\\(\\[a-fA-F0-9\\]\\{1,4\\}\\|\\(\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\\\\\.\\)\\{3\\}\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\)\\$\\)/,
382
+ // "type": "string",
383
+ // }
384
+ // `);
385
+ expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
386
+ {
387
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
388
+ "format": "ipv4",
389
+ "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
390
+ "type": "string",
391
+ }
392
+ `);
393
+
394
+ expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
395
+ {
396
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
397
+ "format": "ipv6",
398
+ "pattern": "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$",
399
+ "type": "string",
400
+ }
401
+ `);
402
+
403
+ expect(z.toJSONSchema(z.mac())).toMatchInlineSnapshot(`
404
+ {
405
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
406
+ "format": "mac",
407
+ "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
408
+ "type": "string",
409
+ }
410
+ `);
411
+ expect(z.toJSONSchema(z.mac({ delimiter: ":" }))).toMatchInlineSnapshot(`
412
+ {
413
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
414
+ "format": "mac",
415
+ "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
416
+ "type": "string",
417
+ }
418
+ `);
419
+ expect(z.toJSONSchema(z.mac({ delimiter: "-" }))).toMatchInlineSnapshot(`
420
+ {
421
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
422
+ "format": "mac",
423
+ "pattern": "^(?:[0-9A-F]{2}-){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}-){5}[0-9a-f]{2}$",
424
+ "type": "string",
425
+ }
426
+ `);
427
+
428
+ expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
429
+ {
430
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
431
+ "contentEncoding": "base64",
432
+ "format": "base64",
433
+ "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
434
+ "type": "string",
435
+ }
436
+ `);
437
+ expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
438
+ {
439
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
440
+ "format": "uri",
441
+ "type": "string",
442
+ }
443
+ `);
444
+ expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
445
+ {
446
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
447
+ "format": "uuid",
448
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
449
+ "type": "string",
450
+ }
451
+ `);
452
+ expect(z.toJSONSchema(z.string().regex(/asdf/))).toMatchInlineSnapshot(`
453
+ {
454
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
455
+ "pattern": "asdf",
456
+ "type": "string",
457
+ }
458
+ `);
459
+ });
460
+
461
+ test("string patterns", () => {
462
+ expect(
463
+ z.toJSONSchema(
464
+ z
465
+ .string()
466
+ .startsWith("hello")
467
+ .includes("cruel")
468
+ .includes("dark", { position: 10 })
469
+ .endsWith("world")
470
+ .regex(/stuff/)
471
+ )
472
+ ).toMatchInlineSnapshot(`
473
+ {
474
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
475
+ "allOf": [
476
+ {
477
+ "pattern": "^hello.*",
478
+ },
479
+ {
480
+ "pattern": "cruel",
481
+ },
482
+ {
483
+ "pattern": "^.{10}dark",
484
+ },
485
+ {
486
+ "pattern": ".*world$",
487
+ },
488
+ {
489
+ "pattern": "stuff",
490
+ },
491
+ ],
492
+ "type": "string",
493
+ }
494
+ `);
495
+
496
+ expect(
497
+ z.toJSONSchema(
498
+ z
499
+ .string()
500
+ .startsWith("hello")
501
+ .includes("cruel")
502
+ .includes("dark", { position: 10 })
503
+ .endsWith("world")
504
+ .regex(/stuff/),
505
+ {
506
+ target: "draft-7",
507
+ }
508
+ )
509
+ ).toMatchInlineSnapshot(`
510
+ {
511
+ "$schema": "http://json-schema.org/draft-07/schema#",
512
+ "allOf": [
513
+ {
514
+ "pattern": "^hello.*",
515
+ "type": "string",
516
+ },
517
+ {
518
+ "pattern": "cruel",
519
+ "type": "string",
520
+ },
521
+ {
522
+ "pattern": "^.{10}dark",
523
+ "type": "string",
524
+ },
525
+ {
526
+ "pattern": ".*world$",
527
+ "type": "string",
528
+ },
529
+ {
530
+ "pattern": "stuff",
531
+ "type": "string",
532
+ },
533
+ ],
534
+ "type": "string",
535
+ }
536
+ `);
537
+ });
538
+
539
+ test("number constraints", () => {
540
+ expect(z.toJSONSchema(z.number().min(5).max(10))).toMatchInlineSnapshot(
541
+ `
542
+ {
543
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
544
+ "maximum": 10,
545
+ "minimum": 5,
546
+ "type": "number",
547
+ }
548
+ `
549
+ );
550
+
551
+ expect(z.toJSONSchema(z.number().gt(5).gt(10))).toMatchInlineSnapshot(`
552
+ {
553
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
554
+ "exclusiveMinimum": 10,
555
+ "type": "number",
556
+ }
557
+ `);
558
+
559
+ expect(z.toJSONSchema(z.number().gt(5).gte(10))).toMatchInlineSnapshot(`
560
+ {
561
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
562
+ "minimum": 10,
563
+ "type": "number",
564
+ }
565
+ `);
566
+
567
+ expect(z.toJSONSchema(z.number().lt(5).lt(3))).toMatchInlineSnapshot(`
568
+ {
569
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
570
+ "exclusiveMaximum": 3,
571
+ "type": "number",
572
+ }
573
+ `);
574
+
575
+ expect(z.toJSONSchema(z.number().lt(5).lt(3).lte(2))).toMatchInlineSnapshot(`
576
+ {
577
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
578
+ "maximum": 2,
579
+ "type": "number",
580
+ }
581
+ `);
582
+
583
+ expect(z.toJSONSchema(z.number().lt(5).lte(3))).toMatchInlineSnapshot(`
584
+ {
585
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
586
+ "maximum": 3,
587
+ "type": "number",
588
+ }
589
+ `);
590
+
591
+ expect(z.toJSONSchema(z.number().gt(5).lt(10))).toMatchInlineSnapshot(`
592
+ {
593
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
594
+ "exclusiveMaximum": 10,
595
+ "exclusiveMinimum": 5,
596
+ "type": "number",
597
+ }
598
+ `);
599
+ expect(z.toJSONSchema(z.number().gte(5).lte(10))).toMatchInlineSnapshot(`
600
+ {
601
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
602
+ "maximum": 10,
603
+ "minimum": 5,
604
+ "type": "number",
605
+ }
606
+ `);
607
+ expect(z.toJSONSchema(z.number().positive())).toMatchInlineSnapshot(`
608
+ {
609
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
610
+ "exclusiveMinimum": 0,
611
+ "type": "number",
612
+ }
613
+ `);
614
+ expect(z.toJSONSchema(z.number().negative())).toMatchInlineSnapshot(`
615
+ {
616
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
617
+ "exclusiveMaximum": 0,
618
+ "type": "number",
619
+ }
620
+ `);
621
+ expect(z.toJSONSchema(z.number().nonpositive())).toMatchInlineSnapshot(`
622
+ {
623
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
624
+ "maximum": 0,
625
+ "type": "number",
626
+ }
627
+ `);
628
+ expect(z.toJSONSchema(z.number().nonnegative())).toMatchInlineSnapshot(`
629
+ {
630
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
631
+ "minimum": 0,
632
+ "type": "number",
633
+ }
634
+ `);
635
+ });
636
+
637
+ test("number constraints draft-4", () => {
638
+ expect(z.toJSONSchema(z.number().gt(5).lt(10), { target: "draft-4" })).toMatchInlineSnapshot(`
639
+ {
640
+ "$schema": "http://json-schema.org/draft-04/schema#",
641
+ "exclusiveMaximum": true,
642
+ "exclusiveMinimum": true,
643
+ "maximum": 10,
644
+ "minimum": 5,
645
+ "type": "number",
646
+ }
647
+ `);
648
+ });
649
+
650
+ test("target normalization draft-04 and draft-07", () => {
651
+ // Test that both old (draft-4, draft-7) and new (draft-04, draft-07) target formats work
652
+ // Test draft-04 / draft-4
653
+ expect(z.toJSONSchema(z.number().gt(5), { target: "draft-04" })).toMatchInlineSnapshot(`
654
+ {
655
+ "$schema": "http://json-schema.org/draft-04/schema#",
656
+ "exclusiveMinimum": true,
657
+ "minimum": 5,
658
+ "type": "number",
659
+ }
660
+ `);
661
+ expect(z.toJSONSchema(z.number().gt(5), { target: "draft-4" })).toMatchInlineSnapshot(`
662
+ {
663
+ "$schema": "http://json-schema.org/draft-04/schema#",
664
+ "exclusiveMinimum": true,
665
+ "minimum": 5,
666
+ "type": "number",
667
+ }
668
+ `);
669
+ // Test draft-07 / draft-7
670
+ expect(z.toJSONSchema(z.number().gt(5), { target: "draft-07" })).toMatchInlineSnapshot(`
671
+ {
672
+ "$schema": "http://json-schema.org/draft-07/schema#",
673
+ "exclusiveMinimum": 5,
674
+ "type": "number",
675
+ }
676
+ `);
677
+ expect(z.toJSONSchema(z.number().gt(5), { target: "draft-7" })).toMatchInlineSnapshot(`
678
+ {
679
+ "$schema": "http://json-schema.org/draft-07/schema#",
680
+ "exclusiveMinimum": 5,
681
+ "type": "number",
682
+ }
683
+ `);
684
+ });
685
+
686
+ test("nullable openapi-3.0", () => {
687
+ const schema = z.string().nullable();
688
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
689
+ validateOpenAPI30Schema(jsonSchema);
690
+ expect(jsonSchema).toMatchInlineSnapshot(`
691
+ {
692
+ "nullable": true,
693
+ "type": "string",
694
+ }
695
+ `);
696
+ });
697
+
698
+ test("union with null openapi-3.0", () => {
699
+ const schema = z.union([z.string(), z.null()]);
700
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
701
+ validateOpenAPI30Schema(jsonSchema);
702
+ expect(jsonSchema).toMatchInlineSnapshot(`
703
+ {
704
+ "anyOf": [
705
+ {
706
+ "type": "string",
707
+ },
708
+ {
709
+ "enum": [
710
+ null,
711
+ ],
712
+ "nullable": true,
713
+ "type": "string",
714
+ },
715
+ ],
716
+ }
717
+ `);
718
+ });
719
+
720
+ test("number with exclusive min-max openapi-3.0", () => {
721
+ const schema = z.number().lt(100).gt(1);
722
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
723
+ validateOpenAPI30Schema(jsonSchema);
724
+ expect(jsonSchema).toMatchInlineSnapshot(`
725
+ {
726
+ "exclusiveMaximum": true,
727
+ "exclusiveMinimum": true,
728
+ "maximum": 100,
729
+ "minimum": 1,
730
+ "type": "number",
731
+ }
732
+ `);
733
+ });
734
+
735
+ test("arrays", () => {
736
+ expect(z.toJSONSchema(z.array(z.string()))).toMatchInlineSnapshot(`
737
+ {
738
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
739
+ "items": {
740
+ "type": "string",
741
+ },
742
+ "type": "array",
743
+ }
744
+ `);
745
+ });
746
+
747
+ test("unions", () => {
748
+ const schema = z.union([z.string(), z.number()]);
749
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
750
+ {
751
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
752
+ "anyOf": [
753
+ {
754
+ "type": "string",
755
+ },
756
+ {
757
+ "type": "number",
758
+ },
759
+ ],
760
+ }
761
+ `);
762
+ });
763
+
764
+ test("discriminated unions", () => {
765
+ const schema = z.discriminatedUnion("type", [
766
+ z.object({ type: z.literal("success"), data: z.string() }),
767
+ z.object({ type: z.literal("error"), message: z.string() }),
768
+ ]);
769
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
770
+ {
771
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
772
+ "oneOf": [
773
+ {
774
+ "additionalProperties": false,
775
+ "properties": {
776
+ "data": {
777
+ "type": "string",
778
+ },
779
+ "type": {
780
+ "const": "success",
781
+ "type": "string",
782
+ },
783
+ },
784
+ "required": [
785
+ "type",
786
+ "data",
787
+ ],
788
+ "type": "object",
789
+ },
790
+ {
791
+ "additionalProperties": false,
792
+ "properties": {
793
+ "message": {
794
+ "type": "string",
795
+ },
796
+ "type": {
797
+ "const": "error",
798
+ "type": "string",
799
+ },
800
+ },
801
+ "required": [
802
+ "type",
803
+ "message",
804
+ ],
805
+ "type": "object",
806
+ },
807
+ ],
808
+ }
809
+ `);
810
+ });
811
+
812
+ test("intersections", () => {
813
+ const schema = z.intersection(z.object({ name: z.string() }), z.object({ age: z.number() }));
814
+
815
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
816
+ {
817
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
818
+ "allOf": [
819
+ {
820
+ "additionalProperties": false,
821
+ "properties": {
822
+ "name": {
823
+ "type": "string",
824
+ },
825
+ },
826
+ "required": [
827
+ "name",
828
+ ],
829
+ "type": "object",
830
+ },
831
+ {
832
+ "additionalProperties": false,
833
+ "properties": {
834
+ "age": {
835
+ "type": "number",
836
+ },
837
+ },
838
+ "required": [
839
+ "age",
840
+ ],
841
+ "type": "object",
842
+ },
843
+ ],
844
+ }
845
+ `);
846
+ });
847
+
848
+ test("record", () => {
849
+ const schema = z.record(z.string(), z.boolean());
850
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
851
+ {
852
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
853
+ "additionalProperties": {
854
+ "type": "boolean",
855
+ },
856
+ "propertyNames": {
857
+ "type": "string",
858
+ },
859
+ "type": "object",
860
+ }
861
+ `);
862
+ });
863
+
864
+ test("record openapi-3.0", () => {
865
+ const schema = z.record(z.string(), z.boolean());
866
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
867
+ validateOpenAPI30Schema(jsonSchema);
868
+ expect(jsonSchema).toMatchInlineSnapshot(`
869
+ {
870
+ "additionalProperties": {
871
+ "type": "boolean",
872
+ },
873
+ "type": "object",
874
+ }
875
+ `);
876
+ });
877
+
878
+ test("record with enum keys adds required", () => {
879
+ const schema = z.record(z.enum(["key1", "key2"]), z.number());
880
+
881
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
882
+ {
883
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
884
+ "additionalProperties": {
885
+ "type": "number",
886
+ },
887
+ "propertyNames": {
888
+ "enum": [
889
+ "key1",
890
+ "key2",
891
+ ],
892
+ "type": "string",
893
+ },
894
+ "required": [
895
+ "key1",
896
+ "key2",
897
+ ],
898
+ "type": "object",
899
+ }
900
+ `);
901
+ });
902
+
903
+ test("record filters enum values to strings and numbers for required", () => {
904
+ enum NumberEnum {
905
+ Zero = 0,
906
+ One = 1,
907
+ }
908
+ const schema = z.record(z.enum(NumberEnum), z.string());
909
+
910
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
911
+ {
912
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
913
+ "additionalProperties": {
914
+ "type": "string",
915
+ },
916
+ "propertyNames": {
917
+ "enum": [
918
+ 0,
919
+ 1,
920
+ ],
921
+ "type": "number",
922
+ },
923
+ "required": [
924
+ 0,
925
+ 1,
926
+ ],
927
+ "type": "object",
928
+ }
929
+ `);
930
+ });
931
+
932
+ test("strict record with regex key uses propertyNames", () => {
933
+ const schema = z.record(z.string().regex(/^label:[a-z]{2}$/), z.string());
934
+
935
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
936
+ {
937
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
938
+ "additionalProperties": {
939
+ "type": "string",
940
+ },
941
+ "propertyNames": {
942
+ "pattern": "^label:[a-z]{2}$",
943
+ "type": "string",
944
+ },
945
+ "type": "object",
946
+ }
947
+ `);
948
+ });
949
+
950
+ test("looseRecord with regex key uses patternProperties", () => {
951
+ const schema = z.looseRecord(z.string().regex(/^label:[a-z]{2}$/), z.string());
952
+
953
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
954
+ {
955
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
956
+ "patternProperties": {
957
+ "^label:[a-z]{2}$": {
958
+ "type": "string",
959
+ },
960
+ },
961
+ "type": "object",
962
+ }
963
+ `);
964
+ });
965
+
966
+ test("looseRecord with multiple regex patterns uses patternProperties", () => {
967
+ const schema = z.looseRecord(
968
+ z
969
+ .string()
970
+ .regex(/^prefix_/)
971
+ .regex(/_suffix$/),
972
+ z.number()
973
+ );
974
+
975
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
976
+ {
977
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
978
+ "patternProperties": {
979
+ "^prefix_": {
980
+ "type": "number",
981
+ },
982
+ "_suffix$": {
983
+ "type": "number",
984
+ },
985
+ },
986
+ "type": "object",
987
+ }
988
+ `);
989
+ });
990
+
991
+ test("looseRecord without regex key uses propertyNames", () => {
992
+ // looseRecord with plain string key should still use propertyNames
993
+ const schema = z.looseRecord(z.string(), z.boolean());
994
+
995
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
996
+ {
997
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
998
+ "additionalProperties": {
999
+ "type": "boolean",
1000
+ },
1001
+ "propertyNames": {
1002
+ "type": "string",
1003
+ },
1004
+ "type": "object",
1005
+ }
1006
+ `);
1007
+ });
1008
+
1009
+ test("intersection of object with looseRecord uses patternProperties", () => {
1010
+ const zLabeled = z.object({ label: z.string() });
1011
+ const zLocalizedLabeled = z.looseRecord(z.string().regex(/^label:[a-z]{2}$/), z.string());
1012
+ const schema = zLabeled.and(zLocalizedLabeled);
1013
+
1014
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1015
+ {
1016
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1017
+ "allOf": [
1018
+ {
1019
+ "additionalProperties": false,
1020
+ "properties": {
1021
+ "label": {
1022
+ "type": "string",
1023
+ },
1024
+ },
1025
+ "required": [
1026
+ "label",
1027
+ ],
1028
+ "type": "object",
1029
+ },
1030
+ {
1031
+ "patternProperties": {
1032
+ "^label:[a-z]{2}$": {
1033
+ "type": "string",
1034
+ },
1035
+ },
1036
+ "type": "object",
1037
+ },
1038
+ ],
1039
+ }
1040
+ `);
1041
+ });
1042
+
1043
+ test("tuple", () => {
1044
+ const schema = z.tuple([z.string(), z.number()]);
1045
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1046
+ {
1047
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1048
+ "prefixItems": [
1049
+ {
1050
+ "type": "string",
1051
+ },
1052
+ {
1053
+ "type": "number",
1054
+ },
1055
+ ],
1056
+ "type": "array",
1057
+ }
1058
+ `);
1059
+ });
1060
+
1061
+ test("tuple with rest", () => {
1062
+ const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
1063
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1064
+ {
1065
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1066
+ "items": {
1067
+ "type": "boolean",
1068
+ },
1069
+ "prefixItems": [
1070
+ {
1071
+ "type": "string",
1072
+ },
1073
+ {
1074
+ "type": "number",
1075
+ },
1076
+ ],
1077
+ "type": "array",
1078
+ }
1079
+ `);
1080
+ });
1081
+
1082
+ test("tuple openapi-3.0", () => {
1083
+ const schema = z.tuple([z.string(), z.number()]);
1084
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1085
+ validateOpenAPI30Schema(jsonSchema);
1086
+ expect(jsonSchema).toMatchInlineSnapshot(`
1087
+ {
1088
+ "items": {
1089
+ "anyOf": [
1090
+ {
1091
+ "type": "string",
1092
+ },
1093
+ {
1094
+ "type": "number",
1095
+ },
1096
+ ],
1097
+ },
1098
+ "maxItems": 2,
1099
+ "minItems": 2,
1100
+ "type": "array",
1101
+ }
1102
+ `);
1103
+ });
1104
+
1105
+ test("tuple with rest openapi-3.0", () => {
1106
+ const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
1107
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1108
+ validateOpenAPI30Schema(jsonSchema);
1109
+ expect(jsonSchema).toMatchInlineSnapshot(`
1110
+ {
1111
+ "items": {
1112
+ "anyOf": [
1113
+ {
1114
+ "type": "string",
1115
+ },
1116
+ {
1117
+ "type": "number",
1118
+ },
1119
+ {
1120
+ "type": "boolean",
1121
+ },
1122
+ ],
1123
+ },
1124
+ "minItems": 3,
1125
+ "type": "array",
1126
+ }
1127
+ `);
1128
+ });
1129
+
1130
+ test("tuple with null openapi-3.0", () => {
1131
+ const schema = z.tuple([z.string(), z.number(), z.null()]);
1132
+ const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1133
+ validateOpenAPI30Schema(jsonSchema);
1134
+ expect(jsonSchema).toMatchInlineSnapshot(`
1135
+ {
1136
+ "items": {
1137
+ "anyOf": [
1138
+ {
1139
+ "type": "string",
1140
+ },
1141
+ {
1142
+ "type": "number",
1143
+ },
1144
+ {
1145
+ "enum": [
1146
+ null,
1147
+ ],
1148
+ "nullable": true,
1149
+ "type": "string",
1150
+ },
1151
+ ],
1152
+ },
1153
+ "maxItems": 3,
1154
+ "minItems": 3,
1155
+ "type": "array",
1156
+ }
1157
+ `);
1158
+ });
1159
+
1160
+ test("tuple draft-7", () => {
1161
+ const schema = z.tuple([z.string(), z.number()]);
1162
+ expect(z.toJSONSchema(schema, { target: "draft-7", io: "input" })).toMatchInlineSnapshot(`
1163
+ {
1164
+ "$schema": "http://json-schema.org/draft-07/schema#",
1165
+ "items": [
1166
+ {
1167
+ "type": "string",
1168
+ },
1169
+ {
1170
+ "type": "number",
1171
+ },
1172
+ ],
1173
+ "type": "array",
1174
+ }
1175
+ `);
1176
+ });
1177
+
1178
+ test("tuple with rest draft-7", () => {
1179
+ const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
1180
+ expect(z.toJSONSchema(schema, { target: "draft-7", io: "input" })).toMatchInlineSnapshot(`
1181
+ {
1182
+ "$schema": "http://json-schema.org/draft-07/schema#",
1183
+ "additionalItems": {
1184
+ "type": "boolean",
1185
+ },
1186
+ "items": [
1187
+ {
1188
+ "type": "string",
1189
+ },
1190
+ {
1191
+ "type": "number",
1192
+ },
1193
+ ],
1194
+ "type": "array",
1195
+ }
1196
+ `);
1197
+ });
1198
+
1199
+ test("tuple with rest draft-7 - issue #5151 regression test", () => {
1200
+ // This test addresses issue #5151: tuple with rest elements and ids
1201
+ // in draft-7 had incorrect internal path handling affecting complex scenarios
1202
+ const primarySchema = z.string().meta({ id: "primary" });
1203
+ const restSchema = z.number().meta({ id: "rest" });
1204
+ const testSchema = z.tuple([primarySchema], restSchema);
1205
+
1206
+ // Test both final output structure AND internal path handling
1207
+ const capturedPaths: string[] = [];
1208
+ const result = z.toJSONSchema(testSchema, {
1209
+ target: "draft-7",
1210
+ override: (ctx) => capturedPaths.push(ctx.path.join("/")),
1211
+ });
1212
+
1213
+ // Verify correct draft-7 structure with metadata extraction
1214
+ expect(result).toMatchInlineSnapshot(`
1215
+ {
1216
+ "$schema": "http://json-schema.org/draft-07/schema#",
1217
+ "additionalItems": {
1218
+ "$ref": "#/definitions/rest",
1219
+ },
1220
+ "definitions": {
1221
+ "primary": {
1222
+ "id": "primary",
1223
+ "type": "string",
1224
+ },
1225
+ "rest": {
1226
+ "id": "rest",
1227
+ "type": "number",
1228
+ },
1229
+ },
1230
+ "items": [
1231
+ {
1232
+ "$ref": "#/definitions/primary",
1233
+ },
1234
+ ],
1235
+ "type": "array",
1236
+ }
1237
+ `);
1238
+
1239
+ // Verify internal paths are correct (this was the actual bug)
1240
+ expect(capturedPaths).toContain("items/0"); // prefix items should use "items" path
1241
+ expect(capturedPaths).toContain("additionalItems"); // rest should use "additionalItems" path
1242
+ expect(capturedPaths).not.toContain("prefixItems/0"); // should not use draft-2020-12 paths
1243
+
1244
+ // Structural validations
1245
+ expect(Array.isArray(result.items)).toBe(true);
1246
+ expect(result.additionalItems).toBeDefined();
1247
+ });
1248
+
1249
+ test("promise", () => {
1250
+ const schema = z.promise(z.string());
1251
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1252
+ {
1253
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1254
+ "type": "string",
1255
+ }
1256
+ `);
1257
+ });
1258
+
1259
+ test("lazy", () => {
1260
+ const schema = z.lazy(() => z.string());
1261
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1262
+ {
1263
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1264
+ "type": "string",
1265
+ }
1266
+ `);
1267
+ });
1268
+
1269
+ // enum
1270
+ test("enum", () => {
1271
+ const a = z.enum(["a", "b", "c"]);
1272
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1273
+ {
1274
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1275
+ "enum": [
1276
+ "a",
1277
+ "b",
1278
+ "c",
1279
+ ],
1280
+ "type": "string",
1281
+ }
1282
+ `);
1283
+
1284
+ enum B {
1285
+ A = 0,
1286
+ B = 1,
1287
+ C = 2,
1288
+ }
1289
+
1290
+ const b = z.enum(B);
1291
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1292
+ {
1293
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1294
+ "enum": [
1295
+ 0,
1296
+ 1,
1297
+ 2,
1298
+ ],
1299
+ "type": "number",
1300
+ }
1301
+ `);
1302
+ });
1303
+
1304
+ // literal
1305
+ test("literal", () => {
1306
+ const a = z.literal("hello");
1307
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1308
+ {
1309
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1310
+ "const": "hello",
1311
+ "type": "string",
1312
+ }
1313
+ `);
1314
+
1315
+ const b = z.literal(7);
1316
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1317
+ {
1318
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1319
+ "const": 7,
1320
+ "type": "number",
1321
+ }
1322
+ `);
1323
+
1324
+ const c = z.literal(["hello", undefined, null, 5, BigInt(1324)]);
1325
+ expect(() => z.toJSONSchema(c)).toThrow();
1326
+
1327
+ const d = z.literal(["hello", null, 5]);
1328
+ expect(z.toJSONSchema(d)).toMatchInlineSnapshot(`
1329
+ {
1330
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1331
+ "enum": [
1332
+ "hello",
1333
+ null,
1334
+ 5,
1335
+ ],
1336
+ }
1337
+ `);
1338
+
1339
+ const e = z.literal(["hello", "zod", "v4"]);
1340
+ expect(z.toJSONSchema(e)).toMatchInlineSnapshot(`
1341
+ {
1342
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1343
+ "enum": [
1344
+ "hello",
1345
+ "zod",
1346
+ "v4",
1347
+ ],
1348
+ "type": "string",
1349
+ }
1350
+ `);
1351
+ });
1352
+
1353
+ test("literal draft-4", () => {
1354
+ const a = z.literal("hello");
1355
+ expect(z.toJSONSchema(a, { target: "draft-4" })).toMatchInlineSnapshot(`
1356
+ {
1357
+ "$schema": "http://json-schema.org/draft-04/schema#",
1358
+ "enum": [
1359
+ "hello",
1360
+ ],
1361
+ "type": "string",
1362
+ }
1363
+ `);
1364
+ });
1365
+
1366
+ // pipe
1367
+ test("pipe", () => {
1368
+ const schema = z
1369
+ .string()
1370
+ .transform((val) => Number.parseInt(val))
1371
+ .pipe(z.number());
1372
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1373
+ {
1374
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1375
+ "type": "number",
1376
+ }
1377
+ `);
1378
+ });
1379
+
1380
+ test("simple objects", () => {
1381
+ const schema = z.object({
1382
+ name: z.string(),
1383
+ age: z.number(),
1384
+ });
1385
+
1386
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(
1387
+ `
1388
+ {
1389
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1390
+ "additionalProperties": false,
1391
+ "properties": {
1392
+ "age": {
1393
+ "type": "number",
1394
+ },
1395
+ "name": {
1396
+ "type": "string",
1397
+ },
1398
+ },
1399
+ "required": [
1400
+ "name",
1401
+ "age",
1402
+ ],
1403
+ "type": "object",
1404
+ }
1405
+ `
1406
+ );
1407
+ });
1408
+
1409
+ test("additionalproperties in z.object", () => {
1410
+ const a = z.object({
1411
+ name: z.string(),
1412
+ });
1413
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1414
+ {
1415
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1416
+ "additionalProperties": false,
1417
+ "properties": {
1418
+ "name": {
1419
+ "type": "string",
1420
+ },
1421
+ },
1422
+ "required": [
1423
+ "name",
1424
+ ],
1425
+ "type": "object",
1426
+ }
1427
+ `);
1428
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
1429
+ {
1430
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1431
+ "properties": {
1432
+ "name": {
1433
+ "type": "string",
1434
+ },
1435
+ },
1436
+ "required": [
1437
+ "name",
1438
+ ],
1439
+ "type": "object",
1440
+ }
1441
+ `);
1442
+ expect(
1443
+ z.toJSONSchema(a, {
1444
+ io: "input",
1445
+ override(ctx) {
1446
+ const def = ctx.zodSchema._zod.def;
1447
+ if (def.type === "object" && !def.catchall) {
1448
+ (ctx.jsonSchema as z.core.JSONSchema.ObjectSchema).additionalProperties = false;
1449
+ }
1450
+ },
1451
+ })
1452
+ ).toMatchInlineSnapshot(`
1453
+ {
1454
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1455
+ "additionalProperties": false,
1456
+ "properties": {
1457
+ "name": {
1458
+ "type": "string",
1459
+ },
1460
+ },
1461
+ "required": [
1462
+ "name",
1463
+ ],
1464
+ "type": "object",
1465
+ }
1466
+ `);
1467
+ });
1468
+
1469
+ test("catchall objects", () => {
1470
+ const a = z.strictObject({
1471
+ name: z.string(),
1472
+ age: z.number(),
1473
+ });
1474
+
1475
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1476
+ {
1477
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1478
+ "additionalProperties": false,
1479
+ "properties": {
1480
+ "age": {
1481
+ "type": "number",
1482
+ },
1483
+ "name": {
1484
+ "type": "string",
1485
+ },
1486
+ },
1487
+ "required": [
1488
+ "name",
1489
+ "age",
1490
+ ],
1491
+ "type": "object",
1492
+ }
1493
+ `);
1494
+
1495
+ const b = z
1496
+ .object({
1497
+ name: z.string(),
1498
+ })
1499
+ .catchall(z.string());
1500
+
1501
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1502
+ {
1503
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1504
+ "additionalProperties": {
1505
+ "type": "string",
1506
+ },
1507
+ "properties": {
1508
+ "name": {
1509
+ "type": "string",
1510
+ },
1511
+ },
1512
+ "required": [
1513
+ "name",
1514
+ ],
1515
+ "type": "object",
1516
+ }
1517
+ `);
1518
+
1519
+ const c = z.looseObject({
1520
+ name: z.string(),
1521
+ });
1522
+
1523
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1524
+ {
1525
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1526
+ "additionalProperties": {},
1527
+ "properties": {
1528
+ "name": {
1529
+ "type": "string",
1530
+ },
1531
+ },
1532
+ "required": [
1533
+ "name",
1534
+ ],
1535
+ "type": "object",
1536
+ }
1537
+ `);
1538
+ });
1539
+
1540
+ test("optional fields - object", () => {
1541
+ const schema = z.object({
1542
+ required: z.string(),
1543
+ optional: z.string().optional(),
1544
+ nonoptional: z.string().optional().nonoptional(),
1545
+ });
1546
+
1547
+ const result = z.toJSONSchema(schema);
1548
+
1549
+ expect(result).toMatchInlineSnapshot(`
1550
+ {
1551
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1552
+ "additionalProperties": false,
1553
+ "properties": {
1554
+ "nonoptional": {
1555
+ "type": "string",
1556
+ },
1557
+ "optional": {
1558
+ "type": "string",
1559
+ },
1560
+ "required": {
1561
+ "type": "string",
1562
+ },
1563
+ },
1564
+ "required": [
1565
+ "required",
1566
+ "nonoptional",
1567
+ ],
1568
+ "type": "object",
1569
+ }
1570
+ `);
1571
+ });
1572
+
1573
+ test("recursive object", () => {
1574
+ interface Category {
1575
+ name: string;
1576
+ subcategories: Category[];
1577
+ }
1578
+
1579
+ const categorySchema: z.ZodType<Category> = z.object({
1580
+ name: z.string(),
1581
+ subcategories: z.array(z.lazy(() => categorySchema)),
1582
+ });
1583
+
1584
+ const result = z.toJSONSchema(categorySchema);
1585
+ expect(result).toMatchInlineSnapshot(`
1586
+ {
1587
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1588
+ "additionalProperties": false,
1589
+ "properties": {
1590
+ "name": {
1591
+ "type": "string",
1592
+ },
1593
+ "subcategories": {
1594
+ "items": {
1595
+ "$ref": "#",
1596
+ },
1597
+ "type": "array",
1598
+ },
1599
+ },
1600
+ "required": [
1601
+ "name",
1602
+ "subcategories",
1603
+ ],
1604
+ "type": "object",
1605
+ }
1606
+ `);
1607
+ });
1608
+
1609
+ test("simple interface", () => {
1610
+ const userSchema = z.object({
1611
+ name: z.string(),
1612
+ age: z.number().optional(),
1613
+ });
1614
+
1615
+ const result = z.toJSONSchema(userSchema);
1616
+ expect(result).toMatchInlineSnapshot(`
1617
+ {
1618
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1619
+ "additionalProperties": false,
1620
+ "properties": {
1621
+ "age": {
1622
+ "type": "number",
1623
+ },
1624
+ "name": {
1625
+ "type": "string",
1626
+ },
1627
+ },
1628
+ "required": [
1629
+ "name",
1630
+ ],
1631
+ "type": "object",
1632
+ }
1633
+ `);
1634
+ });
1635
+
1636
+ test("catchall interface", () => {
1637
+ const a = z.strictObject({
1638
+ name: z.string(),
1639
+ age: z.number(),
1640
+ });
1641
+
1642
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1643
+ {
1644
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1645
+ "additionalProperties": false,
1646
+ "properties": {
1647
+ "age": {
1648
+ "type": "number",
1649
+ },
1650
+ "name": {
1651
+ "type": "string",
1652
+ },
1653
+ },
1654
+ "required": [
1655
+ "name",
1656
+ "age",
1657
+ ],
1658
+ "type": "object",
1659
+ }
1660
+ `);
1661
+
1662
+ const b = z
1663
+ .object({
1664
+ name: z.string(),
1665
+ })
1666
+ .catchall(z.string());
1667
+
1668
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1669
+ {
1670
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1671
+ "additionalProperties": {
1672
+ "type": "string",
1673
+ },
1674
+ "properties": {
1675
+ "name": {
1676
+ "type": "string",
1677
+ },
1678
+ },
1679
+ "required": [
1680
+ "name",
1681
+ ],
1682
+ "type": "object",
1683
+ }
1684
+ `);
1685
+
1686
+ const c = z.looseObject({
1687
+ name: z.string(),
1688
+ });
1689
+
1690
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1691
+ {
1692
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1693
+ "additionalProperties": {},
1694
+ "properties": {
1695
+ "name": {
1696
+ "type": "string",
1697
+ },
1698
+ },
1699
+ "required": [
1700
+ "name",
1701
+ ],
1702
+ "type": "object",
1703
+ }
1704
+ `);
1705
+ });
1706
+
1707
+ test("recursive interface schemas", () => {
1708
+ const TreeNodeSchema = z.object({
1709
+ id: z.string(),
1710
+ get children() {
1711
+ return TreeNodeSchema;
1712
+ },
1713
+ });
1714
+
1715
+ const result = z.toJSONSchema(TreeNodeSchema);
1716
+
1717
+ // Should have definitions for recursive schema
1718
+ expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
1719
+ `
1720
+ "{
1721
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1722
+ "type": "object",
1723
+ "properties": {
1724
+ "id": {
1725
+ "type": "string"
1726
+ },
1727
+ "children": {
1728
+ "$ref": "#"
1729
+ }
1730
+ },
1731
+ "required": [
1732
+ "id",
1733
+ "children"
1734
+ ],
1735
+ "additionalProperties": false
1736
+ }"
1737
+ `
1738
+ );
1739
+ });
1740
+
1741
+ test("mutually recursive interface schemas", () => {
1742
+ const FolderSchema = z.object({
1743
+ name: z.string(),
1744
+ get files() {
1745
+ return z.array(FileSchema);
1746
+ },
1747
+ });
1748
+
1749
+ const FileSchema = z.object({
1750
+ name: z.string(),
1751
+ get parent() {
1752
+ return FolderSchema;
1753
+ },
1754
+ });
1755
+
1756
+ const result = z.toJSONSchema(FolderSchema);
1757
+
1758
+ // Should have definitions for both schemas
1759
+ expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
1760
+ `
1761
+ "{
1762
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1763
+ "type": "object",
1764
+ "properties": {
1765
+ "name": {
1766
+ "type": "string"
1767
+ },
1768
+ "files": {
1769
+ "type": "array",
1770
+ "items": {
1771
+ "type": "object",
1772
+ "properties": {
1773
+ "name": {
1774
+ "type": "string"
1775
+ },
1776
+ "parent": {
1777
+ "$ref": "#"
1778
+ }
1779
+ },
1780
+ "required": [
1781
+ "name",
1782
+ "parent"
1783
+ ],
1784
+ "additionalProperties": false
1785
+ }
1786
+ }
1787
+ },
1788
+ "required": [
1789
+ "name",
1790
+ "files"
1791
+ ],
1792
+ "additionalProperties": false
1793
+ }"
1794
+ `
1795
+ );
1796
+ });
1797
+ });
1798
+
1799
+ test("override", () => {
1800
+ const schema = z.toJSONSchema(z.string(), {
1801
+ override: (ctx) => {
1802
+ ctx.zodSchema;
1803
+ ctx.jsonSchema;
1804
+ ctx.jsonSchema.whatever = "sup";
1805
+ },
1806
+ });
1807
+ expect(schema).toMatchInlineSnapshot(`
1808
+ {
1809
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1810
+ "type": "string",
1811
+ "whatever": "sup",
1812
+ }
1813
+ `);
1814
+ });
1815
+
1816
+ test("override: do not run on references", () => {
1817
+ let overrideCount = 0;
1818
+ const schema = z
1819
+ .union([z.string().date(), z.string().datetime(), z.string().datetime({ local: true })])
1820
+ .meta({ a: true })
1821
+ .transform((str) => new Date(str))
1822
+ .meta({ b: true })
1823
+ .pipe(z.date())
1824
+ .meta({ c: true })
1825
+ .brand("dateIn");
1826
+ z.toJSONSchema(schema, {
1827
+ unrepresentable: "any",
1828
+ io: "input",
1829
+ override(_) {
1830
+ overrideCount++;
1831
+ },
1832
+ });
1833
+
1834
+ expect(overrideCount).toBe(12);
1835
+ });
1836
+
1837
+ test("override with refs", () => {
1838
+ const a = z.string().optional();
1839
+ const result = z.toJSONSchema(a, {
1840
+ override(ctx) {
1841
+ if (ctx.zodSchema._zod.def.type === "string") {
1842
+ ctx.jsonSchema.type = "STRING" as "string";
1843
+ }
1844
+ },
1845
+ });
1846
+
1847
+ expect(result).toMatchInlineSnapshot(`
1848
+ {
1849
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1850
+ "type": "STRING",
1851
+ }
1852
+ `);
1853
+ });
1854
+
1855
+ test("override execution order", () => {
1856
+ const schema = z.union([z.string(), z.number()]);
1857
+ let unionSchema!: any;
1858
+ z.toJSONSchema(schema, {
1859
+ override(ctx) {
1860
+ if (ctx.zodSchema._zod.def.type === "union") {
1861
+ unionSchema = ctx.jsonSchema;
1862
+ }
1863
+ },
1864
+ });
1865
+
1866
+ expect(unionSchema).toMatchInlineSnapshot(`
1867
+ {
1868
+ "anyOf": [
1869
+ {
1870
+ "type": "string",
1871
+ },
1872
+ {
1873
+ "type": "number",
1874
+ },
1875
+ ],
1876
+ }
1877
+ `);
1878
+ });
1879
+
1880
+ test("override with path", () => {
1881
+ const userSchema = z.object({
1882
+ name: z.string(),
1883
+ age: z.number(),
1884
+ });
1885
+
1886
+ const capturedPaths: (string | number)[][] = [];
1887
+
1888
+ z.toJSONSchema(userSchema, {
1889
+ override(ctx) {
1890
+ capturedPaths.push(ctx.path);
1891
+ },
1892
+ });
1893
+
1894
+ expect(capturedPaths).toMatchInlineSnapshot(`
1895
+ [
1896
+ [
1897
+ "properties",
1898
+ "age",
1899
+ ],
1900
+ [
1901
+ "properties",
1902
+ "name",
1903
+ ],
1904
+ [],
1905
+ ]
1906
+ `);
1907
+ });
1908
+
1909
+ test("pipe", () => {
1910
+ const mySchema = z
1911
+ .string()
1912
+ .transform((val) => val.length)
1913
+ .pipe(z.number());
1914
+ // ZodPipe
1915
+
1916
+ const a = z.toJSONSchema(mySchema);
1917
+ expect(a).toMatchInlineSnapshot(`
1918
+ {
1919
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1920
+ "type": "number",
1921
+ }
1922
+ `);
1923
+ // => { type: "number" }
1924
+
1925
+ const b = z.toJSONSchema(mySchema, { io: "input" });
1926
+ expect(b).toMatchInlineSnapshot(`
1927
+ {
1928
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1929
+ "type": "string",
1930
+ }
1931
+ `);
1932
+ // => { type: "string" }
1933
+ });
1934
+
1935
+ test("passthrough schemas", () => {
1936
+ const Internal = z.object({
1937
+ num: z.number(),
1938
+ str: z.string(),
1939
+ });
1940
+ //.meta({ id: "Internal" });
1941
+
1942
+ const External = z.object({
1943
+ a: Internal,
1944
+ b: Internal.optional(),
1945
+ c: z.lazy(() => Internal),
1946
+ d: z.promise(Internal),
1947
+ e: z.pipe(Internal, Internal),
1948
+ });
1949
+
1950
+ const result = z.toJSONSchema(External, {
1951
+ reused: "ref",
1952
+ });
1953
+ expect(result).toMatchInlineSnapshot(`
1954
+ {
1955
+ "$defs": {
1956
+ "__schema0": {
1957
+ "additionalProperties": false,
1958
+ "properties": {
1959
+ "num": {
1960
+ "type": "number",
1961
+ },
1962
+ "str": {
1963
+ "type": "string",
1964
+ },
1965
+ },
1966
+ "required": [
1967
+ "num",
1968
+ "str",
1969
+ ],
1970
+ "type": "object",
1971
+ },
1972
+ },
1973
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1974
+ "additionalProperties": false,
1975
+ "properties": {
1976
+ "a": {
1977
+ "$ref": "#/$defs/__schema0",
1978
+ },
1979
+ "b": {
1980
+ "$ref": "#/$defs/__schema0",
1981
+ },
1982
+ "c": {
1983
+ "$ref": "#/$defs/__schema0",
1984
+ },
1985
+ "d": {
1986
+ "$ref": "#/$defs/__schema0",
1987
+ },
1988
+ "e": {
1989
+ "$ref": "#/$defs/__schema0",
1990
+ },
1991
+ },
1992
+ "required": [
1993
+ "a",
1994
+ "c",
1995
+ "d",
1996
+ "e",
1997
+ ],
1998
+ "type": "object",
1999
+ }
2000
+ `);
2001
+ });
2002
+
2003
+ test("extract schemas with id", () => {
2004
+ const name = z.string().meta({ id: "name" });
2005
+ const result = z.toJSONSchema(
2006
+ z.object({
2007
+ first_name: name,
2008
+ last_name: name.nullable(),
2009
+ middle_name: name.optional(),
2010
+ age: z.number().meta({ id: "age" }),
2011
+ })
2012
+ );
2013
+ expect(result).toMatchInlineSnapshot(`
2014
+ {
2015
+ "$defs": {
2016
+ "age": {
2017
+ "id": "age",
2018
+ "type": "number",
2019
+ },
2020
+ "name": {
2021
+ "id": "name",
2022
+ "type": "string",
2023
+ },
2024
+ },
2025
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2026
+ "additionalProperties": false,
2027
+ "properties": {
2028
+ "age": {
2029
+ "$ref": "#/$defs/age",
2030
+ },
2031
+ "first_name": {
2032
+ "$ref": "#/$defs/name",
2033
+ },
2034
+ "last_name": {
2035
+ "anyOf": [
2036
+ {
2037
+ "$ref": "#/$defs/name",
2038
+ },
2039
+ {
2040
+ "type": "null",
2041
+ },
2042
+ ],
2043
+ },
2044
+ "middle_name": {
2045
+ "$ref": "#/$defs/name",
2046
+ },
2047
+ },
2048
+ "required": [
2049
+ "first_name",
2050
+ "last_name",
2051
+ "age",
2052
+ ],
2053
+ "type": "object",
2054
+ }
2055
+ `);
2056
+ });
2057
+
2058
+ test("unrepresentable literal values are ignored", () => {
2059
+ const a = z.toJSONSchema(z.literal(["hello", null, 5, BigInt(1324), undefined]), { unrepresentable: "any" });
2060
+ expect(a).toMatchInlineSnapshot(`
2061
+ {
2062
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2063
+ "enum": [
2064
+ "hello",
2065
+ null,
2066
+ 5,
2067
+ 1324,
2068
+ ],
2069
+ }
2070
+ `);
2071
+
2072
+ const b = z.toJSONSchema(z.literal([undefined, null, 5, BigInt(1324)]), {
2073
+ unrepresentable: "any",
2074
+ });
2075
+ expect(b).toMatchInlineSnapshot(`
2076
+ {
2077
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2078
+ "enum": [
2079
+ null,
2080
+ 5,
2081
+ 1324,
2082
+ ],
2083
+ }
2084
+ `);
2085
+
2086
+ const c = z.toJSONSchema(z.literal([undefined]), {
2087
+ unrepresentable: "any",
2088
+ });
2089
+ expect(c).toMatchInlineSnapshot(`
2090
+ {
2091
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2092
+ }
2093
+ `);
2094
+ });
2095
+
2096
+ test("describe with id", () => {
2097
+ const jobId = z.string().meta({ id: "jobId" });
2098
+
2099
+ const a = z.toJSONSchema(
2100
+ z.object({
2101
+ current: jobId.describe("Current job"),
2102
+ previous: jobId.describe("Previous job"),
2103
+ })
2104
+ );
2105
+ expect(a).toMatchInlineSnapshot(`
2106
+ {
2107
+ "$defs": {
2108
+ "jobId": {
2109
+ "id": "jobId",
2110
+ "type": "string",
2111
+ },
2112
+ },
2113
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2114
+ "additionalProperties": false,
2115
+ "properties": {
2116
+ "current": {
2117
+ "$ref": "#/$defs/jobId",
2118
+ "description": "Current job",
2119
+ },
2120
+ "previous": {
2121
+ "$ref": "#/$defs/jobId",
2122
+ "description": "Previous job",
2123
+ },
2124
+ },
2125
+ "required": [
2126
+ "current",
2127
+ "previous",
2128
+ ],
2129
+ "type": "object",
2130
+ }
2131
+ `);
2132
+ });
2133
+
2134
+ test("describe with id on wrapper", () => {
2135
+ // Test that $ref propagation works when processor sets a different ref (readonly -> innerType)
2136
+ // but parent was extracted due to having an id
2137
+ const roJobId = z.string().readonly().meta({ id: "roJobId" });
2138
+
2139
+ const a = z.toJSONSchema(
2140
+ z.object({
2141
+ current: roJobId.describe("Current readonly job"),
2142
+ previous: roJobId.describe("Previous readonly job"),
2143
+ })
2144
+ );
2145
+ expect(a).toMatchInlineSnapshot(`
2146
+ {
2147
+ "$defs": {
2148
+ "roJobId": {
2149
+ "id": "roJobId",
2150
+ "readOnly": true,
2151
+ "type": "string",
2152
+ },
2153
+ },
2154
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2155
+ "additionalProperties": false,
2156
+ "properties": {
2157
+ "current": {
2158
+ "$ref": "#/$defs/roJobId",
2159
+ "description": "Current readonly job",
2160
+ },
2161
+ "previous": {
2162
+ "$ref": "#/$defs/roJobId",
2163
+ "description": "Previous readonly job",
2164
+ },
2165
+ },
2166
+ "required": [
2167
+ "current",
2168
+ "previous",
2169
+ ],
2170
+ "type": "object",
2171
+ }
2172
+ `);
2173
+ });
2174
+
2175
+ test("overwrite id", () => {
2176
+ const jobId = z.string().meta({ id: "aaa" });
2177
+
2178
+ const a = z.toJSONSchema(
2179
+ z.object({
2180
+ current: jobId,
2181
+ previous: jobId.meta({ id: "bbb" }),
2182
+ })
2183
+ );
2184
+ expect(a).toMatchInlineSnapshot(`
2185
+ {
2186
+ "$defs": {
2187
+ "aaa": {
2188
+ "id": "aaa",
2189
+ "type": "string",
2190
+ },
2191
+ "bbb": {
2192
+ "$ref": "#/$defs/aaa",
2193
+ "id": "bbb",
2194
+ },
2195
+ },
2196
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2197
+ "additionalProperties": false,
2198
+ "properties": {
2199
+ "current": {
2200
+ "$ref": "#/$defs/aaa",
2201
+ },
2202
+ "previous": {
2203
+ "$ref": "#/$defs/bbb",
2204
+ },
2205
+ },
2206
+ "required": [
2207
+ "current",
2208
+ "previous",
2209
+ ],
2210
+ "type": "object",
2211
+ }
2212
+ `);
2213
+
2214
+ const b = z.toJSONSchema(
2215
+ z.object({
2216
+ current: jobId,
2217
+ previous: jobId.meta({ id: "ccc" }),
2218
+ }),
2219
+ {
2220
+ reused: "ref",
2221
+ }
2222
+ );
2223
+ expect(b).toMatchInlineSnapshot(`
2224
+ {
2225
+ "$defs": {
2226
+ "aaa": {
2227
+ "id": "aaa",
2228
+ "type": "string",
2229
+ },
2230
+ "ccc": {
2231
+ "$ref": "#/$defs/aaa",
2232
+ "id": "ccc",
2233
+ },
2234
+ },
2235
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2236
+ "additionalProperties": false,
2237
+ "properties": {
2238
+ "current": {
2239
+ "$ref": "#/$defs/aaa",
2240
+ },
2241
+ "previous": {
2242
+ "$ref": "#/$defs/ccc",
2243
+ },
2244
+ },
2245
+ "required": [
2246
+ "current",
2247
+ "previous",
2248
+ ],
2249
+ "type": "object",
2250
+ }
2251
+ `);
2252
+ });
2253
+
2254
+ test("overwrite descriptions", () => {
2255
+ const field = z.string().describe("a").describe("b").describe("c");
2256
+
2257
+ const a = z.toJSONSchema(
2258
+ z.object({
2259
+ d: field.describe("d"),
2260
+ e: field.describe("e"),
2261
+ })
2262
+ );
2263
+ expect(a).toMatchInlineSnapshot(`
2264
+ {
2265
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2266
+ "additionalProperties": false,
2267
+ "properties": {
2268
+ "d": {
2269
+ "description": "d",
2270
+ "type": "string",
2271
+ },
2272
+ "e": {
2273
+ "description": "e",
2274
+ "type": "string",
2275
+ },
2276
+ },
2277
+ "required": [
2278
+ "d",
2279
+ "e",
2280
+ ],
2281
+ "type": "object",
2282
+ }
2283
+ `);
2284
+
2285
+ const b = z.toJSONSchema(
2286
+ z.object({
2287
+ d: field.describe("d"),
2288
+ e: field.describe("e"),
2289
+ }),
2290
+ {
2291
+ reused: "ref",
2292
+ }
2293
+ );
2294
+ expect(b).toMatchInlineSnapshot(`
2295
+ {
2296
+ "$defs": {
2297
+ "__schema0": {
2298
+ "description": "c",
2299
+ "type": "string",
2300
+ },
2301
+ },
2302
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2303
+ "additionalProperties": false,
2304
+ "properties": {
2305
+ "d": {
2306
+ "$ref": "#/$defs/__schema0",
2307
+ "description": "d",
2308
+ },
2309
+ "e": {
2310
+ "$ref": "#/$defs/__schema0",
2311
+ "description": "e",
2312
+ },
2313
+ },
2314
+ "required": [
2315
+ "d",
2316
+ "e",
2317
+ ],
2318
+ "type": "object",
2319
+ }
2320
+ `);
2321
+ });
2322
+
2323
+ test("top-level readonly", () => {
2324
+ const A = z
2325
+ .object({
2326
+ name: z.string(),
2327
+ get b() {
2328
+ return B;
2329
+ },
2330
+ })
2331
+ .readonly()
2332
+ .meta({ id: "A" });
2333
+ // z.globalRegistry.add(A, { id: "A" });
2334
+ // .meta({ id: "A" });
2335
+
2336
+ const B = z
2337
+ .object({
2338
+ name: z.string(),
2339
+ get a() {
2340
+ return A;
2341
+ },
2342
+ })
2343
+ .readonly()
2344
+ .meta({ id: "B" });
2345
+ // z.globalRegistry.add(B, { id: "B" });
2346
+ // .meta({ id: "B" });
2347
+
2348
+ const result = z.toJSONSchema(A);
2349
+ expect(result).toMatchInlineSnapshot(`
2350
+ {
2351
+ "$defs": {
2352
+ "B": {
2353
+ "additionalProperties": false,
2354
+ "id": "B",
2355
+ "properties": {
2356
+ "a": {
2357
+ "$ref": "#",
2358
+ },
2359
+ "name": {
2360
+ "type": "string",
2361
+ },
2362
+ },
2363
+ "readOnly": true,
2364
+ "required": [
2365
+ "name",
2366
+ "a",
2367
+ ],
2368
+ "type": "object",
2369
+ },
2370
+ },
2371
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2372
+ "additionalProperties": false,
2373
+ "id": "A",
2374
+ "properties": {
2375
+ "b": {
2376
+ "$ref": "#/$defs/B",
2377
+ },
2378
+ "name": {
2379
+ "type": "string",
2380
+ },
2381
+ },
2382
+ "readOnly": true,
2383
+ "required": [
2384
+ "name",
2385
+ "b",
2386
+ ],
2387
+ "type": "object",
2388
+ }
2389
+ `);
2390
+ });
2391
+
2392
+ test("basic registry", () => {
2393
+ const myRegistry = z.registry<{ id: string }>();
2394
+ const User = z.object({
2395
+ name: z.string(),
2396
+ get posts() {
2397
+ return z.array(Post);
2398
+ },
2399
+ });
2400
+
2401
+ const Post = z.object({
2402
+ title: z.string(),
2403
+ content: z.string(),
2404
+ get author() {
2405
+ return User;
2406
+ },
2407
+ });
2408
+
2409
+ myRegistry.add(User, { id: "User" });
2410
+ myRegistry.add(Post, { id: "Post" });
2411
+
2412
+ const result = z.toJSONSchema(myRegistry, {
2413
+ uri: (id) => `https://example.com/${id}.json`,
2414
+ });
2415
+ expect(result).toMatchInlineSnapshot(`
2416
+ {
2417
+ "schemas": {
2418
+ "Post": {
2419
+ "$id": "https://example.com/Post.json",
2420
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2421
+ "additionalProperties": false,
2422
+ "properties": {
2423
+ "author": {
2424
+ "$ref": "https://example.com/User.json",
2425
+ },
2426
+ "content": {
2427
+ "type": "string",
2428
+ },
2429
+ "title": {
2430
+ "type": "string",
2431
+ },
2432
+ },
2433
+ "required": [
2434
+ "title",
2435
+ "content",
2436
+ "author",
2437
+ ],
2438
+ "type": "object",
2439
+ },
2440
+ "User": {
2441
+ "$id": "https://example.com/User.json",
2442
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2443
+ "additionalProperties": false,
2444
+ "properties": {
2445
+ "name": {
2446
+ "type": "string",
2447
+ },
2448
+ "posts": {
2449
+ "items": {
2450
+ "$ref": "https://example.com/Post.json",
2451
+ },
2452
+ "type": "array",
2453
+ },
2454
+ },
2455
+ "required": [
2456
+ "name",
2457
+ "posts",
2458
+ ],
2459
+ "type": "object",
2460
+ },
2461
+ },
2462
+ }
2463
+ `);
2464
+ });
2465
+
2466
+ test("_ref", () => {
2467
+ // const a = z.promise(z.string().describe("a"));
2468
+ const a = z.toJSONSchema(z.promise(z.string().describe("a")));
2469
+ expect(a).toMatchInlineSnapshot(`
2470
+ {
2471
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2472
+ "description": "a",
2473
+ "type": "string",
2474
+ }
2475
+ `);
2476
+
2477
+ const b = z.toJSONSchema(z.lazy(() => z.string().describe("a")));
2478
+ expect(b).toMatchInlineSnapshot(`
2479
+ {
2480
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2481
+ "description": "a",
2482
+ "type": "string",
2483
+ }
2484
+ `);
2485
+
2486
+ const c = z.toJSONSchema(z.optional(z.string().describe("a")));
2487
+ expect(c).toMatchInlineSnapshot(`
2488
+ {
2489
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2490
+ "description": "a",
2491
+ "type": "string",
2492
+ }
2493
+ `);
2494
+ });
2495
+
2496
+ test("defaults/prefaults", () => {
2497
+ const a = z
2498
+ .string()
2499
+ .transform((val) => val.length)
2500
+ .pipe(z.number());
2501
+ const b = a.prefault("hello");
2502
+ const c = a.default(1234);
2503
+
2504
+ // a
2505
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
2506
+ {
2507
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2508
+ "type": "number",
2509
+ }
2510
+ `);
2511
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
2512
+ {
2513
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2514
+ "type": "string",
2515
+ }
2516
+ `);
2517
+
2518
+ // b
2519
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
2520
+ {
2521
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2522
+ "type": "number",
2523
+ }
2524
+ `);
2525
+ expect(z.toJSONSchema(b, { io: "input" })).toMatchInlineSnapshot(`
2526
+ {
2527
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2528
+ "default": "hello",
2529
+ "type": "string",
2530
+ }
2531
+ `);
2532
+ // c
2533
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
2534
+ {
2535
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2536
+ "default": 1234,
2537
+ "type": "number",
2538
+ }
2539
+ `);
2540
+ expect(z.toJSONSchema(c, { io: "input" })).toMatchInlineSnapshot(`
2541
+ {
2542
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2543
+ "type": "string",
2544
+ }
2545
+ `);
2546
+ });
2547
+
2548
+ test("input type", () => {
2549
+ const schema = z.object({
2550
+ a: z.string(),
2551
+ b: z.string().optional(),
2552
+ c: z.string().default("hello"),
2553
+ d: z.string().nullable(),
2554
+ e: z.string().prefault("hello"),
2555
+ f: z.string().catch("hello"),
2556
+ g: z.never(),
2557
+ h: z.union([z.string(), z.number().default(2)]),
2558
+ i: z.union([z.string(), z.string().optional()]),
2559
+ });
2560
+ expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
2561
+ {
2562
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2563
+ "properties": {
2564
+ "a": {
2565
+ "type": "string",
2566
+ },
2567
+ "b": {
2568
+ "type": "string",
2569
+ },
2570
+ "c": {
2571
+ "default": "hello",
2572
+ "type": "string",
2573
+ },
2574
+ "d": {
2575
+ "anyOf": [
2576
+ {
2577
+ "type": "string",
2578
+ },
2579
+ {
2580
+ "type": "null",
2581
+ },
2582
+ ],
2583
+ },
2584
+ "e": {
2585
+ "default": "hello",
2586
+ "type": "string",
2587
+ },
2588
+ "f": {
2589
+ "default": "hello",
2590
+ "type": "string",
2591
+ },
2592
+ "g": {
2593
+ "not": {},
2594
+ },
2595
+ "h": {
2596
+ "anyOf": [
2597
+ {
2598
+ "type": "string",
2599
+ },
2600
+ {
2601
+ "default": 2,
2602
+ "type": "number",
2603
+ },
2604
+ ],
2605
+ },
2606
+ "i": {
2607
+ "anyOf": [
2608
+ {
2609
+ "type": "string",
2610
+ },
2611
+ {
2612
+ "type": "string",
2613
+ },
2614
+ ],
2615
+ },
2616
+ },
2617
+ "required": [
2618
+ "a",
2619
+ "d",
2620
+ "f",
2621
+ "g",
2622
+ ],
2623
+ "type": "object",
2624
+ }
2625
+ `);
2626
+ expect(z.toJSONSchema(schema, { io: "output" })).toMatchInlineSnapshot(`
2627
+ {
2628
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2629
+ "additionalProperties": false,
2630
+ "properties": {
2631
+ "a": {
2632
+ "type": "string",
2633
+ },
2634
+ "b": {
2635
+ "type": "string",
2636
+ },
2637
+ "c": {
2638
+ "default": "hello",
2639
+ "type": "string",
2640
+ },
2641
+ "d": {
2642
+ "anyOf": [
2643
+ {
2644
+ "type": "string",
2645
+ },
2646
+ {
2647
+ "type": "null",
2648
+ },
2649
+ ],
2650
+ },
2651
+ "e": {
2652
+ "type": "string",
2653
+ },
2654
+ "f": {
2655
+ "default": "hello",
2656
+ "type": "string",
2657
+ },
2658
+ "g": {
2659
+ "not": {},
2660
+ },
2661
+ "h": {
2662
+ "anyOf": [
2663
+ {
2664
+ "type": "string",
2665
+ },
2666
+ {
2667
+ "default": 2,
2668
+ "type": "number",
2669
+ },
2670
+ ],
2671
+ },
2672
+ "i": {
2673
+ "anyOf": [
2674
+ {
2675
+ "type": "string",
2676
+ },
2677
+ {
2678
+ "type": "string",
2679
+ },
2680
+ ],
2681
+ },
2682
+ },
2683
+ "required": [
2684
+ "a",
2685
+ "c",
2686
+ "d",
2687
+ "e",
2688
+ "f",
2689
+ "g",
2690
+ "h",
2691
+ ],
2692
+ "type": "object",
2693
+ }
2694
+ `);
2695
+ });
2696
+
2697
+ test("examples on pipe", () => {
2698
+ const schema = z
2699
+ .string()
2700
+ .meta({ examples: ["test"] })
2701
+ .transform(Number)
2702
+ // .pipe(z.transform(Number).meta({ examples: [4] }))
2703
+ .meta({ examples: [4] });
2704
+
2705
+ const i = z.toJSONSchema(schema, { io: "input", unrepresentable: "any" });
2706
+ expect(i).toMatchInlineSnapshot(`
2707
+ {
2708
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2709
+ "examples": [
2710
+ "test",
2711
+ ],
2712
+ "type": "string",
2713
+ }
2714
+ `);
2715
+ const o = z.toJSONSchema(schema, { io: "output", unrepresentable: "any" });
2716
+ expect(o).toMatchInlineSnapshot(`
2717
+ {
2718
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2719
+ "examples": [
2720
+ 4,
2721
+ ],
2722
+ }
2723
+ `);
2724
+ });
2725
+
2726
+ // test("number checks", () => {
2727
+ // expect(z.toJSONSchema(z.number().int())).toMatchInlineSnapshot(`
2728
+ // {
2729
+ // "maximum": 9007199254740991,
2730
+ // "minimum": -9007199254740991,
2731
+ // "type": "integer",
2732
+ // }
2733
+ // `);
2734
+ // expect(z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
2735
+ // {
2736
+ // "maximum": 9007199254740991,
2737
+ // "minimum": -9007199254740991,
2738
+ // "type": "integer",
2739
+ // }
2740
+ // `);
2741
+ // expect(z.toJSONSchema(z.int().positive())).toMatchInlineSnapshot(`
2742
+ // {
2743
+ // "exclusiveMinimum": 0,
2744
+ // "maximum": 9007199254740991,
2745
+ // "minimum": -9007199254740991,
2746
+ // "type": "integer",
2747
+ // }
2748
+ // `);
2749
+ // expect(z.toJSONSchema(z.int().nonnegative())).toMatchInlineSnapshot(`
2750
+ // {
2751
+ // "maximum": 9007199254740991,
2752
+ // "minimum": 0,
2753
+ // "type": "integer",
2754
+ // }
2755
+ // `);
2756
+ // expect(z.toJSONSchema(z.int().gt(0))).toMatchInlineSnapshot(`
2757
+ // {
2758
+ // "exclusiveMinimum": 0,
2759
+ // "maximum": 9007199254740991,
2760
+ // "minimum": -9007199254740991,
2761
+ // "type": "integer",
2762
+ // }
2763
+ // `);
2764
+ // expect(z.toJSONSchema(z.int().gte(0))).toMatchInlineSnapshot(`
2765
+ // {
2766
+ // "maximum": 9007199254740991,
2767
+ // "minimum": 0,
2768
+ // "type": "integer",
2769
+ // }
2770
+ // `);
2771
+
2772
+ // });
2773
+
2774
+ test("use output type for preprocess", () => {
2775
+ const a = z.preprocess((val) => String(val), z.string());
2776
+
2777
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
2778
+ {
2779
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2780
+ "type": "string",
2781
+ }
2782
+ `);
2783
+ });
2784
+
2785
+ // test("isTransforming", () => {
2786
+ // const tx = z.core.isTransforming;
2787
+ // expect(tx(z.string())).toEqual(false);
2788
+ // expect(tx(z.string().transform((val) => val))).toEqual(true);
2789
+ // expect(tx(z.string().pipe(z.string()))).toEqual(false);
2790
+ // expect(
2791
+ // tx(
2792
+ // z
2793
+ // .string()
2794
+ // .transform((val) => val)
2795
+ // .pipe(z.string())
2796
+ // )
2797
+ // ).toEqual(true);
2798
+
2799
+ // const a = z.transform((val) => val);
2800
+ // expect(tx(z.transform((val) => val))).toEqual(true);
2801
+ // expect(tx(a.optional())).toEqual(true);
2802
+
2803
+ // const b = z.string().optional();
2804
+ // expect(tx(b)).toEqual(false);
2805
+
2806
+ // const c = z.string().prefault("hello");
2807
+ // expect(tx(c)).toEqual(false);
2808
+
2809
+ // const d = z.string().default("hello");
2810
+ // expect(tx(d)).toEqual(false);
2811
+ // });
2812
+
2813
+ test("flatten simple intersections", () => {
2814
+ const FirstSchema = z.object({
2815
+ testNum: z.number(),
2816
+ });
2817
+
2818
+ const SecondSchema = z.object({
2819
+ testStr: z.string(),
2820
+ });
2821
+
2822
+ const ThirdSchema = z.object({
2823
+ testBool: z.boolean(),
2824
+ });
2825
+
2826
+ const HelloSchema = FirstSchema.and(SecondSchema).and(ThirdSchema).describe("123");
2827
+
2828
+ // Zod 3
2829
+ // console.log(JSON.stringify(zodToJsonSchema(HelloSchema), null, 2));
2830
+
2831
+ // Zod 4
2832
+ const result = z.toJSONSchema(HelloSchema, { target: "draft-7" });
2833
+ expect(result).toMatchInlineSnapshot(`
2834
+ {
2835
+ "$schema": "http://json-schema.org/draft-07/schema#",
2836
+ "allOf": [
2837
+ {
2838
+ "additionalProperties": false,
2839
+ "properties": {
2840
+ "testNum": {
2841
+ "type": "number",
2842
+ },
2843
+ },
2844
+ "required": [
2845
+ "testNum",
2846
+ ],
2847
+ "type": "object",
2848
+ },
2849
+ {
2850
+ "additionalProperties": false,
2851
+ "properties": {
2852
+ "testStr": {
2853
+ "type": "string",
2854
+ },
2855
+ },
2856
+ "required": [
2857
+ "testStr",
2858
+ ],
2859
+ "type": "object",
2860
+ },
2861
+ {
2862
+ "additionalProperties": false,
2863
+ "properties": {
2864
+ "testBool": {
2865
+ "type": "boolean",
2866
+ },
2867
+ },
2868
+ "required": [
2869
+ "testBool",
2870
+ ],
2871
+ "type": "object",
2872
+ },
2873
+ ],
2874
+ "description": "123",
2875
+ }
2876
+ `);
2877
+ });
2878
+
2879
+ test("z.file()", () => {
2880
+ const a = z.file();
2881
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
2882
+ {
2883
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2884
+ "contentEncoding": "binary",
2885
+ "format": "binary",
2886
+ "type": "string",
2887
+ }
2888
+ `);
2889
+
2890
+ const b = z.file().mime("image/png").min(1000).max(10000);
2891
+ expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
2892
+ {
2893
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2894
+ "contentEncoding": "binary",
2895
+ "contentMediaType": "image/png",
2896
+ "format": "binary",
2897
+ "maxLength": 10000,
2898
+ "minLength": 1000,
2899
+ "type": "string",
2900
+ }
2901
+ `);
2902
+
2903
+ const c = z.file().mime(["image/png", "image/jpg"]).min(1000).max(10000);
2904
+ expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
2905
+ {
2906
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2907
+ "anyOf": [
2908
+ {
2909
+ "contentMediaType": "image/png",
2910
+ },
2911
+ {
2912
+ "contentMediaType": "image/jpg",
2913
+ },
2914
+ ],
2915
+ "contentEncoding": "binary",
2916
+ "format": "binary",
2917
+ "maxLength": 10000,
2918
+ "minLength": 1000,
2919
+ "type": "string",
2920
+ }
2921
+ `);
2922
+ });
2923
+
2924
+ test("custom toJSONSchema", () => {
2925
+ const schema = z.instanceof(Date);
2926
+ schema._zod.toJSONSchema = () => ({
2927
+ type: "string",
2928
+ format: "date-time",
2929
+ });
2930
+
2931
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
2932
+ {
2933
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2934
+ "format": "date-time",
2935
+ "type": "string",
2936
+ }
2937
+ `);
2938
+ });
2939
+
2940
+ test("cycle detection - root", () => {
2941
+ const schema = z.object({
2942
+ name: z.string(),
2943
+ get subcategories() {
2944
+ return z.array(schema);
2945
+ },
2946
+ });
2947
+
2948
+ expect(() => z.toJSONSchema(schema, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
2949
+ [Error: Cycle detected: #/properties/subcategories/items/<root>
2950
+
2951
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2952
+ `);
2953
+ });
2954
+
2955
+ test("cycle detection - mutual recursion", () => {
2956
+ const A = z.object({
2957
+ name: z.string(),
2958
+ get subcategories() {
2959
+ return z.array(B);
2960
+ },
2961
+ });
2962
+
2963
+ const B = z.object({
2964
+ name: z.string(),
2965
+ get subcategories() {
2966
+ return z.array(A);
2967
+ },
2968
+ });
2969
+
2970
+ expect(() => z.toJSONSchema(A, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
2971
+ [Error: Cycle detected: #/properties/subcategories/items/properties/subcategories/items/<root>
2972
+
2973
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
2974
+ `);
2975
+ });