@psnext/slingcli 3.1.20260904-1 → 3.3.20260914-1
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/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +5 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/util/hasOwn.js +3 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/util/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/util/hasOwn.d.ts +4 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/util/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/hasOwn.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/util/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-PBNSMEG7.js → chunk-BRL3MDQL.js} +10 -10
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/index.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/rpc-entry.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js +79 -32
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/Client.md +25 -8
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +3 -2
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/EventSource.md +4 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/Interceptors.md +7 -3
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +7 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/api/readable.js +33 -43
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/cache/memory-cache-store.js +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/core/connect.js +16 -2
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/core/symbols.js +3 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/agent.js +7 -2
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/balanced-pool.js +7 -4
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h1.js +9 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client-h2.js +221 -12
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/client.js +76 -30
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/dispatcher-base.js +13 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/dispatcher.js +15 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +37 -8
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/retry-agent.js +3 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/round-robin-pool.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +106 -22
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/cache-handler.js +29 -5
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/decorator-handler.js +7 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/deduplication-handler.js +12 -6
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/redirect-handler.js +21 -4
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/handler/retry-handler.js +155 -32
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/cache.js +65 -9
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/decompress.js +115 -13
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/deduplicate.js +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/dns.js +7 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/mock/mock-agent.js +13 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/mock/mock-utils.js +217 -27
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/util/cache.js +43 -3
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/cookies/parse.js +150 -147
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/eventsource/eventsource-stream.js +28 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/eventsource/eventsource.js +13 -3
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/fetch/index.js +6 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/fetch/request.js +2 -3
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/fetch/util.js +6 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/webidl/index.js +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/connection.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/lib/web/websocket/websocket.js +22 -0
- package/node_modules/@earendil-works/pi-coding-agent/node_modules/undici/package.json +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +4 -4
- package/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/errors/index.js +20 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +11 -10
- package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +11 -10
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +2 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +25 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/errors/errors.js +18 -0
- package/node_modules/@smithy/core/dist-es/submodules/errors/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/retry/service-error-classification/service-error-classification.js +11 -10
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/getAwsChunkedEncodingStream.browser.js +2 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/getAwsChunkedEncodingStream.js +23 -8
- package/node_modules/@smithy/core/dist-types/submodules/errors/errors.d.ts +44 -0
- package/node_modules/@smithy/core/dist-types/submodules/errors/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/retry/service-error-classification/service-error-classification.d.ts +4 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/errors/errors.d.ts +44 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/errors/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/service-error-classification/service-error-classification.d.ts +4 -0
- package/node_modules/@smithy/core/errors.d.ts +5 -0
- package/node_modules/@smithy/core/errors.js +5 -0
- package/node_modules/@smithy/core/package.json +11 -2
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.d.ts +1 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +4 -4
- package/node_modules/@types/node/http.d.ts +1 -1
- package/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/node/perf_hooks.d.ts +31 -19
- package/node_modules/@types/node/quic.d.ts +6 -4
- package/node_modules/@types/node/stream/web.d.ts +20 -0
- package/node_modules/@types/node/tls.d.ts +26 -15
- package/node_modules/@types/node/vfs.d.ts +7 -6
- package/node_modules/@types/node/web-globals/streams.d.ts +4 -0
- package/node_modules/@types/node/zlib.d.ts +17 -0
- package/node_modules/hono/dist/cjs/client/client.js +4 -4
- package/node_modules/hono/dist/cjs/hono-base.js +7 -6
- package/node_modules/hono/dist/cjs/jsx/base.js +18 -1
- package/node_modules/hono/dist/cjs/jsx/components.js +25 -26
- package/node_modules/hono/dist/cjs/jsx/context.js +5 -5
- package/node_modules/hono/dist/cjs/jsx/dom/server.js +5 -1
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +2 -2
- package/node_modules/hono/dist/cjs/jsx/streaming.js +4 -5
- package/node_modules/hono/dist/client/client.js +4 -4
- package/node_modules/hono/dist/hono-base.js +7 -6
- package/node_modules/hono/dist/jsx/base.js +15 -1
- package/node_modules/hono/dist/jsx/components.js +26 -27
- package/node_modules/hono/dist/jsx/context.js +6 -6
- package/node_modules/hono/dist/jsx/dom/server.js +5 -1
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +3 -3
- package/node_modules/hono/dist/jsx/streaming.js +5 -6
- package/node_modules/hono/dist/types/context.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/base.d.ts +3 -0
- package/node_modules/hono/package.json +2 -2
- package/node_modules/jose/dist/types/index.d.ts +1 -2
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +7 -11
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +13 -16
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +7 -11
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +16 -19
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +10 -16
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +18 -21
- package/node_modules/jose/dist/types/jwk/embedded.d.ts +3 -1
- package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +4 -6
- package/node_modules/jose/dist/types/jwks/local.d.ts +5 -4
- package/node_modules/jose/dist/types/jwks/remote.d.ts +20 -21
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +4 -4
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +8 -11
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +5 -5
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +8 -11
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +10 -14
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +11 -17
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +14 -11
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +24 -22
- package/node_modules/jose/dist/types/jwt/sign.d.ts +3 -7
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -6
- package/node_modules/jose/dist/types/jwt/verify.d.ts +13 -6
- package/node_modules/jose/dist/types/key/export.d.ts +6 -6
- package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +9 -14
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +10 -10
- package/node_modules/jose/dist/types/key/import.d.ts +19 -18
- package/node_modules/jose/dist/types/types.d.ts +152 -247
- package/node_modules/jose/dist/types/util/base64url.d.ts +7 -7
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +6 -1
- package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +4 -3
- package/node_modules/jose/dist/types/util/errors.d.ts +29 -40
- package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +1 -2
- package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +9 -26
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +3 -3
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +11 -30
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +6 -6
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +33 -57
- package/node_modules/jose/dist/webapi/jwk/embedded.js +3 -4
- package/node_modules/jose/dist/webapi/jwk/thumbprint.js +3 -6
- package/node_modules/jose/dist/webapi/jwks/local.js +16 -10
- package/node_modules/jose/dist/webapi/jwks/remote.js +2 -2
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +2 -4
- package/node_modules/jose/dist/webapi/jws/compact/verify.js +2 -2
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +8 -15
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +4 -14
- package/node_modules/jose/dist/webapi/jws/general/sign.js +4 -11
- package/node_modules/jose/dist/webapi/jws/general/verify.js +5 -7
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +2 -3
- package/node_modules/jose/dist/webapi/jwt/encrypt.js +11 -25
- package/node_modules/jose/dist/webapi/jwt/sign.js +1 -1
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +1 -2
- package/node_modules/jose/dist/webapi/jwt/verify.js +4 -4
- package/node_modules/jose/dist/webapi/key/export.js +12 -16
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +4 -13
- package/node_modules/jose/dist/webapi/key/generate_secret.js +1 -1
- package/node_modules/jose/dist/webapi/key/import.js +5 -9
- package/node_modules/jose/dist/webapi/lib/asn1.js +2 -4
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +35 -0
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +21 -29
- package/node_modules/jose/dist/webapi/lib/deflate.js +9 -19
- package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +0 -4
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +21 -54
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +26 -59
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +29 -43
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +37 -45
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +1 -1
- package/node_modules/jose/dist/webapi/lib/key.js +119 -59
- package/node_modules/jose/dist/webapi/lib/key_management.js +45 -80
- package/node_modules/jose/dist/webapi/lib/{options.js → validate.js} +64 -3
- package/node_modules/jose/dist/webapi/util/base64url.js +5 -19
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +1 -1
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +1 -1
- package/node_modules/jose/package.json +1 -1
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +4 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +70 -14
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/handler/cache-handler.js +21 -5
- package/node_modules/undici/lib/handler/retry-handler.js +42 -7
- package/node_modules/undici/lib/interceptor/cache.js +20 -1
- package/node_modules/undici/lib/interceptor/decompress.js +146 -14
- package/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
- package/node_modules/undici/lib/web/websocket/connection.js +1 -1
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/interceptors.d.ts +2 -0
- package/node_modules/undici-types/client.d.ts +8 -3
- package/node_modules/undici-types/connector.d.ts +1 -0
- package/node_modules/undici-types/cookies.d.ts +1 -1
- package/node_modules/undici-types/dispatcher.d.ts +3 -3
- package/node_modules/undici-types/errors.d.ts +10 -0
- package/node_modules/undici-types/fetch.d.ts +5 -1
- package/node_modules/undici-types/handlers.d.ts +2 -0
- package/node_modules/undici-types/interceptors.d.ts +1 -1
- package/node_modules/undici-types/mock-interceptor.d.ts +5 -1
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/proxy-agent.d.ts +7 -0
- package/node_modules/zod/README.md +2 -2
- package/node_modules/zod/compile.cjs +19 -0
- package/node_modules/zod/index.cjs +19 -0
- package/node_modules/zod/locales/index.cjs +19 -0
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/package.json +8 -7
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v4/classic/external.ts +2 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +248 -25
- package/node_modules/zod/src/v4/classic/schemas.ts +243 -168
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +60 -9
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +6 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +265 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +112 -6
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +130 -1
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +157 -0
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +40 -2
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +27 -7
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +88 -56
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +56 -0
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +3 -2
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +46 -1
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +95 -1
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +33 -1
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +234 -38
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +569 -0
- package/node_modules/zod/src/v4/core/api.ts +44 -28
- package/node_modules/zod/src/v4/core/checks.ts +62 -102
- package/node_modules/zod/src/v4/core/compile.ts +218 -93
- package/node_modules/zod/src/v4/core/core.ts +1 -3
- package/node_modules/zod/src/v4/core/doc.ts +6 -2
- package/node_modules/zod/src/v4/core/errors.ts +3 -6
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +2 -2
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +185 -81
- package/node_modules/zod/src/v4/core/memoizer.ts +75 -28
- package/node_modules/zod/src/v4/core/parse.ts +37 -16
- package/node_modules/zod/src/v4/core/regexes.ts +14 -4
- package/node_modules/zod/src/v4/core/schemas.ts +296 -132
- 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 +35 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +399 -2
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +118 -16
- package/node_modules/zod/src/v4/core/to-json-schema.ts +9 -7
- package/node_modules/zod/src/v4/core/util.ts +218 -147
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/locales/ar.ts +2 -0
- package/node_modules/zod/src/v4/locales/az.ts +2 -0
- package/node_modules/zod/src/v4/locales/be.ts +2 -0
- package/node_modules/zod/src/v4/locales/bg.ts +2 -0
- package/node_modules/zod/src/v4/locales/bn.ts +2 -0
- package/node_modules/zod/src/v4/locales/ca.ts +2 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +2 -0
- package/node_modules/zod/src/v4/locales/cs.ts +2 -0
- package/node_modules/zod/src/v4/locales/da.ts +2 -0
- package/node_modules/zod/src/v4/locales/de.ts +2 -0
- package/node_modules/zod/src/v4/locales/el.ts +2 -0
- package/node_modules/zod/src/v4/locales/en.ts +2 -0
- package/node_modules/zod/src/v4/locales/eo.ts +2 -0
- package/node_modules/zod/src/v4/locales/es.ts +2 -0
- package/node_modules/zod/src/v4/locales/fa.ts +2 -0
- package/node_modules/zod/src/v4/locales/fi.ts +2 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +2 -0
- package/node_modules/zod/src/v4/locales/fr.ts +2 -0
- package/node_modules/zod/src/v4/locales/gu.ts +2 -0
- package/node_modules/zod/src/v4/locales/he.ts +2 -0
- package/node_modules/zod/src/v4/locales/hi.ts +2 -0
- package/node_modules/zod/src/v4/locales/hr.ts +2 -0
- package/node_modules/zod/src/v4/locales/hu.ts +2 -0
- package/node_modules/zod/src/v4/locales/hy.ts +2 -0
- package/node_modules/zod/src/v4/locales/id.ts +2 -0
- package/node_modules/zod/src/v4/locales/index.ts +1 -0
- package/node_modules/zod/src/v4/locales/is.ts +2 -0
- package/node_modules/zod/src/v4/locales/it.ts +2 -0
- package/node_modules/zod/src/v4/locales/ja.ts +2 -0
- package/node_modules/zod/src/v4/locales/ka.ts +2 -0
- package/node_modules/zod/src/v4/locales/km.ts +2 -0
- package/node_modules/zod/src/v4/locales/kn.ts +2 -0
- package/node_modules/zod/src/v4/locales/ko.ts +2 -0
- package/node_modules/zod/src/v4/locales/lt.ts +2 -0
- package/node_modules/zod/src/v4/locales/mk.ts +2 -0
- package/node_modules/zod/src/v4/locales/ms.ts +2 -0
- package/node_modules/zod/src/v4/locales/ne.ts +2 -0
- package/node_modules/zod/src/v4/locales/nl.ts +2 -0
- package/node_modules/zod/src/v4/locales/nn.ts +2 -0
- package/node_modules/zod/src/v4/locales/no.ts +2 -0
- package/node_modules/zod/src/v4/locales/ota.ts +2 -0
- package/node_modules/zod/src/v4/locales/pl.ts +2 -0
- package/node_modules/zod/src/v4/locales/ps.ts +2 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +2 -0
- package/node_modules/zod/src/v4/locales/pt.ts +2 -0
- package/node_modules/zod/src/v4/locales/ro.ts +2 -0
- package/node_modules/zod/src/v4/locales/ru.ts +2 -0
- package/node_modules/zod/src/v4/locales/sk.ts +2 -0
- package/node_modules/zod/src/v4/locales/sl.ts +2 -0
- package/node_modules/zod/src/v4/locales/sv.ts +2 -0
- package/node_modules/zod/src/v4/locales/ta.ts +2 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +2 -0
- package/node_modules/zod/src/v4/locales/tk.ts +2 -0
- package/node_modules/zod/src/v4/locales/tr.ts +2 -0
- package/node_modules/zod/src/v4/locales/uk.ts +2 -0
- package/node_modules/zod/src/v4/locales/ur.ts +2 -0
- package/node_modules/zod/src/v4/locales/uz.ts +2 -0
- package/node_modules/zod/src/v4/locales/vi.ts +2 -0
- package/node_modules/zod/src/v4/locales/yo.ts +2 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +2 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +2 -0
- package/node_modules/zod/src/v4/mini/external.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +32 -7
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +1 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +86 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +16 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +23 -0
- package/node_modules/zod/v3/ZodError.cjs +19 -0
- 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/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +19 -0
- package/node_modules/zod/v4/classic/checks.cjs +19 -0
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +19 -0
- package/node_modules/zod/v4/classic/deep-partial.cjs +19 -0
- package/node_modules/zod/v4/classic/errors.cjs +19 -0
- package/node_modules/zod/v4/classic/external.cjs +22 -1
- package/node_modules/zod/v4/classic/external.d.cts +1 -1
- package/node_modules/zod/v4/classic/external.d.ts +1 -1
- package/node_modules/zod/v4/classic/external.js +1 -1
- package/node_modules/zod/v4/classic/from-json-schema.cjs +264 -24
- package/node_modules/zod/v4/classic/from-json-schema.js +245 -24
- package/node_modules/zod/v4/classic/in-out.cjs +19 -0
- package/node_modules/zod/v4/classic/index.cjs +19 -0
- package/node_modules/zod/v4/classic/iso.cjs +19 -0
- package/node_modules/zod/v4/classic/parse.cjs +19 -0
- package/node_modules/zod/v4/classic/schemas.cjs +100 -35
- package/node_modules/zod/v4/classic/schemas.d.cts +15 -1
- package/node_modules/zod/v4/classic/schemas.d.ts +15 -1
- package/node_modules/zod/v4/classic/schemas.js +77 -33
- package/node_modules/zod/v4/core/api.cjs +45 -22
- package/node_modules/zod/v4/core/api.d.cts +12 -6
- package/node_modules/zod/v4/core/api.d.ts +12 -6
- package/node_modules/zod/v4/core/api.js +25 -22
- package/node_modules/zod/v4/core/checks.cjs +51 -97
- package/node_modules/zod/v4/core/checks.d.cts +17 -1
- package/node_modules/zod/v4/core/checks.d.ts +17 -1
- package/node_modules/zod/v4/core/checks.js +31 -96
- package/node_modules/zod/v4/core/compile.cjs +173 -78
- package/node_modules/zod/v4/core/compile.d.cts +18 -4
- package/node_modules/zod/v4/core/compile.d.ts +18 -4
- package/node_modules/zod/v4/core/compile.js +154 -79
- package/node_modules/zod/v4/core/core.cjs +20 -1
- package/node_modules/zod/v4/core/core.js +1 -1
- package/node_modules/zod/v4/core/doc.cjs +26 -2
- package/node_modules/zod/v4/core/doc.js +7 -2
- package/node_modules/zod/v4/core/errors.cjs +21 -5
- package/node_modules/zod/v4/core/errors.js +2 -5
- package/node_modules/zod/v4/core/index.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +20 -1
- package/node_modules/zod/v4/core/json-schema-generator.js +2 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +188 -72
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +170 -74
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/memoizer.cjs +111 -23
- package/node_modules/zod/v4/core/memoizer.js +69 -23
- package/node_modules/zod/v4/core/parse.cjs +56 -16
- package/node_modules/zod/v4/core/parse.js +37 -16
- package/node_modules/zod/v4/core/regexes.cjs +31 -6
- package/node_modules/zod/v4/core/regexes.d.cts +3 -0
- package/node_modules/zod/v4/core/regexes.d.ts +3 -0
- package/node_modules/zod/v4/core/regexes.js +10 -4
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/schemas.cjs +302 -114
- package/node_modules/zod/v4/core/schemas.d.cts +28 -8
- package/node_modules/zod/v4/core/schemas.d.ts +28 -8
- package/node_modules/zod/v4/core/schemas.js +279 -113
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +28 -7
- package/node_modules/zod/v4/core/to-json-schema.d.cts +4 -3
- package/node_modules/zod/v4/core/to-json-schema.d.ts +4 -3
- package/node_modules/zod/v4/core/to-json-schema.js +7 -6
- package/node_modules/zod/v4/core/util.cjs +177 -143
- package/node_modules/zod/v4/core/util.d.cts +25 -4
- package/node_modules/zod/v4/core/util.d.ts +25 -4
- package/node_modules/zod/v4/core/util.js +156 -143
- 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 +19 -0
- package/node_modules/zod/v4/index.cjs +19 -0
- package/node_modules/zod/v4/locales/ar.cjs +2 -0
- package/node_modules/zod/v4/locales/ar.js +2 -0
- package/node_modules/zod/v4/locales/az.cjs +2 -0
- package/node_modules/zod/v4/locales/az.js +2 -0
- package/node_modules/zod/v4/locales/be.cjs +2 -0
- package/node_modules/zod/v4/locales/be.js +2 -0
- package/node_modules/zod/v4/locales/bg.cjs +2 -0
- package/node_modules/zod/v4/locales/bg.js +2 -0
- package/node_modules/zod/v4/locales/bn.cjs +2 -0
- package/node_modules/zod/v4/locales/bn.js +2 -0
- package/node_modules/zod/v4/locales/ca.cjs +2 -0
- package/node_modules/zod/v4/locales/ca.js +2 -0
- package/node_modules/zod/v4/locales/ckb.cjs +2 -0
- package/node_modules/zod/v4/locales/ckb.js +2 -0
- package/node_modules/zod/v4/locales/cs.cjs +2 -0
- package/node_modules/zod/v4/locales/cs.js +2 -0
- package/node_modules/zod/v4/locales/da.cjs +2 -0
- package/node_modules/zod/v4/locales/da.js +2 -0
- package/node_modules/zod/v4/locales/de.cjs +2 -0
- package/node_modules/zod/v4/locales/de.js +2 -0
- package/node_modules/zod/v4/locales/el.cjs +2 -0
- package/node_modules/zod/v4/locales/el.js +2 -0
- package/node_modules/zod/v4/locales/en.cjs +2 -0
- package/node_modules/zod/v4/locales/en.js +2 -0
- package/node_modules/zod/v4/locales/eo.cjs +2 -0
- package/node_modules/zod/v4/locales/eo.js +2 -0
- package/node_modules/zod/v4/locales/es.cjs +2 -0
- package/node_modules/zod/v4/locales/es.js +2 -0
- package/node_modules/zod/v4/locales/fa.cjs +2 -0
- package/node_modules/zod/v4/locales/fa.js +2 -0
- package/node_modules/zod/v4/locales/fi.cjs +2 -0
- package/node_modules/zod/v4/locales/fi.js +2 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +2 -0
- package/node_modules/zod/v4/locales/fr-CA.js +2 -0
- package/node_modules/zod/v4/locales/fr.cjs +2 -0
- package/node_modules/zod/v4/locales/fr.js +2 -0
- package/node_modules/zod/v4/locales/gu.cjs +2 -0
- package/node_modules/zod/v4/locales/gu.js +2 -0
- package/node_modules/zod/v4/locales/he.cjs +2 -0
- package/node_modules/zod/v4/locales/he.js +2 -0
- package/node_modules/zod/v4/locales/hi.cjs +2 -0
- package/node_modules/zod/v4/locales/hi.js +2 -0
- package/node_modules/zod/v4/locales/hr.cjs +2 -0
- package/node_modules/zod/v4/locales/hr.js +2 -0
- package/node_modules/zod/v4/locales/hu.cjs +2 -0
- package/node_modules/zod/v4/locales/hu.js +2 -0
- package/node_modules/zod/v4/locales/hy.cjs +2 -0
- package/node_modules/zod/v4/locales/hy.js +2 -0
- package/node_modules/zod/v4/locales/id.cjs +2 -0
- package/node_modules/zod/v4/locales/id.js +2 -0
- package/node_modules/zod/v4/locales/index.cjs +22 -1
- package/node_modules/zod/v4/locales/index.d.cts +1 -0
- package/node_modules/zod/v4/locales/index.d.ts +1 -0
- package/node_modules/zod/v4/locales/index.js +1 -0
- package/node_modules/zod/v4/locales/is.cjs +2 -0
- package/node_modules/zod/v4/locales/is.js +2 -0
- package/node_modules/zod/v4/locales/it.cjs +2 -0
- package/node_modules/zod/v4/locales/it.js +2 -0
- package/node_modules/zod/v4/locales/ja.cjs +2 -0
- package/node_modules/zod/v4/locales/ja.js +2 -0
- package/node_modules/zod/v4/locales/ka.cjs +2 -0
- package/node_modules/zod/v4/locales/ka.js +2 -0
- package/node_modules/zod/v4/locales/km.cjs +2 -0
- package/node_modules/zod/v4/locales/km.js +2 -0
- package/node_modules/zod/v4/locales/kn.cjs +2 -0
- package/node_modules/zod/v4/locales/kn.js +2 -0
- package/node_modules/zod/v4/locales/ko.cjs +2 -0
- package/node_modules/zod/v4/locales/ko.js +2 -0
- package/node_modules/zod/v4/locales/lt.cjs +2 -0
- package/node_modules/zod/v4/locales/lt.js +2 -0
- package/node_modules/zod/v4/locales/mk.cjs +2 -0
- package/node_modules/zod/v4/locales/mk.js +2 -0
- package/node_modules/zod/v4/locales/ms.cjs +2 -0
- package/node_modules/zod/v4/locales/ms.js +2 -0
- package/node_modules/zod/v4/locales/ne.cjs +2 -0
- package/node_modules/zod/v4/locales/ne.js +2 -0
- package/node_modules/zod/v4/locales/nl.cjs +2 -0
- package/node_modules/zod/v4/locales/nl.js +2 -0
- package/node_modules/zod/v4/locales/nn.cjs +2 -0
- package/node_modules/zod/v4/locales/nn.js +2 -0
- package/node_modules/zod/v4/locales/no.cjs +2 -0
- package/node_modules/zod/v4/locales/no.js +2 -0
- package/node_modules/zod/v4/locales/ota.cjs +2 -0
- package/node_modules/zod/v4/locales/ota.js +2 -0
- package/node_modules/zod/v4/locales/pl.cjs +2 -0
- package/node_modules/zod/v4/locales/pl.js +2 -0
- package/node_modules/zod/v4/locales/ps.cjs +2 -0
- package/node_modules/zod/v4/locales/ps.js +2 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +2 -0
- package/node_modules/zod/v4/locales/pt-BR.js +2 -0
- package/node_modules/zod/v4/locales/pt.cjs +2 -0
- package/node_modules/zod/v4/locales/pt.js +2 -0
- package/node_modules/zod/v4/locales/ro.cjs +2 -0
- package/node_modules/zod/v4/locales/ro.js +2 -0
- package/node_modules/zod/v4/locales/ru.cjs +2 -0
- package/node_modules/zod/v4/locales/ru.js +2 -0
- package/node_modules/zod/v4/locales/sk.cjs +2 -0
- package/node_modules/zod/v4/locales/sk.js +2 -0
- package/node_modules/zod/v4/locales/sl.cjs +2 -0
- package/node_modules/zod/v4/locales/sl.js +2 -0
- package/node_modules/zod/v4/locales/sv.cjs +2 -0
- package/node_modules/zod/v4/locales/sv.js +2 -0
- package/node_modules/zod/v4/locales/ta.cjs +2 -0
- package/node_modules/zod/v4/locales/ta.js +2 -0
- 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 +2 -0
- package/node_modules/zod/v4/locales/th.js +2 -0
- package/node_modules/zod/v4/locales/tk.cjs +2 -0
- package/node_modules/zod/v4/locales/tk.js +2 -0
- package/node_modules/zod/v4/locales/tr.cjs +2 -0
- package/node_modules/zod/v4/locales/tr.js +2 -0
- package/node_modules/zod/v4/locales/uk.cjs +2 -0
- package/node_modules/zod/v4/locales/uk.js +2 -0
- package/node_modules/zod/v4/locales/ur.cjs +2 -0
- package/node_modules/zod/v4/locales/ur.js +2 -0
- package/node_modules/zod/v4/locales/uz.cjs +2 -0
- package/node_modules/zod/v4/locales/uz.js +2 -0
- package/node_modules/zod/v4/locales/vi.cjs +2 -0
- package/node_modules/zod/v4/locales/vi.js +2 -0
- package/node_modules/zod/v4/locales/yo.cjs +2 -0
- package/node_modules/zod/v4/locales/yo.js +2 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +2 -0
- package/node_modules/zod/v4/locales/zh-CN.js +2 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +2 -0
- package/node_modules/zod/v4/locales/zh-TW.js +2 -0
- package/node_modules/zod/v4/mini/checks.cjs +19 -0
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +19 -0
- package/node_modules/zod/v4/mini/external.cjs +22 -1
- package/node_modules/zod/v4/mini/external.d.cts +1 -1
- package/node_modules/zod/v4/mini/external.d.ts +1 -1
- package/node_modules/zod/v4/mini/external.js +1 -1
- package/node_modules/zod/v4/mini/in-out.cjs +19 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +19 -0
- package/node_modules/zod/v4/mini/parse.cjs +19 -0
- package/node_modules/zod/v4/mini/schemas.cjs +44 -8
- package/node_modules/zod/v4/mini/schemas.d.cts +6 -1
- package/node_modules/zod/v4/mini/schemas.d.ts +6 -1
- package/node_modules/zod/v4/mini/schemas.js +21 -6
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/package.json +2 -2
- package/slingshot/index.js +201 -198
- package/node_modules/jose/dist/webapi/lib/base64.js +0 -20
- package/node_modules/jose/dist/webapi/lib/crypto_key.js +0 -27
- package/node_modules/jose/dist/webapi/lib/helpers.js +0 -45
- package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -12
- package/node_modules/jose/dist/webapi/lib/is_key_like.js +0 -19
- package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +0 -19
- package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +0 -10
- package/node_modules/jose/dist/webapi/lib/key_options.js +0 -8
- package/node_modules/jose/dist/webapi/lib/signing.js +0 -22
- package/node_modules/jose/dist/webapi/lib/type_checks.js +0 -30
|
@@ -5,7 +5,7 @@ import * as core from "./core.js";
|
|
|
5
5
|
import { Doc } from "./doc.js";
|
|
6
6
|
import type * as errors from "./errors.js";
|
|
7
7
|
import type * as JSONSchema from "./json-schema.js";
|
|
8
|
-
import { parse, parseAsync
|
|
8
|
+
import { parse, parseAsync } from "./parse.js";
|
|
9
9
|
import * as regexes from "./regexes.js";
|
|
10
10
|
import type { StandardSchemaV1 } from "./standard-schema.js";
|
|
11
11
|
import type { ProcessParams, ToJSONSchemaContext } from "./to-json-schema.js";
|
|
@@ -30,6 +30,8 @@ export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> ex
|
|
|
30
30
|
readonly async?: boolean | undefined;
|
|
31
31
|
readonly direction?: "forward" | "backward";
|
|
32
32
|
readonly skipChecks?: boolean;
|
|
33
|
+
/** Set only by `validate`/`validateAsync`. A container may stop before its next child, never inside one, so a map entry and a tuple's fixed items parse whole. */
|
|
34
|
+
readonly abortEarly?: boolean;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/** Gives a container cycle support: `attach` wraps its parse, and `alloc` registers the object it builds into before any child is parsed so a reference back to the same input resolves to it. */
|
|
@@ -332,17 +334,25 @@ export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constru
|
|
|
332
334
|
);
|
|
333
335
|
|
|
334
336
|
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
335
|
-
|
|
336
|
-
|
|
337
|
+
// 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
|
|
338
|
+
const toStandardResult = (r: ParsePayload, ctx: ParseContextInternal) =>
|
|
339
|
+
r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
|
|
340
|
+
|
|
341
|
+
async function validateAsync(inst: $ZodType, value: unknown) {
|
|
342
|
+
const ctx: ParseContextInternal = { async: true };
|
|
343
|
+
return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)) as ParsePayload, ctx);
|
|
344
|
+
}
|
|
337
345
|
|
|
338
346
|
export function standardProps(inst: $ZodType): StandardSchemaV1.Props<any, any> {
|
|
339
347
|
return {
|
|
340
348
|
validate: (value: unknown) => {
|
|
349
|
+
const ctx: ParseContextInternal = { async: false };
|
|
341
350
|
try {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
351
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
352
|
+
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
|
|
353
|
+
} catch (_) {}
|
|
354
|
+
// async function so a synchronously throwing check rejects instead of escaping validate
|
|
355
|
+
return validateAsync(inst, value);
|
|
346
356
|
},
|
|
347
357
|
vendor: "zod",
|
|
348
358
|
version: 1 as const,
|
|
@@ -388,7 +398,8 @@ export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInterna
|
|
|
388
398
|
|
|
389
399
|
export const $ZodString: core.$constructor<$ZodString> = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
|
390
400
|
$ZodType.init(inst, def);
|
|
391
|
-
|
|
401
|
+
// a format's own pattern, else unbounded; a template literal derives the check-aware form itself
|
|
402
|
+
inst._zod.pattern = (def as $ZodStringFormatDef).pattern ?? regexes.anyString;
|
|
392
403
|
inst._zod.parse = (payload, _) => {
|
|
393
404
|
if (def.coerce)
|
|
394
405
|
try {
|
|
@@ -511,10 +522,30 @@ export interface $ZodURL extends $ZodType {
|
|
|
511
522
|
|
|
512
523
|
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
513
524
|
export const URL_BAD_FORMAT = 1;
|
|
514
|
-
/** The URL
|
|
525
|
+
/** The URL parser rejected the input. */
|
|
515
526
|
export const URL_UNPARSEABLE = 2;
|
|
516
527
|
|
|
517
|
-
|
|
528
|
+
export function canParseURL(input: string): boolean {
|
|
529
|
+
try {
|
|
530
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
531
|
+
new URL(input);
|
|
532
|
+
return true;
|
|
533
|
+
} catch {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export function validateURL(
|
|
539
|
+
trimmed: string,
|
|
540
|
+
def: Pick<$ZodURLDef, "protocol" | "hostname" | "normalize">
|
|
541
|
+
): URL | true | typeof URL_BAD_FORMAT | typeof URL_UNPARSEABLE {
|
|
542
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
543
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
544
|
+
}
|
|
545
|
+
return parseURLObject(trimmed, def);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
518
549
|
export function parseURLObject(
|
|
519
550
|
trimmed: string,
|
|
520
551
|
def: Pick<$ZodURLDef, "protocol" | "normalize">
|
|
@@ -525,6 +556,10 @@ export function parseURLObject(
|
|
|
525
556
|
}
|
|
526
557
|
|
|
527
558
|
try {
|
|
559
|
+
if (typeof URL !== "undefined") {
|
|
560
|
+
const URLStatic = URL as typeof URL & { parse?: (input: string) => URL | null };
|
|
561
|
+
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
562
|
+
}
|
|
528
563
|
// @ts-ignore
|
|
529
564
|
return new URL(trimmed);
|
|
530
565
|
} catch {
|
|
@@ -555,7 +590,7 @@ export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$construct
|
|
|
555
590
|
try {
|
|
556
591
|
// Trim whitespace from input
|
|
557
592
|
const trimmed = payload.value.trim();
|
|
558
|
-
const url =
|
|
593
|
+
const url = validateURL(trimmed, def);
|
|
559
594
|
|
|
560
595
|
if (url === URL_BAD_FORMAT) {
|
|
561
596
|
payload.issues.push({
|
|
@@ -580,6 +615,11 @@ export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$construct
|
|
|
580
615
|
return;
|
|
581
616
|
}
|
|
582
617
|
|
|
618
|
+
if (url === true) {
|
|
619
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
|
|
583
623
|
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
584
624
|
payload.issues.push({
|
|
585
625
|
code: "invalid_format",
|
|
@@ -777,14 +817,6 @@ export const $ZodISODateTime: core.$constructor<$ZodISODateTime> = /*@__PURE__*/
|
|
|
777
817
|
(inst, def): void => {
|
|
778
818
|
def.pattern ??= regexes.datetime(def);
|
|
779
819
|
$ZodStringFormat.init(inst, def);
|
|
780
|
-
|
|
781
|
-
// these two drop the offset or seconds `date-time` requires — on the bag not the def, since `z.string().check(...)` lands the format on a different schema
|
|
782
|
-
if (def.local || def.precision === -1) {
|
|
783
|
-
inst._zod.bag.laxFormat = true;
|
|
784
|
-
inst._zod.onattach.push((s) => {
|
|
785
|
-
(s._zod.bag as $ZodStringInternals<unknown>["bag"]).laxFormat = true;
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
820
|
}
|
|
789
821
|
);
|
|
790
822
|
|
|
@@ -861,8 +893,6 @@ export interface $ZodIPv4 extends $ZodType {
|
|
|
861
893
|
export const $ZodIPv4: core.$constructor<$ZodIPv4> = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def): void => {
|
|
862
894
|
def.pattern ??= regexes.ipv4;
|
|
863
895
|
$ZodStringFormat.init(inst, def);
|
|
864
|
-
|
|
865
|
-
inst._zod.bag.format = `ipv4`;
|
|
866
896
|
});
|
|
867
897
|
|
|
868
898
|
////////////////////////////// ZodIPv6 //////////////////////////////
|
|
@@ -884,21 +914,13 @@ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
|
884
914
|
|
|
885
915
|
export function isValidIPv6(value: string): boolean {
|
|
886
916
|
if (!ipv6Alphabet.test(value)) return false;
|
|
887
|
-
|
|
888
|
-
// @ts-ignore
|
|
889
|
-
new URL(`http://[${value}]`);
|
|
890
|
-
return true;
|
|
891
|
-
} catch {
|
|
892
|
-
return false;
|
|
893
|
-
}
|
|
917
|
+
return canParseURL(`http://[${value}]`);
|
|
894
918
|
}
|
|
895
919
|
|
|
896
920
|
export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def): void => {
|
|
897
921
|
def.pattern ??= regexes.ipv6;
|
|
898
922
|
$ZodStringFormat.init(inst, def);
|
|
899
923
|
|
|
900
|
-
inst._zod.bag.format = `ipv6`;
|
|
901
|
-
|
|
902
924
|
inst._zod.check = (payload) => {
|
|
903
925
|
if (!isValidIPv6(payload.value)) {
|
|
904
926
|
payload.issues.push({
|
|
@@ -928,8 +950,6 @@ export interface $ZodMAC extends $ZodType {
|
|
|
928
950
|
export const $ZodMAC: core.$constructor<$ZodMAC> = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def): void => {
|
|
929
951
|
def.pattern ??= regexes.mac(def.delimiter);
|
|
930
952
|
$ZodStringFormat.init(inst, def);
|
|
931
|
-
|
|
932
|
-
inst._zod.bag.format = `mac`;
|
|
933
953
|
});
|
|
934
954
|
|
|
935
955
|
////////////////////////////// ZodCIDRv4 //////////////////////////////
|
|
@@ -1021,14 +1041,15 @@ export interface $ZodBase64 extends $ZodType {
|
|
|
1021
1041
|
_zod: $ZodBase64Internals;
|
|
1022
1042
|
}
|
|
1023
1043
|
|
|
1044
|
+
// 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
|
|
1045
|
+
export const base64Charset: RegExp = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1046
|
+
|
|
1024
1047
|
export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$constructor(
|
|
1025
1048
|
"$ZodBase64",
|
|
1026
1049
|
(inst, def): void => {
|
|
1027
|
-
def.pattern ??=
|
|
1050
|
+
def.pattern ??= base64Charset;
|
|
1028
1051
|
$ZodStringFormat.init(inst, def);
|
|
1029
1052
|
|
|
1030
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1031
|
-
|
|
1032
1053
|
inst._zod.check = (payload) => {
|
|
1033
1054
|
if (isValidBase64(payload.value)) return;
|
|
1034
1055
|
|
|
@@ -1043,9 +1064,12 @@ export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$con
|
|
|
1043
1064
|
}
|
|
1044
1065
|
);
|
|
1045
1066
|
|
|
1046
|
-
//////////////////////////////
|
|
1067
|
+
////////////////////////////// ZodBase64URL //////////////////////////////
|
|
1068
|
+
// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
|
|
1069
|
+
export const base64urlCharset: RegExp = /^[A-Za-z0-9_-]*$/;
|
|
1070
|
+
|
|
1047
1071
|
export function isValidBase64URL(data: string): boolean {
|
|
1048
|
-
if (!
|
|
1072
|
+
if (!base64urlCharset.test(data)) return false;
|
|
1049
1073
|
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
1050
1074
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
1051
1075
|
return isValidBase64(padded);
|
|
@@ -1061,11 +1085,9 @@ export interface $ZodBase64URL extends $ZodType {
|
|
|
1061
1085
|
export const $ZodBase64URL: core.$constructor<$ZodBase64URL> = /*@__PURE__*/ core.$constructor(
|
|
1062
1086
|
"$ZodBase64URL",
|
|
1063
1087
|
(inst, def): void => {
|
|
1064
|
-
def.pattern ??=
|
|
1088
|
+
def.pattern ??= base64urlCharset;
|
|
1065
1089
|
$ZodStringFormat.init(inst, def);
|
|
1066
1090
|
|
|
1067
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1068
|
-
|
|
1069
1091
|
inst._zod.check = (payload) => {
|
|
1070
1092
|
if (isValidBase64URL(payload.value)) return;
|
|
1071
1093
|
|
|
@@ -1104,7 +1126,7 @@ function isLuhnAlgo(digits: string): boolean {
|
|
|
1104
1126
|
let bit = 1;
|
|
1105
1127
|
let sum = 0;
|
|
1106
1128
|
while (length) {
|
|
1107
|
-
const value =
|
|
1129
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
1108
1130
|
bit ^= 1;
|
|
1109
1131
|
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value]! : value;
|
|
1110
1132
|
}
|
|
@@ -1144,6 +1166,53 @@ export const $ZodCreditCard: core.$constructor<$ZodCreditCard> = /*@__PURE__*/ c
|
|
|
1144
1166
|
}
|
|
1145
1167
|
);
|
|
1146
1168
|
|
|
1169
|
+
////////////////////////////// ZodIBAN //////////////////////////////
|
|
1170
|
+
|
|
1171
|
+
// iso 7064 mod 97-10 checksum without BigInt
|
|
1172
|
+
function isIso7064Mod97(iban: string): boolean {
|
|
1173
|
+
let remainder = 0;
|
|
1174
|
+
const len = iban.length;
|
|
1175
|
+
for (let i = 4; i < len; i++) {
|
|
1176
|
+
const code = iban.charCodeAt(i);
|
|
1177
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
1178
|
+
}
|
|
1179
|
+
for (let i = 0; i < 4; i++) {
|
|
1180
|
+
const code = iban.charCodeAt(i);
|
|
1181
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
1182
|
+
}
|
|
1183
|
+
return remainder === 1;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
export function isValidIBAN(input: string): boolean {
|
|
1187
|
+
if (!regexes.iban.test(input)) return false;
|
|
1188
|
+
return isIso7064Mod97(input);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
export interface $ZodIBANDef extends $ZodStringFormatDef<"iban"> {}
|
|
1192
|
+
export interface $ZodIBANInternals extends $ZodStringFormatInternals<"iban"> {
|
|
1193
|
+
def: $ZodIBANDef;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
export interface $ZodIBAN extends $ZodType {
|
|
1197
|
+
_zod: $ZodIBANInternals;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
export const $ZodIBAN: core.$constructor<$ZodIBAN> = /*@__PURE__*/ core.$constructor("$ZodIBAN", (inst, def): void => {
|
|
1201
|
+
// shape only — checksum is not expressible as a pattern
|
|
1202
|
+
def.pattern ??= regexes.iban;
|
|
1203
|
+
$ZodStringFormat.init(inst, def);
|
|
1204
|
+
inst._zod.check = (payload) => {
|
|
1205
|
+
if (isValidIBAN(payload.value)) return;
|
|
1206
|
+
payload.issues.push({
|
|
1207
|
+
code: "invalid_format",
|
|
1208
|
+
format: "iban",
|
|
1209
|
+
input: payload.value,
|
|
1210
|
+
inst,
|
|
1211
|
+
continue: !def.abort,
|
|
1212
|
+
});
|
|
1213
|
+
};
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1147
1216
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
1148
1217
|
|
|
1149
1218
|
export function isValidJWT(token: string, algorithm: util.JWTAlgorithm | null = null): boolean {
|
|
@@ -1260,7 +1329,7 @@ export interface $ZodNumber<Input = unknown> extends $ZodType {
|
|
|
1260
1329
|
export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
|
1261
1330
|
$ZodType.init(inst, def);
|
|
1262
1331
|
|
|
1263
|
-
inst._zod.pattern =
|
|
1332
|
+
inst._zod.pattern = regexes.number;
|
|
1264
1333
|
inst._zod.parse = (payload, _ctx) => {
|
|
1265
1334
|
if (def.coerce)
|
|
1266
1335
|
try {
|
|
@@ -1804,6 +1873,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1804
1873
|
|
|
1805
1874
|
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1806
1875
|
const proms: Promise<any>[] = [];
|
|
1876
|
+
const abortEarly = ctx?.abortEarly;
|
|
1807
1877
|
for (let i = 0; i < input.length; i++) {
|
|
1808
1878
|
const item = input[i];
|
|
1809
1879
|
const result = def.element._zod.run(
|
|
@@ -1818,6 +1888,8 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1818
1888
|
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1819
1889
|
} else {
|
|
1820
1890
|
handleArrayResult(result, payload, i);
|
|
1891
|
+
// the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
|
|
1892
|
+
if (abortEarly && result.issues.length !== 0 && util.aborted(result)) break;
|
|
1821
1893
|
}
|
|
1822
1894
|
}
|
|
1823
1895
|
|
|
@@ -1843,7 +1915,7 @@ type OptionalInSchema = { _zod: { optin: "optional" | "defaulted" } };
|
|
|
1843
1915
|
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
|
|
1844
1916
|
? util.IsAny<T[keyof T]> extends true
|
|
1845
1917
|
? Record<string, unknown>
|
|
1846
|
-
:
|
|
1918
|
+
: { [k in string]: core.output<T[keyof T]> }
|
|
1847
1919
|
: keyof (T & Extra) extends never
|
|
1848
1920
|
? Record<string, never>
|
|
1849
1921
|
: util.Prettify<
|
|
@@ -1887,7 +1959,7 @@ export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<st
|
|
|
1887
1959
|
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
|
|
1888
1960
|
? util.IsAny<T[keyof T]> extends true
|
|
1889
1961
|
? Record<string, unknown>
|
|
1890
|
-
:
|
|
1962
|
+
: { [k in string]: core.input<T[keyof T]> }
|
|
1891
1963
|
: keyof (T & Extra) extends never
|
|
1892
1964
|
? Record<string, never>
|
|
1893
1965
|
: util.Prettify<
|
|
@@ -1933,7 +2005,7 @@ function handlePropertyResult(
|
|
|
1933
2005
|
}
|
|
1934
2006
|
|
|
1935
2007
|
if (result.value === undefined) {
|
|
1936
|
-
if (isPresent) {
|
|
2008
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
1937
2009
|
(final.value as any)[key] = undefined;
|
|
1938
2010
|
}
|
|
1939
2011
|
} else {
|
|
@@ -2022,9 +2094,10 @@ function handleCatchall(
|
|
|
2022
2094
|
proms: Promise<any>[],
|
|
2023
2095
|
input: any,
|
|
2024
2096
|
payload: ParsePayload,
|
|
2025
|
-
ctx:
|
|
2097
|
+
ctx: ParseContextInternal,
|
|
2026
2098
|
def: ReturnType<typeof normalizeDef>,
|
|
2027
|
-
inst: $ZodObject
|
|
2099
|
+
inst: $ZodObject,
|
|
2100
|
+
abortEarly: boolean
|
|
2028
2101
|
) {
|
|
2029
2102
|
const unrecognized: string[] = [];
|
|
2030
2103
|
const keySet = def.keySet;
|
|
@@ -2032,7 +2105,13 @@ function handleCatchall(
|
|
|
2032
2105
|
const t = _catchall.def.type;
|
|
2033
2106
|
const optin = _catchall.optin;
|
|
2034
2107
|
const optout = _catchall.optout;
|
|
2108
|
+
// starts at 0, not the current length: the shape phase already ran and may have aborted
|
|
2109
|
+
let seen = 0;
|
|
2035
2110
|
for (const key in input) {
|
|
2111
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2112
|
+
if (util.aborted(payload, seen)) break;
|
|
2113
|
+
seen = payload.issues.length;
|
|
2114
|
+
}
|
|
2036
2115
|
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
2037
2116
|
if (keySet.has(key)) continue;
|
|
2038
2117
|
// 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.
|
|
@@ -2070,28 +2149,22 @@ function handleCatchall(
|
|
|
2070
2149
|
});
|
|
2071
2150
|
}
|
|
2072
2151
|
|
|
2073
|
-
// Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it. Keyed by def, so a def rebuilt by a builder is simply absent rather than inheriting the source's. Read its keys with `Object.keys`, which does not invoke them — that is what lets a discriminated union check its discriminator without resolving an option whose getters reference the union being constructed.
|
|
2074
|
-
const propShapes = new WeakMap<object, Record<string, unknown>>();
|
|
2075
|
-
|
|
2076
2152
|
export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
|
2077
2153
|
// requires cast because technically $ZodObject doesn't extend
|
|
2078
2154
|
$ZodType.init(inst, def);
|
|
2079
|
-
// const sh = def.shape;
|
|
2080
2155
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
},
|
|
2094
|
-
});
|
|
2156
|
+
// 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
|
|
2157
|
+
const sh = desc?.get ? (desc.get as util.ShapeGetter).raw : (def.shape ?? {});
|
|
2158
|
+
if (sh) {
|
|
2159
|
+
// Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
|
|
2160
|
+
const get: util.ShapeGetter = () => {
|
|
2161
|
+
const newSh = { ...sh };
|
|
2162
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
2163
|
+
get.raw = newSh;
|
|
2164
|
+
return newSh;
|
|
2165
|
+
};
|
|
2166
|
+
get.raw = sh;
|
|
2167
|
+
Object.defineProperty(def, "shape", { get });
|
|
2095
2168
|
}
|
|
2096
2169
|
|
|
2097
2170
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
@@ -2137,8 +2210,14 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
2137
2210
|
|
|
2138
2211
|
const proms: Promise<any>[] = [];
|
|
2139
2212
|
const shape = value.shape;
|
|
2213
|
+
const abortEarly = ctx?.abortEarly;
|
|
2214
|
+
let seen = payload.issues.length;
|
|
2140
2215
|
|
|
2141
2216
|
for (const key of value.allKeys) {
|
|
2217
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2218
|
+
if (util.aborted(payload, seen)) break;
|
|
2219
|
+
seen = payload.issues.length;
|
|
2220
|
+
}
|
|
2142
2221
|
if (key === "__proto__") continue;
|
|
2143
2222
|
const el = (shape as any)[key]!;
|
|
2144
2223
|
const optin = el._zod.optin;
|
|
@@ -2156,7 +2235,7 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
2156
2235
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
2157
2236
|
}
|
|
2158
2237
|
|
|
2159
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2238
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
2160
2239
|
};
|
|
2161
2240
|
});
|
|
2162
2241
|
|
|
@@ -2179,12 +2258,18 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
2179
2258
|
|
|
2180
2259
|
const parseStr = (k: string) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2181
2260
|
|
|
2182
|
-
//
|
|
2261
|
+
// 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
|
|
2183
2262
|
const prefixStr = (id: string, k: string) => `
|
|
2263
|
+
let ${id}_ab = false;
|
|
2184
2264
|
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2185
2265
|
const iss = ${id}.issues[i];
|
|
2186
2266
|
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2187
2267
|
payload.issues.push(iss);
|
|
2268
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2269
|
+
}
|
|
2270
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2271
|
+
payload.value = newResult;
|
|
2272
|
+
return payload;
|
|
2188
2273
|
}`;
|
|
2189
2274
|
|
|
2190
2275
|
doc.write(`const input = payload.value;`);
|
|
@@ -2236,6 +2321,10 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
2236
2321
|
input: undefined,
|
|
2237
2322
|
path: [${k}]
|
|
2238
2323
|
});
|
|
2324
|
+
if (ctx && ctx.abortEarly) {
|
|
2325
|
+
payload.value = newResult;
|
|
2326
|
+
return payload;
|
|
2327
|
+
}
|
|
2239
2328
|
}
|
|
2240
2329
|
|
|
2241
2330
|
if (${id}_present) {
|
|
@@ -2247,16 +2336,16 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
2247
2336
|
doc.write(`
|
|
2248
2337
|
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2249
2338
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
}
|
|
2339
|
+
`);
|
|
2340
|
+
if (optin === "defaulted") {
|
|
2341
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2342
|
+
} else {
|
|
2343
|
+
doc.write(`
|
|
2344
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
2256
2345
|
newResult[${k}] = ${id}.value;
|
|
2257
2346
|
}
|
|
2258
|
-
|
|
2259
2347
|
`);
|
|
2348
|
+
}
|
|
2260
2349
|
}
|
|
2261
2350
|
}
|
|
2262
2351
|
|
|
@@ -2296,7 +2385,7 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
2296
2385
|
payload = fastpass(payload, ctx);
|
|
2297
2386
|
|
|
2298
2387
|
if (!catchall) return payload;
|
|
2299
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2388
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
2300
2389
|
}
|
|
2301
2390
|
|
|
2302
2391
|
return superParse(payload, ctx);
|
|
@@ -2533,7 +2622,7 @@ export interface $ZodDiscriminatedUnionInternals<
|
|
|
2533
2622
|
def: $ZodDiscriminatedUnionDef<Options, Disc>;
|
|
2534
2623
|
propValues: util.PropValues;
|
|
2535
2624
|
bag: util.LoosePartial<{
|
|
2536
|
-
optionsMap: Map<util.Primitive, $ZodType>;
|
|
2625
|
+
optionsMap: Map<util.Primitive, $ZodType | null>;
|
|
2537
2626
|
}>;
|
|
2538
2627
|
}
|
|
2539
2628
|
|
|
@@ -2557,7 +2646,7 @@ export type $DiscriminatedOption<Options extends readonly SomeType[], Disc exten
|
|
|
2557
2646
|
: never;
|
|
2558
2647
|
}[number];
|
|
2559
2648
|
|
|
2560
|
-
/** Returns the option
|
|
2649
|
+
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
|
|
2561
2650
|
export function getDiscriminatedOption<
|
|
2562
2651
|
Options extends readonly SomeType[],
|
|
2563
2652
|
Disc extends string,
|
|
@@ -2566,15 +2655,31 @@ export function getDiscriminatedOption<
|
|
|
2566
2655
|
const internals = union._zod;
|
|
2567
2656
|
let map = internals.bag.optionsMap;
|
|
2568
2657
|
if (!map) {
|
|
2569
|
-
map =
|
|
2570
|
-
const { options, discriminator } = internals.def;
|
|
2571
|
-
for (const option of options as unknown as readonly $ZodType[]) {
|
|
2572
|
-
// First declaration wins, matching the order the parse path resolves a duplicate in.
|
|
2573
|
-
for (const v of option._zod.propValues?.[discriminator] ?? []) if (!map.has(v)) map.set(v, option);
|
|
2574
|
-
}
|
|
2658
|
+
map = discriminatorMap(internals.def);
|
|
2575
2659
|
internals.bag.optionsMap = map;
|
|
2576
2660
|
}
|
|
2577
|
-
|
|
2661
|
+
const option = map.get(value as util.Primitive);
|
|
2662
|
+
if (option === null) throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
2663
|
+
return option as any;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
function discriminatorMap(def: $ZodDiscriminatedUnionDef<readonly SomeType[]>): Map<util.Primitive, $ZodType | null> {
|
|
2667
|
+
const map = new Map<util.Primitive, $ZodType | null>();
|
|
2668
|
+
for (const option of def.options as readonly $ZodType[]) {
|
|
2669
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
2670
|
+
if (!values || values.size === 0)
|
|
2671
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2672
|
+
for (const value of values) {
|
|
2673
|
+
if (map.has(value)) {
|
|
2674
|
+
if (value !== undefined) throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
2675
|
+
// keep the collision marked so a later member cannot reclaim it
|
|
2676
|
+
map.set(value, null);
|
|
2677
|
+
} else {
|
|
2678
|
+
map.set(value, option);
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
return map;
|
|
2578
2683
|
}
|
|
2579
2684
|
|
|
2580
2685
|
export interface $ZodDiscriminatedUnion<
|
|
@@ -2594,10 +2699,12 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2594
2699
|
const _super = inst._zod.parse;
|
|
2595
2700
|
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
2596
2701
|
const propValues: util.PropValues = {};
|
|
2702
|
+
let undefinedCount = 0;
|
|
2597
2703
|
for (const option of zod.def.options) {
|
|
2598
2704
|
const pv = option._zod.propValues;
|
|
2599
2705
|
if (!pv || Object.keys(pv).length === 0)
|
|
2600
2706
|
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
2707
|
+
if (pv[zod.def.discriminator]?.has(undefined)) undefinedCount++;
|
|
2601
2708
|
for (const [k, v] of Object.entries(pv!)) {
|
|
2602
2709
|
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
2603
2710
|
util.assignProp(propValues, k, new Set());
|
|
@@ -2607,33 +2714,19 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2607
2714
|
}
|
|
2608
2715
|
}
|
|
2609
2716
|
}
|
|
2717
|
+
if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(undefined);
|
|
2610
2718
|
return propValues;
|
|
2611
2719
|
});
|
|
2612
2720
|
|
|
2613
|
-
// 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
|
|
2721
|
+
// 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.
|
|
2614
2722
|
def.options.forEach((option, i) => {
|
|
2615
|
-
const propShape =
|
|
2723
|
+
const propShape = util.rawShape(option._zod.def);
|
|
2616
2724
|
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
2617
2725
|
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
2618
2726
|
}
|
|
2619
2727
|
});
|
|
2620
2728
|
|
|
2621
|
-
const disc = util.cached(() =>
|
|
2622
|
-
const opts = def.options;
|
|
2623
|
-
const map: Map<util.Primitive, $ZodType> = new Map();
|
|
2624
|
-
for (const o of opts) {
|
|
2625
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
2626
|
-
if (!values || values.size === 0)
|
|
2627
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
2628
|
-
for (const v of values) {
|
|
2629
|
-
if (map.has(v)) {
|
|
2630
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
2631
|
-
}
|
|
2632
|
-
map.set(v, o);
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
return map;
|
|
2636
|
-
});
|
|
2729
|
+
const disc = util.cached(() => discriminatorMap(def));
|
|
2637
2730
|
|
|
2638
2731
|
inst._zod.parse = (payload, ctx) => {
|
|
2639
2732
|
const input = payload.value;
|
|
@@ -2648,8 +2741,10 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2648
2741
|
return payload;
|
|
2649
2742
|
}
|
|
2650
2743
|
|
|
2651
|
-
const
|
|
2652
|
-
|
|
2744
|
+
const value = input?.[def.discriminator];
|
|
2745
|
+
const opt = disc.value.get(value as util.Primitive);
|
|
2746
|
+
// forward metadata cannot choose an encoder for an absent tag
|
|
2747
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
2653
2748
|
return opt._zod.run(payload, ctx) as any;
|
|
2654
2749
|
}
|
|
2655
2750
|
|
|
@@ -2666,7 +2761,7 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2666
2761
|
errors: [],
|
|
2667
2762
|
note: "No matching discriminator",
|
|
2668
2763
|
discriminator: def.discriminator,
|
|
2669
|
-
options: Array.from(disc.value.keys()),
|
|
2764
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
2670
2765
|
input,
|
|
2671
2766
|
path: [def.discriminator],
|
|
2672
2767
|
inst,
|
|
@@ -2959,6 +3054,9 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
|
|
|
2959
3054
|
|
|
2960
3055
|
// 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.
|
|
2961
3056
|
const itemResults: ParsePayload[] = new Array(items.length);
|
|
3057
|
+
// only tracked when there is a rest loop to skip
|
|
3058
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
3059
|
+
let itemAborted = false;
|
|
2962
3060
|
for (let i = 0; i < items.length; i++) {
|
|
2963
3061
|
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
2964
3062
|
if (r instanceof Promise) {
|
|
@@ -2969,13 +3067,20 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
|
|
|
2969
3067
|
);
|
|
2970
3068
|
} else {
|
|
2971
3069
|
itemResults[i] = r;
|
|
3070
|
+
if (abortEarly && !itemAborted && r.issues.length) itemAborted = util.aborted(r);
|
|
2972
3071
|
}
|
|
2973
3072
|
}
|
|
2974
3073
|
|
|
2975
|
-
|
|
3074
|
+
// sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
|
|
3075
|
+
if (def.rest && !itemAborted) {
|
|
2976
3076
|
let i = items.length - 1;
|
|
2977
3077
|
const rest = input.slice(items.length);
|
|
3078
|
+
let seen = payload.issues.length;
|
|
2978
3079
|
for (const el of rest) {
|
|
3080
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
3081
|
+
if (util.aborted(payload, seen)) break;
|
|
3082
|
+
seen = payload.issues.length;
|
|
3083
|
+
}
|
|
2979
3084
|
i++;
|
|
2980
3085
|
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
2981
3086
|
if (result instanceof Promise) {
|
|
@@ -3145,6 +3250,7 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
3145
3250
|
return payload;
|
|
3146
3251
|
}
|
|
3147
3252
|
|
|
3253
|
+
// 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
|
|
3148
3254
|
const proms: Promise<any>[] = [];
|
|
3149
3255
|
|
|
3150
3256
|
const values = def.keyType._zod.values;
|
|
@@ -3349,8 +3455,14 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
|
|
|
3349
3455
|
|
|
3350
3456
|
const proms: Promise<any>[] = [];
|
|
3351
3457
|
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
3458
|
+
const abortEarly = ctx?.abortEarly;
|
|
3459
|
+
let seen = payload.issues.length;
|
|
3352
3460
|
|
|
3353
3461
|
for (const [key, value] of input) {
|
|
3462
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
3463
|
+
if (util.aborted(payload, seen)) break;
|
|
3464
|
+
seen = payload.issues.length;
|
|
3465
|
+
}
|
|
3354
3466
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
3355
3467
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
3356
3468
|
|
|
@@ -3454,7 +3566,13 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
|
|
|
3454
3566
|
|
|
3455
3567
|
const proms: Promise<any>[] = [];
|
|
3456
3568
|
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
3569
|
+
const abortEarly = ctx?.abortEarly;
|
|
3570
|
+
let seen = payload.issues.length;
|
|
3457
3571
|
for (const item of input) {
|
|
3572
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
3573
|
+
if (util.aborted(payload, seen)) break;
|
|
3574
|
+
seen = payload.issues.length;
|
|
3575
|
+
}
|
|
3458
3576
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
3459
3577
|
if (result instanceof Promise) {
|
|
3460
3578
|
proms.push(result.then((result) => handleSetResult(result, payload)));
|
|
@@ -3513,12 +3631,13 @@ export const $ZodEnum: core.$constructor<$ZodEnum> = /*@__PURE__*/ core.$constru
|
|
|
3513
3631
|
const valuesSet = new Set<util.Primitive>(values);
|
|
3514
3632
|
inst._zod.values = valuesSet;
|
|
3515
3633
|
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3634
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
3635
|
+
const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
|
|
3636
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
3637
|
+
return new RegExp(
|
|
3638
|
+
patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$"
|
|
3639
|
+
);
|
|
3640
|
+
});
|
|
3522
3641
|
|
|
3523
3642
|
inst._zod.parse = (payload, _ctx) => {
|
|
3524
3643
|
const input = payload.value;
|
|
@@ -3568,14 +3687,19 @@ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$c
|
|
|
3568
3687
|
const values = new Set<util.Literal>(def.values);
|
|
3569
3688
|
inst._zod.values = values;
|
|
3570
3689
|
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3690
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
3691
|
+
const vals = zod.def.values;
|
|
3692
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
3693
|
+
return new RegExp(
|
|
3694
|
+
vals.length
|
|
3695
|
+
? `^(${vals
|
|
3696
|
+
.map((o: util.Literal) =>
|
|
3697
|
+
typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)
|
|
3698
|
+
)
|
|
3699
|
+
.join("|")})$`
|
|
3700
|
+
: "^[^\\s\\S]$"
|
|
3701
|
+
);
|
|
3702
|
+
});
|
|
3579
3703
|
|
|
3580
3704
|
inst._zod.parse = (payload, _ctx) => {
|
|
3581
3705
|
const input = payload.value;
|
|
@@ -3975,7 +4099,7 @@ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodType
|
|
|
3975
4099
|
}
|
|
3976
4100
|
|
|
3977
4101
|
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
|
|
3978
|
-
extends $ZodTypeInternals<
|
|
4102
|
+
extends $ZodTypeInternals<core.output<T>, core.input<T> | undefined> {
|
|
3979
4103
|
def: $ZodPrefaultDef<T>;
|
|
3980
4104
|
optin: "defaulted";
|
|
3981
4105
|
optout?: "optional" | undefined;
|
|
@@ -4574,6 +4698,51 @@ export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [
|
|
|
4574
4698
|
: never
|
|
4575
4699
|
: never;
|
|
4576
4700
|
|
|
4701
|
+
// 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
|
|
4702
|
+
function leafPattern(schema: $ZodType): string | undefined {
|
|
4703
|
+
const def = schema._zod.def as { pattern?: RegExp; format?: string; checks?: checks.$ZodCheck[] };
|
|
4704
|
+
let pattern = def.pattern;
|
|
4705
|
+
let isInt = !!def.format?.includes("int");
|
|
4706
|
+
let minimum: number | undefined;
|
|
4707
|
+
let maximum: number | undefined;
|
|
4708
|
+
for (const ch of def.checks ?? []) {
|
|
4709
|
+
const d = ch._zod.def as { pattern?: RegExp; format?: string; minimum?: number; maximum?: number; length?: number };
|
|
4710
|
+
if (d.pattern) pattern = d.pattern;
|
|
4711
|
+
isInt ||= !!d.format?.includes("int");
|
|
4712
|
+
const lo = d.minimum ?? d.length;
|
|
4713
|
+
const hi = d.maximum ?? d.length;
|
|
4714
|
+
if (lo !== undefined && (minimum === undefined || lo > minimum)) minimum = lo;
|
|
4715
|
+
if (hi !== undefined && (maximum === undefined || hi < maximum)) maximum = hi;
|
|
4716
|
+
}
|
|
4717
|
+
if (pattern) return pattern.source;
|
|
4718
|
+
// an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
|
|
4719
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum) return "(?!)";
|
|
4720
|
+
if (minimum !== undefined || maximum !== undefined) return regexes.string({ minimum, maximum }).source;
|
|
4721
|
+
const own = schema._zod.pattern;
|
|
4722
|
+
return (isInt && own === regexes.number ? regexes.integer : own)?.source;
|
|
4723
|
+
}
|
|
4724
|
+
|
|
4725
|
+
// 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
|
|
4726
|
+
function partPattern(schema: $ZodType): string | undefined {
|
|
4727
|
+
const def = schema._zod.def as { innerType?: $ZodType; options?: $ZodType[] };
|
|
4728
|
+
const own = schema._zod.pattern?.source;
|
|
4729
|
+
// lazy resolves its inner on the internals, not the def
|
|
4730
|
+
const inner = def.innerType ?? (schema._zod as { innerType?: $ZodType }).innerType;
|
|
4731
|
+
if (inner) {
|
|
4732
|
+
const before = inner._zod.pattern?.source;
|
|
4733
|
+
const after = partPattern(inner);
|
|
4734
|
+
if (own && before && after && after !== before) {
|
|
4735
|
+
return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
|
|
4736
|
+
}
|
|
4737
|
+
return own;
|
|
4738
|
+
}
|
|
4739
|
+
if (def.options) {
|
|
4740
|
+
const sources = def.options.map(partPattern);
|
|
4741
|
+
if (sources.every(Boolean)) return `^(${sources.map((s) => util.cleanRegex(s!)).join("|")})$`;
|
|
4742
|
+
}
|
|
4743
|
+
return leafPattern(schema);
|
|
4744
|
+
}
|
|
4745
|
+
|
|
4577
4746
|
export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
|
|
4578
4747
|
"$ZodTemplateLiteral",
|
|
4579
4748
|
(inst, def) => {
|
|
@@ -4582,18 +4751,11 @@ export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__
|
|
|
4582
4751
|
for (const part of def.parts) {
|
|
4583
4752
|
if (typeof part === "object" && part !== null) {
|
|
4584
4753
|
// is Zod schema
|
|
4585
|
-
|
|
4586
|
-
|
|
4754
|
+
const source = partPattern(part);
|
|
4755
|
+
if (!source) {
|
|
4587
4756
|
throw new Error(`Invalid template literal part, no pattern found: ${[...(part as any)._zod.traits].shift()}`);
|
|
4588
4757
|
}
|
|
4589
|
-
|
|
4590
|
-
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
|
4591
|
-
|
|
4592
|
-
if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
4593
|
-
|
|
4594
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
4595
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
4596
|
-
regexParts.push(source.slice(start, end));
|
|
4758
|
+
regexParts.push(util.cleanRegex(source));
|
|
4597
4759
|
} else if (part === null || util.primitiveTypes.has(typeof part)) {
|
|
4598
4760
|
regexParts.push(util.escapeRegex(`${part}`));
|
|
4599
4761
|
} else {
|
|
@@ -5022,7 +5184,9 @@ export type $ZodStringFormatTypes =
|
|
|
5022
5184
|
| $ZodBase64URL
|
|
5023
5185
|
| $ZodE164
|
|
5024
5186
|
| $ZodCreditCard
|
|
5187
|
+
| $ZodIBAN
|
|
5025
5188
|
| $ZodJWT
|
|
5026
5189
|
| $ZodCustomStringFormat<"hex">
|
|
5027
5190
|
| $ZodCustomStringFormat<util.HashFormat>
|
|
5028
|
-
| $ZodCustomStringFormat<"hostname"
|
|
5191
|
+
| $ZodCustomStringFormat<"hostname">
|
|
5192
|
+
| $ZodCustomStringFormat<"currency_code">;
|