@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
|
@@ -838,6 +838,62 @@ describe("__proto__ as a declared shape key", () => {
|
|
|
838
838
|
expect(() => (schema[method] as any)(mask).shape).toThrow('Unrecognized key: "__proto__"');
|
|
839
839
|
});
|
|
840
840
|
|
|
841
|
+
// the mask is checked against the source's declared keys, which reads without resolving them, so it throws where the mistake is
|
|
842
|
+
test.each(["pick", "omit", "partial", "required"] as const)("%s rejects an undeclared key at the call", (method) => {
|
|
843
|
+
const schema = z.object({ value: z.string() });
|
|
844
|
+
|
|
845
|
+
expect(() => (schema[method] as any)({ nope: true })).toThrow('Unrecognized key: "nope"');
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
// a derived shape is built key by key, and a plain assignment runs whatever setter answers to the key โ `__proto__` always has one, and a polluted prototype can supply one for any name
|
|
849
|
+
test("an inherited setter cannot swallow a derived key", () => {
|
|
850
|
+
let swallowed: unknown;
|
|
851
|
+
Object.defineProperty(Object.prototype, "field", {
|
|
852
|
+
configurable: true,
|
|
853
|
+
set(v) {
|
|
854
|
+
swallowed = v;
|
|
855
|
+
},
|
|
856
|
+
get() {
|
|
857
|
+
return undefined;
|
|
858
|
+
},
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
try {
|
|
862
|
+
const derived = z.object({ field: z.string() }).extend({ extra: z.number() });
|
|
863
|
+
|
|
864
|
+
expect(Object.keys(derived.shape)).toEqual(["field", "extra"]);
|
|
865
|
+
expect(swallowed).toBeUndefined();
|
|
866
|
+
// the key is still validated; what a parse writes into its result is the ambient prototype's business, as it is without a builder
|
|
867
|
+
expect(derived.safeParse({ field: 123, extra: 1 }).success).toBe(false);
|
|
868
|
+
expect(derived.safeParse({ field: "a", extra: 1 }).success).toBe(true);
|
|
869
|
+
} finally {
|
|
870
|
+
delete (Object.prototype as any).field;
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
// a shape resolves by object spread, so a non-enumerable entry is no part of it and no builder may promote one into a derived shape
|
|
875
|
+
test("a non-enumerable shape entry stays out of every derived shape", () => {
|
|
876
|
+
const sym = Symbol("kept");
|
|
877
|
+
const hide = (target: Record<string, any>) =>
|
|
878
|
+
Object.defineProperty(target, "hidden", { value: z.string(), enumerable: false, configurable: true });
|
|
879
|
+
// each case needs a source whose shape is still unresolved, since resolving drops the entry on its own
|
|
880
|
+
const source = () => z.object(hide({ b: z.number(), [sym]: z.boolean() }) as any);
|
|
881
|
+
|
|
882
|
+
expect(Reflect.ownKeys(source().shape)).toEqual(["b", sym]);
|
|
883
|
+
expect(Reflect.ownKeys(source().extend({ c: z.boolean() }).shape)).toEqual(["b", "c", sym]);
|
|
884
|
+
expect(Reflect.ownKeys(source().partial().shape)).toEqual(["b", sym]);
|
|
885
|
+
expect(Reflect.ownKeys(source().merge(z.object({ c: z.boolean() })).shape)).toEqual(["b", "c", sym]);
|
|
886
|
+
expect(Object.keys(z.object({ b: z.number() }).extend(hide({}) as any).shape)).toEqual(["b"]);
|
|
887
|
+
expect(() => source().pick({ hidden: true } as any)).toThrow('Unrecognized key: "hidden"');
|
|
888
|
+
|
|
889
|
+
// promoting it would make a key the source ignores required
|
|
890
|
+
expect(
|
|
891
|
+
source()
|
|
892
|
+
.extend({ c: z.boolean() })
|
|
893
|
+
.safeParse({ b: 1, [sym]: true, c: true }).success
|
|
894
|
+
).toBe(true);
|
|
895
|
+
});
|
|
896
|
+
|
|
841
897
|
test("shape helpers preserve a declared key", () => {
|
|
842
898
|
const shape = () =>
|
|
843
899
|
Object.fromEntries([
|
|
@@ -222,7 +222,8 @@ test("ladder: the rung values themselves", () => {
|
|
|
222
222
|
|
|
223
223
|
test("exactOptional overrides the values and pattern optional installs", () => {
|
|
224
224
|
expect(z.exactOptional(z.enum(["a", "b"]))._zod.values).toEqual(new Set(["a", "b"]));
|
|
225
|
-
|
|
225
|
+
// a format carries its pattern on its def; a chained `.regex()` no longer folds into the inner `_zod.pattern`, the template literal derives that itself
|
|
226
|
+
expect(z.exactOptional(z.stringFormat("abc", /^abc$/))._zod.pattern).toEqual(/^abc$/);
|
|
226
227
|
expect(z.templateLiteral(["a", z.exactOptional(z.literal("b"))]).safeParse("a").success).toEqual(false);
|
|
227
228
|
});
|
|
228
229
|
|
|
@@ -230,5 +231,5 @@ test("exactOptional overrides the values and pattern optional installs", () => {
|
|
|
230
231
|
test("exactOptional's override holds for later instances", () => {
|
|
231
232
|
z.exactOptional(z.enum(["a", "b"]));
|
|
232
233
|
expect(z.exactOptional(z.enum(["c", "d"]))._zod.values).toEqual(new Set(["c", "d"]));
|
|
233
|
-
expect(z.exactOptional(z.
|
|
234
|
+
expect(z.exactOptional(z.stringFormat("xyz", /^xyz$/))._zod.pattern).toEqual(/^xyz$/);
|
|
234
235
|
});
|
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
import { expect, expectTypeOf, test } from "vitest";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
|
|
4
|
+
test.each([false, true])("undefined prefault preserves object keys (jitless: %s)", async (jitless) => {
|
|
5
|
+
const previous = z.config().jitless;
|
|
6
|
+
z.config({ jitless });
|
|
7
|
+
try {
|
|
8
|
+
let calls = 0;
|
|
9
|
+
const field = z.union([z.string(), z.undefined()]).prefault(() => {
|
|
10
|
+
calls++;
|
|
11
|
+
return undefined;
|
|
12
|
+
});
|
|
13
|
+
const schema = z.object({ a: field });
|
|
14
|
+
expectTypeOf<z.output<typeof field>>().toEqualTypeOf<string | undefined>();
|
|
15
|
+
expectTypeOf<z.input<typeof schema>>().toEqualTypeOf<{ a?: string | undefined }>();
|
|
16
|
+
expectTypeOf<z.output<typeof schema>>().toEqualTypeOf<{ a: string | undefined }>();
|
|
17
|
+
expect(schema.parse({})).toStrictEqual({ a: undefined });
|
|
18
|
+
expect(calls).toBe(1);
|
|
19
|
+
expect(schema.parse({ a: undefined })).toStrictEqual({ a: undefined });
|
|
20
|
+
expect(calls).toBe(2);
|
|
21
|
+
expect(await schema.parseAsync({})).toStrictEqual({ a: undefined });
|
|
22
|
+
expect(calls).toBe(3);
|
|
23
|
+
expect(schema.parse({ a: "value" })).toStrictEqual({ a: "value" });
|
|
24
|
+
expect(schema.safeParse({ a: 123 }).success).toBe(false);
|
|
25
|
+
expect(calls).toBe(3);
|
|
26
|
+
|
|
27
|
+
const literal = z.prefault(z.string().optional(), undefined);
|
|
28
|
+
expect(z.core.compileFn(z.object({ a: literal }))({})).toStrictEqual({ a: undefined });
|
|
29
|
+
for (const wrapped of [literal, literal.readonly(), literal.nullable(), z.lazy(() => literal)]) {
|
|
30
|
+
expect(z.object({ a: wrapped }).parse({})).toStrictEqual({ a: undefined });
|
|
31
|
+
}
|
|
32
|
+
expect(z.object({ a: literal.optional() }).parse({})).toStrictEqual({});
|
|
33
|
+
expect(z.object({ a: literal.optional() }).parse({ a: undefined })).toStrictEqual({ a: undefined });
|
|
34
|
+
expect(z.tuple([literal]).parse([])).toStrictEqual([undefined]);
|
|
35
|
+
} finally {
|
|
36
|
+
z.config({ jitless: previous });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("prefault preserves transformed undefined output", async () => {
|
|
41
|
+
const field = z
|
|
42
|
+
.string()
|
|
43
|
+
.transform(() => undefined)
|
|
44
|
+
.prefault("fallback");
|
|
45
|
+
expectTypeOf<z.output<typeof field>>().toEqualTypeOf<undefined>();
|
|
46
|
+
expect(field.parse(undefined)).toBeUndefined();
|
|
47
|
+
const schema = z.object({ a: field, optional: z.string().optional() });
|
|
48
|
+
expectTypeOf<z.output<typeof schema>>().toEqualTypeOf<{ a: undefined; optional?: string | undefined }>();
|
|
49
|
+
expect(schema.parse({})).toStrictEqual({ a: undefined });
|
|
50
|
+
expect(z.core.compileFn(schema)({})).toStrictEqual({ a: undefined });
|
|
51
|
+
expect(z.compile(schema).parse({})).toStrictEqual({ a: undefined });
|
|
52
|
+
expect(
|
|
53
|
+
await z
|
|
54
|
+
.object({
|
|
55
|
+
a: z
|
|
56
|
+
.string()
|
|
57
|
+
.transform(async () => undefined)
|
|
58
|
+
.prefault("fallback"),
|
|
59
|
+
})
|
|
60
|
+
.parseAsync({})
|
|
61
|
+
).toStrictEqual({ a: undefined });
|
|
62
|
+
expect(
|
|
63
|
+
z
|
|
64
|
+
.object({
|
|
65
|
+
a: z
|
|
66
|
+
.string()
|
|
67
|
+
.prefault("fallback")
|
|
68
|
+
.transform(() => undefined),
|
|
69
|
+
})
|
|
70
|
+
.parse({})
|
|
71
|
+
).toStrictEqual({ a: undefined });
|
|
72
|
+
});
|
|
73
|
+
|
|
4
74
|
test("basic prefault", () => {
|
|
5
75
|
const a = z.prefault(z.string().trim(), " default ");
|
|
6
76
|
expect(a).toBeInstanceOf(z.ZodPrefault);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { expect, expectTypeOf, test } from "vitest";
|
|
2
|
+
import * as z from "zod/v4";
|
|
3
|
+
|
|
4
|
+
test("z.properties is a check", () => {
|
|
5
|
+
const s = z.object({ a: z.string(), b: z.string() }).check(z.properties({ a: z.literal("x"), b: z.literal("y") }));
|
|
6
|
+
|
|
7
|
+
// asserts in place: extra keys pass, and every failing key reports
|
|
8
|
+
expect(s.safeParse({ a: "x", b: "y", extra: 1 }).success).toBe(true);
|
|
9
|
+
expect(s.safeParse({ a: "!", b: "!" }).error!.issues.map((i) => i.path)).toEqual([["a"], ["b"]]);
|
|
10
|
+
|
|
11
|
+
// the base already typed the value, so the properties are asserted on whatever it produced โ a string's length, as z.property() does
|
|
12
|
+
const long = z.string().check(z.properties({ length: z.number().min(3) }));
|
|
13
|
+
expect(long.parse("abc")).toBe("abc");
|
|
14
|
+
expect(long.safeParse("ab").error!.issues.map((i) => i.path)).toEqual([["length"]]);
|
|
15
|
+
expect(
|
|
16
|
+
z
|
|
17
|
+
.compile(long)
|
|
18
|
+
.safeParse("ab")
|
|
19
|
+
.error!.issues.map((i) => i.path)
|
|
20
|
+
).toEqual([["length"]]);
|
|
21
|
+
|
|
22
|
+
// not a schema
|
|
23
|
+
// @ts-expect-error a check has no parse of its own
|
|
24
|
+
z.properties({ a: z.string() }).parse;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("z.properties discards transformed output", () => {
|
|
28
|
+
// asserts and never writes back, exactly as z.property() behaves; a nested object schema rebuilds its output even without transforms, so identity cannot distinguish the two
|
|
29
|
+
const s = z.any().check(z.properties({ a: z.string().transform((s) => s.toUpperCase()) }));
|
|
30
|
+
const input = { a: "hi" };
|
|
31
|
+
expect(s.parse(input)).toBe(input);
|
|
32
|
+
expect(input.a).toBe("hi");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("z.instanceof().properties()", () => {
|
|
36
|
+
const httpsUrl = z.instanceof(URL).properties({ protocol: z.literal("https:") });
|
|
37
|
+
expectTypeOf<z.infer<typeof httpsUrl>>().toEqualTypeOf<URL & { protocol: "https:" }>();
|
|
38
|
+
|
|
39
|
+
const u = new URL("https://example.com");
|
|
40
|
+
expect(httpsUrl.parse(u)).toBe(u);
|
|
41
|
+
expect(httpsUrl.safeParse(new URL("http://example.com")).error!.issues.map((i) => i.path)).toEqual([["protocol"]]);
|
|
42
|
+
|
|
43
|
+
// chains, and each call narrows further
|
|
44
|
+
const chained = httpsUrl.properties({ port: z.literal("") });
|
|
45
|
+
expectTypeOf<z.infer<typeof chained>>().toEqualTypeOf<URL & { protocol: "https:" } & { port: "" }>();
|
|
46
|
+
expect(chained.safeParse(u).success).toBe(true);
|
|
47
|
+
expect(chained.safeParse(new URL("https://example.com:8443")).error!.issues.map((i) => i.path)).toEqual([["port"]]);
|
|
48
|
+
|
|
49
|
+
// nothing is written back, so the narrowing is over the shape's input side
|
|
50
|
+
const W = z.instanceof(URL).properties({ search: z.string().transform((s) => s.length) });
|
|
51
|
+
expectTypeOf<z.infer<typeof W>>().toEqualTypeOf<URL & { search: string }>();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("z.instanceof().properties() constrains the shape to the instance type", () => {
|
|
55
|
+
const file = z.instanceof(File).properties({ name: z.string(), size: z.number().max(1024) });
|
|
56
|
+
expectTypeOf<z.infer<typeof file>>().toEqualTypeOf<File & { name: string; size: number }>();
|
|
57
|
+
|
|
58
|
+
// @ts-expect-error no such property on File
|
|
59
|
+
z.instanceof(File).properties({ nmae: z.string() });
|
|
60
|
+
|
|
61
|
+
// @ts-expect-error File["size"] is a number
|
|
62
|
+
z.instanceof(File).properties({ size: z.string() });
|
|
63
|
+
|
|
64
|
+
// methods are out of the shape, so an object literal's inherited toString can't collide with the constraint
|
|
65
|
+
// @ts-expect-error
|
|
66
|
+
z.instanceof(File).properties({ text: z.any() });
|
|
67
|
+
|
|
68
|
+
// a literal still narrows a wider property
|
|
69
|
+
const png = z.instanceof(File).properties({ type: z.literal("image/png") });
|
|
70
|
+
expectTypeOf<z.infer<typeof png>>().toEqualTypeOf<File & { type: "image/png" }>();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("z.properties spreads into .check()", () => {
|
|
74
|
+
// the 4.5 array call sites: the check yields itself from Symbol.iterator
|
|
75
|
+
const p = z.properties({ a: z.literal("x") });
|
|
76
|
+
expect([...p]).toEqual([p]);
|
|
77
|
+
|
|
78
|
+
const s = z.object({ a: z.string() }).check(...z.properties({ a: z.literal("x") }));
|
|
79
|
+
expect(s.safeParse({ a: "x" }).success).toBe(true);
|
|
80
|
+
expect(s.safeParse({ a: "!" }).error!.issues.map((i) => i.path)).toEqual([["a"]]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("z.properties compiles inside a container", () => {
|
|
84
|
+
const outer = z.compile(z.object({ url: z.instanceof(URL).properties({ protocol: z.literal("https:") }) }));
|
|
85
|
+
expect(outer.safeParse({ url: new URL("http://example.com") }).error!.issues.map((i) => i.path)).toEqual([
|
|
86
|
+
["url", "protocol"],
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("z.properties async", async () => {
|
|
91
|
+
const s = z.any().check(z.properties({ a: z.string().refine(async (s) => s.length > 1) }));
|
|
92
|
+
const ok = { a: "hi" };
|
|
93
|
+
await expect(s.parseAsync(ok)).resolves.toBe(ok);
|
|
94
|
+
const bad = await s.safeParseAsync({ a: "!" });
|
|
95
|
+
expect(bad.error!.issues.map((i) => i.path)).toEqual([["a"]]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("z.properties validates symbol keys", () => {
|
|
99
|
+
const sym = Symbol("tag");
|
|
100
|
+
const s = z.any().check(z.properties({ [sym]: z.string() }));
|
|
101
|
+
expect(s.safeParse({ [sym]: "ok" }).success).toBe(true);
|
|
102
|
+
expect(s.safeParse({ [sym]: 123 }).error!.issues.map((i) => i.path)).toEqual([[sym]]);
|
|
103
|
+
expect(
|
|
104
|
+
z
|
|
105
|
+
.compile(s)
|
|
106
|
+
.safeParse({ [sym]: 123 })
|
|
107
|
+
.error!.issues.map((i) => i.path)
|
|
108
|
+
).toEqual([[sym]]);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("z.properties compiled and interpreted agree on a nullish value", () => {
|
|
112
|
+
// a base that permits null reaches the check with one; the compiled property read must not throw where the runtime reports an issue
|
|
113
|
+
const s = z.any().check(...z.properties({ a: z.string() }));
|
|
114
|
+
const expected = [["invalid_type", []]];
|
|
115
|
+
expect(s.safeParse(null).error!.issues.map((i) => [i.code, i.path])).toEqual(expected);
|
|
116
|
+
expect(
|
|
117
|
+
z
|
|
118
|
+
.compile(s)
|
|
119
|
+
.safeParse(null)
|
|
120
|
+
.error!.issues.map((i) => [i.code, i.path])
|
|
121
|
+
).toEqual(expected);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("z.properties with a custom when refuses to compile", () => {
|
|
125
|
+
// `when` is not publicly settable, since it gates the assertion inside the run loop. A hand-built def can still carry one, and compiling it must refuse rather than run the shape unconditionally: a union branch compiles to its own IIFE, so a wrong rejection is absorbed as a branch failure with no fallback.
|
|
126
|
+
const p = new z.core.$ZodCheckProperties({ check: "properties", shape: { a: z.literal("x") }, when: () => false });
|
|
127
|
+
const s = z.union([z.any().check(p), z.object({ b: z.string() })]);
|
|
128
|
+
const input = { a: "wrong", b: "hello" };
|
|
129
|
+
expect(z.compile(s).safeParse(input)).toEqual(s.safeParse(input));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("z.properties survives shape mutation", () => {
|
|
133
|
+
// key and schema are snapshotted together; caching one and reading the other live paired a stale key with a missing schema
|
|
134
|
+
const shape: Record<string, z.ZodType> = { a: z.string() };
|
|
135
|
+
const s = z.any().check(z.properties(shape));
|
|
136
|
+
expect(s.safeParse({ a: "x" }).success).toBe(true);
|
|
137
|
+
delete shape.a;
|
|
138
|
+
expect(s.safeParse({ a: "x" }).success).toBe(true);
|
|
139
|
+
shape.b = z.string();
|
|
140
|
+
expect(s.safeParse({ a: "x" }).success).toBe(true);
|
|
141
|
+
});
|
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
import { expect, expectTypeOf, test } from "vitest";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
|
|
4
|
+
test("recursive object schema type aliases", () => {
|
|
5
|
+
type ObjectField = z.ZodObject<{ [k: string]: ObjectField }>;
|
|
6
|
+
type MixedField = z.ZodString | z.ZodObject<{ [k: string]: MixedField }>;
|
|
7
|
+
expectTypeOf<ObjectField>().toExtend<z.ZodType>();
|
|
8
|
+
expectTypeOf<MixedField>().toExtend<z.ZodType>();
|
|
9
|
+
|
|
10
|
+
type ObjectValue = { [k: string]: ObjectValue };
|
|
11
|
+
type MixedValue = string | { [k: string]: MixedValue };
|
|
12
|
+
expectTypeOf<z.input<ObjectField>>().toEqualTypeOf<ObjectValue>();
|
|
13
|
+
expectTypeOf<z.output<ObjectField>>().toEqualTypeOf<ObjectValue>();
|
|
14
|
+
expectTypeOf<z.input<MixedField>>().toEqualTypeOf<MixedValue>();
|
|
15
|
+
expectTypeOf<z.output<MixedField>>().toEqualTypeOf<MixedValue>();
|
|
16
|
+
|
|
17
|
+
const schema: MixedField = z.object({ name: z.string(), nested: z.object({ name: z.string() }) });
|
|
18
|
+
expect(schema.parse({ name: "a", nested: { name: "b", extra: true } })).toEqual({
|
|
19
|
+
name: "a",
|
|
20
|
+
nested: { name: "b" },
|
|
21
|
+
});
|
|
22
|
+
expect(schema.safeParse({ name: "a", nested: { name: 123 } }).success).toBe(false);
|
|
23
|
+
|
|
24
|
+
type CoreField = z.core.$ZodString<string> | z.core.$ZodObject<{ [k: string]: CoreField }>;
|
|
25
|
+
expectTypeOf<z.input<CoreField>>().toEqualTypeOf<MixedValue>();
|
|
26
|
+
expectTypeOf<z.output<CoreField>>().toEqualTypeOf<MixedValue>();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("recursive object aliases preserve distinct input and output", () => {
|
|
30
|
+
type Field = z.ZodPipe<z.ZodString, z.ZodTransform<number, string>> | z.ZodObject<{ [k: string]: Field }>;
|
|
31
|
+
type Input = string | { [k: string]: Input };
|
|
32
|
+
type Output = number | { [k: string]: Output };
|
|
33
|
+
expectTypeOf<z.input<Field>>().toEqualTypeOf<Input>();
|
|
34
|
+
expectTypeOf<z.output<Field>>().toEqualTypeOf<Output>();
|
|
35
|
+
const schema: Field = z.object({ nested: z.object({ length: z.string().transform((s) => s.length) }) });
|
|
36
|
+
expect(schema.parse({ nested: { length: "abc" } })).toEqual({ nested: { length: 3 } });
|
|
37
|
+
expect(schema.safeParse({ nested: { length: 3 } }).success).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("indexed object inference preserves string keys", () => {
|
|
41
|
+
type Indexed = z.ZodObject<Record<string, z.ZodString>>;
|
|
42
|
+
type Recursive = z.ZodObject<Record<string, Recursive>>;
|
|
43
|
+
expectTypeOf<keyof z.input<Indexed>>().toEqualTypeOf<string>();
|
|
44
|
+
expectTypeOf<keyof z.output<Indexed>>().toEqualTypeOf<string>();
|
|
45
|
+
expectTypeOf<keyof z.input<Recursive>>().toEqualTypeOf<string>();
|
|
46
|
+
expectTypeOf<keyof z.output<Recursive>>().toEqualTypeOf<string>();
|
|
47
|
+
});
|
|
48
|
+
|
|
4
49
|
test("recursion with z.lazy", () => {
|
|
5
50
|
const data = {
|
|
6
51
|
name: "I",
|
|
@@ -556,7 +601,7 @@ test("recursive object with .check()", () => {
|
|
|
556
601
|
expect(() => Category.parse(invalidData)).toThrow();
|
|
557
602
|
});
|
|
558
603
|
|
|
559
|
-
// biome-ignore lint:
|
|
604
|
+
// biome-ignore lint/suspicious/noExportsInTest: unexported it trips noUnusedVariables instead
|
|
560
605
|
export type RecursiveA = z.ZodUnion<
|
|
561
606
|
[
|
|
562
607
|
z.ZodObject<{
|
|
@@ -132,3 +132,22 @@ test("z.toJSONSchema() returns StandardJSONSchemaV1", async () => {
|
|
|
132
132
|
}
|
|
133
133
|
`);
|
|
134
134
|
});
|
|
135
|
+
|
|
136
|
+
test("a failing validate reports the same issues as safeParse, without a ZodError", async () => {
|
|
137
|
+
const schema = z.object({ name: z.string().min(3), age: z.number().refine(async (n) => n > 0) });
|
|
138
|
+
const input = { name: "ab", age: -1 };
|
|
139
|
+
const result = (await schema["~standard"].validate(input)) as { issues: unknown[] };
|
|
140
|
+
expect(result.issues).toEqual((await schema.safeParseAsync(input)).error!.issues);
|
|
141
|
+
expect(result).not.toHaveProperty("error");
|
|
142
|
+
const sync = z.string().min(3)["~standard"].validate("ab") as { issues: unknown[] };
|
|
143
|
+
expect(sync.issues).toEqual(z.string().min(3).safeParse("ab").error!.issues);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("a synchronously throwing check rejects through ~standard instead of throwing", async () => {
|
|
147
|
+
const schema = z.string().refine(() => {
|
|
148
|
+
throw new Error("boom");
|
|
149
|
+
});
|
|
150
|
+
const result = schema["~standard"].validate("abc");
|
|
151
|
+
expect(result).toBeInstanceOf(Promise);
|
|
152
|
+
await expect(result as Promise<unknown>).rejects.toThrow("boom");
|
|
153
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { expect, test } from "vitest";
|
|
2
|
+
import { expect, expectTypeOf, test } from "vitest";
|
|
3
3
|
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
5
|
|
|
@@ -12,6 +12,63 @@ const includesFromIndex2 = z.string().includes("includes", { position: 2 });
|
|
|
12
12
|
const startsWith = z.string().startsWith("startsWith");
|
|
13
13
|
const endsWith = z.string().endsWith("endsWith");
|
|
14
14
|
|
|
15
|
+
test("string factory checks", async () => {
|
|
16
|
+
const schema = z.string({ checks: [z.minLength(1), z.maxLength(3)] as const });
|
|
17
|
+
const chained = z.string().min(1).max(3);
|
|
18
|
+
expectTypeOf<z.output<typeof schema>>().toEqualTypeOf<string>();
|
|
19
|
+
for (const value of ["", "ab", "abcd", 1, undefined]) {
|
|
20
|
+
expect(z.validate(schema, value)).toBe(z.validate(chained, value));
|
|
21
|
+
expect(schema.safeParse(value)).toEqual(chained.safeParse(value));
|
|
22
|
+
}
|
|
23
|
+
expect(z.toJSONSchema(schema)).toEqual(z.toJSONSchema(chained));
|
|
24
|
+
expect(schema.minLength).toBe(1);
|
|
25
|
+
expect(schema.maxLength).toBe(3);
|
|
26
|
+
expect(schema._zod.parent).toBeUndefined();
|
|
27
|
+
expect([...schema._zod.traits]).toEqual([...chained._zod.traits]);
|
|
28
|
+
const extended = schema.max(2);
|
|
29
|
+
expect(extended._zod.parent).toBe(schema);
|
|
30
|
+
expect(z.validate(schema, "abc")).toBe(true);
|
|
31
|
+
expect(z.validate(extended, "abc")).toBe(false);
|
|
32
|
+
const coerce = z.coerce.string({ checks: [z.minLength(2)] });
|
|
33
|
+
expect(coerce.parse(12)).toBe("12");
|
|
34
|
+
expect(z.validate(coerce, 1)).toBe(false);
|
|
35
|
+
const asyncSchema = z.string({
|
|
36
|
+
checks: [
|
|
37
|
+
z.check<string>(async (ctx) => {
|
|
38
|
+
if (ctx.value !== "ok") ctx.issues.push({ code: "custom", input: ctx.value });
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
expect(await asyncSchema.safeParseAsync("ok")).toEqual({ success: true, data: "ok" });
|
|
43
|
+
expect((await asyncSchema.safeParseAsync("bad")).success).toBe(false);
|
|
44
|
+
// @ts-expect-error numeric checks cannot validate strings
|
|
45
|
+
z.string({ checks: [z.gte(1)] });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("factory checks snapshot caller arrays", () => {
|
|
49
|
+
for (const factory of [z.string, z.coerce.string]) {
|
|
50
|
+
for (const initial of [[], [z.minLength(1)]]) {
|
|
51
|
+
const schema = factory({ checks: initial });
|
|
52
|
+
let reads = 0;
|
|
53
|
+
const getterSchema = factory({
|
|
54
|
+
get checks() {
|
|
55
|
+
if (++reads > 1) throw new Error("checks read twice");
|
|
56
|
+
return initial;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
expect(reads).toBe(1);
|
|
60
|
+
expect(z.validate(getterSchema, "long")).toBe(true);
|
|
61
|
+
const before = z.toJSONSchema(schema);
|
|
62
|
+
initial.push(z.minLength(10));
|
|
63
|
+
expect(schema._zod.def.checks).not.toBe(initial);
|
|
64
|
+
expect(z.validate(schema, "long")).toBe(true);
|
|
65
|
+
expect(z.validate(z.compile(schema), "long")).toBe(true);
|
|
66
|
+
expect(z.toJSONSchema(schema)).toEqual(before);
|
|
67
|
+
expect(z.validate(schema.check(z.minLength(2)), "long")).toBe(true);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
15
72
|
test("length checks", () => {
|
|
16
73
|
minFive.parse("12345");
|
|
17
74
|
minFive.parse("123456");
|
|
@@ -264,6 +321,7 @@ test("base64url validations", () => {
|
|
|
264
321
|
|
|
265
322
|
const invalidBase64URLStrings = [
|
|
266
323
|
"w7/Dv8O+w74K", // Has + and / characters (is base64)
|
|
324
|
+
"A", // Invalid length (1 mod 4 carries no whole byte)
|
|
267
325
|
"12345", // Invalid length (not a multiple of 4 characters when adding allowed number of padding characters)
|
|
268
326
|
"12345===", // Not padded correctly
|
|
269
327
|
"!UGF0aWVuY2UgaXMgdGhlIGtleSB0byBzdWNjZXNz", // Invalid character '!'
|
|
@@ -291,6 +349,18 @@ test("big base64 and base64url", () => {
|
|
|
291
349
|
z.base64().parse(bigbase64);
|
|
292
350
|
const bigbase64url = randomBytes(1024 * 1024 * 10).toString("base64url");
|
|
293
351
|
z.base64url().parse(bigbase64url);
|
|
352
|
+
|
|
353
|
+
// template literals compose def.pattern and test it on every parse; the quantified block forms overflowed the regex stack here
|
|
354
|
+
expect(z.templateLiteral(["id-", z.base64()]).safeParse(`id-${bigbase64}`).success).toBe(true);
|
|
355
|
+
expect(z.templateLiteral(["id-", z.base64url()]).safeParse(`id-${bigbase64url}`).success).toBe(true);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
test("template literal composes base64 without alternation leaks", () => {
|
|
359
|
+
// the ^$| alternation in regexes.base64 used to leak: "AAAA" matched with the prefix dropped and "id-AAAA" was rejected
|
|
360
|
+
const tl = z.templateLiteral(["id-", z.base64()]);
|
|
361
|
+
expect(tl.safeParse("id-AAAA").success).toBe(true);
|
|
362
|
+
expect(tl.safeParse("id-").success).toBe(true);
|
|
363
|
+
expect(tl.safeParse("AAAA").success).toBe(false);
|
|
294
364
|
});
|
|
295
365
|
|
|
296
366
|
function makeJwt(header: object, payload: object) {
|
|
@@ -552,6 +622,18 @@ test("emoji validations", () => {
|
|
|
552
622
|
expect(() => emoji.parse("๐ is an emoji")).toThrow();
|
|
553
623
|
expect(() => emoji.parse("๐stuff")).toThrow();
|
|
554
624
|
expect(() => emoji.parse("stuff๐")).toThrow();
|
|
625
|
+
|
|
626
|
+
emoji.parse("1\u{FE0F}\u{20E3}"); // keycap sequences stay valid
|
|
627
|
+
emoji.parse("#\u{FE0F}\u{20E3}");
|
|
628
|
+
|
|
629
|
+
// `\p{Emoji_Component}` alone covers ASCII digits, "#", "*", ZWJ, variation selectors and skin tone modifiers; none is an emoji without a base, so a component-only string is not one either
|
|
630
|
+
expect(() => emoji.parse("123")).toThrow();
|
|
631
|
+
expect(() => emoji.parse("#")).toThrow();
|
|
632
|
+
expect(() => emoji.parse("*")).toThrow();
|
|
633
|
+
expect(() => emoji.parse("\u{200D}")).toThrow();
|
|
634
|
+
expect(() => emoji.parse("\u{FE0F}")).toThrow();
|
|
635
|
+
expect(() => emoji.parse("\u{1F3FD}")).toThrow();
|
|
636
|
+
expect(() => emoji.parse("1\u{FE0F}")).toThrow();
|
|
555
637
|
});
|
|
556
638
|
|
|
557
639
|
test("nanoid", () => {
|
|
@@ -1264,6 +1346,18 @@ test("hostname", () => {
|
|
|
1264
1346
|
expect(() => hostname.parse("example..com")).toThrow();
|
|
1265
1347
|
});
|
|
1266
1348
|
|
|
1349
|
+
test("currency code", () => {
|
|
1350
|
+
const currency = z.currencyCode();
|
|
1351
|
+
for (const code of ["USD", "EUR", "XXX", "XCG", "XAD"]) expect(currency.parse(code)).toBe(code);
|
|
1352
|
+
for (const input of ["", "usd", "US", "USDX", " USD", "ANG", "BGN"])
|
|
1353
|
+
expect(currency.safeParse(input).success).toBe(false);
|
|
1354
|
+
expect(currency.safeParse("usd").error!.issues[0]).toMatchObject({
|
|
1355
|
+
code: "invalid_format",
|
|
1356
|
+
format: "currency_code",
|
|
1357
|
+
message: "Invalid currency code",
|
|
1358
|
+
});
|
|
1359
|
+
});
|
|
1360
|
+
|
|
1267
1361
|
test("hash validation", () => {
|
|
1268
1362
|
// MD5 tests
|
|
1269
1363
|
const md5hex = z.hash("md5");
|
|
@@ -565,7 +565,7 @@ test("regexes", () => {
|
|
|
565
565
|
`"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"`
|
|
566
566
|
);
|
|
567
567
|
expect(email._zod.pattern.source).toMatchInlineSnapshot(
|
|
568
|
-
`"^(
|
|
568
|
+
`"^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"`
|
|
569
569
|
);
|
|
570
570
|
// expect(ip._zod.pattern.source).toMatchInlineSnapshot(
|
|
571
571
|
// `"^(^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$)|(^(([a-fA-F0-9]{1,4}:){7}|::([a-fA-F0-9]{1,4}:){0,6}|([a-fA-F0-9]{1,4}:){1}:([a-fA-F0-9]{1,4}:){0,5}|([a-fA-F0-9]{1,4}:){2}:([a-fA-F0-9]{1,4}:){0,4}|([a-fA-F0-9]{1,4}:){3}:([a-fA-F0-9]{1,4}:){0,3}|([a-fA-F0-9]{1,4}:){4}:([a-fA-F0-9]{1,4}:){0,2}|([a-fA-F0-9]{1,4}:){5}:([a-fA-F0-9]{1,4}:){0,1})([a-fA-F0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$)$"`
|
|
@@ -778,3 +778,35 @@ test("template literal parsing - failure - issue format", () => {
|
|
|
778
778
|
}
|
|
779
779
|
`);
|
|
780
780
|
});
|
|
781
|
+
|
|
782
|
+
test("part patterns fold checks through wrappers and unions", () => {
|
|
783
|
+
// a constrained string keeps its bounds under a wrapper and inside a union
|
|
784
|
+
const wrapped = z.templateLiteral(["a-", z.string().min(2).max(3).optional()]);
|
|
785
|
+
expect(wrapped.safeParse("a-").success).toBe(true);
|
|
786
|
+
expect(wrapped.safeParse("a-xy").success).toBe(true);
|
|
787
|
+
expect(wrapped.safeParse("a-x").success).toBe(false);
|
|
788
|
+
expect(wrapped.safeParse("a-wxyz").success).toBe(false);
|
|
789
|
+
|
|
790
|
+
const union = z.templateLiteral(["", z.union([z.string().regex(/^[a-c]+$/), z.number().int()])]);
|
|
791
|
+
expect(union.safeParse("abc").success).toBe(true);
|
|
792
|
+
expect(union.safeParse("12").success).toBe(true);
|
|
793
|
+
expect(union.safeParse("xyz").success).toBe(false);
|
|
794
|
+
expect(union.safeParse("1.5").success).toBe(false);
|
|
795
|
+
|
|
796
|
+
// an empty length range matches nothing rather than building an invalid quantifier
|
|
797
|
+
const empty = z.templateLiteral(["", z.string().min(8).length(5)]);
|
|
798
|
+
expect(empty.safeParse("abcde").success).toBe(false);
|
|
799
|
+
|
|
800
|
+
// lazy resolves its inner schema on the internals, not the def
|
|
801
|
+
const lazy = z.templateLiteral(["", z.lazy(() => z.string().min(2)).optional()]);
|
|
802
|
+
expect(lazy.safeParse("x").success).toBe(false);
|
|
803
|
+
expect(lazy.safeParse("xy").success).toBe(true);
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
test("an embedded email does not constrain the other parts", () => {
|
|
807
|
+
const schema = z.templateLiteral([z.email(), "|", z.string()]);
|
|
808
|
+
expect(schema.safeParse("a@b.cc|a..b").success).toBe(true);
|
|
809
|
+
expect(schema.safeParse("a@b.cc|xy").success).toBe(true);
|
|
810
|
+
expect(schema.safeParse("a..b@b.cc|xy").success).toBe(false);
|
|
811
|
+
expect(schema.safeParse(".a@b.cc|xy").success).toBe(false);
|
|
812
|
+
});
|