aws-runtime-bridge 1.9.134 → 1.9.137

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 (820) hide show
  1. package/dist/adapter/AcodeSdkAdapter.d.ts +8 -0
  2. package/dist/adapter/AcodeSdkAdapter.js +5 -5
  3. package/dist/config.d.ts +4 -0
  4. package/dist/config.js +2 -2
  5. package/dist/index.js +1 -1
  6. package/dist/routes/ai-sources.js +1 -1
  7. package/dist/routes/capabilities.d.ts +2 -0
  8. package/dist/routes/capabilities.js +2 -0
  9. package/dist/routes/instance.d.ts +0 -1
  10. package/dist/routes/instance.js +1 -1
  11. package/dist/routes/mcp-extra.d.ts +2 -0
  12. package/dist/routes/mcp-extra.js +3 -0
  13. package/dist/routes/mcp.d.ts +1 -0
  14. package/dist/routes/mcp.js +1 -1
  15. package/dist/routes/plugins.d.ts +2 -0
  16. package/dist/routes/plugins.js +2 -0
  17. package/dist/routes/skills.d.ts +1 -0
  18. package/dist/routes/skills.js +1 -1
  19. package/dist/routes/terminal.js +25 -25
  20. package/dist/services/agent-capability-sync.d.ts +7 -0
  21. package/dist/services/agent-capability-sync.js +2 -0
  22. package/{package/cc-switch-sdk/dist → dist}/services/ai-config-service.d.ts +3 -0
  23. package/dist/services/ai-config-service.js +4 -0
  24. package/dist/services/ai-source-apply.d.ts +1 -1
  25. package/dist/services/ai-source-apply.js +1 -1
  26. package/dist/services/capability-config.d.ts +21 -0
  27. package/dist/services/capability-config.js +3 -0
  28. package/dist/services/instance-ai-config-service.d.ts +1 -0
  29. package/dist/services/instance-ai-config-service.js +1 -1
  30. package/dist/services/instance-features.d.ts +21 -0
  31. package/dist/services/instance-features.js +1 -1
  32. package/dist/services/instance-init-service.d.ts +7 -4
  33. package/dist/services/instance-init-service.js +1 -1
  34. package/dist/services/instance-state.js +1 -1
  35. package/dist/services/legacy-path-migration.d.ts +2 -0
  36. package/dist/services/legacy-path-migration.js +1 -1
  37. package/dist/services/mcp-deploy.d.ts +49 -0
  38. package/dist/services/mcp-deploy.js +4 -0
  39. package/dist/services/plugin-event-buffer.d.ts +49 -0
  40. package/dist/services/plugin-event-buffer.js +2 -0
  41. package/dist/services/plugin-manager.d.ts +240 -0
  42. package/dist/services/plugin-manager.js +10 -0
  43. package/dist/services/plugin-package.d.ts +8 -0
  44. package/dist/services/plugin-package.js +2 -0
  45. package/dist/services/skill-manager.d.ts +41 -0
  46. package/dist/services/skill-manager.js +3 -0
  47. package/dist/types.d.ts +11 -61
  48. package/dist/utils/file-utils.d.ts +9 -6
  49. package/dist/utils/file-utils.js +2 -2
  50. package/dist/utils/mcp-utils.d.ts +1 -37
  51. package/dist/utils/mcp-utils.js +1 -1
  52. package/package/acode/dist/built-in-file-tools.js +2 -2
  53. package/package/acode/dist/commands/commandRegistry.d.ts +2 -0
  54. package/package/acode/dist/commands/commandRegistry.js +1 -1
  55. package/package/acode/dist/index.d.ts +2 -0
  56. package/package/acode/dist/index.js +1 -1
  57. package/package/acode/dist/plugin-tools.d.ts +14 -0
  58. package/package/acode/dist/plugin-tools.js +14 -0
  59. package/package/acode/dist/plugin-types.d.ts +109 -0
  60. package/package/acode/dist/runtime.d.ts +2 -0
  61. package/package/acode/dist/runtime.js +14 -14
  62. package/package/acode/dist/sub-agent-manager.js +1 -1
  63. package/package/acode/dist/types.d.ts +3 -0
  64. package/package/aws-client-agent-mcp/dist/agent-client.d.ts +9 -1
  65. package/package/aws-client-agent-mcp/dist/agent-client.js +1 -1
  66. package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +11 -0
  67. package/package/aws-client-agent-mcp/dist/mcp-server.js +21 -21
  68. package/package/aws-client-agent-mcp/dist/mcp-tools.js +2 -4
  69. package/package/aws-client-agent-mcp/dist/memory-tools.js +8 -10
  70. package/package/aws-client-agent-mcp/dist/types.d.ts +21 -0
  71. package/package.json +4 -10
  72. package/dist/adapters/cc-switch/common.d.ts +0 -41
  73. package/dist/adapters/cc-switch/common.js +0 -2
  74. package/dist/adapters/cc-switch/index.d.ts +0 -19
  75. package/dist/adapters/cc-switch/index.js +0 -2
  76. package/dist/adapters/cc-switch/mcp-acode.d.ts +0 -10
  77. package/dist/adapters/cc-switch/mcp-acode.js +0 -2
  78. package/dist/adapters/cc-switch/mcp-claude.d.ts +0 -10
  79. package/dist/adapters/cc-switch/mcp-claude.js +0 -2
  80. package/dist/adapters/cc-switch/mcp-claudecode.d.ts +0 -10
  81. package/dist/adapters/cc-switch/mcp-claudecode.js +0 -2
  82. package/dist/adapters/cc-switch/mcp-codex.d.ts +0 -10
  83. package/dist/adapters/cc-switch/mcp-codex.js +0 -11
  84. package/dist/adapters/cc-switch/mcp-opencode.d.ts +0 -14
  85. package/dist/adapters/cc-switch/mcp-opencode.js +0 -2
  86. package/dist/adapters/cc-switch/mcp-placeholder.d.ts +0 -9
  87. package/dist/adapters/cc-switch/mcp-placeholder.js +0 -2
  88. package/dist/adapters/cc-switch/skill-acode.d.ts +0 -5
  89. package/dist/adapters/cc-switch/skill-acode.js +0 -2
  90. package/dist/adapters/cc-switch/skill-claude.d.ts +0 -5
  91. package/dist/adapters/cc-switch/skill-claude.js +0 -2
  92. package/dist/adapters/cc-switch/skill-claudecode.d.ts +0 -5
  93. package/dist/adapters/cc-switch/skill-claudecode.js +0 -2
  94. package/dist/adapters/cc-switch/skill-codex.d.ts +0 -4
  95. package/dist/adapters/cc-switch/skill-codex.js +0 -2
  96. package/dist/adapters/cc-switch/skill-directory.d.ts +0 -9
  97. package/dist/adapters/cc-switch/skill-directory.js +0 -3
  98. package/dist/adapters/cc-switch/skill-opencode.d.ts +0 -5
  99. package/dist/adapters/cc-switch/skill-opencode.js +0 -2
  100. package/dist/adapters/cc-switch/skill-placeholder.d.ts +0 -9
  101. package/dist/adapters/cc-switch/skill-placeholder.js +0 -2
  102. package/dist/services/cc-switch-sdk.d.ts +0 -17
  103. package/dist/services/cc-switch-sdk.js +0 -2
  104. package/dist/services/instance-service.d.ts +0 -78
  105. package/dist/services/instance-service.js +0 -2
  106. package/node_modules/@cc-switch/sdk/README.md +0 -541
  107. package/node_modules/@cc-switch/sdk/dist/constants.d.ts +0 -8
  108. package/node_modules/@cc-switch/sdk/dist/constants.js +0 -2
  109. package/node_modules/@cc-switch/sdk/dist/errors.d.ts +0 -5
  110. package/node_modules/@cc-switch/sdk/dist/errors.js +0 -2
  111. package/node_modules/@cc-switch/sdk/dist/index.d.ts +0 -5
  112. package/node_modules/@cc-switch/sdk/dist/index.js +0 -2
  113. package/node_modules/@cc-switch/sdk/dist/schemas.d.ts +0 -7
  114. package/node_modules/@cc-switch/sdk/dist/schemas.js +0 -2
  115. package/node_modules/@cc-switch/sdk/dist/sdk.d.ts +0 -59
  116. package/node_modules/@cc-switch/sdk/dist/sdk.js +0 -2
  117. package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.d.ts +0 -81
  118. package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.js +0 -4
  119. package/node_modules/@cc-switch/sdk/dist/services/mcp-model.d.ts +0 -16
  120. package/node_modules/@cc-switch/sdk/dist/services/mcp-model.js +0 -2
  121. package/node_modules/@cc-switch/sdk/dist/services/mcp-service.d.ts +0 -17
  122. package/node_modules/@cc-switch/sdk/dist/services/mcp-service.js +0 -2
  123. package/node_modules/@cc-switch/sdk/dist/services/skill-model.d.ts +0 -16
  124. package/node_modules/@cc-switch/sdk/dist/services/skill-model.js +0 -2
  125. package/node_modules/@cc-switch/sdk/dist/services/skill-service.d.ts +0 -16
  126. package/node_modules/@cc-switch/sdk/dist/services/skill-service.js +0 -2
  127. package/node_modules/@cc-switch/sdk/dist/state.d.ts +0 -3
  128. package/node_modules/@cc-switch/sdk/dist/state.js +0 -2
  129. package/node_modules/@cc-switch/sdk/dist/types.d.ts +0 -78
  130. package/node_modules/@cc-switch/sdk/dist/utils/fs.d.ts +0 -10
  131. package/node_modules/@cc-switch/sdk/dist/utils/fs.js +0 -3
  132. package/node_modules/@cc-switch/sdk/dist/utils/id.d.ts +0 -3
  133. package/node_modules/@cc-switch/sdk/dist/utils/id.js +0 -2
  134. package/node_modules/@cc-switch/sdk/package.json +0 -31
  135. package/node_modules/zod/LICENSE +0 -21
  136. package/node_modules/zod/README.md +0 -208
  137. package/node_modules/zod/index.cjs +0 -33
  138. package/node_modules/zod/index.d.cts +0 -4
  139. package/node_modules/zod/index.d.ts +0 -4
  140. package/node_modules/zod/index.js +0 -4
  141. package/node_modules/zod/locales/index.cjs +0 -17
  142. package/node_modules/zod/locales/index.d.cts +0 -1
  143. package/node_modules/zod/locales/index.d.ts +0 -1
  144. package/node_modules/zod/locales/index.js +0 -1
  145. package/node_modules/zod/locales/package.json +0 -6
  146. package/node_modules/zod/mini/index.cjs +0 -17
  147. package/node_modules/zod/mini/index.d.cts +0 -1
  148. package/node_modules/zod/mini/index.d.ts +0 -1
  149. package/node_modules/zod/mini/index.js +0 -1
  150. package/node_modules/zod/mini/package.json +0 -6
  151. package/node_modules/zod/package.json +0 -135
  152. package/node_modules/zod/src/index.ts +0 -4
  153. package/node_modules/zod/src/locales/index.ts +0 -1
  154. package/node_modules/zod/src/mini/index.ts +0 -1
  155. package/node_modules/zod/src/v3/ZodError.ts +0 -330
  156. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  157. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  158. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  159. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  160. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  161. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  162. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  163. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  164. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  165. package/node_modules/zod/src/v3/errors.ts +0 -13
  166. package/node_modules/zod/src/v3/external.ts +0 -6
  167. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  168. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  169. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  170. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  171. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  172. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  173. package/node_modules/zod/src/v3/index.ts +0 -4
  174. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  175. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  176. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  177. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  178. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  179. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  180. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  181. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  182. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  183. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  184. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  185. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  186. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  187. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -56
  188. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  189. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  190. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  191. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  192. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  193. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  194. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  195. package/node_modules/zod/src/v3/tests/error.test.ts +0 -551
  196. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  197. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  198. package/node_modules/zod/src/v3/tests/function.test.ts +0 -257
  199. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  200. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  201. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
  202. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  203. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
  204. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  205. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  206. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  207. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  208. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -21
  209. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  210. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  211. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  212. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  213. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  214. package/node_modules/zod/src/v3/tests/object.test.ts +0 -434
  215. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  216. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  217. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  218. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  219. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  220. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  221. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  222. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  223. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  224. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
  225. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  226. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  227. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  228. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  229. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  230. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  231. package/node_modules/zod/src/v3/tests/string.test.ts +0 -916
  232. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  233. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  234. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  235. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  236. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  237. package/node_modules/zod/src/v3/types.ts +0 -5138
  238. package/node_modules/zod/src/v4/classic/checks.ts +0 -31
  239. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  240. package/node_modules/zod/src/v4/classic/compat.ts +0 -70
  241. package/node_modules/zod/src/v4/classic/errors.ts +0 -82
  242. package/node_modules/zod/src/v4/classic/external.ts +0 -50
  243. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  244. package/node_modules/zod/src/v4/classic/iso.ts +0 -90
  245. package/node_modules/zod/src/v4/classic/parse.ts +0 -82
  246. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2197
  247. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  248. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  249. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -210
  250. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  251. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  252. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  253. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
  254. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -63
  255. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -276
  256. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  257. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -573
  258. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -562
  259. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  260. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -352
  261. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  262. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -31
  263. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -302
  264. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -365
  265. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  266. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -661
  267. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
  268. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -595
  269. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
  270. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  271. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  272. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -308
  273. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  274. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -68
  275. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -844
  276. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -34
  277. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -171
  278. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -108
  279. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
  280. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -117
  281. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -196
  282. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  283. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  284. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  285. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  286. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -270
  287. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -609
  288. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -136
  289. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -340
  290. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -127
  291. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  292. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -74
  293. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -282
  294. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  295. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  296. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  297. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
  298. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -356
  299. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -582
  300. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -605
  301. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -204
  302. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -181
  303. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -57
  304. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  305. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1080
  306. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -106
  307. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -763
  308. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -2622
  309. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -361
  310. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -163
  311. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -181
  312. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  313. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  314. package/node_modules/zod/src/v4/core/api.ts +0 -1621
  315. package/node_modules/zod/src/v4/core/checks.ts +0 -1287
  316. package/node_modules/zod/src/v4/core/config.ts +0 -15
  317. package/node_modules/zod/src/v4/core/core.ts +0 -115
  318. package/node_modules/zod/src/v4/core/doc.ts +0 -44
  319. package/node_modules/zod/src/v4/core/errors.ts +0 -413
  320. package/node_modules/zod/src/v4/core/index.ts +0 -14
  321. package/node_modules/zod/src/v4/core/json-schema.ts +0 -147
  322. package/node_modules/zod/src/v4/core/parse.ts +0 -195
  323. package/node_modules/zod/src/v4/core/regexes.ts +0 -177
  324. package/node_modules/zod/src/v4/core/registries.ts +0 -97
  325. package/node_modules/zod/src/v4/core/schemas.ts +0 -4317
  326. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -64
  327. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -18
  328. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  329. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  330. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  331. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -181
  332. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  333. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  334. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -1044
  335. package/node_modules/zod/src/v4/core/util.ts +0 -910
  336. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  337. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  338. package/node_modules/zod/src/v4/index.ts +0 -4
  339. package/node_modules/zod/src/v4/locales/ar.ts +0 -125
  340. package/node_modules/zod/src/v4/locales/az.ts +0 -121
  341. package/node_modules/zod/src/v4/locales/be.ts +0 -184
  342. package/node_modules/zod/src/v4/locales/bg.ts +0 -136
  343. package/node_modules/zod/src/v4/locales/ca.ts +0 -127
  344. package/node_modules/zod/src/v4/locales/cs.ts +0 -142
  345. package/node_modules/zod/src/v4/locales/da.ts +0 -141
  346. package/node_modules/zod/src/v4/locales/de.ts +0 -124
  347. package/node_modules/zod/src/v4/locales/en.ts +0 -127
  348. package/node_modules/zod/src/v4/locales/eo.ts +0 -125
  349. package/node_modules/zod/src/v4/locales/es.ts +0 -159
  350. package/node_modules/zod/src/v4/locales/fa.ts +0 -134
  351. package/node_modules/zod/src/v4/locales/fi.ts +0 -131
  352. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -126
  353. package/node_modules/zod/src/v4/locales/fr.ts +0 -124
  354. package/node_modules/zod/src/v4/locales/he.ts +0 -125
  355. package/node_modules/zod/src/v4/locales/hu.ts +0 -126
  356. package/node_modules/zod/src/v4/locales/id.ts +0 -125
  357. package/node_modules/zod/src/v4/locales/index.ts +0 -47
  358. package/node_modules/zod/src/v4/locales/is.ts +0 -127
  359. package/node_modules/zod/src/v4/locales/it.ts +0 -125
  360. package/node_modules/zod/src/v4/locales/ja.ts +0 -122
  361. package/node_modules/zod/src/v4/locales/ka.ts +0 -138
  362. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  363. package/node_modules/zod/src/v4/locales/km.ts +0 -126
  364. package/node_modules/zod/src/v4/locales/ko.ts +0 -131
  365. package/node_modules/zod/src/v4/locales/lt.ts +0 -265
  366. package/node_modules/zod/src/v4/locales/mk.ts +0 -127
  367. package/node_modules/zod/src/v4/locales/ms.ts +0 -124
  368. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  369. package/node_modules/zod/src/v4/locales/no.ts +0 -124
  370. package/node_modules/zod/src/v4/locales/ota.ts +0 -125
  371. package/node_modules/zod/src/v4/locales/pl.ts +0 -126
  372. package/node_modules/zod/src/v4/locales/ps.ts +0 -133
  373. package/node_modules/zod/src/v4/locales/pt.ts +0 -123
  374. package/node_modules/zod/src/v4/locales/ru.ts +0 -184
  375. package/node_modules/zod/src/v4/locales/sl.ts +0 -126
  376. package/node_modules/zod/src/v4/locales/sv.ts +0 -127
  377. package/node_modules/zod/src/v4/locales/ta.ts +0 -125
  378. package/node_modules/zod/src/v4/locales/th.ts +0 -126
  379. package/node_modules/zod/src/v4/locales/tr.ts +0 -121
  380. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  381. package/node_modules/zod/src/v4/locales/uk.ts +0 -126
  382. package/node_modules/zod/src/v4/locales/ur.ts +0 -126
  383. package/node_modules/zod/src/v4/locales/vi.ts +0 -125
  384. package/node_modules/zod/src/v4/locales/yo.ts +0 -131
  385. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -123
  386. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -125
  387. package/node_modules/zod/src/v4/mini/checks.ts +0 -32
  388. package/node_modules/zod/src/v4/mini/coerce.ts +0 -22
  389. package/node_modules/zod/src/v4/mini/external.ts +0 -40
  390. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  391. package/node_modules/zod/src/v4/mini/iso.ts +0 -62
  392. package/node_modules/zod/src/v4/mini/parse.ts +0 -14
  393. package/node_modules/zod/src/v4/mini/schemas.ts +0 -1725
  394. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
  395. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -51
  396. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
  397. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -529
  398. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  399. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
  400. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -43
  401. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -899
  402. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
  403. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -200
  404. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  405. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -275
  406. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -315
  407. package/node_modules/zod/src/v4-mini/index.ts +0 -1
  408. package/node_modules/zod/v3/ZodError.cjs +0 -138
  409. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  410. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  411. package/node_modules/zod/v3/ZodError.js +0 -133
  412. package/node_modules/zod/v3/errors.cjs +0 -17
  413. package/node_modules/zod/v3/errors.d.cts +0 -5
  414. package/node_modules/zod/v3/errors.d.ts +0 -5
  415. package/node_modules/zod/v3/errors.js +0 -9
  416. package/node_modules/zod/v3/external.cjs +0 -22
  417. package/node_modules/zod/v3/external.d.cts +0 -6
  418. package/node_modules/zod/v3/external.d.ts +0 -6
  419. package/node_modules/zod/v3/external.js +0 -6
  420. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  421. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  422. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  423. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  424. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  425. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  426. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  427. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  428. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  429. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  430. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  431. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  432. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  433. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  434. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  435. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  436. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  437. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  438. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  439. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  440. package/node_modules/zod/v3/helpers/util.cjs +0 -137
  441. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  442. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  443. package/node_modules/zod/v3/helpers/util.js +0 -133
  444. package/node_modules/zod/v3/index.cjs +0 -33
  445. package/node_modules/zod/v3/index.d.cts +0 -4
  446. package/node_modules/zod/v3/index.d.ts +0 -4
  447. package/node_modules/zod/v3/index.js +0 -4
  448. package/node_modules/zod/v3/locales/en.cjs +0 -112
  449. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  450. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  451. package/node_modules/zod/v3/locales/en.js +0 -109
  452. package/node_modules/zod/v3/package.json +0 -6
  453. package/node_modules/zod/v3/standard-schema.cjs +0 -2
  454. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  455. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  456. package/node_modules/zod/v3/standard-schema.js +0 -1
  457. package/node_modules/zod/v3/types.cjs +0 -3777
  458. package/node_modules/zod/v3/types.d.cts +0 -1034
  459. package/node_modules/zod/v3/types.d.ts +0 -1034
  460. package/node_modules/zod/v3/types.js +0 -3695
  461. package/node_modules/zod/v4/classic/checks.cjs +0 -32
  462. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  463. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  464. package/node_modules/zod/v4/classic/checks.js +0 -1
  465. package/node_modules/zod/v4/classic/coerce.cjs +0 -47
  466. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  467. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  468. package/node_modules/zod/v4/classic/coerce.js +0 -17
  469. package/node_modules/zod/v4/classic/compat.cjs +0 -61
  470. package/node_modules/zod/v4/classic/compat.d.cts +0 -50
  471. package/node_modules/zod/v4/classic/compat.d.ts +0 -50
  472. package/node_modules/zod/v4/classic/compat.js +0 -31
  473. package/node_modules/zod/v4/classic/errors.cjs +0 -74
  474. package/node_modules/zod/v4/classic/errors.d.cts +0 -30
  475. package/node_modules/zod/v4/classic/errors.d.ts +0 -30
  476. package/node_modules/zod/v4/classic/errors.js +0 -48
  477. package/node_modules/zod/v4/classic/external.cjs +0 -70
  478. package/node_modules/zod/v4/classic/external.d.cts +0 -13
  479. package/node_modules/zod/v4/classic/external.d.ts +0 -13
  480. package/node_modules/zod/v4/classic/external.js +0 -18
  481. package/node_modules/zod/v4/classic/index.cjs +0 -33
  482. package/node_modules/zod/v4/classic/index.d.cts +0 -4
  483. package/node_modules/zod/v4/classic/index.d.ts +0 -4
  484. package/node_modules/zod/v4/classic/index.js +0 -4
  485. package/node_modules/zod/v4/classic/iso.cjs +0 -60
  486. package/node_modules/zod/v4/classic/iso.d.cts +0 -22
  487. package/node_modules/zod/v4/classic/iso.d.ts +0 -22
  488. package/node_modules/zod/v4/classic/iso.js +0 -30
  489. package/node_modules/zod/v4/classic/package.json +0 -6
  490. package/node_modules/zod/v4/classic/parse.cjs +0 -41
  491. package/node_modules/zod/v4/classic/parse.d.cts +0 -31
  492. package/node_modules/zod/v4/classic/parse.d.ts +0 -31
  493. package/node_modules/zod/v4/classic/parse.js +0 -15
  494. package/node_modules/zod/v4/classic/schemas.cjs +0 -1151
  495. package/node_modules/zod/v4/classic/schemas.d.cts +0 -673
  496. package/node_modules/zod/v4/classic/schemas.d.ts +0 -673
  497. package/node_modules/zod/v4/classic/schemas.js +0 -1040
  498. package/node_modules/zod/v4/core/api.cjs +0 -1060
  499. package/node_modules/zod/v4/core/api.d.cts +0 -295
  500. package/node_modules/zod/v4/core/api.d.ts +0 -295
  501. package/node_modules/zod/v4/core/api.js +0 -925
  502. package/node_modules/zod/v4/core/checks.cjs +0 -595
  503. package/node_modules/zod/v4/core/checks.d.cts +0 -278
  504. package/node_modules/zod/v4/core/checks.d.ts +0 -278
  505. package/node_modules/zod/v4/core/checks.js +0 -569
  506. package/node_modules/zod/v4/core/core.cjs +0 -74
  507. package/node_modules/zod/v4/core/core.d.cts +0 -52
  508. package/node_modules/zod/v4/core/core.d.ts +0 -52
  509. package/node_modules/zod/v4/core/core.js +0 -67
  510. package/node_modules/zod/v4/core/doc.cjs +0 -39
  511. package/node_modules/zod/v4/core/doc.d.cts +0 -14
  512. package/node_modules/zod/v4/core/doc.d.ts +0 -14
  513. package/node_modules/zod/v4/core/doc.js +0 -35
  514. package/node_modules/zod/v4/core/errors.cjs +0 -213
  515. package/node_modules/zod/v4/core/errors.d.cts +0 -210
  516. package/node_modules/zod/v4/core/errors.d.ts +0 -210
  517. package/node_modules/zod/v4/core/errors.js +0 -182
  518. package/node_modules/zod/v4/core/index.cjs +0 -43
  519. package/node_modules/zod/v4/core/index.d.cts +0 -14
  520. package/node_modules/zod/v4/core/index.d.ts +0 -14
  521. package/node_modules/zod/v4/core/index.js +0 -14
  522. package/node_modules/zod/v4/core/json-schema.cjs +0 -2
  523. package/node_modules/zod/v4/core/json-schema.d.cts +0 -88
  524. package/node_modules/zod/v4/core/json-schema.d.ts +0 -88
  525. package/node_modules/zod/v4/core/json-schema.js +0 -1
  526. package/node_modules/zod/v4/core/package.json +0 -6
  527. package/node_modules/zod/v4/core/parse.cjs +0 -131
  528. package/node_modules/zod/v4/core/parse.d.cts +0 -49
  529. package/node_modules/zod/v4/core/parse.d.ts +0 -49
  530. package/node_modules/zod/v4/core/parse.js +0 -93
  531. package/node_modules/zod/v4/core/regexes.cjs +0 -136
  532. package/node_modules/zod/v4/core/regexes.d.cts +0 -78
  533. package/node_modules/zod/v4/core/regexes.d.ts +0 -78
  534. package/node_modules/zod/v4/core/regexes.js +0 -127
  535. package/node_modules/zod/v4/core/registries.cjs +0 -57
  536. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  537. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  538. package/node_modules/zod/v4/core/registries.js +0 -52
  539. package/node_modules/zod/v4/core/schemas.cjs +0 -1986
  540. package/node_modules/zod/v4/core/schemas.d.cts +0 -1113
  541. package/node_modules/zod/v4/core/schemas.d.ts +0 -1113
  542. package/node_modules/zod/v4/core/schemas.js +0 -1955
  543. package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  544. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -55
  545. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -55
  546. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  547. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -920
  548. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -90
  549. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -90
  550. package/node_modules/zod/v4/core/to-json-schema.js +0 -915
  551. package/node_modules/zod/v4/core/util.cjs +0 -658
  552. package/node_modules/zod/v4/core/util.d.cts +0 -197
  553. package/node_modules/zod/v4/core/util.d.ts +0 -197
  554. package/node_modules/zod/v4/core/util.js +0 -601
  555. package/node_modules/zod/v4/core/versions.cjs +0 -8
  556. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  557. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  558. package/node_modules/zod/v4/core/versions.js +0 -5
  559. package/node_modules/zod/v4/index.cjs +0 -22
  560. package/node_modules/zod/v4/index.d.cts +0 -3
  561. package/node_modules/zod/v4/index.d.ts +0 -3
  562. package/node_modules/zod/v4/index.js +0 -3
  563. package/node_modules/zod/v4/locales/ar.cjs +0 -143
  564. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  565. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  566. package/node_modules/zod/v4/locales/ar.js +0 -116
  567. package/node_modules/zod/v4/locales/az.cjs +0 -142
  568. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  569. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  570. package/node_modules/zod/v4/locales/az.js +0 -115
  571. package/node_modules/zod/v4/locales/be.cjs +0 -191
  572. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  573. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  574. package/node_modules/zod/v4/locales/be.js +0 -164
  575. package/node_modules/zod/v4/locales/bg.cjs +0 -156
  576. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  577. package/node_modules/zod/v4/locales/bg.d.ts +0 -5
  578. package/node_modules/zod/v4/locales/bg.js +0 -128
  579. package/node_modules/zod/v4/locales/ca.cjs +0 -145
  580. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  581. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  582. package/node_modules/zod/v4/locales/ca.js +0 -118
  583. package/node_modules/zod/v4/locales/cs.cjs +0 -162
  584. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  585. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  586. package/node_modules/zod/v4/locales/cs.js +0 -135
  587. package/node_modules/zod/v4/locales/da.cjs +0 -158
  588. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  589. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  590. package/node_modules/zod/v4/locales/da.js +0 -131
  591. package/node_modules/zod/v4/locales/de.cjs +0 -143
  592. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  593. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  594. package/node_modules/zod/v4/locales/de.js +0 -116
  595. package/node_modules/zod/v4/locales/en.cjs +0 -145
  596. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  597. package/node_modules/zod/v4/locales/en.d.ts +0 -5
  598. package/node_modules/zod/v4/locales/en.js +0 -117
  599. package/node_modules/zod/v4/locales/eo.cjs +0 -144
  600. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  601. package/node_modules/zod/v4/locales/eo.d.ts +0 -5
  602. package/node_modules/zod/v4/locales/eo.js +0 -116
  603. package/node_modules/zod/v4/locales/es.cjs +0 -176
  604. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  605. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  606. package/node_modules/zod/v4/locales/es.js +0 -149
  607. package/node_modules/zod/v4/locales/fa.cjs +0 -149
  608. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  609. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  610. package/node_modules/zod/v4/locales/fa.js +0 -122
  611. package/node_modules/zod/v4/locales/fi.cjs +0 -149
  612. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  613. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  614. package/node_modules/zod/v4/locales/fi.js +0 -122
  615. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -144
  616. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  617. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  618. package/node_modules/zod/v4/locales/fr-CA.js +0 -117
  619. package/node_modules/zod/v4/locales/fr.cjs +0 -143
  620. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  621. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  622. package/node_modules/zod/v4/locales/fr.js +0 -116
  623. package/node_modules/zod/v4/locales/he.cjs +0 -144
  624. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  625. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  626. package/node_modules/zod/v4/locales/he.js +0 -117
  627. package/node_modules/zod/v4/locales/hu.cjs +0 -144
  628. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  629. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  630. package/node_modules/zod/v4/locales/hu.js +0 -117
  631. package/node_modules/zod/v4/locales/id.cjs +0 -143
  632. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  633. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  634. package/node_modules/zod/v4/locales/id.js +0 -116
  635. package/node_modules/zod/v4/locales/index.cjs +0 -100
  636. package/node_modules/zod/v4/locales/index.d.cts +0 -47
  637. package/node_modules/zod/v4/locales/index.d.ts +0 -47
  638. package/node_modules/zod/v4/locales/index.js +0 -47
  639. package/node_modules/zod/v4/locales/is.cjs +0 -145
  640. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  641. package/node_modules/zod/v4/locales/is.d.ts +0 -5
  642. package/node_modules/zod/v4/locales/is.js +0 -117
  643. package/node_modules/zod/v4/locales/it.cjs +0 -144
  644. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  645. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  646. package/node_modules/zod/v4/locales/it.js +0 -117
  647. package/node_modules/zod/v4/locales/ja.cjs +0 -142
  648. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  649. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  650. package/node_modules/zod/v4/locales/ja.js +0 -115
  651. package/node_modules/zod/v4/locales/ka.cjs +0 -153
  652. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  653. package/node_modules/zod/v4/locales/ka.d.ts +0 -5
  654. package/node_modules/zod/v4/locales/ka.js +0 -125
  655. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  656. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  657. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  658. package/node_modules/zod/v4/locales/kh.js +0 -5
  659. package/node_modules/zod/v4/locales/km.cjs +0 -144
  660. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  661. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  662. package/node_modules/zod/v4/locales/km.js +0 -117
  663. package/node_modules/zod/v4/locales/ko.cjs +0 -148
  664. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  665. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  666. package/node_modules/zod/v4/locales/ko.js +0 -121
  667. package/node_modules/zod/v4/locales/lt.cjs +0 -258
  668. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  669. package/node_modules/zod/v4/locales/lt.d.ts +0 -5
  670. package/node_modules/zod/v4/locales/lt.js +0 -230
  671. package/node_modules/zod/v4/locales/mk.cjs +0 -145
  672. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  673. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  674. package/node_modules/zod/v4/locales/mk.js +0 -118
  675. package/node_modules/zod/v4/locales/ms.cjs +0 -143
  676. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  677. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  678. package/node_modules/zod/v4/locales/ms.js +0 -116
  679. package/node_modules/zod/v4/locales/nl.cjs +0 -144
  680. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  681. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  682. package/node_modules/zod/v4/locales/nl.js +0 -117
  683. package/node_modules/zod/v4/locales/no.cjs +0 -143
  684. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  685. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  686. package/node_modules/zod/v4/locales/no.js +0 -116
  687. package/node_modules/zod/v4/locales/ota.cjs +0 -144
  688. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  689. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  690. package/node_modules/zod/v4/locales/ota.js +0 -117
  691. package/node_modules/zod/v4/locales/package.json +0 -6
  692. package/node_modules/zod/v4/locales/pl.cjs +0 -144
  693. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  694. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  695. package/node_modules/zod/v4/locales/pl.js +0 -117
  696. package/node_modules/zod/v4/locales/ps.cjs +0 -149
  697. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  698. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  699. package/node_modules/zod/v4/locales/ps.js +0 -122
  700. package/node_modules/zod/v4/locales/pt.cjs +0 -143
  701. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  702. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  703. package/node_modules/zod/v4/locales/pt.js +0 -116
  704. package/node_modules/zod/v4/locales/ru.cjs +0 -191
  705. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  706. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  707. package/node_modules/zod/v4/locales/ru.js +0 -164
  708. package/node_modules/zod/v4/locales/sl.cjs +0 -144
  709. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  710. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  711. package/node_modules/zod/v4/locales/sl.js +0 -117
  712. package/node_modules/zod/v4/locales/sv.cjs +0 -145
  713. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  714. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  715. package/node_modules/zod/v4/locales/sv.js +0 -118
  716. package/node_modules/zod/v4/locales/ta.cjs +0 -144
  717. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  718. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  719. package/node_modules/zod/v4/locales/ta.js +0 -117
  720. package/node_modules/zod/v4/locales/th.cjs +0 -144
  721. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  722. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  723. package/node_modules/zod/v4/locales/th.js +0 -117
  724. package/node_modules/zod/v4/locales/tr.cjs +0 -143
  725. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  726. package/node_modules/zod/v4/locales/tr.d.ts +0 -5
  727. package/node_modules/zod/v4/locales/tr.js +0 -115
  728. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  729. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  730. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  731. package/node_modules/zod/v4/locales/ua.js +0 -5
  732. package/node_modules/zod/v4/locales/uk.cjs +0 -144
  733. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  734. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  735. package/node_modules/zod/v4/locales/uk.js +0 -117
  736. package/node_modules/zod/v4/locales/ur.cjs +0 -144
  737. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  738. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  739. package/node_modules/zod/v4/locales/ur.js +0 -117
  740. package/node_modules/zod/v4/locales/vi.cjs +0 -143
  741. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  742. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  743. package/node_modules/zod/v4/locales/vi.js +0 -116
  744. package/node_modules/zod/v4/locales/yo.cjs +0 -142
  745. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  746. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  747. package/node_modules/zod/v4/locales/yo.js +0 -115
  748. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -143
  749. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  750. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  751. package/node_modules/zod/v4/locales/zh-CN.js +0 -116
  752. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -144
  753. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  754. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  755. package/node_modules/zod/v4/locales/zh-TW.js +0 -117
  756. package/node_modules/zod/v4/mini/checks.cjs +0 -34
  757. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  758. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  759. package/node_modules/zod/v4/mini/checks.js +0 -1
  760. package/node_modules/zod/v4/mini/coerce.cjs +0 -47
  761. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  762. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  763. package/node_modules/zod/v4/mini/coerce.js +0 -17
  764. package/node_modules/zod/v4/mini/external.cjs +0 -62
  765. package/node_modules/zod/v4/mini/external.d.cts +0 -11
  766. package/node_modules/zod/v4/mini/external.d.ts +0 -11
  767. package/node_modules/zod/v4/mini/external.js +0 -13
  768. package/node_modules/zod/v4/mini/index.cjs +0 -32
  769. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  770. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  771. package/node_modules/zod/v4/mini/index.js +0 -3
  772. package/node_modules/zod/v4/mini/iso.cjs +0 -60
  773. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  774. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  775. package/node_modules/zod/v4/mini/iso.js +0 -30
  776. package/node_modules/zod/v4/mini/package.json +0 -6
  777. package/node_modules/zod/v4/mini/parse.cjs +0 -16
  778. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  779. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  780. package/node_modules/zod/v4/mini/parse.js +0 -1
  781. package/node_modules/zod/v4/mini/schemas.cjs +0 -892
  782. package/node_modules/zod/v4/mini/schemas.d.cts +0 -407
  783. package/node_modules/zod/v4/mini/schemas.d.ts +0 -407
  784. package/node_modules/zod/v4/mini/schemas.js +0 -775
  785. package/node_modules/zod/v4/package.json +0 -6
  786. package/node_modules/zod/v4-mini/index.cjs +0 -17
  787. package/node_modules/zod/v4-mini/index.d.cts +0 -1
  788. package/node_modules/zod/v4-mini/index.d.ts +0 -1
  789. package/node_modules/zod/v4-mini/index.js +0 -1
  790. package/node_modules/zod/v4-mini/package.json +0 -6
  791. package/package/cc-switch-sdk/README.md +0 -541
  792. package/package/cc-switch-sdk/dist/constants.d.ts +0 -8
  793. package/package/cc-switch-sdk/dist/constants.js +0 -2
  794. package/package/cc-switch-sdk/dist/errors.d.ts +0 -5
  795. package/package/cc-switch-sdk/dist/errors.js +0 -2
  796. package/package/cc-switch-sdk/dist/index.d.ts +0 -5
  797. package/package/cc-switch-sdk/dist/index.js +0 -2
  798. package/package/cc-switch-sdk/dist/schemas.d.ts +0 -7
  799. package/package/cc-switch-sdk/dist/schemas.js +0 -2
  800. package/package/cc-switch-sdk/dist/sdk.d.ts +0 -59
  801. package/package/cc-switch-sdk/dist/sdk.js +0 -2
  802. package/package/cc-switch-sdk/dist/services/ai-config-service.js +0 -4
  803. package/package/cc-switch-sdk/dist/services/mcp-model.d.ts +0 -16
  804. package/package/cc-switch-sdk/dist/services/mcp-model.js +0 -2
  805. package/package/cc-switch-sdk/dist/services/mcp-service.d.ts +0 -17
  806. package/package/cc-switch-sdk/dist/services/mcp-service.js +0 -2
  807. package/package/cc-switch-sdk/dist/services/skill-model.d.ts +0 -16
  808. package/package/cc-switch-sdk/dist/services/skill-model.js +0 -2
  809. package/package/cc-switch-sdk/dist/services/skill-service.d.ts +0 -16
  810. package/package/cc-switch-sdk/dist/services/skill-service.js +0 -2
  811. package/package/cc-switch-sdk/dist/state.d.ts +0 -3
  812. package/package/cc-switch-sdk/dist/state.js +0 -2
  813. package/package/cc-switch-sdk/dist/types.d.ts +0 -78
  814. package/package/cc-switch-sdk/dist/types.js +0 -1
  815. package/package/cc-switch-sdk/dist/utils/fs.d.ts +0 -10
  816. package/package/cc-switch-sdk/dist/utils/fs.js +0 -3
  817. package/package/cc-switch-sdk/dist/utils/id.d.ts +0 -3
  818. package/package/cc-switch-sdk/dist/utils/id.js +0 -2
  819. package/package/cc-switch-sdk/package.json +0 -31
  820. /package/{node_modules/@cc-switch/sdk/dist/types.js → package/acode/dist/plugin-types.js} +0 -0
@@ -1,4317 +0,0 @@
1
- import type { $ZodTypeDiscriminable } from "./api.js";
2
- import * as checks from "./checks.js";
3
- import * as core from "./core.js";
4
- import { Doc } from "./doc.js";
5
- import type * as errors from "./errors.js";
6
- import { parse, parseAsync, safeParse, safeParseAsync } from "./parse.js";
7
- import * as regexes from "./regexes.js";
8
- import type { StandardSchemaV1 } from "./standard-schema.js";
9
- import * as util from "./util.js";
10
- import { version } from "./versions.js";
11
-
12
- ///////////////////////////// PARSE //////////////////////////////
13
-
14
- export interface ParseContext<T extends errors.$ZodIssueBase = never> {
15
- /** Customize error messages. */
16
- readonly error?: errors.$ZodErrorMap<T>;
17
- /** Include the `input` field in issue objects. Default `false`. */
18
- readonly reportInput?: boolean;
19
- /** Skip eval-based fast path. Default `false`. */
20
- readonly jitless?: boolean;
21
- /** Abort validation after the first error. Default `false`. */
22
- // readonly abortEarly?: boolean;
23
- }
24
-
25
- /** @internal */
26
- export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
27
- readonly async?: boolean | undefined;
28
- readonly direction?: "forward" | "backward";
29
- readonly skipChecks?: boolean;
30
- }
31
-
32
- export interface ParsePayload<T = unknown> {
33
- value: T;
34
- issues: errors.$ZodRawIssue[];
35
- /** A may to mark a whole payload as aborted. Used in codecs/pipes. */
36
- aborted?: boolean;
37
- }
38
-
39
- export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
40
-
41
- ///////////////////////////// SCHEMAS //////////////////////////////
42
-
43
- export interface $ZodTypeDef {
44
- type:
45
- | "string"
46
- | "number"
47
- | "int"
48
- | "boolean"
49
- | "bigint"
50
- | "symbol"
51
- | "null"
52
- | "undefined"
53
- | "void" // merge with undefined?
54
- | "never"
55
- | "any"
56
- | "unknown"
57
- | "date"
58
- | "object"
59
- | "record"
60
- | "file"
61
- | "array"
62
- | "tuple"
63
- | "union"
64
- | "intersection"
65
- | "map"
66
- | "set"
67
- | "enum"
68
- | "literal"
69
- | "nullable"
70
- | "optional"
71
- | "nonoptional"
72
- | "success"
73
- | "transform"
74
- | "default"
75
- | "prefault"
76
- | "catch"
77
- | "nan"
78
- | "pipe"
79
- | "readonly"
80
- | "template_literal"
81
- | "promise"
82
- | "lazy"
83
- | "function"
84
- | "custom";
85
- error?: errors.$ZodErrorMap<never> | undefined;
86
- checks?: checks.$ZodCheck<never>[];
87
- }
88
-
89
- export interface _$ZodTypeInternals {
90
- /** The `@zod/core` version of this schema */
91
- version: typeof version;
92
-
93
- /** Schema definition. */
94
- def: $ZodTypeDef;
95
- // types: Types;
96
-
97
- /** @internal Randomly generated ID for this schema. */
98
- // id: string;
99
-
100
- /** @internal List of deferred initializers. */
101
- deferred: util.AnyFunc[] | undefined;
102
-
103
- /** @internal Parses input and runs all checks (refinements). */
104
- run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
105
-
106
- /** @internal Parses input, doesn't run checks. */
107
- parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
108
-
109
- /** @internal Stores identifiers for the set of traits implemented by this schema. */
110
- traits: Set<string>;
111
-
112
- /** @internal Indicates that a schema output type should be considered optional inside objects.
113
- * @default Required
114
- */
115
-
116
- /** @internal */
117
- optin?: "optional" | undefined;
118
- /** @internal */
119
- optout?: "optional" | undefined;
120
-
121
- /** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
122
- *
123
- * Defined on: enum, const, literal, null, undefined
124
- * Passthrough: optional, nullable, branded, default, catch, pipe
125
- * Todo: unions?
126
- */
127
- values?: util.PrimitiveSet | undefined;
128
-
129
- /** Default value bubbled up from */
130
- // default?: unknown | undefined;
131
-
132
- /** @internal A set of literal discriminators used for the fast path in discriminated unions. */
133
- propValues?: util.PropValues | undefined;
134
-
135
- /** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
136
- pattern: RegExp | undefined;
137
-
138
- /** @internal The constructor function of this schema. */
139
- constr: new (
140
- def: any
141
- ) => $ZodType;
142
-
143
- /** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
144
- bag: Record<string, unknown>;
145
-
146
- /** @internal The set of issues this schema might throw during type checking. */
147
- isst: errors.$ZodIssueBase;
148
-
149
- /** An optional method used to override `toJSONSchema` logic. */
150
- toJSONSchema?: () => unknown;
151
-
152
- /** @internal The parent of this schema. Only set during certain clone operations. */
153
- parent?: $ZodType | undefined;
154
- }
155
- /** @internal */
156
- export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
157
- /** @internal The inferred output type */
158
- output: O; //extends { $out: infer O } ? O : Out;
159
- /** @internal The inferred input type */
160
- input: I; //extends { $in: infer I } ? I : In;
161
- }
162
-
163
- export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
164
-
165
- export type SomeType = { _zod: _$ZodTypeInternals };
166
-
167
- export interface $ZodType<
168
- O = unknown,
169
- I = unknown,
170
- Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>,
171
- > {
172
- _zod: Internals;
173
- "~standard": $ZodStandardSchema<this>;
174
- }
175
- export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals>
176
- extends $ZodType<T["output"], T["input"], T> {}
177
-
178
- export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
179
- inst ??= {} as any;
180
-
181
- inst._zod.def = def; // set _def property
182
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
183
- inst._zod.version = version;
184
-
185
- const checks = [...(inst._zod.def.checks ?? [])];
186
-
187
- // if inst is itself a checks.$ZodCheck, run it as a check
188
- if (inst._zod.traits.has("$ZodCheck")) {
189
- checks.unshift(inst as any);
190
- }
191
-
192
- for (const ch of checks) {
193
- for (const fn of ch._zod.onattach) {
194
- fn(inst);
195
- }
196
- }
197
-
198
- if (checks.length === 0) {
199
- // deferred initializer
200
- // inst._zod.parse is not yet defined
201
- inst._zod.deferred ??= [];
202
- inst._zod.deferred?.push(() => {
203
- inst._zod.run = inst._zod.parse;
204
- });
205
- } else {
206
- const runChecks = (
207
- payload: ParsePayload,
208
- checks: checks.$ZodCheck<never>[],
209
- ctx?: ParseContextInternal | undefined
210
- ): util.MaybeAsync<ParsePayload> => {
211
- let isAborted = util.aborted(payload);
212
-
213
- let asyncResult!: Promise<unknown> | undefined;
214
- for (const ch of checks) {
215
- if (ch._zod.def.when) {
216
- const shouldRun = ch._zod.def.when(payload);
217
- if (!shouldRun) continue;
218
- } else if (isAborted) {
219
- continue;
220
- }
221
- const currLen = payload.issues.length;
222
- const _ = ch._zod.check(payload as any) as any as ParsePayload;
223
-
224
- if (_ instanceof Promise && ctx?.async === false) {
225
- throw new core.$ZodAsyncError();
226
- }
227
- if (asyncResult || _ instanceof Promise) {
228
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
229
- await _;
230
- const nextLen = payload.issues.length;
231
- if (nextLen === currLen) return;
232
- if (!isAborted) isAborted = util.aborted(payload, currLen);
233
- });
234
- } else {
235
- const nextLen = payload.issues.length;
236
- if (nextLen === currLen) continue;
237
- if (!isAborted) isAborted = util.aborted(payload, currLen);
238
- }
239
- }
240
-
241
- if (asyncResult) {
242
- return asyncResult.then(() => {
243
- return payload;
244
- });
245
- }
246
- return payload;
247
- };
248
-
249
- // const handleChecksResult = (
250
- // checkResult: ParsePayload,
251
- // originalResult: ParsePayload,
252
- // ctx: ParseContextInternal
253
- // ): util.MaybeAsync<ParsePayload> => {
254
- // // if the checks mutated the value && there are no issues, re-parse the result
255
- // if (checkResult.value !== originalResult.value && !checkResult.issues.length)
256
- // return inst._zod.parse(checkResult, ctx);
257
- // return originalResult;
258
- // };
259
- const handleCanaryResult = (canary: ParsePayload, payload: ParsePayload, ctx: ParseContextInternal) => {
260
- // abort if the canary is aborted
261
- if (util.aborted(canary)) {
262
- canary.aborted = true;
263
- return canary;
264
- }
265
-
266
- // run checks first, then
267
- const checkResult = runChecks(payload, checks, ctx);
268
- if (checkResult instanceof Promise) {
269
- if (ctx.async === false) throw new core.$ZodAsyncError();
270
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
271
- }
272
- return inst._zod.parse(checkResult, ctx);
273
- };
274
-
275
- inst._zod.run = (payload, ctx) => {
276
- if (ctx.skipChecks) {
277
- return inst._zod.parse(payload, ctx);
278
- }
279
- if (ctx.direction === "backward") {
280
- // run canary
281
- // initial pass (no checks)
282
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
283
-
284
- if (canary instanceof Promise) {
285
- return canary.then((canary) => {
286
- return handleCanaryResult(canary, payload, ctx);
287
- });
288
- }
289
-
290
- return handleCanaryResult(canary, payload, ctx);
291
- }
292
-
293
- // forward
294
- const result = inst._zod.parse(payload, ctx);
295
- if (result instanceof Promise) {
296
- if (ctx.async === false) throw new core.$ZodAsyncError();
297
- return result.then((result) => runChecks(result, checks, ctx));
298
- }
299
-
300
- return runChecks(result, checks, ctx);
301
- };
302
- }
303
-
304
- inst["~standard"] = {
305
- validate: (value: unknown) => {
306
- try {
307
- const r = safeParse(inst, value);
308
- return r.success ? { value: r.data } : { issues: r.error?.issues };
309
- } catch (_) {
310
- return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
311
- }
312
- },
313
- vendor: "zod",
314
- version: 1 as const,
315
- };
316
- });
317
-
318
- export { clone } from "./util.js";
319
-
320
- //////////////////////////////////////////
321
- //////////////////////////////////////////
322
- ////////// //////////
323
- ////////// $ZodString //////////
324
- ////////// //////////
325
- //////////////////////////////////////////
326
- //////////////////////////////////////////
327
- export interface $ZodStringDef extends $ZodTypeDef {
328
- type: "string";
329
- coerce?: boolean;
330
- checks?: checks.$ZodCheck<string>[];
331
- }
332
-
333
- export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
334
- def: $ZodStringDef;
335
- /** @deprecated Internal API, use with caution (not deprecated) */
336
- pattern: RegExp;
337
-
338
- /** @deprecated Internal API, use with caution (not deprecated) */
339
- isst: errors.$ZodIssueInvalidType;
340
- bag: util.LoosePartial<{
341
- minimum: number;
342
- maximum: number;
343
- patterns: Set<RegExp>;
344
- format: string;
345
- contentEncoding: string;
346
- }>;
347
- }
348
-
349
- export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
350
- // _zod: $ZodStringInternals<Input>;
351
- }
352
-
353
- export const $ZodString: core.$constructor<$ZodString> = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
354
- $ZodType.init(inst, def);
355
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
356
- inst._zod.parse = (payload, _) => {
357
- if (def.coerce)
358
- try {
359
- payload.value = String(payload.value);
360
- } catch (_) {}
361
-
362
- if (typeof payload.value === "string") return payload;
363
-
364
- payload.issues.push({
365
- expected: "string",
366
- code: "invalid_type",
367
-
368
- input: payload.value,
369
- inst,
370
- });
371
- return payload;
372
- };
373
- });
374
-
375
- ////////////////////////////// ZodStringFormat //////////////////////////////
376
-
377
- export interface $ZodStringFormatDef<Format extends string = string>
378
- extends $ZodStringDef,
379
- checks.$ZodCheckStringFormatDef<Format> {}
380
-
381
- export interface $ZodStringFormatInternals<Format extends string = string>
382
- extends $ZodStringInternals<string>,
383
- checks.$ZodCheckStringFormatInternals {
384
- def: $ZodStringFormatDef<Format>;
385
- }
386
- export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
387
- _zod: $ZodStringFormatInternals<Format>;
388
- }
389
-
390
- export const $ZodStringFormat: core.$constructor<$ZodStringFormat> = /*@__PURE__*/ core.$constructor(
391
- "$ZodStringFormat",
392
- (inst, def): void => {
393
- // check initialization must come first
394
- checks.$ZodCheckStringFormat.init(inst, def);
395
- $ZodString.init(inst, def);
396
- }
397
- );
398
-
399
- ////////////////////////////// ZodGUID //////////////////////////////
400
- export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {}
401
- export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {}
402
-
403
- export interface $ZodGUID extends $ZodType {
404
- _zod: $ZodGUIDInternals;
405
- }
406
-
407
- export const $ZodGUID: core.$constructor<$ZodGUID> = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def): void => {
408
- def.pattern ??= regexes.guid;
409
- $ZodStringFormat.init(inst, def);
410
- });
411
-
412
- ////////////////////////////// ZodUUID //////////////////////////////
413
-
414
- export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
415
- version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
416
- }
417
-
418
- export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
419
- def: $ZodUUIDDef;
420
- }
421
-
422
- export interface $ZodUUID extends $ZodType {
423
- _zod: $ZodUUIDInternals;
424
- }
425
-
426
- export const $ZodUUID: core.$constructor<$ZodUUID> = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def): void => {
427
- if (def.version) {
428
- const versionMap: Record<string, number> = {
429
- v1: 1,
430
- v2: 2,
431
- v3: 3,
432
- v4: 4,
433
- v5: 5,
434
- v6: 6,
435
- v7: 7,
436
- v8: 8,
437
- };
438
- const v = versionMap[def.version];
439
- if (v === undefined) throw new Error(`Invalid UUID version: "${def.version}"`);
440
- def.pattern ??= regexes.uuid(v);
441
- } else def.pattern ??= regexes.uuid();
442
- $ZodStringFormat.init(inst, def);
443
- });
444
-
445
- ////////////////////////////// ZodEmail //////////////////////////////
446
-
447
- export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {}
448
- export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {}
449
- export interface $ZodEmail extends $ZodType {
450
- _zod: $ZodEmailInternals;
451
- }
452
-
453
- export const $ZodEmail: core.$constructor<$ZodEmail> = /*@__PURE__*/ core.$constructor(
454
- "$ZodEmail",
455
- (inst, def): void => {
456
- def.pattern ??= regexes.email;
457
- $ZodStringFormat.init(inst, def);
458
- }
459
- );
460
-
461
- ////////////////////////////// ZodURL //////////////////////////////
462
-
463
- export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
464
- hostname?: RegExp | undefined;
465
- protocol?: RegExp | undefined;
466
- normalize?: boolean | undefined;
467
- }
468
- export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
469
- def: $ZodURLDef;
470
- }
471
-
472
- export interface $ZodURL extends $ZodType {
473
- _zod: $ZodURLInternals;
474
- }
475
-
476
- export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
477
- $ZodStringFormat.init(inst, def);
478
- inst._zod.check = (payload) => {
479
- try {
480
- // Trim whitespace from input
481
- const trimmed = payload.value.trim();
482
- // @ts-ignore
483
- const url = new URL(trimmed);
484
-
485
- if (def.hostname) {
486
- def.hostname.lastIndex = 0;
487
- if (!def.hostname.test(url.hostname)) {
488
- payload.issues.push({
489
- code: "invalid_format",
490
- format: "url",
491
- note: "Invalid hostname",
492
- pattern: regexes.hostname.source,
493
- input: payload.value,
494
- inst,
495
- continue: !def.abort,
496
- });
497
- }
498
- }
499
-
500
- if (def.protocol) {
501
- def.protocol.lastIndex = 0;
502
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
503
- payload.issues.push({
504
- code: "invalid_format",
505
- format: "url",
506
- note: "Invalid protocol",
507
- pattern: def.protocol.source,
508
- input: payload.value,
509
- inst,
510
- continue: !def.abort,
511
- });
512
- }
513
- }
514
-
515
- // Set the output value based on normalize flag
516
- if (def.normalize) {
517
- // Use normalized URL
518
- payload.value = url.href;
519
- } else {
520
- // Preserve the original input (trimmed)
521
- payload.value = trimmed;
522
- }
523
-
524
- return;
525
- } catch (_) {
526
- payload.issues.push({
527
- code: "invalid_format",
528
- format: "url",
529
- input: payload.value,
530
- inst,
531
- continue: !def.abort,
532
- });
533
- }
534
- };
535
- });
536
-
537
- ////////////////////////////// ZodEmoji //////////////////////////////
538
-
539
- export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {}
540
- export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {}
541
-
542
- export interface $ZodEmoji extends $ZodType {
543
- _zod: $ZodEmojiInternals;
544
- }
545
-
546
- export const $ZodEmoji: core.$constructor<$ZodEmoji> = /*@__PURE__*/ core.$constructor(
547
- "$ZodEmoji",
548
- (inst, def): void => {
549
- def.pattern ??= regexes.emoji();
550
- $ZodStringFormat.init(inst, def);
551
- }
552
- );
553
-
554
- ////////////////////////////// ZodNanoID //////////////////////////////
555
-
556
- export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {}
557
- export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {}
558
-
559
- export interface $ZodNanoID extends $ZodType {
560
- _zod: $ZodNanoIDInternals;
561
- }
562
-
563
- export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$constructor(
564
- "$ZodNanoID",
565
- (inst, def): void => {
566
- def.pattern ??= regexes.nanoid;
567
- $ZodStringFormat.init(inst, def);
568
- }
569
- );
570
-
571
- ////////////////////////////// ZodCUID //////////////////////////////
572
-
573
- export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {}
574
- export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {}
575
-
576
- export interface $ZodCUID extends $ZodType {
577
- _zod: $ZodCUIDInternals;
578
- }
579
-
580
- export const $ZodCUID: core.$constructor<$ZodCUID> = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def): void => {
581
- def.pattern ??= regexes.cuid;
582
- $ZodStringFormat.init(inst, def);
583
- });
584
-
585
- ////////////////////////////// ZodCUID2 //////////////////////////////
586
-
587
- export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {}
588
- export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {}
589
-
590
- export interface $ZodCUID2 extends $ZodType {
591
- _zod: $ZodCUID2Internals;
592
- }
593
-
594
- export const $ZodCUID2: core.$constructor<$ZodCUID2> = /*@__PURE__*/ core.$constructor(
595
- "$ZodCUID2",
596
- (inst, def): void => {
597
- def.pattern ??= regexes.cuid2;
598
- $ZodStringFormat.init(inst, def);
599
- }
600
- );
601
-
602
- ////////////////////////////// ZodULID //////////////////////////////
603
-
604
- export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {}
605
- export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {}
606
-
607
- export interface $ZodULID extends $ZodType {
608
- _zod: $ZodULIDInternals;
609
- }
610
-
611
- export const $ZodULID: core.$constructor<$ZodULID> = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def): void => {
612
- def.pattern ??= regexes.ulid;
613
- $ZodStringFormat.init(inst, def);
614
- });
615
-
616
- ////////////////////////////// ZodXID //////////////////////////////
617
-
618
- export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {}
619
- export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {}
620
-
621
- export interface $ZodXID extends $ZodType {
622
- _zod: $ZodXIDInternals;
623
- }
624
-
625
- export const $ZodXID: core.$constructor<$ZodXID> = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def): void => {
626
- def.pattern ??= regexes.xid;
627
- $ZodStringFormat.init(inst, def);
628
- });
629
-
630
- ////////////////////////////// ZodKSUID //////////////////////////////
631
-
632
- export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {}
633
- export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {}
634
-
635
- export interface $ZodKSUID extends $ZodType {
636
- _zod: $ZodKSUIDInternals;
637
- }
638
-
639
- export const $ZodKSUID: core.$constructor<$ZodKSUID> = /*@__PURE__*/ core.$constructor(
640
- "$ZodKSUID",
641
- (inst, def): void => {
642
- def.pattern ??= regexes.ksuid;
643
- $ZodStringFormat.init(inst, def);
644
- }
645
- );
646
-
647
- ////////////////////////////// ZodISODateTime //////////////////////////////
648
-
649
- export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
650
- precision: number | null;
651
- offset: boolean;
652
- local: boolean;
653
- }
654
-
655
- export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
656
- def: $ZodISODateTimeDef;
657
- }
658
-
659
- export interface $ZodISODateTime extends $ZodType {
660
- _zod: $ZodISODateTimeInternals;
661
- }
662
-
663
- export const $ZodISODateTime: core.$constructor<$ZodISODateTime> = /*@__PURE__*/ core.$constructor(
664
- "$ZodISODateTime",
665
- (inst, def): void => {
666
- def.pattern ??= regexes.datetime(def);
667
- $ZodStringFormat.init(inst, def);
668
- }
669
- );
670
-
671
- ////////////////////////////// ZodISODate //////////////////////////////
672
-
673
- export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {}
674
- export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {}
675
-
676
- export interface $ZodISODate extends $ZodType {
677
- _zod: $ZodISODateInternals;
678
- }
679
-
680
- export const $ZodISODate: core.$constructor<$ZodISODate> = /*@__PURE__*/ core.$constructor(
681
- "$ZodISODate",
682
- (inst, def): void => {
683
- def.pattern ??= regexes.date;
684
- $ZodStringFormat.init(inst, def);
685
- }
686
- );
687
-
688
- ////////////////////////////// ZodISOTime //////////////////////////////
689
-
690
- export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
691
- precision?: number | null;
692
- }
693
-
694
- export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
695
- def: $ZodISOTimeDef;
696
- }
697
-
698
- export interface $ZodISOTime extends $ZodType {
699
- _zod: $ZodISOTimeInternals;
700
- }
701
-
702
- export const $ZodISOTime: core.$constructor<$ZodISOTime> = /*@__PURE__*/ core.$constructor(
703
- "$ZodISOTime",
704
- (inst, def): void => {
705
- def.pattern ??= regexes.time(def);
706
- $ZodStringFormat.init(inst, def);
707
- }
708
- );
709
-
710
- ////////////////////////////// ZodISODuration //////////////////////////////
711
-
712
- export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {}
713
- export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {}
714
-
715
- export interface $ZodISODuration extends $ZodType {
716
- _zod: $ZodISODurationInternals;
717
- }
718
-
719
- export const $ZodISODuration: core.$constructor<$ZodISODuration> = /*@__PURE__*/ core.$constructor(
720
- "$ZodISODuration",
721
- (inst, def): void => {
722
- def.pattern ??= regexes.duration;
723
- $ZodStringFormat.init(inst, def);
724
- }
725
- );
726
-
727
- ////////////////////////////// ZodIPv4 //////////////////////////////
728
-
729
- export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
730
- version?: "v4";
731
- }
732
-
733
- export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
734
- def: $ZodIPv4Def;
735
- }
736
-
737
- export interface $ZodIPv4 extends $ZodType {
738
- _zod: $ZodIPv4Internals;
739
- }
740
-
741
- export const $ZodIPv4: core.$constructor<$ZodIPv4> = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def): void => {
742
- def.pattern ??= regexes.ipv4;
743
- $ZodStringFormat.init(inst, def);
744
- inst._zod.onattach.push((inst) => {
745
- const bag = inst._zod.bag as $ZodStringInternals<unknown>["bag"];
746
- bag.format = `ipv4`;
747
- });
748
- });
749
-
750
- ////////////////////////////// ZodIPv6 //////////////////////////////
751
-
752
- export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
753
- version?: "v6";
754
- }
755
-
756
- export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
757
- def: $ZodIPv6Def;
758
- }
759
-
760
- export interface $ZodIPv6 extends $ZodType {
761
- _zod: $ZodIPv6Internals;
762
- }
763
-
764
- export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def): void => {
765
- def.pattern ??= regexes.ipv6;
766
- $ZodStringFormat.init(inst, def);
767
-
768
- inst._zod.onattach.push((inst) => {
769
- const bag = inst._zod.bag as $ZodStringInternals<unknown>["bag"];
770
- bag.format = `ipv6`;
771
- });
772
-
773
- inst._zod.check = (payload) => {
774
- try {
775
- // @ts-ignore
776
- new URL(`http://[${payload.value}]`);
777
- // return;
778
- } catch {
779
- payload.issues.push({
780
- code: "invalid_format",
781
- format: "ipv6",
782
- input: payload.value,
783
- inst,
784
- continue: !def.abort,
785
- });
786
- }
787
- };
788
- });
789
-
790
- ////////////////////////////// ZodCIDRv4 //////////////////////////////
791
-
792
- export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
793
- version?: "v4";
794
- }
795
-
796
- export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
797
- def: $ZodCIDRv4Def;
798
- }
799
-
800
- export interface $ZodCIDRv4 extends $ZodType {
801
- _zod: $ZodCIDRv4Internals;
802
- }
803
-
804
- export const $ZodCIDRv4: core.$constructor<$ZodCIDRv4> = /*@__PURE__*/ core.$constructor(
805
- "$ZodCIDRv4",
806
- (inst, def): void => {
807
- def.pattern ??= regexes.cidrv4;
808
- $ZodStringFormat.init(inst, def);
809
- }
810
- );
811
-
812
- ////////////////////////////// ZodCIDRv6 //////////////////////////////
813
-
814
- export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
815
- version?: "v6";
816
- }
817
-
818
- export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
819
- def: $ZodCIDRv6Def;
820
- }
821
-
822
- export interface $ZodCIDRv6 extends $ZodType {
823
- _zod: $ZodCIDRv6Internals;
824
- }
825
-
826
- export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$constructor(
827
- "$ZodCIDRv6",
828
- (inst, def): void => {
829
- def.pattern ??= regexes.cidrv6; // not used for validation
830
- $ZodStringFormat.init(inst, def);
831
-
832
- inst._zod.check = (payload) => {
833
- const parts = payload.value.split("/");
834
- try {
835
- if (parts.length !== 2) throw new Error();
836
- const [address, prefix] = parts;
837
- if (!prefix) throw new Error();
838
- const prefixNum = Number(prefix);
839
- if (`${prefixNum}` !== prefix) throw new Error();
840
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
841
- // @ts-ignore
842
- new URL(`http://[${address}]`);
843
- } catch {
844
- payload.issues.push({
845
- code: "invalid_format",
846
- format: "cidrv6",
847
- input: payload.value,
848
- inst,
849
- continue: !def.abort,
850
- });
851
- }
852
- };
853
- }
854
- );
855
-
856
- ////////////////////////////// ZodBase64 //////////////////////////////
857
- export function isValidBase64(data: string): boolean {
858
- if (data === "") return true;
859
- if (data.length % 4 !== 0) return false;
860
- try {
861
- // @ts-ignore
862
- atob(data);
863
- return true;
864
- } catch {
865
- return false;
866
- }
867
- }
868
-
869
- export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {}
870
- export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {}
871
-
872
- export interface $ZodBase64 extends $ZodType {
873
- _zod: $ZodBase64Internals;
874
- }
875
-
876
- export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$constructor(
877
- "$ZodBase64",
878
- (inst, def): void => {
879
- def.pattern ??= regexes.base64;
880
- $ZodStringFormat.init(inst, def);
881
-
882
- inst._zod.onattach.push((inst) => {
883
- inst._zod.bag.contentEncoding = "base64";
884
- });
885
-
886
- inst._zod.check = (payload) => {
887
- if (isValidBase64(payload.value)) return;
888
-
889
- payload.issues.push({
890
- code: "invalid_format",
891
- format: "base64",
892
- input: payload.value,
893
- inst,
894
- continue: !def.abort,
895
- });
896
- };
897
- }
898
- );
899
-
900
- ////////////////////////////// ZodBase64 //////////////////////////////
901
- export function isValidBase64URL(data: string): boolean {
902
- if (!regexes.base64url.test(data)) return false;
903
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
904
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
905
- return isValidBase64(padded);
906
- }
907
-
908
- export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {}
909
- export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {}
910
-
911
- export interface $ZodBase64URL extends $ZodType {
912
- _zod: $ZodBase64URLInternals;
913
- }
914
-
915
- export const $ZodBase64URL: core.$constructor<$ZodBase64URL> = /*@__PURE__*/ core.$constructor(
916
- "$ZodBase64URL",
917
- (inst, def): void => {
918
- def.pattern ??= regexes.base64url;
919
- $ZodStringFormat.init(inst, def);
920
-
921
- inst._zod.onattach.push((inst) => {
922
- inst._zod.bag.contentEncoding = "base64url";
923
- });
924
-
925
- inst._zod.check = (payload) => {
926
- if (isValidBase64URL(payload.value)) return;
927
-
928
- payload.issues.push({
929
- code: "invalid_format",
930
- format: "base64url",
931
- input: payload.value,
932
- inst,
933
- continue: !def.abort,
934
- });
935
- };
936
- }
937
- );
938
-
939
- ////////////////////////////// ZodE164 //////////////////////////////
940
-
941
- export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {}
942
- export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {}
943
-
944
- export interface $ZodE164 extends $ZodType {
945
- _zod: $ZodE164Internals;
946
- }
947
-
948
- export const $ZodE164: core.$constructor<$ZodE164> = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def): void => {
949
- def.pattern ??= regexes.e164;
950
- $ZodStringFormat.init(inst, def);
951
- });
952
-
953
- ////////////////////////////// ZodJWT //////////////////////////////
954
-
955
- export function isValidJWT(token: string, algorithm: util.JWTAlgorithm | null = null): boolean {
956
- try {
957
- const tokensParts = token.split(".");
958
- if (tokensParts.length !== 3) return false;
959
- const [header] = tokensParts;
960
- if (!header) return false;
961
- // @ts-ignore
962
- const parsedHeader = JSON.parse(atob(header));
963
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
964
- if (!parsedHeader.alg) return false;
965
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
966
- return true;
967
- } catch {
968
- return false;
969
- }
970
- }
971
-
972
- export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
973
- alg?: util.JWTAlgorithm | undefined;
974
- }
975
-
976
- export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
977
- def: $ZodJWTDef;
978
- }
979
-
980
- export interface $ZodJWT extends $ZodType {
981
- _zod: $ZodJWTInternals;
982
- }
983
-
984
- export const $ZodJWT: core.$constructor<$ZodJWT> = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def): void => {
985
- $ZodStringFormat.init(inst, def);
986
- inst._zod.check = (payload) => {
987
- if (isValidJWT(payload.value, def.alg)) return;
988
-
989
- payload.issues.push({
990
- code: "invalid_format",
991
- format: "jwt",
992
- input: payload.value,
993
- inst,
994
- continue: !def.abort,
995
- });
996
- };
997
- });
998
-
999
- ////////////////////////////// ZodCustomStringFormat //////////////////////////////
1000
-
1001
- export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
1002
- fn: (val: string) => unknown;
1003
- }
1004
-
1005
- export interface $ZodCustomStringFormatInternals<Format extends string = string>
1006
- extends $ZodStringFormatInternals<Format> {
1007
- def: $ZodCustomStringFormatDef<Format>;
1008
- }
1009
-
1010
- export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
1011
- _zod: $ZodCustomStringFormatInternals<Format>;
1012
- }
1013
-
1014
- export const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat> = /*@__PURE__*/ core.$constructor(
1015
- "$ZodCustomStringFormat",
1016
- (inst, def): void => {
1017
- $ZodStringFormat.init(inst, def);
1018
- inst._zod.check = (payload) => {
1019
- if (def.fn(payload.value)) return;
1020
-
1021
- payload.issues.push({
1022
- code: "invalid_format",
1023
- format: def.format,
1024
- input: payload.value,
1025
- inst,
1026
- continue: !def.abort,
1027
- });
1028
- };
1029
- }
1030
- );
1031
-
1032
- /////////////////////////////////////////
1033
- /////////////////////////////////////////
1034
- ////////// //////////
1035
- ////////// ZodNumber //////////
1036
- ////////// //////////
1037
- /////////////////////////////////////////
1038
- /////////////////////////////////////////
1039
-
1040
- export interface $ZodNumberDef extends $ZodTypeDef {
1041
- type: "number";
1042
- coerce?: boolean;
1043
- // checks: checks.$ZodCheck<number>[];
1044
- }
1045
-
1046
- export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
1047
- def: $ZodNumberDef;
1048
- /** @deprecated Internal API, use with caution (not deprecated) */
1049
- pattern: RegExp;
1050
- /** @deprecated Internal API, use with caution (not deprecated) */
1051
- isst: errors.$ZodIssueInvalidType;
1052
- bag: util.LoosePartial<{
1053
- minimum: number;
1054
- maximum: number;
1055
- exclusiveMinimum: number;
1056
- exclusiveMaximum: number;
1057
- format: string;
1058
- pattern: RegExp;
1059
- }>;
1060
- }
1061
-
1062
- export interface $ZodNumber<Input = unknown> extends $ZodType {
1063
- _zod: $ZodNumberInternals<Input>;
1064
- }
1065
-
1066
- export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
1067
- $ZodType.init(inst, def);
1068
- inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
1069
-
1070
- inst._zod.parse = (payload, _ctx) => {
1071
- if (def.coerce)
1072
- try {
1073
- payload.value = Number(payload.value);
1074
- } catch (_) {}
1075
- const input = payload.value;
1076
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
1077
- return payload;
1078
- }
1079
-
1080
- const received =
1081
- typeof input === "number"
1082
- ? Number.isNaN(input)
1083
- ? "NaN"
1084
- : !Number.isFinite(input)
1085
- ? "Infinity"
1086
- : undefined
1087
- : undefined;
1088
-
1089
- payload.issues.push({
1090
- expected: "number",
1091
- code: "invalid_type",
1092
-
1093
- input,
1094
- inst,
1095
- ...(received ? { received } : {}),
1096
- });
1097
- return payload;
1098
- };
1099
- });
1100
-
1101
- ///////////////////////////////////////////////
1102
- ////////// ZodNumberFormat //////////
1103
- ///////////////////////////////////////////////
1104
- export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {}
1105
-
1106
- export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
1107
- def: $ZodNumberFormatDef;
1108
- isst: errors.$ZodIssueInvalidType;
1109
- }
1110
-
1111
- export interface $ZodNumberFormat extends $ZodType {
1112
- _zod: $ZodNumberFormatInternals;
1113
- }
1114
-
1115
- export const $ZodNumberFormat: core.$constructor<$ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
1116
- "$ZodNumber",
1117
- (inst, def) => {
1118
- checks.$ZodCheckNumberFormat.init(inst, def);
1119
- $ZodNumber.init(inst, def); // no format checksp
1120
- }
1121
- );
1122
-
1123
- ///////////////////////////////////////////
1124
- ///////////////////////////////////////////
1125
- ////////// ///////////
1126
- ////////// $ZodBoolean //////////
1127
- ////////// ///////////
1128
- ///////////////////////////////////////////
1129
- ///////////////////////////////////////////
1130
-
1131
- export interface $ZodBooleanDef extends $ZodTypeDef {
1132
- type: "boolean";
1133
- coerce?: boolean;
1134
- checks?: checks.$ZodCheck<boolean>[];
1135
- }
1136
-
1137
- export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
1138
- pattern: RegExp;
1139
- def: $ZodBooleanDef;
1140
- isst: errors.$ZodIssueInvalidType;
1141
- }
1142
-
1143
- export interface $ZodBoolean<T = unknown> extends $ZodType {
1144
- _zod: $ZodBooleanInternals<T>;
1145
- }
1146
-
1147
- export const $ZodBoolean: core.$constructor<$ZodBoolean> = /*@__PURE__*/ core.$constructor(
1148
- "$ZodBoolean",
1149
- (inst, def) => {
1150
- $ZodType.init(inst, def);
1151
- inst._zod.pattern = regexes.boolean;
1152
-
1153
- inst._zod.parse = (payload, _ctx) => {
1154
- if (def.coerce)
1155
- try {
1156
- payload.value = Boolean(payload.value);
1157
- } catch (_) {}
1158
- const input = payload.value;
1159
- if (typeof input === "boolean") return payload;
1160
- payload.issues.push({
1161
- expected: "boolean",
1162
- code: "invalid_type",
1163
-
1164
- input,
1165
- inst,
1166
- });
1167
- return payload;
1168
- };
1169
- }
1170
- );
1171
-
1172
- //////////////////////////////////////////
1173
- //////////////////////////////////////////
1174
- ////////// //////////
1175
- ////////// $ZodBigInt //////////
1176
- ////////// //////////
1177
- //////////////////////////////////////////
1178
- //////////////////////////////////////////
1179
-
1180
- export interface $ZodBigIntDef extends $ZodTypeDef {
1181
- type: "bigint";
1182
- coerce?: boolean;
1183
- // checks: checks.$ZodCheck<bigint>[];
1184
- }
1185
-
1186
- export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
1187
- pattern: RegExp;
1188
- /** @internal Internal API, use with caution */
1189
- def: $ZodBigIntDef;
1190
- isst: errors.$ZodIssueInvalidType;
1191
- bag: util.LoosePartial<{
1192
- minimum: bigint;
1193
- maximum: bigint;
1194
- format: string;
1195
- }>;
1196
- }
1197
-
1198
- export interface $ZodBigInt<T = unknown> extends $ZodType {
1199
- _zod: $ZodBigIntInternals<T>;
1200
- }
1201
-
1202
- export const $ZodBigInt: core.$constructor<$ZodBigInt> = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
1203
- $ZodType.init(inst, def);
1204
- inst._zod.pattern = regexes.bigint;
1205
-
1206
- inst._zod.parse = (payload, _ctx) => {
1207
- if (def.coerce)
1208
- try {
1209
- payload.value = BigInt(payload.value);
1210
- } catch (_) {}
1211
-
1212
- if (typeof payload.value === "bigint") return payload;
1213
- payload.issues.push({
1214
- expected: "bigint",
1215
- code: "invalid_type",
1216
-
1217
- input: payload.value,
1218
- inst,
1219
- });
1220
- return payload;
1221
- };
1222
- });
1223
-
1224
- ///////////////////////////////////////////////
1225
- ////////// ZodBigIntFormat //////////
1226
- ///////////////////////////////////////////////
1227
- export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
1228
- check: "bigint_format";
1229
- }
1230
-
1231
- export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
1232
- def: $ZodBigIntFormatDef;
1233
- }
1234
-
1235
- export interface $ZodBigIntFormat extends $ZodType {
1236
- _zod: $ZodBigIntFormatInternals;
1237
- }
1238
-
1239
- export const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
1240
- "$ZodBigInt",
1241
- (inst, def) => {
1242
- checks.$ZodCheckBigIntFormat.init(inst, def);
1243
- $ZodBigInt.init(inst, def); // no format checks
1244
- }
1245
- );
1246
-
1247
- ////////////////////////////////////////////
1248
- ////////////////////////////////////////////
1249
- ////////// //////////
1250
- ////////// $ZodSymbol //////////
1251
- ////////// //////////
1252
- ////////////////////////////////////////////
1253
- ////////////////////////////////////////////
1254
- export interface $ZodSymbolDef extends $ZodTypeDef {
1255
- type: "symbol";
1256
- }
1257
-
1258
- export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
1259
- def: $ZodSymbolDef;
1260
- isst: errors.$ZodIssueInvalidType;
1261
- }
1262
-
1263
- export interface $ZodSymbol extends $ZodType {
1264
- _zod: $ZodSymbolInternals;
1265
- }
1266
-
1267
- export const $ZodSymbol: core.$constructor<$ZodSymbol> = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
1268
- $ZodType.init(inst, def);
1269
-
1270
- inst._zod.parse = (payload, _ctx) => {
1271
- const input = payload.value;
1272
- if (typeof input === "symbol") return payload;
1273
- payload.issues.push({
1274
- expected: "symbol",
1275
- code: "invalid_type",
1276
-
1277
- input,
1278
- inst,
1279
- });
1280
- return payload;
1281
- };
1282
- });
1283
-
1284
- ////////////////////////////////////////////
1285
- ////////////////////////////////////////////
1286
- ////////// //////////
1287
- ////////// $ZodUndefined //////////
1288
- ////////// //////////
1289
- ////////////////////////////////////////////
1290
- ////////////////////////////////////////////
1291
- export interface $ZodUndefinedDef extends $ZodTypeDef {
1292
- type: "undefined";
1293
- }
1294
-
1295
- export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
1296
- pattern: RegExp;
1297
- def: $ZodUndefinedDef;
1298
- values: util.PrimitiveSet;
1299
- isst: errors.$ZodIssueInvalidType;
1300
- }
1301
-
1302
- export interface $ZodUndefined extends $ZodType {
1303
- _zod: $ZodUndefinedInternals;
1304
- }
1305
-
1306
- export const $ZodUndefined: core.$constructor<$ZodUndefined> = /*@__PURE__*/ core.$constructor(
1307
- "$ZodUndefined",
1308
- (inst, def) => {
1309
- $ZodType.init(inst, def);
1310
- inst._zod.pattern = regexes.undefined;
1311
- inst._zod.values = new Set([undefined]);
1312
- inst._zod.optin = "optional";
1313
- inst._zod.optout = "optional";
1314
-
1315
- inst._zod.parse = (payload, _ctx) => {
1316
- const input = payload.value;
1317
- if (typeof input === "undefined") return payload;
1318
- payload.issues.push({
1319
- expected: "undefined",
1320
- code: "invalid_type",
1321
-
1322
- input,
1323
- inst,
1324
- });
1325
- return payload;
1326
- };
1327
- }
1328
- );
1329
-
1330
- ///////////////////////////////////////
1331
- ///////////////////////////////////////
1332
- ////////// //////////
1333
- ////////// $ZodNull /////////
1334
- ////////// //////////
1335
- ///////////////////////////////////////
1336
- ///////////////////////////////////////
1337
-
1338
- export interface $ZodNullDef extends $ZodTypeDef {
1339
- type: "null";
1340
- }
1341
-
1342
- export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
1343
- pattern: RegExp;
1344
- def: $ZodNullDef;
1345
- values: util.PrimitiveSet;
1346
- isst: errors.$ZodIssueInvalidType;
1347
- }
1348
-
1349
- export interface $ZodNull extends $ZodType {
1350
- _zod: $ZodNullInternals;
1351
- }
1352
-
1353
- export const $ZodNull: core.$constructor<$ZodNull> = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
1354
- $ZodType.init(inst, def);
1355
- inst._zod.pattern = regexes.null;
1356
- inst._zod.values = new Set([null]);
1357
-
1358
- inst._zod.parse = (payload, _ctx) => {
1359
- const input = payload.value;
1360
- if (input === null) return payload;
1361
- payload.issues.push({
1362
- expected: "null",
1363
- code: "invalid_type",
1364
-
1365
- input,
1366
- inst,
1367
- });
1368
- return payload;
1369
- };
1370
- });
1371
-
1372
- //////////////////////////////////////
1373
- //////////////////////////////////////
1374
- ////////// //////////
1375
- ////////// $ZodAny //////////
1376
- ////////// //////////
1377
- //////////////////////////////////////
1378
- //////////////////////////////////////
1379
-
1380
- export interface $ZodAnyDef extends $ZodTypeDef {
1381
- type: "any";
1382
- }
1383
-
1384
- export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
1385
- def: $ZodAnyDef;
1386
- isst: never;
1387
- }
1388
-
1389
- export interface $ZodAny extends $ZodType {
1390
- _zod: $ZodAnyInternals;
1391
- }
1392
-
1393
- export const $ZodAny: core.$constructor<$ZodAny> = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
1394
- $ZodType.init(inst, def);
1395
-
1396
- inst._zod.parse = (payload) => payload;
1397
- });
1398
-
1399
- //////////////////////////////////////////
1400
- //////////////////////////////////////////
1401
- ////////// //////////
1402
- ////////// $ZodUnknown //////////
1403
- ////////// //////////
1404
- //////////////////////////////////////////
1405
- //////////////////////////////////////////
1406
-
1407
- export interface $ZodUnknownDef extends $ZodTypeDef {
1408
- type: "unknown";
1409
- }
1410
-
1411
- export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
1412
- def: $ZodUnknownDef;
1413
- isst: never;
1414
- }
1415
-
1416
- export interface $ZodUnknown extends $ZodType {
1417
- _zod: $ZodUnknownInternals;
1418
- }
1419
-
1420
- export const $ZodUnknown: core.$constructor<$ZodUnknown> = /*@__PURE__*/ core.$constructor(
1421
- "$ZodUnknown",
1422
- (inst, def) => {
1423
- $ZodType.init(inst, def);
1424
-
1425
- inst._zod.parse = (payload) => payload;
1426
- }
1427
- );
1428
-
1429
- /////////////////////////////////////////
1430
- /////////////////////////////////////////
1431
- ////////// //////////
1432
- ////////// $ZodNever //////////
1433
- ////////// //////////
1434
- /////////////////////////////////////////
1435
- /////////////////////////////////////////
1436
-
1437
- export interface $ZodNeverDef extends $ZodTypeDef {
1438
- type: "never";
1439
- }
1440
-
1441
- export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
1442
- def: $ZodNeverDef;
1443
- isst: errors.$ZodIssueInvalidType;
1444
- }
1445
-
1446
- export interface $ZodNever extends $ZodType {
1447
- _zod: $ZodNeverInternals;
1448
- }
1449
-
1450
- export const $ZodNever: core.$constructor<$ZodNever> = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
1451
- $ZodType.init(inst, def);
1452
- inst._zod.parse = (payload, _ctx) => {
1453
- payload.issues.push({
1454
- expected: "never",
1455
- code: "invalid_type",
1456
-
1457
- input: payload.value,
1458
- inst,
1459
- });
1460
- return payload;
1461
- };
1462
- });
1463
-
1464
- ////////////////////////////////////////
1465
- ////////////////////////////////////////
1466
- ////////// //////////
1467
- ////////// $ZodVoid //////////
1468
- ////////// //////////
1469
- ////////////////////////////////////////
1470
- ////////////////////////////////////////
1471
-
1472
- export interface $ZodVoidDef extends $ZodTypeDef {
1473
- type: "void";
1474
- }
1475
-
1476
- export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
1477
- def: $ZodVoidDef;
1478
- isst: errors.$ZodIssueInvalidType;
1479
- }
1480
-
1481
- export interface $ZodVoid extends $ZodType {
1482
- _zod: $ZodVoidInternals;
1483
- }
1484
-
1485
- export const $ZodVoid: core.$constructor<$ZodVoid> = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
1486
- $ZodType.init(inst, def);
1487
-
1488
- inst._zod.parse = (payload, _ctx) => {
1489
- const input = payload.value;
1490
- if (typeof input === "undefined") return payload;
1491
- payload.issues.push({
1492
- expected: "void",
1493
- code: "invalid_type",
1494
-
1495
- input,
1496
- inst,
1497
- });
1498
- return payload;
1499
- };
1500
- });
1501
-
1502
- ///////////////////////////////////////
1503
- ///////////////////////////////////////
1504
- ////////// ////////
1505
- ////////// $ZodDate ////////
1506
- ////////// ////////
1507
- ///////////////////////////////////////
1508
- ///////////////////////////////////////
1509
- export interface $ZodDateDef extends $ZodTypeDef {
1510
- type: "date";
1511
- coerce?: boolean;
1512
- }
1513
-
1514
- export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
1515
- def: $ZodDateDef;
1516
- isst: errors.$ZodIssueInvalidType; // | errors.$ZodIssueInvalidDate;
1517
- bag: util.LoosePartial<{
1518
- minimum: Date;
1519
- maximum: Date;
1520
- format: string;
1521
- }>;
1522
- }
1523
-
1524
- export interface $ZodDate<T = unknown> extends $ZodType {
1525
- _zod: $ZodDateInternals<T>;
1526
- }
1527
-
1528
- export const $ZodDate: core.$constructor<$ZodDate> = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
1529
- $ZodType.init(inst, def);
1530
-
1531
- inst._zod.parse = (payload, _ctx) => {
1532
- if (def.coerce) {
1533
- try {
1534
- payload.value = new Date(payload.value as string | number | Date);
1535
- } catch (_err: any) {}
1536
- }
1537
- const input = payload.value;
1538
-
1539
- const isDate = input instanceof Date;
1540
- const isValidDate = isDate && !Number.isNaN(input.getTime());
1541
- if (isValidDate) return payload;
1542
- payload.issues.push({
1543
- expected: "date",
1544
- code: "invalid_type",
1545
-
1546
- input,
1547
- ...(isDate ? { received: "Invalid Date" } : {}),
1548
- inst,
1549
- });
1550
-
1551
- return payload;
1552
- };
1553
- });
1554
-
1555
- /////////////////////////////////////////
1556
- /////////////////////////////////////////
1557
- ////////// //////////
1558
- ////////// $ZodArray //////////
1559
- ////////// //////////
1560
- /////////////////////////////////////////
1561
- /////////////////////////////////////////
1562
-
1563
- export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
1564
- type: "array";
1565
- element: T;
1566
- }
1567
-
1568
- export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
1569
- //$ZodTypeInternals<core.output<T>[], core.input<T>[]> {
1570
- def: $ZodArrayDef<T>;
1571
- isst: errors.$ZodIssueInvalidType;
1572
- output: core.output<T>[];
1573
- input: core.input<T>[];
1574
- }
1575
-
1576
- export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
1577
-
1578
- function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
1579
- if (result.issues.length) {
1580
- final.issues.push(...util.prefixIssues(index, result.issues));
1581
- }
1582
- final.value[index] = result.value;
1583
- }
1584
-
1585
- export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
1586
- $ZodType.init(inst, def);
1587
-
1588
- inst._zod.parse = (payload, ctx) => {
1589
- const input = payload.value;
1590
-
1591
- if (!Array.isArray(input)) {
1592
- payload.issues.push({
1593
- expected: "array",
1594
- code: "invalid_type",
1595
-
1596
- input,
1597
- inst,
1598
- });
1599
- return payload;
1600
- }
1601
-
1602
- payload.value = Array(input.length);
1603
- const proms: Promise<any>[] = [];
1604
- for (let i = 0; i < input.length; i++) {
1605
- const item = input[i];
1606
- const result = def.element._zod.run(
1607
- {
1608
- value: item,
1609
- issues: [],
1610
- },
1611
- ctx
1612
- );
1613
-
1614
- if (result instanceof Promise) {
1615
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1616
- } else {
1617
- handleArrayResult(result, payload, i);
1618
- }
1619
- }
1620
-
1621
- if (proms.length) {
1622
- return Promise.all(proms).then(() => payload);
1623
- }
1624
-
1625
- return payload; //handleArrayResultsAsync(parseResults, final);
1626
- };
1627
- });
1628
-
1629
- //////////////////////////////////////////
1630
- //////////////////////////////////////////
1631
- ////////// //////////
1632
- ////////// $ZodObject //////////
1633
- ////////// //////////
1634
- //////////////////////////////////////////
1635
- //////////////////////////////////////////
1636
-
1637
- type OptionalOutSchema = { _zod: { optout: "optional" } };
1638
- type OptionalInSchema = { _zod: { optin: "optional" } };
1639
-
1640
- export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1641
- ? util.IsAny<T[keyof T]> extends true
1642
- ? Record<string, unknown>
1643
- : Record<string, core.output<T[keyof T]>>
1644
- : keyof (T & Extra) extends never
1645
- ? Record<string, never>
1646
- : util.Prettify<
1647
- {
1648
- -readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
1649
- } & {
1650
- -readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
1651
- } & Extra
1652
- >;
1653
-
1654
- // experimental
1655
- // export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = keyof (T &
1656
- // Extra) extends never
1657
- // ? Record<string, never>
1658
- // : string extends keyof T
1659
- // ? util.Prettify<
1660
- // {
1661
- // [k: string]: util.IsAny<T[string]["_zod"]["output"]> extends true ? unknown : T[string]["_zod"]["output"];
1662
- // } & $InferObjectOutputNoIndex<util.OmitIndexSignature<T>, Extra>
1663
- // >
1664
- // : util.Prettify<$InferObjectOutputNoIndex<T, Extra>>;
1665
-
1666
- // export type $InferObjectOutputNoIndex<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = {
1667
- // [k in keyof T as string extends k
1668
- // ? never
1669
- // : k extends string
1670
- // ? T[k] extends OptionalOutSchema
1671
- // ? never
1672
- // : k
1673
- // : never]: T[k]["_zod"]["output"];
1674
- // } & {
1675
- // [k in keyof T as string extends k
1676
- // ? never
1677
- // : k extends string
1678
- // ? T[k] extends OptionalOutSchema
1679
- // ? k
1680
- // : never
1681
- // : never]?: T[k]["_zod"]["output"];
1682
- // } & Extra;
1683
-
1684
- export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1685
- ? util.IsAny<T[keyof T]> extends true
1686
- ? Record<string, unknown>
1687
- : Record<string, core.input<T[keyof T]>>
1688
- : keyof (T & Extra) extends never
1689
- ? Record<string, never>
1690
- : util.Prettify<
1691
- {
1692
- -readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
1693
- } & {
1694
- -readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
1695
- } & Extra
1696
- >;
1697
-
1698
- function handlePropertyResult(result: ParsePayload, final: ParsePayload, key: PropertyKey, input: any) {
1699
- if (result.issues.length) {
1700
- final.issues.push(...util.prefixIssues(key, result.issues));
1701
- }
1702
-
1703
- if (result.value === undefined) {
1704
- if (key in input) {
1705
- (final.value as any)[key] = undefined;
1706
- }
1707
- } else {
1708
- (final.value as any)[key] = result.value;
1709
- }
1710
- }
1711
-
1712
- export type $ZodObjectConfig = { out: Record<string, unknown>; in: Record<string, unknown> };
1713
-
1714
- export type $loose = {
1715
- out: Record<string, unknown>;
1716
- in: Record<string, unknown>;
1717
- };
1718
- export type $strict = {
1719
- out: {};
1720
- in: {};
1721
- };
1722
- export type $strip = {
1723
- out: {};
1724
- in: {};
1725
- };
1726
-
1727
- export type $catchall<T extends SomeType> = {
1728
- out: { [k: string]: core.output<T> };
1729
- in: { [k: string]: core.input<T> };
1730
- };
1731
-
1732
- export type $ZodShape = Readonly<{ [k: string]: $ZodType }>;
1733
-
1734
- export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
1735
- type: "object";
1736
- shape: Shape;
1737
- catchall?: $ZodType | undefined;
1738
- }
1739
-
1740
- export interface $ZodObjectInternals<
1741
- /** @ts-ignore Cast variance */
1742
- out Shape extends $ZodShape = $ZodShape,
1743
- out Config extends $ZodObjectConfig = $ZodObjectConfig,
1744
- > extends _$ZodTypeInternals {
1745
- def: $ZodObjectDef<Shape>;
1746
- config: Config;
1747
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
1748
- propValues: util.PropValues;
1749
- output: $InferObjectOutput<Shape, Config["out"]>;
1750
- input: $InferObjectInput<Shape, Config["in"]>;
1751
- optin?: "optional" | undefined;
1752
- optout?: "optional" | undefined;
1753
- }
1754
- export type $ZodLooseShape = Record<string, any>;
1755
-
1756
- export interface $ZodObject<
1757
- /** @ts-ignore Cast variance */
1758
- out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>,
1759
- out Params extends $ZodObjectConfig = $ZodObjectConfig,
1760
- > extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {
1761
- "~standard": $ZodStandardSchema<this>;
1762
- }
1763
-
1764
- function normalizeDef(def: $ZodObjectDef) {
1765
- const keys = Object.keys(def.shape);
1766
- for (const k of keys) {
1767
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1768
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1769
- }
1770
- }
1771
- const okeys = util.optionalKeys(def.shape);
1772
-
1773
- return {
1774
- ...def,
1775
- keys,
1776
- keySet: new Set(keys),
1777
- numKeys: keys.length,
1778
- optionalKeys: new Set(okeys),
1779
- };
1780
- }
1781
-
1782
- function handleCatchall(
1783
- proms: Promise<any>[],
1784
- input: any,
1785
- payload: ParsePayload,
1786
- ctx: ParseContext,
1787
- def: ReturnType<typeof normalizeDef>,
1788
- inst: $ZodObject
1789
- ) {
1790
- const unrecognized: string[] = [];
1791
- // iterate over input keys
1792
- const keySet = def.keySet;
1793
- const _catchall = def.catchall!._zod;
1794
- const t = _catchall.def.type;
1795
- for (const key of Object.keys(input)) {
1796
- if (keySet.has(key)) continue;
1797
- if (t === "never") {
1798
- unrecognized.push(key);
1799
- continue;
1800
- }
1801
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1802
-
1803
- if (r instanceof Promise) {
1804
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1805
- } else {
1806
- handlePropertyResult(r, payload, key, input);
1807
- }
1808
- }
1809
-
1810
- if (unrecognized.length) {
1811
- payload.issues.push({
1812
- code: "unrecognized_keys",
1813
- keys: unrecognized,
1814
- input,
1815
- inst,
1816
- });
1817
- }
1818
-
1819
- if (!proms.length) return payload;
1820
- return Promise.all(proms).then(() => {
1821
- return payload;
1822
- });
1823
- }
1824
-
1825
- export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
1826
- // requires cast because technically $ZodObject doesn't extend
1827
- $ZodType.init(inst, def);
1828
- // const sh = def.shape;
1829
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1830
- if (!desc?.get) {
1831
- const sh = def.shape;
1832
- Object.defineProperty(def, "shape", {
1833
- get: () => {
1834
- const newSh = { ...sh };
1835
- Object.defineProperty(def, "shape", {
1836
- value: newSh,
1837
- });
1838
-
1839
- return newSh;
1840
- },
1841
- });
1842
- }
1843
-
1844
- const _normalized = util.cached(() => normalizeDef(def));
1845
-
1846
- util.defineLazy(inst._zod, "propValues", () => {
1847
- const shape = def.shape;
1848
- const propValues: util.PropValues = {};
1849
- for (const key in shape) {
1850
- const field = shape[key]!._zod;
1851
- if (field.values) {
1852
- propValues[key] ??= new Set();
1853
- for (const v of field.values) propValues[key].add(v);
1854
- }
1855
- }
1856
- return propValues;
1857
- });
1858
-
1859
- const isObject = util.isObject;
1860
- const catchall = def.catchall;
1861
-
1862
- let value!: typeof _normalized.value;
1863
-
1864
- inst._zod.parse = (payload, ctx) => {
1865
- value ??= _normalized.value;
1866
- const input = payload.value;
1867
- if (!isObject(input)) {
1868
- payload.issues.push({
1869
- expected: "object",
1870
- code: "invalid_type",
1871
- input,
1872
- inst,
1873
- });
1874
- return payload;
1875
- }
1876
-
1877
- payload.value = {};
1878
-
1879
- const proms: Promise<any>[] = [];
1880
- const shape = value.shape;
1881
-
1882
- for (const key of value.keys) {
1883
- const el = shape[key]!;
1884
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1885
- if (r instanceof Promise) {
1886
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input)));
1887
- } else {
1888
- handlePropertyResult(r, payload, key, input);
1889
- }
1890
- }
1891
-
1892
- if (!catchall) {
1893
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1894
- }
1895
-
1896
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1897
- };
1898
- });
1899
-
1900
- export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor(
1901
- "$ZodObjectJIT",
1902
- (inst, def) => {
1903
- // requires cast because technically $ZodObject doesn't extend
1904
- $ZodObject.init(inst, def);
1905
-
1906
- const superParse = inst._zod.parse;
1907
- const _normalized = util.cached(() => normalizeDef(def));
1908
-
1909
- const generateFastpass = (shape: any) => {
1910
- const doc = new Doc(["shape", "payload", "ctx"]);
1911
- const normalized = _normalized.value;
1912
-
1913
- const parseStr = (key: string) => {
1914
- const k = util.esc(key);
1915
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1916
- };
1917
-
1918
- doc.write(`const input = payload.value;`);
1919
-
1920
- const ids: any = Object.create(null);
1921
- let counter = 0;
1922
- for (const key of normalized.keys) {
1923
- ids[key] = `key_${counter++}`;
1924
- }
1925
-
1926
- // A: preserve key order {
1927
- doc.write(`const newResult = {};`);
1928
- for (const key of normalized.keys) {
1929
- const id = ids[key];
1930
- const k = util.esc(key);
1931
- doc.write(`const ${id} = ${parseStr(key)};`);
1932
- doc.write(`
1933
- if (${id}.issues.length) {
1934
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1935
- ...iss,
1936
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1937
- })));
1938
- }
1939
-
1940
-
1941
- if (${id}.value === undefined) {
1942
- if (${k} in input) {
1943
- newResult[${k}] = undefined;
1944
- }
1945
- } else {
1946
- newResult[${k}] = ${id}.value;
1947
- }
1948
-
1949
- `);
1950
- }
1951
-
1952
- doc.write(`payload.value = newResult;`);
1953
- doc.write(`return payload;`);
1954
- const fn = doc.compile();
1955
- return (payload: any, ctx: any) => fn(shape, payload, ctx);
1956
- };
1957
-
1958
- let fastpass!: ReturnType<typeof generateFastpass>;
1959
-
1960
- const isObject = util.isObject;
1961
- const jit = !core.globalConfig.jitless;
1962
- const allowsEval = util.allowsEval;
1963
-
1964
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
1965
- const catchall = def.catchall;
1966
-
1967
- let value!: typeof _normalized.value;
1968
-
1969
- inst._zod.parse = (payload, ctx) => {
1970
- value ??= _normalized.value;
1971
- const input = payload.value;
1972
- if (!isObject(input)) {
1973
- payload.issues.push({
1974
- expected: "object",
1975
- code: "invalid_type",
1976
- input,
1977
- inst,
1978
- });
1979
- return payload;
1980
- }
1981
-
1982
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1983
- // always synchronous
1984
- if (!fastpass) fastpass = generateFastpass(def.shape);
1985
- payload = fastpass(payload, ctx);
1986
-
1987
- if (!catchall) return payload;
1988
- return handleCatchall([], input, payload, ctx, value, inst);
1989
- }
1990
-
1991
- return superParse(payload, ctx);
1992
- };
1993
- }
1994
- );
1995
-
1996
- /////////////////////////////////////////
1997
- /////////////////////////////////////////
1998
- ////////// ///////////
1999
- ////////// $ZodUnion //////////
2000
- ////////// ///////////
2001
- /////////////////////////////////////////
2002
- /////////////////////////////////////////
2003
- // use generic to distribute union types
2004
- export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
2005
- export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
2006
- export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
2007
- type: "union";
2008
- options: Options;
2009
- }
2010
-
2011
- type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
2012
- type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
2013
-
2014
- export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
2015
- def: $ZodUnionDef<T>;
2016
- isst: errors.$ZodIssueInvalidUnion;
2017
- pattern: T[number]["_zod"]["pattern"];
2018
- values: T[number]["_zod"]["values"]; //GetValues<T[number]>;
2019
- output: $InferUnionOutput<T[number]>;
2020
- input: $InferUnionInput<T[number]>;
2021
- // if any element in the union is optional, then the union is optional
2022
- optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
2023
- optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
2024
- }
2025
-
2026
- export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]>
2027
- extends $ZodType<any, any, $ZodUnionInternals<T>> {
2028
- _zod: $ZodUnionInternals<T>;
2029
- }
2030
-
2031
- function handleUnionResults(results: ParsePayload[], final: ParsePayload, inst: $ZodUnion, ctx?: ParseContext) {
2032
- for (const result of results) {
2033
- if (result.issues.length === 0) {
2034
- final.value = result.value;
2035
- return final;
2036
- }
2037
- }
2038
-
2039
- const nonaborted = results.filter((r) => !util.aborted(r));
2040
- if (nonaborted.length === 1) {
2041
- final.value = nonaborted[0].value;
2042
- return nonaborted[0];
2043
- }
2044
-
2045
- final.issues.push({
2046
- code: "invalid_union",
2047
-
2048
- input: final.value,
2049
- inst,
2050
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
2051
- });
2052
-
2053
- return final;
2054
- }
2055
-
2056
- export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
2057
- $ZodType.init(inst, def);
2058
-
2059
- util.defineLazy(inst._zod, "optin", () =>
2060
- def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined
2061
- );
2062
-
2063
- util.defineLazy(inst._zod, "optout", () =>
2064
- def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
2065
- );
2066
-
2067
- util.defineLazy(inst._zod, "values", () => {
2068
- if (def.options.every((o) => o._zod.values)) {
2069
- return new Set<util.Primitive>(def.options.flatMap((option) => Array.from(option._zod.values!)));
2070
- }
2071
- return undefined;
2072
- });
2073
-
2074
- util.defineLazy(inst._zod, "pattern", () => {
2075
- if (def.options.every((o) => o._zod.pattern)) {
2076
- const patterns = def.options.map((o) => o._zod.pattern);
2077
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p!.source)).join("|")})$`);
2078
- }
2079
- return undefined;
2080
- });
2081
-
2082
- const single = def.options.length === 1;
2083
- const first = def.options[0]._zod.run;
2084
-
2085
- inst._zod.parse = (payload, ctx) => {
2086
- if (single) {
2087
- return first(payload, ctx);
2088
- }
2089
- let async = false;
2090
-
2091
- const results: util.MaybeAsync<ParsePayload>[] = [];
2092
- for (const option of def.options) {
2093
- const result = option._zod.run(
2094
- {
2095
- value: payload.value,
2096
- issues: [],
2097
- },
2098
- ctx
2099
- );
2100
- if (result instanceof Promise) {
2101
- results.push(result);
2102
- async = true;
2103
- } else {
2104
- if (result.issues.length === 0) return result;
2105
- results.push(result);
2106
- }
2107
- }
2108
-
2109
- if (!async) return handleUnionResults(results as ParsePayload[], payload, inst, ctx);
2110
- return Promise.all(results).then((results) => {
2111
- return handleUnionResults(results as ParsePayload[], payload, inst, ctx);
2112
- });
2113
- };
2114
- });
2115
-
2116
- //////////////////////////////////////////////////////
2117
- //////////////////////////////////////////////////////
2118
- ////////// //////////
2119
- ////////// $ZodDiscriminatedUnion //////////
2120
- ////////// //////////
2121
- //////////////////////////////////////////////////////
2122
- //////////////////////////////////////////////////////
2123
-
2124
- export interface $ZodDiscriminatedUnionDef<
2125
- Options extends readonly SomeType[] = readonly $ZodType[],
2126
- Disc extends string = string,
2127
- > extends $ZodUnionDef<Options> {
2128
- discriminator: Disc;
2129
- unionFallback?: boolean;
2130
- }
2131
-
2132
- export interface $ZodDiscriminatedUnionInternals<
2133
- Options extends readonly SomeType[] = readonly $ZodType[],
2134
- Disc extends string = string,
2135
- > extends $ZodUnionInternals<Options> {
2136
- def: $ZodDiscriminatedUnionDef<Options, Disc>;
2137
- propValues: util.PropValues;
2138
- }
2139
-
2140
- export interface $ZodDiscriminatedUnion<
2141
- Options extends readonly SomeType[] = readonly $ZodType[],
2142
- Disc extends string = string,
2143
- > extends $ZodType {
2144
- _zod: $ZodDiscriminatedUnionInternals<Options, Disc>;
2145
- }
2146
-
2147
- export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2148
- /*@__PURE__*/
2149
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
2150
- $ZodUnion.init(inst, def);
2151
-
2152
- const _super = inst._zod.parse;
2153
- util.defineLazy(inst._zod, "propValues", () => {
2154
- const propValues: util.PropValues = {};
2155
- for (const option of def.options) {
2156
- const pv = option._zod.propValues;
2157
- if (!pv || Object.keys(pv).length === 0)
2158
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2159
- for (const [k, v] of Object.entries(pv!)) {
2160
- if (!propValues[k]) propValues[k] = new Set();
2161
- for (const val of v) {
2162
- propValues[k].add(val);
2163
- }
2164
- }
2165
- }
2166
- return propValues;
2167
- });
2168
-
2169
- const disc = util.cached(() => {
2170
- const opts = def.options as $ZodTypeDiscriminable[];
2171
- const map: Map<util.Primitive, $ZodType> = new Map();
2172
- for (const o of opts) {
2173
- const values = o._zod.propValues?.[def.discriminator];
2174
- if (!values || values.size === 0)
2175
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
2176
- for (const v of values) {
2177
- if (map.has(v)) {
2178
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
2179
- }
2180
- map.set(v, o);
2181
- }
2182
- }
2183
- return map;
2184
- });
2185
-
2186
- inst._zod.parse = (payload, ctx) => {
2187
- const input = payload.value;
2188
- if (!util.isObject(input)) {
2189
- payload.issues.push({
2190
- code: "invalid_type",
2191
-
2192
- expected: "object",
2193
- input,
2194
- inst,
2195
- });
2196
- return payload;
2197
- }
2198
-
2199
- const opt = disc.value.get(input?.[def.discriminator] as any);
2200
- if (opt) {
2201
- return opt._zod.run(payload, ctx) as any;
2202
- }
2203
-
2204
- if (def.unionFallback) {
2205
- return _super(payload, ctx);
2206
- }
2207
-
2208
- // no matching discriminator
2209
- payload.issues.push({
2210
- code: "invalid_union",
2211
-
2212
- errors: [],
2213
- note: "No matching discriminator",
2214
- discriminator: def.discriminator,
2215
- input,
2216
- path: [def.discriminator],
2217
- inst,
2218
- });
2219
-
2220
- return payload;
2221
- };
2222
- });
2223
-
2224
- ////////////////////////////////////////////////
2225
- ////////////////////////////////////////////////
2226
- ////////// //////////
2227
- ////////// $ZodIntersection //////////
2228
- ////////// //////////
2229
- ////////////////////////////////////////////////
2230
- ////////////////////////////////////////////////
2231
-
2232
- export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType>
2233
- extends $ZodTypeDef {
2234
- type: "intersection";
2235
- left: Left;
2236
- right: Right;
2237
- }
2238
-
2239
- export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
2240
- extends _$ZodTypeInternals {
2241
- // $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>>
2242
- def: $ZodIntersectionDef<A, B>;
2243
- isst: never;
2244
- optin: A["_zod"]["optin"] | B["_zod"]["optin"];
2245
- optout: A["_zod"]["optout"] | B["_zod"]["optout"];
2246
- output: core.output<A> & core.output<B>;
2247
- input: core.input<A> & core.input<B>;
2248
- }
2249
-
2250
- export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
2251
- _zod: $ZodIntersectionInternals<A, B>;
2252
- }
2253
-
2254
- export const $ZodIntersection: core.$constructor<$ZodIntersection> = /*@__PURE__*/ core.$constructor(
2255
- "$ZodIntersection",
2256
- (inst, def) => {
2257
- $ZodType.init(inst, def);
2258
-
2259
- inst._zod.parse = (payload, ctx) => {
2260
- const input = payload.value;
2261
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
2262
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
2263
- const async = left instanceof Promise || right instanceof Promise;
2264
-
2265
- if (async) {
2266
- return Promise.all([left, right]).then(([left, right]) => {
2267
- return handleIntersectionResults(payload, left, right);
2268
- });
2269
- }
2270
-
2271
- return handleIntersectionResults(payload, left, right);
2272
- };
2273
- }
2274
- );
2275
-
2276
- function mergeValues(
2277
- a: any,
2278
- b: any
2279
- ): { valid: true; data: any } | { valid: false; mergeErrorPath: (string | number)[] } {
2280
- // const aType = parse.t(a);
2281
- // const bType = parse.t(b);
2282
-
2283
- if (a === b) {
2284
- return { valid: true, data: a };
2285
- }
2286
- if (a instanceof Date && b instanceof Date && +a === +b) {
2287
- return { valid: true, data: a };
2288
- }
2289
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
2290
- const bKeys = Object.keys(b);
2291
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2292
-
2293
- const newObj: any = { ...a, ...b };
2294
- for (const key of sharedKeys) {
2295
- const sharedValue = mergeValues(a[key], b[key]);
2296
- if (!sharedValue.valid) {
2297
- return {
2298
- valid: false,
2299
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
2300
- };
2301
- }
2302
- newObj[key] = sharedValue.data;
2303
- }
2304
-
2305
- return { valid: true, data: newObj };
2306
- }
2307
- if (Array.isArray(a) && Array.isArray(b)) {
2308
- if (a.length !== b.length) {
2309
- return { valid: false, mergeErrorPath: [] };
2310
- }
2311
-
2312
- const newArray: unknown[] = [];
2313
- for (let index = 0; index < a.length; index++) {
2314
- const itemA = a[index];
2315
- const itemB = b[index];
2316
- const sharedValue = mergeValues(itemA, itemB);
2317
-
2318
- if (!sharedValue.valid) {
2319
- return {
2320
- valid: false,
2321
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
2322
- };
2323
- }
2324
-
2325
- newArray.push(sharedValue.data);
2326
- }
2327
-
2328
- return { valid: true, data: newArray };
2329
- }
2330
-
2331
- return { valid: false, mergeErrorPath: [] };
2332
- }
2333
-
2334
- function handleIntersectionResults(result: ParsePayload, left: ParsePayload, right: ParsePayload): ParsePayload {
2335
- if (left.issues.length) {
2336
- result.issues.push(...left.issues);
2337
- }
2338
- if (right.issues.length) {
2339
- result.issues.push(...right.issues);
2340
- }
2341
- if (util.aborted(result)) return result;
2342
-
2343
- const merged = mergeValues(left.value, right.value);
2344
-
2345
- if (!merged.valid) {
2346
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
2347
- }
2348
-
2349
- result.value = merged.data;
2350
- return result;
2351
- }
2352
-
2353
- /////////////////////////////////////////
2354
- /////////////////////////////////////////
2355
- ////////// //////////
2356
- ////////// $ZodTuple //////////
2357
- ////////// //////////
2358
- /////////////////////////////////////////
2359
- /////////////////////////////////////////
2360
-
2361
- export interface $ZodTupleDef<
2362
- T extends util.TupleItems = readonly $ZodType[],
2363
- Rest extends SomeType | null = $ZodType | null,
2364
- > extends $ZodTypeDef {
2365
- type: "tuple";
2366
- items: T;
2367
- rest: Rest;
2368
- }
2369
-
2370
- export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
2371
- ...TupleInputTypeWithOptionals<T>,
2372
- ...(Rest extends SomeType ? core.input<Rest>[] : []),
2373
- ];
2374
- type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
2375
- [k in keyof T]: core.input<T[k]>;
2376
- };
2377
- type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
2378
- ...infer Prefix extends SomeType[],
2379
- infer Tail extends SomeType,
2380
- ]
2381
- ? Tail["_zod"]["optin"] extends "optional"
2382
- ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?]
2383
- : TupleInputTypeNoOptionals<T>
2384
- : [];
2385
-
2386
- export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
2387
- ...TupleOutputTypeWithOptionals<T>,
2388
- ...(Rest extends SomeType ? core.output<Rest>[] : []),
2389
- ];
2390
- type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
2391
- [k in keyof T]: core.output<T[k]>;
2392
- };
2393
- type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
2394
- ...infer Prefix extends SomeType[],
2395
- infer Tail extends SomeType,
2396
- ]
2397
- ? Tail["_zod"]["optout"] extends "optional"
2398
- ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?]
2399
- : TupleOutputTypeNoOptionals<T>
2400
- : [];
2401
-
2402
- export interface $ZodTupleInternals<
2403
- T extends util.TupleItems = readonly $ZodType[],
2404
- Rest extends SomeType | null = $ZodType | null,
2405
- > extends _$ZodTypeInternals {
2406
- def: $ZodTupleDef<T, Rest>;
2407
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
2408
- // $ZodTypeInternals<$InferTupleOutputType<T, Rest>, $InferTupleInputType<T, Rest>>
2409
- output: $InferTupleOutputType<T, Rest>;
2410
- input: $InferTupleInputType<T, Rest>;
2411
- }
2412
-
2413
- export interface $ZodTuple<
2414
- T extends util.TupleItems = readonly $ZodType[],
2415
- Rest extends SomeType | null = $ZodType | null,
2416
- > extends $ZodType {
2417
- _zod: $ZodTupleInternals<T, Rest>;
2418
- }
2419
-
2420
- export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
2421
- $ZodType.init(inst, def);
2422
- const items = def.items;
2423
- const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
2424
-
2425
- inst._zod.parse = (payload, ctx) => {
2426
- const input = payload.value;
2427
- if (!Array.isArray(input)) {
2428
- payload.issues.push({
2429
- input,
2430
- inst,
2431
- expected: "tuple",
2432
- code: "invalid_type",
2433
- });
2434
- return payload;
2435
- }
2436
-
2437
- payload.value = [];
2438
- const proms: Promise<any>[] = [];
2439
-
2440
- if (!def.rest) {
2441
- const tooBig = input.length > items.length;
2442
- const tooSmall = input.length < optStart - 1;
2443
- if (tooBig || tooSmall) {
2444
- payload.issues.push({
2445
- ...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
2446
-
2447
- input,
2448
- inst,
2449
- origin: "array" as const,
2450
- });
2451
- return payload;
2452
- }
2453
- }
2454
-
2455
- let i = -1;
2456
- for (const item of items) {
2457
- i++;
2458
- if (i >= input.length) if (i >= optStart) continue;
2459
- const result = item._zod.run(
2460
- {
2461
- value: input[i],
2462
- issues: [],
2463
- },
2464
- ctx
2465
- );
2466
-
2467
- if (result instanceof Promise) {
2468
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
2469
- } else {
2470
- handleTupleResult(result, payload, i);
2471
- }
2472
- }
2473
-
2474
- if (def.rest) {
2475
- const rest = input.slice(items.length);
2476
- for (const el of rest) {
2477
- i++;
2478
- const result = def.rest._zod.run(
2479
- {
2480
- value: el,
2481
- issues: [],
2482
- },
2483
- ctx
2484
- );
2485
-
2486
- if (result instanceof Promise) {
2487
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
2488
- } else {
2489
- handleTupleResult(result, payload, i);
2490
- }
2491
- }
2492
- }
2493
-
2494
- if (proms.length) return Promise.all(proms).then(() => payload);
2495
- return payload;
2496
- };
2497
- });
2498
-
2499
- function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, index: number) {
2500
- if (result.issues.length) {
2501
- final.issues.push(...util.prefixIssues(index, result.issues));
2502
- }
2503
- final.value[index] = result.value;
2504
- }
2505
-
2506
- //////////////////////////////////////////
2507
- //////////////////////////////////////////
2508
- ////////// //////////
2509
- ////////// $ZodRecord //////////
2510
- ////////// //////////
2511
- //////////////////////////////////////////
2512
- //////////////////////////////////////////
2513
-
2514
- export type $ZodRecordKey = $ZodType<string | number | symbol, string | number | symbol>; // $HasValues | $HasPattern;
2515
- export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2516
- extends $ZodTypeDef {
2517
- type: "record";
2518
- keyType: Key;
2519
- valueType: Value;
2520
- }
2521
-
2522
- // export type $InferZodRecordOutput<
2523
- // Key extends $ZodRecordKey = $ZodRecordKey,
2524
- // Value extends SomeType = $ZodType,
2525
- // > = undefined extends Key["_zod"]["values"]
2526
- // ? string extends core.output<Key>
2527
- // ? Record<core.output<Key>, core.output<Value>>
2528
- // : number extends core.output<Key>
2529
- // ? Record<core.output<Key>, core.output<Value>>
2530
- // : symbol extends core.output<Key>
2531
- // ? Record<core.output<Key>, core.output<Value>>
2532
- // : Record<core.output<Key>, core.output<Value>>
2533
- // : Record<core.output<Key>, core.output<Value>>;
2534
- export type $InferZodRecordOutput<
2535
- Key extends $ZodRecordKey = $ZodRecordKey,
2536
- Value extends SomeType = $ZodType,
2537
- > = Key extends $partial
2538
- ? Partial<Record<core.output<Key>, core.output<Value>>>
2539
- : Record<core.output<Key>, core.output<Value>>;
2540
-
2541
- // export type $InferZodRecordInput<
2542
- // Key extends $ZodRecordKey = $ZodRecordKey,
2543
- // Value extends SomeType = $ZodType,
2544
- // > = undefined extends Key["_zod"]["values"]
2545
- // ? string extends core.input<Key>
2546
- // ? Record<core.input<Key>, core.input<Value>>
2547
- // : number extends core.input<Key>
2548
- // ? Record<core.input<Key>, core.input<Value>>
2549
- // : symbol extends core.input<Key>
2550
- // ? Record<core.input<Key>, core.input<Value>>
2551
- // : Record<core.input<Key>, core.input<Value>>
2552
- // : Record<core.input<Key>, core.input<Value>>;
2553
- export type $InferZodRecordInput<
2554
- Key extends $ZodRecordKey = $ZodRecordKey,
2555
- Value extends SomeType = $ZodType,
2556
- > = Key extends $partial
2557
- ? Partial<Record<core.input<Key>, core.input<Value>>>
2558
- : Record<core.input<Key>, core.input<Value>>;
2559
-
2560
- export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2561
- extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
2562
- def: $ZodRecordDef<Key, Value>;
2563
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
2564
- optin?: "optional" | undefined;
2565
- optout?: "optional" | undefined;
2566
- }
2567
-
2568
- export type $partial = { "~~partial": true };
2569
- export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2570
- extends $ZodType {
2571
- _zod: $ZodRecordInternals<Key, Value>;
2572
- }
2573
-
2574
- export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
2575
- $ZodType.init(inst, def);
2576
-
2577
- inst._zod.parse = (payload, ctx) => {
2578
- const input = payload.value;
2579
-
2580
- if (!util.isPlainObject(input)) {
2581
- payload.issues.push({
2582
- expected: "record",
2583
- code: "invalid_type",
2584
-
2585
- input,
2586
- inst,
2587
- });
2588
- return payload;
2589
- }
2590
-
2591
- const proms: Promise<any>[] = [];
2592
-
2593
- if (def.keyType._zod.values) {
2594
- const values = def.keyType._zod.values!;
2595
- payload.value = {};
2596
- for (const key of values) {
2597
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2598
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2599
-
2600
- if (result instanceof Promise) {
2601
- proms.push(
2602
- result.then((result) => {
2603
- if (result.issues.length) {
2604
- payload.issues.push(...util.prefixIssues(key, result.issues));
2605
- }
2606
- payload.value[key] = result.value;
2607
- })
2608
- );
2609
- } else {
2610
- if (result.issues.length) {
2611
- payload.issues.push(...util.prefixIssues(key, result.issues));
2612
- }
2613
- payload.value[key] = result.value;
2614
- }
2615
- }
2616
- }
2617
-
2618
- let unrecognized!: string[];
2619
- for (const key in input) {
2620
- if (!values.has(key)) {
2621
- unrecognized = unrecognized ?? [];
2622
- unrecognized.push(key);
2623
- }
2624
- }
2625
- if (unrecognized && unrecognized.length > 0) {
2626
- payload.issues.push({
2627
- code: "unrecognized_keys",
2628
-
2629
- input,
2630
- inst,
2631
- keys: unrecognized,
2632
- });
2633
- }
2634
- } else {
2635
- payload.value = {};
2636
- for (const key of Reflect.ownKeys(input)) {
2637
- if (key === "__proto__") continue;
2638
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2639
-
2640
- if (keyResult instanceof Promise) {
2641
- throw new Error("Async schemas not supported in object keys currently");
2642
- }
2643
-
2644
- if (keyResult.issues.length) {
2645
- payload.issues.push({
2646
- code: "invalid_key",
2647
-
2648
- origin: "record",
2649
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2650
- input: key,
2651
- path: [key],
2652
- inst,
2653
- });
2654
- payload.value[keyResult.value as PropertyKey] = keyResult.value;
2655
- continue;
2656
- }
2657
-
2658
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2659
-
2660
- if (result instanceof Promise) {
2661
- proms.push(
2662
- result.then((result) => {
2663
- if (result.issues.length) {
2664
- payload.issues.push(...util.prefixIssues(key, result.issues));
2665
- }
2666
- payload.value[keyResult.value as PropertyKey] = result.value;
2667
- })
2668
- );
2669
- } else {
2670
- if (result.issues.length) {
2671
- payload.issues.push(...util.prefixIssues(key, result.issues));
2672
- }
2673
- payload.value[keyResult.value as PropertyKey] = result.value;
2674
- }
2675
- }
2676
- }
2677
-
2678
- if (proms.length) {
2679
- return Promise.all(proms).then(() => payload);
2680
- }
2681
- return payload;
2682
- };
2683
- });
2684
-
2685
- ///////////////////////////////////////
2686
- ///////////////////////////////////////
2687
- ////////// //////////
2688
- ////////// $ZodMap //////////
2689
- ////////// //////////
2690
- ///////////////////////////////////////
2691
- ///////////////////////////////////////
2692
- export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
2693
- type: "map";
2694
- keyType: Key;
2695
- valueType: Value;
2696
- }
2697
-
2698
- export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType>
2699
- extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
2700
- def: $ZodMapDef<Key, Value>;
2701
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
2702
- optin?: "optional" | undefined;
2703
- optout?: "optional" | undefined;
2704
- }
2705
-
2706
- export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
2707
- _zod: $ZodMapInternals<Key, Value>;
2708
- }
2709
-
2710
- export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
2711
- $ZodType.init(inst, def);
2712
-
2713
- inst._zod.parse = (payload, ctx) => {
2714
- const input = payload.value;
2715
- if (!(input instanceof Map)) {
2716
- payload.issues.push({
2717
- expected: "map",
2718
- code: "invalid_type",
2719
-
2720
- input,
2721
- inst,
2722
- });
2723
- return payload;
2724
- }
2725
-
2726
- const proms: Promise<any>[] = [];
2727
- payload.value = new Map();
2728
-
2729
- for (const [key, value] of input) {
2730
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2731
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
2732
-
2733
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
2734
- proms.push(
2735
- Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
2736
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
2737
- })
2738
- );
2739
- } else {
2740
- handleMapResult(keyResult as ParsePayload, valueResult as ParsePayload, payload, key, input, inst, ctx);
2741
- }
2742
- }
2743
-
2744
- if (proms.length) return Promise.all(proms).then(() => payload);
2745
- return payload;
2746
- };
2747
- });
2748
-
2749
- function handleMapResult(
2750
- keyResult: ParsePayload,
2751
- valueResult: ParsePayload,
2752
- final: ParsePayload<Map<unknown, unknown>>,
2753
- key: unknown,
2754
- input: Map<any, any>,
2755
- inst: $ZodMap,
2756
- ctx?: ParseContext | undefined
2757
- ): void {
2758
- if (keyResult.issues.length) {
2759
- if (util.propertyKeyTypes.has(typeof key)) {
2760
- final.issues.push(...util.prefixIssues(key as PropertyKey, keyResult.issues));
2761
- } else {
2762
- final.issues.push({
2763
- code: "invalid_key",
2764
-
2765
- origin: "map",
2766
- input,
2767
- inst,
2768
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2769
- });
2770
- }
2771
- }
2772
- if (valueResult.issues.length) {
2773
- if (util.propertyKeyTypes.has(typeof key)) {
2774
- final.issues.push(...util.prefixIssues(key as PropertyKey, valueResult.issues));
2775
- } else {
2776
- final.issues.push({
2777
- origin: "map",
2778
- code: "invalid_element",
2779
-
2780
- input,
2781
- inst,
2782
- key: key,
2783
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2784
- });
2785
- }
2786
- }
2787
- final.value.set(keyResult.value, valueResult.value);
2788
- }
2789
-
2790
- ///////////////////////////////////////
2791
- ///////////////////////////////////////
2792
- ////////// //////////
2793
- ////////// $ZodSet //////////
2794
- ////////// //////////
2795
- ///////////////////////////////////////
2796
- ///////////////////////////////////////
2797
- export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
2798
- type: "set";
2799
- valueType: T;
2800
- }
2801
-
2802
- export interface $ZodSetInternals<T extends SomeType = $ZodType>
2803
- extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
2804
- def: $ZodSetDef<T>;
2805
- isst: errors.$ZodIssueInvalidType;
2806
- optin?: "optional" | undefined;
2807
- optout?: "optional" | undefined;
2808
- }
2809
-
2810
- export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
2811
- _zod: $ZodSetInternals<T>;
2812
- }
2813
-
2814
- export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
2815
- $ZodType.init(inst, def);
2816
-
2817
- inst._zod.parse = (payload, ctx) => {
2818
- const input = payload.value;
2819
- if (!(input instanceof Set)) {
2820
- payload.issues.push({
2821
- input,
2822
- inst,
2823
- expected: "set",
2824
- code: "invalid_type",
2825
- });
2826
- return payload;
2827
- }
2828
-
2829
- const proms: Promise<any>[] = [];
2830
- payload.value = new Set();
2831
- for (const item of input) {
2832
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
2833
- if (result instanceof Promise) {
2834
- proms.push(result.then((result) => handleSetResult(result, payload)));
2835
- } else handleSetResult(result, payload);
2836
- }
2837
-
2838
- if (proms.length) return Promise.all(proms).then(() => payload);
2839
- return payload;
2840
- };
2841
- });
2842
-
2843
- function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
2844
- if (result.issues.length) {
2845
- final.issues.push(...result.issues);
2846
- }
2847
- final.value.add(result.value);
2848
- }
2849
-
2850
- ////////////////////////////////////////
2851
- ////////////////////////////////////////
2852
- ////////// //////////
2853
- ////////// $ZodEnum //////////
2854
- ////////// //////////
2855
- ////////////////////////////////////////
2856
- ////////////////////////////////////////
2857
- export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
2858
- export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
2859
-
2860
- export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
2861
- type: "enum";
2862
- entries: T;
2863
- }
2864
-
2865
- export interface $ZodEnumInternals<
2866
- /** @ts-ignore Cast variance */
2867
- out T extends util.EnumLike = util.EnumLike,
2868
- > extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
2869
- // enum: T;
2870
-
2871
- def: $ZodEnumDef<T>;
2872
- /** @deprecated Internal API, use with caution (not deprecated) */
2873
- values: util.PrimitiveSet;
2874
- /** @deprecated Internal API, use with caution (not deprecated) */
2875
- pattern: RegExp;
2876
- isst: errors.$ZodIssueInvalidValue;
2877
- }
2878
-
2879
- export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
2880
- _zod: $ZodEnumInternals<T>;
2881
- }
2882
-
2883
- export const $ZodEnum: core.$constructor<$ZodEnum> = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
2884
- $ZodType.init(inst, def);
2885
-
2886
- const values = util.getEnumValues(def.entries);
2887
- const valuesSet = new Set<util.Primitive>(values);
2888
- inst._zod.values = valuesSet;
2889
-
2890
- inst._zod.pattern = new RegExp(
2891
- `^(${values
2892
- .filter((k) => util.propertyKeyTypes.has(typeof k))
2893
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
2894
- .join("|")})$`
2895
- );
2896
-
2897
- inst._zod.parse = (payload, _ctx) => {
2898
- const input = payload.value;
2899
- if (valuesSet.has(input)) {
2900
- return payload;
2901
- }
2902
- payload.issues.push({
2903
- code: "invalid_value",
2904
-
2905
- values,
2906
- input,
2907
- inst,
2908
- });
2909
- return payload;
2910
- };
2911
- });
2912
-
2913
- ////////////////////////////////////////
2914
- ////////////////////////////////////////
2915
- ////////// //////////
2916
- ////////// $ZodLiteral //////////
2917
- ////////// //////////
2918
- ////////////////////////////////////////
2919
- ////////////////////////////////////////
2920
-
2921
- export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
2922
- type: "literal";
2923
- values: T[];
2924
- }
2925
-
2926
- export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
2927
- def: $ZodLiteralDef<T>;
2928
- values: Set<T>;
2929
- pattern: RegExp;
2930
- isst: errors.$ZodIssueInvalidValue;
2931
- }
2932
-
2933
- export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
2934
- _zod: $ZodLiteralInternals<T>;
2935
- }
2936
-
2937
- export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$constructor(
2938
- "$ZodLiteral",
2939
- (inst, def) => {
2940
- $ZodType.init(inst, def);
2941
- if (def.values.length === 0) {
2942
- throw new Error("Cannot create literal schema with no valid values");
2943
- }
2944
-
2945
- inst._zod.values = new Set<util.Literal>(def.values);
2946
- inst._zod.pattern = new RegExp(
2947
- `^(${def.values
2948
-
2949
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
2950
- .join("|")})$`
2951
- );
2952
-
2953
- inst._zod.parse = (payload, _ctx) => {
2954
- const input = payload.value;
2955
- if (inst._zod.values.has(input)) {
2956
- return payload;
2957
- }
2958
- payload.issues.push({
2959
- code: "invalid_value",
2960
-
2961
- values: def.values,
2962
- input,
2963
- inst,
2964
- });
2965
- return payload;
2966
- };
2967
- }
2968
- );
2969
-
2970
- ////////////////////////////////////////
2971
- ////////////////////////////////////////
2972
- ////////// //////////
2973
- ////////// $ZodConst //////////
2974
- ////////// //////////
2975
- ////////////////////////////////////////
2976
- ////////////////////////////////////////
2977
-
2978
- // export interface $ZodConstDef extends $ZodTypeDef {
2979
- // type: "const";
2980
- // value: unknown;
2981
- // }
2982
-
2983
- // export _interface $ZodConstInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
2984
- // _def: $ZodConstDef;
2985
- // _values: util.PrimitiveSet;
2986
- // _pattern: RegExp;
2987
- // _isst: errors.$ZodIssueInvalidValue;
2988
- // }
2989
-
2990
- // export const $ZodConst: core.$constructor<{_zod: $ZodConstInternals}> = /*@__PURE__*/ core.$constructor("$ZodConst", (inst, def) => {
2991
- // $ZodType.init(inst, def);
2992
-
2993
- // if (util.primitiveTypes.has(typeof def.value) || def.value === null) {
2994
- // inst._zod.values = new Set<util.Primitive>(def.value as any);
2995
- // }
2996
-
2997
- // if (util.propertyKeyTypes.has(typeof def.value)) {
2998
- // inst._zod.pattern = new RegExp(
2999
- // `^(${typeof def.value === "string" ? util.escapeRegex(def.value) : (def.value as any).toString()})$`
3000
- // );
3001
- // } else {
3002
- // throw new Error("Const value cannot be converted to regex");
3003
- // }
3004
-
3005
- // inst._zod.parse = (payload, _ctx) => {
3006
- // payload.value = def.value; // always override
3007
- // return payload;
3008
- // };
3009
- // });
3010
-
3011
- //////////////////////////////////////////
3012
- //////////////////////////////////////////
3013
- ////////// //////////
3014
- ////////// $ZodFile //////////
3015
- ////////// //////////
3016
- //////////////////////////////////////////
3017
- //////////////////////////////////////////
3018
-
3019
- // provide a fallback in case the File interface isn't provided in the environment
3020
- type _File = typeof globalThis extends { File: infer F extends new (...args: any[]) => any } ? InstanceType<F> : {};
3021
- /** Do not reference this directly. */
3022
- export interface File extends _File {
3023
- readonly type: string;
3024
- readonly size: number;
3025
- }
3026
-
3027
- export interface $ZodFileDef extends $ZodTypeDef {
3028
- type: "file";
3029
- }
3030
-
3031
- export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
3032
- def: $ZodFileDef;
3033
- isst: errors.$ZodIssueInvalidType;
3034
- bag: util.LoosePartial<{
3035
- minimum: number;
3036
- maximum: number;
3037
- mime: util.MimeTypes[];
3038
- }>;
3039
- }
3040
-
3041
- export interface $ZodFile extends $ZodType {
3042
- _zod: $ZodFileInternals;
3043
- }
3044
-
3045
- export const $ZodFile: core.$constructor<$ZodFile> = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
3046
- $ZodType.init(inst, def);
3047
-
3048
- inst._zod.parse = (payload, _ctx) => {
3049
- const input = payload.value;
3050
- // @ts-ignore
3051
- if (input instanceof File) return payload;
3052
- payload.issues.push({
3053
- expected: "file",
3054
- code: "invalid_type",
3055
-
3056
- input,
3057
- inst,
3058
- });
3059
- return payload;
3060
- };
3061
- });
3062
-
3063
- //////////////////////////////////////////////
3064
- //////////////////////////////////////////////
3065
- ////////// //////////
3066
- ////////// $ZodTransform //////////
3067
- ////////// //////////
3068
- //////////////////////////////////////////////
3069
- //////////////////////////////////////////////
3070
- export interface $ZodTransformDef extends $ZodTypeDef {
3071
- type: "transform";
3072
- transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
3073
- }
3074
- export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
3075
- def: $ZodTransformDef;
3076
- isst: never;
3077
- }
3078
-
3079
- export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
3080
- _zod: $ZodTransformInternals<O, I>;
3081
- }
3082
-
3083
- export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ core.$constructor(
3084
- "$ZodTransform",
3085
- (inst, def) => {
3086
- $ZodType.init(inst, def);
3087
- inst._zod.parse = (payload, ctx) => {
3088
- if (ctx.direction === "backward") {
3089
- throw new core.$ZodEncodeError(inst.constructor.name);
3090
- }
3091
-
3092
- const _out = def.transform(payload.value, payload);
3093
- if (ctx.async) {
3094
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
3095
- return output.then((output) => {
3096
- payload.value = output;
3097
- return payload;
3098
- });
3099
- }
3100
-
3101
- if (_out instanceof Promise) {
3102
- throw new core.$ZodAsyncError();
3103
- }
3104
-
3105
- payload.value = _out;
3106
- return payload;
3107
- };
3108
- }
3109
- );
3110
-
3111
- ////////////////////////////////////////////
3112
- ////////////////////////////////////////////
3113
- ////////// //////////
3114
- ////////// $ZodOptional //////////
3115
- ////////// //////////
3116
- ////////////////////////////////////////////
3117
- ////////////////////////////////////////////
3118
- export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3119
- type: "optional";
3120
- innerType: T;
3121
- }
3122
-
3123
- export interface $ZodOptionalInternals<T extends SomeType = $ZodType>
3124
- extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
3125
- def: $ZodOptionalDef<T>;
3126
- optin: "optional";
3127
- optout: "optional";
3128
- isst: never;
3129
- values: T["_zod"]["values"];
3130
- pattern: T["_zod"]["pattern"];
3131
- }
3132
-
3133
- export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
3134
- _zod: $ZodOptionalInternals<T>;
3135
- }
3136
-
3137
- function handleOptionalResult(result: ParsePayload, input: unknown) {
3138
- if (result.issues.length && input === undefined) {
3139
- return { issues: [], value: undefined };
3140
- }
3141
- return result;
3142
- }
3143
-
3144
- export const $ZodOptional: core.$constructor<$ZodOptional> = /*@__PURE__*/ core.$constructor(
3145
- "$ZodOptional",
3146
- (inst, def) => {
3147
- $ZodType.init(inst, def);
3148
- inst._zod.optin = "optional";
3149
- inst._zod.optout = "optional";
3150
-
3151
- util.defineLazy(inst._zod, "values", () => {
3152
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
3153
- });
3154
- util.defineLazy(inst._zod, "pattern", () => {
3155
- const pattern = def.innerType._zod.pattern;
3156
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
3157
- });
3158
-
3159
- inst._zod.parse = (payload, ctx) => {
3160
- if (def.innerType._zod.optin === "optional") {
3161
- const result = def.innerType._zod.run(payload, ctx);
3162
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
3163
- return handleOptionalResult(result, payload.value);
3164
- }
3165
- if (payload.value === undefined) {
3166
- return payload;
3167
- }
3168
- return def.innerType._zod.run(payload, ctx);
3169
- };
3170
- }
3171
- );
3172
-
3173
- ////////////////////////////////////////////
3174
- ////////////////////////////////////////////
3175
- ////////// //////////
3176
- ////////// $ZodNullable //////////
3177
- ////////// //////////
3178
- ////////////////////////////////////////////
3179
- ////////////////////////////////////////////
3180
- export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3181
- type: "nullable";
3182
- innerType: T;
3183
- }
3184
-
3185
- export interface $ZodNullableInternals<T extends SomeType = $ZodType>
3186
- extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
3187
- def: $ZodNullableDef<T>;
3188
- optin: T["_zod"]["optin"];
3189
- optout: T["_zod"]["optout"];
3190
- isst: never;
3191
- values: T["_zod"]["values"];
3192
- pattern: T["_zod"]["pattern"];
3193
- }
3194
-
3195
- export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
3196
- _zod: $ZodNullableInternals<T>;
3197
- }
3198
-
3199
- export const $ZodNullable: core.$constructor<$ZodNullable> = /*@__PURE__*/ core.$constructor(
3200
- "$ZodNullable",
3201
- (inst, def) => {
3202
- $ZodType.init(inst, def);
3203
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3204
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3205
-
3206
- util.defineLazy(inst._zod, "pattern", () => {
3207
- const pattern = def.innerType._zod.pattern;
3208
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
3209
- });
3210
-
3211
- util.defineLazy(inst._zod, "values", () => {
3212
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
3213
- });
3214
-
3215
- inst._zod.parse = (payload, ctx) => {
3216
- // Forward direction (decode): allow null to pass through
3217
- if (payload.value === null) return payload;
3218
- return def.innerType._zod.run(payload, ctx);
3219
- };
3220
- }
3221
- );
3222
- // );
3223
-
3224
- ////////////////////////////////////////////
3225
- ////////////////////////////////////////////
3226
- ////////// //////////
3227
- ////////// $ZodDefault //////////
3228
- ////////// //////////
3229
- ////////////////////////////////////////////
3230
- ////////////////////////////////////////////
3231
- export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3232
- type: "default";
3233
- innerType: T;
3234
- /** The default value. May be a getter. */
3235
- defaultValue: util.NoUndefined<core.output<T>>;
3236
- }
3237
-
3238
- export interface $ZodDefaultInternals<T extends SomeType = $ZodType>
3239
- extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3240
- def: $ZodDefaultDef<T>;
3241
- optin: "optional";
3242
- optout?: "optional" | undefined; // required
3243
- isst: never;
3244
- values: T["_zod"]["values"];
3245
- }
3246
-
3247
- export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
3248
- _zod: $ZodDefaultInternals<T>;
3249
- }
3250
-
3251
- export const $ZodDefault: core.$constructor<$ZodDefault> = /*@__PURE__*/ core.$constructor(
3252
- "$ZodDefault",
3253
- (inst, def) => {
3254
- $ZodType.init(inst, def);
3255
-
3256
- // inst._zod.qin = "true";
3257
- inst._zod.optin = "optional";
3258
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3259
-
3260
- inst._zod.parse = (payload, ctx) => {
3261
- if (ctx.direction === "backward") {
3262
- return def.innerType._zod.run(payload, ctx);
3263
- }
3264
-
3265
- // Forward direction (decode): apply defaults for undefined input
3266
- if (payload.value === undefined) {
3267
- payload.value = def.defaultValue;
3268
- /**
3269
- * $ZodDefault returns the default value immediately in forward direction.
3270
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
3271
- return payload;
3272
- }
3273
- // Forward direction: continue with default handling
3274
- const result = def.innerType._zod.run(payload, ctx);
3275
- if (result instanceof Promise) {
3276
- return result.then((result) => handleDefaultResult(result, def));
3277
- }
3278
- return handleDefaultResult(result, def);
3279
- };
3280
- }
3281
- );
3282
-
3283
- function handleDefaultResult(payload: ParsePayload, def: $ZodDefaultDef) {
3284
- if (payload.value === undefined) {
3285
- payload.value = def.defaultValue;
3286
- }
3287
- return payload;
3288
- }
3289
-
3290
- ////////////////////////////////////////////
3291
- ////////////////////////////////////////////
3292
- ////////// //////////
3293
- ////////// $ZodPrefault //////////
3294
- ////////// //////////
3295
- ////////////////////////////////////////////
3296
- ////////////////////////////////////////////
3297
-
3298
- export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3299
- type: "prefault";
3300
- innerType: T;
3301
- /** The default value. May be a getter. */
3302
- defaultValue: core.input<T>;
3303
- }
3304
-
3305
- export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
3306
- extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3307
- def: $ZodPrefaultDef<T>;
3308
- optin: "optional";
3309
- optout?: "optional" | undefined;
3310
- isst: never;
3311
- values: T["_zod"]["values"];
3312
- }
3313
-
3314
- export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
3315
- _zod: $ZodPrefaultInternals<T>;
3316
- }
3317
-
3318
- export const $ZodPrefault: core.$constructor<$ZodPrefault> = /*@__PURE__*/ core.$constructor(
3319
- "$ZodPrefault",
3320
- (inst, def) => {
3321
- $ZodType.init(inst, def);
3322
-
3323
- inst._zod.optin = "optional";
3324
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3325
-
3326
- inst._zod.parse = (payload, ctx) => {
3327
- if (ctx.direction === "backward") {
3328
- return def.innerType._zod.run(payload, ctx);
3329
- }
3330
-
3331
- // Forward direction (decode): apply prefault for undefined input
3332
- if (payload.value === undefined) {
3333
- payload.value = def.defaultValue;
3334
- }
3335
- return def.innerType._zod.run(payload, ctx);
3336
- };
3337
- }
3338
- );
3339
-
3340
- ///////////////////////////////////////////////
3341
- ///////////////////////////////////////////////
3342
- ////////// //////////
3343
- ////////// $ZodNonOptional //////////
3344
- ////////// //////////
3345
- ///////////////////////////////////////////////
3346
- ///////////////////////////////////////////////
3347
- export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3348
- type: "nonoptional";
3349
- innerType: T;
3350
- }
3351
-
3352
- export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType>
3353
- extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
3354
- def: $ZodNonOptionalDef<T>;
3355
- isst: errors.$ZodIssueInvalidType;
3356
- values: T["_zod"]["values"];
3357
- optin: "optional" | undefined;
3358
- optout: "optional" | undefined;
3359
- }
3360
-
3361
- export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
3362
- _zod: $ZodNonOptionalInternals<T>;
3363
- }
3364
-
3365
- export const $ZodNonOptional: core.$constructor<$ZodNonOptional> = /*@__PURE__*/ core.$constructor(
3366
- "$ZodNonOptional",
3367
- (inst, def) => {
3368
- $ZodType.init(inst, def);
3369
-
3370
- util.defineLazy(inst._zod, "values", () => {
3371
- const v = def.innerType._zod.values;
3372
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
3373
- });
3374
-
3375
- inst._zod.parse = (payload, ctx) => {
3376
- const result = def.innerType._zod.run(payload, ctx);
3377
- if (result instanceof Promise) {
3378
- return result.then((result) => handleNonOptionalResult(result, inst));
3379
- }
3380
- return handleNonOptionalResult(result, inst);
3381
- };
3382
- }
3383
- );
3384
-
3385
- function handleNonOptionalResult(payload: ParsePayload, inst: $ZodNonOptional) {
3386
- if (!payload.issues.length && payload.value === undefined) {
3387
- payload.issues.push({
3388
- code: "invalid_type",
3389
- expected: "nonoptional",
3390
- input: payload.value,
3391
- inst,
3392
- });
3393
- }
3394
- return payload;
3395
- }
3396
-
3397
- ////////////////////////////////////////////
3398
- ////////////////////////////////////////////
3399
- ////////// //////////
3400
- ////////// $ZodCoalesce //////////
3401
- ////////// //////////
3402
- ////////////////////////////////////////////
3403
- ////////////////////////////////////////////
3404
- // export interface $ZodCoalesceDef<T extends $ZodType = $ZodType> extends $ZodTypeDef {
3405
- // type: "coalesce";
3406
- // innerType: T;
3407
- // defaultValue: () => NonNullable<T['_zod']["output"]>;
3408
- // }
3409
-
3410
- // export _interface $ZodCoalesceInternals<T extends $ZodType = $ZodType>
3411
- // extends $ZodTypeInternals<NonNullable<T['_zod']["output"]>, T['_zod']["input"] | undefined | null> {
3412
- // _def: $ZodCoalesceDef<T>;
3413
- // _isst: errors.$ZodIssueInvalidType;
3414
- // _qin: "true";
3415
- // }
3416
-
3417
- // function handleCoalesceResult(payload: ParsePayload, def: $ZodCoalesceDef) {
3418
- // payload.value ??= def.defaultValue();
3419
- // return payload;
3420
- // }
3421
-
3422
- // export const $ZodCoalesce: core.$constructor<{_zod: $ZodCoalesceInternals}> = /*@__PURE__*/ core.$constructor(
3423
- // "$ZodCoalesce",
3424
- // (inst, def) => {
3425
- // $ZodType.init(inst, def);
3426
- // inst._zod.qin = "true";
3427
- // inst._zod.parse = (payload, ctx) => {
3428
- // const result = def.innerType._zod.run(payload, ctx);
3429
- // if (result instanceof Promise) {
3430
- // return result.then((result) => handleCoalesceResult(result, def));
3431
- // }
3432
- // return handleCoalesceResult(result, def);
3433
- // };
3434
- // }
3435
- // );
3436
-
3437
- /////////////////////////////////////////////
3438
- /////////////////////////////////////////////
3439
- ////////// //////////
3440
- ////////// $ZodSuccess //////////
3441
- ////////// //////////
3442
- /////////////////////////////////////////////
3443
- /////////////////////////////////////////////
3444
- export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3445
- type: "success";
3446
- innerType: T;
3447
- }
3448
-
3449
- export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
3450
- def: $ZodSuccessDef<T>;
3451
- isst: never;
3452
- optin: T["_zod"]["optin"];
3453
- optout: "optional" | undefined;
3454
- }
3455
-
3456
- export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
3457
- _zod: $ZodSuccessInternals<T>;
3458
- }
3459
-
3460
- export const $ZodSuccess: core.$constructor<$ZodSuccess> = /*@__PURE__*/ core.$constructor(
3461
- "$ZodSuccess",
3462
- (inst, def) => {
3463
- $ZodType.init(inst, def);
3464
-
3465
- inst._zod.parse = (payload, ctx) => {
3466
- if (ctx.direction === "backward") {
3467
- throw new core.$ZodEncodeError("ZodSuccess");
3468
- }
3469
-
3470
- const result = def.innerType._zod.run(payload, ctx);
3471
- if (result instanceof Promise) {
3472
- return result.then((result) => {
3473
- payload.value = result.issues.length === 0;
3474
- return payload;
3475
- });
3476
- }
3477
- payload.value = result.issues.length === 0;
3478
- return payload;
3479
- };
3480
- }
3481
- );
3482
-
3483
- ////////////////////////////////////////////
3484
- ////////////////////////////////////////////
3485
- ////////// //////////
3486
- ////////// $ZodCatch //////////
3487
- ////////// //////////
3488
- ////////////////////////////////////////////
3489
- ////////////////////////////////////////////
3490
- export interface $ZodCatchCtx extends ParsePayload {
3491
- /** @deprecated Use `ctx.issues` */
3492
- error: { issues: errors.$ZodIssue[] };
3493
- /** @deprecated Use `ctx.value` */
3494
- input: unknown;
3495
- }
3496
- export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3497
- type: "catch";
3498
- innerType: T;
3499
- catchValue: (ctx: $ZodCatchCtx) => unknown;
3500
- }
3501
-
3502
- export interface $ZodCatchInternals<T extends SomeType = $ZodType>
3503
- extends $ZodTypeInternals<core.output<T>, core.input<T>> {
3504
- def: $ZodCatchDef<T>;
3505
- optin: T["_zod"]["optin"];
3506
- optout: T["_zod"]["optout"];
3507
- isst: never;
3508
- values: T["_zod"]["values"];
3509
- }
3510
-
3511
- export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
3512
- _zod: $ZodCatchInternals<T>;
3513
- }
3514
-
3515
- export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
3516
- $ZodType.init(inst, def);
3517
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3518
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3519
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3520
-
3521
- inst._zod.parse = (payload, ctx) => {
3522
- if (ctx.direction === "backward") {
3523
- return def.innerType._zod.run(payload, ctx);
3524
- }
3525
-
3526
- // Forward direction (decode): apply catch logic
3527
- const result = def.innerType._zod.run(payload, ctx);
3528
- if (result instanceof Promise) {
3529
- return result.then((result) => {
3530
- payload.value = result.value;
3531
- if (result.issues.length) {
3532
- payload.value = def.catchValue({
3533
- ...payload,
3534
- error: {
3535
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3536
- },
3537
- input: payload.value,
3538
- });
3539
- payload.issues = [];
3540
- }
3541
-
3542
- return payload;
3543
- });
3544
- }
3545
-
3546
- payload.value = result.value;
3547
- if (result.issues.length) {
3548
- payload.value = def.catchValue({
3549
- ...payload,
3550
- error: {
3551
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3552
- },
3553
- input: payload.value,
3554
- });
3555
-
3556
- payload.issues = [];
3557
- }
3558
-
3559
- return payload;
3560
- };
3561
- });
3562
-
3563
- ////////////////////////////////////////////
3564
- ////////////////////////////////////////////
3565
- ////////// //////////
3566
- ////////// $ZodNaN //////////
3567
- ////////// //////////
3568
- ////////////////////////////////////////////
3569
- ////////////////////////////////////////////
3570
- export interface $ZodNaNDef extends $ZodTypeDef {
3571
- type: "nan";
3572
- }
3573
-
3574
- export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
3575
- def: $ZodNaNDef;
3576
- isst: errors.$ZodIssueInvalidType;
3577
- }
3578
-
3579
- export interface $ZodNaN extends $ZodType {
3580
- _zod: $ZodNaNInternals;
3581
- }
3582
-
3583
- export const $ZodNaN: core.$constructor<$ZodNaN> = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
3584
- $ZodType.init(inst, def);
3585
-
3586
- inst._zod.parse = (payload, _ctx) => {
3587
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
3588
- payload.issues.push({
3589
- input: payload.value,
3590
- inst,
3591
- expected: "nan",
3592
- code: "invalid_type",
3593
- });
3594
- return payload;
3595
- }
3596
- return payload;
3597
- };
3598
- });
3599
-
3600
- ////////////////////////////////////////////
3601
- ////////////////////////////////////////////
3602
- ////////// //////////
3603
- ////////// $ZodPipe //////////
3604
- ////////// //////////
3605
- ////////////////////////////////////////////
3606
- ////////////////////////////////////////////
3607
- export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
3608
- type: "pipe";
3609
- in: A;
3610
- out: B;
3611
- /** Only defined inside $ZodCodec instances. */
3612
- transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
3613
- /** Only defined inside $ZodCodec instances. */
3614
- reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
3615
- }
3616
-
3617
- export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
3618
- extends $ZodTypeInternals<core.output<B>, core.input<A>> {
3619
- def: $ZodPipeDef<A, B>;
3620
- isst: never;
3621
- values: A["_zod"]["values"];
3622
- optin: A["_zod"]["optin"];
3623
- optout: B["_zod"]["optout"];
3624
- propValues: A["_zod"]["propValues"];
3625
- }
3626
-
3627
- export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
3628
- _zod: $ZodPipeInternals<A, B>;
3629
- }
3630
-
3631
- export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
3632
- $ZodType.init(inst, def);
3633
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
3634
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
3635
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
3636
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3637
-
3638
- inst._zod.parse = (payload, ctx) => {
3639
- if (ctx.direction === "backward") {
3640
- const right = def.out._zod.run(payload, ctx);
3641
- if (right instanceof Promise) {
3642
- return right.then((right) => handlePipeResult(right, def.in, ctx));
3643
- }
3644
- return handlePipeResult(right, def.in, ctx);
3645
- }
3646
-
3647
- const left = def.in._zod.run(payload, ctx);
3648
- if (left instanceof Promise) {
3649
- return left.then((left) => handlePipeResult(left, def.out, ctx));
3650
- }
3651
- return handlePipeResult(left, def.out, ctx);
3652
- };
3653
- });
3654
-
3655
- function handlePipeResult(left: ParsePayload, next: $ZodType, ctx: ParseContextInternal) {
3656
- if (left.issues.length) {
3657
- // prevent further checks
3658
- left.aborted = true;
3659
- return left;
3660
- }
3661
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
3662
- }
3663
-
3664
- ////////////////////////////////////////////
3665
- ////////////////////////////////////////////
3666
- ////////// //////////
3667
- ////////// $ZodCodec //////////
3668
- ////////// //////////
3669
- ////////////////////////////////////////////
3670
- ////////////////////////////////////////////
3671
- export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
3672
- transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
3673
- reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
3674
- }
3675
-
3676
- export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
3677
- extends $ZodTypeInternals<core.output<B>, core.input<A>> {
3678
- def: $ZodCodecDef<A, B>;
3679
- isst: never;
3680
- values: A["_zod"]["values"];
3681
- optin: A["_zod"]["optin"];
3682
- optout: B["_zod"]["optout"];
3683
- propValues: A["_zod"]["propValues"];
3684
- }
3685
-
3686
- export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
3687
- _zod: $ZodCodecInternals<A, B>;
3688
- }
3689
-
3690
- export const $ZodCodec: core.$constructor<$ZodCodec> = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
3691
- $ZodType.init(inst, def);
3692
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
3693
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
3694
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
3695
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3696
-
3697
- inst._zod.parse = (payload, ctx) => {
3698
- const direction = ctx.direction || "forward";
3699
- if (direction === "forward") {
3700
- const left = def.in._zod.run(payload, ctx);
3701
- if (left instanceof Promise) {
3702
- return left.then((left) => handleCodecAResult(left, def, ctx));
3703
- }
3704
- return handleCodecAResult(left, def, ctx);
3705
- } else {
3706
- const right = def.out._zod.run(payload, ctx);
3707
- if (right instanceof Promise) {
3708
- return right.then((right) => handleCodecAResult(right, def, ctx));
3709
- }
3710
- return handleCodecAResult(right, def, ctx);
3711
- }
3712
- };
3713
- });
3714
-
3715
- function handleCodecAResult(result: ParsePayload, def: $ZodCodecDef, ctx: ParseContextInternal) {
3716
- if (result.issues.length) {
3717
- // prevent further checks
3718
- result.aborted = true;
3719
- return result;
3720
- }
3721
-
3722
- const direction = ctx.direction || "forward";
3723
-
3724
- if (direction === "forward") {
3725
- const transformed = def.transform(result.value, result);
3726
- if (transformed instanceof Promise) {
3727
- return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
3728
- }
3729
- return handleCodecTxResult(result, transformed, def.out, ctx);
3730
- } else {
3731
- const transformed = def.reverseTransform(result.value, result);
3732
- if (transformed instanceof Promise) {
3733
- return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
3734
- }
3735
- return handleCodecTxResult(result, transformed, def.in, ctx);
3736
- }
3737
- }
3738
-
3739
- function handleCodecTxResult(left: ParsePayload, value: any, nextSchema: SomeType, ctx: ParseContextInternal) {
3740
- // Check if transform added any issues
3741
- if (left.issues.length) {
3742
- left.aborted = true;
3743
- return left;
3744
- }
3745
-
3746
- return nextSchema._zod.run({ value, issues: left.issues }, ctx);
3747
- }
3748
-
3749
- ////////////////////////////////////////////
3750
- ////////////////////////////////////////////
3751
- ////////// //////////
3752
- ////////// $ZodReadonly //////////
3753
- ////////// //////////
3754
- ////////////////////////////////////////////
3755
- ////////////////////////////////////////////
3756
-
3757
- export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3758
- type: "readonly";
3759
- innerType: T;
3760
- }
3761
-
3762
- export interface $ZodReadonlyInternals<T extends SomeType = $ZodType>
3763
- extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
3764
- def: $ZodReadonlyDef<T>;
3765
- optin: T["_zod"]["optin"];
3766
- optout: T["_zod"]["optout"];
3767
- isst: never;
3768
- propValues: T["_zod"]["propValues"];
3769
- values: T["_zod"]["values"];
3770
- }
3771
-
3772
- export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
3773
- _zod: $ZodReadonlyInternals<T>;
3774
- }
3775
-
3776
- export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.$constructor(
3777
- "$ZodReadonly",
3778
- (inst, def) => {
3779
- $ZodType.init(inst, def);
3780
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
3781
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3782
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3783
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3784
-
3785
- inst._zod.parse = (payload, ctx) => {
3786
- if (ctx.direction === "backward") {
3787
- return def.innerType._zod.run(payload, ctx);
3788
- }
3789
- const result = def.innerType._zod.run(payload, ctx);
3790
- if (result instanceof Promise) {
3791
- return result.then(handleReadonlyResult);
3792
- }
3793
- return handleReadonlyResult(result);
3794
- };
3795
- }
3796
- );
3797
-
3798
- function handleReadonlyResult(payload: ParsePayload): ParsePayload {
3799
- payload.value = Object.freeze(payload.value);
3800
- return payload;
3801
- }
3802
-
3803
- /////////////////////////////////////////////
3804
- /////////////////////////////////////////////
3805
- ////////// //////////
3806
- ////////// $ZodTemplateLiteral //////////
3807
- ////////// //////////
3808
- /////////////////////////////////////////////
3809
- /////////////////////////////////////////////
3810
-
3811
- export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
3812
- type: "template_literal";
3813
- parts: $ZodTemplateLiteralPart[];
3814
- format?: string | undefined;
3815
- }
3816
- export interface $ZodTemplateLiteralInternals<Template extends string = string>
3817
- extends $ZodTypeInternals<Template, Template> {
3818
- pattern: RegExp;
3819
- def: $ZodTemplateLiteralDef;
3820
- isst: errors.$ZodIssueInvalidType;
3821
- }
3822
-
3823
- export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
3824
- _zod: $ZodTemplateLiteralInternals<Template>;
3825
- }
3826
-
3827
- type LiteralPart = Exclude<util.Literal, symbol>; //string | number | boolean | null | undefined;
3828
- interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
3829
- pattern: RegExp;
3830
- }
3831
- interface SchemaPart extends $ZodType {
3832
- _zod: SchemaPartInternals;
3833
- }
3834
- export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
3835
-
3836
- type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
3837
- type AppendToTemplateLiteral<
3838
- Template extends string,
3839
- Suffix extends LiteralPart | $ZodType,
3840
- > = Suffix extends LiteralPart
3841
- ? `${Template}${UndefinedToEmptyString<Suffix>}`
3842
- : Suffix extends $ZodType
3843
- ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}`
3844
- : never;
3845
-
3846
- export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
3847
- infer First extends string,
3848
- ...infer Rest extends string[],
3849
- ]
3850
- ? Rest extends string[]
3851
- ? First extends ""
3852
- ? ConcatenateTupleOfStrings<Rest>
3853
- : `${First}${ConcatenateTupleOfStrings<Rest>}`
3854
- : never
3855
- : "";
3856
- export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
3857
- [K in keyof Parts]: Parts[K] extends LiteralPart
3858
- ? `${UndefinedToEmptyString<Parts[K]>}`
3859
- : Parts[K] extends $ZodType
3860
- ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}`
3861
- : never;
3862
- };
3863
-
3864
- export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<
3865
- ConvertPartsToStringTuple<Parts>
3866
- >;
3867
- // type lkjasd = ConcatenateTupleOfStrings<["Hello", " ", "World", "!"]>; // "Hello World!"
3868
- export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts
3869
- ? ``
3870
- : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart]
3871
- ? Rest extends $ZodTemplateLiteralPart[]
3872
- ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last>
3873
- : never
3874
- : never;
3875
-
3876
- export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
3877
- "$ZodTemplateLiteral",
3878
- (inst, def) => {
3879
- $ZodType.init(inst, def);
3880
- const regexParts: string[] = [];
3881
- for (const part of def.parts) {
3882
- if (typeof part === "object" && part !== null) {
3883
- // is Zod schema
3884
- if (!part._zod.pattern) {
3885
- // if (!source)
3886
- throw new Error(`Invalid template literal part, no pattern found: ${[...(part as any)._zod.traits].shift()}`);
3887
- }
3888
-
3889
- const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
3890
-
3891
- if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
3892
-
3893
- const start = source.startsWith("^") ? 1 : 0;
3894
- const end = source.endsWith("$") ? source.length - 1 : source.length;
3895
- regexParts.push(source.slice(start, end));
3896
- } else if (part === null || util.primitiveTypes.has(typeof part)) {
3897
- regexParts.push(util.escapeRegex(`${part}`));
3898
- } else {
3899
- throw new Error(`Invalid template literal part: ${part}`);
3900
- }
3901
- }
3902
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
3903
-
3904
- inst._zod.parse = (payload, _ctx) => {
3905
- if (typeof payload.value !== "string") {
3906
- payload.issues.push({
3907
- input: payload.value,
3908
- inst,
3909
- expected: "template_literal",
3910
- code: "invalid_type",
3911
- });
3912
- return payload;
3913
- }
3914
-
3915
- inst._zod.pattern.lastIndex = 0;
3916
-
3917
- if (!inst._zod.pattern.test(payload.value)) {
3918
- payload.issues.push({
3919
- input: payload.value,
3920
- inst,
3921
-
3922
- code: "invalid_format",
3923
- format: def.format ?? "template_literal",
3924
- pattern: inst._zod.pattern.source,
3925
- });
3926
- return payload;
3927
- }
3928
-
3929
- return payload;
3930
- };
3931
- }
3932
- );
3933
-
3934
- //////////////////////////////////////////
3935
- //////////////////////////////////////////
3936
- ////////// //////////
3937
- ////////// $ZodFunction //////////
3938
- ////////// //////////
3939
- //////////////////////////////////////////
3940
- //////////////////////////////////////////
3941
- export type $ZodFunctionArgs = $ZodType<unknown[], unknown[]>;
3942
- export type $ZodFunctionIn = $ZodFunctionArgs;
3943
- export type $ZodFunctionOut = $ZodType;
3944
-
3945
- export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
3946
- ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
3947
- ) => core.input<Returns>;
3948
-
3949
- export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
3950
- ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
3951
- ) => util.MaybeAsync<core.input<Returns>>;
3952
-
3953
- export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
3954
- ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
3955
- ) => core.output<Returns>;
3956
-
3957
- export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
3958
- ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
3959
- ) => util.MaybeAsync<core.output<Returns>>;
3960
-
3961
- export interface $ZodFunctionDef<
3962
- In extends $ZodFunctionIn = $ZodFunctionIn,
3963
- Out extends $ZodFunctionOut = $ZodFunctionOut,
3964
- > extends $ZodTypeDef {
3965
- type: "function";
3966
- input: In;
3967
- output: Out;
3968
- }
3969
-
3970
- export interface $ZodFunctionInternals<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut>
3971
- extends $ZodTypeInternals<$InferOuterFunctionType<Args, Returns>, $InferInnerFunctionType<Args, Returns>> {
3972
- def: $ZodFunctionDef<Args, Returns>;
3973
- isst: errors.$ZodIssueInvalidType;
3974
- }
3975
-
3976
- export interface $ZodFunction<
3977
- Args extends $ZodFunctionIn = $ZodFunctionIn,
3978
- Returns extends $ZodFunctionOut = $ZodFunctionOut,
3979
- > extends $ZodType<any, any, $ZodFunctionInternals<Args, Returns>> {
3980
- /** @deprecated */
3981
- _def: $ZodFunctionDef<Args, Returns>;
3982
- _input: $InferInnerFunctionType<Args, Returns>;
3983
- _output: $InferOuterFunctionType<Args, Returns>;
3984
-
3985
- implement<F extends $InferInnerFunctionType<Args, Returns>>(
3986
- func: F
3987
- ): // allow for return type inference
3988
- (
3989
- ...args: Parameters<this["_output"]>
3990
- ) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]>;
3991
-
3992
- implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(
3993
- func: F
3994
- ): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns>;
3995
-
3996
- input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(
3997
- args: Items,
3998
- rest?: Rest
3999
- ): $ZodFunction<$ZodTuple<Items, Rest>, Returns>;
4000
- input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
4001
- input(...args: any[]): $ZodFunction<any, Returns>;
4002
-
4003
- output<NewReturns extends $ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns>;
4004
- }
4005
-
4006
- export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends $ZodType> {
4007
- input?: I;
4008
- output?: O;
4009
- }
4010
-
4011
- export const $ZodFunction: core.$constructor<$ZodFunction> = /*@__PURE__*/ core.$constructor(
4012
- "$ZodFunction",
4013
- (inst, def) => {
4014
- $ZodType.init(inst, def);
4015
- inst._def = def;
4016
- inst._zod.def = def;
4017
-
4018
- inst.implement = (func) => {
4019
- if (typeof func !== "function") {
4020
- throw new Error("implement() must be called with a function");
4021
- }
4022
- return function (this: any, ...args: never[]) {
4023
- const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
4024
- const result = Reflect.apply(func, this, parsedArgs as never[]);
4025
- if (inst._def.output) {
4026
- return parse(inst._def.output, result);
4027
- }
4028
- return result as any;
4029
- };
4030
- };
4031
-
4032
- inst.implementAsync = (func) => {
4033
- if (typeof func !== "function") {
4034
- throw new Error("implementAsync() must be called with a function");
4035
- }
4036
- return async function (this: any, ...args: never[]) {
4037
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
4038
- const result = await Reflect.apply(func, this, parsedArgs as never[]);
4039
- if (inst._def.output) {
4040
- return await parseAsync(inst._def.output, result);
4041
- }
4042
- return result;
4043
- } as any;
4044
- };
4045
-
4046
- inst._zod.parse = (payload, _ctx) => {
4047
- if (typeof payload.value !== "function") {
4048
- payload.issues.push({
4049
- code: "invalid_type",
4050
- expected: "function",
4051
- input: payload.value,
4052
- inst,
4053
- });
4054
- return payload;
4055
- }
4056
-
4057
- // Check if output is a promise type to determine if we should use async implementation
4058
- const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
4059
-
4060
- if (hasPromiseOutput) {
4061
- payload.value = inst.implementAsync(payload.value);
4062
- } else {
4063
- payload.value = inst.implement(payload.value);
4064
- }
4065
- return payload;
4066
- };
4067
-
4068
- inst.input = (...args: any[]): $ZodFunction<any, any> => {
4069
- const F: any = inst.constructor;
4070
- if (Array.isArray(args[0])) {
4071
- return new F({
4072
- type: "function",
4073
- input: new $ZodTuple({
4074
- type: "tuple",
4075
- items: args[0],
4076
- rest: args[1],
4077
- }),
4078
- output: inst._def.output,
4079
- });
4080
- }
4081
-
4082
- return new F({
4083
- type: "function",
4084
- input: args[0],
4085
- output: inst._def.output,
4086
- });
4087
- };
4088
-
4089
- inst.output = (output) => {
4090
- const F: any = inst.constructor;
4091
- return new F({
4092
- type: "function",
4093
- input: inst._def.input,
4094
- output,
4095
- });
4096
- };
4097
-
4098
- return inst;
4099
- }
4100
- );
4101
-
4102
- /////////////////////////////////////////
4103
- /////////////////////////////////////////
4104
- ////////// //////////
4105
- ////////// $ZodPromise //////////
4106
- ////////// //////////
4107
- /////////////////////////////////////////
4108
- /////////////////////////////////////////
4109
- export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
4110
- type: "promise";
4111
- innerType: T;
4112
- }
4113
-
4114
- export interface $ZodPromiseInternals<T extends SomeType = $ZodType>
4115
- extends $ZodTypeInternals<core.output<T>, util.MaybeAsync<core.input<T>>> {
4116
- def: $ZodPromiseDef<T>;
4117
- isst: never;
4118
- }
4119
-
4120
- export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
4121
- _zod: $ZodPromiseInternals<T>;
4122
- }
4123
-
4124
- export const $ZodPromise: core.$constructor<$ZodPromise> = /*@__PURE__*/ core.$constructor(
4125
- "$ZodPromise",
4126
- (inst, def) => {
4127
- $ZodType.init(inst, def);
4128
-
4129
- inst._zod.parse = (payload, ctx) => {
4130
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
4131
- };
4132
- }
4133
- );
4134
-
4135
- //////////////////////////////////////////
4136
- //////////////////////////////////////////
4137
- ////////// //////////
4138
- ////////// $ZodLazy //////////
4139
- ////////// //////////
4140
- //////////////////////////////////////////
4141
- //////////////////////////////////////////
4142
-
4143
- export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
4144
- type: "lazy";
4145
- getter: () => T;
4146
- }
4147
-
4148
- export interface $ZodLazyInternals<T extends SomeType = $ZodType>
4149
- extends $ZodTypeInternals<core.output<T>, core.input<T>> {
4150
- def: $ZodLazyDef<T>;
4151
- isst: never;
4152
- /** Auto-cached way to retrieve the inner schema */
4153
- innerType: T;
4154
- pattern: T["_zod"]["pattern"];
4155
- propValues: T["_zod"]["propValues"];
4156
- optin: T["_zod"]["optin"];
4157
- optout: T["_zod"]["optout"];
4158
- }
4159
-
4160
- export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
4161
- _zod: $ZodLazyInternals<T>;
4162
- }
4163
-
4164
- export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
4165
- $ZodType.init(inst, def);
4166
-
4167
- // let _innerType!: any;
4168
- // util.defineLazy(def, "getter", () => {
4169
- // if (!_innerType) {
4170
- // _innerType = def.getter();
4171
- // }
4172
- // return () => _innerType;
4173
- // });
4174
- util.defineLazy(inst._zod, "innerType", () => def.getter() as $ZodType);
4175
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
4176
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
4177
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType._zod.optin ?? undefined);
4178
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType._zod.optout ?? undefined);
4179
- inst._zod.parse = (payload, ctx) => {
4180
- const inner = inst._zod.innerType;
4181
- return inner._zod.run(payload, ctx);
4182
- };
4183
- });
4184
-
4185
- ////////////////////////////////////////
4186
- ////////////////////////////////////////
4187
- ////////// //////////
4188
- ////////// $ZodCustom //////////
4189
- ////////// //////////
4190
- ////////////////////////////////////////
4191
- ////////////////////////////////////////
4192
- export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
4193
- type: "custom";
4194
- check: "custom";
4195
- path?: PropertyKey[] | undefined;
4196
- error?: errors.$ZodErrorMap | undefined;
4197
- params?: Record<string, any> | undefined;
4198
- fn: (arg: O) => unknown;
4199
- }
4200
-
4201
- export interface $ZodCustomInternals<O = unknown, I = unknown>
4202
- extends $ZodTypeInternals<O, I>,
4203
- checks.$ZodCheckInternals<O> {
4204
- def: $ZodCustomDef;
4205
- issc: errors.$ZodIssue;
4206
- isst: never;
4207
- bag: util.LoosePartial<{
4208
- Class: typeof util.Class;
4209
- }>;
4210
- }
4211
-
4212
- export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
4213
- _zod: $ZodCustomInternals<O, I>;
4214
- }
4215
-
4216
- export const $ZodCustom: core.$constructor<$ZodCustom> = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
4217
- checks.$ZodCheck.init(inst, def);
4218
- $ZodType.init(inst, def);
4219
-
4220
- inst._zod.parse = (payload, _) => {
4221
- return payload;
4222
- };
4223
-
4224
- inst._zod.check = (payload) => {
4225
- const input = payload.value;
4226
- const r = def.fn(input as any);
4227
- if (r instanceof Promise) {
4228
- return r.then((r) => handleRefineResult(r, payload, input, inst));
4229
- }
4230
- handleRefineResult(r, payload, input, inst);
4231
- return;
4232
- };
4233
- });
4234
-
4235
- function handleRefineResult(result: unknown, payload: ParsePayload, input: unknown, inst: $ZodCustom): void {
4236
- if (!result) {
4237
- const _iss: any = {
4238
- code: "custom",
4239
- input,
4240
- inst, // incorporates params.error into issue reporting
4241
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
4242
- continue: !inst._zod.def.abort,
4243
- // params: inst._zod.def.params,
4244
- };
4245
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
4246
- payload.issues.push(util.issue(_iss));
4247
- }
4248
- }
4249
-
4250
- export type $ZodTypes =
4251
- | $ZodString
4252
- | $ZodNumber
4253
- | $ZodBigInt
4254
- | $ZodBoolean
4255
- | $ZodDate
4256
- | $ZodSymbol
4257
- | $ZodUndefined
4258
- | $ZodNullable
4259
- | $ZodNull
4260
- | $ZodAny
4261
- | $ZodUnknown
4262
- | $ZodNever
4263
- | $ZodVoid
4264
- | $ZodArray
4265
- | $ZodObject
4266
- | $ZodUnion
4267
- | $ZodIntersection
4268
- | $ZodTuple
4269
- | $ZodRecord
4270
- | $ZodMap
4271
- | $ZodSet
4272
- | $ZodLiteral
4273
- | $ZodEnum
4274
- | $ZodFunction
4275
- | $ZodPromise
4276
- | $ZodLazy
4277
- | $ZodOptional
4278
- | $ZodDefault
4279
- | $ZodPrefault
4280
- | $ZodTemplateLiteral
4281
- | $ZodCustom
4282
- | $ZodTransform
4283
- | $ZodNonOptional
4284
- | $ZodReadonly
4285
- | $ZodNaN
4286
- | $ZodPipe
4287
- | $ZodSuccess
4288
- | $ZodCatch
4289
- | $ZodFile;
4290
-
4291
- export type $ZodStringFormatTypes =
4292
- | $ZodGUID
4293
- | $ZodUUID
4294
- | $ZodEmail
4295
- | $ZodURL
4296
- | $ZodEmoji
4297
- | $ZodNanoID
4298
- | $ZodCUID
4299
- | $ZodCUID2
4300
- | $ZodULID
4301
- | $ZodXID
4302
- | $ZodKSUID
4303
- | $ZodISODateTime
4304
- | $ZodISODate
4305
- | $ZodISOTime
4306
- | $ZodISODuration
4307
- | $ZodIPv4
4308
- | $ZodIPv6
4309
- | $ZodCIDRv4
4310
- | $ZodCIDRv6
4311
- | $ZodBase64
4312
- | $ZodBase64URL
4313
- | $ZodE164
4314
- | $ZodJWT
4315
- | $ZodCustomStringFormat<"hex">
4316
- | $ZodCustomStringFormat<util.HashFormat>
4317
- | $ZodCustomStringFormat<"hostname">;