fullstacked 0.12.0-1173 → 0.12.0-1184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (500) hide show
  1. package/fullstacked_modules/@fullstacked/ai-agent/README.md +1 -0
  2. package/fullstacked_modules/@fullstacked/ai-agent/chat.json +1 -0
  3. package/fullstacked_modules/@fullstacked/ai-agent/index.scss +15 -0
  4. package/fullstacked_modules/@fullstacked/ai-agent/index.ts +92 -0
  5. package/fullstacked_modules/@fullstacked/ai-agent/lock.json +726 -0
  6. package/fullstacked_modules/@fullstacked/ai-agent/package.json +15 -0
  7. package/fullstacked_modules/@fullstacked/ai-agent/src/conversation.ts +169 -0
  8. package/fullstacked_modules/@fullstacked/ai-agent/src/default.scss +23 -0
  9. package/fullstacked_modules/@fullstacked/ai-agent/src/index.ts +3 -0
  10. package/fullstacked_modules/@fullstacked/ai-agent/src/input.ts +36 -0
  11. package/fullstacked_modules/@fullstacked/ai-agent/src/markdown.ts +46 -0
  12. package/fullstacked_modules/@fullstacked/ai-agent/src/providers/interface.ts +6 -0
  13. package/fullstacked_modules/@fullstacked/ai-agent/src/providers/ollama.ts +42 -0
  14. package/fullstacked_modules/@fullstacked/ai-agent/src/providers/openai.ts +33 -0
  15. package/fullstacked_modules/@fullstacked/ai-agent/story.txt +7 -0
  16. package/fullstacked_modules/ai/index.d.ts +2 -0
  17. package/fullstacked_modules/ai/index.js +88268 -0
  18. package/fullstacked_modules/ai/index.ts +14 -0
  19. package/fullstacked_modules/ai/package.json +5 -0
  20. package/fullstacked_modules/ai/tools/fs.ts +60 -0
  21. package/{lib → fullstacked_modules}/archive/archive.ts +140 -140
  22. package/fullstacked_modules/archive/index.d.ts +2 -0
  23. package/{lib → fullstacked_modules}/archive/index.ts +4 -4
  24. package/{lib → fullstacked_modules}/base64.ts +144 -144
  25. package/fullstacked_modules/bridge/index.ts +120 -0
  26. package/{lib → fullstacked_modules}/bridge/platform/android.ts +18 -18
  27. package/{lib → fullstacked_modules}/bridge/platform/apple.ts +46 -46
  28. package/{lib → fullstacked_modules}/bridge/platform/electron.ts +14 -14
  29. package/{lib → fullstacked_modules}/bridge/platform/linux-gtk.ts +48 -48
  30. package/{lib → fullstacked_modules}/bridge/platform/linux-qt.ts +68 -68
  31. package/{lib → fullstacked_modules}/bridge/platform/node.ts +32 -32
  32. package/{lib → fullstacked_modules}/bridge/platform/wasm.ts +17 -17
  33. package/{lib → fullstacked_modules}/bridge/platform/windows.ts +49 -49
  34. package/{lib → fullstacked_modules}/bridge/serialization.ts +153 -153
  35. package/{lib → fullstacked_modules}/components/snackbar.ts +60 -60
  36. package/fullstacked_modules/config/config.ts +33 -0
  37. package/fullstacked_modules/config/index.ts +3 -0
  38. package/fullstacked_modules/connect/index.d.ts +2 -0
  39. package/{lib → fullstacked_modules}/connect/index.ts +125 -125
  40. package/{lib → fullstacked_modules}/core_message/core_message.ts +57 -76
  41. package/{lib → fullstacked_modules}/core_message/index.ts +3 -3
  42. package/fullstacked_modules/core_open.ts +9 -0
  43. package/fullstacked_modules/esbuild/esbuild.ts +101 -0
  44. package/fullstacked_modules/esbuild/index.ts +3 -0
  45. package/fullstacked_modules/esbuild/sass.ts +103 -0
  46. package/fullstacked_modules/fetch/index.d.ts +2 -0
  47. package/{lib → fullstacked_modules}/fetch/index.ts +332 -318
  48. package/{lib → fullstacked_modules}/fs/fs.ts +157 -157
  49. package/fullstacked_modules/fs/index.d.ts +2 -0
  50. package/{lib → fullstacked_modules}/fs/index.ts +3 -3
  51. package/fullstacked_modules/git/git.ts +238 -0
  52. package/fullstacked_modules/git/index.ts +3 -0
  53. package/fullstacked_modules/packages/index.ts +3 -0
  54. package/fullstacked_modules/packages/packages.ts +143 -0
  55. package/fullstacked_modules/platform/index.d.ts +2 -0
  56. package/{lib → fullstacked_modules}/platform/index.ts +14 -14
  57. package/fullstacked_modules/zod/LICENSE +21 -0
  58. package/fullstacked_modules/zod/README.md +208 -0
  59. package/fullstacked_modules/zod/index.d.cts +4 -0
  60. package/fullstacked_modules/zod/index.d.ts +4 -0
  61. package/fullstacked_modules/zod/locales/index.d.cts +1 -0
  62. package/fullstacked_modules/zod/locales/index.d.ts +1 -0
  63. package/fullstacked_modules/zod/mini/index.d.cts +1 -0
  64. package/fullstacked_modules/zod/mini/index.d.ts +1 -0
  65. package/fullstacked_modules/zod/package.json +134 -0
  66. package/fullstacked_modules/zod/src/index.ts +4 -0
  67. package/fullstacked_modules/zod/src/locales/index.ts +1 -0
  68. package/fullstacked_modules/zod/src/mini/index.ts +1 -0
  69. package/fullstacked_modules/zod/src/v3/ZodError.ts +330 -0
  70. package/fullstacked_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  71. package/fullstacked_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  72. package/fullstacked_modules/zod/src/v3/benchmarks/index.ts +59 -0
  73. package/fullstacked_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  74. package/fullstacked_modules/zod/src/v3/benchmarks/object.ts +69 -0
  75. package/fullstacked_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  76. package/fullstacked_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  77. package/fullstacked_modules/zod/src/v3/benchmarks/string.ts +55 -0
  78. package/fullstacked_modules/zod/src/v3/benchmarks/union.ts +80 -0
  79. package/fullstacked_modules/zod/src/v3/errors.ts +13 -0
  80. package/fullstacked_modules/zod/src/v3/external.ts +6 -0
  81. package/fullstacked_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  82. package/fullstacked_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  83. package/fullstacked_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  84. package/fullstacked_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  85. package/fullstacked_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  86. package/fullstacked_modules/zod/src/v3/helpers/util.ts +224 -0
  87. package/fullstacked_modules/zod/src/v3/index.ts +4 -0
  88. package/fullstacked_modules/zod/src/v3/locales/en.ts +124 -0
  89. package/fullstacked_modules/zod/src/v3/standard-schema.ts +113 -0
  90. package/fullstacked_modules/zod/src/v3/tests/Mocker.ts +54 -0
  91. package/fullstacked_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  92. package/fullstacked_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  93. package/fullstacked_modules/zod/src/v3/tests/array.test.ts +71 -0
  94. package/fullstacked_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  95. package/fullstacked_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  96. package/fullstacked_modules/zod/src/v3/tests/base.test.ts +29 -0
  97. package/fullstacked_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  98. package/fullstacked_modules/zod/src/v3/tests/branded.test.ts +53 -0
  99. package/fullstacked_modules/zod/src/v3/tests/catch.test.ts +220 -0
  100. package/fullstacked_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  101. package/fullstacked_modules/zod/src/v3/tests/complex.test.ts +56 -0
  102. package/fullstacked_modules/zod/src/v3/tests/custom.test.ts +31 -0
  103. package/fullstacked_modules/zod/src/v3/tests/date.test.ts +32 -0
  104. package/fullstacked_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  105. package/fullstacked_modules/zod/src/v3/tests/default.test.ts +112 -0
  106. package/fullstacked_modules/zod/src/v3/tests/description.test.ts +33 -0
  107. package/fullstacked_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  108. package/fullstacked_modules/zod/src/v3/tests/enum.test.ts +80 -0
  109. package/fullstacked_modules/zod/src/v3/tests/error.test.ts +551 -0
  110. package/fullstacked_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  111. package/fullstacked_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  112. package/fullstacked_modules/zod/src/v3/tests/function.test.ts +257 -0
  113. package/fullstacked_modules/zod/src/v3/tests/generics.test.ts +48 -0
  114. package/fullstacked_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  115. package/fullstacked_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  116. package/fullstacked_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  117. package/fullstacked_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  118. package/fullstacked_modules/zod/src/v3/tests/literal.test.ts +36 -0
  119. package/fullstacked_modules/zod/src/v3/tests/map.test.ts +110 -0
  120. package/fullstacked_modules/zod/src/v3/tests/masking.test.ts +4 -0
  121. package/fullstacked_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  122. package/fullstacked_modules/zod/src/v3/tests/nan.test.ts +21 -0
  123. package/fullstacked_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  124. package/fullstacked_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  125. package/fullstacked_modules/zod/src/v3/tests/number.test.ts +176 -0
  126. package/fullstacked_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  127. package/fullstacked_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  128. package/fullstacked_modules/zod/src/v3/tests/object.test.ts +434 -0
  129. package/fullstacked_modules/zod/src/v3/tests/optional.test.ts +42 -0
  130. package/fullstacked_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
  131. package/fullstacked_modules/zod/src/v3/tests/parser.test.ts +41 -0
  132. package/fullstacked_modules/zod/src/v3/tests/partials.test.ts +243 -0
  133. package/fullstacked_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
  134. package/fullstacked_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
  135. package/fullstacked_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
  136. package/fullstacked_modules/zod/src/v3/tests/primitive.test.ts +440 -0
  137. package/fullstacked_modules/zod/src/v3/tests/promise.test.ts +90 -0
  138. package/fullstacked_modules/zod/src/v3/tests/readonly.test.ts +194 -0
  139. package/fullstacked_modules/zod/src/v3/tests/record.test.ts +171 -0
  140. package/fullstacked_modules/zod/src/v3/tests/recursive.test.ts +197 -0
  141. package/fullstacked_modules/zod/src/v3/tests/refine.test.ts +313 -0
  142. package/fullstacked_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
  143. package/fullstacked_modules/zod/src/v3/tests/set.test.ts +142 -0
  144. package/fullstacked_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
  145. package/fullstacked_modules/zod/src/v3/tests/string.test.ts +916 -0
  146. package/fullstacked_modules/zod/src/v3/tests/transformer.test.ts +233 -0
  147. package/fullstacked_modules/zod/src/v3/tests/tuple.test.ts +90 -0
  148. package/fullstacked_modules/zod/src/v3/tests/unions.test.ts +57 -0
  149. package/fullstacked_modules/zod/src/v3/tests/validations.test.ts +133 -0
  150. package/fullstacked_modules/zod/src/v3/tests/void.test.ts +15 -0
  151. package/fullstacked_modules/zod/src/v3/types.ts +5138 -0
  152. package/fullstacked_modules/zod/src/v4/classic/checks.ts +31 -0
  153. package/fullstacked_modules/zod/src/v4/classic/coerce.ts +27 -0
  154. package/fullstacked_modules/zod/src/v4/classic/compat.ts +70 -0
  155. package/fullstacked_modules/zod/src/v4/classic/errors.ts +82 -0
  156. package/fullstacked_modules/zod/src/v4/classic/external.ts +50 -0
  157. package/fullstacked_modules/zod/src/v4/classic/index.ts +5 -0
  158. package/fullstacked_modules/zod/src/v4/classic/iso.ts +90 -0
  159. package/fullstacked_modules/zod/src/v4/classic/parse.ts +33 -0
  160. package/fullstacked_modules/zod/src/v4/classic/schemas.ts +2031 -0
  161. package/fullstacked_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
  162. package/fullstacked_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
  163. package/fullstacked_modules/zod/src/v4/classic/tests/assignability.test.ts +210 -0
  164. package/fullstacked_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
  165. package/fullstacked_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
  166. package/fullstacked_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
  167. package/fullstacked_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
  168. package/fullstacked_modules/zod/src/v4/classic/tests/brand.test.ts +63 -0
  169. package/fullstacked_modules/zod/src/v4/classic/tests/catch.test.ts +251 -0
  170. package/fullstacked_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
  171. package/fullstacked_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
  172. package/fullstacked_modules/zod/src/v4/classic/tests/continuability.test.ts +352 -0
  173. package/fullstacked_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
  174. package/fullstacked_modules/zod/src/v4/classic/tests/date.test.ts +31 -0
  175. package/fullstacked_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
  176. package/fullstacked_modules/zod/src/v4/classic/tests/default.test.ts +313 -0
  177. package/fullstacked_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
  178. package/fullstacked_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +661 -0
  179. package/fullstacked_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
  180. package/fullstacked_modules/zod/src/v4/classic/tests/error-utils.test.ts +595 -0
  181. package/fullstacked_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
  182. package/fullstacked_modules/zod/src/v4/classic/tests/file.test.ts +94 -0
  183. package/fullstacked_modules/zod/src/v4/classic/tests/firstparty.test.ts +175 -0
  184. package/fullstacked_modules/zod/src/v4/classic/tests/function.test.ts +268 -0
  185. package/fullstacked_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
  186. package/fullstacked_modules/zod/src/v4/classic/tests/index.test.ts +829 -0
  187. package/fullstacked_modules/zod/src/v4/classic/tests/instanceof.test.ts +34 -0
  188. package/fullstacked_modules/zod/src/v4/classic/tests/intersection.test.ts +171 -0
  189. package/fullstacked_modules/zod/src/v4/classic/tests/json.test.ts +108 -0
  190. package/fullstacked_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
  191. package/fullstacked_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
  192. package/fullstacked_modules/zod/src/v4/classic/tests/map.test.ts +196 -0
  193. package/fullstacked_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  194. package/fullstacked_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  195. package/fullstacked_modules/zod/src/v4/classic/tests/nonoptional.test.ts +86 -0
  196. package/fullstacked_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  197. package/fullstacked_modules/zod/src/v4/classic/tests/number.test.ts +270 -0
  198. package/fullstacked_modules/zod/src/v4/classic/tests/object.test.ts +563 -0
  199. package/fullstacked_modules/zod/src/v4/classic/tests/optional.test.ts +136 -0
  200. package/fullstacked_modules/zod/src/v4/classic/tests/partial.test.ts +340 -0
  201. package/fullstacked_modules/zod/src/v4/classic/tests/pickomit.test.ts +127 -0
  202. package/fullstacked_modules/zod/src/v4/classic/tests/pipe.test.ts +81 -0
  203. package/fullstacked_modules/zod/src/v4/classic/tests/prefault.test.ts +37 -0
  204. package/fullstacked_modules/zod/src/v4/classic/tests/preprocess.test.ts +287 -0
  205. package/fullstacked_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  206. package/fullstacked_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  207. package/fullstacked_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  208. package/fullstacked_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  209. package/fullstacked_modules/zod/src/v4/classic/tests/record.test.ts +356 -0
  210. package/fullstacked_modules/zod/src/v4/classic/tests/recursive-types.test.ts +477 -0
  211. package/fullstacked_modules/zod/src/v4/classic/tests/refine.test.ts +532 -0
  212. package/fullstacked_modules/zod/src/v4/classic/tests/registries.test.ts +204 -0
  213. package/fullstacked_modules/zod/src/v4/classic/tests/set.test.ts +179 -0
  214. package/fullstacked_modules/zod/src/v4/classic/tests/standard-schema.test.ts +57 -0
  215. package/fullstacked_modules/zod/src/v4/classic/tests/string-formats.test.ts +109 -0
  216. package/fullstacked_modules/zod/src/v4/classic/tests/string.test.ts +996 -0
  217. package/fullstacked_modules/zod/src/v4/classic/tests/stringbool.test.ts +66 -0
  218. package/fullstacked_modules/zod/src/v4/classic/tests/template-literal.test.ts +761 -0
  219. package/fullstacked_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +2341 -0
  220. package/fullstacked_modules/zod/src/v4/classic/tests/transform.test.ts +354 -0
  221. package/fullstacked_modules/zod/src/v4/classic/tests/tuple.test.ts +163 -0
  222. package/fullstacked_modules/zod/src/v4/classic/tests/union.test.ts +181 -0
  223. package/fullstacked_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  224. package/fullstacked_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  225. package/fullstacked_modules/zod/src/v4/core/api.ts +1628 -0
  226. package/fullstacked_modules/zod/src/v4/core/checks.ts +1285 -0
  227. package/fullstacked_modules/zod/src/v4/core/config.ts +15 -0
  228. package/fullstacked_modules/zod/src/v4/core/core.ts +134 -0
  229. package/fullstacked_modules/zod/src/v4/core/doc.ts +44 -0
  230. package/fullstacked_modules/zod/src/v4/core/errors.ts +423 -0
  231. package/fullstacked_modules/zod/src/v4/core/function.ts +176 -0
  232. package/fullstacked_modules/zod/src/v4/core/index.ts +15 -0
  233. package/fullstacked_modules/zod/src/v4/core/json-schema.ts +146 -0
  234. package/fullstacked_modules/zod/src/v4/core/parse.ts +94 -0
  235. package/fullstacked_modules/zod/src/v4/core/regexes.ts +138 -0
  236. package/fullstacked_modules/zod/src/v4/core/registries.ts +97 -0
  237. package/fullstacked_modules/zod/src/v4/core/schemas.ts +3900 -0
  238. package/fullstacked_modules/zod/src/v4/core/standard-schema.ts +64 -0
  239. package/fullstacked_modules/zod/src/v4/core/tests/extend.test.ts +18 -0
  240. package/fullstacked_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  241. package/fullstacked_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  242. package/fullstacked_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  243. package/fullstacked_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  244. package/fullstacked_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  245. package/fullstacked_modules/zod/src/v4/core/to-json-schema.ts +1004 -0
  246. package/fullstacked_modules/zod/src/v4/core/util.ts +827 -0
  247. package/fullstacked_modules/zod/src/v4/core/versions.ts +5 -0
  248. package/fullstacked_modules/zod/src/v4/core/zsf.ts +323 -0
  249. package/fullstacked_modules/zod/src/v4/index.ts +4 -0
  250. package/fullstacked_modules/zod/src/v4/locales/ar.ts +125 -0
  251. package/fullstacked_modules/zod/src/v4/locales/az.ts +121 -0
  252. package/fullstacked_modules/zod/src/v4/locales/be.ts +184 -0
  253. package/fullstacked_modules/zod/src/v4/locales/bg.ts +136 -0
  254. package/fullstacked_modules/zod/src/v4/locales/ca.ts +127 -0
  255. package/fullstacked_modules/zod/src/v4/locales/cs.ts +142 -0
  256. package/fullstacked_modules/zod/src/v4/locales/da.ts +141 -0
  257. package/fullstacked_modules/zod/src/v4/locales/de.ts +124 -0
  258. package/fullstacked_modules/zod/src/v4/locales/en.ts +127 -0
  259. package/fullstacked_modules/zod/src/v4/locales/eo.ts +125 -0
  260. package/fullstacked_modules/zod/src/v4/locales/es.ts +125 -0
  261. package/fullstacked_modules/zod/src/v4/locales/fa.ts +134 -0
  262. package/fullstacked_modules/zod/src/v4/locales/fi.ts +131 -0
  263. package/fullstacked_modules/zod/src/v4/locales/fr-CA.ts +126 -0
  264. package/fullstacked_modules/zod/src/v4/locales/fr.ts +124 -0
  265. package/fullstacked_modules/zod/src/v4/locales/he.ts +125 -0
  266. package/fullstacked_modules/zod/src/v4/locales/hu.ts +126 -0
  267. package/fullstacked_modules/zod/src/v4/locales/id.ts +125 -0
  268. package/fullstacked_modules/zod/src/v4/locales/index.ts +42 -0
  269. package/fullstacked_modules/zod/src/v4/locales/is.ts +127 -0
  270. package/fullstacked_modules/zod/src/v4/locales/it.ts +125 -0
  271. package/fullstacked_modules/zod/src/v4/locales/ja.ts +122 -0
  272. package/fullstacked_modules/zod/src/v4/locales/kh.ts +126 -0
  273. package/fullstacked_modules/zod/src/v4/locales/ko.ts +131 -0
  274. package/fullstacked_modules/zod/src/v4/locales/mk.ts +127 -0
  275. package/fullstacked_modules/zod/src/v4/locales/ms.ts +124 -0
  276. package/fullstacked_modules/zod/src/v4/locales/nl.ts +126 -0
  277. package/fullstacked_modules/zod/src/v4/locales/no.ts +124 -0
  278. package/fullstacked_modules/zod/src/v4/locales/ota.ts +125 -0
  279. package/fullstacked_modules/zod/src/v4/locales/pl.ts +126 -0
  280. package/fullstacked_modules/zod/src/v4/locales/ps.ts +133 -0
  281. package/fullstacked_modules/zod/src/v4/locales/pt.ts +123 -0
  282. package/fullstacked_modules/zod/src/v4/locales/ru.ts +184 -0
  283. package/fullstacked_modules/zod/src/v4/locales/sl.ts +126 -0
  284. package/fullstacked_modules/zod/src/v4/locales/sv.ts +127 -0
  285. package/fullstacked_modules/zod/src/v4/locales/ta.ts +125 -0
  286. package/fullstacked_modules/zod/src/v4/locales/th.ts +126 -0
  287. package/fullstacked_modules/zod/src/v4/locales/tr.ts +121 -0
  288. package/fullstacked_modules/zod/src/v4/locales/ua.ts +126 -0
  289. package/fullstacked_modules/zod/src/v4/locales/ur.ts +126 -0
  290. package/fullstacked_modules/zod/src/v4/locales/vi.ts +125 -0
  291. package/fullstacked_modules/zod/src/v4/locales/yo.ts +131 -0
  292. package/fullstacked_modules/zod/src/v4/locales/zh-CN.ts +123 -0
  293. package/fullstacked_modules/zod/src/v4/locales/zh-TW.ts +125 -0
  294. package/fullstacked_modules/zod/src/v4/mini/checks.ts +32 -0
  295. package/fullstacked_modules/zod/src/v4/mini/coerce.ts +22 -0
  296. package/fullstacked_modules/zod/src/v4/mini/external.ts +40 -0
  297. package/fullstacked_modules/zod/src/v4/mini/index.ts +3 -0
  298. package/fullstacked_modules/zod/src/v4/mini/iso.ts +62 -0
  299. package/fullstacked_modules/zod/src/v4/mini/parse.ts +1 -0
  300. package/fullstacked_modules/zod/src/v4/mini/schemas.ts +1592 -0
  301. package/fullstacked_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
  302. package/fullstacked_modules/zod/src/v4/mini/tests/brand.test.ts +51 -0
  303. package/fullstacked_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
  304. package/fullstacked_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
  305. package/fullstacked_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
  306. package/fullstacked_modules/zod/src/v4/mini/tests/functions.test.ts +43 -0
  307. package/fullstacked_modules/zod/src/v4/mini/tests/index.test.ts +871 -0
  308. package/fullstacked_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
  309. package/fullstacked_modules/zod/src/v4/mini/tests/object.test.ts +185 -0
  310. package/fullstacked_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
  311. package/fullstacked_modules/zod/src/v4/mini/tests/recursive-types.test.ts +275 -0
  312. package/fullstacked_modules/zod/src/v4/mini/tests/string.test.ts +299 -0
  313. package/fullstacked_modules/zod/src/v4-mini/index.ts +1 -0
  314. package/fullstacked_modules/zod/v3/ZodError.d.cts +164 -0
  315. package/fullstacked_modules/zod/v3/ZodError.d.ts +164 -0
  316. package/fullstacked_modules/zod/v3/errors.d.cts +5 -0
  317. package/fullstacked_modules/zod/v3/errors.d.ts +5 -0
  318. package/fullstacked_modules/zod/v3/external.d.cts +6 -0
  319. package/fullstacked_modules/zod/v3/external.d.ts +6 -0
  320. package/fullstacked_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  321. package/fullstacked_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  322. package/fullstacked_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  323. package/fullstacked_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  324. package/fullstacked_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  325. package/fullstacked_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  326. package/fullstacked_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  327. package/fullstacked_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  328. package/fullstacked_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  329. package/fullstacked_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  330. package/fullstacked_modules/zod/v3/helpers/util.d.cts +85 -0
  331. package/fullstacked_modules/zod/v3/helpers/util.d.ts +85 -0
  332. package/fullstacked_modules/zod/v3/index.d.cts +4 -0
  333. package/fullstacked_modules/zod/v3/index.d.ts +4 -0
  334. package/fullstacked_modules/zod/v3/locales/en.d.cts +3 -0
  335. package/fullstacked_modules/zod/v3/locales/en.d.ts +3 -0
  336. package/fullstacked_modules/zod/v3/standard-schema.d.cts +102 -0
  337. package/fullstacked_modules/zod/v3/standard-schema.d.ts +102 -0
  338. package/fullstacked_modules/zod/v3/types.d.cts +1034 -0
  339. package/fullstacked_modules/zod/v3/types.d.ts +1034 -0
  340. package/fullstacked_modules/zod/v4/classic/checks.d.cts +1 -0
  341. package/fullstacked_modules/zod/v4/classic/checks.d.ts +1 -0
  342. package/fullstacked_modules/zod/v4/classic/coerce.d.cts +17 -0
  343. package/fullstacked_modules/zod/v4/classic/coerce.d.ts +17 -0
  344. package/fullstacked_modules/zod/v4/classic/compat.d.cts +50 -0
  345. package/fullstacked_modules/zod/v4/classic/compat.d.ts +50 -0
  346. package/fullstacked_modules/zod/v4/classic/errors.d.cts +30 -0
  347. package/fullstacked_modules/zod/v4/classic/errors.d.ts +30 -0
  348. package/fullstacked_modules/zod/v4/classic/external.d.cts +13 -0
  349. package/fullstacked_modules/zod/v4/classic/external.d.ts +13 -0
  350. package/fullstacked_modules/zod/v4/classic/index.d.cts +4 -0
  351. package/fullstacked_modules/zod/v4/classic/index.d.ts +4 -0
  352. package/fullstacked_modules/zod/v4/classic/iso.d.cts +22 -0
  353. package/fullstacked_modules/zod/v4/classic/iso.d.ts +22 -0
  354. package/fullstacked_modules/zod/v4/classic/parse.d.cts +23 -0
  355. package/fullstacked_modules/zod/v4/classic/parse.d.ts +23 -0
  356. package/fullstacked_modules/zod/v4/classic/schemas.d.cts +619 -0
  357. package/fullstacked_modules/zod/v4/classic/schemas.d.ts +619 -0
  358. package/fullstacked_modules/zod/v4/core/api.d.cts +296 -0
  359. package/fullstacked_modules/zod/v4/core/api.d.ts +296 -0
  360. package/fullstacked_modules/zod/v4/core/checks.d.cts +278 -0
  361. package/fullstacked_modules/zod/v4/core/checks.d.ts +278 -0
  362. package/fullstacked_modules/zod/v4/core/core.d.cts +49 -0
  363. package/fullstacked_modules/zod/v4/core/core.d.ts +49 -0
  364. package/fullstacked_modules/zod/v4/core/doc.d.cts +14 -0
  365. package/fullstacked_modules/zod/v4/core/doc.d.ts +14 -0
  366. package/fullstacked_modules/zod/v4/core/errors.d.cts +210 -0
  367. package/fullstacked_modules/zod/v4/core/errors.d.ts +210 -0
  368. package/fullstacked_modules/zod/v4/core/function.d.cts +52 -0
  369. package/fullstacked_modules/zod/v4/core/function.d.ts +52 -0
  370. package/fullstacked_modules/zod/v4/core/index.d.cts +15 -0
  371. package/fullstacked_modules/zod/v4/core/index.d.ts +15 -0
  372. package/fullstacked_modules/zod/v4/core/json-schema.d.cts +87 -0
  373. package/fullstacked_modules/zod/v4/core/json-schema.d.ts +87 -0
  374. package/fullstacked_modules/zod/v4/core/parse.d.cts +25 -0
  375. package/fullstacked_modules/zod/v4/core/parse.d.ts +25 -0
  376. package/fullstacked_modules/zod/v4/core/regexes.d.cts +62 -0
  377. package/fullstacked_modules/zod/v4/core/regexes.d.ts +62 -0
  378. package/fullstacked_modules/zod/v4/core/registries.d.cts +35 -0
  379. package/fullstacked_modules/zod/v4/core/registries.d.ts +35 -0
  380. package/fullstacked_modules/zod/v4/core/schemas.d.cts +1055 -0
  381. package/fullstacked_modules/zod/v4/core/schemas.d.ts +1055 -0
  382. package/fullstacked_modules/zod/v4/core/standard-schema.d.cts +55 -0
  383. package/fullstacked_modules/zod/v4/core/standard-schema.d.ts +55 -0
  384. package/fullstacked_modules/zod/v4/core/to-json-schema.d.cts +89 -0
  385. package/fullstacked_modules/zod/v4/core/to-json-schema.d.ts +89 -0
  386. package/fullstacked_modules/zod/v4/core/util.d.cts +185 -0
  387. package/fullstacked_modules/zod/v4/core/util.d.ts +185 -0
  388. package/fullstacked_modules/zod/v4/core/versions.d.cts +5 -0
  389. package/fullstacked_modules/zod/v4/core/versions.d.ts +5 -0
  390. package/fullstacked_modules/zod/v4/index.d.cts +3 -0
  391. package/fullstacked_modules/zod/v4/index.d.ts +3 -0
  392. package/fullstacked_modules/zod/v4/locales/ar.d.cts +5 -0
  393. package/fullstacked_modules/zod/v4/locales/ar.d.ts +4 -0
  394. package/fullstacked_modules/zod/v4/locales/az.d.cts +5 -0
  395. package/fullstacked_modules/zod/v4/locales/az.d.ts +4 -0
  396. package/fullstacked_modules/zod/v4/locales/be.d.cts +5 -0
  397. package/fullstacked_modules/zod/v4/locales/be.d.ts +4 -0
  398. package/fullstacked_modules/zod/v4/locales/bg.d.cts +5 -0
  399. package/fullstacked_modules/zod/v4/locales/bg.d.ts +5 -0
  400. package/fullstacked_modules/zod/v4/locales/ca.d.cts +5 -0
  401. package/fullstacked_modules/zod/v4/locales/ca.d.ts +4 -0
  402. package/fullstacked_modules/zod/v4/locales/cs.d.cts +5 -0
  403. package/fullstacked_modules/zod/v4/locales/cs.d.ts +4 -0
  404. package/fullstacked_modules/zod/v4/locales/da.d.cts +5 -0
  405. package/fullstacked_modules/zod/v4/locales/da.d.ts +4 -0
  406. package/fullstacked_modules/zod/v4/locales/de.d.cts +5 -0
  407. package/fullstacked_modules/zod/v4/locales/de.d.ts +4 -0
  408. package/fullstacked_modules/zod/v4/locales/en.d.cts +5 -0
  409. package/fullstacked_modules/zod/v4/locales/en.d.ts +5 -0
  410. package/fullstacked_modules/zod/v4/locales/eo.d.cts +5 -0
  411. package/fullstacked_modules/zod/v4/locales/eo.d.ts +5 -0
  412. package/fullstacked_modules/zod/v4/locales/es.d.cts +5 -0
  413. package/fullstacked_modules/zod/v4/locales/es.d.ts +4 -0
  414. package/fullstacked_modules/zod/v4/locales/fa.d.cts +5 -0
  415. package/fullstacked_modules/zod/v4/locales/fa.d.ts +4 -0
  416. package/fullstacked_modules/zod/v4/locales/fi.d.cts +5 -0
  417. package/fullstacked_modules/zod/v4/locales/fi.d.ts +4 -0
  418. package/fullstacked_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  419. package/fullstacked_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  420. package/fullstacked_modules/zod/v4/locales/fr.d.cts +5 -0
  421. package/fullstacked_modules/zod/v4/locales/fr.d.ts +4 -0
  422. package/fullstacked_modules/zod/v4/locales/he.d.cts +5 -0
  423. package/fullstacked_modules/zod/v4/locales/he.d.ts +4 -0
  424. package/fullstacked_modules/zod/v4/locales/hu.d.cts +5 -0
  425. package/fullstacked_modules/zod/v4/locales/hu.d.ts +4 -0
  426. package/fullstacked_modules/zod/v4/locales/id.d.cts +5 -0
  427. package/fullstacked_modules/zod/v4/locales/id.d.ts +4 -0
  428. package/fullstacked_modules/zod/v4/locales/index.d.cts +42 -0
  429. package/fullstacked_modules/zod/v4/locales/index.d.ts +42 -0
  430. package/fullstacked_modules/zod/v4/locales/is.d.cts +5 -0
  431. package/fullstacked_modules/zod/v4/locales/is.d.ts +5 -0
  432. package/fullstacked_modules/zod/v4/locales/it.d.cts +5 -0
  433. package/fullstacked_modules/zod/v4/locales/it.d.ts +4 -0
  434. package/fullstacked_modules/zod/v4/locales/ja.d.cts +5 -0
  435. package/fullstacked_modules/zod/v4/locales/ja.d.ts +4 -0
  436. package/fullstacked_modules/zod/v4/locales/kh.d.cts +5 -0
  437. package/fullstacked_modules/zod/v4/locales/kh.d.ts +4 -0
  438. package/fullstacked_modules/zod/v4/locales/ko.d.cts +5 -0
  439. package/fullstacked_modules/zod/v4/locales/ko.d.ts +4 -0
  440. package/fullstacked_modules/zod/v4/locales/mk.d.cts +5 -0
  441. package/fullstacked_modules/zod/v4/locales/mk.d.ts +4 -0
  442. package/fullstacked_modules/zod/v4/locales/ms.d.cts +5 -0
  443. package/fullstacked_modules/zod/v4/locales/ms.d.ts +4 -0
  444. package/fullstacked_modules/zod/v4/locales/nl.d.cts +5 -0
  445. package/fullstacked_modules/zod/v4/locales/nl.d.ts +4 -0
  446. package/fullstacked_modules/zod/v4/locales/no.d.cts +5 -0
  447. package/fullstacked_modules/zod/v4/locales/no.d.ts +4 -0
  448. package/fullstacked_modules/zod/v4/locales/ota.d.cts +5 -0
  449. package/fullstacked_modules/zod/v4/locales/ota.d.ts +4 -0
  450. package/fullstacked_modules/zod/v4/locales/pl.d.cts +5 -0
  451. package/fullstacked_modules/zod/v4/locales/pl.d.ts +4 -0
  452. package/fullstacked_modules/zod/v4/locales/ps.d.cts +5 -0
  453. package/fullstacked_modules/zod/v4/locales/ps.d.ts +4 -0
  454. package/fullstacked_modules/zod/v4/locales/pt.d.cts +5 -0
  455. package/fullstacked_modules/zod/v4/locales/pt.d.ts +4 -0
  456. package/fullstacked_modules/zod/v4/locales/ru.d.cts +5 -0
  457. package/fullstacked_modules/zod/v4/locales/ru.d.ts +4 -0
  458. package/fullstacked_modules/zod/v4/locales/sl.d.cts +5 -0
  459. package/fullstacked_modules/zod/v4/locales/sl.d.ts +4 -0
  460. package/fullstacked_modules/zod/v4/locales/sv.d.cts +5 -0
  461. package/fullstacked_modules/zod/v4/locales/sv.d.ts +4 -0
  462. package/fullstacked_modules/zod/v4/locales/ta.d.cts +5 -0
  463. package/fullstacked_modules/zod/v4/locales/ta.d.ts +4 -0
  464. package/fullstacked_modules/zod/v4/locales/th.d.cts +5 -0
  465. package/fullstacked_modules/zod/v4/locales/th.d.ts +4 -0
  466. package/fullstacked_modules/zod/v4/locales/tr.d.cts +5 -0
  467. package/fullstacked_modules/zod/v4/locales/tr.d.ts +5 -0
  468. package/fullstacked_modules/zod/v4/locales/ua.d.cts +5 -0
  469. package/fullstacked_modules/zod/v4/locales/ua.d.ts +4 -0
  470. package/fullstacked_modules/zod/v4/locales/ur.d.cts +5 -0
  471. package/fullstacked_modules/zod/v4/locales/ur.d.ts +4 -0
  472. package/fullstacked_modules/zod/v4/locales/vi.d.cts +5 -0
  473. package/fullstacked_modules/zod/v4/locales/vi.d.ts +4 -0
  474. package/fullstacked_modules/zod/v4/locales/yo.d.cts +5 -0
  475. package/fullstacked_modules/zod/v4/locales/yo.d.ts +4 -0
  476. package/fullstacked_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  477. package/fullstacked_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  478. package/fullstacked_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  479. package/fullstacked_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  480. package/fullstacked_modules/zod/v4/mini/checks.d.cts +1 -0
  481. package/fullstacked_modules/zod/v4/mini/checks.d.ts +1 -0
  482. package/fullstacked_modules/zod/v4/mini/coerce.d.cts +7 -0
  483. package/fullstacked_modules/zod/v4/mini/coerce.d.ts +7 -0
  484. package/fullstacked_modules/zod/v4/mini/external.d.cts +11 -0
  485. package/fullstacked_modules/zod/v4/mini/external.d.ts +11 -0
  486. package/fullstacked_modules/zod/v4/mini/index.d.cts +3 -0
  487. package/fullstacked_modules/zod/v4/mini/index.d.ts +3 -0
  488. package/fullstacked_modules/zod/v4/mini/iso.d.cts +22 -0
  489. package/fullstacked_modules/zod/v4/mini/iso.d.ts +22 -0
  490. package/fullstacked_modules/zod/v4/mini/parse.d.cts +1 -0
  491. package/fullstacked_modules/zod/v4/mini/parse.d.ts +1 -0
  492. package/fullstacked_modules/zod/v4/mini/schemas.d.cts +358 -0
  493. package/fullstacked_modules/zod/v4/mini/schemas.d.ts +358 -0
  494. package/fullstacked_modules/zod/v4-mini/index.d.cts +1 -0
  495. package/fullstacked_modules/zod/v4-mini/index.d.ts +1 -0
  496. package/index.js +17 -12
  497. package/package.json +1 -1
  498. package/lib/bridge/index.ts +0 -53
  499. package/lib/fullstacked.d.ts +0 -208
  500. /package/{lib → fullstacked_modules}/components/snackbar.css +0 -0
@@ -0,0 +1,1004 @@
1
+ import type * as checks from "./checks.js";
2
+ import type * as JSONSchema from "./json-schema.js";
3
+ import { $ZodRegistry, globalRegistry } from "./registries.js";
4
+ import type * as schemas from "./schemas.js";
5
+ import { getEnumValues } from "./util.js";
6
+
7
+ interface JSONSchemaGeneratorParams {
8
+ /** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
9
+ * @default globalRegistry */
10
+ metadata?: $ZodRegistry<Record<string, any>>;
11
+ /** The JSON Schema version to target.
12
+ * - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
13
+ * - `"draft-7"` — JSON Schema Draft 7
14
+ * - `"draft-4"` — JSON Schema Draft 4 */
15
+ target?: "draft-4" | "draft-7" | "draft-2020-12";
16
+ /** How to handle unrepresentable types.
17
+ * - `"throw"` — Default. Unrepresentable types throw an error
18
+ * - `"any"` — Unrepresentable types become `{}` */
19
+ unrepresentable?: "throw" | "any";
20
+ /** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
21
+ override?: (ctx: {
22
+ zodSchema: schemas.$ZodTypes;
23
+ jsonSchema: JSONSchema.BaseSchema;
24
+ path: (string | number)[];
25
+ }) => void;
26
+ /** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, Error converting schema to JSONz, defaults, coerced primitives, etc.
27
+ * - `"output"` — Default. Convert the output schema.
28
+ * - `"input"` — Convert the input schema. */
29
+ io?: "input" | "output";
30
+ }
31
+
32
+ interface ProcessParams {
33
+ schemaPath: schemas.$ZodType[];
34
+ path: (string | number)[];
35
+ }
36
+
37
+ interface EmitParams {
38
+ /** How to handle cycles.
39
+ * - `"ref"` — Default. Cycles will be broken using $defs
40
+ * - `"throw"` — Cycles will throw an error if encountered */
41
+ cycles?: "ref" | "throw";
42
+ /* How to handle reused schemas.
43
+ * - `"inline"` — Default. Reused schemas will be inlined
44
+ * - `"ref"` — Reused schemas will be extracted as $defs */
45
+ reused?: "ref" | "inline";
46
+
47
+ external?:
48
+ | {
49
+ /** */
50
+ registry: $ZodRegistry<{ id?: string | undefined }>;
51
+ uri?: ((id: string) => string) | undefined;
52
+ defs: Record<string, JSONSchema.BaseSchema>;
53
+ }
54
+ | undefined;
55
+ }
56
+
57
+ interface Seen {
58
+ /** JSON Schema result for this Zod schema */
59
+ schema: JSONSchema.BaseSchema;
60
+ /** A cached version of the schema that doesn't get overwritten during ref resolution */
61
+ def?: JSONSchema.BaseSchema;
62
+ defId?: string | undefined;
63
+ /** Number of times this schema was encountered during traversal */
64
+ count: number;
65
+ /** Cycle path */
66
+ cycle?: (string | number)[] | undefined;
67
+ isParent?: boolean | undefined;
68
+ ref?: schemas.$ZodType | undefined | null;
69
+ /** JSON Schema property path for this schema */
70
+ path?: (string | number)[] | undefined;
71
+ }
72
+
73
+ export class JSONSchemaGenerator {
74
+ metadataRegistry: $ZodRegistry<Record<string, any>>;
75
+ target: "draft-4" | "draft-7" | "draft-2020-12";
76
+ unrepresentable: "throw" | "any";
77
+ override: (ctx: {
78
+ zodSchema: schemas.$ZodTypes;
79
+ jsonSchema: JSONSchema.BaseSchema;
80
+ path: (string | number)[];
81
+ }) => void;
82
+ io: "input" | "output";
83
+
84
+ counter = 0;
85
+ seen: Map<schemas.$ZodType, Seen>;
86
+
87
+ constructor(params?: JSONSchemaGeneratorParams) {
88
+ this.metadataRegistry = params?.metadata ?? globalRegistry;
89
+ this.target = params?.target ?? "draft-2020-12";
90
+ this.unrepresentable = params?.unrepresentable ?? "throw";
91
+ this.override = params?.override ?? (() => {});
92
+ this.io = params?.io ?? "output";
93
+
94
+ this.seen = new Map();
95
+ }
96
+
97
+ process(schema: schemas.$ZodType, _params: ProcessParams = { path: [], schemaPath: [] }): JSONSchema.BaseSchema {
98
+ const def = (schema as schemas.$ZodTypes)._zod.def;
99
+
100
+ const formatMap: Partial<Record<checks.$ZodStringFormats, string | undefined>> = {
101
+ guid: "uuid",
102
+ url: "uri",
103
+ datetime: "date-time",
104
+ json_string: "json-string",
105
+ regex: "", // do not set
106
+ };
107
+
108
+ // check for schema in seens
109
+ const seen = this.seen.get(schema);
110
+
111
+ if (seen) {
112
+ seen.count++;
113
+
114
+ // check if cycle
115
+ const isCycle = _params.schemaPath.includes(schema);
116
+ if (isCycle) {
117
+ seen.cycle = _params.path;
118
+ }
119
+
120
+ return seen.schema;
121
+ }
122
+
123
+ // initialize
124
+ const result: Seen = { schema: {}, count: 1, cycle: undefined, path: _params.path };
125
+ this.seen.set(schema, result);
126
+
127
+ // custom method overrides default behavior
128
+ const overrideSchema = schema._zod.toJSONSchema?.();
129
+ if (overrideSchema) {
130
+ result.schema = overrideSchema as any;
131
+ } else {
132
+ const params = {
133
+ ..._params,
134
+ schemaPath: [..._params.schemaPath, schema],
135
+ path: _params.path,
136
+ };
137
+
138
+ const parent = schema._zod.parent;
139
+
140
+ if (parent) {
141
+ // schema was cloned from another schema
142
+ result.ref = parent;
143
+ this.process(parent, params);
144
+ this.seen.get(parent)!.isParent = true;
145
+ } else {
146
+ const _json = result.schema;
147
+ switch (def.type) {
148
+ case "string": {
149
+ const json: JSONSchema.StringSchema = _json as any;
150
+ json.type = "string";
151
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
152
+ .bag as schemas.$ZodStringInternals<unknown>["bag"];
153
+ if (typeof minimum === "number") json.minLength = minimum;
154
+ if (typeof maximum === "number") json.maxLength = maximum;
155
+ // custom pattern overrides format
156
+ if (format) {
157
+ json.format = formatMap[format as checks.$ZodStringFormats] ?? format;
158
+ if (json.format === "") delete json.format; // empty format is not valid
159
+ }
160
+ if (contentEncoding) json.contentEncoding = contentEncoding;
161
+ if (patterns && patterns.size > 0) {
162
+ const regexes = [...patterns];
163
+ if (regexes.length === 1) json.pattern = regexes[0]!.source;
164
+ else if (regexes.length > 1) {
165
+ result.schema.allOf = [
166
+ ...regexes.map((regex) => ({
167
+ ...(this.target === "draft-7" || this.target === "draft-4" ? ({ type: "string" } as const) : {}),
168
+ pattern: regex.source,
169
+ })),
170
+ ];
171
+ }
172
+ }
173
+
174
+ break;
175
+ }
176
+ case "number": {
177
+ const json: JSONSchema.NumberSchema | JSONSchema.IntegerSchema = _json as any;
178
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
179
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
180
+ else json.type = "number";
181
+
182
+ if (typeof exclusiveMinimum === "number") {
183
+ if (this.target === "draft-4") {
184
+ json.minimum = exclusiveMinimum;
185
+ json.exclusiveMinimum = true;
186
+ } else {
187
+ json.exclusiveMinimum = exclusiveMinimum;
188
+ }
189
+ }
190
+ if (typeof minimum === "number") {
191
+ json.minimum = minimum;
192
+ if (typeof exclusiveMinimum === "number" && this.target !== "draft-4") {
193
+ if (exclusiveMinimum >= minimum) delete json.minimum;
194
+ else delete json.exclusiveMinimum;
195
+ }
196
+ }
197
+
198
+ if (typeof exclusiveMaximum === "number") {
199
+ if (this.target === "draft-4") {
200
+ json.maximum = exclusiveMaximum;
201
+ json.exclusiveMaximum = true;
202
+ } else {
203
+ json.exclusiveMaximum = exclusiveMaximum;
204
+ }
205
+ }
206
+ if (typeof maximum === "number") {
207
+ json.maximum = maximum;
208
+ if (typeof exclusiveMaximum === "number" && this.target !== "draft-4") {
209
+ if (exclusiveMaximum <= maximum) delete json.maximum;
210
+ else delete json.exclusiveMaximum;
211
+ }
212
+ }
213
+
214
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
215
+
216
+ break;
217
+ }
218
+ case "boolean": {
219
+ const json = _json as JSONSchema.BooleanSchema;
220
+ json.type = "boolean";
221
+ break;
222
+ }
223
+ case "bigint": {
224
+ if (this.unrepresentable === "throw") {
225
+ throw new Error("BigInt cannot be represented in JSON Schema");
226
+ }
227
+ break;
228
+ }
229
+ case "symbol": {
230
+ if (this.unrepresentable === "throw") {
231
+ throw new Error("Symbols cannot be represented in JSON Schema");
232
+ }
233
+ break;
234
+ }
235
+ case "null": {
236
+ _json.type = "null";
237
+ break;
238
+ }
239
+ case "any": {
240
+ break;
241
+ }
242
+ case "unknown": {
243
+ break;
244
+ }
245
+ case "undefined": {
246
+ if (this.unrepresentable === "throw") {
247
+ throw new Error("Undefined cannot be represented in JSON Schema");
248
+ }
249
+ break;
250
+ }
251
+ case "void": {
252
+ if (this.unrepresentable === "throw") {
253
+ throw new Error("Void cannot be represented in JSON Schema");
254
+ }
255
+ break;
256
+ }
257
+ case "never": {
258
+ _json.not = {};
259
+ break;
260
+ }
261
+ case "date": {
262
+ if (this.unrepresentable === "throw") {
263
+ throw new Error("Date cannot be represented in JSON Schema");
264
+ }
265
+ break;
266
+ }
267
+ case "array": {
268
+ const json: JSONSchema.ArraySchema = _json as any;
269
+ const { minimum, maximum } = schema._zod.bag;
270
+ if (typeof minimum === "number") json.minItems = minimum;
271
+ if (typeof maximum === "number") json.maxItems = maximum;
272
+
273
+ json.type = "array";
274
+ json.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
275
+ break;
276
+ }
277
+ case "object": {
278
+ const json: JSONSchema.ObjectSchema = _json as any;
279
+ json.type = "object";
280
+ json.properties = {};
281
+ const shape = def.shape; // params.shapeCache.get(schema)!;
282
+
283
+ for (const key in shape) {
284
+ json.properties[key] = this.process(shape[key]!, {
285
+ ...params,
286
+ path: [...params.path, "properties", key],
287
+ });
288
+ }
289
+
290
+ // required keys
291
+ const allKeys = new Set(Object.keys(shape));
292
+ // const optionalKeys = new Set(def.optional);
293
+ const requiredKeys = new Set(
294
+ [...allKeys].filter((key) => {
295
+ const v = def.shape[key]!._zod;
296
+ if (this.io === "input") {
297
+ return v.optin === undefined;
298
+ } else {
299
+ return v.optout === undefined;
300
+ }
301
+ })
302
+ );
303
+
304
+ if (requiredKeys.size > 0) {
305
+ json.required = Array.from(requiredKeys);
306
+ }
307
+
308
+ // catchall
309
+ if (def.catchall?._zod.def.type === "never") {
310
+ // strict
311
+ json.additionalProperties = false;
312
+ } else if (!def.catchall) {
313
+ // regular
314
+ if (this.io === "output") json.additionalProperties = false;
315
+ } else if (def.catchall) {
316
+ json.additionalProperties = this.process(def.catchall, {
317
+ ...params,
318
+ path: [...params.path, "additionalProperties"],
319
+ });
320
+ }
321
+
322
+ break;
323
+ }
324
+ case "union": {
325
+ const json: JSONSchema.BaseSchema = _json as any;
326
+ json.anyOf = def.options.map((x, i) =>
327
+ this.process(x, {
328
+ ...params,
329
+ path: [...params.path, "anyOf", i],
330
+ })
331
+ );
332
+ break;
333
+ }
334
+ case "intersection": {
335
+ const json: JSONSchema.BaseSchema = _json as any;
336
+ const a = this.process(def.left, {
337
+ ...params,
338
+ path: [...params.path, "allOf", 0],
339
+ });
340
+ const b = this.process(def.right, {
341
+ ...params,
342
+ path: [...params.path, "allOf", 1],
343
+ });
344
+
345
+ const isSimpleIntersection = (val: any) => "allOf" in val && Object.keys(val).length === 1;
346
+ const allOf = [
347
+ ...(isSimpleIntersection(a) ? (a.allOf as any[]) : [a]),
348
+ ...(isSimpleIntersection(b) ? (b.allOf as any[]) : [b]),
349
+ ];
350
+ json.allOf = allOf;
351
+ break;
352
+ }
353
+ case "tuple": {
354
+ const json: JSONSchema.ArraySchema = _json as any;
355
+ json.type = "array";
356
+ const prefixItems = def.items.map((x, i) =>
357
+ this.process(x, { ...params, path: [...params.path, "prefixItems", i] })
358
+ );
359
+ if (this.target === "draft-2020-12") {
360
+ json.prefixItems = prefixItems;
361
+ } else {
362
+ json.items = prefixItems;
363
+ }
364
+
365
+ if (def.rest) {
366
+ const rest = this.process(def.rest, {
367
+ ...params,
368
+ path: [...params.path, "items"],
369
+ });
370
+ if (this.target === "draft-2020-12") {
371
+ json.items = rest;
372
+ } else {
373
+ json.additionalItems = rest;
374
+ }
375
+ }
376
+
377
+ // additionalItems
378
+ if (def.rest) {
379
+ json.items = this.process(def.rest, {
380
+ ...params,
381
+ path: [...params.path, "items"],
382
+ });
383
+ }
384
+
385
+ // length
386
+ const { minimum, maximum } = schema._zod.bag as {
387
+ minimum?: number;
388
+ maximum?: number;
389
+ };
390
+ if (typeof minimum === "number") json.minItems = minimum;
391
+ if (typeof maximum === "number") json.maxItems = maximum;
392
+ break;
393
+ }
394
+ case "record": {
395
+ const json: JSONSchema.ObjectSchema = _json as any;
396
+ json.type = "object";
397
+ if (this.target !== "draft-4") {
398
+ json.propertyNames = this.process(def.keyType, {
399
+ ...params,
400
+ path: [...params.path, "propertyNames"],
401
+ });
402
+ }
403
+ json.additionalProperties = this.process(def.valueType, {
404
+ ...params,
405
+ path: [...params.path, "additionalProperties"],
406
+ });
407
+ break;
408
+ }
409
+ case "map": {
410
+ if (this.unrepresentable === "throw") {
411
+ throw new Error("Map cannot be represented in JSON Schema");
412
+ }
413
+ break;
414
+ }
415
+ case "set": {
416
+ if (this.unrepresentable === "throw") {
417
+ throw new Error("Set cannot be represented in JSON Schema");
418
+ }
419
+ break;
420
+ }
421
+ case "enum": {
422
+ const json: JSONSchema.BaseSchema = _json as any;
423
+ const values = getEnumValues(def.entries);
424
+ // Number enums can have both string and number values
425
+ if (values.every((v) => typeof v === "number")) json.type = "number";
426
+ if (values.every((v) => typeof v === "string")) json.type = "string";
427
+ json.enum = values;
428
+ break;
429
+ }
430
+ case "literal": {
431
+ const json: JSONSchema.BaseSchema = _json as any;
432
+ const vals: (string | number | boolean | null)[] = [];
433
+ for (const val of def.values) {
434
+ if (val === undefined) {
435
+ if (this.unrepresentable === "throw") {
436
+ throw new Error("Literal `undefined` cannot be represented in JSON Schema");
437
+ } else {
438
+ // do not add to vals
439
+ }
440
+ } else if (typeof val === "bigint") {
441
+ if (this.unrepresentable === "throw") {
442
+ throw new Error("BigInt literals cannot be represented in JSON Schema");
443
+ } else {
444
+ vals.push(Number(val));
445
+ }
446
+ } else {
447
+ vals.push(val);
448
+ }
449
+ }
450
+ if (vals.length === 0) {
451
+ // do nothing (an undefined literal was stripped)
452
+ } else if (vals.length === 1) {
453
+ const val = vals[0]!;
454
+ json.type = val === null ? ("null" as const) : (typeof val as any);
455
+ if (this.target === "draft-4") {
456
+ json.enum = [val];
457
+ } else {
458
+ json.const = val;
459
+ }
460
+ } else {
461
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
462
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
463
+ if (vals.every((v) => typeof v === "boolean")) json.type = "string";
464
+ if (vals.every((v) => v === null)) json.type = "null";
465
+ json.enum = vals;
466
+ }
467
+ break;
468
+ }
469
+
470
+ case "file": {
471
+ const json: JSONSchema.StringSchema = _json as any;
472
+ const file: JSONSchema.StringSchema = {
473
+ type: "string",
474
+ format: "binary",
475
+ contentEncoding: "binary",
476
+ };
477
+
478
+ const { minimum, maximum, mime } = schema._zod.bag as schemas.$ZodFileInternals["bag"];
479
+ if (minimum !== undefined) file.minLength = minimum;
480
+ if (maximum !== undefined) file.maxLength = maximum;
481
+ if (mime) {
482
+ if (mime.length === 1) {
483
+ file.contentMediaType = mime[0]!;
484
+ Object.assign(json, file);
485
+ } else {
486
+ json.anyOf = mime.map((m) => {
487
+ const mFile: JSONSchema.StringSchema = { ...file, contentMediaType: m };
488
+ return mFile;
489
+ });
490
+ }
491
+ } else {
492
+ Object.assign(json, file);
493
+ }
494
+
495
+ // if (this.unrepresentable === "throw") {
496
+ // throw new Error("File cannot be represented in JSON Schema");
497
+ // }
498
+ break;
499
+ }
500
+ case "transform": {
501
+ if (this.unrepresentable === "throw") {
502
+ throw new Error("Transforms cannot be represented in JSON Schema");
503
+ }
504
+ break;
505
+ }
506
+
507
+ case "nullable": {
508
+ const inner = this.process(def.innerType, params);
509
+ _json.anyOf = [inner, { type: "null" }];
510
+ break;
511
+ }
512
+ case "nonoptional": {
513
+ this.process(def.innerType, params);
514
+ result.ref = def.innerType;
515
+ break;
516
+ }
517
+ case "success": {
518
+ const json = _json as JSONSchema.BooleanSchema;
519
+ json.type = "boolean";
520
+ break;
521
+ }
522
+ case "default": {
523
+ this.process(def.innerType, params);
524
+ result.ref = def.innerType;
525
+ _json.default = JSON.parse(JSON.stringify(def.defaultValue));
526
+ break;
527
+ }
528
+ case "prefault": {
529
+ this.process(def.innerType, params);
530
+ result.ref = def.innerType;
531
+ if (this.io === "input") _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
532
+
533
+ break;
534
+ }
535
+ case "catch": {
536
+ // use conditionals
537
+ this.process(def.innerType, params);
538
+ result.ref = def.innerType;
539
+ let catchValue: any;
540
+ try {
541
+ catchValue = def.catchValue(undefined as any);
542
+ } catch {
543
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
544
+ }
545
+ _json.default = catchValue;
546
+ break;
547
+ }
548
+ case "nan": {
549
+ if (this.unrepresentable === "throw") {
550
+ throw new Error("NaN cannot be represented in JSON Schema");
551
+ }
552
+ break;
553
+ }
554
+ case "template_literal": {
555
+ const json = _json as JSONSchema.StringSchema;
556
+ const pattern = schema._zod.pattern;
557
+ if (!pattern) throw new Error("Pattern not found in template literal");
558
+ json.type = "string";
559
+ json.pattern = pattern.source;
560
+ break;
561
+ }
562
+ case "pipe": {
563
+ const innerType = this.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
564
+ this.process(innerType, params);
565
+ result.ref = innerType;
566
+ break;
567
+ }
568
+ case "readonly": {
569
+ this.process(def.innerType, params);
570
+ result.ref = def.innerType;
571
+ _json.readOnly = true;
572
+ break;
573
+ }
574
+ // passthrough types
575
+ case "promise": {
576
+ this.process(def.innerType, params);
577
+ result.ref = def.innerType;
578
+ break;
579
+ }
580
+ case "optional": {
581
+ this.process(def.innerType, params);
582
+ result.ref = def.innerType;
583
+ break;
584
+ }
585
+ case "lazy": {
586
+ const innerType = (schema as schemas.$ZodLazy)._zod.innerType;
587
+ this.process(innerType, params);
588
+ result.ref = innerType;
589
+ break;
590
+ }
591
+ case "custom": {
592
+ if (this.unrepresentable === "throw") {
593
+ throw new Error("Custom types cannot be represented in JSON Schema");
594
+ }
595
+ break;
596
+ }
597
+ default: {
598
+ def satisfies never;
599
+ }
600
+ }
601
+ }
602
+ }
603
+
604
+ // metadata
605
+ const meta = this.metadataRegistry.get(schema);
606
+ if (meta) Object.assign(result.schema, meta);
607
+
608
+ if (this.io === "input" && isTransforming(schema)) {
609
+ // examples/defaults only apply to output type of pipe
610
+ delete result.schema.examples;
611
+ delete result.schema.default;
612
+ }
613
+
614
+ // set prefault as default
615
+ if (this.io === "input" && result.schema._prefault) result.schema.default ??= result.schema._prefault;
616
+ delete result.schema._prefault;
617
+
618
+ // pulling fresh from this.seen in case it was overwritten
619
+ const _result = this.seen.get(schema)!;
620
+
621
+ return _result.schema;
622
+ }
623
+
624
+ emit(schema: schemas.$ZodType, _params?: EmitParams): JSONSchema.BaseSchema {
625
+ const params = {
626
+ cycles: _params?.cycles ?? "ref",
627
+ reused: _params?.reused ?? "inline",
628
+ // unrepresentable: _params?.unrepresentable ?? "throw",
629
+ // uri: _params?.uri ?? ((id) => `${id}`),
630
+ external: _params?.external ?? undefined,
631
+ } satisfies EmitParams;
632
+
633
+ // iterate over seen map;
634
+ const root = this.seen.get(schema);
635
+
636
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
637
+
638
+ // initialize result with root schema fields
639
+ // Object.assign(result, seen.cached);
640
+
641
+ // returns a ref to the schema
642
+ // defId will be empty if the ref points to an external schema (or #)
643
+ const makeURI = (entry: [schemas.$ZodType<unknown, unknown>, Seen]): { ref: string; defId?: string } => {
644
+ // comparing the seen objects because sometimes
645
+ // multiple schemas map to the same seen object.
646
+ // e.g. lazy
647
+
648
+ // external is configured
649
+ const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
650
+ if (params.external) {
651
+ const externalId = params.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${this.counter++}`;
652
+
653
+ // check if schema is in the external registry
654
+ const uriGenerator = params.external.uri ?? ((id) => id);
655
+ if (externalId) {
656
+ return { ref: uriGenerator(externalId) };
657
+ }
658
+
659
+ // otherwise, add to __shared
660
+ const id: string = entry[1].defId ?? (entry[1].schema.id as string) ?? `schema${this.counter++}`;
661
+ entry[1].defId = id; // set defId so it will be reused if needed
662
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
663
+ }
664
+
665
+ if (entry[1] === root) {
666
+ return { ref: "#" };
667
+ }
668
+
669
+ // self-contained schema
670
+ const uriPrefix = `#`;
671
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
672
+ const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
673
+ return { defId, ref: defUriPrefix + defId };
674
+ };
675
+
676
+ // stored cached version in `def` property
677
+ // remove all properties, set $ref
678
+ const extractToDef = (entry: [schemas.$ZodType<unknown, unknown>, Seen]): void => {
679
+ // if the schema is already a reference, do not extract it
680
+ if (entry[1].schema.$ref) {
681
+ return;
682
+ }
683
+ const seen = entry[1];
684
+ const { ref, defId } = makeURI(entry);
685
+
686
+ seen.def = { ...seen.schema };
687
+ // defId won't be set if the schema is a reference to an external schema
688
+ if (defId) seen.defId = defId;
689
+ // wipe away all properties except $ref
690
+ const schema = seen.schema;
691
+ for (const key in schema) {
692
+ delete schema[key];
693
+ }
694
+ schema.$ref = ref;
695
+ };
696
+
697
+ // throw on cycles
698
+
699
+ // break cycles
700
+ if (params.cycles === "throw") {
701
+ for (const entry of this.seen.entries()) {
702
+ const seen = entry[1];
703
+ if (seen.cycle) {
704
+ throw new Error(
705
+ "Cycle detected: " +
706
+ `#/${seen.cycle?.join("/")}/<root>` +
707
+ '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.'
708
+ );
709
+ }
710
+ }
711
+ }
712
+
713
+ // extract schemas into $defs
714
+ for (const entry of this.seen.entries()) {
715
+ const seen = entry[1];
716
+
717
+ // convert root schema to # $ref
718
+ if (schema === entry[0]) {
719
+ extractToDef(entry); // this has special handling for the root schema
720
+ continue;
721
+ }
722
+
723
+ // extract schemas that are in the external registry
724
+ if (params.external) {
725
+ const ext = params.external.registry.get(entry[0])?.id;
726
+ if (schema !== entry[0] && ext) {
727
+ extractToDef(entry);
728
+ continue;
729
+ }
730
+ }
731
+
732
+ // extract schemas with `id` meta
733
+ const id = this.metadataRegistry.get(entry[0])?.id;
734
+ if (id) {
735
+ extractToDef(entry);
736
+ continue;
737
+ }
738
+
739
+ // break cycles
740
+ if (seen.cycle) {
741
+ // any
742
+ extractToDef(entry);
743
+ continue;
744
+ }
745
+
746
+ // extract reused schemas
747
+ if (seen.count > 1) {
748
+ if (params.reused === "ref") {
749
+ extractToDef(entry);
750
+ // biome-ignore lint:
751
+ continue;
752
+ }
753
+ }
754
+ }
755
+
756
+ // flatten _refs
757
+ const flattenRef = (zodSchema: schemas.$ZodType, params: Pick<ToJSONSchemaParams, "target">) => {
758
+ const seen = this.seen.get(zodSchema)!;
759
+ const schema = seen.def ?? seen.schema;
760
+
761
+ const _cached = { ...schema };
762
+
763
+ // already seen
764
+ if (seen.ref === null) {
765
+ return;
766
+ }
767
+
768
+ // flatten ref if defined
769
+ const ref = seen.ref;
770
+ seen.ref = null; // prevent recursion
771
+ if (ref) {
772
+ flattenRef(ref, params);
773
+
774
+ // merge referenced schema into current
775
+ const refSchema = this.seen.get(ref)!.schema;
776
+ if (refSchema.$ref && (params.target === "draft-7" || params.target === "draft-4")) {
777
+ schema.allOf = schema.allOf ?? [];
778
+ schema.allOf.push(refSchema);
779
+ } else {
780
+ Object.assign(schema, refSchema);
781
+ Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
782
+ }
783
+ }
784
+
785
+ // execute overrides
786
+ if (!seen.isParent)
787
+ this.override({
788
+ zodSchema: zodSchema as schemas.$ZodTypes,
789
+ jsonSchema: schema,
790
+ path: seen.path ?? [],
791
+ });
792
+ };
793
+
794
+ for (const entry of [...this.seen.entries()].reverse()) {
795
+ flattenRef(entry[0], { target: this.target });
796
+ }
797
+
798
+ const result: JSONSchema.BaseSchema = {};
799
+ if (this.target === "draft-2020-12") {
800
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
801
+ } else if (this.target === "draft-7") {
802
+ result.$schema = "http://json-schema.org/draft-07/schema#";
803
+ } else if (this.target === "draft-4") {
804
+ result.$schema = "http://json-schema.org/draft-04/schema#";
805
+ } else {
806
+ // @ts-ignore
807
+ console.warn(`Invalid target: ${this.target}`);
808
+ }
809
+
810
+ if (params.external?.uri) {
811
+ const id = params.external.registry.get(schema)?.id;
812
+ if (!id) throw new Error("Schema is missing an `id` property");
813
+ result.$id = params.external.uri(id);
814
+ }
815
+
816
+ Object.assign(result, root.def);
817
+
818
+ // build defs object
819
+ const defs: JSONSchema.BaseSchema["$defs"] = params.external?.defs ?? {};
820
+ for (const entry of this.seen.entries()) {
821
+ const seen = entry[1];
822
+ if (seen.def && seen.defId) {
823
+ defs[seen.defId] = seen.def;
824
+ }
825
+ }
826
+
827
+ // set definitions in result
828
+ if (params.external) {
829
+ } else {
830
+ if (Object.keys(defs).length > 0) {
831
+ if (this.target === "draft-2020-12") {
832
+ result.$defs = defs;
833
+ } else {
834
+ result.definitions = defs;
835
+ }
836
+ }
837
+ }
838
+
839
+ try {
840
+ // this "finalizes" this schema and ensures all cycles are removed
841
+ // each call to .emit() is functionally independent
842
+ // though the seen map is shared
843
+ return JSON.parse(JSON.stringify(result));
844
+ } catch (_err) {
845
+ throw new Error("Error converting schema to JSON.");
846
+ }
847
+ }
848
+ }
849
+
850
+ interface ToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {}
851
+ interface RegistryToJSONSchemaParams extends Omit<JSONSchemaGeneratorParams & EmitParams, "external"> {
852
+ uri?: (id: string) => string;
853
+ }
854
+
855
+ export function toJSONSchema(schema: schemas.$ZodType, _params?: ToJSONSchemaParams): JSONSchema.BaseSchema;
856
+ export function toJSONSchema(
857
+ registry: $ZodRegistry<{ id?: string | undefined }>,
858
+ _params?: RegistryToJSONSchemaParams
859
+ ): { schemas: Record<string, JSONSchema.BaseSchema> };
860
+ export function toJSONSchema(
861
+ input: schemas.$ZodType | $ZodRegistry<{ id?: string | undefined }>,
862
+ _params?: ToJSONSchemaParams
863
+ ): any {
864
+ if (input instanceof $ZodRegistry) {
865
+ const gen = new JSONSchemaGenerator(_params);
866
+ const defs: any = {};
867
+ for (const entry of input._idmap.entries()) {
868
+ const [_, schema] = entry;
869
+ gen.process(schema);
870
+ }
871
+
872
+ const schemas: Record<string, JSONSchema.BaseSchema> = {};
873
+ const external = {
874
+ registry: input,
875
+ uri: (_params as RegistryToJSONSchemaParams)?.uri,
876
+ defs,
877
+ };
878
+ for (const entry of input._idmap.entries()) {
879
+ const [key, schema] = entry;
880
+ schemas[key] = gen.emit(schema, {
881
+ ..._params,
882
+ external,
883
+ });
884
+ }
885
+
886
+ if (Object.keys(defs).length > 0) {
887
+ const defsSegment = gen.target === "draft-2020-12" ? "$defs" : "definitions";
888
+ schemas.__shared = {
889
+ [defsSegment]: defs,
890
+ };
891
+ }
892
+
893
+ return { schemas };
894
+ }
895
+
896
+ const gen = new JSONSchemaGenerator(_params);
897
+ gen.process(input);
898
+
899
+ return gen.emit(input, _params);
900
+ }
901
+
902
+ function isTransforming(
903
+ _schema: schemas.$ZodType,
904
+ _ctx?: {
905
+ seen: Set<schemas.$ZodType>;
906
+ }
907
+ ): boolean {
908
+ const ctx = _ctx ?? { seen: new Set() };
909
+
910
+ if (ctx.seen.has(_schema)) return false;
911
+ ctx.seen.add(_schema);
912
+
913
+ const schema = _schema as schemas.$ZodTypes;
914
+ const def = schema._zod.def;
915
+ switch (def.type) {
916
+ case "string":
917
+ case "number":
918
+ case "bigint":
919
+ case "boolean":
920
+ case "date":
921
+ case "symbol":
922
+ case "undefined":
923
+ case "null":
924
+ case "any":
925
+ case "unknown":
926
+ case "never":
927
+ case "void":
928
+ case "literal":
929
+ case "enum":
930
+ case "nan":
931
+ case "file":
932
+ case "template_literal":
933
+ return false;
934
+ case "array": {
935
+ return isTransforming(def.element, ctx);
936
+ }
937
+ case "object": {
938
+ for (const key in def.shape) {
939
+ if (isTransforming(def.shape[key]!, ctx)) return true;
940
+ }
941
+ return false;
942
+ }
943
+ case "union": {
944
+ for (const option of def.options) {
945
+ if (isTransforming(option, ctx)) return true;
946
+ }
947
+ return false;
948
+ }
949
+ case "intersection": {
950
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
951
+ }
952
+ case "tuple": {
953
+ for (const item of def.items) {
954
+ if (isTransforming(item, ctx)) return true;
955
+ }
956
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
957
+ return false;
958
+ }
959
+ case "record": {
960
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
961
+ }
962
+ case "map": {
963
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
964
+ }
965
+ case "set": {
966
+ return isTransforming(def.valueType, ctx);
967
+ }
968
+
969
+ // inner types
970
+ case "promise":
971
+ case "optional":
972
+ case "nonoptional":
973
+ case "nullable":
974
+ case "readonly":
975
+ return isTransforming(def.innerType, ctx);
976
+ case "lazy":
977
+ return isTransforming(def.getter(), ctx);
978
+ case "default": {
979
+ return isTransforming(def.innerType, ctx);
980
+ }
981
+ case "prefault": {
982
+ return isTransforming(def.innerType, ctx);
983
+ }
984
+ case "custom": {
985
+ return false;
986
+ }
987
+ case "transform": {
988
+ return true;
989
+ }
990
+ case "pipe": {
991
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
992
+ }
993
+ case "success": {
994
+ return false;
995
+ }
996
+ case "catch": {
997
+ return false;
998
+ }
999
+
1000
+ default:
1001
+ def satisfies never;
1002
+ }
1003
+ throw new Error(`Unknown schema type: ${(def as any).type}`);
1004
+ }