@learncard/react 2.5.17 → 2.5.18

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