@vitos-pizza/vitos-pizza 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (931) hide show
  1. package/AGENTS.md +6 -4
  2. package/CHANGELOG.md +27 -0
  3. package/README.md +6 -4
  4. package/package.json +17 -13
  5. package/packages/agent-mode/extensions/index.ts +12 -10
  6. package/packages/agent-mode/package.json +5 -4
  7. package/packages/agent-mode/src/plan-instructions.ts +20 -56
  8. package/packages/keybindings/extensions/index.ts +14 -6
  9. package/packages/keybindings/package.json +1 -1
  10. package/packages/keybindings/presets/shortcuts.json +1 -1
  11. package/packages/permission-system/package.json +2 -2
  12. package/packages/question/package.json +1 -1
  13. package/packages/session-title/package.json +3 -3
  14. package/packages/settings-preset/extensions/index.ts +53 -0
  15. package/packages/settings-preset/package.json +19 -0
  16. package/packages/settings-preset/presets/settings.json +15 -0
  17. package/packages/settings-preset/tsconfig.json +11 -0
  18. package/packages/subagents/agents/planner.md +10 -14
  19. package/packages/subagents/agents/scout.md +10 -18
  20. package/packages/subagents/agents/title.md +1 -0
  21. package/packages/subagents/agents/worker.md +7 -19
  22. package/packages/subagents/package.json +1 -1
  23. package/packages/subagents/skills/subagents/SKILL.md +27 -28
  24. package/packages/subagents/src/agents.ts +17 -0
  25. package/packages/subagents/src/execute-subagent.ts +3 -6
  26. package/packages/subagents/src/run-agent.ts +2 -1
  27. package/packages/todoist/package.json +1 -1
  28. package/packages/ui-enhancements/package.json +1 -1
  29. package/packages/ui-enhancements/src/chrome/border-status.ts +76 -3
  30. package/packages/ui-enhancements/src/chrome/execute-prompt.ts +83 -0
  31. package/packages/websearch/extensions/index.ts +4 -2
  32. package/packages/websearch/package.json +1 -1
  33. package/scripts/sync-pi-manifest.mjs +1 -1
  34. package/node_modules/@vitos-pizza/agent-mode/extensions/index.ts +0 -138
  35. package/node_modules/@vitos-pizza/agent-mode/package.json +0 -31
  36. package/node_modules/@vitos-pizza/agent-mode/src/apply-mode.ts +0 -60
  37. package/node_modules/@vitos-pizza/agent-mode/src/mode-events.ts +0 -102
  38. package/node_modules/@vitos-pizza/agent-mode/src/modes.ts +0 -43
  39. package/node_modules/@vitos-pizza/agent-mode/src/plan-instructions.ts +0 -85
  40. package/node_modules/@vitos-pizza/agent-mode/tests/apply-mode.test.ts +0 -36
  41. package/node_modules/@vitos-pizza/agent-mode/tests/mode-events.test.ts +0 -22
  42. package/node_modules/@vitos-pizza/agent-mode/tests/modes.test.ts +0 -38
  43. package/node_modules/@vitos-pizza/agent-mode/tests/plan-instructions.test.ts +0 -68
  44. package/node_modules/@vitos-pizza/agent-mode/tsconfig.json +0 -13
  45. package/node_modules/@vitos-pizza/agent-mode/vitest.config.ts +0 -8
  46. package/node_modules/@vitos-pizza/keybindings/extensions/index.ts +0 -104
  47. package/node_modules/@vitos-pizza/keybindings/package.json +0 -26
  48. package/node_modules/@vitos-pizza/keybindings/presets/shortcuts.json +0 -3
  49. package/node_modules/@vitos-pizza/keybindings/src/bind.ts +0 -57
  50. package/node_modules/@vitos-pizza/keybindings/src/config.ts +0 -84
  51. package/node_modules/@vitos-pizza/keybindings/src/registry.ts +0 -43
  52. package/node_modules/@vitos-pizza/keybindings/src/types.ts +0 -54
  53. package/node_modules/@vitos-pizza/keybindings/tests/config.test.ts +0 -83
  54. package/node_modules/@vitos-pizza/keybindings/tests/registry.test.ts +0 -142
  55. package/node_modules/@vitos-pizza/keybindings/tsconfig.json +0 -13
  56. package/node_modules/@vitos-pizza/keybindings/vitest.config.ts +0 -8
  57. package/node_modules/@vitos-pizza/permission-system/extensions/index.ts +0 -162
  58. package/node_modules/@vitos-pizza/permission-system/package.json +0 -34
  59. package/node_modules/@vitos-pizza/permission-system/presets/default.json +0 -36
  60. package/node_modules/@vitos-pizza/permission-system/presets/plan.json +0 -25
  61. package/node_modules/@vitos-pizza/permission-system/presets/yolo.json +0 -15
  62. package/node_modules/@vitos-pizza/permission-system/src/bash/matcher.ts +0 -54
  63. package/node_modules/@vitos-pizza/permission-system/src/bash/parser.ts +0 -40
  64. package/node_modules/@vitos-pizza/permission-system/src/config-paths.ts +0 -23
  65. package/node_modules/@vitos-pizza/permission-system/src/detect-preset-mode.ts +0 -61
  66. package/node_modules/@vitos-pizza/permission-system/src/expand-home.ts +0 -12
  67. package/node_modules/@vitos-pizza/permission-system/src/forwarding/forwarder.ts +0 -224
  68. package/node_modules/@vitos-pizza/permission-system/src/forwarding/subagent-registry.ts +0 -61
  69. package/node_modules/@vitos-pizza/permission-system/src/gates/path-utils.ts +0 -66
  70. package/node_modules/@vitos-pizza/permission-system/src/gates/pipeline.ts +0 -151
  71. package/node_modules/@vitos-pizza/permission-system/src/handlers/before-agent-start.ts +0 -86
  72. package/node_modules/@vitos-pizza/permission-system/src/handlers/skill-input.ts +0 -1
  73. package/node_modules/@vitos-pizza/permission-system/src/handlers/tool-call-gate.ts +0 -204
  74. package/node_modules/@vitos-pizza/permission-system/src/mode-api.ts +0 -44
  75. package/node_modules/@vitos-pizza/permission-system/src/permission-evaluator.ts +0 -233
  76. package/node_modules/@vitos-pizza/permission-system/src/permission-session.ts +0 -62
  77. package/node_modules/@vitos-pizza/permission-system/src/policy-loader.ts +0 -211
  78. package/node_modules/@vitos-pizza/permission-system/src/sanitizers/skill-prompt.ts +0 -99
  79. package/node_modules/@vitos-pizza/permission-system/src/sanitizers/system-prompt.ts +0 -221
  80. package/node_modules/@vitos-pizza/permission-system/src/service.ts +0 -66
  81. package/node_modules/@vitos-pizza/permission-system/src/session-approvals.ts +0 -4
  82. package/node_modules/@vitos-pizza/permission-system/src/types.ts +0 -80
  83. package/node_modules/@vitos-pizza/permission-system/src/ui/approval-summary.ts +0 -43
  84. package/node_modules/@vitos-pizza/permission-system/src/ui/config-modal.ts +0 -36
  85. package/node_modules/@vitos-pizza/permission-system/src/ui/permission-dialog.ts +0 -52
  86. package/node_modules/@vitos-pizza/permission-system/src/wildcard-matcher.ts +0 -81
  87. package/node_modules/@vitos-pizza/permission-system/src/yaml-frontmatter.ts +0 -84
  88. package/node_modules/@vitos-pizza/permission-system/src/yolo/runtime-api.ts +0 -49
  89. package/node_modules/@vitos-pizza/permission-system/tests/bash-parser.test.ts +0 -32
  90. package/node_modules/@vitos-pizza/permission-system/tests/before-agent-start.test.ts +0 -61
  91. package/node_modules/@vitos-pizza/permission-system/tests/detect-preset-mode.test.ts +0 -68
  92. package/node_modules/@vitos-pizza/permission-system/tests/forwarder.test.ts +0 -55
  93. package/node_modules/@vitos-pizza/permission-system/tests/gates.test.ts +0 -170
  94. package/node_modules/@vitos-pizza/permission-system/tests/path-utils.test.ts +0 -68
  95. package/node_modules/@vitos-pizza/permission-system/tests/permission-evaluator.test.ts +0 -82
  96. package/node_modules/@vitos-pizza/permission-system/tests/policy-loader.test.ts +0 -25
  97. package/node_modules/@vitos-pizza/permission-system/tests/system-prompt-sanitizer.test.ts +0 -22
  98. package/node_modules/@vitos-pizza/permission-system/tests/wildcard-matcher.test.ts +0 -27
  99. package/node_modules/@vitos-pizza/permission-system/tsconfig.json +0 -13
  100. package/node_modules/@vitos-pizza/permission-system/vitest.config.ts +0 -8
  101. package/node_modules/@vitos-pizza/question/extensions/index.ts +0 -79
  102. package/node_modules/@vitos-pizza/question/package.json +0 -26
  103. package/node_modules/@vitos-pizza/question/src/forwarding/channels.ts +0 -6
  104. package/node_modules/@vitos-pizza/question/src/forwarding/file-watcher.ts +0 -106
  105. package/node_modules/@vitos-pizza/question/src/forwarding/forwarder.ts +0 -187
  106. package/node_modules/@vitos-pizza/question/src/parent-session.ts +0 -18
  107. package/node_modules/@vitos-pizza/question/src/question-ui.ts +0 -242
  108. package/node_modules/@vitos-pizza/question/src/register-tool.ts +0 -221
  109. package/node_modules/@vitos-pizza/question/src/types.ts +0 -41
  110. package/node_modules/@vitos-pizza/question/tests/forwarder.test.ts +0 -66
  111. package/node_modules/@vitos-pizza/question/tests/parent-session.test.ts +0 -29
  112. package/node_modules/@vitos-pizza/question/tests/question-ui-width-cache.test.ts +0 -45
  113. package/node_modules/@vitos-pizza/question/tests/register-tool-render.test.ts +0 -48
  114. package/node_modules/@vitos-pizza/question/tsconfig.json +0 -13
  115. package/node_modules/@vitos-pizza/question/vitest.config.ts +0 -8
  116. package/node_modules/@vitos-pizza/session-title/extensions/index.ts +0 -137
  117. package/node_modules/@vitos-pizza/session-title/package.json +0 -37
  118. package/node_modules/@vitos-pizza/session-title/src/build-title-prompt.ts +0 -16
  119. package/node_modules/@vitos-pizza/session-title/src/extract-title-context.ts +0 -55
  120. package/node_modules/@vitos-pizza/session-title/src/fast-rules.ts +0 -48
  121. package/node_modules/@vitos-pizza/session-title/src/load-settings.ts +0 -70
  122. package/node_modules/@vitos-pizza/session-title/src/normalize-title.ts +0 -20
  123. package/node_modules/@vitos-pizza/session-title/src/parse-title-response.ts +0 -6
  124. package/node_modules/@vitos-pizza/session-title/src/resolve-title-model.ts +0 -33
  125. package/node_modules/@vitos-pizza/session-title/src/schedule-title-job.ts +0 -53
  126. package/node_modules/@vitos-pizza/session-title/src/should-schedule.ts +0 -30
  127. package/node_modules/@vitos-pizza/session-title/src/title-agent.ts +0 -60
  128. package/node_modules/@vitos-pizza/session-title/src/truncate-input.ts +0 -10
  129. package/node_modules/@vitos-pizza/session-title/src/types.ts +0 -29
  130. package/node_modules/@vitos-pizza/session-title/tests/build-title-prompt.test.ts +0 -34
  131. package/node_modules/@vitos-pizza/session-title/tests/extension.test.ts +0 -198
  132. package/node_modules/@vitos-pizza/session-title/tests/extract-title-context.test.ts +0 -48
  133. package/node_modules/@vitos-pizza/session-title/tests/fast-rules.test.ts +0 -43
  134. package/node_modules/@vitos-pizza/session-title/tests/parse-title-response.test.ts +0 -34
  135. package/node_modules/@vitos-pizza/session-title/tests/should-schedule.test.ts +0 -30
  136. package/node_modules/@vitos-pizza/session-title/tests/title-agent.test.ts +0 -154
  137. package/node_modules/@vitos-pizza/session-title/tests/truncate-input.test.ts +0 -15
  138. package/node_modules/@vitos-pizza/session-title/tsconfig.json +0 -13
  139. package/node_modules/@vitos-pizza/session-title/vitest.config.ts +0 -8
  140. package/node_modules/@vitos-pizza/subagents/agents/planner.md +0 -46
  141. package/node_modules/@vitos-pizza/subagents/agents/scout.md +0 -40
  142. package/node_modules/@vitos-pizza/subagents/agents/title.md +0 -13
  143. package/node_modules/@vitos-pizza/subagents/agents/worker.md +0 -36
  144. package/node_modules/@vitos-pizza/subagents/extensions/index.ts +0 -164
  145. package/node_modules/@vitos-pizza/subagents/package.json +0 -34
  146. package/node_modules/@vitos-pizza/subagents/skills/subagents/SKILL.md +0 -86
  147. package/node_modules/@vitos-pizza/subagents/src/agents.ts +0 -166
  148. package/node_modules/@vitos-pizza/subagents/src/async/job-tracker.ts +0 -71
  149. package/node_modules/@vitos-pizza/subagents/src/async/spawn-async.ts +0 -220
  150. package/node_modules/@vitos-pizza/subagents/src/async/storage.ts +0 -57
  151. package/node_modules/@vitos-pizza/subagents/src/env.ts +0 -4
  152. package/node_modules/@vitos-pizza/subagents/src/execute-subagent.ts +0 -285
  153. package/node_modules/@vitos-pizza/subagents/src/progress.ts +0 -187
  154. package/node_modules/@vitos-pizza/subagents/src/render-animation.ts +0 -40
  155. package/node_modules/@vitos-pizza/subagents/src/render.ts +0 -428
  156. package/node_modules/@vitos-pizza/subagents/src/rpc/channels.ts +0 -21
  157. package/node_modules/@vitos-pizza/subagents/src/rpc/client.ts +0 -144
  158. package/node_modules/@vitos-pizza/subagents/src/rpc/server.ts +0 -11
  159. package/node_modules/@vitos-pizza/subagents/src/run-agent.ts +0 -313
  160. package/node_modules/@vitos-pizza/subagents/src/runtime.ts +0 -102
  161. package/node_modules/@vitos-pizza/subagents/src/schema.ts +0 -62
  162. package/node_modules/@vitos-pizza/subagents/src/spawn.ts +0 -104
  163. package/node_modules/@vitos-pizza/subagents/src/types.ts +0 -92
  164. package/node_modules/@vitos-pizza/subagents/src/utils.ts +0 -100
  165. package/node_modules/@vitos-pizza/subagents/src/wait.ts +0 -159
  166. package/node_modules/@vitos-pizza/subagents/tests/agents.test.ts +0 -19
  167. package/node_modules/@vitos-pizza/subagents/tests/execute-subagent.test.ts +0 -96
  168. package/node_modules/@vitos-pizza/subagents/tests/extension.test.ts +0 -42
  169. package/node_modules/@vitos-pizza/subagents/tests/progress.test.ts +0 -206
  170. package/node_modules/@vitos-pizza/subagents/tests/rpc.test.ts +0 -74
  171. package/node_modules/@vitos-pizza/subagents/tsconfig.json +0 -13
  172. package/node_modules/@vitos-pizza/subagents/vitest.config.ts +0 -8
  173. package/node_modules/@vitos-pizza/ui-enhancements/extensions/index.ts +0 -10
  174. package/node_modules/@vitos-pizza/ui-enhancements/package.json +0 -28
  175. package/node_modules/@vitos-pizza/ui-enhancements/src/bash-readonly.ts +0 -82
  176. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/agent-mode-badge.ts +0 -60
  177. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/border-status.ts +0 -193
  178. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/format-border.ts +0 -46
  179. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/header-info.ts +0 -66
  180. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/recent-sessions.ts +0 -132
  181. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/resize-recovery.ts +0 -63
  182. package/node_modules/@vitos-pizza/ui-enhancements/src/chrome/welcome-header.ts +0 -127
  183. package/node_modules/@vitos-pizza/ui-enhancements/src/config.ts +0 -75
  184. package/node_modules/@vitos-pizza/ui-enhancements/src/register-ui-enhancements.ts +0 -47
  185. package/node_modules/@vitos-pizza/ui-enhancements/src/session.ts +0 -72
  186. package/node_modules/@vitos-pizza/ui-enhancements/src/tools/bash-write-edit.ts +0 -148
  187. package/node_modules/@vitos-pizza/ui-enhancements/src/tools/index.ts +0 -22
  188. package/node_modules/@vitos-pizza/ui-enhancements/src/tools/read-find-grep-ls.ts +0 -235
  189. package/node_modules/@vitos-pizza/ui-enhancements/src/tools/text-content.ts +0 -42
  190. package/node_modules/@vitos-pizza/ui-enhancements/src/tools/tool-cache.ts +0 -87
  191. package/node_modules/@vitos-pizza/ui-enhancements/src/utils/shorten-path.ts +0 -9
  192. package/node_modules/@vitos-pizza/ui-enhancements/tests/agent-mode-badge.test.ts +0 -35
  193. package/node_modules/@vitos-pizza/ui-enhancements/tests/bash-readonly.test.ts +0 -43
  194. package/node_modules/@vitos-pizza/ui-enhancements/tests/format-border.test.ts +0 -36
  195. package/node_modules/@vitos-pizza/ui-enhancements/tests/recent-sessions.test.ts +0 -72
  196. package/node_modules/@vitos-pizza/ui-enhancements/tests/resize-recovery.test.ts +0 -135
  197. package/node_modules/@vitos-pizza/ui-enhancements/tsconfig.json +0 -13
  198. package/node_modules/@vitos-pizza/ui-enhancements/vitest.config.ts +0 -8
  199. package/node_modules/@vitos-pizza/websearch/extensions/index.ts +0 -130
  200. package/node_modules/@vitos-pizza/websearch/package.json +0 -28
  201. package/node_modules/@vitos-pizza/websearch/src/backends/brave.ts +0 -35
  202. package/node_modules/@vitos-pizza/websearch/src/backends/exa-mcp.ts +0 -139
  203. package/node_modules/@vitos-pizza/websearch/src/backends/firecrawl.ts +0 -86
  204. package/node_modules/@vitos-pizza/websearch/src/backends/registry.ts +0 -98
  205. package/node_modules/@vitos-pizza/websearch/src/backends/tavily.ts +0 -32
  206. package/node_modules/@vitos-pizza/websearch/src/config.ts +0 -124
  207. package/node_modules/@vitos-pizza/websearch/src/credentials.ts +0 -35
  208. package/node_modules/@vitos-pizza/websearch/src/dispatch.ts +0 -57
  209. package/node_modules/@vitos-pizza/websearch/src/formatters.ts +0 -44
  210. package/node_modules/@vitos-pizza/websearch/src/parsers.ts +0 -75
  211. package/node_modules/@vitos-pizza/websearch/src/readers/jina.ts +0 -42
  212. package/node_modules/@vitos-pizza/websearch/src/schema.ts +0 -37
  213. package/node_modules/@vitos-pizza/websearch/src/status.ts +0 -103
  214. package/node_modules/@vitos-pizza/websearch/src/types.ts +0 -29
  215. package/node_modules/@vitos-pizza/websearch/src/utils.ts +0 -117
  216. package/node_modules/@vitos-pizza/websearch/tests/backends.test.ts +0 -103
  217. package/node_modules/@vitos-pizza/websearch/tests/config.test.ts +0 -71
  218. package/node_modules/@vitos-pizza/websearch/tests/dispatch.test.ts +0 -69
  219. package/node_modules/@vitos-pizza/websearch/tsconfig.json +0 -13
  220. package/node_modules/@vitos-pizza/websearch/vitest.config.ts +0 -8
  221. package/node_modules/node-addon-api/LICENSE.md +0 -9
  222. package/node_modules/node-addon-api/README.md +0 -95
  223. package/node_modules/node-addon-api/common.gypi +0 -21
  224. package/node_modules/node-addon-api/except.gypi +0 -25
  225. package/node_modules/node-addon-api/index.js +0 -14
  226. package/node_modules/node-addon-api/napi-inl.deprecated.h +0 -186
  227. package/node_modules/node-addon-api/napi-inl.h +0 -7211
  228. package/node_modules/node-addon-api/napi.h +0 -3420
  229. package/node_modules/node-addon-api/node_addon_api.gyp +0 -42
  230. package/node_modules/node-addon-api/node_api.gyp +0 -9
  231. package/node_modules/node-addon-api/noexcept.gypi +0 -26
  232. package/node_modules/node-addon-api/nothing.c +0 -0
  233. package/node_modules/node-addon-api/package-support.json +0 -21
  234. package/node_modules/node-addon-api/package.json +0 -480
  235. package/node_modules/node-addon-api/tools/README.md +0 -73
  236. package/node_modules/node-addon-api/tools/check-napi.js +0 -99
  237. package/node_modules/node-addon-api/tools/clang-format.js +0 -71
  238. package/node_modules/node-addon-api/tools/conversion.js +0 -301
  239. package/node_modules/node-gyp-build/LICENSE +0 -21
  240. package/node_modules/node-gyp-build/README.md +0 -58
  241. package/node_modules/node-gyp-build/SECURITY.md +0 -5
  242. package/node_modules/node-gyp-build/bin.js +0 -84
  243. package/node_modules/node-gyp-build/build-test.js +0 -19
  244. package/node_modules/node-gyp-build/index.js +0 -6
  245. package/node_modules/node-gyp-build/node-gyp-build.js +0 -207
  246. package/node_modules/node-gyp-build/optional.js +0 -7
  247. package/node_modules/node-gyp-build/package.json +0 -43
  248. package/node_modules/tree-sitter-bash/LICENSE +0 -21
  249. package/node_modules/tree-sitter-bash/README.md +0 -44
  250. package/node_modules/tree-sitter-bash/binding.gyp +0 -30
  251. package/node_modules/tree-sitter-bash/bindings/node/binding.cc +0 -20
  252. package/node_modules/tree-sitter-bash/bindings/node/binding_test.js +0 -9
  253. package/node_modules/tree-sitter-bash/bindings/node/index.d.ts +0 -28
  254. package/node_modules/tree-sitter-bash/bindings/node/index.js +0 -11
  255. package/node_modules/tree-sitter-bash/grammar.js +0 -1201
  256. package/node_modules/tree-sitter-bash/package.json +0 -60
  257. package/node_modules/tree-sitter-bash/prebuilds/darwin-arm64/tree-sitter-bash.node +0 -0
  258. package/node_modules/tree-sitter-bash/prebuilds/darwin-x64/tree-sitter-bash.node +0 -0
  259. package/node_modules/tree-sitter-bash/prebuilds/linux-arm64/tree-sitter-bash.node +0 -0
  260. package/node_modules/tree-sitter-bash/prebuilds/linux-x64/tree-sitter-bash.node +0 -0
  261. package/node_modules/tree-sitter-bash/prebuilds/win32-arm64/tree-sitter-bash.node +0 -0
  262. package/node_modules/tree-sitter-bash/prebuilds/win32-x64/tree-sitter-bash.node +0 -0
  263. package/node_modules/tree-sitter-bash/queries/highlights.scm +0 -56
  264. package/node_modules/tree-sitter-bash/src/grammar.json +0 -7145
  265. package/node_modules/tree-sitter-bash/src/node-types.json +0 -2894
  266. package/node_modules/tree-sitter-bash/src/parser.c +0 -350631
  267. package/node_modules/tree-sitter-bash/src/scanner.c +0 -1217
  268. package/node_modules/tree-sitter-bash/src/tree_sitter/alloc.h +0 -54
  269. package/node_modules/tree-sitter-bash/src/tree_sitter/array.h +0 -291
  270. package/node_modules/tree-sitter-bash/src/tree_sitter/parser.h +0 -286
  271. package/node_modules/tree-sitter-bash/tree-sitter-bash.wasm +0 -0
  272. package/node_modules/tree-sitter-bash/tree-sitter.json +0 -46
  273. package/packages/permission-system/node_modules/web-tree-sitter/LICENSE +0 -21
  274. package/packages/permission-system/node_modules/web-tree-sitter/README.md +0 -269
  275. package/packages/permission-system/node_modules/web-tree-sitter/debug/tree-sitter.cjs +0 -4558
  276. package/packages/permission-system/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +0 -7
  277. package/packages/permission-system/node_modules/web-tree-sitter/debug/tree-sitter.js +0 -4516
  278. package/packages/permission-system/node_modules/web-tree-sitter/debug/tree-sitter.js.map +0 -7
  279. package/packages/permission-system/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  280. package/packages/permission-system/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +0 -31
  281. package/packages/permission-system/node_modules/web-tree-sitter/lib/alloc.c +0 -48
  282. package/packages/permission-system/node_modules/web-tree-sitter/lib/alloc.h +0 -41
  283. package/packages/permission-system/node_modules/web-tree-sitter/lib/array.h +0 -291
  284. package/packages/permission-system/node_modules/web-tree-sitter/lib/atomic.h +0 -68
  285. package/packages/permission-system/node_modules/web-tree-sitter/lib/clock.h +0 -146
  286. package/packages/permission-system/node_modules/web-tree-sitter/lib/error_costs.h +0 -11
  287. package/packages/permission-system/node_modules/web-tree-sitter/lib/get_changed_ranges.c +0 -523
  288. package/packages/permission-system/node_modules/web-tree-sitter/lib/get_changed_ranges.h +0 -36
  289. package/packages/permission-system/node_modules/web-tree-sitter/lib/host.h +0 -21
  290. package/packages/permission-system/node_modules/web-tree-sitter/lib/language.c +0 -293
  291. package/packages/permission-system/node_modules/web-tree-sitter/lib/language.h +0 -293
  292. package/packages/permission-system/node_modules/web-tree-sitter/lib/length.h +0 -52
  293. package/packages/permission-system/node_modules/web-tree-sitter/lib/lexer.c +0 -483
  294. package/packages/permission-system/node_modules/web-tree-sitter/lib/lexer.h +0 -54
  295. package/packages/permission-system/node_modules/web-tree-sitter/lib/lib.c +0 -12
  296. package/packages/permission-system/node_modules/web-tree-sitter/lib/node.c +0 -875
  297. package/packages/permission-system/node_modules/web-tree-sitter/lib/parser.c +0 -2297
  298. package/packages/permission-system/node_modules/web-tree-sitter/lib/parser.h +0 -286
  299. package/packages/permission-system/node_modules/web-tree-sitter/lib/point.h +0 -48
  300. package/packages/permission-system/node_modules/web-tree-sitter/lib/query.c +0 -4347
  301. package/packages/permission-system/node_modules/web-tree-sitter/lib/reduce_action.h +0 -34
  302. package/packages/permission-system/node_modules/web-tree-sitter/lib/reusable_node.h +0 -95
  303. package/packages/permission-system/node_modules/web-tree-sitter/lib/stack.c +0 -912
  304. package/packages/permission-system/node_modules/web-tree-sitter/lib/stack.h +0 -133
  305. package/packages/permission-system/node_modules/web-tree-sitter/lib/subtree.c +0 -1034
  306. package/packages/permission-system/node_modules/web-tree-sitter/lib/subtree.h +0 -399
  307. package/packages/permission-system/node_modules/web-tree-sitter/lib/tree-sitter.c +0 -987
  308. package/packages/permission-system/node_modules/web-tree-sitter/lib/tree.c +0 -170
  309. package/packages/permission-system/node_modules/web-tree-sitter/lib/tree.h +0 -31
  310. package/packages/permission-system/node_modules/web-tree-sitter/lib/tree_cursor.c +0 -716
  311. package/packages/permission-system/node_modules/web-tree-sitter/lib/tree_cursor.h +0 -48
  312. package/packages/permission-system/node_modules/web-tree-sitter/lib/ts_assert.h +0 -11
  313. package/packages/permission-system/node_modules/web-tree-sitter/lib/unicode.h +0 -75
  314. package/packages/permission-system/node_modules/web-tree-sitter/lib/wasm_store.c +0 -1937
  315. package/packages/permission-system/node_modules/web-tree-sitter/lib/wasm_store.h +0 -31
  316. package/packages/permission-system/node_modules/web-tree-sitter/package.json +0 -98
  317. package/packages/permission-system/node_modules/web-tree-sitter/src/bindings.ts +0 -26
  318. package/packages/permission-system/node_modules/web-tree-sitter/src/constants.ts +0 -133
  319. package/packages/permission-system/node_modules/web-tree-sitter/src/index.ts +0 -31
  320. package/packages/permission-system/node_modules/web-tree-sitter/src/language.ts +0 -291
  321. package/packages/permission-system/node_modules/web-tree-sitter/src/lookahead_iterator.ts +0 -75
  322. package/packages/permission-system/node_modules/web-tree-sitter/src/marshal.ts +0 -176
  323. package/packages/permission-system/node_modules/web-tree-sitter/src/node.ts +0 -646
  324. package/packages/permission-system/node_modules/web-tree-sitter/src/parser.ts +0 -325
  325. package/packages/permission-system/node_modules/web-tree-sitter/src/query.ts +0 -973
  326. package/packages/permission-system/node_modules/web-tree-sitter/src/tree.ts +0 -145
  327. package/packages/permission-system/node_modules/web-tree-sitter/src/tree_cursor.ts +0 -318
  328. package/packages/permission-system/node_modules/web-tree-sitter/tree-sitter.cjs +0 -4031
  329. package/packages/permission-system/node_modules/web-tree-sitter/tree-sitter.cjs.map +0 -7
  330. package/packages/permission-system/node_modules/web-tree-sitter/tree-sitter.js +0 -3980
  331. package/packages/permission-system/node_modules/web-tree-sitter/tree-sitter.js.map +0 -7
  332. package/packages/permission-system/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  333. package/packages/permission-system/node_modules/web-tree-sitter/tree-sitter.wasm.map +0 -30
  334. package/packages/permission-system/node_modules/web-tree-sitter/web-tree-sitter.d.ts +0 -1030
  335. package/packages/permission-system/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +0 -56
  336. package/packages/permission-system/node_modules/zod/LICENSE +0 -21
  337. package/packages/permission-system/node_modules/zod/README.md +0 -208
  338. package/packages/permission-system/node_modules/zod/index.cjs +0 -33
  339. package/packages/permission-system/node_modules/zod/index.d.cts +0 -4
  340. package/packages/permission-system/node_modules/zod/index.d.ts +0 -4
  341. package/packages/permission-system/node_modules/zod/index.js +0 -4
  342. package/packages/permission-system/node_modules/zod/package.json +0 -118
  343. package/packages/permission-system/node_modules/zod/src/index.ts +0 -4
  344. package/packages/permission-system/node_modules/zod/src/v3/ZodError.ts +0 -330
  345. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  346. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  347. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  348. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  349. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  350. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  351. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  352. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  353. package/packages/permission-system/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  354. package/packages/permission-system/node_modules/zod/src/v3/errors.ts +0 -13
  355. package/packages/permission-system/node_modules/zod/src/v3/external.ts +0 -6
  356. package/packages/permission-system/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  357. package/packages/permission-system/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  358. package/packages/permission-system/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  359. package/packages/permission-system/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  360. package/packages/permission-system/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  361. package/packages/permission-system/node_modules/zod/src/v3/helpers/util.ts +0 -224
  362. package/packages/permission-system/node_modules/zod/src/v3/index.ts +0 -4
  363. package/packages/permission-system/node_modules/zod/src/v3/locales/en.ts +0 -124
  364. package/packages/permission-system/node_modules/zod/src/v3/standard-schema.ts +0 -113
  365. package/packages/permission-system/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  366. package/packages/permission-system/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  367. package/packages/permission-system/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  368. package/packages/permission-system/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  369. package/packages/permission-system/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  370. package/packages/permission-system/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  371. package/packages/permission-system/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  372. package/packages/permission-system/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  373. package/packages/permission-system/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  374. package/packages/permission-system/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  375. package/packages/permission-system/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  376. package/packages/permission-system/node_modules/zod/src/v3/tests/complex.test.ts +0 -56
  377. package/packages/permission-system/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  378. package/packages/permission-system/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  379. package/packages/permission-system/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  380. package/packages/permission-system/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  381. package/packages/permission-system/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  382. package/packages/permission-system/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  383. package/packages/permission-system/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  384. package/packages/permission-system/node_modules/zod/src/v3/tests/error.test.ts +0 -551
  385. package/packages/permission-system/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  386. package/packages/permission-system/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  387. package/packages/permission-system/node_modules/zod/src/v3/tests/function.test.ts +0 -257
  388. package/packages/permission-system/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  389. package/packages/permission-system/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  390. package/packages/permission-system/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
  391. package/packages/permission-system/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  392. package/packages/permission-system/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
  393. package/packages/permission-system/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  394. package/packages/permission-system/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  395. package/packages/permission-system/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  396. package/packages/permission-system/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  397. package/packages/permission-system/node_modules/zod/src/v3/tests/nan.test.ts +0 -21
  398. package/packages/permission-system/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  399. package/packages/permission-system/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  400. package/packages/permission-system/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  401. package/packages/permission-system/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  402. package/packages/permission-system/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  403. package/packages/permission-system/node_modules/zod/src/v3/tests/object.test.ts +0 -434
  404. package/packages/permission-system/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  405. package/packages/permission-system/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  406. package/packages/permission-system/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  407. package/packages/permission-system/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  408. package/packages/permission-system/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  409. package/packages/permission-system/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  410. package/packages/permission-system/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  411. package/packages/permission-system/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  412. package/packages/permission-system/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  413. package/packages/permission-system/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
  414. package/packages/permission-system/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  415. package/packages/permission-system/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  416. package/packages/permission-system/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  417. package/packages/permission-system/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  418. package/packages/permission-system/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  419. package/packages/permission-system/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  420. package/packages/permission-system/node_modules/zod/src/v3/tests/string.test.ts +0 -916
  421. package/packages/permission-system/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  422. package/packages/permission-system/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  423. package/packages/permission-system/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  424. package/packages/permission-system/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  425. package/packages/permission-system/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  426. package/packages/permission-system/node_modules/zod/src/v3/types.ts +0 -5136
  427. package/packages/permission-system/node_modules/zod/src/v4/classic/checks.ts +0 -30
  428. package/packages/permission-system/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  429. package/packages/permission-system/node_modules/zod/src/v4/classic/compat.ts +0 -66
  430. package/packages/permission-system/node_modules/zod/src/v4/classic/errors.ts +0 -75
  431. package/packages/permission-system/node_modules/zod/src/v4/classic/external.ts +0 -50
  432. package/packages/permission-system/node_modules/zod/src/v4/classic/index.ts +0 -5
  433. package/packages/permission-system/node_modules/zod/src/v4/classic/iso.ts +0 -90
  434. package/packages/permission-system/node_modules/zod/src/v4/classic/parse.ts +0 -33
  435. package/packages/permission-system/node_modules/zod/src/v4/classic/schemas.ts +0 -2054
  436. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  437. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  438. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -210
  439. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  440. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  441. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  442. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
  443. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -63
  444. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -252
  445. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  446. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  447. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -352
  448. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  449. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -31
  450. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -296
  451. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -313
  452. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  453. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -619
  454. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
  455. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -527
  456. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
  457. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -91
  458. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -175
  459. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -268
  460. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  461. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -829
  462. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -34
  463. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -171
  464. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -108
  465. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
  466. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -92
  467. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -196
  468. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  469. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  470. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -86
  471. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  472. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -247
  473. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -563
  474. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -123
  475. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -147
  476. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -127
  477. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -81
  478. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -37
  479. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -298
  480. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  481. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  482. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  483. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
  484. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -342
  485. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -356
  486. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -532
  487. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -204
  488. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -179
  489. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -57
  490. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -109
  491. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -881
  492. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -66
  493. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -758
  494. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -2314
  495. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -250
  496. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -163
  497. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -94
  498. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  499. package/packages/permission-system/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  500. package/packages/permission-system/node_modules/zod/src/v4/core/api.ts +0 -1594
  501. package/packages/permission-system/node_modules/zod/src/v4/core/checks.ts +0 -1283
  502. package/packages/permission-system/node_modules/zod/src/v4/core/config.ts +0 -15
  503. package/packages/permission-system/node_modules/zod/src/v4/core/core.ts +0 -134
  504. package/packages/permission-system/node_modules/zod/src/v4/core/doc.ts +0 -44
  505. package/packages/permission-system/node_modules/zod/src/v4/core/errors.ts +0 -424
  506. package/packages/permission-system/node_modules/zod/src/v4/core/function.ts +0 -176
  507. package/packages/permission-system/node_modules/zod/src/v4/core/index.ts +0 -15
  508. package/packages/permission-system/node_modules/zod/src/v4/core/json-schema.ts +0 -143
  509. package/packages/permission-system/node_modules/zod/src/v4/core/parse.ts +0 -94
  510. package/packages/permission-system/node_modules/zod/src/v4/core/regexes.ts +0 -135
  511. package/packages/permission-system/node_modules/zod/src/v4/core/registries.ts +0 -96
  512. package/packages/permission-system/node_modules/zod/src/v4/core/schemas.ts +0 -3842
  513. package/packages/permission-system/node_modules/zod/src/v4/core/standard-schema.ts +0 -64
  514. package/packages/permission-system/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  515. package/packages/permission-system/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  516. package/packages/permission-system/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  517. package/packages/permission-system/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  518. package/packages/permission-system/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  519. package/packages/permission-system/node_modules/zod/src/v4/core/to-json-schema.ts +0 -977
  520. package/packages/permission-system/node_modules/zod/src/v4/core/util.ts +0 -775
  521. package/packages/permission-system/node_modules/zod/src/v4/core/versions.ts +0 -5
  522. package/packages/permission-system/node_modules/zod/src/v4/core/zsf.ts +0 -323
  523. package/packages/permission-system/node_modules/zod/src/v4/index.ts +0 -4
  524. package/packages/permission-system/node_modules/zod/src/v4/locales/ar.ts +0 -125
  525. package/packages/permission-system/node_modules/zod/src/v4/locales/az.ts +0 -121
  526. package/packages/permission-system/node_modules/zod/src/v4/locales/be.ts +0 -184
  527. package/packages/permission-system/node_modules/zod/src/v4/locales/ca.ts +0 -127
  528. package/packages/permission-system/node_modules/zod/src/v4/locales/cs.ts +0 -142
  529. package/packages/permission-system/node_modules/zod/src/v4/locales/de.ts +0 -124
  530. package/packages/permission-system/node_modules/zod/src/v4/locales/en.ts +0 -127
  531. package/packages/permission-system/node_modules/zod/src/v4/locales/eo.ts +0 -125
  532. package/packages/permission-system/node_modules/zod/src/v4/locales/es.ts +0 -125
  533. package/packages/permission-system/node_modules/zod/src/v4/locales/fa.ts +0 -134
  534. package/packages/permission-system/node_modules/zod/src/v4/locales/fi.ts +0 -131
  535. package/packages/permission-system/node_modules/zod/src/v4/locales/fr-CA.ts +0 -126
  536. package/packages/permission-system/node_modules/zod/src/v4/locales/fr.ts +0 -124
  537. package/packages/permission-system/node_modules/zod/src/v4/locales/he.ts +0 -125
  538. package/packages/permission-system/node_modules/zod/src/v4/locales/hu.ts +0 -126
  539. package/packages/permission-system/node_modules/zod/src/v4/locales/id.ts +0 -125
  540. package/packages/permission-system/node_modules/zod/src/v4/locales/index.ts +0 -39
  541. package/packages/permission-system/node_modules/zod/src/v4/locales/it.ts +0 -125
  542. package/packages/permission-system/node_modules/zod/src/v4/locales/ja.ts +0 -122
  543. package/packages/permission-system/node_modules/zod/src/v4/locales/kh.ts +0 -126
  544. package/packages/permission-system/node_modules/zod/src/v4/locales/ko.ts +0 -131
  545. package/packages/permission-system/node_modules/zod/src/v4/locales/mk.ts +0 -127
  546. package/packages/permission-system/node_modules/zod/src/v4/locales/ms.ts +0 -124
  547. package/packages/permission-system/node_modules/zod/src/v4/locales/nl.ts +0 -126
  548. package/packages/permission-system/node_modules/zod/src/v4/locales/no.ts +0 -124
  549. package/packages/permission-system/node_modules/zod/src/v4/locales/ota.ts +0 -125
  550. package/packages/permission-system/node_modules/zod/src/v4/locales/pl.ts +0 -126
  551. package/packages/permission-system/node_modules/zod/src/v4/locales/ps.ts +0 -133
  552. package/packages/permission-system/node_modules/zod/src/v4/locales/pt.ts +0 -123
  553. package/packages/permission-system/node_modules/zod/src/v4/locales/ru.ts +0 -184
  554. package/packages/permission-system/node_modules/zod/src/v4/locales/sl.ts +0 -126
  555. package/packages/permission-system/node_modules/zod/src/v4/locales/sv.ts +0 -127
  556. package/packages/permission-system/node_modules/zod/src/v4/locales/ta.ts +0 -125
  557. package/packages/permission-system/node_modules/zod/src/v4/locales/th.ts +0 -126
  558. package/packages/permission-system/node_modules/zod/src/v4/locales/tr.ts +0 -121
  559. package/packages/permission-system/node_modules/zod/src/v4/locales/ua.ts +0 -126
  560. package/packages/permission-system/node_modules/zod/src/v4/locales/ur.ts +0 -126
  561. package/packages/permission-system/node_modules/zod/src/v4/locales/vi.ts +0 -125
  562. package/packages/permission-system/node_modules/zod/src/v4/locales/zh-CN.ts +0 -123
  563. package/packages/permission-system/node_modules/zod/src/v4/locales/zh-TW.ts +0 -125
  564. package/packages/permission-system/node_modules/zod/src/v4/mini/checks.ts +0 -32
  565. package/packages/permission-system/node_modules/zod/src/v4/mini/coerce.ts +0 -22
  566. package/packages/permission-system/node_modules/zod/src/v4/mini/external.ts +0 -40
  567. package/packages/permission-system/node_modules/zod/src/v4/mini/index.ts +0 -3
  568. package/packages/permission-system/node_modules/zod/src/v4/mini/iso.ts +0 -62
  569. package/packages/permission-system/node_modules/zod/src/v4/mini/parse.ts +0 -1
  570. package/packages/permission-system/node_modules/zod/src/v4/mini/schemas.ts +0 -1579
  571. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
  572. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -51
  573. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
  574. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  575. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
  576. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -43
  577. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -871
  578. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
  579. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -185
  580. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  581. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -275
  582. package/packages/permission-system/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -299
  583. package/packages/permission-system/node_modules/zod/src/v4-mini/index.ts +0 -1
  584. package/packages/permission-system/node_modules/zod/v3/ZodError.cjs +0 -138
  585. package/packages/permission-system/node_modules/zod/v3/ZodError.d.cts +0 -164
  586. package/packages/permission-system/node_modules/zod/v3/ZodError.d.ts +0 -164
  587. package/packages/permission-system/node_modules/zod/v3/ZodError.js +0 -133
  588. package/packages/permission-system/node_modules/zod/v3/errors.cjs +0 -17
  589. package/packages/permission-system/node_modules/zod/v3/errors.d.cts +0 -5
  590. package/packages/permission-system/node_modules/zod/v3/errors.d.ts +0 -5
  591. package/packages/permission-system/node_modules/zod/v3/errors.js +0 -9
  592. package/packages/permission-system/node_modules/zod/v3/external.cjs +0 -22
  593. package/packages/permission-system/node_modules/zod/v3/external.d.cts +0 -6
  594. package/packages/permission-system/node_modules/zod/v3/external.d.ts +0 -6
  595. package/packages/permission-system/node_modules/zod/v3/external.js +0 -6
  596. package/packages/permission-system/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  597. package/packages/permission-system/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  598. package/packages/permission-system/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  599. package/packages/permission-system/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  600. package/packages/permission-system/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  601. package/packages/permission-system/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  602. package/packages/permission-system/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  603. package/packages/permission-system/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  604. package/packages/permission-system/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  605. package/packages/permission-system/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  606. package/packages/permission-system/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  607. package/packages/permission-system/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  608. package/packages/permission-system/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  609. package/packages/permission-system/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  610. package/packages/permission-system/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  611. package/packages/permission-system/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  612. package/packages/permission-system/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  613. package/packages/permission-system/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  614. package/packages/permission-system/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  615. package/packages/permission-system/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  616. package/packages/permission-system/node_modules/zod/v3/helpers/util.cjs +0 -137
  617. package/packages/permission-system/node_modules/zod/v3/helpers/util.d.cts +0 -85
  618. package/packages/permission-system/node_modules/zod/v3/helpers/util.d.ts +0 -85
  619. package/packages/permission-system/node_modules/zod/v3/helpers/util.js +0 -133
  620. package/packages/permission-system/node_modules/zod/v3/index.cjs +0 -33
  621. package/packages/permission-system/node_modules/zod/v3/index.d.cts +0 -4
  622. package/packages/permission-system/node_modules/zod/v3/index.d.ts +0 -4
  623. package/packages/permission-system/node_modules/zod/v3/index.js +0 -4
  624. package/packages/permission-system/node_modules/zod/v3/locales/en.cjs +0 -111
  625. package/packages/permission-system/node_modules/zod/v3/locales/en.d.cts +0 -3
  626. package/packages/permission-system/node_modules/zod/v3/locales/en.d.ts +0 -3
  627. package/packages/permission-system/node_modules/zod/v3/locales/en.js +0 -109
  628. package/packages/permission-system/node_modules/zod/v3/standard-schema.cjs +0 -2
  629. package/packages/permission-system/node_modules/zod/v3/standard-schema.d.cts +0 -102
  630. package/packages/permission-system/node_modules/zod/v3/standard-schema.d.ts +0 -102
  631. package/packages/permission-system/node_modules/zod/v3/standard-schema.js +0 -1
  632. package/packages/permission-system/node_modules/zod/v3/types.cjs +0 -3775
  633. package/packages/permission-system/node_modules/zod/v3/types.d.cts +0 -1031
  634. package/packages/permission-system/node_modules/zod/v3/types.d.ts +0 -1031
  635. package/packages/permission-system/node_modules/zod/v3/types.js +0 -3693
  636. package/packages/permission-system/node_modules/zod/v4/classic/checks.cjs +0 -32
  637. package/packages/permission-system/node_modules/zod/v4/classic/checks.d.cts +0 -1
  638. package/packages/permission-system/node_modules/zod/v4/classic/checks.d.ts +0 -1
  639. package/packages/permission-system/node_modules/zod/v4/classic/checks.js +0 -1
  640. package/packages/permission-system/node_modules/zod/v4/classic/coerce.cjs +0 -47
  641. package/packages/permission-system/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  642. package/packages/permission-system/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  643. package/packages/permission-system/node_modules/zod/v4/classic/coerce.js +0 -17
  644. package/packages/permission-system/node_modules/zod/v4/classic/compat.cjs +0 -57
  645. package/packages/permission-system/node_modules/zod/v4/classic/compat.d.cts +0 -46
  646. package/packages/permission-system/node_modules/zod/v4/classic/compat.d.ts +0 -46
  647. package/packages/permission-system/node_modules/zod/v4/classic/compat.js +0 -27
  648. package/packages/permission-system/node_modules/zod/v4/classic/errors.cjs +0 -67
  649. package/packages/permission-system/node_modules/zod/v4/classic/errors.d.cts +0 -30
  650. package/packages/permission-system/node_modules/zod/v4/classic/errors.d.ts +0 -30
  651. package/packages/permission-system/node_modules/zod/v4/classic/errors.js +0 -41
  652. package/packages/permission-system/node_modules/zod/v4/classic/external.cjs +0 -70
  653. package/packages/permission-system/node_modules/zod/v4/classic/external.d.cts +0 -13
  654. package/packages/permission-system/node_modules/zod/v4/classic/external.d.ts +0 -13
  655. package/packages/permission-system/node_modules/zod/v4/classic/external.js +0 -18
  656. package/packages/permission-system/node_modules/zod/v4/classic/index.cjs +0 -33
  657. package/packages/permission-system/node_modules/zod/v4/classic/index.d.cts +0 -4
  658. package/packages/permission-system/node_modules/zod/v4/classic/index.d.ts +0 -4
  659. package/packages/permission-system/node_modules/zod/v4/classic/index.js +0 -4
  660. package/packages/permission-system/node_modules/zod/v4/classic/iso.cjs +0 -60
  661. package/packages/permission-system/node_modules/zod/v4/classic/iso.d.cts +0 -22
  662. package/packages/permission-system/node_modules/zod/v4/classic/iso.d.ts +0 -22
  663. package/packages/permission-system/node_modules/zod/v4/classic/iso.js +0 -30
  664. package/packages/permission-system/node_modules/zod/v4/classic/parse.cjs +0 -32
  665. package/packages/permission-system/node_modules/zod/v4/classic/parse.d.cts +0 -23
  666. package/packages/permission-system/node_modules/zod/v4/classic/parse.d.ts +0 -23
  667. package/packages/permission-system/node_modules/zod/v4/classic/parse.js +0 -6
  668. package/packages/permission-system/node_modules/zod/v4/classic/schemas.cjs +0 -1109
  669. package/packages/permission-system/node_modules/zod/v4/classic/schemas.d.cts +0 -630
  670. package/packages/permission-system/node_modules/zod/v4/classic/schemas.d.ts +0 -630
  671. package/packages/permission-system/node_modules/zod/v4/classic/schemas.js +0 -1006
  672. package/packages/permission-system/node_modules/zod/v4/core/api.cjs +0 -1039
  673. package/packages/permission-system/node_modules/zod/v4/core/api.d.cts +0 -284
  674. package/packages/permission-system/node_modules/zod/v4/core/api.d.ts +0 -284
  675. package/packages/permission-system/node_modules/zod/v4/core/api.js +0 -906
  676. package/packages/permission-system/node_modules/zod/v4/core/checks.cjs +0 -591
  677. package/packages/permission-system/node_modules/zod/v4/core/checks.d.cts +0 -278
  678. package/packages/permission-system/node_modules/zod/v4/core/checks.d.ts +0 -278
  679. package/packages/permission-system/node_modules/zod/v4/core/checks.js +0 -565
  680. package/packages/permission-system/node_modules/zod/v4/core/core.cjs +0 -67
  681. package/packages/permission-system/node_modules/zod/v4/core/core.d.cts +0 -49
  682. package/packages/permission-system/node_modules/zod/v4/core/core.d.ts +0 -49
  683. package/packages/permission-system/node_modules/zod/v4/core/core.js +0 -61
  684. package/packages/permission-system/node_modules/zod/v4/core/doc.cjs +0 -39
  685. package/packages/permission-system/node_modules/zod/v4/core/doc.d.cts +0 -14
  686. package/packages/permission-system/node_modules/zod/v4/core/doc.d.ts +0 -14
  687. package/packages/permission-system/node_modules/zod/v4/core/doc.js +0 -35
  688. package/packages/permission-system/node_modules/zod/v4/core/errors.cjs +0 -226
  689. package/packages/permission-system/node_modules/zod/v4/core/errors.d.cts +0 -208
  690. package/packages/permission-system/node_modules/zod/v4/core/errors.d.ts +0 -208
  691. package/packages/permission-system/node_modules/zod/v4/core/errors.js +0 -195
  692. package/packages/permission-system/node_modules/zod/v4/core/function.cjs +0 -102
  693. package/packages/permission-system/node_modules/zod/v4/core/function.d.cts +0 -52
  694. package/packages/permission-system/node_modules/zod/v4/core/function.d.ts +0 -52
  695. package/packages/permission-system/node_modules/zod/v4/core/function.js +0 -75
  696. package/packages/permission-system/node_modules/zod/v4/core/index.cjs +0 -44
  697. package/packages/permission-system/node_modules/zod/v4/core/index.d.cts +0 -15
  698. package/packages/permission-system/node_modules/zod/v4/core/index.d.ts +0 -15
  699. package/packages/permission-system/node_modules/zod/v4/core/index.js +0 -15
  700. package/packages/permission-system/node_modules/zod/v4/core/json-schema.cjs +0 -2
  701. package/packages/permission-system/node_modules/zod/v4/core/json-schema.d.cts +0 -87
  702. package/packages/permission-system/node_modules/zod/v4/core/json-schema.d.ts +0 -87
  703. package/packages/permission-system/node_modules/zod/v4/core/json-schema.js +0 -1
  704. package/packages/permission-system/node_modules/zod/v4/core/parse.cjs +0 -87
  705. package/packages/permission-system/node_modules/zod/v4/core/parse.d.cts +0 -25
  706. package/packages/permission-system/node_modules/zod/v4/core/parse.d.ts +0 -25
  707. package/packages/permission-system/node_modules/zod/v4/core/parse.js +0 -57
  708. package/packages/permission-system/node_modules/zod/v4/core/regexes.cjs +0 -103
  709. package/packages/permission-system/node_modules/zod/v4/core/regexes.d.cts +0 -62
  710. package/packages/permission-system/node_modules/zod/v4/core/regexes.d.ts +0 -62
  711. package/packages/permission-system/node_modules/zod/v4/core/regexes.js +0 -95
  712. package/packages/permission-system/node_modules/zod/v4/core/registries.cjs +0 -56
  713. package/packages/permission-system/node_modules/zod/v4/core/registries.d.cts +0 -35
  714. package/packages/permission-system/node_modules/zod/v4/core/registries.d.ts +0 -35
  715. package/packages/permission-system/node_modules/zod/v4/core/registries.js +0 -51
  716. package/packages/permission-system/node_modules/zod/v4/core/schemas.cjs +0 -1748
  717. package/packages/permission-system/node_modules/zod/v4/core/schemas.d.cts +0 -1041
  718. package/packages/permission-system/node_modules/zod/v4/core/schemas.d.ts +0 -1041
  719. package/packages/permission-system/node_modules/zod/v4/core/schemas.js +0 -1717
  720. package/packages/permission-system/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  721. package/packages/permission-system/node_modules/zod/v4/core/standard-schema.d.cts +0 -55
  722. package/packages/permission-system/node_modules/zod/v4/core/standard-schema.d.ts +0 -55
  723. package/packages/permission-system/node_modules/zod/v4/core/standard-schema.js +0 -1
  724. package/packages/permission-system/node_modules/zod/v4/core/to-json-schema.cjs +0 -854
  725. package/packages/permission-system/node_modules/zod/v4/core/to-json-schema.d.cts +0 -88
  726. package/packages/permission-system/node_modules/zod/v4/core/to-json-schema.d.ts +0 -88
  727. package/packages/permission-system/node_modules/zod/v4/core/to-json-schema.js +0 -849
  728. package/packages/permission-system/node_modules/zod/v4/core/util.cjs +0 -539
  729. package/packages/permission-system/node_modules/zod/v4/core/util.d.cts +0 -183
  730. package/packages/permission-system/node_modules/zod/v4/core/util.d.ts +0 -183
  731. package/packages/permission-system/node_modules/zod/v4/core/util.js +0 -493
  732. package/packages/permission-system/node_modules/zod/v4/core/versions.cjs +0 -8
  733. package/packages/permission-system/node_modules/zod/v4/core/versions.d.cts +0 -5
  734. package/packages/permission-system/node_modules/zod/v4/core/versions.d.ts +0 -5
  735. package/packages/permission-system/node_modules/zod/v4/core/versions.js +0 -5
  736. package/packages/permission-system/node_modules/zod/v4/index.cjs +0 -22
  737. package/packages/permission-system/node_modules/zod/v4/index.d.cts +0 -3
  738. package/packages/permission-system/node_modules/zod/v4/index.d.ts +0 -3
  739. package/packages/permission-system/node_modules/zod/v4/index.js +0 -3
  740. package/packages/permission-system/node_modules/zod/v4/locales/ar.cjs +0 -142
  741. package/packages/permission-system/node_modules/zod/v4/locales/ar.d.cts +0 -4
  742. package/packages/permission-system/node_modules/zod/v4/locales/ar.d.ts +0 -4
  743. package/packages/permission-system/node_modules/zod/v4/locales/ar.js +0 -116
  744. package/packages/permission-system/node_modules/zod/v4/locales/az.cjs +0 -141
  745. package/packages/permission-system/node_modules/zod/v4/locales/az.d.cts +0 -4
  746. package/packages/permission-system/node_modules/zod/v4/locales/az.d.ts +0 -4
  747. package/packages/permission-system/node_modules/zod/v4/locales/az.js +0 -115
  748. package/packages/permission-system/node_modules/zod/v4/locales/be.cjs +0 -190
  749. package/packages/permission-system/node_modules/zod/v4/locales/be.d.cts +0 -4
  750. package/packages/permission-system/node_modules/zod/v4/locales/be.d.ts +0 -4
  751. package/packages/permission-system/node_modules/zod/v4/locales/be.js +0 -164
  752. package/packages/permission-system/node_modules/zod/v4/locales/ca.cjs +0 -144
  753. package/packages/permission-system/node_modules/zod/v4/locales/ca.d.cts +0 -4
  754. package/packages/permission-system/node_modules/zod/v4/locales/ca.d.ts +0 -4
  755. package/packages/permission-system/node_modules/zod/v4/locales/ca.js +0 -118
  756. package/packages/permission-system/node_modules/zod/v4/locales/cs.cjs +0 -161
  757. package/packages/permission-system/node_modules/zod/v4/locales/cs.d.cts +0 -4
  758. package/packages/permission-system/node_modules/zod/v4/locales/cs.d.ts +0 -4
  759. package/packages/permission-system/node_modules/zod/v4/locales/cs.js +0 -135
  760. package/packages/permission-system/node_modules/zod/v4/locales/de.cjs +0 -142
  761. package/packages/permission-system/node_modules/zod/v4/locales/de.d.cts +0 -4
  762. package/packages/permission-system/node_modules/zod/v4/locales/de.d.ts +0 -4
  763. package/packages/permission-system/node_modules/zod/v4/locales/de.js +0 -116
  764. package/packages/permission-system/node_modules/zod/v4/locales/en.cjs +0 -145
  765. package/packages/permission-system/node_modules/zod/v4/locales/en.d.cts +0 -5
  766. package/packages/permission-system/node_modules/zod/v4/locales/en.d.ts +0 -5
  767. package/packages/permission-system/node_modules/zod/v4/locales/en.js +0 -117
  768. package/packages/permission-system/node_modules/zod/v4/locales/eo.cjs +0 -144
  769. package/packages/permission-system/node_modules/zod/v4/locales/eo.d.cts +0 -5
  770. package/packages/permission-system/node_modules/zod/v4/locales/eo.d.ts +0 -5
  771. package/packages/permission-system/node_modules/zod/v4/locales/eo.js +0 -116
  772. package/packages/permission-system/node_modules/zod/v4/locales/es.cjs +0 -143
  773. package/packages/permission-system/node_modules/zod/v4/locales/es.d.cts +0 -4
  774. package/packages/permission-system/node_modules/zod/v4/locales/es.d.ts +0 -4
  775. package/packages/permission-system/node_modules/zod/v4/locales/es.js +0 -117
  776. package/packages/permission-system/node_modules/zod/v4/locales/fa.cjs +0 -148
  777. package/packages/permission-system/node_modules/zod/v4/locales/fa.d.cts +0 -4
  778. package/packages/permission-system/node_modules/zod/v4/locales/fa.d.ts +0 -4
  779. package/packages/permission-system/node_modules/zod/v4/locales/fa.js +0 -122
  780. package/packages/permission-system/node_modules/zod/v4/locales/fi.cjs +0 -148
  781. package/packages/permission-system/node_modules/zod/v4/locales/fi.d.cts +0 -4
  782. package/packages/permission-system/node_modules/zod/v4/locales/fi.d.ts +0 -4
  783. package/packages/permission-system/node_modules/zod/v4/locales/fi.js +0 -122
  784. package/packages/permission-system/node_modules/zod/v4/locales/fr-CA.cjs +0 -143
  785. package/packages/permission-system/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
  786. package/packages/permission-system/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  787. package/packages/permission-system/node_modules/zod/v4/locales/fr-CA.js +0 -117
  788. package/packages/permission-system/node_modules/zod/v4/locales/fr.cjs +0 -142
  789. package/packages/permission-system/node_modules/zod/v4/locales/fr.d.cts +0 -4
  790. package/packages/permission-system/node_modules/zod/v4/locales/fr.d.ts +0 -4
  791. package/packages/permission-system/node_modules/zod/v4/locales/fr.js +0 -116
  792. package/packages/permission-system/node_modules/zod/v4/locales/he.cjs +0 -143
  793. package/packages/permission-system/node_modules/zod/v4/locales/he.d.cts +0 -4
  794. package/packages/permission-system/node_modules/zod/v4/locales/he.d.ts +0 -4
  795. package/packages/permission-system/node_modules/zod/v4/locales/he.js +0 -117
  796. package/packages/permission-system/node_modules/zod/v4/locales/hu.cjs +0 -143
  797. package/packages/permission-system/node_modules/zod/v4/locales/hu.d.cts +0 -4
  798. package/packages/permission-system/node_modules/zod/v4/locales/hu.d.ts +0 -4
  799. package/packages/permission-system/node_modules/zod/v4/locales/hu.js +0 -117
  800. package/packages/permission-system/node_modules/zod/v4/locales/id.cjs +0 -142
  801. package/packages/permission-system/node_modules/zod/v4/locales/id.d.cts +0 -4
  802. package/packages/permission-system/node_modules/zod/v4/locales/id.d.ts +0 -4
  803. package/packages/permission-system/node_modules/zod/v4/locales/id.js +0 -116
  804. package/packages/permission-system/node_modules/zod/v4/locales/index.cjs +0 -84
  805. package/packages/permission-system/node_modules/zod/v4/locales/index.d.cts +0 -39
  806. package/packages/permission-system/node_modules/zod/v4/locales/index.d.ts +0 -39
  807. package/packages/permission-system/node_modules/zod/v4/locales/index.js +0 -39
  808. package/packages/permission-system/node_modules/zod/v4/locales/it.cjs +0 -143
  809. package/packages/permission-system/node_modules/zod/v4/locales/it.d.cts +0 -4
  810. package/packages/permission-system/node_modules/zod/v4/locales/it.d.ts +0 -4
  811. package/packages/permission-system/node_modules/zod/v4/locales/it.js +0 -117
  812. package/packages/permission-system/node_modules/zod/v4/locales/ja.cjs +0 -141
  813. package/packages/permission-system/node_modules/zod/v4/locales/ja.d.cts +0 -4
  814. package/packages/permission-system/node_modules/zod/v4/locales/ja.d.ts +0 -4
  815. package/packages/permission-system/node_modules/zod/v4/locales/ja.js +0 -115
  816. package/packages/permission-system/node_modules/zod/v4/locales/kh.cjs +0 -143
  817. package/packages/permission-system/node_modules/zod/v4/locales/kh.d.cts +0 -4
  818. package/packages/permission-system/node_modules/zod/v4/locales/kh.d.ts +0 -4
  819. package/packages/permission-system/node_modules/zod/v4/locales/kh.js +0 -117
  820. package/packages/permission-system/node_modules/zod/v4/locales/ko.cjs +0 -147
  821. package/packages/permission-system/node_modules/zod/v4/locales/ko.d.cts +0 -4
  822. package/packages/permission-system/node_modules/zod/v4/locales/ko.d.ts +0 -4
  823. package/packages/permission-system/node_modules/zod/v4/locales/ko.js +0 -121
  824. package/packages/permission-system/node_modules/zod/v4/locales/mk.cjs +0 -144
  825. package/packages/permission-system/node_modules/zod/v4/locales/mk.d.cts +0 -4
  826. package/packages/permission-system/node_modules/zod/v4/locales/mk.d.ts +0 -4
  827. package/packages/permission-system/node_modules/zod/v4/locales/mk.js +0 -118
  828. package/packages/permission-system/node_modules/zod/v4/locales/ms.cjs +0 -142
  829. package/packages/permission-system/node_modules/zod/v4/locales/ms.d.cts +0 -4
  830. package/packages/permission-system/node_modules/zod/v4/locales/ms.d.ts +0 -4
  831. package/packages/permission-system/node_modules/zod/v4/locales/ms.js +0 -116
  832. package/packages/permission-system/node_modules/zod/v4/locales/nl.cjs +0 -143
  833. package/packages/permission-system/node_modules/zod/v4/locales/nl.d.cts +0 -4
  834. package/packages/permission-system/node_modules/zod/v4/locales/nl.d.ts +0 -4
  835. package/packages/permission-system/node_modules/zod/v4/locales/nl.js +0 -117
  836. package/packages/permission-system/node_modules/zod/v4/locales/no.cjs +0 -142
  837. package/packages/permission-system/node_modules/zod/v4/locales/no.d.cts +0 -4
  838. package/packages/permission-system/node_modules/zod/v4/locales/no.d.ts +0 -4
  839. package/packages/permission-system/node_modules/zod/v4/locales/no.js +0 -116
  840. package/packages/permission-system/node_modules/zod/v4/locales/ota.cjs +0 -143
  841. package/packages/permission-system/node_modules/zod/v4/locales/ota.d.cts +0 -4
  842. package/packages/permission-system/node_modules/zod/v4/locales/ota.d.ts +0 -4
  843. package/packages/permission-system/node_modules/zod/v4/locales/ota.js +0 -117
  844. package/packages/permission-system/node_modules/zod/v4/locales/pl.cjs +0 -143
  845. package/packages/permission-system/node_modules/zod/v4/locales/pl.d.cts +0 -4
  846. package/packages/permission-system/node_modules/zod/v4/locales/pl.d.ts +0 -4
  847. package/packages/permission-system/node_modules/zod/v4/locales/pl.js +0 -117
  848. package/packages/permission-system/node_modules/zod/v4/locales/ps.cjs +0 -148
  849. package/packages/permission-system/node_modules/zod/v4/locales/ps.d.cts +0 -4
  850. package/packages/permission-system/node_modules/zod/v4/locales/ps.d.ts +0 -4
  851. package/packages/permission-system/node_modules/zod/v4/locales/ps.js +0 -122
  852. package/packages/permission-system/node_modules/zod/v4/locales/pt.cjs +0 -142
  853. package/packages/permission-system/node_modules/zod/v4/locales/pt.d.cts +0 -4
  854. package/packages/permission-system/node_modules/zod/v4/locales/pt.d.ts +0 -4
  855. package/packages/permission-system/node_modules/zod/v4/locales/pt.js +0 -116
  856. package/packages/permission-system/node_modules/zod/v4/locales/ru.cjs +0 -190
  857. package/packages/permission-system/node_modules/zod/v4/locales/ru.d.cts +0 -4
  858. package/packages/permission-system/node_modules/zod/v4/locales/ru.d.ts +0 -4
  859. package/packages/permission-system/node_modules/zod/v4/locales/ru.js +0 -164
  860. package/packages/permission-system/node_modules/zod/v4/locales/sl.cjs +0 -143
  861. package/packages/permission-system/node_modules/zod/v4/locales/sl.d.cts +0 -4
  862. package/packages/permission-system/node_modules/zod/v4/locales/sl.d.ts +0 -4
  863. package/packages/permission-system/node_modules/zod/v4/locales/sl.js +0 -117
  864. package/packages/permission-system/node_modules/zod/v4/locales/sv.cjs +0 -144
  865. package/packages/permission-system/node_modules/zod/v4/locales/sv.d.cts +0 -4
  866. package/packages/permission-system/node_modules/zod/v4/locales/sv.d.ts +0 -4
  867. package/packages/permission-system/node_modules/zod/v4/locales/sv.js +0 -118
  868. package/packages/permission-system/node_modules/zod/v4/locales/ta.cjs +0 -143
  869. package/packages/permission-system/node_modules/zod/v4/locales/ta.d.cts +0 -4
  870. package/packages/permission-system/node_modules/zod/v4/locales/ta.d.ts +0 -4
  871. package/packages/permission-system/node_modules/zod/v4/locales/ta.js +0 -117
  872. package/packages/permission-system/node_modules/zod/v4/locales/th.cjs +0 -143
  873. package/packages/permission-system/node_modules/zod/v4/locales/th.d.cts +0 -4
  874. package/packages/permission-system/node_modules/zod/v4/locales/th.d.ts +0 -4
  875. package/packages/permission-system/node_modules/zod/v4/locales/th.js +0 -117
  876. package/packages/permission-system/node_modules/zod/v4/locales/tr.cjs +0 -143
  877. package/packages/permission-system/node_modules/zod/v4/locales/tr.d.cts +0 -5
  878. package/packages/permission-system/node_modules/zod/v4/locales/tr.d.ts +0 -5
  879. package/packages/permission-system/node_modules/zod/v4/locales/tr.js +0 -115
  880. package/packages/permission-system/node_modules/zod/v4/locales/ua.cjs +0 -143
  881. package/packages/permission-system/node_modules/zod/v4/locales/ua.d.cts +0 -4
  882. package/packages/permission-system/node_modules/zod/v4/locales/ua.d.ts +0 -4
  883. package/packages/permission-system/node_modules/zod/v4/locales/ua.js +0 -117
  884. package/packages/permission-system/node_modules/zod/v4/locales/ur.cjs +0 -143
  885. package/packages/permission-system/node_modules/zod/v4/locales/ur.d.cts +0 -4
  886. package/packages/permission-system/node_modules/zod/v4/locales/ur.d.ts +0 -4
  887. package/packages/permission-system/node_modules/zod/v4/locales/ur.js +0 -117
  888. package/packages/permission-system/node_modules/zod/v4/locales/vi.cjs +0 -142
  889. package/packages/permission-system/node_modules/zod/v4/locales/vi.d.cts +0 -4
  890. package/packages/permission-system/node_modules/zod/v4/locales/vi.d.ts +0 -4
  891. package/packages/permission-system/node_modules/zod/v4/locales/vi.js +0 -116
  892. package/packages/permission-system/node_modules/zod/v4/locales/zh-CN.cjs +0 -142
  893. package/packages/permission-system/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
  894. package/packages/permission-system/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  895. package/packages/permission-system/node_modules/zod/v4/locales/zh-CN.js +0 -116
  896. package/packages/permission-system/node_modules/zod/v4/locales/zh-TW.cjs +0 -143
  897. package/packages/permission-system/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
  898. package/packages/permission-system/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  899. package/packages/permission-system/node_modules/zod/v4/locales/zh-TW.js +0 -117
  900. package/packages/permission-system/node_modules/zod/v4/mini/checks.cjs +0 -34
  901. package/packages/permission-system/node_modules/zod/v4/mini/checks.d.cts +0 -1
  902. package/packages/permission-system/node_modules/zod/v4/mini/checks.d.ts +0 -1
  903. package/packages/permission-system/node_modules/zod/v4/mini/checks.js +0 -1
  904. package/packages/permission-system/node_modules/zod/v4/mini/coerce.cjs +0 -47
  905. package/packages/permission-system/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  906. package/packages/permission-system/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  907. package/packages/permission-system/node_modules/zod/v4/mini/coerce.js +0 -17
  908. package/packages/permission-system/node_modules/zod/v4/mini/external.cjs +0 -62
  909. package/packages/permission-system/node_modules/zod/v4/mini/external.d.cts +0 -11
  910. package/packages/permission-system/node_modules/zod/v4/mini/external.d.ts +0 -11
  911. package/packages/permission-system/node_modules/zod/v4/mini/external.js +0 -13
  912. package/packages/permission-system/node_modules/zod/v4/mini/index.cjs +0 -32
  913. package/packages/permission-system/node_modules/zod/v4/mini/index.d.cts +0 -3
  914. package/packages/permission-system/node_modules/zod/v4/mini/index.d.ts +0 -3
  915. package/packages/permission-system/node_modules/zod/v4/mini/index.js +0 -3
  916. package/packages/permission-system/node_modules/zod/v4/mini/iso.cjs +0 -60
  917. package/packages/permission-system/node_modules/zod/v4/mini/iso.d.cts +0 -22
  918. package/packages/permission-system/node_modules/zod/v4/mini/iso.d.ts +0 -22
  919. package/packages/permission-system/node_modules/zod/v4/mini/iso.js +0 -30
  920. package/packages/permission-system/node_modules/zod/v4/mini/parse.cjs +0 -8
  921. package/packages/permission-system/node_modules/zod/v4/mini/parse.d.cts +0 -1
  922. package/packages/permission-system/node_modules/zod/v4/mini/parse.d.ts +0 -1
  923. package/packages/permission-system/node_modules/zod/v4/mini/parse.js +0 -1
  924. package/packages/permission-system/node_modules/zod/v4/mini/schemas.cjs +0 -839
  925. package/packages/permission-system/node_modules/zod/v4/mini/schemas.d.cts +0 -356
  926. package/packages/permission-system/node_modules/zod/v4/mini/schemas.d.ts +0 -356
  927. package/packages/permission-system/node_modules/zod/v4/mini/schemas.js +0 -732
  928. package/packages/permission-system/node_modules/zod/v4-mini/index.cjs +0 -17
  929. package/packages/permission-system/node_modules/zod/v4-mini/index.d.cts +0 -1
  930. package/packages/permission-system/node_modules/zod/v4-mini/index.d.ts +0 -1
  931. package/packages/permission-system/node_modules/zod/v4-mini/index.js +0 -1
@@ -1,3775 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
4
- exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = void 0;
5
- exports.datetimeRegex = datetimeRegex;
6
- exports.custom = custom;
7
- const ZodError_js_1 = require("./ZodError.cjs");
8
- const errors_js_1 = require("./errors.cjs");
9
- const errorUtil_js_1 = require("./helpers/errorUtil.cjs");
10
- const parseUtil_js_1 = require("./helpers/parseUtil.cjs");
11
- const util_js_1 = require("./helpers/util.cjs");
12
- class ParseInputLazyPath {
13
- constructor(parent, value, path, key) {
14
- this._cachedPath = [];
15
- this.parent = parent;
16
- this.data = value;
17
- this._path = path;
18
- this._key = key;
19
- }
20
- get path() {
21
- if (!this._cachedPath.length) {
22
- if (Array.isArray(this._key)) {
23
- this._cachedPath.push(...this._path, ...this._key);
24
- }
25
- else {
26
- this._cachedPath.push(...this._path, this._key);
27
- }
28
- }
29
- return this._cachedPath;
30
- }
31
- }
32
- const handleResult = (ctx, result) => {
33
- if ((0, parseUtil_js_1.isValid)(result)) {
34
- return { success: true, data: result.value };
35
- }
36
- else {
37
- if (!ctx.common.issues.length) {
38
- throw new Error("Validation failed but no issues detected.");
39
- }
40
- return {
41
- success: false,
42
- get error() {
43
- if (this._error)
44
- return this._error;
45
- const error = new ZodError_js_1.ZodError(ctx.common.issues);
46
- this._error = error;
47
- return this._error;
48
- },
49
- };
50
- }
51
- };
52
- function processCreateParams(params) {
53
- if (!params)
54
- return {};
55
- const { errorMap, invalid_type_error, required_error, description } = params;
56
- if (errorMap && (invalid_type_error || required_error)) {
57
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
58
- }
59
- if (errorMap)
60
- return { errorMap: errorMap, description };
61
- const customMap = (iss, ctx) => {
62
- const { message } = params;
63
- if (iss.code === "invalid_enum_value") {
64
- return { message: message ?? ctx.defaultError };
65
- }
66
- if (typeof ctx.data === "undefined") {
67
- return { message: message ?? required_error ?? ctx.defaultError };
68
- }
69
- if (iss.code !== "invalid_type")
70
- return { message: ctx.defaultError };
71
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
72
- };
73
- return { errorMap: customMap, description };
74
- }
75
- class ZodType {
76
- get description() {
77
- return this._def.description;
78
- }
79
- _getType(input) {
80
- return (0, util_js_1.getParsedType)(input.data);
81
- }
82
- _getOrReturnCtx(input, ctx) {
83
- return (ctx || {
84
- common: input.parent.common,
85
- data: input.data,
86
- parsedType: (0, util_js_1.getParsedType)(input.data),
87
- schemaErrorMap: this._def.errorMap,
88
- path: input.path,
89
- parent: input.parent,
90
- });
91
- }
92
- _processInputParams(input) {
93
- return {
94
- status: new parseUtil_js_1.ParseStatus(),
95
- ctx: {
96
- common: input.parent.common,
97
- data: input.data,
98
- parsedType: (0, util_js_1.getParsedType)(input.data),
99
- schemaErrorMap: this._def.errorMap,
100
- path: input.path,
101
- parent: input.parent,
102
- },
103
- };
104
- }
105
- _parseSync(input) {
106
- const result = this._parse(input);
107
- if ((0, parseUtil_js_1.isAsync)(result)) {
108
- throw new Error("Synchronous parse encountered promise.");
109
- }
110
- return result;
111
- }
112
- _parseAsync(input) {
113
- const result = this._parse(input);
114
- return Promise.resolve(result);
115
- }
116
- parse(data, params) {
117
- const result = this.safeParse(data, params);
118
- if (result.success)
119
- return result.data;
120
- throw result.error;
121
- }
122
- safeParse(data, params) {
123
- const ctx = {
124
- common: {
125
- issues: [],
126
- async: params?.async ?? false,
127
- contextualErrorMap: params?.errorMap,
128
- },
129
- path: params?.path || [],
130
- schemaErrorMap: this._def.errorMap,
131
- parent: null,
132
- data,
133
- parsedType: (0, util_js_1.getParsedType)(data),
134
- };
135
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
136
- return handleResult(ctx, result);
137
- }
138
- "~validate"(data) {
139
- const ctx = {
140
- common: {
141
- issues: [],
142
- async: !!this["~standard"].async,
143
- },
144
- path: [],
145
- schemaErrorMap: this._def.errorMap,
146
- parent: null,
147
- data,
148
- parsedType: (0, util_js_1.getParsedType)(data),
149
- };
150
- if (!this["~standard"].async) {
151
- try {
152
- const result = this._parseSync({ data, path: [], parent: ctx });
153
- return (0, parseUtil_js_1.isValid)(result)
154
- ? {
155
- value: result.value,
156
- }
157
- : {
158
- issues: ctx.common.issues,
159
- };
160
- }
161
- catch (err) {
162
- if (err?.message?.toLowerCase()?.includes("encountered")) {
163
- this["~standard"].async = true;
164
- }
165
- ctx.common = {
166
- issues: [],
167
- async: true,
168
- };
169
- }
170
- }
171
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => (0, parseUtil_js_1.isValid)(result)
172
- ? {
173
- value: result.value,
174
- }
175
- : {
176
- issues: ctx.common.issues,
177
- });
178
- }
179
- async parseAsync(data, params) {
180
- const result = await this.safeParseAsync(data, params);
181
- if (result.success)
182
- return result.data;
183
- throw result.error;
184
- }
185
- async safeParseAsync(data, params) {
186
- const ctx = {
187
- common: {
188
- issues: [],
189
- contextualErrorMap: params?.errorMap,
190
- async: true,
191
- },
192
- path: params?.path || [],
193
- schemaErrorMap: this._def.errorMap,
194
- parent: null,
195
- data,
196
- parsedType: (0, util_js_1.getParsedType)(data),
197
- };
198
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
199
- const result = await ((0, parseUtil_js_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
200
- return handleResult(ctx, result);
201
- }
202
- refine(check, message) {
203
- const getIssueProperties = (val) => {
204
- if (typeof message === "string" || typeof message === "undefined") {
205
- return { message };
206
- }
207
- else if (typeof message === "function") {
208
- return message(val);
209
- }
210
- else {
211
- return message;
212
- }
213
- };
214
- return this._refinement((val, ctx) => {
215
- const result = check(val);
216
- const setError = () => ctx.addIssue({
217
- code: ZodError_js_1.ZodIssueCode.custom,
218
- ...getIssueProperties(val),
219
- });
220
- if (typeof Promise !== "undefined" && result instanceof Promise) {
221
- return result.then((data) => {
222
- if (!data) {
223
- setError();
224
- return false;
225
- }
226
- else {
227
- return true;
228
- }
229
- });
230
- }
231
- if (!result) {
232
- setError();
233
- return false;
234
- }
235
- else {
236
- return true;
237
- }
238
- });
239
- }
240
- refinement(check, refinementData) {
241
- return this._refinement((val, ctx) => {
242
- if (!check(val)) {
243
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
244
- return false;
245
- }
246
- else {
247
- return true;
248
- }
249
- });
250
- }
251
- _refinement(refinement) {
252
- return new ZodEffects({
253
- schema: this,
254
- typeName: ZodFirstPartyTypeKind.ZodEffects,
255
- effect: { type: "refinement", refinement },
256
- });
257
- }
258
- superRefine(refinement) {
259
- return this._refinement(refinement);
260
- }
261
- constructor(def) {
262
- /** Alias of safeParseAsync */
263
- this.spa = this.safeParseAsync;
264
- this._def = def;
265
- this.parse = this.parse.bind(this);
266
- this.safeParse = this.safeParse.bind(this);
267
- this.parseAsync = this.parseAsync.bind(this);
268
- this.safeParseAsync = this.safeParseAsync.bind(this);
269
- this.spa = this.spa.bind(this);
270
- this.refine = this.refine.bind(this);
271
- this.refinement = this.refinement.bind(this);
272
- this.superRefine = this.superRefine.bind(this);
273
- this.optional = this.optional.bind(this);
274
- this.nullable = this.nullable.bind(this);
275
- this.nullish = this.nullish.bind(this);
276
- this.array = this.array.bind(this);
277
- this.promise = this.promise.bind(this);
278
- this.or = this.or.bind(this);
279
- this.and = this.and.bind(this);
280
- this.transform = this.transform.bind(this);
281
- this.brand = this.brand.bind(this);
282
- this.default = this.default.bind(this);
283
- this.catch = this.catch.bind(this);
284
- this.describe = this.describe.bind(this);
285
- this.pipe = this.pipe.bind(this);
286
- this.readonly = this.readonly.bind(this);
287
- this.isNullable = this.isNullable.bind(this);
288
- this.isOptional = this.isOptional.bind(this);
289
- this["~standard"] = {
290
- version: 1,
291
- vendor: "zod",
292
- validate: (data) => this["~validate"](data),
293
- };
294
- }
295
- optional() {
296
- return ZodOptional.create(this, this._def);
297
- }
298
- nullable() {
299
- return ZodNullable.create(this, this._def);
300
- }
301
- nullish() {
302
- return this.nullable().optional();
303
- }
304
- array() {
305
- return ZodArray.create(this);
306
- }
307
- promise() {
308
- return ZodPromise.create(this, this._def);
309
- }
310
- or(option) {
311
- return ZodUnion.create([this, option], this._def);
312
- }
313
- and(incoming) {
314
- return ZodIntersection.create(this, incoming, this._def);
315
- }
316
- transform(transform) {
317
- return new ZodEffects({
318
- ...processCreateParams(this._def),
319
- schema: this,
320
- typeName: ZodFirstPartyTypeKind.ZodEffects,
321
- effect: { type: "transform", transform },
322
- });
323
- }
324
- default(def) {
325
- const defaultValueFunc = typeof def === "function" ? def : () => def;
326
- return new ZodDefault({
327
- ...processCreateParams(this._def),
328
- innerType: this,
329
- defaultValue: defaultValueFunc,
330
- typeName: ZodFirstPartyTypeKind.ZodDefault,
331
- });
332
- }
333
- brand() {
334
- return new ZodBranded({
335
- typeName: ZodFirstPartyTypeKind.ZodBranded,
336
- type: this,
337
- ...processCreateParams(this._def),
338
- });
339
- }
340
- catch(def) {
341
- const catchValueFunc = typeof def === "function" ? def : () => def;
342
- return new ZodCatch({
343
- ...processCreateParams(this._def),
344
- innerType: this,
345
- catchValue: catchValueFunc,
346
- typeName: ZodFirstPartyTypeKind.ZodCatch,
347
- });
348
- }
349
- describe(description) {
350
- const This = this.constructor;
351
- return new This({
352
- ...this._def,
353
- description,
354
- });
355
- }
356
- pipe(target) {
357
- return ZodPipeline.create(this, target);
358
- }
359
- readonly() {
360
- return ZodReadonly.create(this);
361
- }
362
- isOptional() {
363
- return this.safeParse(undefined).success;
364
- }
365
- isNullable() {
366
- return this.safeParse(null).success;
367
- }
368
- }
369
- exports.ZodType = ZodType;
370
- exports.Schema = ZodType;
371
- exports.ZodSchema = ZodType;
372
- const cuidRegex = /^c[^\s-]{8,}$/i;
373
- const cuid2Regex = /^[0-9a-z]+$/;
374
- const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
375
- // const uuidRegex =
376
- // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
377
- const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
378
- const nanoidRegex = /^[a-z0-9_-]{21}$/i;
379
- const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
380
- const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
381
- // from https://stackoverflow.com/a/46181/1550155
382
- // old version: too slow, didn't support unicode
383
- // const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
384
- //old email regex
385
- // const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
386
- // eslint-disable-next-line
387
- // const emailRegex =
388
- // /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((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}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-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})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
389
- // const emailRegex =
390
- // /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
391
- // const emailRegex =
392
- // /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
393
- const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
394
- // const emailRegex =
395
- // /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
396
- // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
397
- const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
398
- let emojiRegex;
399
- // faster, simpler, safer
400
- const ipv4Regex = /^(?:(?: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])$/;
401
- const ipv4CidrRegex = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/;
402
- // const ipv6Regex =
403
- // /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-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})))$/;
404
- const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
405
- const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
406
- // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
407
- const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
408
- // https://base64.guru/standards/base64url
409
- const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
410
- // simple
411
- // const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;
412
- // no leap year validation
413
- // const dateRegexSource = `\\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\\d|2\\d))`;
414
- // with leap year validation
415
- const dateRegexSource = `((\\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])))`;
416
- const dateRegex = new RegExp(`^${dateRegexSource}$`);
417
- function timeRegexSource(args) {
418
- let secondsRegexSource = `[0-5]\\d`;
419
- if (args.precision) {
420
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
421
- }
422
- else if (args.precision == null) {
423
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
424
- }
425
- const secondsQuantifier = args.precision ? "+" : "?"; // require seconds if precision is nonzero
426
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
427
- }
428
- function timeRegex(args) {
429
- return new RegExp(`^${timeRegexSource(args)}$`);
430
- }
431
- // Adapted from https://stackoverflow.com/a/3143231
432
- function datetimeRegex(args) {
433
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
434
- const opts = [];
435
- opts.push(args.local ? `Z?` : `Z`);
436
- if (args.offset)
437
- opts.push(`([+-]\\d{2}:?\\d{2})`);
438
- regex = `${regex}(${opts.join("|")})`;
439
- return new RegExp(`^${regex}$`);
440
- }
441
- function isValidIP(ip, version) {
442
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
443
- return true;
444
- }
445
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
446
- return true;
447
- }
448
- return false;
449
- }
450
- function isValidJWT(jwt, alg) {
451
- if (!jwtRegex.test(jwt))
452
- return false;
453
- try {
454
- const [header] = jwt.split(".");
455
- if (!header)
456
- return false;
457
- // Convert base64url to base64
458
- const base64 = header
459
- .replace(/-/g, "+")
460
- .replace(/_/g, "/")
461
- .padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
462
- const decoded = JSON.parse(atob(base64));
463
- if (typeof decoded !== "object" || decoded === null)
464
- return false;
465
- if ("typ" in decoded && decoded?.typ !== "JWT")
466
- return false;
467
- if (!decoded.alg)
468
- return false;
469
- if (alg && decoded.alg !== alg)
470
- return false;
471
- return true;
472
- }
473
- catch {
474
- return false;
475
- }
476
- }
477
- function isValidCidr(ip, version) {
478
- if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
479
- return true;
480
- }
481
- if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
482
- return true;
483
- }
484
- return false;
485
- }
486
- class ZodString extends ZodType {
487
- _parse(input) {
488
- if (this._def.coerce) {
489
- input.data = String(input.data);
490
- }
491
- const parsedType = this._getType(input);
492
- if (parsedType !== util_js_1.ZodParsedType.string) {
493
- const ctx = this._getOrReturnCtx(input);
494
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
495
- code: ZodError_js_1.ZodIssueCode.invalid_type,
496
- expected: util_js_1.ZodParsedType.string,
497
- received: ctx.parsedType,
498
- });
499
- return parseUtil_js_1.INVALID;
500
- }
501
- const status = new parseUtil_js_1.ParseStatus();
502
- let ctx = undefined;
503
- for (const check of this._def.checks) {
504
- if (check.kind === "min") {
505
- if (input.data.length < check.value) {
506
- ctx = this._getOrReturnCtx(input, ctx);
507
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
508
- code: ZodError_js_1.ZodIssueCode.too_small,
509
- minimum: check.value,
510
- type: "string",
511
- inclusive: true,
512
- exact: false,
513
- message: check.message,
514
- });
515
- status.dirty();
516
- }
517
- }
518
- else if (check.kind === "max") {
519
- if (input.data.length > check.value) {
520
- ctx = this._getOrReturnCtx(input, ctx);
521
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
522
- code: ZodError_js_1.ZodIssueCode.too_big,
523
- maximum: check.value,
524
- type: "string",
525
- inclusive: true,
526
- exact: false,
527
- message: check.message,
528
- });
529
- status.dirty();
530
- }
531
- }
532
- else if (check.kind === "length") {
533
- const tooBig = input.data.length > check.value;
534
- const tooSmall = input.data.length < check.value;
535
- if (tooBig || tooSmall) {
536
- ctx = this._getOrReturnCtx(input, ctx);
537
- if (tooBig) {
538
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
539
- code: ZodError_js_1.ZodIssueCode.too_big,
540
- maximum: check.value,
541
- type: "string",
542
- inclusive: true,
543
- exact: true,
544
- message: check.message,
545
- });
546
- }
547
- else if (tooSmall) {
548
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
549
- code: ZodError_js_1.ZodIssueCode.too_small,
550
- minimum: check.value,
551
- type: "string",
552
- inclusive: true,
553
- exact: true,
554
- message: check.message,
555
- });
556
- }
557
- status.dirty();
558
- }
559
- }
560
- else if (check.kind === "email") {
561
- if (!emailRegex.test(input.data)) {
562
- ctx = this._getOrReturnCtx(input, ctx);
563
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
564
- validation: "email",
565
- code: ZodError_js_1.ZodIssueCode.invalid_string,
566
- message: check.message,
567
- });
568
- status.dirty();
569
- }
570
- }
571
- else if (check.kind === "emoji") {
572
- if (!emojiRegex) {
573
- emojiRegex = new RegExp(_emojiRegex, "u");
574
- }
575
- if (!emojiRegex.test(input.data)) {
576
- ctx = this._getOrReturnCtx(input, ctx);
577
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
578
- validation: "emoji",
579
- code: ZodError_js_1.ZodIssueCode.invalid_string,
580
- message: check.message,
581
- });
582
- status.dirty();
583
- }
584
- }
585
- else if (check.kind === "uuid") {
586
- if (!uuidRegex.test(input.data)) {
587
- ctx = this._getOrReturnCtx(input, ctx);
588
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
589
- validation: "uuid",
590
- code: ZodError_js_1.ZodIssueCode.invalid_string,
591
- message: check.message,
592
- });
593
- status.dirty();
594
- }
595
- }
596
- else if (check.kind === "nanoid") {
597
- if (!nanoidRegex.test(input.data)) {
598
- ctx = this._getOrReturnCtx(input, ctx);
599
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
600
- validation: "nanoid",
601
- code: ZodError_js_1.ZodIssueCode.invalid_string,
602
- message: check.message,
603
- });
604
- status.dirty();
605
- }
606
- }
607
- else if (check.kind === "cuid") {
608
- if (!cuidRegex.test(input.data)) {
609
- ctx = this._getOrReturnCtx(input, ctx);
610
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
611
- validation: "cuid",
612
- code: ZodError_js_1.ZodIssueCode.invalid_string,
613
- message: check.message,
614
- });
615
- status.dirty();
616
- }
617
- }
618
- else if (check.kind === "cuid2") {
619
- if (!cuid2Regex.test(input.data)) {
620
- ctx = this._getOrReturnCtx(input, ctx);
621
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
622
- validation: "cuid2",
623
- code: ZodError_js_1.ZodIssueCode.invalid_string,
624
- message: check.message,
625
- });
626
- status.dirty();
627
- }
628
- }
629
- else if (check.kind === "ulid") {
630
- if (!ulidRegex.test(input.data)) {
631
- ctx = this._getOrReturnCtx(input, ctx);
632
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
633
- validation: "ulid",
634
- code: ZodError_js_1.ZodIssueCode.invalid_string,
635
- message: check.message,
636
- });
637
- status.dirty();
638
- }
639
- }
640
- else if (check.kind === "url") {
641
- try {
642
- new URL(input.data);
643
- }
644
- catch {
645
- ctx = this._getOrReturnCtx(input, ctx);
646
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
647
- validation: "url",
648
- code: ZodError_js_1.ZodIssueCode.invalid_string,
649
- message: check.message,
650
- });
651
- status.dirty();
652
- }
653
- }
654
- else if (check.kind === "regex") {
655
- check.regex.lastIndex = 0;
656
- const testResult = check.regex.test(input.data);
657
- if (!testResult) {
658
- ctx = this._getOrReturnCtx(input, ctx);
659
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
660
- validation: "regex",
661
- code: ZodError_js_1.ZodIssueCode.invalid_string,
662
- message: check.message,
663
- });
664
- status.dirty();
665
- }
666
- }
667
- else if (check.kind === "trim") {
668
- input.data = input.data.trim();
669
- }
670
- else if (check.kind === "includes") {
671
- if (!input.data.includes(check.value, check.position)) {
672
- ctx = this._getOrReturnCtx(input, ctx);
673
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
674
- code: ZodError_js_1.ZodIssueCode.invalid_string,
675
- validation: { includes: check.value, position: check.position },
676
- message: check.message,
677
- });
678
- status.dirty();
679
- }
680
- }
681
- else if (check.kind === "toLowerCase") {
682
- input.data = input.data.toLowerCase();
683
- }
684
- else if (check.kind === "toUpperCase") {
685
- input.data = input.data.toUpperCase();
686
- }
687
- else if (check.kind === "startsWith") {
688
- if (!input.data.startsWith(check.value)) {
689
- ctx = this._getOrReturnCtx(input, ctx);
690
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
691
- code: ZodError_js_1.ZodIssueCode.invalid_string,
692
- validation: { startsWith: check.value },
693
- message: check.message,
694
- });
695
- status.dirty();
696
- }
697
- }
698
- else if (check.kind === "endsWith") {
699
- if (!input.data.endsWith(check.value)) {
700
- ctx = this._getOrReturnCtx(input, ctx);
701
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
702
- code: ZodError_js_1.ZodIssueCode.invalid_string,
703
- validation: { endsWith: check.value },
704
- message: check.message,
705
- });
706
- status.dirty();
707
- }
708
- }
709
- else if (check.kind === "datetime") {
710
- const regex = datetimeRegex(check);
711
- if (!regex.test(input.data)) {
712
- ctx = this._getOrReturnCtx(input, ctx);
713
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
714
- code: ZodError_js_1.ZodIssueCode.invalid_string,
715
- validation: "datetime",
716
- message: check.message,
717
- });
718
- status.dirty();
719
- }
720
- }
721
- else if (check.kind === "date") {
722
- const regex = dateRegex;
723
- if (!regex.test(input.data)) {
724
- ctx = this._getOrReturnCtx(input, ctx);
725
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
726
- code: ZodError_js_1.ZodIssueCode.invalid_string,
727
- validation: "date",
728
- message: check.message,
729
- });
730
- status.dirty();
731
- }
732
- }
733
- else if (check.kind === "time") {
734
- const regex = timeRegex(check);
735
- if (!regex.test(input.data)) {
736
- ctx = this._getOrReturnCtx(input, ctx);
737
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
738
- code: ZodError_js_1.ZodIssueCode.invalid_string,
739
- validation: "time",
740
- message: check.message,
741
- });
742
- status.dirty();
743
- }
744
- }
745
- else if (check.kind === "duration") {
746
- if (!durationRegex.test(input.data)) {
747
- ctx = this._getOrReturnCtx(input, ctx);
748
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
749
- validation: "duration",
750
- code: ZodError_js_1.ZodIssueCode.invalid_string,
751
- message: check.message,
752
- });
753
- status.dirty();
754
- }
755
- }
756
- else if (check.kind === "ip") {
757
- if (!isValidIP(input.data, check.version)) {
758
- ctx = this._getOrReturnCtx(input, ctx);
759
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
760
- validation: "ip",
761
- code: ZodError_js_1.ZodIssueCode.invalid_string,
762
- message: check.message,
763
- });
764
- status.dirty();
765
- }
766
- }
767
- else if (check.kind === "jwt") {
768
- if (!isValidJWT(input.data, check.alg)) {
769
- ctx = this._getOrReturnCtx(input, ctx);
770
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
771
- validation: "jwt",
772
- code: ZodError_js_1.ZodIssueCode.invalid_string,
773
- message: check.message,
774
- });
775
- status.dirty();
776
- }
777
- }
778
- else if (check.kind === "cidr") {
779
- if (!isValidCidr(input.data, check.version)) {
780
- ctx = this._getOrReturnCtx(input, ctx);
781
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
782
- validation: "cidr",
783
- code: ZodError_js_1.ZodIssueCode.invalid_string,
784
- message: check.message,
785
- });
786
- status.dirty();
787
- }
788
- }
789
- else if (check.kind === "base64") {
790
- if (!base64Regex.test(input.data)) {
791
- ctx = this._getOrReturnCtx(input, ctx);
792
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
793
- validation: "base64",
794
- code: ZodError_js_1.ZodIssueCode.invalid_string,
795
- message: check.message,
796
- });
797
- status.dirty();
798
- }
799
- }
800
- else if (check.kind === "base64url") {
801
- if (!base64urlRegex.test(input.data)) {
802
- ctx = this._getOrReturnCtx(input, ctx);
803
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
804
- validation: "base64url",
805
- code: ZodError_js_1.ZodIssueCode.invalid_string,
806
- message: check.message,
807
- });
808
- status.dirty();
809
- }
810
- }
811
- else {
812
- util_js_1.util.assertNever(check);
813
- }
814
- }
815
- return { status: status.value, value: input.data };
816
- }
817
- _regex(regex, validation, message) {
818
- return this.refinement((data) => regex.test(data), {
819
- validation,
820
- code: ZodError_js_1.ZodIssueCode.invalid_string,
821
- ...errorUtil_js_1.errorUtil.errToObj(message),
822
- });
823
- }
824
- _addCheck(check) {
825
- return new ZodString({
826
- ...this._def,
827
- checks: [...this._def.checks, check],
828
- });
829
- }
830
- email(message) {
831
- return this._addCheck({ kind: "email", ...errorUtil_js_1.errorUtil.errToObj(message) });
832
- }
833
- url(message) {
834
- return this._addCheck({ kind: "url", ...errorUtil_js_1.errorUtil.errToObj(message) });
835
- }
836
- emoji(message) {
837
- return this._addCheck({ kind: "emoji", ...errorUtil_js_1.errorUtil.errToObj(message) });
838
- }
839
- uuid(message) {
840
- return this._addCheck({ kind: "uuid", ...errorUtil_js_1.errorUtil.errToObj(message) });
841
- }
842
- nanoid(message) {
843
- return this._addCheck({ kind: "nanoid", ...errorUtil_js_1.errorUtil.errToObj(message) });
844
- }
845
- cuid(message) {
846
- return this._addCheck({ kind: "cuid", ...errorUtil_js_1.errorUtil.errToObj(message) });
847
- }
848
- cuid2(message) {
849
- return this._addCheck({ kind: "cuid2", ...errorUtil_js_1.errorUtil.errToObj(message) });
850
- }
851
- ulid(message) {
852
- return this._addCheck({ kind: "ulid", ...errorUtil_js_1.errorUtil.errToObj(message) });
853
- }
854
- base64(message) {
855
- return this._addCheck({ kind: "base64", ...errorUtil_js_1.errorUtil.errToObj(message) });
856
- }
857
- base64url(message) {
858
- // base64url encoding is a modification of base64 that can safely be used in URLs and filenames
859
- return this._addCheck({
860
- kind: "base64url",
861
- ...errorUtil_js_1.errorUtil.errToObj(message),
862
- });
863
- }
864
- jwt(options) {
865
- return this._addCheck({ kind: "jwt", ...errorUtil_js_1.errorUtil.errToObj(options) });
866
- }
867
- ip(options) {
868
- return this._addCheck({ kind: "ip", ...errorUtil_js_1.errorUtil.errToObj(options) });
869
- }
870
- cidr(options) {
871
- return this._addCheck({ kind: "cidr", ...errorUtil_js_1.errorUtil.errToObj(options) });
872
- }
873
- datetime(options) {
874
- if (typeof options === "string") {
875
- return this._addCheck({
876
- kind: "datetime",
877
- precision: null,
878
- offset: false,
879
- local: false,
880
- message: options,
881
- });
882
- }
883
- return this._addCheck({
884
- kind: "datetime",
885
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
886
- offset: options?.offset ?? false,
887
- local: options?.local ?? false,
888
- ...errorUtil_js_1.errorUtil.errToObj(options?.message),
889
- });
890
- }
891
- date(message) {
892
- return this._addCheck({ kind: "date", message });
893
- }
894
- time(options) {
895
- if (typeof options === "string") {
896
- return this._addCheck({
897
- kind: "time",
898
- precision: null,
899
- message: options,
900
- });
901
- }
902
- return this._addCheck({
903
- kind: "time",
904
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
905
- ...errorUtil_js_1.errorUtil.errToObj(options?.message),
906
- });
907
- }
908
- duration(message) {
909
- return this._addCheck({ kind: "duration", ...errorUtil_js_1.errorUtil.errToObj(message) });
910
- }
911
- regex(regex, message) {
912
- return this._addCheck({
913
- kind: "regex",
914
- regex: regex,
915
- ...errorUtil_js_1.errorUtil.errToObj(message),
916
- });
917
- }
918
- includes(value, options) {
919
- return this._addCheck({
920
- kind: "includes",
921
- value: value,
922
- position: options?.position,
923
- ...errorUtil_js_1.errorUtil.errToObj(options?.message),
924
- });
925
- }
926
- startsWith(value, message) {
927
- return this._addCheck({
928
- kind: "startsWith",
929
- value: value,
930
- ...errorUtil_js_1.errorUtil.errToObj(message),
931
- });
932
- }
933
- endsWith(value, message) {
934
- return this._addCheck({
935
- kind: "endsWith",
936
- value: value,
937
- ...errorUtil_js_1.errorUtil.errToObj(message),
938
- });
939
- }
940
- min(minLength, message) {
941
- return this._addCheck({
942
- kind: "min",
943
- value: minLength,
944
- ...errorUtil_js_1.errorUtil.errToObj(message),
945
- });
946
- }
947
- max(maxLength, message) {
948
- return this._addCheck({
949
- kind: "max",
950
- value: maxLength,
951
- ...errorUtil_js_1.errorUtil.errToObj(message),
952
- });
953
- }
954
- length(len, message) {
955
- return this._addCheck({
956
- kind: "length",
957
- value: len,
958
- ...errorUtil_js_1.errorUtil.errToObj(message),
959
- });
960
- }
961
- /**
962
- * Equivalent to `.min(1)`
963
- */
964
- nonempty(message) {
965
- return this.min(1, errorUtil_js_1.errorUtil.errToObj(message));
966
- }
967
- trim() {
968
- return new ZodString({
969
- ...this._def,
970
- checks: [...this._def.checks, { kind: "trim" }],
971
- });
972
- }
973
- toLowerCase() {
974
- return new ZodString({
975
- ...this._def,
976
- checks: [...this._def.checks, { kind: "toLowerCase" }],
977
- });
978
- }
979
- toUpperCase() {
980
- return new ZodString({
981
- ...this._def,
982
- checks: [...this._def.checks, { kind: "toUpperCase" }],
983
- });
984
- }
985
- get isDatetime() {
986
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
987
- }
988
- get isDate() {
989
- return !!this._def.checks.find((ch) => ch.kind === "date");
990
- }
991
- get isTime() {
992
- return !!this._def.checks.find((ch) => ch.kind === "time");
993
- }
994
- get isDuration() {
995
- return !!this._def.checks.find((ch) => ch.kind === "duration");
996
- }
997
- get isEmail() {
998
- return !!this._def.checks.find((ch) => ch.kind === "email");
999
- }
1000
- get isURL() {
1001
- return !!this._def.checks.find((ch) => ch.kind === "url");
1002
- }
1003
- get isEmoji() {
1004
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
1005
- }
1006
- get isUUID() {
1007
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
1008
- }
1009
- get isNANOID() {
1010
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1011
- }
1012
- get isCUID() {
1013
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
1014
- }
1015
- get isCUID2() {
1016
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1017
- }
1018
- get isULID() {
1019
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
1020
- }
1021
- get isIP() {
1022
- return !!this._def.checks.find((ch) => ch.kind === "ip");
1023
- }
1024
- get isCIDR() {
1025
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
1026
- }
1027
- get isBase64() {
1028
- return !!this._def.checks.find((ch) => ch.kind === "base64");
1029
- }
1030
- get isBase64url() {
1031
- // base64url encoding is a modification of base64 that can safely be used in URLs and filenames
1032
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
1033
- }
1034
- get minLength() {
1035
- let min = null;
1036
- for (const ch of this._def.checks) {
1037
- if (ch.kind === "min") {
1038
- if (min === null || ch.value > min)
1039
- min = ch.value;
1040
- }
1041
- }
1042
- return min;
1043
- }
1044
- get maxLength() {
1045
- let max = null;
1046
- for (const ch of this._def.checks) {
1047
- if (ch.kind === "max") {
1048
- if (max === null || ch.value < max)
1049
- max = ch.value;
1050
- }
1051
- }
1052
- return max;
1053
- }
1054
- }
1055
- exports.ZodString = ZodString;
1056
- ZodString.create = (params) => {
1057
- return new ZodString({
1058
- checks: [],
1059
- typeName: ZodFirstPartyTypeKind.ZodString,
1060
- coerce: params?.coerce ?? false,
1061
- ...processCreateParams(params),
1062
- });
1063
- };
1064
- // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
1065
- function floatSafeRemainder(val, step) {
1066
- const valDecCount = (val.toString().split(".")[1] || "").length;
1067
- const stepDecCount = (step.toString().split(".")[1] || "").length;
1068
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1069
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1070
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1071
- return (valInt % stepInt) / 10 ** decCount;
1072
- }
1073
- class ZodNumber extends ZodType {
1074
- constructor() {
1075
- super(...arguments);
1076
- this.min = this.gte;
1077
- this.max = this.lte;
1078
- this.step = this.multipleOf;
1079
- }
1080
- _parse(input) {
1081
- if (this._def.coerce) {
1082
- input.data = Number(input.data);
1083
- }
1084
- const parsedType = this._getType(input);
1085
- if (parsedType !== util_js_1.ZodParsedType.number) {
1086
- const ctx = this._getOrReturnCtx(input);
1087
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1088
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1089
- expected: util_js_1.ZodParsedType.number,
1090
- received: ctx.parsedType,
1091
- });
1092
- return parseUtil_js_1.INVALID;
1093
- }
1094
- let ctx = undefined;
1095
- const status = new parseUtil_js_1.ParseStatus();
1096
- for (const check of this._def.checks) {
1097
- if (check.kind === "int") {
1098
- if (!util_js_1.util.isInteger(input.data)) {
1099
- ctx = this._getOrReturnCtx(input, ctx);
1100
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1101
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1102
- expected: "integer",
1103
- received: "float",
1104
- message: check.message,
1105
- });
1106
- status.dirty();
1107
- }
1108
- }
1109
- else if (check.kind === "min") {
1110
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1111
- if (tooSmall) {
1112
- ctx = this._getOrReturnCtx(input, ctx);
1113
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1114
- code: ZodError_js_1.ZodIssueCode.too_small,
1115
- minimum: check.value,
1116
- type: "number",
1117
- inclusive: check.inclusive,
1118
- exact: false,
1119
- message: check.message,
1120
- });
1121
- status.dirty();
1122
- }
1123
- }
1124
- else if (check.kind === "max") {
1125
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1126
- if (tooBig) {
1127
- ctx = this._getOrReturnCtx(input, ctx);
1128
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1129
- code: ZodError_js_1.ZodIssueCode.too_big,
1130
- maximum: check.value,
1131
- type: "number",
1132
- inclusive: check.inclusive,
1133
- exact: false,
1134
- message: check.message,
1135
- });
1136
- status.dirty();
1137
- }
1138
- }
1139
- else if (check.kind === "multipleOf") {
1140
- if (floatSafeRemainder(input.data, check.value) !== 0) {
1141
- ctx = this._getOrReturnCtx(input, ctx);
1142
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1143
- code: ZodError_js_1.ZodIssueCode.not_multiple_of,
1144
- multipleOf: check.value,
1145
- message: check.message,
1146
- });
1147
- status.dirty();
1148
- }
1149
- }
1150
- else if (check.kind === "finite") {
1151
- if (!Number.isFinite(input.data)) {
1152
- ctx = this._getOrReturnCtx(input, ctx);
1153
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1154
- code: ZodError_js_1.ZodIssueCode.not_finite,
1155
- message: check.message,
1156
- });
1157
- status.dirty();
1158
- }
1159
- }
1160
- else {
1161
- util_js_1.util.assertNever(check);
1162
- }
1163
- }
1164
- return { status: status.value, value: input.data };
1165
- }
1166
- gte(value, message) {
1167
- return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));
1168
- }
1169
- gt(value, message) {
1170
- return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));
1171
- }
1172
- lte(value, message) {
1173
- return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));
1174
- }
1175
- lt(value, message) {
1176
- return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));
1177
- }
1178
- setLimit(kind, value, inclusive, message) {
1179
- return new ZodNumber({
1180
- ...this._def,
1181
- checks: [
1182
- ...this._def.checks,
1183
- {
1184
- kind,
1185
- value,
1186
- inclusive,
1187
- message: errorUtil_js_1.errorUtil.toString(message),
1188
- },
1189
- ],
1190
- });
1191
- }
1192
- _addCheck(check) {
1193
- return new ZodNumber({
1194
- ...this._def,
1195
- checks: [...this._def.checks, check],
1196
- });
1197
- }
1198
- int(message) {
1199
- return this._addCheck({
1200
- kind: "int",
1201
- message: errorUtil_js_1.errorUtil.toString(message),
1202
- });
1203
- }
1204
- positive(message) {
1205
- return this._addCheck({
1206
- kind: "min",
1207
- value: 0,
1208
- inclusive: false,
1209
- message: errorUtil_js_1.errorUtil.toString(message),
1210
- });
1211
- }
1212
- negative(message) {
1213
- return this._addCheck({
1214
- kind: "max",
1215
- value: 0,
1216
- inclusive: false,
1217
- message: errorUtil_js_1.errorUtil.toString(message),
1218
- });
1219
- }
1220
- nonpositive(message) {
1221
- return this._addCheck({
1222
- kind: "max",
1223
- value: 0,
1224
- inclusive: true,
1225
- message: errorUtil_js_1.errorUtil.toString(message),
1226
- });
1227
- }
1228
- nonnegative(message) {
1229
- return this._addCheck({
1230
- kind: "min",
1231
- value: 0,
1232
- inclusive: true,
1233
- message: errorUtil_js_1.errorUtil.toString(message),
1234
- });
1235
- }
1236
- multipleOf(value, message) {
1237
- return this._addCheck({
1238
- kind: "multipleOf",
1239
- value: value,
1240
- message: errorUtil_js_1.errorUtil.toString(message),
1241
- });
1242
- }
1243
- finite(message) {
1244
- return this._addCheck({
1245
- kind: "finite",
1246
- message: errorUtil_js_1.errorUtil.toString(message),
1247
- });
1248
- }
1249
- safe(message) {
1250
- return this._addCheck({
1251
- kind: "min",
1252
- inclusive: true,
1253
- value: Number.MIN_SAFE_INTEGER,
1254
- message: errorUtil_js_1.errorUtil.toString(message),
1255
- })._addCheck({
1256
- kind: "max",
1257
- inclusive: true,
1258
- value: Number.MAX_SAFE_INTEGER,
1259
- message: errorUtil_js_1.errorUtil.toString(message),
1260
- });
1261
- }
1262
- get minValue() {
1263
- let min = null;
1264
- for (const ch of this._def.checks) {
1265
- if (ch.kind === "min") {
1266
- if (min === null || ch.value > min)
1267
- min = ch.value;
1268
- }
1269
- }
1270
- return min;
1271
- }
1272
- get maxValue() {
1273
- let max = null;
1274
- for (const ch of this._def.checks) {
1275
- if (ch.kind === "max") {
1276
- if (max === null || ch.value < max)
1277
- max = ch.value;
1278
- }
1279
- }
1280
- return max;
1281
- }
1282
- get isInt() {
1283
- return !!this._def.checks.find((ch) => ch.kind === "int" || (ch.kind === "multipleOf" && util_js_1.util.isInteger(ch.value)));
1284
- }
1285
- get isFinite() {
1286
- let max = null;
1287
- let min = null;
1288
- for (const ch of this._def.checks) {
1289
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1290
- return true;
1291
- }
1292
- else if (ch.kind === "min") {
1293
- if (min === null || ch.value > min)
1294
- min = ch.value;
1295
- }
1296
- else if (ch.kind === "max") {
1297
- if (max === null || ch.value < max)
1298
- max = ch.value;
1299
- }
1300
- }
1301
- return Number.isFinite(min) && Number.isFinite(max);
1302
- }
1303
- }
1304
- exports.ZodNumber = ZodNumber;
1305
- ZodNumber.create = (params) => {
1306
- return new ZodNumber({
1307
- checks: [],
1308
- typeName: ZodFirstPartyTypeKind.ZodNumber,
1309
- coerce: params?.coerce || false,
1310
- ...processCreateParams(params),
1311
- });
1312
- };
1313
- class ZodBigInt extends ZodType {
1314
- constructor() {
1315
- super(...arguments);
1316
- this.min = this.gte;
1317
- this.max = this.lte;
1318
- }
1319
- _parse(input) {
1320
- if (this._def.coerce) {
1321
- try {
1322
- input.data = BigInt(input.data);
1323
- }
1324
- catch {
1325
- return this._getInvalidInput(input);
1326
- }
1327
- }
1328
- const parsedType = this._getType(input);
1329
- if (parsedType !== util_js_1.ZodParsedType.bigint) {
1330
- return this._getInvalidInput(input);
1331
- }
1332
- let ctx = undefined;
1333
- const status = new parseUtil_js_1.ParseStatus();
1334
- for (const check of this._def.checks) {
1335
- if (check.kind === "min") {
1336
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1337
- if (tooSmall) {
1338
- ctx = this._getOrReturnCtx(input, ctx);
1339
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1340
- code: ZodError_js_1.ZodIssueCode.too_small,
1341
- type: "bigint",
1342
- minimum: check.value,
1343
- inclusive: check.inclusive,
1344
- message: check.message,
1345
- });
1346
- status.dirty();
1347
- }
1348
- }
1349
- else if (check.kind === "max") {
1350
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1351
- if (tooBig) {
1352
- ctx = this._getOrReturnCtx(input, ctx);
1353
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1354
- code: ZodError_js_1.ZodIssueCode.too_big,
1355
- type: "bigint",
1356
- maximum: check.value,
1357
- inclusive: check.inclusive,
1358
- message: check.message,
1359
- });
1360
- status.dirty();
1361
- }
1362
- }
1363
- else if (check.kind === "multipleOf") {
1364
- if (input.data % check.value !== BigInt(0)) {
1365
- ctx = this._getOrReturnCtx(input, ctx);
1366
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1367
- code: ZodError_js_1.ZodIssueCode.not_multiple_of,
1368
- multipleOf: check.value,
1369
- message: check.message,
1370
- });
1371
- status.dirty();
1372
- }
1373
- }
1374
- else {
1375
- util_js_1.util.assertNever(check);
1376
- }
1377
- }
1378
- return { status: status.value, value: input.data };
1379
- }
1380
- _getInvalidInput(input) {
1381
- const ctx = this._getOrReturnCtx(input);
1382
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1383
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1384
- expected: util_js_1.ZodParsedType.bigint,
1385
- received: ctx.parsedType,
1386
- });
1387
- return parseUtil_js_1.INVALID;
1388
- }
1389
- gte(value, message) {
1390
- return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));
1391
- }
1392
- gt(value, message) {
1393
- return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));
1394
- }
1395
- lte(value, message) {
1396
- return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));
1397
- }
1398
- lt(value, message) {
1399
- return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));
1400
- }
1401
- setLimit(kind, value, inclusive, message) {
1402
- return new ZodBigInt({
1403
- ...this._def,
1404
- checks: [
1405
- ...this._def.checks,
1406
- {
1407
- kind,
1408
- value,
1409
- inclusive,
1410
- message: errorUtil_js_1.errorUtil.toString(message),
1411
- },
1412
- ],
1413
- });
1414
- }
1415
- _addCheck(check) {
1416
- return new ZodBigInt({
1417
- ...this._def,
1418
- checks: [...this._def.checks, check],
1419
- });
1420
- }
1421
- positive(message) {
1422
- return this._addCheck({
1423
- kind: "min",
1424
- value: BigInt(0),
1425
- inclusive: false,
1426
- message: errorUtil_js_1.errorUtil.toString(message),
1427
- });
1428
- }
1429
- negative(message) {
1430
- return this._addCheck({
1431
- kind: "max",
1432
- value: BigInt(0),
1433
- inclusive: false,
1434
- message: errorUtil_js_1.errorUtil.toString(message),
1435
- });
1436
- }
1437
- nonpositive(message) {
1438
- return this._addCheck({
1439
- kind: "max",
1440
- value: BigInt(0),
1441
- inclusive: true,
1442
- message: errorUtil_js_1.errorUtil.toString(message),
1443
- });
1444
- }
1445
- nonnegative(message) {
1446
- return this._addCheck({
1447
- kind: "min",
1448
- value: BigInt(0),
1449
- inclusive: true,
1450
- message: errorUtil_js_1.errorUtil.toString(message),
1451
- });
1452
- }
1453
- multipleOf(value, message) {
1454
- return this._addCheck({
1455
- kind: "multipleOf",
1456
- value,
1457
- message: errorUtil_js_1.errorUtil.toString(message),
1458
- });
1459
- }
1460
- get minValue() {
1461
- let min = null;
1462
- for (const ch of this._def.checks) {
1463
- if (ch.kind === "min") {
1464
- if (min === null || ch.value > min)
1465
- min = ch.value;
1466
- }
1467
- }
1468
- return min;
1469
- }
1470
- get maxValue() {
1471
- let max = null;
1472
- for (const ch of this._def.checks) {
1473
- if (ch.kind === "max") {
1474
- if (max === null || ch.value < max)
1475
- max = ch.value;
1476
- }
1477
- }
1478
- return max;
1479
- }
1480
- }
1481
- exports.ZodBigInt = ZodBigInt;
1482
- ZodBigInt.create = (params) => {
1483
- return new ZodBigInt({
1484
- checks: [],
1485
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
1486
- coerce: params?.coerce ?? false,
1487
- ...processCreateParams(params),
1488
- });
1489
- };
1490
- class ZodBoolean extends ZodType {
1491
- _parse(input) {
1492
- if (this._def.coerce) {
1493
- input.data = Boolean(input.data);
1494
- }
1495
- const parsedType = this._getType(input);
1496
- if (parsedType !== util_js_1.ZodParsedType.boolean) {
1497
- const ctx = this._getOrReturnCtx(input);
1498
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1499
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1500
- expected: util_js_1.ZodParsedType.boolean,
1501
- received: ctx.parsedType,
1502
- });
1503
- return parseUtil_js_1.INVALID;
1504
- }
1505
- return (0, parseUtil_js_1.OK)(input.data);
1506
- }
1507
- }
1508
- exports.ZodBoolean = ZodBoolean;
1509
- ZodBoolean.create = (params) => {
1510
- return new ZodBoolean({
1511
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
1512
- coerce: params?.coerce || false,
1513
- ...processCreateParams(params),
1514
- });
1515
- };
1516
- class ZodDate extends ZodType {
1517
- _parse(input) {
1518
- if (this._def.coerce) {
1519
- input.data = new Date(input.data);
1520
- }
1521
- const parsedType = this._getType(input);
1522
- if (parsedType !== util_js_1.ZodParsedType.date) {
1523
- const ctx = this._getOrReturnCtx(input);
1524
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1525
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1526
- expected: util_js_1.ZodParsedType.date,
1527
- received: ctx.parsedType,
1528
- });
1529
- return parseUtil_js_1.INVALID;
1530
- }
1531
- if (Number.isNaN(input.data.getTime())) {
1532
- const ctx = this._getOrReturnCtx(input);
1533
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1534
- code: ZodError_js_1.ZodIssueCode.invalid_date,
1535
- });
1536
- return parseUtil_js_1.INVALID;
1537
- }
1538
- const status = new parseUtil_js_1.ParseStatus();
1539
- let ctx = undefined;
1540
- for (const check of this._def.checks) {
1541
- if (check.kind === "min") {
1542
- if (input.data.getTime() < check.value) {
1543
- ctx = this._getOrReturnCtx(input, ctx);
1544
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1545
- code: ZodError_js_1.ZodIssueCode.too_small,
1546
- message: check.message,
1547
- inclusive: true,
1548
- exact: false,
1549
- minimum: check.value,
1550
- type: "date",
1551
- });
1552
- status.dirty();
1553
- }
1554
- }
1555
- else if (check.kind === "max") {
1556
- if (input.data.getTime() > check.value) {
1557
- ctx = this._getOrReturnCtx(input, ctx);
1558
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1559
- code: ZodError_js_1.ZodIssueCode.too_big,
1560
- message: check.message,
1561
- inclusive: true,
1562
- exact: false,
1563
- maximum: check.value,
1564
- type: "date",
1565
- });
1566
- status.dirty();
1567
- }
1568
- }
1569
- else {
1570
- util_js_1.util.assertNever(check);
1571
- }
1572
- }
1573
- return {
1574
- status: status.value,
1575
- value: new Date(input.data.getTime()),
1576
- };
1577
- }
1578
- _addCheck(check) {
1579
- return new ZodDate({
1580
- ...this._def,
1581
- checks: [...this._def.checks, check],
1582
- });
1583
- }
1584
- min(minDate, message) {
1585
- return this._addCheck({
1586
- kind: "min",
1587
- value: minDate.getTime(),
1588
- message: errorUtil_js_1.errorUtil.toString(message),
1589
- });
1590
- }
1591
- max(maxDate, message) {
1592
- return this._addCheck({
1593
- kind: "max",
1594
- value: maxDate.getTime(),
1595
- message: errorUtil_js_1.errorUtil.toString(message),
1596
- });
1597
- }
1598
- get minDate() {
1599
- let min = null;
1600
- for (const ch of this._def.checks) {
1601
- if (ch.kind === "min") {
1602
- if (min === null || ch.value > min)
1603
- min = ch.value;
1604
- }
1605
- }
1606
- return min != null ? new Date(min) : null;
1607
- }
1608
- get maxDate() {
1609
- let max = null;
1610
- for (const ch of this._def.checks) {
1611
- if (ch.kind === "max") {
1612
- if (max === null || ch.value < max)
1613
- max = ch.value;
1614
- }
1615
- }
1616
- return max != null ? new Date(max) : null;
1617
- }
1618
- }
1619
- exports.ZodDate = ZodDate;
1620
- ZodDate.create = (params) => {
1621
- return new ZodDate({
1622
- checks: [],
1623
- coerce: params?.coerce || false,
1624
- typeName: ZodFirstPartyTypeKind.ZodDate,
1625
- ...processCreateParams(params),
1626
- });
1627
- };
1628
- class ZodSymbol extends ZodType {
1629
- _parse(input) {
1630
- const parsedType = this._getType(input);
1631
- if (parsedType !== util_js_1.ZodParsedType.symbol) {
1632
- const ctx = this._getOrReturnCtx(input);
1633
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1634
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1635
- expected: util_js_1.ZodParsedType.symbol,
1636
- received: ctx.parsedType,
1637
- });
1638
- return parseUtil_js_1.INVALID;
1639
- }
1640
- return (0, parseUtil_js_1.OK)(input.data);
1641
- }
1642
- }
1643
- exports.ZodSymbol = ZodSymbol;
1644
- ZodSymbol.create = (params) => {
1645
- return new ZodSymbol({
1646
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
1647
- ...processCreateParams(params),
1648
- });
1649
- };
1650
- class ZodUndefined extends ZodType {
1651
- _parse(input) {
1652
- const parsedType = this._getType(input);
1653
- if (parsedType !== util_js_1.ZodParsedType.undefined) {
1654
- const ctx = this._getOrReturnCtx(input);
1655
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1656
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1657
- expected: util_js_1.ZodParsedType.undefined,
1658
- received: ctx.parsedType,
1659
- });
1660
- return parseUtil_js_1.INVALID;
1661
- }
1662
- return (0, parseUtil_js_1.OK)(input.data);
1663
- }
1664
- }
1665
- exports.ZodUndefined = ZodUndefined;
1666
- ZodUndefined.create = (params) => {
1667
- return new ZodUndefined({
1668
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
1669
- ...processCreateParams(params),
1670
- });
1671
- };
1672
- class ZodNull extends ZodType {
1673
- _parse(input) {
1674
- const parsedType = this._getType(input);
1675
- if (parsedType !== util_js_1.ZodParsedType.null) {
1676
- const ctx = this._getOrReturnCtx(input);
1677
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1678
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1679
- expected: util_js_1.ZodParsedType.null,
1680
- received: ctx.parsedType,
1681
- });
1682
- return parseUtil_js_1.INVALID;
1683
- }
1684
- return (0, parseUtil_js_1.OK)(input.data);
1685
- }
1686
- }
1687
- exports.ZodNull = ZodNull;
1688
- ZodNull.create = (params) => {
1689
- return new ZodNull({
1690
- typeName: ZodFirstPartyTypeKind.ZodNull,
1691
- ...processCreateParams(params),
1692
- });
1693
- };
1694
- class ZodAny extends ZodType {
1695
- constructor() {
1696
- super(...arguments);
1697
- // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.
1698
- this._any = true;
1699
- }
1700
- _parse(input) {
1701
- return (0, parseUtil_js_1.OK)(input.data);
1702
- }
1703
- }
1704
- exports.ZodAny = ZodAny;
1705
- ZodAny.create = (params) => {
1706
- return new ZodAny({
1707
- typeName: ZodFirstPartyTypeKind.ZodAny,
1708
- ...processCreateParams(params),
1709
- });
1710
- };
1711
- class ZodUnknown extends ZodType {
1712
- constructor() {
1713
- super(...arguments);
1714
- // required
1715
- this._unknown = true;
1716
- }
1717
- _parse(input) {
1718
- return (0, parseUtil_js_1.OK)(input.data);
1719
- }
1720
- }
1721
- exports.ZodUnknown = ZodUnknown;
1722
- ZodUnknown.create = (params) => {
1723
- return new ZodUnknown({
1724
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
1725
- ...processCreateParams(params),
1726
- });
1727
- };
1728
- class ZodNever extends ZodType {
1729
- _parse(input) {
1730
- const ctx = this._getOrReturnCtx(input);
1731
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1732
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1733
- expected: util_js_1.ZodParsedType.never,
1734
- received: ctx.parsedType,
1735
- });
1736
- return parseUtil_js_1.INVALID;
1737
- }
1738
- }
1739
- exports.ZodNever = ZodNever;
1740
- ZodNever.create = (params) => {
1741
- return new ZodNever({
1742
- typeName: ZodFirstPartyTypeKind.ZodNever,
1743
- ...processCreateParams(params),
1744
- });
1745
- };
1746
- class ZodVoid extends ZodType {
1747
- _parse(input) {
1748
- const parsedType = this._getType(input);
1749
- if (parsedType !== util_js_1.ZodParsedType.undefined) {
1750
- const ctx = this._getOrReturnCtx(input);
1751
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1752
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1753
- expected: util_js_1.ZodParsedType.void,
1754
- received: ctx.parsedType,
1755
- });
1756
- return parseUtil_js_1.INVALID;
1757
- }
1758
- return (0, parseUtil_js_1.OK)(input.data);
1759
- }
1760
- }
1761
- exports.ZodVoid = ZodVoid;
1762
- ZodVoid.create = (params) => {
1763
- return new ZodVoid({
1764
- typeName: ZodFirstPartyTypeKind.ZodVoid,
1765
- ...processCreateParams(params),
1766
- });
1767
- };
1768
- class ZodArray extends ZodType {
1769
- _parse(input) {
1770
- const { ctx, status } = this._processInputParams(input);
1771
- const def = this._def;
1772
- if (ctx.parsedType !== util_js_1.ZodParsedType.array) {
1773
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1774
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1775
- expected: util_js_1.ZodParsedType.array,
1776
- received: ctx.parsedType,
1777
- });
1778
- return parseUtil_js_1.INVALID;
1779
- }
1780
- if (def.exactLength !== null) {
1781
- const tooBig = ctx.data.length > def.exactLength.value;
1782
- const tooSmall = ctx.data.length < def.exactLength.value;
1783
- if (tooBig || tooSmall) {
1784
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1785
- code: tooBig ? ZodError_js_1.ZodIssueCode.too_big : ZodError_js_1.ZodIssueCode.too_small,
1786
- minimum: (tooSmall ? def.exactLength.value : undefined),
1787
- maximum: (tooBig ? def.exactLength.value : undefined),
1788
- type: "array",
1789
- inclusive: true,
1790
- exact: true,
1791
- message: def.exactLength.message,
1792
- });
1793
- status.dirty();
1794
- }
1795
- }
1796
- if (def.minLength !== null) {
1797
- if (ctx.data.length < def.minLength.value) {
1798
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1799
- code: ZodError_js_1.ZodIssueCode.too_small,
1800
- minimum: def.minLength.value,
1801
- type: "array",
1802
- inclusive: true,
1803
- exact: false,
1804
- message: def.minLength.message,
1805
- });
1806
- status.dirty();
1807
- }
1808
- }
1809
- if (def.maxLength !== null) {
1810
- if (ctx.data.length > def.maxLength.value) {
1811
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1812
- code: ZodError_js_1.ZodIssueCode.too_big,
1813
- maximum: def.maxLength.value,
1814
- type: "array",
1815
- inclusive: true,
1816
- exact: false,
1817
- message: def.maxLength.message,
1818
- });
1819
- status.dirty();
1820
- }
1821
- }
1822
- if (ctx.common.async) {
1823
- return Promise.all([...ctx.data].map((item, i) => {
1824
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1825
- })).then((result) => {
1826
- return parseUtil_js_1.ParseStatus.mergeArray(status, result);
1827
- });
1828
- }
1829
- const result = [...ctx.data].map((item, i) => {
1830
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1831
- });
1832
- return parseUtil_js_1.ParseStatus.mergeArray(status, result);
1833
- }
1834
- get element() {
1835
- return this._def.type;
1836
- }
1837
- min(minLength, message) {
1838
- return new ZodArray({
1839
- ...this._def,
1840
- minLength: { value: minLength, message: errorUtil_js_1.errorUtil.toString(message) },
1841
- });
1842
- }
1843
- max(maxLength, message) {
1844
- return new ZodArray({
1845
- ...this._def,
1846
- maxLength: { value: maxLength, message: errorUtil_js_1.errorUtil.toString(message) },
1847
- });
1848
- }
1849
- length(len, message) {
1850
- return new ZodArray({
1851
- ...this._def,
1852
- exactLength: { value: len, message: errorUtil_js_1.errorUtil.toString(message) },
1853
- });
1854
- }
1855
- nonempty(message) {
1856
- return this.min(1, message);
1857
- }
1858
- }
1859
- exports.ZodArray = ZodArray;
1860
- ZodArray.create = (schema, params) => {
1861
- return new ZodArray({
1862
- type: schema,
1863
- minLength: null,
1864
- maxLength: null,
1865
- exactLength: null,
1866
- typeName: ZodFirstPartyTypeKind.ZodArray,
1867
- ...processCreateParams(params),
1868
- });
1869
- };
1870
- function deepPartialify(schema) {
1871
- if (schema instanceof ZodObject) {
1872
- const newShape = {};
1873
- for (const key in schema.shape) {
1874
- const fieldSchema = schema.shape[key];
1875
- newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1876
- }
1877
- return new ZodObject({
1878
- ...schema._def,
1879
- shape: () => newShape,
1880
- });
1881
- }
1882
- else if (schema instanceof ZodArray) {
1883
- return new ZodArray({
1884
- ...schema._def,
1885
- type: deepPartialify(schema.element),
1886
- });
1887
- }
1888
- else if (schema instanceof ZodOptional) {
1889
- return ZodOptional.create(deepPartialify(schema.unwrap()));
1890
- }
1891
- else if (schema instanceof ZodNullable) {
1892
- return ZodNullable.create(deepPartialify(schema.unwrap()));
1893
- }
1894
- else if (schema instanceof ZodTuple) {
1895
- return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
1896
- }
1897
- else {
1898
- return schema;
1899
- }
1900
- }
1901
- class ZodObject extends ZodType {
1902
- constructor() {
1903
- super(...arguments);
1904
- this._cached = null;
1905
- /**
1906
- * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
1907
- * If you want to pass through unknown properties, use `.passthrough()` instead.
1908
- */
1909
- this.nonstrict = this.passthrough;
1910
- // extend<
1911
- // Augmentation extends ZodRawShape,
1912
- // NewOutput extends util.flatten<{
1913
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1914
- // ? Augmentation[k]["_output"]
1915
- // : k extends keyof Output
1916
- // ? Output[k]
1917
- // : never;
1918
- // }>,
1919
- // NewInput extends util.flatten<{
1920
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1921
- // ? Augmentation[k]["_input"]
1922
- // : k extends keyof Input
1923
- // ? Input[k]
1924
- // : never;
1925
- // }>
1926
- // >(
1927
- // augmentation: Augmentation
1928
- // ): ZodObject<
1929
- // extendShape<T, Augmentation>,
1930
- // UnknownKeys,
1931
- // Catchall,
1932
- // NewOutput,
1933
- // NewInput
1934
- // > {
1935
- // return new ZodObject({
1936
- // ...this._def,
1937
- // shape: () => ({
1938
- // ...this._def.shape(),
1939
- // ...augmentation,
1940
- // }),
1941
- // }) as any;
1942
- // }
1943
- /**
1944
- * @deprecated Use `.extend` instead
1945
- * */
1946
- this.augment = this.extend;
1947
- }
1948
- _getCached() {
1949
- if (this._cached !== null)
1950
- return this._cached;
1951
- const shape = this._def.shape();
1952
- const keys = util_js_1.util.objectKeys(shape);
1953
- this._cached = { shape, keys };
1954
- return this._cached;
1955
- }
1956
- _parse(input) {
1957
- const parsedType = this._getType(input);
1958
- if (parsedType !== util_js_1.ZodParsedType.object) {
1959
- const ctx = this._getOrReturnCtx(input);
1960
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
1961
- code: ZodError_js_1.ZodIssueCode.invalid_type,
1962
- expected: util_js_1.ZodParsedType.object,
1963
- received: ctx.parsedType,
1964
- });
1965
- return parseUtil_js_1.INVALID;
1966
- }
1967
- const { status, ctx } = this._processInputParams(input);
1968
- const { shape, keys: shapeKeys } = this._getCached();
1969
- const extraKeys = [];
1970
- if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
1971
- for (const key in ctx.data) {
1972
- if (!shapeKeys.includes(key)) {
1973
- extraKeys.push(key);
1974
- }
1975
- }
1976
- }
1977
- const pairs = [];
1978
- for (const key of shapeKeys) {
1979
- const keyValidator = shape[key];
1980
- const value = ctx.data[key];
1981
- pairs.push({
1982
- key: { status: "valid", value: key },
1983
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
1984
- alwaysSet: key in ctx.data,
1985
- });
1986
- }
1987
- if (this._def.catchall instanceof ZodNever) {
1988
- const unknownKeys = this._def.unknownKeys;
1989
- if (unknownKeys === "passthrough") {
1990
- for (const key of extraKeys) {
1991
- pairs.push({
1992
- key: { status: "valid", value: key },
1993
- value: { status: "valid", value: ctx.data[key] },
1994
- });
1995
- }
1996
- }
1997
- else if (unknownKeys === "strict") {
1998
- if (extraKeys.length > 0) {
1999
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2000
- code: ZodError_js_1.ZodIssueCode.unrecognized_keys,
2001
- keys: extraKeys,
2002
- });
2003
- status.dirty();
2004
- }
2005
- }
2006
- else if (unknownKeys === "strip") {
2007
- }
2008
- else {
2009
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2010
- }
2011
- }
2012
- else {
2013
- // run catchall validation
2014
- const catchall = this._def.catchall;
2015
- for (const key of extraKeys) {
2016
- const value = ctx.data[key];
2017
- pairs.push({
2018
- key: { status: "valid", value: key },
2019
- value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key) //, ctx.child(key), value, getParsedType(value)
2020
- ),
2021
- alwaysSet: key in ctx.data,
2022
- });
2023
- }
2024
- }
2025
- if (ctx.common.async) {
2026
- return Promise.resolve()
2027
- .then(async () => {
2028
- const syncPairs = [];
2029
- for (const pair of pairs) {
2030
- const key = await pair.key;
2031
- const value = await pair.value;
2032
- syncPairs.push({
2033
- key,
2034
- value,
2035
- alwaysSet: pair.alwaysSet,
2036
- });
2037
- }
2038
- return syncPairs;
2039
- })
2040
- .then((syncPairs) => {
2041
- return parseUtil_js_1.ParseStatus.mergeObjectSync(status, syncPairs);
2042
- });
2043
- }
2044
- else {
2045
- return parseUtil_js_1.ParseStatus.mergeObjectSync(status, pairs);
2046
- }
2047
- }
2048
- get shape() {
2049
- return this._def.shape();
2050
- }
2051
- strict(message) {
2052
- errorUtil_js_1.errorUtil.errToObj;
2053
- return new ZodObject({
2054
- ...this._def,
2055
- unknownKeys: "strict",
2056
- ...(message !== undefined
2057
- ? {
2058
- errorMap: (issue, ctx) => {
2059
- const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2060
- if (issue.code === "unrecognized_keys")
2061
- return {
2062
- message: errorUtil_js_1.errorUtil.errToObj(message).message ?? defaultError,
2063
- };
2064
- return {
2065
- message: defaultError,
2066
- };
2067
- },
2068
- }
2069
- : {}),
2070
- });
2071
- }
2072
- strip() {
2073
- return new ZodObject({
2074
- ...this._def,
2075
- unknownKeys: "strip",
2076
- });
2077
- }
2078
- passthrough() {
2079
- return new ZodObject({
2080
- ...this._def,
2081
- unknownKeys: "passthrough",
2082
- });
2083
- }
2084
- // const AugmentFactory =
2085
- // <Def extends ZodObjectDef>(def: Def) =>
2086
- // <Augmentation extends ZodRawShape>(
2087
- // augmentation: Augmentation
2088
- // ): ZodObject<
2089
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2090
- // Def["unknownKeys"],
2091
- // Def["catchall"]
2092
- // > => {
2093
- // return new ZodObject({
2094
- // ...def,
2095
- // shape: () => ({
2096
- // ...def.shape(),
2097
- // ...augmentation,
2098
- // }),
2099
- // }) as any;
2100
- // };
2101
- extend(augmentation) {
2102
- return new ZodObject({
2103
- ...this._def,
2104
- shape: () => ({
2105
- ...this._def.shape(),
2106
- ...augmentation,
2107
- }),
2108
- });
2109
- }
2110
- /**
2111
- * Prior to zod@1.0.12 there was a bug in the
2112
- * inferred type of merged objects. Please
2113
- * upgrade if you are experiencing issues.
2114
- */
2115
- merge(merging) {
2116
- const merged = new ZodObject({
2117
- unknownKeys: merging._def.unknownKeys,
2118
- catchall: merging._def.catchall,
2119
- shape: () => ({
2120
- ...this._def.shape(),
2121
- ...merging._def.shape(),
2122
- }),
2123
- typeName: ZodFirstPartyTypeKind.ZodObject,
2124
- });
2125
- return merged;
2126
- }
2127
- // merge<
2128
- // Incoming extends AnyZodObject,
2129
- // Augmentation extends Incoming["shape"],
2130
- // NewOutput extends {
2131
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2132
- // ? Augmentation[k]["_output"]
2133
- // : k extends keyof Output
2134
- // ? Output[k]
2135
- // : never;
2136
- // },
2137
- // NewInput extends {
2138
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2139
- // ? Augmentation[k]["_input"]
2140
- // : k extends keyof Input
2141
- // ? Input[k]
2142
- // : never;
2143
- // }
2144
- // >(
2145
- // merging: Incoming
2146
- // ): ZodObject<
2147
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2148
- // Incoming["_def"]["unknownKeys"],
2149
- // Incoming["_def"]["catchall"],
2150
- // NewOutput,
2151
- // NewInput
2152
- // > {
2153
- // const merged: any = new ZodObject({
2154
- // unknownKeys: merging._def.unknownKeys,
2155
- // catchall: merging._def.catchall,
2156
- // shape: () =>
2157
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2158
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2159
- // }) as any;
2160
- // return merged;
2161
- // }
2162
- setKey(key, schema) {
2163
- return this.augment({ [key]: schema });
2164
- }
2165
- // merge<Incoming extends AnyZodObject>(
2166
- // merging: Incoming
2167
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2168
- // ZodObject<
2169
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2170
- // Incoming["_def"]["unknownKeys"],
2171
- // Incoming["_def"]["catchall"]
2172
- // > {
2173
- // // const mergedShape = objectUtil.mergeShapes(
2174
- // // this._def.shape(),
2175
- // // merging._def.shape()
2176
- // // );
2177
- // const merged: any = new ZodObject({
2178
- // unknownKeys: merging._def.unknownKeys,
2179
- // catchall: merging._def.catchall,
2180
- // shape: () =>
2181
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2182
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2183
- // }) as any;
2184
- // return merged;
2185
- // }
2186
- catchall(index) {
2187
- return new ZodObject({
2188
- ...this._def,
2189
- catchall: index,
2190
- });
2191
- }
2192
- pick(mask) {
2193
- const shape = {};
2194
- for (const key of util_js_1.util.objectKeys(mask)) {
2195
- if (mask[key] && this.shape[key]) {
2196
- shape[key] = this.shape[key];
2197
- }
2198
- }
2199
- return new ZodObject({
2200
- ...this._def,
2201
- shape: () => shape,
2202
- });
2203
- }
2204
- omit(mask) {
2205
- const shape = {};
2206
- for (const key of util_js_1.util.objectKeys(this.shape)) {
2207
- if (!mask[key]) {
2208
- shape[key] = this.shape[key];
2209
- }
2210
- }
2211
- return new ZodObject({
2212
- ...this._def,
2213
- shape: () => shape,
2214
- });
2215
- }
2216
- /**
2217
- * @deprecated
2218
- */
2219
- deepPartial() {
2220
- return deepPartialify(this);
2221
- }
2222
- partial(mask) {
2223
- const newShape = {};
2224
- for (const key of util_js_1.util.objectKeys(this.shape)) {
2225
- const fieldSchema = this.shape[key];
2226
- if (mask && !mask[key]) {
2227
- newShape[key] = fieldSchema;
2228
- }
2229
- else {
2230
- newShape[key] = fieldSchema.optional();
2231
- }
2232
- }
2233
- return new ZodObject({
2234
- ...this._def,
2235
- shape: () => newShape,
2236
- });
2237
- }
2238
- required(mask) {
2239
- const newShape = {};
2240
- for (const key of util_js_1.util.objectKeys(this.shape)) {
2241
- if (mask && !mask[key]) {
2242
- newShape[key] = this.shape[key];
2243
- }
2244
- else {
2245
- const fieldSchema = this.shape[key];
2246
- let newField = fieldSchema;
2247
- while (newField instanceof ZodOptional) {
2248
- newField = newField._def.innerType;
2249
- }
2250
- newShape[key] = newField;
2251
- }
2252
- }
2253
- return new ZodObject({
2254
- ...this._def,
2255
- shape: () => newShape,
2256
- });
2257
- }
2258
- keyof() {
2259
- return createZodEnum(util_js_1.util.objectKeys(this.shape));
2260
- }
2261
- }
2262
- exports.ZodObject = ZodObject;
2263
- ZodObject.create = (shape, params) => {
2264
- return new ZodObject({
2265
- shape: () => shape,
2266
- unknownKeys: "strip",
2267
- catchall: ZodNever.create(),
2268
- typeName: ZodFirstPartyTypeKind.ZodObject,
2269
- ...processCreateParams(params),
2270
- });
2271
- };
2272
- ZodObject.strictCreate = (shape, params) => {
2273
- return new ZodObject({
2274
- shape: () => shape,
2275
- unknownKeys: "strict",
2276
- catchall: ZodNever.create(),
2277
- typeName: ZodFirstPartyTypeKind.ZodObject,
2278
- ...processCreateParams(params),
2279
- });
2280
- };
2281
- ZodObject.lazycreate = (shape, params) => {
2282
- return new ZodObject({
2283
- shape,
2284
- unknownKeys: "strip",
2285
- catchall: ZodNever.create(),
2286
- typeName: ZodFirstPartyTypeKind.ZodObject,
2287
- ...processCreateParams(params),
2288
- });
2289
- };
2290
- class ZodUnion extends ZodType {
2291
- _parse(input) {
2292
- const { ctx } = this._processInputParams(input);
2293
- const options = this._def.options;
2294
- function handleResults(results) {
2295
- // return first issue-free validation if it exists
2296
- for (const result of results) {
2297
- if (result.result.status === "valid") {
2298
- return result.result;
2299
- }
2300
- }
2301
- for (const result of results) {
2302
- if (result.result.status === "dirty") {
2303
- // add issues from dirty option
2304
- ctx.common.issues.push(...result.ctx.common.issues);
2305
- return result.result;
2306
- }
2307
- }
2308
- // return invalid
2309
- const unionErrors = results.map((result) => new ZodError_js_1.ZodError(result.ctx.common.issues));
2310
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2311
- code: ZodError_js_1.ZodIssueCode.invalid_union,
2312
- unionErrors,
2313
- });
2314
- return parseUtil_js_1.INVALID;
2315
- }
2316
- if (ctx.common.async) {
2317
- return Promise.all(options.map(async (option) => {
2318
- const childCtx = {
2319
- ...ctx,
2320
- common: {
2321
- ...ctx.common,
2322
- issues: [],
2323
- },
2324
- parent: null,
2325
- };
2326
- return {
2327
- result: await option._parseAsync({
2328
- data: ctx.data,
2329
- path: ctx.path,
2330
- parent: childCtx,
2331
- }),
2332
- ctx: childCtx,
2333
- };
2334
- })).then(handleResults);
2335
- }
2336
- else {
2337
- let dirty = undefined;
2338
- const issues = [];
2339
- for (const option of options) {
2340
- const childCtx = {
2341
- ...ctx,
2342
- common: {
2343
- ...ctx.common,
2344
- issues: [],
2345
- },
2346
- parent: null,
2347
- };
2348
- const result = option._parseSync({
2349
- data: ctx.data,
2350
- path: ctx.path,
2351
- parent: childCtx,
2352
- });
2353
- if (result.status === "valid") {
2354
- return result;
2355
- }
2356
- else if (result.status === "dirty" && !dirty) {
2357
- dirty = { result, ctx: childCtx };
2358
- }
2359
- if (childCtx.common.issues.length) {
2360
- issues.push(childCtx.common.issues);
2361
- }
2362
- }
2363
- if (dirty) {
2364
- ctx.common.issues.push(...dirty.ctx.common.issues);
2365
- return dirty.result;
2366
- }
2367
- const unionErrors = issues.map((issues) => new ZodError_js_1.ZodError(issues));
2368
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2369
- code: ZodError_js_1.ZodIssueCode.invalid_union,
2370
- unionErrors,
2371
- });
2372
- return parseUtil_js_1.INVALID;
2373
- }
2374
- }
2375
- get options() {
2376
- return this._def.options;
2377
- }
2378
- }
2379
- exports.ZodUnion = ZodUnion;
2380
- ZodUnion.create = (types, params) => {
2381
- return new ZodUnion({
2382
- options: types,
2383
- typeName: ZodFirstPartyTypeKind.ZodUnion,
2384
- ...processCreateParams(params),
2385
- });
2386
- };
2387
- /////////////////////////////////////////////////////
2388
- /////////////////////////////////////////////////////
2389
- ////////// //////////
2390
- ////////// ZodDiscriminatedUnion //////////
2391
- ////////// //////////
2392
- /////////////////////////////////////////////////////
2393
- /////////////////////////////////////////////////////
2394
- const getDiscriminator = (type) => {
2395
- if (type instanceof ZodLazy) {
2396
- return getDiscriminator(type.schema);
2397
- }
2398
- else if (type instanceof ZodEffects) {
2399
- return getDiscriminator(type.innerType());
2400
- }
2401
- else if (type instanceof ZodLiteral) {
2402
- return [type.value];
2403
- }
2404
- else if (type instanceof ZodEnum) {
2405
- return type.options;
2406
- }
2407
- else if (type instanceof ZodNativeEnum) {
2408
- // eslint-disable-next-line ban/ban
2409
- return util_js_1.util.objectValues(type.enum);
2410
- }
2411
- else if (type instanceof ZodDefault) {
2412
- return getDiscriminator(type._def.innerType);
2413
- }
2414
- else if (type instanceof ZodUndefined) {
2415
- return [undefined];
2416
- }
2417
- else if (type instanceof ZodNull) {
2418
- return [null];
2419
- }
2420
- else if (type instanceof ZodOptional) {
2421
- return [undefined, ...getDiscriminator(type.unwrap())];
2422
- }
2423
- else if (type instanceof ZodNullable) {
2424
- return [null, ...getDiscriminator(type.unwrap())];
2425
- }
2426
- else if (type instanceof ZodBranded) {
2427
- return getDiscriminator(type.unwrap());
2428
- }
2429
- else if (type instanceof ZodReadonly) {
2430
- return getDiscriminator(type.unwrap());
2431
- }
2432
- else if (type instanceof ZodCatch) {
2433
- return getDiscriminator(type._def.innerType);
2434
- }
2435
- else {
2436
- return [];
2437
- }
2438
- };
2439
- class ZodDiscriminatedUnion extends ZodType {
2440
- _parse(input) {
2441
- const { ctx } = this._processInputParams(input);
2442
- if (ctx.parsedType !== util_js_1.ZodParsedType.object) {
2443
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2444
- code: ZodError_js_1.ZodIssueCode.invalid_type,
2445
- expected: util_js_1.ZodParsedType.object,
2446
- received: ctx.parsedType,
2447
- });
2448
- return parseUtil_js_1.INVALID;
2449
- }
2450
- const discriminator = this.discriminator;
2451
- const discriminatorValue = ctx.data[discriminator];
2452
- const option = this.optionsMap.get(discriminatorValue);
2453
- if (!option) {
2454
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2455
- code: ZodError_js_1.ZodIssueCode.invalid_union_discriminator,
2456
- options: Array.from(this.optionsMap.keys()),
2457
- path: [discriminator],
2458
- });
2459
- return parseUtil_js_1.INVALID;
2460
- }
2461
- if (ctx.common.async) {
2462
- return option._parseAsync({
2463
- data: ctx.data,
2464
- path: ctx.path,
2465
- parent: ctx,
2466
- });
2467
- }
2468
- else {
2469
- return option._parseSync({
2470
- data: ctx.data,
2471
- path: ctx.path,
2472
- parent: ctx,
2473
- });
2474
- }
2475
- }
2476
- get discriminator() {
2477
- return this._def.discriminator;
2478
- }
2479
- get options() {
2480
- return this._def.options;
2481
- }
2482
- get optionsMap() {
2483
- return this._def.optionsMap;
2484
- }
2485
- /**
2486
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2487
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2488
- * have a different value for each object in the union.
2489
- * @param discriminator the name of the discriminator property
2490
- * @param types an array of object schemas
2491
- * @param params
2492
- */
2493
- static create(discriminator, options, params) {
2494
- // Get all the valid discriminator values
2495
- const optionsMap = new Map();
2496
- // try {
2497
- for (const type of options) {
2498
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2499
- if (!discriminatorValues.length) {
2500
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2501
- }
2502
- for (const value of discriminatorValues) {
2503
- if (optionsMap.has(value)) {
2504
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2505
- }
2506
- optionsMap.set(value, type);
2507
- }
2508
- }
2509
- return new ZodDiscriminatedUnion({
2510
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2511
- discriminator,
2512
- options,
2513
- optionsMap,
2514
- ...processCreateParams(params),
2515
- });
2516
- }
2517
- }
2518
- exports.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
2519
- function mergeValues(a, b) {
2520
- const aType = (0, util_js_1.getParsedType)(a);
2521
- const bType = (0, util_js_1.getParsedType)(b);
2522
- if (a === b) {
2523
- return { valid: true, data: a };
2524
- }
2525
- else if (aType === util_js_1.ZodParsedType.object && bType === util_js_1.ZodParsedType.object) {
2526
- const bKeys = util_js_1.util.objectKeys(b);
2527
- const sharedKeys = util_js_1.util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2528
- const newObj = { ...a, ...b };
2529
- for (const key of sharedKeys) {
2530
- const sharedValue = mergeValues(a[key], b[key]);
2531
- if (!sharedValue.valid) {
2532
- return { valid: false };
2533
- }
2534
- newObj[key] = sharedValue.data;
2535
- }
2536
- return { valid: true, data: newObj };
2537
- }
2538
- else if (aType === util_js_1.ZodParsedType.array && bType === util_js_1.ZodParsedType.array) {
2539
- if (a.length !== b.length) {
2540
- return { valid: false };
2541
- }
2542
- const newArray = [];
2543
- for (let index = 0; index < a.length; index++) {
2544
- const itemA = a[index];
2545
- const itemB = b[index];
2546
- const sharedValue = mergeValues(itemA, itemB);
2547
- if (!sharedValue.valid) {
2548
- return { valid: false };
2549
- }
2550
- newArray.push(sharedValue.data);
2551
- }
2552
- return { valid: true, data: newArray };
2553
- }
2554
- else if (aType === util_js_1.ZodParsedType.date && bType === util_js_1.ZodParsedType.date && +a === +b) {
2555
- return { valid: true, data: a };
2556
- }
2557
- else {
2558
- return { valid: false };
2559
- }
2560
- }
2561
- class ZodIntersection extends ZodType {
2562
- _parse(input) {
2563
- const { status, ctx } = this._processInputParams(input);
2564
- const handleParsed = (parsedLeft, parsedRight) => {
2565
- if ((0, parseUtil_js_1.isAborted)(parsedLeft) || (0, parseUtil_js_1.isAborted)(parsedRight)) {
2566
- return parseUtil_js_1.INVALID;
2567
- }
2568
- const merged = mergeValues(parsedLeft.value, parsedRight.value);
2569
- if (!merged.valid) {
2570
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2571
- code: ZodError_js_1.ZodIssueCode.invalid_intersection_types,
2572
- });
2573
- return parseUtil_js_1.INVALID;
2574
- }
2575
- if ((0, parseUtil_js_1.isDirty)(parsedLeft) || (0, parseUtil_js_1.isDirty)(parsedRight)) {
2576
- status.dirty();
2577
- }
2578
- return { status: status.value, value: merged.data };
2579
- };
2580
- if (ctx.common.async) {
2581
- return Promise.all([
2582
- this._def.left._parseAsync({
2583
- data: ctx.data,
2584
- path: ctx.path,
2585
- parent: ctx,
2586
- }),
2587
- this._def.right._parseAsync({
2588
- data: ctx.data,
2589
- path: ctx.path,
2590
- parent: ctx,
2591
- }),
2592
- ]).then(([left, right]) => handleParsed(left, right));
2593
- }
2594
- else {
2595
- return handleParsed(this._def.left._parseSync({
2596
- data: ctx.data,
2597
- path: ctx.path,
2598
- parent: ctx,
2599
- }), this._def.right._parseSync({
2600
- data: ctx.data,
2601
- path: ctx.path,
2602
- parent: ctx,
2603
- }));
2604
- }
2605
- }
2606
- }
2607
- exports.ZodIntersection = ZodIntersection;
2608
- ZodIntersection.create = (left, right, params) => {
2609
- return new ZodIntersection({
2610
- left: left,
2611
- right: right,
2612
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
2613
- ...processCreateParams(params),
2614
- });
2615
- };
2616
- // type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
2617
- class ZodTuple extends ZodType {
2618
- _parse(input) {
2619
- const { status, ctx } = this._processInputParams(input);
2620
- if (ctx.parsedType !== util_js_1.ZodParsedType.array) {
2621
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2622
- code: ZodError_js_1.ZodIssueCode.invalid_type,
2623
- expected: util_js_1.ZodParsedType.array,
2624
- received: ctx.parsedType,
2625
- });
2626
- return parseUtil_js_1.INVALID;
2627
- }
2628
- if (ctx.data.length < this._def.items.length) {
2629
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2630
- code: ZodError_js_1.ZodIssueCode.too_small,
2631
- minimum: this._def.items.length,
2632
- inclusive: true,
2633
- exact: false,
2634
- type: "array",
2635
- });
2636
- return parseUtil_js_1.INVALID;
2637
- }
2638
- const rest = this._def.rest;
2639
- if (!rest && ctx.data.length > this._def.items.length) {
2640
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2641
- code: ZodError_js_1.ZodIssueCode.too_big,
2642
- maximum: this._def.items.length,
2643
- inclusive: true,
2644
- exact: false,
2645
- type: "array",
2646
- });
2647
- status.dirty();
2648
- }
2649
- const items = [...ctx.data]
2650
- .map((item, itemIndex) => {
2651
- const schema = this._def.items[itemIndex] || this._def.rest;
2652
- if (!schema)
2653
- return null;
2654
- return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2655
- })
2656
- .filter((x) => !!x); // filter nulls
2657
- if (ctx.common.async) {
2658
- return Promise.all(items).then((results) => {
2659
- return parseUtil_js_1.ParseStatus.mergeArray(status, results);
2660
- });
2661
- }
2662
- else {
2663
- return parseUtil_js_1.ParseStatus.mergeArray(status, items);
2664
- }
2665
- }
2666
- get items() {
2667
- return this._def.items;
2668
- }
2669
- rest(rest) {
2670
- return new ZodTuple({
2671
- ...this._def,
2672
- rest,
2673
- });
2674
- }
2675
- }
2676
- exports.ZodTuple = ZodTuple;
2677
- ZodTuple.create = (schemas, params) => {
2678
- if (!Array.isArray(schemas)) {
2679
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2680
- }
2681
- return new ZodTuple({
2682
- items: schemas,
2683
- typeName: ZodFirstPartyTypeKind.ZodTuple,
2684
- rest: null,
2685
- ...processCreateParams(params),
2686
- });
2687
- };
2688
- class ZodRecord extends ZodType {
2689
- get keySchema() {
2690
- return this._def.keyType;
2691
- }
2692
- get valueSchema() {
2693
- return this._def.valueType;
2694
- }
2695
- _parse(input) {
2696
- const { status, ctx } = this._processInputParams(input);
2697
- if (ctx.parsedType !== util_js_1.ZodParsedType.object) {
2698
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2699
- code: ZodError_js_1.ZodIssueCode.invalid_type,
2700
- expected: util_js_1.ZodParsedType.object,
2701
- received: ctx.parsedType,
2702
- });
2703
- return parseUtil_js_1.INVALID;
2704
- }
2705
- const pairs = [];
2706
- const keyType = this._def.keyType;
2707
- const valueType = this._def.valueType;
2708
- for (const key in ctx.data) {
2709
- pairs.push({
2710
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2711
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2712
- alwaysSet: key in ctx.data,
2713
- });
2714
- }
2715
- if (ctx.common.async) {
2716
- return parseUtil_js_1.ParseStatus.mergeObjectAsync(status, pairs);
2717
- }
2718
- else {
2719
- return parseUtil_js_1.ParseStatus.mergeObjectSync(status, pairs);
2720
- }
2721
- }
2722
- get element() {
2723
- return this._def.valueType;
2724
- }
2725
- static create(first, second, third) {
2726
- if (second instanceof ZodType) {
2727
- return new ZodRecord({
2728
- keyType: first,
2729
- valueType: second,
2730
- typeName: ZodFirstPartyTypeKind.ZodRecord,
2731
- ...processCreateParams(third),
2732
- });
2733
- }
2734
- return new ZodRecord({
2735
- keyType: ZodString.create(),
2736
- valueType: first,
2737
- typeName: ZodFirstPartyTypeKind.ZodRecord,
2738
- ...processCreateParams(second),
2739
- });
2740
- }
2741
- }
2742
- exports.ZodRecord = ZodRecord;
2743
- class ZodMap extends ZodType {
2744
- get keySchema() {
2745
- return this._def.keyType;
2746
- }
2747
- get valueSchema() {
2748
- return this._def.valueType;
2749
- }
2750
- _parse(input) {
2751
- const { status, ctx } = this._processInputParams(input);
2752
- if (ctx.parsedType !== util_js_1.ZodParsedType.map) {
2753
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2754
- code: ZodError_js_1.ZodIssueCode.invalid_type,
2755
- expected: util_js_1.ZodParsedType.map,
2756
- received: ctx.parsedType,
2757
- });
2758
- return parseUtil_js_1.INVALID;
2759
- }
2760
- const keyType = this._def.keyType;
2761
- const valueType = this._def.valueType;
2762
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2763
- return {
2764
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2765
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])),
2766
- };
2767
- });
2768
- if (ctx.common.async) {
2769
- const finalMap = new Map();
2770
- return Promise.resolve().then(async () => {
2771
- for (const pair of pairs) {
2772
- const key = await pair.key;
2773
- const value = await pair.value;
2774
- if (key.status === "aborted" || value.status === "aborted") {
2775
- return parseUtil_js_1.INVALID;
2776
- }
2777
- if (key.status === "dirty" || value.status === "dirty") {
2778
- status.dirty();
2779
- }
2780
- finalMap.set(key.value, value.value);
2781
- }
2782
- return { status: status.value, value: finalMap };
2783
- });
2784
- }
2785
- else {
2786
- const finalMap = new Map();
2787
- for (const pair of pairs) {
2788
- const key = pair.key;
2789
- const value = pair.value;
2790
- if (key.status === "aborted" || value.status === "aborted") {
2791
- return parseUtil_js_1.INVALID;
2792
- }
2793
- if (key.status === "dirty" || value.status === "dirty") {
2794
- status.dirty();
2795
- }
2796
- finalMap.set(key.value, value.value);
2797
- }
2798
- return { status: status.value, value: finalMap };
2799
- }
2800
- }
2801
- }
2802
- exports.ZodMap = ZodMap;
2803
- ZodMap.create = (keyType, valueType, params) => {
2804
- return new ZodMap({
2805
- valueType,
2806
- keyType,
2807
- typeName: ZodFirstPartyTypeKind.ZodMap,
2808
- ...processCreateParams(params),
2809
- });
2810
- };
2811
- class ZodSet extends ZodType {
2812
- _parse(input) {
2813
- const { status, ctx } = this._processInputParams(input);
2814
- if (ctx.parsedType !== util_js_1.ZodParsedType.set) {
2815
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2816
- code: ZodError_js_1.ZodIssueCode.invalid_type,
2817
- expected: util_js_1.ZodParsedType.set,
2818
- received: ctx.parsedType,
2819
- });
2820
- return parseUtil_js_1.INVALID;
2821
- }
2822
- const def = this._def;
2823
- if (def.minSize !== null) {
2824
- if (ctx.data.size < def.minSize.value) {
2825
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2826
- code: ZodError_js_1.ZodIssueCode.too_small,
2827
- minimum: def.minSize.value,
2828
- type: "set",
2829
- inclusive: true,
2830
- exact: false,
2831
- message: def.minSize.message,
2832
- });
2833
- status.dirty();
2834
- }
2835
- }
2836
- if (def.maxSize !== null) {
2837
- if (ctx.data.size > def.maxSize.value) {
2838
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2839
- code: ZodError_js_1.ZodIssueCode.too_big,
2840
- maximum: def.maxSize.value,
2841
- type: "set",
2842
- inclusive: true,
2843
- exact: false,
2844
- message: def.maxSize.message,
2845
- });
2846
- status.dirty();
2847
- }
2848
- }
2849
- const valueType = this._def.valueType;
2850
- function finalizeSet(elements) {
2851
- const parsedSet = new Set();
2852
- for (const element of elements) {
2853
- if (element.status === "aborted")
2854
- return parseUtil_js_1.INVALID;
2855
- if (element.status === "dirty")
2856
- status.dirty();
2857
- parsedSet.add(element.value);
2858
- }
2859
- return { status: status.value, value: parsedSet };
2860
- }
2861
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2862
- if (ctx.common.async) {
2863
- return Promise.all(elements).then((elements) => finalizeSet(elements));
2864
- }
2865
- else {
2866
- return finalizeSet(elements);
2867
- }
2868
- }
2869
- min(minSize, message) {
2870
- return new ZodSet({
2871
- ...this._def,
2872
- minSize: { value: minSize, message: errorUtil_js_1.errorUtil.toString(message) },
2873
- });
2874
- }
2875
- max(maxSize, message) {
2876
- return new ZodSet({
2877
- ...this._def,
2878
- maxSize: { value: maxSize, message: errorUtil_js_1.errorUtil.toString(message) },
2879
- });
2880
- }
2881
- size(size, message) {
2882
- return this.min(size, message).max(size, message);
2883
- }
2884
- nonempty(message) {
2885
- return this.min(1, message);
2886
- }
2887
- }
2888
- exports.ZodSet = ZodSet;
2889
- ZodSet.create = (valueType, params) => {
2890
- return new ZodSet({
2891
- valueType,
2892
- minSize: null,
2893
- maxSize: null,
2894
- typeName: ZodFirstPartyTypeKind.ZodSet,
2895
- ...processCreateParams(params),
2896
- });
2897
- };
2898
- class ZodFunction extends ZodType {
2899
- constructor() {
2900
- super(...arguments);
2901
- this.validate = this.implement;
2902
- }
2903
- _parse(input) {
2904
- const { ctx } = this._processInputParams(input);
2905
- if (ctx.parsedType !== util_js_1.ZodParsedType.function) {
2906
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
2907
- code: ZodError_js_1.ZodIssueCode.invalid_type,
2908
- expected: util_js_1.ZodParsedType.function,
2909
- received: ctx.parsedType,
2910
- });
2911
- return parseUtil_js_1.INVALID;
2912
- }
2913
- function makeArgsIssue(args, error) {
2914
- return (0, parseUtil_js_1.makeIssue)({
2915
- data: args,
2916
- path: ctx.path,
2917
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_js_1.getErrorMap)(), errors_js_1.defaultErrorMap].filter((x) => !!x),
2918
- issueData: {
2919
- code: ZodError_js_1.ZodIssueCode.invalid_arguments,
2920
- argumentsError: error,
2921
- },
2922
- });
2923
- }
2924
- function makeReturnsIssue(returns, error) {
2925
- return (0, parseUtil_js_1.makeIssue)({
2926
- data: returns,
2927
- path: ctx.path,
2928
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_js_1.getErrorMap)(), errors_js_1.defaultErrorMap].filter((x) => !!x),
2929
- issueData: {
2930
- code: ZodError_js_1.ZodIssueCode.invalid_return_type,
2931
- returnTypeError: error,
2932
- },
2933
- });
2934
- }
2935
- const params = { errorMap: ctx.common.contextualErrorMap };
2936
- const fn = ctx.data;
2937
- if (this._def.returns instanceof ZodPromise) {
2938
- // Would love a way to avoid disabling this rule, but we need
2939
- // an alias (using an arrow function was what caused 2651).
2940
- // eslint-disable-next-line @typescript-eslint/no-this-alias
2941
- const me = this;
2942
- return (0, parseUtil_js_1.OK)(async function (...args) {
2943
- const error = new ZodError_js_1.ZodError([]);
2944
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2945
- error.addIssue(makeArgsIssue(args, e));
2946
- throw error;
2947
- });
2948
- const result = await Reflect.apply(fn, this, parsedArgs);
2949
- const parsedReturns = await me._def.returns._def.type
2950
- .parseAsync(result, params)
2951
- .catch((e) => {
2952
- error.addIssue(makeReturnsIssue(result, e));
2953
- throw error;
2954
- });
2955
- return parsedReturns;
2956
- });
2957
- }
2958
- else {
2959
- // Would love a way to avoid disabling this rule, but we need
2960
- // an alias (using an arrow function was what caused 2651).
2961
- // eslint-disable-next-line @typescript-eslint/no-this-alias
2962
- const me = this;
2963
- return (0, parseUtil_js_1.OK)(function (...args) {
2964
- const parsedArgs = me._def.args.safeParse(args, params);
2965
- if (!parsedArgs.success) {
2966
- throw new ZodError_js_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
2967
- }
2968
- const result = Reflect.apply(fn, this, parsedArgs.data);
2969
- const parsedReturns = me._def.returns.safeParse(result, params);
2970
- if (!parsedReturns.success) {
2971
- throw new ZodError_js_1.ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2972
- }
2973
- return parsedReturns.data;
2974
- });
2975
- }
2976
- }
2977
- parameters() {
2978
- return this._def.args;
2979
- }
2980
- returnType() {
2981
- return this._def.returns;
2982
- }
2983
- args(...items) {
2984
- return new ZodFunction({
2985
- ...this._def,
2986
- args: ZodTuple.create(items).rest(ZodUnknown.create()),
2987
- });
2988
- }
2989
- returns(returnType) {
2990
- return new ZodFunction({
2991
- ...this._def,
2992
- returns: returnType,
2993
- });
2994
- }
2995
- implement(func) {
2996
- const validatedFunc = this.parse(func);
2997
- return validatedFunc;
2998
- }
2999
- strictImplement(func) {
3000
- const validatedFunc = this.parse(func);
3001
- return validatedFunc;
3002
- }
3003
- static create(args, returns, params) {
3004
- return new ZodFunction({
3005
- args: (args ? args : ZodTuple.create([]).rest(ZodUnknown.create())),
3006
- returns: returns || ZodUnknown.create(),
3007
- typeName: ZodFirstPartyTypeKind.ZodFunction,
3008
- ...processCreateParams(params),
3009
- });
3010
- }
3011
- }
3012
- exports.ZodFunction = ZodFunction;
3013
- class ZodLazy extends ZodType {
3014
- get schema() {
3015
- return this._def.getter();
3016
- }
3017
- _parse(input) {
3018
- const { ctx } = this._processInputParams(input);
3019
- const lazySchema = this._def.getter();
3020
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3021
- }
3022
- }
3023
- exports.ZodLazy = ZodLazy;
3024
- ZodLazy.create = (getter, params) => {
3025
- return new ZodLazy({
3026
- getter: getter,
3027
- typeName: ZodFirstPartyTypeKind.ZodLazy,
3028
- ...processCreateParams(params),
3029
- });
3030
- };
3031
- class ZodLiteral extends ZodType {
3032
- _parse(input) {
3033
- if (input.data !== this._def.value) {
3034
- const ctx = this._getOrReturnCtx(input);
3035
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3036
- received: ctx.data,
3037
- code: ZodError_js_1.ZodIssueCode.invalid_literal,
3038
- expected: this._def.value,
3039
- });
3040
- return parseUtil_js_1.INVALID;
3041
- }
3042
- return { status: "valid", value: input.data };
3043
- }
3044
- get value() {
3045
- return this._def.value;
3046
- }
3047
- }
3048
- exports.ZodLiteral = ZodLiteral;
3049
- ZodLiteral.create = (value, params) => {
3050
- return new ZodLiteral({
3051
- value: value,
3052
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
3053
- ...processCreateParams(params),
3054
- });
3055
- };
3056
- function createZodEnum(values, params) {
3057
- return new ZodEnum({
3058
- values,
3059
- typeName: ZodFirstPartyTypeKind.ZodEnum,
3060
- ...processCreateParams(params),
3061
- });
3062
- }
3063
- class ZodEnum extends ZodType {
3064
- _parse(input) {
3065
- if (typeof input.data !== "string") {
3066
- const ctx = this._getOrReturnCtx(input);
3067
- const expectedValues = this._def.values;
3068
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3069
- expected: util_js_1.util.joinValues(expectedValues),
3070
- received: ctx.parsedType,
3071
- code: ZodError_js_1.ZodIssueCode.invalid_type,
3072
- });
3073
- return parseUtil_js_1.INVALID;
3074
- }
3075
- if (!this._cache) {
3076
- this._cache = new Set(this._def.values);
3077
- }
3078
- if (!this._cache.has(input.data)) {
3079
- const ctx = this._getOrReturnCtx(input);
3080
- const expectedValues = this._def.values;
3081
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3082
- received: ctx.data,
3083
- code: ZodError_js_1.ZodIssueCode.invalid_enum_value,
3084
- options: expectedValues,
3085
- });
3086
- return parseUtil_js_1.INVALID;
3087
- }
3088
- return (0, parseUtil_js_1.OK)(input.data);
3089
- }
3090
- get options() {
3091
- return this._def.values;
3092
- }
3093
- get enum() {
3094
- const enumValues = {};
3095
- for (const val of this._def.values) {
3096
- enumValues[val] = val;
3097
- }
3098
- return enumValues;
3099
- }
3100
- get Values() {
3101
- const enumValues = {};
3102
- for (const val of this._def.values) {
3103
- enumValues[val] = val;
3104
- }
3105
- return enumValues;
3106
- }
3107
- get Enum() {
3108
- const enumValues = {};
3109
- for (const val of this._def.values) {
3110
- enumValues[val] = val;
3111
- }
3112
- return enumValues;
3113
- }
3114
- extract(values, newDef = this._def) {
3115
- return ZodEnum.create(values, {
3116
- ...this._def,
3117
- ...newDef,
3118
- });
3119
- }
3120
- exclude(values, newDef = this._def) {
3121
- return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3122
- ...this._def,
3123
- ...newDef,
3124
- });
3125
- }
3126
- }
3127
- exports.ZodEnum = ZodEnum;
3128
- ZodEnum.create = createZodEnum;
3129
- class ZodNativeEnum extends ZodType {
3130
- _parse(input) {
3131
- const nativeEnumValues = util_js_1.util.getValidEnumValues(this._def.values);
3132
- const ctx = this._getOrReturnCtx(input);
3133
- if (ctx.parsedType !== util_js_1.ZodParsedType.string && ctx.parsedType !== util_js_1.ZodParsedType.number) {
3134
- const expectedValues = util_js_1.util.objectValues(nativeEnumValues);
3135
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3136
- expected: util_js_1.util.joinValues(expectedValues),
3137
- received: ctx.parsedType,
3138
- code: ZodError_js_1.ZodIssueCode.invalid_type,
3139
- });
3140
- return parseUtil_js_1.INVALID;
3141
- }
3142
- if (!this._cache) {
3143
- this._cache = new Set(util_js_1.util.getValidEnumValues(this._def.values));
3144
- }
3145
- if (!this._cache.has(input.data)) {
3146
- const expectedValues = util_js_1.util.objectValues(nativeEnumValues);
3147
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3148
- received: ctx.data,
3149
- code: ZodError_js_1.ZodIssueCode.invalid_enum_value,
3150
- options: expectedValues,
3151
- });
3152
- return parseUtil_js_1.INVALID;
3153
- }
3154
- return (0, parseUtil_js_1.OK)(input.data);
3155
- }
3156
- get enum() {
3157
- return this._def.values;
3158
- }
3159
- }
3160
- exports.ZodNativeEnum = ZodNativeEnum;
3161
- ZodNativeEnum.create = (values, params) => {
3162
- return new ZodNativeEnum({
3163
- values: values,
3164
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3165
- ...processCreateParams(params),
3166
- });
3167
- };
3168
- class ZodPromise extends ZodType {
3169
- unwrap() {
3170
- return this._def.type;
3171
- }
3172
- _parse(input) {
3173
- const { ctx } = this._processInputParams(input);
3174
- if (ctx.parsedType !== util_js_1.ZodParsedType.promise && ctx.common.async === false) {
3175
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3176
- code: ZodError_js_1.ZodIssueCode.invalid_type,
3177
- expected: util_js_1.ZodParsedType.promise,
3178
- received: ctx.parsedType,
3179
- });
3180
- return parseUtil_js_1.INVALID;
3181
- }
3182
- const promisified = ctx.parsedType === util_js_1.ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3183
- return (0, parseUtil_js_1.OK)(promisified.then((data) => {
3184
- return this._def.type.parseAsync(data, {
3185
- path: ctx.path,
3186
- errorMap: ctx.common.contextualErrorMap,
3187
- });
3188
- }));
3189
- }
3190
- }
3191
- exports.ZodPromise = ZodPromise;
3192
- ZodPromise.create = (schema, params) => {
3193
- return new ZodPromise({
3194
- type: schema,
3195
- typeName: ZodFirstPartyTypeKind.ZodPromise,
3196
- ...processCreateParams(params),
3197
- });
3198
- };
3199
- class ZodEffects extends ZodType {
3200
- innerType() {
3201
- return this._def.schema;
3202
- }
3203
- sourceType() {
3204
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
3205
- ? this._def.schema.sourceType()
3206
- : this._def.schema;
3207
- }
3208
- _parse(input) {
3209
- const { status, ctx } = this._processInputParams(input);
3210
- const effect = this._def.effect || null;
3211
- const checkCtx = {
3212
- addIssue: (arg) => {
3213
- (0, parseUtil_js_1.addIssueToContext)(ctx, arg);
3214
- if (arg.fatal) {
3215
- status.abort();
3216
- }
3217
- else {
3218
- status.dirty();
3219
- }
3220
- },
3221
- get path() {
3222
- return ctx.path;
3223
- },
3224
- };
3225
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3226
- if (effect.type === "preprocess") {
3227
- const processed = effect.transform(ctx.data, checkCtx);
3228
- if (ctx.common.async) {
3229
- return Promise.resolve(processed).then(async (processed) => {
3230
- if (status.value === "aborted")
3231
- return parseUtil_js_1.INVALID;
3232
- const result = await this._def.schema._parseAsync({
3233
- data: processed,
3234
- path: ctx.path,
3235
- parent: ctx,
3236
- });
3237
- if (result.status === "aborted")
3238
- return parseUtil_js_1.INVALID;
3239
- if (result.status === "dirty")
3240
- return (0, parseUtil_js_1.DIRTY)(result.value);
3241
- if (status.value === "dirty")
3242
- return (0, parseUtil_js_1.DIRTY)(result.value);
3243
- return result;
3244
- });
3245
- }
3246
- else {
3247
- if (status.value === "aborted")
3248
- return parseUtil_js_1.INVALID;
3249
- const result = this._def.schema._parseSync({
3250
- data: processed,
3251
- path: ctx.path,
3252
- parent: ctx,
3253
- });
3254
- if (result.status === "aborted")
3255
- return parseUtil_js_1.INVALID;
3256
- if (result.status === "dirty")
3257
- return (0, parseUtil_js_1.DIRTY)(result.value);
3258
- if (status.value === "dirty")
3259
- return (0, parseUtil_js_1.DIRTY)(result.value);
3260
- return result;
3261
- }
3262
- }
3263
- if (effect.type === "refinement") {
3264
- const executeRefinement = (acc) => {
3265
- const result = effect.refinement(acc, checkCtx);
3266
- if (ctx.common.async) {
3267
- return Promise.resolve(result);
3268
- }
3269
- if (result instanceof Promise) {
3270
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3271
- }
3272
- return acc;
3273
- };
3274
- if (ctx.common.async === false) {
3275
- const inner = this._def.schema._parseSync({
3276
- data: ctx.data,
3277
- path: ctx.path,
3278
- parent: ctx,
3279
- });
3280
- if (inner.status === "aborted")
3281
- return parseUtil_js_1.INVALID;
3282
- if (inner.status === "dirty")
3283
- status.dirty();
3284
- // return value is ignored
3285
- executeRefinement(inner.value);
3286
- return { status: status.value, value: inner.value };
3287
- }
3288
- else {
3289
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3290
- if (inner.status === "aborted")
3291
- return parseUtil_js_1.INVALID;
3292
- if (inner.status === "dirty")
3293
- status.dirty();
3294
- return executeRefinement(inner.value).then(() => {
3295
- return { status: status.value, value: inner.value };
3296
- });
3297
- });
3298
- }
3299
- }
3300
- if (effect.type === "transform") {
3301
- if (ctx.common.async === false) {
3302
- const base = this._def.schema._parseSync({
3303
- data: ctx.data,
3304
- path: ctx.path,
3305
- parent: ctx,
3306
- });
3307
- if (!(0, parseUtil_js_1.isValid)(base))
3308
- return parseUtil_js_1.INVALID;
3309
- const result = effect.transform(base.value, checkCtx);
3310
- if (result instanceof Promise) {
3311
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3312
- }
3313
- return { status: status.value, value: result };
3314
- }
3315
- else {
3316
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3317
- if (!(0, parseUtil_js_1.isValid)(base))
3318
- return parseUtil_js_1.INVALID;
3319
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3320
- status: status.value,
3321
- value: result,
3322
- }));
3323
- });
3324
- }
3325
- }
3326
- util_js_1.util.assertNever(effect);
3327
- }
3328
- }
3329
- exports.ZodEffects = ZodEffects;
3330
- exports.ZodTransformer = ZodEffects;
3331
- ZodEffects.create = (schema, effect, params) => {
3332
- return new ZodEffects({
3333
- schema,
3334
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3335
- effect,
3336
- ...processCreateParams(params),
3337
- });
3338
- };
3339
- ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3340
- return new ZodEffects({
3341
- schema,
3342
- effect: { type: "preprocess", transform: preprocess },
3343
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3344
- ...processCreateParams(params),
3345
- });
3346
- };
3347
- class ZodOptional extends ZodType {
3348
- _parse(input) {
3349
- const parsedType = this._getType(input);
3350
- if (parsedType === util_js_1.ZodParsedType.undefined) {
3351
- return (0, parseUtil_js_1.OK)(undefined);
3352
- }
3353
- return this._def.innerType._parse(input);
3354
- }
3355
- unwrap() {
3356
- return this._def.innerType;
3357
- }
3358
- }
3359
- exports.ZodOptional = ZodOptional;
3360
- ZodOptional.create = (type, params) => {
3361
- return new ZodOptional({
3362
- innerType: type,
3363
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3364
- ...processCreateParams(params),
3365
- });
3366
- };
3367
- class ZodNullable extends ZodType {
3368
- _parse(input) {
3369
- const parsedType = this._getType(input);
3370
- if (parsedType === util_js_1.ZodParsedType.null) {
3371
- return (0, parseUtil_js_1.OK)(null);
3372
- }
3373
- return this._def.innerType._parse(input);
3374
- }
3375
- unwrap() {
3376
- return this._def.innerType;
3377
- }
3378
- }
3379
- exports.ZodNullable = ZodNullable;
3380
- ZodNullable.create = (type, params) => {
3381
- return new ZodNullable({
3382
- innerType: type,
3383
- typeName: ZodFirstPartyTypeKind.ZodNullable,
3384
- ...processCreateParams(params),
3385
- });
3386
- };
3387
- class ZodDefault extends ZodType {
3388
- _parse(input) {
3389
- const { ctx } = this._processInputParams(input);
3390
- let data = ctx.data;
3391
- if (ctx.parsedType === util_js_1.ZodParsedType.undefined) {
3392
- data = this._def.defaultValue();
3393
- }
3394
- return this._def.innerType._parse({
3395
- data,
3396
- path: ctx.path,
3397
- parent: ctx,
3398
- });
3399
- }
3400
- removeDefault() {
3401
- return this._def.innerType;
3402
- }
3403
- }
3404
- exports.ZodDefault = ZodDefault;
3405
- ZodDefault.create = (type, params) => {
3406
- return new ZodDefault({
3407
- innerType: type,
3408
- typeName: ZodFirstPartyTypeKind.ZodDefault,
3409
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3410
- ...processCreateParams(params),
3411
- });
3412
- };
3413
- class ZodCatch extends ZodType {
3414
- _parse(input) {
3415
- const { ctx } = this._processInputParams(input);
3416
- // newCtx is used to not collect issues from inner types in ctx
3417
- const newCtx = {
3418
- ...ctx,
3419
- common: {
3420
- ...ctx.common,
3421
- issues: [],
3422
- },
3423
- };
3424
- const result = this._def.innerType._parse({
3425
- data: newCtx.data,
3426
- path: newCtx.path,
3427
- parent: {
3428
- ...newCtx,
3429
- },
3430
- });
3431
- if ((0, parseUtil_js_1.isAsync)(result)) {
3432
- return result.then((result) => {
3433
- return {
3434
- status: "valid",
3435
- value: result.status === "valid"
3436
- ? result.value
3437
- : this._def.catchValue({
3438
- get error() {
3439
- return new ZodError_js_1.ZodError(newCtx.common.issues);
3440
- },
3441
- input: newCtx.data,
3442
- }),
3443
- };
3444
- });
3445
- }
3446
- else {
3447
- return {
3448
- status: "valid",
3449
- value: result.status === "valid"
3450
- ? result.value
3451
- : this._def.catchValue({
3452
- get error() {
3453
- return new ZodError_js_1.ZodError(newCtx.common.issues);
3454
- },
3455
- input: newCtx.data,
3456
- }),
3457
- };
3458
- }
3459
- }
3460
- removeCatch() {
3461
- return this._def.innerType;
3462
- }
3463
- }
3464
- exports.ZodCatch = ZodCatch;
3465
- ZodCatch.create = (type, params) => {
3466
- return new ZodCatch({
3467
- innerType: type,
3468
- typeName: ZodFirstPartyTypeKind.ZodCatch,
3469
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3470
- ...processCreateParams(params),
3471
- });
3472
- };
3473
- class ZodNaN extends ZodType {
3474
- _parse(input) {
3475
- const parsedType = this._getType(input);
3476
- if (parsedType !== util_js_1.ZodParsedType.nan) {
3477
- const ctx = this._getOrReturnCtx(input);
3478
- (0, parseUtil_js_1.addIssueToContext)(ctx, {
3479
- code: ZodError_js_1.ZodIssueCode.invalid_type,
3480
- expected: util_js_1.ZodParsedType.nan,
3481
- received: ctx.parsedType,
3482
- });
3483
- return parseUtil_js_1.INVALID;
3484
- }
3485
- return { status: "valid", value: input.data };
3486
- }
3487
- }
3488
- exports.ZodNaN = ZodNaN;
3489
- ZodNaN.create = (params) => {
3490
- return new ZodNaN({
3491
- typeName: ZodFirstPartyTypeKind.ZodNaN,
3492
- ...processCreateParams(params),
3493
- });
3494
- };
3495
- exports.BRAND = Symbol("zod_brand");
3496
- class ZodBranded extends ZodType {
3497
- _parse(input) {
3498
- const { ctx } = this._processInputParams(input);
3499
- const data = ctx.data;
3500
- return this._def.type._parse({
3501
- data,
3502
- path: ctx.path,
3503
- parent: ctx,
3504
- });
3505
- }
3506
- unwrap() {
3507
- return this._def.type;
3508
- }
3509
- }
3510
- exports.ZodBranded = ZodBranded;
3511
- class ZodPipeline extends ZodType {
3512
- _parse(input) {
3513
- const { status, ctx } = this._processInputParams(input);
3514
- if (ctx.common.async) {
3515
- const handleAsync = async () => {
3516
- const inResult = await this._def.in._parseAsync({
3517
- data: ctx.data,
3518
- path: ctx.path,
3519
- parent: ctx,
3520
- });
3521
- if (inResult.status === "aborted")
3522
- return parseUtil_js_1.INVALID;
3523
- if (inResult.status === "dirty") {
3524
- status.dirty();
3525
- return (0, parseUtil_js_1.DIRTY)(inResult.value);
3526
- }
3527
- else {
3528
- return this._def.out._parseAsync({
3529
- data: inResult.value,
3530
- path: ctx.path,
3531
- parent: ctx,
3532
- });
3533
- }
3534
- };
3535
- return handleAsync();
3536
- }
3537
- else {
3538
- const inResult = this._def.in._parseSync({
3539
- data: ctx.data,
3540
- path: ctx.path,
3541
- parent: ctx,
3542
- });
3543
- if (inResult.status === "aborted")
3544
- return parseUtil_js_1.INVALID;
3545
- if (inResult.status === "dirty") {
3546
- status.dirty();
3547
- return {
3548
- status: "dirty",
3549
- value: inResult.value,
3550
- };
3551
- }
3552
- else {
3553
- return this._def.out._parseSync({
3554
- data: inResult.value,
3555
- path: ctx.path,
3556
- parent: ctx,
3557
- });
3558
- }
3559
- }
3560
- }
3561
- static create(a, b) {
3562
- return new ZodPipeline({
3563
- in: a,
3564
- out: b,
3565
- typeName: ZodFirstPartyTypeKind.ZodPipeline,
3566
- });
3567
- }
3568
- }
3569
- exports.ZodPipeline = ZodPipeline;
3570
- class ZodReadonly extends ZodType {
3571
- _parse(input) {
3572
- const result = this._def.innerType._parse(input);
3573
- const freeze = (data) => {
3574
- if ((0, parseUtil_js_1.isValid)(data)) {
3575
- data.value = Object.freeze(data.value);
3576
- }
3577
- return data;
3578
- };
3579
- return (0, parseUtil_js_1.isAsync)(result) ? result.then((data) => freeze(data)) : freeze(result);
3580
- }
3581
- unwrap() {
3582
- return this._def.innerType;
3583
- }
3584
- }
3585
- exports.ZodReadonly = ZodReadonly;
3586
- ZodReadonly.create = (type, params) => {
3587
- return new ZodReadonly({
3588
- innerType: type,
3589
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
3590
- ...processCreateParams(params),
3591
- });
3592
- };
3593
- ////////////////////////////////////////
3594
- ////////////////////////////////////////
3595
- ////////// //////////
3596
- ////////// z.custom //////////
3597
- ////////// //////////
3598
- ////////////////////////////////////////
3599
- ////////////////////////////////////////
3600
- function cleanParams(params, data) {
3601
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3602
- const p2 = typeof p === "string" ? { message: p } : p;
3603
- return p2;
3604
- }
3605
- function custom(check, _params = {},
3606
- /**
3607
- * @deprecated
3608
- *
3609
- * Pass `fatal` into the params object instead:
3610
- *
3611
- * ```ts
3612
- * z.string().custom((val) => val.length > 5, { fatal: false })
3613
- * ```
3614
- *
3615
- */
3616
- fatal) {
3617
- if (check)
3618
- return ZodAny.create().superRefine((data, ctx) => {
3619
- const r = check(data);
3620
- if (r instanceof Promise) {
3621
- return r.then((r) => {
3622
- if (!r) {
3623
- const params = cleanParams(_params, data);
3624
- const _fatal = params.fatal ?? fatal ?? true;
3625
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3626
- }
3627
- });
3628
- }
3629
- if (!r) {
3630
- const params = cleanParams(_params, data);
3631
- const _fatal = params.fatal ?? fatal ?? true;
3632
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3633
- }
3634
- return;
3635
- });
3636
- return ZodAny.create();
3637
- }
3638
- exports.late = {
3639
- object: ZodObject.lazycreate,
3640
- };
3641
- var ZodFirstPartyTypeKind;
3642
- (function (ZodFirstPartyTypeKind) {
3643
- ZodFirstPartyTypeKind["ZodString"] = "ZodString";
3644
- ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
3645
- ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
3646
- ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
3647
- ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
3648
- ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3649
- ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
3650
- ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
3651
- ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
3652
- ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
3653
- ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
3654
- ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
3655
- ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
3656
- ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
3657
- ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
3658
- ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
3659
- ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3660
- ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
3661
- ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
3662
- ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
3663
- ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
3664
- ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
3665
- ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
3666
- ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
3667
- ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
3668
- ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
3669
- ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
3670
- ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
3671
- ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
3672
- ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
3673
- ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3674
- ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
3675
- ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
3676
- ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3677
- ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
3678
- ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
3679
- })(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
3680
- // requires TS 4.4+
3681
- class Class {
3682
- constructor(..._) { }
3683
- }
3684
- const instanceOfType = (
3685
- // const instanceOfType = <T extends new (...args: any[]) => any>(
3686
- cls, params = {
3687
- message: `Input not instance of ${cls.name}`,
3688
- }) => custom((data) => data instanceof cls, params);
3689
- exports.instanceof = instanceOfType;
3690
- const stringType = ZodString.create;
3691
- exports.string = stringType;
3692
- const numberType = ZodNumber.create;
3693
- exports.number = numberType;
3694
- const nanType = ZodNaN.create;
3695
- exports.nan = nanType;
3696
- const bigIntType = ZodBigInt.create;
3697
- exports.bigint = bigIntType;
3698
- const booleanType = ZodBoolean.create;
3699
- exports.boolean = booleanType;
3700
- const dateType = ZodDate.create;
3701
- exports.date = dateType;
3702
- const symbolType = ZodSymbol.create;
3703
- exports.symbol = symbolType;
3704
- const undefinedType = ZodUndefined.create;
3705
- exports.undefined = undefinedType;
3706
- const nullType = ZodNull.create;
3707
- exports.null = nullType;
3708
- const anyType = ZodAny.create;
3709
- exports.any = anyType;
3710
- const unknownType = ZodUnknown.create;
3711
- exports.unknown = unknownType;
3712
- const neverType = ZodNever.create;
3713
- exports.never = neverType;
3714
- const voidType = ZodVoid.create;
3715
- exports.void = voidType;
3716
- const arrayType = ZodArray.create;
3717
- exports.array = arrayType;
3718
- const objectType = ZodObject.create;
3719
- exports.object = objectType;
3720
- const strictObjectType = ZodObject.strictCreate;
3721
- exports.strictObject = strictObjectType;
3722
- const unionType = ZodUnion.create;
3723
- exports.union = unionType;
3724
- const discriminatedUnionType = ZodDiscriminatedUnion.create;
3725
- exports.discriminatedUnion = discriminatedUnionType;
3726
- const intersectionType = ZodIntersection.create;
3727
- exports.intersection = intersectionType;
3728
- const tupleType = ZodTuple.create;
3729
- exports.tuple = tupleType;
3730
- const recordType = ZodRecord.create;
3731
- exports.record = recordType;
3732
- const mapType = ZodMap.create;
3733
- exports.map = mapType;
3734
- const setType = ZodSet.create;
3735
- exports.set = setType;
3736
- const functionType = ZodFunction.create;
3737
- exports.function = functionType;
3738
- const lazyType = ZodLazy.create;
3739
- exports.lazy = lazyType;
3740
- const literalType = ZodLiteral.create;
3741
- exports.literal = literalType;
3742
- const enumType = ZodEnum.create;
3743
- exports.enum = enumType;
3744
- const nativeEnumType = ZodNativeEnum.create;
3745
- exports.nativeEnum = nativeEnumType;
3746
- const promiseType = ZodPromise.create;
3747
- exports.promise = promiseType;
3748
- const effectsType = ZodEffects.create;
3749
- exports.effect = effectsType;
3750
- exports.transformer = effectsType;
3751
- const optionalType = ZodOptional.create;
3752
- exports.optional = optionalType;
3753
- const nullableType = ZodNullable.create;
3754
- exports.nullable = nullableType;
3755
- const preprocessType = ZodEffects.createWithPreprocess;
3756
- exports.preprocess = preprocessType;
3757
- const pipelineType = ZodPipeline.create;
3758
- exports.pipeline = pipelineType;
3759
- const ostring = () => stringType().optional();
3760
- exports.ostring = ostring;
3761
- const onumber = () => numberType().optional();
3762
- exports.onumber = onumber;
3763
- const oboolean = () => booleanType().optional();
3764
- exports.oboolean = oboolean;
3765
- exports.coerce = {
3766
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3767
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3768
- boolean: ((arg) => ZodBoolean.create({
3769
- ...arg,
3770
- coerce: true,
3771
- })),
3772
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3773
- date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
3774
- };
3775
- exports.NEVER = parseUtil_js_1.INVALID;