@design-edito/tools 0.1.60 → 0.1.62

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