scordi-extension 1.16.3 → 1.16.4

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