langgraph-ui-components 0.0.3 → 0.0.6

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 (536) hide show
  1. package/README.md +32 -0
  2. package/dist/index.es10.js +31 -16
  3. package/dist/index.es10.js.map +1 -1
  4. package/dist/index.es100.js +37 -5
  5. package/dist/index.es100.js.map +1 -1
  6. package/dist/index.es101.js +160 -67
  7. package/dist/index.es101.js.map +1 -1
  8. package/dist/index.es102.js +196 -30
  9. package/dist/index.es102.js.map +1 -1
  10. package/dist/index.es103.js +14 -5
  11. package/dist/index.es103.js.map +1 -1
  12. package/dist/index.es104.js +32 -2
  13. package/dist/index.es104.js.map +1 -1
  14. package/dist/index.es105.js +33 -10
  15. package/dist/index.es105.js.map +1 -1
  16. package/dist/index.es106.js +3110 -454
  17. package/dist/index.es106.js.map +1 -1
  18. package/dist/index.es107.js +5 -5
  19. package/dist/index.es108.js +2 -2
  20. package/dist/index.es109.js +12 -142
  21. package/dist/index.es109.js.map +1 -1
  22. package/dist/index.es11.js +146 -120
  23. package/dist/index.es11.js.map +1 -1
  24. package/dist/index.es110.js +11 -906
  25. package/dist/index.es110.js.map +1 -1
  26. package/dist/index.es111.js +483 -262
  27. package/dist/index.es111.js.map +1 -1
  28. package/dist/index.es112.js +7 -4
  29. package/dist/index.es112.js.map +1 -1
  30. package/dist/index.es113.js +2 -446
  31. package/dist/index.es113.js.map +1 -1
  32. package/dist/index.es114.js +141 -41
  33. package/dist/index.es114.js.map +1 -1
  34. package/dist/index.es115.js +904 -20
  35. package/dist/index.es115.js.map +1 -1
  36. package/dist/index.es116.js +267 -66
  37. package/dist/index.es116.js.map +1 -1
  38. package/dist/index.es117.js +3 -130
  39. package/dist/index.es117.js.map +1 -1
  40. package/dist/index.es118.js +437 -42
  41. package/dist/index.es118.js.map +1 -1
  42. package/dist/index.es119.js +46 -10
  43. package/dist/index.es119.js.map +1 -1
  44. package/dist/index.es12.js +13 -103
  45. package/dist/index.es12.js.map +1 -1
  46. package/dist/index.es120.js +22 -45
  47. package/dist/index.es120.js.map +1 -1
  48. package/dist/index.es121.js +72 -92
  49. package/dist/index.es121.js.map +1 -1
  50. package/dist/index.es122.js +126 -50
  51. package/dist/index.es122.js.map +1 -1
  52. package/dist/index.es123.js +46 -13
  53. package/dist/index.es123.js.map +1 -1
  54. package/dist/index.es124.js +9 -14
  55. package/dist/index.es124.js.map +1 -1
  56. package/dist/index.es125.js +45 -89
  57. package/dist/index.es125.js.map +1 -1
  58. package/dist/index.es126.js +99 -2
  59. package/dist/index.es126.js.map +1 -1
  60. package/dist/index.es127.js +48 -51
  61. package/dist/index.es127.js.map +1 -1
  62. package/dist/index.es128.js +14 -99
  63. package/dist/index.es128.js.map +1 -1
  64. package/dist/index.es129.js +88 -190
  65. package/dist/index.es129.js.map +1 -1
  66. package/dist/index.es13.js +126 -33
  67. package/dist/index.es13.js.map +1 -1
  68. package/dist/index.es130.js +2 -110
  69. package/dist/index.es130.js.map +1 -1
  70. package/dist/index.es131.js +163 -34
  71. package/dist/index.es131.js.map +1 -1
  72. package/dist/index.es132.js +2 -10
  73. package/dist/index.es132.js.map +1 -1
  74. package/dist/index.es133.js +55 -10
  75. package/dist/index.es133.js.map +1 -1
  76. package/dist/index.es134.js +99 -11
  77. package/dist/index.es134.js.map +1 -1
  78. package/dist/index.es135.js +181 -81
  79. package/dist/index.es135.js.map +1 -1
  80. package/dist/index.es136.js +105 -270
  81. package/dist/index.es136.js.map +1 -1
  82. package/dist/index.es137.js +35 -2
  83. package/dist/index.es137.js.map +1 -1
  84. package/dist/index.es138.js +10 -164
  85. package/dist/index.es138.js.map +1 -1
  86. package/dist/index.es139.js +11 -51
  87. package/dist/index.es139.js.map +1 -1
  88. package/dist/index.es140.js +11 -39
  89. package/dist/index.es140.js.map +1 -1
  90. package/dist/index.es141.js +89 -33
  91. package/dist/index.es141.js.map +1 -1
  92. package/dist/index.es142.js +264 -29
  93. package/dist/index.es142.js.map +1 -1
  94. package/dist/index.es143.js +2 -24
  95. package/dist/index.es143.js.map +1 -1
  96. package/dist/index.es144.js +158 -585
  97. package/dist/index.es144.js.map +1 -1
  98. package/dist/index.es145.js +44 -118
  99. package/dist/index.es145.js.map +1 -1
  100. package/dist/index.es146.js +34 -158
  101. package/dist/index.es146.js.map +1 -1
  102. package/dist/index.es147.js +35 -2
  103. package/dist/index.es147.js.map +1 -1
  104. package/dist/index.es148.js +40 -2
  105. package/dist/index.es148.js.map +1 -1
  106. package/dist/index.es149.js +24 -2
  107. package/dist/index.es149.js.map +1 -1
  108. package/dist/index.es15.js +15 -15
  109. package/dist/index.es150.js +589 -20
  110. package/dist/index.es150.js.map +1 -1
  111. package/dist/index.es151.js +125 -2
  112. package/dist/index.es151.js.map +1 -1
  113. package/dist/index.es152.js +3 -24
  114. package/dist/index.es152.js.map +1 -1
  115. package/dist/index.es153.js +2 -4
  116. package/dist/index.es153.js.map +1 -1
  117. package/dist/index.es154.js +2 -5
  118. package/dist/index.es154.js.map +1 -1
  119. package/dist/index.es155.js +22 -13
  120. package/dist/index.es155.js.map +1 -1
  121. package/dist/index.es156.js +2 -6
  122. package/dist/index.es156.js.map +1 -1
  123. package/dist/index.es157.js +25 -8
  124. package/dist/index.es157.js.map +1 -1
  125. package/dist/index.es158.js +5 -64
  126. package/dist/index.es158.js.map +1 -1
  127. package/dist/index.es159.js +12 -21
  128. package/dist/index.es159.js.map +1 -1
  129. package/dist/index.es16.js +2 -2
  130. package/dist/index.es160.js +5 -5
  131. package/dist/index.es160.js.map +1 -1
  132. package/dist/index.es161.js +8 -349
  133. package/dist/index.es161.js.map +1 -1
  134. package/dist/index.es162.js +1 -1
  135. package/dist/index.es163.js +1 -1
  136. package/dist/index.es164.js +3 -3
  137. package/dist/index.es165.js +63 -6
  138. package/dist/index.es165.js.map +1 -1
  139. package/dist/index.es166.js +21 -102
  140. package/dist/index.es166.js.map +1 -1
  141. package/dist/index.es167.js +5 -118
  142. package/dist/index.es167.js.map +1 -1
  143. package/dist/index.es168.js +330 -117
  144. package/dist/index.es168.js.map +1 -1
  145. package/dist/index.es169.js +6 -114
  146. package/dist/index.es169.js.map +1 -1
  147. package/dist/index.es17.js +2 -2
  148. package/dist/index.es170.js +103 -6
  149. package/dist/index.es170.js.map +1 -1
  150. package/dist/index.es171.js +119 -2
  151. package/dist/index.es171.js.map +1 -1
  152. package/dist/index.es172.js +134 -140
  153. package/dist/index.es172.js.map +1 -1
  154. package/dist/index.es173.js +115 -2
  155. package/dist/index.es173.js.map +1 -1
  156. package/dist/index.es174.js +6 -3737
  157. package/dist/index.es174.js.map +1 -1
  158. package/dist/index.es175.js +2 -342
  159. package/dist/index.es175.js.map +1 -1
  160. package/dist/index.es176.js +138 -105
  161. package/dist/index.es176.js.map +1 -1
  162. package/dist/index.es177.js +2 -133
  163. package/dist/index.es177.js.map +1 -1
  164. package/dist/index.es178.js +3734 -12
  165. package/dist/index.es178.js.map +1 -1
  166. package/dist/index.es179.js +326 -136
  167. package/dist/index.es179.js.map +1 -1
  168. package/dist/index.es180.js +107 -13
  169. package/dist/index.es180.js.map +1 -1
  170. package/dist/index.es181.js +131 -6
  171. package/dist/index.es181.js.map +1 -1
  172. package/dist/index.es182.js +13 -19
  173. package/dist/index.es182.js.map +1 -1
  174. package/dist/index.es183.js +139 -77
  175. package/dist/index.es183.js.map +1 -1
  176. package/dist/index.es184.js +13 -241
  177. package/dist/index.es184.js.map +1 -1
  178. package/dist/index.es185.js +8 -24
  179. package/dist/index.es185.js.map +1 -1
  180. package/dist/index.es186.js +21 -6
  181. package/dist/index.es186.js.map +1 -1
  182. package/dist/index.es187.js +90 -4
  183. package/dist/index.es187.js.map +1 -1
  184. package/dist/index.es188.js +240 -15
  185. package/dist/index.es188.js.map +1 -1
  186. package/dist/index.es189.js +24 -8
  187. package/dist/index.es189.js.map +1 -1
  188. package/dist/index.es19.js +15 -119
  189. package/dist/index.es19.js.map +1 -1
  190. package/dist/index.es190.js +5 -31
  191. package/dist/index.es190.js.map +1 -1
  192. package/dist/index.es191.js +4 -6
  193. package/dist/index.es191.js.map +1 -1
  194. package/dist/index.es192.js +17 -105
  195. package/dist/index.es192.js.map +1 -1
  196. package/dist/index.es193.js +6 -11
  197. package/dist/index.es193.js.map +1 -1
  198. package/dist/index.es194.js +32 -18
  199. package/dist/index.es194.js.map +1 -1
  200. package/dist/index.es195.js +6 -31
  201. package/dist/index.es195.js.map +1 -1
  202. package/dist/index.es196.js +106 -4
  203. package/dist/index.es196.js.map +1 -1
  204. package/dist/index.es197.js +12 -4
  205. package/dist/index.es197.js.map +1 -1
  206. package/dist/index.es198.js +17 -4
  207. package/dist/index.es198.js.map +1 -1
  208. package/dist/index.es199.js +21 -27
  209. package/dist/index.es199.js.map +1 -1
  210. package/dist/index.es2.js +25 -16
  211. package/dist/index.es2.js.map +1 -1
  212. package/dist/index.es20.js +37 -17
  213. package/dist/index.es20.js.map +1 -1
  214. package/dist/index.es200.js +3 -7
  215. package/dist/index.es200.js.map +1 -1
  216. package/dist/index.es201.js +3 -4
  217. package/dist/index.es201.js.map +1 -1
  218. package/dist/index.es202.js +5 -7
  219. package/dist/index.es202.js.map +1 -1
  220. package/dist/index.es203.js +36 -41
  221. package/dist/index.es203.js.map +1 -1
  222. package/dist/index.es204.js +5 -10
  223. package/dist/index.es204.js.map +1 -1
  224. package/dist/index.es205.js +5 -241
  225. package/dist/index.es205.js.map +1 -1
  226. package/dist/index.es206.js +5 -49
  227. package/dist/index.es206.js.map +1 -1
  228. package/dist/index.es207.js +29 -22
  229. package/dist/index.es207.js.map +1 -1
  230. package/dist/index.es208.js +10 -10
  231. package/dist/index.es208.js.map +1 -1
  232. package/dist/index.es209.js +241 -7
  233. package/dist/index.es209.js.map +1 -1
  234. package/dist/index.es21.js +27 -67
  235. package/dist/index.es21.js.map +1 -1
  236. package/dist/index.es210.js +50 -6
  237. package/dist/index.es210.js.map +1 -1
  238. package/dist/index.es211.js +30 -60
  239. package/dist/index.es211.js.map +1 -1
  240. package/dist/index.es212.js +11 -39
  241. package/dist/index.es212.js.map +1 -1
  242. package/dist/index.es213.js +7 -31
  243. package/dist/index.es213.js.map +1 -1
  244. package/dist/index.es214.js +6 -61
  245. package/dist/index.es214.js.map +1 -1
  246. package/dist/index.es215.js +58 -8
  247. package/dist/index.es215.js.map +1 -1
  248. package/dist/index.es216.js +34 -16
  249. package/dist/index.es216.js.map +1 -1
  250. package/dist/index.es217.js +31 -4
  251. package/dist/index.es217.js.map +1 -1
  252. package/dist/index.es218.js +58 -13
  253. package/dist/index.es218.js.map +1 -1
  254. package/dist/index.es219.js +14 -32
  255. package/dist/index.es219.js.map +1 -1
  256. package/dist/index.es22.js +140 -30
  257. package/dist/index.es22.js.map +1 -1
  258. package/dist/index.es220.js +23 -5
  259. package/dist/index.es220.js.map +1 -1
  260. package/dist/index.es221.js +4 -4
  261. package/dist/index.es221.js.map +1 -1
  262. package/dist/index.es222.js +16 -4
  263. package/dist/index.es222.js.map +1 -1
  264. package/dist/index.es223.js +32 -7
  265. package/dist/index.es223.js.map +1 -1
  266. package/dist/index.es224.js +4 -91
  267. package/dist/index.es224.js.map +1 -1
  268. package/dist/index.es225.js +4 -17
  269. package/dist/index.es225.js.map +1 -1
  270. package/dist/index.es226.js +5 -762
  271. package/dist/index.es226.js.map +1 -1
  272. package/dist/index.es227.js +8 -66
  273. package/dist/index.es227.js.map +1 -1
  274. package/dist/index.es228.js +83 -165
  275. package/dist/index.es228.js.map +1 -1
  276. package/dist/index.es229.js +16 -36
  277. package/dist/index.es229.js.map +1 -1
  278. package/dist/index.es23.js +17 -32
  279. package/dist/index.es23.js.map +1 -1
  280. package/dist/index.es230.js +761 -136
  281. package/dist/index.es230.js.map +1 -1
  282. package/dist/index.es231.js +66 -93
  283. package/dist/index.es231.js.map +1 -1
  284. package/dist/index.es232.js +172 -31
  285. package/dist/index.es232.js.map +1 -1
  286. package/dist/index.es233.js +129 -277
  287. package/dist/index.es233.js.map +1 -1
  288. package/dist/index.es234.js +92 -25
  289. package/dist/index.es234.js.map +1 -1
  290. package/dist/index.es235.js +31 -22
  291. package/dist/index.es235.js.map +1 -1
  292. package/dist/index.es236.js +284 -14
  293. package/dist/index.es236.js.map +1 -1
  294. package/dist/index.es237.js +24 -13
  295. package/dist/index.es237.js.map +1 -1
  296. package/dist/index.es238.js +17 -19
  297. package/dist/index.es238.js.map +1 -1
  298. package/dist/index.es239.js +12 -43
  299. package/dist/index.es239.js.map +1 -1
  300. package/dist/index.es24.js +57 -136
  301. package/dist/index.es24.js.map +1 -1
  302. package/dist/index.es240.js +14 -11
  303. package/dist/index.es240.js.map +1 -1
  304. package/dist/index.es241.js +24 -10
  305. package/dist/index.es241.js.map +1 -1
  306. package/dist/index.es242.js +45 -11
  307. package/dist/index.es242.js.map +1 -1
  308. package/dist/index.es243.js +11 -14
  309. package/dist/index.es243.js.map +1 -1
  310. package/dist/index.es244.js +10 -10
  311. package/dist/index.es244.js.map +1 -1
  312. package/dist/index.es245.js +11 -11
  313. package/dist/index.es245.js.map +1 -1
  314. package/dist/index.es246.js +14 -11
  315. package/dist/index.es246.js.map +1 -1
  316. package/dist/index.es247.js +10 -14
  317. package/dist/index.es247.js.map +1 -1
  318. package/dist/index.es248.js +11 -11
  319. package/dist/index.es248.js.map +1 -1
  320. package/dist/index.es249.js +11 -11
  321. package/dist/index.es249.js.map +1 -1
  322. package/dist/index.es25.js +298 -94
  323. package/dist/index.es25.js.map +1 -1
  324. package/dist/index.es250.js +15 -11
  325. package/dist/index.es250.js.map +1 -1
  326. package/dist/index.es251.js +11 -11
  327. package/dist/index.es251.js.map +1 -1
  328. package/dist/index.es252.js +11 -11
  329. package/dist/index.es252.js.map +1 -1
  330. package/dist/index.es253.js +10 -10
  331. package/dist/index.es253.js.map +1 -1
  332. package/dist/index.es254.js +10 -10
  333. package/dist/index.es254.js.map +1 -1
  334. package/dist/index.es255.js +10 -10
  335. package/dist/index.es255.js.map +1 -1
  336. package/dist/index.es256.js +11 -56
  337. package/dist/index.es256.js.map +1 -1
  338. package/dist/index.es257.js +11 -49
  339. package/dist/index.es257.js.map +1 -1
  340. package/dist/index.es258.js +11 -119
  341. package/dist/index.es258.js.map +1 -1
  342. package/dist/index.es259.js +56 -384
  343. package/dist/index.es259.js.map +1 -1
  344. package/dist/index.es26.js +116 -65
  345. package/dist/index.es26.js.map +1 -1
  346. package/dist/index.es260.js +47 -16
  347. package/dist/index.es260.js.map +1 -1
  348. package/dist/index.es261.js +118 -10
  349. package/dist/index.es261.js.map +1 -1
  350. package/dist/index.es262.js +379 -26
  351. package/dist/index.es262.js.map +1 -1
  352. package/dist/index.es263.js +13 -26
  353. package/dist/index.es263.js.map +1 -1
  354. package/dist/index.es264.js +10 -61
  355. package/dist/index.es264.js.map +1 -1
  356. package/dist/index.es265.js +25 -11
  357. package/dist/index.es265.js.map +1 -1
  358. package/dist/index.es266.js +25 -71
  359. package/dist/index.es266.js.map +1 -1
  360. package/dist/index.es267.js +62 -11
  361. package/dist/index.es267.js.map +1 -1
  362. package/dist/index.es268.js +17 -11
  363. package/dist/index.es268.js.map +1 -1
  364. package/dist/index.es269.js +75 -13
  365. package/dist/index.es269.js.map +1 -1
  366. package/dist/index.es27.js +91 -168
  367. package/dist/index.es27.js.map +1 -1
  368. package/dist/index.es270.js +11 -52
  369. package/dist/index.es270.js.map +1 -1
  370. package/dist/index.es271.js +11 -166
  371. package/dist/index.es271.js.map +1 -1
  372. package/dist/index.es272.js +16 -2
  373. package/dist/index.es272.js.map +1 -1
  374. package/dist/index.es273.js +51 -9
  375. package/dist/index.es273.js.map +1 -1
  376. package/dist/index.es274.js +165 -18
  377. package/dist/index.es274.js.map +1 -1
  378. package/dist/index.es275.js +36 -37
  379. package/dist/index.es275.js.map +1 -1
  380. package/dist/index.es276.js +5 -0
  381. package/dist/index.es276.js.map +1 -0
  382. package/dist/index.es277.js +14 -0
  383. package/dist/index.es277.js.map +1 -0
  384. package/dist/index.es278.js +23 -0
  385. package/dist/index.es278.js.map +1 -0
  386. package/dist/index.es279.js +42 -0
  387. package/dist/index.es279.js.map +1 -0
  388. package/dist/index.es28.js +68 -24
  389. package/dist/index.es28.js.map +1 -1
  390. package/dist/index.es29.js +178 -12
  391. package/dist/index.es29.js.map +1 -1
  392. package/dist/index.es30.js +23 -437
  393. package/dist/index.es30.js.map +1 -1
  394. package/dist/index.es31.js +13 -15
  395. package/dist/index.es31.js.map +1 -1
  396. package/dist/index.es32.js +429 -107
  397. package/dist/index.es32.js.map +1 -1
  398. package/dist/index.es33.js +112 -65
  399. package/dist/index.es33.js.map +1 -1
  400. package/dist/index.es34.js +71 -18
  401. package/dist/index.es34.js.map +1 -1
  402. package/dist/index.es35.js +17 -260
  403. package/dist/index.es35.js.map +1 -1
  404. package/dist/index.es36.js +249 -31
  405. package/dist/index.es36.js.map +1 -1
  406. package/dist/index.es37.js +27 -199
  407. package/dist/index.es37.js.map +1 -1
  408. package/dist/index.es38.js +198 -50
  409. package/dist/index.es38.js.map +1 -1
  410. package/dist/index.es39.js +45 -120
  411. package/dist/index.es39.js.map +1 -1
  412. package/dist/index.es40.js +132 -14
  413. package/dist/index.es40.js.map +1 -1
  414. package/dist/index.es41.js +19 -225
  415. package/dist/index.es41.js.map +1 -1
  416. package/dist/index.es42.js +229 -8
  417. package/dist/index.es42.js.map +1 -1
  418. package/dist/index.es43.js +7 -1190
  419. package/dist/index.es43.js.map +1 -1
  420. package/dist/index.es44.js +1191 -6
  421. package/dist/index.es44.js.map +1 -1
  422. package/dist/index.es45.js +6 -146
  423. package/dist/index.es45.js.map +1 -1
  424. package/dist/index.es46.js +147 -7
  425. package/dist/index.es46.js.map +1 -1
  426. package/dist/index.es47.js +15 -92
  427. package/dist/index.es47.js.map +1 -1
  428. package/dist/index.es49.js +5 -35
  429. package/dist/index.es49.js.map +1 -1
  430. package/dist/index.es50.js +7 -71
  431. package/dist/index.es50.js.map +1 -1
  432. package/dist/index.es51.js +89 -33
  433. package/dist/index.es51.js.map +1 -1
  434. package/dist/index.es52.js +3 -305
  435. package/dist/index.es52.js.map +1 -1
  436. package/dist/index.es53.js +36 -9
  437. package/dist/index.es53.js.map +1 -1
  438. package/dist/index.es54.js +64 -83
  439. package/dist/index.es54.js.map +1 -1
  440. package/dist/index.es55.js +36 -6
  441. package/dist/index.es55.js.map +1 -1
  442. package/dist/index.es56.js +303 -12
  443. package/dist/index.es56.js.map +1 -1
  444. package/dist/index.es57.js +9 -143
  445. package/dist/index.es57.js.map +1 -1
  446. package/dist/index.es58.js +83 -292
  447. package/dist/index.es58.js.map +1 -1
  448. package/dist/index.es59.js +6 -64
  449. package/dist/index.es59.js.map +1 -1
  450. package/dist/index.es6.js +21 -5
  451. package/dist/index.es6.js.map +1 -1
  452. package/dist/index.es60.js +12 -210
  453. package/dist/index.es60.js.map +1 -1
  454. package/dist/index.es61.js +138 -29
  455. package/dist/index.es61.js.map +1 -1
  456. package/dist/index.es62.js +299 -8
  457. package/dist/index.es62.js.map +1 -1
  458. package/dist/index.es63.js +65 -11
  459. package/dist/index.es63.js.map +1 -1
  460. package/dist/index.es64.js +201 -175
  461. package/dist/index.es64.js.map +1 -1
  462. package/dist/index.es65.js +33 -23
  463. package/dist/index.es65.js.map +1 -1
  464. package/dist/index.es66.js +8 -1399
  465. package/dist/index.es66.js.map +1 -1
  466. package/dist/index.es67.js +12 -9
  467. package/dist/index.es67.js.map +1 -1
  468. package/dist/index.es68.js +187 -8
  469. package/dist/index.es68.js.map +1 -1
  470. package/dist/index.es69.js +24 -6
  471. package/dist/index.es69.js.map +1 -1
  472. package/dist/index.es70.js +1384 -147
  473. package/dist/index.es70.js.map +1 -1
  474. package/dist/index.es71.js +9 -672
  475. package/dist/index.es71.js.map +1 -1
  476. package/dist/index.es72.js +8 -12
  477. package/dist/index.es72.js.map +1 -1
  478. package/dist/index.es73.js +6 -40
  479. package/dist/index.es73.js.map +1 -1
  480. package/dist/index.es74.js +155 -26
  481. package/dist/index.es74.js.map +1 -1
  482. package/dist/index.es75.js +657 -217
  483. package/dist/index.es75.js.map +1 -1
  484. package/dist/index.es76.js +11 -29
  485. package/dist/index.es76.js.map +1 -1
  486. package/dist/index.es77.js +37 -72
  487. package/dist/index.es77.js.map +1 -1
  488. package/dist/index.es78.js +32 -74
  489. package/dist/index.es78.js.map +1 -1
  490. package/dist/index.es79.js +226 -46
  491. package/dist/index.es79.js.map +1 -1
  492. package/dist/index.es80.js +6 -6
  493. package/dist/index.es80.js.map +1 -1
  494. package/dist/index.es81.js +71 -39
  495. package/dist/index.es81.js.map +1 -1
  496. package/dist/index.es82.js +73 -54
  497. package/dist/index.es82.js.map +1 -1
  498. package/dist/index.es83.js +52 -13
  499. package/dist/index.es83.js.map +1 -1
  500. package/dist/index.es84.js +28 -135
  501. package/dist/index.es84.js.map +1 -1
  502. package/dist/index.es85.js +42 -20
  503. package/dist/index.es85.js.map +1 -1
  504. package/dist/index.es86.js +36 -181
  505. package/dist/index.es86.js.map +1 -1
  506. package/dist/index.es87.js +5 -241
  507. package/dist/index.es87.js.map +1 -1
  508. package/dist/index.es88.js +65 -347
  509. package/dist/index.es88.js.map +1 -1
  510. package/dist/index.es89.js +31 -131
  511. package/dist/index.es89.js.map +1 -1
  512. package/dist/index.es90.js +49 -62
  513. package/dist/index.es90.js.map +1 -1
  514. package/dist/index.es91.js +13 -37
  515. package/dist/index.es91.js.map +1 -1
  516. package/dist/index.es92.js +134 -34
  517. package/dist/index.es92.js.map +1 -1
  518. package/dist/index.es93.js +20 -165
  519. package/dist/index.es93.js.map +1 -1
  520. package/dist/index.es94.js +162 -183
  521. package/dist/index.es94.js.map +1 -1
  522. package/dist/index.es95.js +240 -13
  523. package/dist/index.es95.js.map +1 -1
  524. package/dist/index.es96.js +352 -27
  525. package/dist/index.es96.js.map +1 -1
  526. package/dist/index.es97.js +130 -27
  527. package/dist/index.es97.js.map +1 -1
  528. package/dist/index.es98.js +64 -3151
  529. package/dist/index.es98.js.map +1 -1
  530. package/dist/index.es99.js +34 -34
  531. package/dist/index.es99.js.map +1 -1
  532. package/dist/langgraph-ui-components.css +107 -0
  533. package/dist/styles.css +1 -1
  534. package/package.json +8 -7
  535. package/dist/index.es48.js +0 -7
  536. package/dist/index.es48.js.map +0 -1
@@ -1,504 +1,3160 @@
1
- import { __export } from "./index.es46.js";
2
- import { getBufferString } from "./index.es41.js";
3
- import { getEnvironmentVariable } from "./index.es127.js";
4
- import { isBaseCallbackHandler, BaseCallbackHandler } from "./index.es128.js";
5
- import { isBaseTracer } from "./index.es113.js";
6
- import { ConsoleCallbackHandler } from "./index.es129.js";
7
- import { LangChainTracer } from "./index.es130.js";
8
- import { consumeCallback } from "./index.es131.js";
9
- import "./index.es132.js";
10
- import { isTracingEnabled } from "./index.es133.js";
11
- import { _getConfigureHooks, getContextVariable } from "./index.es134.js";
12
- import { v7 } from "uuid";
13
- var manager_exports = {};
14
- __export(manager_exports, {
15
- BaseCallbackManager: () => BaseCallbackManager,
16
- BaseRunManager: () => BaseRunManager,
17
- CallbackManager: () => CallbackManager,
18
- CallbackManagerForChainRun: () => CallbackManagerForChainRun,
19
- CallbackManagerForLLMRun: () => CallbackManagerForLLMRun,
20
- CallbackManagerForRetrieverRun: () => CallbackManagerForRetrieverRun,
21
- CallbackManagerForToolRun: () => CallbackManagerForToolRun,
22
- ensureHandler: () => ensureHandler,
23
- parseCallbackConfigArg: () => parseCallbackConfigArg
24
- });
25
- function parseCallbackConfigArg(arg) {
26
- if (!arg) return {};
27
- else if (Array.isArray(arg) || "name" in arg) return { callbacks: arg };
28
- else return arg;
29
- }
30
- var BaseCallbackManager = class {
31
- setHandler(handler) {
32
- return this.setHandlers([handler]);
33
- }
34
- };
35
- var BaseRunManager = class {
36
- constructor(runId, handlers, inheritableHandlers, tags, inheritableTags, metadata, inheritableMetadata, _parentRunId) {
37
- this.runId = runId;
38
- this.handlers = handlers;
39
- this.inheritableHandlers = inheritableHandlers;
40
- this.tags = tags;
41
- this.inheritableTags = inheritableTags;
42
- this.metadata = metadata;
43
- this.inheritableMetadata = inheritableMetadata;
44
- this._parentRunId = _parentRunId;
45
- }
46
- get parentRunId() {
47
- return this._parentRunId;
48
- }
49
- async handleText(text) {
50
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
51
- try {
52
- await handler.handleText?.(text, this.runId, this._parentRunId, this.tags);
53
- } catch (err) {
54
- const logFunction = handler.raiseError ? console.error : console.warn;
55
- logFunction(`Error in handler ${handler.constructor.name}, handleText: ${err}`);
56
- if (handler.raiseError) throw err;
1
+ import { ZodIssueCode, ZodError } from "./index.es173.js";
2
+ import { getParsedType, util, ZodParsedType } from "./index.es172.js";
3
+ import { errorUtil } from "./index.es174.js";
4
+ import { OK, ParseStatus, isAsync, isValid, addIssueToContext, INVALID, DIRTY, isAborted, isDirty } from "./index.es171.js";
5
+ class ParseInputLazyPath {
6
+ constructor(parent, value, path, key) {
7
+ this._cachedPath = [];
8
+ this.parent = parent;
9
+ this.data = value;
10
+ this._path = path;
11
+ this._key = key;
12
+ }
13
+ get path() {
14
+ if (!this._cachedPath.length) {
15
+ if (Array.isArray(this._key)) {
16
+ this._cachedPath.push(...this._path, ...this._key);
17
+ } else {
18
+ this._cachedPath.push(...this._path, this._key);
57
19
  }
58
- }, handler.awaitHandlers)));
20
+ }
21
+ return this._cachedPath;
59
22
  }
60
- async handleCustomEvent(eventName, data, _runId, _tags, _metadata) {
61
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
62
- try {
63
- await handler.handleCustomEvent?.(eventName, data, this.runId, this.tags, this.metadata);
64
- } catch (err) {
65
- const logFunction = handler.raiseError ? console.error : console.warn;
66
- logFunction(`Error in handler ${handler.constructor.name}, handleCustomEvent: ${err}`);
67
- if (handler.raiseError) throw err;
68
- }
69
- }, handler.awaitHandlers)));
70
- }
71
- };
72
- var CallbackManagerForRetrieverRun = class extends BaseRunManager {
73
- getChild(tag) {
74
- const manager = new CallbackManager(this.runId);
75
- manager.setHandlers(this.inheritableHandlers);
76
- manager.addTags(this.inheritableTags);
77
- manager.addMetadata(this.inheritableMetadata);
78
- if (tag) manager.addTags([tag], false);
79
- return manager;
80
- }
81
- async handleRetrieverEnd(documents) {
82
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
83
- if (!handler.ignoreRetriever) try {
84
- await handler.handleRetrieverEnd?.(documents, this.runId, this._parentRunId, this.tags);
85
- } catch (err) {
86
- const logFunction = handler.raiseError ? console.error : console.warn;
87
- logFunction(`Error in handler ${handler.constructor.name}, handleRetriever`);
88
- if (handler.raiseError) throw err;
89
- }
90
- }, handler.awaitHandlers)));
91
- }
92
- async handleRetrieverError(err) {
93
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
94
- if (!handler.ignoreRetriever) try {
95
- await handler.handleRetrieverError?.(err, this.runId, this._parentRunId, this.tags);
96
- } catch (error) {
97
- const logFunction = handler.raiseError ? console.error : console.warn;
98
- logFunction(`Error in handler ${handler.constructor.name}, handleRetrieverError: ${error}`);
99
- if (handler.raiseError) throw err;
100
- }
101
- }, handler.awaitHandlers)));
102
- }
103
- };
104
- var CallbackManagerForLLMRun = class extends BaseRunManager {
105
- async handleLLMNewToken(token, idx, _runId, _parentRunId, _tags, fields) {
106
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
107
- if (!handler.ignoreLLM) try {
108
- await handler.handleLLMNewToken?.(token, idx ?? {
109
- prompt: 0,
110
- completion: 0
111
- }, this.runId, this._parentRunId, this.tags, fields);
112
- } catch (err) {
113
- const logFunction = handler.raiseError ? console.error : console.warn;
114
- logFunction(`Error in handler ${handler.constructor.name}, handleLLMNewToken: ${err}`);
115
- if (handler.raiseError) throw err;
116
- }
117
- }, handler.awaitHandlers)));
118
- }
119
- async handleLLMError(err, _runId, _parentRunId, _tags, extraParams) {
120
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
121
- if (!handler.ignoreLLM) try {
122
- await handler.handleLLMError?.(err, this.runId, this._parentRunId, this.tags, extraParams);
123
- } catch (err$1) {
124
- const logFunction = handler.raiseError ? console.error : console.warn;
125
- logFunction(`Error in handler ${handler.constructor.name}, handleLLMError: ${err$1}`);
126
- if (handler.raiseError) throw err$1;
127
- }
128
- }, handler.awaitHandlers)));
129
- }
130
- async handleLLMEnd(output, _runId, _parentRunId, _tags, extraParams) {
131
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
132
- if (!handler.ignoreLLM) try {
133
- await handler.handleLLMEnd?.(output, this.runId, this._parentRunId, this.tags, extraParams);
134
- } catch (err) {
135
- const logFunction = handler.raiseError ? console.error : console.warn;
136
- logFunction(`Error in handler ${handler.constructor.name}, handleLLMEnd: ${err}`);
137
- if (handler.raiseError) throw err;
138
- }
139
- }, handler.awaitHandlers)));
140
- }
141
- };
142
- var CallbackManagerForChainRun = class extends BaseRunManager {
143
- getChild(tag) {
144
- const manager = new CallbackManager(this.runId);
145
- manager.setHandlers(this.inheritableHandlers);
146
- manager.addTags(this.inheritableTags);
147
- manager.addMetadata(this.inheritableMetadata);
148
- if (tag) manager.addTags([tag], false);
149
- return manager;
150
- }
151
- async handleChainError(err, _runId, _parentRunId, _tags, kwargs) {
152
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
153
- if (!handler.ignoreChain) try {
154
- await handler.handleChainError?.(err, this.runId, this._parentRunId, this.tags, kwargs);
155
- } catch (err$1) {
156
- const logFunction = handler.raiseError ? console.error : console.warn;
157
- logFunction(`Error in handler ${handler.constructor.name}, handleChainError: ${err$1}`);
158
- if (handler.raiseError) throw err$1;
159
- }
160
- }, handler.awaitHandlers)));
161
- }
162
- async handleChainEnd(output, _runId, _parentRunId, _tags, kwargs) {
163
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
164
- if (!handler.ignoreChain) try {
165
- await handler.handleChainEnd?.(output, this.runId, this._parentRunId, this.tags, kwargs);
166
- } catch (err) {
167
- const logFunction = handler.raiseError ? console.error : console.warn;
168
- logFunction(`Error in handler ${handler.constructor.name}, handleChainEnd: ${err}`);
169
- if (handler.raiseError) throw err;
23
+ }
24
+ const handleResult = (ctx, result) => {
25
+ if (isValid(result)) {
26
+ return { success: true, data: result.value };
27
+ } else {
28
+ if (!ctx.common.issues.length) {
29
+ throw new Error("Validation failed but no issues detected.");
30
+ }
31
+ return {
32
+ success: false,
33
+ get error() {
34
+ if (this._error)
35
+ return this._error;
36
+ const error = new ZodError(ctx.common.issues);
37
+ this._error = error;
38
+ return this._error;
170
39
  }
171
- }, handler.awaitHandlers)));
40
+ };
172
41
  }
173
- async handleAgentAction(action) {
174
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
175
- if (!handler.ignoreAgent) try {
176
- await handler.handleAgentAction?.(action, this.runId, this._parentRunId, this.tags);
177
- } catch (err) {
178
- const logFunction = handler.raiseError ? console.error : console.warn;
179
- logFunction(`Error in handler ${handler.constructor.name}, handleAgentAction: ${err}`);
180
- if (handler.raiseError) throw err;
42
+ };
43
+ function processCreateParams(params) {
44
+ if (!params)
45
+ return {};
46
+ const { errorMap, invalid_type_error, required_error, description } = params;
47
+ if (errorMap && (invalid_type_error || required_error)) {
48
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
49
+ }
50
+ if (errorMap)
51
+ return { errorMap, description };
52
+ const customMap = (iss, ctx) => {
53
+ const { message } = params;
54
+ if (iss.code === "invalid_enum_value") {
55
+ return { message: message ?? ctx.defaultError };
56
+ }
57
+ if (typeof ctx.data === "undefined") {
58
+ return { message: message ?? required_error ?? ctx.defaultError };
59
+ }
60
+ if (iss.code !== "invalid_type")
61
+ return { message: ctx.defaultError };
62
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
63
+ };
64
+ return { errorMap: customMap, description };
65
+ }
66
+ class ZodType {
67
+ get description() {
68
+ return this._def.description;
69
+ }
70
+ _getType(input) {
71
+ return getParsedType(input.data);
72
+ }
73
+ _getOrReturnCtx(input, ctx) {
74
+ return ctx || {
75
+ common: input.parent.common,
76
+ data: input.data,
77
+ parsedType: getParsedType(input.data),
78
+ schemaErrorMap: this._def.errorMap,
79
+ path: input.path,
80
+ parent: input.parent
81
+ };
82
+ }
83
+ _processInputParams(input) {
84
+ return {
85
+ status: new ParseStatus(),
86
+ ctx: {
87
+ common: input.parent.common,
88
+ data: input.data,
89
+ parsedType: getParsedType(input.data),
90
+ schemaErrorMap: this._def.errorMap,
91
+ path: input.path,
92
+ parent: input.parent
181
93
  }
182
- }, handler.awaitHandlers)));
94
+ };
183
95
  }
184
- async handleAgentEnd(action) {
185
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
186
- if (!handler.ignoreAgent) try {
187
- await handler.handleAgentEnd?.(action, this.runId, this._parentRunId, this.tags);
188
- } catch (err) {
189
- const logFunction = handler.raiseError ? console.error : console.warn;
190
- logFunction(`Error in handler ${handler.constructor.name}, handleAgentEnd: ${err}`);
191
- if (handler.raiseError) throw err;
192
- }
193
- }, handler.awaitHandlers)));
194
- }
195
- };
196
- var CallbackManagerForToolRun = class extends BaseRunManager {
197
- getChild(tag) {
198
- const manager = new CallbackManager(this.runId);
199
- manager.setHandlers(this.inheritableHandlers);
200
- manager.addTags(this.inheritableTags);
201
- manager.addMetadata(this.inheritableMetadata);
202
- if (tag) manager.addTags([tag], false);
203
- return manager;
204
- }
205
- async handleToolError(err) {
206
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
207
- if (!handler.ignoreAgent) try {
208
- await handler.handleToolError?.(err, this.runId, this._parentRunId, this.tags);
209
- } catch (err$1) {
210
- const logFunction = handler.raiseError ? console.error : console.warn;
211
- logFunction(`Error in handler ${handler.constructor.name}, handleToolError: ${err$1}`);
212
- if (handler.raiseError) throw err$1;
213
- }
214
- }, handler.awaitHandlers)));
215
- }
216
- async handleToolEnd(output) {
217
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
218
- if (!handler.ignoreAgent) try {
219
- await handler.handleToolEnd?.(output, this.runId, this._parentRunId, this.tags);
96
+ _parseSync(input) {
97
+ const result = this._parse(input);
98
+ if (isAsync(result)) {
99
+ throw new Error("Synchronous parse encountered promise.");
100
+ }
101
+ return result;
102
+ }
103
+ _parseAsync(input) {
104
+ const result = this._parse(input);
105
+ return Promise.resolve(result);
106
+ }
107
+ parse(data, params) {
108
+ const result = this.safeParse(data, params);
109
+ if (result.success)
110
+ return result.data;
111
+ throw result.error;
112
+ }
113
+ safeParse(data, params) {
114
+ const ctx = {
115
+ common: {
116
+ issues: [],
117
+ async: params?.async ?? false,
118
+ contextualErrorMap: params?.errorMap
119
+ },
120
+ path: params?.path || [],
121
+ schemaErrorMap: this._def.errorMap,
122
+ parent: null,
123
+ data,
124
+ parsedType: getParsedType(data)
125
+ };
126
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
127
+ return handleResult(ctx, result);
128
+ }
129
+ "~validate"(data) {
130
+ const ctx = {
131
+ common: {
132
+ issues: [],
133
+ async: !!this["~standard"].async
134
+ },
135
+ path: [],
136
+ schemaErrorMap: this._def.errorMap,
137
+ parent: null,
138
+ data,
139
+ parsedType: getParsedType(data)
140
+ };
141
+ if (!this["~standard"].async) {
142
+ try {
143
+ const result = this._parseSync({ data, path: [], parent: ctx });
144
+ return isValid(result) ? {
145
+ value: result.value
146
+ } : {
147
+ issues: ctx.common.issues
148
+ };
220
149
  } catch (err) {
221
- const logFunction = handler.raiseError ? console.error : console.warn;
222
- logFunction(`Error in handler ${handler.constructor.name}, handleToolEnd: ${err}`);
223
- if (handler.raiseError) throw err;
224
- }
225
- }, handler.awaitHandlers)));
226
- }
227
- };
228
- var CallbackManager = class CallbackManager2 extends BaseCallbackManager {
229
- handlers = [];
230
- inheritableHandlers = [];
231
- tags = [];
232
- inheritableTags = [];
233
- metadata = {};
234
- inheritableMetadata = {};
235
- name = "callback_manager";
236
- _parentRunId;
237
- constructor(parentRunId, options) {
238
- super();
239
- this.handlers = options?.handlers ?? this.handlers;
240
- this.inheritableHandlers = options?.inheritableHandlers ?? this.inheritableHandlers;
241
- this.tags = options?.tags ?? this.tags;
242
- this.inheritableTags = options?.inheritableTags ?? this.inheritableTags;
243
- this.metadata = options?.metadata ?? this.metadata;
244
- this.inheritableMetadata = options?.inheritableMetadata ?? this.inheritableMetadata;
245
- this._parentRunId = parentRunId;
150
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
151
+ this["~standard"].async = true;
152
+ }
153
+ ctx.common = {
154
+ issues: [],
155
+ async: true
156
+ };
157
+ }
158
+ }
159
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
160
+ value: result.value
161
+ } : {
162
+ issues: ctx.common.issues
163
+ });
246
164
  }
247
- /**
248
- * Gets the parent run ID, if any.
249
- *
250
- * @returns The parent run ID.
251
- */
252
- getParentRunId() {
253
- return this._parentRunId;
254
- }
255
- async handleLLMStart(llm, prompts, runId = void 0, _parentRunId = void 0, extraParams = void 0, _tags = void 0, _metadata = void 0, runName = void 0) {
256
- return Promise.all(prompts.map(async (prompt, idx) => {
257
- const runId_ = idx === 0 && runId ? runId : v7();
258
- await Promise.all(this.handlers.map((handler) => {
259
- if (handler.ignoreLLM) return;
260
- if (isBaseTracer(handler)) handler._createRunForLLMStart(llm, [prompt], runId_, this._parentRunId, extraParams, this.tags, this.metadata, runName);
261
- return consumeCallback(async () => {
262
- try {
263
- await handler.handleLLMStart?.(llm, [prompt], runId_, this._parentRunId, extraParams, this.tags, this.metadata, runName);
264
- } catch (err) {
265
- const logFunction = handler.raiseError ? console.error : console.warn;
266
- logFunction(`Error in handler ${handler.constructor.name}, handleLLMStart: ${err}`);
267
- if (handler.raiseError) throw err;
268
- }
269
- }, handler.awaitHandlers);
270
- }));
271
- return new CallbackManagerForLLMRun(runId_, this.handlers, this.inheritableHandlers, this.tags, this.inheritableTags, this.metadata, this.inheritableMetadata, this._parentRunId);
272
- }));
165
+ async parseAsync(data, params) {
166
+ const result = await this.safeParseAsync(data, params);
167
+ if (result.success)
168
+ return result.data;
169
+ throw result.error;
170
+ }
171
+ async safeParseAsync(data, params) {
172
+ const ctx = {
173
+ common: {
174
+ issues: [],
175
+ contextualErrorMap: params?.errorMap,
176
+ async: true
177
+ },
178
+ path: params?.path || [],
179
+ schemaErrorMap: this._def.errorMap,
180
+ parent: null,
181
+ data,
182
+ parsedType: getParsedType(data)
183
+ };
184
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
185
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
186
+ return handleResult(ctx, result);
273
187
  }
274
- async handleChatModelStart(llm, messages, runId = void 0, _parentRunId = void 0, extraParams = void 0, _tags = void 0, _metadata = void 0, runName = void 0) {
275
- return Promise.all(messages.map(async (messageGroup, idx) => {
276
- const runId_ = idx === 0 && runId ? runId : v7();
277
- await Promise.all(this.handlers.map((handler) => {
278
- if (handler.ignoreLLM) return;
279
- if (isBaseTracer(handler)) handler._createRunForChatModelStart(llm, [messageGroup], runId_, this._parentRunId, extraParams, this.tags, this.metadata, runName);
280
- return consumeCallback(async () => {
281
- try {
282
- if (handler.handleChatModelStart) await handler.handleChatModelStart?.(llm, [messageGroup], runId_, this._parentRunId, extraParams, this.tags, this.metadata, runName);
283
- else if (handler.handleLLMStart) {
284
- const messageString = getBufferString(messageGroup);
285
- await handler.handleLLMStart?.(llm, [messageString], runId_, this._parentRunId, extraParams, this.tags, this.metadata, runName);
286
- }
287
- } catch (err) {
288
- const logFunction = handler.raiseError ? console.error : console.warn;
289
- logFunction(`Error in handler ${handler.constructor.name}, handleLLMStart: ${err}`);
290
- if (handler.raiseError) throw err;
188
+ refine(check, message) {
189
+ const getIssueProperties = (val) => {
190
+ if (typeof message === "string" || typeof message === "undefined") {
191
+ return { message };
192
+ } else if (typeof message === "function") {
193
+ return message(val);
194
+ } else {
195
+ return message;
196
+ }
197
+ };
198
+ return this._refinement((val, ctx) => {
199
+ const result = check(val);
200
+ const setError = () => ctx.addIssue({
201
+ code: ZodIssueCode.custom,
202
+ ...getIssueProperties(val)
203
+ });
204
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
205
+ return result.then((data) => {
206
+ if (!data) {
207
+ setError();
208
+ return false;
209
+ } else {
210
+ return true;
291
211
  }
292
- }, handler.awaitHandlers);
293
- }));
294
- return new CallbackManagerForLLMRun(runId_, this.handlers, this.inheritableHandlers, this.tags, this.inheritableTags, this.metadata, this.inheritableMetadata, this._parentRunId);
295
- }));
212
+ });
213
+ }
214
+ if (!result) {
215
+ setError();
216
+ return false;
217
+ } else {
218
+ return true;
219
+ }
220
+ });
221
+ }
222
+ refinement(check, refinementData) {
223
+ return this._refinement((val, ctx) => {
224
+ if (!check(val)) {
225
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
226
+ return false;
227
+ } else {
228
+ return true;
229
+ }
230
+ });
231
+ }
232
+ _refinement(refinement) {
233
+ return new ZodEffects({
234
+ schema: this,
235
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
236
+ effect: { type: "refinement", refinement }
237
+ });
238
+ }
239
+ superRefine(refinement) {
240
+ return this._refinement(refinement);
241
+ }
242
+ constructor(def) {
243
+ this.spa = this.safeParseAsync;
244
+ this._def = def;
245
+ this.parse = this.parse.bind(this);
246
+ this.safeParse = this.safeParse.bind(this);
247
+ this.parseAsync = this.parseAsync.bind(this);
248
+ this.safeParseAsync = this.safeParseAsync.bind(this);
249
+ this.spa = this.spa.bind(this);
250
+ this.refine = this.refine.bind(this);
251
+ this.refinement = this.refinement.bind(this);
252
+ this.superRefine = this.superRefine.bind(this);
253
+ this.optional = this.optional.bind(this);
254
+ this.nullable = this.nullable.bind(this);
255
+ this.nullish = this.nullish.bind(this);
256
+ this.array = this.array.bind(this);
257
+ this.promise = this.promise.bind(this);
258
+ this.or = this.or.bind(this);
259
+ this.and = this.and.bind(this);
260
+ this.transform = this.transform.bind(this);
261
+ this.brand = this.brand.bind(this);
262
+ this.default = this.default.bind(this);
263
+ this.catch = this.catch.bind(this);
264
+ this.describe = this.describe.bind(this);
265
+ this.pipe = this.pipe.bind(this);
266
+ this.readonly = this.readonly.bind(this);
267
+ this.isNullable = this.isNullable.bind(this);
268
+ this.isOptional = this.isOptional.bind(this);
269
+ this["~standard"] = {
270
+ version: 1,
271
+ vendor: "zod",
272
+ validate: (data) => this["~validate"](data)
273
+ };
274
+ }
275
+ optional() {
276
+ return ZodOptional.create(this, this._def);
277
+ }
278
+ nullable() {
279
+ return ZodNullable.create(this, this._def);
280
+ }
281
+ nullish() {
282
+ return this.nullable().optional();
283
+ }
284
+ array() {
285
+ return ZodArray.create(this);
286
+ }
287
+ promise() {
288
+ return ZodPromise.create(this, this._def);
289
+ }
290
+ or(option) {
291
+ return ZodUnion.create([this, option], this._def);
292
+ }
293
+ and(incoming) {
294
+ return ZodIntersection.create(this, incoming, this._def);
295
+ }
296
+ transform(transform) {
297
+ return new ZodEffects({
298
+ ...processCreateParams(this._def),
299
+ schema: this,
300
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
301
+ effect: { type: "transform", transform }
302
+ });
296
303
  }
297
- async handleChainStart(chain, inputs, runId = v7(), runType = void 0, _tags = void 0, _metadata = void 0, runName = void 0, _parentRunId = void 0, extra = void 0) {
298
- await Promise.all(this.handlers.map((handler) => {
299
- if (handler.ignoreChain) return;
300
- if (isBaseTracer(handler)) handler._createRunForChainStart(chain, inputs, runId, this._parentRunId, this.tags, this.metadata, runType, runName, extra);
301
- return consumeCallback(async () => {
304
+ default(def) {
305
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
306
+ return new ZodDefault({
307
+ ...processCreateParams(this._def),
308
+ innerType: this,
309
+ defaultValue: defaultValueFunc,
310
+ typeName: ZodFirstPartyTypeKind.ZodDefault
311
+ });
312
+ }
313
+ brand() {
314
+ return new ZodBranded({
315
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
316
+ type: this,
317
+ ...processCreateParams(this._def)
318
+ });
319
+ }
320
+ catch(def) {
321
+ const catchValueFunc = typeof def === "function" ? def : () => def;
322
+ return new ZodCatch({
323
+ ...processCreateParams(this._def),
324
+ innerType: this,
325
+ catchValue: catchValueFunc,
326
+ typeName: ZodFirstPartyTypeKind.ZodCatch
327
+ });
328
+ }
329
+ describe(description) {
330
+ const This = this.constructor;
331
+ return new This({
332
+ ...this._def,
333
+ description
334
+ });
335
+ }
336
+ pipe(target) {
337
+ return ZodPipeline.create(this, target);
338
+ }
339
+ readonly() {
340
+ return ZodReadonly.create(this);
341
+ }
342
+ isOptional() {
343
+ return this.safeParse(void 0).success;
344
+ }
345
+ isNullable() {
346
+ return this.safeParse(null).success;
347
+ }
348
+ }
349
+ const cuidRegex = /^c[^\s-]{8,}$/i;
350
+ const cuid2Regex = /^[0-9a-z]+$/;
351
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
352
+ const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
353
+ const nanoidRegex = /^[a-z0-9_-]{21}$/i;
354
+ const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
355
+ const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
356
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
357
+ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
358
+ let emojiRegex;
359
+ const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
360
+ const ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
361
+ const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
362
+ const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
363
+ const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
364
+ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
365
+ const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
366
+ const dateRegex = new RegExp(`^${dateRegexSource}$`);
367
+ function timeRegexSource(args) {
368
+ let secondsRegexSource = `[0-5]\\d`;
369
+ if (args.precision) {
370
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
371
+ } else if (args.precision == null) {
372
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
373
+ }
374
+ const secondsQuantifier = args.precision ? "+" : "?";
375
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
376
+ }
377
+ function timeRegex(args) {
378
+ return new RegExp(`^${timeRegexSource(args)}$`);
379
+ }
380
+ function datetimeRegex(args) {
381
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
382
+ const opts = [];
383
+ opts.push(args.local ? `Z?` : `Z`);
384
+ if (args.offset)
385
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
386
+ regex = `${regex}(${opts.join("|")})`;
387
+ return new RegExp(`^${regex}$`);
388
+ }
389
+ function isValidIP(ip, version) {
390
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
391
+ return true;
392
+ }
393
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
394
+ return true;
395
+ }
396
+ return false;
397
+ }
398
+ function isValidJWT(jwt, alg) {
399
+ if (!jwtRegex.test(jwt))
400
+ return false;
401
+ try {
402
+ const [header] = jwt.split(".");
403
+ if (!header)
404
+ return false;
405
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
406
+ const decoded = JSON.parse(atob(base64));
407
+ if (typeof decoded !== "object" || decoded === null)
408
+ return false;
409
+ if ("typ" in decoded && decoded?.typ !== "JWT")
410
+ return false;
411
+ if (!decoded.alg)
412
+ return false;
413
+ if (alg && decoded.alg !== alg)
414
+ return false;
415
+ return true;
416
+ } catch {
417
+ return false;
418
+ }
419
+ }
420
+ function isValidCidr(ip, version) {
421
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
422
+ return true;
423
+ }
424
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
425
+ return true;
426
+ }
427
+ return false;
428
+ }
429
+ class ZodString extends ZodType {
430
+ _parse(input) {
431
+ if (this._def.coerce) {
432
+ input.data = String(input.data);
433
+ }
434
+ const parsedType = this._getType(input);
435
+ if (parsedType !== ZodParsedType.string) {
436
+ const ctx2 = this._getOrReturnCtx(input);
437
+ addIssueToContext(ctx2, {
438
+ code: ZodIssueCode.invalid_type,
439
+ expected: ZodParsedType.string,
440
+ received: ctx2.parsedType
441
+ });
442
+ return INVALID;
443
+ }
444
+ const status = new ParseStatus();
445
+ let ctx = void 0;
446
+ for (const check of this._def.checks) {
447
+ if (check.kind === "min") {
448
+ if (input.data.length < check.value) {
449
+ ctx = this._getOrReturnCtx(input, ctx);
450
+ addIssueToContext(ctx, {
451
+ code: ZodIssueCode.too_small,
452
+ minimum: check.value,
453
+ type: "string",
454
+ inclusive: true,
455
+ exact: false,
456
+ message: check.message
457
+ });
458
+ status.dirty();
459
+ }
460
+ } else if (check.kind === "max") {
461
+ if (input.data.length > check.value) {
462
+ ctx = this._getOrReturnCtx(input, ctx);
463
+ addIssueToContext(ctx, {
464
+ code: ZodIssueCode.too_big,
465
+ maximum: check.value,
466
+ type: "string",
467
+ inclusive: true,
468
+ exact: false,
469
+ message: check.message
470
+ });
471
+ status.dirty();
472
+ }
473
+ } else if (check.kind === "length") {
474
+ const tooBig = input.data.length > check.value;
475
+ const tooSmall = input.data.length < check.value;
476
+ if (tooBig || tooSmall) {
477
+ ctx = this._getOrReturnCtx(input, ctx);
478
+ if (tooBig) {
479
+ addIssueToContext(ctx, {
480
+ code: ZodIssueCode.too_big,
481
+ maximum: check.value,
482
+ type: "string",
483
+ inclusive: true,
484
+ exact: true,
485
+ message: check.message
486
+ });
487
+ } else if (tooSmall) {
488
+ addIssueToContext(ctx, {
489
+ code: ZodIssueCode.too_small,
490
+ minimum: check.value,
491
+ type: "string",
492
+ inclusive: true,
493
+ exact: true,
494
+ message: check.message
495
+ });
496
+ }
497
+ status.dirty();
498
+ }
499
+ } else if (check.kind === "email") {
500
+ if (!emailRegex.test(input.data)) {
501
+ ctx = this._getOrReturnCtx(input, ctx);
502
+ addIssueToContext(ctx, {
503
+ validation: "email",
504
+ code: ZodIssueCode.invalid_string,
505
+ message: check.message
506
+ });
507
+ status.dirty();
508
+ }
509
+ } else if (check.kind === "emoji") {
510
+ if (!emojiRegex) {
511
+ emojiRegex = new RegExp(_emojiRegex, "u");
512
+ }
513
+ if (!emojiRegex.test(input.data)) {
514
+ ctx = this._getOrReturnCtx(input, ctx);
515
+ addIssueToContext(ctx, {
516
+ validation: "emoji",
517
+ code: ZodIssueCode.invalid_string,
518
+ message: check.message
519
+ });
520
+ status.dirty();
521
+ }
522
+ } else if (check.kind === "uuid") {
523
+ if (!uuidRegex.test(input.data)) {
524
+ ctx = this._getOrReturnCtx(input, ctx);
525
+ addIssueToContext(ctx, {
526
+ validation: "uuid",
527
+ code: ZodIssueCode.invalid_string,
528
+ message: check.message
529
+ });
530
+ status.dirty();
531
+ }
532
+ } else if (check.kind === "nanoid") {
533
+ if (!nanoidRegex.test(input.data)) {
534
+ ctx = this._getOrReturnCtx(input, ctx);
535
+ addIssueToContext(ctx, {
536
+ validation: "nanoid",
537
+ code: ZodIssueCode.invalid_string,
538
+ message: check.message
539
+ });
540
+ status.dirty();
541
+ }
542
+ } else if (check.kind === "cuid") {
543
+ if (!cuidRegex.test(input.data)) {
544
+ ctx = this._getOrReturnCtx(input, ctx);
545
+ addIssueToContext(ctx, {
546
+ validation: "cuid",
547
+ code: ZodIssueCode.invalid_string,
548
+ message: check.message
549
+ });
550
+ status.dirty();
551
+ }
552
+ } else if (check.kind === "cuid2") {
553
+ if (!cuid2Regex.test(input.data)) {
554
+ ctx = this._getOrReturnCtx(input, ctx);
555
+ addIssueToContext(ctx, {
556
+ validation: "cuid2",
557
+ code: ZodIssueCode.invalid_string,
558
+ message: check.message
559
+ });
560
+ status.dirty();
561
+ }
562
+ } else if (check.kind === "ulid") {
563
+ if (!ulidRegex.test(input.data)) {
564
+ ctx = this._getOrReturnCtx(input, ctx);
565
+ addIssueToContext(ctx, {
566
+ validation: "ulid",
567
+ code: ZodIssueCode.invalid_string,
568
+ message: check.message
569
+ });
570
+ status.dirty();
571
+ }
572
+ } else if (check.kind === "url") {
302
573
  try {
303
- await handler.handleChainStart?.(chain, inputs, runId, this._parentRunId, this.tags, this.metadata, runType, runName, extra);
304
- } catch (err) {
305
- const logFunction = handler.raiseError ? console.error : console.warn;
306
- logFunction(`Error in handler ${handler.constructor.name}, handleChainStart: ${err}`);
307
- if (handler.raiseError) throw err;
574
+ new URL(input.data);
575
+ } catch {
576
+ ctx = this._getOrReturnCtx(input, ctx);
577
+ addIssueToContext(ctx, {
578
+ validation: "url",
579
+ code: ZodIssueCode.invalid_string,
580
+ message: check.message
581
+ });
582
+ status.dirty();
308
583
  }
309
- }, handler.awaitHandlers);
310
- }));
311
- return new CallbackManagerForChainRun(runId, this.handlers, this.inheritableHandlers, this.tags, this.inheritableTags, this.metadata, this.inheritableMetadata, this._parentRunId);
584
+ } else if (check.kind === "regex") {
585
+ check.regex.lastIndex = 0;
586
+ const testResult = check.regex.test(input.data);
587
+ if (!testResult) {
588
+ ctx = this._getOrReturnCtx(input, ctx);
589
+ addIssueToContext(ctx, {
590
+ validation: "regex",
591
+ code: ZodIssueCode.invalid_string,
592
+ message: check.message
593
+ });
594
+ status.dirty();
595
+ }
596
+ } else if (check.kind === "trim") {
597
+ input.data = input.data.trim();
598
+ } else if (check.kind === "includes") {
599
+ if (!input.data.includes(check.value, check.position)) {
600
+ ctx = this._getOrReturnCtx(input, ctx);
601
+ addIssueToContext(ctx, {
602
+ code: ZodIssueCode.invalid_string,
603
+ validation: { includes: check.value, position: check.position },
604
+ message: check.message
605
+ });
606
+ status.dirty();
607
+ }
608
+ } else if (check.kind === "toLowerCase") {
609
+ input.data = input.data.toLowerCase();
610
+ } else if (check.kind === "toUpperCase") {
611
+ input.data = input.data.toUpperCase();
612
+ } else if (check.kind === "startsWith") {
613
+ if (!input.data.startsWith(check.value)) {
614
+ ctx = this._getOrReturnCtx(input, ctx);
615
+ addIssueToContext(ctx, {
616
+ code: ZodIssueCode.invalid_string,
617
+ validation: { startsWith: check.value },
618
+ message: check.message
619
+ });
620
+ status.dirty();
621
+ }
622
+ } else if (check.kind === "endsWith") {
623
+ if (!input.data.endsWith(check.value)) {
624
+ ctx = this._getOrReturnCtx(input, ctx);
625
+ addIssueToContext(ctx, {
626
+ code: ZodIssueCode.invalid_string,
627
+ validation: { endsWith: check.value },
628
+ message: check.message
629
+ });
630
+ status.dirty();
631
+ }
632
+ } else if (check.kind === "datetime") {
633
+ const regex = datetimeRegex(check);
634
+ if (!regex.test(input.data)) {
635
+ ctx = this._getOrReturnCtx(input, ctx);
636
+ addIssueToContext(ctx, {
637
+ code: ZodIssueCode.invalid_string,
638
+ validation: "datetime",
639
+ message: check.message
640
+ });
641
+ status.dirty();
642
+ }
643
+ } else if (check.kind === "date") {
644
+ const regex = dateRegex;
645
+ if (!regex.test(input.data)) {
646
+ ctx = this._getOrReturnCtx(input, ctx);
647
+ addIssueToContext(ctx, {
648
+ code: ZodIssueCode.invalid_string,
649
+ validation: "date",
650
+ message: check.message
651
+ });
652
+ status.dirty();
653
+ }
654
+ } else if (check.kind === "time") {
655
+ const regex = timeRegex(check);
656
+ if (!regex.test(input.data)) {
657
+ ctx = this._getOrReturnCtx(input, ctx);
658
+ addIssueToContext(ctx, {
659
+ code: ZodIssueCode.invalid_string,
660
+ validation: "time",
661
+ message: check.message
662
+ });
663
+ status.dirty();
664
+ }
665
+ } else if (check.kind === "duration") {
666
+ if (!durationRegex.test(input.data)) {
667
+ ctx = this._getOrReturnCtx(input, ctx);
668
+ addIssueToContext(ctx, {
669
+ validation: "duration",
670
+ code: ZodIssueCode.invalid_string,
671
+ message: check.message
672
+ });
673
+ status.dirty();
674
+ }
675
+ } else if (check.kind === "ip") {
676
+ if (!isValidIP(input.data, check.version)) {
677
+ ctx = this._getOrReturnCtx(input, ctx);
678
+ addIssueToContext(ctx, {
679
+ validation: "ip",
680
+ code: ZodIssueCode.invalid_string,
681
+ message: check.message
682
+ });
683
+ status.dirty();
684
+ }
685
+ } else if (check.kind === "jwt") {
686
+ if (!isValidJWT(input.data, check.alg)) {
687
+ ctx = this._getOrReturnCtx(input, ctx);
688
+ addIssueToContext(ctx, {
689
+ validation: "jwt",
690
+ code: ZodIssueCode.invalid_string,
691
+ message: check.message
692
+ });
693
+ status.dirty();
694
+ }
695
+ } else if (check.kind === "cidr") {
696
+ if (!isValidCidr(input.data, check.version)) {
697
+ ctx = this._getOrReturnCtx(input, ctx);
698
+ addIssueToContext(ctx, {
699
+ validation: "cidr",
700
+ code: ZodIssueCode.invalid_string,
701
+ message: check.message
702
+ });
703
+ status.dirty();
704
+ }
705
+ } else if (check.kind === "base64") {
706
+ if (!base64Regex.test(input.data)) {
707
+ ctx = this._getOrReturnCtx(input, ctx);
708
+ addIssueToContext(ctx, {
709
+ validation: "base64",
710
+ code: ZodIssueCode.invalid_string,
711
+ message: check.message
712
+ });
713
+ status.dirty();
714
+ }
715
+ } else if (check.kind === "base64url") {
716
+ if (!base64urlRegex.test(input.data)) {
717
+ ctx = this._getOrReturnCtx(input, ctx);
718
+ addIssueToContext(ctx, {
719
+ validation: "base64url",
720
+ code: ZodIssueCode.invalid_string,
721
+ message: check.message
722
+ });
723
+ status.dirty();
724
+ }
725
+ } else {
726
+ util.assertNever(check);
727
+ }
728
+ }
729
+ return { status: status.value, value: input.data };
312
730
  }
313
- async handleToolStart(tool, input, runId = v7(), _parentRunId = void 0, _tags = void 0, _metadata = void 0, runName = void 0) {
314
- await Promise.all(this.handlers.map((handler) => {
315
- if (handler.ignoreAgent) return;
316
- if (isBaseTracer(handler)) handler._createRunForToolStart(tool, input, runId, this._parentRunId, this.tags, this.metadata, runName);
317
- return consumeCallback(async () => {
318
- try {
319
- await handler.handleToolStart?.(tool, input, runId, this._parentRunId, this.tags, this.metadata, runName);
320
- } catch (err) {
321
- const logFunction = handler.raiseError ? console.error : console.warn;
322
- logFunction(`Error in handler ${handler.constructor.name}, handleToolStart: ${err}`);
323
- if (handler.raiseError) throw err;
731
+ _regex(regex, validation, message) {
732
+ return this.refinement((data) => regex.test(data), {
733
+ validation,
734
+ code: ZodIssueCode.invalid_string,
735
+ ...errorUtil.errToObj(message)
736
+ });
737
+ }
738
+ _addCheck(check) {
739
+ return new ZodString({
740
+ ...this._def,
741
+ checks: [...this._def.checks, check]
742
+ });
743
+ }
744
+ email(message) {
745
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
746
+ }
747
+ url(message) {
748
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
749
+ }
750
+ emoji(message) {
751
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
752
+ }
753
+ uuid(message) {
754
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
755
+ }
756
+ nanoid(message) {
757
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
758
+ }
759
+ cuid(message) {
760
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
761
+ }
762
+ cuid2(message) {
763
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
764
+ }
765
+ ulid(message) {
766
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
767
+ }
768
+ base64(message) {
769
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
770
+ }
771
+ base64url(message) {
772
+ return this._addCheck({
773
+ kind: "base64url",
774
+ ...errorUtil.errToObj(message)
775
+ });
776
+ }
777
+ jwt(options) {
778
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
779
+ }
780
+ ip(options) {
781
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
782
+ }
783
+ cidr(options) {
784
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
785
+ }
786
+ datetime(options) {
787
+ if (typeof options === "string") {
788
+ return this._addCheck({
789
+ kind: "datetime",
790
+ precision: null,
791
+ offset: false,
792
+ local: false,
793
+ message: options
794
+ });
795
+ }
796
+ return this._addCheck({
797
+ kind: "datetime",
798
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
799
+ offset: options?.offset ?? false,
800
+ local: options?.local ?? false,
801
+ ...errorUtil.errToObj(options?.message)
802
+ });
803
+ }
804
+ date(message) {
805
+ return this._addCheck({ kind: "date", message });
806
+ }
807
+ time(options) {
808
+ if (typeof options === "string") {
809
+ return this._addCheck({
810
+ kind: "time",
811
+ precision: null,
812
+ message: options
813
+ });
814
+ }
815
+ return this._addCheck({
816
+ kind: "time",
817
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
818
+ ...errorUtil.errToObj(options?.message)
819
+ });
820
+ }
821
+ duration(message) {
822
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
823
+ }
824
+ regex(regex, message) {
825
+ return this._addCheck({
826
+ kind: "regex",
827
+ regex,
828
+ ...errorUtil.errToObj(message)
829
+ });
830
+ }
831
+ includes(value, options) {
832
+ return this._addCheck({
833
+ kind: "includes",
834
+ value,
835
+ position: options?.position,
836
+ ...errorUtil.errToObj(options?.message)
837
+ });
838
+ }
839
+ startsWith(value, message) {
840
+ return this._addCheck({
841
+ kind: "startsWith",
842
+ value,
843
+ ...errorUtil.errToObj(message)
844
+ });
845
+ }
846
+ endsWith(value, message) {
847
+ return this._addCheck({
848
+ kind: "endsWith",
849
+ value,
850
+ ...errorUtil.errToObj(message)
851
+ });
852
+ }
853
+ min(minLength, message) {
854
+ return this._addCheck({
855
+ kind: "min",
856
+ value: minLength,
857
+ ...errorUtil.errToObj(message)
858
+ });
859
+ }
860
+ max(maxLength, message) {
861
+ return this._addCheck({
862
+ kind: "max",
863
+ value: maxLength,
864
+ ...errorUtil.errToObj(message)
865
+ });
866
+ }
867
+ length(len, message) {
868
+ return this._addCheck({
869
+ kind: "length",
870
+ value: len,
871
+ ...errorUtil.errToObj(message)
872
+ });
873
+ }
874
+ /**
875
+ * Equivalent to `.min(1)`
876
+ */
877
+ nonempty(message) {
878
+ return this.min(1, errorUtil.errToObj(message));
879
+ }
880
+ trim() {
881
+ return new ZodString({
882
+ ...this._def,
883
+ checks: [...this._def.checks, { kind: "trim" }]
884
+ });
885
+ }
886
+ toLowerCase() {
887
+ return new ZodString({
888
+ ...this._def,
889
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
890
+ });
891
+ }
892
+ toUpperCase() {
893
+ return new ZodString({
894
+ ...this._def,
895
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
896
+ });
897
+ }
898
+ get isDatetime() {
899
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
900
+ }
901
+ get isDate() {
902
+ return !!this._def.checks.find((ch) => ch.kind === "date");
903
+ }
904
+ get isTime() {
905
+ return !!this._def.checks.find((ch) => ch.kind === "time");
906
+ }
907
+ get isDuration() {
908
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
909
+ }
910
+ get isEmail() {
911
+ return !!this._def.checks.find((ch) => ch.kind === "email");
912
+ }
913
+ get isURL() {
914
+ return !!this._def.checks.find((ch) => ch.kind === "url");
915
+ }
916
+ get isEmoji() {
917
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
918
+ }
919
+ get isUUID() {
920
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
921
+ }
922
+ get isNANOID() {
923
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
924
+ }
925
+ get isCUID() {
926
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
927
+ }
928
+ get isCUID2() {
929
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
930
+ }
931
+ get isULID() {
932
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
933
+ }
934
+ get isIP() {
935
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
936
+ }
937
+ get isCIDR() {
938
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
939
+ }
940
+ get isBase64() {
941
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
942
+ }
943
+ get isBase64url() {
944
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
945
+ }
946
+ get minLength() {
947
+ let min = null;
948
+ for (const ch of this._def.checks) {
949
+ if (ch.kind === "min") {
950
+ if (min === null || ch.value > min)
951
+ min = ch.value;
952
+ }
953
+ }
954
+ return min;
955
+ }
956
+ get maxLength() {
957
+ let max = null;
958
+ for (const ch of this._def.checks) {
959
+ if (ch.kind === "max") {
960
+ if (max === null || ch.value < max)
961
+ max = ch.value;
962
+ }
963
+ }
964
+ return max;
965
+ }
966
+ }
967
+ ZodString.create = (params) => {
968
+ return new ZodString({
969
+ checks: [],
970
+ typeName: ZodFirstPartyTypeKind.ZodString,
971
+ coerce: params?.coerce ?? false,
972
+ ...processCreateParams(params)
973
+ });
974
+ };
975
+ function floatSafeRemainder(val, step) {
976
+ const valDecCount = (val.toString().split(".")[1] || "").length;
977
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
978
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
979
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
980
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
981
+ return valInt % stepInt / 10 ** decCount;
982
+ }
983
+ class ZodNumber extends ZodType {
984
+ constructor() {
985
+ super(...arguments);
986
+ this.min = this.gte;
987
+ this.max = this.lte;
988
+ this.step = this.multipleOf;
989
+ }
990
+ _parse(input) {
991
+ if (this._def.coerce) {
992
+ input.data = Number(input.data);
993
+ }
994
+ const parsedType = this._getType(input);
995
+ if (parsedType !== ZodParsedType.number) {
996
+ const ctx2 = this._getOrReturnCtx(input);
997
+ addIssueToContext(ctx2, {
998
+ code: ZodIssueCode.invalid_type,
999
+ expected: ZodParsedType.number,
1000
+ received: ctx2.parsedType
1001
+ });
1002
+ return INVALID;
1003
+ }
1004
+ let ctx = void 0;
1005
+ const status = new ParseStatus();
1006
+ for (const check of this._def.checks) {
1007
+ if (check.kind === "int") {
1008
+ if (!util.isInteger(input.data)) {
1009
+ ctx = this._getOrReturnCtx(input, ctx);
1010
+ addIssueToContext(ctx, {
1011
+ code: ZodIssueCode.invalid_type,
1012
+ expected: "integer",
1013
+ received: "float",
1014
+ message: check.message
1015
+ });
1016
+ status.dirty();
324
1017
  }
325
- }, handler.awaitHandlers);
326
- }));
327
- return new CallbackManagerForToolRun(runId, this.handlers, this.inheritableHandlers, this.tags, this.inheritableTags, this.metadata, this.inheritableMetadata, this._parentRunId);
1018
+ } else if (check.kind === "min") {
1019
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1020
+ if (tooSmall) {
1021
+ ctx = this._getOrReturnCtx(input, ctx);
1022
+ addIssueToContext(ctx, {
1023
+ code: ZodIssueCode.too_small,
1024
+ minimum: check.value,
1025
+ type: "number",
1026
+ inclusive: check.inclusive,
1027
+ exact: false,
1028
+ message: check.message
1029
+ });
1030
+ status.dirty();
1031
+ }
1032
+ } else if (check.kind === "max") {
1033
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1034
+ if (tooBig) {
1035
+ ctx = this._getOrReturnCtx(input, ctx);
1036
+ addIssueToContext(ctx, {
1037
+ code: ZodIssueCode.too_big,
1038
+ maximum: check.value,
1039
+ type: "number",
1040
+ inclusive: check.inclusive,
1041
+ exact: false,
1042
+ message: check.message
1043
+ });
1044
+ status.dirty();
1045
+ }
1046
+ } else if (check.kind === "multipleOf") {
1047
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1048
+ ctx = this._getOrReturnCtx(input, ctx);
1049
+ addIssueToContext(ctx, {
1050
+ code: ZodIssueCode.not_multiple_of,
1051
+ multipleOf: check.value,
1052
+ message: check.message
1053
+ });
1054
+ status.dirty();
1055
+ }
1056
+ } else if (check.kind === "finite") {
1057
+ if (!Number.isFinite(input.data)) {
1058
+ ctx = this._getOrReturnCtx(input, ctx);
1059
+ addIssueToContext(ctx, {
1060
+ code: ZodIssueCode.not_finite,
1061
+ message: check.message
1062
+ });
1063
+ status.dirty();
1064
+ }
1065
+ } else {
1066
+ util.assertNever(check);
1067
+ }
1068
+ }
1069
+ return { status: status.value, value: input.data };
328
1070
  }
329
- async handleRetrieverStart(retriever, query, runId = v7(), _parentRunId = void 0, _tags = void 0, _metadata = void 0, runName = void 0) {
330
- await Promise.all(this.handlers.map((handler) => {
331
- if (handler.ignoreRetriever) return;
332
- if (isBaseTracer(handler)) handler._createRunForRetrieverStart(retriever, query, runId, this._parentRunId, this.tags, this.metadata, runName);
333
- return consumeCallback(async () => {
334
- try {
335
- await handler.handleRetrieverStart?.(retriever, query, runId, this._parentRunId, this.tags, this.metadata, runName);
336
- } catch (err) {
337
- const logFunction = handler.raiseError ? console.error : console.warn;
338
- logFunction(`Error in handler ${handler.constructor.name}, handleRetrieverStart: ${err}`);
339
- if (handler.raiseError) throw err;
1071
+ gte(value, message) {
1072
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1073
+ }
1074
+ gt(value, message) {
1075
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1076
+ }
1077
+ lte(value, message) {
1078
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1079
+ }
1080
+ lt(value, message) {
1081
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1082
+ }
1083
+ setLimit(kind, value, inclusive, message) {
1084
+ return new ZodNumber({
1085
+ ...this._def,
1086
+ checks: [
1087
+ ...this._def.checks,
1088
+ {
1089
+ kind,
1090
+ value,
1091
+ inclusive,
1092
+ message: errorUtil.toString(message)
340
1093
  }
341
- }, handler.awaitHandlers);
342
- }));
343
- return new CallbackManagerForRetrieverRun(runId, this.handlers, this.inheritableHandlers, this.tags, this.inheritableTags, this.metadata, this.inheritableMetadata, this._parentRunId);
1094
+ ]
1095
+ });
344
1096
  }
345
- async handleCustomEvent(eventName, data, runId, _tags, _metadata) {
346
- await Promise.all(this.handlers.map((handler) => consumeCallback(async () => {
347
- if (!handler.ignoreCustomEvent) try {
348
- await handler.handleCustomEvent?.(eventName, data, runId, this.tags, this.metadata);
349
- } catch (err) {
350
- const logFunction = handler.raiseError ? console.error : console.warn;
351
- logFunction(`Error in handler ${handler.constructor.name}, handleCustomEvent: ${err}`);
352
- if (handler.raiseError) throw err;
353
- }
354
- }, handler.awaitHandlers)));
355
- }
356
- addHandler(handler, inherit = true) {
357
- this.handlers.push(handler);
358
- if (inherit) this.inheritableHandlers.push(handler);
359
- }
360
- removeHandler(handler) {
361
- this.handlers = this.handlers.filter((_handler) => _handler !== handler);
362
- this.inheritableHandlers = this.inheritableHandlers.filter((_handler) => _handler !== handler);
363
- }
364
- setHandlers(handlers, inherit = true) {
365
- this.handlers = [];
366
- this.inheritableHandlers = [];
367
- for (const handler of handlers) this.addHandler(handler, inherit);
368
- }
369
- addTags(tags, inherit = true) {
370
- this.removeTags(tags);
371
- this.tags.push(...tags);
372
- if (inherit) this.inheritableTags.push(...tags);
373
- }
374
- removeTags(tags) {
375
- this.tags = this.tags.filter((tag) => !tags.includes(tag));
376
- this.inheritableTags = this.inheritableTags.filter((tag) => !tags.includes(tag));
377
- }
378
- addMetadata(metadata, inherit = true) {
379
- this.metadata = {
380
- ...this.metadata,
381
- ...metadata
382
- };
383
- if (inherit) this.inheritableMetadata = {
384
- ...this.inheritableMetadata,
385
- ...metadata
1097
+ _addCheck(check) {
1098
+ return new ZodNumber({
1099
+ ...this._def,
1100
+ checks: [...this._def.checks, check]
1101
+ });
1102
+ }
1103
+ int(message) {
1104
+ return this._addCheck({
1105
+ kind: "int",
1106
+ message: errorUtil.toString(message)
1107
+ });
1108
+ }
1109
+ positive(message) {
1110
+ return this._addCheck({
1111
+ kind: "min",
1112
+ value: 0,
1113
+ inclusive: false,
1114
+ message: errorUtil.toString(message)
1115
+ });
1116
+ }
1117
+ negative(message) {
1118
+ return this._addCheck({
1119
+ kind: "max",
1120
+ value: 0,
1121
+ inclusive: false,
1122
+ message: errorUtil.toString(message)
1123
+ });
1124
+ }
1125
+ nonpositive(message) {
1126
+ return this._addCheck({
1127
+ kind: "max",
1128
+ value: 0,
1129
+ inclusive: true,
1130
+ message: errorUtil.toString(message)
1131
+ });
1132
+ }
1133
+ nonnegative(message) {
1134
+ return this._addCheck({
1135
+ kind: "min",
1136
+ value: 0,
1137
+ inclusive: true,
1138
+ message: errorUtil.toString(message)
1139
+ });
1140
+ }
1141
+ multipleOf(value, message) {
1142
+ return this._addCheck({
1143
+ kind: "multipleOf",
1144
+ value,
1145
+ message: errorUtil.toString(message)
1146
+ });
1147
+ }
1148
+ finite(message) {
1149
+ return this._addCheck({
1150
+ kind: "finite",
1151
+ message: errorUtil.toString(message)
1152
+ });
1153
+ }
1154
+ safe(message) {
1155
+ return this._addCheck({
1156
+ kind: "min",
1157
+ inclusive: true,
1158
+ value: Number.MIN_SAFE_INTEGER,
1159
+ message: errorUtil.toString(message)
1160
+ })._addCheck({
1161
+ kind: "max",
1162
+ inclusive: true,
1163
+ value: Number.MAX_SAFE_INTEGER,
1164
+ message: errorUtil.toString(message)
1165
+ });
1166
+ }
1167
+ get minValue() {
1168
+ let min = null;
1169
+ for (const ch of this._def.checks) {
1170
+ if (ch.kind === "min") {
1171
+ if (min === null || ch.value > min)
1172
+ min = ch.value;
1173
+ }
1174
+ }
1175
+ return min;
1176
+ }
1177
+ get maxValue() {
1178
+ let max = null;
1179
+ for (const ch of this._def.checks) {
1180
+ if (ch.kind === "max") {
1181
+ if (max === null || ch.value < max)
1182
+ max = ch.value;
1183
+ }
1184
+ }
1185
+ return max;
1186
+ }
1187
+ get isInt() {
1188
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1189
+ }
1190
+ get isFinite() {
1191
+ let max = null;
1192
+ let min = null;
1193
+ for (const ch of this._def.checks) {
1194
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1195
+ return true;
1196
+ } else if (ch.kind === "min") {
1197
+ if (min === null || ch.value > min)
1198
+ min = ch.value;
1199
+ } else if (ch.kind === "max") {
1200
+ if (max === null || ch.value < max)
1201
+ max = ch.value;
1202
+ }
1203
+ }
1204
+ return Number.isFinite(min) && Number.isFinite(max);
1205
+ }
1206
+ }
1207
+ ZodNumber.create = (params) => {
1208
+ return new ZodNumber({
1209
+ checks: [],
1210
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1211
+ coerce: params?.coerce || false,
1212
+ ...processCreateParams(params)
1213
+ });
1214
+ };
1215
+ class ZodBigInt extends ZodType {
1216
+ constructor() {
1217
+ super(...arguments);
1218
+ this.min = this.gte;
1219
+ this.max = this.lte;
1220
+ }
1221
+ _parse(input) {
1222
+ if (this._def.coerce) {
1223
+ try {
1224
+ input.data = BigInt(input.data);
1225
+ } catch {
1226
+ return this._getInvalidInput(input);
1227
+ }
1228
+ }
1229
+ const parsedType = this._getType(input);
1230
+ if (parsedType !== ZodParsedType.bigint) {
1231
+ return this._getInvalidInput(input);
1232
+ }
1233
+ let ctx = void 0;
1234
+ const status = new ParseStatus();
1235
+ for (const check of this._def.checks) {
1236
+ if (check.kind === "min") {
1237
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1238
+ if (tooSmall) {
1239
+ ctx = this._getOrReturnCtx(input, ctx);
1240
+ addIssueToContext(ctx, {
1241
+ code: ZodIssueCode.too_small,
1242
+ type: "bigint",
1243
+ minimum: check.value,
1244
+ inclusive: check.inclusive,
1245
+ message: check.message
1246
+ });
1247
+ status.dirty();
1248
+ }
1249
+ } else if (check.kind === "max") {
1250
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1251
+ if (tooBig) {
1252
+ ctx = this._getOrReturnCtx(input, ctx);
1253
+ addIssueToContext(ctx, {
1254
+ code: ZodIssueCode.too_big,
1255
+ type: "bigint",
1256
+ maximum: check.value,
1257
+ inclusive: check.inclusive,
1258
+ message: check.message
1259
+ });
1260
+ status.dirty();
1261
+ }
1262
+ } else if (check.kind === "multipleOf") {
1263
+ if (input.data % check.value !== BigInt(0)) {
1264
+ ctx = this._getOrReturnCtx(input, ctx);
1265
+ addIssueToContext(ctx, {
1266
+ code: ZodIssueCode.not_multiple_of,
1267
+ multipleOf: check.value,
1268
+ message: check.message
1269
+ });
1270
+ status.dirty();
1271
+ }
1272
+ } else {
1273
+ util.assertNever(check);
1274
+ }
1275
+ }
1276
+ return { status: status.value, value: input.data };
1277
+ }
1278
+ _getInvalidInput(input) {
1279
+ const ctx = this._getOrReturnCtx(input);
1280
+ addIssueToContext(ctx, {
1281
+ code: ZodIssueCode.invalid_type,
1282
+ expected: ZodParsedType.bigint,
1283
+ received: ctx.parsedType
1284
+ });
1285
+ return INVALID;
1286
+ }
1287
+ gte(value, message) {
1288
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1289
+ }
1290
+ gt(value, message) {
1291
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1292
+ }
1293
+ lte(value, message) {
1294
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1295
+ }
1296
+ lt(value, message) {
1297
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1298
+ }
1299
+ setLimit(kind, value, inclusive, message) {
1300
+ return new ZodBigInt({
1301
+ ...this._def,
1302
+ checks: [
1303
+ ...this._def.checks,
1304
+ {
1305
+ kind,
1306
+ value,
1307
+ inclusive,
1308
+ message: errorUtil.toString(message)
1309
+ }
1310
+ ]
1311
+ });
1312
+ }
1313
+ _addCheck(check) {
1314
+ return new ZodBigInt({
1315
+ ...this._def,
1316
+ checks: [...this._def.checks, check]
1317
+ });
1318
+ }
1319
+ positive(message) {
1320
+ return this._addCheck({
1321
+ kind: "min",
1322
+ value: BigInt(0),
1323
+ inclusive: false,
1324
+ message: errorUtil.toString(message)
1325
+ });
1326
+ }
1327
+ negative(message) {
1328
+ return this._addCheck({
1329
+ kind: "max",
1330
+ value: BigInt(0),
1331
+ inclusive: false,
1332
+ message: errorUtil.toString(message)
1333
+ });
1334
+ }
1335
+ nonpositive(message) {
1336
+ return this._addCheck({
1337
+ kind: "max",
1338
+ value: BigInt(0),
1339
+ inclusive: true,
1340
+ message: errorUtil.toString(message)
1341
+ });
1342
+ }
1343
+ nonnegative(message) {
1344
+ return this._addCheck({
1345
+ kind: "min",
1346
+ value: BigInt(0),
1347
+ inclusive: true,
1348
+ message: errorUtil.toString(message)
1349
+ });
1350
+ }
1351
+ multipleOf(value, message) {
1352
+ return this._addCheck({
1353
+ kind: "multipleOf",
1354
+ value,
1355
+ message: errorUtil.toString(message)
1356
+ });
1357
+ }
1358
+ get minValue() {
1359
+ let min = null;
1360
+ for (const ch of this._def.checks) {
1361
+ if (ch.kind === "min") {
1362
+ if (min === null || ch.value > min)
1363
+ min = ch.value;
1364
+ }
1365
+ }
1366
+ return min;
1367
+ }
1368
+ get maxValue() {
1369
+ let max = null;
1370
+ for (const ch of this._def.checks) {
1371
+ if (ch.kind === "max") {
1372
+ if (max === null || ch.value < max)
1373
+ max = ch.value;
1374
+ }
1375
+ }
1376
+ return max;
1377
+ }
1378
+ }
1379
+ ZodBigInt.create = (params) => {
1380
+ return new ZodBigInt({
1381
+ checks: [],
1382
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1383
+ coerce: params?.coerce ?? false,
1384
+ ...processCreateParams(params)
1385
+ });
1386
+ };
1387
+ class ZodBoolean extends ZodType {
1388
+ _parse(input) {
1389
+ if (this._def.coerce) {
1390
+ input.data = Boolean(input.data);
1391
+ }
1392
+ const parsedType = this._getType(input);
1393
+ if (parsedType !== ZodParsedType.boolean) {
1394
+ const ctx = this._getOrReturnCtx(input);
1395
+ addIssueToContext(ctx, {
1396
+ code: ZodIssueCode.invalid_type,
1397
+ expected: ZodParsedType.boolean,
1398
+ received: ctx.parsedType
1399
+ });
1400
+ return INVALID;
1401
+ }
1402
+ return OK(input.data);
1403
+ }
1404
+ }
1405
+ ZodBoolean.create = (params) => {
1406
+ return new ZodBoolean({
1407
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1408
+ coerce: params?.coerce || false,
1409
+ ...processCreateParams(params)
1410
+ });
1411
+ };
1412
+ class ZodDate extends ZodType {
1413
+ _parse(input) {
1414
+ if (this._def.coerce) {
1415
+ input.data = new Date(input.data);
1416
+ }
1417
+ const parsedType = this._getType(input);
1418
+ if (parsedType !== ZodParsedType.date) {
1419
+ const ctx2 = this._getOrReturnCtx(input);
1420
+ addIssueToContext(ctx2, {
1421
+ code: ZodIssueCode.invalid_type,
1422
+ expected: ZodParsedType.date,
1423
+ received: ctx2.parsedType
1424
+ });
1425
+ return INVALID;
1426
+ }
1427
+ if (Number.isNaN(input.data.getTime())) {
1428
+ const ctx2 = this._getOrReturnCtx(input);
1429
+ addIssueToContext(ctx2, {
1430
+ code: ZodIssueCode.invalid_date
1431
+ });
1432
+ return INVALID;
1433
+ }
1434
+ const status = new ParseStatus();
1435
+ let ctx = void 0;
1436
+ for (const check of this._def.checks) {
1437
+ if (check.kind === "min") {
1438
+ if (input.data.getTime() < check.value) {
1439
+ ctx = this._getOrReturnCtx(input, ctx);
1440
+ addIssueToContext(ctx, {
1441
+ code: ZodIssueCode.too_small,
1442
+ message: check.message,
1443
+ inclusive: true,
1444
+ exact: false,
1445
+ minimum: check.value,
1446
+ type: "date"
1447
+ });
1448
+ status.dirty();
1449
+ }
1450
+ } else if (check.kind === "max") {
1451
+ if (input.data.getTime() > check.value) {
1452
+ ctx = this._getOrReturnCtx(input, ctx);
1453
+ addIssueToContext(ctx, {
1454
+ code: ZodIssueCode.too_big,
1455
+ message: check.message,
1456
+ inclusive: true,
1457
+ exact: false,
1458
+ maximum: check.value,
1459
+ type: "date"
1460
+ });
1461
+ status.dirty();
1462
+ }
1463
+ } else {
1464
+ util.assertNever(check);
1465
+ }
1466
+ }
1467
+ return {
1468
+ status: status.value,
1469
+ value: new Date(input.data.getTime())
386
1470
  };
387
1471
  }
388
- removeMetadata(metadata) {
389
- for (const key of Object.keys(metadata)) {
390
- delete this.metadata[key];
391
- delete this.inheritableMetadata[key];
1472
+ _addCheck(check) {
1473
+ return new ZodDate({
1474
+ ...this._def,
1475
+ checks: [...this._def.checks, check]
1476
+ });
1477
+ }
1478
+ min(minDate, message) {
1479
+ return this._addCheck({
1480
+ kind: "min",
1481
+ value: minDate.getTime(),
1482
+ message: errorUtil.toString(message)
1483
+ });
1484
+ }
1485
+ max(maxDate, message) {
1486
+ return this._addCheck({
1487
+ kind: "max",
1488
+ value: maxDate.getTime(),
1489
+ message: errorUtil.toString(message)
1490
+ });
1491
+ }
1492
+ get minDate() {
1493
+ let min = null;
1494
+ for (const ch of this._def.checks) {
1495
+ if (ch.kind === "min") {
1496
+ if (min === null || ch.value > min)
1497
+ min = ch.value;
1498
+ }
1499
+ }
1500
+ return min != null ? new Date(min) : null;
1501
+ }
1502
+ get maxDate() {
1503
+ let max = null;
1504
+ for (const ch of this._def.checks) {
1505
+ if (ch.kind === "max") {
1506
+ if (max === null || ch.value < max)
1507
+ max = ch.value;
1508
+ }
1509
+ }
1510
+ return max != null ? new Date(max) : null;
1511
+ }
1512
+ }
1513
+ ZodDate.create = (params) => {
1514
+ return new ZodDate({
1515
+ checks: [],
1516
+ coerce: params?.coerce || false,
1517
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1518
+ ...processCreateParams(params)
1519
+ });
1520
+ };
1521
+ class ZodSymbol extends ZodType {
1522
+ _parse(input) {
1523
+ const parsedType = this._getType(input);
1524
+ if (parsedType !== ZodParsedType.symbol) {
1525
+ const ctx = this._getOrReturnCtx(input);
1526
+ addIssueToContext(ctx, {
1527
+ code: ZodIssueCode.invalid_type,
1528
+ expected: ZodParsedType.symbol,
1529
+ received: ctx.parsedType
1530
+ });
1531
+ return INVALID;
1532
+ }
1533
+ return OK(input.data);
1534
+ }
1535
+ }
1536
+ ZodSymbol.create = (params) => {
1537
+ return new ZodSymbol({
1538
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1539
+ ...processCreateParams(params)
1540
+ });
1541
+ };
1542
+ class ZodUndefined extends ZodType {
1543
+ _parse(input) {
1544
+ const parsedType = this._getType(input);
1545
+ if (parsedType !== ZodParsedType.undefined) {
1546
+ const ctx = this._getOrReturnCtx(input);
1547
+ addIssueToContext(ctx, {
1548
+ code: ZodIssueCode.invalid_type,
1549
+ expected: ZodParsedType.undefined,
1550
+ received: ctx.parsedType
1551
+ });
1552
+ return INVALID;
1553
+ }
1554
+ return OK(input.data);
1555
+ }
1556
+ }
1557
+ ZodUndefined.create = (params) => {
1558
+ return new ZodUndefined({
1559
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
1560
+ ...processCreateParams(params)
1561
+ });
1562
+ };
1563
+ class ZodNull extends ZodType {
1564
+ _parse(input) {
1565
+ const parsedType = this._getType(input);
1566
+ if (parsedType !== ZodParsedType.null) {
1567
+ const ctx = this._getOrReturnCtx(input);
1568
+ addIssueToContext(ctx, {
1569
+ code: ZodIssueCode.invalid_type,
1570
+ expected: ZodParsedType.null,
1571
+ received: ctx.parsedType
1572
+ });
1573
+ return INVALID;
1574
+ }
1575
+ return OK(input.data);
1576
+ }
1577
+ }
1578
+ ZodNull.create = (params) => {
1579
+ return new ZodNull({
1580
+ typeName: ZodFirstPartyTypeKind.ZodNull,
1581
+ ...processCreateParams(params)
1582
+ });
1583
+ };
1584
+ class ZodAny extends ZodType {
1585
+ constructor() {
1586
+ super(...arguments);
1587
+ this._any = true;
1588
+ }
1589
+ _parse(input) {
1590
+ return OK(input.data);
1591
+ }
1592
+ }
1593
+ ZodAny.create = (params) => {
1594
+ return new ZodAny({
1595
+ typeName: ZodFirstPartyTypeKind.ZodAny,
1596
+ ...processCreateParams(params)
1597
+ });
1598
+ };
1599
+ class ZodUnknown extends ZodType {
1600
+ constructor() {
1601
+ super(...arguments);
1602
+ this._unknown = true;
1603
+ }
1604
+ _parse(input) {
1605
+ return OK(input.data);
1606
+ }
1607
+ }
1608
+ ZodUnknown.create = (params) => {
1609
+ return new ZodUnknown({
1610
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
1611
+ ...processCreateParams(params)
1612
+ });
1613
+ };
1614
+ class ZodNever extends ZodType {
1615
+ _parse(input) {
1616
+ const ctx = this._getOrReturnCtx(input);
1617
+ addIssueToContext(ctx, {
1618
+ code: ZodIssueCode.invalid_type,
1619
+ expected: ZodParsedType.never,
1620
+ received: ctx.parsedType
1621
+ });
1622
+ return INVALID;
1623
+ }
1624
+ }
1625
+ ZodNever.create = (params) => {
1626
+ return new ZodNever({
1627
+ typeName: ZodFirstPartyTypeKind.ZodNever,
1628
+ ...processCreateParams(params)
1629
+ });
1630
+ };
1631
+ class ZodVoid extends ZodType {
1632
+ _parse(input) {
1633
+ const parsedType = this._getType(input);
1634
+ if (parsedType !== ZodParsedType.undefined) {
1635
+ const ctx = this._getOrReturnCtx(input);
1636
+ addIssueToContext(ctx, {
1637
+ code: ZodIssueCode.invalid_type,
1638
+ expected: ZodParsedType.void,
1639
+ received: ctx.parsedType
1640
+ });
1641
+ return INVALID;
1642
+ }
1643
+ return OK(input.data);
1644
+ }
1645
+ }
1646
+ ZodVoid.create = (params) => {
1647
+ return new ZodVoid({
1648
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
1649
+ ...processCreateParams(params)
1650
+ });
1651
+ };
1652
+ class ZodArray extends ZodType {
1653
+ _parse(input) {
1654
+ const { ctx, status } = this._processInputParams(input);
1655
+ const def = this._def;
1656
+ if (ctx.parsedType !== ZodParsedType.array) {
1657
+ addIssueToContext(ctx, {
1658
+ code: ZodIssueCode.invalid_type,
1659
+ expected: ZodParsedType.array,
1660
+ received: ctx.parsedType
1661
+ });
1662
+ return INVALID;
1663
+ }
1664
+ if (def.exactLength !== null) {
1665
+ const tooBig = ctx.data.length > def.exactLength.value;
1666
+ const tooSmall = ctx.data.length < def.exactLength.value;
1667
+ if (tooBig || tooSmall) {
1668
+ addIssueToContext(ctx, {
1669
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1670
+ minimum: tooSmall ? def.exactLength.value : void 0,
1671
+ maximum: tooBig ? def.exactLength.value : void 0,
1672
+ type: "array",
1673
+ inclusive: true,
1674
+ exact: true,
1675
+ message: def.exactLength.message
1676
+ });
1677
+ status.dirty();
1678
+ }
392
1679
  }
1680
+ if (def.minLength !== null) {
1681
+ if (ctx.data.length < def.minLength.value) {
1682
+ addIssueToContext(ctx, {
1683
+ code: ZodIssueCode.too_small,
1684
+ minimum: def.minLength.value,
1685
+ type: "array",
1686
+ inclusive: true,
1687
+ exact: false,
1688
+ message: def.minLength.message
1689
+ });
1690
+ status.dirty();
1691
+ }
1692
+ }
1693
+ if (def.maxLength !== null) {
1694
+ if (ctx.data.length > def.maxLength.value) {
1695
+ addIssueToContext(ctx, {
1696
+ code: ZodIssueCode.too_big,
1697
+ maximum: def.maxLength.value,
1698
+ type: "array",
1699
+ inclusive: true,
1700
+ exact: false,
1701
+ message: def.maxLength.message
1702
+ });
1703
+ status.dirty();
1704
+ }
1705
+ }
1706
+ if (ctx.common.async) {
1707
+ return Promise.all([...ctx.data].map((item, i) => {
1708
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1709
+ })).then((result2) => {
1710
+ return ParseStatus.mergeArray(status, result2);
1711
+ });
1712
+ }
1713
+ const result = [...ctx.data].map((item, i) => {
1714
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1715
+ });
1716
+ return ParseStatus.mergeArray(status, result);
1717
+ }
1718
+ get element() {
1719
+ return this._def.type;
1720
+ }
1721
+ min(minLength, message) {
1722
+ return new ZodArray({
1723
+ ...this._def,
1724
+ minLength: { value: minLength, message: errorUtil.toString(message) }
1725
+ });
1726
+ }
1727
+ max(maxLength, message) {
1728
+ return new ZodArray({
1729
+ ...this._def,
1730
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
1731
+ });
1732
+ }
1733
+ length(len, message) {
1734
+ return new ZodArray({
1735
+ ...this._def,
1736
+ exactLength: { value: len, message: errorUtil.toString(message) }
1737
+ });
1738
+ }
1739
+ nonempty(message) {
1740
+ return this.min(1, message);
1741
+ }
1742
+ }
1743
+ ZodArray.create = (schema, params) => {
1744
+ return new ZodArray({
1745
+ type: schema,
1746
+ minLength: null,
1747
+ maxLength: null,
1748
+ exactLength: null,
1749
+ typeName: ZodFirstPartyTypeKind.ZodArray,
1750
+ ...processCreateParams(params)
1751
+ });
1752
+ };
1753
+ function deepPartialify(schema) {
1754
+ if (schema instanceof ZodObject) {
1755
+ const newShape = {};
1756
+ for (const key in schema.shape) {
1757
+ const fieldSchema = schema.shape[key];
1758
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1759
+ }
1760
+ return new ZodObject({
1761
+ ...schema._def,
1762
+ shape: () => newShape
1763
+ });
1764
+ } else if (schema instanceof ZodArray) {
1765
+ return new ZodArray({
1766
+ ...schema._def,
1767
+ type: deepPartialify(schema.element)
1768
+ });
1769
+ } else if (schema instanceof ZodOptional) {
1770
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
1771
+ } else if (schema instanceof ZodNullable) {
1772
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
1773
+ } else if (schema instanceof ZodTuple) {
1774
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
1775
+ } else {
1776
+ return schema;
1777
+ }
1778
+ }
1779
+ class ZodObject extends ZodType {
1780
+ constructor() {
1781
+ super(...arguments);
1782
+ this._cached = null;
1783
+ this.nonstrict = this.passthrough;
1784
+ this.augment = this.extend;
1785
+ }
1786
+ _getCached() {
1787
+ if (this._cached !== null)
1788
+ return this._cached;
1789
+ const shape = this._def.shape();
1790
+ const keys = util.objectKeys(shape);
1791
+ this._cached = { shape, keys };
1792
+ return this._cached;
393
1793
  }
394
- copy(additionalHandlers = [], inherit = true) {
395
- const manager = new CallbackManager2(this._parentRunId);
396
- for (const handler of this.handlers) {
397
- const inheritable = this.inheritableHandlers.includes(handler);
398
- manager.addHandler(handler, inheritable);
1794
+ _parse(input) {
1795
+ const parsedType = this._getType(input);
1796
+ if (parsedType !== ZodParsedType.object) {
1797
+ const ctx2 = this._getOrReturnCtx(input);
1798
+ addIssueToContext(ctx2, {
1799
+ code: ZodIssueCode.invalid_type,
1800
+ expected: ZodParsedType.object,
1801
+ received: ctx2.parsedType
1802
+ });
1803
+ return INVALID;
1804
+ }
1805
+ const { status, ctx } = this._processInputParams(input);
1806
+ const { shape, keys: shapeKeys } = this._getCached();
1807
+ const extraKeys = [];
1808
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
1809
+ for (const key in ctx.data) {
1810
+ if (!shapeKeys.includes(key)) {
1811
+ extraKeys.push(key);
1812
+ }
1813
+ }
399
1814
  }
400
- for (const tag of this.tags) {
401
- const inheritable = this.inheritableTags.includes(tag);
402
- manager.addTags([tag], inheritable);
1815
+ const pairs = [];
1816
+ for (const key of shapeKeys) {
1817
+ const keyValidator = shape[key];
1818
+ const value = ctx.data[key];
1819
+ pairs.push({
1820
+ key: { status: "valid", value: key },
1821
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
1822
+ alwaysSet: key in ctx.data
1823
+ });
403
1824
  }
404
- for (const key of Object.keys(this.metadata)) {
405
- const inheritable = Object.keys(this.inheritableMetadata).includes(key);
406
- manager.addMetadata({ [key]: this.metadata[key] }, inheritable);
1825
+ if (this._def.catchall instanceof ZodNever) {
1826
+ const unknownKeys = this._def.unknownKeys;
1827
+ if (unknownKeys === "passthrough") {
1828
+ for (const key of extraKeys) {
1829
+ pairs.push({
1830
+ key: { status: "valid", value: key },
1831
+ value: { status: "valid", value: ctx.data[key] }
1832
+ });
1833
+ }
1834
+ } else if (unknownKeys === "strict") {
1835
+ if (extraKeys.length > 0) {
1836
+ addIssueToContext(ctx, {
1837
+ code: ZodIssueCode.unrecognized_keys,
1838
+ keys: extraKeys
1839
+ });
1840
+ status.dirty();
1841
+ }
1842
+ } else if (unknownKeys === "strip") ;
1843
+ else {
1844
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
1845
+ }
1846
+ } else {
1847
+ const catchall = this._def.catchall;
1848
+ for (const key of extraKeys) {
1849
+ const value = ctx.data[key];
1850
+ pairs.push({
1851
+ key: { status: "valid", value: key },
1852
+ value: catchall._parse(
1853
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
1854
+ //, ctx.child(key), value, getParsedType(value)
1855
+ ),
1856
+ alwaysSet: key in ctx.data
1857
+ });
1858
+ }
407
1859
  }
408
- for (const handler of additionalHandlers) {
409
- if (manager.handlers.filter((h) => h.name === "console_callback_handler").some((h) => h.name === handler.name)) continue;
410
- manager.addHandler(handler, inherit);
1860
+ if (ctx.common.async) {
1861
+ return Promise.resolve().then(async () => {
1862
+ const syncPairs = [];
1863
+ for (const pair of pairs) {
1864
+ const key = await pair.key;
1865
+ const value = await pair.value;
1866
+ syncPairs.push({
1867
+ key,
1868
+ value,
1869
+ alwaysSet: pair.alwaysSet
1870
+ });
1871
+ }
1872
+ return syncPairs;
1873
+ }).then((syncPairs) => {
1874
+ return ParseStatus.mergeObjectSync(status, syncPairs);
1875
+ });
1876
+ } else {
1877
+ return ParseStatus.mergeObjectSync(status, pairs);
411
1878
  }
412
- return manager;
413
1879
  }
414
- static fromHandlers(handlers) {
415
- class Handler extends BaseCallbackHandler {
416
- name = v7();
417
- constructor() {
418
- super();
419
- Object.assign(this, handlers);
1880
+ get shape() {
1881
+ return this._def.shape();
1882
+ }
1883
+ strict(message) {
1884
+ errorUtil.errToObj;
1885
+ return new ZodObject({
1886
+ ...this._def,
1887
+ unknownKeys: "strict",
1888
+ ...message !== void 0 ? {
1889
+ errorMap: (issue, ctx) => {
1890
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
1891
+ if (issue.code === "unrecognized_keys")
1892
+ return {
1893
+ message: errorUtil.errToObj(message).message ?? defaultError
1894
+ };
1895
+ return {
1896
+ message: defaultError
1897
+ };
1898
+ }
1899
+ } : {}
1900
+ });
1901
+ }
1902
+ strip() {
1903
+ return new ZodObject({
1904
+ ...this._def,
1905
+ unknownKeys: "strip"
1906
+ });
1907
+ }
1908
+ passthrough() {
1909
+ return new ZodObject({
1910
+ ...this._def,
1911
+ unknownKeys: "passthrough"
1912
+ });
1913
+ }
1914
+ // const AugmentFactory =
1915
+ // <Def extends ZodObjectDef>(def: Def) =>
1916
+ // <Augmentation extends ZodRawShape>(
1917
+ // augmentation: Augmentation
1918
+ // ): ZodObject<
1919
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1920
+ // Def["unknownKeys"],
1921
+ // Def["catchall"]
1922
+ // > => {
1923
+ // return new ZodObject({
1924
+ // ...def,
1925
+ // shape: () => ({
1926
+ // ...def.shape(),
1927
+ // ...augmentation,
1928
+ // }),
1929
+ // }) as any;
1930
+ // };
1931
+ extend(augmentation) {
1932
+ return new ZodObject({
1933
+ ...this._def,
1934
+ shape: () => ({
1935
+ ...this._def.shape(),
1936
+ ...augmentation
1937
+ })
1938
+ });
1939
+ }
1940
+ /**
1941
+ * Prior to zod@1.0.12 there was a bug in the
1942
+ * inferred type of merged objects. Please
1943
+ * upgrade if you are experiencing issues.
1944
+ */
1945
+ merge(merging) {
1946
+ const merged = new ZodObject({
1947
+ unknownKeys: merging._def.unknownKeys,
1948
+ catchall: merging._def.catchall,
1949
+ shape: () => ({
1950
+ ...this._def.shape(),
1951
+ ...merging._def.shape()
1952
+ }),
1953
+ typeName: ZodFirstPartyTypeKind.ZodObject
1954
+ });
1955
+ return merged;
1956
+ }
1957
+ // merge<
1958
+ // Incoming extends AnyZodObject,
1959
+ // Augmentation extends Incoming["shape"],
1960
+ // NewOutput extends {
1961
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1962
+ // ? Augmentation[k]["_output"]
1963
+ // : k extends keyof Output
1964
+ // ? Output[k]
1965
+ // : never;
1966
+ // },
1967
+ // NewInput extends {
1968
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1969
+ // ? Augmentation[k]["_input"]
1970
+ // : k extends keyof Input
1971
+ // ? Input[k]
1972
+ // : never;
1973
+ // }
1974
+ // >(
1975
+ // merging: Incoming
1976
+ // ): ZodObject<
1977
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1978
+ // Incoming["_def"]["unknownKeys"],
1979
+ // Incoming["_def"]["catchall"],
1980
+ // NewOutput,
1981
+ // NewInput
1982
+ // > {
1983
+ // const merged: any = new ZodObject({
1984
+ // unknownKeys: merging._def.unknownKeys,
1985
+ // catchall: merging._def.catchall,
1986
+ // shape: () =>
1987
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1988
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1989
+ // }) as any;
1990
+ // return merged;
1991
+ // }
1992
+ setKey(key, schema) {
1993
+ return this.augment({ [key]: schema });
1994
+ }
1995
+ // merge<Incoming extends AnyZodObject>(
1996
+ // merging: Incoming
1997
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1998
+ // ZodObject<
1999
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2000
+ // Incoming["_def"]["unknownKeys"],
2001
+ // Incoming["_def"]["catchall"]
2002
+ // > {
2003
+ // // const mergedShape = objectUtil.mergeShapes(
2004
+ // // this._def.shape(),
2005
+ // // merging._def.shape()
2006
+ // // );
2007
+ // const merged: any = new ZodObject({
2008
+ // unknownKeys: merging._def.unknownKeys,
2009
+ // catchall: merging._def.catchall,
2010
+ // shape: () =>
2011
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2012
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2013
+ // }) as any;
2014
+ // return merged;
2015
+ // }
2016
+ catchall(index) {
2017
+ return new ZodObject({
2018
+ ...this._def,
2019
+ catchall: index
2020
+ });
2021
+ }
2022
+ pick(mask) {
2023
+ const shape = {};
2024
+ for (const key of util.objectKeys(mask)) {
2025
+ if (mask[key] && this.shape[key]) {
2026
+ shape[key] = this.shape[key];
420
2027
  }
421
2028
  }
422
- const manager = new this();
423
- manager.addHandler(new Handler());
424
- return manager;
2029
+ return new ZodObject({
2030
+ ...this._def,
2031
+ shape: () => shape
2032
+ });
425
2033
  }
426
- static configure(inheritableHandlers, localHandlers, inheritableTags, localTags, inheritableMetadata, localMetadata, options) {
427
- return this._configureSync(inheritableHandlers, localHandlers, inheritableTags, localTags, inheritableMetadata, localMetadata, options);
2034
+ omit(mask) {
2035
+ const shape = {};
2036
+ for (const key of util.objectKeys(this.shape)) {
2037
+ if (!mask[key]) {
2038
+ shape[key] = this.shape[key];
2039
+ }
2040
+ }
2041
+ return new ZodObject({
2042
+ ...this._def,
2043
+ shape: () => shape
2044
+ });
2045
+ }
2046
+ /**
2047
+ * @deprecated
2048
+ */
2049
+ deepPartial() {
2050
+ return deepPartialify(this);
428
2051
  }
429
- static _configureSync(inheritableHandlers, localHandlers, inheritableTags, localTags, inheritableMetadata, localMetadata, options) {
430
- let callbackManager;
431
- if (inheritableHandlers || localHandlers) {
432
- if (Array.isArray(inheritableHandlers) || !inheritableHandlers) {
433
- callbackManager = new CallbackManager2();
434
- callbackManager.setHandlers(inheritableHandlers?.map(ensureHandler) ?? [], true);
435
- } else callbackManager = inheritableHandlers;
436
- callbackManager = callbackManager.copy(Array.isArray(localHandlers) ? localHandlers.map(ensureHandler) : localHandlers?.handlers, false);
2052
+ partial(mask) {
2053
+ const newShape = {};
2054
+ for (const key of util.objectKeys(this.shape)) {
2055
+ const fieldSchema = this.shape[key];
2056
+ if (mask && !mask[key]) {
2057
+ newShape[key] = fieldSchema;
2058
+ } else {
2059
+ newShape[key] = fieldSchema.optional();
2060
+ }
437
2061
  }
438
- const verboseEnabled = getEnvironmentVariable("LANGCHAIN_VERBOSE") === "true" || options?.verbose;
439
- const tracingV2Enabled = LangChainTracer.getTraceableRunTree()?.tracingEnabled || isTracingEnabled();
440
- const tracingEnabled = tracingV2Enabled || (getEnvironmentVariable("LANGCHAIN_TRACING") ?? false);
441
- if (verboseEnabled || tracingEnabled) {
442
- if (!callbackManager) callbackManager = new CallbackManager2();
443
- if (verboseEnabled && !callbackManager.handlers.some((handler) => handler.name === ConsoleCallbackHandler.prototype.name)) {
444
- const consoleHandler = new ConsoleCallbackHandler();
445
- callbackManager.addHandler(consoleHandler, true);
2062
+ return new ZodObject({
2063
+ ...this._def,
2064
+ shape: () => newShape
2065
+ });
2066
+ }
2067
+ required(mask) {
2068
+ const newShape = {};
2069
+ for (const key of util.objectKeys(this.shape)) {
2070
+ if (mask && !mask[key]) {
2071
+ newShape[key] = this.shape[key];
2072
+ } else {
2073
+ const fieldSchema = this.shape[key];
2074
+ let newField = fieldSchema;
2075
+ while (newField instanceof ZodOptional) {
2076
+ newField = newField._def.innerType;
2077
+ }
2078
+ newShape[key] = newField;
2079
+ }
2080
+ }
2081
+ return new ZodObject({
2082
+ ...this._def,
2083
+ shape: () => newShape
2084
+ });
2085
+ }
2086
+ keyof() {
2087
+ return createZodEnum(util.objectKeys(this.shape));
2088
+ }
2089
+ }
2090
+ ZodObject.create = (shape, params) => {
2091
+ return new ZodObject({
2092
+ shape: () => shape,
2093
+ unknownKeys: "strip",
2094
+ catchall: ZodNever.create(),
2095
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2096
+ ...processCreateParams(params)
2097
+ });
2098
+ };
2099
+ ZodObject.strictCreate = (shape, params) => {
2100
+ return new ZodObject({
2101
+ shape: () => shape,
2102
+ unknownKeys: "strict",
2103
+ catchall: ZodNever.create(),
2104
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2105
+ ...processCreateParams(params)
2106
+ });
2107
+ };
2108
+ ZodObject.lazycreate = (shape, params) => {
2109
+ return new ZodObject({
2110
+ shape,
2111
+ unknownKeys: "strip",
2112
+ catchall: ZodNever.create(),
2113
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2114
+ ...processCreateParams(params)
2115
+ });
2116
+ };
2117
+ class ZodUnion extends ZodType {
2118
+ _parse(input) {
2119
+ const { ctx } = this._processInputParams(input);
2120
+ const options = this._def.options;
2121
+ function handleResults(results) {
2122
+ for (const result of results) {
2123
+ if (result.result.status === "valid") {
2124
+ return result.result;
2125
+ }
446
2126
  }
447
- if (tracingEnabled && !callbackManager.handlers.some((handler) => handler.name === "langchain_tracer")) {
448
- if (tracingV2Enabled) {
449
- const tracerV2 = new LangChainTracer();
450
- callbackManager.addHandler(tracerV2, true);
2127
+ for (const result of results) {
2128
+ if (result.result.status === "dirty") {
2129
+ ctx.common.issues.push(...result.ctx.common.issues);
2130
+ return result.result;
451
2131
  }
452
2132
  }
453
- if (tracingV2Enabled) {
454
- const implicitRunTree = LangChainTracer.getTraceableRunTree();
455
- if (implicitRunTree && callbackManager._parentRunId === void 0) {
456
- callbackManager._parentRunId = implicitRunTree.id;
457
- const tracerV2 = callbackManager.handlers.find((handler) => handler.name === "langchain_tracer");
458
- tracerV2?.updateFromRunTree(implicitRunTree);
2133
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2134
+ addIssueToContext(ctx, {
2135
+ code: ZodIssueCode.invalid_union,
2136
+ unionErrors
2137
+ });
2138
+ return INVALID;
2139
+ }
2140
+ if (ctx.common.async) {
2141
+ return Promise.all(options.map(async (option) => {
2142
+ const childCtx = {
2143
+ ...ctx,
2144
+ common: {
2145
+ ...ctx.common,
2146
+ issues: []
2147
+ },
2148
+ parent: null
2149
+ };
2150
+ return {
2151
+ result: await option._parseAsync({
2152
+ data: ctx.data,
2153
+ path: ctx.path,
2154
+ parent: childCtx
2155
+ }),
2156
+ ctx: childCtx
2157
+ };
2158
+ })).then(handleResults);
2159
+ } else {
2160
+ let dirty = void 0;
2161
+ const issues = [];
2162
+ for (const option of options) {
2163
+ const childCtx = {
2164
+ ...ctx,
2165
+ common: {
2166
+ ...ctx.common,
2167
+ issues: []
2168
+ },
2169
+ parent: null
2170
+ };
2171
+ const result = option._parseSync({
2172
+ data: ctx.data,
2173
+ path: ctx.path,
2174
+ parent: childCtx
2175
+ });
2176
+ if (result.status === "valid") {
2177
+ return result;
2178
+ } else if (result.status === "dirty" && !dirty) {
2179
+ dirty = { result, ctx: childCtx };
459
2180
  }
2181
+ if (childCtx.common.issues.length) {
2182
+ issues.push(childCtx.common.issues);
2183
+ }
2184
+ }
2185
+ if (dirty) {
2186
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2187
+ return dirty.result;
460
2188
  }
2189
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2190
+ addIssueToContext(ctx, {
2191
+ code: ZodIssueCode.invalid_union,
2192
+ unionErrors
2193
+ });
2194
+ return INVALID;
461
2195
  }
462
- for (const { contextVar, inheritable = true, handlerClass, envVar } of _getConfigureHooks()) {
463
- const createIfNotInContext = envVar && getEnvironmentVariable(envVar) === "true" && handlerClass;
464
- let handler;
465
- const contextVarValue = contextVar !== void 0 ? getContextVariable(contextVar) : void 0;
466
- if (contextVarValue && isBaseCallbackHandler(contextVarValue)) handler = contextVarValue;
467
- else if (createIfNotInContext) handler = new handlerClass({});
468
- if (handler !== void 0) {
469
- if (!callbackManager) callbackManager = new CallbackManager2();
470
- if (!callbackManager.handlers.some((h) => h.name === handler.name)) callbackManager.addHandler(handler, inheritable);
2196
+ }
2197
+ get options() {
2198
+ return this._def.options;
2199
+ }
2200
+ }
2201
+ ZodUnion.create = (types, params) => {
2202
+ return new ZodUnion({
2203
+ options: types,
2204
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2205
+ ...processCreateParams(params)
2206
+ });
2207
+ };
2208
+ function mergeValues(a, b) {
2209
+ const aType = getParsedType(a);
2210
+ const bType = getParsedType(b);
2211
+ if (a === b) {
2212
+ return { valid: true, data: a };
2213
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2214
+ const bKeys = util.objectKeys(b);
2215
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2216
+ const newObj = { ...a, ...b };
2217
+ for (const key of sharedKeys) {
2218
+ const sharedValue = mergeValues(a[key], b[key]);
2219
+ if (!sharedValue.valid) {
2220
+ return { valid: false };
471
2221
  }
2222
+ newObj[key] = sharedValue.data;
472
2223
  }
473
- if (inheritableTags || localTags) {
474
- if (callbackManager) {
475
- callbackManager.addTags(inheritableTags ?? []);
476
- callbackManager.addTags(localTags ?? [], false);
2224
+ return { valid: true, data: newObj };
2225
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2226
+ if (a.length !== b.length) {
2227
+ return { valid: false };
2228
+ }
2229
+ const newArray = [];
2230
+ for (let index = 0; index < a.length; index++) {
2231
+ const itemA = a[index];
2232
+ const itemB = b[index];
2233
+ const sharedValue = mergeValues(itemA, itemB);
2234
+ if (!sharedValue.valid) {
2235
+ return { valid: false };
477
2236
  }
2237
+ newArray.push(sharedValue.data);
478
2238
  }
479
- if (inheritableMetadata || localMetadata) {
480
- if (callbackManager) {
481
- callbackManager.addMetadata(inheritableMetadata ?? {});
482
- callbackManager.addMetadata(localMetadata ?? {}, false);
2239
+ return { valid: true, data: newArray };
2240
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2241
+ return { valid: true, data: a };
2242
+ } else {
2243
+ return { valid: false };
2244
+ }
2245
+ }
2246
+ class ZodIntersection extends ZodType {
2247
+ _parse(input) {
2248
+ const { status, ctx } = this._processInputParams(input);
2249
+ const handleParsed = (parsedLeft, parsedRight) => {
2250
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2251
+ return INVALID;
2252
+ }
2253
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2254
+ if (!merged.valid) {
2255
+ addIssueToContext(ctx, {
2256
+ code: ZodIssueCode.invalid_intersection_types
2257
+ });
2258
+ return INVALID;
483
2259
  }
2260
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2261
+ status.dirty();
2262
+ }
2263
+ return { status: status.value, value: merged.data };
2264
+ };
2265
+ if (ctx.common.async) {
2266
+ return Promise.all([
2267
+ this._def.left._parseAsync({
2268
+ data: ctx.data,
2269
+ path: ctx.path,
2270
+ parent: ctx
2271
+ }),
2272
+ this._def.right._parseAsync({
2273
+ data: ctx.data,
2274
+ path: ctx.path,
2275
+ parent: ctx
2276
+ })
2277
+ ]).then(([left, right]) => handleParsed(left, right));
2278
+ } else {
2279
+ return handleParsed(this._def.left._parseSync({
2280
+ data: ctx.data,
2281
+ path: ctx.path,
2282
+ parent: ctx
2283
+ }), this._def.right._parseSync({
2284
+ data: ctx.data,
2285
+ path: ctx.path,
2286
+ parent: ctx
2287
+ }));
484
2288
  }
485
- return callbackManager;
486
2289
  }
2290
+ }
2291
+ ZodIntersection.create = (left, right, params) => {
2292
+ return new ZodIntersection({
2293
+ left,
2294
+ right,
2295
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2296
+ ...processCreateParams(params)
2297
+ });
487
2298
  };
488
- function ensureHandler(handler) {
489
- if ("name" in handler) return handler;
490
- return BaseCallbackHandler.fromMethods(handler);
2299
+ class ZodTuple extends ZodType {
2300
+ _parse(input) {
2301
+ const { status, ctx } = this._processInputParams(input);
2302
+ if (ctx.parsedType !== ZodParsedType.array) {
2303
+ addIssueToContext(ctx, {
2304
+ code: ZodIssueCode.invalid_type,
2305
+ expected: ZodParsedType.array,
2306
+ received: ctx.parsedType
2307
+ });
2308
+ return INVALID;
2309
+ }
2310
+ if (ctx.data.length < this._def.items.length) {
2311
+ addIssueToContext(ctx, {
2312
+ code: ZodIssueCode.too_small,
2313
+ minimum: this._def.items.length,
2314
+ inclusive: true,
2315
+ exact: false,
2316
+ type: "array"
2317
+ });
2318
+ return INVALID;
2319
+ }
2320
+ const rest = this._def.rest;
2321
+ if (!rest && ctx.data.length > this._def.items.length) {
2322
+ addIssueToContext(ctx, {
2323
+ code: ZodIssueCode.too_big,
2324
+ maximum: this._def.items.length,
2325
+ inclusive: true,
2326
+ exact: false,
2327
+ type: "array"
2328
+ });
2329
+ status.dirty();
2330
+ }
2331
+ const items = [...ctx.data].map((item, itemIndex) => {
2332
+ const schema = this._def.items[itemIndex] || this._def.rest;
2333
+ if (!schema)
2334
+ return null;
2335
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2336
+ }).filter((x) => !!x);
2337
+ if (ctx.common.async) {
2338
+ return Promise.all(items).then((results) => {
2339
+ return ParseStatus.mergeArray(status, results);
2340
+ });
2341
+ } else {
2342
+ return ParseStatus.mergeArray(status, items);
2343
+ }
2344
+ }
2345
+ get items() {
2346
+ return this._def.items;
2347
+ }
2348
+ rest(rest) {
2349
+ return new ZodTuple({
2350
+ ...this._def,
2351
+ rest
2352
+ });
2353
+ }
491
2354
  }
2355
+ ZodTuple.create = (schemas, params) => {
2356
+ if (!Array.isArray(schemas)) {
2357
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2358
+ }
2359
+ return new ZodTuple({
2360
+ items: schemas,
2361
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2362
+ rest: null,
2363
+ ...processCreateParams(params)
2364
+ });
2365
+ };
2366
+ class ZodMap extends ZodType {
2367
+ get keySchema() {
2368
+ return this._def.keyType;
2369
+ }
2370
+ get valueSchema() {
2371
+ return this._def.valueType;
2372
+ }
2373
+ _parse(input) {
2374
+ const { status, ctx } = this._processInputParams(input);
2375
+ if (ctx.parsedType !== ZodParsedType.map) {
2376
+ addIssueToContext(ctx, {
2377
+ code: ZodIssueCode.invalid_type,
2378
+ expected: ZodParsedType.map,
2379
+ received: ctx.parsedType
2380
+ });
2381
+ return INVALID;
2382
+ }
2383
+ const keyType = this._def.keyType;
2384
+ const valueType = this._def.valueType;
2385
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2386
+ return {
2387
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2388
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2389
+ };
2390
+ });
2391
+ if (ctx.common.async) {
2392
+ const finalMap = /* @__PURE__ */ new Map();
2393
+ return Promise.resolve().then(async () => {
2394
+ for (const pair of pairs) {
2395
+ const key = await pair.key;
2396
+ const value = await pair.value;
2397
+ if (key.status === "aborted" || value.status === "aborted") {
2398
+ return INVALID;
2399
+ }
2400
+ if (key.status === "dirty" || value.status === "dirty") {
2401
+ status.dirty();
2402
+ }
2403
+ finalMap.set(key.value, value.value);
2404
+ }
2405
+ return { status: status.value, value: finalMap };
2406
+ });
2407
+ } else {
2408
+ const finalMap = /* @__PURE__ */ new Map();
2409
+ for (const pair of pairs) {
2410
+ const key = pair.key;
2411
+ const value = pair.value;
2412
+ if (key.status === "aborted" || value.status === "aborted") {
2413
+ return INVALID;
2414
+ }
2415
+ if (key.status === "dirty" || value.status === "dirty") {
2416
+ status.dirty();
2417
+ }
2418
+ finalMap.set(key.value, value.value);
2419
+ }
2420
+ return { status: status.value, value: finalMap };
2421
+ }
2422
+ }
2423
+ }
2424
+ ZodMap.create = (keyType, valueType, params) => {
2425
+ return new ZodMap({
2426
+ valueType,
2427
+ keyType,
2428
+ typeName: ZodFirstPartyTypeKind.ZodMap,
2429
+ ...processCreateParams(params)
2430
+ });
2431
+ };
2432
+ class ZodSet extends ZodType {
2433
+ _parse(input) {
2434
+ const { status, ctx } = this._processInputParams(input);
2435
+ if (ctx.parsedType !== ZodParsedType.set) {
2436
+ addIssueToContext(ctx, {
2437
+ code: ZodIssueCode.invalid_type,
2438
+ expected: ZodParsedType.set,
2439
+ received: ctx.parsedType
2440
+ });
2441
+ return INVALID;
2442
+ }
2443
+ const def = this._def;
2444
+ if (def.minSize !== null) {
2445
+ if (ctx.data.size < def.minSize.value) {
2446
+ addIssueToContext(ctx, {
2447
+ code: ZodIssueCode.too_small,
2448
+ minimum: def.minSize.value,
2449
+ type: "set",
2450
+ inclusive: true,
2451
+ exact: false,
2452
+ message: def.minSize.message
2453
+ });
2454
+ status.dirty();
2455
+ }
2456
+ }
2457
+ if (def.maxSize !== null) {
2458
+ if (ctx.data.size > def.maxSize.value) {
2459
+ addIssueToContext(ctx, {
2460
+ code: ZodIssueCode.too_big,
2461
+ maximum: def.maxSize.value,
2462
+ type: "set",
2463
+ inclusive: true,
2464
+ exact: false,
2465
+ message: def.maxSize.message
2466
+ });
2467
+ status.dirty();
2468
+ }
2469
+ }
2470
+ const valueType = this._def.valueType;
2471
+ function finalizeSet(elements2) {
2472
+ const parsedSet = /* @__PURE__ */ new Set();
2473
+ for (const element of elements2) {
2474
+ if (element.status === "aborted")
2475
+ return INVALID;
2476
+ if (element.status === "dirty")
2477
+ status.dirty();
2478
+ parsedSet.add(element.value);
2479
+ }
2480
+ return { status: status.value, value: parsedSet };
2481
+ }
2482
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2483
+ if (ctx.common.async) {
2484
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
2485
+ } else {
2486
+ return finalizeSet(elements);
2487
+ }
2488
+ }
2489
+ min(minSize, message) {
2490
+ return new ZodSet({
2491
+ ...this._def,
2492
+ minSize: { value: minSize, message: errorUtil.toString(message) }
2493
+ });
2494
+ }
2495
+ max(maxSize, message) {
2496
+ return new ZodSet({
2497
+ ...this._def,
2498
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
2499
+ });
2500
+ }
2501
+ size(size, message) {
2502
+ return this.min(size, message).max(size, message);
2503
+ }
2504
+ nonempty(message) {
2505
+ return this.min(1, message);
2506
+ }
2507
+ }
2508
+ ZodSet.create = (valueType, params) => {
2509
+ return new ZodSet({
2510
+ valueType,
2511
+ minSize: null,
2512
+ maxSize: null,
2513
+ typeName: ZodFirstPartyTypeKind.ZodSet,
2514
+ ...processCreateParams(params)
2515
+ });
2516
+ };
2517
+ class ZodLazy extends ZodType {
2518
+ get schema() {
2519
+ return this._def.getter();
2520
+ }
2521
+ _parse(input) {
2522
+ const { ctx } = this._processInputParams(input);
2523
+ const lazySchema = this._def.getter();
2524
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
2525
+ }
2526
+ }
2527
+ ZodLazy.create = (getter, params) => {
2528
+ return new ZodLazy({
2529
+ getter,
2530
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
2531
+ ...processCreateParams(params)
2532
+ });
2533
+ };
2534
+ class ZodLiteral extends ZodType {
2535
+ _parse(input) {
2536
+ if (input.data !== this._def.value) {
2537
+ const ctx = this._getOrReturnCtx(input);
2538
+ addIssueToContext(ctx, {
2539
+ received: ctx.data,
2540
+ code: ZodIssueCode.invalid_literal,
2541
+ expected: this._def.value
2542
+ });
2543
+ return INVALID;
2544
+ }
2545
+ return { status: "valid", value: input.data };
2546
+ }
2547
+ get value() {
2548
+ return this._def.value;
2549
+ }
2550
+ }
2551
+ ZodLiteral.create = (value, params) => {
2552
+ return new ZodLiteral({
2553
+ value,
2554
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
2555
+ ...processCreateParams(params)
2556
+ });
2557
+ };
2558
+ function createZodEnum(values, params) {
2559
+ return new ZodEnum({
2560
+ values,
2561
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
2562
+ ...processCreateParams(params)
2563
+ });
2564
+ }
2565
+ class ZodEnum extends ZodType {
2566
+ _parse(input) {
2567
+ if (typeof input.data !== "string") {
2568
+ const ctx = this._getOrReturnCtx(input);
2569
+ const expectedValues = this._def.values;
2570
+ addIssueToContext(ctx, {
2571
+ expected: util.joinValues(expectedValues),
2572
+ received: ctx.parsedType,
2573
+ code: ZodIssueCode.invalid_type
2574
+ });
2575
+ return INVALID;
2576
+ }
2577
+ if (!this._cache) {
2578
+ this._cache = new Set(this._def.values);
2579
+ }
2580
+ if (!this._cache.has(input.data)) {
2581
+ const ctx = this._getOrReturnCtx(input);
2582
+ const expectedValues = this._def.values;
2583
+ addIssueToContext(ctx, {
2584
+ received: ctx.data,
2585
+ code: ZodIssueCode.invalid_enum_value,
2586
+ options: expectedValues
2587
+ });
2588
+ return INVALID;
2589
+ }
2590
+ return OK(input.data);
2591
+ }
2592
+ get options() {
2593
+ return this._def.values;
2594
+ }
2595
+ get enum() {
2596
+ const enumValues = {};
2597
+ for (const val of this._def.values) {
2598
+ enumValues[val] = val;
2599
+ }
2600
+ return enumValues;
2601
+ }
2602
+ get Values() {
2603
+ const enumValues = {};
2604
+ for (const val of this._def.values) {
2605
+ enumValues[val] = val;
2606
+ }
2607
+ return enumValues;
2608
+ }
2609
+ get Enum() {
2610
+ const enumValues = {};
2611
+ for (const val of this._def.values) {
2612
+ enumValues[val] = val;
2613
+ }
2614
+ return enumValues;
2615
+ }
2616
+ extract(values, newDef = this._def) {
2617
+ return ZodEnum.create(values, {
2618
+ ...this._def,
2619
+ ...newDef
2620
+ });
2621
+ }
2622
+ exclude(values, newDef = this._def) {
2623
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
2624
+ ...this._def,
2625
+ ...newDef
2626
+ });
2627
+ }
2628
+ }
2629
+ ZodEnum.create = createZodEnum;
2630
+ class ZodNativeEnum extends ZodType {
2631
+ _parse(input) {
2632
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
2633
+ const ctx = this._getOrReturnCtx(input);
2634
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
2635
+ const expectedValues = util.objectValues(nativeEnumValues);
2636
+ addIssueToContext(ctx, {
2637
+ expected: util.joinValues(expectedValues),
2638
+ received: ctx.parsedType,
2639
+ code: ZodIssueCode.invalid_type
2640
+ });
2641
+ return INVALID;
2642
+ }
2643
+ if (!this._cache) {
2644
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
2645
+ }
2646
+ if (!this._cache.has(input.data)) {
2647
+ const expectedValues = util.objectValues(nativeEnumValues);
2648
+ addIssueToContext(ctx, {
2649
+ received: ctx.data,
2650
+ code: ZodIssueCode.invalid_enum_value,
2651
+ options: expectedValues
2652
+ });
2653
+ return INVALID;
2654
+ }
2655
+ return OK(input.data);
2656
+ }
2657
+ get enum() {
2658
+ return this._def.values;
2659
+ }
2660
+ }
2661
+ ZodNativeEnum.create = (values, params) => {
2662
+ return new ZodNativeEnum({
2663
+ values,
2664
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
2665
+ ...processCreateParams(params)
2666
+ });
2667
+ };
2668
+ class ZodPromise extends ZodType {
2669
+ unwrap() {
2670
+ return this._def.type;
2671
+ }
2672
+ _parse(input) {
2673
+ const { ctx } = this._processInputParams(input);
2674
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
2675
+ addIssueToContext(ctx, {
2676
+ code: ZodIssueCode.invalid_type,
2677
+ expected: ZodParsedType.promise,
2678
+ received: ctx.parsedType
2679
+ });
2680
+ return INVALID;
2681
+ }
2682
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
2683
+ return OK(promisified.then((data) => {
2684
+ return this._def.type.parseAsync(data, {
2685
+ path: ctx.path,
2686
+ errorMap: ctx.common.contextualErrorMap
2687
+ });
2688
+ }));
2689
+ }
2690
+ }
2691
+ ZodPromise.create = (schema, params) => {
2692
+ return new ZodPromise({
2693
+ type: schema,
2694
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
2695
+ ...processCreateParams(params)
2696
+ });
2697
+ };
2698
+ class ZodEffects extends ZodType {
2699
+ innerType() {
2700
+ return this._def.schema;
2701
+ }
2702
+ sourceType() {
2703
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2704
+ }
2705
+ _parse(input) {
2706
+ const { status, ctx } = this._processInputParams(input);
2707
+ const effect = this._def.effect || null;
2708
+ const checkCtx = {
2709
+ addIssue: (arg) => {
2710
+ addIssueToContext(ctx, arg);
2711
+ if (arg.fatal) {
2712
+ status.abort();
2713
+ } else {
2714
+ status.dirty();
2715
+ }
2716
+ },
2717
+ get path() {
2718
+ return ctx.path;
2719
+ }
2720
+ };
2721
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
2722
+ if (effect.type === "preprocess") {
2723
+ const processed = effect.transform(ctx.data, checkCtx);
2724
+ if (ctx.common.async) {
2725
+ return Promise.resolve(processed).then(async (processed2) => {
2726
+ if (status.value === "aborted")
2727
+ return INVALID;
2728
+ const result = await this._def.schema._parseAsync({
2729
+ data: processed2,
2730
+ path: ctx.path,
2731
+ parent: ctx
2732
+ });
2733
+ if (result.status === "aborted")
2734
+ return INVALID;
2735
+ if (result.status === "dirty")
2736
+ return DIRTY(result.value);
2737
+ if (status.value === "dirty")
2738
+ return DIRTY(result.value);
2739
+ return result;
2740
+ });
2741
+ } else {
2742
+ if (status.value === "aborted")
2743
+ return INVALID;
2744
+ const result = this._def.schema._parseSync({
2745
+ data: processed,
2746
+ path: ctx.path,
2747
+ parent: ctx
2748
+ });
2749
+ if (result.status === "aborted")
2750
+ return INVALID;
2751
+ if (result.status === "dirty")
2752
+ return DIRTY(result.value);
2753
+ if (status.value === "dirty")
2754
+ return DIRTY(result.value);
2755
+ return result;
2756
+ }
2757
+ }
2758
+ if (effect.type === "refinement") {
2759
+ const executeRefinement = (acc) => {
2760
+ const result = effect.refinement(acc, checkCtx);
2761
+ if (ctx.common.async) {
2762
+ return Promise.resolve(result);
2763
+ }
2764
+ if (result instanceof Promise) {
2765
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2766
+ }
2767
+ return acc;
2768
+ };
2769
+ if (ctx.common.async === false) {
2770
+ const inner = this._def.schema._parseSync({
2771
+ data: ctx.data,
2772
+ path: ctx.path,
2773
+ parent: ctx
2774
+ });
2775
+ if (inner.status === "aborted")
2776
+ return INVALID;
2777
+ if (inner.status === "dirty")
2778
+ status.dirty();
2779
+ executeRefinement(inner.value);
2780
+ return { status: status.value, value: inner.value };
2781
+ } else {
2782
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
2783
+ if (inner.status === "aborted")
2784
+ return INVALID;
2785
+ if (inner.status === "dirty")
2786
+ status.dirty();
2787
+ return executeRefinement(inner.value).then(() => {
2788
+ return { status: status.value, value: inner.value };
2789
+ });
2790
+ });
2791
+ }
2792
+ }
2793
+ if (effect.type === "transform") {
2794
+ if (ctx.common.async === false) {
2795
+ const base = this._def.schema._parseSync({
2796
+ data: ctx.data,
2797
+ path: ctx.path,
2798
+ parent: ctx
2799
+ });
2800
+ if (!isValid(base))
2801
+ return INVALID;
2802
+ const result = effect.transform(base.value, checkCtx);
2803
+ if (result instanceof Promise) {
2804
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
2805
+ }
2806
+ return { status: status.value, value: result };
2807
+ } else {
2808
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
2809
+ if (!isValid(base))
2810
+ return INVALID;
2811
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
2812
+ status: status.value,
2813
+ value: result
2814
+ }));
2815
+ });
2816
+ }
2817
+ }
2818
+ util.assertNever(effect);
2819
+ }
2820
+ }
2821
+ ZodEffects.create = (schema, effect, params) => {
2822
+ return new ZodEffects({
2823
+ schema,
2824
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2825
+ effect,
2826
+ ...processCreateParams(params)
2827
+ });
2828
+ };
2829
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
2830
+ return new ZodEffects({
2831
+ schema,
2832
+ effect: { type: "preprocess", transform: preprocess },
2833
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2834
+ ...processCreateParams(params)
2835
+ });
2836
+ };
2837
+ class ZodOptional extends ZodType {
2838
+ _parse(input) {
2839
+ const parsedType = this._getType(input);
2840
+ if (parsedType === ZodParsedType.undefined) {
2841
+ return OK(void 0);
2842
+ }
2843
+ return this._def.innerType._parse(input);
2844
+ }
2845
+ unwrap() {
2846
+ return this._def.innerType;
2847
+ }
2848
+ }
2849
+ ZodOptional.create = (type, params) => {
2850
+ return new ZodOptional({
2851
+ innerType: type,
2852
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
2853
+ ...processCreateParams(params)
2854
+ });
2855
+ };
2856
+ class ZodNullable extends ZodType {
2857
+ _parse(input) {
2858
+ const parsedType = this._getType(input);
2859
+ if (parsedType === ZodParsedType.null) {
2860
+ return OK(null);
2861
+ }
2862
+ return this._def.innerType._parse(input);
2863
+ }
2864
+ unwrap() {
2865
+ return this._def.innerType;
2866
+ }
2867
+ }
2868
+ ZodNullable.create = (type, params) => {
2869
+ return new ZodNullable({
2870
+ innerType: type,
2871
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
2872
+ ...processCreateParams(params)
2873
+ });
2874
+ };
2875
+ class ZodDefault extends ZodType {
2876
+ _parse(input) {
2877
+ const { ctx } = this._processInputParams(input);
2878
+ let data = ctx.data;
2879
+ if (ctx.parsedType === ZodParsedType.undefined) {
2880
+ data = this._def.defaultValue();
2881
+ }
2882
+ return this._def.innerType._parse({
2883
+ data,
2884
+ path: ctx.path,
2885
+ parent: ctx
2886
+ });
2887
+ }
2888
+ removeDefault() {
2889
+ return this._def.innerType;
2890
+ }
2891
+ }
2892
+ ZodDefault.create = (type, params) => {
2893
+ return new ZodDefault({
2894
+ innerType: type,
2895
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
2896
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
2897
+ ...processCreateParams(params)
2898
+ });
2899
+ };
2900
+ class ZodCatch extends ZodType {
2901
+ _parse(input) {
2902
+ const { ctx } = this._processInputParams(input);
2903
+ const newCtx = {
2904
+ ...ctx,
2905
+ common: {
2906
+ ...ctx.common,
2907
+ issues: []
2908
+ }
2909
+ };
2910
+ const result = this._def.innerType._parse({
2911
+ data: newCtx.data,
2912
+ path: newCtx.path,
2913
+ parent: {
2914
+ ...newCtx
2915
+ }
2916
+ });
2917
+ if (isAsync(result)) {
2918
+ return result.then((result2) => {
2919
+ return {
2920
+ status: "valid",
2921
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
2922
+ get error() {
2923
+ return new ZodError(newCtx.common.issues);
2924
+ },
2925
+ input: newCtx.data
2926
+ })
2927
+ };
2928
+ });
2929
+ } else {
2930
+ return {
2931
+ status: "valid",
2932
+ value: result.status === "valid" ? result.value : this._def.catchValue({
2933
+ get error() {
2934
+ return new ZodError(newCtx.common.issues);
2935
+ },
2936
+ input: newCtx.data
2937
+ })
2938
+ };
2939
+ }
2940
+ }
2941
+ removeCatch() {
2942
+ return this._def.innerType;
2943
+ }
2944
+ }
2945
+ ZodCatch.create = (type, params) => {
2946
+ return new ZodCatch({
2947
+ innerType: type,
2948
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
2949
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
2950
+ ...processCreateParams(params)
2951
+ });
2952
+ };
2953
+ class ZodNaN extends ZodType {
2954
+ _parse(input) {
2955
+ const parsedType = this._getType(input);
2956
+ if (parsedType !== ZodParsedType.nan) {
2957
+ const ctx = this._getOrReturnCtx(input);
2958
+ addIssueToContext(ctx, {
2959
+ code: ZodIssueCode.invalid_type,
2960
+ expected: ZodParsedType.nan,
2961
+ received: ctx.parsedType
2962
+ });
2963
+ return INVALID;
2964
+ }
2965
+ return { status: "valid", value: input.data };
2966
+ }
2967
+ }
2968
+ ZodNaN.create = (params) => {
2969
+ return new ZodNaN({
2970
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
2971
+ ...processCreateParams(params)
2972
+ });
2973
+ };
2974
+ class ZodBranded extends ZodType {
2975
+ _parse(input) {
2976
+ const { ctx } = this._processInputParams(input);
2977
+ const data = ctx.data;
2978
+ return this._def.type._parse({
2979
+ data,
2980
+ path: ctx.path,
2981
+ parent: ctx
2982
+ });
2983
+ }
2984
+ unwrap() {
2985
+ return this._def.type;
2986
+ }
2987
+ }
2988
+ class ZodPipeline extends ZodType {
2989
+ _parse(input) {
2990
+ const { status, ctx } = this._processInputParams(input);
2991
+ if (ctx.common.async) {
2992
+ const handleAsync = async () => {
2993
+ const inResult = await this._def.in._parseAsync({
2994
+ data: ctx.data,
2995
+ path: ctx.path,
2996
+ parent: ctx
2997
+ });
2998
+ if (inResult.status === "aborted")
2999
+ return INVALID;
3000
+ if (inResult.status === "dirty") {
3001
+ status.dirty();
3002
+ return DIRTY(inResult.value);
3003
+ } else {
3004
+ return this._def.out._parseAsync({
3005
+ data: inResult.value,
3006
+ path: ctx.path,
3007
+ parent: ctx
3008
+ });
3009
+ }
3010
+ };
3011
+ return handleAsync();
3012
+ } else {
3013
+ const inResult = this._def.in._parseSync({
3014
+ data: ctx.data,
3015
+ path: ctx.path,
3016
+ parent: ctx
3017
+ });
3018
+ if (inResult.status === "aborted")
3019
+ return INVALID;
3020
+ if (inResult.status === "dirty") {
3021
+ status.dirty();
3022
+ return {
3023
+ status: "dirty",
3024
+ value: inResult.value
3025
+ };
3026
+ } else {
3027
+ return this._def.out._parseSync({
3028
+ data: inResult.value,
3029
+ path: ctx.path,
3030
+ parent: ctx
3031
+ });
3032
+ }
3033
+ }
3034
+ }
3035
+ static create(a, b) {
3036
+ return new ZodPipeline({
3037
+ in: a,
3038
+ out: b,
3039
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3040
+ });
3041
+ }
3042
+ }
3043
+ class ZodReadonly extends ZodType {
3044
+ _parse(input) {
3045
+ const result = this._def.innerType._parse(input);
3046
+ const freeze = (data) => {
3047
+ if (isValid(data)) {
3048
+ data.value = Object.freeze(data.value);
3049
+ }
3050
+ return data;
3051
+ };
3052
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3053
+ }
3054
+ unwrap() {
3055
+ return this._def.innerType;
3056
+ }
3057
+ }
3058
+ ZodReadonly.create = (type, params) => {
3059
+ return new ZodReadonly({
3060
+ innerType: type,
3061
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3062
+ ...processCreateParams(params)
3063
+ });
3064
+ };
3065
+ var ZodFirstPartyTypeKind;
3066
+ (function(ZodFirstPartyTypeKind2) {
3067
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3068
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3069
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3070
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3071
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3072
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3073
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3074
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3075
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3076
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3077
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3078
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3079
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3080
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3081
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3082
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3083
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3084
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3085
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3086
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3087
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3088
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3089
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3090
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3091
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3092
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
3093
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
3094
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
3095
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
3096
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
3097
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
3098
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
3099
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3100
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3101
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3102
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3103
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3104
+ const stringType = ZodString.create;
3105
+ const anyType = ZodAny.create;
3106
+ ZodNever.create;
3107
+ ZodArray.create;
3108
+ const objectType = ZodObject.create;
3109
+ ZodUnion.create;
3110
+ ZodIntersection.create;
3111
+ ZodTuple.create;
3112
+ ZodEnum.create;
3113
+ ZodPromise.create;
3114
+ ZodOptional.create;
3115
+ ZodNullable.create;
492
3116
  export {
493
- BaseCallbackManager,
494
- BaseRunManager,
495
- CallbackManager,
496
- CallbackManagerForChainRun,
497
- CallbackManagerForLLMRun,
498
- CallbackManagerForRetrieverRun,
499
- CallbackManagerForToolRun,
500
- ensureHandler,
501
- manager_exports,
502
- parseCallbackConfigArg
3117
+ ZodType as Schema,
3118
+ ZodAny,
3119
+ ZodArray,
3120
+ ZodBigInt,
3121
+ ZodBoolean,
3122
+ ZodBranded,
3123
+ ZodCatch,
3124
+ ZodDate,
3125
+ ZodDefault,
3126
+ ZodEffects,
3127
+ ZodEnum,
3128
+ ZodFirstPartyTypeKind,
3129
+ ZodIntersection,
3130
+ ZodLazy,
3131
+ ZodLiteral,
3132
+ ZodMap,
3133
+ ZodNaN,
3134
+ ZodNativeEnum,
3135
+ ZodNever,
3136
+ ZodNull,
3137
+ ZodNullable,
3138
+ ZodNumber,
3139
+ ZodObject,
3140
+ ZodOptional,
3141
+ ZodPipeline,
3142
+ ZodPromise,
3143
+ ZodReadonly,
3144
+ ZodType as ZodSchema,
3145
+ ZodSet,
3146
+ ZodString,
3147
+ ZodSymbol,
3148
+ ZodEffects as ZodTransformer,
3149
+ ZodTuple,
3150
+ ZodType,
3151
+ ZodUndefined,
3152
+ ZodUnion,
3153
+ ZodUnknown,
3154
+ ZodVoid,
3155
+ anyType as any,
3156
+ datetimeRegex,
3157
+ objectType as object,
3158
+ stringType as string
503
3159
  };
504
3160
  //# sourceMappingURL=index.es106.js.map