@suveren/gateway 0.39.0 → 0.41.0
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/dist/control-plane/index.mjs +182 -37
- package/dist/mcp-server/http.mjs +356 -72
- package/dist/ui/assets/index-CO-dj98E.js +123 -0
- package/dist/ui/assets/index-DM9WXky8.css +1 -0
- package/dist/ui/index.html +2 -2
- package/node_modules/@hap/core/README.md +3 -3
- package/node_modules/@hap/core/dist/index.d.mts +567 -123
- package/node_modules/@hap/core/dist/index.d.ts +567 -123
- package/node_modules/@hap/core/dist/index.js +869 -23
- package/node_modules/@hap/core/dist/index.mjs +829 -22
- package/node_modules/@hap/core/node_modules/@hpke/core/LICENSE +21 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/README.md +263 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.js +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/package.json +3 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.js +167 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts +34 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.js +56 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts +145 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.js +326 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts +15 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.js +68 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts +19 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.js +62 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts +13 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts +8 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts +40 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts +7 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts +10 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts +26 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.js +112 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +214 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +214 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.js +66 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.js +66 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts +5 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.js +28 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts +236 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.js +235 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.js +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.js +45 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts +2 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.js +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/package.json +46 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.js +47 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/package.json +3 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.js +183 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts +34 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.js +70 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts +145 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.js +340 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts +15 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.js +82 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts +19 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.js +78 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts +13 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts +8 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts +40 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts +7 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts +10 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts +26 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.js +128 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +228 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +228 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.js +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.js +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts +5 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.js +42 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts +236 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.js +255 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.js +52 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.js +59 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts +2 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.js +19 -0
- package/node_modules/@hap/core/package.json +2 -1
- package/node_modules/@hap/core/src/canonicalize.ts +9 -0
- package/node_modules/@hap/core/src/commitment-modes.ts +21 -9
- package/node_modules/@hap/core/src/errors.ts +24 -8
- package/node_modules/@hap/core/src/gatekeeper.ts +52 -8
- package/node_modules/@hap/core/src/index.ts +5 -1
- package/node_modules/@hap/core/src/issuance.ts +250 -0
- package/node_modules/@hap/core/src/mandate.ts +52 -14
- package/node_modules/@hap/core/src/owner-signature.ts +86 -39
- package/node_modules/@hap/core/src/profile.ts +45 -0
- package/node_modules/@hap/core/src/proposal-content.ts +219 -0
- package/node_modules/@hap/core/src/ticket-projection.ts +167 -0
- package/node_modules/@hap/core/src/ticket.ts +254 -20
- package/node_modules/@hap/core/src/types.ts +33 -5
- package/node_modules/@hap/core/src/verifier-policy.ts +178 -0
- package/node_modules/@hap/core/src/versions.ts +50 -19
- package/node_modules/@hono/node-server/dist/index.cjs +31 -6
- package/node_modules/@hono/node-server/dist/index.mjs +31 -6
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@hpke/common/esm/package.json +5 -1
- package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts +2 -2
- package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/curve/montgomery.js +41 -26
- package/node_modules/@hpke/common/esm/src/hash/sha3.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/hash/sha3.js +0 -15
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts +2 -1
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.js +12 -2
- package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.js +14 -3
- package/node_modules/@hpke/common/esm/src/utils/misc.d.ts +6 -0
- package/node_modules/@hpke/common/esm/src/utils/misc.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/utils/misc.js +43 -10
- package/node_modules/@hpke/common/esm/src/utils/noble.d.ts +1 -1
- package/node_modules/@hpke/common/esm/src/utils/noble.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/utils/noble.js +21 -10
- package/node_modules/@hpke/common/package.json +5 -1
- package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts +2 -2
- package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/curve/montgomery.js +40 -25
- package/node_modules/@hpke/common/script/src/hash/sha3.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/hash/sha3.js +0 -15
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts +2 -1
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.js +12 -2
- package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.js +13 -2
- package/node_modules/@hpke/common/script/src/utils/misc.d.ts +6 -0
- package/node_modules/@hpke/common/script/src/utils/misc.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/utils/misc.js +43 -9
- package/node_modules/@hpke/common/script/src/utils/noble.d.ts +1 -1
- package/node_modules/@hpke/common/script/src/utils/noble.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/utils/noble.js +22 -11
- package/node_modules/@hpke/core/README.md +56 -56
- package/node_modules/@hpke/core/esm/package.json +2 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +3 -201
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +3 -21
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +3 -201
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.js +216 -0
- package/node_modules/@hpke/core/package.json +6 -2
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +4 -202
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +3 -21
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +4 -202
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.js +230 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js +10 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/transport.d.ts +8 -8
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/transport.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +10 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts +8 -8
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/package.json +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +752 -0
- package/node_modules/encodeurl/README.md +14 -0
- package/node_modules/encodeurl/index.js +5 -10
- package/node_modules/encodeurl/package.json +10 -6
- package/node_modules/express-rate-limit/dist/index.cjs +7 -3
- package/node_modules/express-rate-limit/dist/index.mjs +7 -3
- package/node_modules/express-rate-limit/package.json +10 -10
- package/node_modules/follow-redirects/README.md +27 -1
- package/node_modules/follow-redirects/index.js +1 -5
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/hono/README.md +2 -3
- package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +1 -1
- package/node_modules/hono/dist/cjs/helper/css/common.js +11 -8
- package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
- package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
- package/node_modules/hono/dist/cjs/hono-base.js +4 -10
- package/node_modules/hono/dist/cjs/hono.js +0 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +9 -1
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +3 -1
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +2 -2
- package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
- package/node_modules/hono/dist/cjs/utils/mount.js +35 -0
- package/node_modules/hono/dist/cjs/utils/url.js +21 -6
- package/node_modules/hono/dist/cjs/validator/validator.js +1 -1
- package/node_modules/hono/dist/context.js +1 -1
- package/node_modules/hono/dist/helper/css/common.js +11 -8
- package/node_modules/hono/dist/helper/css/index.js +1 -1
- package/node_modules/hono/dist/helper/route/index.js +3 -1
- package/node_modules/hono/dist/hono-base.js +4 -10
- package/node_modules/hono/dist/hono.js +0 -1
- package/node_modules/hono/dist/jsx/base.js +1 -1
- package/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
- package/node_modules/hono/dist/middleware/bearer-auth/index.js +9 -1
- package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/middleware/language/language.js +1 -1
- package/node_modules/hono/dist/middleware/mount/index.js +4 -4
- package/node_modules/hono/dist/middleware/serve-static/index.js +3 -1
- package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
- package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/router/trie-router/node.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +21 -9
- package/node_modules/hono/dist/types/index.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
- package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
- package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
- package/node_modules/hono/dist/utils/mount.js +34 -0
- package/node_modules/hono/dist/utils/url.js +21 -7
- package/node_modules/hono/dist/validator/validator.js +1 -1
- package/node_modules/hono/package.json +1 -1
- package/node_modules/http-proxy-middleware/dist/handlers/fix-request-body.js +2 -2
- package/node_modules/http-proxy-middleware/package.json +1 -1
- package/node_modules/ip-address/README.md +39 -39
- package/node_modules/ip-address/dist/common.js +2 -2
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.js +1 -1
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/package.json +2 -2
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
- package/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
- package/node_modules/jose/dist/types/types.d.ts +8 -0
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
- package/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
- package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
- package/node_modules/jose/package.json +1 -1
- package/node_modules/postcss/lib/input.js +1 -1
- package/node_modules/postcss/lib/lazy-result.js +1 -1
- package/node_modules/postcss/lib/no-work-result.js +1 -1
- package/node_modules/postcss/lib/node.js +2 -2
- package/node_modules/postcss/lib/processor.js +1 -1
- package/node_modules/postcss/lib/warning.js +1 -0
- package/node_modules/postcss/package.json +1 -1
- package/node_modules/qs/CHANGELOG.md +29 -22
- package/node_modules/qs/dist/qs.js +14 -14
- package/node_modules/qs/eslint.config.mjs +6 -0
- package/node_modules/qs/lib/stringify.js +1 -1
- package/node_modules/qs/package.json +5 -5
- package/node_modules/qs/test/stringify.js +74 -0
- package/node_modules/zod/README.md +34 -24
- package/node_modules/zod/compile.cjs +96 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +22 -3
- package/node_modules/zod/index.d.cts +3 -4
- package/node_modules/zod/index.d.ts +3 -4
- package/node_modules/zod/index.js +7 -4
- package/node_modules/zod/locales/index.cjs +36 -0
- package/node_modules/zod/locales/index.d.cts +1 -0
- package/node_modules/zod/locales/index.d.ts +1 -0
- package/node_modules/zod/locales/index.js +1 -0
- package/node_modules/zod/locales/package.json +7 -0
- package/node_modules/zod/mini/index.cjs +51 -0
- package/node_modules/zod/mini/index.d.cts +3 -0
- package/node_modules/zod/mini/index.d.ts +3 -0
- package/node_modules/zod/mini/index.js +3 -0
- package/node_modules/zod/mini/package.json +7 -0
- package/node_modules/zod/package.json +44 -15
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +7 -4
- package/node_modules/zod/src/locales/index.ts +1 -0
- package/node_modules/zod/src/mini/index.ts +3 -0
- package/node_modules/zod/src/v3/ZodError.ts +23 -13
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/complex.test.ts +17 -3
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +7 -3
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/nan.test.ts +5 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +10 -13
- package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +8 -2
- package/node_modules/zod/src/v3/types.ts +8 -6
- package/node_modules/zod/src/v4/classic/checks.ts +3 -0
- package/node_modules/zod/src/v4/classic/compat.ts +30 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +61 -39
- package/node_modules/zod/src/v4/classic/external.ts +18 -11
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +944 -0
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +57 -2
- package/node_modules/zod/src/v4/classic/schemas.ts +1258 -375
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +86 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +35 -8
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +192 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +43 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +357 -5
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +572 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +704 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +27 -5
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +67 -6
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +37 -17
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +142 -0
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +221 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +333 -10
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +394 -4
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +9 -4
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +4 -0
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +1467 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +160 -37
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +67 -0
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +134 -5
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +93 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +168 -5
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +4 -3
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +37 -1
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +153 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +15 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +161 -7
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +457 -14
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +255 -12
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +350 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +89 -5
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +25 -5
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +107 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +44 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +74 -21
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +1 -69
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +553 -10
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +352 -1
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +229 -68
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +40 -1
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +20 -3
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +96 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +16 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +568 -9
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +58 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +70 -16
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3409 -990
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +128 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +353 -5
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +219 -3
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +442 -161
- package/node_modules/zod/src/v4/core/checks.ts +134 -151
- package/node_modules/zod/src/v4/core/compile.ts +2322 -0
- package/node_modules/zod/src/v4/core/core.ts +146 -50
- package/node_modules/zod/src/v4/core/doc.ts +18 -10
- package/node_modules/zod/src/v4/core/errors.ts +221 -102
- package/node_modules/zod/src/v4/core/index.ts +5 -1
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +131 -0
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +934 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +9 -4
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +252 -37
- package/node_modules/zod/src/v4/core/regexes.ts +112 -30
- package/node_modules/zod/src/v4/core/registries.ts +19 -10
- package/node_modules/zod/src/v4/core/schemas.ts +1972 -588
- package/node_modules/zod/src/v4/core/standard-schema.ts +114 -19
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +214 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +1 -1
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +180 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +2 -2
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +706 -826
- package/node_modules/zod/src/v4/core/util.ts +675 -157
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +22 -27
- package/node_modules/zod/src/v4/locales/az.ts +22 -27
- package/node_modules/zod/src/v4/locales/be.ts +31 -27
- package/node_modules/zod/src/v4/locales/bg.ts +133 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +22 -28
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +26 -45
- package/node_modules/zod/src/v4/locales/da.ts +128 -0
- package/node_modules/zod/src/v4/locales/de.ts +24 -27
- package/node_modules/zod/src/v4/locales/el.ts +124 -0
- package/node_modules/zod/src/v4/locales/en.ts +38 -29
- package/node_modules/zod/src/v4/locales/eo.ts +25 -27
- package/node_modules/zod/src/v4/locales/es.ts +53 -33
- package/node_modules/zod/src/v4/locales/fa.ts +24 -27
- package/node_modules/zod/src/v4/locales/fi.ts +22 -27
- package/node_modules/zod/src/v4/locales/fr-CA.ts +22 -27
- package/node_modules/zod/src/v4/locales/fr.ts +58 -43
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +208 -80
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +135 -0
- package/node_modules/zod/src/v4/locales/hu.ts +24 -28
- package/node_modules/zod/src/v4/locales/hy.ts +175 -0
- package/node_modules/zod/src/v4/locales/id.ts +22 -27
- package/node_modules/zod/src/v4/locales/index.ts +24 -0
- package/node_modules/zod/src/v4/locales/is.ts +124 -0
- package/node_modules/zod/src/v4/locales/it.ts +24 -28
- package/node_modules/zod/src/v4/locales/ja.ts +24 -27
- package/node_modules/zod/src/v4/locales/ka.ts +128 -0
- package/node_modules/zod/src/v4/locales/kh.ts +3 -122
- package/node_modules/zod/src/v4/locales/km.ts +124 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +22 -27
- package/node_modules/zod/src/v4/locales/lt.ts +243 -0
- package/node_modules/zod/src/v4/locales/mk.ts +24 -28
- package/node_modules/zod/src/v4/locales/ms.ts +23 -27
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +37 -37
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +26 -29
- package/node_modules/zod/src/v4/locales/ota.ts +25 -28
- package/node_modules/zod/src/v4/locales/pl.ts +24 -27
- package/node_modules/zod/src/v4/locales/ps.ts +24 -26
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +107 -71
- package/node_modules/zod/src/v4/locales/ro.ts +132 -0
- package/node_modules/zod/src/v4/locales/ru.ts +31 -27
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +24 -27
- package/node_modules/zod/src/v4/locales/sv.ts +26 -29
- package/node_modules/zod/src/v4/locales/ta.ts +25 -27
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +25 -27
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +22 -27
- package/node_modules/zod/src/v4/locales/ua.ts +3 -122
- package/node_modules/zod/src/v4/locales/uk.ts +122 -0
- package/node_modules/zod/src/v4/locales/ur.ts +25 -27
- package/node_modules/zod/src/v4/locales/uz.ts +120 -0
- package/node_modules/zod/src/v4/locales/vi.ts +24 -27
- package/node_modules/zod/src/v4/locales/yo.ts +129 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +25 -27
- package/node_modules/zod/src/v4/locales/zh-TW.ts +22 -27
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +5 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +15 -3
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/iso.ts +8 -4
- package/node_modules/zod/src/v4/mini/parse.ts +16 -1
- package/node_modules/zod/src/v4/mini/schemas.ts +586 -114
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +57 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +63 -2
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +582 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +12 -18
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +24 -5
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +7 -36
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +281 -6
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +15 -1
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +116 -9
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +1 -1
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +68 -2
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +98 -1
- package/node_modules/zod/src/v4-mini/index.ts +3 -1
- package/node_modules/zod/v3/ZodError.cjs +42 -13
- package/node_modules/zod/v3/ZodError.d.cts +6 -6
- package/node_modules/zod/v3/ZodError.d.ts +6 -6
- package/node_modules/zod/v3/ZodError.js +23 -13
- package/node_modules/zod/v3/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/locales/en.cjs +1 -0
- package/node_modules/zod/v3/locales/en.d.cts +1 -1
- package/node_modules/zod/v3/package.json +7 -0
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +28 -5
- package/node_modules/zod/v3/types.d.cts +4 -1
- package/node_modules/zod/v3/types.d.ts +4 -1
- package/node_modules/zod/v3/types.js +9 -5
- package/node_modules/zod/v4/classic/checks.cjs +22 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +24 -1
- package/node_modules/zod/v4/classic/compat.d.cts +13 -11
- package/node_modules/zod/v4/classic/compat.d.ts +13 -11
- package/node_modules/zod/v4/classic/compat.js +4 -0
- package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +63 -28
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +45 -29
- package/node_modules/zod/v4/classic/external.cjs +55 -28
- package/node_modules/zod/v4/classic/external.d.cts +8 -2
- package/node_modules/zod/v4/classic/external.d.ts +8 -2
- package/node_modules/zod/v4/classic/external.js +7 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +926 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.js +881 -0
- package/node_modules/zod/v4/classic/in-out.cjs +82 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +21 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +30 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/package.json +7 -0
- package/node_modules/zod/v4/classic/parse.cjs +32 -1
- package/node_modules/zod/v4/classic/parse.d.cts +21 -0
- package/node_modules/zod/v4/classic/parse.d.ts +21 -0
- package/node_modules/zod/v4/classic/parse.js +10 -0
- package/node_modules/zod/v4/classic/schemas.cjs +805 -238
- package/node_modules/zod/v4/classic/schemas.d.cts +241 -55
- package/node_modules/zod/v4/classic/schemas.d.ts +241 -55
- package/node_modules/zod/v4/classic/schemas.js +766 -237
- package/node_modules/zod/v4/core/api.cjs +284 -54
- package/node_modules/zod/v4/core/api.d.cts +133 -82
- package/node_modules/zod/v4/core/api.d.ts +133 -82
- package/node_modules/zod/v4/core/api.js +255 -54
- package/node_modules/zod/v4/core/checks.cjs +100 -130
- package/node_modules/zod/v4/core/checks.d.cts +32 -16
- package/node_modules/zod/v4/core/checks.d.ts +32 -16
- package/node_modules/zod/v4/core/checks.js +80 -129
- package/node_modules/zod/v4/core/compile.cjs +1916 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1866 -0
- package/node_modules/zod/v4/core/core.cjs +120 -20
- package/node_modules/zod/v4/core/core.d.cts +40 -7
- package/node_modules/zod/v4/core/core.d.ts +40 -7
- package/node_modules/zod/v4/core/core.js +101 -21
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- package/node_modules/zod/v4/core/doc.d.cts +4 -2
- package/node_modules/zod/v4/core/doc.d.ts +4 -2
- package/node_modules/zod/v4/core/doc.js +12 -9
- package/node_modules/zod/v4/core/errors.cjs +151 -60
- package/node_modules/zod/v4/core/errors.d.cts +41 -24
- package/node_modules/zod/v4/core/errors.d.ts +41 -24
- package/node_modules/zod/v4/core/errors.js +132 -60
- package/node_modules/zod/v4/core/index.cjs +28 -2
- package/node_modules/zod/v4/core/index.d.cts +5 -1
- package/node_modules/zod/v4/core/index.d.ts +5 -1
- package/node_modules/zod/v4/core/index.js +5 -1
- package/node_modules/zod/v4/core/json-schema-generator.cjs +122 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.js +99 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +929 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +843 -0
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +6 -4
- package/node_modules/zod/v4/core/json-schema.d.ts +6 -4
- package/node_modules/zod/v4/core/memoizer.cjs +360 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +311 -0
- package/node_modules/zod/v4/core/package.json +7 -0
- package/node_modules/zod/v4/core/parse.cjs +183 -37
- package/node_modules/zod/v4/core/parse.d.cts +34 -7
- package/node_modules/zod/v4/core/parse.d.ts +34 -7
- package/node_modules/zod/v4/core/parse.js +154 -36
- package/node_modules/zod/v4/core/regexes.cjs +137 -31
- package/node_modules/zod/v4/core/regexes.d.cts +30 -2
- package/node_modules/zod/v4/core/regexes.d.ts +30 -2
- package/node_modules/zod/v4/core/regexes.js +90 -29
- package/node_modules/zod/v4/core/registries.cjs +26 -7
- package/node_modules/zod/v4/core/registries.d.cts +2 -2
- package/node_modules/zod/v4/core/registries.d.ts +2 -2
- package/node_modules/zod/v4/core/registries.js +9 -9
- package/node_modules/zod/v4/core/schemas.cjs +1373 -422
- package/node_modules/zod/v4/core/schemas.d.cts +276 -42
- package/node_modules/zod/v4/core/schemas.d.ts +276 -42
- package/node_modules/zod/v4/core/schemas.js +1341 -422
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +90 -19
- package/node_modules/zod/v4/core/standard-schema.d.ts +90 -19
- package/node_modules/zod/v4/core/to-json-schema.cjs +628 -801
- package/node_modules/zod/v4/core/to-json-schema.d.cts +103 -37
- package/node_modules/zod/v4/core/to-json-schema.d.ts +103 -37
- package/node_modules/zod/v4/core/to-json-schema.js +602 -800
- package/node_modules/zod/v4/core/util.cjs +580 -155
- package/node_modules/zod/v4/core/util.d.cts +98 -1
- package/node_modules/zod/v4/core/util.d.ts +98 -1
- package/node_modules/zod/v4/core/util.js +536 -156
- package/node_modules/zod/v4/core/versions.cjs +21 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +214 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +34 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +20 -24
- package/node_modules/zod/v4/locales/ar.d.cts +2 -1
- package/node_modules/zod/v4/locales/ar.js +19 -24
- package/node_modules/zod/v4/locales/az.cjs +20 -24
- package/node_modules/zod/v4/locales/az.d.cts +2 -1
- package/node_modules/zod/v4/locales/az.js +19 -24
- package/node_modules/zod/v4/locales/be.cjs +29 -24
- package/node_modules/zod/v4/locales/be.d.cts +2 -1
- package/node_modules/zod/v4/locales/be.js +28 -24
- package/node_modules/zod/v4/locales/bg.cjs +152 -0
- package/node_modules/zod/v4/locales/bg.d.cts +5 -0
- package/node_modules/zod/v4/locales/bg.d.ts +4 -0
- package/node_modules/zod/v4/locales/bg.js +125 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +20 -25
- package/node_modules/zod/v4/locales/ca.d.cts +2 -1
- package/node_modules/zod/v4/locales/ca.js +19 -25
- package/node_modules/zod/v4/locales/ckb.cjs +160 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +24 -42
- package/node_modules/zod/v4/locales/cs.d.cts +2 -1
- package/node_modules/zod/v4/locales/cs.js +23 -42
- package/node_modules/zod/v4/locales/da.cjs +147 -0
- package/node_modules/zod/v4/locales/da.d.cts +5 -0
- package/node_modules/zod/v4/locales/da.d.ts +4 -0
- package/node_modules/zod/v4/locales/da.js +120 -0
- package/node_modules/zod/v4/locales/de.cjs +22 -24
- package/node_modules/zod/v4/locales/de.d.cts +2 -1
- package/node_modules/zod/v4/locales/de.js +21 -24
- package/node_modules/zod/v4/locales/el.cjs +139 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +112 -0
- package/node_modules/zod/v4/locales/en.cjs +35 -28
- package/node_modules/zod/v4/locales/en.d.cts +2 -2
- package/node_modules/zod/v4/locales/en.d.ts +0 -1
- package/node_modules/zod/v4/locales/en.js +34 -26
- package/node_modules/zod/v4/locales/eo.cjs +23 -26
- package/node_modules/zod/v4/locales/eo.d.cts +2 -2
- package/node_modules/zod/v4/locales/eo.d.ts +0 -1
- package/node_modules/zod/v4/locales/eo.js +22 -24
- package/node_modules/zod/v4/locales/es.cjs +51 -31
- package/node_modules/zod/v4/locales/es.d.cts +2 -1
- package/node_modules/zod/v4/locales/es.js +50 -31
- package/node_modules/zod/v4/locales/fa.cjs +22 -24
- package/node_modules/zod/v4/locales/fa.d.cts +2 -1
- package/node_modules/zod/v4/locales/fa.js +21 -24
- package/node_modules/zod/v4/locales/fi.cjs +20 -24
- package/node_modules/zod/v4/locales/fi.d.cts +2 -1
- package/node_modules/zod/v4/locales/fi.js +19 -24
- package/node_modules/zod/v4/locales/fr-CA.cjs +20 -24
- package/node_modules/zod/v4/locales/fr-CA.d.cts +2 -1
- package/node_modules/zod/v4/locales/fr-CA.js +19 -24
- package/node_modules/zod/v4/locales/fr.cjs +53 -39
- package/node_modules/zod/v4/locales/fr.d.cts +2 -1
- package/node_modules/zod/v4/locales/fr.js +52 -39
- package/node_modules/zod/v4/locales/gu.cjs +140 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +113 -0
- package/node_modules/zod/v4/locales/he.cjs +183 -78
- package/node_modules/zod/v4/locales/he.d.cts +2 -1
- package/node_modules/zod/v4/locales/he.js +182 -78
- package/node_modules/zod/v4/locales/hi.cjs +138 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +153 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +126 -0
- package/node_modules/zod/v4/locales/hu.cjs +22 -25
- package/node_modules/zod/v4/locales/hu.d.cts +2 -1
- package/node_modules/zod/v4/locales/hu.js +21 -25
- package/node_modules/zod/v4/locales/hy.cjs +185 -0
- package/node_modules/zod/v4/locales/hy.d.cts +5 -0
- package/node_modules/zod/v4/locales/hy.d.ts +4 -0
- package/node_modules/zod/v4/locales/hy.js +158 -0
- package/node_modules/zod/v4/locales/id.cjs +20 -24
- package/node_modules/zod/v4/locales/id.d.cts +2 -1
- package/node_modules/zod/v4/locales/id.js +19 -24
- package/node_modules/zod/v4/locales/index.cjs +69 -1
- package/node_modules/zod/v4/locales/index.d.cts +24 -0
- package/node_modules/zod/v4/locales/index.d.ts +24 -0
- package/node_modules/zod/v4/locales/index.js +24 -0
- package/node_modules/zod/v4/locales/is.cjs +141 -0
- package/node_modules/zod/v4/locales/is.d.cts +5 -0
- package/node_modules/zod/v4/locales/is.d.ts +4 -0
- package/node_modules/zod/v4/locales/is.js +114 -0
- package/node_modules/zod/v4/locales/it.cjs +22 -25
- package/node_modules/zod/v4/locales/it.d.cts +2 -1
- package/node_modules/zod/v4/locales/it.js +21 -25
- package/node_modules/zod/v4/locales/ja.cjs +22 -24
- package/node_modules/zod/v4/locales/ja.d.cts +2 -1
- package/node_modules/zod/v4/locales/ja.js +21 -24
- package/node_modules/zod/v4/locales/ka.cjs +144 -0
- package/node_modules/zod/v4/locales/ka.d.cts +5 -0
- package/node_modules/zod/v4/locales/ka.d.ts +4 -0
- package/node_modules/zod/v4/locales/ka.js +117 -0
- package/node_modules/zod/v4/locales/kh.cjs +6 -137
- package/node_modules/zod/v4/locales/kh.d.cts +2 -1
- package/node_modules/zod/v4/locales/kh.d.ts +1 -0
- package/node_modules/zod/v4/locales/kh.js +3 -115
- package/node_modules/zod/v4/locales/km.cjs +142 -0
- package/node_modules/zod/v4/locales/km.d.cts +5 -0
- package/node_modules/zod/v4/locales/km.d.ts +4 -0
- package/node_modules/zod/v4/locales/km.js +115 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +20 -24
- package/node_modules/zod/v4/locales/ko.d.cts +2 -1
- package/node_modules/zod/v4/locales/ko.js +19 -24
- package/node_modules/zod/v4/locales/lt.cjs +234 -0
- package/node_modules/zod/v4/locales/lt.d.cts +5 -0
- package/node_modules/zod/v4/locales/lt.d.ts +4 -0
- package/node_modules/zod/v4/locales/lt.js +207 -0
- package/node_modules/zod/v4/locales/mk.cjs +22 -25
- package/node_modules/zod/v4/locales/mk.d.cts +2 -1
- package/node_modules/zod/v4/locales/mk.js +21 -25
- package/node_modules/zod/v4/locales/ms.cjs +21 -24
- package/node_modules/zod/v4/locales/ms.d.cts +2 -1
- package/node_modules/zod/v4/locales/ms.js +20 -24
- package/node_modules/zod/v4/locales/ne.cjs +138 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +31 -32
- package/node_modules/zod/v4/locales/nl.d.cts +2 -1
- package/node_modules/zod/v4/locales/nl.js +30 -32
- package/node_modules/zod/v4/locales/nn.cjs +140 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +113 -0
- package/node_modules/zod/v4/locales/no.cjs +24 -26
- package/node_modules/zod/v4/locales/no.d.cts +2 -1
- package/node_modules/zod/v4/locales/no.js +23 -26
- package/node_modules/zod/v4/locales/ota.cjs +23 -25
- package/node_modules/zod/v4/locales/ota.d.cts +2 -1
- package/node_modules/zod/v4/locales/ota.js +22 -25
- package/node_modules/zod/v4/locales/package.json +7 -0
- package/node_modules/zod/v4/locales/pl.cjs +22 -24
- package/node_modules/zod/v4/locales/pl.d.cts +2 -1
- package/node_modules/zod/v4/locales/pl.js +21 -24
- package/node_modules/zod/v4/locales/ps.cjs +22 -24
- package/node_modules/zod/v4/locales/ps.d.cts +2 -1
- package/node_modules/zod/v4/locales/ps.js +21 -24
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +95 -68
- package/node_modules/zod/v4/locales/pt.d.cts +2 -1
- package/node_modules/zod/v4/locales/pt.js +94 -68
- package/node_modules/zod/v4/locales/ro.cjs +149 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +122 -0
- package/node_modules/zod/v4/locales/ru.cjs +29 -24
- package/node_modules/zod/v4/locales/ru.d.cts +2 -1
- package/node_modules/zod/v4/locales/ru.js +28 -24
- package/node_modules/zod/v4/locales/sk.cjs +143 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +22 -24
- package/node_modules/zod/v4/locales/sl.d.cts +2 -1
- package/node_modules/zod/v4/locales/sl.js +21 -24
- package/node_modules/zod/v4/locales/sv.cjs +24 -26
- package/node_modules/zod/v4/locales/sv.d.cts +2 -1
- package/node_modules/zod/v4/locales/sv.js +23 -26
- package/node_modules/zod/v4/locales/ta.cjs +23 -24
- package/node_modules/zod/v4/locales/ta.d.cts +2 -1
- package/node_modules/zod/v4/locales/ta.js +22 -24
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +23 -24
- package/node_modules/zod/v4/locales/th.d.cts +2 -1
- package/node_modules/zod/v4/locales/th.js +22 -24
- package/node_modules/zod/v4/locales/tk.cjs +134 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +20 -26
- package/node_modules/zod/v4/locales/tr.d.cts +2 -2
- package/node_modules/zod/v4/locales/tr.d.ts +0 -1
- package/node_modules/zod/v4/locales/tr.js +19 -24
- package/node_modules/zod/v4/locales/ua.cjs +6 -137
- package/node_modules/zod/v4/locales/ua.d.cts +2 -1
- package/node_modules/zod/v4/locales/ua.d.ts +1 -0
- package/node_modules/zod/v4/locales/ua.js +3 -115
- package/node_modules/zod/v4/locales/uk.cjs +140 -0
- package/node_modules/zod/v4/locales/uk.d.cts +5 -0
- package/node_modules/zod/v4/locales/uk.d.ts +4 -0
- package/node_modules/zod/v4/locales/uk.js +113 -0
- package/node_modules/zod/v4/locales/ur.cjs +23 -24
- package/node_modules/zod/v4/locales/ur.d.cts +2 -1
- package/node_modules/zod/v4/locales/ur.js +22 -24
- package/node_modules/zod/v4/locales/uz.cjs +140 -0
- package/node_modules/zod/v4/locales/uz.d.cts +5 -0
- package/node_modules/zod/v4/locales/uz.d.ts +4 -0
- package/node_modules/zod/v4/locales/uz.js +113 -0
- package/node_modules/zod/v4/locales/vi.cjs +22 -24
- package/node_modules/zod/v4/locales/vi.d.cts +2 -1
- package/node_modules/zod/v4/locales/vi.js +21 -24
- package/node_modules/zod/v4/locales/yo.cjs +139 -0
- package/node_modules/zod/v4/locales/yo.d.cts +5 -0
- package/node_modules/zod/v4/locales/yo.d.ts +4 -0
- package/node_modules/zod/v4/locales/yo.js +112 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +23 -24
- package/node_modules/zod/v4/locales/zh-CN.d.cts +2 -1
- package/node_modules/zod/v4/locales/zh-CN.js +22 -24
- package/node_modules/zod/v4/locales/zh-TW.cjs +20 -24
- package/node_modules/zod/v4/locales/zh-TW.d.cts +2 -1
- package/node_modules/zod/v4/locales/zh-TW.js +19 -24
- package/node_modules/zod/v4/mini/checks.cjs +21 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/coerce.cjs +24 -0
- package/node_modules/zod/v4/mini/coerce.js +5 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +36 -3
- package/node_modules/zod/v4/mini/external.d.cts +7 -2
- package/node_modules/zod/v4/mini/external.d.ts +7 -2
- package/node_modules/zod/v4/mini/external.js +4 -1
- package/node_modules/zod/v4/mini/in-out.cjs +82 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +27 -4
- package/node_modules/zod/v4/mini/iso.js +8 -4
- package/node_modules/zod/v4/mini/package.json +7 -0
- package/node_modules/zod/v4/mini/parse.cjs +30 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +390 -82
- package/node_modules/zod/v4/mini/schemas.d.cts +156 -32
- package/node_modules/zod/v4/mini/schemas.d.ts +156 -32
- package/node_modules/zod/v4/mini/schemas.js +329 -59
- package/node_modules/zod/v4/package.json +7 -0
- package/node_modules/zod/v4-mini/index.cjs +35 -1
- package/node_modules/zod/v4-mini/index.d.cts +3 -1
- package/node_modules/zod/v4-mini/index.d.ts +3 -1
- package/node_modules/zod/v4-mini/index.js +3 -1
- package/node_modules/zod/v4-mini/package.json +7 -0
- package/package.json +4 -4
- package/dist/ui/assets/index-DNNXeRpZ.js +0 -123
- package/dist/ui/assets/index-Osk4E49r.css +0 -1
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- package/node_modules/zod/src/v4/core/function.ts +0 -176
- package/node_modules/zod/v4/core/function.cjs +0 -102
- package/node_modules/zod/v4/core/function.d.cts +0 -52
- package/node_modules/zod/v4/core/function.d.ts +0 -52
- package/node_modules/zod/v4/core/function.js +0 -75
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as checks from "./checks.js";
|
|
2
2
|
import * as core from "./core.js";
|
|
3
3
|
import { Doc } from "./doc.js";
|
|
4
|
-
import {
|
|
4
|
+
import { parse, parseAsync } from "./parse.js";
|
|
5
5
|
import * as regexes from "./regexes.js";
|
|
6
6
|
import * as util from "./util.js";
|
|
7
7
|
import { version } from "./versions.js";
|
|
@@ -11,20 +11,20 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
11
11
|
inst._zod.def = def; // set _def property
|
|
12
12
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
13
13
|
inst._zod.version = version;
|
|
14
|
-
const
|
|
14
|
+
const defChecks = inst._zod.def.checks;
|
|
15
15
|
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const checks = inst._zod.traits.has("$ZodCheck")
|
|
17
|
+
? [inst, ...(defChecks ?? [])]
|
|
18
|
+
: defChecks?.length
|
|
19
|
+
? [...defChecks]
|
|
20
|
+
: [];
|
|
20
21
|
for (const ch of checks) {
|
|
21
22
|
for (const fn of ch._zod.onattach) {
|
|
22
23
|
fn(inst);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
if (checks.length === 0) {
|
|
26
|
-
// deferred initializer
|
|
27
|
-
// inst._zod.parse is not yet defined
|
|
27
|
+
// deferred initializer inst._zod.parse is not yet defined
|
|
28
28
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
29
29
|
inst._zod.deferred?.push(() => {
|
|
30
30
|
inst._zod.run = inst._zod.parse;
|
|
@@ -32,10 +32,14 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const runChecks = (payload, checks, ctx) => {
|
|
35
|
+
if (payload.memo)
|
|
36
|
+
return payload;
|
|
35
37
|
let isAborted = util.aborted(payload);
|
|
36
38
|
let asyncResult;
|
|
37
39
|
for (const ch of checks) {
|
|
38
40
|
if (ch._zod.def.when) {
|
|
41
|
+
if (util.explicitlyAborted(payload))
|
|
42
|
+
continue;
|
|
39
43
|
const shouldRun = ch._zod.def.when(payload);
|
|
40
44
|
if (!shouldRun)
|
|
41
45
|
continue;
|
|
@@ -54,6 +58,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
54
58
|
const nextLen = payload.issues.length;
|
|
55
59
|
if (nextLen === currLen)
|
|
56
60
|
return;
|
|
61
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
57
62
|
if (!isAborted)
|
|
58
63
|
isAborted = util.aborted(payload, currLen);
|
|
59
64
|
});
|
|
@@ -62,6 +67,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
62
67
|
const nextLen = payload.issues.length;
|
|
63
68
|
if (nextLen === currLen)
|
|
64
69
|
continue;
|
|
70
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
65
71
|
if (!isAborted)
|
|
66
72
|
isAborted = util.aborted(payload, currLen);
|
|
67
73
|
}
|
|
@@ -73,7 +79,36 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
73
79
|
}
|
|
74
80
|
return payload;
|
|
75
81
|
};
|
|
82
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
83
|
+
// abort if the canary is aborted
|
|
84
|
+
if (util.aborted(canary)) {
|
|
85
|
+
canary.aborted = true;
|
|
86
|
+
return canary;
|
|
87
|
+
}
|
|
88
|
+
// run checks first, then
|
|
89
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
90
|
+
if (checkResult instanceof Promise) {
|
|
91
|
+
if (ctx.async === false)
|
|
92
|
+
throw new core.$ZodAsyncError();
|
|
93
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
94
|
+
}
|
|
95
|
+
return inst._zod.parse(checkResult, ctx);
|
|
96
|
+
};
|
|
76
97
|
inst._zod.run = (payload, ctx) => {
|
|
98
|
+
if (ctx.skipChecks) {
|
|
99
|
+
return inst._zod.parse(payload, ctx);
|
|
100
|
+
}
|
|
101
|
+
if (ctx.direction === "backward") {
|
|
102
|
+
// run canary initial pass (no checks)
|
|
103
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
104
|
+
if (canary instanceof Promise) {
|
|
105
|
+
return canary.then((canary) => {
|
|
106
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
110
|
+
}
|
|
111
|
+
// forward
|
|
77
112
|
const result = inst._zod.parse(payload, ctx);
|
|
78
113
|
if (result instanceof Promise) {
|
|
79
114
|
if (ctx.async === false)
|
|
@@ -83,24 +118,44 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
83
118
|
return runChecks(result, checks, ctx);
|
|
84
119
|
};
|
|
85
120
|
}
|
|
86
|
-
|
|
121
|
+
}, {
|
|
122
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
123
|
+
get "~standard"() {
|
|
124
|
+
return util.hide(this, "~standard", standardProps(this));
|
|
125
|
+
},
|
|
126
|
+
set "~standard"(value) {
|
|
127
|
+
util.own(this, "~standard", value);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
131
|
+
// a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
|
|
132
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
|
|
133
|
+
async function validateAsync(inst, value) {
|
|
134
|
+
const ctx = { async: true };
|
|
135
|
+
return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
|
|
136
|
+
}
|
|
137
|
+
export function standardProps(inst) {
|
|
138
|
+
return {
|
|
87
139
|
validate: (value) => {
|
|
140
|
+
const ctx = { async: false };
|
|
88
141
|
try {
|
|
89
|
-
const r =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
catch (_) {
|
|
93
|
-
return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
|
142
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
143
|
+
if (!(r instanceof Promise))
|
|
144
|
+
return toStandardResult(r, ctx);
|
|
94
145
|
}
|
|
146
|
+
catch (_) { }
|
|
147
|
+
// async function so a synchronously throwing check rejects instead of escaping validate
|
|
148
|
+
return validateAsync(inst, value);
|
|
95
149
|
},
|
|
96
150
|
vendor: "zod",
|
|
97
151
|
version: 1,
|
|
98
152
|
};
|
|
99
|
-
}
|
|
153
|
+
}
|
|
100
154
|
export { clone } from "./util.js";
|
|
101
155
|
export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
|
102
156
|
$ZodType.init(inst, def);
|
|
103
|
-
|
|
157
|
+
// a format's own pattern, else unbounded; a template literal derives the check-aware form itself
|
|
158
|
+
inst._zod.pattern = def.pattern ?? regexes.anyString;
|
|
104
159
|
inst._zod.parse = (payload, _) => {
|
|
105
160
|
if (def.coerce)
|
|
106
161
|
try {
|
|
@@ -152,48 +207,115 @@ export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def
|
|
|
152
207
|
def.pattern ?? (def.pattern = regexes.email);
|
|
153
208
|
$ZodStringFormat.init(inst, def);
|
|
154
209
|
});
|
|
210
|
+
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
211
|
+
export const URL_BAD_FORMAT = 1;
|
|
212
|
+
/** The URL parser rejected the input. */
|
|
213
|
+
export const URL_UNPARSEABLE = 2;
|
|
214
|
+
export function canParseURL(input) {
|
|
215
|
+
try {
|
|
216
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
217
|
+
return URL.canParse(input);
|
|
218
|
+
new URL(input);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export function validateURL(trimmed, def) {
|
|
226
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
227
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
228
|
+
}
|
|
229
|
+
return parseURLObject(trimmed, def);
|
|
230
|
+
}
|
|
231
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
232
|
+
export function parseURLObject(trimmed, def) {
|
|
233
|
+
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
234
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
235
|
+
return URL_BAD_FORMAT;
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
if (typeof URL !== "undefined") {
|
|
239
|
+
const URLStatic = URL;
|
|
240
|
+
if (typeof URLStatic.parse === "function")
|
|
241
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
242
|
+
}
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
return new URL(trimmed);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return URL_UNPARSEABLE;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
251
|
+
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
|
|
252
|
+
export function stripTabAndNewline(value) {
|
|
253
|
+
return value.replace(asciiTabOrNewline, "");
|
|
254
|
+
}
|
|
255
|
+
export function urlHostnameOk(url, hostname) {
|
|
256
|
+
hostname.lastIndex = 0;
|
|
257
|
+
return hostname.test(url.hostname);
|
|
258
|
+
}
|
|
259
|
+
export function urlProtocolOk(url, protocol) {
|
|
260
|
+
protocol.lastIndex = 0;
|
|
261
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
262
|
+
}
|
|
155
263
|
export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
|
|
156
264
|
$ZodStringFormat.init(inst, def);
|
|
157
265
|
inst._zod.check = (payload) => {
|
|
158
266
|
try {
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
continue: !def.abort,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
267
|
+
// Trim whitespace from input
|
|
268
|
+
const trimmed = payload.value.trim();
|
|
269
|
+
const url = validateURL(trimmed, def);
|
|
270
|
+
if (url === URL_BAD_FORMAT) {
|
|
271
|
+
payload.issues.push({
|
|
272
|
+
code: "invalid_format",
|
|
273
|
+
format: "url",
|
|
274
|
+
note: "Invalid URL format",
|
|
275
|
+
input: payload.value,
|
|
276
|
+
inst,
|
|
277
|
+
continue: !def.abort,
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
175
280
|
}
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
inst,
|
|
186
|
-
continue: !def.abort,
|
|
187
|
-
});
|
|
188
|
-
}
|
|
281
|
+
if (url === URL_UNPARSEABLE) {
|
|
282
|
+
payload.issues.push({
|
|
283
|
+
code: "invalid_format",
|
|
284
|
+
format: "url",
|
|
285
|
+
input: payload.value,
|
|
286
|
+
inst,
|
|
287
|
+
continue: !def.abort,
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
189
290
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
291
|
+
if (url === true) {
|
|
292
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
293
|
+
return;
|
|
193
294
|
}
|
|
194
|
-
|
|
195
|
-
payload.
|
|
295
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
296
|
+
payload.issues.push({
|
|
297
|
+
code: "invalid_format",
|
|
298
|
+
format: "url",
|
|
299
|
+
note: "Invalid hostname",
|
|
300
|
+
pattern: def.hostname.source,
|
|
301
|
+
input: payload.value,
|
|
302
|
+
inst,
|
|
303
|
+
continue: !def.abort,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
307
|
+
payload.issues.push({
|
|
308
|
+
code: "invalid_format",
|
|
309
|
+
format: "url",
|
|
310
|
+
note: "Invalid protocol",
|
|
311
|
+
pattern: def.protocol.source,
|
|
312
|
+
input: payload.value,
|
|
313
|
+
inst,
|
|
314
|
+
continue: !def.abort,
|
|
315
|
+
});
|
|
196
316
|
}
|
|
317
|
+
// Set the output value based on normalize flag
|
|
318
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
197
319
|
return;
|
|
198
320
|
}
|
|
199
321
|
catch (_) {
|
|
@@ -212,9 +334,16 @@ export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def
|
|
|
212
334
|
$ZodStringFormat.init(inst, def);
|
|
213
335
|
});
|
|
214
336
|
export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
|
|
215
|
-
def.
|
|
337
|
+
if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
|
|
338
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
339
|
+
def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
|
|
216
340
|
$ZodStringFormat.init(inst, def);
|
|
217
341
|
});
|
|
342
|
+
/**
|
|
343
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
344
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
345
|
+
* See https://github.com/paralleldrive/cuid.
|
|
346
|
+
*/
|
|
218
347
|
export const $ZodCUID = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def) => {
|
|
219
348
|
def.pattern ?? (def.pattern = regexes.cuid);
|
|
220
349
|
$ZodStringFormat.init(inst, def);
|
|
@@ -254,24 +383,19 @@ export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration"
|
|
|
254
383
|
export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def) => {
|
|
255
384
|
def.pattern ?? (def.pattern = regexes.ipv4);
|
|
256
385
|
$ZodStringFormat.init(inst, def);
|
|
257
|
-
inst._zod.onattach.push((inst) => {
|
|
258
|
-
const bag = inst._zod.bag;
|
|
259
|
-
bag.format = `ipv4`;
|
|
260
|
-
});
|
|
261
386
|
});
|
|
387
|
+
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
|
|
388
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
389
|
+
export function isValidIPv6(value) {
|
|
390
|
+
if (!ipv6Alphabet.test(value))
|
|
391
|
+
return false;
|
|
392
|
+
return canParseURL(`http://[${value}]`);
|
|
393
|
+
}
|
|
262
394
|
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
|
263
395
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
264
396
|
$ZodStringFormat.init(inst, def);
|
|
265
|
-
inst._zod.onattach.push((inst) => {
|
|
266
|
-
const bag = inst._zod.bag;
|
|
267
|
-
bag.format = `ipv6`;
|
|
268
|
-
});
|
|
269
397
|
inst._zod.check = (payload) => {
|
|
270
|
-
|
|
271
|
-
new URL(`http://[${payload.value}]`);
|
|
272
|
-
// return;
|
|
273
|
-
}
|
|
274
|
-
catch {
|
|
398
|
+
if (!isValidIPv6(payload.value)) {
|
|
275
399
|
payload.issues.push({
|
|
276
400
|
code: "invalid_format",
|
|
277
401
|
format: "ipv6",
|
|
@@ -282,26 +406,33 @@ export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def)
|
|
|
282
406
|
}
|
|
283
407
|
};
|
|
284
408
|
});
|
|
409
|
+
export const $ZodMAC = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def) => {
|
|
410
|
+
def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
|
|
411
|
+
$ZodStringFormat.init(inst, def);
|
|
412
|
+
});
|
|
285
413
|
export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, def) => {
|
|
286
414
|
def.pattern ?? (def.pattern = regexes.cidrv4);
|
|
287
415
|
$ZodStringFormat.init(inst, def);
|
|
288
416
|
});
|
|
417
|
+
export function isValidCIDRv6(value) {
|
|
418
|
+
const parts = value.split("/");
|
|
419
|
+
if (parts.length !== 2)
|
|
420
|
+
return false;
|
|
421
|
+
const [address, prefix] = parts;
|
|
422
|
+
if (!prefix)
|
|
423
|
+
return false;
|
|
424
|
+
const prefixNum = Number(prefix);
|
|
425
|
+
if (`${prefixNum}` !== prefix)
|
|
426
|
+
return false;
|
|
427
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
428
|
+
return false;
|
|
429
|
+
return isValidIPv6(address);
|
|
430
|
+
}
|
|
289
431
|
export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
290
432
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
291
433
|
$ZodStringFormat.init(inst, def);
|
|
292
434
|
inst._zod.check = (payload) => {
|
|
293
|
-
|
|
294
|
-
try {
|
|
295
|
-
if (!prefix)
|
|
296
|
-
throw new Error();
|
|
297
|
-
const prefixNum = Number(prefix);
|
|
298
|
-
if (`${prefixNum}` !== prefix)
|
|
299
|
-
throw new Error();
|
|
300
|
-
if (prefixNum < 0 || prefixNum > 128)
|
|
301
|
-
throw new Error();
|
|
302
|
-
new URL(`http://[${address}]`);
|
|
303
|
-
}
|
|
304
|
-
catch {
|
|
435
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
305
436
|
payload.issues.push({
|
|
306
437
|
code: "invalid_format",
|
|
307
438
|
format: "cidrv6",
|
|
@@ -316,9 +447,13 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
|
|
|
316
447
|
export function isValidBase64(data) {
|
|
317
448
|
if (data === "")
|
|
318
449
|
return true;
|
|
450
|
+
// atob ignores whitespace, so reject it up front.
|
|
451
|
+
if (/\s/.test(data))
|
|
452
|
+
return false;
|
|
319
453
|
if (data.length % 4 !== 0)
|
|
320
454
|
return false;
|
|
321
455
|
try {
|
|
456
|
+
// @ts-ignore
|
|
322
457
|
atob(data);
|
|
323
458
|
return true;
|
|
324
459
|
}
|
|
@@ -326,12 +461,11 @@ export function isValidBase64(data) {
|
|
|
326
461
|
return false;
|
|
327
462
|
}
|
|
328
463
|
}
|
|
464
|
+
// lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
|
|
465
|
+
export const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
329
466
|
export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, def) => {
|
|
330
|
-
def.pattern ?? (def.pattern =
|
|
467
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
331
468
|
$ZodStringFormat.init(inst, def);
|
|
332
|
-
inst._zod.onattach.push((inst) => {
|
|
333
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
334
|
-
});
|
|
335
469
|
inst._zod.check = (payload) => {
|
|
336
470
|
if (isValidBase64(payload.value))
|
|
337
471
|
return;
|
|
@@ -344,20 +478,19 @@ export const $ZodBase64 = /*@__PURE__*/ core.$constructor("$ZodBase64", (inst, d
|
|
|
344
478
|
});
|
|
345
479
|
};
|
|
346
480
|
});
|
|
347
|
-
//////////////////////////////
|
|
481
|
+
////////////////////////////// ZodBase64URL //////////////////////////////
|
|
482
|
+
// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
|
|
483
|
+
export const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
348
484
|
export function isValidBase64URL(data) {
|
|
349
|
-
if (!
|
|
485
|
+
if (!base64urlCharset.test(data))
|
|
350
486
|
return false;
|
|
351
487
|
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
352
488
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
353
489
|
return isValidBase64(padded);
|
|
354
490
|
}
|
|
355
491
|
export const $ZodBase64URL = /*@__PURE__*/ core.$constructor("$ZodBase64URL", (inst, def) => {
|
|
356
|
-
def.pattern ?? (def.pattern =
|
|
492
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
357
493
|
$ZodStringFormat.init(inst, def);
|
|
358
|
-
inst._zod.onattach.push((inst) => {
|
|
359
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
360
|
-
});
|
|
361
494
|
inst._zod.check = (payload) => {
|
|
362
495
|
if (isValidBase64URL(payload.value))
|
|
363
496
|
return;
|
|
@@ -374,6 +507,77 @@ export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def)
|
|
|
374
507
|
def.pattern ?? (def.pattern = regexes.e164);
|
|
375
508
|
$ZodStringFormat.init(inst, def);
|
|
376
509
|
});
|
|
510
|
+
////////////////////////////// ZodCreditCard //////////////////////////////
|
|
511
|
+
const CC_SANITIZE = /[- ]/g;
|
|
512
|
+
/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
|
|
513
|
+
function isLuhnAlgo(digits) {
|
|
514
|
+
let length = digits.length;
|
|
515
|
+
let bit = 1;
|
|
516
|
+
let sum = 0;
|
|
517
|
+
while (length) {
|
|
518
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
519
|
+
bit ^= 1;
|
|
520
|
+
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
|
|
521
|
+
}
|
|
522
|
+
return sum % 10 === 0;
|
|
523
|
+
}
|
|
524
|
+
export function isValidCreditCard(input) {
|
|
525
|
+
if (!regexes.creditCard.test(input))
|
|
526
|
+
return false;
|
|
527
|
+
return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
|
|
528
|
+
}
|
|
529
|
+
export const $ZodCreditCard = /*@__PURE__*/ core.$constructor("$ZodCreditCard", (inst, def) => {
|
|
530
|
+
// Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
|
|
531
|
+
def.pattern ?? (def.pattern = regexes.creditCard);
|
|
532
|
+
$ZodStringFormat.init(inst, def);
|
|
533
|
+
inst._zod.check = (payload) => {
|
|
534
|
+
if (isValidCreditCard(payload.value))
|
|
535
|
+
return;
|
|
536
|
+
payload.issues.push({
|
|
537
|
+
code: "invalid_format",
|
|
538
|
+
format: "credit_card",
|
|
539
|
+
input: payload.value,
|
|
540
|
+
inst,
|
|
541
|
+
continue: !def.abort,
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
});
|
|
545
|
+
////////////////////////////// ZodIBAN //////////////////////////////
|
|
546
|
+
// iso 7064 mod 97-10 checksum without BigInt
|
|
547
|
+
function isIso7064Mod97(iban) {
|
|
548
|
+
let remainder = 0;
|
|
549
|
+
const len = iban.length;
|
|
550
|
+
for (let i = 4; i < len; i++) {
|
|
551
|
+
const code = iban.charCodeAt(i);
|
|
552
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
553
|
+
}
|
|
554
|
+
for (let i = 0; i < 4; i++) {
|
|
555
|
+
const code = iban.charCodeAt(i);
|
|
556
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
557
|
+
}
|
|
558
|
+
return remainder === 1;
|
|
559
|
+
}
|
|
560
|
+
export function isValidIBAN(input) {
|
|
561
|
+
if (!regexes.iban.test(input))
|
|
562
|
+
return false;
|
|
563
|
+
return isIso7064Mod97(input);
|
|
564
|
+
}
|
|
565
|
+
export const $ZodIBAN = /*@__PURE__*/ core.$constructor("$ZodIBAN", (inst, def) => {
|
|
566
|
+
// shape only — checksum is not expressible as a pattern
|
|
567
|
+
def.pattern ?? (def.pattern = regexes.iban);
|
|
568
|
+
$ZodStringFormat.init(inst, def);
|
|
569
|
+
inst._zod.check = (payload) => {
|
|
570
|
+
if (isValidIBAN(payload.value))
|
|
571
|
+
return;
|
|
572
|
+
payload.issues.push({
|
|
573
|
+
code: "invalid_format",
|
|
574
|
+
format: "iban",
|
|
575
|
+
input: payload.value,
|
|
576
|
+
inst,
|
|
577
|
+
continue: !def.abort,
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
});
|
|
377
581
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
378
582
|
export function isValidJWT(token, algorithm = null) {
|
|
379
583
|
try {
|
|
@@ -383,6 +587,7 @@ export function isValidJWT(token, algorithm = null) {
|
|
|
383
587
|
const [header] = tokensParts;
|
|
384
588
|
if (!header)
|
|
385
589
|
return false;
|
|
590
|
+
// @ts-ignore
|
|
386
591
|
const parsedHeader = JSON.parse(atob(header));
|
|
387
592
|
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
388
593
|
return false;
|
|
@@ -426,7 +631,7 @@ export const $ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("$ZodCusto
|
|
|
426
631
|
});
|
|
427
632
|
export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
|
428
633
|
$ZodType.init(inst, def);
|
|
429
|
-
inst._zod.pattern =
|
|
634
|
+
inst._zod.pattern = regexes.number;
|
|
430
635
|
inst._zod.parse = (payload, _ctx) => {
|
|
431
636
|
if (def.coerce)
|
|
432
637
|
try {
|
|
@@ -441,7 +646,7 @@ export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, d
|
|
|
441
646
|
? Number.isNaN(input)
|
|
442
647
|
? "NaN"
|
|
443
648
|
: !Number.isFinite(input)
|
|
444
|
-
?
|
|
649
|
+
? String(input)
|
|
445
650
|
: undefined
|
|
446
651
|
: undefined;
|
|
447
652
|
payload.issues.push({
|
|
@@ -454,9 +659,9 @@ export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, d
|
|
|
454
659
|
return payload;
|
|
455
660
|
};
|
|
456
661
|
});
|
|
457
|
-
export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$
|
|
662
|
+
export const $ZodNumberFormat = /*@__PURE__*/ core.$constructor("$ZodNumberFormat", (inst, def) => {
|
|
458
663
|
checks.$ZodCheckNumberFormat.init(inst, def);
|
|
459
|
-
$ZodNumber.init(inst, def); // no format
|
|
664
|
+
$ZodNumber.init(inst, def); // no format checks
|
|
460
665
|
});
|
|
461
666
|
export const $ZodBoolean = /*@__PURE__*/ core.$constructor("$ZodBoolean", (inst, def) => {
|
|
462
667
|
$ZodType.init(inst, def);
|
|
@@ -499,7 +704,7 @@ export const $ZodBigInt = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, d
|
|
|
499
704
|
return payload;
|
|
500
705
|
};
|
|
501
706
|
});
|
|
502
|
-
export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$
|
|
707
|
+
export const $ZodBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodBigIntFormat", (inst, def) => {
|
|
503
708
|
checks.$ZodCheckBigIntFormat.init(inst, def);
|
|
504
709
|
$ZodBigInt.init(inst, def); // no format checks
|
|
505
710
|
});
|
|
@@ -522,8 +727,6 @@ export const $ZodUndefined = /*@__PURE__*/ core.$constructor("$ZodUndefined", (i
|
|
|
522
727
|
$ZodType.init(inst, def);
|
|
523
728
|
inst._zod.pattern = regexes.undefined;
|
|
524
729
|
inst._zod.values = new Set([undefined]);
|
|
525
|
-
inst._zod.optin = "optional";
|
|
526
|
-
inst._zod.optout = "optional";
|
|
527
730
|
inst._zod.parse = (payload, _ctx) => {
|
|
528
731
|
const input = payload.value;
|
|
529
732
|
if (typeof input === "undefined")
|
|
@@ -613,6 +816,33 @@ export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def)
|
|
|
613
816
|
return payload;
|
|
614
817
|
};
|
|
615
818
|
});
|
|
819
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
820
|
+
function capSize(inst, size) {
|
|
821
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
822
|
+
if (!caps.length)
|
|
823
|
+
return;
|
|
824
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
825
|
+
const parse = inst._zod.parse;
|
|
826
|
+
inst._zod.parse = (payload, ctx) => {
|
|
827
|
+
const n = size(payload.value);
|
|
828
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
829
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
830
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
831
|
+
const start = payload.issues.length;
|
|
832
|
+
ch._zod.check(payload);
|
|
833
|
+
// the value is still the raw input, so no later check may read it
|
|
834
|
+
payload.issues[start].continue = false;
|
|
835
|
+
util.attachSchema(payload.issues, start, inst);
|
|
836
|
+
return payload;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return parse(payload, ctx);
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
844
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
845
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
616
846
|
function handleArrayResult(result, final, index) {
|
|
617
847
|
if (result.issues.length) {
|
|
618
848
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -621,6 +851,8 @@ function handleArrayResult(result, final, index) {
|
|
|
621
851
|
}
|
|
622
852
|
export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
|
|
623
853
|
$ZodType.init(inst, def);
|
|
854
|
+
const memo = core.globalConfig.memoizer;
|
|
855
|
+
memo?.attach(inst);
|
|
624
856
|
inst._zod.parse = (payload, ctx) => {
|
|
625
857
|
const input = payload.value;
|
|
626
858
|
if (!Array.isArray(input)) {
|
|
@@ -632,8 +864,9 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
632
864
|
});
|
|
633
865
|
return payload;
|
|
634
866
|
}
|
|
635
|
-
payload.value = Array(input.length);
|
|
867
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
636
868
|
const proms = [];
|
|
869
|
+
const abortEarly = ctx?.abortEarly;
|
|
637
870
|
for (let i = 0; i < input.length; i++) {
|
|
638
871
|
const item = input[i];
|
|
639
872
|
const result = def.element._zod.run({
|
|
@@ -645,6 +878,9 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
645
878
|
}
|
|
646
879
|
else {
|
|
647
880
|
handleArrayResult(result, payload, i);
|
|
881
|
+
// the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
|
|
882
|
+
if (abortEarly && result.issues.length !== 0 && util.aborted(result))
|
|
883
|
+
break;
|
|
648
884
|
}
|
|
649
885
|
}
|
|
650
886
|
if (proms.length) {
|
|
@@ -652,129 +888,306 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
652
888
|
}
|
|
653
889
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
654
890
|
};
|
|
891
|
+
capSize(inst, arraySize);
|
|
655
892
|
});
|
|
656
|
-
function
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
893
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
894
|
+
const isPresent = key in input;
|
|
895
|
+
const isOptionalOut = optout === "optional";
|
|
896
|
+
// The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
|
|
897
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
898
|
+
return;
|
|
660
899
|
}
|
|
661
|
-
final.value[key] = result.value;
|
|
662
|
-
}
|
|
663
|
-
function handleOptionalObjectResult(result, final, key, input) {
|
|
664
900
|
if (result.issues.length) {
|
|
665
|
-
//
|
|
666
|
-
if (
|
|
667
|
-
|
|
668
|
-
if (key in input) {
|
|
669
|
-
final.value[key] = undefined;
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
final.value[key] = result.value;
|
|
673
|
-
}
|
|
901
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
902
|
+
if (optin !== undefined && isOptionalOut && !isPresent) {
|
|
903
|
+
return;
|
|
674
904
|
}
|
|
675
|
-
|
|
676
|
-
|
|
905
|
+
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
906
|
+
}
|
|
907
|
+
if (!isPresent && optin === undefined) {
|
|
908
|
+
if (!result.issues.length) {
|
|
909
|
+
final.issues.push({
|
|
910
|
+
code: "invalid_type",
|
|
911
|
+
expected: "nonoptional",
|
|
912
|
+
input: undefined,
|
|
913
|
+
path: [key],
|
|
914
|
+
});
|
|
677
915
|
}
|
|
916
|
+
return;
|
|
678
917
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
if (key in input)
|
|
918
|
+
if (result.value === undefined) {
|
|
919
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
682
920
|
final.value[key] = undefined;
|
|
921
|
+
}
|
|
683
922
|
}
|
|
684
923
|
else {
|
|
685
|
-
// non-undefined value
|
|
686
924
|
final.value[key] = result.value;
|
|
687
925
|
}
|
|
688
926
|
}
|
|
927
|
+
// one shared instance; a fresh [] per schema cost 56 bytes retained
|
|
928
|
+
const NO_SYMBOL_KEYS = [];
|
|
929
|
+
function normalizeDef(def) {
|
|
930
|
+
const keys = Object.keys(def.shape);
|
|
931
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
932
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
933
|
+
// aliases `keys` when there are no symbols, so a string-only shape keeps one array
|
|
934
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
935
|
+
for (const k of allKeys) {
|
|
936
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
937
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
const okeys = util.optionalKeys(def.shape);
|
|
941
|
+
return {
|
|
942
|
+
...def,
|
|
943
|
+
allKeys,
|
|
944
|
+
symbolKeys,
|
|
945
|
+
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
946
|
+
keySet: new Set(keys),
|
|
947
|
+
numKeys: keys.length,
|
|
948
|
+
optionalKeys: new Set(okeys),
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
952
|
+
const unrecognized = [];
|
|
953
|
+
const keySet = def.keySet;
|
|
954
|
+
const _catchall = def.catchall._zod;
|
|
955
|
+
const t = _catchall.def.type;
|
|
956
|
+
const optin = _catchall.optin;
|
|
957
|
+
const optout = _catchall.optout;
|
|
958
|
+
// starts at 0, not the current length: the shape phase already ran and may have aborted
|
|
959
|
+
let seen = 0;
|
|
960
|
+
for (const key in input) {
|
|
961
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
962
|
+
if (util.aborted(payload, seen))
|
|
963
|
+
break;
|
|
964
|
+
seen = payload.issues.length;
|
|
965
|
+
}
|
|
966
|
+
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
967
|
+
if (keySet.has(key))
|
|
968
|
+
continue;
|
|
969
|
+
// Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
|
|
970
|
+
if (key === "__proto__") {
|
|
971
|
+
if (t === "never")
|
|
972
|
+
unrecognized.push(key);
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
if (t === "never") {
|
|
976
|
+
unrecognized.push(key);
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
980
|
+
if (r instanceof Promise) {
|
|
981
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (unrecognized.length) {
|
|
988
|
+
payload.issues.push({
|
|
989
|
+
code: "unrecognized_keys",
|
|
990
|
+
keys: unrecognized,
|
|
991
|
+
input,
|
|
992
|
+
inst,
|
|
993
|
+
// Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
|
|
994
|
+
continue: true,
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
if (!proms.length)
|
|
998
|
+
return payload;
|
|
999
|
+
return Promise.all(proms).then(() => {
|
|
1000
|
+
return payload;
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
689
1003
|
export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
|
690
1004
|
// requires cast because technically $ZodObject doesn't extend
|
|
691
1005
|
$ZodType.init(inst, def);
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
keys,
|
|
703
|
-
keySet: new Set(keys),
|
|
704
|
-
numKeys: keys.length,
|
|
705
|
-
optionalKeys: new Set(okeys),
|
|
1006
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1007
|
+
// a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
|
|
1008
|
+
const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
|
|
1009
|
+
if (sh) {
|
|
1010
|
+
// Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
|
|
1011
|
+
const get = () => {
|
|
1012
|
+
const newSh = { ...sh };
|
|
1013
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
1014
|
+
get.raw = newSh;
|
|
1015
|
+
return newSh;
|
|
706
1016
|
};
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
1017
|
+
get.raw = sh;
|
|
1018
|
+
Object.defineProperty(def, "shape", { get });
|
|
1019
|
+
}
|
|
1020
|
+
const _normalized = util.cached(() => normalizeDef(def));
|
|
1021
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
1022
|
+
const shape = zod.def.shape;
|
|
710
1023
|
const propValues = {};
|
|
711
1024
|
for (const key in shape) {
|
|
712
1025
|
const field = shape[key]._zod;
|
|
713
1026
|
if (field.values) {
|
|
714
|
-
|
|
1027
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
1028
|
+
util.assignProp(propValues, key, new Set());
|
|
1029
|
+
}
|
|
715
1030
|
for (const v of field.values)
|
|
716
1031
|
propValues[key].add(v);
|
|
1032
|
+
// An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
|
|
1033
|
+
if (field.optin !== undefined)
|
|
1034
|
+
propValues[key].add(undefined);
|
|
717
1035
|
}
|
|
718
1036
|
}
|
|
719
1037
|
return propValues;
|
|
720
1038
|
});
|
|
1039
|
+
const isObject = util.isObject;
|
|
1040
|
+
const catchall = def.catchall;
|
|
1041
|
+
let value;
|
|
1042
|
+
const memo = core.globalConfig.memoizer;
|
|
1043
|
+
memo?.attach(inst);
|
|
1044
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1045
|
+
value ?? (value = _normalized.value);
|
|
1046
|
+
const input = payload.value;
|
|
1047
|
+
if (!isObject(input)) {
|
|
1048
|
+
payload.issues.push({
|
|
1049
|
+
expected: "object",
|
|
1050
|
+
code: "invalid_type",
|
|
1051
|
+
input,
|
|
1052
|
+
inst,
|
|
1053
|
+
});
|
|
1054
|
+
return payload;
|
|
1055
|
+
}
|
|
1056
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1057
|
+
const proms = [];
|
|
1058
|
+
const shape = value.shape;
|
|
1059
|
+
const abortEarly = ctx?.abortEarly;
|
|
1060
|
+
let seen = payload.issues.length;
|
|
1061
|
+
for (const key of value.allKeys) {
|
|
1062
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1063
|
+
if (util.aborted(payload, seen))
|
|
1064
|
+
break;
|
|
1065
|
+
seen = payload.issues.length;
|
|
1066
|
+
}
|
|
1067
|
+
if (key === "__proto__")
|
|
1068
|
+
continue;
|
|
1069
|
+
const el = shape[key];
|
|
1070
|
+
const optin = el._zod.optin;
|
|
1071
|
+
const optout = el._zod.optout;
|
|
1072
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1073
|
+
if (r instanceof Promise) {
|
|
1074
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
if (!catchall) {
|
|
1081
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1082
|
+
}
|
|
1083
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1084
|
+
};
|
|
1085
|
+
});
|
|
1086
|
+
export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
1087
|
+
// requires cast because technically $ZodObject doesn't extend
|
|
1088
|
+
$ZodObject.init(inst, def);
|
|
1089
|
+
const superParse = inst._zod.parse;
|
|
1090
|
+
const _normalized = util.cached(() => normalizeDef(def));
|
|
1091
|
+
const memo = core.globalConfig.memoizer;
|
|
721
1092
|
const generateFastpass = (shape) => {
|
|
722
|
-
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
723
1093
|
const normalized = _normalized.value;
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
1094
|
+
const syms = normalized.symbolKeys;
|
|
1095
|
+
// a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
|
|
1096
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
1097
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1098
|
+
// prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
|
|
1099
|
+
const prefixStr = (id, k) => `
|
|
1100
|
+
let ${id}_ab = false;
|
|
1101
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
1102
|
+
const iss = ${id}.issues[i];
|
|
1103
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
1104
|
+
payload.issues.push(iss);
|
|
1105
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
1106
|
+
}
|
|
1107
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
1108
|
+
payload.value = newResult;
|
|
1109
|
+
return payload;
|
|
1110
|
+
}`;
|
|
728
1111
|
doc.write(`const input = payload.value;`);
|
|
729
1112
|
const ids = Object.create(null);
|
|
730
1113
|
let counter = 0;
|
|
731
|
-
for (const key of normalized.
|
|
1114
|
+
for (const key of normalized.allKeys) {
|
|
732
1115
|
ids[key] = `key_${counter++}`;
|
|
733
1116
|
}
|
|
734
1117
|
// A: preserve key order {
|
|
735
|
-
doc.write(`const newResult = {}`);
|
|
736
|
-
for (const key of normalized.
|
|
737
|
-
if (
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
1118
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
1119
|
+
for (const key of normalized.allKeys) {
|
|
1120
|
+
if (key === "__proto__")
|
|
1121
|
+
continue;
|
|
1122
|
+
const id = ids[key];
|
|
1123
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
|
|
1124
|
+
const isPresent = `${k} in input`;
|
|
1125
|
+
const schema = shape[key];
|
|
1126
|
+
const optin = schema?._zod?.optin;
|
|
1127
|
+
const isOptionalIn = optin !== undefined;
|
|
1128
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1129
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
1130
|
+
if (isOptionalIn && isOptionalOut) {
|
|
1131
|
+
// For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
|
|
1132
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
741
1133
|
doc.write(`
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1134
|
+
const ${id}_present = ${isPresent};
|
|
1135
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
1136
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
if (${assign}) {
|
|
1140
|
+
newResult[${k}] = ${id}.value;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
`);
|
|
746
1145
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1146
|
+
else if (!isOptionalIn) {
|
|
1147
|
+
doc.write(`
|
|
1148
|
+
const ${id}_present = ${isPresent};
|
|
1149
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1150
|
+
}
|
|
1151
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
1152
|
+
payload.issues.push({
|
|
1153
|
+
code: "invalid_type",
|
|
1154
|
+
expected: "nonoptional",
|
|
1155
|
+
input: undefined,
|
|
1156
|
+
path: [${k}]
|
|
1157
|
+
});
|
|
1158
|
+
if (ctx && ctx.abortEarly) {
|
|
1159
|
+
payload.value = newResult;
|
|
1160
|
+
return payload;
|
|
754
1161
|
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (${id}_present) {
|
|
758
1165
|
newResult[${k}] = ${id}.value;
|
|
759
1166
|
}
|
|
760
|
-
|
|
1167
|
+
|
|
1168
|
+
`);
|
|
761
1169
|
}
|
|
762
1170
|
else {
|
|
763
|
-
const id = ids[key];
|
|
764
|
-
// const id = ids[key];
|
|
765
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
766
1171
|
doc.write(`
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1172
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1173
|
+
}
|
|
1174
|
+
`);
|
|
1175
|
+
if (optin === "defaulted") {
|
|
1176
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
doc.write(`
|
|
1180
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1181
|
+
newResult[${k}] = ${id}.value;
|
|
1182
|
+
}
|
|
1183
|
+
`);
|
|
1184
|
+
}
|
|
772
1185
|
}
|
|
773
1186
|
}
|
|
774
1187
|
doc.write(`payload.value = newResult;`);
|
|
775
1188
|
doc.write(`return payload;`);
|
|
776
|
-
|
|
777
|
-
return (
|
|
1189
|
+
// closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
|
|
1190
|
+
return doc.compile();
|
|
778
1191
|
};
|
|
779
1192
|
let fastpass;
|
|
780
1193
|
const isObject = util.isObject;
|
|
@@ -795,80 +1208,16 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
795
1208
|
});
|
|
796
1209
|
return payload;
|
|
797
1210
|
}
|
|
798
|
-
const proms = [];
|
|
799
1211
|
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
800
1212
|
// always synchronous
|
|
801
1213
|
if (!fastpass)
|
|
802
1214
|
fastpass = generateFastpass(def.shape);
|
|
803
1215
|
payload = fastpass(payload, ctx);
|
|
1216
|
+
if (!catchall)
|
|
1217
|
+
return payload;
|
|
1218
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
804
1219
|
}
|
|
805
|
-
|
|
806
|
-
payload.value = {};
|
|
807
|
-
const shape = value.shape;
|
|
808
|
-
for (const key of value.keys) {
|
|
809
|
-
const el = shape[key];
|
|
810
|
-
// do not add omitted optional keys
|
|
811
|
-
// if (!(key in input)) {
|
|
812
|
-
// if (optionalKeys.has(key)) continue;
|
|
813
|
-
// payload.issues.push({
|
|
814
|
-
// code: "invalid_type",
|
|
815
|
-
// path: [key],
|
|
816
|
-
// expected: "nonoptional",
|
|
817
|
-
// note: `Missing required key: "${key}"`,
|
|
818
|
-
// input,
|
|
819
|
-
// inst,
|
|
820
|
-
// });
|
|
821
|
-
// }
|
|
822
|
-
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
823
|
-
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
824
|
-
if (r instanceof Promise) {
|
|
825
|
-
proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
|
|
826
|
-
}
|
|
827
|
-
else if (isOptional) {
|
|
828
|
-
handleOptionalObjectResult(r, payload, key, input);
|
|
829
|
-
}
|
|
830
|
-
else {
|
|
831
|
-
handleObjectResult(r, payload, key);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
if (!catchall) {
|
|
836
|
-
// return payload;
|
|
837
|
-
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
838
|
-
}
|
|
839
|
-
const unrecognized = [];
|
|
840
|
-
// iterate over input keys
|
|
841
|
-
const keySet = value.keySet;
|
|
842
|
-
const _catchall = catchall._zod;
|
|
843
|
-
const t = _catchall.def.type;
|
|
844
|
-
for (const key of Object.keys(input)) {
|
|
845
|
-
if (keySet.has(key))
|
|
846
|
-
continue;
|
|
847
|
-
if (t === "never") {
|
|
848
|
-
unrecognized.push(key);
|
|
849
|
-
continue;
|
|
850
|
-
}
|
|
851
|
-
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
852
|
-
if (r instanceof Promise) {
|
|
853
|
-
proms.push(r.then((r) => handleObjectResult(r, payload, key)));
|
|
854
|
-
}
|
|
855
|
-
else {
|
|
856
|
-
handleObjectResult(r, payload, key);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
if (unrecognized.length) {
|
|
860
|
-
payload.issues.push({
|
|
861
|
-
code: "unrecognized_keys",
|
|
862
|
-
keys: unrecognized,
|
|
863
|
-
input,
|
|
864
|
-
inst,
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
if (!proms.length)
|
|
868
|
-
return payload;
|
|
869
|
-
return Promise.all(proms).then(() => {
|
|
870
|
-
return payload;
|
|
871
|
-
});
|
|
1220
|
+
return superParse(payload, ctx);
|
|
872
1221
|
};
|
|
873
1222
|
});
|
|
874
1223
|
function handleUnionResults(results, final, inst, ctx) {
|
|
@@ -878,6 +1227,11 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
878
1227
|
return final;
|
|
879
1228
|
}
|
|
880
1229
|
}
|
|
1230
|
+
const nonaborted = results.filter((r) => !util.aborted(r));
|
|
1231
|
+
if (nonaborted.length === 1) {
|
|
1232
|
+
final.value = nonaborted[0].value;
|
|
1233
|
+
return nonaborted[0];
|
|
1234
|
+
}
|
|
881
1235
|
final.issues.push({
|
|
882
1236
|
code: "invalid_union",
|
|
883
1237
|
input: final.value,
|
|
@@ -888,22 +1242,30 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
888
1242
|
}
|
|
889
1243
|
export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
|
890
1244
|
$ZodType.init(inst, def);
|
|
891
|
-
util.
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1245
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
|
|
1246
|
+
? "defaulted"
|
|
1247
|
+
: zod.def.options.some((o) => o._zod.optin !== undefined)
|
|
1248
|
+
? "optional"
|
|
1249
|
+
: undefined);
|
|
1250
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
1251
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
1252
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
1253
|
+
return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
896
1254
|
}
|
|
897
1255
|
return undefined;
|
|
898
1256
|
});
|
|
899
|
-
util.
|
|
900
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
901
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1257
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
1258
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
1259
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
902
1260
|
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
|
903
1261
|
}
|
|
904
1262
|
return undefined;
|
|
905
1263
|
});
|
|
1264
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
906
1265
|
inst._zod.parse = (payload, ctx) => {
|
|
1266
|
+
if (first) {
|
|
1267
|
+
return first(payload, ctx);
|
|
1268
|
+
}
|
|
907
1269
|
let async = false;
|
|
908
1270
|
const results = [];
|
|
909
1271
|
for (const option of def.options) {
|
|
@@ -928,43 +1290,137 @@ export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def
|
|
|
928
1290
|
});
|
|
929
1291
|
};
|
|
930
1292
|
});
|
|
1293
|
+
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
1294
|
+
const matches = [];
|
|
1295
|
+
for (let i = 0; i < results.length; i++) {
|
|
1296
|
+
if (results[i].issues.length === 0)
|
|
1297
|
+
matches.push(i);
|
|
1298
|
+
}
|
|
1299
|
+
if (matches.length === 1) {
|
|
1300
|
+
final.value = results[matches[0]].value;
|
|
1301
|
+
return final;
|
|
1302
|
+
}
|
|
1303
|
+
if (matches.length === 0) {
|
|
1304
|
+
// No matches - same as regular union
|
|
1305
|
+
final.issues.push({
|
|
1306
|
+
code: "invalid_union",
|
|
1307
|
+
input: final.value,
|
|
1308
|
+
inst,
|
|
1309
|
+
errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
else {
|
|
1313
|
+
// Multiple matches - exclusive union failure
|
|
1314
|
+
final.issues.push({
|
|
1315
|
+
code: "invalid_union",
|
|
1316
|
+
input: final.value,
|
|
1317
|
+
inst,
|
|
1318
|
+
errors: [],
|
|
1319
|
+
inclusive: false,
|
|
1320
|
+
matches,
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
return final;
|
|
1324
|
+
}
|
|
1325
|
+
export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
|
|
1326
|
+
$ZodUnion.init(inst, def);
|
|
1327
|
+
def.inclusive = false;
|
|
1328
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1329
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1330
|
+
if (first) {
|
|
1331
|
+
return first(payload, ctx);
|
|
1332
|
+
}
|
|
1333
|
+
let async = false;
|
|
1334
|
+
const results = [];
|
|
1335
|
+
for (const option of def.options) {
|
|
1336
|
+
const result = option._zod.run({
|
|
1337
|
+
value: payload.value,
|
|
1338
|
+
issues: [],
|
|
1339
|
+
}, ctx);
|
|
1340
|
+
if (result instanceof Promise) {
|
|
1341
|
+
results.push(result);
|
|
1342
|
+
async = true;
|
|
1343
|
+
}
|
|
1344
|
+
else {
|
|
1345
|
+
results.push(result);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (!async)
|
|
1349
|
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
|
1350
|
+
return Promise.all(results).then((results) => {
|
|
1351
|
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
|
1352
|
+
});
|
|
1353
|
+
};
|
|
1354
|
+
});
|
|
1355
|
+
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
|
|
1356
|
+
export function getDiscriminatedOption(union, value) {
|
|
1357
|
+
const internals = union._zod;
|
|
1358
|
+
let map = internals.bag.optionsMap;
|
|
1359
|
+
if (!map) {
|
|
1360
|
+
map = discriminatorMap(internals.def);
|
|
1361
|
+
internals.bag.optionsMap = map;
|
|
1362
|
+
}
|
|
1363
|
+
const option = map.get(value);
|
|
1364
|
+
if (option === null)
|
|
1365
|
+
throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
1366
|
+
return option;
|
|
1367
|
+
}
|
|
1368
|
+
function discriminatorMap(def) {
|
|
1369
|
+
const map = new Map();
|
|
1370
|
+
for (const option of def.options) {
|
|
1371
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
1372
|
+
if (!values || values.size === 0)
|
|
1373
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1374
|
+
for (const value of values) {
|
|
1375
|
+
if (map.has(value)) {
|
|
1376
|
+
if (value !== undefined)
|
|
1377
|
+
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
1378
|
+
// keep the collision marked so a later member cannot reclaim it
|
|
1379
|
+
map.set(value, null);
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
map.set(value, option);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
return map;
|
|
1387
|
+
}
|
|
931
1388
|
export const $ZodDiscriminatedUnion =
|
|
932
1389
|
/*@__PURE__*/
|
|
933
1390
|
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1391
|
+
def.inclusive = false;
|
|
934
1392
|
$ZodUnion.init(inst, def);
|
|
935
1393
|
const _super = inst._zod.parse;
|
|
936
|
-
util.
|
|
1394
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
937
1395
|
const propValues = {};
|
|
938
|
-
|
|
1396
|
+
let undefinedCount = 0;
|
|
1397
|
+
for (const option of zod.def.options) {
|
|
939
1398
|
const pv = option._zod.propValues;
|
|
940
1399
|
if (!pv || Object.keys(pv).length === 0)
|
|
941
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1400
|
+
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
1401
|
+
if (pv[zod.def.discriminator]?.has(undefined))
|
|
1402
|
+
undefinedCount++;
|
|
942
1403
|
for (const [k, v] of Object.entries(pv)) {
|
|
943
|
-
if (!propValues
|
|
944
|
-
propValues
|
|
1404
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
1405
|
+
util.assignProp(propValues, k, new Set());
|
|
1406
|
+
}
|
|
945
1407
|
for (const val of v) {
|
|
946
1408
|
propValues[k].add(val);
|
|
947
1409
|
}
|
|
948
1410
|
}
|
|
949
1411
|
}
|
|
1412
|
+
if (!zod.def.unionFallback && undefinedCount > 1)
|
|
1413
|
+
propValues[zod.def.discriminator]?.delete(undefined);
|
|
950
1414
|
return propValues;
|
|
951
1415
|
});
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
if (!values || values.size === 0)
|
|
958
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
959
|
-
for (const v of values) {
|
|
960
|
-
if (map.has(v)) {
|
|
961
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
962
|
-
}
|
|
963
|
-
map.set(v, o);
|
|
964
|
-
}
|
|
1416
|
+
// Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
|
|
1417
|
+
def.options.forEach((option, i) => {
|
|
1418
|
+
const propShape = util.rawShape(option._zod.def);
|
|
1419
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
1420
|
+
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
965
1421
|
}
|
|
966
|
-
return map;
|
|
967
1422
|
});
|
|
1423
|
+
const disc = util.cached(() => discriminatorMap(def));
|
|
968
1424
|
inst._zod.parse = (payload, ctx) => {
|
|
969
1425
|
const input = payload.value;
|
|
970
1426
|
if (!util.isObject(input)) {
|
|
@@ -976,11 +1432,16 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
976
1432
|
});
|
|
977
1433
|
return payload;
|
|
978
1434
|
}
|
|
979
|
-
const
|
|
980
|
-
|
|
1435
|
+
const value = input?.[def.discriminator];
|
|
1436
|
+
const opt = disc.value.get(value);
|
|
1437
|
+
// forward metadata cannot choose an encoder for an absent tag
|
|
1438
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
981
1439
|
return opt._zod.run(payload, ctx);
|
|
982
1440
|
}
|
|
983
|
-
|
|
1441
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
1442
|
+
// - explicitly enabled via unionFallback, or
|
|
1443
|
+
// - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
|
|
1444
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
984
1445
|
return _super(payload, ctx);
|
|
985
1446
|
}
|
|
986
1447
|
// no matching discriminator
|
|
@@ -988,6 +1449,8 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
988
1449
|
code: "invalid_union",
|
|
989
1450
|
errors: [],
|
|
990
1451
|
note: "No matching discriminator",
|
|
1452
|
+
discriminator: def.discriminator,
|
|
1453
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
991
1454
|
input,
|
|
992
1455
|
path: [def.discriminator],
|
|
993
1456
|
inst,
|
|
@@ -1010,7 +1473,7 @@ export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersectio
|
|
|
1010
1473
|
return handleIntersectionResults(payload, left, right);
|
|
1011
1474
|
};
|
|
1012
1475
|
});
|
|
1013
|
-
function mergeValues(a, b) {
|
|
1476
|
+
export function mergeValues(a, b) {
|
|
1014
1477
|
// const aType = parse.t(a);
|
|
1015
1478
|
// const bType = parse.t(b);
|
|
1016
1479
|
if (a === b) {
|
|
@@ -1023,7 +1486,11 @@ function mergeValues(a, b) {
|
|
|
1023
1486
|
const bKeys = Object.keys(b);
|
|
1024
1487
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1025
1488
|
const newObj = { ...a, ...b };
|
|
1489
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
1490
|
+
delete newObj.__proto__;
|
|
1026
1491
|
for (const key of sharedKeys) {
|
|
1492
|
+
if (key === "__proto__")
|
|
1493
|
+
continue;
|
|
1027
1494
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1028
1495
|
if (!sharedValue.valid) {
|
|
1029
1496
|
return {
|
|
@@ -1057,16 +1524,55 @@ function mergeValues(a, b) {
|
|
|
1057
1524
|
return { valid: false, mergeErrorPath: [] };
|
|
1058
1525
|
}
|
|
1059
1526
|
function handleIntersectionResults(result, left, right) {
|
|
1060
|
-
|
|
1061
|
-
|
|
1527
|
+
// Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
|
|
1528
|
+
const unrecKeys = new Map();
|
|
1529
|
+
let unrecIssue;
|
|
1530
|
+
const keyIssues = new Map();
|
|
1531
|
+
const collect = (iss, side) => {
|
|
1532
|
+
let keys;
|
|
1533
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
1534
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
1535
|
+
keys = iss.keys;
|
|
1536
|
+
}
|
|
1537
|
+
else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
1538
|
+
const k = String(iss.path[0]);
|
|
1539
|
+
if (!keyIssues.has(k))
|
|
1540
|
+
keyIssues.set(k, iss);
|
|
1541
|
+
keys = [k];
|
|
1542
|
+
}
|
|
1543
|
+
else {
|
|
1544
|
+
return false;
|
|
1545
|
+
}
|
|
1546
|
+
for (const k of keys) {
|
|
1547
|
+
if (!unrecKeys.has(k))
|
|
1548
|
+
unrecKeys.set(k, {});
|
|
1549
|
+
unrecKeys.get(k)[side] = true;
|
|
1550
|
+
}
|
|
1551
|
+
return true;
|
|
1552
|
+
};
|
|
1553
|
+
for (const iss of left.issues) {
|
|
1554
|
+
if (!collect(iss, "l"))
|
|
1555
|
+
result.issues.push(iss);
|
|
1062
1556
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1557
|
+
for (const iss of right.issues) {
|
|
1558
|
+
if (!collect(iss, "r"))
|
|
1559
|
+
result.issues.push(iss);
|
|
1560
|
+
}
|
|
1561
|
+
// Report only keys rejected by BOTH sides
|
|
1562
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1563
|
+
if (bothKeys.length) {
|
|
1564
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
1565
|
+
if (aggregated.length)
|
|
1566
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
1567
|
+
for (const k of bothKeys) {
|
|
1568
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
1569
|
+
result.issues.push(keyIssues.get(k));
|
|
1570
|
+
}
|
|
1065
1571
|
}
|
|
1066
|
-
if (util.aborted(result))
|
|
1067
|
-
return result;
|
|
1068
1572
|
const merged = mergeValues(left.value, right.value);
|
|
1069
1573
|
if (!merged.valid) {
|
|
1574
|
+
if (util.aborted(result))
|
|
1575
|
+
return result;
|
|
1070
1576
|
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1071
1577
|
}
|
|
1072
1578
|
result.value = merged.data;
|
|
@@ -1075,7 +1581,8 @@ function handleIntersectionResults(result, left, right) {
|
|
|
1075
1581
|
export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
|
|
1076
1582
|
$ZodType.init(inst, def);
|
|
1077
1583
|
const items = def.items;
|
|
1078
|
-
const
|
|
1584
|
+
const memo = core.globalConfig.memoizer;
|
|
1585
|
+
memo?.attach(inst);
|
|
1079
1586
|
inst._zod.parse = (payload, ctx) => {
|
|
1080
1587
|
const input = payload.value;
|
|
1081
1588
|
if (!Array.isArray(input)) {
|
|
@@ -1087,67 +1594,132 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
|
|
|
1087
1594
|
});
|
|
1088
1595
|
return payload;
|
|
1089
1596
|
}
|
|
1090
|
-
payload.value = [];
|
|
1597
|
+
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
1091
1598
|
const proms = [];
|
|
1599
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
1600
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
1092
1601
|
if (!def.rest) {
|
|
1093
|
-
|
|
1094
|
-
const tooSmall = input.length < optStart - 1;
|
|
1095
|
-
if (tooBig || tooSmall) {
|
|
1602
|
+
if (input.length < optinStart) {
|
|
1096
1603
|
payload.issues.push({
|
|
1604
|
+
code: "too_small",
|
|
1605
|
+
minimum: optinStart,
|
|
1606
|
+
inclusive: true,
|
|
1097
1607
|
input,
|
|
1098
1608
|
inst,
|
|
1099
1609
|
origin: "array",
|
|
1100
|
-
...(tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }),
|
|
1101
1610
|
});
|
|
1102
1611
|
return payload;
|
|
1103
1612
|
}
|
|
1613
|
+
if (input.length > items.length) {
|
|
1614
|
+
payload.issues.push({
|
|
1615
|
+
code: "too_big",
|
|
1616
|
+
maximum: items.length,
|
|
1617
|
+
inclusive: true,
|
|
1618
|
+
input,
|
|
1619
|
+
inst,
|
|
1620
|
+
origin: "array",
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1104
1623
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
1624
|
+
// Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
|
|
1625
|
+
const itemResults = new Array(items.length);
|
|
1626
|
+
// only tracked when there is a rest loop to skip
|
|
1627
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
1628
|
+
let itemAborted = false;
|
|
1629
|
+
for (let i = 0; i < items.length; i++) {
|
|
1630
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
1631
|
+
if (r instanceof Promise) {
|
|
1632
|
+
proms.push(r.then((rr) => {
|
|
1633
|
+
itemResults[i] = rr;
|
|
1634
|
+
}));
|
|
1117
1635
|
}
|
|
1118
1636
|
else {
|
|
1119
|
-
|
|
1637
|
+
itemResults[i] = r;
|
|
1638
|
+
if (abortEarly && !itemAborted && r.issues.length)
|
|
1639
|
+
itemAborted = util.aborted(r);
|
|
1120
1640
|
}
|
|
1121
1641
|
}
|
|
1122
|
-
|
|
1642
|
+
// sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
|
|
1643
|
+
if (def.rest && !itemAborted) {
|
|
1644
|
+
let i = items.length - 1;
|
|
1123
1645
|
const rest = input.slice(items.length);
|
|
1646
|
+
let seen = payload.issues.length;
|
|
1124
1647
|
for (const el of rest) {
|
|
1648
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1649
|
+
if (util.aborted(payload, seen))
|
|
1650
|
+
break;
|
|
1651
|
+
seen = payload.issues.length;
|
|
1652
|
+
}
|
|
1125
1653
|
i++;
|
|
1126
|
-
const result = def.rest._zod.run({
|
|
1127
|
-
value: el,
|
|
1128
|
-
issues: [],
|
|
1129
|
-
}, ctx);
|
|
1654
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
1130
1655
|
if (result instanceof Promise) {
|
|
1131
|
-
proms.push(result.then((
|
|
1656
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
1132
1657
|
}
|
|
1133
1658
|
else {
|
|
1134
1659
|
handleTupleResult(result, payload, i);
|
|
1135
1660
|
}
|
|
1136
1661
|
}
|
|
1137
1662
|
}
|
|
1138
|
-
if (proms.length)
|
|
1139
|
-
return Promise.all(proms).then(() => payload);
|
|
1140
|
-
|
|
1663
|
+
if (proms.length) {
|
|
1664
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
1665
|
+
}
|
|
1666
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
1141
1667
|
};
|
|
1142
1668
|
});
|
|
1669
|
+
function getTupleOptStart(items, key) {
|
|
1670
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
1671
|
+
// optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
|
|
1672
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
1673
|
+
if (!omittable)
|
|
1674
|
+
return i + 1;
|
|
1675
|
+
}
|
|
1676
|
+
return 0;
|
|
1677
|
+
}
|
|
1143
1678
|
function handleTupleResult(result, final, index) {
|
|
1144
1679
|
if (result.issues.length) {
|
|
1145
1680
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
1146
1681
|
}
|
|
1147
1682
|
final.value[index] = result.value;
|
|
1148
1683
|
}
|
|
1684
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1685
|
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
|
|
1686
|
+
for (let i = 0; i < items.length; i++) {
|
|
1687
|
+
const r = itemResults[i];
|
|
1688
|
+
const isPresent = i < input.length;
|
|
1689
|
+
// The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
|
|
1690
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
1691
|
+
final.value.length = i;
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
if (r.issues.length) {
|
|
1695
|
+
if (!isPresent && i >= optoutStart) {
|
|
1696
|
+
final.value.length = i;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
1700
|
+
}
|
|
1701
|
+
final.value[i] = r.value;
|
|
1702
|
+
}
|
|
1703
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
1704
|
+
// (the array analog of an absent optional key on an object). The
|
|
1705
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
1706
|
+
// *inside* the input must be preserved even when the schema is
|
|
1707
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
1708
|
+
// explicit undefined value).
|
|
1709
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
1710
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
1711
|
+
final.value.length = i;
|
|
1712
|
+
}
|
|
1713
|
+
else {
|
|
1714
|
+
break;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
return final;
|
|
1718
|
+
}
|
|
1149
1719
|
export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
|
1150
1720
|
$ZodType.init(inst, def);
|
|
1721
|
+
const memo = core.globalConfig.memoizer;
|
|
1722
|
+
memo?.attach(inst);
|
|
1151
1723
|
inst._zod.parse = (payload, ctx) => {
|
|
1152
1724
|
const input = payload.value;
|
|
1153
1725
|
if (!util.isPlainObject(input)) {
|
|
@@ -1159,34 +1731,66 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1159
1731
|
});
|
|
1160
1732
|
return payload;
|
|
1161
1733
|
}
|
|
1734
|
+
// no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
|
|
1162
1735
|
const proms = [];
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
payload.value = {};
|
|
1736
|
+
const values = def.keyType._zod.values;
|
|
1737
|
+
if (values && !def.partial) {
|
|
1738
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1739
|
+
const recordKeys = new Set();
|
|
1166
1740
|
for (const key of values) {
|
|
1167
1741
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1742
|
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1743
|
+
// A declared __proto__ is stripped but is not an unrecognized key.
|
|
1744
|
+
if (key === "__proto__")
|
|
1745
|
+
continue;
|
|
1746
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1747
|
+
if (keyResult instanceof Promise) {
|
|
1748
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
1749
|
+
}
|
|
1750
|
+
if (keyResult.issues.length) {
|
|
1751
|
+
payload.issues.push({
|
|
1752
|
+
code: "invalid_key",
|
|
1753
|
+
origin: "record",
|
|
1754
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1755
|
+
input: key,
|
|
1756
|
+
path: [key],
|
|
1757
|
+
inst,
|
|
1758
|
+
});
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
const outKey = keyResult.value;
|
|
1762
|
+
if (outKey === "__proto__")
|
|
1763
|
+
continue;
|
|
1168
1764
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1169
1765
|
if (result instanceof Promise) {
|
|
1170
1766
|
proms.push(result.then((result) => {
|
|
1171
1767
|
if (result.issues.length) {
|
|
1172
1768
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1173
1769
|
}
|
|
1174
|
-
payload.value[
|
|
1770
|
+
payload.value[outKey] = result.value;
|
|
1175
1771
|
}));
|
|
1176
1772
|
}
|
|
1177
1773
|
else {
|
|
1178
1774
|
if (result.issues.length) {
|
|
1179
1775
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1180
1776
|
}
|
|
1181
|
-
payload.value[
|
|
1777
|
+
payload.value[outKey] = result.value;
|
|
1182
1778
|
}
|
|
1183
1779
|
}
|
|
1184
1780
|
}
|
|
1185
1781
|
let unrecognized;
|
|
1186
1782
|
for (const key in input) {
|
|
1187
|
-
if (!
|
|
1188
|
-
|
|
1189
|
-
|
|
1783
|
+
if (!recordKeys.has(key)) {
|
|
1784
|
+
if (def.mode === "loose") {
|
|
1785
|
+
// skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
|
|
1786
|
+
if (key === "__proto__")
|
|
1787
|
+
continue;
|
|
1788
|
+
payload.value[key] = input[key];
|
|
1789
|
+
}
|
|
1790
|
+
else {
|
|
1791
|
+
unrecognized = unrecognized ?? [];
|
|
1792
|
+
unrecognized.push(key);
|
|
1793
|
+
}
|
|
1190
1794
|
}
|
|
1191
1795
|
}
|
|
1192
1796
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -1195,46 +1799,86 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1195
1799
|
input,
|
|
1196
1800
|
inst,
|
|
1197
1801
|
keys: unrecognized,
|
|
1802
|
+
continue: true,
|
|
1198
1803
|
});
|
|
1199
1804
|
}
|
|
1200
1805
|
}
|
|
1201
1806
|
else {
|
|
1202
|
-
payload.value = {};
|
|
1807
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1808
|
+
// An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
|
|
1809
|
+
let unrecognized;
|
|
1810
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
1203
1811
|
for (const key of Reflect.ownKeys(input)) {
|
|
1204
1812
|
if (key === "__proto__")
|
|
1205
1813
|
continue;
|
|
1206
|
-
|
|
1814
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
1815
|
+
continue;
|
|
1816
|
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1207
1817
|
if (keyResult instanceof Promise) {
|
|
1208
1818
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1209
1819
|
}
|
|
1820
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1821
|
+
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
1822
|
+
if (checkNumericKey) {
|
|
1823
|
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
1824
|
+
if (retryResult instanceof Promise) {
|
|
1825
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
1826
|
+
}
|
|
1827
|
+
if (retryResult.issues.length === 0) {
|
|
1828
|
+
keyResult = retryResult;
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1210
1831
|
if (keyResult.issues.length) {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1832
|
+
if (def.mode === "loose") {
|
|
1833
|
+
// Pass through unchanged
|
|
1834
|
+
payload.value[key] = input[key];
|
|
1835
|
+
}
|
|
1836
|
+
else if (values) {
|
|
1837
|
+
unrecognized = unrecognized ?? [];
|
|
1838
|
+
unrecognized.push(key);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
// Default "strict" behavior: error on invalid key
|
|
1842
|
+
payload.issues.push({
|
|
1843
|
+
code: "invalid_key",
|
|
1844
|
+
origin: "record",
|
|
1845
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1846
|
+
input: key,
|
|
1847
|
+
path: [key],
|
|
1848
|
+
inst,
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1220
1851
|
continue;
|
|
1221
1852
|
}
|
|
1853
|
+
// the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
|
|
1854
|
+
const outKey = keyResult.value;
|
|
1855
|
+
if (outKey === "__proto__")
|
|
1856
|
+
continue;
|
|
1222
1857
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1223
1858
|
if (result instanceof Promise) {
|
|
1224
1859
|
proms.push(result.then((result) => {
|
|
1225
1860
|
if (result.issues.length) {
|
|
1226
1861
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1227
1862
|
}
|
|
1228
|
-
payload.value[
|
|
1863
|
+
payload.value[outKey] = result.value;
|
|
1229
1864
|
}));
|
|
1230
1865
|
}
|
|
1231
1866
|
else {
|
|
1232
1867
|
if (result.issues.length) {
|
|
1233
1868
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1234
1869
|
}
|
|
1235
|
-
payload.value[
|
|
1870
|
+
payload.value[outKey] = result.value;
|
|
1236
1871
|
}
|
|
1237
1872
|
}
|
|
1873
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
1874
|
+
payload.issues.push({
|
|
1875
|
+
code: "unrecognized_keys",
|
|
1876
|
+
input,
|
|
1877
|
+
inst,
|
|
1878
|
+
keys: unrecognized,
|
|
1879
|
+
continue: true,
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1238
1882
|
}
|
|
1239
1883
|
if (proms.length) {
|
|
1240
1884
|
return Promise.all(proms).then(() => payload);
|
|
@@ -1244,6 +1888,8 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1244
1888
|
});
|
|
1245
1889
|
export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
|
|
1246
1890
|
$ZodType.init(inst, def);
|
|
1891
|
+
const memo = core.globalConfig.memoizer;
|
|
1892
|
+
memo?.attach(inst);
|
|
1247
1893
|
inst._zod.parse = (payload, ctx) => {
|
|
1248
1894
|
const input = payload.value;
|
|
1249
1895
|
if (!(input instanceof Map)) {
|
|
@@ -1256,8 +1902,15 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
|
|
|
1256
1902
|
return payload;
|
|
1257
1903
|
}
|
|
1258
1904
|
const proms = [];
|
|
1259
|
-
payload.value = new Map();
|
|
1905
|
+
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
1906
|
+
const abortEarly = ctx?.abortEarly;
|
|
1907
|
+
let seen = payload.issues.length;
|
|
1260
1908
|
for (const [key, value] of input) {
|
|
1909
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1910
|
+
if (util.aborted(payload, seen))
|
|
1911
|
+
break;
|
|
1912
|
+
seen = payload.issues.length;
|
|
1913
|
+
}
|
|
1261
1914
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1262
1915
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
1263
1916
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
@@ -1273,6 +1926,7 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
|
|
|
1273
1926
|
return Promise.all(proms).then(() => payload);
|
|
1274
1927
|
return payload;
|
|
1275
1928
|
};
|
|
1929
|
+
capSize(inst, mapSize);
|
|
1276
1930
|
});
|
|
1277
1931
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
1278
1932
|
if (keyResult.issues.length) {
|
|
@@ -1281,8 +1935,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
1281
1935
|
}
|
|
1282
1936
|
else {
|
|
1283
1937
|
final.issues.push({
|
|
1284
|
-
origin: "map",
|
|
1285
1938
|
code: "invalid_key",
|
|
1939
|
+
origin: "map",
|
|
1286
1940
|
input,
|
|
1287
1941
|
inst,
|
|
1288
1942
|
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
@@ -1308,6 +1962,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
1308
1962
|
}
|
|
1309
1963
|
export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
|
|
1310
1964
|
$ZodType.init(inst, def);
|
|
1965
|
+
const memo = core.globalConfig.memoizer;
|
|
1966
|
+
memo?.attach(inst);
|
|
1311
1967
|
inst._zod.parse = (payload, ctx) => {
|
|
1312
1968
|
const input = payload.value;
|
|
1313
1969
|
if (!(input instanceof Set)) {
|
|
@@ -1320,8 +1976,15 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
|
|
|
1320
1976
|
return payload;
|
|
1321
1977
|
}
|
|
1322
1978
|
const proms = [];
|
|
1323
|
-
payload.value = new Set();
|
|
1979
|
+
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
1980
|
+
const abortEarly = ctx?.abortEarly;
|
|
1981
|
+
let seen = payload.issues.length;
|
|
1324
1982
|
for (const item of input) {
|
|
1983
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1984
|
+
if (util.aborted(payload, seen))
|
|
1985
|
+
break;
|
|
1986
|
+
seen = payload.issues.length;
|
|
1987
|
+
}
|
|
1325
1988
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
1326
1989
|
if (result instanceof Promise) {
|
|
1327
1990
|
proms.push(result.then((result) => handleSetResult(result, payload)));
|
|
@@ -1333,6 +1996,7 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
|
|
|
1333
1996
|
return Promise.all(proms).then(() => payload);
|
|
1334
1997
|
return payload;
|
|
1335
1998
|
};
|
|
1999
|
+
capSize(inst, setSize);
|
|
1336
2000
|
});
|
|
1337
2001
|
function handleSetResult(result, final) {
|
|
1338
2002
|
if (result.issues.length) {
|
|
@@ -1343,14 +2007,16 @@ function handleSetResult(result, final) {
|
|
|
1343
2007
|
export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
|
|
1344
2008
|
$ZodType.init(inst, def);
|
|
1345
2009
|
const values = util.getEnumValues(def.entries);
|
|
1346
|
-
|
|
1347
|
-
inst._zod.
|
|
1348
|
-
|
|
1349
|
-
.
|
|
1350
|
-
|
|
2010
|
+
const valuesSet = new Set(values);
|
|
2011
|
+
inst._zod.values = valuesSet;
|
|
2012
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2013
|
+
const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
|
|
2014
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
2015
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2016
|
+
});
|
|
1351
2017
|
inst._zod.parse = (payload, _ctx) => {
|
|
1352
2018
|
const input = payload.value;
|
|
1353
|
-
if (
|
|
2019
|
+
if (valuesSet.has(input)) {
|
|
1354
2020
|
return payload;
|
|
1355
2021
|
}
|
|
1356
2022
|
payload.issues.push({
|
|
@@ -1364,13 +2030,20 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
|
|
|
1364
2030
|
});
|
|
1365
2031
|
export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
|
|
1366
2032
|
$ZodType.init(inst, def);
|
|
1367
|
-
|
|
1368
|
-
inst._zod.
|
|
1369
|
-
|
|
1370
|
-
.
|
|
2033
|
+
const values = new Set(def.values);
|
|
2034
|
+
inst._zod.values = values;
|
|
2035
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2036
|
+
const vals = zod.def.values;
|
|
2037
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
2038
|
+
return new RegExp(vals.length
|
|
2039
|
+
? `^(${vals
|
|
2040
|
+
.map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
|
|
2041
|
+
.join("|")})$`
|
|
2042
|
+
: "^[^\\s\\S]$");
|
|
2043
|
+
});
|
|
1371
2044
|
inst._zod.parse = (payload, _ctx) => {
|
|
1372
2045
|
const input = payload.value;
|
|
1373
|
-
if (
|
|
2046
|
+
if (values.has(input)) {
|
|
1374
2047
|
return payload;
|
|
1375
2048
|
}
|
|
1376
2049
|
payload.issues.push({
|
|
@@ -1386,6 +2059,7 @@ export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def)
|
|
|
1386
2059
|
$ZodType.init(inst, def);
|
|
1387
2060
|
inst._zod.parse = (payload, _ctx) => {
|
|
1388
2061
|
const input = payload.value;
|
|
2062
|
+
// @ts-ignore
|
|
1389
2063
|
if (input instanceof File)
|
|
1390
2064
|
return payload;
|
|
1391
2065
|
payload.issues.push({
|
|
@@ -1399,9 +2073,14 @@ export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def)
|
|
|
1399
2073
|
});
|
|
1400
2074
|
export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
|
|
1401
2075
|
$ZodType.init(inst, def);
|
|
1402
|
-
inst._zod.
|
|
2076
|
+
inst._zod.optin = "optional";
|
|
2077
|
+
core.globalConfig.memoizer?.guard(inst);
|
|
2078
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2079
|
+
if (ctx.direction === "backward") {
|
|
2080
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
2081
|
+
}
|
|
1403
2082
|
const _out = def.transform(payload.value, payload);
|
|
1404
|
-
if (
|
|
2083
|
+
if (ctx.async) {
|
|
1405
2084
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1406
2085
|
return output.then((output) => {
|
|
1407
2086
|
payload.value = output;
|
|
@@ -1415,39 +2094,62 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
|
|
|
1415
2094
|
return payload;
|
|
1416
2095
|
};
|
|
1417
2096
|
});
|
|
2097
|
+
function handleOptionalResult(payload, result) {
|
|
2098
|
+
// A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
|
|
2099
|
+
payload.value = result.issues.length ? undefined : result.value;
|
|
2100
|
+
return payload;
|
|
2101
|
+
}
|
|
1418
2102
|
export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
|
|
1419
2103
|
$ZodType.init(inst, def);
|
|
1420
|
-
|
|
2104
|
+
// .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
|
|
2105
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
1421
2106
|
inst._zod.optout = "optional";
|
|
1422
|
-
util.
|
|
1423
|
-
|
|
2107
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2108
|
+
const values = zod.def.innerType._zod.values;
|
|
2109
|
+
return values ? new Set([...values, undefined]) : undefined;
|
|
1424
2110
|
});
|
|
1425
|
-
util.
|
|
1426
|
-
const pattern = def.innerType._zod.pattern;
|
|
2111
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2112
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1427
2113
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
|
1428
2114
|
});
|
|
1429
2115
|
inst._zod.parse = (payload, ctx) => {
|
|
1430
|
-
if (def.innerType._zod.optin === "optional") {
|
|
1431
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1432
|
-
}
|
|
1433
2116
|
if (payload.value === undefined) {
|
|
1434
|
-
|
|
2117
|
+
// Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
|
|
2118
|
+
if (def.innerType._zod.optin !== "defaulted")
|
|
2119
|
+
return payload;
|
|
2120
|
+
// Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
|
|
2121
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2122
|
+
if (result instanceof Promise)
|
|
2123
|
+
return result.then((result) => handleOptionalResult(payload, result));
|
|
2124
|
+
return handleOptionalResult(payload, result);
|
|
1435
2125
|
}
|
|
1436
2126
|
return def.innerType._zod.run(payload, ctx);
|
|
1437
2127
|
};
|
|
1438
2128
|
});
|
|
2129
|
+
export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptional", (inst, def) => {
|
|
2130
|
+
// Call parent init - inherits optin/optout = "optional"
|
|
2131
|
+
$ZodOptional.init(inst, def);
|
|
2132
|
+
// Override values/pattern to NOT add undefined
|
|
2133
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2134
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2135
|
+
// Override parse to just delegate (no undefined handling)
|
|
2136
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2137
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2138
|
+
};
|
|
2139
|
+
});
|
|
1439
2140
|
export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
|
|
1440
2141
|
$ZodType.init(inst, def);
|
|
1441
|
-
util.
|
|
1442
|
-
util.
|
|
1443
|
-
util.
|
|
1444
|
-
const pattern = def.innerType._zod.pattern;
|
|
2142
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2143
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2144
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2145
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1445
2146
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
1446
2147
|
});
|
|
1447
|
-
util.
|
|
1448
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
2148
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2149
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
|
|
1449
2150
|
});
|
|
1450
2151
|
inst._zod.parse = (payload, ctx) => {
|
|
2152
|
+
// Forward direction (decode): allow null to pass through
|
|
1451
2153
|
if (payload.value === null)
|
|
1452
2154
|
return payload;
|
|
1453
2155
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1456,16 +2158,21 @@ export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (ins
|
|
|
1456
2158
|
export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
|
|
1457
2159
|
$ZodType.init(inst, def);
|
|
1458
2160
|
// inst._zod.qin = "true";
|
|
1459
|
-
inst._zod.optin = "
|
|
1460
|
-
util.
|
|
2161
|
+
inst._zod.optin = "defaulted";
|
|
2162
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1461
2163
|
inst._zod.parse = (payload, ctx) => {
|
|
2164
|
+
if (ctx.direction === "backward") {
|
|
2165
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2166
|
+
}
|
|
2167
|
+
// Forward direction (decode): apply defaults for undefined input
|
|
1462
2168
|
if (payload.value === undefined) {
|
|
1463
2169
|
payload.value = def.defaultValue;
|
|
1464
2170
|
/**
|
|
1465
|
-
* $ZodDefault
|
|
2171
|
+
* $ZodDefault returns the default value immediately in forward direction.
|
|
1466
2172
|
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1467
2173
|
return payload;
|
|
1468
2174
|
}
|
|
2175
|
+
// Forward direction: continue with default handling
|
|
1469
2176
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1470
2177
|
if (result instanceof Promise) {
|
|
1471
2178
|
return result.then((result) => handleDefaultResult(result, def));
|
|
@@ -1481,9 +2188,13 @@ function handleDefaultResult(payload, def) {
|
|
|
1481
2188
|
}
|
|
1482
2189
|
export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
|
|
1483
2190
|
$ZodType.init(inst, def);
|
|
1484
|
-
inst._zod.optin = "
|
|
1485
|
-
util.
|
|
2191
|
+
inst._zod.optin = "defaulted";
|
|
2192
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1486
2193
|
inst._zod.parse = (payload, ctx) => {
|
|
2194
|
+
if (ctx.direction === "backward") {
|
|
2195
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2196
|
+
}
|
|
2197
|
+
// Forward direction (decode): apply prefault for undefined input
|
|
1487
2198
|
if (payload.value === undefined) {
|
|
1488
2199
|
payload.value = def.defaultValue;
|
|
1489
2200
|
}
|
|
@@ -1492,8 +2203,8 @@ export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (ins
|
|
|
1492
2203
|
});
|
|
1493
2204
|
export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
|
|
1494
2205
|
$ZodType.init(inst, def);
|
|
1495
|
-
util.
|
|
1496
|
-
const v = def.innerType._zod.values;
|
|
2206
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2207
|
+
const v = zod.def.innerType._zod.values;
|
|
1497
2208
|
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
1498
2209
|
});
|
|
1499
2210
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1518,6 +2229,9 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
1518
2229
|
export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst, def) => {
|
|
1519
2230
|
$ZodType.init(inst, def);
|
|
1520
2231
|
inst._zod.parse = (payload, ctx) => {
|
|
2232
|
+
if (ctx.direction === "backward") {
|
|
2233
|
+
throw new core.$ZodEncodeError("ZodSuccess");
|
|
2234
|
+
}
|
|
1521
2235
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1522
2236
|
if (result instanceof Promise) {
|
|
1523
2237
|
return result.then((result) => {
|
|
@@ -1529,41 +2243,40 @@ export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst,
|
|
|
1529
2243
|
return payload;
|
|
1530
2244
|
};
|
|
1531
2245
|
});
|
|
2246
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2247
|
+
if (!result.issues.length) {
|
|
2248
|
+
payload.value = result.value;
|
|
2249
|
+
// The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
|
|
2250
|
+
if (result.memo)
|
|
2251
|
+
payload.memo = true;
|
|
2252
|
+
return payload;
|
|
2253
|
+
}
|
|
2254
|
+
// Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
|
|
2255
|
+
payload.value = def.catchValue({
|
|
2256
|
+
...result,
|
|
2257
|
+
value: payload.value,
|
|
2258
|
+
error: {
|
|
2259
|
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
2260
|
+
},
|
|
2261
|
+
input: payload.value,
|
|
2262
|
+
});
|
|
2263
|
+
return payload;
|
|
2264
|
+
}
|
|
1532
2265
|
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
1533
2266
|
$ZodType.init(inst, def);
|
|
1534
|
-
inst._zod.optin
|
|
1535
|
-
util.
|
|
1536
|
-
util.
|
|
2267
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2268
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2269
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1537
2270
|
inst._zod.parse = (payload, ctx) => {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
return result.then((result) => {
|
|
1541
|
-
payload.value = result.value;
|
|
1542
|
-
if (result.issues.length) {
|
|
1543
|
-
payload.value = def.catchValue({
|
|
1544
|
-
...payload,
|
|
1545
|
-
error: {
|
|
1546
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1547
|
-
},
|
|
1548
|
-
input: payload.value,
|
|
1549
|
-
});
|
|
1550
|
-
payload.issues = [];
|
|
1551
|
-
}
|
|
1552
|
-
return payload;
|
|
1553
|
-
});
|
|
2271
|
+
if (ctx.direction === "backward") {
|
|
2272
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1554
2273
|
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
error: {
|
|
1560
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1561
|
-
},
|
|
1562
|
-
input: payload.value,
|
|
1563
|
-
});
|
|
1564
|
-
payload.issues = [];
|
|
2274
|
+
// Forward direction (decode): apply catch logic
|
|
2275
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2276
|
+
if (result instanceof Promise) {
|
|
2277
|
+
return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
1565
2278
|
}
|
|
1566
|
-
return payload;
|
|
2279
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
1567
2280
|
};
|
|
1568
2281
|
});
|
|
1569
2282
|
export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
|
|
@@ -1583,30 +2296,101 @@ export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) =>
|
|
|
1583
2296
|
});
|
|
1584
2297
|
export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
|
|
1585
2298
|
$ZodType.init(inst, def);
|
|
1586
|
-
util.
|
|
1587
|
-
util.
|
|
1588
|
-
util.
|
|
2299
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2300
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2301
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2302
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1589
2303
|
inst._zod.parse = (payload, ctx) => {
|
|
2304
|
+
if (ctx.direction === "backward") {
|
|
2305
|
+
const right = def.out._zod.run(payload, ctx);
|
|
2306
|
+
if (right instanceof Promise) {
|
|
2307
|
+
return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
2308
|
+
}
|
|
2309
|
+
return handlePipeResult(right, def.in, ctx);
|
|
2310
|
+
}
|
|
1590
2311
|
const left = def.in._zod.run(payload, ctx);
|
|
1591
2312
|
if (left instanceof Promise) {
|
|
1592
|
-
return left.then((left) => handlePipeResult(left, def, ctx));
|
|
2313
|
+
return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
1593
2314
|
}
|
|
1594
|
-
return handlePipeResult(left, def, ctx);
|
|
2315
|
+
return handlePipeResult(left, def.out, ctx);
|
|
1595
2316
|
};
|
|
1596
2317
|
});
|
|
1597
|
-
function handlePipeResult(left,
|
|
1598
|
-
|
|
2318
|
+
function handlePipeResult(left, next, ctx) {
|
|
2319
|
+
// Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
|
|
2320
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2321
|
+
// prevent further checks
|
|
2322
|
+
left.aborted = true;
|
|
1599
2323
|
return left;
|
|
1600
2324
|
}
|
|
1601
|
-
return
|
|
2325
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1602
2326
|
}
|
|
2327
|
+
export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
|
|
2328
|
+
$ZodType.init(inst, def);
|
|
2329
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2330
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2331
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2332
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2333
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2334
|
+
const direction = ctx.direction || "forward";
|
|
2335
|
+
if (direction === "forward") {
|
|
2336
|
+
const left = def.in._zod.run(payload, ctx);
|
|
2337
|
+
if (left instanceof Promise) {
|
|
2338
|
+
return left.then((left) => handleCodecAResult(left, def, ctx));
|
|
2339
|
+
}
|
|
2340
|
+
return handleCodecAResult(left, def, ctx);
|
|
2341
|
+
}
|
|
2342
|
+
else {
|
|
2343
|
+
const right = def.out._zod.run(payload, ctx);
|
|
2344
|
+
if (right instanceof Promise) {
|
|
2345
|
+
return right.then((right) => handleCodecAResult(right, def, ctx));
|
|
2346
|
+
}
|
|
2347
|
+
return handleCodecAResult(right, def, ctx);
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
});
|
|
2351
|
+
function handleCodecAResult(result, def, ctx) {
|
|
2352
|
+
if (result.issues.length) {
|
|
2353
|
+
// prevent further checks
|
|
2354
|
+
result.aborted = true;
|
|
2355
|
+
return result;
|
|
2356
|
+
}
|
|
2357
|
+
const direction = ctx.direction || "forward";
|
|
2358
|
+
if (direction === "forward") {
|
|
2359
|
+
const transformed = def.transform(result.value, result);
|
|
2360
|
+
if (transformed instanceof Promise) {
|
|
2361
|
+
return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
|
|
2362
|
+
}
|
|
2363
|
+
return handleCodecTxResult(result, transformed, def.out, ctx);
|
|
2364
|
+
}
|
|
2365
|
+
else {
|
|
2366
|
+
const transformed = def.reverseTransform(result.value, result);
|
|
2367
|
+
if (transformed instanceof Promise) {
|
|
2368
|
+
return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
|
|
2369
|
+
}
|
|
2370
|
+
return handleCodecTxResult(result, transformed, def.in, ctx);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
2374
|
+
// Check if transform added any issues
|
|
2375
|
+
if (left.issues.length) {
|
|
2376
|
+
left.aborted = true;
|
|
2377
|
+
return left;
|
|
2378
|
+
}
|
|
2379
|
+
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
2380
|
+
}
|
|
2381
|
+
export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess", (inst, def) => {
|
|
2382
|
+
$ZodPipe.init(inst, def);
|
|
2383
|
+
});
|
|
1603
2384
|
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1604
2385
|
$ZodType.init(inst, def);
|
|
1605
|
-
util.
|
|
1606
|
-
util.
|
|
1607
|
-
util.
|
|
1608
|
-
util.
|
|
2386
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2387
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2388
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2389
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
1609
2390
|
inst._zod.parse = (payload, ctx) => {
|
|
2391
|
+
if (ctx.direction === "backward") {
|
|
2392
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2393
|
+
}
|
|
1610
2394
|
const result = def.innerType._zod.run(payload, ctx);
|
|
1611
2395
|
if (result instanceof Promise) {
|
|
1612
2396
|
return result.then(handleReadonlyResult);
|
|
@@ -1615,24 +2399,72 @@ export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (ins
|
|
|
1615
2399
|
};
|
|
1616
2400
|
});
|
|
1617
2401
|
function handleReadonlyResult(payload) {
|
|
1618
|
-
|
|
2402
|
+
// A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
|
|
2403
|
+
if (!payload.memo)
|
|
2404
|
+
payload.value = Object.freeze(payload.value);
|
|
1619
2405
|
return payload;
|
|
1620
2406
|
}
|
|
2407
|
+
// a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
|
|
2408
|
+
function leafPattern(schema) {
|
|
2409
|
+
const def = schema._zod.def;
|
|
2410
|
+
let pattern = def.pattern;
|
|
2411
|
+
let isInt = !!def.format?.includes("int");
|
|
2412
|
+
let minimum;
|
|
2413
|
+
let maximum;
|
|
2414
|
+
for (const ch of def.checks ?? []) {
|
|
2415
|
+
const d = ch._zod.def;
|
|
2416
|
+
if (d.pattern)
|
|
2417
|
+
pattern = d.pattern;
|
|
2418
|
+
isInt || (isInt = !!d.format?.includes("int"));
|
|
2419
|
+
const lo = d.minimum ?? d.length;
|
|
2420
|
+
const hi = d.maximum ?? d.length;
|
|
2421
|
+
if (lo !== undefined && (minimum === undefined || lo > minimum))
|
|
2422
|
+
minimum = lo;
|
|
2423
|
+
if (hi !== undefined && (maximum === undefined || hi < maximum))
|
|
2424
|
+
maximum = hi;
|
|
2425
|
+
}
|
|
2426
|
+
if (pattern)
|
|
2427
|
+
return pattern.source;
|
|
2428
|
+
// an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
|
|
2429
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum)
|
|
2430
|
+
return "(?!)";
|
|
2431
|
+
if (minimum !== undefined || maximum !== undefined)
|
|
2432
|
+
return regexes.string({ minimum, maximum }).source;
|
|
2433
|
+
const own = schema._zod.pattern;
|
|
2434
|
+
return (isInt && own === regexes.number ? regexes.integer : own)?.source;
|
|
2435
|
+
}
|
|
2436
|
+
// a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
|
|
2437
|
+
function partPattern(schema) {
|
|
2438
|
+
const def = schema._zod.def;
|
|
2439
|
+
const own = schema._zod.pattern?.source;
|
|
2440
|
+
// lazy resolves its inner on the internals, not the def
|
|
2441
|
+
const inner = def.innerType ?? schema._zod.innerType;
|
|
2442
|
+
if (inner) {
|
|
2443
|
+
const before = inner._zod.pattern?.source;
|
|
2444
|
+
const after = partPattern(inner);
|
|
2445
|
+
if (own && before && after && after !== before) {
|
|
2446
|
+
return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
|
|
2447
|
+
}
|
|
2448
|
+
return own;
|
|
2449
|
+
}
|
|
2450
|
+
if (def.options) {
|
|
2451
|
+
const sources = def.options.map(partPattern);
|
|
2452
|
+
if (sources.every(Boolean))
|
|
2453
|
+
return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
|
|
2454
|
+
}
|
|
2455
|
+
return leafPattern(schema);
|
|
2456
|
+
}
|
|
1621
2457
|
export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
1622
2458
|
$ZodType.init(inst, def);
|
|
1623
2459
|
const regexParts = [];
|
|
1624
2460
|
for (const part of def.parts) {
|
|
1625
|
-
if (part
|
|
1626
|
-
|
|
1627
|
-
|
|
2461
|
+
if (typeof part === "object" && part !== null) {
|
|
2462
|
+
// is Zod schema
|
|
2463
|
+
const source = partPattern(part);
|
|
2464
|
+
if (!source) {
|
|
1628
2465
|
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
|
1629
2466
|
}
|
|
1630
|
-
|
|
1631
|
-
if (!source)
|
|
1632
|
-
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
1633
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
1634
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
1635
|
-
regexParts.push(source.slice(start, end));
|
|
2467
|
+
regexParts.push(util.cleanRegex(source));
|
|
1636
2468
|
}
|
|
1637
2469
|
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
|
1638
2470
|
regexParts.push(util.escapeRegex(`${part}`));
|
|
@@ -1647,7 +2479,7 @@ export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplate
|
|
|
1647
2479
|
payload.issues.push({
|
|
1648
2480
|
input: payload.value,
|
|
1649
2481
|
inst,
|
|
1650
|
-
expected: "
|
|
2482
|
+
expected: "string",
|
|
1651
2483
|
code: "invalid_type",
|
|
1652
2484
|
});
|
|
1653
2485
|
return payload;
|
|
@@ -1658,7 +2490,7 @@ export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplate
|
|
|
1658
2490
|
input: payload.value,
|
|
1659
2491
|
inst,
|
|
1660
2492
|
code: "invalid_format",
|
|
1661
|
-
format: "template_literal",
|
|
2493
|
+
format: def.format ?? "template_literal",
|
|
1662
2494
|
pattern: inst._zod.pattern.source,
|
|
1663
2495
|
});
|
|
1664
2496
|
return payload;
|
|
@@ -1666,6 +2498,87 @@ export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplate
|
|
|
1666
2498
|
return payload;
|
|
1667
2499
|
};
|
|
1668
2500
|
});
|
|
2501
|
+
export const $ZodFunction = /*@__PURE__*/ core.$constructor("$ZodFunction", (inst, def) => {
|
|
2502
|
+
$ZodType.init(inst, def);
|
|
2503
|
+
// Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
|
|
2504
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
2505
|
+
inst._zod.def = def;
|
|
2506
|
+
inst.implement = (func) => {
|
|
2507
|
+
if (typeof func !== "function") {
|
|
2508
|
+
throw new Error("implement() must be called with a function");
|
|
2509
|
+
}
|
|
2510
|
+
// Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
|
|
2511
|
+
return Object.defineProperty(function (...args) {
|
|
2512
|
+
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
|
2513
|
+
const result = Reflect.apply(func, this, parsedArgs);
|
|
2514
|
+
if (inst._def.output) {
|
|
2515
|
+
return parse(inst._def.output, result);
|
|
2516
|
+
}
|
|
2517
|
+
return result;
|
|
2518
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
2519
|
+
};
|
|
2520
|
+
inst.implementAsync = (func) => {
|
|
2521
|
+
if (typeof func !== "function") {
|
|
2522
|
+
throw new Error("implementAsync() must be called with a function");
|
|
2523
|
+
}
|
|
2524
|
+
return Object.defineProperty(async function (...args) {
|
|
2525
|
+
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
|
|
2526
|
+
const result = await Reflect.apply(func, this, parsedArgs);
|
|
2527
|
+
if (inst._def.output) {
|
|
2528
|
+
return await parseAsync(inst._def.output, result);
|
|
2529
|
+
}
|
|
2530
|
+
return result;
|
|
2531
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
2532
|
+
};
|
|
2533
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2534
|
+
if (typeof payload.value !== "function") {
|
|
2535
|
+
payload.issues.push({
|
|
2536
|
+
code: "invalid_type",
|
|
2537
|
+
expected: "function",
|
|
2538
|
+
input: payload.value,
|
|
2539
|
+
inst,
|
|
2540
|
+
});
|
|
2541
|
+
return payload;
|
|
2542
|
+
}
|
|
2543
|
+
// Check if output is a promise type to determine if we should use async implementation
|
|
2544
|
+
const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
|
|
2545
|
+
if (hasPromiseOutput) {
|
|
2546
|
+
payload.value = inst.implementAsync(payload.value);
|
|
2547
|
+
}
|
|
2548
|
+
else {
|
|
2549
|
+
payload.value = inst.implement(payload.value);
|
|
2550
|
+
}
|
|
2551
|
+
return payload;
|
|
2552
|
+
};
|
|
2553
|
+
inst.input = (...args) => {
|
|
2554
|
+
const F = inst.constructor;
|
|
2555
|
+
if (Array.isArray(args[0])) {
|
|
2556
|
+
return new F({
|
|
2557
|
+
type: "function",
|
|
2558
|
+
input: new $ZodTuple({
|
|
2559
|
+
type: "tuple",
|
|
2560
|
+
items: args[0],
|
|
2561
|
+
rest: args[1],
|
|
2562
|
+
}),
|
|
2563
|
+
output: inst._def.output,
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
return new F({
|
|
2567
|
+
type: "function",
|
|
2568
|
+
input: args[0],
|
|
2569
|
+
output: inst._def.output,
|
|
2570
|
+
});
|
|
2571
|
+
};
|
|
2572
|
+
inst.output = (output) => {
|
|
2573
|
+
const F = inst.constructor;
|
|
2574
|
+
return new F({
|
|
2575
|
+
type: "function",
|
|
2576
|
+
input: inst._def.input,
|
|
2577
|
+
output,
|
|
2578
|
+
});
|
|
2579
|
+
};
|
|
2580
|
+
return inst;
|
|
2581
|
+
});
|
|
1669
2582
|
export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst, def) => {
|
|
1670
2583
|
$ZodType.init(inst, def);
|
|
1671
2584
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1674,11 +2587,17 @@ export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst,
|
|
|
1674
2587
|
});
|
|
1675
2588
|
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
1676
2589
|
$ZodType.init(inst, def);
|
|
1677
|
-
|
|
1678
|
-
util.defineLazy(inst._zod, "
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
2590
|
+
// Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
|
|
2591
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
2592
|
+
const d = def;
|
|
2593
|
+
if (!d._cachedInner)
|
|
2594
|
+
d._cachedInner = def.getter();
|
|
2595
|
+
return d._cachedInner;
|
|
2596
|
+
});
|
|
2597
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
|
|
2598
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
|
|
2599
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
|
|
2600
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
|
|
1682
2601
|
inst._zod.parse = (payload, ctx) => {
|
|
1683
2602
|
const inner = inst._zod.innerType;
|
|
1684
2603
|
return inner._zod.run(payload, ctx);
|