@openclaw/feishu 2026.9.4 → 2026.9.5
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/assets/activity.svg +3 -0
- package/assets/icon.png +0 -0
- package/dist/{accounts-cCMNFBKg.js → .setup/accounts-DmU0xYPx.mjs} +1 -1
- package/dist/{app-registration-BI99e_JI.js → .setup/app-registration-Bv4mvauR.mjs} +1 -1
- package/dist/{channel-HDnQAH4Z.js → .setup/channel-C1KrXXJa.mjs} +93 -86
- package/dist/{channel.runtime-B-f6ajOp.js → .setup/channel.runtime-Bizuv7WZ.mjs} +32 -18
- package/dist/{chat-zhIPXu4X.js → .setup/chat-dWJYS63b.mjs} +2 -2
- package/dist/{client-DMbIL3UH.js → .setup/client-DCwNVFZg.mjs} +128 -11
- package/dist/{conversation-id-VYgGQ-GX.js → .setup/conversation-id-H-lUayji.mjs} +49 -14
- package/dist/{monitor-EuNsFn2T.js → .setup/monitor-C69OLzgO.mjs} +4 -4
- package/dist/{monitor.account-CZ7EtqYS.js → .setup/monitor.account-zwHb3HKM.mjs} +68 -52
- package/dist/{probe-D_SatdZl.js → .setup/probe-bdidyhAn.mjs} +2 -2
- package/dist/{reply-delivery-result-C3smdVzb.js → .setup/reply-delivery-result-DFjxGLgX.mjs} +129 -116
- package/dist/.setup/runtime-setter-api-CG-RC4_r.mjs +3 -0
- package/dist/.setup/secret-contract-api-jmCkqVLc.mjs +3 -0
- package/dist/{security-audit-DKfR4Cv3.js → .setup/security-audit-CmiKKfU-.mjs} +1 -1
- package/dist/{session-conversation-DFCIvQK-.js → .setup/session-conversation-ZC6TC1zk.mjs} +1 -1
- package/dist/.setup/setup-api-CTRwX09n.mjs +3 -0
- package/dist/{subagent-hooks-Buadpie_.js → .setup/subagent-hooks-BBfF1hZk.mjs} +3 -19
- package/dist/api.js +29 -15
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +3 -3
- package/dist/doctor-contract-api.js +1 -1
- package/dist/runtime-api.js +1 -1
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +4 -3
- package/dist/subagent-hooks-api.js +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/es/index.js +199 -35
- package/node_modules/@larksuiteoapi/node-sdk/lib/index.js +199 -35
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/README.md +233 -5
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.js +387 -89
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/browser/axios.cjs +458 -98
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.js +458 -98
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/node/axios.cjs +568 -116
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.cts +4 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.ts +4 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/http.js +134 -50
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/Axios.js +19 -14
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/buildFullPath.js +1 -13
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/mergeConfig.js +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/toFormData.js +14 -21
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/utils.js +134 -13
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/package.json +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/README.md +24 -17
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.js +124 -14
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.js +63 -9
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.js +133 -18
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/descriptor.generated.d.ts +7 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/descriptor.js +24 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/protojson.js +14 -4
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/textformat.js +8 -4
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/google/protobuf/descriptor.json +20 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/google/protobuf/descriptor.proto +14 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/index.d.ts +12 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/package.json +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/decoder.js +31 -2
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/enum.js +10 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/object.js +5 -2
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/parse.js +9 -4
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/reader.js +61 -7
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/type.js +10 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/wrappers.js +5 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/.github/THREAT_MODEL.md +3 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/CHANGELOG.md +15 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/README.md +19 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/dist/qs.js +21 -21
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/eslint.config.mjs +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/parse.js +3 -4
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/stringify.js +23 -8
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/utils.js +10 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/package.json +4 -4
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/parse.js +192 -3
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/stringify.js +317 -0
- package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/utils.js +12 -0
- package/node_modules/@larksuiteoapi/node-sdk/package.json +1 -1
- package/node_modules/@larksuiteoapi/node-sdk/types/index.d.ts +35 -0
- package/node_modules/typebox/build/compile/validator.d.mts +1 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +7 -5
- package/node_modules/typebox/build/format/iri.mjs +5 -1
- package/node_modules/typebox/build/guard/emit.mjs +2 -4
- package/node_modules/typebox/build/guard/guard.mjs +6 -18
- package/node_modules/typebox/build/guard/string.mjs +16 -24
- package/node_modules/typebox/build/schema/build.mjs +2 -2
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/compile.d.mts +3 -2
- package/node_modules/typebox/build/schema/compile.mjs +8 -8
- package/node_modules/typebox/build/schema/engine/_context.d.mts +6 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +23 -15
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +4 -7
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +34 -16
- package/node_modules/typebox/build/schema/engine/_stack.mjs +148 -104
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -8
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +26 -18
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +3 -6
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +11 -7
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +7 -15
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -8
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +6 -11
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +4 -10
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +11 -7
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +19 -15
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +137 -133
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +5 -9
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +5 -9
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +2 -6
- package/node_modules/typebox/build/schema/errors.d.mts +2 -2
- package/node_modules/typebox/build/schema/errors.mjs +8 -14
- package/node_modules/typebox/build/schema/intern/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/intern/index.mjs +1 -0
- package/node_modules/typebox/build/schema/intern/intern.d.mts +11 -0
- package/node_modules/typebox/build/schema/intern/intern.mjs +293 -0
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +288 -0
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +300 -0
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +143 -0
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +149 -0
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +155 -0
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +172 -0
- package/node_modules/typebox/build/schema/meta/index.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/index.mjs +2 -0
- package/node_modules/typebox/build/schema/meta/meta.d.mts +9 -0
- package/node_modules/typebox/build/schema/meta/meta.mjs +15 -0
- package/node_modules/typebox/build/schema/meta/schema.d.mts +6 -0
- package/node_modules/typebox/build/schema/meta/schema.mjs +1 -0
- package/node_modules/typebox/build/schema/parse.d.mts +1 -0
- package/node_modules/typebox/build/schema/parse.mjs +10 -5
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +8 -3
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +268 -139
- package/node_modules/typebox/build/schema/schema.d.mts +2 -0
- package/node_modules/typebox/build/schema/schema.mjs +2 -0
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -12
- package/node_modules/typebox/build/value/errors/errors.mjs +2 -7
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +59 -89
- package/node_modules/zod/README.md +27 -0
- package/node_modules/zod/compile.cjs +77 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +2 -2
- package/node_modules/zod/index.d.cts +1 -2
- package/node_modules/zod/index.d.ts +1 -2
- package/node_modules/zod/index.js +5 -2
- package/node_modules/zod/package.json +13 -2
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +5 -2
- package/node_modules/zod/src/v3/ZodError.ts +22 -12
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
- package/node_modules/zod/src/v3/types.ts +5 -5
- package/node_modules/zod/src/v4/classic/checks.ts +1 -0
- package/node_modules/zod/src/v4/classic/compat.ts +26 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +59 -44
- package/node_modules/zod/src/v4/classic/external.ts +12 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +140 -78
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +10 -4
- package/node_modules/zod/src/v4/classic/schemas.ts +452 -262
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +135 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +30 -1
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +720 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +155 -13
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +11 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +274 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +425 -10
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +281 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +47 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +183 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +46 -9
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +245 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +234 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +33 -2
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +127 -5
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +11 -2
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1585 -173
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +48 -12
- package/node_modules/zod/src/v4/core/checks.ts +57 -44
- package/node_modules/zod/src/v4/core/compile.ts +2188 -0
- package/node_modules/zod/src/v4/core/core.ts +98 -19
- package/node_modules/zod/src/v4/core/doc.ts +11 -7
- package/node_modules/zod/src/v4/core/errors.ts +115 -24
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +6 -1
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +257 -93
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +284 -0
- package/node_modules/zod/src/v4/core/parse.ts +131 -38
- package/node_modules/zod/src/v4/core/regexes.ts +30 -13
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +759 -461
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +969 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +1639 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +31 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +275 -42
- package/node_modules/zod/src/v4/core/util.ts +268 -42
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +3 -0
- package/node_modules/zod/src/v4/locales/az.ts +3 -0
- package/node_modules/zod/src/v4/locales/be.ts +10 -0
- package/node_modules/zod/src/v4/locales/bg.ts +3 -0
- package/node_modules/zod/src/v4/locales/bn.ts +121 -0
- package/node_modules/zod/src/v4/locales/ca.ts +3 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +138 -0
- package/node_modules/zod/src/v4/locales/cs.ts +3 -0
- package/node_modules/zod/src/v4/locales/da.ts +5 -2
- package/node_modules/zod/src/v4/locales/de.ts +3 -0
- package/node_modules/zod/src/v4/locales/el.ts +1 -0
- package/node_modules/zod/src/v4/locales/en.ts +15 -4
- package/node_modules/zod/src/v4/locales/eo.ts +3 -0
- package/node_modules/zod/src/v4/locales/es.ts +2 -0
- package/node_modules/zod/src/v4/locales/fa.ts +3 -0
- package/node_modules/zod/src/v4/locales/fi.ts +3 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +3 -0
- package/node_modules/zod/src/v4/locales/fr.ts +19 -14
- package/node_modules/zod/src/v4/locales/gu.ts +121 -0
- package/node_modules/zod/src/v4/locales/he.ts +6 -1
- package/node_modules/zod/src/v4/locales/hi.ts +124 -0
- package/node_modules/zod/src/v4/locales/hr.ts +2 -0
- package/node_modules/zod/src/v4/locales/hu.ts +3 -0
- package/node_modules/zod/src/v4/locales/hy.ts +9 -0
- package/node_modules/zod/src/v4/locales/id.ts +3 -0
- package/node_modules/zod/src/v4/locales/index.ts +10 -0
- package/node_modules/zod/src/v4/locales/is.ts +3 -0
- package/node_modules/zod/src/v4/locales/it.ts +3 -0
- package/node_modules/zod/src/v4/locales/ja.ts +3 -0
- package/node_modules/zod/src/v4/locales/ka.ts +3 -0
- package/node_modules/zod/src/v4/locales/km.ts +3 -0
- package/node_modules/zod/src/v4/locales/kn.ts +124 -0
- package/node_modules/zod/src/v4/locales/ko.ts +3 -0
- package/node_modules/zod/src/v4/locales/lt.ts +2 -0
- package/node_modules/zod/src/v4/locales/mk.ts +3 -0
- package/node_modules/zod/src/v4/locales/ms.ts +3 -0
- package/node_modules/zod/src/v4/locales/ne.ts +126 -0
- package/node_modules/zod/src/v4/locales/nl.ts +3 -0
- package/node_modules/zod/src/v4/locales/nn.ts +119 -0
- package/node_modules/zod/src/v4/locales/no.ts +5 -2
- package/node_modules/zod/src/v4/locales/ota.ts +3 -0
- package/node_modules/zod/src/v4/locales/pl.ts +3 -0
- package/node_modules/zod/src/v4/locales/ps.ts +3 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +159 -0
- package/node_modules/zod/src/v4/locales/pt.ts +99 -58
- package/node_modules/zod/src/v4/locales/ro.ts +1 -0
- package/node_modules/zod/src/v4/locales/ru.ts +10 -0
- package/node_modules/zod/src/v4/locales/sk.ts +121 -0
- package/node_modules/zod/src/v4/locales/sl.ts +3 -0
- package/node_modules/zod/src/v4/locales/sv.ts +5 -2
- package/node_modules/zod/src/v4/locales/ta.ts +3 -0
- package/node_modules/zod/src/v4/locales/th.ts +3 -0
- package/node_modules/zod/src/v4/locales/tk.ts +111 -0
- package/node_modules/zod/src/v4/locales/tr.ts +3 -0
- package/node_modules/zod/src/v4/locales/uk.ts +3 -0
- package/node_modules/zod/src/v4/locales/ur.ts +3 -0
- package/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/zod/src/v4/locales/vi.ts +3 -0
- package/node_modules/zod/src/v4/locales/yo.ts +3 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +3 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +3 -0
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +10 -1
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/parse.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +135 -56
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +72 -5
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +21 -0
- package/node_modules/zod/v3/ZodError.cjs +22 -12
- package/node_modules/zod/v3/ZodError.d.cts +1 -1
- package/node_modules/zod/v3/ZodError.d.ts +1 -1
- package/node_modules/zod/v3/ZodError.js +22 -12
- package/node_modules/zod/v3/types.cjs +7 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +2 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/compat.d.cts +9 -11
- package/node_modules/zod/v4/classic/compat.d.ts +9 -11
- package/node_modules/zod/v4/classic/deep-partial.cjs +39 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +43 -34
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +43 -34
- package/node_modules/zod/v4/classic/external.cjs +30 -27
- package/node_modules/zod/v4/classic/external.d.cts +5 -2
- package/node_modules/zod/v4/classic/external.d.ts +5 -2
- package/node_modules/zod/v4/classic/external.js +5 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +136 -75
- package/node_modules/zod/v4/classic/from-json-schema.js +136 -75
- package/node_modules/zod/v4/classic/in-out.cjs +63 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +2 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +11 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/parse.cjs +4 -1
- package/node_modules/zod/v4/classic/parse.d.cts +17 -4
- package/node_modules/zod/v4/classic/parse.d.ts +17 -4
- package/node_modules/zod/v4/classic/parse.js +1 -0
- package/node_modules/zod/v4/classic/schemas.cjs +498 -398
- package/node_modules/zod/v4/classic/schemas.d.cts +53 -18
- package/node_modules/zod/v4/classic/schemas.d.ts +53 -18
- package/node_modules/zod/v4/classic/schemas.js +492 -396
- package/node_modules/zod/v4/core/api.cjs +23 -4
- package/node_modules/zod/v4/core/api.d.cts +13 -9
- package/node_modules/zod/v4/core/api.d.ts +13 -9
- package/node_modules/zod/v4/core/api.js +21 -4
- package/node_modules/zod/v4/core/checks.cjs +37 -31
- package/node_modules/zod/v4/core/checks.d.cts +13 -13
- package/node_modules/zod/v4/core/checks.d.ts +13 -13
- package/node_modules/zod/v4/core/checks.js +37 -31
- package/node_modules/zod/v4/core/compile.cjs +1813 -0
- package/node_modules/zod/v4/core/compile.d.cts +51 -0
- package/node_modules/zod/v4/core/compile.d.ts +51 -0
- package/node_modules/zod/v4/core/compile.js +1783 -0
- package/node_modules/zod/v4/core/core.cjs +81 -18
- package/node_modules/zod/v4/core/core.d.cts +16 -4
- package/node_modules/zod/v4/core/core.d.ts +16 -4
- package/node_modules/zod/v4/core/core.js +82 -19
- package/node_modules/zod/v4/core/doc.cjs +5 -7
- package/node_modules/zod/v4/core/doc.d.cts +3 -1
- package/node_modules/zod/v4/core/doc.d.ts +3 -1
- package/node_modules/zod/v4/core/doc.js +5 -7
- package/node_modules/zod/v4/core/errors.cjs +110 -25
- package/node_modules/zod/v4/core/errors.d.cts +4 -0
- package/node_modules/zod/v4/core/errors.d.ts +4 -0
- package/node_modules/zod/v4/core/errors.js +110 -25
- package/node_modules/zod/v4/core/index.cjs +5 -1
- package/node_modules/zod/v4/core/index.d.cts +3 -0
- package/node_modules/zod/v4/core/index.d.ts +3 -0
- package/node_modules/zod/v4/core/index.js +3 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +4 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.js +4 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +264 -95
- package/node_modules/zod/v4/core/json-schema-processors.js +243 -97
- package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
- package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
- package/node_modules/zod/v4/core/memoizer.cjs +272 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +265 -0
- package/node_modules/zod/v4/core/parse.cjs +96 -34
- package/node_modules/zod/v4/core/parse.d.cts +14 -11
- package/node_modules/zod/v4/core/parse.d.ts +14 -11
- package/node_modules/zod/v4/core/parse.js +94 -33
- package/node_modules/zod/v4/core/regexes.cjs +27 -15
- package/node_modules/zod/v4/core/regexes.d.cts +2 -0
- package/node_modules/zod/v4/core/regexes.d.ts +2 -0
- package/node_modules/zod/v4/core/regexes.js +24 -13
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +537 -326
- package/node_modules/zod/v4/core/schemas.d.cts +100 -31
- package/node_modules/zod/v4/core/schemas.d.ts +100 -31
- package/node_modules/zod/v4/core/schemas.js +526 -325
- package/node_modules/zod/v4/core/to-json-schema.cjs +242 -39
- package/node_modules/zod/v4/core/to-json-schema.d.cts +42 -3
- package/node_modules/zod/v4/core/to-json-schema.d.ts +42 -3
- package/node_modules/zod/v4/core/to-json-schema.js +241 -39
- package/node_modules/zod/v4/core/util.cjs +212 -31
- package/node_modules/zod/v4/core/util.d.cts +58 -1
- package/node_modules/zod/v4/core/util.d.ts +58 -1
- package/node_modules/zod/v4/core/util.js +202 -30
- package/node_modules/zod/v4/core/versions.cjs +2 -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 +195 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +15 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +3 -0
- package/node_modules/zod/v4/locales/ar.js +3 -0
- package/node_modules/zod/v4/locales/az.cjs +3 -0
- package/node_modules/zod/v4/locales/az.js +3 -0
- package/node_modules/zod/v4/locales/be.cjs +10 -0
- package/node_modules/zod/v4/locales/be.js +10 -0
- package/node_modules/zod/v4/locales/bg.cjs +3 -0
- package/node_modules/zod/v4/locales/bg.js +3 -0
- package/node_modules/zod/v4/locales/bn.cjs +138 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +111 -0
- package/node_modules/zod/v4/locales/ca.cjs +3 -0
- package/node_modules/zod/v4/locales/ca.js +3 -0
- package/node_modules/zod/v4/locales/ckb.cjs +158 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +131 -0
- package/node_modules/zod/v4/locales/cs.cjs +3 -0
- package/node_modules/zod/v4/locales/cs.js +3 -0
- package/node_modules/zod/v4/locales/da.cjs +5 -2
- package/node_modules/zod/v4/locales/da.js +5 -2
- package/node_modules/zod/v4/locales/de.cjs +3 -0
- package/node_modules/zod/v4/locales/de.js +3 -0
- package/node_modules/zod/v4/locales/el.cjs +1 -0
- package/node_modules/zod/v4/locales/el.js +1 -0
- package/node_modules/zod/v4/locales/en.cjs +14 -4
- package/node_modules/zod/v4/locales/en.js +14 -4
- package/node_modules/zod/v4/locales/eo.cjs +3 -0
- package/node_modules/zod/v4/locales/eo.js +3 -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 +3 -0
- package/node_modules/zod/v4/locales/fa.js +3 -0
- package/node_modules/zod/v4/locales/fi.cjs +3 -0
- package/node_modules/zod/v4/locales/fi.js +3 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +3 -0
- package/node_modules/zod/v4/locales/fr-CA.js +3 -0
- package/node_modules/zod/v4/locales/fr.cjs +16 -14
- package/node_modules/zod/v4/locales/fr.js +16 -14
- package/node_modules/zod/v4/locales/gu.cjs +138 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +111 -0
- package/node_modules/zod/v4/locales/he.cjs +5 -0
- package/node_modules/zod/v4/locales/he.js +5 -0
- package/node_modules/zod/v4/locales/hi.cjs +136 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +109 -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 +3 -0
- package/node_modules/zod/v4/locales/hu.js +3 -0
- package/node_modules/zod/v4/locales/hy.cjs +9 -0
- package/node_modules/zod/v4/locales/hy.js +9 -0
- package/node_modules/zod/v4/locales/id.cjs +3 -0
- package/node_modules/zod/v4/locales/id.js +3 -0
- package/node_modules/zod/v4/locales/index.cjs +22 -2
- package/node_modules/zod/v4/locales/index.d.cts +10 -0
- package/node_modules/zod/v4/locales/index.d.ts +10 -0
- package/node_modules/zod/v4/locales/index.js +10 -0
- package/node_modules/zod/v4/locales/is.cjs +3 -0
- package/node_modules/zod/v4/locales/is.js +3 -0
- package/node_modules/zod/v4/locales/it.cjs +3 -0
- package/node_modules/zod/v4/locales/it.js +3 -0
- package/node_modules/zod/v4/locales/ja.cjs +3 -0
- package/node_modules/zod/v4/locales/ja.js +3 -0
- package/node_modules/zod/v4/locales/ka.cjs +3 -0
- package/node_modules/zod/v4/locales/ka.js +3 -0
- package/node_modules/zod/v4/locales/km.cjs +3 -0
- package/node_modules/zod/v4/locales/km.js +3 -0
- package/node_modules/zod/v4/locales/kn.cjs +141 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +114 -0
- package/node_modules/zod/v4/locales/ko.cjs +3 -0
- package/node_modules/zod/v4/locales/ko.js +3 -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 +3 -0
- package/node_modules/zod/v4/locales/mk.js +3 -0
- package/node_modules/zod/v4/locales/ms.cjs +3 -0
- package/node_modules/zod/v4/locales/ms.js +3 -0
- package/node_modules/zod/v4/locales/ne.cjs +136 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +109 -0
- package/node_modules/zod/v4/locales/nl.cjs +3 -0
- package/node_modules/zod/v4/locales/nl.js +3 -0
- package/node_modules/zod/v4/locales/nn.cjs +138 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +111 -0
- package/node_modules/zod/v4/locales/no.cjs +5 -2
- package/node_modules/zod/v4/locales/no.js +5 -2
- package/node_modules/zod/v4/locales/ota.cjs +3 -0
- package/node_modules/zod/v4/locales/ota.js +3 -0
- package/node_modules/zod/v4/locales/pl.cjs +3 -0
- package/node_modules/zod/v4/locales/pl.js +3 -0
- package/node_modules/zod/v4/locales/ps.cjs +3 -0
- package/node_modules/zod/v4/locales/ps.js +3 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +168 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +141 -0
- package/node_modules/zod/v4/locales/pt.cjs +87 -55
- package/node_modules/zod/v4/locales/pt.js +87 -55
- package/node_modules/zod/v4/locales/ro.cjs +1 -0
- package/node_modules/zod/v4/locales/ro.js +1 -0
- package/node_modules/zod/v4/locales/ru.cjs +10 -0
- package/node_modules/zod/v4/locales/ru.js +10 -0
- package/node_modules/zod/v4/locales/sk.cjs +141 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +114 -0
- package/node_modules/zod/v4/locales/sl.cjs +3 -0
- package/node_modules/zod/v4/locales/sl.js +3 -0
- package/node_modules/zod/v4/locales/sv.cjs +5 -2
- package/node_modules/zod/v4/locales/sv.js +5 -2
- package/node_modules/zod/v4/locales/ta.cjs +3 -0
- package/node_modules/zod/v4/locales/ta.js +3 -0
- package/node_modules/zod/v4/locales/th.cjs +3 -0
- package/node_modules/zod/v4/locales/th.js +3 -0
- package/node_modules/zod/v4/locales/tk.cjs +132 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +105 -0
- package/node_modules/zod/v4/locales/tr.cjs +3 -0
- package/node_modules/zod/v4/locales/tr.js +3 -0
- package/node_modules/zod/v4/locales/uk.cjs +3 -0
- package/node_modules/zod/v4/locales/uk.js +3 -0
- package/node_modules/zod/v4/locales/ur.cjs +3 -0
- package/node_modules/zod/v4/locales/ur.js +3 -0
- package/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/zod/v4/locales/vi.cjs +3 -0
- package/node_modules/zod/v4/locales/vi.js +3 -0
- package/node_modules/zod/v4/locales/yo.cjs +3 -0
- package/node_modules/zod/v4/locales/yo.js +3 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +3 -0
- package/node_modules/zod/v4/locales/zh-CN.js +3 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +3 -0
- package/node_modules/zod/v4/locales/zh-TW.js +3 -0
- package/node_modules/zod/v4/mini/checks.cjs +2 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/deep-partial.cjs +39 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +12 -1
- package/node_modules/zod/v4/mini/external.d.cts +5 -2
- package/node_modules/zod/v4/mini/external.d.ts +5 -2
- package/node_modules/zod/v4/mini/external.js +3 -1
- package/node_modules/zod/v4/mini/in-out.cjs +63 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/parse.cjs +3 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +75 -47
- package/node_modules/zod/v4/mini/schemas.d.cts +43 -13
- package/node_modules/zod/v4/mini/schemas.d.ts +43 -13
- package/node_modules/zod/v4/mini/schemas.js +71 -45
- package/openclaw.plugin.json +25 -58
- package/package.json +10 -7
- package/dist/targets-BTQCYRZQ.js +0 -48
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- /package/dist/{audio-preflight.runtime-BBfC9elv.js → .setup/audio-preflight.runtime-BBfC9elv.mjs} +0 -0
- /package/dist/{doctor-contract-w6FpMypv.js → .setup/doctor-contract-w6FpMypv.mjs} +0 -0
- /package/dist/{json-response-DXajw_FU.js → .setup/json-response-DXajw_FU.mjs} +0 -0
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{runtime-C5JxBWZp.js → .setup/runtime-C5JxBWZp.mjs} +0 -0
- /package/dist/{secret-contract-BCpDLdg9.js → .setup/secret-contract-BCpDLdg9.mjs} +0 -0
- /package/dist/{security-audit-shared-CK5rVR-1.js → .setup/security-audit-shared-CK5rVR-1.mjs} +0 -0
- /package/dist/{thread-bindings-BiL1wGqK.js → .setup/thread-bindings-BiL1wGqK.mjs} +0 -0
|
@@ -11,19 +11,20 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
11
11
|
inst._zod.def = def; // set _def property
|
|
12
12
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
13
13
|
inst._zod.version = version;
|
|
14
|
-
const
|
|
14
|
+
const defChecks = inst._zod.def.checks;
|
|
15
15
|
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const checks = inst._zod.traits.has("$ZodCheck")
|
|
17
|
+
? [inst, ...(defChecks ?? [])]
|
|
18
|
+
: defChecks?.length
|
|
19
|
+
? [...defChecks]
|
|
20
|
+
: [];
|
|
19
21
|
for (const ch of checks) {
|
|
20
22
|
for (const fn of ch._zod.onattach) {
|
|
21
23
|
fn(inst);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
if (checks.length === 0) {
|
|
25
|
-
// deferred initializer
|
|
26
|
-
// inst._zod.parse is not yet defined
|
|
27
|
+
// deferred initializer inst._zod.parse is not yet defined
|
|
27
28
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
28
29
|
inst._zod.deferred?.push(() => {
|
|
29
30
|
inst._zod.run = inst._zod.parse;
|
|
@@ -31,6 +32,8 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
const runChecks = (payload, checks, ctx) => {
|
|
35
|
+
if (payload.memo)
|
|
36
|
+
return payload;
|
|
34
37
|
let isAborted = util.aborted(payload);
|
|
35
38
|
let asyncResult;
|
|
36
39
|
for (const ch of checks) {
|
|
@@ -55,6 +58,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
55
58
|
const nextLen = payload.issues.length;
|
|
56
59
|
if (nextLen === currLen)
|
|
57
60
|
return;
|
|
61
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
58
62
|
if (!isAborted)
|
|
59
63
|
isAborted = util.aborted(payload, currLen);
|
|
60
64
|
});
|
|
@@ -63,6 +67,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
63
67
|
const nextLen = payload.issues.length;
|
|
64
68
|
if (nextLen === currLen)
|
|
65
69
|
continue;
|
|
70
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
66
71
|
if (!isAborted)
|
|
67
72
|
isAborted = util.aborted(payload, currLen);
|
|
68
73
|
}
|
|
@@ -94,8 +99,7 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
94
99
|
return inst._zod.parse(payload, ctx);
|
|
95
100
|
}
|
|
96
101
|
if (ctx.direction === "backward") {
|
|
97
|
-
// run canary
|
|
98
|
-
// initial pass (no checks)
|
|
102
|
+
// run canary initial pass (no checks)
|
|
99
103
|
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
100
104
|
if (canary instanceof Promise) {
|
|
101
105
|
return canary.then((canary) => {
|
|
@@ -114,21 +118,31 @@ export const $ZodType = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def)
|
|
|
114
118
|
return runChecks(result, checks, ctx);
|
|
115
119
|
};
|
|
116
120
|
}
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
}, {
|
|
122
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
123
|
+
get "~standard"() {
|
|
124
|
+
return util.hide(this, "~standard", standardProps(this));
|
|
125
|
+
},
|
|
126
|
+
set "~standard"(value) {
|
|
127
|
+
util.own(this, "~standard", value);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
131
|
+
const toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
132
|
+
export function standardProps(inst) {
|
|
133
|
+
return {
|
|
119
134
|
validate: (value) => {
|
|
120
135
|
try {
|
|
121
|
-
|
|
122
|
-
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
136
|
+
return toStandardResult(safeParse(inst, value));
|
|
123
137
|
}
|
|
124
138
|
catch (_) {
|
|
125
|
-
return safeParseAsync(inst, value).then(
|
|
139
|
+
return safeParseAsync(inst, value).then(toStandardResult);
|
|
126
140
|
}
|
|
127
141
|
},
|
|
128
142
|
vendor: "zod",
|
|
129
143
|
version: 1,
|
|
130
|
-
}
|
|
131
|
-
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
132
146
|
export { clone } from "./util.js";
|
|
133
147
|
export const $ZodString = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
|
134
148
|
$ZodType.init(inst, def);
|
|
@@ -184,66 +198,89 @@ export const $ZodEmail = /*@__PURE__*/ core.$constructor("$ZodEmail", (inst, def
|
|
|
184
198
|
def.pattern ?? (def.pattern = regexes.email);
|
|
185
199
|
$ZodStringFormat.init(inst, def);
|
|
186
200
|
});
|
|
201
|
+
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
202
|
+
export const URL_BAD_FORMAT = 1;
|
|
203
|
+
/** The URL constructor rejected the input. */
|
|
204
|
+
export const URL_UNPARSEABLE = 2;
|
|
205
|
+
/** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
|
|
206
|
+
export function parseURLObject(trimmed, def) {
|
|
207
|
+
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
208
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
209
|
+
return URL_BAD_FORMAT;
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
return new URL(trimmed);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return URL_UNPARSEABLE;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
220
|
+
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
|
|
221
|
+
export function stripTabAndNewline(value) {
|
|
222
|
+
return value.replace(asciiTabOrNewline, "");
|
|
223
|
+
}
|
|
224
|
+
export function urlHostnameOk(url, hostname) {
|
|
225
|
+
hostname.lastIndex = 0;
|
|
226
|
+
return hostname.test(url.hostname);
|
|
227
|
+
}
|
|
228
|
+
export function urlProtocolOk(url, protocol) {
|
|
229
|
+
protocol.lastIndex = 0;
|
|
230
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
231
|
+
}
|
|
187
232
|
export const $ZodURL = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
|
|
188
233
|
$ZodStringFormat.init(inst, def);
|
|
189
234
|
inst._zod.check = (payload) => {
|
|
190
235
|
try {
|
|
191
236
|
// Trim whitespace from input
|
|
192
237
|
const trimmed = payload.value.trim();
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
// @ts-ignore
|
|
209
|
-
const url = new URL(trimmed);
|
|
210
|
-
if (def.hostname) {
|
|
211
|
-
def.hostname.lastIndex = 0;
|
|
212
|
-
if (!def.hostname.test(url.hostname)) {
|
|
213
|
-
payload.issues.push({
|
|
214
|
-
code: "invalid_format",
|
|
215
|
-
format: "url",
|
|
216
|
-
note: "Invalid hostname",
|
|
217
|
-
pattern: def.hostname.source,
|
|
218
|
-
input: payload.value,
|
|
219
|
-
inst,
|
|
220
|
-
continue: !def.abort,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
238
|
+
const url = parseURLObject(trimmed, def);
|
|
239
|
+
if (url === URL_BAD_FORMAT) {
|
|
240
|
+
payload.issues.push({
|
|
241
|
+
code: "invalid_format",
|
|
242
|
+
format: "url",
|
|
243
|
+
note: "Invalid URL format",
|
|
244
|
+
input: payload.value,
|
|
245
|
+
inst,
|
|
246
|
+
continue: !def.abort,
|
|
247
|
+
});
|
|
248
|
+
return;
|
|
223
249
|
}
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
inst,
|
|
234
|
-
continue: !def.abort,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
250
|
+
if (url === URL_UNPARSEABLE) {
|
|
251
|
+
payload.issues.push({
|
|
252
|
+
code: "invalid_format",
|
|
253
|
+
format: "url",
|
|
254
|
+
input: payload.value,
|
|
255
|
+
inst,
|
|
256
|
+
continue: !def.abort,
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
237
259
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
260
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
261
|
+
payload.issues.push({
|
|
262
|
+
code: "invalid_format",
|
|
263
|
+
format: "url",
|
|
264
|
+
note: "Invalid hostname",
|
|
265
|
+
pattern: def.hostname.source,
|
|
266
|
+
input: payload.value,
|
|
267
|
+
inst,
|
|
268
|
+
continue: !def.abort,
|
|
269
|
+
});
|
|
242
270
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
271
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
272
|
+
payload.issues.push({
|
|
273
|
+
code: "invalid_format",
|
|
274
|
+
format: "url",
|
|
275
|
+
note: "Invalid protocol",
|
|
276
|
+
pattern: def.protocol.source,
|
|
277
|
+
input: payload.value,
|
|
278
|
+
inst,
|
|
279
|
+
continue: !def.abort,
|
|
280
|
+
});
|
|
246
281
|
}
|
|
282
|
+
// Set the output value based on normalize flag
|
|
283
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
247
284
|
return;
|
|
248
285
|
}
|
|
249
286
|
catch (_) {
|
|
@@ -262,7 +299,9 @@ export const $ZodEmoji = /*@__PURE__*/ core.$constructor("$ZodEmoji", (inst, def
|
|
|
262
299
|
$ZodStringFormat.init(inst, def);
|
|
263
300
|
});
|
|
264
301
|
export const $ZodNanoID = /*@__PURE__*/ core.$constructor("$ZodNanoID", (inst, def) => {
|
|
265
|
-
def.
|
|
302
|
+
if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
|
|
303
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
304
|
+
def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
|
|
266
305
|
$ZodStringFormat.init(inst, def);
|
|
267
306
|
});
|
|
268
307
|
/**
|
|
@@ -293,6 +332,13 @@ export const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def
|
|
|
293
332
|
export const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
|
|
294
333
|
def.pattern ?? (def.pattern = regexes.datetime(def));
|
|
295
334
|
$ZodStringFormat.init(inst, def);
|
|
335
|
+
// these two drop the offset or seconds `date-time` requires — on the bag not the def, since `z.string().check(...)` lands the format on a different schema
|
|
336
|
+
if (def.local || def.precision === -1) {
|
|
337
|
+
inst._zod.bag.laxFormat = true;
|
|
338
|
+
inst._zod.onattach.push((s) => {
|
|
339
|
+
s._zod.bag.laxFormat = true;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
296
342
|
});
|
|
297
343
|
export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
|
|
298
344
|
def.pattern ?? (def.pattern = regexes.date);
|
|
@@ -311,17 +357,26 @@ export const $ZodIPv4 = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def)
|
|
|
311
357
|
$ZodStringFormat.init(inst, def);
|
|
312
358
|
inst._zod.bag.format = `ipv4`;
|
|
313
359
|
});
|
|
360
|
+
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
|
|
361
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
362
|
+
export function isValidIPv6(value) {
|
|
363
|
+
if (!ipv6Alphabet.test(value))
|
|
364
|
+
return false;
|
|
365
|
+
try {
|
|
366
|
+
// @ts-ignore
|
|
367
|
+
new URL(`http://[${value}]`);
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
314
374
|
export const $ZodIPv6 = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def) => {
|
|
315
375
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
316
376
|
$ZodStringFormat.init(inst, def);
|
|
317
377
|
inst._zod.bag.format = `ipv6`;
|
|
318
378
|
inst._zod.check = (payload) => {
|
|
319
|
-
|
|
320
|
-
// @ts-ignore
|
|
321
|
-
new URL(`http://[${payload.value}]`);
|
|
322
|
-
// return;
|
|
323
|
-
}
|
|
324
|
-
catch {
|
|
379
|
+
if (!isValidIPv6(payload.value)) {
|
|
325
380
|
payload.issues.push({
|
|
326
381
|
code: "invalid_format",
|
|
327
382
|
format: "ipv6",
|
|
@@ -341,26 +396,25 @@ export const $ZodCIDRv4 = /*@__PURE__*/ core.$constructor("$ZodCIDRv4", (inst, d
|
|
|
341
396
|
def.pattern ?? (def.pattern = regexes.cidrv4);
|
|
342
397
|
$ZodStringFormat.init(inst, def);
|
|
343
398
|
});
|
|
399
|
+
export function isValidCIDRv6(value) {
|
|
400
|
+
const parts = value.split("/");
|
|
401
|
+
if (parts.length !== 2)
|
|
402
|
+
return false;
|
|
403
|
+
const [address, prefix] = parts;
|
|
404
|
+
if (!prefix)
|
|
405
|
+
return false;
|
|
406
|
+
const prefixNum = Number(prefix);
|
|
407
|
+
if (`${prefixNum}` !== prefix)
|
|
408
|
+
return false;
|
|
409
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
410
|
+
return false;
|
|
411
|
+
return isValidIPv6(address);
|
|
412
|
+
}
|
|
344
413
|
export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
345
414
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
346
415
|
$ZodStringFormat.init(inst, def);
|
|
347
416
|
inst._zod.check = (payload) => {
|
|
348
|
-
|
|
349
|
-
try {
|
|
350
|
-
if (parts.length !== 2)
|
|
351
|
-
throw new Error();
|
|
352
|
-
const [address, prefix] = parts;
|
|
353
|
-
if (!prefix)
|
|
354
|
-
throw new Error();
|
|
355
|
-
const prefixNum = Number(prefix);
|
|
356
|
-
if (`${prefixNum}` !== prefix)
|
|
357
|
-
throw new Error();
|
|
358
|
-
if (prefixNum < 0 || prefixNum > 128)
|
|
359
|
-
throw new Error();
|
|
360
|
-
// @ts-ignore
|
|
361
|
-
new URL(`http://[${address}]`);
|
|
362
|
-
}
|
|
363
|
-
catch {
|
|
417
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
364
418
|
payload.issues.push({
|
|
365
419
|
code: "invalid_format",
|
|
366
420
|
format: "cidrv6",
|
|
@@ -433,6 +487,41 @@ export const $ZodE164 = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def)
|
|
|
433
487
|
def.pattern ?? (def.pattern = regexes.e164);
|
|
434
488
|
$ZodStringFormat.init(inst, def);
|
|
435
489
|
});
|
|
490
|
+
////////////////////////////// ZodCreditCard //////////////////////////////
|
|
491
|
+
const CC_SANITIZE = /[- ]/g;
|
|
492
|
+
/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
|
|
493
|
+
function isLuhnAlgo(digits) {
|
|
494
|
+
let length = digits.length;
|
|
495
|
+
let bit = 1;
|
|
496
|
+
let sum = 0;
|
|
497
|
+
while (length) {
|
|
498
|
+
const value = +digits[--length];
|
|
499
|
+
bit ^= 1;
|
|
500
|
+
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
|
|
501
|
+
}
|
|
502
|
+
return sum % 10 === 0;
|
|
503
|
+
}
|
|
504
|
+
export function isValidCreditCard(input) {
|
|
505
|
+
if (!regexes.creditCard.test(input))
|
|
506
|
+
return false;
|
|
507
|
+
return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
|
|
508
|
+
}
|
|
509
|
+
export const $ZodCreditCard = /*@__PURE__*/ core.$constructor("$ZodCreditCard", (inst, def) => {
|
|
510
|
+
// Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
|
|
511
|
+
def.pattern ?? (def.pattern = regexes.creditCard);
|
|
512
|
+
$ZodStringFormat.init(inst, def);
|
|
513
|
+
inst._zod.check = (payload) => {
|
|
514
|
+
if (isValidCreditCard(payload.value))
|
|
515
|
+
return;
|
|
516
|
+
payload.issues.push({
|
|
517
|
+
code: "invalid_format",
|
|
518
|
+
format: "credit_card",
|
|
519
|
+
input: payload.value,
|
|
520
|
+
inst,
|
|
521
|
+
continue: !def.abort,
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
});
|
|
436
525
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
437
526
|
export function isValidJWT(token, algorithm = null) {
|
|
438
527
|
try {
|
|
@@ -501,7 +590,7 @@ export const $ZodNumber = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, d
|
|
|
501
590
|
? Number.isNaN(input)
|
|
502
591
|
? "NaN"
|
|
503
592
|
: !Number.isFinite(input)
|
|
504
|
-
?
|
|
593
|
+
? String(input)
|
|
505
594
|
: undefined
|
|
506
595
|
: undefined;
|
|
507
596
|
payload.issues.push({
|
|
@@ -679,6 +768,8 @@ function handleArrayResult(result, final, index) {
|
|
|
679
768
|
}
|
|
680
769
|
export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
|
|
681
770
|
$ZodType.init(inst, def);
|
|
771
|
+
const memo = core.globalConfig.memoizer;
|
|
772
|
+
memo?.attach(inst);
|
|
682
773
|
inst._zod.parse = (payload, ctx) => {
|
|
683
774
|
const input = payload.value;
|
|
684
775
|
if (!Array.isArray(input)) {
|
|
@@ -690,7 +781,7 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
690
781
|
});
|
|
691
782
|
return payload;
|
|
692
783
|
}
|
|
693
|
-
payload.value = Array(input.length);
|
|
784
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
694
785
|
const proms = [];
|
|
695
786
|
for (let i = 0; i < input.length; i++) {
|
|
696
787
|
const item = input[i];
|
|
@@ -711,16 +802,21 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
711
802
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
712
803
|
};
|
|
713
804
|
});
|
|
714
|
-
function handlePropertyResult(result, final, key, input,
|
|
805
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
715
806
|
const isPresent = key in input;
|
|
807
|
+
const isOptionalOut = optout === "optional";
|
|
808
|
+
// The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
|
|
809
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
716
812
|
if (result.issues.length) {
|
|
717
813
|
// For optional-in/out schemas, ignore errors on absent keys.
|
|
718
|
-
if (
|
|
814
|
+
if (optin !== undefined && isOptionalOut && !isPresent) {
|
|
719
815
|
return;
|
|
720
816
|
}
|
|
721
817
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
722
818
|
}
|
|
723
|
-
if (!isPresent &&
|
|
819
|
+
if (!isPresent && optin === undefined) {
|
|
724
820
|
if (!result.issues.length) {
|
|
725
821
|
final.issues.push({
|
|
726
822
|
code: "invalid_type",
|
|
@@ -740,17 +836,25 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
740
836
|
final.value[key] = result.value;
|
|
741
837
|
}
|
|
742
838
|
}
|
|
839
|
+
// one shared instance; a fresh [] per schema cost 56 bytes retained
|
|
840
|
+
const NO_SYMBOL_KEYS = [];
|
|
743
841
|
function normalizeDef(def) {
|
|
744
842
|
const keys = Object.keys(def.shape);
|
|
745
|
-
|
|
843
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
844
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
845
|
+
// aliases `keys` when there are no symbols, so a string-only shape keeps one array
|
|
846
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
847
|
+
for (const k of allKeys) {
|
|
746
848
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
747
|
-
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
849
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
748
850
|
}
|
|
749
851
|
}
|
|
750
852
|
const okeys = util.optionalKeys(def.shape);
|
|
751
853
|
return {
|
|
752
854
|
...def,
|
|
753
|
-
|
|
855
|
+
allKeys,
|
|
856
|
+
symbolKeys,
|
|
857
|
+
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
754
858
|
keySet: new Set(keys),
|
|
755
859
|
numKeys: keys.length,
|
|
756
860
|
optionalKeys: new Set(okeys),
|
|
@@ -761,25 +865,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
761
865
|
const keySet = def.keySet;
|
|
762
866
|
const _catchall = def.catchall._zod;
|
|
763
867
|
const t = _catchall.def.type;
|
|
764
|
-
const
|
|
765
|
-
const
|
|
868
|
+
const optin = _catchall.optin;
|
|
869
|
+
const optout = _catchall.optout;
|
|
766
870
|
for (const key in input) {
|
|
767
|
-
//
|
|
768
|
-
// assignment setter on the plain {} we build into
|
|
769
|
-
if (key === "__proto__")
|
|
770
|
-
continue;
|
|
871
|
+
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
771
872
|
if (keySet.has(key))
|
|
772
873
|
continue;
|
|
874
|
+
// Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
|
|
875
|
+
if (key === "__proto__") {
|
|
876
|
+
if (t === "never")
|
|
877
|
+
unrecognized.push(key);
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
773
880
|
if (t === "never") {
|
|
774
881
|
unrecognized.push(key);
|
|
775
882
|
continue;
|
|
776
883
|
}
|
|
777
884
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
778
885
|
if (r instanceof Promise) {
|
|
779
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
886
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
780
887
|
}
|
|
781
888
|
else {
|
|
782
|
-
handlePropertyResult(r, payload, key, input,
|
|
889
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
783
890
|
}
|
|
784
891
|
}
|
|
785
892
|
if (unrecognized.length) {
|
|
@@ -788,6 +895,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
788
895
|
keys: unrecognized,
|
|
789
896
|
input,
|
|
790
897
|
inst,
|
|
898
|
+
// Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
|
|
899
|
+
continue: true,
|
|
791
900
|
});
|
|
792
901
|
}
|
|
793
902
|
if (!proms.length)
|
|
@@ -796,6 +905,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
796
905
|
return payload;
|
|
797
906
|
});
|
|
798
907
|
}
|
|
908
|
+
// Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it. Keyed by def, so a def rebuilt by a builder is simply absent rather than inheriting the source's. Read its keys with `Object.keys`, which does not invoke them — that is what lets a discriminated union check its discriminator without resolving an option whose getters reference the union being constructed.
|
|
909
|
+
const propShapes = new WeakMap();
|
|
799
910
|
export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
|
800
911
|
// requires cast because technically $ZodObject doesn't extend
|
|
801
912
|
$ZodType.init(inst, def);
|
|
@@ -803,26 +914,33 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
803
914
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
804
915
|
if (!desc?.get) {
|
|
805
916
|
const sh = def.shape;
|
|
917
|
+
propShapes.set(def, sh);
|
|
806
918
|
Object.defineProperty(def, "shape", {
|
|
807
919
|
get: () => {
|
|
808
920
|
const newSh = { ...sh };
|
|
809
921
|
Object.defineProperty(def, "shape", {
|
|
810
922
|
value: newSh,
|
|
811
923
|
});
|
|
924
|
+
propShapes.set(def, newSh);
|
|
812
925
|
return newSh;
|
|
813
926
|
},
|
|
814
927
|
});
|
|
815
928
|
}
|
|
816
929
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
817
|
-
util.
|
|
818
|
-
const shape = def.shape;
|
|
930
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
931
|
+
const shape = zod.def.shape;
|
|
819
932
|
const propValues = {};
|
|
820
933
|
for (const key in shape) {
|
|
821
934
|
const field = shape[key]._zod;
|
|
822
935
|
if (field.values) {
|
|
823
|
-
|
|
936
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
937
|
+
util.assignProp(propValues, key, new Set());
|
|
938
|
+
}
|
|
824
939
|
for (const v of field.values)
|
|
825
940
|
propValues[key].add(v);
|
|
941
|
+
// An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
|
|
942
|
+
if (field.optin !== undefined)
|
|
943
|
+
propValues[key].add(undefined);
|
|
826
944
|
}
|
|
827
945
|
}
|
|
828
946
|
return propValues;
|
|
@@ -830,6 +948,8 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
830
948
|
const isObject = util.isObject;
|
|
831
949
|
const catchall = def.catchall;
|
|
832
950
|
let value;
|
|
951
|
+
const memo = core.globalConfig.memoizer;
|
|
952
|
+
memo?.attach(inst);
|
|
833
953
|
inst._zod.parse = (payload, ctx) => {
|
|
834
954
|
value ?? (value = _normalized.value);
|
|
835
955
|
const input = payload.value;
|
|
@@ -842,19 +962,21 @@ export const $ZodObject = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, d
|
|
|
842
962
|
});
|
|
843
963
|
return payload;
|
|
844
964
|
}
|
|
845
|
-
payload.value = {};
|
|
965
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
846
966
|
const proms = [];
|
|
847
967
|
const shape = value.shape;
|
|
848
|
-
for (const key of value.
|
|
968
|
+
for (const key of value.allKeys) {
|
|
969
|
+
if (key === "__proto__")
|
|
970
|
+
continue;
|
|
849
971
|
const el = shape[key];
|
|
850
|
-
const
|
|
851
|
-
const
|
|
972
|
+
const optin = el._zod.optin;
|
|
973
|
+
const optout = el._zod.optout;
|
|
852
974
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
853
975
|
if (r instanceof Promise) {
|
|
854
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
976
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
855
977
|
}
|
|
856
978
|
else {
|
|
857
|
-
handlePropertyResult(r, payload, key, input,
|
|
979
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
858
980
|
}
|
|
859
981
|
}
|
|
860
982
|
if (!catchall) {
|
|
@@ -868,58 +990,59 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
868
990
|
$ZodObject.init(inst, def);
|
|
869
991
|
const superParse = inst._zod.parse;
|
|
870
992
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
993
|
+
const memo = core.globalConfig.memoizer;
|
|
871
994
|
const generateFastpass = (shape) => {
|
|
872
|
-
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
873
995
|
const normalized = _normalized.value;
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
996
|
+
const syms = normalized.symbolKeys;
|
|
997
|
+
// a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
|
|
998
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
999
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1000
|
+
// Prefixes in place, like util.prefixIssues does for every interpreted path.
|
|
1001
|
+
const prefixStr = (id, k) => `
|
|
1002
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
1003
|
+
const iss = ${id}.issues[i];
|
|
1004
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
1005
|
+
payload.issues.push(iss);
|
|
1006
|
+
}`;
|
|
878
1007
|
doc.write(`const input = payload.value;`);
|
|
879
1008
|
const ids = Object.create(null);
|
|
880
1009
|
let counter = 0;
|
|
881
|
-
for (const key of normalized.
|
|
1010
|
+
for (const key of normalized.allKeys) {
|
|
882
1011
|
ids[key] = `key_${counter++}`;
|
|
883
1012
|
}
|
|
884
1013
|
// A: preserve key order {
|
|
885
|
-
doc.write(`const newResult = {};`);
|
|
886
|
-
for (const key of normalized.
|
|
1014
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
1015
|
+
for (const key of normalized.allKeys) {
|
|
1016
|
+
if (key === "__proto__")
|
|
1017
|
+
continue;
|
|
887
1018
|
const id = ids[key];
|
|
888
|
-
const k = util.esc(key);
|
|
1019
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
|
|
1020
|
+
const isPresent = `${k} in input`;
|
|
889
1021
|
const schema = shape[key];
|
|
890
|
-
const
|
|
1022
|
+
const optin = schema?._zod?.optin;
|
|
1023
|
+
const isOptionalIn = optin !== undefined;
|
|
891
1024
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
892
|
-
doc.write(`const ${id} = ${parseStr(
|
|
1025
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
893
1026
|
if (isOptionalIn && isOptionalOut) {
|
|
894
|
-
// For optional-in/out schemas, ignore errors on absent keys
|
|
1027
|
+
// For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
|
|
1028
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
895
1029
|
doc.write(`
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
...iss,
|
|
900
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
901
|
-
})));
|
|
1030
|
+
const ${id}_present = ${isPresent};
|
|
1031
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
1032
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
902
1033
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
if (${k} in input) {
|
|
907
|
-
newResult[${k}] = undefined;
|
|
1034
|
+
|
|
1035
|
+
if (${assign}) {
|
|
1036
|
+
newResult[${k}] = ${id}.value;
|
|
908
1037
|
}
|
|
909
|
-
} else {
|
|
910
|
-
newResult[${k}] = ${id}.value;
|
|
911
1038
|
}
|
|
912
|
-
|
|
1039
|
+
|
|
913
1040
|
`);
|
|
914
1041
|
}
|
|
915
1042
|
else if (!isOptionalIn) {
|
|
916
1043
|
doc.write(`
|
|
917
|
-
const ${id}_present = ${
|
|
918
|
-
if (${id}.issues.length) {
|
|
919
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
920
|
-
...iss,
|
|
921
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
922
|
-
})));
|
|
1044
|
+
const ${id}_present = ${isPresent};
|
|
1045
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
923
1046
|
}
|
|
924
1047
|
if (!${id}_present && !${id}.issues.length) {
|
|
925
1048
|
payload.issues.push({
|
|
@@ -931,39 +1054,31 @@ export const $ZodObjectJIT = /*@__PURE__*/ core.$constructor("$ZodObjectJIT", (i
|
|
|
931
1054
|
}
|
|
932
1055
|
|
|
933
1056
|
if (${id}_present) {
|
|
934
|
-
|
|
935
|
-
newResult[${k}] = undefined;
|
|
936
|
-
} else {
|
|
937
|
-
newResult[${k}] = ${id}.value;
|
|
938
|
-
}
|
|
1057
|
+
newResult[${k}] = ${id}.value;
|
|
939
1058
|
}
|
|
940
1059
|
|
|
941
1060
|
`);
|
|
942
1061
|
}
|
|
943
1062
|
else {
|
|
944
1063
|
doc.write(`
|
|
945
|
-
if (${id}.issues.length) {
|
|
946
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
947
|
-
...iss,
|
|
948
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
949
|
-
})));
|
|
1064
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
950
1065
|
}
|
|
951
1066
|
|
|
952
1067
|
if (${id}.value === undefined) {
|
|
953
|
-
if (${
|
|
1068
|
+
if (${isPresent}) {
|
|
954
1069
|
newResult[${k}] = undefined;
|
|
955
1070
|
}
|
|
956
1071
|
} else {
|
|
957
1072
|
newResult[${k}] = ${id}.value;
|
|
958
1073
|
}
|
|
959
|
-
|
|
1074
|
+
|
|
960
1075
|
`);
|
|
961
1076
|
}
|
|
962
1077
|
}
|
|
963
1078
|
doc.write(`payload.value = newResult;`);
|
|
964
1079
|
doc.write(`return payload;`);
|
|
965
|
-
|
|
966
|
-
return (
|
|
1080
|
+
// closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
|
|
1081
|
+
return doc.compile();
|
|
967
1082
|
};
|
|
968
1083
|
let fastpass;
|
|
969
1084
|
const isObject = util.isObject;
|
|
@@ -1018,17 +1133,21 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
1018
1133
|
}
|
|
1019
1134
|
export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
|
1020
1135
|
$ZodType.init(inst, def);
|
|
1021
|
-
util.
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1136
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
|
|
1137
|
+
? "defaulted"
|
|
1138
|
+
: zod.def.options.some((o) => o._zod.optin !== undefined)
|
|
1139
|
+
? "optional"
|
|
1140
|
+
: undefined);
|
|
1141
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
1142
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
1143
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
1144
|
+
return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1026
1145
|
}
|
|
1027
1146
|
return undefined;
|
|
1028
1147
|
});
|
|
1029
|
-
util.
|
|
1030
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1031
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1148
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
1149
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
1150
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
1032
1151
|
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
|
1033
1152
|
}
|
|
1034
1153
|
return undefined;
|
|
@@ -1063,12 +1182,16 @@ export const $ZodUnion = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def
|
|
|
1063
1182
|
};
|
|
1064
1183
|
});
|
|
1065
1184
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1185
|
+
const matches = [];
|
|
1186
|
+
for (let i = 0; i < results.length; i++) {
|
|
1187
|
+
if (results[i].issues.length === 0)
|
|
1188
|
+
matches.push(i);
|
|
1189
|
+
}
|
|
1190
|
+
if (matches.length === 1) {
|
|
1191
|
+
final.value = results[matches[0]].value;
|
|
1069
1192
|
return final;
|
|
1070
1193
|
}
|
|
1071
|
-
if (
|
|
1194
|
+
if (matches.length === 0) {
|
|
1072
1195
|
// No matches - same as regular union
|
|
1073
1196
|
final.issues.push({
|
|
1074
1197
|
code: "invalid_union",
|
|
@@ -1085,6 +1208,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1085
1208
|
inst,
|
|
1086
1209
|
errors: [],
|
|
1087
1210
|
inclusive: false,
|
|
1211
|
+
matches,
|
|
1088
1212
|
});
|
|
1089
1213
|
}
|
|
1090
1214
|
return final;
|
|
@@ -1119,21 +1243,39 @@ export const $ZodXor = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) =>
|
|
|
1119
1243
|
});
|
|
1120
1244
|
};
|
|
1121
1245
|
});
|
|
1246
|
+
/** Returns the option of `union` whose discriminator claims `value`. */
|
|
1247
|
+
export function getDiscriminatedOption(union, value) {
|
|
1248
|
+
const internals = union._zod;
|
|
1249
|
+
let map = internals.bag.optionsMap;
|
|
1250
|
+
if (!map) {
|
|
1251
|
+
map = new Map();
|
|
1252
|
+
const { options, discriminator } = internals.def;
|
|
1253
|
+
for (const option of options) {
|
|
1254
|
+
// First declaration wins, matching the order the parse path resolves a duplicate in.
|
|
1255
|
+
for (const v of option._zod.propValues?.[discriminator] ?? [])
|
|
1256
|
+
if (!map.has(v))
|
|
1257
|
+
map.set(v, option);
|
|
1258
|
+
}
|
|
1259
|
+
internals.bag.optionsMap = map;
|
|
1260
|
+
}
|
|
1261
|
+
return map.get(value);
|
|
1262
|
+
}
|
|
1122
1263
|
export const $ZodDiscriminatedUnion =
|
|
1123
1264
|
/*@__PURE__*/
|
|
1124
1265
|
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1125
1266
|
def.inclusive = false;
|
|
1126
1267
|
$ZodUnion.init(inst, def);
|
|
1127
1268
|
const _super = inst._zod.parse;
|
|
1128
|
-
util.
|
|
1269
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
1129
1270
|
const propValues = {};
|
|
1130
|
-
for (const option of def.options) {
|
|
1271
|
+
for (const option of zod.def.options) {
|
|
1131
1272
|
const pv = option._zod.propValues;
|
|
1132
1273
|
if (!pv || Object.keys(pv).length === 0)
|
|
1133
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1274
|
+
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
1134
1275
|
for (const [k, v] of Object.entries(pv)) {
|
|
1135
|
-
if (!propValues
|
|
1136
|
-
propValues
|
|
1276
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
1277
|
+
util.assignProp(propValues, k, new Set());
|
|
1278
|
+
}
|
|
1137
1279
|
for (const val of v) {
|
|
1138
1280
|
propValues[k].add(val);
|
|
1139
1281
|
}
|
|
@@ -1141,6 +1283,13 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1141
1283
|
}
|
|
1142
1284
|
return propValues;
|
|
1143
1285
|
});
|
|
1286
|
+
// Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes, lazies, and objects rebuilt by a builder such as `.extend()` — are left to the map.
|
|
1287
|
+
def.options.forEach((option, i) => {
|
|
1288
|
+
const propShape = propShapes.get(option._zod.def);
|
|
1289
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
1290
|
+
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1144
1293
|
const disc = util.cached(() => {
|
|
1145
1294
|
const opts = def.options;
|
|
1146
1295
|
const map = new Map();
|
|
@@ -1174,8 +1323,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1174
1323
|
}
|
|
1175
1324
|
// Fall back to union matching when the fast discriminator path fails:
|
|
1176
1325
|
// - explicitly enabled via unionFallback, or
|
|
1177
|
-
// - during backward direction (encode), since codec-based discriminators
|
|
1178
|
-
// have different values in forward vs backward directions
|
|
1326
|
+
// - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
|
|
1179
1327
|
if (def.unionFallback || ctx.direction === "backward") {
|
|
1180
1328
|
return _super(payload, ctx);
|
|
1181
1329
|
}
|
|
@@ -1208,7 +1356,7 @@ export const $ZodIntersection = /*@__PURE__*/ core.$constructor("$ZodIntersectio
|
|
|
1208
1356
|
return handleIntersectionResults(payload, left, right);
|
|
1209
1357
|
};
|
|
1210
1358
|
});
|
|
1211
|
-
function mergeValues(a, b) {
|
|
1359
|
+
export function mergeValues(a, b) {
|
|
1212
1360
|
// const aType = parse.t(a);
|
|
1213
1361
|
// const bType = parse.t(b);
|
|
1214
1362
|
if (a === b) {
|
|
@@ -1221,7 +1369,11 @@ function mergeValues(a, b) {
|
|
|
1221
1369
|
const bKeys = Object.keys(b);
|
|
1222
1370
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1223
1371
|
const newObj = { ...a, ...b };
|
|
1372
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
1373
|
+
delete newObj.__proto__;
|
|
1224
1374
|
for (const key of sharedKeys) {
|
|
1375
|
+
if (key === "__proto__")
|
|
1376
|
+
continue;
|
|
1225
1377
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1226
1378
|
if (!sharedValue.valid) {
|
|
1227
1379
|
return {
|
|
@@ -1255,43 +1407,55 @@ function mergeValues(a, b) {
|
|
|
1255
1407
|
return { valid: false, mergeErrorPath: [] };
|
|
1256
1408
|
}
|
|
1257
1409
|
function handleIntersectionResults(result, left, right) {
|
|
1258
|
-
// Track which side(s)
|
|
1410
|
+
// Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
|
|
1259
1411
|
const unrecKeys = new Map();
|
|
1260
1412
|
let unrecIssue;
|
|
1261
|
-
|
|
1262
|
-
|
|
1413
|
+
const keyIssues = new Map();
|
|
1414
|
+
const collect = (iss, side) => {
|
|
1415
|
+
let keys;
|
|
1416
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
1263
1417
|
unrecIssue ?? (unrecIssue = iss);
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1418
|
+
keys = iss.keys;
|
|
1419
|
+
}
|
|
1420
|
+
else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
1421
|
+
const k = String(iss.path[0]);
|
|
1422
|
+
if (!keyIssues.has(k))
|
|
1423
|
+
keyIssues.set(k, iss);
|
|
1424
|
+
keys = [k];
|
|
1269
1425
|
}
|
|
1270
1426
|
else {
|
|
1271
|
-
|
|
1427
|
+
return false;
|
|
1428
|
+
}
|
|
1429
|
+
for (const k of keys) {
|
|
1430
|
+
if (!unrecKeys.has(k))
|
|
1431
|
+
unrecKeys.set(k, {});
|
|
1432
|
+
unrecKeys.get(k)[side] = true;
|
|
1272
1433
|
}
|
|
1434
|
+
return true;
|
|
1435
|
+
};
|
|
1436
|
+
for (const iss of left.issues) {
|
|
1437
|
+
if (!collect(iss, "l"))
|
|
1438
|
+
result.issues.push(iss);
|
|
1273
1439
|
}
|
|
1274
1440
|
for (const iss of right.issues) {
|
|
1275
|
-
if (iss
|
|
1276
|
-
for (const k of iss.keys) {
|
|
1277
|
-
if (!unrecKeys.has(k))
|
|
1278
|
-
unrecKeys.set(k, {});
|
|
1279
|
-
unrecKeys.get(k).r = true;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
else {
|
|
1441
|
+
if (!collect(iss, "r"))
|
|
1283
1442
|
result.issues.push(iss);
|
|
1284
|
-
}
|
|
1285
1443
|
}
|
|
1286
|
-
// Report only keys
|
|
1444
|
+
// Report only keys rejected by BOTH sides
|
|
1287
1445
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1288
|
-
if (bothKeys.length
|
|
1289
|
-
|
|
1446
|
+
if (bothKeys.length) {
|
|
1447
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
1448
|
+
if (aggregated.length)
|
|
1449
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
1450
|
+
for (const k of bothKeys) {
|
|
1451
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
1452
|
+
result.issues.push(keyIssues.get(k));
|
|
1453
|
+
}
|
|
1290
1454
|
}
|
|
1291
|
-
if (util.aborted(result))
|
|
1292
|
-
return result;
|
|
1293
1455
|
const merged = mergeValues(left.value, right.value);
|
|
1294
1456
|
if (!merged.valid) {
|
|
1457
|
+
if (util.aborted(result))
|
|
1458
|
+
return result;
|
|
1295
1459
|
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1296
1460
|
}
|
|
1297
1461
|
result.value = merged.data;
|
|
@@ -1300,6 +1464,8 @@ function handleIntersectionResults(result, left, right) {
|
|
|
1300
1464
|
export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
|
|
1301
1465
|
$ZodType.init(inst, def);
|
|
1302
1466
|
const items = def.items;
|
|
1467
|
+
const memo = core.globalConfig.memoizer;
|
|
1468
|
+
memo?.attach(inst);
|
|
1303
1469
|
inst._zod.parse = (payload, ctx) => {
|
|
1304
1470
|
const input = payload.value;
|
|
1305
1471
|
if (!Array.isArray(input)) {
|
|
@@ -1311,7 +1477,7 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
|
|
|
1311
1477
|
});
|
|
1312
1478
|
return payload;
|
|
1313
1479
|
}
|
|
1314
|
-
payload.value = [];
|
|
1480
|
+
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
1315
1481
|
const proms = [];
|
|
1316
1482
|
const optinStart = getTupleOptStart(items, "optin");
|
|
1317
1483
|
const optoutStart = getTupleOptStart(items, "optout");
|
|
@@ -1338,10 +1504,7 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
|
|
|
1338
1504
|
});
|
|
1339
1505
|
}
|
|
1340
1506
|
}
|
|
1341
|
-
// Run every item in parallel, collecting results into an indexed
|
|
1342
|
-
// array. The post-processing in `handleTupleResults` walks them in
|
|
1343
|
-
// order so it can decide whether an absent optional-output error can
|
|
1344
|
-
// truncate the tail or must be reported to preserve required output.
|
|
1507
|
+
// Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
|
|
1345
1508
|
const itemResults = new Array(items.length);
|
|
1346
1509
|
for (let i = 0; i < items.length; i++) {
|
|
1347
1510
|
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
@@ -1376,7 +1539,9 @@ export const $ZodTuple = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def
|
|
|
1376
1539
|
});
|
|
1377
1540
|
function getTupleOptStart(items, key) {
|
|
1378
1541
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
1379
|
-
|
|
1542
|
+
// optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
|
|
1543
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
1544
|
+
if (!omittable)
|
|
1380
1545
|
return i + 1;
|
|
1381
1546
|
}
|
|
1382
1547
|
return 0;
|
|
@@ -1388,12 +1553,15 @@ function handleTupleResult(result, final, index) {
|
|
|
1388
1553
|
final.value[index] = result.value;
|
|
1389
1554
|
}
|
|
1390
1555
|
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1391
|
-
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
|
|
1392
|
-
// rule, but only after `optoutStart`: the first index where the output
|
|
1393
|
-
// tuple tail can be absent.
|
|
1556
|
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
|
|
1394
1557
|
for (let i = 0; i < items.length; i++) {
|
|
1395
1558
|
const r = itemResults[i];
|
|
1396
1559
|
const isPresent = i < input.length;
|
|
1560
|
+
// The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
|
|
1561
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
1562
|
+
final.value.length = i;
|
|
1563
|
+
break;
|
|
1564
|
+
}
|
|
1397
1565
|
if (r.issues.length) {
|
|
1398
1566
|
if (!isPresent && i >= optoutStart) {
|
|
1399
1567
|
final.value.length = i;
|
|
@@ -1421,6 +1589,8 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
|
1421
1589
|
}
|
|
1422
1590
|
export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
|
1423
1591
|
$ZodType.init(inst, def);
|
|
1592
|
+
const memo = core.globalConfig.memoizer;
|
|
1593
|
+
memo?.attach(inst);
|
|
1424
1594
|
inst._zod.parse = (payload, ctx) => {
|
|
1425
1595
|
const input = payload.value;
|
|
1426
1596
|
if (!util.isPlainObject(input)) {
|
|
@@ -1434,12 +1604,15 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1434
1604
|
}
|
|
1435
1605
|
const proms = [];
|
|
1436
1606
|
const values = def.keyType._zod.values;
|
|
1437
|
-
if (values) {
|
|
1438
|
-
payload.value = {};
|
|
1607
|
+
if (values && !def.partial) {
|
|
1608
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1439
1609
|
const recordKeys = new Set();
|
|
1440
1610
|
for (const key of values) {
|
|
1441
1611
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1442
1612
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1613
|
+
// A declared __proto__ is stripped but is not an unrecognized key.
|
|
1614
|
+
if (key === "__proto__")
|
|
1615
|
+
continue;
|
|
1443
1616
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1444
1617
|
if (keyResult instanceof Promise) {
|
|
1445
1618
|
throw new Error("Async schemas not supported in object keys currently");
|
|
@@ -1456,6 +1629,8 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1456
1629
|
continue;
|
|
1457
1630
|
}
|
|
1458
1631
|
const outKey = keyResult.value;
|
|
1632
|
+
if (outKey === "__proto__")
|
|
1633
|
+
continue;
|
|
1459
1634
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1460
1635
|
if (result instanceof Promise) {
|
|
1461
1636
|
proms.push(result.then((result) => {
|
|
@@ -1476,8 +1651,16 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1476
1651
|
let unrecognized;
|
|
1477
1652
|
for (const key in input) {
|
|
1478
1653
|
if (!recordKeys.has(key)) {
|
|
1479
|
-
|
|
1480
|
-
|
|
1654
|
+
if (def.mode === "loose") {
|
|
1655
|
+
// skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
|
|
1656
|
+
if (key === "__proto__")
|
|
1657
|
+
continue;
|
|
1658
|
+
payload.value[key] = input[key];
|
|
1659
|
+
}
|
|
1660
|
+
else {
|
|
1661
|
+
unrecognized = unrecognized ?? [];
|
|
1662
|
+
unrecognized.push(key);
|
|
1663
|
+
}
|
|
1481
1664
|
}
|
|
1482
1665
|
}
|
|
1483
1666
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -1486,11 +1669,14 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1486
1669
|
input,
|
|
1487
1670
|
inst,
|
|
1488
1671
|
keys: unrecognized,
|
|
1672
|
+
continue: true,
|
|
1489
1673
|
});
|
|
1490
1674
|
}
|
|
1491
1675
|
}
|
|
1492
1676
|
else {
|
|
1493
|
-
payload.value = {};
|
|
1677
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1678
|
+
// An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
|
|
1679
|
+
let unrecognized;
|
|
1494
1680
|
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
1495
1681
|
for (const key of Reflect.ownKeys(input)) {
|
|
1496
1682
|
if (key === "__proto__")
|
|
@@ -1501,8 +1687,7 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1501
1687
|
if (keyResult instanceof Promise) {
|
|
1502
1688
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1503
1689
|
}
|
|
1504
|
-
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
1505
|
-
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1690
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1506
1691
|
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
1507
1692
|
if (checkNumericKey) {
|
|
1508
1693
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
@@ -1518,6 +1703,10 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1518
1703
|
// Pass through unchanged
|
|
1519
1704
|
payload.value[key] = input[key];
|
|
1520
1705
|
}
|
|
1706
|
+
else if (values) {
|
|
1707
|
+
unrecognized = unrecognized ?? [];
|
|
1708
|
+
unrecognized.push(key);
|
|
1709
|
+
}
|
|
1521
1710
|
else {
|
|
1522
1711
|
// Default "strict" behavior: error on invalid key
|
|
1523
1712
|
payload.issues.push({
|
|
@@ -1531,22 +1720,35 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1531
1720
|
}
|
|
1532
1721
|
continue;
|
|
1533
1722
|
}
|
|
1723
|
+
// the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
|
|
1724
|
+
const outKey = keyResult.value;
|
|
1725
|
+
if (outKey === "__proto__")
|
|
1726
|
+
continue;
|
|
1534
1727
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1535
1728
|
if (result instanceof Promise) {
|
|
1536
1729
|
proms.push(result.then((result) => {
|
|
1537
1730
|
if (result.issues.length) {
|
|
1538
1731
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1539
1732
|
}
|
|
1540
|
-
payload.value[
|
|
1733
|
+
payload.value[outKey] = result.value;
|
|
1541
1734
|
}));
|
|
1542
1735
|
}
|
|
1543
1736
|
else {
|
|
1544
1737
|
if (result.issues.length) {
|
|
1545
1738
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1546
1739
|
}
|
|
1547
|
-
payload.value[
|
|
1740
|
+
payload.value[outKey] = result.value;
|
|
1548
1741
|
}
|
|
1549
1742
|
}
|
|
1743
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
1744
|
+
payload.issues.push({
|
|
1745
|
+
code: "unrecognized_keys",
|
|
1746
|
+
input,
|
|
1747
|
+
inst,
|
|
1748
|
+
keys: unrecognized,
|
|
1749
|
+
continue: true,
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1550
1752
|
}
|
|
1551
1753
|
if (proms.length) {
|
|
1552
1754
|
return Promise.all(proms).then(() => payload);
|
|
@@ -1556,6 +1758,8 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1556
1758
|
});
|
|
1557
1759
|
export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
|
|
1558
1760
|
$ZodType.init(inst, def);
|
|
1761
|
+
const memo = core.globalConfig.memoizer;
|
|
1762
|
+
memo?.attach(inst);
|
|
1559
1763
|
inst._zod.parse = (payload, ctx) => {
|
|
1560
1764
|
const input = payload.value;
|
|
1561
1765
|
if (!(input instanceof Map)) {
|
|
@@ -1568,7 +1772,7 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
|
|
|
1568
1772
|
return payload;
|
|
1569
1773
|
}
|
|
1570
1774
|
const proms = [];
|
|
1571
|
-
payload.value = new Map();
|
|
1775
|
+
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
1572
1776
|
for (const [key, value] of input) {
|
|
1573
1777
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1574
1778
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
@@ -1620,6 +1824,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
1620
1824
|
}
|
|
1621
1825
|
export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
|
|
1622
1826
|
$ZodType.init(inst, def);
|
|
1827
|
+
const memo = core.globalConfig.memoizer;
|
|
1828
|
+
memo?.attach(inst);
|
|
1623
1829
|
inst._zod.parse = (payload, ctx) => {
|
|
1624
1830
|
const input = payload.value;
|
|
1625
1831
|
if (!(input instanceof Set)) {
|
|
@@ -1632,7 +1838,7 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
|
|
|
1632
1838
|
return payload;
|
|
1633
1839
|
}
|
|
1634
1840
|
const proms = [];
|
|
1635
|
-
payload.value = new Set();
|
|
1841
|
+
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
1636
1842
|
for (const item of input) {
|
|
1637
1843
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
1638
1844
|
if (result instanceof Promise) {
|
|
@@ -1657,10 +1863,9 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
|
|
|
1657
1863
|
const values = util.getEnumValues(def.entries);
|
|
1658
1864
|
const valuesSet = new Set(values);
|
|
1659
1865
|
inst._zod.values = valuesSet;
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
.join("|")})$`);
|
|
1866
|
+
const patternValues = values.filter((k) => util.propertyKeyTypes.has(typeof k));
|
|
1867
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
1868
|
+
inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
1664
1869
|
inst._zod.parse = (payload, _ctx) => {
|
|
1665
1870
|
const input = payload.value;
|
|
1666
1871
|
if (valuesSet.has(input)) {
|
|
@@ -1677,14 +1882,14 @@ export const $ZodEnum = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def)
|
|
|
1677
1882
|
});
|
|
1678
1883
|
export const $ZodLiteral = /*@__PURE__*/ core.$constructor("$ZodLiteral", (inst, def) => {
|
|
1679
1884
|
$ZodType.init(inst, def);
|
|
1680
|
-
if (def.values.length === 0) {
|
|
1681
|
-
throw new Error("Cannot create literal schema with no valid values");
|
|
1682
|
-
}
|
|
1683
1885
|
const values = new Set(def.values);
|
|
1684
1886
|
inst._zod.values = values;
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
.
|
|
1887
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
1888
|
+
inst._zod.pattern = new RegExp(def.values.length
|
|
1889
|
+
? `^(${def.values
|
|
1890
|
+
.map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
|
|
1891
|
+
.join("|")})$`
|
|
1892
|
+
: "^[^\\s\\S]$");
|
|
1688
1893
|
inst._zod.parse = (payload, _ctx) => {
|
|
1689
1894
|
const input = payload.value;
|
|
1690
1895
|
if (values.has(input)) {
|
|
@@ -1718,6 +1923,7 @@ export const $ZodFile = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def)
|
|
|
1718
1923
|
export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (inst, def) => {
|
|
1719
1924
|
$ZodType.init(inst, def);
|
|
1720
1925
|
inst._zod.optin = "optional";
|
|
1926
|
+
core.globalConfig.memoizer?.guard(inst);
|
|
1721
1927
|
inst._zod.parse = (payload, ctx) => {
|
|
1722
1928
|
if (ctx.direction === "backward") {
|
|
1723
1929
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -1727,7 +1933,6 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
|
|
|
1727
1933
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
1728
1934
|
return output.then((output) => {
|
|
1729
1935
|
payload.value = output;
|
|
1730
|
-
payload.fallback = true;
|
|
1731
1936
|
return payload;
|
|
1732
1937
|
});
|
|
1733
1938
|
}
|
|
@@ -1735,37 +1940,37 @@ export const $ZodTransform = /*@__PURE__*/ core.$constructor("$ZodTransform", (i
|
|
|
1735
1940
|
throw new core.$ZodAsyncError();
|
|
1736
1941
|
}
|
|
1737
1942
|
payload.value = _out;
|
|
1738
|
-
payload.fallback = true;
|
|
1739
1943
|
return payload;
|
|
1740
1944
|
};
|
|
1741
1945
|
});
|
|
1742
|
-
function handleOptionalResult(
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
return result;
|
|
1946
|
+
function handleOptionalResult(payload, result) {
|
|
1947
|
+
// A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
|
|
1948
|
+
payload.value = result.issues.length ? undefined : result.value;
|
|
1949
|
+
return payload;
|
|
1747
1950
|
}
|
|
1748
1951
|
export const $ZodOptional = /*@__PURE__*/ core.$constructor("$ZodOptional", (inst, def) => {
|
|
1749
1952
|
$ZodType.init(inst, def);
|
|
1750
|
-
|
|
1953
|
+
// .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
|
|
1954
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
1751
1955
|
inst._zod.optout = "optional";
|
|
1752
|
-
util.
|
|
1753
|
-
|
|
1956
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
1957
|
+
const values = zod.def.innerType._zod.values;
|
|
1958
|
+
return values ? new Set([...values, undefined]) : undefined;
|
|
1754
1959
|
});
|
|
1755
|
-
util.
|
|
1756
|
-
const pattern = def.innerType._zod.pattern;
|
|
1960
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
1961
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1757
1962
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
|
1758
1963
|
});
|
|
1759
1964
|
inst._zod.parse = (payload, ctx) => {
|
|
1760
|
-
if (def.innerType._zod.optin === "optional") {
|
|
1761
|
-
const input = payload.value;
|
|
1762
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1763
|
-
if (result instanceof Promise)
|
|
1764
|
-
return result.then((r) => handleOptionalResult(r, input));
|
|
1765
|
-
return handleOptionalResult(result, input);
|
|
1766
|
-
}
|
|
1767
1965
|
if (payload.value === undefined) {
|
|
1768
|
-
|
|
1966
|
+
// Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
|
|
1967
|
+
if (def.innerType._zod.optin !== "defaulted")
|
|
1968
|
+
return payload;
|
|
1969
|
+
// Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
|
|
1970
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
1971
|
+
if (result instanceof Promise)
|
|
1972
|
+
return result.then((result) => handleOptionalResult(payload, result));
|
|
1973
|
+
return handleOptionalResult(payload, result);
|
|
1769
1974
|
}
|
|
1770
1975
|
return def.innerType._zod.run(payload, ctx);
|
|
1771
1976
|
};
|
|
@@ -1774,8 +1979,8 @@ export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptio
|
|
|
1774
1979
|
// Call parent init - inherits optin/optout = "optional"
|
|
1775
1980
|
$ZodOptional.init(inst, def);
|
|
1776
1981
|
// Override values/pattern to NOT add undefined
|
|
1777
|
-
util.
|
|
1778
|
-
util.
|
|
1982
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1983
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
1779
1984
|
// Override parse to just delegate (no undefined handling)
|
|
1780
1985
|
inst._zod.parse = (payload, ctx) => {
|
|
1781
1986
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1783,14 +1988,14 @@ export const $ZodExactOptional = /*@__PURE__*/ core.$constructor("$ZodExactOptio
|
|
|
1783
1988
|
});
|
|
1784
1989
|
export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (inst, def) => {
|
|
1785
1990
|
$ZodType.init(inst, def);
|
|
1786
|
-
util.
|
|
1787
|
-
util.
|
|
1788
|
-
util.
|
|
1789
|
-
const pattern = def.innerType._zod.pattern;
|
|
1991
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
1992
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
1993
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
1994
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1790
1995
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
1791
1996
|
});
|
|
1792
|
-
util.
|
|
1793
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
1997
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
1998
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
|
|
1794
1999
|
});
|
|
1795
2000
|
inst._zod.parse = (payload, ctx) => {
|
|
1796
2001
|
// Forward direction (decode): allow null to pass through
|
|
@@ -1802,8 +2007,8 @@ export const $ZodNullable = /*@__PURE__*/ core.$constructor("$ZodNullable", (ins
|
|
|
1802
2007
|
export const $ZodDefault = /*@__PURE__*/ core.$constructor("$ZodDefault", (inst, def) => {
|
|
1803
2008
|
$ZodType.init(inst, def);
|
|
1804
2009
|
// inst._zod.qin = "true";
|
|
1805
|
-
inst._zod.optin = "
|
|
1806
|
-
util.
|
|
2010
|
+
inst._zod.optin = "defaulted";
|
|
2011
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1807
2012
|
inst._zod.parse = (payload, ctx) => {
|
|
1808
2013
|
if (ctx.direction === "backward") {
|
|
1809
2014
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1832,8 +2037,8 @@ function handleDefaultResult(payload, def) {
|
|
|
1832
2037
|
}
|
|
1833
2038
|
export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (inst, def) => {
|
|
1834
2039
|
$ZodType.init(inst, def);
|
|
1835
|
-
inst._zod.optin = "
|
|
1836
|
-
util.
|
|
2040
|
+
inst._zod.optin = "defaulted";
|
|
2041
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1837
2042
|
inst._zod.parse = (payload, ctx) => {
|
|
1838
2043
|
if (ctx.direction === "backward") {
|
|
1839
2044
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1847,8 +2052,8 @@ export const $ZodPrefault = /*@__PURE__*/ core.$constructor("$ZodPrefault", (ins
|
|
|
1847
2052
|
});
|
|
1848
2053
|
export const $ZodNonOptional = /*@__PURE__*/ core.$constructor("$ZodNonOptional", (inst, def) => {
|
|
1849
2054
|
$ZodType.init(inst, def);
|
|
1850
|
-
util.
|
|
1851
|
-
const v = def.innerType._zod.values;
|
|
2055
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2056
|
+
const v = zod.def.innerType._zod.values;
|
|
1852
2057
|
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
1853
2058
|
});
|
|
1854
2059
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1887,47 +2092,40 @@ export const $ZodSuccess = /*@__PURE__*/ core.$constructor("$ZodSuccess", (inst,
|
|
|
1887
2092
|
return payload;
|
|
1888
2093
|
};
|
|
1889
2094
|
});
|
|
2095
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2096
|
+
if (!result.issues.length) {
|
|
2097
|
+
payload.value = result.value;
|
|
2098
|
+
// The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
|
|
2099
|
+
if (result.memo)
|
|
2100
|
+
payload.memo = true;
|
|
2101
|
+
return payload;
|
|
2102
|
+
}
|
|
2103
|
+
// Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
|
|
2104
|
+
payload.value = def.catchValue({
|
|
2105
|
+
...result,
|
|
2106
|
+
value: payload.value,
|
|
2107
|
+
error: {
|
|
2108
|
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
2109
|
+
},
|
|
2110
|
+
input: payload.value,
|
|
2111
|
+
});
|
|
2112
|
+
return payload;
|
|
2113
|
+
}
|
|
1890
2114
|
export const $ZodCatch = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
1891
2115
|
$ZodType.init(inst, def);
|
|
1892
|
-
inst._zod.optin
|
|
1893
|
-
util.
|
|
1894
|
-
util.
|
|
2116
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2117
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2118
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1895
2119
|
inst._zod.parse = (payload, ctx) => {
|
|
1896
2120
|
if (ctx.direction === "backward") {
|
|
1897
2121
|
return def.innerType._zod.run(payload, ctx);
|
|
1898
2122
|
}
|
|
1899
2123
|
// Forward direction (decode): apply catch logic
|
|
1900
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2124
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
1901
2125
|
if (result instanceof Promise) {
|
|
1902
|
-
return result.then((result) =>
|
|
1903
|
-
payload.value = result.value;
|
|
1904
|
-
if (result.issues.length) {
|
|
1905
|
-
payload.value = def.catchValue({
|
|
1906
|
-
...payload,
|
|
1907
|
-
error: {
|
|
1908
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1909
|
-
},
|
|
1910
|
-
input: payload.value,
|
|
1911
|
-
});
|
|
1912
|
-
payload.issues = [];
|
|
1913
|
-
payload.fallback = true;
|
|
1914
|
-
}
|
|
1915
|
-
return payload;
|
|
1916
|
-
});
|
|
1917
|
-
}
|
|
1918
|
-
payload.value = result.value;
|
|
1919
|
-
if (result.issues.length) {
|
|
1920
|
-
payload.value = def.catchValue({
|
|
1921
|
-
...payload,
|
|
1922
|
-
error: {
|
|
1923
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1924
|
-
},
|
|
1925
|
-
input: payload.value,
|
|
1926
|
-
});
|
|
1927
|
-
payload.issues = [];
|
|
1928
|
-
payload.fallback = true;
|
|
2126
|
+
return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
1929
2127
|
}
|
|
1930
|
-
return payload;
|
|
2128
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
1931
2129
|
};
|
|
1932
2130
|
});
|
|
1933
2131
|
export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
|
|
@@ -1947,10 +2145,10 @@ export const $ZodNaN = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) =>
|
|
|
1947
2145
|
});
|
|
1948
2146
|
export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
|
|
1949
2147
|
$ZodType.init(inst, def);
|
|
1950
|
-
util.
|
|
1951
|
-
util.
|
|
1952
|
-
util.
|
|
1953
|
-
util.
|
|
2148
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2149
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2150
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2151
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1954
2152
|
inst._zod.parse = (payload, ctx) => {
|
|
1955
2153
|
if (ctx.direction === "backward") {
|
|
1956
2154
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -1967,19 +2165,20 @@ export const $ZodPipe = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def)
|
|
|
1967
2165
|
};
|
|
1968
2166
|
});
|
|
1969
2167
|
function handlePipeResult(left, next, ctx) {
|
|
1970
|
-
|
|
2168
|
+
// Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
|
|
2169
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
1971
2170
|
// prevent further checks
|
|
1972
2171
|
left.aborted = true;
|
|
1973
2172
|
return left;
|
|
1974
2173
|
}
|
|
1975
|
-
return next._zod.run({ value: left.value, issues: left.issues
|
|
2174
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
1976
2175
|
}
|
|
1977
2176
|
export const $ZodCodec = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
|
|
1978
2177
|
$ZodType.init(inst, def);
|
|
1979
|
-
util.
|
|
1980
|
-
util.
|
|
1981
|
-
util.
|
|
1982
|
-
util.
|
|
2178
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2179
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2180
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2181
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1983
2182
|
inst._zod.parse = (payload, ctx) => {
|
|
1984
2183
|
const direction = ctx.direction || "forward";
|
|
1985
2184
|
if (direction === "forward") {
|
|
@@ -2033,10 +2232,10 @@ export const $ZodPreprocess = /*@__PURE__*/ core.$constructor("$ZodPreprocess",
|
|
|
2033
2232
|
});
|
|
2034
2233
|
export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (inst, def) => {
|
|
2035
2234
|
$ZodType.init(inst, def);
|
|
2036
|
-
util.
|
|
2037
|
-
util.
|
|
2038
|
-
util.
|
|
2039
|
-
util.
|
|
2235
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2236
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2237
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2238
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2040
2239
|
inst._zod.parse = (payload, ctx) => {
|
|
2041
2240
|
if (ctx.direction === "backward") {
|
|
2042
2241
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2049,7 +2248,9 @@ export const $ZodReadonly = /*@__PURE__*/ core.$constructor("$ZodReadonly", (ins
|
|
|
2049
2248
|
};
|
|
2050
2249
|
});
|
|
2051
2250
|
function handleReadonlyResult(payload) {
|
|
2052
|
-
|
|
2251
|
+
// A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
|
|
2252
|
+
if (!payload.memo)
|
|
2253
|
+
payload.value = Object.freeze(payload.value);
|
|
2053
2254
|
return payload;
|
|
2054
2255
|
}
|
|
2055
2256
|
export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
@@ -2103,33 +2304,35 @@ export const $ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("$ZodTemplate
|
|
|
2103
2304
|
});
|
|
2104
2305
|
export const $ZodFunction = /*@__PURE__*/ core.$constructor("$ZodFunction", (inst, def) => {
|
|
2105
2306
|
$ZodType.init(inst, def);
|
|
2106
|
-
|
|
2307
|
+
// Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
|
|
2308
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
2107
2309
|
inst._zod.def = def;
|
|
2108
2310
|
inst.implement = (func) => {
|
|
2109
2311
|
if (typeof func !== "function") {
|
|
2110
2312
|
throw new Error("implement() must be called with a function");
|
|
2111
2313
|
}
|
|
2112
|
-
|
|
2314
|
+
// Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
|
|
2315
|
+
return Object.defineProperty(function (...args) {
|
|
2113
2316
|
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
|
2114
2317
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
2115
2318
|
if (inst._def.output) {
|
|
2116
2319
|
return parse(inst._def.output, result);
|
|
2117
2320
|
}
|
|
2118
2321
|
return result;
|
|
2119
|
-
};
|
|
2322
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
2120
2323
|
};
|
|
2121
2324
|
inst.implementAsync = (func) => {
|
|
2122
2325
|
if (typeof func !== "function") {
|
|
2123
2326
|
throw new Error("implementAsync() must be called with a function");
|
|
2124
2327
|
}
|
|
2125
|
-
return async function (...args) {
|
|
2328
|
+
return Object.defineProperty(async function (...args) {
|
|
2126
2329
|
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
|
|
2127
2330
|
const result = await Reflect.apply(func, this, parsedArgs);
|
|
2128
2331
|
if (inst._def.output) {
|
|
2129
2332
|
return await parseAsync(inst._def.output, result);
|
|
2130
2333
|
}
|
|
2131
2334
|
return result;
|
|
2132
|
-
};
|
|
2335
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
2133
2336
|
};
|
|
2134
2337
|
inst._zod.parse = (payload, _ctx) => {
|
|
2135
2338
|
if (typeof payload.value !== "function") {
|
|
@@ -2188,19 +2391,17 @@ export const $ZodPromise = /*@__PURE__*/ core.$constructor("$ZodPromise", (inst,
|
|
|
2188
2391
|
});
|
|
2189
2392
|
export const $ZodLazy = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
2190
2393
|
$ZodType.init(inst, def);
|
|
2191
|
-
// Cache the resolved inner type on the shared `def` so all clones of this
|
|
2192
|
-
// lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
|
|
2193
|
-
// preserving identity for cycle detection on recursive schemas.
|
|
2394
|
+
// Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
|
|
2194
2395
|
util.defineLazy(inst._zod, "innerType", () => {
|
|
2195
2396
|
const d = def;
|
|
2196
2397
|
if (!d._cachedInner)
|
|
2197
2398
|
d._cachedInner = def.getter();
|
|
2198
2399
|
return d._cachedInner;
|
|
2199
2400
|
});
|
|
2200
|
-
util.
|
|
2201
|
-
util.
|
|
2202
|
-
util.
|
|
2203
|
-
util.
|
|
2401
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
|
|
2402
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
|
|
2403
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
|
|
2404
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
|
|
2204
2405
|
inst._zod.parse = (payload, ctx) => {
|
|
2205
2406
|
const inner = inst._zod.innerType;
|
|
2206
2407
|
return inner._zod.run(payload, ctx);
|