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