aws-runtime-bridge 1.9.135 → 1.9.139

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