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