@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
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
1
|
+
import { expect, expectTypeOf, test } from "vitest";
|
|
2
2
|
|
|
3
3
|
import * as z from "../../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
INVALID,
|
|
6
|
+
ZodCompileAsyncError,
|
|
7
|
+
ZodCompileUnsupportedError,
|
|
8
|
+
compile,
|
|
9
|
+
compileFn,
|
|
10
|
+
withParser,
|
|
11
|
+
} from "../compile.js";
|
|
12
|
+
import { $ZodAsyncError } from "../core.js";
|
|
5
13
|
|
|
6
14
|
// Differential helper: assert compiled schema matches the original on a value.
|
|
7
15
|
function expectMatch(schema: z.ZodType, value: unknown) {
|
|
@@ -1350,6 +1358,29 @@ test("runtime island inside array element", () => {
|
|
|
1350
1358
|
invalid(aot, ["a", true]);
|
|
1351
1359
|
});
|
|
1352
1360
|
|
|
1361
|
+
test("an island thrown from inside an indented block leaves the indent level alone", () => {
|
|
1362
|
+
// nullable opens an indented block, coerce throws inside it, and the property islands the pair — two of them so a leak compounds
|
|
1363
|
+
const schema = z.object({ a: z.coerce.number().nullable(), b: z.coerce.number().nullable(), tail: z.string() });
|
|
1364
|
+
expect(compileFn(schema, { debug: true }).code).toMatchInlineSnapshot(`
|
|
1365
|
+
"// Constants: INVALID, c0, c1, c2
|
|
1366
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return INVALID;
|
|
1367
|
+
const v0 = input["a"];
|
|
1368
|
+
if (!("a" in input)) return INVALID;
|
|
1369
|
+
const v1 = c1(c0, v0);
|
|
1370
|
+
if (v1 === INVALID) return INVALID;
|
|
1371
|
+
const v2 = input["b"];
|
|
1372
|
+
if (!("b" in input)) return INVALID;
|
|
1373
|
+
const v3 = c1(c2, v2);
|
|
1374
|
+
if (v3 === INVALID) return INVALID;
|
|
1375
|
+
const v4 = input["tail"];
|
|
1376
|
+
if (typeof v4 !== "string") return INVALID;
|
|
1377
|
+
const v5 = { "a": v1, "b": v3, "tail": v4 };
|
|
1378
|
+
return v5;"
|
|
1379
|
+
`);
|
|
1380
|
+
expectMatch(schema, { a: "1", b: null, tail: "x" });
|
|
1381
|
+
expectMatch(schema, { a: "nope", b: null, tail: "x" });
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1353
1384
|
test("url string-format check never assigns to its accessor", () => {
|
|
1354
1385
|
// const accessor (array element): previously emitted `elem = normalized`,
|
|
1355
1386
|
// a TypeError on valid input.
|
|
@@ -1417,6 +1448,26 @@ test("xor and custom when-gated checks force runtime fallback", () => {
|
|
|
1417
1448
|
expectMatch(z.object({ n: gated }), { n: 3 }); // runtime skips the gated check
|
|
1418
1449
|
});
|
|
1419
1450
|
|
|
1451
|
+
test("compiled parse surfaces the interpreter's throws through the fallback", () => {
|
|
1452
|
+
// an unmergeable intersection bails to INVALID, and the fallback it hands to raises the interpreter's own error
|
|
1453
|
+
const unmergeable = compile(
|
|
1454
|
+
z.intersection(
|
|
1455
|
+
z.number(),
|
|
1456
|
+
z.number().transform((x) => x + 1)
|
|
1457
|
+
),
|
|
1458
|
+
{ strict: true }
|
|
1459
|
+
);
|
|
1460
|
+
expect(() => unmergeable.parse(1234)).toThrowErrorMatchingInlineSnapshot(
|
|
1461
|
+
`[Error: Unmergable intersection. Error path: []]`
|
|
1462
|
+
);
|
|
1463
|
+
|
|
1464
|
+
// a when-gated check islands at codegen, and the island's INVALID for an async run reaches the same fallback
|
|
1465
|
+
const gated = z.number().refine(() => Promise.resolve(true));
|
|
1466
|
+
(gated._zod.def.checks![0]!._zod.def as { when?: unknown }).when = () => true;
|
|
1467
|
+
const compiled = compile(z.object({ n: gated }), { strict: true });
|
|
1468
|
+
expect(() => compiled.parse({ n: 3 })).toThrow($ZodAsyncError);
|
|
1469
|
+
});
|
|
1470
|
+
|
|
1420
1471
|
test("strict objects reject inherited enumerable keys like the runtime", () => {
|
|
1421
1472
|
const schema = z.strictObject({ a: z.string() });
|
|
1422
1473
|
expectMatch(schema, Object.assign(Object.create({ extra: 1 }), { a: "x" }));
|
|
@@ -1637,3 +1688,349 @@ test("strict is per-call, so a supported schema compiles either way", () => {
|
|
|
1637
1688
|
invalid(aot, { a: 1, b: 1 });
|
|
1638
1689
|
}
|
|
1639
1690
|
});
|
|
1691
|
+
|
|
1692
|
+
test("compiled records walk own enumerable keys without Reflect.ownKeys", () => {
|
|
1693
|
+
// a getOwnPropertyNames snapshot plus a per-key recheck sees the same keys as the runtime's Reflect.ownKeys walk: inherited enumerables are skipped, symbols fail a string key schema but pass a symbol one, and the numeric-string retry still applies
|
|
1694
|
+
const sym = Symbol("s");
|
|
1695
|
+
const bare = compile(z.record(z.string(), z.number()));
|
|
1696
|
+
const inherited = Object.assign(Object.create({ proto: 1 }), { a: 1 });
|
|
1697
|
+
expect(bare.parse(inherited)).toEqual({ a: 1 });
|
|
1698
|
+
const symbolic = { a: 1, [sym]: 2 };
|
|
1699
|
+
expect(bare.safeParse(symbolic).error!.issues).toEqual(
|
|
1700
|
+
z.record(z.string(), z.number()).safeParse(symbolic).error!.issues
|
|
1701
|
+
);
|
|
1702
|
+
expect(bare.safeParse({ a: 1, b: "x" }).error!.issues).toEqual(
|
|
1703
|
+
z.record(z.string(), z.number()).safeParse({ a: 1, b: "x" }).error!.issues
|
|
1704
|
+
);
|
|
1705
|
+
const symKeys = compile(z.record(z.symbol(), z.number()));
|
|
1706
|
+
expect(symKeys.parse({ [sym]: 2 })).toEqual({ [sym]: 2 });
|
|
1707
|
+
expect(symKeys.safeParse({ a: 1 }).success).toBe(false);
|
|
1708
|
+
const emailKeys = compile(z.record(z.email(), z.number()));
|
|
1709
|
+
expect(emailKeys.parse({ "a@b.co": 1 })).toEqual({ "a@b.co": 1 });
|
|
1710
|
+
expect(emailKeys.safeParse({ "a@b.co": 1, [sym]: 2 }).success).toBe(false);
|
|
1711
|
+
expect(compile(z.record(z.number(), z.string())).parse({ 1: "a" })).toEqual({ 1: "a" });
|
|
1712
|
+
// keys are snapshotted before any value is read and rechecked when visited, like the runtime's Reflect.ownKeys walk: a getter that adds a key mid-walk is not visited, one that hides a later key skips it
|
|
1713
|
+
const mutating = (effect: (o: Record<PropertyKey, unknown>) => void) => {
|
|
1714
|
+
const o: Record<PropertyKey, unknown> = {};
|
|
1715
|
+
Object.defineProperty(o, "a", {
|
|
1716
|
+
enumerable: true,
|
|
1717
|
+
get() {
|
|
1718
|
+
effect(o);
|
|
1719
|
+
return 1;
|
|
1720
|
+
},
|
|
1721
|
+
});
|
|
1722
|
+
o.b = 2;
|
|
1723
|
+
return o;
|
|
1724
|
+
};
|
|
1725
|
+
const both = z.record(z.union([z.string(), z.symbol()]), z.number());
|
|
1726
|
+
for (const [schema, effect] of [
|
|
1727
|
+
[
|
|
1728
|
+
both,
|
|
1729
|
+
(o: Record<PropertyKey, unknown>) => {
|
|
1730
|
+
o[sym] = 2;
|
|
1731
|
+
},
|
|
1732
|
+
],
|
|
1733
|
+
[
|
|
1734
|
+
z.record(z.string(), z.number()),
|
|
1735
|
+
(o: Record<PropertyKey, unknown>) => {
|
|
1736
|
+
o[sym] = "bad";
|
|
1737
|
+
},
|
|
1738
|
+
],
|
|
1739
|
+
[
|
|
1740
|
+
z.record(z.string(), z.number()),
|
|
1741
|
+
(o: Record<PropertyKey, unknown>) => {
|
|
1742
|
+
o.z = "bad";
|
|
1743
|
+
},
|
|
1744
|
+
],
|
|
1745
|
+
[
|
|
1746
|
+
z.record(z.string(), z.number()),
|
|
1747
|
+
(o: Record<PropertyKey, unknown>) => Object.defineProperty(o, "b", { enumerable: false }),
|
|
1748
|
+
],
|
|
1749
|
+
] as const) {
|
|
1750
|
+
const expected = schema.safeParse(mutating(effect));
|
|
1751
|
+
const actual = compile(schema).safeParse(mutating(effect));
|
|
1752
|
+
expect(actual.success).toBe(expected.success);
|
|
1753
|
+
if (expected.success)
|
|
1754
|
+
expect(Reflect.ownKeys(actual.data as object)).toEqual(Reflect.ownKeys(expected.data as object));
|
|
1755
|
+
else expect(actual.error!.issues).toEqual(expected.error!.issues);
|
|
1756
|
+
}
|
|
1757
|
+
// a getter that defines an own key under an inherited enumerable name mid-walk: the snapshot predates it, so neither walk visits it, and a union that accepts the record cannot be corrected by a fallback
|
|
1758
|
+
const shadowing = () => {
|
|
1759
|
+
const o = Object.create({ z: 0 });
|
|
1760
|
+
Object.defineProperty(o, "a", {
|
|
1761
|
+
enumerable: true,
|
|
1762
|
+
get() {
|
|
1763
|
+
Object.defineProperty(o, "z", { value: 2, enumerable: true });
|
|
1764
|
+
return 1;
|
|
1765
|
+
},
|
|
1766
|
+
});
|
|
1767
|
+
return o;
|
|
1768
|
+
};
|
|
1769
|
+
const inUnion = z.union([z.record(z.string(), z.number()), z.any()]);
|
|
1770
|
+
expect(compile(inUnion).parse(shadowing())).toStrictEqual(inUnion.parse(shadowing()));
|
|
1771
|
+
expect(compile(inUnion).parse(shadowing())).toStrictEqual({ a: 1 });
|
|
1772
|
+
// a key that is non-enumerable at snapshot time and revealed by an earlier getter is in the snapshot and passes the recheck, like the runtime
|
|
1773
|
+
const revealing = () => {
|
|
1774
|
+
const o: Record<string, unknown> = {};
|
|
1775
|
+
Object.defineProperty(o, "a", {
|
|
1776
|
+
enumerable: true,
|
|
1777
|
+
get() {
|
|
1778
|
+
Object.defineProperty(o, "b", { enumerable: true });
|
|
1779
|
+
return 1;
|
|
1780
|
+
},
|
|
1781
|
+
});
|
|
1782
|
+
Object.defineProperty(o, "b", { value: 2, enumerable: false, configurable: true });
|
|
1783
|
+
return o;
|
|
1784
|
+
};
|
|
1785
|
+
const plain = z.record(z.string(), z.number());
|
|
1786
|
+
expect(compile(plain).parse(revealing())).toStrictEqual(plain.parse(revealing()));
|
|
1787
|
+
expect(compile(plain).parse(revealing())).toStrictEqual({ a: 1, b: 2 });
|
|
1788
|
+
});
|
|
1789
|
+
|
|
1790
|
+
test("validate honors custom checks composed with format traits", () => {
|
|
1791
|
+
const postProcessor = z.core.globalConfig.postProcessor;
|
|
1792
|
+
z.core.globalConfig.postProcessor = undefined;
|
|
1793
|
+
try {
|
|
1794
|
+
const CustomEmail = z.core.$constructor<z.core.$ZodEmail>("CustomEmail", (inst, def) => {
|
|
1795
|
+
inst._zod.check = (payload) => {
|
|
1796
|
+
if (payload.value !== "custom") payload.issues.push({ code: "custom", input: payload.value });
|
|
1797
|
+
};
|
|
1798
|
+
z.core.$ZodEmail.init(inst, def);
|
|
1799
|
+
});
|
|
1800
|
+
const schema = new CustomEmail({ type: "string", format: "email", check: "string_format" });
|
|
1801
|
+
for (const [input, valid] of [
|
|
1802
|
+
["custom", true],
|
|
1803
|
+
["test@example.com", false],
|
|
1804
|
+
[42, false],
|
|
1805
|
+
] as const) {
|
|
1806
|
+
expect(z.safeParse(schema, input).success).toBe(valid);
|
|
1807
|
+
expect(z.validate(schema, input)).toBe(valid);
|
|
1808
|
+
}
|
|
1809
|
+
} finally {
|
|
1810
|
+
z.core.globalConfig.postProcessor = postProcessor;
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1813
|
+
|
|
1814
|
+
test("validate honors standalone format checks", () => {
|
|
1815
|
+
const cases = [
|
|
1816
|
+
[z.iso.datetime(), "2021-01-01T00:00:00Z"],
|
|
1817
|
+
[z.iso.date(), "2021-01-01"],
|
|
1818
|
+
[z.iso.time(), "00:00:00"],
|
|
1819
|
+
[z.iso.duration(), "P1Y2M3DT4H5M6S"],
|
|
1820
|
+
[z.email(), "test@example.com"],
|
|
1821
|
+
[z.uuid(), "20354d7a-e4fe-47af-8ff6-187bca92f3f9"],
|
|
1822
|
+
[z.ipv4(), "192.168.0.1"],
|
|
1823
|
+
] as const;
|
|
1824
|
+
|
|
1825
|
+
for (const [schema, valid] of cases) {
|
|
1826
|
+
expect(schema._zod.traits.has("$ZodStringFormat")).toBe(true);
|
|
1827
|
+
expect(schema instanceof z.core.$ZodStringFormat).toBe(true);
|
|
1828
|
+
expect(z.validate(schema, valid)).toBe(true);
|
|
1829
|
+
expect(z.validate(schema, "invalid")).toBe(false);
|
|
1830
|
+
expect(z.validate(schema, 1)).toBe(false);
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
const source = z.email();
|
|
1834
|
+
const refined = source.refine((value) => value.startsWith("x"));
|
|
1835
|
+
const asyncRefined = source.refine(async () => true);
|
|
1836
|
+
const coercedDef = Object.assign(Object.create({ coerce: true }), source._zod.def);
|
|
1837
|
+
const coerced = source.clone(coercedDef);
|
|
1838
|
+
const checkedDef = Object.assign(Object.create({ checks: refined._zod.def.checks }), source._zod.def);
|
|
1839
|
+
const inheritedChecked = source.clone(checkedDef);
|
|
1840
|
+
expect(z.validate(refined, "test@example.com")).toBe(false);
|
|
1841
|
+
expect(z.validate(refined, "x@example.com")).toBe(true);
|
|
1842
|
+
expect(z.validate(inheritedChecked, "test@example.com")).toBe(false);
|
|
1843
|
+
expect(() => z.validate(asyncRefined, "test@example.com")).toThrow($ZodAsyncError);
|
|
1844
|
+
expect(z.validate(coerced, { toString: () => "test@example.com" })).toBe(true);
|
|
1845
|
+
});
|
|
1846
|
+
|
|
1847
|
+
test("runtime validate preserves contexts, getters, errors, and regex state", () => {
|
|
1848
|
+
const postProcessor = z.core.globalConfig.postProcessor;
|
|
1849
|
+
z.core.globalConfig.postProcessor = undefined;
|
|
1850
|
+
try {
|
|
1851
|
+
const source = z.email();
|
|
1852
|
+
expect(z.validate(source, "invalid", { skipChecks: true } as any)).toBe(true);
|
|
1853
|
+
|
|
1854
|
+
let whenReads = 0;
|
|
1855
|
+
const whenProto = Object.defineProperty({}, "when", {
|
|
1856
|
+
enumerable: true,
|
|
1857
|
+
get() {
|
|
1858
|
+
whenReads++;
|
|
1859
|
+
return () => false;
|
|
1860
|
+
},
|
|
1861
|
+
});
|
|
1862
|
+
const whenDef = Object.assign(Object.create(whenProto), source._zod.def);
|
|
1863
|
+
const gated = source.clone(whenDef as typeof source._zod.def);
|
|
1864
|
+
expect(whenReads).toBe(0);
|
|
1865
|
+
expect(z.validate(gated, "invalid")).toBe(true);
|
|
1866
|
+
expect(whenReads).toBeGreaterThan(0);
|
|
1867
|
+
|
|
1868
|
+
let errorReads = 0;
|
|
1869
|
+
const errorDef = Object.defineProperties({}, Object.getOwnPropertyDescriptors(source._zod.def));
|
|
1870
|
+
Object.defineProperty(errorDef, "error", {
|
|
1871
|
+
enumerable: true,
|
|
1872
|
+
get() {
|
|
1873
|
+
errorReads++;
|
|
1874
|
+
return () => "custom";
|
|
1875
|
+
},
|
|
1876
|
+
});
|
|
1877
|
+
const customError = source.clone(errorDef as typeof source._zod.def);
|
|
1878
|
+
expect(z.validate(customError, "invalid")).toBe(false);
|
|
1879
|
+
expect(errorReads).toBe(0);
|
|
1880
|
+
const result = customError.safeParse("invalid");
|
|
1881
|
+
expect(errorReads).toBe(0);
|
|
1882
|
+
if (result.success) expect.unreachable();
|
|
1883
|
+
expect(result.error.issues[0]?.message).toBe("custom");
|
|
1884
|
+
expect(errorReads).toBeGreaterThan(0);
|
|
1885
|
+
|
|
1886
|
+
const pattern = /^a$/g;
|
|
1887
|
+
const cloned = source.clone({ ...source._zod.def, pattern });
|
|
1888
|
+
for (let i = 0; i < 3; i++) expect(z.validate(cloned, "a")).toBe(true);
|
|
1889
|
+
expect(z.validate(cloned, "b")).toBe(false);
|
|
1890
|
+
expect(pattern.lastIndex).toBe(0);
|
|
1891
|
+
const replacement = /^b$/g;
|
|
1892
|
+
cloned._zod.def.pattern = replacement;
|
|
1893
|
+
expect(z.validate(cloned, "a")).toBe(false);
|
|
1894
|
+
expect(z.validate(cloned, "b")).toBe(true);
|
|
1895
|
+
} finally {
|
|
1896
|
+
z.core.globalConfig.postProcessor = postProcessor;
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
|
|
1900
|
+
test("validate preserves live pattern accessor reads", () => {
|
|
1901
|
+
const postProcessor = z.core.globalConfig.postProcessor;
|
|
1902
|
+
z.core.globalConfig.postProcessor = undefined;
|
|
1903
|
+
try {
|
|
1904
|
+
const schema = z.email();
|
|
1905
|
+
let reads = 0;
|
|
1906
|
+
Object.defineProperty(schema.def, "pattern", {
|
|
1907
|
+
get: () => (++reads % 2 === 1 ? /^a$/ : /^b$/),
|
|
1908
|
+
});
|
|
1909
|
+
expect(schema.safeParse("b").success).toBe(true);
|
|
1910
|
+
expect(reads).toBe(2);
|
|
1911
|
+
reads = 0;
|
|
1912
|
+
expect(z.validate(schema, "b")).toBe(true);
|
|
1913
|
+
expect(reads).toBe(2);
|
|
1914
|
+
} finally {
|
|
1915
|
+
z.core.globalConfig.postProcessor = postProcessor;
|
|
1916
|
+
}
|
|
1917
|
+
});
|
|
1918
|
+
|
|
1919
|
+
test.each(["when", "coerce"] as const)("runtime validate honors live %s options", (option) => {
|
|
1920
|
+
const postProcessor = z.core.globalConfig.postProcessor;
|
|
1921
|
+
z.core.globalConfig.postProcessor = undefined;
|
|
1922
|
+
try {
|
|
1923
|
+
for (const inherited of [false, true]) {
|
|
1924
|
+
const schema = z.email();
|
|
1925
|
+
const input = option === "when" ? "invalid" : { toString: () => "test@example.com" };
|
|
1926
|
+
expect(z.validate(schema, input)).toBe(false);
|
|
1927
|
+
|
|
1928
|
+
const target = inherited ? Object.create(Object.getPrototypeOf(schema.def)) : schema.def;
|
|
1929
|
+
let reads = 0;
|
|
1930
|
+
Object.defineProperty(target, option, {
|
|
1931
|
+
get() {
|
|
1932
|
+
reads++;
|
|
1933
|
+
return option === "when" ? () => false : true;
|
|
1934
|
+
},
|
|
1935
|
+
});
|
|
1936
|
+
if (inherited) Object.setPrototypeOf(schema.def, target);
|
|
1937
|
+
expect(reads).toBe(0);
|
|
1938
|
+
expect(z.validate(schema, input)).toBe(true);
|
|
1939
|
+
expect(reads).toBeGreaterThan(0);
|
|
1940
|
+
expect(schema.safeParse(input).success).toBe(true);
|
|
1941
|
+
}
|
|
1942
|
+
} finally {
|
|
1943
|
+
z.core.globalConfig.postProcessor = postProcessor;
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
|
|
1947
|
+
test("validate uses compiled validators and runtime fallbacks", () => {
|
|
1948
|
+
const compiled = compile(z.email());
|
|
1949
|
+
expect((compiled._zod.bag as { validator?: unknown }).validator).toBeTypeOf("function");
|
|
1950
|
+
expect(z.validate(compiled, "test@example.com")).toBe(true);
|
|
1951
|
+
expect(z.validate(compiled, "invalid")).toBe(false);
|
|
1952
|
+
expect(z.validate(compiled, "invalid", { skipChecks: true } as any)).toBe(true);
|
|
1953
|
+
|
|
1954
|
+
const source = z.email();
|
|
1955
|
+
const installed = withParser(source, () => INVALID);
|
|
1956
|
+
const bag = installed._zod.bag as { fallbackRun: typeof source._zod.run };
|
|
1957
|
+
const originalRun = bag.fallbackRun;
|
|
1958
|
+
let fallbackRuns = 0;
|
|
1959
|
+
bag.fallbackRun = (payload, ctx) => {
|
|
1960
|
+
fallbackRuns++;
|
|
1961
|
+
return originalRun(payload, ctx);
|
|
1962
|
+
};
|
|
1963
|
+
expect(z.validate(installed, "invalid")).toBe(false);
|
|
1964
|
+
expect(fallbackRuns).toBeGreaterThan(0);
|
|
1965
|
+
});
|
|
1966
|
+
|
|
1967
|
+
// withParser: a parser Zod did not generate, installed on the same wrapper compile() uses.
|
|
1968
|
+
|
|
1969
|
+
// tags its output so a test fails loudly if the runtime ran instead of the supplied parser
|
|
1970
|
+
function taggedParser(input: unknown) {
|
|
1971
|
+
if (typeof input !== "object" || input === null) return INVALID;
|
|
1972
|
+
const o = input as Record<string, unknown>;
|
|
1973
|
+
if (typeof o.a !== "string") return INVALID;
|
|
1974
|
+
return { a: o.a, tag: "supplied" };
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
const withParserSchema = z.object({ a: z.string() });
|
|
1978
|
+
|
|
1979
|
+
test("withParser installs the supplied parser", () => {
|
|
1980
|
+
const installed = withParser(withParserSchema, taggedParser);
|
|
1981
|
+
expect(installed.parse({ a: "x" })).toStrictEqual({ a: "x", tag: "supplied" });
|
|
1982
|
+
// the clone is a new schema; the original keeps the runtime
|
|
1983
|
+
expect(installed).not.toBe(withParserSchema);
|
|
1984
|
+
expect(withParserSchema.parse({ a: "x" })).toStrictEqual({ a: "x" });
|
|
1985
|
+
});
|
|
1986
|
+
|
|
1987
|
+
test("withParser hands INVALID to the runtime and gets a real ZodError", () => {
|
|
1988
|
+
const installed = withParser(withParserSchema, taggedParser);
|
|
1989
|
+
const result = installed.safeParse({ a: 1 });
|
|
1990
|
+
expect(result.success).toBe(false);
|
|
1991
|
+
expect(result.error!.issues).toEqual(withParserSchema.safeParse({ a: 1 }).error!.issues);
|
|
1992
|
+
});
|
|
1993
|
+
|
|
1994
|
+
test("withParser answers validate with the supplied parser", () => {
|
|
1995
|
+
const installed = withParser(withParserSchema, taggedParser);
|
|
1996
|
+
expect(z.validate(installed, { a: "x" })).toBe(true);
|
|
1997
|
+
expect(z.validate(installed, { a: 1 })).toBe(false);
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
test("withParser bypasses the fast path on async, like compile()", async () => {
|
|
2001
|
+
const installed = withParser(withParserSchema, taggedParser);
|
|
2002
|
+
// async runs on the runtime, so the tag is absent
|
|
2003
|
+
await expect(installed.parseAsync({ a: "x" })).resolves.toStrictEqual({ a: "x" });
|
|
2004
|
+
});
|
|
2005
|
+
|
|
2006
|
+
test("withParser reaches a parse it does not own the call site of", () => {
|
|
2007
|
+
const installed = withParser(withParserSchema, taggedParser);
|
|
2008
|
+
// installing on _zod.run rather than wrapping a call site is the whole point: a framework holding the schema gets the supplied parser through Standard Schema, and so does z.parse
|
|
2009
|
+
expect((installed["~standard"].validate({ a: "x" }) as { value: unknown }).value).toStrictEqual({
|
|
2010
|
+
a: "x",
|
|
2011
|
+
tag: "supplied",
|
|
2012
|
+
});
|
|
2013
|
+
expect(z.parse(installed, { a: "x" })).toStrictEqual({ a: "x", tag: "supplied" });
|
|
2014
|
+
});
|
|
2015
|
+
|
|
2016
|
+
test("withParser refuses a recursive schema", () => {
|
|
2017
|
+
type Node = { next: Node | null };
|
|
2018
|
+
const Node: z.ZodType<Node> = z.object({ next: z.lazy(() => z.nullable(Node)) });
|
|
2019
|
+
expect(() => withParser(Node, () => INVALID)).toThrow(ZodCompileUnsupportedError);
|
|
2020
|
+
});
|
|
2021
|
+
|
|
2022
|
+
test("withParser leaves encode on the runtime", () => {
|
|
2023
|
+
const codec = z.codec(z.string(), z.number(), {
|
|
2024
|
+
decode: (s) => Number(s),
|
|
2025
|
+
encode: (n) => String(n),
|
|
2026
|
+
});
|
|
2027
|
+
const installed = withParser(codec, () => INVALID);
|
|
2028
|
+
expect(z.encode(installed, 5)).toBe("5");
|
|
2029
|
+
});
|
|
2030
|
+
|
|
2031
|
+
test("withParser rejects a parser whose output contradicts the schema", () => {
|
|
2032
|
+
// the returned schema still claims T, so a parser that succeeds with something else would make parse() lie about its own type
|
|
2033
|
+
// @ts-expect-error a number is not the output of z.string()
|
|
2034
|
+
withParser(z.string(), () => 123);
|
|
2035
|
+
expectTypeOf(withParser(z.string(), () => "ok")).toEqualTypeOf<z.ZodString>();
|
|
2036
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { regexes } from "zod/v4/core";
|
|
4
|
+
|
|
5
|
+
// the lookahead form `regexes.email` had before this rewrite
|
|
6
|
+
const legacy = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
7
|
+
|
|
8
|
+
const table: [string, boolean][] = [
|
|
9
|
+
["a@b.cc", true],
|
|
10
|
+
["first.last@example.com", true],
|
|
11
|
+
["a.b.c.d@b.cc", true],
|
|
12
|
+
["'a@b.cc", true],
|
|
13
|
+
["a'b@b.cc", true],
|
|
14
|
+
["a+b@b.cc", true],
|
|
15
|
+
["a-@b.cc", true],
|
|
16
|
+
["a_@b.cc", true],
|
|
17
|
+
["a@0b.cc", true],
|
|
18
|
+
["a@b.c.dd", true],
|
|
19
|
+
["a@b-.cc", true],
|
|
20
|
+
[".a@b.cc", false],
|
|
21
|
+
["a.@b.cc", false],
|
|
22
|
+
["a..b@b.cc", false],
|
|
23
|
+
["....@b.cc", false],
|
|
24
|
+
["a@b..cc", false],
|
|
25
|
+
["a@.b.cc", false],
|
|
26
|
+
["a@b.cc.", false],
|
|
27
|
+
["a'@b.cc", false],
|
|
28
|
+
["'@b.cc", false],
|
|
29
|
+
["@b.cc", false],
|
|
30
|
+
["a@b.c", false],
|
|
31
|
+
["a@b.c0", false],
|
|
32
|
+
["a@-b.cc", false],
|
|
33
|
+
["a@b.cc@d.ee", false],
|
|
34
|
+
["a b@b.cc", false],
|
|
35
|
+
["café@b.cc", false],
|
|
36
|
+
["😀@b.cc", false],
|
|
37
|
+
["a\0@b.cc", false],
|
|
38
|
+
// `$` is not multiline, so no trailing terminator is tolerated
|
|
39
|
+
["a@b.cc\n", false],
|
|
40
|
+
["a@b.cc\r", false],
|
|
41
|
+
["\na@b.cc", false],
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
test("boundary cases", () => {
|
|
45
|
+
for (const [input, expected] of table) {
|
|
46
|
+
expect([input, regexes.email.test(input)]).toEqual([input, expected]);
|
|
47
|
+
expect([input, legacy.test(input)]).toEqual([input, expected]);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// one representative per character class the two grammars can tell apart
|
|
52
|
+
const classes = ["a", "0", "_", "'", "-", ".", "@", "!", "\n"];
|
|
53
|
+
|
|
54
|
+
test("exhaustive agreement over every string of length <= 6 in the class alphabet", () => {
|
|
55
|
+
const idx: number[] = [];
|
|
56
|
+
let accepted = 0;
|
|
57
|
+
for (let len = 0; len <= 6; len++) {
|
|
58
|
+
idx.length = len;
|
|
59
|
+
idx.fill(0);
|
|
60
|
+
for (;;) {
|
|
61
|
+
let s = "";
|
|
62
|
+
for (let i = 0; i < len; i++) s += classes[idx[i]!];
|
|
63
|
+
const a = legacy.test(s);
|
|
64
|
+
if (a !== regexes.email.test(s)) expect.unreachable(`disagreement on ${JSON.stringify(s)}`);
|
|
65
|
+
if (a) accepted++;
|
|
66
|
+
let p = len - 1;
|
|
67
|
+
while (p >= 0 && ++idx[p]! === classes.length) idx[p--] = 0;
|
|
68
|
+
if (p < 0) break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// 4 chars can precede `@`, 2 can open a domain label, 1 is a letter for the TLD
|
|
72
|
+
expect(accepted).toBe(8);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
function rng(seed: number) {
|
|
76
|
+
let s = seed >>> 0;
|
|
77
|
+
return () => {
|
|
78
|
+
s = (s + 0x6d2b79f5) >>> 0;
|
|
79
|
+
let t = s;
|
|
80
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
81
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
82
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const local = "abZ09_'+-.".split("");
|
|
87
|
+
const domain = "abZ09-.".split("");
|
|
88
|
+
const hostile = ["@", ".", "..", "...", "\n", "\r", "\0", "\t", " ", '"', "é", "😀", "\\", "<", ";", "/", "{"];
|
|
89
|
+
const any = [...local, ...domain, ...hostile];
|
|
90
|
+
|
|
91
|
+
function fuzz(r: () => number): string {
|
|
92
|
+
const pick = <T>(xs: T[]): T => xs[Math.floor(r() * xs.length)]!;
|
|
93
|
+
const run = (xs: string[], max: number) => {
|
|
94
|
+
let out = "";
|
|
95
|
+
for (let i = Math.floor(r() * max); i > 0; i--) out += pick(xs);
|
|
96
|
+
return out;
|
|
97
|
+
};
|
|
98
|
+
switch (Math.floor(r() * 8)) {
|
|
99
|
+
case 0:
|
|
100
|
+
return run(any, 40);
|
|
101
|
+
case 1:
|
|
102
|
+
return `${run(local, 24)}@${run(domain, 24)}`;
|
|
103
|
+
case 2:
|
|
104
|
+
return `${run(local, 8)}${".".repeat(1 + Math.floor(r() * 6))}${run(local, 8)}@${run(domain, 12)}`;
|
|
105
|
+
case 3:
|
|
106
|
+
return `${run(local, 8)}@${run(domain, 8)}${".".repeat(1 + Math.floor(r() * 6))}${run(domain, 8)}`;
|
|
107
|
+
case 4: {
|
|
108
|
+
// single-character mutation of a valid address
|
|
109
|
+
const base = `${run("abZ09_'+-".split(""), 10)}@example.com`;
|
|
110
|
+
const i = Math.floor(r() * base.length);
|
|
111
|
+
return Math.floor(r() * 3) === 0
|
|
112
|
+
? base.slice(0, i) + pick(any) + base.slice(i)
|
|
113
|
+
: base.slice(0, i) + (Math.floor(r() * 2) ? pick(any) : "") + base.slice(i + 1);
|
|
114
|
+
}
|
|
115
|
+
case 5:
|
|
116
|
+
return (
|
|
117
|
+
"a".repeat(1 + Math.floor(r() * 60)) +
|
|
118
|
+
".".repeat(Math.floor(r() * 4)) +
|
|
119
|
+
run(local, 4) +
|
|
120
|
+
(r() < 0.5 ? "@" : "") +
|
|
121
|
+
run(domain, 10)
|
|
122
|
+
);
|
|
123
|
+
case 6:
|
|
124
|
+
return `${run(local, 8)}@${run(domain, 6)}@${run(domain, 8)}`;
|
|
125
|
+
default:
|
|
126
|
+
return pick(["", "\n", " "]) + run(local, 8) + "@example.com" + pick(["", "\n", "\r\n", " ", "\0"]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
test("differential fuzz", () => {
|
|
131
|
+
const r = rng(0x5eed);
|
|
132
|
+
let accepted = 0;
|
|
133
|
+
for (let i = 0; i < 25_000; i++) {
|
|
134
|
+
const s = fuzz(r);
|
|
135
|
+
const a = legacy.test(s);
|
|
136
|
+
if (a !== regexes.email.test(s)) expect.unreachable(`disagreement on ${JSON.stringify(s)}`);
|
|
137
|
+
if (a) accepted++;
|
|
138
|
+
}
|
|
139
|
+
expect(accepted).toBeGreaterThan(500);
|
|
140
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import * as z from "zod/v4";
|
|
3
|
+
|
|
4
|
+
test("locales - tg", () => {
|
|
5
|
+
z.config(z.locales.tg());
|
|
6
|
+
|
|
7
|
+
const invalidType = z.number().safeParse("a");
|
|
8
|
+
expect(invalidType.error!.issues[0].code).toBe("invalid_type");
|
|
9
|
+
expect(invalidType.error!.issues[0].message).toBe("Вуруди нодуруст: рақам интизор мерафт, сатр гирифта шуд");
|
|
10
|
+
|
|
11
|
+
const invalidType2 = z.string().safeParse(1);
|
|
12
|
+
expect(invalidType2.error!.issues[0].code).toBe("invalid_type");
|
|
13
|
+
expect(invalidType2.error!.issues[0].message).toBe("Вуруди нодуруст: сатр интизор мерафт, рақам гирифта шуд");
|
|
14
|
+
|
|
15
|
+
const invalidValue = z.enum(["a", "b"]).safeParse(1);
|
|
16
|
+
expect(invalidValue.error!.issues[0].code).toBe("invalid_value");
|
|
17
|
+
expect(invalidValue.error!.issues[0].message).toBe('Интихоби нодуруст: яке аз "a"|"b" интизор мерафт');
|
|
18
|
+
|
|
19
|
+
const tooBig = z.number().max(10).safeParse(15);
|
|
20
|
+
expect(tooBig.error!.issues[0].code).toBe("too_big");
|
|
21
|
+
expect(tooBig.error!.issues[0].message).toBe("Хеле калон: number бояд <=10 бошад");
|
|
22
|
+
|
|
23
|
+
const tooSmall = z.number().min(10).safeParse(5);
|
|
24
|
+
expect(tooSmall.error!.issues[0].code).toBe("too_small");
|
|
25
|
+
expect(tooSmall.error!.issues[0].message).toBe("Хеле хурд: number бояд >=10 бошад");
|
|
26
|
+
|
|
27
|
+
// singular units after numerals in Tajik
|
|
28
|
+
const tooShort = z.string().min(5).safeParse("hi");
|
|
29
|
+
expect(tooShort.error!.issues[0].message).toBe("Хеле хурд: string бояд >=5 аломат дошта бошад");
|
|
30
|
+
|
|
31
|
+
const tooFewItems = z.array(z.number()).min(2).safeParse([1]);
|
|
32
|
+
expect(tooFewItems.error!.issues[0].message).toBe("Хеле хурд: array бояд >=2 унсур дошта бошад");
|
|
33
|
+
|
|
34
|
+
const invalidEmail = z.string().email().safeParse("nope");
|
|
35
|
+
expect(invalidEmail.error!.issues[0].code).toBe("invalid_format");
|
|
36
|
+
expect(invalidEmail.error!.issues[0].message).toBe("суроғаи email-и нодуруст");
|
|
37
|
+
|
|
38
|
+
const invalidStart = z.string().startsWith("ab").safeParse("xy");
|
|
39
|
+
expect(invalidStart.error!.issues[0].message).toBe('Сатри нодуруст: бояд бо "ab" оғоз шавад');
|
|
40
|
+
|
|
41
|
+
const invalidRegex = z.string().regex(/abcd/).safeParse("xy");
|
|
42
|
+
expect(invalidRegex.error!.issues[0].message).toContain("мувофиқат кунад");
|
|
43
|
+
|
|
44
|
+
const notMultipleOf = z.number().multipleOf(5).safeParse(7);
|
|
45
|
+
expect(notMultipleOf.error!.issues[0].message).toBe("Рақами нодуруст: бояд ба 5 бе бақия тақсим шавад");
|
|
46
|
+
|
|
47
|
+
const oneUnknownKey = z.strictObject({ a: z.string() }).safeParse({ a: "x", b: 1 });
|
|
48
|
+
expect(oneUnknownKey.error!.issues[0].message).toBe('Калиди номаълум: "b"');
|
|
49
|
+
|
|
50
|
+
const twoUnknownKeys = z.strictObject({ a: z.string() }).safeParse({ a: "x", b: 1, c: 2 });
|
|
51
|
+
expect(twoUnknownKeys.error!.issues[0].message).toBe('Калидҳои номаълум: "b", "c"');
|
|
52
|
+
|
|
53
|
+
const cases: [z.ZodType, unknown, string][] = [
|
|
54
|
+
[z.literal("a"), "b", 'Вуруди нодуруст: "a" интизор мерафт'],
|
|
55
|
+
[z.boolean(), null, "Вуруди нодуруст: boolean интизор мерафт, null гирифта шуд"],
|
|
56
|
+
[z.number(), Number.NaN, "Вуруди нодуруст: рақам интизор мерафт, NaN гирифта шуд"],
|
|
57
|
+
[z.number().lt(10), 10, "Хеле калон: number бояд <10 бошад"],
|
|
58
|
+
[z.number().gt(10), 10, "Хеле хурд: number бояд >10 бошад"],
|
|
59
|
+
[z.string().max(1), "ab", "Хеле калон: string бояд <=1 аломат дошта бошад"],
|
|
60
|
+
[z.set(z.string()).min(1), new Set(), "Хеле хурд: set бояд >=1 унсур дошта бошад"],
|
|
61
|
+
[z.map(z.string(), z.number()).min(1), new Map(), "Хеле хурд: map бояд >=1 сабт дошта бошад"],
|
|
62
|
+
[z.file().min(1), new File([], "empty"), "Хеле хурд: file бояд >=1 байт дошта бошад"],
|
|
63
|
+
[z.string().endsWith("ab"), "xy", 'Сатри нодуруст: бояд бо "ab" анҷом ёбад'],
|
|
64
|
+
[z.string().includes("ab"), "xy", 'Сатри нодуруст: бояд "ab"-ро дар бар гирад'],
|
|
65
|
+
[z.stringFormat("custom", () => false), "xy", "custom-и нодуруст"],
|
|
66
|
+
[z.union([z.string(), z.number()]), null, "Вуруди нодуруст"],
|
|
67
|
+
[
|
|
68
|
+
z.discriminatedUnion("kind", [z.object({ kind: z.literal("a") }), z.object({ kind: z.literal("b") })]),
|
|
69
|
+
{ kind: "c" },
|
|
70
|
+
"Қимати нодурусти дискриминатор: 'a' | 'b' интизор мерафт",
|
|
71
|
+
],
|
|
72
|
+
[z.record(z.string().min(2), z.number()), { a: 1 }, "Калиди нодуруст дар record"],
|
|
73
|
+
[z.map(z.string(), z.number()), new Map([[{}, 1]]), "Калиди нодуруст дар map"],
|
|
74
|
+
[z.map(z.object({}), z.number()), new Map([[{}, "a"]]), "Қимати нодуруст дар map"],
|
|
75
|
+
[z.custom(() => false), "a", "Вуруди нодуруст"],
|
|
76
|
+
];
|
|
77
|
+
for (const [schema, input, message] of cases) {
|
|
78
|
+
expect(schema.safeParse(input).error!.issues[0].message).toBe(message);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
expect(z.object({ name: z.string().min(1), age: z.number().min(0) }).parse({ name: "Ali", age: 30 })).toEqual({
|
|
82
|
+
name: "Ali",
|
|
83
|
+
age: 30,
|
|
84
|
+
});
|
|
85
|
+
});
|