@chrona-city/ugc-kit 1.5.13 → 1.6.9

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 (1653) hide show
  1. package/.agents/skills/chrona-3d-assets/SKILL.md +15 -0
  2. package/.agents/skills/chrona-ecs-creator/SKILL.md +17 -0
  3. package/.agents/skills/chrona-gameplay-js/SKILL.md +19 -0
  4. package/.agents/skills/chrona-realtime/SKILL.md +23 -0
  5. package/.agents/skills/chrona-repair/SKILL.md +13 -0
  6. package/README.md +26 -8
  7. package/bin/chrona.mjs +6 -2
  8. package/chrona.contract.lock.json +74 -6
  9. package/chrona.controlled-presentation.lock.json +8 -8
  10. package/chrona.core.lock.json +16 -12
  11. package/chrona.document-presentation.lock.json +52 -0
  12. package/chrona.ecs.lock.json +3 -3
  13. package/chrona.gameplay-tests.lock.json +9 -9
  14. package/chrona.ground-endpoint.lock.json +28 -0
  15. package/chrona.ground-spaces.lock.json +40 -0
  16. package/chrona.personal-state.lock.json +28 -0
  17. package/chrona.pipeline.lock.json +10 -10
  18. package/chrona.private-state-view.lock.json +2 -2
  19. package/chrona.private-state.lock.json +2 -2
  20. package/chrona.registry.lock.json +2 -2
  21. package/chrona.sandbox.lock.json +11 -7
  22. package/chrona.scene-interaction-v2.lock.json +28 -0
  23. package/chrona.world-scene-runtime.lock.json +49 -9
  24. package/chrona.world-scene.lock.json +9 -5
  25. package/compiler/local-builder.lock.json +1 -1
  26. package/compiler/source/contracts/creator/rules/v1/rules.mjs +99 -0
  27. package/compiler/source/contracts/creator/rules/v1/ugc-rules.json +807 -0
  28. package/compiler/source/contracts/ugc/authored-motion/v1/declaration.mjs +124 -0
  29. package/compiler/source/contracts/ugc/core-ecs/v1/core-view.mjs +146 -0
  30. package/compiler/source/contracts/ugc/core-ecs/v1/limits.json +4 -0
  31. package/compiler/source/contracts/ugc/document-presentation/v1/document.mjs +148 -27
  32. package/compiler/source/contracts/ugc/document-presentation/v1/profile-1.1.0.json +25 -0
  33. package/compiler/source/contracts/ugc/document-presentation/v1/profile-1.2.0.json +25 -0
  34. package/compiler/source/contracts/ugc/document-presentation/v1/profile-1.3.0.json +26 -0
  35. package/compiler/source/contracts/ugc/document-presentation/v1/profile-1.5.0.json +25 -0
  36. package/compiler/source/contracts/ugc/document-presentation/v1/profile-1.6.0.json +26 -0
  37. package/compiler/source/contracts/ugc/ecs-runtime/v1/private-world.mjs +313 -0
  38. package/compiler/source/contracts/ugc/live-rule-slot/v1/slot.json +58 -0
  39. package/compiler/source/contracts/ugc/local-content/v1/document-snapshot.mjs +13 -29
  40. package/compiler/source/contracts/ugc/local-content/v1/ground-snapshot.mjs +89 -0
  41. package/compiler/source/contracts/ugc/local-content/v1/snapshot.mjs +49 -6
  42. package/compiler/source/contracts/ugc/open-creation/v1/custom-actions.mjs +92 -0
  43. package/compiler/source/contracts/ugc/open-creation/v1/data-authority.mjs +37 -0
  44. package/compiler/source/contracts/ugc/open-creation/v1/declaration.mjs +28 -0
  45. package/compiler/source/contracts/ugc/open-creation/v1/dynamic-entities.mjs +186 -0
  46. package/compiler/source/contracts/ugc/open-creation/v1/open-world.mjs +269 -0
  47. package/compiler/source/contracts/ugc/pipeline/v1/conformance/js/pipeline-validator.mjs +35 -7
  48. package/compiler/source/contracts/ugc/private-state/v1/projection.mjs +178 -0
  49. package/compiler/source/contracts/ugc/registry/v1/resolution-policy.json +3 -3
  50. package/compiler/source/contracts/ugc/runtime-content/v1/asset-budget.mjs +21 -0
  51. package/compiler/source/contracts/ugc/runtime-content/v1/limits.json +5 -0
  52. package/compiler/source/contracts/ugc/runtime-content/v1/validate.mjs +420 -0
  53. package/compiler/source/contracts/ugc/sandbox/v1/sha256.mjs +47 -0
  54. package/compiler/source/contracts/ugc/server-entities/v1/entities.mjs +221 -0
  55. package/compiler/source/contracts/ugc/server-entities/v1/events.mjs +336 -0
  56. package/compiler/source/contracts/ugc/server-entities/v1/limits.json +112 -0
  57. package/compiler/source/contracts/ugc/server-entities/v1/roads.mjs +164 -0
  58. package/compiler/source/contracts/ugc/v1/conformance/js/package-validator.mjs +51 -5
  59. package/compiler/source/contracts/ugc/v1/host-runnable.mjs +23 -0
  60. package/compiler/source/contracts/ugc/world-scene/v2/asset-graph.mjs +8 -12
  61. package/compiler/source/contracts/ugc/world-scene/v2/contract-set.json +1 -0
  62. package/compiler/source/contracts/ugc/world-scene-runtime/v1/runtime-plan.schema.json +41 -13
  63. package/compiler/source/contracts/ugc/world-scene-runtime/v1/runtime-policy.mjs +2 -2
  64. package/compiler/source/contracts/ugc/world-scene-runtime/v2/contract-set.json +10 -0
  65. package/compiler/source/contracts/ugc/world-scene-runtime/v2/report.mjs +21 -14
  66. package/compiler/source/contracts/ugc/world-scene-runtime/v2/runtime-policy.mjs +17 -3
  67. package/compiler/source/services/game-worker/src/runtime/content/flight-runtime.js +2 -1
  68. package/compiler/source/services/game-worker/src/runtime/rooms/flight-collision.js +55 -30
  69. package/compiler/source/services/game-worker/src/runtime/rooms/flight-motion.js +99 -0
  70. package/compiler/source/services/game-worker/src/runtime/rooms/flight-preparation.js +3 -2
  71. package/compiler/source/services/game-worker/src/runtime/rooms/flight-room-controller.js +130 -24
  72. package/compiler/source/services/ugc-pipeline/src/asset-inspection.mjs +78 -28
  73. package/compiler/source/services/ugc-pipeline/src/document-presentation-model.mjs +2 -2
  74. package/compiler/source/services/ugc-pipeline/src/ground-rules-model.mjs +4 -5
  75. package/compiler/source/services/ugc-pipeline/src/local-content.mjs +29 -16
  76. package/compiler/source/services/ugc-pipeline/src/registry-release.mjs +4 -1
  77. package/compiler/source/services/ugc-pipeline/src/resource-bindings-model.mjs +3 -3
  78. package/compiler/source/services/ugc-pipeline/src/rules-locks.mjs +18 -0
  79. package/compiler/source/services/ugc-pipeline/src/scene-interaction-model.mjs +4 -5
  80. package/compiler/source/services/ugc-pipeline/src/visual-closure-v2.mjs +2 -2
  81. package/compiler/source/services/ugc-pipeline/src/world-scene-model.mjs +3 -3
  82. package/compiler/source/services/ugc-pipeline/src/world-scene-policies.json +138 -0
  83. package/compiler/source/services/ugc-pipeline/src/world-scene-runtime.mjs +4 -3
  84. package/consistency-vectors.snapshot.lock.json +14 -0
  85. package/contracts/creator/check/v1/rule-table.json +433 -0
  86. package/contracts/creator/check/v1/rules/client.json +924 -0
  87. package/contracts/creator/check/v1/rules/kit.json +1702 -0
  88. package/contracts/creator/check/v1/rules/platform.json +608 -0
  89. package/contracts/creator/check/v1/rules/publish.json +2484 -0
  90. package/contracts/creator/check/v1/rules/room.json +279 -0
  91. package/contracts/creator/rules/v1/rules.mjs +69 -0
  92. package/contracts/creator/rules/v1/vectors.json +39 -0
  93. package/contracts/ecs/realtime/consistency/v1/vectors.json +2437 -0
  94. package/contracts/errors/registry/v1/codes.json +13255 -0
  95. package/contracts/gameplay/step-input/step-input.mjs +16 -0
  96. package/contracts/network/realtime/authored-entity.mjs +67 -0
  97. package/contracts/network/realtime/revision-selection.mjs +65 -0
  98. package/contracts/testdata/gameplay-consistency/vectors.json +149 -0
  99. package/contracts/ugc/authored-motion/v1/declaration.mjs +124 -0
  100. package/contracts/ugc/core-ecs/v1/core-view.mjs +13 -5
  101. package/contracts/ugc/core-ecs/v1/limits.json +4 -0
  102. package/contracts/ugc/creator-source/v1/SOURCE-PACKAGE.md +1 -1
  103. package/contracts/ugc/creator-source/v1/source-package.mjs +24 -7
  104. package/contracts/ugc/creator-source/v1/source-package.schema.json +3 -3
  105. package/contracts/ugc/creator-source/v1/source-package.test.mjs +20 -2
  106. package/contracts/ugc/document-presentation/v1/document.mjs +148 -27
  107. package/contracts/ugc/document-presentation/v1/profile-1.1.0.json +25 -0
  108. package/contracts/ugc/document-presentation/v1/profile-1.2.0.json +25 -0
  109. package/contracts/ugc/document-presentation/v1/profile-1.3.0.json +26 -0
  110. package/contracts/ugc/document-presentation/v1/profile-1.5.0.json +25 -0
  111. package/contracts/ugc/document-presentation/v1/profile-1.6.0.json +26 -0
  112. package/contracts/ugc/ecs-runtime/v1/private-world.mjs +21 -7
  113. package/contracts/ugc/live-rule-slot/v1/slot.json +58 -0
  114. package/contracts/ugc/live-rule-slot/v1/slot.mjs +80 -0
  115. package/contracts/ugc/local-content/v1/README.md +10 -0
  116. package/contracts/ugc/local-content/v1/document-snapshot.mjs +13 -29
  117. package/contracts/ugc/local-content/v1/ground-snapshot.mjs +89 -0
  118. package/contracts/ugc/local-content/v1/snapshot.mjs +49 -6
  119. package/contracts/ugc/local-content/v1/spatial-plan.mjs +24 -0
  120. package/contracts/ugc/open-creation/v1/custom-actions.mjs +92 -0
  121. package/contracts/ugc/open-creation/v1/data-authority.mjs +37 -0
  122. package/contracts/ugc/open-creation/v1/declaration.mjs +28 -0
  123. package/contracts/ugc/open-creation/v1/dynamic-entities.mjs +186 -0
  124. package/contracts/ugc/open-creation/v1/open-world.mjs +269 -0
  125. package/contracts/ugc/public-runtime/v1/README.md +13 -1
  126. package/contracts/ugc/public-runtime/v1/compatibility-rows.test.mjs +79 -0
  127. package/contracts/ugc/public-runtime/v1/document-runtime.test.mjs +20 -5
  128. package/contracts/ugc/public-runtime/v1/manifest.mjs +24 -12
  129. package/contracts/ugc/public-runtime/v1/revision-vectors.test.mjs +49 -0
  130. package/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json +119 -6
  131. package/contracts/ugc/runtime-content/v1/asset-budget.mjs +21 -0
  132. package/contracts/ugc/runtime-content/v1/limits.json +5 -0
  133. package/contracts/ugc/runtime-content/v1/validate.mjs +420 -0
  134. package/contracts/ugc/sandbox/v1/conformance/js/sandbox-validator.mjs +85 -6
  135. package/contracts/ugc/server-entities/v1/entities.mjs +221 -0
  136. package/contracts/ugc/server-entities/v1/events.mjs +336 -0
  137. package/contracts/ugc/server-entities/v1/limits.json +112 -0
  138. package/contracts/ugc/server-entities/v1/roads.mjs +164 -0
  139. package/contracts/ugc/v1/conformance/js/package-validator.mjs +51 -5
  140. package/contracts/ugc/v1/host-runnable.mjs +23 -0
  141. package/contracts/ugc/world-scene-runtime/v1/runtime-policy.mjs +2 -2
  142. package/contracts/ugc/world-scene-runtime/v2/runtime-policy.mjs +17 -3
  143. package/creator-check.source-lock.json +40 -0
  144. package/creator-release.json +1 -1
  145. package/docs/ai-index.md +193 -0
  146. package/docs/assets-3d-spec.md +114 -3
  147. package/docs/audio.md +110 -0
  148. package/docs/authored-avatars.md +67 -0
  149. package/docs/authored-entities.md +165 -0
  150. package/docs/capability-map.json +57 -0
  151. package/docs/controlled-presentation.md +53 -0
  152. package/docs/core-ecs.md +46 -0
  153. package/docs/declaration-generator.md +292 -0
  154. package/docs/document-presentation.md +14 -0
  155. package/docs/gameplay-inputs.md +77 -0
  156. package/docs/gameplay-lifecycle-tests.md +89 -0
  157. package/docs/ground-rules.md +63 -0
  158. package/docs/harness-onboarding.md +45 -22
  159. package/docs/live-rule-slots.md +57 -0
  160. package/docs/mcp-tools.md +39 -0
  161. package/docs/meshy.md +4 -4
  162. package/docs/migrate-1.6.md +63 -0
  163. package/docs/npm-creator.md +419 -254
  164. package/docs/open-creation.md +259 -0
  165. package/docs/player-private-components.md +51 -0
  166. package/docs/player-saves.md +175 -0
  167. package/docs/player-visible-state.md +65 -0
  168. package/docs/playtest.md +223 -0
  169. package/docs/private-ecs.md +48 -0
  170. package/docs/private-events.md +82 -0
  171. package/docs/private-state.md +30 -0
  172. package/docs/realtime-patterns.md +624 -0
  173. package/docs/recipes.md +397 -0
  174. package/docs/reference.md +365 -0
  175. package/docs/runtime-download.md +13 -5
  176. package/docs/scene-import.md +132 -0
  177. package/docs/scene-interactions.md +28 -0
  178. package/docs/server-entities.md +83 -0
  179. package/docs/weather.md +77 -0
  180. package/docs/work-brief.md +71 -0
  181. package/document-action-result.source-lock.json +8 -4
  182. package/error-codes.snapshot.lock.json +14 -0
  183. package/gameplay-consistency.source-lock.json +20 -0
  184. package/lib/authority-notice.mjs +76 -0
  185. package/lib/behavior-radius-check.mjs +71 -0
  186. package/lib/builtin-write.mjs +70 -0
  187. package/lib/capability-harness.mjs +4 -3
  188. package/lib/compress-model.mjs +266 -0
  189. package/lib/creator-agent-live.mjs +3 -0
  190. package/lib/creator-api.mjs +301 -148
  191. package/lib/creator-assets-restore.mjs +102 -0
  192. package/lib/creator-capability-map.mjs +28 -0
  193. package/lib/creator-check.mjs +338 -0
  194. package/lib/creator-cli.mjs +929 -118
  195. package/lib/creator-contribution.mjs +46 -37
  196. package/lib/creator-docs.mjs +56 -0
  197. package/lib/creator-entry.mjs +134 -0
  198. package/lib/creator-fix.mjs +208 -0
  199. package/lib/creator-init-paths.mjs +22 -13
  200. package/lib/creator-init.mjs +22 -9
  201. package/lib/creator-install.mjs +335 -65
  202. package/lib/creator-installed-platform.mjs +13 -0
  203. package/lib/creator-intent-rules.mjs +15 -0
  204. package/lib/creator-intent.mjs +147 -0
  205. package/lib/creator-issue.mjs +241 -0
  206. package/lib/creator-mcp.mjs +336 -140
  207. package/lib/creator-migrate.mjs +194 -0
  208. package/lib/creator-onboarding.mjs +3 -1
  209. package/lib/creator-platform.mjs +223 -29
  210. package/lib/creator-playtest.mjs +398 -0
  211. package/lib/creator-preview.mjs +80 -0
  212. package/lib/creator-project-snapshot.mjs +182 -108
  213. package/lib/creator-project-update.mjs +132 -102
  214. package/lib/creator-project.mjs +213 -62
  215. package/lib/creator-provenance.mjs +12 -10
  216. package/lib/creator-rebundle.mjs +68 -0
  217. package/lib/creator-rules.mjs +76 -0
  218. package/lib/creator-session.mjs +123 -25
  219. package/lib/creator-source-package.mjs +2 -2
  220. package/lib/creator-submit.mjs +252 -101
  221. package/lib/creator-toolchain-compat.mjs +473 -3
  222. package/lib/creator-upgrade.mjs +58 -33
  223. package/lib/creator-upload-state.mjs +61 -6
  224. package/lib/creator-workspace-guide.mjs +79 -0
  225. package/lib/declaration-generator.mjs +609 -0
  226. package/lib/declaration-problems.mjs +108 -0
  227. package/lib/document-action-result.mjs +7 -4
  228. package/lib/document-prechecks.mjs +633 -0
  229. package/lib/document-presentation.mjs +47 -15
  230. package/lib/document-refresh.mjs +46 -0
  231. package/lib/ecs-access.mjs +179 -0
  232. package/lib/failure-messages.mjs +42 -0
  233. package/lib/gameplay-imports.mjs +34 -0
  234. package/lib/host-consistency.mjs +74 -0
  235. package/lib/host-ipc/distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/manifest.mjs +24 -12
  236. package/lib/host-ipc/distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json +119 -6
  237. package/lib/host-ipc/host-ipc.schema.json +80 -0
  238. package/lib/host-ipc/runtime-contract.mjs +2 -0
  239. package/lib/host-ipc/source-lock.json +5 -5
  240. package/lib/host-runnable-scope.mjs +19 -0
  241. package/lib/legacy-patterns.mjs +705 -0
  242. package/lib/live-baseline-shape.mjs +30 -0
  243. package/lib/live-baseline.mjs +108 -0
  244. package/lib/live-rule-check.mjs +96 -0
  245. package/lib/local-builder.mjs +20 -5
  246. package/lib/local-content.mjs +6 -4
  247. package/lib/local-development.mjs +96 -24
  248. package/lib/local-room.mjs +12 -0
  249. package/lib/meshy-api.mjs +57 -1
  250. package/lib/meshy-store.mjs +1 -1
  251. package/lib/movement-authority.mjs +24 -0
  252. package/lib/platform-discovery.mjs +61 -0
  253. package/lib/platform-limits.mjs +6 -0
  254. package/lib/playtest-browser.mjs +121 -0
  255. package/lib/playtest-compare.mjs +42 -0
  256. package/lib/playtest-page.mjs +372 -0
  257. package/lib/playtest-vehicle.mjs +234 -0
  258. package/lib/presentation-project-update.mjs +126 -4
  259. package/lib/private-ecs-harness.mjs +39 -17
  260. package/lib/private-event-harness.mjs +3 -5
  261. package/lib/project-validation.mjs +852 -167
  262. package/lib/publish-prechecks.mjs +28 -0
  263. package/lib/relay-notice.mjs +13 -0
  264. package/lib/rule-fuzz.mjs +45 -0
  265. package/lib/rule-pack.mjs +150 -0
  266. package/lib/rule-selection.mjs +130 -0
  267. package/lib/rule-tests-child.mjs +40 -0
  268. package/lib/rule-tests-sandbox.mjs +75 -0
  269. package/lib/runtime-content.mjs +49 -0
  270. package/lib/runtime-download.mjs +94 -31
  271. package/lib/runtime-host-client.mjs +30 -12
  272. package/lib/runtime-host.mjs +7 -10
  273. package/lib/runtime-install.mjs +46 -6
  274. package/lib/runtime-prechecks.mjs +133 -0
  275. package/lib/runtime-proxy-fetch.mjs +117 -0
  276. package/lib/runtime-snapshot.mjs +20 -20
  277. package/lib/runtime-source.mjs +30 -14
  278. package/lib/sandbox-projection/v1/room-state-projection.mjs +116 -0
  279. package/lib/scene-assets.mjs +5 -5
  280. package/lib/scene-import-profiles.mjs +8 -0
  281. package/lib/scene-import.mjs +737 -0
  282. package/lib/server-entities-check.mjs +160 -0
  283. package/lib/toolchain-history.json +602 -0
  284. package/lib/vendor/mcp.mjs +33787 -0
  285. package/lib/vendor/smol-toml.mjs +744 -0
  286. package/lib/writable-by-others.mjs +8 -0
  287. package/live-rule-slot.source-lock.json +20 -0
  288. package/llms.txt +43 -0
  289. package/local-builder.snapshot.lock.json +3 -3
  290. package/local-content.snapshot.lock.json +112 -8
  291. package/package.json +251 -22
  292. package/public-runtime.snapshot.lock.json +13 -9
  293. package/realtime-revision.source-lock.json +20 -0
  294. package/runtime-catalog.json +16 -16
  295. package/sandbox-projection.source-lock.json +15 -0
  296. package/sdk/client/index.js +3 -2
  297. package/source-package.snapshot.lock.json +5 -5
  298. package/templates/document-presentation/README.md +5 -0
  299. package/templates/document-presentation/assets.js +36 -10
  300. package/templates/document-presentation/authority.js +25 -7
  301. package/templates/document-presentation/live-view.js +100 -0
  302. package/templates/document-presentation/local-first.js +45 -0
  303. package/templates/document-presentation/motion.js +2 -0
  304. package/templates/document-presentation/ready-gate.js +37 -0
  305. package/templates/document-presentation/state-view.js +26 -0
  306. package/templates/document-presentation/weather-blend.js +57 -0
  307. package/templates/document-presentation/weather-particles.js +192 -0
  308. package/templates/document-presentation/wet-ripples.js +61 -0
  309. package/templates/examples/coin-rush/README.md +5 -0
  310. package/templates/examples/coin-rush/chrona.generate.json +63 -0
  311. package/templates/examples/coin-rush/content/assets/runtime/arena.gltf +399 -0
  312. package/templates/examples/coin-rush/content/assets/runtime/runner.gltf +197 -0
  313. package/templates/examples/coin-rush/content/bindings/resources.json +19 -0
  314. package/templates/examples/coin-rush/content/gameplay/client/presentation.js +44 -0
  315. package/templates/examples/coin-rush/content/gameplay/shared/rules.js +49 -0
  316. package/templates/examples/coin-rush/content/manifest.json +100 -0
  317. package/templates/examples/coin-rush/content/provenance.json +20 -0
  318. package/templates/examples/coin-rush/content/rules/ground.json +45 -0
  319. package/templates/examples/coin-rush/content/tests/budgets.json +5 -0
  320. package/templates/examples/coin-rush/content/tests/rules.json +16 -0
  321. package/templates/examples/open-creation/README.md +5 -0
  322. package/templates/examples/open-creation/chrona.generate.json +55 -0
  323. package/templates/examples/open-creation/content/assets/runtime/arena.gltf +399 -0
  324. package/templates/examples/open-creation/content/assets/runtime/runner.gltf +197 -0
  325. package/templates/examples/open-creation/content/bindings/resources.json +19 -0
  326. package/templates/examples/open-creation/content/gameplay/client/presentation.js +33 -0
  327. package/templates/examples/open-creation/content/gameplay/shared/rules.js +29 -0
  328. package/templates/examples/open-creation/content/manifest.json +100 -0
  329. package/templates/examples/open-creation/content/provenance.json +20 -0
  330. package/templates/examples/open-creation/content/rules/ground.json +45 -0
  331. package/templates/examples/open-creation/content/tests/budgets.json +5 -0
  332. package/templates/examples/open-creation/content/tests/rules.json +16 -0
  333. package/templates/live-rule-slot/score-slot.js +16 -0
  334. package/templates/npm-project/AGENTS.md +101 -4
  335. package/templates/npm-project/preview.command +7 -0
  336. package/templates/npm-project/preview.ps1 +6 -0
  337. package/templates/npm-project/scripts/install-kit.mjs +70 -0
  338. package/templates/npm-project/setup.command +3 -0
  339. package/templates/npm-project/setup.ps1 +14 -0
  340. package/templates/npm-project/setup.sh +11 -0
  341. package/templates/public-untrusted/content/gameplay/client/local-first.js +45 -0
  342. package/templates/public-untrusted/content/gameplay/client/smoothing.js +83 -0
  343. package/templates/public-untrusted/content/manifest.json +2 -1
  344. package/templates/public-untrusted/content/tests/scenarios.json +20 -2
  345. package/contracts/ugc/capability-wiring/v1/capability-proposal.schema.json +0 -82
  346. package/contracts/ugc/capability-wiring/v1/conformance/js/wiring-validator.mjs +0 -95
  347. package/contracts/ugc/capability-wiring/v1/conformance/web/index.html +0 -5
  348. package/contracts/ugc/capability-wiring/v1/conformance/web/runner.mjs +0 -32
  349. package/contracts/ugc/capability-wiring/v1/contract-set.json +0 -8
  350. package/contracts/ugc/capability-wiring/v1/error-codes.json +0 -15
  351. package/contracts/ugc/capability-wiring/v1/needs-capability.schema.json +0 -18
  352. package/contracts/ugc/capability-wiring/v1/testdata/vectors.json +0 -128
  353. package/contracts/ugc/capability-wiring/v1/wiring-release.schema.json +0 -66
  354. package/contracts/ugc/controlled-presentation/v1/README.md +0 -175
  355. package/contracts/ugc/controlled-presentation/v1/approval.schema.json +0 -53
  356. package/contracts/ugc/controlled-presentation/v1/command.schema.json +0 -243
  357. package/contracts/ugc/controlled-presentation/v1/conformance/run-vectors.mjs +0 -39
  358. package/contracts/ugc/controlled-presentation/v1/conformance/run-view-vectors.mjs +0 -54
  359. package/contracts/ugc/controlled-presentation/v1/conformance/web/index.html +0 -1
  360. package/contracts/ugc/controlled-presentation/v1/conformance/web/runner.mjs +0 -4
  361. package/contracts/ugc/controlled-presentation/v1/conformance/web/view-runner.mjs +0 -5
  362. package/contracts/ugc/controlled-presentation/v1/conformance/web/view.html +0 -1
  363. package/contracts/ugc/controlled-presentation/v1/context.schema.json +0 -19
  364. package/contracts/ugc/controlled-presentation/v1/contract-set.json +0 -33
  365. package/contracts/ugc/controlled-presentation/v1/export-view.mjs +0 -44
  366. package/contracts/ugc/controlled-presentation/v1/grant.schema.json +0 -120
  367. package/contracts/ugc/controlled-presentation/v1/presentation.mjs +0 -180
  368. package/contracts/ugc/controlled-presentation/v1/testdata/vectors.json +0 -565
  369. package/contracts/ugc/controlled-presentation/v1/view.mjs +0 -46
  370. package/contracts/ugc/controlled-presentation/v1/view.schema.json +0 -90
  371. package/contracts/ugc/core-ecs/v1/README.md +0 -13
  372. package/contracts/ugc/core-ecs/v1/api.json +0 -28
  373. package/contracts/ugc/core-ecs/v1/conformance/run-vectors.mjs +0 -33
  374. package/contracts/ugc/core-ecs/v1/conformance/web/index.html +0 -1
  375. package/contracts/ugc/core-ecs/v1/conformance/web/runner.mjs +0 -4
  376. package/contracts/ugc/core-ecs/v1/test-fixture.schema.json +0 -169
  377. package/contracts/ugc/core-ecs/v1/testdata/vectors.json +0 -57
  378. package/contracts/ugc/document-presentation/v1/README.md +0 -167
  379. package/contracts/ugc/document-presentation/v1/contract-set.json +0 -18
  380. package/contracts/ugc/document-presentation/v1/document.schema.json +0 -161
  381. package/contracts/ugc/document-presentation/v1/document.test.mjs +0 -138
  382. package/contracts/ugc/document-presentation/v1/source.schema.json +0 -88
  383. package/contracts/ugc/ecs-runtime/v1/README.md +0 -25
  384. package/contracts/ugc/ecs-runtime/v1/api.json +0 -46
  385. package/contracts/ugc/ecs-runtime/v1/conformance/run-vectors.mjs +0 -41
  386. package/contracts/ugc/ecs-runtime/v1/conformance/web/index.html +0 -3
  387. package/contracts/ugc/ecs-runtime/v1/conformance/web/runner.mjs +0 -5
  388. package/contracts/ugc/ecs-runtime/v1/testdata/vectors.json +0 -1318
  389. package/contracts/ugc/gameplay-tests/v1/README.md +0 -78
  390. package/contracts/ugc/gameplay-tests/v1/cases.mjs +0 -70
  391. package/contracts/ugc/gameplay-tests/v1/cases.schema.json +0 -262
  392. package/contracts/ugc/gameplay-tests/v1/conformance/run-vectors.mjs +0 -21
  393. package/contracts/ugc/gameplay-tests/v1/conformance/web/index.html +0 -1
  394. package/contracts/ugc/gameplay-tests/v1/conformance/web/runner.mjs +0 -4
  395. package/contracts/ugc/gameplay-tests/v1/contract-set.json +0 -9
  396. package/contracts/ugc/gameplay-tests/v1/scene-step.mjs +0 -49
  397. package/contracts/ugc/gameplay-tests/v1/testdata/vectors.json +0 -1504
  398. package/contracts/ugc/ground-rules/v1/README.md +0 -44
  399. package/contracts/ugc/ground-rules/v1/conformance/run-vectors.mjs +0 -31
  400. package/contracts/ugc/ground-rules/v1/conformance/web/index.html +0 -1
  401. package/contracts/ugc/ground-rules/v1/conformance/web/runner.mjs +0 -4
  402. package/contracts/ugc/ground-rules/v1/contract-set.json +0 -9
  403. package/contracts/ugc/ground-rules/v1/effective-ground-rules.schema.json +0 -27
  404. package/contracts/ugc/ground-rules/v1/ground-rules.schema.json +0 -33
  405. package/contracts/ugc/ground-rules/v1/testdata/vectors.json +0 -57
  406. package/contracts/ugc/ground-rules/v2/README.md +0 -88
  407. package/contracts/ugc/ground-rules/v2/contract-set.json +0 -20
  408. package/contracts/ugc/ground-rules/v2/ground-rules.schema.json +0 -373
  409. package/contracts/ugc/ground-rules/v2/spaces.test.mjs +0 -58
  410. package/contracts/ugc/ground-rules/v2/spatial-source.schema.json +0 -788
  411. package/contracts/ugc/ground-rules/v2/spatial.test.mjs +0 -142
  412. package/contracts/ugc/ground-rules/v2.2/README.md +0 -73
  413. package/contracts/ugc/ground-rules/v2.2/center-band.test.mjs +0 -149
  414. package/contracts/ugc/ground-rules/v2.2/contract-set.json +0 -8
  415. package/contracts/ugc/ground-rules/v2.2/spatial-source.schema.json +0 -1049
  416. package/contracts/ugc/personal-state/v1/README.md +0 -181
  417. package/contracts/ugc/personal-state/v1/declaration.schema.json +0 -295
  418. package/contracts/ugc/personal-state/v1/declaration.test.mjs +0 -26
  419. package/contracts/ugc/personal-state/v1/marker.schema.json +0 -9
  420. package/contracts/ugc/personal-state/v1/node-plan.test.mjs +0 -65
  421. package/contracts/ugc/pipeline/v1/PLATFORM-SOURCE.md +0 -54
  422. package/contracts/ugc/pipeline/v1/PRESENTATION.md +0 -13
  423. package/contracts/ugc/pipeline/v1/build-record.schema.json +0 -93
  424. package/contracts/ugc/pipeline/v1/conformance/js/pipeline-validator.mjs +0 -196
  425. package/contracts/ugc/pipeline/v1/conformance/js/platform-release-validator.mjs +0 -78
  426. package/contracts/ugc/pipeline/v1/conformance/web/index.html +0 -5
  427. package/contracts/ugc/pipeline/v1/conformance/web/runner.mjs +0 -30
  428. package/contracts/ugc/pipeline/v1/contract-set.json +0 -30
  429. package/contracts/ugc/pipeline/v1/error-codes.json +0 -95
  430. package/contracts/ugc/pipeline/v1/platform-publication-binding.schema.json +0 -56
  431. package/contracts/ugc/pipeline/v1/public-release-descriptor.schema.json +0 -264
  432. package/contracts/ugc/pipeline/v1/publication-operation.schema.json +0 -97
  433. package/contracts/ugc/pipeline/v1/release-index.schema.json +0 -192
  434. package/contracts/ugc/pipeline/v1/review-decision.schema.json +0 -212
  435. package/contracts/ugc/pipeline/v1/submission-receipt.schema.json +0 -15
  436. package/contracts/ugc/pipeline/v1/testdata/vectors.json +0 -1713
  437. package/contracts/ugc/private-event-view/v1/README.md +0 -83
  438. package/contracts/ugc/private-event-view/v1/conformance/run-vectors.mjs +0 -65
  439. package/contracts/ugc/private-event-view/v1/conformance/web/index.html +0 -1
  440. package/contracts/ugc/private-event-view/v1/conformance/web/runner.mjs +0 -5
  441. package/contracts/ugc/private-event-view/v1/contract-set.json +0 -9
  442. package/contracts/ugc/private-event-view/v1/export.mjs +0 -22
  443. package/contracts/ugc/private-event-view/v1/testdata/vectors.json +0 -22
  444. package/contracts/ugc/private-event-view/v1/view.mjs +0 -130
  445. package/contracts/ugc/private-event-view/v1/view.schema.json +0 -204
  446. package/contracts/ugc/private-events/v1/README.md +0 -102
  447. package/contracts/ugc/private-events/v1/conformance/run-vectors.mjs +0 -52
  448. package/contracts/ugc/private-events/v1/conformance/web/index.html +0 -1
  449. package/contracts/ugc/private-events/v1/conformance/web/runner.mjs +0 -4
  450. package/contracts/ugc/private-events/v1/contract-set.json +0 -9
  451. package/contracts/ugc/private-events/v1/events.schema.json +0 -19
  452. package/contracts/ugc/private-events/v1/grant.schema.json +0 -15
  453. package/contracts/ugc/private-events/v1/output.schema.json +0 -15
  454. package/contracts/ugc/private-events/v1/testdata/vectors.json +0 -55
  455. package/contracts/ugc/private-state/v1/README.md +0 -95
  456. package/contracts/ugc/private-state/v1/conformance/run-vectors.mjs +0 -40
  457. package/contracts/ugc/private-state/v1/conformance/web/index.html +0 -1
  458. package/contracts/ugc/private-state/v1/conformance/web/runner.mjs +0 -4
  459. package/contracts/ugc/private-state/v1/contract-set.json +0 -9
  460. package/contracts/ugc/private-state/v1/field-table.schema.json +0 -136
  461. package/contracts/ugc/private-state/v1/projection.schema.json +0 -515
  462. package/contracts/ugc/private-state/v1/testdata/vectors.json +0 -76
  463. package/contracts/ugc/private-state-view/v1/README.md +0 -91
  464. package/contracts/ugc/private-state-view/v1/conformance/run-vectors.mjs +0 -52
  465. package/contracts/ugc/private-state-view/v1/conformance/web/index.html +0 -1
  466. package/contracts/ugc/private-state-view/v1/conformance/web/runner.mjs +0 -5
  467. package/contracts/ugc/private-state-view/v1/contract-set.json +0 -24
  468. package/contracts/ugc/private-state-view/v1/export.mjs +0 -29
  469. package/contracts/ugc/private-state-view/v1/publication.schema.json +0 -82
  470. package/contracts/ugc/private-state-view/v1/testdata/vectors.json +0 -21
  471. package/contracts/ugc/private-state-view/v1/view.mjs +0 -199
  472. package/contracts/ugc/private-state-view/v1/view.schema.json +0 -255
  473. package/contracts/ugc/public-runtime/v1/static-room-runtime.test.mjs +0 -225
  474. package/contracts/ugc/registry/v1/capabilities-lock.schema.json +0 -110
  475. package/contracts/ugc/registry/v1/capability-query-result.schema.json +0 -33
  476. package/contracts/ugc/registry/v1/capability-query.schema.json +0 -14
  477. package/contracts/ugc/registry/v1/capability-registry.schema.json +0 -83
  478. package/contracts/ugc/registry/v1/conformance/web/index.html +0 -5
  479. package/contracts/ugc/registry/v1/conformance/web/runner.mjs +0 -68
  480. package/contracts/ugc/registry/v1/contract-set.json +0 -23
  481. package/contracts/ugc/registry/v1/effective-budgets.schema.json +0 -34
  482. package/contracts/ugc/registry/v1/error-codes.json +0 -11
  483. package/contracts/ugc/registry/v1/network-profile-lock.schema.json +0 -26
  484. package/contracts/ugc/registry/v1/registry.json +0 -1
  485. package/contracts/ugc/registry/v1/resolution-policy.json +0 -70
  486. package/contracts/ugc/registry/v1/resolution-result.schema.json +0 -49
  487. package/contracts/ugc/registry/v1/testdata/vectors.json +0 -405
  488. package/contracts/ugc/resource-bindings/v1/AUTHORED-AVATAR.md +0 -133
  489. package/contracts/ugc/resource-bindings/v1/README.md +0 -61
  490. package/contracts/ugc/resource-bindings/v1/authored-avatar.schema.json +0 -48
  491. package/contracts/ugc/resource-bindings/v1/bindings.schema.json +0 -45
  492. package/contracts/ugc/resource-bindings/v1/conformance/authored-avatar-vectors.mjs +0 -26
  493. package/contracts/ugc/resource-bindings/v1/conformance/run-vectors.mjs +0 -32
  494. package/contracts/ugc/resource-bindings/v1/conformance/web/index.html +0 -1
  495. package/contracts/ugc/resource-bindings/v1/conformance/web/runner.mjs +0 -13
  496. package/contracts/ugc/resource-bindings/v1/contract-set.json +0 -9
  497. package/contracts/ugc/resource-bindings/v1/testdata/authored-avatar-vectors.json +0 -146
  498. package/contracts/ugc/resource-bindings/v1/testdata/authored-avatar.json +0 -13
  499. package/contracts/ugc/resource-bindings/v1/testdata/vectors.json +0 -68
  500. package/contracts/ugc/sandbox/v1/conformance/web/index.html +0 -5
  501. package/contracts/ugc/sandbox/v1/conformance/web/runner.mjs +0 -26
  502. package/contracts/ugc/sandbox/v1/contract-set.json +0 -19
  503. package/contracts/ugc/sandbox/v1/error-codes.json +0 -25
  504. package/contracts/ugc/sandbox/v1/execution-result.schema.json +0 -80
  505. package/contracts/ugc/sandbox/v1/launch-request.schema.json +0 -96
  506. package/contracts/ugc/sandbox/v1/lifecycle-message.schema.json +0 -18
  507. package/contracts/ugc/sandbox/v1/local-launch-request.schema.json +0 -34
  508. package/contracts/ugc/sandbox/v1/private-ecs-grant.schema.json +0 -32
  509. package/contracts/ugc/sandbox/v1/sandbox-profile.schema.json +0 -70
  510. package/contracts/ugc/sandbox/v1/testdata/vectors.json +0 -89
  511. package/contracts/ugc/scene-interaction/v1/README.md +0 -63
  512. package/contracts/ugc/scene-interaction/v1/conformance/run-vectors.mjs +0 -26
  513. package/contracts/ugc/scene-interaction/v1/conformance/web/index.html +0 -1
  514. package/contracts/ugc/scene-interaction/v1/conformance/web/runner.mjs +0 -4
  515. package/contracts/ugc/scene-interaction/v1/contract-set.json +0 -26
  516. package/contracts/ugc/scene-interaction/v1/effective-targets.schema.json +0 -76
  517. package/contracts/ugc/scene-interaction/v1/request.schema.json +0 -30
  518. package/contracts/ugc/scene-interaction/v1/result.schema.json +0 -88
  519. package/contracts/ugc/scene-interaction/v1/targets.schema.json +0 -49
  520. package/contracts/ugc/scene-interaction/v1/testdata/vectors.json +0 -732
  521. package/contracts/ugc/scene-interaction/v2/README.md +0 -63
  522. package/contracts/ugc/scene-interaction/v2/contract-set.json +0 -19
  523. package/contracts/ugc/scene-interaction/v2/metric.test.mjs +0 -99
  524. package/contracts/ugc/scene-interaction/v2/targets.schema.json +0 -229
  525. package/contracts/ugc/scene-presentation/v1/INK-MATH.md +0 -64
  526. package/contracts/ugc/scene-presentation/v1/README.md +0 -126
  527. package/contracts/ugc/scene-presentation/v1/RENDER-POLICY.md +0 -63
  528. package/contracts/ugc/scene-presentation/v1/conformance/ink-vectors.mjs +0 -34
  529. package/contracts/ugc/scene-presentation/v1/conformance/render-policy-vectors.mjs +0 -62
  530. package/contracts/ugc/scene-presentation/v1/conformance/vectors.mjs +0 -128
  531. package/contracts/ugc/scene-presentation/v1/contract-set.json +0 -6
  532. package/contracts/ugc/scene-presentation/v1/ink-math.mjs +0 -70
  533. package/contracts/ugc/scene-presentation/v1/render-policy.schema.json +0 -27
  534. package/contracts/ugc/scene-presentation/v1/scene.schema.json +0 -66
  535. package/contracts/ugc/v1/COVER.md +0 -38
  536. package/contracts/ugc/v1/SCENE-PROVENANCE.md +0 -54
  537. package/contracts/ugc/v1/candidate-submission.schema.json +0 -16
  538. package/contracts/ugc/v1/capability-request.schema.json +0 -29
  539. package/contracts/ugc/v1/compatibility.json +0 -32
  540. package/contracts/ugc/v1/components.schema.json +0 -77
  541. package/contracts/ugc/v1/conformance/js/capability-operations.mjs +0 -13
  542. package/contracts/ugc/v1/conformance/js/scene-provenance.mjs +0 -121
  543. package/contracts/ugc/v1/conformance/js/source-validator.mjs +0 -99
  544. package/contracts/ugc/v1/conformance/web/index.html +0 -5
  545. package/contracts/ugc/v1/conformance/web/runner.mjs +0 -82
  546. package/contracts/ugc/v1/contract-set.json +0 -38
  547. package/contracts/ugc/v1/creator-sdk.json +0 -84
  548. package/contracts/ugc/v1/error-codes.json +0 -53
  549. package/contracts/ugc/v1/manifest.schema.json +0 -215
  550. package/contracts/ugc/v1/network-intent.schema.json +0 -15
  551. package/contracts/ugc/v1/prefabs.schema.json +0 -29
  552. package/contracts/ugc/v1/provenance.schema.json +0 -160
  553. package/contracts/ugc/v1/scene.schema.json +0 -37
  554. package/contracts/ugc/v1/testdata/capability-operation-vectors.json +0 -243
  555. package/contracts/ugc/v1/testdata/cover-vectors.json +0 -25
  556. package/contracts/ugc/v1/testdata/invalid/authored-avatar-missing-capability.json +0 -44
  557. package/contracts/ugc/v1/testdata/invalid/authored-avatar-wrong-capability.json +0 -51
  558. package/contracts/ugc/v1/testdata/invalid/budget-overflow.json +0 -1
  559. package/contracts/ugc/v1/testdata/invalid/build-field-override.json +0 -1
  560. package/contracts/ugc/v1/testdata/invalid/creator-server-entrypoint.json +0 -5
  561. package/contracts/ugc/v1/testdata/invalid/forbidden-network-control.json +0 -1
  562. package/contracts/ugc/v1/testdata/invalid/ground-authority.json +0 -57
  563. package/contracts/ugc/v1/testdata/invalid/ground-budget.json +0 -56
  564. package/contracts/ugc/v1/testdata/invalid/ground-dependency.json +0 -49
  565. package/contracts/ugc/v1/testdata/invalid/ground-identity.json +0 -56
  566. package/contracts/ugc/v1/testdata/invalid/ground-missing.json +0 -13
  567. package/contracts/ugc/v1/testdata/invalid/ground-optional.json +0 -60
  568. package/contracts/ugc/v1/testdata/invalid/ground-path.json +0 -56
  569. package/contracts/ugc/v1/testdata/invalid/ground-run-dependency.json +0 -56
  570. package/contracts/ugc/v1/testdata/invalid/ground-version.json +0 -56
  571. package/contracts/ugc/v1/testdata/invalid/missing-required-field.json +0 -1
  572. package/contracts/ugc/v1/testdata/invalid/missing-shared-entrypoint.json +0 -5
  573. package/contracts/ugc/v1/testdata/invalid/path-escape.json +0 -1
  574. package/contracts/ugc/v1/testdata/invalid/private-events-authority.json +0 -35
  575. package/contracts/ugc/v1/testdata/invalid/private-events-budget.json +0 -35
  576. package/contracts/ugc/v1/testdata/invalid/private-events-dependency.json +0 -27
  577. package/contracts/ugc/v1/testdata/invalid/private-events-empty.json +0 -20
  578. package/contracts/ugc/v1/testdata/invalid/private-events-identity.json +0 -34
  579. package/contracts/ugc/v1/testdata/invalid/private-events-missing.json +0 -13
  580. package/contracts/ugc/v1/testdata/invalid/private-events-optional.json +0 -38
  581. package/contracts/ugc/v1/testdata/invalid/private-events-path.json +0 -34
  582. package/contracts/ugc/v1/testdata/invalid/private-events-type.json +0 -34
  583. package/contracts/ugc/v1/testdata/invalid/private-events-unknown-ref.json +0 -34
  584. package/contracts/ugc/v1/testdata/invalid/private-events-version.json +0 -34
  585. package/contracts/ugc/v1/testdata/invalid/resource-bindings-identity.json +0 -18
  586. package/contracts/ugc/v1/testdata/invalid/resource-bindings-kind.json +0 -19
  587. package/contracts/ugc/v1/testdata/invalid/resource-bindings-missing.json +0 -6
  588. package/contracts/ugc/v1/testdata/invalid/resource-bindings-path.json +0 -6
  589. package/contracts/ugc/v1/testdata/invalid/resource-bindings-type.json +0 -8
  590. package/contracts/ugc/v1/testdata/invalid/resource-bindings-unknown.json +0 -18
  591. package/contracts/ugc/v1/testdata/invalid/scene-interactions-authority.json +0 -61
  592. package/contracts/ugc/v1/testdata/invalid/scene-interactions-core-unknown.json +0 -61
  593. package/contracts/ugc/v1/testdata/invalid/scene-interactions-dependency.json +0 -53
  594. package/contracts/ugc/v1/testdata/invalid/scene-interactions-identity.json +0 -60
  595. package/contracts/ugc/v1/testdata/invalid/scene-interactions-missing-transform.json +0 -50
  596. package/contracts/ugc/v1/testdata/invalid/scene-interactions-missing.json +0 -49
  597. package/contracts/ugc/v1/testdata/invalid/scene-interactions-optional.json +0 -64
  598. package/contracts/ugc/v1/testdata/invalid/scene-interactions-partial-transform.json +0 -59
  599. package/contracts/ugc/v1/testdata/invalid/scene-interactions-path.json +0 -60
  600. package/contracts/ugc/v1/testdata/invalid/scene-interactions-radius.json +0 -60
  601. package/contracts/ugc/v1/testdata/invalid/scene-interactions-unknown-target.json +0 -60
  602. package/contracts/ugc/v1/testdata/invalid/scene-interactions-version.json +0 -60
  603. package/contracts/ugc/v1/testdata/invalid/scene-presentation-authority.json +0 -166
  604. package/contracts/ugc/v1/testdata/invalid/scene-presentation-capability.json +0 -158
  605. package/contracts/ugc/v1/testdata/invalid/scene-presentation-identity.json +0 -165
  606. package/contracts/ugc/v1/testdata/invalid/scene-presentation-missing.json +0 -13
  607. package/contracts/ugc/v1/testdata/invalid/scene-presentation-optional.json +0 -169
  608. package/contracts/ugc/v1/testdata/invalid/scene-presentation-path.json +0 -165
  609. package/contracts/ugc/v1/testdata/invalid/scene-presentation-undeclared.json +0 -163
  610. package/contracts/ugc/v1/testdata/invalid/scene-presentation-unknown-material.json +0 -165
  611. package/contracts/ugc/v1/testdata/invalid/schema-incompatible.json +0 -1
  612. package/contracts/ugc/v1/testdata/invalid/unknown-required-component.json +0 -1
  613. package/contracts/ugc/v1/testdata/invalid/world-scene-dual-motion.json +0 -7
  614. package/contracts/ugc/v1/testdata/invalid/world-scene-identity.json +0 -90
  615. package/contracts/ugc/v1/testdata/invalid/world-scene-missing-capability.json +0 -85
  616. package/contracts/ugc/v1/testdata/invalid/world-scene-missing.json +0 -28
  617. package/contracts/ugc/v1/testdata/invalid/world-scene-optional-capability.json +0 -94
  618. package/contracts/ugc/v1/testdata/invalid/world-scene-path.json +0 -6
  619. package/contracts/ugc/v1/testdata/invalid/world-scene-version.json +0 -90
  620. package/contracts/ugc/v1/testdata/scene-provenance-vectors.json +0 -56
  621. package/contracts/ugc/v1/testdata/source-vectors.json +0 -83
  622. package/contracts/ugc/v1/testdata/valid/authored-avatar.json +0 -51
  623. package/contracts/ugc/v1/testdata/valid/boundary.json +0 -1
  624. package/contracts/ugc/v1/testdata/valid/components.json +0 -15
  625. package/contracts/ugc/v1/testdata/valid/cosmetic.json +0 -9
  626. package/contracts/ugc/v1/testdata/valid/ground-rules.json +0 -56
  627. package/contracts/ugc/v1/testdata/valid/minimal.json +0 -15
  628. package/contracts/ugc/v1/testdata/valid/prefabs.json +0 -11
  629. package/contracts/ugc/v1/testdata/valid/private-events.json +0 -34
  630. package/contracts/ugc/v1/testdata/valid/resource-bindings.json +0 -18
  631. package/contracts/ugc/v1/testdata/valid/scene-interactions.json +0 -60
  632. package/contracts/ugc/v1/testdata/valid/scene-presentation.json +0 -165
  633. package/contracts/ugc/v1/testdata/valid/scene.json +0 -6
  634. package/contracts/ugc/v1/testdata/valid/unknown-optional-component.json +0 -1
  635. package/contracts/ugc/v1/testdata/valid/world-scene.json +0 -90
  636. package/contracts/ugc/v1/testdata/vectors.json +0 -555
  637. package/contracts/ugc/v1/validation-report.schema.json +0 -61
  638. package/contracts/ugc/world-scene/v1/collision-identity.mjs +0 -73
  639. package/contracts/ugc/world-scene/v1/collision-target.schema.json +0 -18
  640. package/contracts/ugc/world-scene/v1/conformance/flight-avatar-vectors.mjs +0 -27
  641. package/contracts/ugc/world-scene/v1/conformance/run-vectors.mjs +0 -29
  642. package/contracts/ugc/world-scene/v1/coordinates.schema.json +0 -16
  643. package/contracts/ugc/world-scene/v1/flight-avatar-actions.mjs +0 -3
  644. package/contracts/ugc/world-scene/v1/flight-avatar-sample.schema.json +0 -14
  645. package/contracts/ugc/world-scene/v1/scene-declaration.schema.json +0 -40
  646. package/contracts/ugc/world-scene/v1/testdata/flight-avatar-actions.json +0 -48
  647. package/contracts/ugc/world-scene/v1/testdata/scene-declaration-vectors.json +0 -103
  648. package/contracts/ugc/world-scene/v1/testdata/vectors.json +0 -55
  649. package/contracts/ugc/world-scene/v1/visual-tileset.mjs +0 -112
  650. package/contracts/ugc/world-scene/v1/visual-tileset.schema.json +0 -35
  651. package/contracts/ugc/world-scene/v2/ASSET-GRAPH.md +0 -13
  652. package/contracts/ugc/world-scene/v2/ENCODED-RESOURCES.md +0 -117
  653. package/contracts/ugc/world-scene/v2/PARTITION.md +0 -59
  654. package/contracts/ugc/world-scene/v2/VISUAL-TILESET.md +0 -80
  655. package/contracts/ugc/world-scene/v2/asset-graph.mjs +0 -169
  656. package/contracts/ugc/world-scene/v2/collision-index.schema.json +0 -29
  657. package/contracts/ugc/world-scene/v2/collision-partition.schema.json +0 -37
  658. package/contracts/ugc/world-scene/v2/conformance/asset-graph-vectors.mjs +0 -52
  659. package/contracts/ugc/world-scene/v2/conformance/collision-index-vectors.mjs +0 -29
  660. package/contracts/ugc/world-scene/v2/conformance/encoded-resource-vectors.mjs +0 -17
  661. package/contracts/ugc/world-scene/v2/conformance/partition-vectors.mjs +0 -74
  662. package/contracts/ugc/world-scene/v2/conformance/visual-vectors.mjs +0 -24
  663. package/contracts/ugc/world-scene/v2/contract-set.json +0 -50
  664. package/contracts/ugc/world-scene/v2/encoded-resource.schema.json +0 -17
  665. package/contracts/ugc/world-scene/v2/scene-declaration.schema.json +0 -21
  666. package/contracts/ugc/world-scene/v2/testdata/asset-graph-vectors.json +0 -3354
  667. package/contracts/ugc/world-scene/v2/testdata/collision-index-vectors.json +0 -103
  668. package/contracts/ugc/world-scene/v2/testdata/encoded-resource-vectors.json +0 -372
  669. package/contracts/ugc/world-scene/v2/testdata/visual-vectors.json +0 -43
  670. package/contracts/ugc/world-scene/v2/vendor/pako-raw-inflate.provenance.json +0 -43
  671. package/contracts/ugc/world-scene/v2/visual-tileset.mjs +0 -107
  672. package/contracts/ugc/world-scene/v2/visual-tileset.schema.json +0 -33
  673. package/contracts/ugc/world-scene-runtime/v1/runtime-plan.schema.json +0 -660
  674. package/contracts/ugc/world-scene-runtime/v1/testdata/policy-vectors.json +0 -40
  675. package/contracts/ugc/world-scene-runtime/v2/COLLISION-CAPACITY.md +0 -74
  676. package/contracts/ugc/world-scene-runtime/v2/REPORT.md +0 -91
  677. package/contracts/ugc/world-scene-runtime/v2/RUNTIME-PROJECTION.md +0 -110
  678. package/contracts/ugc/world-scene-runtime/v2/VISUAL-WORK.md +0 -72
  679. package/contracts/ugc/world-scene-runtime/v2/collision-capacity.schema.json +0 -62
  680. package/contracts/ugc/world-scene-runtime/v2/conformance/capacity-vectors.mjs +0 -25
  681. package/contracts/ugc/world-scene-runtime/v2/conformance/report-vectors.mjs +0 -141
  682. package/contracts/ugc/world-scene-runtime/v2/conformance/runtime-vectors.mjs +0 -41
  683. package/contracts/ugc/world-scene-runtime/v2/conformance/visual-work-vectors.mjs +0 -21
  684. package/contracts/ugc/world-scene-runtime/v2/contract-set.json +0 -45
  685. package/contracts/ugc/world-scene-runtime/v2/report.mjs +0 -184
  686. package/contracts/ugc/world-scene-runtime/v2/runtime-plan.schema.json +0 -38
  687. package/contracts/ugc/world-scene-runtime/v2/testdata/capacity-vectors.json +0 -30
  688. package/contracts/ugc/world-scene-runtime/v2/testdata/report-fixture.json +0 -250
  689. package/contracts/ugc/world-scene-runtime/v2/testdata/runtime-vectors.json +0 -39
  690. package/contracts/ugc/world-scene-runtime/v2/testdata/visual-work-vectors.json +0 -28
  691. package/contracts/ugc/world-scene-runtime/v2/visual-work-policy.mjs +0 -59
  692. package/document-presentation.snapshot.lock.json +0 -40
  693. package/ground-endpoint.snapshot.lock.json +0 -36
  694. package/ground-spaces.snapshot.lock.json +0 -57
  695. package/lib/creator-source-archive.mjs +0 -182
  696. package/node_modules/@modelcontextprotocol/core/LICENSE +0 -216
  697. package/node_modules/@modelcontextprotocol/core/README.md +0 -40
  698. package/node_modules/@modelcontextprotocol/core/dist/auth-BWdKR39I.d.mts +0 -8501
  699. package/node_modules/@modelcontextprotocol/core/dist/auth-BWdKR39I.d.mts.map +0 -1
  700. package/node_modules/@modelcontextprotocol/core/dist/auth-CUe6YdwF.mjs +0 -1678
  701. package/node_modules/@modelcontextprotocol/core/dist/auth-CUe6YdwF.mjs.map +0 -1
  702. package/node_modules/@modelcontextprotocol/core/dist/auth-CfDMXiII.cjs +0 -2899
  703. package/node_modules/@modelcontextprotocol/core/dist/auth-CfDMXiII.cjs.map +0 -1
  704. package/node_modules/@modelcontextprotocol/core/dist/auth-hYtaIUZm.d.cts +0 -8501
  705. package/node_modules/@modelcontextprotocol/core/dist/auth-hYtaIUZm.d.cts.map +0 -1
  706. package/node_modules/@modelcontextprotocol/core/dist/index.cjs +0 -175
  707. package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +0 -2
  708. package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +0 -2
  709. package/node_modules/@modelcontextprotocol/core/dist/index.mjs +0 -3
  710. package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +0 -201
  711. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +0 -99
  712. package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts.map +0 -1
  713. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +0 -99
  714. package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts.map +0 -1
  715. package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +0 -3
  716. package/node_modules/@modelcontextprotocol/core/package.json +0 -85
  717. package/node_modules/@modelcontextprotocol/server/LICENSE +0 -216
  718. package/node_modules/@modelcontextprotocol/server/README.md +0 -30
  719. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs +0 -7514
  720. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs.map +0 -1
  721. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CgI-5L6O.d.mts +0 -1071
  722. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-CgI-5L6O.d.mts.map +0 -1
  723. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-FOQRM7up.d.cts +0 -1071
  724. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-FOQRM7up.d.cts.map +0 -1
  725. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-ZaoO9afR.cjs +0 -7531
  726. package/node_modules/@modelcontextprotocol/server/dist/ajvProvider-ZaoO9afR.cjs.map +0 -1
  727. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-BwbPzsdI.cjs +0 -986
  728. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-BwbPzsdI.cjs.map +0 -1
  729. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-C03CSigr.d.mts +0 -74
  730. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-C03CSigr.d.mts.map +0 -1
  731. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-doTkZbTr.d.cts +0 -74
  732. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-doTkZbTr.d.cts.map +0 -1
  733. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-p3WaZPqB.mjs +0 -981
  734. package/node_modules/@modelcontextprotocol/server/dist/cfWorkerProvider-p3WaZPqB.mjs.map +0 -1
  735. package/node_modules/@modelcontextprotocol/server/dist/chunk-Bnu9O96Y.cjs +0 -60
  736. package/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs +0 -42
  737. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-CLhGwQTn.d.mts +0 -4043
  738. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-CLhGwQTn.d.mts.map +0 -1
  739. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-dBHMsxwf.d.cts +0 -4045
  740. package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-dBHMsxwf.d.cts.map +0 -1
  741. package/node_modules/@modelcontextprotocol/server/dist/dialects-D8eXzoGv.cjs +0 -46
  742. package/node_modules/@modelcontextprotocol/server/dist/dialects-D8eXzoGv.cjs.map +0 -1
  743. package/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs +0 -34
  744. package/node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs.map +0 -1
  745. package/node_modules/@modelcontextprotocol/server/dist/index.cjs +0 -2055
  746. package/node_modules/@modelcontextprotocol/server/dist/index.cjs.map +0 -1
  747. package/node_modules/@modelcontextprotocol/server/dist/index.d.cts +0 -739
  748. package/node_modules/@modelcontextprotocol/server/dist/index.d.cts.map +0 -1
  749. package/node_modules/@modelcontextprotocol/server/dist/index.d.mts +0 -739
  750. package/node_modules/@modelcontextprotocol/server/dist/index.d.mts.map +0 -1
  751. package/node_modules/@modelcontextprotocol/server/dist/index.mjs +0 -1870
  752. package/node_modules/@modelcontextprotocol/server/dist/index.mjs.map +0 -1
  753. package/node_modules/@modelcontextprotocol/server/dist/mcp-D7GmuPnv.cjs +0 -2022
  754. package/node_modules/@modelcontextprotocol/server/dist/mcp-D7GmuPnv.cjs.map +0 -1
  755. package/node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs +0 -1931
  756. package/node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs.map +0 -1
  757. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.cjs +0 -23
  758. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.cjs.map +0 -1
  759. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.cts +0 -11
  760. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.cts.map +0 -1
  761. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.mts +0 -11
  762. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.d.mts.map +0 -1
  763. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.mjs +0 -22
  764. package/node_modules/@modelcontextprotocol/server/dist/shimsBrowser.mjs.map +0 -1
  765. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.cjs +0 -12
  766. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.d.cts +0 -3
  767. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.d.mts +0 -3
  768. package/node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs +0 -4
  769. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs +0 -30
  770. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs.map +0 -1
  771. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.cts +0 -10
  772. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.cts.map +0 -1
  773. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.mts +0 -10
  774. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.d.mts.map +0 -1
  775. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs +0 -29
  776. package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs.map +0 -1
  777. package/node_modules/@modelcontextprotocol/server/dist/src-CX2iR2pK.mjs +0 -7606
  778. package/node_modules/@modelcontextprotocol/server/dist/src-CX2iR2pK.mjs.map +0 -1
  779. package/node_modules/@modelcontextprotocol/server/dist/src-STyD_Vvf.cjs +0 -8104
  780. package/node_modules/@modelcontextprotocol/server/dist/src-STyD_Vvf.cjs.map +0 -1
  781. package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs +0 -564
  782. package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs.map +0 -1
  783. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts +0 -107
  784. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts.map +0 -1
  785. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts +0 -107
  786. package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts.map +0 -1
  787. package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs +0 -562
  788. package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs.map +0 -1
  789. package/node_modules/@modelcontextprotocol/server/dist/types-DUs7mGBv.d.mts +0 -1099
  790. package/node_modules/@modelcontextprotocol/server/dist/types-DUs7mGBv.d.mts.map +0 -1
  791. package/node_modules/@modelcontextprotocol/server/dist/types-DsbMXNFL.d.cts +0 -1099
  792. package/node_modules/@modelcontextprotocol/server/dist/types-DsbMXNFL.d.cts.map +0 -1
  793. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.cjs +0 -5
  794. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.d.cts +0 -2
  795. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.d.mts +0 -2
  796. package/node_modules/@modelcontextprotocol/server/dist/validators/ajv.mjs +0 -3
  797. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.cjs +0 -3
  798. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.d.cts +0 -2
  799. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.d.mts +0 -2
  800. package/node_modules/@modelcontextprotocol/server/dist/validators/cfWorker.mjs +0 -3
  801. package/node_modules/@modelcontextprotocol/server/package.json +0 -160
  802. package/node_modules/smol-toml/LICENSE +0 -24
  803. package/node_modules/smol-toml/README.md +0 -236
  804. package/node_modules/smol-toml/dist/date.d.ts +0 -41
  805. package/node_modules/smol-toml/dist/date.js +0 -127
  806. package/node_modules/smol-toml/dist/error.d.ts +0 -38
  807. package/node_modules/smol-toml/dist/error.js +0 -63
  808. package/node_modules/smol-toml/dist/extract.d.ts +0 -30
  809. package/node_modules/smol-toml/dist/extract.js +0 -109
  810. package/node_modules/smol-toml/dist/index.cjs +0 -906
  811. package/node_modules/smol-toml/dist/index.d.ts +0 -43
  812. package/node_modules/smol-toml/dist/index.js +0 -33
  813. package/node_modules/smol-toml/dist/parse.d.ts +0 -37
  814. package/node_modules/smol-toml/dist/parse.js +0 -148
  815. package/node_modules/smol-toml/dist/primitive.d.ts +0 -31
  816. package/node_modules/smol-toml/dist/primitive.js +0 -178
  817. package/node_modules/smol-toml/dist/stringify.d.ts +0 -31
  818. package/node_modules/smol-toml/dist/stringify.js +0 -163
  819. package/node_modules/smol-toml/dist/struct.d.ts +0 -32
  820. package/node_modules/smol-toml/dist/struct.js +0 -194
  821. package/node_modules/smol-toml/dist/util.d.ts +0 -42
  822. package/node_modules/smol-toml/dist/util.js +0 -106
  823. package/node_modules/smol-toml/package.json +0 -54
  824. package/node_modules/zod/LICENSE +0 -21
  825. package/node_modules/zod/README.md +0 -218
  826. package/node_modules/zod/compile.cjs +0 -77
  827. package/node_modules/zod/compile.d.cts +0 -1
  828. package/node_modules/zod/compile.d.ts +0 -1
  829. package/node_modules/zod/compile.js +0 -52
  830. package/node_modules/zod/index.cjs +0 -33
  831. package/node_modules/zod/index.d.cts +0 -3
  832. package/node_modules/zod/index.d.ts +0 -3
  833. package/node_modules/zod/index.js +0 -7
  834. package/node_modules/zod/locales/index.cjs +0 -17
  835. package/node_modules/zod/locales/index.d.cts +0 -1
  836. package/node_modules/zod/locales/index.d.ts +0 -1
  837. package/node_modules/zod/locales/index.js +0 -1
  838. package/node_modules/zod/locales/package.json +0 -7
  839. package/node_modules/zod/mini/index.cjs +0 -32
  840. package/node_modules/zod/mini/index.d.cts +0 -3
  841. package/node_modules/zod/mini/index.d.ts +0 -3
  842. package/node_modules/zod/mini/index.js +0 -3
  843. package/node_modules/zod/mini/package.json +0 -7
  844. package/node_modules/zod/package.json +0 -146
  845. package/node_modules/zod/src/compile.ts +0 -56
  846. package/node_modules/zod/src/index.ts +0 -7
  847. package/node_modules/zod/src/locales/index.ts +0 -1
  848. package/node_modules/zod/src/mini/index.ts +0 -3
  849. package/node_modules/zod/src/v3/ZodError.ts +0 -340
  850. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  851. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  852. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  853. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  854. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  855. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  856. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  857. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  858. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  859. package/node_modules/zod/src/v3/errors.ts +0 -13
  860. package/node_modules/zod/src/v3/external.ts +0 -6
  861. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  862. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  863. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  864. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  865. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  866. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  867. package/node_modules/zod/src/v3/index.ts +0 -4
  868. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  869. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  870. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  871. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  872. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  873. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  874. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  875. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  876. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  877. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  878. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  879. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  880. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  881. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  882. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  883. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  884. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  885. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  886. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  887. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  888. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  889. package/node_modules/zod/src/v3/tests/error.test.ts +0 -586
  890. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  891. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  892. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  893. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  894. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  895. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -128
  896. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  897. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -206
  898. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  899. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  900. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  901. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  902. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  903. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  904. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  905. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  906. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  907. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  908. package/node_modules/zod/src/v3/tests/object.test.ts +0 -431
  909. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  910. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  911. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  912. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  913. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  914. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  915. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  916. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  917. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  918. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -114
  919. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  920. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  921. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  922. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  923. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  924. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  925. package/node_modules/zod/src/v3/tests/string.test.ts +0 -922
  926. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  927. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  928. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  929. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  930. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  931. package/node_modules/zod/src/v3/types.ts +0 -5138
  932. package/node_modules/zod/src/v4/classic/checks.ts +0 -33
  933. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  934. package/node_modules/zod/src/v4/classic/compat.ts +0 -78
  935. package/node_modules/zod/src/v4/classic/deep-partial.ts +0 -76
  936. package/node_modules/zod/src/v4/classic/errors.ts +0 -97
  937. package/node_modules/zod/src/v4/classic/external.ts +0 -55
  938. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -721
  939. package/node_modules/zod/src/v4/classic/in-out.ts +0 -45
  940. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  941. package/node_modules/zod/src/v4/classic/iso.ts +0 -20
  942. package/node_modules/zod/src/v4/classic/parse.ts +0 -88
  943. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2862
  944. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  945. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -86
  946. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  947. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -351
  948. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  949. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  950. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  951. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -83
  952. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  953. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -604
  954. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  955. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -572
  956. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -704
  957. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  958. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  959. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +0 -76
  960. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  961. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +0 -720
  962. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -92
  963. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -316
  964. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +0 -380
  965. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +0 -32
  966. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -455
  967. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  968. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  969. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -221
  970. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -836
  971. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -296
  972. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -917
  973. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -979
  974. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  975. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  976. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  977. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -1310
  978. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -391
  979. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  980. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -32
  981. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -67
  982. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +0 -159
  983. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -958
  984. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +0 -281
  985. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -107
  986. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -334
  987. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +0 -183
  988. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -39
  989. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  990. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -262
  991. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -128
  992. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  993. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  994. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -342
  995. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  996. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  997. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  998. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  999. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -362
  1000. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -950
  1001. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +0 -234
  1002. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -366
  1003. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -497
  1004. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  1005. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  1006. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -74
  1007. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -44
  1008. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  1009. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  1010. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  1011. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  1012. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -184
  1013. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -885
  1014. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -662
  1015. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +0 -68
  1016. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -693
  1017. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  1018. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -190
  1019. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -134
  1020. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  1021. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1346
  1022. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -124
  1023. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -780
  1024. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  1025. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -4537
  1026. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  1027. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -511
  1028. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -310
  1029. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  1030. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +0 -76
  1031. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  1032. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  1033. package/node_modules/zod/src/v4/core/api.ts +0 -1859
  1034. package/node_modules/zod/src/v4/core/checks.ts +0 -1306
  1035. package/node_modules/zod/src/v4/core/compile.ts +0 -2188
  1036. package/node_modules/zod/src/v4/core/core.ts +0 -232
  1037. package/node_modules/zod/src/v4/core/doc.ts +0 -48
  1038. package/node_modules/zod/src/v4/core/errors.ts +0 -546
  1039. package/node_modules/zod/src/v4/core/index.ts +0 -19
  1040. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -131
  1041. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -830
  1042. package/node_modules/zod/src/v4/core/json-schema.ts +0 -148
  1043. package/node_modules/zod/src/v4/core/memoizer.ts +0 -284
  1044. package/node_modules/zod/src/v4/core/parse.ts +0 -288
  1045. package/node_modules/zod/src/v4/core/regexes.ts +0 -207
  1046. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  1047. package/node_modules/zod/src/v4/core/schemas.ts +0 -5028
  1048. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  1049. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +0 -969
  1050. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +0 -89
  1051. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +0 -26
  1052. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +0 -34
  1053. package/node_modules/zod/src/v4/core/tests/compile.test.ts +0 -1639
  1054. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  1055. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  1056. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  1057. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -214
  1058. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  1059. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -180
  1060. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  1061. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  1062. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  1063. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  1064. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +0 -42
  1065. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  1066. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +0 -69
  1067. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  1068. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  1069. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  1070. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  1071. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +0 -51
  1072. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +0 -31
  1073. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -855
  1074. package/node_modules/zod/src/v4/core/util.ts +0 -1209
  1075. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  1076. package/node_modules/zod/src/v4/core/visit.ts +0 -193
  1077. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  1078. package/node_modules/zod/src/v4/index.ts +0 -4
  1079. package/node_modules/zod/src/v4/locales/ar.ts +0 -118
  1080. package/node_modules/zod/src/v4/locales/az.ts +0 -114
  1081. package/node_modules/zod/src/v4/locales/be.ts +0 -186
  1082. package/node_modules/zod/src/v4/locales/bg.ts +0 -131
  1083. package/node_modules/zod/src/v4/locales/bn.ts +0 -121
  1084. package/node_modules/zod/src/v4/locales/ca.ts +0 -119
  1085. package/node_modules/zod/src/v4/locales/ckb.ts +0 -138
  1086. package/node_modules/zod/src/v4/locales/cs.ts +0 -121
  1087. package/node_modules/zod/src/v4/locales/da.ts +0 -126
  1088. package/node_modules/zod/src/v4/locales/de.ts +0 -119
  1089. package/node_modules/zod/src/v4/locales/el.ts +0 -122
  1090. package/node_modules/zod/src/v4/locales/en.ts +0 -134
  1091. package/node_modules/zod/src/v4/locales/eo.ts +0 -121
  1092. package/node_modules/zod/src/v4/locales/es.ts +0 -143
  1093. package/node_modules/zod/src/v4/locales/fa.ts +0 -129
  1094. package/node_modules/zod/src/v4/locales/fi.ts +0 -124
  1095. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -119
  1096. package/node_modules/zod/src/v4/locales/fr.ts +0 -137
  1097. package/node_modules/zod/src/v4/locales/gu.ts +0 -121
  1098. package/node_modules/zod/src/v4/locales/he.ts +0 -251
  1099. package/node_modules/zod/src/v4/locales/hi.ts +0 -124
  1100. package/node_modules/zod/src/v4/locales/hr.ts +0 -133
  1101. package/node_modules/zod/src/v4/locales/hu.ts +0 -120
  1102. package/node_modules/zod/src/v4/locales/hy.ts +0 -173
  1103. package/node_modules/zod/src/v4/locales/id.ts +0 -118
  1104. package/node_modules/zod/src/v4/locales/index.ts +0 -62
  1105. package/node_modules/zod/src/v4/locales/is.ts +0 -122
  1106. package/node_modules/zod/src/v4/locales/it.ts +0 -119
  1107. package/node_modules/zod/src/v4/locales/ja.ts +0 -117
  1108. package/node_modules/zod/src/v4/locales/ka.ts +0 -126
  1109. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  1110. package/node_modules/zod/src/v4/locales/km.ts +0 -122
  1111. package/node_modules/zod/src/v4/locales/kn.ts +0 -124
  1112. package/node_modules/zod/src/v4/locales/ko.ts +0 -124
  1113. package/node_modules/zod/src/v4/locales/lt.ts +0 -241
  1114. package/node_modules/zod/src/v4/locales/mk.ts +0 -121
  1115. package/node_modules/zod/src/v4/locales/ms.ts +0 -118
  1116. package/node_modules/zod/src/v4/locales/ne.ts +0 -126
  1117. package/node_modules/zod/src/v4/locales/nl.ts +0 -124
  1118. package/node_modules/zod/src/v4/locales/nn.ts +0 -119
  1119. package/node_modules/zod/src/v4/locales/no.ts +0 -119
  1120. package/node_modules/zod/src/v4/locales/ota.ts +0 -120
  1121. package/node_modules/zod/src/v4/locales/pl.ts +0 -121
  1122. package/node_modules/zod/src/v4/locales/ps.ts +0 -129
  1123. package/node_modules/zod/src/v4/locales/pt-BR.ts +0 -159
  1124. package/node_modules/zod/src/v4/locales/pt.ts +0 -157
  1125. package/node_modules/zod/src/v4/locales/ro.ts +0 -130
  1126. package/node_modules/zod/src/v4/locales/ru.ts +0 -186
  1127. package/node_modules/zod/src/v4/locales/sk.ts +0 -121
  1128. package/node_modules/zod/src/v4/locales/sl.ts +0 -121
  1129. package/node_modules/zod/src/v4/locales/sv.ts +0 -122
  1130. package/node_modules/zod/src/v4/locales/ta.ts +0 -121
  1131. package/node_modules/zod/src/v4/locales/th.ts +0 -122
  1132. package/node_modules/zod/src/v4/locales/tk.ts +0 -111
  1133. package/node_modules/zod/src/v4/locales/tr.ts +0 -114
  1134. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  1135. package/node_modules/zod/src/v4/locales/uk.ts +0 -120
  1136. package/node_modules/zod/src/v4/locales/ur.ts +0 -122
  1137. package/node_modules/zod/src/v4/locales/uz.ts +0 -118
  1138. package/node_modules/zod/src/v4/locales/vi.ts +0 -120
  1139. package/node_modules/zod/src/v4/locales/yo.ts +0 -127
  1140. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -119
  1141. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -118
  1142. package/node_modules/zod/src/v4/mini/checks.ts +0 -33
  1143. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  1144. package/node_modules/zod/src/v4/mini/deep-partial.ts +0 -73
  1145. package/node_modules/zod/src/v4/mini/external.ts +0 -50
  1146. package/node_modules/zod/src/v4/mini/in-out.ts +0 -45
  1147. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  1148. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  1149. package/node_modules/zod/src/v4/mini/parse.ts +0 -16
  1150. package/node_modules/zod/src/v4/mini/schemas.ts +0 -2026
  1151. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -57
  1152. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -190
  1153. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  1154. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -158
  1155. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -582
  1156. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  1157. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +0 -84
  1158. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +0 -54
  1159. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -41
  1160. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -14
  1161. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -1060
  1162. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -109
  1163. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -292
  1164. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  1165. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -325
  1166. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  1167. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -373
  1168. package/node_modules/zod/src/v4-mini/index.ts +0 -3
  1169. package/node_modules/zod/v3/ZodError.cjs +0 -148
  1170. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  1171. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  1172. package/node_modules/zod/v3/ZodError.js +0 -143
  1173. package/node_modules/zod/v3/errors.cjs +0 -17
  1174. package/node_modules/zod/v3/errors.d.cts +0 -5
  1175. package/node_modules/zod/v3/errors.d.ts +0 -5
  1176. package/node_modules/zod/v3/errors.js +0 -9
  1177. package/node_modules/zod/v3/external.cjs +0 -22
  1178. package/node_modules/zod/v3/external.d.cts +0 -6
  1179. package/node_modules/zod/v3/external.d.ts +0 -6
  1180. package/node_modules/zod/v3/external.js +0 -6
  1181. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  1182. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  1183. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  1184. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  1185. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  1186. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  1187. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  1188. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  1189. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  1190. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  1191. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  1192. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  1193. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  1194. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  1195. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  1196. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  1197. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  1198. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  1199. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  1200. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  1201. package/node_modules/zod/v3/helpers/util.cjs +0 -137
  1202. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  1203. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  1204. package/node_modules/zod/v3/helpers/util.js +0 -133
  1205. package/node_modules/zod/v3/index.cjs +0 -33
  1206. package/node_modules/zod/v3/index.d.cts +0 -4
  1207. package/node_modules/zod/v3/index.d.ts +0 -4
  1208. package/node_modules/zod/v3/index.js +0 -4
  1209. package/node_modules/zod/v3/locales/en.cjs +0 -112
  1210. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  1211. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  1212. package/node_modules/zod/v3/locales/en.js +0 -109
  1213. package/node_modules/zod/v3/package.json +0 -7
  1214. package/node_modules/zod/v3/standard-schema.cjs +0 -2
  1215. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  1216. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  1217. package/node_modules/zod/v3/standard-schema.js +0 -1
  1218. package/node_modules/zod/v3/types.cjs +0 -3779
  1219. package/node_modules/zod/v3/types.d.cts +0 -1034
  1220. package/node_modules/zod/v3/types.d.ts +0 -1034
  1221. package/node_modules/zod/v3/types.js +0 -3697
  1222. package/node_modules/zod/v4/classic/checks.cjs +0 -34
  1223. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  1224. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  1225. package/node_modules/zod/v4/classic/checks.js +0 -1
  1226. package/node_modules/zod/v4/classic/coerce.cjs +0 -47
  1227. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  1228. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  1229. package/node_modules/zod/v4/classic/coerce.js +0 -17
  1230. package/node_modules/zod/v4/classic/compat.cjs +0 -61
  1231. package/node_modules/zod/v4/classic/compat.d.cts +0 -48
  1232. package/node_modules/zod/v4/classic/compat.d.ts +0 -48
  1233. package/node_modules/zod/v4/classic/compat.js +0 -31
  1234. package/node_modules/zod/v4/classic/deep-partial.cjs +0 -39
  1235. package/node_modules/zod/v4/classic/deep-partial.d.cts +0 -14
  1236. package/node_modules/zod/v4/classic/deep-partial.d.ts +0 -14
  1237. package/node_modules/zod/v4/classic/deep-partial.js +0 -13
  1238. package/node_modules/zod/v4/classic/errors.cjs +0 -83
  1239. package/node_modules/zod/v4/classic/errors.d.cts +0 -29
  1240. package/node_modules/zod/v4/classic/errors.d.ts +0 -29
  1241. package/node_modules/zod/v4/classic/errors.js +0 -57
  1242. package/node_modules/zod/v4/classic/external.cjs +0 -76
  1243. package/node_modules/zod/v4/classic/external.d.cts +0 -19
  1244. package/node_modules/zod/v4/classic/external.d.ts +0 -19
  1245. package/node_modules/zod/v4/classic/external.js +0 -17
  1246. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -686
  1247. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  1248. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  1249. package/node_modules/zod/v4/classic/from-json-schema.js +0 -660
  1250. package/node_modules/zod/v4/classic/in-out.cjs +0 -63
  1251. package/node_modules/zod/v4/classic/in-out.d.cts +0 -8
  1252. package/node_modules/zod/v4/classic/in-out.d.ts +0 -8
  1253. package/node_modules/zod/v4/classic/in-out.js +0 -36
  1254. package/node_modules/zod/v4/classic/index.cjs +0 -33
  1255. package/node_modules/zod/v4/classic/index.d.cts +0 -3
  1256. package/node_modules/zod/v4/classic/index.d.ts +0 -3
  1257. package/node_modules/zod/v4/classic/index.js +0 -4
  1258. package/node_modules/zod/v4/classic/iso.cjs +0 -49
  1259. package/node_modules/zod/v4/classic/iso.d.cts +0 -7
  1260. package/node_modules/zod/v4/classic/iso.d.ts +0 -7
  1261. package/node_modules/zod/v4/classic/iso.js +0 -15
  1262. package/node_modules/zod/v4/classic/package.json +0 -7
  1263. package/node_modules/zod/v4/classic/parse.cjs +0 -44
  1264. package/node_modules/zod/v4/classic/parse.d.cts +0 -44
  1265. package/node_modules/zod/v4/classic/parse.d.ts +0 -44
  1266. package/node_modules/zod/v4/classic/parse.js +0 -16
  1267. package/node_modules/zod/v4/classic/schemas.cjs +0 -1611
  1268. package/node_modules/zod/v4/classic/schemas.d.cts +0 -802
  1269. package/node_modules/zod/v4/classic/schemas.d.ts +0 -802
  1270. package/node_modules/zod/v4/classic/schemas.js +0 -1491
  1271. package/node_modules/zod/v4/core/api.cjs +0 -1246
  1272. package/node_modules/zod/v4/core/api.d.cts +0 -329
  1273. package/node_modules/zod/v4/core/api.d.ts +0 -329
  1274. package/node_modules/zod/v4/core/api.js +0 -1104
  1275. package/node_modules/zod/v4/core/checks.cjs +0 -607
  1276. package/node_modules/zod/v4/core/checks.d.cts +0 -278
  1277. package/node_modules/zod/v4/core/checks.d.ts +0 -278
  1278. package/node_modules/zod/v4/core/checks.js +0 -581
  1279. package/node_modules/zod/v4/core/compile.cjs +0 -1813
  1280. package/node_modules/zod/v4/core/compile.d.cts +0 -51
  1281. package/node_modules/zod/v4/core/compile.d.ts +0 -51
  1282. package/node_modules/zod/v4/core/compile.js +0 -1783
  1283. package/node_modules/zod/v4/core/core.cjs +0 -148
  1284. package/node_modules/zod/v4/core/core.d.cts +0 -82
  1285. package/node_modules/zod/v4/core/core.d.ts +0 -82
  1286. package/node_modules/zod/v4/core/core.js +0 -141
  1287. package/node_modules/zod/v4/core/doc.cjs +0 -37
  1288. package/node_modules/zod/v4/core/doc.d.cts +0 -16
  1289. package/node_modules/zod/v4/core/doc.d.ts +0 -16
  1290. package/node_modules/zod/v4/core/doc.js +0 -33
  1291. package/node_modules/zod/v4/core/errors.cjs +0 -301
  1292. package/node_modules/zod/v4/core/errors.d.cts +0 -225
  1293. package/node_modules/zod/v4/core/errors.d.ts +0 -225
  1294. package/node_modules/zod/v4/core/errors.js +0 -270
  1295. package/node_modules/zod/v4/core/index.cjs +0 -51
  1296. package/node_modules/zod/v4/core/index.d.cts +0 -19
  1297. package/node_modules/zod/v4/core/index.d.ts +0 -19
  1298. package/node_modules/zod/v4/core/index.js +0 -19
  1299. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -103
  1300. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  1301. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  1302. package/node_modules/zod/v4/core/json-schema-generator.js +0 -99
  1303. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -813
  1304. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -49
  1305. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -49
  1306. package/node_modules/zod/v4/core/json-schema-processors.js +0 -747
  1307. package/node_modules/zod/v4/core/json-schema.cjs +0 -2
  1308. package/node_modules/zod/v4/core/json-schema.d.cts +0 -89
  1309. package/node_modules/zod/v4/core/json-schema.d.ts +0 -89
  1310. package/node_modules/zod/v4/core/json-schema.js +0 -1
  1311. package/node_modules/zod/v4/core/memoizer.cjs +0 -272
  1312. package/node_modules/zod/v4/core/memoizer.d.cts +0 -15
  1313. package/node_modules/zod/v4/core/memoizer.d.ts +0 -15
  1314. package/node_modules/zod/v4/core/memoizer.js +0 -265
  1315. package/node_modules/zod/v4/core/package.json +0 -7
  1316. package/node_modules/zod/v4/core/parse.cjs +0 -193
  1317. package/node_modules/zod/v4/core/parse.d.cts +0 -52
  1318. package/node_modules/zod/v4/core/parse.d.ts +0 -52
  1319. package/node_modules/zod/v4/core/parse.js +0 -154
  1320. package/node_modules/zod/v4/core/regexes.cjs +0 -184
  1321. package/node_modules/zod/v4/core/regexes.d.cts +0 -87
  1322. package/node_modules/zod/v4/core/regexes.d.ts +0 -87
  1323. package/node_modules/zod/v4/core/regexes.js +0 -150
  1324. package/node_modules/zod/v4/core/registries.cjs +0 -56
  1325. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  1326. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  1327. package/node_modules/zod/v4/core/registries.js +0 -51
  1328. package/node_modules/zod/v4/core/schemas.cjs +0 -2481
  1329. package/node_modules/zod/v4/core/schemas.d.cts +0 -1253
  1330. package/node_modules/zod/v4/core/schemas.d.ts +0 -1253
  1331. package/node_modules/zod/v4/core/schemas.js +0 -2440
  1332. package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  1333. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  1334. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  1335. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  1336. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -660
  1337. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -153
  1338. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -153
  1339. package/node_modules/zod/v4/core/to-json-schema.js +0 -650
  1340. package/node_modules/zod/v4/core/util.cjs +0 -915
  1341. package/node_modules/zod/v4/core/util.d.cts +0 -257
  1342. package/node_modules/zod/v4/core/util.d.ts +0 -257
  1343. package/node_modules/zod/v4/core/util.js +0 -846
  1344. package/node_modules/zod/v4/core/versions.cjs +0 -8
  1345. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  1346. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  1347. package/node_modules/zod/v4/core/versions.js +0 -5
  1348. package/node_modules/zod/v4/core/visit.cjs +0 -195
  1349. package/node_modules/zod/v4/core/visit.d.cts +0 -30
  1350. package/node_modules/zod/v4/core/visit.d.ts +0 -30
  1351. package/node_modules/zod/v4/core/visit.js +0 -169
  1352. package/node_modules/zod/v4/index.cjs +0 -32
  1353. package/node_modules/zod/v4/index.d.cts +0 -3
  1354. package/node_modules/zod/v4/index.d.ts +0 -3
  1355. package/node_modules/zod/v4/index.js +0 -4
  1356. package/node_modules/zod/v4/locales/ar.cjs +0 -136
  1357. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  1358. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  1359. package/node_modules/zod/v4/locales/ar.js +0 -109
  1360. package/node_modules/zod/v4/locales/az.cjs +0 -135
  1361. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  1362. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  1363. package/node_modules/zod/v4/locales/az.js +0 -108
  1364. package/node_modules/zod/v4/locales/be.cjs +0 -193
  1365. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  1366. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  1367. package/node_modules/zod/v4/locales/be.js +0 -166
  1368. package/node_modules/zod/v4/locales/bg.cjs +0 -150
  1369. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  1370. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  1371. package/node_modules/zod/v4/locales/bg.js +0 -123
  1372. package/node_modules/zod/v4/locales/bn.cjs +0 -138
  1373. package/node_modules/zod/v4/locales/bn.d.cts +0 -5
  1374. package/node_modules/zod/v4/locales/bn.d.ts +0 -4
  1375. package/node_modules/zod/v4/locales/bn.js +0 -111
  1376. package/node_modules/zod/v4/locales/ca.cjs +0 -137
  1377. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  1378. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  1379. package/node_modules/zod/v4/locales/ca.js +0 -110
  1380. package/node_modules/zod/v4/locales/ckb.cjs +0 -158
  1381. package/node_modules/zod/v4/locales/ckb.d.cts +0 -5
  1382. package/node_modules/zod/v4/locales/ckb.d.ts +0 -4
  1383. package/node_modules/zod/v4/locales/ckb.js +0 -131
  1384. package/node_modules/zod/v4/locales/cs.cjs +0 -141
  1385. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  1386. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  1387. package/node_modules/zod/v4/locales/cs.js +0 -114
  1388. package/node_modules/zod/v4/locales/da.cjs +0 -145
  1389. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  1390. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  1391. package/node_modules/zod/v4/locales/da.js +0 -118
  1392. package/node_modules/zod/v4/locales/de.cjs +0 -138
  1393. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  1394. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  1395. package/node_modules/zod/v4/locales/de.js +0 -111
  1396. package/node_modules/zod/v4/locales/el.cjs +0 -137
  1397. package/node_modules/zod/v4/locales/el.d.cts +0 -5
  1398. package/node_modules/zod/v4/locales/el.d.ts +0 -4
  1399. package/node_modules/zod/v4/locales/el.js +0 -110
  1400. package/node_modules/zod/v4/locales/en.cjs +0 -150
  1401. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  1402. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  1403. package/node_modules/zod/v4/locales/en.js +0 -123
  1404. package/node_modules/zod/v4/locales/eo.cjs +0 -139
  1405. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  1406. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  1407. package/node_modules/zod/v4/locales/eo.js +0 -112
  1408. package/node_modules/zod/v4/locales/es.cjs +0 -161
  1409. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  1410. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  1411. package/node_modules/zod/v4/locales/es.js +0 -134
  1412. package/node_modules/zod/v4/locales/fa.cjs +0 -144
  1413. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  1414. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  1415. package/node_modules/zod/v4/locales/fa.js +0 -117
  1416. package/node_modules/zod/v4/locales/fi.cjs +0 -142
  1417. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  1418. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  1419. package/node_modules/zod/v4/locales/fi.js +0 -115
  1420. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -137
  1421. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  1422. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  1423. package/node_modules/zod/v4/locales/fr-CA.js +0 -110
  1424. package/node_modules/zod/v4/locales/fr.cjs +0 -154
  1425. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  1426. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  1427. package/node_modules/zod/v4/locales/fr.js +0 -127
  1428. package/node_modules/zod/v4/locales/gu.cjs +0 -138
  1429. package/node_modules/zod/v4/locales/gu.d.cts +0 -5
  1430. package/node_modules/zod/v4/locales/gu.d.ts +0 -4
  1431. package/node_modules/zod/v4/locales/gu.js +0 -111
  1432. package/node_modules/zod/v4/locales/he.cjs +0 -246
  1433. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  1434. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  1435. package/node_modules/zod/v4/locales/he.js +0 -219
  1436. package/node_modules/zod/v4/locales/hi.cjs +0 -136
  1437. package/node_modules/zod/v4/locales/hi.d.cts +0 -5
  1438. package/node_modules/zod/v4/locales/hi.d.ts +0 -4
  1439. package/node_modules/zod/v4/locales/hi.js +0 -109
  1440. package/node_modules/zod/v4/locales/hr.cjs +0 -151
  1441. package/node_modules/zod/v4/locales/hr.d.cts +0 -5
  1442. package/node_modules/zod/v4/locales/hr.d.ts +0 -4
  1443. package/node_modules/zod/v4/locales/hr.js +0 -124
  1444. package/node_modules/zod/v4/locales/hu.cjs +0 -138
  1445. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  1446. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  1447. package/node_modules/zod/v4/locales/hu.js +0 -111
  1448. package/node_modules/zod/v4/locales/hy.cjs +0 -183
  1449. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  1450. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  1451. package/node_modules/zod/v4/locales/hy.js +0 -156
  1452. package/node_modules/zod/v4/locales/id.cjs +0 -136
  1453. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  1454. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  1455. package/node_modules/zod/v4/locales/id.js +0 -109
  1456. package/node_modules/zod/v4/locales/index.cjs +0 -131
  1457. package/node_modules/zod/v4/locales/index.d.cts +0 -62
  1458. package/node_modules/zod/v4/locales/index.d.ts +0 -62
  1459. package/node_modules/zod/v4/locales/index.js +0 -62
  1460. package/node_modules/zod/v4/locales/is.cjs +0 -139
  1461. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  1462. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  1463. package/node_modules/zod/v4/locales/is.js +0 -112
  1464. package/node_modules/zod/v4/locales/it.cjs +0 -138
  1465. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  1466. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  1467. package/node_modules/zod/v4/locales/it.js +0 -111
  1468. package/node_modules/zod/v4/locales/ja.cjs +0 -137
  1469. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  1470. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  1471. package/node_modules/zod/v4/locales/ja.js +0 -110
  1472. package/node_modules/zod/v4/locales/ka.cjs +0 -142
  1473. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  1474. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  1475. package/node_modules/zod/v4/locales/ka.js +0 -115
  1476. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  1477. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  1478. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  1479. package/node_modules/zod/v4/locales/kh.js +0 -5
  1480. package/node_modules/zod/v4/locales/km.cjs +0 -140
  1481. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  1482. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  1483. package/node_modules/zod/v4/locales/km.js +0 -113
  1484. package/node_modules/zod/v4/locales/kn.cjs +0 -141
  1485. package/node_modules/zod/v4/locales/kn.d.cts +0 -5
  1486. package/node_modules/zod/v4/locales/kn.d.ts +0 -4
  1487. package/node_modules/zod/v4/locales/kn.js +0 -114
  1488. package/node_modules/zod/v4/locales/ko.cjs +0 -141
  1489. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  1490. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  1491. package/node_modules/zod/v4/locales/ko.js +0 -114
  1492. package/node_modules/zod/v4/locales/lt.cjs +0 -232
  1493. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  1494. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  1495. package/node_modules/zod/v4/locales/lt.js +0 -205
  1496. package/node_modules/zod/v4/locales/mk.cjs +0 -139
  1497. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  1498. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  1499. package/node_modules/zod/v4/locales/mk.js +0 -112
  1500. package/node_modules/zod/v4/locales/ms.cjs +0 -137
  1501. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  1502. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  1503. package/node_modules/zod/v4/locales/ms.js +0 -110
  1504. package/node_modules/zod/v4/locales/ne.cjs +0 -136
  1505. package/node_modules/zod/v4/locales/ne.d.cts +0 -5
  1506. package/node_modules/zod/v4/locales/ne.d.ts +0 -4
  1507. package/node_modules/zod/v4/locales/ne.js +0 -109
  1508. package/node_modules/zod/v4/locales/nl.cjs +0 -140
  1509. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  1510. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  1511. package/node_modules/zod/v4/locales/nl.js +0 -113
  1512. package/node_modules/zod/v4/locales/nn.cjs +0 -138
  1513. package/node_modules/zod/v4/locales/nn.d.cts +0 -5
  1514. package/node_modules/zod/v4/locales/nn.d.ts +0 -4
  1515. package/node_modules/zod/v4/locales/nn.js +0 -111
  1516. package/node_modules/zod/v4/locales/no.cjs +0 -138
  1517. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  1518. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  1519. package/node_modules/zod/v4/locales/no.js +0 -111
  1520. package/node_modules/zod/v4/locales/ota.cjs +0 -139
  1521. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  1522. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  1523. package/node_modules/zod/v4/locales/ota.js +0 -112
  1524. package/node_modules/zod/v4/locales/package.json +0 -7
  1525. package/node_modules/zod/v4/locales/pl.cjs +0 -139
  1526. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  1527. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  1528. package/node_modules/zod/v4/locales/pl.js +0 -112
  1529. package/node_modules/zod/v4/locales/ps.cjs +0 -144
  1530. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  1531. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  1532. package/node_modules/zod/v4/locales/ps.js +0 -117
  1533. package/node_modules/zod/v4/locales/pt-BR.cjs +0 -168
  1534. package/node_modules/zod/v4/locales/pt-BR.d.cts +0 -5
  1535. package/node_modules/zod/v4/locales/pt-BR.d.ts +0 -4
  1536. package/node_modules/zod/v4/locales/pt-BR.js +0 -141
  1537. package/node_modules/zod/v4/locales/pt.cjs +0 -167
  1538. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  1539. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  1540. package/node_modules/zod/v4/locales/pt.js +0 -140
  1541. package/node_modules/zod/v4/locales/ro.cjs +0 -147
  1542. package/node_modules/zod/v4/locales/ro.d.cts +0 -5
  1543. package/node_modules/zod/v4/locales/ro.d.ts +0 -4
  1544. package/node_modules/zod/v4/locales/ro.js +0 -120
  1545. package/node_modules/zod/v4/locales/ru.cjs +0 -193
  1546. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  1547. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  1548. package/node_modules/zod/v4/locales/ru.js +0 -166
  1549. package/node_modules/zod/v4/locales/sk.cjs +0 -141
  1550. package/node_modules/zod/v4/locales/sk.d.cts +0 -5
  1551. package/node_modules/zod/v4/locales/sk.d.ts +0 -4
  1552. package/node_modules/zod/v4/locales/sk.js +0 -114
  1553. package/node_modules/zod/v4/locales/sl.cjs +0 -139
  1554. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  1555. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  1556. package/node_modules/zod/v4/locales/sl.js +0 -112
  1557. package/node_modules/zod/v4/locales/sv.cjs +0 -140
  1558. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  1559. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  1560. package/node_modules/zod/v4/locales/sv.js +0 -113
  1561. package/node_modules/zod/v4/locales/ta.cjs +0 -140
  1562. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  1563. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  1564. package/node_modules/zod/v4/locales/ta.js +0 -113
  1565. package/node_modules/zod/v4/locales/th.cjs +0 -140
  1566. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  1567. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  1568. package/node_modules/zod/v4/locales/th.js +0 -113
  1569. package/node_modules/zod/v4/locales/tk.cjs +0 -132
  1570. package/node_modules/zod/v4/locales/tk.d.cts +0 -5
  1571. package/node_modules/zod/v4/locales/tk.d.ts +0 -4
  1572. package/node_modules/zod/v4/locales/tk.js +0 -105
  1573. package/node_modules/zod/v4/locales/tr.cjs +0 -135
  1574. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  1575. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  1576. package/node_modules/zod/v4/locales/tr.js +0 -108
  1577. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  1578. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  1579. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  1580. package/node_modules/zod/v4/locales/ua.js +0 -5
  1581. package/node_modules/zod/v4/locales/uk.cjs +0 -138
  1582. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  1583. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  1584. package/node_modules/zod/v4/locales/uk.js +0 -111
  1585. package/node_modules/zod/v4/locales/ur.cjs +0 -140
  1586. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  1587. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  1588. package/node_modules/zod/v4/locales/ur.js +0 -113
  1589. package/node_modules/zod/v4/locales/uz.cjs +0 -138
  1590. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  1591. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  1592. package/node_modules/zod/v4/locales/uz.js +0 -111
  1593. package/node_modules/zod/v4/locales/vi.cjs +0 -138
  1594. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  1595. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  1596. package/node_modules/zod/v4/locales/vi.js +0 -111
  1597. package/node_modules/zod/v4/locales/yo.cjs +0 -137
  1598. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  1599. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  1600. package/node_modules/zod/v4/locales/yo.js +0 -110
  1601. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -139
  1602. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  1603. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  1604. package/node_modules/zod/v4/locales/zh-CN.js +0 -112
  1605. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -137
  1606. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  1607. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  1608. package/node_modules/zod/v4/locales/zh-TW.js +0 -110
  1609. package/node_modules/zod/v4/mini/checks.cjs +0 -35
  1610. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  1611. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  1612. package/node_modules/zod/v4/mini/checks.js +0 -1
  1613. package/node_modules/zod/v4/mini/coerce.cjs +0 -52
  1614. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  1615. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  1616. package/node_modules/zod/v4/mini/coerce.js +0 -22
  1617. package/node_modules/zod/v4/mini/deep-partial.cjs +0 -39
  1618. package/node_modules/zod/v4/mini/deep-partial.d.cts +0 -14
  1619. package/node_modules/zod/v4/mini/deep-partial.d.ts +0 -14
  1620. package/node_modules/zod/v4/mini/deep-partial.js +0 -13
  1621. package/node_modules/zod/v4/mini/external.cjs +0 -74
  1622. package/node_modules/zod/v4/mini/external.d.cts +0 -16
  1623. package/node_modules/zod/v4/mini/external.d.ts +0 -16
  1624. package/node_modules/zod/v4/mini/external.js +0 -16
  1625. package/node_modules/zod/v4/mini/in-out.cjs +0 -63
  1626. package/node_modules/zod/v4/mini/in-out.d.cts +0 -8
  1627. package/node_modules/zod/v4/mini/in-out.d.ts +0 -8
  1628. package/node_modules/zod/v4/mini/in-out.js +0 -36
  1629. package/node_modules/zod/v4/mini/index.cjs +0 -32
  1630. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  1631. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  1632. package/node_modules/zod/v4/mini/index.js +0 -3
  1633. package/node_modules/zod/v4/mini/iso.cjs +0 -64
  1634. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  1635. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  1636. package/node_modules/zod/v4/mini/iso.js +0 -34
  1637. package/node_modules/zod/v4/mini/package.json +0 -7
  1638. package/node_modules/zod/v4/mini/parse.cjs +0 -18
  1639. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  1640. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  1641. package/node_modules/zod/v4/mini/parse.js +0 -1
  1642. package/node_modules/zod/v4/mini/schemas.cjs +0 -1111
  1643. package/node_modules/zod/v4/mini/schemas.d.cts +0 -475
  1644. package/node_modules/zod/v4/mini/schemas.d.ts +0 -475
  1645. package/node_modules/zod/v4/mini/schemas.js +0 -987
  1646. package/node_modules/zod/v4/package.json +0 -7
  1647. package/node_modules/zod/v4-mini/index.cjs +0 -32
  1648. package/node_modules/zod/v4-mini/index.d.cts +0 -3
  1649. package/node_modules/zod/v4-mini/index.d.ts +0 -3
  1650. package/node_modules/zod/v4-mini/index.js +0 -3
  1651. package/node_modules/zod/v4-mini/package.json +0 -7
  1652. package/personal-state.snapshot.lock.json +0 -40
  1653. package/scene-interaction-v2.snapshot.lock.json +0 -36
@@ -1,4537 +0,0 @@
1
- import { Validator } from "@seriousme/openapi-schema-validator";
2
- import { describe, expect, test } from "vitest";
3
- import * as z from "zod";
4
- // import * as zCore from "zod/v4/core";
5
-
6
- const openAPI30Validator = new Validator();
7
- /** @see https://github.com/colinhacks/zod/issues/5147 */
8
- const validateOpenAPI30Schema = async (zodJSONSchema: Record<string, unknown>): Promise<true> => {
9
- const res = await openAPI30Validator.validate({
10
- openapi: "3.0.0",
11
- info: {
12
- title: "SampleApi",
13
- description: "Sample backend service",
14
- version: "1.0.0",
15
- },
16
- components: { schemas: { test: zodJSONSchema } },
17
- paths: {},
18
- });
19
-
20
- if (!res.valid) {
21
- // `console.error` should make `vitest` trow an unhandled error printing the validation messages in consoles
22
- console.error(
23
- `OpenAPI schema is not valid against ${openAPI30Validator.version}`,
24
- JSON.stringify(res.errors, null, 2)
25
- );
26
- }
27
-
28
- return true;
29
- };
30
-
31
- describe("toJSONSchema", () => {
32
- test("primitive types", () => {
33
- expect(z.toJSONSchema(z.string())).toMatchInlineSnapshot(`
34
- {
35
- "$schema": "https://json-schema.org/draft/2020-12/schema",
36
- "type": "string",
37
- }
38
- `);
39
- expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
40
- {
41
- "$schema": "https://json-schema.org/draft/2020-12/schema",
42
- "type": "number",
43
- }
44
- `);
45
- expect(z.toJSONSchema(z.boolean())).toMatchInlineSnapshot(`
46
- {
47
- "$schema": "https://json-schema.org/draft/2020-12/schema",
48
- "type": "boolean",
49
- }
50
- `);
51
- expect(z.toJSONSchema(z.null())).toMatchInlineSnapshot(`
52
- {
53
- "$schema": "https://json-schema.org/draft/2020-12/schema",
54
- "type": "null",
55
- }
56
- `);
57
- expect(z.toJSONSchema(z.undefined(), { unrepresentable: "any" })).toMatchInlineSnapshot(`
58
- {
59
- "$schema": "https://json-schema.org/draft/2020-12/schema",
60
- }
61
- `);
62
- expect(z.toJSONSchema(z.any())).toMatchInlineSnapshot(`
63
- {
64
- "$schema": "https://json-schema.org/draft/2020-12/schema",
65
- }
66
- `);
67
- expect(z.toJSONSchema(z.unknown())).toMatchInlineSnapshot(`
68
- {
69
- "$schema": "https://json-schema.org/draft/2020-12/schema",
70
- }
71
- `);
72
- expect(z.toJSONSchema(z.never())).toMatchInlineSnapshot(`
73
- {
74
- "$schema": "https://json-schema.org/draft/2020-12/schema",
75
- "not": {},
76
- }
77
- `);
78
- expect(z.toJSONSchema(z.email())).toMatchInlineSnapshot(`
79
- {
80
- "$schema": "https://json-schema.org/draft/2020-12/schema",
81
- "format": "email",
82
- "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
83
- "type": "string",
84
- }
85
- `);
86
- expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
87
- {
88
- "$schema": "https://json-schema.org/draft/2020-12/schema",
89
- "format": "date-time",
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))$",
91
- "type": "string",
92
- }
93
- `);
94
- expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
95
- {
96
- "$schema": "https://json-schema.org/draft/2020-12/schema",
97
- "format": "date",
98
- "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])))$",
99
- "type": "string",
100
- }
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
-
113
- expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
114
- {
115
- "$schema": "https://json-schema.org/draft/2020-12/schema",
116
- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
117
- "type": "string",
118
- }
119
- `);
120
- expect(z.toJSONSchema(z.iso.time({ precision: -1 }))).toMatchInlineSnapshot(`
121
- {
122
- "$schema": "https://json-schema.org/draft/2020-12/schema",
123
- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d$",
124
- "type": "string",
125
- }
126
- `);
127
- expect(z.toJSONSchema(z.iso.time({ precision: 0 }))).toMatchInlineSnapshot(`
128
- {
129
- "$schema": "https://json-schema.org/draft/2020-12/schema",
130
- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$",
131
- "type": "string",
132
- }
133
- `);
134
- expect(z.toJSONSchema(z.iso.time({ precision: 3 }))).toMatchInlineSnapshot(`
135
- {
136
- "$schema": "https://json-schema.org/draft/2020-12/schema",
137
- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}$",
138
- "type": "string",
139
- }
140
- `);
141
- expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
142
- {
143
- "$schema": "https://json-schema.org/draft/2020-12/schema",
144
- "format": "duration",
145
- "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
146
- "type": "string",
147
- }
148
- `);
149
- expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
150
- {
151
- "$schema": "https://json-schema.org/draft/2020-12/schema",
152
- "format": "ipv4",
153
- "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
154
- "type": "string",
155
- }
156
- `);
157
- expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
158
- {
159
- "$schema": "https://json-schema.org/draft/2020-12/schema",
160
- "format": "ipv6",
161
- "pattern": "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$",
162
- "type": "string",
163
- }
164
- `);
165
- expect(z.toJSONSchema(z.mac())).toMatchInlineSnapshot(`
166
- {
167
- "$schema": "https://json-schema.org/draft/2020-12/schema",
168
- "format": "mac",
169
- "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
170
- "type": "string",
171
- }
172
- `);
173
- expect(z.toJSONSchema(z.mac({ delimiter: ":" }))).toMatchInlineSnapshot(`
174
- {
175
- "$schema": "https://json-schema.org/draft/2020-12/schema",
176
- "format": "mac",
177
- "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
178
- "type": "string",
179
- }
180
- `);
181
- expect(z.toJSONSchema(z.mac({ delimiter: "-" }))).toMatchInlineSnapshot(`
182
- {
183
- "$schema": "https://json-schema.org/draft/2020-12/schema",
184
- "format": "mac",
185
- "pattern": "^(?:[0-9A-F]{2}-){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}-){5}[0-9a-f]{2}$",
186
- "type": "string",
187
- }
188
- `);
189
- expect(z.toJSONSchema(z.uuid())).toMatchInlineSnapshot(`
190
- {
191
- "$schema": "https://json-schema.org/draft/2020-12/schema",
192
- "format": "uuid",
193
- "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
194
- "type": "string",
195
- }
196
- `);
197
- expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
198
- {
199
- "$schema": "https://json-schema.org/draft/2020-12/schema",
200
- "format": "uuid",
201
- "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
202
- "type": "string",
203
- }
204
- `);
205
- expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
206
- {
207
- "$schema": "https://json-schema.org/draft/2020-12/schema",
208
- "format": "uri",
209
- "type": "string",
210
- }
211
- `);
212
- expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
213
- {
214
- "$schema": "https://json-schema.org/draft/2020-12/schema",
215
- "contentEncoding": "base64",
216
- "format": "base64",
217
- "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
218
- "type": "string",
219
- }
220
- `);
221
- expect(z.toJSONSchema(z.cuid())).toMatchInlineSnapshot(`
222
- {
223
- "$schema": "https://json-schema.org/draft/2020-12/schema",
224
- "format": "cuid",
225
- "pattern": "^[cC][0-9a-z]{6,}$",
226
- "type": "string",
227
- }
228
- `);
229
- // expect(z.toJSONSchema(z.regex(/asdf/))).toMatchInlineSnapshot();
230
- expect(z.toJSONSchema(z.emoji())).toMatchInlineSnapshot(`
231
- {
232
- "$schema": "https://json-schema.org/draft/2020-12/schema",
233
- "format": "emoji",
234
- "pattern": "^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",
235
- "type": "string",
236
- }
237
- `);
238
- expect(z.toJSONSchema(z.nanoid())).toMatchInlineSnapshot(`
239
- {
240
- "$schema": "https://json-schema.org/draft/2020-12/schema",
241
- "format": "nanoid",
242
- "pattern": "^[a-zA-Z0-9_-]{21}$",
243
- "type": "string",
244
- }
245
- `);
246
- expect(z.toJSONSchema(z.nanoid({ length: 64 }))).toMatchInlineSnapshot(`
247
- {
248
- "$schema": "https://json-schema.org/draft/2020-12/schema",
249
- "format": "nanoid",
250
- "pattern": "^[a-zA-Z0-9_-]{64}$",
251
- "type": "string",
252
- }
253
- `);
254
- expect(z.toJSONSchema(z.cuid2())).toMatchInlineSnapshot(`
255
- {
256
- "$schema": "https://json-schema.org/draft/2020-12/schema",
257
- "format": "cuid2",
258
- "pattern": "^[0-9a-z]+$",
259
- "type": "string",
260
- }
261
- `);
262
- expect(z.toJSONSchema(z.ulid())).toMatchInlineSnapshot(`
263
- {
264
- "$schema": "https://json-schema.org/draft/2020-12/schema",
265
- "format": "ulid",
266
- "pattern": "^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$",
267
- "type": "string",
268
- }
269
- `);
270
- // expect(z.toJSONSchema(z.cidr())).toMatchInlineSnapshot();
271
- expect(z.toJSONSchema(z.number())).toMatchInlineSnapshot(`
272
- {
273
- "$schema": "https://json-schema.org/draft/2020-12/schema",
274
- "type": "number",
275
- }
276
- `);
277
- expect(z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
278
- {
279
- "$schema": "https://json-schema.org/draft/2020-12/schema",
280
- "maximum": 9007199254740991,
281
- "minimum": -9007199254740991,
282
- "type": "integer",
283
- }
284
- `);
285
- expect(z.toJSONSchema(z.int32())).toMatchInlineSnapshot(`
286
- {
287
- "$schema": "https://json-schema.org/draft/2020-12/schema",
288
- "maximum": 2147483647,
289
- "minimum": -2147483648,
290
- "type": "integer",
291
- }
292
- `);
293
- expect(z.toJSONSchema(z.float32())).toMatchInlineSnapshot(`
294
- {
295
- "$schema": "https://json-schema.org/draft/2020-12/schema",
296
- "maximum": 3.4028234663852886e+38,
297
- "minimum": -3.4028234663852886e+38,
298
- "type": "number",
299
- }
300
- `);
301
- expect(z.toJSONSchema(z.float64())).toMatchInlineSnapshot(`
302
- {
303
- "$schema": "https://json-schema.org/draft/2020-12/schema",
304
- "maximum": 1.7976931348623157e+308,
305
- "minimum": -1.7976931348623157e+308,
306
- "type": "number",
307
- }
308
- `);
309
- expect(z.toJSONSchema(z.jwt())).toMatchInlineSnapshot(`
310
- {
311
- "$schema": "https://json-schema.org/draft/2020-12/schema",
312
- "format": "jwt",
313
- "type": "string",
314
- }
315
- `);
316
- });
317
-
318
- test("unsupported schema types", () => {
319
- expect(() => z.toJSONSchema(z.bigint())).toThrow("BigInt cannot be represented in JSON Schema");
320
- expect(() => z.toJSONSchema(z.int64())).toThrow("BigInt cannot be represented in JSON Schema");
321
- expect(() => z.toJSONSchema(z.symbol())).toThrow("Symbols cannot be represented in JSON Schema");
322
- expect(() => z.toJSONSchema(z.void())).toThrow("Void cannot be represented in JSON Schema");
323
- expect(() => z.toJSONSchema(z.undefined())).toThrow("Undefined cannot be represented in JSON Schema");
324
- expect(() => z.toJSONSchema(z.date())).toThrow("Date cannot be represented in JSON Schema");
325
- expect(() => z.toJSONSchema(z.map(z.string(), z.number()))).toThrow("Map cannot be represented in JSON Schema");
326
- expect(() => z.toJSONSchema(z.set(z.string()))).toThrow("Set cannot be represented in JSON Schema");
327
- expect(() => z.toJSONSchema(z.custom(() => true))).toThrow("Custom types cannot be represented in JSON Schema");
328
-
329
- // Transform
330
- const transformSchema = z.string().transform((val) => Number.parseInt(val));
331
- expect(() => z.toJSONSchema(transformSchema)).toThrow("Transforms cannot be represented in JSON Schema");
332
-
333
- // Static catch values
334
- const staticCatchSchema = z.string().catch(() => "sup");
335
- expect(z.toJSONSchema(staticCatchSchema)).toMatchInlineSnapshot(`
336
- {
337
- "$schema": "https://json-schema.org/draft/2020-12/schema",
338
- "default": "sup",
339
- "type": "string",
340
- }
341
- `);
342
-
343
- // Dynamic catch values
344
- const dynamicCatchSchema = z.string().catch((ctx) => `${ctx.issues.length}`);
345
- expect(() => z.toJSONSchema(dynamicCatchSchema)).toThrow("Dynamic catch values are not supported in JSON Schema");
346
- expect(z.toJSONSchema(dynamicCatchSchema, { unrepresentable: "any" })).toMatchInlineSnapshot(`
347
- {
348
- "$schema": "https://json-schema.org/draft/2020-12/schema",
349
- "type": "string",
350
- }
351
- `);
352
- });
353
-
354
- test("string formats", () => {
355
- expect(z.toJSONSchema(z.string().email())).toMatchInlineSnapshot(`
356
- {
357
- "$schema": "https://json-schema.org/draft/2020-12/schema",
358
- "format": "email",
359
- "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
360
- "type": "string",
361
- }
362
- `);
363
- expect(z.toJSONSchema(z.string().uuid())).toMatchInlineSnapshot(`
364
- {
365
- "$schema": "https://json-schema.org/draft/2020-12/schema",
366
- "format": "uuid",
367
- "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
368
- "type": "string",
369
- }
370
- `);
371
- expect(z.toJSONSchema(z.iso.datetime())).toMatchInlineSnapshot(`
372
- {
373
- "$schema": "https://json-schema.org/draft/2020-12/schema",
374
- "format": "date-time",
375
- "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))$",
376
- "type": "string",
377
- }
378
- `);
379
-
380
- expect(z.toJSONSchema(z.iso.date())).toMatchInlineSnapshot(`
381
- {
382
- "$schema": "https://json-schema.org/draft/2020-12/schema",
383
- "format": "date",
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])))$",
385
- "type": "string",
386
- }
387
- `);
388
- expect(z.toJSONSchema(z.iso.time())).toMatchInlineSnapshot(`
389
- {
390
- "$schema": "https://json-schema.org/draft/2020-12/schema",
391
- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",
392
- "type": "string",
393
- }
394
- `);
395
- expect(z.toJSONSchema(z.iso.duration())).toMatchInlineSnapshot(`
396
- {
397
- "$schema": "https://json-schema.org/draft/2020-12/schema",
398
- "format": "duration",
399
- "pattern": "^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$",
400
- "type": "string",
401
- }
402
- `);
403
- // expect(z.toJSONSchema(z.string().ip())).toMatchInlineSnapshot(`
404
- // {
405
- // "pattern": /\\(\\^\\(\\?:\\(\\?:25\\[0-5\\]\\|2\\[0-4\\]\\[0-9\\]\\|1\\[0-9\\]\\[0-9\\]\\|\\[1-9\\]\\[0-9\\]\\|\\[0-9\\]\\)\\\\\\.\\)\\{3\\}\\(\\?:25\\[0-5\\]\\|2\\[0-4\\]\\[0-9\\]\\|1\\[0-9\\]\\[0-9\\]\\|\\[1-9\\]\\[0-9\\]\\|\\[0-9\\]\\)\\$\\)\\|\\(\\^\\(\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{7\\}\\|::\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,6\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{1\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,5\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{2\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,4\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{3\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,3\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{4\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,2\\}\\|\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{5\\}:\\(\\[a-fA-F0-9\\]\\{1,4\\}:\\)\\{0,1\\}\\)\\(\\[a-fA-F0-9\\]\\{1,4\\}\\|\\(\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\\\\\.\\)\\{3\\}\\(\\(25\\[0-5\\]\\)\\|\\(2\\[0-4\\]\\[0-9\\]\\)\\|\\(1\\[0-9\\]\\{2\\}\\)\\|\\(\\[0-9\\]\\{1,2\\}\\)\\)\\)\\$\\)/,
406
- // "type": "string",
407
- // }
408
- // `);
409
- expect(z.toJSONSchema(z.ipv4())).toMatchInlineSnapshot(`
410
- {
411
- "$schema": "https://json-schema.org/draft/2020-12/schema",
412
- "format": "ipv4",
413
- "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
414
- "type": "string",
415
- }
416
- `);
417
-
418
- expect(z.toJSONSchema(z.ipv6())).toMatchInlineSnapshot(`
419
- {
420
- "$schema": "https://json-schema.org/draft/2020-12/schema",
421
- "format": "ipv6",
422
- "pattern": "^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$",
423
- "type": "string",
424
- }
425
- `);
426
-
427
- expect(z.toJSONSchema(z.mac())).toMatchInlineSnapshot(`
428
- {
429
- "$schema": "https://json-schema.org/draft/2020-12/schema",
430
- "format": "mac",
431
- "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
432
- "type": "string",
433
- }
434
- `);
435
- expect(z.toJSONSchema(z.mac({ delimiter: ":" }))).toMatchInlineSnapshot(`
436
- {
437
- "$schema": "https://json-schema.org/draft/2020-12/schema",
438
- "format": "mac",
439
- "pattern": "^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$",
440
- "type": "string",
441
- }
442
- `);
443
- expect(z.toJSONSchema(z.mac({ delimiter: "-" }))).toMatchInlineSnapshot(`
444
- {
445
- "$schema": "https://json-schema.org/draft/2020-12/schema",
446
- "format": "mac",
447
- "pattern": "^(?:[0-9A-F]{2}-){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}-){5}[0-9a-f]{2}$",
448
- "type": "string",
449
- }
450
- `);
451
-
452
- expect(z.toJSONSchema(z.base64())).toMatchInlineSnapshot(`
453
- {
454
- "$schema": "https://json-schema.org/draft/2020-12/schema",
455
- "contentEncoding": "base64",
456
- "format": "base64",
457
- "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
458
- "type": "string",
459
- }
460
- `);
461
- expect(z.toJSONSchema(z.url())).toMatchInlineSnapshot(`
462
- {
463
- "$schema": "https://json-schema.org/draft/2020-12/schema",
464
- "format": "uri",
465
- "type": "string",
466
- }
467
- `);
468
- expect(z.toJSONSchema(z.guid())).toMatchInlineSnapshot(`
469
- {
470
- "$schema": "https://json-schema.org/draft/2020-12/schema",
471
- "format": "uuid",
472
- "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
473
- "type": "string",
474
- }
475
- `);
476
- expect(z.toJSONSchema(z.string().regex(/asdf/))).toMatchInlineSnapshot(`
477
- {
478
- "$schema": "https://json-schema.org/draft/2020-12/schema",
479
- "pattern": "asdf",
480
- "type": "string",
481
- }
482
- `);
483
- });
484
-
485
- test("string patterns", () => {
486
- expect(
487
- z.toJSONSchema(
488
- z
489
- .string()
490
- .startsWith("hello")
491
- .includes("cruel")
492
- .includes("dark", { position: 10 })
493
- .endsWith("world")
494
- .regex(/stuff/)
495
- )
496
- ).toMatchInlineSnapshot(`
497
- {
498
- "$schema": "https://json-schema.org/draft/2020-12/schema",
499
- "allOf": [
500
- {
501
- "pattern": "^hello.*",
502
- },
503
- {
504
- "pattern": "cruel",
505
- },
506
- {
507
- "pattern": "^.{10,}dark",
508
- },
509
- {
510
- "pattern": ".*world$",
511
- },
512
- {
513
- "pattern": "stuff",
514
- },
515
- ],
516
- "type": "string",
517
- }
518
- `);
519
-
520
- expect(
521
- z.toJSONSchema(
522
- z
523
- .string()
524
- .startsWith("hello")
525
- .includes("cruel")
526
- .includes("dark", { position: 10 })
527
- .endsWith("world")
528
- .regex(/stuff/),
529
- {
530
- target: "draft-7",
531
- }
532
- )
533
- ).toMatchInlineSnapshot(`
534
- {
535
- "$schema": "http://json-schema.org/draft-07/schema#",
536
- "allOf": [
537
- {
538
- "pattern": "^hello.*",
539
- "type": "string",
540
- },
541
- {
542
- "pattern": "cruel",
543
- "type": "string",
544
- },
545
- {
546
- "pattern": "^.{10,}dark",
547
- "type": "string",
548
- },
549
- {
550
- "pattern": ".*world$",
551
- "type": "string",
552
- },
553
- {
554
- "pattern": "stuff",
555
- "type": "string",
556
- },
557
- ],
558
- "type": "string",
559
- }
560
- `);
561
- });
562
-
563
- test("includes with position emits a pattern matching runtime semantics", () => {
564
- // String.prototype.includes(sub, position) matches `sub` at `position` OR
565
- // LATER, so the JSON Schema pattern must allow >= position leading chars.
566
- const schema = z.string().includes("foo", { position: 2 });
567
- const json = z.toJSONSchema(schema) as { pattern?: string };
568
- expect(json.pattern).toBe("^.{2,}foo");
569
-
570
- const re = new RegExp(json.pattern!);
571
- for (const input of ["xxfoo", "xxxfoo", "xfoo", "ab"]) {
572
- expect(re.test(input)).toBe(schema.safeParse(input).success);
573
- }
574
- });
575
-
576
- test("number constraints", () => {
577
- expect(z.toJSONSchema(z.number().min(5).max(10))).toMatchInlineSnapshot(
578
- `
579
- {
580
- "$schema": "https://json-schema.org/draft/2020-12/schema",
581
- "maximum": 10,
582
- "minimum": 5,
583
- "type": "number",
584
- }
585
- `
586
- );
587
-
588
- expect(z.toJSONSchema(z.number().gt(5).gt(10))).toMatchInlineSnapshot(`
589
- {
590
- "$schema": "https://json-schema.org/draft/2020-12/schema",
591
- "exclusiveMinimum": 10,
592
- "type": "number",
593
- }
594
- `);
595
-
596
- expect(z.toJSONSchema(z.number().gt(5).gte(10))).toMatchInlineSnapshot(`
597
- {
598
- "$schema": "https://json-schema.org/draft/2020-12/schema",
599
- "minimum": 10,
600
- "type": "number",
601
- }
602
- `);
603
-
604
- expect(z.toJSONSchema(z.number().lt(5).lt(3))).toMatchInlineSnapshot(`
605
- {
606
- "$schema": "https://json-schema.org/draft/2020-12/schema",
607
- "exclusiveMaximum": 3,
608
- "type": "number",
609
- }
610
- `);
611
-
612
- expect(z.toJSONSchema(z.number().lt(5).lt(3).lte(2))).toMatchInlineSnapshot(`
613
- {
614
- "$schema": "https://json-schema.org/draft/2020-12/schema",
615
- "maximum": 2,
616
- "type": "number",
617
- }
618
- `);
619
-
620
- expect(z.toJSONSchema(z.number().lt(5).lte(3))).toMatchInlineSnapshot(`
621
- {
622
- "$schema": "https://json-schema.org/draft/2020-12/schema",
623
- "maximum": 3,
624
- "type": "number",
625
- }
626
- `);
627
-
628
- expect(z.toJSONSchema(z.number().gt(5).lt(10))).toMatchInlineSnapshot(`
629
- {
630
- "$schema": "https://json-schema.org/draft/2020-12/schema",
631
- "exclusiveMaximum": 10,
632
- "exclusiveMinimum": 5,
633
- "type": "number",
634
- }
635
- `);
636
- expect(z.toJSONSchema(z.number().gte(5).lte(10))).toMatchInlineSnapshot(`
637
- {
638
- "$schema": "https://json-schema.org/draft/2020-12/schema",
639
- "maximum": 10,
640
- "minimum": 5,
641
- "type": "number",
642
- }
643
- `);
644
- expect(z.toJSONSchema(z.number().positive())).toMatchInlineSnapshot(`
645
- {
646
- "$schema": "https://json-schema.org/draft/2020-12/schema",
647
- "exclusiveMinimum": 0,
648
- "type": "number",
649
- }
650
- `);
651
- expect(z.toJSONSchema(z.number().negative())).toMatchInlineSnapshot(`
652
- {
653
- "$schema": "https://json-schema.org/draft/2020-12/schema",
654
- "exclusiveMaximum": 0,
655
- "type": "number",
656
- }
657
- `);
658
- expect(z.toJSONSchema(z.number().nonpositive())).toMatchInlineSnapshot(`
659
- {
660
- "$schema": "https://json-schema.org/draft/2020-12/schema",
661
- "maximum": 0,
662
- "type": "number",
663
- }
664
- `);
665
- expect(z.toJSONSchema(z.number().nonnegative())).toMatchInlineSnapshot(`
666
- {
667
- "$schema": "https://json-schema.org/draft/2020-12/schema",
668
- "minimum": 0,
669
- "type": "number",
670
- }
671
- `);
672
- });
673
-
674
- test("number constraints draft-4", () => {
675
- expect(z.toJSONSchema(z.number().gt(5).lt(10), { target: "draft-4" })).toMatchInlineSnapshot(`
676
- {
677
- "$schema": "http://json-schema.org/draft-04/schema#",
678
- "exclusiveMaximum": true,
679
- "exclusiveMinimum": true,
680
- "maximum": 10,
681
- "minimum": 5,
682
- "type": "number",
683
- }
684
- `);
685
- });
686
-
687
- test("number constraints intersection draft-04", () => {
688
- // When both minimum (from .int()) and exclusiveMinimum (from .positive()) exist, the more restrictive constraint should be used
689
- expect(z.toJSONSchema(z.number().int().positive().lte(65535), { target: "draft-04" })).toMatchInlineSnapshot(`
690
- {
691
- "$schema": "http://json-schema.org/draft-04/schema#",
692
- "exclusiveMinimum": true,
693
- "maximum": 65535,
694
- "minimum": 0,
695
- "type": "integer",
696
- }
697
- `);
698
- // Same for openapi-3.0
699
- expect(z.toJSONSchema(z.number().int().positive().lte(65535), { target: "openapi-3.0" })).toMatchInlineSnapshot(`
700
- {
701
- "exclusiveMinimum": true,
702
- "maximum": 65535,
703
- "minimum": 0,
704
- "type": "integer",
705
- }
706
- `);
707
- // When inclusive minimum is more restrictive than exclusive minimum
708
- expect(z.toJSONSchema(z.number().gt(3).gte(10), { target: "draft-04" })).toMatchInlineSnapshot(`
709
- {
710
- "$schema": "http://json-schema.org/draft-04/schema#",
711
- "minimum": 10,
712
- "type": "number",
713
- }
714
- `);
715
- // Same logic for maximum constraints
716
- expect(z.toJSONSchema(z.number().int().negative(), { target: "draft-04" })).toMatchInlineSnapshot(`
717
- {
718
- "$schema": "http://json-schema.org/draft-04/schema#",
719
- "exclusiveMaximum": true,
720
- "maximum": 0,
721
- "minimum": -9007199254740991,
722
- "type": "integer",
723
- }
724
- `);
725
- });
726
-
727
- test("target normalization draft-04 and draft-07", () => {
728
- // Test that both old (draft-4, draft-7) and new (draft-04, draft-07) target formats work
729
-
730
- // Test draft-04 / draft-4
731
- expect(z.toJSONSchema(z.number().gt(5), { target: "draft-04" })).toMatchInlineSnapshot(`
732
- {
733
- "$schema": "http://json-schema.org/draft-04/schema#",
734
- "exclusiveMinimum": true,
735
- "minimum": 5,
736
- "type": "number",
737
- }
738
- `);
739
- expect(z.toJSONSchema(z.number().gt(5), { target: "draft-4" })).toMatchInlineSnapshot(`
740
- {
741
- "$schema": "http://json-schema.org/draft-04/schema#",
742
- "exclusiveMinimum": true,
743
- "minimum": 5,
744
- "type": "number",
745
- }
746
- `);
747
- // Test draft-07 / draft-7
748
- expect(z.toJSONSchema(z.number().gt(5), { target: "draft-07" })).toMatchInlineSnapshot(`
749
- {
750
- "$schema": "http://json-schema.org/draft-07/schema#",
751
- "exclusiveMinimum": 5,
752
- "type": "number",
753
- }
754
- `);
755
- expect(z.toJSONSchema(z.number().gt(5), { target: "draft-7" })).toMatchInlineSnapshot(`
756
- {
757
- "$schema": "http://json-schema.org/draft-07/schema#",
758
- "exclusiveMinimum": 5,
759
- "type": "number",
760
- }
761
- `);
762
- });
763
-
764
- test("nullable openapi-3.0", () => {
765
- const schema = z.string().nullable();
766
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
767
- validateOpenAPI30Schema(jsonSchema);
768
- expect(jsonSchema).toMatchInlineSnapshot(`
769
- {
770
- "nullable": true,
771
- "type": "string",
772
- }
773
- `);
774
- });
775
-
776
- test("union with null openapi-3.0", () => {
777
- const schema = z.union([z.string(), z.null()]);
778
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
779
- validateOpenAPI30Schema(jsonSchema);
780
- expect(jsonSchema).toMatchInlineSnapshot(`
781
- {
782
- "anyOf": [
783
- {
784
- "type": "string",
785
- },
786
- {
787
- "enum": [
788
- null,
789
- ],
790
- "nullable": true,
791
- "type": "string",
792
- },
793
- ],
794
- }
795
- `);
796
- });
797
-
798
- test("number with exclusive min-max openapi-3.0", () => {
799
- const schema = z.number().lt(100).gt(1);
800
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
801
- validateOpenAPI30Schema(jsonSchema);
802
- expect(jsonSchema).toMatchInlineSnapshot(`
803
- {
804
- "exclusiveMaximum": true,
805
- "exclusiveMinimum": true,
806
- "maximum": 100,
807
- "minimum": 1,
808
- "type": "number",
809
- }
810
- `);
811
- });
812
-
813
- test("arrays", () => {
814
- expect(z.toJSONSchema(z.array(z.string()))).toMatchInlineSnapshot(`
815
- {
816
- "$schema": "https://json-schema.org/draft/2020-12/schema",
817
- "items": {
818
- "type": "string",
819
- },
820
- "type": "array",
821
- }
822
- `);
823
- });
824
-
825
- test("unions", () => {
826
- const schema = z.union([z.string(), z.number()]);
827
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
828
- {
829
- "$schema": "https://json-schema.org/draft/2020-12/schema",
830
- "type": [
831
- "string",
832
- "number",
833
- ],
834
- }
835
- `);
836
- });
837
-
838
- test("nullable compacts to a type array", () => {
839
- expect(z.toJSONSchema(z.string().nullable())).toMatchInlineSnapshot(`
840
- {
841
- "$schema": "https://json-schema.org/draft/2020-12/schema",
842
- "type": [
843
- "string",
844
- "null",
845
- ],
846
- }
847
- `);
848
-
849
- // a nested union folds into the outer type array rather than leaving a mixed shape
850
- expect(z.toJSONSchema(z.union([z.string(), z.number()]).nullable())).toMatchInlineSnapshot(`
851
- {
852
- "$schema": "https://json-schema.org/draft/2020-12/schema",
853
- "type": [
854
- "string",
855
- "number",
856
- "null",
857
- ],
858
- }
859
- `);
860
-
861
- // the null branch is bare but the object branch is not, so this stays an anyOf
862
- expect(z.toJSONSchema(z.object({ a: z.string() }).nullable())).toMatchInlineSnapshot(`
863
- {
864
- "$schema": "https://json-schema.org/draft/2020-12/schema",
865
- "anyOf": [
866
- {
867
- "additionalProperties": false,
868
- "properties": {
869
- "a": {
870
- "type": "string",
871
- },
872
- },
873
- "required": [
874
- "a",
875
- ],
876
- "type": "object",
877
- },
878
- {
879
- "type": "null",
880
- },
881
- ],
882
- }
883
- `);
884
- });
885
-
886
- test("duplicate branches dedupe, single branch stays a bare type", () => {
887
- // a `type` array must have unique members, so two branches that erase to the same bare type collapse
888
- const refined = z.union([z.string().refine((s) => s.length > 2), z.string().refine((s) => s.length < 9)]);
889
- expect(z.toJSONSchema(refined)).toMatchInlineSnapshot(`
890
- {
891
- "$schema": "https://json-schema.org/draft/2020-12/schema",
892
- "type": "string",
893
- }
894
- `);
895
- expect(z.toJSONSchema(z.union([z.string()]))).toMatchInlineSnapshot(`
896
- {
897
- "$schema": "https://json-schema.org/draft/2020-12/schema",
898
- "type": "string",
899
- }
900
- `);
901
- });
902
-
903
- test("compaction runs after overrides and ref extraction", () => {
904
- // an override decorates the string branch, so it is no longer a bare type and must survive in anyOf
905
- const decorated = z.toJSONSchema(z.union([z.string(), z.number()]), {
906
- override(ctx) {
907
- if (ctx.zodSchema._zod.def.type === "string") ctx.jsonSchema.whatever = "sup";
908
- },
909
- });
910
- expect(decorated).toMatchInlineSnapshot(`
911
- {
912
- "$schema": "https://json-schema.org/draft/2020-12/schema",
913
- "anyOf": [
914
- {
915
- "type": "string",
916
- "whatever": "sup",
917
- },
918
- {
919
- "type": "number",
920
- },
921
- ],
922
- }
923
- `);
924
-
925
- // a branch extracted into $defs is a $ref, not a bare type, so `reused` is not silently bypassed
926
- const shared = z.string();
927
- expect(
928
- z.toJSONSchema(z.object({ a: shared, b: z.union([shared, z.null()]) }), { reused: "ref" })
929
- ).toMatchInlineSnapshot(`
930
- {
931
- "$defs": {
932
- "__schema0": {
933
- "type": "string",
934
- },
935
- },
936
- "$schema": "https://json-schema.org/draft/2020-12/schema",
937
- "additionalProperties": false,
938
- "properties": {
939
- "a": {
940
- "$ref": "#/$defs/__schema0",
941
- },
942
- "b": {
943
- "anyOf": [
944
- {
945
- "$ref": "#/$defs/__schema0",
946
- },
947
- {
948
- "type": "null",
949
- },
950
- ],
951
- },
952
- },
953
- "required": [
954
- "a",
955
- "b",
956
- ],
957
- "type": "object",
958
- }
959
- `);
960
- });
961
-
962
- test("openapi-3.0 keeps a single-string type", () => {
963
- // OpenAPI 3.0 has no type arrays; nullability is spelled with `nullable`
964
- expect(z.toJSONSchema(z.string().nullable(), { target: "openapi-3.0" })).toMatchInlineSnapshot(`
965
- {
966
- "nullable": true,
967
- "type": "string",
968
- }
969
- `);
970
- });
971
-
972
- test("union with constrained branch is not compacted", () => {
973
- const schema = z.union([z.string().min(1), z.number()]);
974
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
975
- {
976
- "$schema": "https://json-schema.org/draft/2020-12/schema",
977
- "anyOf": [
978
- {
979
- "minLength": 1,
980
- "type": "string",
981
- },
982
- {
983
- "type": "number",
984
- },
985
- ],
986
- }
987
- `);
988
- });
989
-
990
- test("union of literals is not compacted", () => {
991
- const schema = z.union([z.literal("a"), z.literal("b")]);
992
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
993
- {
994
- "$schema": "https://json-schema.org/draft/2020-12/schema",
995
- "anyOf": [
996
- {
997
- "const": "a",
998
- "type": "string",
999
- },
1000
- {
1001
- "const": "b",
1002
- "type": "string",
1003
- },
1004
- ],
1005
- }
1006
- `);
1007
- });
1008
-
1009
- test("discriminated unions", () => {
1010
- const schema = z.discriminatedUnion("type", [
1011
- z.object({ type: z.literal("success"), data: z.string() }),
1012
- z.object({ type: z.literal("error"), message: z.string() }),
1013
- ]);
1014
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1015
- {
1016
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1017
- "oneOf": [
1018
- {
1019
- "additionalProperties": false,
1020
- "properties": {
1021
- "data": {
1022
- "type": "string",
1023
- },
1024
- "type": {
1025
- "const": "success",
1026
- "type": "string",
1027
- },
1028
- },
1029
- "required": [
1030
- "type",
1031
- "data",
1032
- ],
1033
- "type": "object",
1034
- },
1035
- {
1036
- "additionalProperties": false,
1037
- "properties": {
1038
- "message": {
1039
- "type": "string",
1040
- },
1041
- "type": {
1042
- "const": "error",
1043
- "type": "string",
1044
- },
1045
- },
1046
- "required": [
1047
- "type",
1048
- "message",
1049
- ],
1050
- "type": "object",
1051
- },
1052
- ],
1053
- }
1054
- `);
1055
- });
1056
-
1057
- test("intersections", () => {
1058
- const schema = z.intersection(z.object({ name: z.string() }), z.object({ age: z.number() }));
1059
-
1060
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1061
- {
1062
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1063
- "additionalProperties": false,
1064
- "properties": {
1065
- "age": {
1066
- "type": "number",
1067
- },
1068
- "name": {
1069
- "type": "string",
1070
- },
1071
- },
1072
- "required": [
1073
- "name",
1074
- "age",
1075
- ],
1076
- "type": "object",
1077
- }
1078
- `);
1079
- });
1080
-
1081
- test("record", () => {
1082
- const schema = z.record(z.string(), z.boolean());
1083
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1084
- {
1085
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1086
- "additionalProperties": {
1087
- "type": "boolean",
1088
- },
1089
- "propertyNames": {
1090
- "type": "string",
1091
- },
1092
- "type": "object",
1093
- }
1094
- `);
1095
- });
1096
-
1097
- test("record openapi-3.0", () => {
1098
- const schema = z.record(z.string(), z.boolean());
1099
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1100
- validateOpenAPI30Schema(jsonSchema);
1101
- expect(jsonSchema).toMatchInlineSnapshot(`
1102
- {
1103
- "additionalProperties": {
1104
- "type": "boolean",
1105
- },
1106
- "type": "object",
1107
- }
1108
- `);
1109
- });
1110
-
1111
- test("record with enum keys adds required", () => {
1112
- const schema = z.record(z.enum(["key1", "key2"]), z.number());
1113
-
1114
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1115
- {
1116
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1117
- "additionalProperties": {
1118
- "type": "number",
1119
- },
1120
- "propertyNames": {
1121
- "enum": [
1122
- "key1",
1123
- "key2",
1124
- ],
1125
- "type": "string",
1126
- },
1127
- "required": [
1128
- "key1",
1129
- "key2",
1130
- ],
1131
- "type": "object",
1132
- }
1133
- `);
1134
- });
1135
-
1136
- test("record with enum keys drops required for an optional-in value under io: input", () => {
1137
- const schema = z.record(z.enum(["key1", "key2"]), z.number().default(0));
1138
-
1139
- expect(z.toJSONSchema(schema, { io: "input" }).required).toBeUndefined();
1140
- expect(z.toJSONSchema(schema).required).toEqual(["key1", "key2"]);
1141
- expect(z.toJSONSchema(z.record(z.enum(["key1", "key2"]), z.number()), { io: "input" }).required).toEqual([
1142
- "key1",
1143
- "key2",
1144
- ]);
1145
- // A caught value keeps required, matching the input type and z.object().
1146
- expect(z.toJSONSchema(z.record(z.enum(["key1", "key2"]), z.number().catch(0)), { io: "input" }).required).toEqual([
1147
- "key1",
1148
- "key2",
1149
- ]);
1150
- });
1151
-
1152
- test("record stringifies numeric enum keys for propertyNames and required", () => {
1153
- enum NumberEnum {
1154
- Zero = 0,
1155
- One = 1,
1156
- }
1157
- const schema = z.record(z.enum(NumberEnum), z.string());
1158
-
1159
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1160
- {
1161
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1162
- "additionalProperties": {
1163
- "type": "string",
1164
- },
1165
- "propertyNames": {
1166
- "enum": [
1167
- "0",
1168
- "1",
1169
- ],
1170
- "type": "string",
1171
- },
1172
- "required": [
1173
- "0",
1174
- "1",
1175
- ],
1176
- "type": "object",
1177
- }
1178
- `);
1179
- });
1180
-
1181
- test("record with a numeric key emits propertyNames over the numeric-string form", () => {
1182
- expect(z.toJSONSchema(z.record(z.number(), z.boolean())).propertyNames).toEqual({
1183
- type: "string",
1184
- pattern: "^-?\\d+(?:\\.\\d+)?$",
1185
- });
1186
- // range checks can't apply to a key, so only the integer shape survives
1187
- expect(z.toJSONSchema(z.record(z.int32(), z.boolean())).propertyNames).toEqual({
1188
- type: "string",
1189
- pattern: "^-?\\d+$",
1190
- });
1191
- expect(z.toJSONSchema(z.record(z.literal([1, 2]), z.boolean()))).toMatchObject({
1192
- propertyNames: { type: "string", enum: ["1", "2"] },
1193
- required: ["1", "2"],
1194
- });
1195
- expect(z.toJSONSchema(z.record(z.literal(1), z.boolean())).propertyNames).toEqual({
1196
- type: "string",
1197
- const: "1",
1198
- });
1199
- });
1200
-
1201
- test("record key rewrite reaches through wrappers and union branches", () => {
1202
- const numericString = { type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" };
1203
- // a wrapper only carries its inner type once the refs are flattened, so this is decided after the record itself is emitted
1204
- expect(
1205
- z.toJSONSchema(
1206
- z.record(
1207
- z.lazy(() => z.number()),
1208
- z.boolean()
1209
- )
1210
- ).propertyNames
1211
- ).toEqual(numericString);
1212
- expect(z.toJSONSchema(z.record(z.number().pipe(z.number()), z.boolean())).propertyNames).toEqual(numericString);
1213
- expect(z.toJSONSchema(z.record(z.number().readonly(), z.boolean())).propertyNames).toMatchObject(numericString);
1214
- expect(z.toJSONSchema(z.record(z.union([z.literal("Tuna"), z.literal(21)]), z.string()))).toMatchObject({
1215
- propertyNames: {
1216
- anyOf: [
1217
- { type: "string", const: "Tuna" },
1218
- { type: "string", const: "21" },
1219
- ],
1220
- },
1221
- required: ["Tuna", "21"],
1222
- });
1223
- });
1224
-
1225
- test("record with a numeric key inlines an extracted key, and leaves a string one referenced", () => {
1226
- expect(z.toJSONSchema(z.record(z.number().meta({ id: "Num" }), z.boolean())).propertyNames).toEqual({
1227
- type: "string",
1228
- pattern: "^-?\\d+(?:\\.\\d+)?$",
1229
- });
1230
- expect(z.toJSONSchema(z.record(z.string().meta({ id: "Str" }), z.boolean())).propertyNames).toEqual({
1231
- $ref: "#/$defs/Str",
1232
- });
1233
- // the value position still wants the number form, so the two cannot share one def
1234
- const key = z.number().meta({ id: "Shared" });
1235
- expect(z.toJSONSchema(z.object({ a: key, b: z.record(key, z.string()) }))).toMatchObject({
1236
- properties: { a: { $ref: "#/$defs/Shared" }, b: { propertyNames: { type: "string" } } },
1237
- $defs: { Shared: { type: "number" } },
1238
- });
1239
- });
1240
-
1241
- test("record key rewrite reaches a wrapped record", () => {
1242
- // the flatten copies a record's properties onto its wrapper by reference, so the rewrite has to find every copy
1243
- expect(z.toJSONSchema(z.record(z.number(), z.boolean()).optional()).propertyNames).toEqual({
1244
- type: "string",
1245
- pattern: "^-?\\d+(?:\\.\\d+)?$",
1246
- });
1247
- expect(z.toJSONSchema(z.object({ a: z.record(z.literal([1, 2]), z.boolean()).optional() }))).toMatchObject({
1248
- properties: { a: { propertyNames: { type: "string", enum: ["1", "2"] }, required: ["1", "2"] } },
1249
- });
1250
- });
1251
-
1252
- test("record with a recursive key converts without looping", () => {
1253
- const numeric: any = z.lazy(() => z.union([z.number(), numeric]));
1254
- expect(z.toJSONSchema(z.record(numeric, z.boolean())).propertyNames).toMatchObject({
1255
- anyOf: [{ type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" }, { $ref: "#/$defs/__schema0" }],
1256
- });
1257
- // a key with nothing to re-express keeps the reference it had
1258
- const stringy: any = z.lazy(() => z.union([z.string(), stringy]));
1259
- expect(z.toJSONSchema(z.record(stringy, z.boolean())).propertyNames).toEqual({ $ref: "#/$defs/__schema0" });
1260
- expect(
1261
- z.toJSONSchema(z.record(z.union([z.literal("a"), z.literal("b")]).meta({ id: "Keys" }), z.boolean()))
1262
- .propertyNames
1263
- ).toEqual({ $ref: "#/$defs/Keys" });
1264
- });
1265
-
1266
- test("record with a heterogeneous key stringifies only its numeric members", () => {
1267
- // a mixed key carries no `type`, so the numeric members are caught by value rather than by type
1268
- expect(z.toJSONSchema(z.record(z.literal(["a", 1]), z.boolean()))).toMatchObject({
1269
- propertyNames: { enum: ["a", "1"] },
1270
- required: ["a", "1"],
1271
- });
1272
- // a member no key can spell is left as it was, since the parser only ever retries a key as a number
1273
- expect(z.toJSONSchema(z.record(z.literal(["a", true]) as any, z.boolean())).propertyNames).toEqual({
1274
- enum: ["a", true],
1275
- });
1276
- });
1277
-
1278
- test("record stringifies required for every target", () => {
1279
- const schema = z.record(z.literal([1, 2]), z.boolean());
1280
- for (const target of ["draft-2020-12", "draft-7", "draft-4", "openapi-3.0"] as const) {
1281
- expect(z.toJSONSchema(schema, { target }).required).toEqual(["1", "2"]);
1282
- }
1283
- });
1284
-
1285
- test("strict record with regex key uses propertyNames", () => {
1286
- const schema = z.record(z.string().regex(/^label:[a-z]{2}$/), z.string());
1287
-
1288
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1289
- {
1290
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1291
- "additionalProperties": {
1292
- "type": "string",
1293
- },
1294
- "propertyNames": {
1295
- "pattern": "^label:[a-z]{2}$",
1296
- "type": "string",
1297
- },
1298
- "type": "object",
1299
- }
1300
- `);
1301
- });
1302
-
1303
- test("looseRecord with regex key uses patternProperties", () => {
1304
- const schema = z.looseRecord(z.string().regex(/^label:[a-z]{2}$/), z.string());
1305
-
1306
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1307
- {
1308
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1309
- "patternProperties": {
1310
- "^label:[a-z]{2}$": {
1311
- "type": "string",
1312
- },
1313
- },
1314
- "type": "object",
1315
- }
1316
- `);
1317
- });
1318
-
1319
- test("looseRecord with multiple regex patterns uses patternProperties", () => {
1320
- const schema = z.looseRecord(
1321
- z
1322
- .string()
1323
- .regex(/^prefix_/)
1324
- .regex(/_suffix$/),
1325
- z.number()
1326
- );
1327
-
1328
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1329
- {
1330
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1331
- "patternProperties": {
1332
- "^prefix_": {
1333
- "type": "number",
1334
- },
1335
- "_suffix$": {
1336
- "type": "number",
1337
- },
1338
- },
1339
- "type": "object",
1340
- }
1341
- `);
1342
- });
1343
-
1344
- test("looseRecord without regex key uses propertyNames", () => {
1345
- // looseRecord with plain string key should still use propertyNames
1346
- const schema = z.looseRecord(z.string(), z.boolean());
1347
-
1348
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1349
- {
1350
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1351
- "additionalProperties": {
1352
- "type": "boolean",
1353
- },
1354
- "propertyNames": {
1355
- "type": "string",
1356
- },
1357
- "type": "object",
1358
- }
1359
- `);
1360
- });
1361
-
1362
- test("intersection of object with looseRecord uses patternProperties", () => {
1363
- const zLabeled = z.object({ label: z.string() });
1364
- const zLocalizedLabeled = z.looseRecord(z.string().regex(/^label:[a-z]{2}$/), z.string());
1365
- const schema = zLabeled.and(zLocalizedLabeled);
1366
-
1367
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1368
- {
1369
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1370
- "allOf": [
1371
- {
1372
- "additionalProperties": false,
1373
- "properties": {
1374
- "label": {
1375
- "type": "string",
1376
- },
1377
- },
1378
- "required": [
1379
- "label",
1380
- ],
1381
- "type": "object",
1382
- },
1383
- {
1384
- "patternProperties": {
1385
- "^label:[a-z]{2}$": {
1386
- "type": "string",
1387
- },
1388
- },
1389
- "type": "object",
1390
- },
1391
- ],
1392
- }
1393
- `);
1394
- });
1395
-
1396
- test("tuple", () => {
1397
- const schema = z.tuple([z.string(), z.number()]);
1398
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1399
- {
1400
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1401
- "items": false,
1402
- "maxItems": 2,
1403
- "minItems": 2,
1404
- "prefixItems": [
1405
- {
1406
- "type": "string",
1407
- },
1408
- {
1409
- "type": "number",
1410
- },
1411
- ],
1412
- "type": "array",
1413
- }
1414
- `);
1415
- });
1416
-
1417
- test("tuple with rest", () => {
1418
- const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
1419
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1420
- {
1421
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1422
- "items": {
1423
- "type": "boolean",
1424
- },
1425
- "minItems": 2,
1426
- "prefixItems": [
1427
- {
1428
- "type": "string",
1429
- },
1430
- {
1431
- "type": "number",
1432
- },
1433
- ],
1434
- "type": "array",
1435
- }
1436
- `);
1437
- });
1438
-
1439
- test("tuple openapi-3.0", () => {
1440
- const schema = z.tuple([z.string(), z.number()]);
1441
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1442
- validateOpenAPI30Schema(jsonSchema);
1443
- expect(jsonSchema).toMatchInlineSnapshot(`
1444
- {
1445
- "items": {
1446
- "anyOf": [
1447
- {
1448
- "type": "string",
1449
- },
1450
- {
1451
- "type": "number",
1452
- },
1453
- ],
1454
- },
1455
- "maxItems": 2,
1456
- "minItems": 2,
1457
- "type": "array",
1458
- }
1459
- `);
1460
- });
1461
-
1462
- test("tuple with rest openapi-3.0", () => {
1463
- const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
1464
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1465
- validateOpenAPI30Schema(jsonSchema);
1466
- expect(jsonSchema).toMatchInlineSnapshot(`
1467
- {
1468
- "items": {
1469
- "anyOf": [
1470
- {
1471
- "type": "string",
1472
- },
1473
- {
1474
- "type": "number",
1475
- },
1476
- {
1477
- "type": "boolean",
1478
- },
1479
- ],
1480
- },
1481
- "minItems": 2,
1482
- "type": "array",
1483
- }
1484
- `);
1485
- });
1486
-
1487
- test("tuple with null openapi-3.0", () => {
1488
- const schema = z.tuple([z.string(), z.number(), z.null()]);
1489
- const jsonSchema = z.toJSONSchema(schema, { target: "openapi-3.0" });
1490
- validateOpenAPI30Schema(jsonSchema);
1491
- expect(jsonSchema).toMatchInlineSnapshot(`
1492
- {
1493
- "items": {
1494
- "anyOf": [
1495
- {
1496
- "type": "string",
1497
- },
1498
- {
1499
- "type": "number",
1500
- },
1501
- {
1502
- "enum": [
1503
- null,
1504
- ],
1505
- "nullable": true,
1506
- "type": "string",
1507
- },
1508
- ],
1509
- },
1510
- "maxItems": 3,
1511
- "minItems": 3,
1512
- "type": "array",
1513
- }
1514
- `);
1515
- });
1516
-
1517
- test("tuple draft-7", () => {
1518
- const schema = z.tuple([z.string(), z.number()]);
1519
- expect(z.toJSONSchema(schema, { target: "draft-7", io: "input" })).toMatchInlineSnapshot(`
1520
- {
1521
- "$schema": "http://json-schema.org/draft-07/schema#",
1522
- "additionalItems": false,
1523
- "items": [
1524
- {
1525
- "type": "string",
1526
- },
1527
- {
1528
- "type": "number",
1529
- },
1530
- ],
1531
- "maxItems": 2,
1532
- "minItems": 2,
1533
- "type": "array",
1534
- }
1535
- `);
1536
- });
1537
-
1538
- test("tuple with rest draft-7", () => {
1539
- const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
1540
- expect(z.toJSONSchema(schema, { target: "draft-7", io: "input" })).toMatchInlineSnapshot(`
1541
- {
1542
- "$schema": "http://json-schema.org/draft-07/schema#",
1543
- "additionalItems": {
1544
- "type": "boolean",
1545
- },
1546
- "items": [
1547
- {
1548
- "type": "string",
1549
- },
1550
- {
1551
- "type": "number",
1552
- },
1553
- ],
1554
- "minItems": 2,
1555
- "type": "array",
1556
- }
1557
- `);
1558
- });
1559
-
1560
- test("tuple with rest draft-7 - issue #5151 regression test", () => {
1561
- // This test addresses issue #5151: tuple with rest elements and ids in draft-7 had incorrect internal path handling affecting complex scenarios
1562
- const primarySchema = z.string().meta({ id: "primary" });
1563
- const restSchema = z.number().meta({ id: "rest" });
1564
- const testSchema = z.tuple([primarySchema], restSchema);
1565
-
1566
- // Test both final output structure AND internal path handling
1567
- const capturedPaths: string[] = [];
1568
- const result = z.toJSONSchema(testSchema, {
1569
- target: "draft-7",
1570
- override: (ctx) => capturedPaths.push(ctx.path.join("/")),
1571
- });
1572
-
1573
- // Verify correct draft-7 structure with metadata extraction
1574
- expect(result).toMatchInlineSnapshot(`
1575
- {
1576
- "$schema": "http://json-schema.org/draft-07/schema#",
1577
- "additionalItems": {
1578
- "$ref": "#/definitions/rest",
1579
- },
1580
- "definitions": {
1581
- "primary": {
1582
- "type": "string",
1583
- },
1584
- "rest": {
1585
- "type": "number",
1586
- },
1587
- },
1588
- "items": [
1589
- {
1590
- "$ref": "#/definitions/primary",
1591
- },
1592
- ],
1593
- "minItems": 1,
1594
- "type": "array",
1595
- }
1596
- `);
1597
-
1598
- // Verify internal paths are correct (this was the actual bug)
1599
- expect(capturedPaths).toContain("items/0"); // prefix items should use "items" path
1600
- expect(capturedPaths).toContain("additionalItems"); // rest should use "additionalItems" path
1601
- expect(capturedPaths).not.toContain("prefixItems/0"); // should not use draft-2020-12 paths
1602
-
1603
- // Structural validations
1604
- expect(Array.isArray(result.items)).toBe(true);
1605
- expect(result.additionalItems).toBeDefined();
1606
- });
1607
-
1608
- test("closed tuple length constraints - issue #6193", () => {
1609
- const schema = z.tuple([z.string(), z.string(), z.object({ lang: z.string() })]);
1610
-
1611
- expect(schema.safeParse(["a", "b", { lang: "en" }, "extra"]).success).toBe(false);
1612
-
1613
- const draft2020 = z.toJSONSchema(schema, { target: "draft-2020-12" });
1614
- expect(draft2020.items).toBe(false);
1615
- expect(draft2020.minItems).toBe(3);
1616
- expect(draft2020.maxItems).toBe(3);
1617
-
1618
- const draft7 = z.toJSONSchema(schema, { target: "draft-7", io: "input" });
1619
- expect(draft7.additionalItems).toBe(false);
1620
- expect(draft7.minItems).toBe(3);
1621
- expect(draft7.maxItems).toBe(3);
1622
-
1623
- const openapi = z.toJSONSchema(schema, { target: "openapi-3.0" });
1624
- validateOpenAPI30Schema(openapi);
1625
- expect(openapi.minItems).toBe(3);
1626
- expect(openapi.maxItems).toBe(3);
1627
- });
1628
-
1629
- test("closed tuple with optional trailing items", () => {
1630
- const schema = z.tuple([z.string(), z.number().optional()]);
1631
-
1632
- const draft2020 = z.toJSONSchema(schema, { target: "draft-2020-12" });
1633
- expect(draft2020.items).toBe(false);
1634
- expect(draft2020.minItems).toBe(1);
1635
- expect(draft2020.maxItems).toBe(2);
1636
-
1637
- const draft7 = z.toJSONSchema(schema, { target: "draft-7", io: "input" });
1638
- expect(draft7.additionalItems).toBe(false);
1639
- expect(draft7.minItems).toBe(1);
1640
- expect(draft7.maxItems).toBe(2);
1641
- });
1642
-
1643
- test("empty closed tuple rejects extra elements", () => {
1644
- const schema = z.tuple([]);
1645
-
1646
- const draft2020 = z.toJSONSchema(schema, { target: "draft-2020-12" });
1647
- expect(draft2020.items).toBe(false);
1648
- expect(draft2020.maxItems).toBe(0);
1649
-
1650
- const draft7 = z.toJSONSchema(schema, { target: "draft-7", io: "input" });
1651
- expect(draft7.additionalItems).toBe(false);
1652
- expect(draft7.maxItems).toBe(0);
1653
-
1654
- const openapi = z.toJSONSchema(schema, { target: "openapi-3.0" });
1655
- validateOpenAPI30Schema(openapi);
1656
- expect(openapi.maxItems).toBe(0);
1657
- });
1658
-
1659
- test("closed tuple length respects io direction with defaults", () => {
1660
- const schema = z.tuple([z.string(), z.string().default("x")]);
1661
-
1662
- const input = z.toJSONSchema(schema, { target: "draft-2020-12", io: "input" });
1663
- expect(input.items).toBe(false);
1664
- expect(input.minItems).toBe(1);
1665
- expect(input.maxItems).toBe(2);
1666
-
1667
- const output = z.toJSONSchema(schema, { target: "draft-2020-12", io: "output" });
1668
- expect(output.items).toBe(false);
1669
- expect(output.minItems).toBe(2);
1670
- expect(output.maxItems).toBe(2);
1671
- });
1672
-
1673
- test("closed tuple length resolves input optionality past transform and catch", () => {
1674
- const minItems = (schema: z.core.$ZodType, io: "input" | "output") =>
1675
- z.toJSONSchema(schema, { target: "draft-2020-12", io }).minItems;
1676
-
1677
- // Both let the parser observe an absent slot, but declare a required input.
1678
- const pre = z.tuple([z.string(), z.preprocess((v) => v, z.string())]);
1679
- expect(minItems(pre, "input")).toBe(2);
1680
- expect(minItems(pre, "output")).toBe(2);
1681
-
1682
- const caught = z.tuple([z.string(), z.string().catch("x")]);
1683
- expect(minItems(caught, "input")).toBe(2);
1684
- expect(minItems(caught, "output")).toBe(2);
1685
-
1686
- // Resolution passes through the wrapper rather than stopping at it.
1687
- expect(minItems(z.tuple([z.string(), z.string().optional().catch("x")]), "input")).toBe(1);
1688
- });
1689
-
1690
- test("promise", () => {
1691
- const schema = z.promise(z.string());
1692
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1693
- {
1694
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1695
- "type": "string",
1696
- }
1697
- `);
1698
- });
1699
-
1700
- test("lazy", () => {
1701
- const schema = z.lazy(() => z.string());
1702
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1703
- {
1704
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1705
- "type": "string",
1706
- }
1707
- `);
1708
- });
1709
-
1710
- // enum
1711
- test("enum", () => {
1712
- const a = z.enum(["a", "b", "c"]);
1713
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1714
- {
1715
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1716
- "enum": [
1717
- "a",
1718
- "b",
1719
- "c",
1720
- ],
1721
- "type": "string",
1722
- }
1723
- `);
1724
-
1725
- enum B {
1726
- A = 0,
1727
- B = 1,
1728
- C = 2,
1729
- }
1730
-
1731
- const b = z.enum(B);
1732
- expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1733
- {
1734
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1735
- "enum": [
1736
- 0,
1737
- 1,
1738
- 2,
1739
- ],
1740
- "type": "number",
1741
- }
1742
- `);
1743
- });
1744
-
1745
- // literal
1746
- test("literal", () => {
1747
- const a = z.literal("hello");
1748
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1749
- {
1750
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1751
- "const": "hello",
1752
- "type": "string",
1753
- }
1754
- `);
1755
-
1756
- const b = z.literal(7);
1757
- expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1758
- {
1759
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1760
- "const": 7,
1761
- "type": "number",
1762
- }
1763
- `);
1764
-
1765
- const c = z.literal(["hello", undefined, null, 5, BigInt(1324)]);
1766
- expect(() => z.toJSONSchema(c)).toThrow();
1767
-
1768
- const d = z.literal(["hello", null, 5]);
1769
- expect(z.toJSONSchema(d)).toMatchInlineSnapshot(`
1770
- {
1771
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1772
- "enum": [
1773
- "hello",
1774
- null,
1775
- 5,
1776
- ],
1777
- }
1778
- `);
1779
-
1780
- const e = z.literal(["hello", "zod", "v4"]);
1781
- expect(z.toJSONSchema(e)).toMatchInlineSnapshot(`
1782
- {
1783
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1784
- "enum": [
1785
- "hello",
1786
- "zod",
1787
- "v4",
1788
- ],
1789
- "type": "string",
1790
- }
1791
- `);
1792
- });
1793
-
1794
- test("literal draft-4", () => {
1795
- const a = z.literal("hello");
1796
- expect(z.toJSONSchema(a, { target: "draft-4" })).toMatchInlineSnapshot(`
1797
- {
1798
- "$schema": "http://json-schema.org/draft-04/schema#",
1799
- "enum": [
1800
- "hello",
1801
- ],
1802
- "type": "string",
1803
- }
1804
- `);
1805
- });
1806
-
1807
- // pipe
1808
- test("pipe", () => {
1809
- const schema = z
1810
- .string()
1811
- .transform((val) => Number.parseInt(val))
1812
- .pipe(z.number());
1813
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
1814
- {
1815
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1816
- "type": "number",
1817
- }
1818
- `);
1819
- });
1820
-
1821
- test("simple objects", () => {
1822
- const schema = z.object({
1823
- name: z.string(),
1824
- age: z.number(),
1825
- });
1826
-
1827
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(
1828
- `
1829
- {
1830
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1831
- "additionalProperties": false,
1832
- "properties": {
1833
- "age": {
1834
- "type": "number",
1835
- },
1836
- "name": {
1837
- "type": "string",
1838
- },
1839
- },
1840
- "required": [
1841
- "name",
1842
- "age",
1843
- ],
1844
- "type": "object",
1845
- }
1846
- `
1847
- );
1848
- });
1849
-
1850
- test("additionalproperties in z.object", () => {
1851
- const a = z.object({
1852
- name: z.string(),
1853
- });
1854
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1855
- {
1856
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1857
- "additionalProperties": false,
1858
- "properties": {
1859
- "name": {
1860
- "type": "string",
1861
- },
1862
- },
1863
- "required": [
1864
- "name",
1865
- ],
1866
- "type": "object",
1867
- }
1868
- `);
1869
- expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
1870
- {
1871
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1872
- "properties": {
1873
- "name": {
1874
- "type": "string",
1875
- },
1876
- },
1877
- "required": [
1878
- "name",
1879
- ],
1880
- "type": "object",
1881
- }
1882
- `);
1883
- expect(
1884
- z.toJSONSchema(a, {
1885
- io: "input",
1886
- override(ctx) {
1887
- const def = ctx.zodSchema._zod.def;
1888
- if (def.type === "object" && !def.catchall) {
1889
- (ctx.jsonSchema as z.core.JSONSchema.ObjectSchema).additionalProperties = false;
1890
- }
1891
- },
1892
- })
1893
- ).toMatchInlineSnapshot(`
1894
- {
1895
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1896
- "additionalProperties": false,
1897
- "properties": {
1898
- "name": {
1899
- "type": "string",
1900
- },
1901
- },
1902
- "required": [
1903
- "name",
1904
- ],
1905
- "type": "object",
1906
- }
1907
- `);
1908
- });
1909
-
1910
- test("catchall objects", () => {
1911
- const a = z.strictObject({
1912
- name: z.string(),
1913
- age: z.number(),
1914
- });
1915
-
1916
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
1917
- {
1918
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1919
- "additionalProperties": false,
1920
- "properties": {
1921
- "age": {
1922
- "type": "number",
1923
- },
1924
- "name": {
1925
- "type": "string",
1926
- },
1927
- },
1928
- "required": [
1929
- "name",
1930
- "age",
1931
- ],
1932
- "type": "object",
1933
- }
1934
- `);
1935
-
1936
- const b = z
1937
- .object({
1938
- name: z.string(),
1939
- })
1940
- .catchall(z.string());
1941
-
1942
- expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
1943
- {
1944
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1945
- "additionalProperties": {
1946
- "type": "string",
1947
- },
1948
- "properties": {
1949
- "name": {
1950
- "type": "string",
1951
- },
1952
- },
1953
- "required": [
1954
- "name",
1955
- ],
1956
- "type": "object",
1957
- }
1958
- `);
1959
-
1960
- const c = z.looseObject({
1961
- name: z.string(),
1962
- });
1963
-
1964
- expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
1965
- {
1966
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1967
- "additionalProperties": {},
1968
- "properties": {
1969
- "name": {
1970
- "type": "string",
1971
- },
1972
- },
1973
- "required": [
1974
- "name",
1975
- ],
1976
- "type": "object",
1977
- }
1978
- `);
1979
- });
1980
-
1981
- test("optional fields - object", () => {
1982
- const schema = z.object({
1983
- required: z.string(),
1984
- optional: z.string().optional(),
1985
- nonoptional: z.string().optional().nonoptional(),
1986
- });
1987
-
1988
- const result = z.toJSONSchema(schema);
1989
-
1990
- expect(result).toMatchInlineSnapshot(`
1991
- {
1992
- "$schema": "https://json-schema.org/draft/2020-12/schema",
1993
- "additionalProperties": false,
1994
- "properties": {
1995
- "nonoptional": {
1996
- "type": "string",
1997
- },
1998
- "optional": {
1999
- "type": "string",
2000
- },
2001
- "required": {
2002
- "type": "string",
2003
- },
2004
- },
2005
- "required": [
2006
- "required",
2007
- "nonoptional",
2008
- ],
2009
- "type": "object",
2010
- }
2011
- `);
2012
- });
2013
-
2014
- test("recursive object", () => {
2015
- interface Category {
2016
- name: string;
2017
- subcategories: Category[];
2018
- }
2019
-
2020
- const categorySchema: z.ZodType<Category> = z.object({
2021
- name: z.string(),
2022
- subcategories: z.array(z.lazy(() => categorySchema)),
2023
- });
2024
-
2025
- const result = z.toJSONSchema(categorySchema);
2026
- expect(result).toMatchInlineSnapshot(`
2027
- {
2028
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2029
- "additionalProperties": false,
2030
- "properties": {
2031
- "name": {
2032
- "type": "string",
2033
- },
2034
- "subcategories": {
2035
- "items": {
2036
- "$ref": "#",
2037
- },
2038
- "type": "array",
2039
- },
2040
- },
2041
- "required": [
2042
- "name",
2043
- "subcategories",
2044
- ],
2045
- "type": "object",
2046
- }
2047
- `);
2048
- });
2049
-
2050
- test("simple interface", () => {
2051
- const userSchema = z.object({
2052
- name: z.string(),
2053
- age: z.number().optional(),
2054
- });
2055
-
2056
- const result = z.toJSONSchema(userSchema);
2057
- expect(result).toMatchInlineSnapshot(`
2058
- {
2059
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2060
- "additionalProperties": false,
2061
- "properties": {
2062
- "age": {
2063
- "type": "number",
2064
- },
2065
- "name": {
2066
- "type": "string",
2067
- },
2068
- },
2069
- "required": [
2070
- "name",
2071
- ],
2072
- "type": "object",
2073
- }
2074
- `);
2075
- });
2076
-
2077
- test("catchall interface", () => {
2078
- const a = z.strictObject({
2079
- name: z.string(),
2080
- age: z.number(),
2081
- });
2082
-
2083
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
2084
- {
2085
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2086
- "additionalProperties": false,
2087
- "properties": {
2088
- "age": {
2089
- "type": "number",
2090
- },
2091
- "name": {
2092
- "type": "string",
2093
- },
2094
- },
2095
- "required": [
2096
- "name",
2097
- "age",
2098
- ],
2099
- "type": "object",
2100
- }
2101
- `);
2102
-
2103
- const b = z
2104
- .object({
2105
- name: z.string(),
2106
- })
2107
- .catchall(z.string());
2108
-
2109
- expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
2110
- {
2111
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2112
- "additionalProperties": {
2113
- "type": "string",
2114
- },
2115
- "properties": {
2116
- "name": {
2117
- "type": "string",
2118
- },
2119
- },
2120
- "required": [
2121
- "name",
2122
- ],
2123
- "type": "object",
2124
- }
2125
- `);
2126
-
2127
- const c = z.looseObject({
2128
- name: z.string(),
2129
- });
2130
-
2131
- expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
2132
- {
2133
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2134
- "additionalProperties": {},
2135
- "properties": {
2136
- "name": {
2137
- "type": "string",
2138
- },
2139
- },
2140
- "required": [
2141
- "name",
2142
- ],
2143
- "type": "object",
2144
- }
2145
- `);
2146
- });
2147
-
2148
- test("recursive interface schemas", () => {
2149
- const TreeNodeSchema = z.object({
2150
- id: z.string(),
2151
- get children() {
2152
- return TreeNodeSchema;
2153
- },
2154
- });
2155
-
2156
- const result = z.toJSONSchema(TreeNodeSchema);
2157
-
2158
- // Should have definitions for recursive schema
2159
- expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
2160
- `
2161
- "{
2162
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2163
- "type": "object",
2164
- "properties": {
2165
- "id": {
2166
- "type": "string"
2167
- },
2168
- "children": {
2169
- "$ref": "#"
2170
- }
2171
- },
2172
- "required": [
2173
- "id",
2174
- "children"
2175
- ],
2176
- "additionalProperties": false
2177
- }"
2178
- `
2179
- );
2180
- });
2181
-
2182
- test("mutually recursive interface schemas", () => {
2183
- const FolderSchema = z.object({
2184
- name: z.string(),
2185
- get files() {
2186
- return z.array(FileSchema);
2187
- },
2188
- });
2189
-
2190
- const FileSchema = z.object({
2191
- name: z.string(),
2192
- get parent() {
2193
- return FolderSchema;
2194
- },
2195
- });
2196
-
2197
- const result = z.toJSONSchema(FolderSchema);
2198
-
2199
- // Should have definitions for both schemas
2200
- expect(JSON.stringify(result, null, 2)).toMatchInlineSnapshot(
2201
- `
2202
- "{
2203
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2204
- "type": "object",
2205
- "properties": {
2206
- "name": {
2207
- "type": "string"
2208
- },
2209
- "files": {
2210
- "type": "array",
2211
- "items": {
2212
- "type": "object",
2213
- "properties": {
2214
- "name": {
2215
- "type": "string"
2216
- },
2217
- "parent": {
2218
- "$ref": "#"
2219
- }
2220
- },
2221
- "required": [
2222
- "name",
2223
- "parent"
2224
- ],
2225
- "additionalProperties": false
2226
- }
2227
- }
2228
- },
2229
- "required": [
2230
- "name",
2231
- "files"
2232
- ],
2233
- "additionalProperties": false
2234
- }"
2235
- `
2236
- );
2237
- });
2238
- });
2239
-
2240
- test("override", () => {
2241
- const schema = z.toJSONSchema(z.string(), {
2242
- override: (ctx) => {
2243
- ctx.zodSchema;
2244
- ctx.jsonSchema;
2245
- ctx.jsonSchema.whatever = "sup";
2246
- },
2247
- });
2248
- expect(schema).toMatchInlineSnapshot(`
2249
- {
2250
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2251
- "type": "string",
2252
- "whatever": "sup",
2253
- }
2254
- `);
2255
- });
2256
-
2257
- test("override: do not run on references", () => {
2258
- let overrideCount = 0;
2259
- const schema = z
2260
- .union([z.string().date(), z.string().datetime(), z.string().datetime({ local: true })])
2261
- .meta({ a: true })
2262
- .transform((str) => new Date(str))
2263
- .meta({ b: true })
2264
- .pipe(z.date())
2265
- .meta({ c: true })
2266
- .brand("dateIn");
2267
- z.toJSONSchema(schema, {
2268
- unrepresentable: "any",
2269
- io: "input",
2270
- override(_) {
2271
- overrideCount++;
2272
- },
2273
- });
2274
-
2275
- expect(overrideCount).toBe(12);
2276
- });
2277
-
2278
- test("override with refs", () => {
2279
- const a = z.string().optional();
2280
- const result = z.toJSONSchema(a, {
2281
- override(ctx) {
2282
- if (ctx.zodSchema._zod.def.type === "string") {
2283
- ctx.jsonSchema.type = "STRING" as "string";
2284
- }
2285
- },
2286
- });
2287
-
2288
- expect(result).toMatchInlineSnapshot(`
2289
- {
2290
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2291
- "type": "STRING",
2292
- }
2293
- `);
2294
- });
2295
-
2296
- test("override execution order", () => {
2297
- const schema = z.union([z.string(), z.number()]);
2298
- let unionSchema!: any;
2299
- z.toJSONSchema(schema, {
2300
- override(ctx) {
2301
- if (ctx.zodSchema._zod.def.type === "union") {
2302
- unionSchema = ctx.jsonSchema;
2303
- }
2304
- },
2305
- });
2306
-
2307
- expect(unionSchema).toMatchInlineSnapshot(`
2308
- {
2309
- "type": [
2310
- "string",
2311
- "number",
2312
- ],
2313
- }
2314
- `);
2315
- });
2316
-
2317
- test("override with path", () => {
2318
- const userSchema = z.object({
2319
- name: z.string(),
2320
- age: z.number(),
2321
- });
2322
-
2323
- const capturedPaths: (string | number)[][] = [];
2324
-
2325
- z.toJSONSchema(userSchema, {
2326
- override(ctx) {
2327
- capturedPaths.push(ctx.path);
2328
- },
2329
- });
2330
-
2331
- expect(capturedPaths).toMatchInlineSnapshot(`
2332
- [
2333
- [
2334
- "properties",
2335
- "age",
2336
- ],
2337
- [
2338
- "properties",
2339
- "name",
2340
- ],
2341
- [],
2342
- ]
2343
- `);
2344
- });
2345
-
2346
- test("pipe", () => {
2347
- const mySchema = z
2348
- .string()
2349
- .transform((val) => val.length)
2350
- .pipe(z.number());
2351
- // ZodPipe
2352
-
2353
- const a = z.toJSONSchema(mySchema);
2354
- expect(a).toMatchInlineSnapshot(`
2355
- {
2356
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2357
- "type": "number",
2358
- }
2359
- `);
2360
- // => { type: "number" }
2361
-
2362
- const b = z.toJSONSchema(mySchema, { io: "input" });
2363
- expect(b).toMatchInlineSnapshot(`
2364
- {
2365
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2366
- "type": "string",
2367
- }
2368
- `);
2369
- // => { type: "string" }
2370
- });
2371
-
2372
- test("passthrough schemas", () => {
2373
- const Internal = z.object({
2374
- num: z.number(),
2375
- str: z.string(),
2376
- });
2377
- //.meta({ id: "Internal" });
2378
-
2379
- const External = z.object({
2380
- a: Internal,
2381
- b: Internal.optional(),
2382
- c: z.lazy(() => Internal),
2383
- d: z.promise(Internal),
2384
- e: z.pipe(Internal, Internal),
2385
- });
2386
-
2387
- const result = z.toJSONSchema(External, {
2388
- reused: "ref",
2389
- });
2390
- expect(result).toMatchInlineSnapshot(`
2391
- {
2392
- "$defs": {
2393
- "__schema0": {
2394
- "additionalProperties": false,
2395
- "properties": {
2396
- "num": {
2397
- "type": "number",
2398
- },
2399
- "str": {
2400
- "type": "string",
2401
- },
2402
- },
2403
- "required": [
2404
- "num",
2405
- "str",
2406
- ],
2407
- "type": "object",
2408
- },
2409
- },
2410
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2411
- "additionalProperties": false,
2412
- "properties": {
2413
- "a": {
2414
- "$ref": "#/$defs/__schema0",
2415
- },
2416
- "b": {
2417
- "$ref": "#/$defs/__schema0",
2418
- },
2419
- "c": {
2420
- "$ref": "#/$defs/__schema0",
2421
- },
2422
- "d": {
2423
- "$ref": "#/$defs/__schema0",
2424
- },
2425
- "e": {
2426
- "$ref": "#/$defs/__schema0",
2427
- },
2428
- },
2429
- "required": [
2430
- "a",
2431
- "c",
2432
- "d",
2433
- "e",
2434
- ],
2435
- "type": "object",
2436
- }
2437
- `);
2438
- });
2439
-
2440
- test("extract schemas with id", () => {
2441
- const name = z.string().meta({ id: "name" });
2442
- const result = z.toJSONSchema(
2443
- z.object({
2444
- first_name: name,
2445
- last_name: name.nullable(),
2446
- middle_name: name.optional(),
2447
- age: z.number().meta({ id: "age" }),
2448
- })
2449
- );
2450
- expect(result).toMatchInlineSnapshot(`
2451
- {
2452
- "$defs": {
2453
- "age": {
2454
- "type": "number",
2455
- },
2456
- "name": {
2457
- "type": "string",
2458
- },
2459
- },
2460
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2461
- "additionalProperties": false,
2462
- "properties": {
2463
- "age": {
2464
- "$ref": "#/$defs/age",
2465
- },
2466
- "first_name": {
2467
- "$ref": "#/$defs/name",
2468
- },
2469
- "last_name": {
2470
- "anyOf": [
2471
- {
2472
- "$ref": "#/$defs/name",
2473
- },
2474
- {
2475
- "type": "null",
2476
- },
2477
- ],
2478
- },
2479
- "middle_name": {
2480
- "$ref": "#/$defs/name",
2481
- },
2482
- },
2483
- "required": [
2484
- "first_name",
2485
- "last_name",
2486
- "age",
2487
- ],
2488
- "type": "object",
2489
- }
2490
- `);
2491
- });
2492
-
2493
- test("escapes JSON Pointer reserved characters in $ref but not in $defs key", () => {
2494
- const User = z.object({ name: z.string() }).meta({ id: "Shared/User~" });
2495
- const result = z.toJSONSchema(z.object({ User }));
2496
- // the $ref pointer escapes `/` -> `~1` and `~` -> `~0` (RFC 6901),
2497
- // while the $defs key keeps the original id
2498
- expect((result.properties!.User as any).$ref).toBe("#/$defs/Shared~1User~0");
2499
- expect(Object.keys(result.$defs!)).toEqual(["Shared/User~"]);
2500
- });
2501
-
2502
- test("escapes JSON Pointer reserved characters in the root $ref", () => {
2503
- const User = z.object({ name: z.string() }).meta({ id: "Shared/User~" });
2504
- const result = z.toJSONSchema(User);
2505
- expect(result.$ref).toBe("#/$defs/Shared~1User~0");
2506
- expect(Object.keys(result.$defs!)).toEqual(["Shared/User~"]);
2507
- });
2508
-
2509
- test("a multipleOf divisor JSON Schema cannot express goes through `unrepresentable`", () => {
2510
- // the keyword must be strictly greater than zero, and NaN/Infinity do not survive JSON at all
2511
- for (const divisor of [0, Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]) {
2512
- expect(() => z.toJSONSchema(z.number().multipleOf(divisor))).toThrow(/cannot be represented in JSON Schema/);
2513
- expect(z.toJSONSchema(z.number().multipleOf(divisor), { unrepresentable: "any" })).toMatchObject({
2514
- type: "number",
2515
- });
2516
- expect(z.toJSONSchema(z.number().multipleOf(divisor), { unrepresentable: "any" })).not.toHaveProperty("multipleOf");
2517
- }
2518
-
2519
- // a negative divisor accepts exactly what its absolute value accepts, so it still maps
2520
- expect(z.number().multipleOf(-5).safeParse(10).success).toEqual(true);
2521
- expect(z.number().multipleOf(-5).safeParse(13).success).toEqual(false);
2522
- expect(z.toJSONSchema(z.number().multipleOf(-5))).toMatchObject({ multipleOf: 5 });
2523
- expect(z.toJSONSchema(z.number().multipleOf(0.1))).toMatchObject({ multipleOf: 0.1 });
2524
- });
2525
-
2526
- test("unrepresentable default values go through `unrepresentable`", () => {
2527
- // a bigint default has no reliable JSON encoding, so it is dropped rather than approximated
2528
- expect(z.toJSONSchema(z.bigint().default(0n), { unrepresentable: "any" })).toMatchInlineSnapshot(`
2529
- {
2530
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2531
- }
2532
- `);
2533
- expect(z.toJSONSchema(z.bigint().prefault(2n), { io: "input", unrepresentable: "any" })).toMatchInlineSnapshot(`
2534
- {
2535
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2536
- }
2537
- `);
2538
- // including when nested inside an otherwise representable default
2539
- expect(
2540
- z.toJSONSchema(z.object({ a: z.bigint() }).default({ a: 1n }), { unrepresentable: "any" })
2541
- ).toMatchInlineSnapshot(`
2542
- {
2543
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2544
- "additionalProperties": false,
2545
- "properties": {
2546
- "a": {},
2547
- },
2548
- "required": [
2549
- "a",
2550
- ],
2551
- "type": "object",
2552
- }
2553
- `);
2554
-
2555
- // 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
2556
- expect(() => z.toJSONSchema(z.bigint().default(0n))).toThrow("BigInt cannot be represented in JSON Schema");
2557
- expect(() => z.toJSONSchema(z.unknown().default(1n))).toThrow("BigInt defaults cannot be represented in JSON Schema");
2558
-
2559
- // representable defaults are untouched
2560
- expect(z.toJSONSchema(z.object({ a: z.number() }).default({ a: 2 }))).toMatchInlineSnapshot(`
2561
- {
2562
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2563
- "additionalProperties": false,
2564
- "default": {
2565
- "a": 2,
2566
- },
2567
- "properties": {
2568
- "a": {
2569
- "type": "number",
2570
- },
2571
- },
2572
- "required": [
2573
- "a",
2574
- ],
2575
- "type": "object",
2576
- }
2577
- `);
2578
- });
2579
-
2580
- test("an `unrepresentable` handler can represent a bigint default", () => {
2581
- // one handler covers both the type and its default, so no `unrepresentable: "any"` is needed and every other unrepresentable type still throws
2582
- expect(
2583
- z.toJSONSchema(z.object({ startAt: z.coerce.bigint().optional().default(0n) }), {
2584
- io: "input",
2585
- unrepresentable: ({ zodSchema }) => {
2586
- const def = zodSchema._zod.def;
2587
- if (def.type === "bigint") return { type: "integer", format: "int64" };
2588
- if (def.type === "default") return { default: String(def.defaultValue) };
2589
- return "throw";
2590
- },
2591
- })
2592
- ).toMatchInlineSnapshot(`
2593
- {
2594
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2595
- "properties": {
2596
- "startAt": {
2597
- "default": "0",
2598
- "format": "int64",
2599
- "type": "integer",
2600
- },
2601
- },
2602
- "type": "object",
2603
- }
2604
- `);
2605
-
2606
- // a handler may also drop just the default while still representing the type
2607
- expect(
2608
- z.toJSONSchema(z.bigint().default(0n), {
2609
- unrepresentable: ({ zodSchema }) =>
2610
- zodSchema._zod.def.type === "bigint" ? { type: "integer", format: "int64" } : "any",
2611
- })
2612
- ).toMatchInlineSnapshot(`
2613
- {
2614
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2615
- "format": "int64",
2616
- "type": "integer",
2617
- }
2618
- `);
2619
- });
2620
-
2621
- test("unrepresentable literal values are ignored", () => {
2622
- const a = z.toJSONSchema(z.literal(["hello", null, 5, BigInt(1324), undefined]), { unrepresentable: "any" });
2623
- expect(a).toMatchInlineSnapshot(`
2624
- {
2625
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2626
- "enum": [
2627
- "hello",
2628
- null,
2629
- 5,
2630
- 1324,
2631
- ],
2632
- }
2633
- `);
2634
-
2635
- const b = z.toJSONSchema(z.literal([undefined, null, 5, BigInt(1324)]), {
2636
- unrepresentable: "any",
2637
- });
2638
- expect(b).toMatchInlineSnapshot(`
2639
- {
2640
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2641
- "enum": [
2642
- null,
2643
- 5,
2644
- 1324,
2645
- ],
2646
- }
2647
- `);
2648
-
2649
- const c = z.toJSONSchema(z.literal([undefined]), {
2650
- unrepresentable: "any",
2651
- });
2652
- expect(c).toMatchInlineSnapshot(`
2653
- {
2654
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2655
- }
2656
- `);
2657
- });
2658
-
2659
- test("describe with id", () => {
2660
- const jobId = z.string().meta({ id: "jobId" });
2661
-
2662
- const a = z.toJSONSchema(
2663
- z.object({
2664
- current: jobId.describe("Current job"),
2665
- previous: jobId.describe("Previous job"),
2666
- })
2667
- );
2668
- expect(a).toMatchInlineSnapshot(`
2669
- {
2670
- "$defs": {
2671
- "jobId": {
2672
- "type": "string",
2673
- },
2674
- },
2675
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2676
- "additionalProperties": false,
2677
- "properties": {
2678
- "current": {
2679
- "$ref": "#/$defs/jobId",
2680
- "description": "Current job",
2681
- },
2682
- "previous": {
2683
- "$ref": "#/$defs/jobId",
2684
- "description": "Previous job",
2685
- },
2686
- },
2687
- "required": [
2688
- "current",
2689
- "previous",
2690
- ],
2691
- "type": "object",
2692
- }
2693
- `);
2694
- });
2695
-
2696
- test("id is stripped from $defs entries (draft-2020-12)", () => {
2697
- // 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.
2698
- const inner = z.string().meta({ id: "Inner" });
2699
- const result = z.toJSONSchema(z.object({ a: inner, b: inner }));
2700
- expect(result.$defs?.Inner).toEqual({ type: "string" });
2701
- expect((result.$defs?.Inner as any).id).toBeUndefined();
2702
- });
2703
-
2704
- test("id is stripped from definitions entries (draft-04)", () => {
2705
- // 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.
2706
- const inner = z.string().meta({ id: "Inner" });
2707
- const result = z.toJSONSchema(z.object({ a: inner, b: inner }), { target: "draft-04" }) as any;
2708
- expect(result.definitions?.Inner).toEqual({ type: "string" });
2709
- expect(result.definitions?.Inner?.id).toBeUndefined();
2710
- });
2711
-
2712
- test("id is stripped from root schema", () => {
2713
- // The registration tag should not appear on the root either.
2714
- const A = z.object({ name: z.string() }).meta({ id: "A" });
2715
- const result = z.toJSONSchema(A);
2716
- expect((result as any).id).toBeUndefined();
2717
- });
2718
-
2719
- test("root schema with id is hoisted into $defs", () => {
2720
- const A = z.object({ name: z.string() }).meta({ id: "A" });
2721
- const result = z.toJSONSchema(A);
2722
-
2723
- expect(result).toEqual({
2724
- $schema: "https://json-schema.org/draft/2020-12/schema",
2725
- $ref: "#/$defs/A",
2726
- $defs: {
2727
- A: {
2728
- type: "object",
2729
- properties: {
2730
- name: {
2731
- type: "string",
2732
- },
2733
- },
2734
- required: ["name"],
2735
- additionalProperties: false,
2736
- },
2737
- },
2738
- });
2739
- });
2740
-
2741
- test("root schema with id uses definitions on legacy targets", () => {
2742
- const A = z.object({ name: z.string() }).meta({ id: "A" });
2743
- const result = z.toJSONSchema(A, { target: "draft-07" });
2744
-
2745
- expect(result).toEqual({
2746
- $schema: "http://json-schema.org/draft-07/schema#",
2747
- $ref: "#/definitions/A",
2748
- definitions: {
2749
- A: {
2750
- type: "object",
2751
- properties: {
2752
- name: {
2753
- type: "string",
2754
- },
2755
- },
2756
- required: ["name"],
2757
- additionalProperties: false,
2758
- },
2759
- },
2760
- });
2761
- });
2762
-
2763
- test("id is observable in override callback", () => {
2764
- // The strip happens after override callbacks run, so userland override code can still read `jsonSchema.id` if it wants to.
2765
- const inner = z.string().meta({ id: "Inner" });
2766
- const seenIds: Array<string | undefined> = [];
2767
- z.toJSONSchema(z.object({ a: inner }), {
2768
- override: ({ jsonSchema }) => {
2769
- if (jsonSchema.id !== undefined) seenIds.push(jsonSchema.id as string);
2770
- },
2771
- });
2772
- expect(seenIds).toContain("Inner");
2773
- });
2774
-
2775
- test("describe with id on wrapper", () => {
2776
- // Test that $ref propagation works when processor sets a different ref (readonly -> innerType) but parent was extracted due to having an id
2777
- const roJobId = z.string().readonly().meta({ id: "roJobId" });
2778
-
2779
- const a = z.toJSONSchema(
2780
- z.object({
2781
- current: roJobId.describe("Current readonly job"),
2782
- previous: roJobId.describe("Previous readonly job"),
2783
- })
2784
- );
2785
- expect(a).toMatchInlineSnapshot(`
2786
- {
2787
- "$defs": {
2788
- "roJobId": {
2789
- "readOnly": true,
2790
- "type": "string",
2791
- },
2792
- },
2793
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2794
- "additionalProperties": false,
2795
- "properties": {
2796
- "current": {
2797
- "$ref": "#/$defs/roJobId",
2798
- "description": "Current readonly job",
2799
- },
2800
- "previous": {
2801
- "$ref": "#/$defs/roJobId",
2802
- "description": "Previous readonly job",
2803
- },
2804
- },
2805
- "required": [
2806
- "current",
2807
- "previous",
2808
- ],
2809
- "type": "object",
2810
- }
2811
- `);
2812
- });
2813
-
2814
- test("overwrite id", () => {
2815
- const jobId = z.string().meta({ id: "aaa" });
2816
-
2817
- const a = z.toJSONSchema(
2818
- z.object({
2819
- current: jobId,
2820
- previous: jobId.meta({ id: "bbb" }),
2821
- })
2822
- );
2823
- expect(a).toMatchInlineSnapshot(`
2824
- {
2825
- "$defs": {
2826
- "aaa": {
2827
- "type": "string",
2828
- },
2829
- "bbb": {
2830
- "$ref": "#/$defs/aaa",
2831
- },
2832
- },
2833
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2834
- "additionalProperties": false,
2835
- "properties": {
2836
- "current": {
2837
- "$ref": "#/$defs/aaa",
2838
- },
2839
- "previous": {
2840
- "$ref": "#/$defs/bbb",
2841
- },
2842
- },
2843
- "required": [
2844
- "current",
2845
- "previous",
2846
- ],
2847
- "type": "object",
2848
- }
2849
- `);
2850
-
2851
- const b = z.toJSONSchema(
2852
- z.object({
2853
- current: jobId,
2854
- previous: jobId.meta({ id: "ccc" }),
2855
- }),
2856
- {
2857
- reused: "ref",
2858
- }
2859
- );
2860
- expect(b).toMatchInlineSnapshot(`
2861
- {
2862
- "$defs": {
2863
- "aaa": {
2864
- "type": "string",
2865
- },
2866
- "ccc": {
2867
- "$ref": "#/$defs/aaa",
2868
- },
2869
- },
2870
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2871
- "additionalProperties": false,
2872
- "properties": {
2873
- "current": {
2874
- "$ref": "#/$defs/aaa",
2875
- },
2876
- "previous": {
2877
- "$ref": "#/$defs/ccc",
2878
- },
2879
- },
2880
- "required": [
2881
- "current",
2882
- "previous",
2883
- ],
2884
- "type": "object",
2885
- }
2886
- `);
2887
- });
2888
-
2889
- test("overwrite descriptions", () => {
2890
- const field = z.string().describe("a").describe("b").describe("c");
2891
-
2892
- const a = z.toJSONSchema(
2893
- z.object({
2894
- d: field.describe("d"),
2895
- e: field.describe("e"),
2896
- })
2897
- );
2898
- expect(a).toMatchInlineSnapshot(`
2899
- {
2900
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2901
- "additionalProperties": false,
2902
- "properties": {
2903
- "d": {
2904
- "description": "d",
2905
- "type": "string",
2906
- },
2907
- "e": {
2908
- "description": "e",
2909
- "type": "string",
2910
- },
2911
- },
2912
- "required": [
2913
- "d",
2914
- "e",
2915
- ],
2916
- "type": "object",
2917
- }
2918
- `);
2919
-
2920
- const b = z.toJSONSchema(
2921
- z.object({
2922
- d: field.describe("d"),
2923
- e: field.describe("e"),
2924
- }),
2925
- {
2926
- reused: "ref",
2927
- }
2928
- );
2929
- expect(b).toMatchInlineSnapshot(`
2930
- {
2931
- "$defs": {
2932
- "__schema0": {
2933
- "description": "c",
2934
- "type": "string",
2935
- },
2936
- },
2937
- "$schema": "https://json-schema.org/draft/2020-12/schema",
2938
- "additionalProperties": false,
2939
- "properties": {
2940
- "d": {
2941
- "$ref": "#/$defs/__schema0",
2942
- "description": "d",
2943
- },
2944
- "e": {
2945
- "$ref": "#/$defs/__schema0",
2946
- "description": "e",
2947
- },
2948
- },
2949
- "required": [
2950
- "d",
2951
- "e",
2952
- ],
2953
- "type": "object",
2954
- }
2955
- `);
2956
- });
2957
-
2958
- test("top-level readonly", () => {
2959
- const A = z
2960
- .object({
2961
- name: z.string(),
2962
- get b() {
2963
- return B;
2964
- },
2965
- })
2966
- .readonly()
2967
- .meta({ id: "A" });
2968
- // z.globalRegistry.add(A, { id: "A" });
2969
- // .meta({ id: "A" });
2970
-
2971
- const B = z
2972
- .object({
2973
- name: z.string(),
2974
- get a() {
2975
- return A;
2976
- },
2977
- })
2978
- .readonly()
2979
- .meta({ id: "B" });
2980
- // z.globalRegistry.add(B, { id: "B" });
2981
- // .meta({ id: "B" });
2982
-
2983
- const result = z.toJSONSchema(A);
2984
- expect(result).toEqual({
2985
- $schema: "https://json-schema.org/draft/2020-12/schema",
2986
- $ref: "#/$defs/A",
2987
- $defs: {
2988
- A: {
2989
- additionalProperties: false,
2990
- properties: {
2991
- b: {
2992
- $ref: "#/$defs/B",
2993
- },
2994
- name: {
2995
- type: "string",
2996
- },
2997
- },
2998
- readOnly: true,
2999
- required: ["name", "b"],
3000
- type: "object",
3001
- },
3002
- B: {
3003
- additionalProperties: false,
3004
- properties: {
3005
- a: {
3006
- $ref: "#/$defs/A",
3007
- },
3008
- name: {
3009
- type: "string",
3010
- },
3011
- },
3012
- readOnly: true,
3013
- required: ["name", "a"],
3014
- type: "object",
3015
- },
3016
- },
3017
- });
3018
- });
3019
-
3020
- test("basic registry", () => {
3021
- const myRegistry = z.registry<{ id: string }>();
3022
- const User = z.object({
3023
- name: z.string(),
3024
- get posts() {
3025
- return z.array(Post);
3026
- },
3027
- });
3028
-
3029
- const Post = z.object({
3030
- title: z.string(),
3031
- content: z.string(),
3032
- get author() {
3033
- return User;
3034
- },
3035
- });
3036
-
3037
- myRegistry.add(User, { id: "User" });
3038
- myRegistry.add(Post, { id: "Post" });
3039
-
3040
- const result = z.toJSONSchema(myRegistry, {
3041
- uri: (id) => `https://example.com/${id}.json`,
3042
- });
3043
- expect(result).toMatchInlineSnapshot(`
3044
- {
3045
- "schemas": {
3046
- "Post": {
3047
- "$id": "https://example.com/Post.json",
3048
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3049
- "additionalProperties": false,
3050
- "properties": {
3051
- "author": {
3052
- "$ref": "https://example.com/User.json",
3053
- },
3054
- "content": {
3055
- "type": "string",
3056
- },
3057
- "title": {
3058
- "type": "string",
3059
- },
3060
- },
3061
- "required": [
3062
- "title",
3063
- "content",
3064
- "author",
3065
- ],
3066
- "type": "object",
3067
- },
3068
- "User": {
3069
- "$id": "https://example.com/User.json",
3070
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3071
- "additionalProperties": false,
3072
- "properties": {
3073
- "name": {
3074
- "type": "string",
3075
- },
3076
- "posts": {
3077
- "items": {
3078
- "$ref": "https://example.com/Post.json",
3079
- },
3080
- "type": "array",
3081
- },
3082
- },
3083
- "required": [
3084
- "name",
3085
- "posts",
3086
- ],
3087
- "type": "object",
3088
- },
3089
- },
3090
- }
3091
- `);
3092
- });
3093
-
3094
- test("large registry converts in linear time", () => {
3095
- const count = 2000;
3096
- const convert = (withIntersection: boolean) => {
3097
- const registry = z.registry<{ id: string }>();
3098
- for (let i = 0; i < count; i++) {
3099
- registry.add(
3100
- z.object({ id: z.string(), name: z.string(), count: z.number(), nested: z.object({ a: z.boolean() }) }),
3101
- { id: `Type${i}` }
3102
- );
3103
- }
3104
- if (withIntersection) registry.add(z.object({ a: z.string() }).and(z.object({ b: z.string() })), { id: "Inter" });
3105
-
3106
- const start = performance.now();
3107
- const { schemas } = z.toJSONSchema(registry, { uri: (id) => `https://example.com/${id}.json` });
3108
- return { schemas, elapsed: performance.now() - start };
3109
- };
3110
-
3111
- const plain = convert(false);
3112
- expect(Object.keys(plain.schemas)).toHaveLength(count);
3113
- expect(plain.schemas.Type0).toMatchObject({
3114
- $id: "https://example.com/Type0.json",
3115
- type: "object",
3116
- properties: { nested: { type: "object" } },
3117
- });
3118
- expect(plain.schemas[`Type${count - 1}`]!.$id).toBe(`https://example.com/Type${count - 1}.json`);
3119
-
3120
- // 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.
3121
- expect(plain.elapsed).toBeLessThan(5000);
3122
-
3123
- // 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.
3124
- const folded = convert(true);
3125
- expect(folded.schemas.Inter).toMatchObject({ type: "object", properties: { a: {}, b: {} } });
3126
- expect(folded.elapsed).toBeLessThan(plain.elapsed * 4 + 100);
3127
- });
3128
-
3129
- test("a registry of records with numeric keys converts in linear time", () => {
3130
- const count = 2000;
3131
- const convert = (key: (i: number) => z.core.$ZodType) => {
3132
- const registry = z.registry<{ id: string }>();
3133
- for (let i = 0; i < count; i++) {
3134
- registry.add(z.object({ m: z.record(key(i) as z.core.$ZodRecordKey, z.boolean()) }), { id: `Type${i}` });
3135
- }
3136
- const start = performance.now();
3137
- const { schemas } = z.toJSONSchema(registry, { uri: (id) => `https://example.com/${id}.json` });
3138
- return { schemas, elapsed: performance.now() - start };
3139
- };
3140
-
3141
- const string = convert(() => z.string());
3142
- const numeric = convert(() => z.number());
3143
- expect(numeric.schemas.Type0).toMatchObject({
3144
- properties: { m: { propertyNames: { type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" } } },
3145
- });
3146
-
3147
- // 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.
3148
- expect(numeric.elapsed).toBeLessThan(string.elapsed * 2 + 50);
3149
-
3150
- // 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.
3151
- const extracted = convert((i) => z.number().meta({ id: `Key${i}` }));
3152
- expect(extracted.schemas.Type0).toMatchObject({
3153
- properties: { m: { propertyNames: { type: "string", pattern: "^-?\\d+(?:\\.\\d+)?$" } } },
3154
- });
3155
- });
3156
-
3157
- test("registry extracts unregistered subschemas into __shared", () => {
3158
- const registry = z.registry<{ id: string }>();
3159
- const address = z.object({ street: z.string() }).meta({ id: "Address" });
3160
- registry.add(z.object({ home: address, work: address }), { id: "Person" });
3161
- registry.add(z.object({ hq: address }), { id: "Company" });
3162
-
3163
- const { schemas } = z.toJSONSchema(registry, { uri: (id) => `https://example.com/${id}.json` });
3164
-
3165
- expect(schemas.__shared).toMatchInlineSnapshot(`
3166
- {
3167
- "$defs": {
3168
- "Address": {
3169
- "additionalProperties": false,
3170
- "properties": {
3171
- "street": {
3172
- "type": "string",
3173
- },
3174
- },
3175
- "required": [
3176
- "street",
3177
- ],
3178
- "type": "object",
3179
- },
3180
- },
3181
- }
3182
- `);
3183
- expect(schemas.Person).toMatchInlineSnapshot(`
3184
- {
3185
- "$id": "https://example.com/Person.json",
3186
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3187
- "additionalProperties": false,
3188
- "properties": {
3189
- "home": {
3190
- "$ref": "https://example.com/__shared.json#/$defs/Address",
3191
- },
3192
- "work": {
3193
- "$ref": "https://example.com/__shared.json#/$defs/Address",
3194
- },
3195
- },
3196
- "required": [
3197
- "home",
3198
- "work",
3199
- ],
3200
- "type": "object",
3201
- }
3202
- `);
3203
- // 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.
3204
- expect(schemas.Company!.properties!.hq).toEqual({
3205
- $ref: "https://example.com/__shared.json#/$defs/Address",
3206
- });
3207
- });
3208
-
3209
- test("registry extracts reused subschemas into __shared without an id", () => {
3210
- const registry = z.registry<{ id: string }>();
3211
- const shared = z.object({ q: z.string() });
3212
- registry.add(z.object({ a: shared, b: shared }), { id: "First" });
3213
- registry.add(z.object({ c: shared }), { id: "Second" });
3214
-
3215
- const { schemas } = z.toJSONSchema(registry, { uri: (id) => `${id}.json`, reused: "ref" });
3216
-
3217
- // The id is counter-generated, so this pins that ctx.counter is consumed exactly once.
3218
- expect(Object.keys(schemas.__shared!.$defs!)).toEqual(["schema0"]);
3219
- expect(schemas.First!.properties!.a).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3220
- expect(schemas.Second!.properties!.c).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3221
- });
3222
-
3223
- test("JSONSchemaGenerator re-runs shared passes when emit params change", () => {
3224
- const shared = z.object({ s: z.string() });
3225
- const a = z.object({ x: shared, y: shared });
3226
- const registry = z.registry<{ id: string }>();
3227
- registry.add(a, { id: "A" });
3228
-
3229
- const gen = new z.core.JSONSchemaGenerator({ target: "draft-2020-12" });
3230
- gen.process(a);
3231
- const defs: Record<string, any> = {};
3232
- const external = { registry, uri: (id: string) => `${id}.json`, defs };
3233
-
3234
- gen.emit(a, { external, reused: "inline" });
3235
- // Same `external`, different `reused` — the second emit must still extract `shared`.
3236
- const second: any = gen.emit(a, { external, reused: "ref" });
3237
-
3238
- expect(Object.keys(defs)).toEqual(["schema0"]);
3239
- expect(second.properties.x).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3240
- expect(second.properties.y).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3241
- });
3242
-
3243
- test("JSONSchemaGenerator still throws on cycles when a later emit asks for it", () => {
3244
- const Node: any = z.object({
3245
- v: z.string(),
3246
- get next() {
3247
- return Node;
3248
- },
3249
- });
3250
- const registry = z.registry<{ id: string }>();
3251
- registry.add(Node, { id: "Node" });
3252
-
3253
- const gen = new z.core.JSONSchemaGenerator({ target: "draft-2020-12" });
3254
- gen.process(Node);
3255
- const external = { registry, uri: (id: string) => `${id}.json`, defs: {} };
3256
-
3257
- gen.emit(Node, { external, cycles: "ref" });
3258
- expect(() => gen.emit(Node, { external, cycles: "throw" })).toThrow(/Cycle detected/);
3259
- });
3260
-
3261
- test("JSONSchemaGenerator re-runs shared passes on a no-params emit", () => {
3262
- const shared = z.object({ s: z.string() });
3263
- const a = z.object({ x: shared });
3264
- const registry = z.registry<{ id: string }>();
3265
- registry.add(a, { id: "A" });
3266
-
3267
- const gen = new z.core.JSONSchemaGenerator({ target: "draft-2020-12" });
3268
- gen.process(a);
3269
- const defs: Record<string, any> = {};
3270
- gen.emit(a, { external: { registry, uri: (id: string) => `${id}.json`, defs }, reused: "ref" });
3271
-
3272
- // 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.
3273
- gen.process(shared);
3274
- const second: any = gen.emit(a);
3275
-
3276
- expect(Object.keys(defs)).toEqual(["schema0"]);
3277
- expect(second.properties.x).toEqual({ $ref: "__shared.json#/$defs/schema0" });
3278
- });
3279
-
3280
- test("_ref", () => {
3281
- // const a = z.promise(z.string().describe("a"));
3282
- const a = z.toJSONSchema(z.promise(z.string().describe("a")));
3283
- expect(a).toMatchInlineSnapshot(`
3284
- {
3285
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3286
- "description": "a",
3287
- "type": "string",
3288
- }
3289
- `);
3290
-
3291
- const b = z.toJSONSchema(z.lazy(() => z.string().describe("a")));
3292
- expect(b).toMatchInlineSnapshot(`
3293
- {
3294
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3295
- "description": "a",
3296
- "type": "string",
3297
- }
3298
- `);
3299
-
3300
- const c = z.toJSONSchema(z.optional(z.string().describe("a")));
3301
- expect(c).toMatchInlineSnapshot(`
3302
- {
3303
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3304
- "description": "a",
3305
- "type": "string",
3306
- }
3307
- `);
3308
-
3309
- const d = z.toJSONSchema(z.string().meta({ id: "foo" }).describe("bar").optional());
3310
- expect(d).toMatchInlineSnapshot(`
3311
- {
3312
- "$defs": {
3313
- "foo": {
3314
- "type": "string",
3315
- },
3316
- },
3317
- "$ref": "#/$defs/foo",
3318
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3319
- "description": "bar",
3320
- }
3321
- `);
3322
- });
3323
-
3324
- test("defaults/prefaults", () => {
3325
- const a = z
3326
- .string()
3327
- .transform((val) => val.length)
3328
- .pipe(z.number());
3329
- const b = a.prefault("hello");
3330
- const c = a.default(1234);
3331
-
3332
- // a
3333
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
3334
- {
3335
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3336
- "type": "number",
3337
- }
3338
- `);
3339
- expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
3340
- {
3341
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3342
- "type": "string",
3343
- }
3344
- `);
3345
-
3346
- // b
3347
- expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
3348
- {
3349
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3350
- "type": "number",
3351
- }
3352
- `);
3353
- expect(z.toJSONSchema(b, { io: "input" })).toMatchInlineSnapshot(`
3354
- {
3355
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3356
- "default": "hello",
3357
- "type": "string",
3358
- }
3359
- `);
3360
- // c
3361
- expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
3362
- {
3363
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3364
- "default": 1234,
3365
- "type": "number",
3366
- }
3367
- `);
3368
- expect(z.toJSONSchema(c, { io: "input" })).toMatchInlineSnapshot(`
3369
- {
3370
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3371
- "type": "string",
3372
- }
3373
- `);
3374
- });
3375
-
3376
- test("catch on a transforming schema", () => {
3377
- const a = z
3378
- .string()
3379
- .transform((val) => val.length)
3380
- .pipe(z.number())
3381
- .catch(0);
3382
-
3383
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
3384
- {
3385
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3386
- "default": 0,
3387
- "type": "number",
3388
- }
3389
- `);
3390
- // catch values are output-typed, so they are not valid input
3391
- expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
3392
- {
3393
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3394
- "type": "string",
3395
- }
3396
- `);
3397
-
3398
- // the catch no longer hides the inner transform from ancestors, so their output-typed metadata is stripped too — matching a bare nested transform
3399
- expect(z.toJSONSchema(z.object({ a }).meta({ examples: [{ a: 1 }] }), { io: "input" })).toMatchInlineSnapshot(`
3400
- {
3401
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3402
- "properties": {
3403
- "a": {
3404
- "type": "string",
3405
- },
3406
- },
3407
- "required": [
3408
- "a",
3409
- ],
3410
- "type": "object",
3411
- }
3412
- `);
3413
- });
3414
-
3415
- test("falsy prefaults (false, 0, empty string)", () => {
3416
- // boolean prefault false
3417
- const a = z.boolean().prefault(false);
3418
- expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
3419
- {
3420
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3421
- "default": false,
3422
- "type": "boolean",
3423
- }
3424
- `);
3425
-
3426
- // number prefault 0
3427
- const b = z.number().prefault(0);
3428
- expect(z.toJSONSchema(b, { io: "input" })).toMatchInlineSnapshot(`
3429
- {
3430
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3431
- "default": 0,
3432
- "type": "number",
3433
- }
3434
- `);
3435
-
3436
- // string prefault empty string
3437
- const c = z.string().prefault("");
3438
- expect(z.toJSONSchema(c, { io: "input" })).toMatchInlineSnapshot(`
3439
- {
3440
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3441
- "default": "",
3442
- "type": "string",
3443
- }
3444
- `);
3445
- });
3446
-
3447
- test("input type", () => {
3448
- const schema = z.object({
3449
- a: z.string(),
3450
- b: z.string().optional(),
3451
- c: z.string().default("hello"),
3452
- d: z.string().nullable(),
3453
- e: z.string().prefault("hello"),
3454
- f: z.string().catch("hello"),
3455
- g: z.never(),
3456
- h: z.union([z.string(), z.number().default(2)]),
3457
- i: z.union([z.string(), z.string().optional()]),
3458
- });
3459
- expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
3460
- {
3461
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3462
- "properties": {
3463
- "a": {
3464
- "type": "string",
3465
- },
3466
- "b": {
3467
- "type": "string",
3468
- },
3469
- "c": {
3470
- "default": "hello",
3471
- "type": "string",
3472
- },
3473
- "d": {
3474
- "type": [
3475
- "string",
3476
- "null",
3477
- ],
3478
- },
3479
- "e": {
3480
- "default": "hello",
3481
- "type": "string",
3482
- },
3483
- "f": {
3484
- "default": "hello",
3485
- "type": "string",
3486
- },
3487
- "g": {
3488
- "not": {},
3489
- },
3490
- "h": {
3491
- "anyOf": [
3492
- {
3493
- "type": "string",
3494
- },
3495
- {
3496
- "default": 2,
3497
- "type": "number",
3498
- },
3499
- ],
3500
- },
3501
- "i": {
3502
- "type": "string",
3503
- },
3504
- },
3505
- "required": [
3506
- "a",
3507
- "d",
3508
- "f",
3509
- "g",
3510
- ],
3511
- "type": "object",
3512
- }
3513
- `);
3514
- expect(z.toJSONSchema(schema, { io: "output" })).toMatchInlineSnapshot(`
3515
- {
3516
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3517
- "additionalProperties": false,
3518
- "properties": {
3519
- "a": {
3520
- "type": "string",
3521
- },
3522
- "b": {
3523
- "type": "string",
3524
- },
3525
- "c": {
3526
- "default": "hello",
3527
- "type": "string",
3528
- },
3529
- "d": {
3530
- "type": [
3531
- "string",
3532
- "null",
3533
- ],
3534
- },
3535
- "e": {
3536
- "type": "string",
3537
- },
3538
- "f": {
3539
- "default": "hello",
3540
- "type": "string",
3541
- },
3542
- "g": {
3543
- "not": {},
3544
- },
3545
- "h": {
3546
- "anyOf": [
3547
- {
3548
- "type": "string",
3549
- },
3550
- {
3551
- "default": 2,
3552
- "type": "number",
3553
- },
3554
- ],
3555
- },
3556
- "i": {
3557
- "type": "string",
3558
- },
3559
- },
3560
- "required": [
3561
- "a",
3562
- "c",
3563
- "d",
3564
- "e",
3565
- "f",
3566
- "g",
3567
- "h",
3568
- ],
3569
- "type": "object",
3570
- }
3571
- `);
3572
- });
3573
-
3574
- test("examples on pipe", () => {
3575
- const schema = z
3576
- .string()
3577
- .meta({ examples: ["test"] })
3578
- .transform(Number)
3579
- // .pipe(z.transform(Number).meta({ examples: [4] }))
3580
- .meta({ examples: [4] });
3581
-
3582
- const i = z.toJSONSchema(schema, { io: "input", unrepresentable: "any" });
3583
- expect(i).toMatchInlineSnapshot(`
3584
- {
3585
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3586
- "examples": [
3587
- "test",
3588
- ],
3589
- "type": "string",
3590
- }
3591
- `);
3592
- const o = z.toJSONSchema(schema, { io: "output", unrepresentable: "any" });
3593
- expect(o).toMatchInlineSnapshot(`
3594
- {
3595
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3596
- "examples": [
3597
- 4,
3598
- ],
3599
- }
3600
- `);
3601
- });
3602
-
3603
- // test("number checks", () => {
3604
- // expect(z.toJSONSchema(z.number().int())).toMatchInlineSnapshot(`
3605
- // {
3606
- // "maximum": 9007199254740991,
3607
- // "minimum": -9007199254740991,
3608
- // "type": "integer",
3609
- // }
3610
- // `);
3611
- // expect(z.toJSONSchema(z.int())).toMatchInlineSnapshot(`
3612
- // {
3613
- // "maximum": 9007199254740991,
3614
- // "minimum": -9007199254740991,
3615
- // "type": "integer",
3616
- // }
3617
- // `);
3618
- // expect(z.toJSONSchema(z.int().positive())).toMatchInlineSnapshot(`
3619
- // {
3620
- // "exclusiveMinimum": 0,
3621
- // "maximum": 9007199254740991,
3622
- // "minimum": -9007199254740991,
3623
- // "type": "integer",
3624
- // }
3625
- // `);
3626
- // expect(z.toJSONSchema(z.int().nonnegative())).toMatchInlineSnapshot(`
3627
- // {
3628
- // "maximum": 9007199254740991,
3629
- // "minimum": 0,
3630
- // "type": "integer",
3631
- // }
3632
- // `);
3633
- // expect(z.toJSONSchema(z.int().gt(0))).toMatchInlineSnapshot(`
3634
- // {
3635
- // "exclusiveMinimum": 0,
3636
- // "maximum": 9007199254740991,
3637
- // "minimum": -9007199254740991,
3638
- // "type": "integer",
3639
- // }
3640
- // `);
3641
- // expect(z.toJSONSchema(z.int().gte(0))).toMatchInlineSnapshot(`
3642
- // {
3643
- // "maximum": 9007199254740991,
3644
- // "minimum": 0,
3645
- // "type": "integer",
3646
- // }
3647
- // `);
3648
-
3649
- // });
3650
-
3651
- test("use output type for preprocess", () => {
3652
- const a = z.preprocess((val) => String(val), z.string());
3653
-
3654
- expect(z.toJSONSchema(a, { io: "input" })).toMatchInlineSnapshot(`
3655
- {
3656
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3657
- "type": "string",
3658
- }
3659
- `);
3660
- });
3661
-
3662
- test("object property with preprocess stays required in input JSON schema", () => {
3663
- const schema = z.object({
3664
- noPreprocess: z.string(),
3665
- withPreprocess: z.preprocess((v) => v, z.string()),
3666
- optionalPreprocess: z.preprocess((v) => v, z.string().optional()),
3667
- });
3668
-
3669
- // A preprocessed property is only optional when its inner schema is — the
3670
- // transform wrapper must not make a required property optional in the input
3671
- // JSON schema (matches runtime: `schema.parse({})` rejects `withPreprocess`).
3672
- expect(z.toJSONSchema(schema, { io: "input" })).toMatchInlineSnapshot(`
3673
- {
3674
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3675
- "properties": {
3676
- "noPreprocess": {
3677
- "type": "string",
3678
- },
3679
- "optionalPreprocess": {
3680
- "type": "string",
3681
- },
3682
- "withPreprocess": {
3683
- "type": "string",
3684
- },
3685
- },
3686
- "required": [
3687
- "noPreprocess",
3688
- "withPreprocess",
3689
- ],
3690
- "type": "object",
3691
- }
3692
- `);
3693
- });
3694
-
3695
- test("input JSON schema resolves requiredness past transform and catch wrappers", () => {
3696
- const required = (schema: z.ZodObject) =>
3697
- (z.toJSONSchema(schema, { io: "input" }) as z.core.JSONSchema.ObjectSchema).required;
3698
- const id = (v: unknown) => v;
3699
-
3700
- // catch observes an absent key at runtime, but its declared input type stays required (#5003)
3701
- expect(required(z.object({ a: z.string().catch("x") }))).toEqual(["a"]);
3702
- expect(required(z.object({ a: z.string().optional().catch("x") }))).toBeUndefined();
3703
- // nested preprocess and the legacy transform-pipe form both resolve through to the inner schema
3704
- expect(required(z.object({ a: z.preprocess(id, z.preprocess(id, z.string())) }))).toEqual(["a"]);
3705
- expect(required(z.object({ a: z.transform((v: unknown) => String(v)).pipe(z.string()) }))).toEqual(["a"]);
3706
- });
3707
-
3708
- test("strip output-side examples from input JSON schema for codec", () => {
3709
- const codec = z
3710
- .codec(z.string(), z.number(), { decode: (s) => Number(s), encode: (n) => String(n) })
3711
- .meta({ examples: [42] });
3712
-
3713
- expect(z.toJSONSchema(codec, { io: "input" })).toMatchInlineSnapshot(`
3714
- {
3715
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3716
- "type": "string",
3717
- }
3718
- `);
3719
- expect(z.toJSONSchema(codec, { io: "output" })).toMatchInlineSnapshot(`
3720
- {
3721
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3722
- "examples": [
3723
- 42,
3724
- ],
3725
- "type": "number",
3726
- }
3727
- `);
3728
- });
3729
-
3730
- // test("isTransforming", () => {
3731
- // const tx = z.core.isTransforming;
3732
- // expect(tx(z.string())).toEqual(false);
3733
- // expect(tx(z.string().transform((val) => val))).toEqual(true);
3734
- // expect(tx(z.string().pipe(z.string()))).toEqual(false);
3735
- // expect(
3736
- // tx(
3737
- // z
3738
- // .string()
3739
- // .transform((val) => val)
3740
- // .pipe(z.string())
3741
- // )
3742
- // ).toEqual(true);
3743
-
3744
- // const a = z.transform((val) => val);
3745
- // expect(tx(z.transform((val) => val))).toEqual(true);
3746
- // expect(tx(a.optional())).toEqual(true);
3747
-
3748
- // const b = z.string().optional();
3749
- // expect(tx(b)).toEqual(false);
3750
-
3751
- // const c = z.string().prefault("hello");
3752
- // expect(tx(c)).toEqual(false);
3753
-
3754
- // const d = z.string().default("hello");
3755
- // expect(tx(d)).toEqual(false);
3756
- // });
3757
-
3758
- test("flatten simple intersections", () => {
3759
- const FirstSchema = z.object({
3760
- testNum: z.number(),
3761
- });
3762
-
3763
- const SecondSchema = z.object({
3764
- testStr: z.string(),
3765
- });
3766
-
3767
- const ThirdSchema = z.object({
3768
- testBool: z.boolean(),
3769
- });
3770
-
3771
- const HelloSchema = FirstSchema.and(SecondSchema).and(ThirdSchema).describe("123");
3772
-
3773
- // Zod 3
3774
- // console.log(JSON.stringify(zodToJsonSchema(HelloSchema), null, 2));
3775
-
3776
- // Zod 4
3777
- const result = z.toJSONSchema(HelloSchema, { target: "draft-7" });
3778
- expect(result).toMatchInlineSnapshot(`
3779
- {
3780
- "$schema": "http://json-schema.org/draft-07/schema#",
3781
- "additionalProperties": false,
3782
- "description": "123",
3783
- "properties": {
3784
- "testBool": {
3785
- "type": "boolean",
3786
- },
3787
- "testNum": {
3788
- "type": "number",
3789
- },
3790
- "testStr": {
3791
- "type": "string",
3792
- },
3793
- },
3794
- "required": [
3795
- "testNum",
3796
- "testStr",
3797
- "testBool",
3798
- ],
3799
- "type": "object",
3800
- }
3801
- `);
3802
- });
3803
-
3804
- test("z.file()", () => {
3805
- const a = z.file();
3806
- expect(z.toJSONSchema(a)).toMatchInlineSnapshot(`
3807
- {
3808
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3809
- "contentEncoding": "binary",
3810
- "format": "binary",
3811
- "type": "string",
3812
- }
3813
- `);
3814
-
3815
- const b = z.file().mime("image/png").min(1000).max(10000);
3816
- expect(z.toJSONSchema(b)).toMatchInlineSnapshot(`
3817
- {
3818
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3819
- "contentEncoding": "binary",
3820
- "contentMediaType": "image/png",
3821
- "format": "binary",
3822
- "maxLength": 10000,
3823
- "minLength": 1000,
3824
- "type": "string",
3825
- }
3826
- `);
3827
-
3828
- const c = z.file().mime(["image/png", "image/jpg"]).min(1000).max(10000);
3829
- expect(z.toJSONSchema(c)).toMatchInlineSnapshot(`
3830
- {
3831
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3832
- "anyOf": [
3833
- {
3834
- "contentMediaType": "image/png",
3835
- },
3836
- {
3837
- "contentMediaType": "image/jpg",
3838
- },
3839
- ],
3840
- "contentEncoding": "binary",
3841
- "format": "binary",
3842
- "maxLength": 10000,
3843
- "minLength": 1000,
3844
- "type": "string",
3845
- }
3846
- `);
3847
- });
3848
-
3849
- test("custom toJSONSchema", () => {
3850
- const schema = z.instanceof(Date);
3851
- schema._zod.toJSONSchema = () => ({
3852
- type: "string",
3853
- format: "date-time",
3854
- });
3855
-
3856
- expect(z.toJSONSchema(schema)).toMatchInlineSnapshot(`
3857
- {
3858
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3859
- "format": "date-time",
3860
- "type": "string",
3861
- }
3862
- `);
3863
- });
3864
-
3865
- test("cycle detection - root", () => {
3866
- const schema = z.object({
3867
- name: z.string(),
3868
- get subcategories() {
3869
- return z.array(schema);
3870
- },
3871
- });
3872
-
3873
- expect(() => z.toJSONSchema(schema, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
3874
- [Error: Cycle detected: #/properties/subcategories/items/<root>
3875
-
3876
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
3877
- `);
3878
- });
3879
-
3880
- test("cycle detection - mutual recursion", () => {
3881
- const A = z.object({
3882
- name: z.string(),
3883
- get subcategories() {
3884
- return z.array(B);
3885
- },
3886
- });
3887
-
3888
- const B = z.object({
3889
- name: z.string(),
3890
- get subcategories() {
3891
- return z.array(A);
3892
- },
3893
- });
3894
-
3895
- expect(() => z.toJSONSchema(A, { cycles: "throw" })).toThrowErrorMatchingInlineSnapshot(`
3896
- [Error: Cycle detected: #/properties/subcategories/items/properties/subcategories/items/<root>
3897
-
3898
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.]
3899
- `);
3900
- });
3901
-
3902
- test("recursive lazy with describe does not stack overflow", () => {
3903
- const NodeSchema: z.ZodType = z.lazy(() =>
3904
- z
3905
- .object({
3906
- value: z.string().describe("node value"),
3907
- children: z.array(NodeSchema.describe("child node")).optional().describe("child list"),
3908
- })
3909
- .describe("tree node")
3910
- );
3911
-
3912
- const result = z.toJSONSchema(NodeSchema, { cycles: "ref", reused: "ref" });
3913
- expect(result).toBeDefined();
3914
- expect(result.$defs).toBeDefined();
3915
- });
3916
-
3917
- test("__proto__ shape key is emitted as an own property", () => {
3918
- const schema = z.object({ ["__proto__"]: z.literal("admin"), role: z.string() });
3919
- const result = z.toJSONSchema(schema, { io: "input" });
3920
-
3921
- expect(result.required).toEqual(["__proto__", "role"]);
3922
- // every required key needs a matching entry in properties
3923
- for (const key of result.required!) {
3924
- expect(Object.prototype.hasOwnProperty.call(result.properties, key)).toBe(true);
3925
- }
3926
- expect(JSON.parse(JSON.stringify(result)).properties.__proto__).toEqual({ type: "string", const: "admin" });
3927
- });
3928
-
3929
- test("__proto__ registry id is emitted as an own entry", () => {
3930
- const myRegistry = z.registry<{ id: string }>();
3931
- myRegistry.add(z.object({ a: z.string() }), { id: "__proto__" });
3932
- myRegistry.add(z.object({ b: z.string() }), { id: "normal" });
3933
-
3934
- expect(Object.keys(z.toJSONSchema(myRegistry).schemas)).toEqual(["__proto__", "normal"]);
3935
- });
3936
-
3937
- test("__proto__ def id emits a resolvable $ref", () => {
3938
- const myRegistry = z.registry<{ id: string }>();
3939
- const Inner = z.object({ x: z.string() });
3940
- myRegistry.add(Inner, { id: "__proto__" });
3941
-
3942
- const json = JSON.parse(JSON.stringify(z.toJSONSchema(z.object({ a: Inner, b: Inner }), { metadata: myRegistry })));
3943
- expect(json.properties.a.$ref).toBe("#/$defs/__proto__");
3944
- expect(json.$defs.__proto__).toBeDefined();
3945
- });
3946
-
3947
- test("__proto__ patternProperties key is emitted as an own property", () => {
3948
- const result = z.toJSONSchema(z.looseRecord(z.string().regex(/__proto__/), z.string()));
3949
-
3950
- expect(Object.getPrototypeOf(result.patternProperties)).toBe(Object.prototype);
3951
- expect(Object.prototype.hasOwnProperty.call(result.patternProperties, "__proto__")).toBe(true);
3952
- expect(result.patternProperties?.__proto__).toEqual({ type: "string" });
3953
- });
3954
-
3955
- test("__proto__ metadata survives direct and wrapper metadata merges", () => {
3956
- for (const schema of [z.string(), z.readonly(z.string())]) {
3957
- const registry = z.registry<Record<string, unknown>>();
3958
- registry.add(schema, Object.fromEntries([["__proto__", { marker: true }]]));
3959
-
3960
- const result: any = z.toJSONSchema(schema, { metadata: registry });
3961
- expect(Object.getPrototypeOf(result)).toBe(Object.prototype);
3962
- expect(Object.prototype.hasOwnProperty.call(result, "__proto__")).toBe(true);
3963
- expect(result.__proto__).toEqual({ marker: true });
3964
- expect(JSON.parse(JSON.stringify(result)).__proto__).toEqual({ marker: true });
3965
- }
3966
- });
3967
-
3968
- test("partialRecord does not require finite keys", () => {
3969
- const result = z.toJSONSchema(z.partialRecord(z.enum(["__proto__", "b"]), z.string()));
3970
-
3971
- expect(result.required).toBeUndefined();
3972
- expect(result.propertyNames).toEqual({ type: "string", enum: ["__proto__", "b"] });
3973
- expect(result.additionalProperties).toEqual({ type: "string" });
3974
- });
3975
-
3976
- describe("unrepresentable callback", () => {
3977
- test("is consulted for every unrepresentable type", () => {
3978
- const seen: string[] = [];
3979
- const collect: z.core.UnrepresentableHandler<z.core.$ZodTypes> = ({ zodSchema }) => {
3980
- seen.push(zodSchema._zod.def.type);
3981
- return "any";
3982
- };
3983
-
3984
- const schemas = [
3985
- z.bigint(),
3986
- z.symbol(),
3987
- z.undefined(),
3988
- z.void(),
3989
- z.date(),
3990
- z.nan(),
3991
- z.custom<string>(),
3992
- z.map(z.string(), z.string()),
3993
- z.set(z.string()),
3994
- z.transform((x: unknown) => x),
3995
- z.literal([undefined]),
3996
- z.literal([1n]),
3997
- z.string().catch(() => {
3998
- throw new Error("dynamic");
3999
- }),
4000
- // z.function() is not a ZodType, but its processor is reachable through the same path
4001
- z.function() as unknown as z.ZodType,
4002
- ];
4003
- for (const schema of schemas) z.toJSONSchema(schema, { unrepresentable: collect });
4004
-
4005
- expect(seen).toEqual([
4006
- "bigint",
4007
- "symbol",
4008
- "undefined",
4009
- "void",
4010
- "date",
4011
- "nan",
4012
- "custom",
4013
- "map",
4014
- "set",
4015
- "transform",
4016
- "literal",
4017
- "literal",
4018
- "catch",
4019
- "function",
4020
- ]);
4021
- });
4022
-
4023
- test("returned JSON Schema replaces the unrepresentable node", () => {
4024
- // the motivating case: represent dates, keep throwing for everything else
4025
- const params: z.core.ToJSONSchemaParams = {
4026
- unrepresentable: ({ zodSchema }) =>
4027
- zodSchema._zod.def.type === "date" ? { type: "string", format: "date-time" } : "throw",
4028
- };
4029
- expect(z.toJSONSchema(z.object({ when: z.date() }), params)).toMatchInlineSnapshot(`
4030
- {
4031
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4032
- "additionalProperties": false,
4033
- "properties": {
4034
- "when": {
4035
- "format": "date-time",
4036
- "type": "string",
4037
- },
4038
- },
4039
- "required": [
4040
- "when",
4041
- ],
4042
- "type": "object",
4043
- }
4044
- `);
4045
- expect(() => z.toJSONSchema(z.object({ id: z.bigint() }), params)).toThrow(
4046
- "BigInt cannot be represented in JSON Schema"
4047
- );
4048
- });
4049
-
4050
- test("`throw` and `undefined` returns produce the default error", () => {
4051
- expect(() => z.toJSONSchema(z.date(), { unrepresentable: () => "throw" })).toThrow(
4052
- "Date cannot be represented in JSON Schema"
4053
- );
4054
- expect(() => z.toJSONSchema(z.date(), { unrepresentable: () => undefined })).toThrow(
4055
- "Date cannot be represented in JSON Schema"
4056
- );
4057
- });
4058
-
4059
- test("`any` return matches the string option", () => {
4060
- expect(z.toJSONSchema(z.date(), { unrepresentable: () => "any" })).toEqual(
4061
- z.toJSONSchema(z.date(), { unrepresentable: "any" })
4062
- );
4063
- });
4064
-
4065
- test("`message` distinguishes sites that share a schema", () => {
4066
- const seen: string[] = [];
4067
- expect(
4068
- z.toJSONSchema(z.literal([undefined, 1n, "a"]), {
4069
- unrepresentable: ({ zodSchema, message }) => {
4070
- seen.push(`${zodSchema._zod.def.type}: ${message}`);
4071
- return "any";
4072
- },
4073
- })
4074
- ).toMatchInlineSnapshot(`
4075
- {
4076
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4077
- "enum": [
4078
- 1,
4079
- "a",
4080
- ],
4081
- }
4082
- `);
4083
- // same `zodSchema`, different message -- the only way to tell the two literal sites apart
4084
- expect(seen).toEqual([
4085
- "literal: Literal `undefined` cannot be represented in JSON Schema",
4086
- "literal: BigInt literals cannot be represented in JSON Schema",
4087
- ]);
4088
- });
4089
-
4090
- test("errors thrown by the callback propagate", () => {
4091
- expect(() =>
4092
- z.toJSONSchema(z.object({ when: z.date() }), {
4093
- unrepresentable: ({ zodSchema, path }) => {
4094
- throw new Error(`${zodSchema._zod.def.type} at /${path.join("/")}`);
4095
- },
4096
- })
4097
- ).toThrow("date at /properties/when");
4098
- });
4099
-
4100
- test("runs before `override`", () => {
4101
- const order: string[] = [];
4102
- expect(
4103
- z.toJSONSchema(z.date(), {
4104
- unrepresentable: () => {
4105
- order.push("unrepresentable");
4106
- return { type: "string" };
4107
- },
4108
- override: (ctx) => {
4109
- order.push("override");
4110
- if (ctx.jsonSchema.type === "string") ctx.jsonSchema.format = "date-time";
4111
- },
4112
- })
4113
- ).toMatchInlineSnapshot(`
4114
- {
4115
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4116
- "format": "date-time",
4117
- "type": "string",
4118
- }
4119
- `);
4120
- expect(order).toEqual(["unrepresentable", "override"]);
4121
- });
4122
-
4123
- test("a returned schema replaces the whole literal", () => {
4124
- expect(
4125
- z.toJSONSchema(z.literal(["a", 1n]), {
4126
- unrepresentable: () => ({ type: "string", pattern: "^\\d+$" }),
4127
- })
4128
- ).toMatchInlineSnapshot(`
4129
- {
4130
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4131
- "pattern": "^\\d+$",
4132
- "type": "string",
4133
- }
4134
- `);
4135
-
4136
- // "any" keeps the existing per-value behavior: undefined dropped, bigint coerced
4137
- expect(z.toJSONSchema(z.literal(["a", 1n, undefined]), { unrepresentable: () => "any" })).toEqual(
4138
- z.toJSONSchema(z.literal(["a", 1n, undefined]), { unrepresentable: "any" })
4139
- );
4140
- });
4141
-
4142
- const dateToString: z.core.ToJSONSchemaParams["unrepresentable"] = ({ zodSchema }) =>
4143
- zodSchema._zod.def.type === "date" ? { type: "string", format: "date-time" } : "throw";
4144
-
4145
- test("emits a valid OpenAPI 3.0 schema", async () => {
4146
- const jsonSchema = z.toJSONSchema(z.object({ start: z.date() }), {
4147
- target: "openapi-3.0",
4148
- unrepresentable: dateToString,
4149
- });
4150
- expect(jsonSchema).toMatchInlineSnapshot(`
4151
- {
4152
- "additionalProperties": false,
4153
- "properties": {
4154
- "start": {
4155
- "format": "date-time",
4156
- "type": "string",
4157
- },
4158
- },
4159
- "required": [
4160
- "start",
4161
- ],
4162
- "type": "object",
4163
- }
4164
- `);
4165
- await expect(validateOpenAPI30Schema(jsonSchema)).resolves.toBe(true);
4166
- });
4167
-
4168
- test("the returned schema survives extraction into $defs", () => {
4169
- const When = z.date().meta({ id: "When" });
4170
- expect(
4171
- z.toJSONSchema(z.object({ start: When, end: When }), { unrepresentable: dateToString })
4172
- ).toMatchInlineSnapshot(`
4173
- {
4174
- "$defs": {
4175
- "When": {
4176
- "format": "date-time",
4177
- "type": "string",
4178
- },
4179
- },
4180
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4181
- "additionalProperties": false,
4182
- "properties": {
4183
- "end": {
4184
- "$ref": "#/$defs/When",
4185
- },
4186
- "start": {
4187
- "$ref": "#/$defs/When",
4188
- },
4189
- },
4190
- "required": [
4191
- "start",
4192
- "end",
4193
- ],
4194
- "type": "object",
4195
- }
4196
- `);
4197
- });
4198
-
4199
- test("applies to dynamic catch values", () => {
4200
- const schema = z.string().catch(() => {
4201
- throw new Error("dynamic");
4202
- });
4203
- expect(
4204
- z.toJSONSchema(schema, {
4205
- unrepresentable: () => ({ default: "fallback" }),
4206
- })
4207
- ).toMatchInlineSnapshot(`
4208
- {
4209
- "$schema": "https://json-schema.org/draft/2020-12/schema",
4210
- "default": "fallback",
4211
- "type": "string",
4212
- }
4213
- `);
4214
- });
4215
- });
4216
-
4217
- describe("intersection folding", () => {
4218
- const TARGETS = ["draft-2020-12", "draft-07", "draft-04", "openapi-3.0"] as const;
4219
- const body = (schema: z.ZodType, params?: Parameters<typeof z.toJSONSchema>[1]) => {
4220
- const { $schema, ...rest } = z.toJSONSchema(schema, params) as Record<string, unknown>;
4221
- return rest;
4222
- };
4223
-
4224
- test("two objects become one object", () => {
4225
- expect(body(z.object({ name: z.string() }).and(z.object({ age: z.number() })))).toMatchInlineSnapshot(`
4226
- {
4227
- "additionalProperties": false,
4228
- "properties": {
4229
- "age": {
4230
- "type": "number",
4231
- },
4232
- "name": {
4233
- "type": "string",
4234
- },
4235
- },
4236
- "required": [
4237
- "name",
4238
- "age",
4239
- ],
4240
- "type": "object",
4241
- }
4242
- `);
4243
- });
4244
-
4245
- test("the folded shape is identical on every target", () => {
4246
- const schema = z.object({ name: z.string() }).and(z.object({ age: z.number() }));
4247
- const bodies = TARGETS.map((target) => body(schema, { target }));
4248
- for (const emitted of bodies) expect(emitted).toEqual(bodies[0]);
4249
- });
4250
-
4251
- test("closed only when every member is closed", () => {
4252
- expect(body(z.strictObject({ a: z.string() }).and(z.strictObject({ b: z.number() })))).toMatchObject({
4253
- additionalProperties: false,
4254
- });
4255
- // 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.
4256
- expect(body(z.looseObject({ a: z.string() }).and(z.object({ b: z.number() })))).not.toHaveProperty(
4257
- "additionalProperties"
4258
- );
4259
- });
4260
-
4261
- test("chained and nested intersections fold flat", () => {
4262
- const chained = z
4263
- .object({ a: z.string() })
4264
- .and(z.object({ b: z.string() }))
4265
- .and(z.object({ c: z.string() }));
4266
- expect(body(chained)).toMatchObject({ properties: { a: {}, b: {}, c: {} }, required: ["a", "b", "c"] });
4267
- const nested = z.object({ a: z.string() }).and(z.object({ b: z.string() }).and(z.object({ c: z.string() })));
4268
- expect(body(nested)).toEqual(body(chained));
4269
- });
4270
-
4271
- test("required is the union, and an optional key stays optional", () => {
4272
- expect(body(z.object({ a: z.string().optional() }).and(z.object({ b: z.string() })))).toMatchObject({
4273
- properties: { a: { type: "string" }, b: { type: "string" } },
4274
- required: ["b"],
4275
- });
4276
- });
4277
-
4278
- test("a key both members declare has to satisfy both", () => {
4279
- // identical declarations collapse
4280
- expect(body(z.object({ k: z.string() }).and(z.object({ k: z.string() })))).toMatchObject({
4281
- properties: { k: { type: "string" } },
4282
- });
4283
- // object declarations fold, matching the parser's deep merge
4284
- expect(
4285
- body(z.object({ k: z.object({ a: z.string() }) }).and(z.object({ k: z.object({ b: z.string() }) })))
4286
- ).toMatchObject({
4287
- properties: { k: { type: "object", properties: { a: {}, b: {} }, required: ["a", "b"] } },
4288
- });
4289
- // anything else stays an intersection one level down
4290
- expect(body(z.object({ k: z.string() }).and(z.object({ k: z.number() })))).toMatchObject({
4291
- properties: { k: { allOf: [{ type: "string" }, { type: "number" }] } },
4292
- });
4293
- });
4294
-
4295
- test("an intersection distributes over a union", () => {
4296
- const schema = z
4297
- .object({ name: z.string() })
4298
- .and(
4299
- z.discriminatedUnion("type", [
4300
- z.object({ type: z.literal("a"), value: z.string() }),
4301
- z.object({ type: z.literal("b"), count: z.number() }),
4302
- ])
4303
- );
4304
- expect(body(schema)).toMatchObject({
4305
- oneOf: [
4306
- { type: "object", properties: { name: {}, type: {}, value: {} }, additionalProperties: false },
4307
- { type: "object", properties: { name: {}, type: {}, count: {} }, additionalProperties: false },
4308
- ],
4309
- });
4310
- const inclusive = z
4311
- .object({ name: z.string() })
4312
- .and(z.union([z.object({ v: z.string() }), z.object({ c: z.number() })]));
4313
- expect(body(inclusive)).toMatchObject({
4314
- anyOf: [{ properties: { name: {}, v: {} } }, { properties: { name: {}, c: {} } }],
4315
- });
4316
- });
4317
-
4318
- test("input conversion has nothing to close", () => {
4319
- expect(body(z.object({ a: z.string() }).and(z.object({ b: z.string() })), { io: "input" })).toEqual({
4320
- type: "object",
4321
- properties: { a: { type: "string" }, b: { type: "string" } },
4322
- required: ["a", "b"],
4323
- });
4324
- });
4325
-
4326
- test("folds through a property and through z.lazy", () => {
4327
- expect(body(z.object({ inner: z.object({ a: z.string() }).and(z.object({ b: z.string() })) }))).toMatchObject({
4328
- properties: { inner: { type: "object", properties: { a: {}, b: {} } } },
4329
- });
4330
- const self: z.ZodType = z.lazy(() => z.object({ a: z.string() }).and(z.object({ next: z.optional(self) })));
4331
- expect(body(self)).toMatchObject({ type: "object", properties: { a: {}, next: { $ref: "#" } } });
4332
- });
4333
-
4334
- test("metadata on the intersection itself survives", () => {
4335
- expect(
4336
- body(
4337
- z
4338
- .object({ a: z.string() })
4339
- .and(z.object({ b: z.string() }))
4340
- .meta({ title: "T" })
4341
- )
4342
- ).toMatchObject({
4343
- title: "T",
4344
- type: "object",
4345
- properties: { a: {}, b: {} },
4346
- });
4347
- });
4348
-
4349
- test("a catchall constrains the sibling's keys too", () => {
4350
- // 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.
4351
- const schema = z
4352
- .object({ a: z.string() })
4353
- .catchall(z.number())
4354
- .and(z.object({ b: z.string() }));
4355
- expect(body(schema)).toEqual({
4356
- type: "object",
4357
- properties: { a: { type: "string" }, b: { allOf: [{ type: "number" }, { type: "string" }] } },
4358
- required: ["a", "b"],
4359
- additionalProperties: { type: "number" },
4360
- });
4361
- });
4362
-
4363
- test("two catchalls both constrain the keys neither declares", () => {
4364
- const schema = z
4365
- .object({})
4366
- .catchall(z.number())
4367
- .and(z.object({}).catchall(z.number().min(0)));
4368
- expect(body(schema)).toEqual({
4369
- type: "object",
4370
- properties: {},
4371
- additionalProperties: { allOf: [{ type: "number" }, { type: "number", minimum: 0 }] },
4372
- });
4373
- expect(schema.safeParse({ zz: 5 }).success).toBe(true);
4374
- expect(schema.safeParse({ zz: -1 }).success).toBe(false);
4375
- });
4376
-
4377
- test("the emitted openness agrees with the parser for every pair of object modes", () => {
4378
- const modes = {
4379
- strip: (shape: z.ZodRawShape) => z.object(shape),
4380
- strict: (shape: z.ZodRawShape) => z.strictObject(shape),
4381
- loose: (shape: z.ZodRawShape) => z.looseObject(shape),
4382
- catchall: (shape: z.ZodRawShape) => z.object(shape).catchall(z.number()),
4383
- };
4384
- const grid: Record<string, unknown> = {};
4385
- for (const [leftName, left] of Object.entries(modes)) {
4386
- for (const [rightName, right] of Object.entries(modes)) {
4387
- const schema = left({ a: z.string() }).and(right({ b: z.number() }));
4388
- const emitted = body(schema) as { additionalProperties?: unknown };
4389
- grid[`${leftName} & ${rightName}`] = emitted.additionalProperties ?? "open";
4390
-
4391
- // Whatever the emitted keyword says, it has to agree with what the parser does with a key neither member declares.
4392
- const parsed = schema.safeParse({ a: "s", b: 1, zz: 7 });
4393
- const keepsUnknown = parsed.success && Object.prototype.hasOwnProperty.call(parsed.data, "zz");
4394
- if (keepsUnknown) expect(emitted.additionalProperties).not.toBe(false);
4395
- }
4396
- }
4397
- expect(grid).toMatchInlineSnapshot(`
4398
- {
4399
- "catchall & catchall": {
4400
- "type": "number",
4401
- },
4402
- "catchall & loose": {
4403
- "type": "number",
4404
- },
4405
- "catchall & strict": {
4406
- "type": "number",
4407
- },
4408
- "catchall & strip": {
4409
- "type": "number",
4410
- },
4411
- "loose & catchall": {
4412
- "type": "number",
4413
- },
4414
- "loose & loose": "open",
4415
- "loose & strict": "open",
4416
- "loose & strip": "open",
4417
- "strict & catchall": {
4418
- "type": "number",
4419
- },
4420
- "strict & loose": "open",
4421
- "strict & strict": false,
4422
- "strict & strip": false,
4423
- "strip & catchall": {
4424
- "type": "number",
4425
- },
4426
- "strip & loose": "open",
4427
- "strip & strict": false,
4428
- "strip & strip": false,
4429
- }
4430
- `);
4431
- });
4432
-
4433
- test("a __proto__ key stays an own property", () => {
4434
- const folded = body(z.object({ ["__proto__"]: z.string() }).and(z.object({ b: z.number() }))) as any;
4435
- expect(Object.prototype.hasOwnProperty.call(folded.properties, "__proto__")).toBe(true);
4436
- expect(folded.required).toEqual(["__proto__", "b"]);
4437
- });
4438
- });
4439
-
4440
- describe("intersection folding declines", () => {
4441
- // 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.
4442
- const allOf = (schema: z.ZodType, params?: Parameters<typeof z.toJSONSchema>[1]) =>
4443
- (z.toJSONSchema(schema, params) as any).allOf;
4444
-
4445
- test("a member that is a reference keeps its reference", () => {
4446
- const named = z.object({ a: z.string() }).meta({ id: "Named" });
4447
- expect(allOf(named.and(z.object({ b: z.string() })))[0]).toEqual({ $ref: "#/$defs/Named" });
4448
-
4449
- const shared = z.object({ c: z.string() });
4450
- const reused = z.toJSONSchema(z.object({ x: shared.and(z.object({ d: z.string() })), y: shared }), {
4451
- reused: "ref",
4452
- }) as any;
4453
- expect(reused.properties.x.allOf[0]).toEqual({ $ref: "#/$defs/__schema0" });
4454
-
4455
- const cyclic: any = z.object({
4456
- get next() {
4457
- return z.optional(cyclic);
4458
- },
4459
- n: z.string(),
4460
- });
4461
- expect(allOf(cyclic.and(z.object({ m: z.string() })))[0].$ref).toBe("#/$defs/__schema0");
4462
- });
4463
-
4464
- test("an annotated member keeps its place", () => {
4465
- expect(
4466
- allOf(
4467
- z
4468
- .object({ a: z.string() })
4469
- .describe("A")
4470
- .and(z.object({ b: z.string() }))
4471
- )[0]
4472
- ).toMatchObject({
4473
- description: "A",
4474
- });
4475
- });
4476
-
4477
- test("members that are not plain objects are left alone", () => {
4478
- expect(allOf(z.intersection(z.string().min(2), z.string().max(5)))).toHaveLength(2);
4479
- expect(allOf(z.object({ a: z.string() }).and(z.nullable(z.object({ b: z.string() }))))).toHaveLength(2);
4480
- expect(
4481
- allOf(z.object({ label: z.string() }).and(z.looseRecord(z.string().regex(/^label:[a-z]{2}$/), z.string())))
4482
- ).toHaveLength(2);
4483
- });
4484
-
4485
- test("a shared member is never rewritten for its other uses", () => {
4486
- const shared = z.object({ c: z.string() });
4487
- const result = z.toJSONSchema(z.object({ x: shared.and(z.object({ d: z.string() })), y: shared })) as any;
4488
- expect(result.properties.x).toMatchObject({ properties: { c: {}, d: {} }, additionalProperties: false });
4489
- // `y` is the same Zod schema, emitted separately, and keeps the closedness it had on its own.
4490
- expect(result.properties.y).toEqual({
4491
- type: "object",
4492
- properties: { c: { type: "string" } },
4493
- required: ["c"],
4494
- additionalProperties: false,
4495
- });
4496
- });
4497
-
4498
- test("registry conversion keeps its cross-references", () => {
4499
- const registry = z.registry<{ id: string }>();
4500
- const left = z.object({ p: z.string() });
4501
- const right = z.object({ q: z.string() });
4502
- registry.add(left, { id: "P" });
4503
- registry.add(right, { id: "Q" });
4504
- registry.add(left.and(right), { id: "PQ" });
4505
- expect((z.toJSONSchema(registry) as any).schemas.PQ.allOf).toEqual([{ $ref: "P" }, { $ref: "Q" }]);
4506
- });
4507
-
4508
- test("override still runs, and sees the intersection before it folds", () => {
4509
- const schema = z.object({ a: z.string() }).and(z.object({ b: z.string() }));
4510
- const result = z.toJSONSchema(schema, {
4511
- override(ctx) {
4512
- if ((ctx.jsonSchema as any).allOf) (ctx.jsonSchema as any).title = "intersection";
4513
- },
4514
- }) as any;
4515
- expect(result).toMatchObject({ title: "intersection", type: "object", properties: { a: {}, b: {} } });
4516
- });
4517
-
4518
- test("an override that writes object keywords wins over the fold", () => {
4519
- // The override runs first, so anything it puts on the intersection is deliberate. Folding would overwrite it silently, so the fold stands down instead.
4520
- const result = z.toJSONSchema(z.object({ a: z.string() }).and(z.object({ b: z.string() })), {
4521
- override(ctx) {
4522
- if ((ctx.jsonSchema as any).allOf) (ctx.jsonSchema as any).additionalProperties = true;
4523
- },
4524
- }) as any;
4525
- expect(result.additionalProperties).toBe(true);
4526
- expect(result.allOf).toHaveLength(2);
4527
- });
4528
-
4529
- test("more than one union member is left alone rather than multiplied out", () => {
4530
- // 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.
4531
- const schema = z
4532
- .object({ a: z.string() })
4533
- .and(z.union([z.object({ v: z.string() }), z.object({ w: z.string() })]))
4534
- .and(z.union([z.object({ x: z.string() }), z.object({ y: z.string() })]));
4535
- expect(allOf(schema)).toHaveLength(3);
4536
- });
4537
- });