@psnext/slingcli 3.0.20260827-1 → 3.3.20260911-1

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 (976) hide show
  1. package/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +5 -0
  2. package/node_modules/@aws-sdk/core/dist-es/submodules/util/hasOwn.js +3 -0
  3. package/node_modules/@aws-sdk/core/dist-es/submodules/util/index.js +1 -0
  4. package/node_modules/@aws-sdk/core/dist-types/submodules/util/hasOwn.d.ts +4 -0
  5. package/node_modules/@aws-sdk/core/dist-types/submodules/util/index.d.ts +1 -0
  6. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/hasOwn.d.ts +1 -0
  7. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/index.d.ts +1 -0
  8. package/node_modules/@aws-sdk/core/package.json +1 -1
  9. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  10. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -4
  11. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +1 -0
  12. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +2 -3
  13. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +8 -1
  14. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +2 -2
  15. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  16. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  17. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  18. package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +2 -0
  19. package/node_modules/@aws-sdk/credential-provider-node/dist-es/runtime/memoize-chain.js +2 -0
  20. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  21. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  22. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +3 -3
  23. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  24. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  25. package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
  26. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  27. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  28. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  29. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  30. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  31. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -4
  32. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +1 -0
  33. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +2 -3
  34. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +8 -1
  35. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +2 -2
  36. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  37. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-PBNSMEG7.js → chunk-VDBOM5UG.js} +9 -9
  38. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js +1 -1
  39. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/index.js +1 -1
  40. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/rpc-entry.js +1 -1
  41. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/Client.md +25 -8
  42. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +3 -2
  43. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/EventSource.md +4 -0
  44. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/Interceptors.md +7 -3
  45. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +7 -1
  46. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/api/readable.js +33 -43
  47. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/cache/memory-cache-store.js +2 -2
  48. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/core/connect.js +16 -2
  49. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/core/symbols.js +3 -0
  50. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/agent.js +7 -2
  51. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/balanced-pool.js +7 -4
  52. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h1.js +9 -1
  53. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js +221 -12
  54. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js +76 -30
  55. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/dispatcher-base.js +13 -1
  56. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/dispatcher.js +15 -1
  57. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -0
  58. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +37 -8
  59. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -1
  60. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/retry-agent.js +3 -0
  61. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/round-robin-pool.js +1 -1
  62. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +106 -22
  63. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/cache-handler.js +29 -5
  64. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/decorator-handler.js +7 -1
  65. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/deduplication-handler.js +12 -6
  66. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/redirect-handler.js +21 -4
  67. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/retry-handler.js +155 -32
  68. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/cache.js +65 -9
  69. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/decompress.js +115 -13
  70. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/deduplicate.js +5 -4
  71. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/dns.js +7 -0
  72. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/dump.js +10 -23
  73. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/mock/mock-agent.js +13 -1
  74. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/mock/mock-utils.js +217 -27
  75. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/util/cache.js +43 -3
  76. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/cookies/parse.js +150 -147
  77. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/eventsource/eventsource-stream.js +28 -1
  78. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/eventsource/eventsource.js +13 -3
  79. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/fetch/index.js +6 -0
  80. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/fetch/request.js +2 -3
  81. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/fetch/util.js +6 -1
  82. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/webidl/index.js +3 -3
  83. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/connection.js +1 -1
  84. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
  85. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
  86. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/websocket.js +22 -0
  87. package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/package.json +3 -3
  88. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +4 -4
  89. package/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  90. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  91. package/node_modules/@smithy/core/dist-cjs/submodules/errors/index.js +20 -0
  92. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +11 -10
  93. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +11 -10
  94. package/node_modules/@smithy/core/dist-es/submodules/errors/errors.js +18 -0
  95. package/node_modules/@smithy/core/dist-es/submodules/errors/index.js +1 -0
  96. package/node_modules/@smithy/core/dist-es/submodules/retry/service-error-classification/service-error-classification.js +11 -10
  97. package/node_modules/@smithy/core/dist-types/submodules/errors/errors.d.ts +44 -0
  98. package/node_modules/@smithy/core/dist-types/submodules/errors/index.d.ts +1 -0
  99. package/node_modules/@smithy/core/dist-types/submodules/retry/service-error-classification/service-error-classification.d.ts +4 -0
  100. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/errors/errors.d.ts +44 -0
  101. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/errors/index.d.ts +1 -0
  102. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/service-error-classification/service-error-classification.d.ts +4 -0
  103. package/node_modules/@smithy/core/errors.d.ts +5 -0
  104. package/node_modules/@smithy/core/errors.js +5 -0
  105. package/node_modules/@smithy/core/package.json +11 -2
  106. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -1
  107. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +2 -1
  108. package/node_modules/@smithy/fetch-http-handler/package.json +3 -3
  109. package/node_modules/@smithy/types/dist-types/http/httpHandlerInitialization.d.ts +14 -0
  110. package/node_modules/@smithy/types/dist-types/ts3.4/http/httpHandlerInitialization.d.ts +14 -0
  111. package/node_modules/@smithy/types/package.json +1 -1
  112. package/node_modules/@types/node/README.md +3 -3
  113. package/node_modules/@types/node/assert/strict.d.ts +56 -13
  114. package/node_modules/@types/node/assert.d.ts +190 -189
  115. package/node_modules/@types/node/async_hooks.d.ts +43 -151
  116. package/node_modules/@types/node/buffer.buffer.d.ts +13 -12
  117. package/node_modules/@types/node/buffer.d.ts +237 -102
  118. package/node_modules/@types/node/child_process.d.ts +154 -39
  119. package/node_modules/@types/node/cluster.d.ts +384 -238
  120. package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  121. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  122. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  123. package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
  124. package/node_modules/@types/node/console.d.ts +404 -45
  125. package/node_modules/@types/node/constants.d.ts +10 -3
  126. package/node_modules/@types/node/crypto.d.ts +1600 -1007
  127. package/node_modules/@types/node/dgram.d.ts +81 -133
  128. package/node_modules/@types/node/diagnostics_channel.d.ts +59 -277
  129. package/node_modules/@types/node/dns/promises.d.ts +15 -9
  130. package/node_modules/@types/node/dns.d.ts +183 -136
  131. package/node_modules/@types/node/domain.d.ts +32 -12
  132. package/node_modules/@types/node/events.d.ts +696 -728
  133. package/node_modules/@types/node/fs/promises.d.ts +85 -256
  134. package/node_modules/@types/node/fs.d.ts +525 -865
  135. package/node_modules/@types/node/globals.d.ts +34 -12
  136. package/node_modules/@types/node/globals.typedarray.d.ts +0 -63
  137. package/node_modules/@types/node/http.d.ts +311 -432
  138. package/node_modules/@types/node/http2.d.ts +891 -545
  139. package/node_modules/@types/node/https.d.ts +243 -64
  140. package/node_modules/@types/node/index.d.ts +7 -25
  141. package/node_modules/@types/node/inspector.d.ts +58 -70
  142. package/node_modules/@types/node/inspector.generated.d.ts +411 -765
  143. package/node_modules/@types/node/module.d.ts +219 -54
  144. package/node_modules/@types/node/net.d.ts +222 -208
  145. package/node_modules/@types/node/os.d.ts +49 -41
  146. package/node_modules/@types/node/package.json +3 -13
  147. package/node_modules/@types/node/path.d.ts +141 -119
  148. package/node_modules/@types/node/perf_hooks.d.ts +673 -310
  149. package/node_modules/@types/node/process.d.ts +205 -389
  150. package/node_modules/@types/node/punycode.d.ts +31 -3
  151. package/node_modules/@types/node/querystring.d.ts +16 -3
  152. package/node_modules/@types/node/readline/promises.d.ts +6 -3
  153. package/node_modules/@types/node/readline.d.ts +152 -66
  154. package/node_modules/@types/node/repl.d.ts +109 -101
  155. package/node_modules/@types/node/sea.d.ts +116 -1
  156. package/node_modules/@types/node/sqlite.d.ts +68 -486
  157. package/node_modules/@types/node/stream/consumers.d.ts +15 -91
  158. package/node_modules/@types/node/stream/promises.d.ts +15 -136
  159. package/node_modules/@types/node/stream/web.d.ts +456 -179
  160. package/node_modules/@types/node/stream.d.ts +491 -603
  161. package/node_modules/@types/node/string_decoder.d.ts +43 -3
  162. package/node_modules/@types/node/test.d.ts +292 -513
  163. package/node_modules/@types/node/timers/promises.d.ts +18 -3
  164. package/node_modules/@types/node/timers.d.ts +141 -3
  165. package/node_modules/@types/node/tls.d.ts +242 -140
  166. package/node_modules/@types/node/trace_events.d.ts +97 -3
  167. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +8 -7
  168. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -2
  169. package/node_modules/@types/node/ts5.6/index.d.ts +6 -26
  170. package/node_modules/@types/node/tty.d.ts +43 -61
  171. package/node_modules/@types/node/url.d.ts +584 -156
  172. package/node_modules/@types/node/util.d.ts +1110 -181
  173. package/node_modules/@types/node/v8.d.ts +36 -175
  174. package/node_modules/@types/node/vm.d.ts +209 -292
  175. package/node_modules/@types/node/wasi.d.ts +74 -24
  176. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +2 -27
  177. package/node_modules/@types/node/web-globals/domexception.d.ts +0 -15
  178. package/node_modules/@types/node/web-globals/events.d.ts +0 -9
  179. package/node_modules/@types/node/web-globals/fetch.d.ts +0 -14
  180. package/node_modules/@types/node/web-globals/navigator.d.ts +0 -3
  181. package/node_modules/@types/node/web-globals/streams.d.ts +0 -93
  182. package/node_modules/@types/node/worker_threads.d.ts +407 -257
  183. package/node_modules/@types/node/zlib.d.ts +165 -7
  184. package/node_modules/express-rate-limit/dist/index.cjs +6 -3
  185. package/node_modules/express-rate-limit/dist/index.d.cts +11 -0
  186. package/node_modules/express-rate-limit/dist/index.d.mts +11 -0
  187. package/node_modules/express-rate-limit/dist/index.d.ts +11 -0
  188. package/node_modules/express-rate-limit/dist/index.mjs +6 -3
  189. package/node_modules/express-rate-limit/{license.md → license} +7 -6
  190. package/node_modules/express-rate-limit/package.json +5 -5
  191. package/node_modules/express-rate-limit/readme.md +1 -0
  192. package/node_modules/fast-uri/index.js +20 -5
  193. package/node_modules/fast-uri/lib/utils.js +8 -1
  194. package/node_modules/fast-uri/package.json +1 -1
  195. package/node_modules/fast-uri/test/component-safe-serialization.test.js +58 -0
  196. package/node_modules/fast-uri/test/ipv6-validation.test.js +34 -0
  197. package/node_modules/hono/dist/cjs/client/client.js +4 -4
  198. package/node_modules/hono/dist/cjs/hono-base.js +7 -6
  199. package/node_modules/hono/dist/cjs/jsx/base.js +18 -1
  200. package/node_modules/hono/dist/cjs/jsx/components.js +25 -26
  201. package/node_modules/hono/dist/cjs/jsx/context.js +5 -5
  202. package/node_modules/hono/dist/cjs/jsx/dom/server.js +5 -1
  203. package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +2 -2
  204. package/node_modules/hono/dist/cjs/jsx/streaming.js +4 -5
  205. package/node_modules/hono/dist/client/client.js +4 -4
  206. package/node_modules/hono/dist/hono-base.js +7 -6
  207. package/node_modules/hono/dist/jsx/base.js +15 -1
  208. package/node_modules/hono/dist/jsx/components.js +26 -27
  209. package/node_modules/hono/dist/jsx/context.js +6 -6
  210. package/node_modules/hono/dist/jsx/dom/server.js +5 -1
  211. package/node_modules/hono/dist/jsx/intrinsic-element/components.js +3 -3
  212. package/node_modules/hono/dist/jsx/streaming.js +5 -6
  213. package/node_modules/hono/dist/types/context.d.ts +2 -2
  214. package/node_modules/hono/dist/types/jsx/base.d.ts +3 -0
  215. package/node_modules/hono/package.json +2 -2
  216. package/node_modules/ip-address/README.md +92 -82
  217. package/node_modules/ip-address/dist/common.d.ts +20 -0
  218. package/node_modules/ip-address/dist/common.js +36 -0
  219. package/node_modules/ip-address/dist/common.js.map +1 -1
  220. package/node_modules/ip-address/dist/ipv4.d.ts +50 -0
  221. package/node_modules/ip-address/dist/ipv4.js +75 -0
  222. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  223. package/node_modules/ip-address/dist/ipv6.d.ts +79 -10
  224. package/node_modules/ip-address/dist/ipv6.js +120 -30
  225. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  226. package/node_modules/ip-address/dist/v4/constants.d.ts +12 -0
  227. package/node_modules/ip-address/dist/v4/constants.js +40 -1
  228. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  229. package/node_modules/ip-address/dist/v6/constants.d.ts +14 -0
  230. package/node_modules/ip-address/dist/v6/constants.js +47 -1
  231. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  232. package/node_modules/ip-address/package.json +1 -1
  233. package/node_modules/jose/dist/types/index.d.ts +1 -2
  234. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +12 -25
  235. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +18 -32
  236. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +12 -25
  237. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +24 -50
  238. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +15 -30
  239. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +29 -52
  240. package/node_modules/jose/dist/types/jwk/embedded.d.ts +5 -8
  241. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +7 -9
  242. package/node_modules/jose/dist/types/jwks/local.d.ts +10 -13
  243. package/node_modules/jose/dist/types/jwks/remote.d.ts +29 -41
  244. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +8 -13
  245. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +14 -26
  246. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +10 -19
  247. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +14 -26
  248. package/node_modules/jose/dist/types/jws/general/sign.d.ts +19 -33
  249. package/node_modules/jose/dist/types/jws/general/verify.d.ts +17 -32
  250. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +20 -27
  251. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +30 -35
  252. package/node_modules/jose/dist/types/jwt/sign.d.ts +8 -13
  253. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +10 -19
  254. package/node_modules/jose/dist/types/jwt/verify.d.ts +19 -22
  255. package/node_modules/jose/dist/types/key/export.d.ts +10 -10
  256. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +15 -22
  257. package/node_modules/jose/dist/types/key/generate_secret.d.ts +12 -19
  258. package/node_modules/jose/dist/types/key/import.d.ts +25 -31
  259. package/node_modules/jose/dist/types/types.d.ts +184 -319
  260. package/node_modules/jose/dist/types/util/base64url.d.ts +7 -7
  261. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +5 -7
  262. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +6 -5
  263. package/node_modules/jose/dist/types/util/errors.d.ts +50 -88
  264. package/node_modules/jose/dist/webapi/index.js +70 -32
  265. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +6 -8
  266. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +25 -48
  267. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +14 -14
  268. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +34 -64
  269. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +38 -49
  270. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +100 -172
  271. package/node_modules/jose/dist/webapi/jwk/embedded.js +29 -32
  272. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +51 -70
  273. package/node_modules/jose/dist/webapi/jwks/local.js +53 -64
  274. package/node_modules/jose/dist/webapi/jwks/remote.js +88 -136
  275. package/node_modules/jose/dist/webapi/jws/compact/sign.js +19 -21
  276. package/node_modules/jose/dist/webapi/jws/compact/verify.js +7 -8
  277. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +22 -31
  278. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +11 -24
  279. package/node_modules/jose/dist/webapi/jws/general/sign.js +55 -73
  280. package/node_modules/jose/dist/webapi/jws/general/verify.js +43 -69
  281. package/node_modules/jose/dist/webapi/jwt/decrypt.js +12 -20
  282. package/node_modules/jose/dist/webapi/jwt/encrypt.js +43 -70
  283. package/node_modules/jose/dist/webapi/jwt/sign.js +17 -16
  284. package/node_modules/jose/dist/webapi/jwt/unsecured.js +31 -40
  285. package/node_modules/jose/dist/webapi/jwt/verify.js +12 -14
  286. package/node_modules/jose/dist/webapi/key/export.js +32 -41
  287. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +32 -49
  288. package/node_modules/jose/dist/webapi/key/generate_secret.js +35 -40
  289. package/node_modules/jose/dist/webapi/key/import.js +48 -56
  290. package/node_modules/jose/dist/webapi/lib/asn1.js +128 -169
  291. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +72 -41
  292. package/node_modules/jose/dist/webapi/lib/content_encryption.js +75 -119
  293. package/node_modules/jose/dist/webapi/lib/deflate.js +35 -47
  294. package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +102 -93
  295. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +178 -234
  296. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +71 -138
  297. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +62 -61
  298. package/node_modules/jose/dist/webapi/lib/jws_sign.js +43 -82
  299. package/node_modules/jose/dist/webapi/lib/jws_verify.js +78 -131
  300. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +123 -209
  301. package/node_modules/jose/dist/webapi/lib/key.js +147 -139
  302. package/node_modules/jose/dist/webapi/lib/key_algorithm.js +13 -8
  303. package/node_modules/jose/dist/webapi/lib/key_descriptor.js +8 -6
  304. package/node_modules/jose/dist/webapi/lib/key_management.js +169 -235
  305. package/node_modules/jose/dist/webapi/lib/validate.js +122 -0
  306. package/node_modules/jose/dist/webapi/util/base64url.js +14 -37
  307. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -31
  308. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +18 -23
  309. package/node_modules/jose/dist/webapi/util/errors.js +94 -84
  310. package/node_modules/jose/package.json +17 -81
  311. package/node_modules/protobufjs/dist/light/protobuf.js +59 -6
  312. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  313. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  314. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  315. package/node_modules/protobufjs/dist/minimal/protobuf.js +22 -2
  316. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  317. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  318. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  319. package/node_modules/protobufjs/dist/protobuf.js +59 -6
  320. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  321. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  322. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  323. package/node_modules/protobufjs/package.json +1 -1
  324. package/node_modules/protobufjs/src/decoder.js +32 -3
  325. package/node_modules/protobufjs/src/reader.js +20 -0
  326. package/node_modules/protobufjs/src/wrappers.js +5 -1
  327. package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  328. package/node_modules/qs/CHANGELOG.md +15 -0
  329. package/node_modules/qs/README.md +19 -1
  330. package/node_modules/qs/dist/qs.js +21 -21
  331. package/node_modules/qs/eslint.config.mjs +1 -1
  332. package/node_modules/qs/lib/parse.js +3 -4
  333. package/node_modules/qs/lib/stringify.js +23 -8
  334. package/node_modules/qs/lib/utils.js +10 -3
  335. package/node_modules/qs/package.json +4 -4
  336. package/node_modules/qs/test/parse.js +192 -3
  337. package/node_modules/qs/test/stringify.js +317 -0
  338. package/node_modules/qs/test/utils.js +12 -0
  339. package/node_modules/undici/lib/dispatcher/balanced-pool.js +4 -2
  340. package/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
  341. package/node_modules/undici/lib/dispatcher/client-h2.js +70 -14
  342. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  343. package/node_modules/undici/lib/handler/cache-handler.js +21 -5
  344. package/node_modules/undici/lib/handler/retry-handler.js +42 -7
  345. package/node_modules/undici/lib/interceptor/cache.js +20 -1
  346. package/node_modules/undici/lib/interceptor/decompress.js +146 -14
  347. package/node_modules/undici/lib/interceptor/dump.js +10 -23
  348. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
  349. package/node_modules/undici/lib/web/websocket/connection.js +1 -1
  350. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
  351. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
  352. package/node_modules/undici/package.json +1 -1
  353. package/node_modules/undici/types/interceptors.d.ts +2 -0
  354. package/node_modules/undici-types/agent.d.ts +13 -12
  355. package/node_modules/undici-types/api.d.ts +26 -26
  356. package/node_modules/undici-types/balanced-pool.d.ts +12 -13
  357. package/node_modules/undici-types/client.d.ts +34 -55
  358. package/node_modules/undici-types/connector.d.ts +2 -4
  359. package/node_modules/undici-types/cookies.d.ts +0 -2
  360. package/node_modules/undici-types/diagnostics-channel.d.ts +10 -18
  361. package/node_modules/undici-types/dispatcher.d.ts +137 -134
  362. package/node_modules/undici-types/env-http-proxy-agent.d.ts +3 -4
  363. package/node_modules/undici-types/errors.d.ts +54 -82
  364. package/node_modules/undici-types/eventsource.d.ts +4 -9
  365. package/node_modules/undici-types/fetch.d.ts +24 -46
  366. package/node_modules/undici-types/file.d.ts +39 -0
  367. package/node_modules/undici-types/filereader.d.ts +54 -0
  368. package/node_modules/undici-types/formdata.d.ts +7 -7
  369. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  370. package/node_modules/undici-types/global-origin.d.ts +5 -5
  371. package/node_modules/undici-types/handlers.d.ts +9 -8
  372. package/node_modules/undici-types/header.d.ts +1 -162
  373. package/node_modules/undici-types/index.d.ts +47 -69
  374. package/node_modules/undici-types/interceptors.d.ts +9 -72
  375. package/node_modules/undici-types/mock-agent.d.ts +18 -36
  376. package/node_modules/undici-types/mock-client.d.ts +4 -6
  377. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  378. package/node_modules/undici-types/mock-interceptor.d.ts +20 -21
  379. package/node_modules/undici-types/mock-pool.d.ts +4 -6
  380. package/node_modules/undici-types/package.json +1 -1
  381. package/node_modules/undici-types/patch.d.ts +4 -0
  382. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  383. package/node_modules/undici-types/pool.d.ts +14 -14
  384. package/node_modules/undici-types/proxy-agent.d.ts +6 -7
  385. package/node_modules/undici-types/readable.d.ts +16 -19
  386. package/node_modules/undici-types/retry-agent.d.ts +1 -1
  387. package/node_modules/undici-types/retry-handler.d.ts +10 -19
  388. package/node_modules/undici-types/util.d.ts +3 -3
  389. package/node_modules/undici-types/webidl.d.ts +30 -148
  390. package/node_modules/undici-types/websocket.d.ts +10 -48
  391. package/node_modules/zod/README.md +27 -0
  392. package/node_modules/zod/compile.cjs +96 -0
  393. package/node_modules/zod/compile.d.cts +1 -0
  394. package/node_modules/zod/compile.d.ts +1 -0
  395. package/node_modules/zod/compile.js +52 -0
  396. package/node_modules/zod/index.cjs +21 -2
  397. package/node_modules/zod/index.d.cts +1 -2
  398. package/node_modules/zod/index.d.ts +1 -2
  399. package/node_modules/zod/index.js +5 -2
  400. package/node_modules/zod/locales/index.cjs +19 -0
  401. package/node_modules/zod/mini/index.cjs +19 -0
  402. package/node_modules/zod/package.json +20 -8
  403. package/node_modules/zod/src/compile.ts +56 -0
  404. package/node_modules/zod/src/index.ts +5 -2
  405. package/node_modules/zod/src/v3/ZodError.ts +22 -12
  406. package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
  407. package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
  408. package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
  409. package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
  410. package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
  411. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
  412. package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
  413. package/node_modules/zod/src/v3/types.ts +5 -5
  414. package/node_modules/zod/src/v4/classic/compat.ts +26 -18
  415. package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
  416. package/node_modules/zod/src/v4/classic/errors.ts +59 -44
  417. package/node_modules/zod/src/v4/classic/external.ts +14 -9
  418. package/node_modules/zod/src/v4/classic/from-json-schema.ts +363 -78
  419. package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
  420. package/node_modules/zod/src/v4/classic/index.ts +2 -2
  421. package/node_modules/zod/src/v4/classic/iso.ts +2 -72
  422. package/node_modules/zod/src/v4/classic/parse.ts +10 -4
  423. package/node_modules/zod/src/v4/classic/schemas.ts +652 -371
  424. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
  425. package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
  426. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +185 -0
  427. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
  428. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
  429. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
  430. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
  431. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +3 -3
  432. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
  433. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +994 -0
  434. package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
  435. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
  436. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
  437. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
  438. package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
  439. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
  440. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +261 -13
  441. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
  442. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
  443. package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
  444. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +4 -0
  445. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +582 -10
  446. package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
  447. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
  448. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
  449. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
  450. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
  451. package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
  452. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +297 -0
  453. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -0
  454. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
  455. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
  456. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
  457. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
  458. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
  459. package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
  460. package/node_modules/zod/src/v4/classic/tests/number.test.ts +46 -9
  461. package/node_modules/zod/src/v4/classic/tests/object.test.ts +301 -12
  462. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
  463. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
  464. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
  465. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
  466. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
  467. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +225 -0
  468. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
  469. package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
  470. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +79 -3
  471. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
  472. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
  473. package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
  474. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
  475. package/node_modules/zod/src/v4/classic/tests/string.test.ts +152 -5
  476. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
  477. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +44 -3
  478. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1758 -202
  479. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
  480. package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
  481. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
  482. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
  483. package/node_modules/zod/src/v4/core/api.ts +73 -13
  484. package/node_modules/zod/src/v4/core/checks.ts +58 -145
  485. package/node_modules/zod/src/v4/core/compile.ts +2302 -0
  486. package/node_modules/zod/src/v4/core/core.ts +98 -19
  487. package/node_modules/zod/src/v4/core/doc.ts +17 -9
  488. package/node_modules/zod/src/v4/core/errors.ts +113 -25
  489. package/node_modules/zod/src/v4/core/index.ts +3 -0
  490. package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
  491. package/node_modules/zod/src/v4/core/json-schema-processors.ts +468 -146
  492. package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
  493. package/node_modules/zod/src/v4/core/memoizer.ts +334 -0
  494. package/node_modules/zod/src/v4/core/parse.ts +164 -50
  495. package/node_modules/zod/src/v4/core/regexes.ts +38 -15
  496. package/node_modules/zod/src/v4/core/registries.ts +2 -2
  497. package/node_modules/zod/src/v4/core/schemas.ts +1073 -538
  498. package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
  499. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +969 -0
  500. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
  501. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
  502. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
  503. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
  504. package/node_modules/zod/src/v4/core/tests/compile.test.ts +1859 -0
  505. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
  506. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
  507. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
  508. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
  509. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
  510. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
  511. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
  512. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
  513. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
  514. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +31 -0
  515. package/node_modules/zod/src/v4/core/to-json-schema.ts +284 -49
  516. package/node_modules/zod/src/v4/core/util.ts +458 -157
  517. package/node_modules/zod/src/v4/core/versions.ts +2 -2
  518. package/node_modules/zod/src/v4/core/visit.ts +204 -0
  519. package/node_modules/zod/src/v4/index.ts +3 -3
  520. package/node_modules/zod/src/v4/locales/ar.ts +4 -0
  521. package/node_modules/zod/src/v4/locales/az.ts +4 -0
  522. package/node_modules/zod/src/v4/locales/be.ts +11 -0
  523. package/node_modules/zod/src/v4/locales/bg.ts +4 -0
  524. package/node_modules/zod/src/v4/locales/bn.ts +122 -0
  525. package/node_modules/zod/src/v4/locales/ca.ts +4 -0
  526. package/node_modules/zod/src/v4/locales/ckb.ts +139 -0
  527. package/node_modules/zod/src/v4/locales/cs.ts +4 -0
  528. package/node_modules/zod/src/v4/locales/da.ts +6 -2
  529. package/node_modules/zod/src/v4/locales/de.ts +4 -0
  530. package/node_modules/zod/src/v4/locales/el.ts +2 -0
  531. package/node_modules/zod/src/v4/locales/en.ts +16 -4
  532. package/node_modules/zod/src/v4/locales/eo.ts +4 -0
  533. package/node_modules/zod/src/v4/locales/es.ts +3 -0
  534. package/node_modules/zod/src/v4/locales/fa.ts +4 -0
  535. package/node_modules/zod/src/v4/locales/fi.ts +4 -0
  536. package/node_modules/zod/src/v4/locales/fr-CA.ts +4 -0
  537. package/node_modules/zod/src/v4/locales/fr.ts +20 -14
  538. package/node_modules/zod/src/v4/locales/gu.ts +122 -0
  539. package/node_modules/zod/src/v4/locales/he.ts +7 -1
  540. package/node_modules/zod/src/v4/locales/hi.ts +125 -0
  541. package/node_modules/zod/src/v4/locales/hr.ts +3 -0
  542. package/node_modules/zod/src/v4/locales/hu.ts +4 -0
  543. package/node_modules/zod/src/v4/locales/hy.ts +10 -0
  544. package/node_modules/zod/src/v4/locales/id.ts +4 -0
  545. package/node_modules/zod/src/v4/locales/index.ts +11 -0
  546. package/node_modules/zod/src/v4/locales/is.ts +4 -0
  547. package/node_modules/zod/src/v4/locales/it.ts +4 -0
  548. package/node_modules/zod/src/v4/locales/ja.ts +4 -0
  549. package/node_modules/zod/src/v4/locales/ka.ts +4 -0
  550. package/node_modules/zod/src/v4/locales/km.ts +4 -0
  551. package/node_modules/zod/src/v4/locales/kn.ts +125 -0
  552. package/node_modules/zod/src/v4/locales/ko.ts +4 -0
  553. package/node_modules/zod/src/v4/locales/lt.ts +3 -0
  554. package/node_modules/zod/src/v4/locales/mk.ts +4 -0
  555. package/node_modules/zod/src/v4/locales/ms.ts +4 -0
  556. package/node_modules/zod/src/v4/locales/ne.ts +127 -0
  557. package/node_modules/zod/src/v4/locales/nl.ts +4 -0
  558. package/node_modules/zod/src/v4/locales/nn.ts +120 -0
  559. package/node_modules/zod/src/v4/locales/no.ts +6 -2
  560. package/node_modules/zod/src/v4/locales/ota.ts +4 -0
  561. package/node_modules/zod/src/v4/locales/pl.ts +4 -0
  562. package/node_modules/zod/src/v4/locales/ps.ts +4 -0
  563. package/node_modules/zod/src/v4/locales/pt-BR.ts +160 -0
  564. package/node_modules/zod/src/v4/locales/pt.ts +100 -58
  565. package/node_modules/zod/src/v4/locales/ro.ts +2 -0
  566. package/node_modules/zod/src/v4/locales/ru.ts +11 -0
  567. package/node_modules/zod/src/v4/locales/sk.ts +122 -0
  568. package/node_modules/zod/src/v4/locales/sl.ts +4 -0
  569. package/node_modules/zod/src/v4/locales/sv.ts +6 -2
  570. package/node_modules/zod/src/v4/locales/ta.ts +4 -0
  571. package/node_modules/zod/src/v4/locales/tg.ts +134 -0
  572. package/node_modules/zod/src/v4/locales/th.ts +4 -0
  573. package/node_modules/zod/src/v4/locales/tk.ts +112 -0
  574. package/node_modules/zod/src/v4/locales/tr.ts +4 -0
  575. package/node_modules/zod/src/v4/locales/uk.ts +4 -0
  576. package/node_modules/zod/src/v4/locales/ur.ts +4 -0
  577. package/node_modules/zod/src/v4/locales/uz.ts +2 -0
  578. package/node_modules/zod/src/v4/locales/vi.ts +4 -0
  579. package/node_modules/zod/src/v4/locales/yo.ts +4 -0
  580. package/node_modules/zod/src/v4/locales/zh-CN.ts +4 -0
  581. package/node_modules/zod/src/v4/locales/zh-TW.ts +4 -0
  582. package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
  583. package/node_modules/zod/src/v4/mini/external.ts +12 -1
  584. package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
  585. package/node_modules/zod/src/v4/mini/parse.ts +2 -0
  586. package/node_modules/zod/src/v4/mini/schemas.ts +174 -59
  587. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
  588. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
  589. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
  590. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
  591. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
  592. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
  593. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
  594. package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
  595. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
  596. package/node_modules/zod/src/v4/mini/tests/index.test.ts +102 -5
  597. package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
  598. package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
  599. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +16 -0
  600. package/node_modules/zod/src/v4/mini/tests/string.test.ts +37 -0
  601. package/node_modules/zod/v3/ZodError.cjs +41 -12
  602. package/node_modules/zod/v3/ZodError.d.cts +1 -1
  603. package/node_modules/zod/v3/ZodError.d.ts +1 -1
  604. package/node_modules/zod/v3/ZodError.js +22 -12
  605. package/node_modules/zod/v3/errors.cjs +19 -0
  606. package/node_modules/zod/v3/external.cjs +19 -0
  607. package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
  608. package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
  609. package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
  610. package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
  611. package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
  612. package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
  613. package/node_modules/zod/v3/helpers/util.cjs +19 -0
  614. package/node_modules/zod/v3/index.cjs +19 -0
  615. package/node_modules/zod/v3/standard-schema.cjs +19 -0
  616. package/node_modules/zod/v3/types.cjs +26 -5
  617. package/node_modules/zod/v3/types.js +7 -5
  618. package/node_modules/zod/v4/classic/checks.cjs +19 -0
  619. package/node_modules/zod/v4/classic/coerce.cjs +19 -0
  620. package/node_modules/zod/v4/classic/compat.cjs +19 -0
  621. package/node_modules/zod/v4/classic/compat.d.cts +9 -11
  622. package/node_modules/zod/v4/classic/compat.d.ts +9 -11
  623. package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
  624. package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
  625. package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
  626. package/node_modules/zod/v4/classic/deep-partial.js +13 -0
  627. package/node_modules/zod/v4/classic/errors.cjs +62 -34
  628. package/node_modules/zod/v4/classic/errors.d.cts +3 -4
  629. package/node_modules/zod/v4/classic/errors.d.ts +3 -4
  630. package/node_modules/zod/v4/classic/errors.js +43 -34
  631. package/node_modules/zod/v4/classic/external.cjs +51 -27
  632. package/node_modules/zod/v4/classic/external.d.cts +5 -2
  633. package/node_modules/zod/v4/classic/external.d.ts +5 -2
  634. package/node_modules/zod/v4/classic/external.js +5 -8
  635. package/node_modules/zod/v4/classic/from-json-schema.cjs +376 -75
  636. package/node_modules/zod/v4/classic/from-json-schema.js +357 -75
  637. package/node_modules/zod/v4/classic/in-out.cjs +82 -0
  638. package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
  639. package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
  640. package/node_modules/zod/v4/classic/in-out.js +36 -0
  641. package/node_modules/zod/v4/classic/index.cjs +21 -2
  642. package/node_modules/zod/v4/classic/index.d.cts +1 -2
  643. package/node_modules/zod/v4/classic/index.d.ts +1 -2
  644. package/node_modules/zod/v4/classic/index.js +2 -2
  645. package/node_modules/zod/v4/classic/iso.cjs +30 -22
  646. package/node_modules/zod/v4/classic/iso.d.cts +2 -17
  647. package/node_modules/zod/v4/classic/iso.d.ts +2 -17
  648. package/node_modules/zod/v4/classic/iso.js +2 -17
  649. package/node_modules/zod/v4/classic/parse.cjs +23 -1
  650. package/node_modules/zod/v4/classic/parse.d.cts +17 -4
  651. package/node_modules/zod/v4/classic/parse.d.ts +17 -4
  652. package/node_modules/zod/v4/classic/parse.js +1 -0
  653. package/node_modules/zod/v4/classic/schemas.cjs +591 -422
  654. package/node_modules/zod/v4/classic/schemas.d.cts +70 -19
  655. package/node_modules/zod/v4/classic/schemas.d.ts +70 -19
  656. package/node_modules/zod/v4/classic/schemas.js +564 -420
  657. package/node_modules/zod/v4/core/api.cjs +58 -4
  658. package/node_modules/zod/v4/core/api.d.cts +16 -10
  659. package/node_modules/zod/v4/core/api.d.ts +16 -10
  660. package/node_modules/zod/v4/core/api.js +36 -4
  661. package/node_modules/zod/v4/core/checks.cjs +56 -127
  662. package/node_modules/zod/v4/core/checks.d.cts +13 -13
  663. package/node_modules/zod/v4/core/checks.d.ts +13 -13
  664. package/node_modules/zod/v4/core/checks.js +37 -127
  665. package/node_modules/zod/v4/core/compile.cjs +1913 -0
  666. package/node_modules/zod/v4/core/compile.d.cts +65 -0
  667. package/node_modules/zod/v4/core/compile.d.ts +65 -0
  668. package/node_modules/zod/v4/core/compile.js +1863 -0
  669. package/node_modules/zod/v4/core/core.cjs +100 -18
  670. package/node_modules/zod/v4/core/core.d.cts +16 -4
  671. package/node_modules/zod/v4/core/core.d.ts +16 -4
  672. package/node_modules/zod/v4/core/core.js +82 -19
  673. package/node_modules/zod/v4/core/doc.cjs +31 -9
  674. package/node_modules/zod/v4/core/doc.d.cts +3 -1
  675. package/node_modules/zod/v4/core/doc.d.ts +3 -1
  676. package/node_modules/zod/v4/core/doc.js +12 -9
  677. package/node_modules/zod/v4/core/errors.cjs +126 -25
  678. package/node_modules/zod/v4/core/errors.d.cts +4 -0
  679. package/node_modules/zod/v4/core/errors.d.ts +4 -0
  680. package/node_modules/zod/v4/core/errors.js +107 -25
  681. package/node_modules/zod/v4/core/index.cjs +24 -1
  682. package/node_modules/zod/v4/core/index.d.cts +3 -0
  683. package/node_modules/zod/v4/core/index.d.ts +3 -0
  684. package/node_modules/zod/v4/core/index.js +3 -0
  685. package/node_modules/zod/v4/core/json-schema-generator.cjs +24 -1
  686. package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
  687. package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
  688. package/node_modules/zod/v4/core/json-schema-generator.js +6 -2
  689. package/node_modules/zod/v4/core/json-schema-processors.cjs +470 -149
  690. package/node_modules/zod/v4/core/json-schema-processors.d.cts +17 -0
  691. package/node_modules/zod/v4/core/json-schema-processors.d.ts +17 -0
  692. package/node_modules/zod/v4/core/json-schema-processors.js +427 -150
  693. package/node_modules/zod/v4/core/json-schema.cjs +19 -0
  694. package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
  695. package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
  696. package/node_modules/zod/v4/core/memoizer.cjs +363 -0
  697. package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
  698. package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
  699. package/node_modules/zod/v4/core/memoizer.js +314 -0
  700. package/node_modules/zod/v4/core/parse.cjs +148 -46
  701. package/node_modules/zod/v4/core/parse.d.cts +14 -11
  702. package/node_modules/zod/v4/core/parse.d.ts +14 -11
  703. package/node_modules/zod/v4/core/parse.js +127 -45
  704. package/node_modules/zod/v4/core/regexes.cjs +52 -17
  705. package/node_modules/zod/v4/core/regexes.d.cts +4 -0
  706. package/node_modules/zod/v4/core/regexes.d.ts +4 -0
  707. package/node_modules/zod/v4/core/regexes.js +30 -15
  708. package/node_modules/zod/v4/core/registries.cjs +19 -0
  709. package/node_modules/zod/v4/core/registries.js +2 -2
  710. package/node_modules/zod/v4/core/schemas.cjs +826 -387
  711. package/node_modules/zod/v4/core/schemas.d.cts +140 -36
  712. package/node_modules/zod/v4/core/schemas.d.ts +140 -36
  713. package/node_modules/zod/v4/core/schemas.js +796 -387
  714. package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
  715. package/node_modules/zod/v4/core/to-json-schema.cjs +270 -45
  716. package/node_modules/zod/v4/core/to-json-schema.d.cts +48 -5
  717. package/node_modules/zod/v4/core/to-json-schema.d.ts +48 -5
  718. package/node_modules/zod/v4/core/to-json-schema.js +248 -45
  719. package/node_modules/zod/v4/core/util.cjs +376 -157
  720. package/node_modules/zod/v4/core/util.d.cts +79 -1
  721. package/node_modules/zod/v4/core/util.d.ts +79 -1
  722. package/node_modules/zod/v4/core/util.js +345 -156
  723. package/node_modules/zod/v4/core/versions.cjs +21 -2
  724. package/node_modules/zod/v4/core/versions.d.cts +1 -1
  725. package/node_modules/zod/v4/core/versions.d.ts +1 -1
  726. package/node_modules/zod/v4/core/versions.js +2 -2
  727. package/node_modules/zod/v4/core/visit.cjs +226 -0
  728. package/node_modules/zod/v4/core/visit.d.cts +30 -0
  729. package/node_modules/zod/v4/core/visit.d.ts +30 -0
  730. package/node_modules/zod/v4/core/visit.js +181 -0
  731. package/node_modules/zod/v4/index.cjs +34 -5
  732. package/node_modules/zod/v4/index.d.cts +2 -2
  733. package/node_modules/zod/v4/index.d.ts +2 -2
  734. package/node_modules/zod/v4/index.js +3 -2
  735. package/node_modules/zod/v4/locales/ar.cjs +4 -0
  736. package/node_modules/zod/v4/locales/ar.js +4 -0
  737. package/node_modules/zod/v4/locales/az.cjs +4 -0
  738. package/node_modules/zod/v4/locales/az.js +4 -0
  739. package/node_modules/zod/v4/locales/be.cjs +11 -0
  740. package/node_modules/zod/v4/locales/be.js +11 -0
  741. package/node_modules/zod/v4/locales/bg.cjs +4 -0
  742. package/node_modules/zod/v4/locales/bg.js +4 -0
  743. package/node_modules/zod/v4/locales/bn.cjs +139 -0
  744. package/node_modules/zod/v4/locales/bn.d.cts +5 -0
  745. package/node_modules/zod/v4/locales/bn.d.ts +4 -0
  746. package/node_modules/zod/v4/locales/bn.js +112 -0
  747. package/node_modules/zod/v4/locales/ca.cjs +4 -0
  748. package/node_modules/zod/v4/locales/ca.js +4 -0
  749. package/node_modules/zod/v4/locales/ckb.cjs +159 -0
  750. package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
  751. package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
  752. package/node_modules/zod/v4/locales/ckb.js +132 -0
  753. package/node_modules/zod/v4/locales/cs.cjs +4 -0
  754. package/node_modules/zod/v4/locales/cs.js +4 -0
  755. package/node_modules/zod/v4/locales/da.cjs +6 -2
  756. package/node_modules/zod/v4/locales/da.js +6 -2
  757. package/node_modules/zod/v4/locales/de.cjs +4 -0
  758. package/node_modules/zod/v4/locales/de.js +4 -0
  759. package/node_modules/zod/v4/locales/el.cjs +2 -0
  760. package/node_modules/zod/v4/locales/el.js +2 -0
  761. package/node_modules/zod/v4/locales/en.cjs +15 -4
  762. package/node_modules/zod/v4/locales/en.js +15 -4
  763. package/node_modules/zod/v4/locales/eo.cjs +4 -0
  764. package/node_modules/zod/v4/locales/eo.js +4 -0
  765. package/node_modules/zod/v4/locales/es.cjs +3 -0
  766. package/node_modules/zod/v4/locales/es.js +3 -0
  767. package/node_modules/zod/v4/locales/fa.cjs +4 -0
  768. package/node_modules/zod/v4/locales/fa.js +4 -0
  769. package/node_modules/zod/v4/locales/fi.cjs +4 -0
  770. package/node_modules/zod/v4/locales/fi.js +4 -0
  771. package/node_modules/zod/v4/locales/fr-CA.cjs +4 -0
  772. package/node_modules/zod/v4/locales/fr-CA.js +4 -0
  773. package/node_modules/zod/v4/locales/fr.cjs +17 -14
  774. package/node_modules/zod/v4/locales/fr.js +17 -14
  775. package/node_modules/zod/v4/locales/gu.cjs +139 -0
  776. package/node_modules/zod/v4/locales/gu.d.cts +5 -0
  777. package/node_modules/zod/v4/locales/gu.d.ts +4 -0
  778. package/node_modules/zod/v4/locales/gu.js +112 -0
  779. package/node_modules/zod/v4/locales/he.cjs +6 -0
  780. package/node_modules/zod/v4/locales/he.js +6 -0
  781. package/node_modules/zod/v4/locales/hi.cjs +137 -0
  782. package/node_modules/zod/v4/locales/hi.d.cts +5 -0
  783. package/node_modules/zod/v4/locales/hi.d.ts +4 -0
  784. package/node_modules/zod/v4/locales/hi.js +110 -0
  785. package/node_modules/zod/v4/locales/hr.cjs +3 -0
  786. package/node_modules/zod/v4/locales/hr.js +3 -0
  787. package/node_modules/zod/v4/locales/hu.cjs +4 -0
  788. package/node_modules/zod/v4/locales/hu.js +4 -0
  789. package/node_modules/zod/v4/locales/hy.cjs +10 -0
  790. package/node_modules/zod/v4/locales/hy.js +10 -0
  791. package/node_modules/zod/v4/locales/id.cjs +4 -0
  792. package/node_modules/zod/v4/locales/id.js +4 -0
  793. package/node_modules/zod/v4/locales/index.cjs +43 -2
  794. package/node_modules/zod/v4/locales/index.d.cts +11 -0
  795. package/node_modules/zod/v4/locales/index.d.ts +11 -0
  796. package/node_modules/zod/v4/locales/index.js +11 -0
  797. package/node_modules/zod/v4/locales/is.cjs +4 -0
  798. package/node_modules/zod/v4/locales/is.js +4 -0
  799. package/node_modules/zod/v4/locales/it.cjs +4 -0
  800. package/node_modules/zod/v4/locales/it.js +4 -0
  801. package/node_modules/zod/v4/locales/ja.cjs +4 -0
  802. package/node_modules/zod/v4/locales/ja.js +4 -0
  803. package/node_modules/zod/v4/locales/ka.cjs +4 -0
  804. package/node_modules/zod/v4/locales/ka.js +4 -0
  805. package/node_modules/zod/v4/locales/km.cjs +4 -0
  806. package/node_modules/zod/v4/locales/km.js +4 -0
  807. package/node_modules/zod/v4/locales/kn.cjs +142 -0
  808. package/node_modules/zod/v4/locales/kn.d.cts +5 -0
  809. package/node_modules/zod/v4/locales/kn.d.ts +4 -0
  810. package/node_modules/zod/v4/locales/kn.js +115 -0
  811. package/node_modules/zod/v4/locales/ko.cjs +4 -0
  812. package/node_modules/zod/v4/locales/ko.js +4 -0
  813. package/node_modules/zod/v4/locales/lt.cjs +3 -0
  814. package/node_modules/zod/v4/locales/lt.js +3 -0
  815. package/node_modules/zod/v4/locales/mk.cjs +4 -0
  816. package/node_modules/zod/v4/locales/mk.js +4 -0
  817. package/node_modules/zod/v4/locales/ms.cjs +4 -0
  818. package/node_modules/zod/v4/locales/ms.js +4 -0
  819. package/node_modules/zod/v4/locales/ne.cjs +137 -0
  820. package/node_modules/zod/v4/locales/ne.d.cts +5 -0
  821. package/node_modules/zod/v4/locales/ne.d.ts +4 -0
  822. package/node_modules/zod/v4/locales/ne.js +110 -0
  823. package/node_modules/zod/v4/locales/nl.cjs +4 -0
  824. package/node_modules/zod/v4/locales/nl.js +4 -0
  825. package/node_modules/zod/v4/locales/nn.cjs +139 -0
  826. package/node_modules/zod/v4/locales/nn.d.cts +5 -0
  827. package/node_modules/zod/v4/locales/nn.d.ts +4 -0
  828. package/node_modules/zod/v4/locales/nn.js +112 -0
  829. package/node_modules/zod/v4/locales/no.cjs +6 -2
  830. package/node_modules/zod/v4/locales/no.js +6 -2
  831. package/node_modules/zod/v4/locales/ota.cjs +4 -0
  832. package/node_modules/zod/v4/locales/ota.js +4 -0
  833. package/node_modules/zod/v4/locales/pl.cjs +4 -0
  834. package/node_modules/zod/v4/locales/pl.js +4 -0
  835. package/node_modules/zod/v4/locales/ps.cjs +4 -0
  836. package/node_modules/zod/v4/locales/ps.js +4 -0
  837. package/node_modules/zod/v4/locales/pt-BR.cjs +169 -0
  838. package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
  839. package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
  840. package/node_modules/zod/v4/locales/pt-BR.js +142 -0
  841. package/node_modules/zod/v4/locales/pt.cjs +88 -55
  842. package/node_modules/zod/v4/locales/pt.js +88 -55
  843. package/node_modules/zod/v4/locales/ro.cjs +2 -0
  844. package/node_modules/zod/v4/locales/ro.js +2 -0
  845. package/node_modules/zod/v4/locales/ru.cjs +11 -0
  846. package/node_modules/zod/v4/locales/ru.js +11 -0
  847. package/node_modules/zod/v4/locales/sk.cjs +142 -0
  848. package/node_modules/zod/v4/locales/sk.d.cts +5 -0
  849. package/node_modules/zod/v4/locales/sk.d.ts +4 -0
  850. package/node_modules/zod/v4/locales/sk.js +115 -0
  851. package/node_modules/zod/v4/locales/sl.cjs +4 -0
  852. package/node_modules/zod/v4/locales/sl.js +4 -0
  853. package/node_modules/zod/v4/locales/sv.cjs +6 -2
  854. package/node_modules/zod/v4/locales/sv.js +6 -2
  855. package/node_modules/zod/v4/locales/ta.cjs +4 -0
  856. package/node_modules/zod/v4/locales/ta.js +4 -0
  857. package/node_modules/zod/v4/locales/tg.cjs +143 -0
  858. package/node_modules/zod/v4/locales/tg.d.cts +5 -0
  859. package/node_modules/zod/v4/locales/tg.d.ts +4 -0
  860. package/node_modules/zod/v4/locales/tg.js +116 -0
  861. package/node_modules/zod/v4/locales/th.cjs +4 -0
  862. package/node_modules/zod/v4/locales/th.js +4 -0
  863. package/node_modules/zod/v4/locales/tk.cjs +133 -0
  864. package/node_modules/zod/v4/locales/tk.d.cts +5 -0
  865. package/node_modules/zod/v4/locales/tk.d.ts +4 -0
  866. package/node_modules/zod/v4/locales/tk.js +106 -0
  867. package/node_modules/zod/v4/locales/tr.cjs +4 -0
  868. package/node_modules/zod/v4/locales/tr.js +4 -0
  869. package/node_modules/zod/v4/locales/uk.cjs +4 -0
  870. package/node_modules/zod/v4/locales/uk.js +4 -0
  871. package/node_modules/zod/v4/locales/ur.cjs +4 -0
  872. package/node_modules/zod/v4/locales/ur.js +4 -0
  873. package/node_modules/zod/v4/locales/uz.cjs +2 -0
  874. package/node_modules/zod/v4/locales/uz.js +2 -0
  875. package/node_modules/zod/v4/locales/vi.cjs +4 -0
  876. package/node_modules/zod/v4/locales/vi.js +4 -0
  877. package/node_modules/zod/v4/locales/yo.cjs +4 -0
  878. package/node_modules/zod/v4/locales/yo.js +4 -0
  879. package/node_modules/zod/v4/locales/zh-CN.cjs +4 -0
  880. package/node_modules/zod/v4/locales/zh-CN.js +4 -0
  881. package/node_modules/zod/v4/locales/zh-TW.cjs +4 -0
  882. package/node_modules/zod/v4/locales/zh-TW.js +4 -0
  883. package/node_modules/zod/v4/mini/checks.cjs +19 -0
  884. package/node_modules/zod/v4/mini/coerce.cjs +19 -0
  885. package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
  886. package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
  887. package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
  888. package/node_modules/zod/v4/mini/deep-partial.js +13 -0
  889. package/node_modules/zod/v4/mini/external.cjs +33 -1
  890. package/node_modules/zod/v4/mini/external.d.cts +5 -2
  891. package/node_modules/zod/v4/mini/external.d.ts +5 -2
  892. package/node_modules/zod/v4/mini/external.js +3 -1
  893. package/node_modules/zod/v4/mini/in-out.cjs +82 -0
  894. package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
  895. package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
  896. package/node_modules/zod/v4/mini/in-out.js +36 -0
  897. package/node_modules/zod/v4/mini/index.cjs +19 -0
  898. package/node_modules/zod/v4/mini/iso.cjs +19 -0
  899. package/node_modules/zod/v4/mini/parse.cjs +22 -1
  900. package/node_modules/zod/v4/mini/parse.d.cts +1 -1
  901. package/node_modules/zod/v4/mini/parse.d.ts +1 -1
  902. package/node_modules/zod/v4/mini/parse.js +1 -1
  903. package/node_modules/zod/v4/mini/schemas.cjs +115 -49
  904. package/node_modules/zod/v4/mini/schemas.d.cts +52 -14
  905. package/node_modules/zod/v4/mini/schemas.d.ts +52 -14
  906. package/node_modules/zod/v4/mini/schemas.js +90 -47
  907. package/node_modules/zod/v4-mini/index.cjs +19 -0
  908. package/package.json +3 -2
  909. package/skills/context-management/SKILL.md +258 -0
  910. package/skills/figma-implement-design/SKILL.md +258 -0
  911. package/skills/orchestrator/SKILL.md +82 -0
  912. package/skills/s-help/SKILL.md +42 -0
  913. package/skills/s-help/resources/README.md +23 -0
  914. package/skills/s-help/resources/commands.json +78 -0
  915. package/skills/s-help/resources/s-acm.md +26 -0
  916. package/skills/s-help/resources/s-bash-mode.md +23 -0
  917. package/skills/s-help/resources/s-bash-reset.md +23 -0
  918. package/skills/s-help/resources/s-context.md +25 -0
  919. package/skills/s-help/resources/s-filechanges-accept.md +25 -0
  920. package/skills/s-help/resources/s-filechanges-decline.md +30 -0
  921. package/skills/s-help/resources/s-filechanges.md +38 -0
  922. package/skills/s-help/resources/s-footer.md +38 -0
  923. package/skills/s-help/resources/s-promptlib.md +28 -0
  924. package/skills/s-help/resources/s-skills-manager.md +31 -0
  925. package/skills/s-help/resources/s-stash-history.md +26 -0
  926. package/skills/screenshot/SKILL.md +267 -0
  927. package/skills/screenshot/scripts/ensure_macos_permissions.sh +54 -0
  928. package/skills/screenshot/scripts/macos_display_info.swift +22 -0
  929. package/skills/screenshot/scripts/macos_permissions.swift +40 -0
  930. package/skills/screenshot/scripts/macos_window_info.swift +126 -0
  931. package/skills/screenshot/scripts/take_screenshot.ps1 +163 -0
  932. package/skills/screenshot/scripts/take_screenshot.py +585 -0
  933. package/slingshot/index.js +232 -230
  934. package/node_modules/@types/node/ffi.d.ts +0 -486
  935. package/node_modules/@types/node/inspector/promises.d.ts +0 -35
  936. package/node_modules/@types/node/path/posix.d.ts +0 -8
  937. package/node_modules/@types/node/path/win32.d.ts +0 -8
  938. package/node_modules/@types/node/quic.d.ts +0 -2151
  939. package/node_modules/@types/node/stream/iter.d.ts +0 -452
  940. package/node_modules/@types/node/test/reporters.d.ts +0 -59
  941. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +0 -71
  942. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +0 -72
  943. package/node_modules/@types/node/ts5.7/index.d.ts +0 -118
  944. package/node_modules/@types/node/util/types.d.ts +0 -558
  945. package/node_modules/@types/node/vfs.d.ts +0 -210
  946. package/node_modules/@types/node/web-globals/blob.d.ts +0 -23
  947. package/node_modules/@types/node/web-globals/console.d.ts +0 -9
  948. package/node_modules/@types/node/web-globals/crypto.d.ts +0 -39
  949. package/node_modules/@types/node/web-globals/encoding.d.ts +0 -11
  950. package/node_modules/@types/node/web-globals/importmeta.d.ts +0 -13
  951. package/node_modules/@types/node/web-globals/messaging.d.ts +0 -23
  952. package/node_modules/@types/node/web-globals/performance.d.ts +0 -45
  953. package/node_modules/@types/node/web-globals/timers.d.ts +0 -44
  954. package/node_modules/@types/node/web-globals/url.d.ts +0 -24
  955. package/node_modules/@types/node/zlib/iter.d.ts +0 -131
  956. package/node_modules/jose/dist/webapi/lib/base64.js +0 -22
  957. package/node_modules/jose/dist/webapi/lib/crypto_key.js +0 -28
  958. package/node_modules/jose/dist/webapi/lib/helpers.js +0 -42
  959. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -26
  960. package/node_modules/jose/dist/webapi/lib/is_key_like.js +0 -17
  961. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +0 -20
  962. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +0 -17
  963. package/node_modules/jose/dist/webapi/lib/key_options.js +0 -6
  964. package/node_modules/jose/dist/webapi/lib/options.js +0 -74
  965. package/node_modules/jose/dist/webapi/lib/signing.js +0 -26
  966. package/node_modules/jose/dist/webapi/lib/type_checks.js +0 -33
  967. package/node_modules/undici-types/cache-interceptor.d.ts +0 -179
  968. package/node_modules/undici-types/client-stats.d.ts +0 -15
  969. package/node_modules/undici-types/dispatcher1-wrapper.d.ts +0 -7
  970. package/node_modules/undici-types/h2c-client.d.ts +0 -73
  971. package/node_modules/undici-types/mock-call-history.d.ts +0 -111
  972. package/node_modules/undici-types/round-robin-pool.d.ts +0 -39
  973. package/node_modules/undici-types/snapshot-agent.d.ts +0 -113
  974. package/node_modules/undici-types/socks5-proxy-agent.d.ts +0 -25
  975. package/node_modules/undici-types/utility.d.ts +0 -7
  976. package/node_modules/zod/src/v4/core/config.ts +0 -15
@@ -18,8 +18,7 @@ const validateOpenAPI30Schema = async (zodJSONSchema: Record<string, unknown>):
18
18
  });
19
19
 
20
20
  if (!res.valid) {
21
- // `console.error` should make `vitest` trow an unhandled error
22
- // printing the validation messages in consoles
21
+ // `console.error` should make `vitest` trow an unhandled error printing the validation messages in consoles
23
22
  console.error(
24
23
  `OpenAPI schema is not valid against ${openAPI30Validator.version}`,
25
24
  JSON.stringify(res.errors, null, 2)
@@ -80,7 +79,7 @@ describe("toJSONSchema", () => {
80
79
  {
81
80
  "$schema": "https://json-schema.org/draft/2020-12/schema",
82
81
  "format": "email",
83
- "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
82
+ "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
84
83
  "type": "string",
85
84
  }
86
85
  `);
@@ -88,7 +87,7 @@ describe("toJSONSchema", () => {
88
87
  {
89
88
  "$schema": "https://json-schema.org/draft/2020-12/schema",
90
89
  "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))$",
90
+ "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
91
  "type": "string",
93
92
  }
94
93
  `);
@@ -100,6 +99,17 @@ describe("toJSONSchema", () => {
100
99
  "type": "string",
101
100
  }
102
101
  `);
102
+ // only shapes keeping both an offset and seconds may advertise `date-time`, composed onto a string as well as constructed
103
+ expect(z.toJSONSchema(z.iso.datetime()).format).toEqual("date-time");
104
+ expect(z.toJSONSchema(z.iso.datetime({ offset: true })).format).toEqual("date-time");
105
+ expect(z.toJSONSchema(z.iso.datetime({ precision: 0 })).format).toEqual("date-time");
106
+ expect(z.toJSONSchema(z.iso.datetime({ local: true })).format).toEqual(undefined);
107
+ expect(z.toJSONSchema(z.iso.datetime({ precision: -1 })).format).toEqual(undefined);
108
+ expect(z.toJSONSchema(z.string().check(z.iso.datetime({ local: true }))).format).toEqual(undefined);
109
+ expect(z.toJSONSchema(z.string().check(z.iso.datetime())).format).toEqual("date-time");
110
+ // the pattern still describes what the schema accepts
111
+ expect(z.toJSONSchema(z.iso.datetime({ local: true })).pattern).toBeDefined();
112
+
103
113
  expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
104
114
  {
105
115
  "$schema": "https://json-schema.org/draft/2020-12/schema",
@@ -208,6 +218,15 @@ describe("toJSONSchema", () => {
208
218
  "type": "string",
209
219
  }
210
220
  `);
221
+ expect(z.toJSONSchema(z.base64url())).toMatchInlineSnapshot(`
222
+ {
223
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
224
+ "contentEncoding": "base64url",
225
+ "format": "base64url",
226
+ "pattern": "^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$",
227
+ "type": "string",
228
+ }
229
+ `);
211
230
  expect(z.toJSONSchema(z.cuid())).toMatchInlineSnapshot(`
212
231
  {
213
232
  "$schema": "https://json-schema.org/draft/2020-12/schema",
@@ -221,7 +240,7 @@ describe("toJSONSchema", () => {
221
240
  {
222
241
  "$schema": "https://json-schema.org/draft/2020-12/schema",
223
242
  "format": "emoji",
224
- "pattern": "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
243
+ "pattern": "^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",
225
244
  "type": "string",
226
245
  }
227
246
  `);
@@ -233,6 +252,14 @@ describe("toJSONSchema", () => {
233
252
  "type": "string",
234
253
  }
235
254
  `);
255
+ expect(z.toJSONSchema(z.nanoid({ length: 64 }))).toMatchInlineSnapshot(`
256
+ {
257
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
258
+ "format": "nanoid",
259
+ "pattern": "^[a-zA-Z0-9_-]{64}$",
260
+ "type": "string",
261
+ }
262
+ `);
236
263
  expect(z.toJSONSchema(z.cuid2())).toMatchInlineSnapshot(`
237
264
  {
238
265
  "$schema": "https://json-schema.org/draft/2020-12/schema",
@@ -245,7 +272,7 @@ describe("toJSONSchema", () => {
245
272
  {
246
273
  "$schema": "https://json-schema.org/draft/2020-12/schema",
247
274
  "format": "ulid",
248
- "pattern": "^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$",
275
+ "pattern": "^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$",
249
276
  "type": "string",
250
277
  }
251
278
  `);
@@ -325,6 +352,12 @@ describe("toJSONSchema", () => {
325
352
  // Dynamic catch values
326
353
  const dynamicCatchSchema = z.string().catch((ctx) => `${ctx.issues.length}`);
327
354
  expect(() => z.toJSONSchema(dynamicCatchSchema)).toThrow("Dynamic catch values are not supported in JSON Schema");
355
+ expect(z.toJSONSchema(dynamicCatchSchema, { unrepresentable: "any" })).toMatchInlineSnapshot(`
356
+ {
357
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
358
+ "type": "string",
359
+ }
360
+ `);
328
361
  });
329
362
 
330
363
  test("string formats", () => {
@@ -332,7 +365,7 @@ describe("toJSONSchema", () => {
332
365
  {
333
366
  "$schema": "https://json-schema.org/draft/2020-12/schema",
334
367
  "format": "email",
335
- "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
368
+ "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
336
369
  "type": "string",
337
370
  }
338
371
  `);
@@ -348,7 +381,7 @@ describe("toJSONSchema", () => {
348
381
  {
349
382
  "$schema": "https://json-schema.org/draft/2020-12/schema",
350
383
  "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))$",
384
+ "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
385
  "type": "string",
353
386
  }
354
387
  `);
@@ -458,6 +491,30 @@ describe("toJSONSchema", () => {
458
491
  `);
459
492
  });
460
493
 
494
+ test("base64url pattern agrees with parse", () => {
495
+ const schema = z.base64url();
496
+ const pattern = new RegExp(z.toJSONSchema(schema).pattern!);
497
+ // lengths 1 (mod 4) carry no whole byte; the emitted pattern must reject them like parse does
498
+ for (const s of ["", "A", "AA", "AAA", "AAAA", "AAAAA"]) {
499
+ expect(pattern.test(s)).toBe(schema.safeParse(s).success);
500
+ }
501
+ });
502
+
503
+ test("base64 pattern agrees with parse", () => {
504
+ const schema = z.base64();
505
+ const pattern = new RegExp(z.toJSONSchema(schema).pattern!);
506
+ // the runtime def.pattern is lax; the emitted pattern must still carry the block structure parse enforces
507
+ for (const s of ["", "A", "AA", "AAA", "AAAA", "AAAAA", "AA==", "AAA=", "A===", "=", "AAAA=="]) {
508
+ expect(pattern.test(s)).toBe(schema.safeParse(s).success);
509
+ }
510
+ });
511
+
512
+ test("looseRecord with a format key emits the exact pattern", () => {
513
+ // recordProcessor reads bag.patterns directly; it must apply the same lax-to-exact swap as stringProcessor
514
+ const json = z.toJSONSchema(z.looseRecord(z.base64url(), z.number()));
515
+ expect(Object.keys(json.patternProperties!)).toEqual([z.regexes.base64url.source]);
516
+ });
517
+
461
518
  test("string patterns", () => {
462
519
  expect(
463
520
  z.toJSONSchema(
@@ -480,7 +537,7 @@ describe("toJSONSchema", () => {
480
537
  "pattern": "cruel",
481
538
  },
482
539
  {
483
- "pattern": "^.{10}dark",
540
+ "pattern": "^.{10,}dark",
484
541
  },
485
542
  {
486
543
  "pattern": ".*world$",
@@ -519,7 +576,7 @@ describe("toJSONSchema", () => {
519
576
  "type": "string",
520
577
  },
521
578
  {
522
- "pattern": "^.{10}dark",
579
+ "pattern": "^.{10,}dark",
523
580
  "type": "string",
524
581
  },
525
582
  {
@@ -536,6 +593,19 @@ describe("toJSONSchema", () => {
536
593
  `);
537
594
  });
538
595
 
596
+ test("includes with position emits a pattern matching runtime semantics", () => {
597
+ // String.prototype.includes(sub, position) matches `sub` at `position` OR
598
+ // LATER, so the JSON Schema pattern must allow >= position leading chars.
599
+ const schema = z.string().includes("foo", { position: 2 });
600
+ const json = z.toJSONSchema(schema) as { pattern?: string };
601
+ expect(json.pattern).toBe("^.{2,}foo");
602
+
603
+ const re = new RegExp(json.pattern!);
604
+ for (const input of ["xxfoo", "xxxfoo", "xfoo", "ab"]) {
605
+ expect(re.test(input)).toBe(schema.safeParse(input).success);
606
+ }
607
+ });
608
+
539
609
  test("number constraints", () => {
540
610
  expect(z.toJSONSchema(z.number().min(5).max(10))).toMatchInlineSnapshot(
541
611
  `
@@ -648,8 +718,7 @@ describe("toJSONSchema", () => {
648
718
  });
649
719
 
650
720
  test("number constraints intersection draft-04", () => {
651
- // When both minimum (from .int()) and exclusiveMinimum (from .positive()) exist,
652
- // the more restrictive constraint should be used
721
+ // When both minimum (from .int()) and exclusiveMinimum (from .positive()) exist, the more restrictive constraint should be used
653
722
  expect(z.toJSONSchema(z.number().int().positive().lte(65535), { target: "draft-04" })).toMatchInlineSnapshot(`
654
723
  {
655
724
  "$schema": "http://json-schema.org/draft-04/schema#",
@@ -688,8 +757,120 @@ describe("toJSONSchema", () => {
688
757
  `);
689
758
  });
690
759
 
760
+ test("number constraints order independence with int()", () => {
761
+ // .int() applied last should not overwrite the tighter bounds .min()/.max() already stored
762
+ expect(z.toJSONSchema(z.number().int().min(0).max(23))).toMatchInlineSnapshot(`
763
+ {
764
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
765
+ "maximum": 23,
766
+ "minimum": 0,
767
+ "type": "integer",
768
+ }
769
+ `);
770
+ expect(z.toJSONSchema(z.number().min(0).max(23).int())).toMatchInlineSnapshot(`
771
+ {
772
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
773
+ "maximum": 23,
774
+ "minimum": 0,
775
+ "type": "integer",
776
+ }
777
+ `);
778
+ });
779
+
780
+ test("chained multipleOf divisors emit the whole conjunction", () => {
781
+ // runtime rejects 4 (not a multiple of 3), so the emitted schema must too
782
+ expect(z.toJSONSchema(z.number().multipleOf(2).multipleOf(3))).toMatchInlineSnapshot(`
783
+ {
784
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
785
+ "allOf": [
786
+ {
787
+ "multipleOf": 3,
788
+ },
789
+ ],
790
+ "multipleOf": 2,
791
+ "type": "number",
792
+ }
793
+ `);
794
+ });
795
+
796
+ test("length() does not overwrite a tighter earlier bound", () => {
797
+ // min(8) + length(5) matches nothing at runtime; the emitted bounds stay honest about that
798
+ expect(z.toJSONSchema(z.string().min(8).length(5))).toMatchInlineSnapshot(`
799
+ {
800
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
801
+ "maxLength": 5,
802
+ "minLength": 8,
803
+ "type": "string",
804
+ }
805
+ `);
806
+ });
807
+
808
+ test("an integer format keeps the emitted type integer whatever format lands last", () => {
809
+ // runtime rejects 1.5 in both orders, so both must emit type integer
810
+ const after = z.number().int().check(z.float32());
811
+ expect(after.safeParse(1.5).success).toBe(false);
812
+ expect(z.toJSONSchema(after).type).toBe("integer");
813
+ expect(z.toJSONSchema(z.number().check(z.float32()).int()).type).toBe("integer");
814
+ });
815
+
816
+ test("disjoint mime checks emit a false schema, not an unconstrained file", () => {
817
+ const file = z.file().mime("image/png").mime("text/plain");
818
+ expect(z.toJSONSchema(file)).toMatchInlineSnapshot(`
819
+ {
820
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
821
+ "contentEncoding": "binary",
822
+ "format": "binary",
823
+ "not": {},
824
+ "type": "string",
825
+ }
826
+ `);
827
+ });
828
+
829
+ test("a custom mime narrowing via onattach intersects with built-in mime checks", () => {
830
+ const check = {
831
+ _zod: {
832
+ def: { check: "custom_mime" },
833
+ onattach: [
834
+ (inst: any) => {
835
+ inst._zod.bag.mime = ["text/plain"];
836
+ },
837
+ ],
838
+ check: () => {},
839
+ },
840
+ };
841
+ const file = z
842
+ .file()
843
+ .mime(["image/png", "text/plain"])
844
+ .check(check as any);
845
+ expect(z.toJSONSchema(file).contentMediaType).toBe("text/plain");
846
+ });
847
+
848
+ test("a custom check contributing via onattach still lands", () => {
849
+ // third-party checks have no converter handler; their bag writes are merged in as a fallback
850
+ const check = {
851
+ _zod: {
852
+ def: { check: "custom_range" },
853
+ onattach: [
854
+ (inst: any) => {
855
+ const bag = inst._zod.bag;
856
+ if (bag.minimum === undefined || 5 > bag.minimum) bag.minimum = 5;
857
+ },
858
+ ],
859
+ check: () => {},
860
+ },
861
+ };
862
+ expect(z.toJSONSchema(z.number().check(check as any))).toMatchInlineSnapshot(`
863
+ {
864
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
865
+ "minimum": 5,
866
+ "type": "number",
867
+ }
868
+ `);
869
+ });
870
+
691
871
  test("target normalization draft-04 and draft-07", () => {
692
872
  // Test that both old (draft-4, draft-7) and new (draft-04, draft-07) target formats work
873
+
693
874
  // Test draft-04 / draft-4
694
875
  expect(z.toJSONSchema(z.number().gt(5), { target: "draft-04" })).toMatchInlineSnapshot(`
695
876
  {
@@ -787,11 +968,159 @@ describe("toJSONSchema", () => {
787
968
 
788
969
  test("unions", () => {
789
970
  const schema = z.union([z.string(), z.number()]);
971
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
972
+ {
973
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
974
+ "type": [
975
+ "string",
976
+ "number",
977
+ ],
978
+ }
979
+ `);
980
+ });
981
+
982
+ test("nullable compacts to a type array", () => {
983
+ expect(z.toJSONSchema(z.string().nullable())).toMatchInlineSnapshot(`
984
+ {
985
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
986
+ "type": [
987
+ "string",
988
+ "null",
989
+ ],
990
+ }
991
+ `);
992
+
993
+ // a nested union folds into the outer type array rather than leaving a mixed shape
994
+ expect(z.toJSONSchema(z.union([z.string(), z.number()]).nullable())).toMatchInlineSnapshot(`
995
+ {
996
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
997
+ "type": [
998
+ "string",
999
+ "number",
1000
+ "null",
1001
+ ],
1002
+ }
1003
+ `);
1004
+
1005
+ // the null branch is bare but the object branch is not, so this stays an anyOf
1006
+ expect(z.toJSONSchema(z.object({ a: z.string() }).nullable())).toMatchInlineSnapshot(`
1007
+ {
1008
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1009
+ "anyOf": [
1010
+ {
1011
+ "additionalProperties": false,
1012
+ "properties": {
1013
+ "a": {
1014
+ "type": "string",
1015
+ },
1016
+ },
1017
+ "required": [
1018
+ "a",
1019
+ ],
1020
+ "type": "object",
1021
+ },
1022
+ {
1023
+ "type": "null",
1024
+ },
1025
+ ],
1026
+ }
1027
+ `);
1028
+ });
1029
+
1030
+ test("duplicate branches dedupe, single branch stays a bare type", () => {
1031
+ // a `type` array must have unique members, so two branches that erase to the same bare type collapse
1032
+ const refined = z.union([z.string().refine((s) => s.length > 2), z.string().refine((s) => s.length < 9)]);
1033
+ expect(z.toJSONSchema(refined)).toMatchInlineSnapshot(`
1034
+ {
1035
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1036
+ "type": "string",
1037
+ }
1038
+ `);
1039
+ expect(z.toJSONSchema(z.union([z.string()]))).toMatchInlineSnapshot(`
1040
+ {
1041
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1042
+ "type": "string",
1043
+ }
1044
+ `);
1045
+ });
1046
+
1047
+ test("compaction runs after overrides and ref extraction", () => {
1048
+ // an override decorates the string branch, so it is no longer a bare type and must survive in anyOf
1049
+ const decorated = z.toJSONSchema(z.union([z.string(), z.number()]), {
1050
+ override(ctx) {
1051
+ if (ctx.zodSchema._zod.def.type === "string") ctx.jsonSchema.whatever = "sup";
1052
+ },
1053
+ });
1054
+ expect(decorated).toMatchInlineSnapshot(`
1055
+ {
1056
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1057
+ "anyOf": [
1058
+ {
1059
+ "type": "string",
1060
+ "whatever": "sup",
1061
+ },
1062
+ {
1063
+ "type": "number",
1064
+ },
1065
+ ],
1066
+ }
1067
+ `);
1068
+
1069
+ // a branch extracted into $defs is a $ref, not a bare type, so `reused` is not silently bypassed
1070
+ const shared = z.string();
1071
+ expect(
1072
+ z.toJSONSchema(z.object({ a: shared, b: z.union([shared, z.null()]) }), { reused: "ref" })
1073
+ ).toMatchInlineSnapshot(`
1074
+ {
1075
+ "$defs": {
1076
+ "__schema0": {
1077
+ "type": "string",
1078
+ },
1079
+ },
1080
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1081
+ "additionalProperties": false,
1082
+ "properties": {
1083
+ "a": {
1084
+ "$ref": "#/$defs/__schema0",
1085
+ },
1086
+ "b": {
1087
+ "anyOf": [
1088
+ {
1089
+ "$ref": "#/$defs/__schema0",
1090
+ },
1091
+ {
1092
+ "type": "null",
1093
+ },
1094
+ ],
1095
+ },
1096
+ },
1097
+ "required": [
1098
+ "a",
1099
+ "b",
1100
+ ],
1101
+ "type": "object",
1102
+ }
1103
+ `);
1104
+ });
1105
+
1106
+ test("openapi-3.0 keeps a single-string type", () => {
1107
+ // OpenAPI 3.0 has no type arrays; nullability is spelled with `nullable`
1108
+ expect(z.toJSONSchema(z.string().nullable(), { target: "openapi-3.0" })).toMatchInlineSnapshot(`
1109
+ {
1110
+ "nullable": true,
1111
+ "type": "string",
1112
+ }
1113
+ `);
1114
+ });
1115
+
1116
+ test("union with constrained branch is not compacted", () => {
1117
+ const schema = z.union([z.string().min(1), z.number()]);
790
1118
  expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
791
1119
  {
792
1120
  "$schema": "https://json-schema.org/draft/2020-12/schema",
793
1121
  "anyOf": [
794
1122
  {
1123
+ "minLength": 1,
795
1124
  "type": "string",
796
1125
  },
797
1126
  {
@@ -802,6 +1131,25 @@ describe("toJSONSchema", () => {
802
1131
  `);
803
1132
  });
804
1133
 
1134
+ test("union of literals is not compacted", () => {
1135
+ const schema = z.union([z.literal("a"), z.literal("b")]);
1136
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1137
+ {
1138
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1139
+ "anyOf": [
1140
+ {
1141
+ "const": "a",
1142
+ "type": "string",
1143
+ },
1144
+ {
1145
+ "const": "b",
1146
+ "type": "string",
1147
+ },
1148
+ ],
1149
+ }
1150
+ `);
1151
+ });
1152
+
805
1153
  test("discriminated unions", () => {
806
1154
  const schema = z.discriminatedUnion("type", [
807
1155
  z.object({ type: z.literal("success"), data: z.string() }),
@@ -856,32 +1204,20 @@ describe("toJSONSchema", () => {
856
1204
  expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
857
1205
  {
858
1206
  "$schema": "https://json-schema.org/draft/2020-12/schema",
859
- "allOf": [
860
- {
861
- "additionalProperties": false,
862
- "properties": {
863
- "name": {
864
- "type": "string",
865
- },
866
- },
867
- "required": [
868
- "name",
869
- ],
870
- "type": "object",
1207
+ "additionalProperties": false,
1208
+ "properties": {
1209
+ "age": {
1210
+ "type": "number",
871
1211
  },
872
- {
873
- "additionalProperties": false,
874
- "properties": {
875
- "age": {
876
- "type": "number",
877
- },
878
- },
879
- "required": [
880
- "age",
881
- ],
882
- "type": "object",
1212
+ "name": {
1213
+ "type": "string",
883
1214
  },
1215
+ },
1216
+ "required": [
1217
+ "name",
1218
+ "age",
884
1219
  ],
1220
+ "type": "object",
885
1221
  }
886
1222
  `);
887
1223
  });
@@ -941,7 +1277,23 @@ describe("toJSONSchema", () => {
941
1277
  `);
942
1278
  });
943
1279
 
944
- test("record filters enum values to strings and numbers for required", () => {
1280
+ test("record with enum keys drops required for an optional-in value under io: input", () => {
1281
+ const schema = z.record(z.enum(["key1", "key2"]), z.number().default(0));
1282
+
1283
+ expect(z.toJSONSchema(schema, { io: "input" }).required).toBeUndefined();
1284
+ expect(z.toJSONSchema(schema).required).toEqual(["key1", "key2"]);
1285
+ expect(z.toJSONSchema(z.record(z.enum(["key1", "key2"]), z.number()), { io: "input" }).required).toEqual([
1286
+ "key1",
1287
+ "key2",
1288
+ ]);
1289
+ // A caught value keeps required, matching the input type and z.object().
1290
+ expect(z.toJSONSchema(z.record(z.enum(["key1", "key2"]), z.number().catch(0)), { io: "input" }).required).toEqual([
1291
+ "key1",
1292
+ "key2",
1293
+ ]);
1294
+ });
1295
+
1296
+ test("record stringifies numeric enum keys for propertyNames and required", () => {
945
1297
  enum NumberEnum {
946
1298
  Zero = 0,
947
1299
  One = 1,
@@ -956,33 +1308,137 @@ describe("toJSONSchema", () => {
956
1308
  },
957
1309
  "propertyNames": {
958
1310
  "enum": [
959
- 0,
960
- 1,
1311
+ "0",
1312
+ "1",
961
1313
  ],
962
- "type": "number",
1314
+ "type": "string",
963
1315
  },
964
1316
  "required": [
965
- 0,
966
- 1,
1317
+ "0",
1318
+ "1",
967
1319
  ],
968
1320
  "type": "object",
969
1321
  }
970
1322
  `);
971
1323
  });
972
1324
 
973
- test("strict record with regex key uses propertyNames", () => {
974
- const schema = z.record(z.string().regex(/^label:[a-z]{2}$/), z.string());
1325
+ test("record with a numeric key emits propertyNames over the numeric-string form", () => {
1326
+ expect(z.toJSONSchema(z.record(z.number(), z.boolean())).propertyNames).toEqual({
1327
+ type: "string",
1328
+ pattern: "^-?\\d+(?:\\.\\d+)?$",
1329
+ });
1330
+ // range checks can't apply to a key, so only the integer shape survives
1331
+ expect(z.toJSONSchema(z.record(z.int32(), z.boolean())).propertyNames).toEqual({
1332
+ type: "string",
1333
+ pattern: "^-?\\d+$",
1334
+ });
1335
+ expect(z.toJSONSchema(z.record(z.literal([1, 2]), z.boolean()))).toMatchObject({
1336
+ propertyNames: { type: "string", enum: ["1", "2"] },
1337
+ required: ["1", "2"],
1338
+ });
1339
+ expect(z.toJSONSchema(z.record(z.literal(1), z.boolean())).propertyNames).toEqual({
1340
+ type: "string",
1341
+ const: "1",
1342
+ });
1343
+ });
975
1344
 
976
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
977
- {
978
- "$schema": "https://json-schema.org/draft/2020-12/schema",
979
- "additionalProperties": {
980
- "type": "string",
981
- },
982
- "propertyNames": {
983
- "pattern": "^label:[a-z]{2}$",
984
- "type": "string",
985
- },
1345
+ test("record key rewrite reaches through wrappers and union branches", () => {
1346
+ const numericString = { type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" };
1347
+ // a wrapper only carries its inner type once the refs are flattened, so this is decided after the record itself is emitted
1348
+ expect(
1349
+ z.toJSONSchema(
1350
+ z.record(
1351
+ z.lazy(() => z.number()),
1352
+ z.boolean()
1353
+ )
1354
+ ).propertyNames
1355
+ ).toEqual(numericString);
1356
+ expect(z.toJSONSchema(z.record(z.number().pipe(z.number()), z.boolean())).propertyNames).toEqual(numericString);
1357
+ expect(z.toJSONSchema(z.record(z.number().readonly(), z.boolean())).propertyNames).toMatchObject(numericString);
1358
+ expect(z.toJSONSchema(z.record(z.union([z.literal("Tuna"), z.literal(21)]), z.string()))).toMatchObject({
1359
+ propertyNames: {
1360
+ anyOf: [
1361
+ { type: "string", const: "Tuna" },
1362
+ { type: "string", const: "21" },
1363
+ ],
1364
+ },
1365
+ required: ["Tuna", "21"],
1366
+ });
1367
+ });
1368
+
1369
+ test("record with a numeric key inlines an extracted key, and leaves a string one referenced", () => {
1370
+ expect(z.toJSONSchema(z.record(z.number().meta({ id: "Num" }), z.boolean())).propertyNames).toEqual({
1371
+ type: "string",
1372
+ pattern: "^-?\\d+(?:\\.\\d+)?$",
1373
+ });
1374
+ expect(z.toJSONSchema(z.record(z.string().meta({ id: "Str" }), z.boolean())).propertyNames).toEqual({
1375
+ $ref: "#/$defs/Str",
1376
+ });
1377
+ // the value position still wants the number form, so the two cannot share one def
1378
+ const key = z.number().meta({ id: "Shared" });
1379
+ expect(z.toJSONSchema(z.object({ a: key, b: z.record(key, z.string()) }))).toMatchObject({
1380
+ properties: { a: { $ref: "#/$defs/Shared" }, b: { propertyNames: { type: "string" } } },
1381
+ $defs: { Shared: { type: "number" } },
1382
+ });
1383
+ });
1384
+
1385
+ test("record key rewrite reaches a wrapped record", () => {
1386
+ // the flatten copies a record's properties onto its wrapper by reference, so the rewrite has to find every copy
1387
+ expect(z.toJSONSchema(z.record(z.number(), z.boolean()).optional()).propertyNames).toEqual({
1388
+ type: "string",
1389
+ pattern: "^-?\\d+(?:\\.\\d+)?$",
1390
+ });
1391
+ expect(z.toJSONSchema(z.object({ a: z.record(z.literal([1, 2]), z.boolean()).optional() }))).toMatchObject({
1392
+ properties: { a: { propertyNames: { type: "string", enum: ["1", "2"] }, required: ["1", "2"] } },
1393
+ });
1394
+ });
1395
+
1396
+ test("record with a recursive key converts without looping", () => {
1397
+ const numeric: any = z.lazy(() => z.union([z.number(), numeric]));
1398
+ expect(z.toJSONSchema(z.record(numeric, z.boolean())).propertyNames).toMatchObject({
1399
+ anyOf: [{ type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" }, { $ref: "#/$defs/__schema0" }],
1400
+ });
1401
+ // a key with nothing to re-express keeps the reference it had
1402
+ const stringy: any = z.lazy(() => z.union([z.string(), stringy]));
1403
+ expect(z.toJSONSchema(z.record(stringy, z.boolean())).propertyNames).toEqual({ $ref: "#/$defs/__schema0" });
1404
+ expect(
1405
+ z.toJSONSchema(z.record(z.union([z.literal("a"), z.literal("b")]).meta({ id: "Keys" }), z.boolean()))
1406
+ .propertyNames
1407
+ ).toEqual({ $ref: "#/$defs/Keys" });
1408
+ });
1409
+
1410
+ test("record with a heterogeneous key stringifies only its numeric members", () => {
1411
+ // a mixed key carries no `type`, so the numeric members are caught by value rather than by type
1412
+ expect(z.toJSONSchema(z.record(z.literal(["a", 1]), z.boolean()))).toMatchObject({
1413
+ propertyNames: { enum: ["a", "1"] },
1414
+ required: ["a", "1"],
1415
+ });
1416
+ // a member no key can spell is left as it was, since the parser only ever retries a key as a number
1417
+ expect(z.toJSONSchema(z.record(z.literal(["a", true]) as any, z.boolean())).propertyNames).toEqual({
1418
+ enum: ["a", true],
1419
+ });
1420
+ });
1421
+
1422
+ test("record stringifies required for every target", () => {
1423
+ const schema = z.record(z.literal([1, 2]), z.boolean());
1424
+ for (const target of ["draft-2020-12", "draft-7", "draft-4", "openapi-3.0"] as const) {
1425
+ expect(z.toJSONSchema(schema, { target }).required).toEqual(["1", "2"]);
1426
+ }
1427
+ });
1428
+
1429
+ test("strict record with regex key uses propertyNames", () => {
1430
+ const schema = z.record(z.string().regex(/^label:[a-z]{2}$/), z.string());
1431
+
1432
+ expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1433
+ {
1434
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1435
+ "additionalProperties": {
1436
+ "type": "string",
1437
+ },
1438
+ "propertyNames": {
1439
+ "pattern": "^label:[a-z]{2}$",
1440
+ "type": "string",
1441
+ },
986
1442
  "type": "object",
987
1443
  }
988
1444
  `);
@@ -1086,6 +1542,9 @@ describe("toJSONSchema", () => {
1086
1542
  expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1087
1543
  {
1088
1544
  "$schema": "https://json-schema.org/draft/2020-12/schema",
1545
+ "items": false,
1546
+ "maxItems": 2,
1547
+ "minItems": 2,
1089
1548
  "prefixItems": [
1090
1549
  {
1091
1550
  "type": "string",
@@ -1107,6 +1566,7 @@ describe("toJSONSchema", () => {
1107
1566
  "items": {
1108
1567
  "type": "boolean",
1109
1568
  },
1569
+ "minItems": 2,
1110
1570
  "prefixItems": [
1111
1571
  {
1112
1572
  "type": "string",
@@ -1162,7 +1622,7 @@ describe("toJSONSchema", () => {
1162
1622
  },
1163
1623
  ],
1164
1624
  },
1165
- "minItems": 3,
1625
+ "minItems": 2,
1166
1626
  "type": "array",
1167
1627
  }
1168
1628
  `);
@@ -1203,6 +1663,7 @@ describe("toJSONSchema", () => {
1203
1663
  expect(z.toJSONSchema(schema, { target: "draft-7", io: "input" })).toMatchInlineSnapshot(`
1204
1664
  {
1205
1665
  "$schema": "http://json-schema.org/draft-07/schema#",
1666
+ "additionalItems": false,
1206
1667
  "items": [
1207
1668
  {
1208
1669
  "type": "string",
@@ -1211,6 +1672,8 @@ describe("toJSONSchema", () => {
1211
1672
  "type": "number",
1212
1673
  },
1213
1674
  ],
1675
+ "maxItems": 2,
1676
+ "minItems": 2,
1214
1677
  "type": "array",
1215
1678
  }
1216
1679
  `);
@@ -1232,14 +1695,14 @@ describe("toJSONSchema", () => {
1232
1695
  "type": "number",
1233
1696
  },
1234
1697
  ],
1698
+ "minItems": 2,
1235
1699
  "type": "array",
1236
1700
  }
1237
1701
  `);
1238
1702
  });
1239
1703
 
1240
1704
  test("tuple with rest draft-7 - issue #5151 regression test", () => {
1241
- // This test addresses issue #5151: tuple with rest elements and ids
1242
- // in draft-7 had incorrect internal path handling affecting complex scenarios
1705
+ // This test addresses issue #5151: tuple with rest elements and ids in draft-7 had incorrect internal path handling affecting complex scenarios
1243
1706
  const primarySchema = z.string().meta({ id: "primary" });
1244
1707
  const restSchema = z.number().meta({ id: "rest" });
1245
1708
  const testSchema = z.tuple([primarySchema], restSchema);
@@ -1271,6 +1734,7 @@ describe("toJSONSchema", () => {
1271
1734
  "$ref": "#/definitions/primary",
1272
1735
  },
1273
1736
  ],
1737
+ "minItems": 1,
1274
1738
  "type": "array",
1275
1739
  }
1276
1740
  `);
@@ -1285,6 +1749,88 @@ describe("toJSONSchema", () => {
1285
1749
  expect(result.additionalItems).toBeDefined();
1286
1750
  });
1287
1751
 
1752
+ test("closed tuple length constraints - issue #6193", () => {
1753
+ const schema = z.tuple([z.string(), z.string(), z.object({ lang: z.string() })]);
1754
+
1755
+ expect(schema.safeParse(["a", "b", { lang: "en" }, "extra"]).success).toBe(false);
1756
+
1757
+ const draft2020 = z.toJSONSchema(schema, { target: "draft-2020-12" });
1758
+ expect(draft2020.items).toBe(false);
1759
+ expect(draft2020.minItems).toBe(3);
1760
+ expect(draft2020.maxItems).toBe(3);
1761
+
1762
+ const draft7 = z.toJSONSchema(schema, { target: "draft-7", io: "input" });
1763
+ expect(draft7.additionalItems).toBe(false);
1764
+ expect(draft7.minItems).toBe(3);
1765
+ expect(draft7.maxItems).toBe(3);
1766
+
1767
+ const openapi = z.toJSONSchema(schema, { target: "openapi-3.0" });
1768
+ validateOpenAPI30Schema(openapi);
1769
+ expect(openapi.minItems).toBe(3);
1770
+ expect(openapi.maxItems).toBe(3);
1771
+ });
1772
+
1773
+ test("closed tuple with optional trailing items", () => {
1774
+ const schema = z.tuple([z.string(), z.number().optional()]);
1775
+
1776
+ const draft2020 = z.toJSONSchema(schema, { target: "draft-2020-12" });
1777
+ expect(draft2020.items).toBe(false);
1778
+ expect(draft2020.minItems).toBe(1);
1779
+ expect(draft2020.maxItems).toBe(2);
1780
+
1781
+ const draft7 = z.toJSONSchema(schema, { target: "draft-7", io: "input" });
1782
+ expect(draft7.additionalItems).toBe(false);
1783
+ expect(draft7.minItems).toBe(1);
1784
+ expect(draft7.maxItems).toBe(2);
1785
+ });
1786
+
1787
+ test("empty closed tuple rejects extra elements", () => {
1788
+ const schema = z.tuple([]);
1789
+
1790
+ const draft2020 = z.toJSONSchema(schema, { target: "draft-2020-12" });
1791
+ expect(draft2020.items).toBe(false);
1792
+ expect(draft2020.maxItems).toBe(0);
1793
+
1794
+ const draft7 = z.toJSONSchema(schema, { target: "draft-7", io: "input" });
1795
+ expect(draft7.additionalItems).toBe(false);
1796
+ expect(draft7.maxItems).toBe(0);
1797
+
1798
+ const openapi = z.toJSONSchema(schema, { target: "openapi-3.0" });
1799
+ validateOpenAPI30Schema(openapi);
1800
+ expect(openapi.maxItems).toBe(0);
1801
+ });
1802
+
1803
+ test("closed tuple length respects io direction with defaults", () => {
1804
+ const schema = z.tuple([z.string(), z.string().default("x")]);
1805
+
1806
+ const input = z.toJSONSchema(schema, { target: "draft-2020-12", io: "input" });
1807
+ expect(input.items).toBe(false);
1808
+ expect(input.minItems).toBe(1);
1809
+ expect(input.maxItems).toBe(2);
1810
+
1811
+ const output = z.toJSONSchema(schema, { target: "draft-2020-12", io: "output" });
1812
+ expect(output.items).toBe(false);
1813
+ expect(output.minItems).toBe(2);
1814
+ expect(output.maxItems).toBe(2);
1815
+ });
1816
+
1817
+ test("closed tuple length resolves input optionality past transform and catch", () => {
1818
+ const minItems = (schema: z.core.$ZodType, io: "input" | "output") =>
1819
+ z.toJSONSchema(schema, { target: "draft-2020-12", io }).minItems;
1820
+
1821
+ // Both let the parser observe an absent slot, but declare a required input.
1822
+ const pre = z.tuple([z.string(), z.preprocess((v) => v, z.string())]);
1823
+ expect(minItems(pre, "input")).toBe(2);
1824
+ expect(minItems(pre, "output")).toBe(2);
1825
+
1826
+ const caught = z.tuple([z.string(), z.string().catch("x")]);
1827
+ expect(minItems(caught, "input")).toBe(2);
1828
+ expect(minItems(caught, "output")).toBe(2);
1829
+
1830
+ // Resolution passes through the wrapper rather than stopping at it.
1831
+ expect(minItems(z.tuple([z.string(), z.string().optional().catch("x")]), "input")).toBe(1);
1832
+ });
1833
+
1288
1834
  test("promise", () => {
1289
1835
  const schema = z.promise(z.string());
1290
1836
  expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
@@ -1904,13 +2450,9 @@ test("override execution order", () => {
1904
2450
 
1905
2451
  expect(unionSchema).toMatchInlineSnapshot(`
1906
2452
  {
1907
- "anyOf": [
1908
- {
1909
- "type": "string",
1910
- },
1911
- {
1912
- "type": "number",
1913
- },
2453
+ "type": [
2454
+ "string",
2455
+ "number",
1914
2456
  ],
1915
2457
  }
1916
2458
  `);
@@ -2092,6 +2634,134 @@ test("extract schemas with id", () => {
2092
2634
  `);
2093
2635
  });
2094
2636
 
2637
+ test("escapes JSON Pointer reserved characters in $ref but not in $defs key", () => {
2638
+ const User = z.object({ name: z.string() }).meta({ id: "Shared/User~" });
2639
+ const result = z.toJSONSchema(z.object({ User }));
2640
+ // the $ref pointer escapes `/` -> `~1` and `~` -> `~0` (RFC 6901),
2641
+ // while the $defs key keeps the original id
2642
+ expect((result.properties!.User as any).$ref).toBe("#/$defs/Shared~1User~0");
2643
+ expect(Object.keys(result.$defs!)).toEqual(["Shared/User~"]);
2644
+ });
2645
+
2646
+ test("escapes JSON Pointer reserved characters in the root $ref", () => {
2647
+ const User = z.object({ name: z.string() }).meta({ id: "Shared/User~" });
2648
+ const result = z.toJSONSchema(User);
2649
+ expect(result.$ref).toBe("#/$defs/Shared~1User~0");
2650
+ expect(Object.keys(result.$defs!)).toEqual(["Shared/User~"]);
2651
+ });
2652
+
2653
+ test("a multipleOf divisor JSON Schema cannot express goes through `unrepresentable`", () => {
2654
+ // the keyword must be strictly greater than zero, and NaN/Infinity do not survive JSON at all
2655
+ for (const divisor of [0, Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]) {
2656
+ expect(() => z.toJSONSchema(z.number().multipleOf(divisor))).toThrow(/cannot be represented in JSON Schema/);
2657
+ expect(z.toJSONSchema(z.number().multipleOf(divisor), { unrepresentable: "any" })).toMatchObject({
2658
+ type: "number",
2659
+ });
2660
+ expect(z.toJSONSchema(z.number().multipleOf(divisor), { unrepresentable: "any" })).not.toHaveProperty("multipleOf");
2661
+ }
2662
+
2663
+ // a negative divisor accepts exactly what its absolute value accepts, so it still maps
2664
+ expect(z.number().multipleOf(-5).safeParse(10).success).toEqual(true);
2665
+ expect(z.number().multipleOf(-5).safeParse(13).success).toEqual(false);
2666
+ expect(z.toJSONSchema(z.number().multipleOf(-5))).toMatchObject({ multipleOf: 5 });
2667
+ expect(z.toJSONSchema(z.number().multipleOf(0.1))).toMatchObject({ multipleOf: 0.1 });
2668
+ });
2669
+
2670
+ test("unrepresentable default values go through `unrepresentable`", () => {
2671
+ // a bigint default has no reliable JSON encoding, so it is dropped rather than approximated
2672
+ expect(z.toJSONSchema(z.bigint().default(0n), { unrepresentable: "any" })).toMatchInlineSnapshot(`
2673
+ {
2674
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2675
+ }
2676
+ `);
2677
+ expect(z.toJSONSchema(z.bigint().prefault(2n), { io: "input", unrepresentable: "any" })).toMatchInlineSnapshot(`
2678
+ {
2679
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2680
+ }
2681
+ `);
2682
+ // including when nested inside an otherwise representable default
2683
+ expect(
2684
+ z.toJSONSchema(z.object({ a: z.bigint() }).default({ a: 1n }), { unrepresentable: "any" })
2685
+ ).toMatchInlineSnapshot(`
2686
+ {
2687
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2688
+ "additionalProperties": false,
2689
+ "properties": {
2690
+ "a": {},
2691
+ },
2692
+ "required": [
2693
+ "a",
2694
+ ],
2695
+ "type": "object",
2696
+ }
2697
+ `);
2698
+
2699
+ // under the default strict mode the inner type throws first; a representable inner type surfaces the default's own error rather than a raw `JSON.stringify` TypeError
2700
+ expect(() => z.toJSONSchema(z.bigint().default(0n))).toThrow("BigInt cannot be represented in JSON Schema");
2701
+ expect(() => z.toJSONSchema(z.unknown().default(1n))).toThrow("BigInt defaults cannot be represented in JSON Schema");
2702
+
2703
+ // representable defaults are untouched
2704
+ expect(z.toJSONSchema(z.object({ a: z.number() }).default({ a: 2 }))).toMatchInlineSnapshot(`
2705
+ {
2706
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2707
+ "additionalProperties": false,
2708
+ "default": {
2709
+ "a": 2,
2710
+ },
2711
+ "properties": {
2712
+ "a": {
2713
+ "type": "number",
2714
+ },
2715
+ },
2716
+ "required": [
2717
+ "a",
2718
+ ],
2719
+ "type": "object",
2720
+ }
2721
+ `);
2722
+ });
2723
+
2724
+ test("an `unrepresentable` handler can represent a bigint default", () => {
2725
+ // one handler covers both the type and its default, so no `unrepresentable: "any"` is needed and every other unrepresentable type still throws
2726
+ expect(
2727
+ z.toJSONSchema(z.object({ startAt: z.coerce.bigint().optional().default(0n) }), {
2728
+ io: "input",
2729
+ unrepresentable: ({ zodSchema }) => {
2730
+ const def = zodSchema._zod.def;
2731
+ if (def.type === "bigint") return { type: "integer", format: "int64" };
2732
+ if (def.type === "default") return { default: String(def.defaultValue) };
2733
+ return "throw";
2734
+ },
2735
+ })
2736
+ ).toMatchInlineSnapshot(`
2737
+ {
2738
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2739
+ "properties": {
2740
+ "startAt": {
2741
+ "default": "0",
2742
+ "format": "int64",
2743
+ "type": "integer",
2744
+ },
2745
+ },
2746
+ "type": "object",
2747
+ }
2748
+ `);
2749
+
2750
+ // a handler may also drop just the default while still representing the type
2751
+ expect(
2752
+ z.toJSONSchema(z.bigint().default(0n), {
2753
+ unrepresentable: ({ zodSchema }) =>
2754
+ zodSchema._zod.def.type === "bigint" ? { type: "integer", format: "int64" } : "any",
2755
+ })
2756
+ ).toMatchInlineSnapshot(`
2757
+ {
2758
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2759
+ "format": "int64",
2760
+ "type": "integer",
2761
+ }
2762
+ `);
2763
+ });
2764
+
2095
2765
  test("unrepresentable literal values are ignored", () => {
2096
2766
  const a = z.toJSONSchema(z.literal(["hello", null, 5, BigInt(1324), undefined]), { unrepresentable: "any" });
2097
2767
  expect(a).toMatchInlineSnapshot(`
@@ -2168,8 +2838,7 @@ test("describe with id", () => {
2168
2838
  });
2169
2839
 
2170
2840
  test("id is stripped from $defs entries (draft-2020-12)", () => {
2171
- // The `id` in `.meta()` is a registration tag — it determines the $defs key
2172
- // but should not leak into the definition body, where it is redundant.
2841
+ // The `id` in `.meta()` is a registration tag — it determines the $defs key but should not leak into the definition body, where it is redundant.
2173
2842
  const inner = z.string().meta({ id: "Inner" });
2174
2843
  const result = z.toJSONSchema(z.object({ a: inner, b: inner }));
2175
2844
  expect(result.$defs?.Inner).toEqual({ type: "string" });
@@ -2177,9 +2846,7 @@ test("id is stripped from $defs entries (draft-2020-12)", () => {
2177
2846
  });
2178
2847
 
2179
2848
  test("id is stripped from definitions entries (draft-04)", () => {
2180
- // In draft-04, `id` is a reserved keyword that sets a base URI for the
2181
- // subschema. Leaking Zod's registration tag here is semantically wrong, so
2182
- // ensure it is stripped.
2849
+ // In draft-04, `id` is a reserved keyword that sets a base URI for the subschema. Leaking Zod's registration tag here is semantically wrong, so ensure it is stripped.
2183
2850
  const inner = z.string().meta({ id: "Inner" });
2184
2851
  const result = z.toJSONSchema(z.object({ a: inner, b: inner }), { target: "draft-04" }) as any;
2185
2852
  expect(result.definitions?.Inner).toEqual({ type: "string" });
@@ -2193,9 +2860,52 @@ test("id is stripped from root schema", () => {
2193
2860
  expect((result as any).id).toBeUndefined();
2194
2861
  });
2195
2862
 
2863
+ test("root schema with id is hoisted into $defs", () => {
2864
+ const A = z.object({ name: z.string() }).meta({ id: "A" });
2865
+ const result = z.toJSONSchema(A);
2866
+
2867
+ expect(result).toEqual({
2868
+ $schema: "https://json-schema.org/draft/2020-12/schema",
2869
+ $ref: "#/$defs/A",
2870
+ $defs: {
2871
+ A: {
2872
+ type: "object",
2873
+ properties: {
2874
+ name: {
2875
+ type: "string",
2876
+ },
2877
+ },
2878
+ required: ["name"],
2879
+ additionalProperties: false,
2880
+ },
2881
+ },
2882
+ });
2883
+ });
2884
+
2885
+ test("root schema with id uses definitions on legacy targets", () => {
2886
+ const A = z.object({ name: z.string() }).meta({ id: "A" });
2887
+ const result = z.toJSONSchema(A, { target: "draft-07" });
2888
+
2889
+ expect(result).toEqual({
2890
+ $schema: "http://json-schema.org/draft-07/schema#",
2891
+ $ref: "#/definitions/A",
2892
+ definitions: {
2893
+ A: {
2894
+ type: "object",
2895
+ properties: {
2896
+ name: {
2897
+ type: "string",
2898
+ },
2899
+ },
2900
+ required: ["name"],
2901
+ additionalProperties: false,
2902
+ },
2903
+ },
2904
+ });
2905
+ });
2906
+
2196
2907
  test("id is observable in override callback", () => {
2197
- // The strip happens after override callbacks run, so userland override code
2198
- // can still read `jsonSchema.id` if it wants to.
2908
+ // The strip happens after override callbacks run, so userland override code can still read `jsonSchema.id` if it wants to.
2199
2909
  const inner = z.string().meta({ id: "Inner" });
2200
2910
  const seenIds: Array<string | undefined> = [];
2201
2911
  z.toJSONSchema(z.object({ a: inner }), {
@@ -2207,8 +2917,7 @@ test("id is observable in override callback", () => {
2207
2917
  });
2208
2918
 
2209
2919
  test("describe with id on wrapper", () => {
2210
- // Test that $ref propagation works when processor sets a different ref (readonly -> innerType)
2211
- // but parent was extracted due to having an id
2920
+ // Test that $ref propagation works when processor sets a different ref (readonly -> innerType) but parent was extracted due to having an id
2212
2921
  const roJobId = z.string().readonly().meta({ id: "roJobId" });
2213
2922
 
2214
2923
  const a = z.toJSONSchema(
@@ -2416,45 +3125,40 @@ test("top-level readonly", () => {
2416
3125
  // .meta({ id: "B" });
2417
3126
 
2418
3127
  const result = z.toJSONSchema(A);
2419
- expect(result).toMatchInlineSnapshot(`
2420
- {
2421
- "$defs": {
2422
- "B": {
2423
- "additionalProperties": false,
2424
- "properties": {
2425
- "a": {
2426
- "$ref": "#",
2427
- },
2428
- "name": {
2429
- "type": "string",
2430
- },
3128
+ expect(result).toEqual({
3129
+ $schema: "https://json-schema.org/draft/2020-12/schema",
3130
+ $ref: "#/$defs/A",
3131
+ $defs: {
3132
+ A: {
3133
+ additionalProperties: false,
3134
+ properties: {
3135
+ b: {
3136
+ $ref: "#/$defs/B",
3137
+ },
3138
+ name: {
3139
+ type: "string",
2431
3140
  },
2432
- "readOnly": true,
2433
- "required": [
2434
- "name",
2435
- "a",
2436
- ],
2437
- "type": "object",
2438
3141
  },
3142
+ readOnly: true,
3143
+ required: ["name", "b"],
3144
+ type: "object",
2439
3145
  },
2440
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2441
- "additionalProperties": false,
2442
- "properties": {
2443
- "b": {
2444
- "$ref": "#/$defs/B",
2445
- },
2446
- "name": {
2447
- "type": "string",
3146
+ B: {
3147
+ additionalProperties: false,
3148
+ properties: {
3149
+ a: {
3150
+ $ref: "#/$defs/A",
3151
+ },
3152
+ name: {
3153
+ type: "string",
3154
+ },
2448
3155
  },
3156
+ readOnly: true,
3157
+ required: ["name", "a"],
3158
+ type: "object",
2449
3159
  },
2450
- "readOnly": true,
2451
- "required": [
2452
- "name",
2453
- "b",
2454
- ],
2455
- "type": "object",
2456
- }
2457
- `);
3160
+ },
3161
+ });
2458
3162
  });
2459
3163
 
2460
3164
  test("basic registry", () => {
@@ -2531,51 +3235,237 @@ test("basic registry", () => {
2531
3235
  `);
2532
3236
  });
2533
3237
 
2534
- test("_ref", () => {
2535
- // const a = z.promise(z.string().describe("a"));
2536
- const a = z.toJSONSchema(z.promise(z.string().describe("a")));
2537
- expect(a).toMatchInlineSnapshot(`
2538
- {
2539
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2540
- "description": "a",
2541
- "type": "string",
3238
+ test("large registry converts in linear time", () => {
3239
+ const count = 2000;
3240
+ const convert = (withIntersection: boolean) => {
3241
+ const registry = z.registry<{ id: string }>();
3242
+ for (let i = 0; i < count; i++) {
3243
+ registry.add(
3244
+ z.object({ id: z.string(), name: z.string(), count: z.number(), nested: z.object({ a: z.boolean() }) }),
3245
+ { id: `Type${i}` }
3246
+ );
2542
3247
  }
2543
- `);
3248
+ if (withIntersection) registry.add(z.object({ a: z.string() }).and(z.object({ b: z.string() })), { id: "Inter" });
3249
+
3250
+ const start = performance.now();
3251
+ const { schemas } = z.toJSONSchema(registry, { uri: (id) => `https://example.com/${id}.json` });
3252
+ return { schemas, elapsed: performance.now() - start };
3253
+ };
3254
+
3255
+ const plain = convert(false);
3256
+ expect(Object.keys(plain.schemas)).toHaveLength(count);
3257
+ expect(plain.schemas.Type0).toMatchObject({
3258
+ $id: "https://example.com/Type0.json",
3259
+ type: "object",
3260
+ properties: { nested: { type: "object" } },
3261
+ });
3262
+ expect(plain.schemas[`Type${count - 1}`]!.$id).toBe(`https://example.com/Type${count - 1}.json`);
2544
3263
 
2545
- const b = z.toJSONSchema(z.lazy(() => z.string().describe("a")));
2546
- expect(b).toMatchInlineSnapshot(`
2547
- {
2548
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2549
- "description": "a",
2550
- "type": "string",
2551
- }
2552
- `);
3264
+ // The whole-map passes in extractDefs/finalize used to re-run once per registered schema, which made this quadratic: ~9s of CPU at this size before the passes were hoisted, ~50ms after.
3265
+ expect(plain.elapsed).toBeLessThan(5000);
2553
3266
 
2554
- const c = z.toJSONSchema(z.optional(z.string().describe("a")));
2555
- expect(c).toMatchInlineSnapshot(`
2556
- {
2557
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2558
- "description": "a",
2559
- "type": "string",
3267
+ // The intersection fold walks the whole map as well, so it has to run inside the same guard. Hoisting it back out costs ~10x at this size. Comparing the two conversions rather than asserting a fixed budget keeps this independent of how fast the machine is.
3268
+ const folded = convert(true);
3269
+ expect(folded.schemas.Inter).toMatchObject({ type: "object", properties: { a: {}, b: {} } });
3270
+ expect(folded.elapsed).toBeLessThan(plain.elapsed * 4 + 100);
3271
+ });
3272
+
3273
+ test("a registry of records with numeric keys converts in linear time", () => {
3274
+ const count = 2000;
3275
+ const convert = (key: (i: number) => z.core.$ZodType) => {
3276
+ const registry = z.registry<{ id: string }>();
3277
+ for (let i = 0; i < count; i++) {
3278
+ registry.add(z.object({ m: z.record(key(i) as z.core.$ZodRecordKey, z.boolean()) }), { id: `Type${i}` });
2560
3279
  }
2561
- `);
3280
+ const start = performance.now();
3281
+ const { schemas } = z.toJSONSchema(registry, { uri: (id) => `https://example.com/${id}.json` });
3282
+ return { schemas, elapsed: performance.now() - start };
3283
+ };
3284
+
3285
+ const string = convert(() => z.string());
3286
+ const numeric = convert(() => z.number());
3287
+ expect(numeric.schemas.Type0).toMatchObject({
3288
+ properties: { m: { propertyNames: { type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" } } },
3289
+ });
2562
3290
 
2563
- const d = z.toJSONSchema(z.string().meta({ id: "foo" }).describe("bar").optional());
2564
- expect(d).toMatchInlineSnapshot(`
3291
+ // The rewrite has to find every carrier the flatten copied `propertyNames` onto, which means a pass over the whole seen map. Running that once per record rather than once per conversion cost ~10x at this size. A string key needs no rewrite at all, so comparing against it keeps this independent of how fast the machine is.
3292
+ expect(numeric.elapsed).toBeLessThan(string.elapsed * 2 + 50);
3293
+
3294
+ // An extracted key resolves through a map built once per conversion rather than a search per reference. There is no stable timing control for that — extraction has its own $defs cost, which swamps the difference — so this only pins the shape.
3295
+ const extracted = convert((i) => z.number().meta({ id: `Key${i}` }));
3296
+ expect(extracted.schemas.Type0).toMatchObject({
3297
+ properties: { m: { propertyNames: { type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" } } },
3298
+ });
3299
+ });
3300
+
3301
+ test("registry extracts unregistered subschemas into __shared", () => {
3302
+ const registry = z.registry<{ id: string }>();
3303
+ const address = z.object({ street: z.string() }).meta({ id: "Address" });
3304
+ registry.add(z.object({ home: address, work: address }), { id: "Person" });
3305
+ registry.add(z.object({ hq: address }), { id: "Company" });
3306
+
3307
+ const { schemas } = z.toJSONSchema(registry, { uri: (id) => `https://example.com/${id}.json` });
3308
+
3309
+ expect(schemas.__shared).toMatchInlineSnapshot(`
2565
3310
  {
2566
3311
  "$defs": {
2567
- "foo": {
2568
- "type": "string",
3312
+ "Address": {
3313
+ "additionalProperties": false,
3314
+ "properties": {
3315
+ "street": {
3316
+ "type": "string",
3317
+ },
3318
+ },
3319
+ "required": [
3320
+ "street",
3321
+ ],
3322
+ "type": "object",
2569
3323
  },
2570
3324
  },
2571
- "$ref": "#/$defs/foo",
3325
+ }
3326
+ `);
3327
+ expect(schemas.Person).toMatchInlineSnapshot(`
3328
+ {
3329
+ "$id": "https://example.com/Person.json",
2572
3330
  "$schema": "https://json-schema.org/draft/2020-12/schema",
2573
- "description": "bar",
3331
+ "additionalProperties": false,
3332
+ "properties": {
3333
+ "home": {
3334
+ "$ref": "https://example.com/__shared.json#/$defs/Address",
3335
+ },
3336
+ "work": {
3337
+ "$ref": "https://example.com/__shared.json#/$defs/Address",
3338
+ },
3339
+ },
3340
+ "required": [
3341
+ "home",
3342
+ "work",
3343
+ ],
3344
+ "type": "object",
2574
3345
  }
2575
3346
  `);
3347
+ // Company is emitted after Person, so it only resolves if the shared $defs built on the first finalize are still reachable — the pass that writes them no longer runs per schema.
3348
+ expect(schemas.Company!.properties!.hq).toEqual({
3349
+ $ref: "https://example.com/__shared.json#/$defs/Address",
3350
+ });
2576
3351
  });
2577
3352
 
2578
- test("defaults/prefaults", () => {
3353
+ test("registry extracts reused subschemas into __shared without an id", () => {
3354
+ const registry = z.registry<{ id: string }>();
3355
+ const shared = z.object({ q: z.string() });
3356
+ registry.add(z.object({ a: shared, b: shared }), { id: "First" });
3357
+ registry.add(z.object({ c: shared }), { id: "Second" });
3358
+
3359
+ const { schemas } = z.toJSONSchema(registry, { uri: (id) => `${id}.json`, reused: "ref" });
3360
+
3361
+ // The id is counter-generated, so this pins that ctx.counter is consumed exactly once.
3362
+ expect(Object.keys(schemas.__shared!.$defs!)).toEqual(["schema0"]);
3363
+ expect(schemas.First!.properties!.a).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3364
+ expect(schemas.Second!.properties!.c).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3365
+ });
3366
+
3367
+ test("JSONSchemaGenerator re-runs shared passes when emit params change", () => {
3368
+ const shared = z.object({ s: z.string() });
3369
+ const a = z.object({ x: shared, y: shared });
3370
+ const registry = z.registry<{ id: string }>();
3371
+ registry.add(a, { id: "A" });
3372
+
3373
+ const gen = new z.core.JSONSchemaGenerator({ target: "draft-2020-12" });
3374
+ gen.process(a);
3375
+ const defs: Record<string, any> = {};
3376
+ const external = { registry, uri: (id: string) => `${id}.json`, defs };
3377
+
3378
+ gen.emit(a, { external, reused: "inline" });
3379
+ // Same `external`, different `reused` — the second emit must still extract `shared`.
3380
+ const second: any = gen.emit(a, { external, reused: "ref" });
3381
+
3382
+ expect(Object.keys(defs)).toEqual(["schema0"]);
3383
+ expect(second.properties.x).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3384
+ expect(second.properties.y).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3385
+ });
3386
+
3387
+ test("JSONSchemaGenerator still throws on cycles when a later emit asks for it", () => {
3388
+ const Node: any = z.object({
3389
+ v: z.string(),
3390
+ get next() {
3391
+ return Node;
3392
+ },
3393
+ });
3394
+ const registry = z.registry<{ id: string }>();
3395
+ registry.add(Node, { id: "Node" });
3396
+
3397
+ const gen = new z.core.JSONSchemaGenerator({ target: "draft-2020-12" });
3398
+ gen.process(Node);
3399
+ const external = { registry, uri: (id: string) => `${id}.json`, defs: {} };
3400
+
3401
+ gen.emit(Node, { external, cycles: "ref" });
3402
+ expect(() => gen.emit(Node, { external, cycles: "throw" })).toThrow(/Cycle detected/);
3403
+ });
3404
+
3405
+ test("JSONSchemaGenerator re-runs shared passes on a no-params emit", () => {
3406
+ const shared = z.object({ s: z.string() });
3407
+ const a = z.object({ x: shared });
3408
+ const registry = z.registry<{ id: string }>();
3409
+ registry.add(a, { id: "A" });
3410
+
3411
+ const gen = new z.core.JSONSchemaGenerator({ target: "draft-2020-12" });
3412
+ gen.process(a);
3413
+ const defs: Record<string, any> = {};
3414
+ gen.emit(a, { external: { registry, uri: (id: string) => `${id}.json`, defs }, reused: "ref" });
3415
+
3416
+ // Re-processing an already-seen schema bumps `seen.count`, which `extractDefs` branches on under `reused: "ref"` — and it returns early, so it cannot clear the guards itself.
3417
+ gen.process(shared);
3418
+ const second: any = gen.emit(a);
3419
+
3420
+ expect(Object.keys(defs)).toEqual(["schema0"]);
3421
+ expect(second.properties.x).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3422
+ });
3423
+
3424
+ test("_ref", () => {
3425
+ // const a = z.promise(z.string().describe("a"));
3426
+ const a = z.toJSONSchema(z.promise(z.string().describe("a")));
3427
+ expect(a).toMatchInlineSnapshot(`
3428
+ {
3429
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3430
+ "description": "a",
3431
+ "type": "string",
3432
+ }
3433
+ `);
3434
+
3435
+ const b = z.toJSONSchema(z.lazy(() => z.string().describe("a")));
3436
+ expect(b).toMatchInlineSnapshot(`
3437
+ {
3438
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3439
+ "description": "a",
3440
+ "type": "string",
3441
+ }
3442
+ `);
3443
+
3444
+ const c = z.toJSONSchema(z.optional(z.string().describe("a")));
3445
+ expect(c).toMatchInlineSnapshot(`
3446
+ {
3447
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3448
+ "description": "a",
3449
+ "type": "string",
3450
+ }
3451
+ `);
3452
+
3453
+ const d = z.toJSONSchema(z.string().meta({ id: "foo" }).describe("bar").optional());
3454
+ expect(d).toMatchInlineSnapshot(`
3455
+ {
3456
+ "$defs": {
3457
+ "foo": {
3458
+ "type": "string",
3459
+ },
3460
+ },
3461
+ "$ref": "#/$defs/foo",
3462
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3463
+ "description": "bar",
3464
+ }
3465
+ `);
3466
+ });
3467
+
3468
+ test("defaults/prefaults", () => {
2579
3469
  const a = z
2580
3470
  .string()
2581
3471
  .transform((val) => val.length)
@@ -2627,6 +3517,45 @@ test("defaults/prefaults", () => {
2627
3517
  `);
2628
3518
  });
2629
3519
 
3520
+ test("catch on a transforming schema", () => {
3521
+ const a = z
3522
+ .string()
3523
+ .transform((val) => val.length)
3524
+ .pipe(z.number())
3525
+ .catch(0);
3526
+
3527
+ expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
3528
+ {
3529
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3530
+ "default": 0,
3531
+ "type": "number",
3532
+ }
3533
+ `);
3534
+ // catch values are output-typed, so they are not valid input
3535
+ expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
3536
+ {
3537
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3538
+ "type": "string",
3539
+ }
3540
+ `);
3541
+
3542
+ // the catch no longer hides the inner transform from ancestors, so their output-typed metadata is stripped too — matching a bare nested transform
3543
+ expect(z.toJSONSchema(z.object({ a }).meta({ examples: [{ a: 1 }] }), { io: "input" })).toMatchInlineSnapshot(`
3544
+ {
3545
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3546
+ "properties": {
3547
+ "a": {
3548
+ "type": "string",
3549
+ },
3550
+ },
3551
+ "required": [
3552
+ "a",
3553
+ ],
3554
+ "type": "object",
3555
+ }
3556
+ `);
3557
+ });
3558
+
2630
3559
  test("falsy prefaults (false, 0, empty string)", () => {
2631
3560
  // boolean prefault false
2632
3561
  const a = z.boolean().prefault(false);
@@ -2686,13 +3615,9 @@ test("input type", () => {
2686
3615
  "type": "string",
2687
3616
  },
2688
3617
  "d": {
2689
- "anyOf": [
2690
- {
2691
- "type": "string",
2692
- },
2693
- {
2694
- "type": "null",
2695
- },
3618
+ "type": [
3619
+ "string",
3620
+ "null",
2696
3621
  ],
2697
3622
  },
2698
3623
  "e": {
@@ -2718,19 +3643,13 @@ test("input type", () => {
2718
3643
  ],
2719
3644
  },
2720
3645
  "i": {
2721
- "anyOf": [
2722
- {
2723
- "type": "string",
2724
- },
2725
- {
2726
- "type": "string",
2727
- },
2728
- ],
3646
+ "type": "string",
2729
3647
  },
2730
3648
  },
2731
3649
  "required": [
2732
3650
  "a",
2733
3651
  "d",
3652
+ "f",
2734
3653
  "g",
2735
3654
  ],
2736
3655
  "type": "object",
@@ -2752,13 +3671,9 @@ test("input type", () => {
2752
3671
  "type": "string",
2753
3672
  },
2754
3673
  "d": {
2755
- "anyOf": [
2756
- {
2757
- "type": "string",
2758
- },
2759
- {
2760
- "type": "null",
2761
- },
3674
+ "type": [
3675
+ "string",
3676
+ "null",
2762
3677
  ],
2763
3678
  },
2764
3679
  "e": {
@@ -2783,14 +3698,7 @@ test("input type", () => {
2783
3698
  ],
2784
3699
  },
2785
3700
  "i": {
2786
- "anyOf": [
2787
- {
2788
- "type": "string",
2789
- },
2790
- {
2791
- "type": "string",
2792
- },
2793
- ],
3701
+ "type": "string",
2794
3702
  },
2795
3703
  },
2796
3704
  "required": [
@@ -2895,6 +3803,52 @@ test("use output type for preprocess", () => {
2895
3803
  `);
2896
3804
  });
2897
3805
 
3806
+ test("object property with preprocess stays required in input JSON schema", () => {
3807
+ const schema = z.object({
3808
+ noPreprocess: z.string(),
3809
+ withPreprocess: z.preprocess((v) => v, z.string()),
3810
+ optionalPreprocess: z.preprocess((v) => v, z.string().optional()),
3811
+ });
3812
+
3813
+ // A preprocessed property is only optional when its inner schema is — the
3814
+ // transform wrapper must not make a required property optional in the input
3815
+ // JSON schema (matches runtime: `schema.parse({})` rejects `withPreprocess`).
3816
+ expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
3817
+ {
3818
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3819
+ "properties": {
3820
+ "noPreprocess": {
3821
+ "type": "string",
3822
+ },
3823
+ "optionalPreprocess": {
3824
+ "type": "string",
3825
+ },
3826
+ "withPreprocess": {
3827
+ "type": "string",
3828
+ },
3829
+ },
3830
+ "required": [
3831
+ "noPreprocess",
3832
+ "withPreprocess",
3833
+ ],
3834
+ "type": "object",
3835
+ }
3836
+ `);
3837
+ });
3838
+
3839
+ test("input JSON schema resolves requiredness past transform and catch wrappers", () => {
3840
+ const required = (schema: z.ZodObject) =>
3841
+ (z.toJSONSchema(schema, { io: "input" }) as z.core.JSONSchema.ObjectSchema).required;
3842
+ const id = (v: unknown) => v;
3843
+
3844
+ // catch observes an absent key at runtime, but its declared input type stays required (#5003)
3845
+ expect(required(z.object({ a: z.string().catch("x") }))).toEqual(["a"]);
3846
+ expect(required(z.object({ a: z.string().optional().catch("x") }))).toBeUndefined();
3847
+ // nested preprocess and the legacy transform-pipe form both resolve through to the inner schema
3848
+ expect(required(z.object({ a: z.preprocess(id, z.preprocess(id, z.string())) }))).toEqual(["a"]);
3849
+ expect(required(z.object({ a: z.transform((v: unknown) => String(v)).pipe(z.string()) }))).toEqual(["a"]);
3850
+ });
3851
+
2898
3852
  test("strip output-side examples from input JSON schema for codec", () => {
2899
3853
  const codec = z
2900
3854
  .codec(z.string(), z.number(), { decode: (s) => Number(s), encode: (n) => String(n) })
@@ -2968,45 +3922,25 @@ test("flatten simple intersections", () => {
2968
3922
  expect(result).toMatchInlineSnapshot(`
2969
3923
  {
2970
3924
  "$schema": "http://json-schema.org/draft-07/schema#",
2971
- "allOf": [
2972
- {
2973
- "additionalProperties": false,
2974
- "properties": {
2975
- "testNum": {
2976
- "type": "number",
2977
- },
2978
- },
2979
- "required": [
2980
- "testNum",
2981
- ],
2982
- "type": "object",
3925
+ "additionalProperties": false,
3926
+ "description": "123",
3927
+ "properties": {
3928
+ "testBool": {
3929
+ "type": "boolean",
2983
3930
  },
2984
- {
2985
- "additionalProperties": false,
2986
- "properties": {
2987
- "testStr": {
2988
- "type": "string",
2989
- },
2990
- },
2991
- "required": [
2992
- "testStr",
2993
- ],
2994
- "type": "object",
3931
+ "testNum": {
3932
+ "type": "number",
2995
3933
  },
2996
- {
2997
- "additionalProperties": false,
2998
- "properties": {
2999
- "testBool": {
3000
- "type": "boolean",
3001
- },
3002
- },
3003
- "required": [
3004
- "testBool",
3005
- ],
3006
- "type": "object",
3934
+ "testStr": {
3935
+ "type": "string",
3007
3936
  },
3937
+ },
3938
+ "required": [
3939
+ "testNum",
3940
+ "testStr",
3941
+ "testBool",
3008
3942
  ],
3009
- "description": "123",
3943
+ "type": "object",
3010
3944
  }
3011
3945
  `);
3012
3946
  });
@@ -3123,3 +4057,625 @@ test("recursive lazy with describe does not stack overflow", () => {
3123
4057
  expect(result).toBeDefined();
3124
4058
  expect(result.$defs).toBeDefined();
3125
4059
  });
4060
+
4061
+ test("__proto__ shape key is emitted as an own property", () => {
4062
+ const schema = z.object({ ["__proto__"]: z.literal("admin"), role: z.string() });
4063
+ const result = z.toJSONSchema(schema, { io: "input" });
4064
+
4065
+ expect(result.required).toEqual(["__proto__", "role"]);
4066
+ // every required key needs a matching entry in properties
4067
+ for (const key of result.required!) {
4068
+ expect(Object.prototype.hasOwnProperty.call(result.properties, key)).toBe(true);
4069
+ }
4070
+ expect(JSON.parse(JSON.stringify(result)).properties.__proto__).toEqual({ type: "string", const: "admin" });
4071
+ });
4072
+
4073
+ test("__proto__ registry id is emitted as an own entry", () => {
4074
+ const myRegistry = z.registry<{ id: string }>();
4075
+ myRegistry.add(z.object({ a: z.string() }), { id: "__proto__" });
4076
+ myRegistry.add(z.object({ b: z.string() }), { id: "normal" });
4077
+
4078
+ expect(Object.keys(z.toJSONSchema(myRegistry).schemas)).toEqual(["__proto__", "normal"]);
4079
+ });
4080
+
4081
+ test("__proto__ def id emits a resolvable $ref", () => {
4082
+ const myRegistry = z.registry<{ id: string }>();
4083
+ const Inner = z.object({ x: z.string() });
4084
+ myRegistry.add(Inner, { id: "__proto__" });
4085
+
4086
+ const json = JSON.parse(JSON.stringify(z.toJSONSchema(z.object({ a: Inner, b: Inner }), { metadata: myRegistry })));
4087
+ expect(json.properties.a.$ref).toBe("#/$defs/__proto__");
4088
+ expect(json.$defs.__proto__).toBeDefined();
4089
+ });
4090
+
4091
+ test("__proto__ patternProperties key is emitted as an own property", () => {
4092
+ const result = z.toJSONSchema(z.looseRecord(z.string().regex(/__proto__/), z.string()));
4093
+
4094
+ expect(Object.getPrototypeOf(result.patternProperties)).toBe(Object.prototype);
4095
+ expect(Object.prototype.hasOwnProperty.call(result.patternProperties, "__proto__")).toBe(true);
4096
+ expect(result.patternProperties?.__proto__).toEqual({ type: "string" });
4097
+ });
4098
+
4099
+ test("__proto__ metadata survives direct and wrapper metadata merges", () => {
4100
+ for (const schema of [z.string(), z.readonly(z.string())]) {
4101
+ const registry = z.registry<Record<string, unknown>>();
4102
+ registry.add(schema, Object.fromEntries([["__proto__", { marker: true }]]));
4103
+
4104
+ const result: any = z.toJSONSchema(schema, { metadata: registry });
4105
+ expect(Object.getPrototypeOf(result)).toBe(Object.prototype);
4106
+ expect(Object.prototype.hasOwnProperty.call(result, "__proto__")).toBe(true);
4107
+ expect(result.__proto__).toEqual({ marker: true });
4108
+ expect(JSON.parse(JSON.stringify(result)).__proto__).toEqual({ marker: true });
4109
+ }
4110
+ });
4111
+
4112
+ test("partialRecord does not require finite keys", () => {
4113
+ const result = z.toJSONSchema(z.partialRecord(z.enum(["__proto__", "b"]), z.string()));
4114
+
4115
+ expect(result.required).toBeUndefined();
4116
+ expect(result.propertyNames).toEqual({ type: "string", enum: ["__proto__", "b"] });
4117
+ expect(result.additionalProperties).toEqual({ type: "string" });
4118
+ });
4119
+
4120
+ describe("unrepresentable callback", () => {
4121
+ test("is consulted for every unrepresentable type", () => {
4122
+ const seen: string[] = [];
4123
+ const collect: z.core.UnrepresentableHandler<z.core.$ZodTypes> = ({ zodSchema }) => {
4124
+ seen.push(zodSchema._zod.def.type);
4125
+ return "any";
4126
+ };
4127
+
4128
+ const schemas = [
4129
+ z.bigint(),
4130
+ z.symbol(),
4131
+ z.undefined(),
4132
+ z.void(),
4133
+ z.date(),
4134
+ z.nan(),
4135
+ z.custom<string>(),
4136
+ z.map(z.string(), z.string()),
4137
+ z.set(z.string()),
4138
+ z.transform((x: unknown) => x),
4139
+ z.literal([undefined]),
4140
+ z.literal([1n]),
4141
+ z.string().catch(() => {
4142
+ throw new Error("dynamic");
4143
+ }),
4144
+ // z.function() is not a ZodType, but its processor is reachable through the same path
4145
+ z.function() as unknown as z.ZodType,
4146
+ ];
4147
+ for (const schema of schemas) z.toJSONSchema(schema, { unrepresentable: collect });
4148
+
4149
+ expect(seen).toEqual([
4150
+ "bigint",
4151
+ "symbol",
4152
+ "undefined",
4153
+ "void",
4154
+ "date",
4155
+ "nan",
4156
+ "custom",
4157
+ "map",
4158
+ "set",
4159
+ "transform",
4160
+ "literal",
4161
+ "literal",
4162
+ "catch",
4163
+ "function",
4164
+ ]);
4165
+ });
4166
+
4167
+ test("returned JSON Schema replaces the unrepresentable node", () => {
4168
+ // the motivating case: represent dates, keep throwing for everything else
4169
+ const params: z.core.ToJSONSchemaParams = {
4170
+ unrepresentable: ({ zodSchema }) =>
4171
+ zodSchema._zod.def.type === "date" ? { type: "string", format: "date-time" } : "throw",
4172
+ };
4173
+ expect(z.toJSONSchema(z.object({ when: z.date() }), params)).toMatchInlineSnapshot(`
4174
+ {
4175
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4176
+ "additionalProperties": false,
4177
+ "properties": {
4178
+ "when": {
4179
+ "format": "date-time",
4180
+ "type": "string",
4181
+ },
4182
+ },
4183
+ "required": [
4184
+ "when",
4185
+ ],
4186
+ "type": "object",
4187
+ }
4188
+ `);
4189
+ expect(() => z.toJSONSchema(z.object({ id: z.bigint() }), params)).toThrow(
4190
+ "BigInt cannot be represented in JSON Schema"
4191
+ );
4192
+ });
4193
+
4194
+ test("`throw` and `undefined` returns produce the default error", () => {
4195
+ expect(() => z.toJSONSchema(z.date(), { unrepresentable: () => "throw" })).toThrow(
4196
+ "Date cannot be represented in JSON Schema"
4197
+ );
4198
+ expect(() => z.toJSONSchema(z.date(), { unrepresentable: () => undefined })).toThrow(
4199
+ "Date cannot be represented in JSON Schema"
4200
+ );
4201
+ });
4202
+
4203
+ test("`any` return matches the string option", () => {
4204
+ expect(z.toJSONSchema(z.date(), { unrepresentable: () => "any" })).toEqual(
4205
+ z.toJSONSchema(z.date(), { unrepresentable: "any" })
4206
+ );
4207
+ });
4208
+
4209
+ test("`message` distinguishes sites that share a schema", () => {
4210
+ const seen: string[] = [];
4211
+ expect(
4212
+ z.toJSONSchema(z.literal([undefined, 1n, "a"]), {
4213
+ unrepresentable: ({ zodSchema, message }) => {
4214
+ seen.push(`${zodSchema._zod.def.type}: ${message}`);
4215
+ return "any";
4216
+ },
4217
+ })
4218
+ ).toMatchInlineSnapshot(`
4219
+ {
4220
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4221
+ "enum": [
4222
+ 1,
4223
+ "a",
4224
+ ],
4225
+ }
4226
+ `);
4227
+ // same `zodSchema`, different message -- the only way to tell the two literal sites apart
4228
+ expect(seen).toEqual([
4229
+ "literal: Literal `undefined` cannot be represented in JSON Schema",
4230
+ "literal: BigInt literals cannot be represented in JSON Schema",
4231
+ ]);
4232
+ });
4233
+
4234
+ test("errors thrown by the callback propagate", () => {
4235
+ expect(() =>
4236
+ z.toJSONSchema(z.object({ when: z.date() }), {
4237
+ unrepresentable: ({ zodSchema, path }) => {
4238
+ throw new Error(`${zodSchema._zod.def.type} at /${path.join("/")}`);
4239
+ },
4240
+ })
4241
+ ).toThrow("date at /properties/when");
4242
+ });
4243
+
4244
+ test("runs before `override`", () => {
4245
+ const order: string[] = [];
4246
+ expect(
4247
+ z.toJSONSchema(z.date(), {
4248
+ unrepresentable: () => {
4249
+ order.push("unrepresentable");
4250
+ return { type: "string" };
4251
+ },
4252
+ override: (ctx) => {
4253
+ order.push("override");
4254
+ if (ctx.jsonSchema.type === "string") ctx.jsonSchema.format = "date-time";
4255
+ },
4256
+ })
4257
+ ).toMatchInlineSnapshot(`
4258
+ {
4259
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4260
+ "format": "date-time",
4261
+ "type": "string",
4262
+ }
4263
+ `);
4264
+ expect(order).toEqual(["unrepresentable", "override"]);
4265
+ });
4266
+
4267
+ test("a returned schema replaces the whole literal", () => {
4268
+ expect(
4269
+ z.toJSONSchema(z.literal(["a", 1n]), {
4270
+ unrepresentable: () => ({ type: "string", pattern: "^\\d+$" }),
4271
+ })
4272
+ ).toMatchInlineSnapshot(`
4273
+ {
4274
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4275
+ "pattern": "^\\d+$",
4276
+ "type": "string",
4277
+ }
4278
+ `);
4279
+
4280
+ // "any" keeps the existing per-value behavior: undefined dropped, bigint coerced
4281
+ expect(z.toJSONSchema(z.literal(["a", 1n, undefined]), { unrepresentable: () => "any" })).toEqual(
4282
+ z.toJSONSchema(z.literal(["a", 1n, undefined]), { unrepresentable: "any" })
4283
+ );
4284
+ });
4285
+
4286
+ const dateToString: z.core.ToJSONSchemaParams["unrepresentable"] = ({ zodSchema }) =>
4287
+ zodSchema._zod.def.type === "date" ? { type: "string", format: "date-time" } : "throw";
4288
+
4289
+ test("emits a valid OpenAPI 3.0 schema", async () => {
4290
+ const jsonSchema = z.toJSONSchema(z.object({ start: z.date() }), {
4291
+ target: "openapi-3.0",
4292
+ unrepresentable: dateToString,
4293
+ });
4294
+ expect(jsonSchema).toMatchInlineSnapshot(`
4295
+ {
4296
+ "additionalProperties": false,
4297
+ "properties": {
4298
+ "start": {
4299
+ "format": "date-time",
4300
+ "type": "string",
4301
+ },
4302
+ },
4303
+ "required": [
4304
+ "start",
4305
+ ],
4306
+ "type": "object",
4307
+ }
4308
+ `);
4309
+ await expect(validateOpenAPI30Schema(jsonSchema)).resolves.toBe(true);
4310
+ });
4311
+
4312
+ test("the returned schema survives extraction into $defs", () => {
4313
+ const When = z.date().meta({ id: "When" });
4314
+ expect(
4315
+ z.toJSONSchema(z.object({ start: When, end: When }), { unrepresentable: dateToString })
4316
+ ).toMatchInlineSnapshot(`
4317
+ {
4318
+ "$defs": {
4319
+ "When": {
4320
+ "format": "date-time",
4321
+ "type": "string",
4322
+ },
4323
+ },
4324
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4325
+ "additionalProperties": false,
4326
+ "properties": {
4327
+ "end": {
4328
+ "$ref": "#/$defs/When",
4329
+ },
4330
+ "start": {
4331
+ "$ref": "#/$defs/When",
4332
+ },
4333
+ },
4334
+ "required": [
4335
+ "start",
4336
+ "end",
4337
+ ],
4338
+ "type": "object",
4339
+ }
4340
+ `);
4341
+ });
4342
+
4343
+ test("applies to dynamic catch values", () => {
4344
+ const schema = z.string().catch(() => {
4345
+ throw new Error("dynamic");
4346
+ });
4347
+ expect(
4348
+ z.toJSONSchema(schema, {
4349
+ unrepresentable: () => ({ default: "fallback" }),
4350
+ })
4351
+ ).toMatchInlineSnapshot(`
4352
+ {
4353
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4354
+ "default": "fallback",
4355
+ "type": "string",
4356
+ }
4357
+ `);
4358
+ });
4359
+ });
4360
+
4361
+ describe("intersection folding", () => {
4362
+ const TARGETS = ["draft-2020-12", "draft-07", "draft-04", "openapi-3.0"] as const;
4363
+ const body = (schema: z.ZodType, params?: Parameters<typeof z.toJSONSchema>[1]) => {
4364
+ const { $schema, ...rest } = z.toJSONSchema(schema, params) as Record<string, unknown>;
4365
+ return rest;
4366
+ };
4367
+
4368
+ test("two objects become one object", () => {
4369
+ expect(body(z.object({ name: z.string() }).and(z.object({ age: z.number() })))).toMatchInlineSnapshot(`
4370
+ {
4371
+ "additionalProperties": false,
4372
+ "properties": {
4373
+ "age": {
4374
+ "type": "number",
4375
+ },
4376
+ "name": {
4377
+ "type": "string",
4378
+ },
4379
+ },
4380
+ "required": [
4381
+ "name",
4382
+ "age",
4383
+ ],
4384
+ "type": "object",
4385
+ }
4386
+ `);
4387
+ });
4388
+
4389
+ test("the folded shape is identical on every target", () => {
4390
+ const schema = z.object({ name: z.string() }).and(z.object({ age: z.number() }));
4391
+ const bodies = TARGETS.map((target) => body(schema, { target }));
4392
+ for (const emitted of bodies) expect(emitted).toEqual(bodies[0]);
4393
+ });
4394
+
4395
+ test("closed only when every member is closed", () => {
4396
+ expect(body(z.strictObject({ a: z.string() }).and(z.strictObject({ b: z.number() })))).toMatchObject({
4397
+ additionalProperties: false,
4398
+ });
4399
+ // A loose member keeps the intersection open, which is what the parser does: it merges both results, so the loose side's extra keys survive.
4400
+ expect(body(z.looseObject({ a: z.string() }).and(z.object({ b: z.number() })))).not.toHaveProperty(
4401
+ "additionalProperties"
4402
+ );
4403
+ });
4404
+
4405
+ test("chained and nested intersections fold flat", () => {
4406
+ const chained = z
4407
+ .object({ a: z.string() })
4408
+ .and(z.object({ b: z.string() }))
4409
+ .and(z.object({ c: z.string() }));
4410
+ expect(body(chained)).toMatchObject({ properties: { a: {}, b: {}, c: {} }, required: ["a", "b", "c"] });
4411
+ const nested = z.object({ a: z.string() }).and(z.object({ b: z.string() }).and(z.object({ c: z.string() })));
4412
+ expect(body(nested)).toEqual(body(chained));
4413
+ });
4414
+
4415
+ test("required is the union, and an optional key stays optional", () => {
4416
+ expect(body(z.object({ a: z.string().optional() }).and(z.object({ b: z.string() })))).toMatchObject({
4417
+ properties: { a: { type: "string" }, b: { type: "string" } },
4418
+ required: ["b"],
4419
+ });
4420
+ });
4421
+
4422
+ test("a key both members declare has to satisfy both", () => {
4423
+ // identical declarations collapse
4424
+ expect(body(z.object({ k: z.string() }).and(z.object({ k: z.string() })))).toMatchObject({
4425
+ properties: { k: { type: "string" } },
4426
+ });
4427
+ // object declarations fold, matching the parser's deep merge
4428
+ expect(
4429
+ body(z.object({ k: z.object({ a: z.string() }) }).and(z.object({ k: z.object({ b: z.string() }) })))
4430
+ ).toMatchObject({
4431
+ properties: { k: { type: "object", properties: { a: {}, b: {} }, required: ["a", "b"] } },
4432
+ });
4433
+ // anything else stays an intersection one level down
4434
+ expect(body(z.object({ k: z.string() }).and(z.object({ k: z.number() })))).toMatchObject({
4435
+ properties: { k: { allOf: [{ type: "string" }, { type: "number" }] } },
4436
+ });
4437
+ });
4438
+
4439
+ test("an intersection distributes over a union", () => {
4440
+ const schema = z
4441
+ .object({ name: z.string() })
4442
+ .and(
4443
+ z.discriminatedUnion("type", [
4444
+ z.object({ type: z.literal("a"), value: z.string() }),
4445
+ z.object({ type: z.literal("b"), count: z.number() }),
4446
+ ])
4447
+ );
4448
+ expect(body(schema)).toMatchObject({
4449
+ oneOf: [
4450
+ { type: "object", properties: { name: {}, type: {}, value: {} }, additionalProperties: false },
4451
+ { type: "object", properties: { name: {}, type: {}, count: {} }, additionalProperties: false },
4452
+ ],
4453
+ });
4454
+ const inclusive = z
4455
+ .object({ name: z.string() })
4456
+ .and(z.union([z.object({ v: z.string() }), z.object({ c: z.number() })]));
4457
+ expect(body(inclusive)).toMatchObject({
4458
+ anyOf: [{ properties: { name: {}, v: {} } }, { properties: { name: {}, c: {} } }],
4459
+ });
4460
+ });
4461
+
4462
+ test("input conversion has nothing to close", () => {
4463
+ expect(body(z.object({ a: z.string() }).and(z.object({ b: z.string() })), { io: "input" })).toEqual({
4464
+ type: "object",
4465
+ properties: { a: { type: "string" }, b: { type: "string" } },
4466
+ required: ["a", "b"],
4467
+ });
4468
+ });
4469
+
4470
+ test("folds through a property and through z.lazy", () => {
4471
+ expect(body(z.object({ inner: z.object({ a: z.string() }).and(z.object({ b: z.string() })) }))).toMatchObject({
4472
+ properties: { inner: { type: "object", properties: { a: {}, b: {} } } },
4473
+ });
4474
+ const self: z.ZodType = z.lazy(() => z.object({ a: z.string() }).and(z.object({ next: z.optional(self) })));
4475
+ expect(body(self)).toMatchObject({ type: "object", properties: { a: {}, next: { $ref: "#" } } });
4476
+ });
4477
+
4478
+ test("metadata on the intersection itself survives", () => {
4479
+ expect(
4480
+ body(
4481
+ z
4482
+ .object({ a: z.string() })
4483
+ .and(z.object({ b: z.string() }))
4484
+ .meta({ title: "T" })
4485
+ )
4486
+ ).toMatchObject({
4487
+ title: "T",
4488
+ type: "object",
4489
+ properties: { a: {}, b: {} },
4490
+ });
4491
+ });
4492
+
4493
+ test("a catchall constrains the sibling's keys too", () => {
4494
+ // The catchall member does not declare `b`, so its `additionalProperties` is what it demands of `b`. Folding `b` into `properties` has to carry that demand across, or the key would escape it.
4495
+ const schema = z
4496
+ .object({ a: z.string() })
4497
+ .catchall(z.number())
4498
+ .and(z.object({ b: z.string() }));
4499
+ expect(body(schema)).toEqual({
4500
+ type: "object",
4501
+ properties: { a: { type: "string" }, b: { allOf: [{ type: "number" }, { type: "string" }] } },
4502
+ required: ["a", "b"],
4503
+ additionalProperties: { type: "number" },
4504
+ });
4505
+ });
4506
+
4507
+ test("two catchalls both constrain the keys neither declares", () => {
4508
+ const schema = z
4509
+ .object({})
4510
+ .catchall(z.number())
4511
+ .and(z.object({}).catchall(z.number().min(0)));
4512
+ expect(body(schema)).toEqual({
4513
+ type: "object",
4514
+ properties: {},
4515
+ additionalProperties: { allOf: [{ type: "number" }, { type: "number", minimum: 0 }] },
4516
+ });
4517
+ expect(schema.safeParse({ zz: 5 }).success).toBe(true);
4518
+ expect(schema.safeParse({ zz: -1 }).success).toBe(false);
4519
+ });
4520
+
4521
+ test("the emitted openness agrees with the parser for every pair of object modes", () => {
4522
+ const modes = {
4523
+ strip: (shape: z.ZodRawShape) => z.object(shape),
4524
+ strict: (shape: z.ZodRawShape) => z.strictObject(shape),
4525
+ loose: (shape: z.ZodRawShape) => z.looseObject(shape),
4526
+ catchall: (shape: z.ZodRawShape) => z.object(shape).catchall(z.number()),
4527
+ };
4528
+ const grid: Record<string, unknown> = {};
4529
+ for (const [leftName, left] of Object.entries(modes)) {
4530
+ for (const [rightName, right] of Object.entries(modes)) {
4531
+ const schema = left({ a: z.string() }).and(right({ b: z.number() }));
4532
+ const emitted = body(schema) as { additionalProperties?: unknown };
4533
+ grid[`${leftName} & ${rightName}`] = emitted.additionalProperties ?? "open";
4534
+
4535
+ // Whatever the emitted keyword says, it has to agree with what the parser does with a key neither member declares.
4536
+ const parsed = schema.safeParse({ a: "s", b: 1, zz: 7 });
4537
+ const keepsUnknown = parsed.success && Object.prototype.hasOwnProperty.call(parsed.data, "zz");
4538
+ if (keepsUnknown) expect(emitted.additionalProperties).not.toBe(false);
4539
+ }
4540
+ }
4541
+ expect(grid).toMatchInlineSnapshot(`
4542
+ {
4543
+ "catchall & catchall": {
4544
+ "type": "number",
4545
+ },
4546
+ "catchall & loose": {
4547
+ "type": "number",
4548
+ },
4549
+ "catchall & strict": {
4550
+ "type": "number",
4551
+ },
4552
+ "catchall & strip": {
4553
+ "type": "number",
4554
+ },
4555
+ "loose & catchall": {
4556
+ "type": "number",
4557
+ },
4558
+ "loose & loose": "open",
4559
+ "loose & strict": "open",
4560
+ "loose & strip": "open",
4561
+ "strict & catchall": {
4562
+ "type": "number",
4563
+ },
4564
+ "strict & loose": "open",
4565
+ "strict & strict": false,
4566
+ "strict & strip": false,
4567
+ "strip & catchall": {
4568
+ "type": "number",
4569
+ },
4570
+ "strip & loose": "open",
4571
+ "strip & strict": false,
4572
+ "strip & strip": false,
4573
+ }
4574
+ `);
4575
+ });
4576
+
4577
+ test("a __proto__ key stays an own property", () => {
4578
+ const folded = body(z.object({ ["__proto__"]: z.string() }).and(z.object({ b: z.number() }))) as any;
4579
+ expect(Object.prototype.hasOwnProperty.call(folded.properties, "__proto__")).toBe(true);
4580
+ expect(folded.required).toEqual(["__proto__", "b"]);
4581
+ });
4582
+ });
4583
+
4584
+ describe("intersection folding declines", () => {
4585
+ // Every case here keeps the `allOf` it produces today. The fold only understands the four object keywords, so a member carrying anything else is left alone rather than having a constraint dropped or an annotation re-scoped.
4586
+ const allOf = (schema: z.ZodType, params?: Parameters<typeof z.toJSONSchema>[1]) =>
4587
+ (z.toJSONSchema(schema, params) as any).allOf;
4588
+
4589
+ test("a member that is a reference keeps its reference", () => {
4590
+ const named = z.object({ a: z.string() }).meta({ id: "Named" });
4591
+ expect(allOf(named.and(z.object({ b: z.string() })))[0]).toEqual({ $ref: "#/$defs/Named" });
4592
+
4593
+ const shared = z.object({ c: z.string() });
4594
+ const reused = z.toJSONSchema(z.object({ x: shared.and(z.object({ d: z.string() })), y: shared }), {
4595
+ reused: "ref",
4596
+ }) as any;
4597
+ expect(reused.properties.x.allOf[0]).toEqual({ $ref: "#/$defs/__schema0" });
4598
+
4599
+ const cyclic: any = z.object({
4600
+ get next() {
4601
+ return z.optional(cyclic);
4602
+ },
4603
+ n: z.string(),
4604
+ });
4605
+ expect(allOf(cyclic.and(z.object({ m: z.string() })))[0].$ref).toBe("#/$defs/__schema0");
4606
+ });
4607
+
4608
+ test("an annotated member keeps its place", () => {
4609
+ expect(
4610
+ allOf(
4611
+ z
4612
+ .object({ a: z.string() })
4613
+ .describe("A")
4614
+ .and(z.object({ b: z.string() }))
4615
+ )[0]
4616
+ ).toMatchObject({
4617
+ description: "A",
4618
+ });
4619
+ });
4620
+
4621
+ test("members that are not plain objects are left alone", () => {
4622
+ expect(allOf(z.intersection(z.string().min(2), z.string().max(5)))).toHaveLength(2);
4623
+ expect(allOf(z.object({ a: z.string() }).and(z.nullable(z.object({ b: z.string() }))))).toHaveLength(2);
4624
+ expect(
4625
+ allOf(z.object({ label: z.string() }).and(z.looseRecord(z.string().regex(/^label:[a-z]{2}$/), z.string())))
4626
+ ).toHaveLength(2);
4627
+ });
4628
+
4629
+ test("a shared member is never rewritten for its other uses", () => {
4630
+ const shared = z.object({ c: z.string() });
4631
+ const result = z.toJSONSchema(z.object({ x: shared.and(z.object({ d: z.string() })), y: shared })) as any;
4632
+ expect(result.properties.x).toMatchObject({ properties: { c: {}, d: {} }, additionalProperties: false });
4633
+ // `y` is the same Zod schema, emitted separately, and keeps the closedness it had on its own.
4634
+ expect(result.properties.y).toEqual({
4635
+ type: "object",
4636
+ properties: { c: { type: "string" } },
4637
+ required: ["c"],
4638
+ additionalProperties: false,
4639
+ });
4640
+ });
4641
+
4642
+ test("registry conversion keeps its cross-references", () => {
4643
+ const registry = z.registry<{ id: string }>();
4644
+ const left = z.object({ p: z.string() });
4645
+ const right = z.object({ q: z.string() });
4646
+ registry.add(left, { id: "P" });
4647
+ registry.add(right, { id: "Q" });
4648
+ registry.add(left.and(right), { id: "PQ" });
4649
+ expect((z.toJSONSchema(registry) as any).schemas.PQ.allOf).toEqual([{ $ref: "P" }, { $ref: "Q" }]);
4650
+ });
4651
+
4652
+ test("override still runs, and sees the intersection before it folds", () => {
4653
+ const schema = z.object({ a: z.string() }).and(z.object({ b: z.string() }));
4654
+ const result = z.toJSONSchema(schema, {
4655
+ override(ctx) {
4656
+ if ((ctx.jsonSchema as any).allOf) (ctx.jsonSchema as any).title = "intersection";
4657
+ },
4658
+ }) as any;
4659
+ expect(result).toMatchObject({ title: "intersection", type: "object", properties: { a: {}, b: {} } });
4660
+ });
4661
+
4662
+ test("an override that writes object keywords wins over the fold", () => {
4663
+ // The override runs first, so anything it puts on the intersection is deliberate. Folding would overwrite it silently, so the fold stands down instead.
4664
+ const result = z.toJSONSchema(z.object({ a: z.string() }).and(z.object({ b: z.string() })), {
4665
+ override(ctx) {
4666
+ if ((ctx.jsonSchema as any).allOf) (ctx.jsonSchema as any).additionalProperties = true;
4667
+ },
4668
+ }) as any;
4669
+ expect(result.additionalProperties).toBe(true);
4670
+ expect(result.allOf).toHaveLength(2);
4671
+ });
4672
+
4673
+ test("more than one union member is left alone rather than multiplied out", () => {
4674
+ // The second union lands among the members the first is distributed across, and a union is not an object, so every branch fails to fold and the whole intersection stands down.
4675
+ const schema = z
4676
+ .object({ a: z.string() })
4677
+ .and(z.union([z.object({ v: z.string() }), z.object({ w: z.string() })]))
4678
+ .and(z.union([z.object({ x: z.string() }), z.object({ y: z.string() })]));
4679
+ expect(allOf(schema)).toHaveLength(3);
4680
+ });
4681
+ });