cross-seed 7.0.0-21 → 7.0.0-23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action.js +7 -8
- package/dist/action.js.map +1 -1
- package/dist/arr.js +2 -2
- package/dist/arr.js.map +1 -1
- package/dist/bencode.d.ts +62 -0
- package/dist/bencode.js +248 -0
- package/dist/bencode.js.map +1 -0
- package/dist/clients/Deluge.d.ts +5 -10
- package/dist/clients/Deluge.js +115 -89
- package/dist/clients/Deluge.js.map +1 -1
- package/dist/clients/QBittorrent.d.ts +3 -0
- package/dist/clients/QBittorrent.js +43 -30
- package/dist/clients/QBittorrent.js.map +1 -1
- package/dist/clients/RTorrent.d.ts +3 -2
- package/dist/clients/RTorrent.js +120 -41
- package/dist/clients/RTorrent.js.map +1 -1
- package/dist/clients/TorrentClient.d.ts +3 -2
- package/dist/clients/TorrentClient.js +3 -5
- package/dist/clients/TorrentClient.js.map +1 -1
- package/dist/clients/Transmission.d.ts +1 -0
- package/dist/clients/Transmission.js +90 -40
- package/dist/clients/Transmission.js.map +1 -1
- package/dist/clients/qbittorrent-version.d.ts +6 -0
- package/dist/clients/qbittorrent-version.js +11 -0
- package/dist/clients/qbittorrent-version.js.map +1 -0
- package/dist/clients/scgi.d.ts +14 -0
- package/dist/clients/scgi.js +111 -0
- package/dist/clients/scgi.js.map +1 -0
- package/dist/cmd.js +1 -1
- package/dist/cmd.js.map +1 -1
- package/dist/configuration.js +49 -9
- package/dist/configuration.js.map +1 -1
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +12 -2
- package/dist/constants.js.map +1 -1
- package/dist/dataFiles.d.ts +1 -0
- package/dist/dataFiles.js +252 -60
- package/dist/dataFiles.js.map +1 -1
- package/dist/db.js +8 -4
- package/dist/db.js.map +1 -1
- package/dist/decide.js +8 -8
- package/dist/decide.js.map +1 -1
- package/dist/devLogin.js.map +1 -1
- package/dist/diff.js.map +1 -1
- package/dist/indexers.js +5 -4
- package/dist/indexers.js.map +1 -1
- package/dist/inject.js +5 -5
- package/dist/inject.js.map +1 -1
- package/dist/jobs.js +2 -1
- package/dist/jobs.js.map +1 -1
- package/dist/libraryInventory.d.ts +176 -0
- package/dist/libraryInventory.js +701 -0
- package/dist/libraryInventory.js.map +1 -0
- package/dist/logger.js +7 -5
- package/dist/logger.js.map +1 -1
- package/dist/migrations/09-clientAndDataSearchees.js +1 -0
- package/dist/migrations/09-clientAndDataSearchees.js.map +1 -1
- package/dist/migrations/17-api-key-settings-json.js +3 -1
- package/dist/migrations/17-api-key-settings-json.js.map +1 -1
- package/dist/migrations/18-library-inventory.d.ts +9 -0
- package/dist/migrations/18-library-inventory.js +48 -0
- package/dist/migrations/18-library-inventory.js.map +1 -0
- package/dist/migrations/19-library-files.d.ts +9 -0
- package/dist/migrations/19-library-files.js +26 -0
- package/dist/migrations/19-library-files.js.map +1 -0
- package/dist/migrations/migrations.d.ts +12 -5
- package/dist/migrations/migrations.js +5 -1
- package/dist/migrations/migrations.js.map +1 -1
- package/dist/parseTorrent.d.ts +1 -1
- package/dist/parseTorrent.js +18 -4
- package/dist/parseTorrent.js.map +1 -1
- package/dist/pipeline.js +12 -11
- package/dist/pipeline.js.map +1 -1
- package/dist/problems/linking.js +1 -1
- package/dist/problems/linking.js.map +1 -1
- package/dist/problems.js +2 -1
- package/dist/problems.js.map +1 -1
- package/dist/pushNotifier.js +10 -9
- package/dist/pushNotifier.js.map +1 -1
- package/dist/routes/baseApi.d.ts +8 -0
- package/dist/routes/baseApi.js +26 -52
- package/dist/routes/baseApi.js.map +1 -1
- package/dist/routes/devLogin.js +1 -0
- package/dist/routes/devLogin.js.map +1 -1
- package/dist/routes/indexerApi.js +1 -0
- package/dist/routes/indexerApi.js.map +1 -1
- package/dist/routes/staticFrontendPlugin.js +1 -0
- package/dist/routes/staticFrontendPlugin.js.map +1 -1
- package/dist/searchee.d.ts +14 -2
- package/dist/searchee.js +26 -9
- package/dist/searchee.js.map +1 -1
- package/dist/services/indexerService.js +8 -2
- package/dist/services/indexerService.js.map +1 -1
- package/dist/startup.d.ts +1 -0
- package/dist/startup.js +11 -4
- package/dist/startup.js.map +1 -1
- package/dist/torrent.js +302 -115
- package/dist/torrent.js.map +1 -1
- package/dist/torznab.d.ts +2 -2
- package/dist/torznab.js +15 -14
- package/dist/torznab.js.map +1 -1
- package/dist/trpc/routers/auth.js +1 -1
- package/dist/trpc/routers/auth.js.map +1 -1
- package/dist/trpc/routers/clients.js +8 -13
- package/dist/trpc/routers/clients.js.map +1 -1
- package/dist/trpc/routers/index.d.ts +51 -50
- package/dist/trpc/routers/index.js +2 -2
- package/dist/trpc/routers/index.js.map +1 -1
- package/dist/trpc/routers/jobs.js +1 -1
- package/dist/trpc/routers/jobs.js.map +1 -1
- package/dist/trpc/routers/library.d.ts +50 -0
- package/dist/trpc/routers/library.js +85 -0
- package/dist/trpc/routers/library.js.map +1 -0
- package/dist/trpc/routers/logs.js +6 -5
- package/dist/trpc/routers/logs.js.map +1 -1
- package/dist/trpc/routers/settings.js +78 -21
- package/dist/trpc/routers/settings.js.map +1 -1
- package/dist/trpc/routers/stats.d.ts +1 -0
- package/dist/trpc/routers/stats.js +11 -5
- package/dist/trpc/routers/stats.js.map +1 -1
- package/dist/userAuth.js +1 -1
- package/dist/userAuth.js.map +1 -1
- package/dist/utils/background.d.ts +7 -0
- package/dist/utils/background.js +14 -0
- package/dist/utils/background.js.map +1 -0
- package/dist/utils/logWatcher.js +3 -2
- package/dist/utils/logWatcher.js.map +1 -1
- package/dist/utils.d.ts +11 -1
- package/dist/utils.js +47 -8
- package/dist/utils.js.map +1 -1
- package/dist/webui/assets/DeleteOption-DkdJCiOu.js +1 -0
- package/dist/webui/assets/FieldInfo-rcCXc0d-.js +1 -0
- package/dist/webui/assets/Page-CKwSnUie.js +1 -0
- package/dist/webui/assets/array-field-DM2mAVqa.js +1 -0
- package/dist/webui/assets/badge-CLUazitN.js +1 -0
- package/dist/webui/assets/button-DoKPR9Fv.js +1 -0
- package/dist/webui/assets/check-BlfHpqkp.js +1 -0
- package/dist/webui/assets/clients-B5C80D0F.js +1 -0
- package/dist/webui/assets/connect-BM7yGLAl.js +2 -0
- package/dist/webui/assets/createLucideIcon-Cv-_CLkr.js +1 -0
- package/dist/webui/assets/debug-C8d57uIb.js +1 -0
- package/dist/webui/assets/directories-DkJnb01t.js +1 -0
- package/dist/webui/assets/dist-B7BqKb_s.js +1 -0
- package/dist/webui/assets/dist-CXZZv-cf.js +41 -0
- package/dist/webui/assets/dist-ChMQZgJB.js +1 -0
- package/dist/webui/assets/dist-DQ6Xm99Z.js +1 -0
- package/dist/webui/assets/duration-field-w-qiOS_S.js +1 -0
- package/dist/webui/assets/general-2HmkyF5T.js +1 -0
- package/dist/webui/assets/health-D6tv4ioy.js +1 -0
- package/dist/webui/assets/index-NlorOk2I.js +11 -0
- package/dist/webui/assets/index-UQKt4Igp.css +2 -0
- package/dist/webui/assets/input-BggK3IOz.js +1 -0
- package/dist/webui/assets/jobs-Do8vAIqy.js +1 -0
- package/dist/webui/assets/library-B1r1nAY-.js +1 -0
- package/dist/webui/assets/loader-circle-D988WNxu.js +1 -0
- package/dist/webui/assets/logs-_rm8bxf-.js +1 -0
- package/dist/webui/assets/number-field-CeKyqI7R.js +1 -0
- package/dist/webui/assets/react-dom-DtIef6y6.js +1 -0
- package/dist/webui/assets/required-indicator-Ba9NOQEP.js +1 -0
- package/dist/webui/assets/routes-Djgf7dZI.js +1 -0
- package/dist/webui/assets/search-DGY0ui92.js +1 -0
- package/dist/webui/assets/select-BzZ418Yt.js +1 -0
- package/dist/webui/assets/select-field-DsBowTDT.js +1 -0
- package/dist/webui/assets/settings-B4G8vHXc.js +1 -0
- package/dist/webui/assets/sidebar-Qy-rYdhU.js +5 -0
- package/dist/webui/assets/submit-button-Bx2Dvr03.js +1 -0
- package/dist/webui/assets/switch-CttdmVGp.js +1 -0
- package/dist/webui/assets/switch-field-p-JPVVvW.js +1 -0
- package/dist/webui/assets/table-Bs6CQscS.js +1 -0
- package/dist/webui/assets/{test-tube-CbcievIk.js → test-tube-DD9Yz2bZ.js} +1 -1
- package/dist/webui/assets/text-field-B0a3dEGb.js +1 -0
- package/dist/webui/assets/time-KFQKyrl-.js +1 -0
- package/dist/webui/assets/trackers-DG-YCaaO.js +7 -0
- package/dist/webui/assets/{trash-D083IWKI.js → trash-PHXIGUCt.js} +1 -1
- package/dist/webui/assets/use-settings-form-submit-CDmMUcwW.js +57 -0
- package/dist/webui/assets/useSelector-BoN-mufS.js +2 -0
- package/dist/webui/assets/utils-P-unlvb4.js +1 -0
- package/dist/webui/assets/with-selector-fbK2t2oY.js +1 -0
- package/dist/webui/index.html +12 -14
- package/node_modules/@cross-seed/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@cross-seed/shared/package.json +6 -2
- package/node_modules/zod/README.md +30 -20
- package/node_modules/zod/compile.cjs +96 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +21 -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/locales/index.cjs +19 -0
- package/node_modules/zod/locales/package.json +2 -1
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/mini/package.json +2 -1
- package/node_modules/zod/package.json +20 -8
- 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/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/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 +8 -11
- package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +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 +60 -45
- package/node_modules/zod/src/v4/classic/external.ts +15 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +389 -88
- 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 +16 -10
- package/node_modules/zod/src/v4/classic/schemas.ts +863 -335
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +29 -2
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +192 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +328 -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 +144 -2
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +4 -4
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +31 -17
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +90 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +221 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +291 -10
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +324 -2
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +743 -10
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +37 -6
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +23 -4
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -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 +215 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/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/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +138 -7
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +378 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +156 -13
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +71 -1
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +71 -1
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +44 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +69 -0
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +269 -16
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +126 -1
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +123 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +15 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +269 -4
- 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 +48 -7
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1948 -205
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +330 -2
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +93 -2
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +111 -34
- package/node_modules/zod/src/v4/core/checks.ts +120 -147
- package/node_modules/zod/src/v4/core/compile.ts +2322 -0
- package/node_modules/zod/src/v4/core/core.ts +116 -24
- package/node_modules/zod/src/v4/core/doc.ts +17 -9
- package/node_modules/zod/src/v4/core/errors.ts +138 -43
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +440 -173
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +167 -53
- package/node_modules/zod/src/v4/core/regexes.ts +50 -16
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +1219 -531
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +214 -0
- 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 +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +288 -44
- package/node_modules/zod/src/v4/core/util.ts +506 -179
- 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 +5 -0
- package/node_modules/zod/src/v4/locales/az.ts +5 -0
- package/node_modules/zod/src/v4/locales/be.ts +12 -0
- package/node_modules/zod/src/v4/locales/bg.ts +5 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +5 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +5 -0
- package/node_modules/zod/src/v4/locales/da.ts +7 -2
- package/node_modules/zod/src/v4/locales/de.ts +5 -0
- package/node_modules/zod/src/v4/locales/el.ts +124 -0
- package/node_modules/zod/src/v4/locales/en.ts +21 -4
- package/node_modules/zod/src/v4/locales/eo.ts +5 -0
- package/node_modules/zod/src/v4/locales/es.ts +4 -0
- package/node_modules/zod/src/v4/locales/fa.ts +5 -0
- package/node_modules/zod/src/v4/locales/fi.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr.ts +41 -18
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +8 -1
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +135 -0
- package/node_modules/zod/src/v4/locales/hu.ts +5 -0
- package/node_modules/zod/src/v4/locales/hy.ts +11 -0
- package/node_modules/zod/src/v4/locales/id.ts +5 -0
- package/node_modules/zod/src/v4/locales/index.ts +14 -0
- package/node_modules/zod/src/v4/locales/is.ts +5 -0
- package/node_modules/zod/src/v4/locales/it.ts +6 -1
- package/node_modules/zod/src/v4/locales/ja.ts +5 -0
- package/node_modules/zod/src/v4/locales/ka.ts +13 -8
- package/node_modules/zod/src/v4/locales/km.ts +5 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +5 -0
- package/node_modules/zod/src/v4/locales/lt.ts +4 -0
- package/node_modules/zod/src/v4/locales/mk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ms.ts +5 -0
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +5 -0
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +7 -2
- package/node_modules/zod/src/v4/locales/ota.ts +5 -0
- package/node_modules/zod/src/v4/locales/pl.ts +5 -0
- package/node_modules/zod/src/v4/locales/ps.ts +5 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +101 -58
- package/node_modules/zod/src/v4/locales/ro.ts +132 -0
- package/node_modules/zod/src/v4/locales/ru.ts +12 -0
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +5 -0
- package/node_modules/zod/src/v4/locales/sv.ts +7 -2
- package/node_modules/zod/src/v4/locales/ta.ts +5 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +5 -0
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +5 -0
- package/node_modules/zod/src/v4/locales/uk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ur.ts +5 -0
- package/node_modules/zod/src/v4/locales/uz.ts +4 -0
- package/node_modules/zod/src/v4/locales/vi.ts +5 -0
- package/node_modules/zod/src/v4/locales/yo.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +5 -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 +13 -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 +214 -79
- 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 +54 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- 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 +187 -4
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +74 -9
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +67 -1
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +49 -0
- package/node_modules/zod/v3/ZodError.cjs +41 -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/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/package.json +2 -1
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +26 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +21 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +19 -0
- 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 +58 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +62 -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 +44 -35
- package/node_modules/zod/v4/classic/external.cjs +51 -27
- package/node_modules/zod/v4/classic/external.d.cts +6 -2
- package/node_modules/zod/v4/classic/external.d.ts +6 -2
- package/node_modules/zod/v4/classic/external.js +5 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +394 -78
- package/node_modules/zod/v4/classic/from-json-schema.js +375 -78
- package/node_modules/zod/v4/classic/in-out.cjs +82 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +21 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +30 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/zod/v4/classic/parse.cjs +23 -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 +629 -225
- package/node_modules/zod/v4/classic/schemas.d.cts +104 -27
- package/node_modules/zod/v4/classic/schemas.d.ts +104 -27
- package/node_modules/zod/v4/classic/schemas.js +601 -223
- package/node_modules/zod/v4/core/api.cjs +73 -26
- package/node_modules/zod/v4/core/api.d.cts +40 -9
- package/node_modules/zod/v4/core/api.d.ts +40 -9
- package/node_modules/zod/v4/core/api.js +51 -26
- package/node_modules/zod/v4/core/checks.cjs +88 -128
- package/node_modules/zod/v4/core/checks.d.cts +30 -14
- package/node_modules/zod/v4/core/checks.d.ts +30 -14
- package/node_modules/zod/v4/core/checks.js +68 -127
- package/node_modules/zod/v4/core/compile.cjs +1916 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1866 -0
- package/node_modules/zod/v4/core/core.cjs +104 -20
- 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 +87 -22
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- 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 +12 -9
- package/node_modules/zod/v4/core/errors.cjs +146 -42
- package/node_modules/zod/v4/core/errors.d.cts +5 -0
- package/node_modules/zod/v4/core/errors.d.ts +5 -0
- package/node_modules/zod/v4/core/errors.js +127 -42
- package/node_modules/zod/v4/core/index.cjs +24 -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 +24 -1
- 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 +6 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +454 -173
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +413 -175
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- 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 +360 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +311 -0
- package/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/zod/v4/core/parse.cjs +151 -49
- 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 +130 -48
- package/node_modules/zod/v4/core/regexes.cjs +61 -18
- package/node_modules/zod/v4/core/regexes.d.cts +11 -0
- package/node_modules/zod/v4/core/regexes.d.ts +11 -0
- package/node_modules/zod/v4/core/regexes.js +39 -16
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +957 -382
- package/node_modules/zod/v4/core/schemas.d.cts +154 -25
- package/node_modules/zod/v4/core/schemas.d.ts +154 -25
- package/node_modules/zod/v4/core/schemas.js +925 -382
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +275 -40
- package/node_modules/zod/v4/core/to-json-schema.d.cts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.d.ts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.js +253 -39
- package/node_modules/zod/v4/core/util.cjs +428 -174
- package/node_modules/zod/v4/core/util.d.cts +82 -1
- package/node_modules/zod/v4/core/util.d.ts +82 -1
- package/node_modules/zod/v4/core/util.js +397 -175
- package/node_modules/zod/v4/core/versions.cjs +21 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +214 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +34 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +5 -0
- package/node_modules/zod/v4/locales/ar.js +5 -0
- package/node_modules/zod/v4/locales/az.cjs +5 -0
- package/node_modules/zod/v4/locales/az.js +5 -0
- package/node_modules/zod/v4/locales/be.cjs +12 -0
- package/node_modules/zod/v4/locales/be.js +12 -0
- package/node_modules/zod/v4/locales/bg.cjs +5 -0
- package/node_modules/zod/v4/locales/bg.js +5 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +5 -0
- package/node_modules/zod/v4/locales/ca.js +5 -0
- package/node_modules/zod/v4/locales/ckb.cjs +160 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +5 -0
- package/node_modules/zod/v4/locales/cs.js +5 -0
- package/node_modules/zod/v4/locales/da.cjs +7 -2
- package/node_modules/zod/v4/locales/da.js +7 -2
- package/node_modules/zod/v4/locales/de.cjs +5 -0
- package/node_modules/zod/v4/locales/de.js +5 -0
- package/node_modules/zod/v4/locales/el.cjs +139 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +112 -0
- package/node_modules/zod/v4/locales/en.cjs +20 -4
- package/node_modules/zod/v4/locales/en.js +20 -4
- package/node_modules/zod/v4/locales/eo.cjs +5 -0
- package/node_modules/zod/v4/locales/eo.js +5 -0
- package/node_modules/zod/v4/locales/es.cjs +4 -0
- package/node_modules/zod/v4/locales/es.js +4 -0
- package/node_modules/zod/v4/locales/fa.cjs +5 -0
- package/node_modules/zod/v4/locales/fa.js +5 -0
- package/node_modules/zod/v4/locales/fi.cjs +5 -0
- package/node_modules/zod/v4/locales/fi.js +5 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +5 -0
- package/node_modules/zod/v4/locales/fr-CA.js +5 -0
- package/node_modules/zod/v4/locales/fr.cjs +38 -17
- package/node_modules/zod/v4/locales/fr.js +38 -17
- package/node_modules/zod/v4/locales/gu.cjs +140 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +113 -0
- package/node_modules/zod/v4/locales/he.cjs +7 -0
- package/node_modules/zod/v4/locales/he.js +7 -0
- package/node_modules/zod/v4/locales/hi.cjs +138 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +153 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +126 -0
- package/node_modules/zod/v4/locales/hu.cjs +5 -0
- package/node_modules/zod/v4/locales/hu.js +5 -0
- package/node_modules/zod/v4/locales/hy.cjs +11 -0
- package/node_modules/zod/v4/locales/hy.js +11 -0
- package/node_modules/zod/v4/locales/id.cjs +5 -0
- package/node_modules/zod/v4/locales/id.js +5 -0
- package/node_modules/zod/v4/locales/index.cjs +49 -1
- package/node_modules/zod/v4/locales/index.d.cts +14 -0
- package/node_modules/zod/v4/locales/index.d.ts +14 -0
- package/node_modules/zod/v4/locales/index.js +14 -0
- package/node_modules/zod/v4/locales/is.cjs +5 -0
- package/node_modules/zod/v4/locales/is.js +5 -0
- package/node_modules/zod/v4/locales/it.cjs +6 -1
- package/node_modules/zod/v4/locales/it.js +6 -1
- package/node_modules/zod/v4/locales/ja.cjs +5 -0
- package/node_modules/zod/v4/locales/ja.js +5 -0
- package/node_modules/zod/v4/locales/ka.cjs +13 -8
- package/node_modules/zod/v4/locales/ka.js +13 -8
- package/node_modules/zod/v4/locales/km.cjs +5 -0
- package/node_modules/zod/v4/locales/km.js +5 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +5 -0
- package/node_modules/zod/v4/locales/ko.js +5 -0
- package/node_modules/zod/v4/locales/lt.cjs +4 -0
- package/node_modules/zod/v4/locales/lt.js +4 -0
- package/node_modules/zod/v4/locales/mk.cjs +5 -0
- package/node_modules/zod/v4/locales/mk.js +5 -0
- package/node_modules/zod/v4/locales/ms.cjs +5 -0
- package/node_modules/zod/v4/locales/ms.js +5 -0
- package/node_modules/zod/v4/locales/ne.cjs +138 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +5 -0
- package/node_modules/zod/v4/locales/nl.js +5 -0
- package/node_modules/zod/v4/locales/nn.cjs +140 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +113 -0
- package/node_modules/zod/v4/locales/no.cjs +7 -2
- package/node_modules/zod/v4/locales/no.js +7 -2
- package/node_modules/zod/v4/locales/ota.cjs +5 -0
- package/node_modules/zod/v4/locales/ota.js +5 -0
- package/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/zod/v4/locales/pl.cjs +5 -0
- package/node_modules/zod/v4/locales/pl.js +5 -0
- package/node_modules/zod/v4/locales/ps.cjs +5 -0
- package/node_modules/zod/v4/locales/ps.js +5 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +89 -55
- package/node_modules/zod/v4/locales/pt.js +89 -55
- package/node_modules/zod/v4/locales/ro.cjs +149 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +122 -0
- package/node_modules/zod/v4/locales/ru.cjs +12 -0
- package/node_modules/zod/v4/locales/ru.js +12 -0
- package/node_modules/zod/v4/locales/sk.cjs +143 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +5 -0
- package/node_modules/zod/v4/locales/sl.js +5 -0
- package/node_modules/zod/v4/locales/sv.cjs +7 -2
- package/node_modules/zod/v4/locales/sv.js +7 -2
- package/node_modules/zod/v4/locales/ta.cjs +5 -0
- package/node_modules/zod/v4/locales/ta.js +5 -0
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +5 -0
- package/node_modules/zod/v4/locales/th.js +5 -0
- package/node_modules/zod/v4/locales/tk.cjs +134 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +5 -0
- package/node_modules/zod/v4/locales/tr.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +5 -0
- package/node_modules/zod/v4/locales/uk.js +5 -0
- package/node_modules/zod/v4/locales/ur.cjs +5 -0
- package/node_modules/zod/v4/locales/ur.js +5 -0
- package/node_modules/zod/v4/locales/uz.cjs +4 -0
- package/node_modules/zod/v4/locales/uz.js +4 -0
- package/node_modules/zod/v4/locales/vi.cjs +5 -0
- package/node_modules/zod/v4/locales/vi.js +5 -0
- package/node_modules/zod/v4/locales/yo.cjs +5 -0
- package/node_modules/zod/v4/locales/yo.js +5 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-CN.js +5 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-TW.js +5 -0
- package/node_modules/zod/v4/mini/checks.cjs +21 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +33 -1
- package/node_modules/zod/v4/mini/external.d.cts +6 -2
- package/node_modules/zod/v4/mini/external.d.ts +6 -2
- package/node_modules/zod/v4/mini/external.js +3 -1
- package/node_modules/zod/v4/mini/in-out.cjs +82 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +19 -0
- package/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/zod/v4/mini/parse.cjs +22 -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 +151 -50
- package/node_modules/zod/v4/mini/schemas.d.cts +75 -22
- package/node_modules/zod/v4/mini/schemas.d.ts +75 -22
- package/node_modules/zod/v4/mini/schemas.js +125 -48
- package/node_modules/zod/v4/package.json +2 -1
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +16 -14
- package/dist/trpc/routers/searchees.d.ts +0 -51
- package/dist/trpc/routers/searchees.js +0 -156
- package/dist/trpc/routers/searchees.js.map +0 -1
- package/dist/webui/assets/ClientOnly-CzZIsGML.js +0 -1
- package/dist/webui/assets/DeleteOption-dxKSbv6N.js +0 -1
- package/dist/webui/assets/FieldInfo-FLjtPgL4.js +0 -1
- package/dist/webui/assets/Page-C7KClZ28.js +0 -1
- package/dist/webui/assets/array-field-DGB7Lbh7.js +0 -1
- package/dist/webui/assets/badge-hukNSIir.js +0 -1
- package/dist/webui/assets/button-1cIaa9Lf.js +0 -1
- package/dist/webui/assets/check-CUrWQ2C7.js +0 -1
- package/dist/webui/assets/chevron-down-CVVogpPh.js +0 -1
- package/dist/webui/assets/clients-CHdgqO4r.js +0 -1
- package/dist/webui/assets/connect-Cr6Q3W8U.js +0 -2
- package/dist/webui/assets/createLucideIcon-zYRS_Hrv.js +0 -1
- package/dist/webui/assets/debug-CEmoQ2W_.js +0 -1
- package/dist/webui/assets/directories-CNuHKfHz.js +0 -1
- package/dist/webui/assets/dist-Bbmh5Du9.js +0 -1
- package/dist/webui/assets/dist-DhH_lYkz.js +0 -1
- package/dist/webui/assets/dist-DzdkRn7I.js +0 -1
- package/dist/webui/assets/dist-b2njvUJz.js +0 -41
- package/dist/webui/assets/dist-d-Lt00zD.js +0 -1
- package/dist/webui/assets/duration-field-CnlQcr37.js +0 -1
- package/dist/webui/assets/form-context-B-ekdUc0.js +0 -1
- package/dist/webui/assets/form-validation-context-CPAPOloL.js +0 -1
- package/dist/webui/assets/general-Cs8dEydJ.js +0 -1
- package/dist/webui/assets/health-DugF7R6A.js +0 -1
- package/dist/webui/assets/index-DhV1H9AB.css +0 -2
- package/dist/webui/assets/index-DinSQfHc.js +0 -11
- package/dist/webui/assets/input-CsfmMUT5.js +0 -1
- package/dist/webui/assets/jobs-Cr1xWWzM.js +0 -1
- package/dist/webui/assets/library-BNsctrbc.js +0 -1
- package/dist/webui/assets/loader-circle-BQbzoYGJ.js +0 -1
- package/dist/webui/assets/logs-C1l3cu_j.js +0 -1
- package/dist/webui/assets/number-field-Ce3QdLSz.js +0 -1
- package/dist/webui/assets/react-dom-mEftaaxx.js +0 -1
- package/dist/webui/assets/required-indicator-BXf2UzTH.js +0 -1
- package/dist/webui/assets/routes-Bw2nXmFg.js +0 -1
- package/dist/webui/assets/search-D9W5vk_0.js +0 -1
- package/dist/webui/assets/select-CZn10WME.js +0 -1
- package/dist/webui/assets/select-field-DozTirAZ.js +0 -1
- package/dist/webui/assets/settings-BXbhXNDK.js +0 -1
- package/dist/webui/assets/sidebar-y9WJu7Jw.js +0 -5
- package/dist/webui/assets/submit-button-CBOzR0f_.js +0 -1
- package/dist/webui/assets/switch-D4S9As9u.js +0 -1
- package/dist/webui/assets/switch-field-2E9ctvy_.js +0 -1
- package/dist/webui/assets/table-B1Y18B60.js +0 -1
- package/dist/webui/assets/text-field-DV4EP-I8.js +0 -1
- package/dist/webui/assets/time-DjUFOA4D.js +0 -1
- package/dist/webui/assets/trackers-ULhLxA6-.js +0 -7
- package/dist/webui/assets/use-settings-form-submit-D87nmJRy.js +0 -79
- package/dist/webui/assets/useBaseQuery-BvrWhgOK.js +0 -1
- package/dist/webui/assets/useRouterState-CZfD5Xdv.js +0 -1
- package/dist/webui/assets/useStore-CusP06SD.js +0 -1
- package/node_modules/zod/src/v4/core/config.ts +0 -15
|
@@ -23,11 +23,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.$
|
|
27
|
-
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodExactOptional = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = void 0;
|
|
26
|
+
exports.$ZodObject = exports.$ZodArray = exports.$ZodDate = exports.$ZodVoid = exports.$ZodNever = exports.$ZodUnknown = exports.$ZodAny = exports.$ZodNull = exports.$ZodUndefined = exports.$ZodSymbol = exports.$ZodBigIntFormat = exports.$ZodBigInt = exports.$ZodBoolean = exports.$ZodNumberFormat = exports.$ZodNumber = exports.$ZodCustomStringFormat = exports.$ZodJWT = exports.$ZodIBAN = exports.$ZodCreditCard = exports.$ZodE164 = exports.$ZodBase64URL = exports.base64urlCharset = exports.$ZodBase64 = exports.base64Charset = exports.$ZodCIDRv6 = exports.$ZodCIDRv4 = exports.$ZodMAC = exports.$ZodIPv6 = exports.$ZodIPv4 = exports.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.URL_UNPARSEABLE = exports.URL_BAD_FORMAT = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
|
|
27
|
+
exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodPreprocess = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodExactOptional = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = void 0;
|
|
28
|
+
exports.standardProps = standardProps;
|
|
29
|
+
exports.canParseURL = canParseURL;
|
|
30
|
+
exports.validateURL = validateURL;
|
|
31
|
+
exports.parseURLObject = parseURLObject;
|
|
32
|
+
exports.stripTabAndNewline = stripTabAndNewline;
|
|
33
|
+
exports.urlHostnameOk = urlHostnameOk;
|
|
34
|
+
exports.urlProtocolOk = urlProtocolOk;
|
|
35
|
+
exports.isValidIPv6 = isValidIPv6;
|
|
36
|
+
exports.isValidCIDRv6 = isValidCIDRv6;
|
|
28
37
|
exports.isValidBase64 = isValidBase64;
|
|
29
38
|
exports.isValidBase64URL = isValidBase64URL;
|
|
39
|
+
exports.isValidCreditCard = isValidCreditCard;
|
|
40
|
+
exports.isValidIBAN = isValidIBAN;
|
|
30
41
|
exports.isValidJWT = isValidJWT;
|
|
42
|
+
exports.getDiscriminatedOption = getDiscriminatedOption;
|
|
43
|
+
exports.mergeValues = mergeValues;
|
|
31
44
|
const checks = __importStar(require("./checks.cjs"));
|
|
32
45
|
const core = __importStar(require("./core.cjs"));
|
|
33
46
|
const doc_js_1 = require("./doc.cjs");
|
|
@@ -41,19 +54,20 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
41
54
|
inst._zod.def = def; // set _def property
|
|
42
55
|
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
43
56
|
inst._zod.version = versions_js_1.version;
|
|
44
|
-
const
|
|
57
|
+
const defChecks = inst._zod.def.checks;
|
|
45
58
|
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
const checks = inst._zod.traits.has("$ZodCheck")
|
|
60
|
+
? [inst, ...(defChecks ?? [])]
|
|
61
|
+
: defChecks?.length
|
|
62
|
+
? [...defChecks]
|
|
63
|
+
: [];
|
|
49
64
|
for (const ch of checks) {
|
|
50
65
|
for (const fn of ch._zod.onattach) {
|
|
51
66
|
fn(inst);
|
|
52
67
|
}
|
|
53
68
|
}
|
|
54
69
|
if (checks.length === 0) {
|
|
55
|
-
// deferred initializer
|
|
56
|
-
// inst._zod.parse is not yet defined
|
|
70
|
+
// deferred initializer inst._zod.parse is not yet defined
|
|
57
71
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
58
72
|
inst._zod.deferred?.push(() => {
|
|
59
73
|
inst._zod.run = inst._zod.parse;
|
|
@@ -61,10 +75,14 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
61
75
|
}
|
|
62
76
|
else {
|
|
63
77
|
const runChecks = (payload, checks, ctx) => {
|
|
78
|
+
if (payload.memo)
|
|
79
|
+
return payload;
|
|
64
80
|
let isAborted = util.aborted(payload);
|
|
65
81
|
let asyncResult;
|
|
66
82
|
for (const ch of checks) {
|
|
67
83
|
if (ch._zod.def.when) {
|
|
84
|
+
if (util.explicitlyAborted(payload))
|
|
85
|
+
continue;
|
|
68
86
|
const shouldRun = ch._zod.def.when(payload);
|
|
69
87
|
if (!shouldRun)
|
|
70
88
|
continue;
|
|
@@ -83,6 +101,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
83
101
|
const nextLen = payload.issues.length;
|
|
84
102
|
if (nextLen === currLen)
|
|
85
103
|
return;
|
|
104
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
86
105
|
if (!isAborted)
|
|
87
106
|
isAborted = util.aborted(payload, currLen);
|
|
88
107
|
});
|
|
@@ -91,6 +110,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
91
110
|
const nextLen = payload.issues.length;
|
|
92
111
|
if (nextLen === currLen)
|
|
93
112
|
continue;
|
|
113
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
94
114
|
if (!isAborted)
|
|
95
115
|
isAborted = util.aborted(payload, currLen);
|
|
96
116
|
}
|
|
@@ -122,8 +142,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
122
142
|
return inst._zod.parse(payload, ctx);
|
|
123
143
|
}
|
|
124
144
|
if (ctx.direction === "backward") {
|
|
125
|
-
// run canary
|
|
126
|
-
// initial pass (no checks)
|
|
145
|
+
// run canary initial pass (no checks)
|
|
127
146
|
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
128
147
|
if (canary instanceof Promise) {
|
|
129
148
|
return canary.then((canary) => {
|
|
@@ -142,26 +161,45 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
|
|
|
142
161
|
return runChecks(result, checks, ctx);
|
|
143
162
|
};
|
|
144
163
|
}
|
|
145
|
-
|
|
146
|
-
|
|
164
|
+
}, {
|
|
165
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
166
|
+
get "~standard"() {
|
|
167
|
+
return util.hide(this, "~standard", standardProps(this));
|
|
168
|
+
},
|
|
169
|
+
set "~standard"(value) {
|
|
170
|
+
util.own(this, "~standard", value);
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
174
|
+
// a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
|
|
175
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
|
|
176
|
+
async function validateAsync(inst, value) {
|
|
177
|
+
const ctx = { async: true };
|
|
178
|
+
return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
|
|
179
|
+
}
|
|
180
|
+
function standardProps(inst) {
|
|
181
|
+
return {
|
|
147
182
|
validate: (value) => {
|
|
183
|
+
const ctx = { async: false };
|
|
148
184
|
try {
|
|
149
|
-
const r = (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
catch (_) {
|
|
153
|
-
return (0, parse_js_1.safeParseAsync)(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
|
|
185
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
186
|
+
if (!(r instanceof Promise))
|
|
187
|
+
return toStandardResult(r, ctx);
|
|
154
188
|
}
|
|
189
|
+
catch (_) { }
|
|
190
|
+
// async function so a synchronously throwing check rejects instead of escaping validate
|
|
191
|
+
return validateAsync(inst, value);
|
|
155
192
|
},
|
|
156
193
|
vendor: "zod",
|
|
157
194
|
version: 1,
|
|
158
|
-
}
|
|
159
|
-
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
160
197
|
var util_js_1 = require("./util.cjs");
|
|
161
198
|
Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
|
|
162
199
|
exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
|
|
163
200
|
exports.$ZodType.init(inst, def);
|
|
164
|
-
|
|
201
|
+
// a format's own pattern, else unbounded; a template literal derives the check-aware form itself
|
|
202
|
+
inst._zod.pattern = def.pattern ?? regexes.anyString;
|
|
165
203
|
inst._zod.parse = (payload, _) => {
|
|
166
204
|
if (def.coerce)
|
|
167
205
|
try {
|
|
@@ -213,51 +251,115 @@ exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
|
|
|
213
251
|
def.pattern ?? (def.pattern = regexes.email);
|
|
214
252
|
exports.$ZodStringFormat.init(inst, def);
|
|
215
253
|
});
|
|
254
|
+
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
255
|
+
exports.URL_BAD_FORMAT = 1;
|
|
256
|
+
/** The URL parser rejected the input. */
|
|
257
|
+
exports.URL_UNPARSEABLE = 2;
|
|
258
|
+
function canParseURL(input) {
|
|
259
|
+
try {
|
|
260
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
261
|
+
return URL.canParse(input);
|
|
262
|
+
new URL(input);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function validateURL(trimmed, def) {
|
|
270
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
271
|
+
return canParseURL(trimmed) || exports.URL_UNPARSEABLE;
|
|
272
|
+
}
|
|
273
|
+
return parseURLObject(trimmed, def);
|
|
274
|
+
}
|
|
275
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
276
|
+
function parseURLObject(trimmed, def) {
|
|
277
|
+
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
278
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
279
|
+
return exports.URL_BAD_FORMAT;
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
if (typeof URL !== "undefined") {
|
|
283
|
+
const URLStatic = URL;
|
|
284
|
+
if (typeof URLStatic.parse === "function")
|
|
285
|
+
return URLStatic.parse(trimmed) ?? exports.URL_UNPARSEABLE;
|
|
286
|
+
}
|
|
287
|
+
// @ts-ignore
|
|
288
|
+
return new URL(trimmed);
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return exports.URL_UNPARSEABLE;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
295
|
+
/** 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. */
|
|
296
|
+
function stripTabAndNewline(value) {
|
|
297
|
+
return value.replace(asciiTabOrNewline, "");
|
|
298
|
+
}
|
|
299
|
+
function urlHostnameOk(url, hostname) {
|
|
300
|
+
hostname.lastIndex = 0;
|
|
301
|
+
return hostname.test(url.hostname);
|
|
302
|
+
}
|
|
303
|
+
function urlProtocolOk(url, protocol) {
|
|
304
|
+
protocol.lastIndex = 0;
|
|
305
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
306
|
+
}
|
|
216
307
|
exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
|
|
217
308
|
exports.$ZodStringFormat.init(inst, def);
|
|
218
309
|
inst._zod.check = (payload) => {
|
|
219
310
|
try {
|
|
220
311
|
// Trim whitespace from input
|
|
221
312
|
const trimmed = payload.value.trim();
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
inst,
|
|
234
|
-
continue: !def.abort,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
313
|
+
const url = validateURL(trimmed, def);
|
|
314
|
+
if (url === exports.URL_BAD_FORMAT) {
|
|
315
|
+
payload.issues.push({
|
|
316
|
+
code: "invalid_format",
|
|
317
|
+
format: "url",
|
|
318
|
+
note: "Invalid URL format",
|
|
319
|
+
input: payload.value,
|
|
320
|
+
inst,
|
|
321
|
+
continue: !def.abort,
|
|
322
|
+
});
|
|
323
|
+
return;
|
|
237
324
|
}
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
inst,
|
|
248
|
-
continue: !def.abort,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
325
|
+
if (url === exports.URL_UNPARSEABLE) {
|
|
326
|
+
payload.issues.push({
|
|
327
|
+
code: "invalid_format",
|
|
328
|
+
format: "url",
|
|
329
|
+
input: payload.value,
|
|
330
|
+
inst,
|
|
331
|
+
continue: !def.abort,
|
|
332
|
+
});
|
|
333
|
+
return;
|
|
251
334
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
payload.value = url.href;
|
|
335
|
+
if (url === true) {
|
|
336
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
337
|
+
return;
|
|
256
338
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
339
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
340
|
+
payload.issues.push({
|
|
341
|
+
code: "invalid_format",
|
|
342
|
+
format: "url",
|
|
343
|
+
note: "Invalid hostname",
|
|
344
|
+
pattern: def.hostname.source,
|
|
345
|
+
input: payload.value,
|
|
346
|
+
inst,
|
|
347
|
+
continue: !def.abort,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
351
|
+
payload.issues.push({
|
|
352
|
+
code: "invalid_format",
|
|
353
|
+
format: "url",
|
|
354
|
+
note: "Invalid protocol",
|
|
355
|
+
pattern: def.protocol.source,
|
|
356
|
+
input: payload.value,
|
|
357
|
+
inst,
|
|
358
|
+
continue: !def.abort,
|
|
359
|
+
});
|
|
260
360
|
}
|
|
361
|
+
// Set the output value based on normalize flag
|
|
362
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
261
363
|
return;
|
|
262
364
|
}
|
|
263
365
|
catch (_) {
|
|
@@ -276,9 +378,16 @@ exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
|
|
|
276
378
|
exports.$ZodStringFormat.init(inst, def);
|
|
277
379
|
});
|
|
278
380
|
exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
|
|
279
|
-
def.
|
|
381
|
+
if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
|
|
382
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
383
|
+
def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
|
|
280
384
|
exports.$ZodStringFormat.init(inst, def);
|
|
281
385
|
});
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
388
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
389
|
+
* See https://github.com/paralleldrive/cuid.
|
|
390
|
+
*/
|
|
282
391
|
exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
|
|
283
392
|
def.pattern ?? (def.pattern = regexes.cuid);
|
|
284
393
|
exports.$ZodStringFormat.init(inst, def);
|
|
@@ -318,19 +427,19 @@ exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
|
|
|
318
427
|
exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
|
|
319
428
|
def.pattern ?? (def.pattern = regexes.ipv4);
|
|
320
429
|
exports.$ZodStringFormat.init(inst, def);
|
|
321
|
-
inst._zod.bag.format = `ipv4`;
|
|
322
430
|
});
|
|
431
|
+
/** 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`. */
|
|
432
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
433
|
+
function isValidIPv6(value) {
|
|
434
|
+
if (!ipv6Alphabet.test(value))
|
|
435
|
+
return false;
|
|
436
|
+
return canParseURL(`http://[${value}]`);
|
|
437
|
+
}
|
|
323
438
|
exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
|
|
324
439
|
def.pattern ?? (def.pattern = regexes.ipv6);
|
|
325
440
|
exports.$ZodStringFormat.init(inst, def);
|
|
326
|
-
inst._zod.bag.format = `ipv6`;
|
|
327
441
|
inst._zod.check = (payload) => {
|
|
328
|
-
|
|
329
|
-
// @ts-ignore
|
|
330
|
-
new URL(`http://[${payload.value}]`);
|
|
331
|
-
// return;
|
|
332
|
-
}
|
|
333
|
-
catch {
|
|
442
|
+
if (!isValidIPv6(payload.value)) {
|
|
334
443
|
payload.issues.push({
|
|
335
444
|
code: "invalid_format",
|
|
336
445
|
format: "ipv6",
|
|
@@ -344,32 +453,30 @@ exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
|
|
|
344
453
|
exports.$ZodMAC = core.$constructor("$ZodMAC", (inst, def) => {
|
|
345
454
|
def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
|
|
346
455
|
exports.$ZodStringFormat.init(inst, def);
|
|
347
|
-
inst._zod.bag.format = `mac`;
|
|
348
456
|
});
|
|
349
457
|
exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
|
|
350
458
|
def.pattern ?? (def.pattern = regexes.cidrv4);
|
|
351
459
|
exports.$ZodStringFormat.init(inst, def);
|
|
352
460
|
});
|
|
461
|
+
function isValidCIDRv6(value) {
|
|
462
|
+
const parts = value.split("/");
|
|
463
|
+
if (parts.length !== 2)
|
|
464
|
+
return false;
|
|
465
|
+
const [address, prefix] = parts;
|
|
466
|
+
if (!prefix)
|
|
467
|
+
return false;
|
|
468
|
+
const prefixNum = Number(prefix);
|
|
469
|
+
if (`${prefixNum}` !== prefix)
|
|
470
|
+
return false;
|
|
471
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
472
|
+
return false;
|
|
473
|
+
return isValidIPv6(address);
|
|
474
|
+
}
|
|
353
475
|
exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
354
476
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
355
477
|
exports.$ZodStringFormat.init(inst, def);
|
|
356
478
|
inst._zod.check = (payload) => {
|
|
357
|
-
|
|
358
|
-
try {
|
|
359
|
-
if (parts.length !== 2)
|
|
360
|
-
throw new Error();
|
|
361
|
-
const [address, prefix] = parts;
|
|
362
|
-
if (!prefix)
|
|
363
|
-
throw new Error();
|
|
364
|
-
const prefixNum = Number(prefix);
|
|
365
|
-
if (`${prefixNum}` !== prefix)
|
|
366
|
-
throw new Error();
|
|
367
|
-
if (prefixNum < 0 || prefixNum > 128)
|
|
368
|
-
throw new Error();
|
|
369
|
-
// @ts-ignore
|
|
370
|
-
new URL(`http://[${address}]`);
|
|
371
|
-
}
|
|
372
|
-
catch {
|
|
479
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
373
480
|
payload.issues.push({
|
|
374
481
|
code: "invalid_format",
|
|
375
482
|
format: "cidrv6",
|
|
@@ -384,6 +491,9 @@ exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
384
491
|
function isValidBase64(data) {
|
|
385
492
|
if (data === "")
|
|
386
493
|
return true;
|
|
494
|
+
// atob ignores whitespace, so reject it up front.
|
|
495
|
+
if (/\s/.test(data))
|
|
496
|
+
return false;
|
|
387
497
|
if (data.length % 4 !== 0)
|
|
388
498
|
return false;
|
|
389
499
|
try {
|
|
@@ -395,10 +505,11 @@ function isValidBase64(data) {
|
|
|
395
505
|
return false;
|
|
396
506
|
}
|
|
397
507
|
}
|
|
508
|
+
// lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
|
|
509
|
+
exports.base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
398
510
|
exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
|
|
399
|
-
def.pattern ?? (def.pattern =
|
|
511
|
+
def.pattern ?? (def.pattern = exports.base64Charset);
|
|
400
512
|
exports.$ZodStringFormat.init(inst, def);
|
|
401
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
402
513
|
inst._zod.check = (payload) => {
|
|
403
514
|
if (isValidBase64(payload.value))
|
|
404
515
|
return;
|
|
@@ -411,18 +522,19 @@ exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
|
|
|
411
522
|
});
|
|
412
523
|
};
|
|
413
524
|
});
|
|
414
|
-
//////////////////////////////
|
|
525
|
+
////////////////////////////// ZodBase64URL //////////////////////////////
|
|
526
|
+
// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
|
|
527
|
+
exports.base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
415
528
|
function isValidBase64URL(data) {
|
|
416
|
-
if (!
|
|
529
|
+
if (!exports.base64urlCharset.test(data))
|
|
417
530
|
return false;
|
|
418
531
|
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
419
532
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
420
533
|
return isValidBase64(padded);
|
|
421
534
|
}
|
|
422
535
|
exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
|
|
423
|
-
def.pattern ?? (def.pattern =
|
|
536
|
+
def.pattern ?? (def.pattern = exports.base64urlCharset);
|
|
424
537
|
exports.$ZodStringFormat.init(inst, def);
|
|
425
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
426
538
|
inst._zod.check = (payload) => {
|
|
427
539
|
if (isValidBase64URL(payload.value))
|
|
428
540
|
return;
|
|
@@ -439,6 +551,77 @@ exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
|
|
|
439
551
|
def.pattern ?? (def.pattern = regexes.e164);
|
|
440
552
|
exports.$ZodStringFormat.init(inst, def);
|
|
441
553
|
});
|
|
554
|
+
////////////////////////////// ZodCreditCard //////////////////////////////
|
|
555
|
+
const CC_SANITIZE = /[- ]/g;
|
|
556
|
+
/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
|
|
557
|
+
function isLuhnAlgo(digits) {
|
|
558
|
+
let length = digits.length;
|
|
559
|
+
let bit = 1;
|
|
560
|
+
let sum = 0;
|
|
561
|
+
while (length) {
|
|
562
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
563
|
+
bit ^= 1;
|
|
564
|
+
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
|
|
565
|
+
}
|
|
566
|
+
return sum % 10 === 0;
|
|
567
|
+
}
|
|
568
|
+
function isValidCreditCard(input) {
|
|
569
|
+
if (!regexes.creditCard.test(input))
|
|
570
|
+
return false;
|
|
571
|
+
return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
|
|
572
|
+
}
|
|
573
|
+
exports.$ZodCreditCard = core.$constructor("$ZodCreditCard", (inst, def) => {
|
|
574
|
+
// 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.
|
|
575
|
+
def.pattern ?? (def.pattern = regexes.creditCard);
|
|
576
|
+
exports.$ZodStringFormat.init(inst, def);
|
|
577
|
+
inst._zod.check = (payload) => {
|
|
578
|
+
if (isValidCreditCard(payload.value))
|
|
579
|
+
return;
|
|
580
|
+
payload.issues.push({
|
|
581
|
+
code: "invalid_format",
|
|
582
|
+
format: "credit_card",
|
|
583
|
+
input: payload.value,
|
|
584
|
+
inst,
|
|
585
|
+
continue: !def.abort,
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
});
|
|
589
|
+
////////////////////////////// ZodIBAN //////////////////////////////
|
|
590
|
+
// iso 7064 mod 97-10 checksum without BigInt
|
|
591
|
+
function isIso7064Mod97(iban) {
|
|
592
|
+
let remainder = 0;
|
|
593
|
+
const len = iban.length;
|
|
594
|
+
for (let i = 4; i < len; i++) {
|
|
595
|
+
const code = iban.charCodeAt(i);
|
|
596
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
597
|
+
}
|
|
598
|
+
for (let i = 0; i < 4; i++) {
|
|
599
|
+
const code = iban.charCodeAt(i);
|
|
600
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
601
|
+
}
|
|
602
|
+
return remainder === 1;
|
|
603
|
+
}
|
|
604
|
+
function isValidIBAN(input) {
|
|
605
|
+
if (!regexes.iban.test(input))
|
|
606
|
+
return false;
|
|
607
|
+
return isIso7064Mod97(input);
|
|
608
|
+
}
|
|
609
|
+
exports.$ZodIBAN = core.$constructor("$ZodIBAN", (inst, def) => {
|
|
610
|
+
// shape only — checksum is not expressible as a pattern
|
|
611
|
+
def.pattern ?? (def.pattern = regexes.iban);
|
|
612
|
+
exports.$ZodStringFormat.init(inst, def);
|
|
613
|
+
inst._zod.check = (payload) => {
|
|
614
|
+
if (isValidIBAN(payload.value))
|
|
615
|
+
return;
|
|
616
|
+
payload.issues.push({
|
|
617
|
+
code: "invalid_format",
|
|
618
|
+
format: "iban",
|
|
619
|
+
input: payload.value,
|
|
620
|
+
inst,
|
|
621
|
+
continue: !def.abort,
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
});
|
|
442
625
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
443
626
|
function isValidJWT(token, algorithm = null) {
|
|
444
627
|
try {
|
|
@@ -492,7 +675,7 @@ exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (in
|
|
|
492
675
|
});
|
|
493
676
|
exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
|
|
494
677
|
exports.$ZodType.init(inst, def);
|
|
495
|
-
inst._zod.pattern =
|
|
678
|
+
inst._zod.pattern = regexes.number;
|
|
496
679
|
inst._zod.parse = (payload, _ctx) => {
|
|
497
680
|
if (def.coerce)
|
|
498
681
|
try {
|
|
@@ -507,7 +690,7 @@ exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
|
|
|
507
690
|
? Number.isNaN(input)
|
|
508
691
|
? "NaN"
|
|
509
692
|
: !Number.isFinite(input)
|
|
510
|
-
?
|
|
693
|
+
? String(input)
|
|
511
694
|
: undefined
|
|
512
695
|
: undefined;
|
|
513
696
|
payload.issues.push({
|
|
@@ -588,8 +771,6 @@ exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
|
|
|
588
771
|
exports.$ZodType.init(inst, def);
|
|
589
772
|
inst._zod.pattern = regexes.undefined;
|
|
590
773
|
inst._zod.values = new Set([undefined]);
|
|
591
|
-
inst._zod.optin = "optional";
|
|
592
|
-
inst._zod.optout = "optional";
|
|
593
774
|
inst._zod.parse = (payload, _ctx) => {
|
|
594
775
|
const input = payload.value;
|
|
595
776
|
if (typeof input === "undefined")
|
|
@@ -679,6 +860,33 @@ exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
|
|
|
679
860
|
return payload;
|
|
680
861
|
};
|
|
681
862
|
});
|
|
863
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
864
|
+
function capSize(inst, size) {
|
|
865
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
866
|
+
if (!caps.length)
|
|
867
|
+
return;
|
|
868
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
869
|
+
const parse = inst._zod.parse;
|
|
870
|
+
inst._zod.parse = (payload, ctx) => {
|
|
871
|
+
const n = size(payload.value);
|
|
872
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
873
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
874
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
875
|
+
const start = payload.issues.length;
|
|
876
|
+
ch._zod.check(payload);
|
|
877
|
+
// the value is still the raw input, so no later check may read it
|
|
878
|
+
payload.issues[start].continue = false;
|
|
879
|
+
util.attachSchema(payload.issues, start, inst);
|
|
880
|
+
return payload;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return parse(payload, ctx);
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
888
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
889
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
682
890
|
function handleArrayResult(result, final, index) {
|
|
683
891
|
if (result.issues.length) {
|
|
684
892
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -687,6 +895,8 @@ function handleArrayResult(result, final, index) {
|
|
|
687
895
|
}
|
|
688
896
|
exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
689
897
|
exports.$ZodType.init(inst, def);
|
|
898
|
+
const memo = core.globalConfig.memoizer;
|
|
899
|
+
memo?.attach(inst);
|
|
690
900
|
inst._zod.parse = (payload, ctx) => {
|
|
691
901
|
const input = payload.value;
|
|
692
902
|
if (!Array.isArray(input)) {
|
|
@@ -698,8 +908,9 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
|
698
908
|
});
|
|
699
909
|
return payload;
|
|
700
910
|
}
|
|
701
|
-
payload.value = Array(input.length);
|
|
911
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
702
912
|
const proms = [];
|
|
913
|
+
const abortEarly = ctx?.abortEarly;
|
|
703
914
|
for (let i = 0; i < input.length; i++) {
|
|
704
915
|
const item = input[i];
|
|
705
916
|
const result = def.element._zod.run({
|
|
@@ -711,6 +922,9 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
|
711
922
|
}
|
|
712
923
|
else {
|
|
713
924
|
handleArrayResult(result, payload, i);
|
|
925
|
+
// the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
|
|
926
|
+
if (abortEarly && result.issues.length !== 0 && util.aborted(result))
|
|
927
|
+
break;
|
|
714
928
|
}
|
|
715
929
|
}
|
|
716
930
|
if (proms.length) {
|
|
@@ -718,17 +932,35 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
|
718
932
|
}
|
|
719
933
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
720
934
|
};
|
|
935
|
+
capSize(inst, arraySize);
|
|
721
936
|
});
|
|
722
|
-
function handlePropertyResult(result, final, key, input,
|
|
937
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
938
|
+
const isPresent = key in input;
|
|
939
|
+
const isOptionalOut = optout === "optional";
|
|
940
|
+
// 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.
|
|
941
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
723
944
|
if (result.issues.length) {
|
|
724
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
725
|
-
if (isOptionalOut && !
|
|
945
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
946
|
+
if (optin !== undefined && isOptionalOut && !isPresent) {
|
|
726
947
|
return;
|
|
727
948
|
}
|
|
728
949
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
729
950
|
}
|
|
951
|
+
if (!isPresent && optin === undefined) {
|
|
952
|
+
if (!result.issues.length) {
|
|
953
|
+
final.issues.push({
|
|
954
|
+
code: "invalid_type",
|
|
955
|
+
expected: "nonoptional",
|
|
956
|
+
input: undefined,
|
|
957
|
+
path: [key],
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
730
962
|
if (result.value === undefined) {
|
|
731
|
-
if (
|
|
963
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
732
964
|
final.value[key] = undefined;
|
|
733
965
|
}
|
|
734
966
|
}
|
|
@@ -736,42 +968,64 @@ function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
|
736
968
|
final.value[key] = result.value;
|
|
737
969
|
}
|
|
738
970
|
}
|
|
971
|
+
// one shared instance; a fresh [] per schema cost 56 bytes retained
|
|
972
|
+
const NO_SYMBOL_KEYS = [];
|
|
739
973
|
function normalizeDef(def) {
|
|
740
974
|
const keys = Object.keys(def.shape);
|
|
741
|
-
|
|
975
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
976
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
977
|
+
// aliases `keys` when there are no symbols, so a string-only shape keeps one array
|
|
978
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
979
|
+
for (const k of allKeys) {
|
|
742
980
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
743
|
-
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
981
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
744
982
|
}
|
|
745
983
|
}
|
|
746
984
|
const okeys = util.optionalKeys(def.shape);
|
|
747
985
|
return {
|
|
748
986
|
...def,
|
|
749
|
-
|
|
987
|
+
allKeys,
|
|
988
|
+
symbolKeys,
|
|
989
|
+
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
750
990
|
keySet: new Set(keys),
|
|
751
991
|
numKeys: keys.length,
|
|
752
992
|
optionalKeys: new Set(okeys),
|
|
753
993
|
};
|
|
754
994
|
}
|
|
755
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
995
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
756
996
|
const unrecognized = [];
|
|
757
|
-
// iterate over input keys
|
|
758
997
|
const keySet = def.keySet;
|
|
759
998
|
const _catchall = def.catchall._zod;
|
|
760
999
|
const t = _catchall.def.type;
|
|
761
|
-
const
|
|
1000
|
+
const optin = _catchall.optin;
|
|
1001
|
+
const optout = _catchall.optout;
|
|
1002
|
+
// starts at 0, not the current length: the shape phase already ran and may have aborted
|
|
1003
|
+
let seen = 0;
|
|
762
1004
|
for (const key in input) {
|
|
1005
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1006
|
+
if (util.aborted(payload, seen))
|
|
1007
|
+
break;
|
|
1008
|
+
seen = payload.issues.length;
|
|
1009
|
+
}
|
|
1010
|
+
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
763
1011
|
if (keySet.has(key))
|
|
764
1012
|
continue;
|
|
1013
|
+
// 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.
|
|
1014
|
+
if (key === "__proto__") {
|
|
1015
|
+
if (t === "never")
|
|
1016
|
+
unrecognized.push(key);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
765
1019
|
if (t === "never") {
|
|
766
1020
|
unrecognized.push(key);
|
|
767
1021
|
continue;
|
|
768
1022
|
}
|
|
769
1023
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
770
1024
|
if (r instanceof Promise) {
|
|
771
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1025
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
772
1026
|
}
|
|
773
1027
|
else {
|
|
774
|
-
handlePropertyResult(r, payload, key, input,
|
|
1028
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
775
1029
|
}
|
|
776
1030
|
}
|
|
777
1031
|
if (unrecognized.length) {
|
|
@@ -780,6 +1034,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
780
1034
|
keys: unrecognized,
|
|
781
1035
|
input,
|
|
782
1036
|
inst,
|
|
1037
|
+
// 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.
|
|
1038
|
+
continue: true,
|
|
783
1039
|
});
|
|
784
1040
|
}
|
|
785
1041
|
if (!proms.length)
|
|
@@ -791,30 +1047,35 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
791
1047
|
exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
792
1048
|
// requires cast because technically $ZodObject doesn't extend
|
|
793
1049
|
exports.$ZodType.init(inst, def);
|
|
794
|
-
// const sh = def.shape;
|
|
795
1050
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1051
|
+
// a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
|
|
1052
|
+
const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
|
|
1053
|
+
if (sh) {
|
|
1054
|
+
// Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
|
|
1055
|
+
const get = () => {
|
|
1056
|
+
const newSh = { ...sh };
|
|
1057
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
1058
|
+
get.raw = newSh;
|
|
1059
|
+
return newSh;
|
|
1060
|
+
};
|
|
1061
|
+
get.raw = sh;
|
|
1062
|
+
Object.defineProperty(def, "shape", { get });
|
|
807
1063
|
}
|
|
808
1064
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
809
|
-
util.
|
|
810
|
-
const shape = def.shape;
|
|
1065
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
1066
|
+
const shape = zod.def.shape;
|
|
811
1067
|
const propValues = {};
|
|
812
1068
|
for (const key in shape) {
|
|
813
1069
|
const field = shape[key]._zod;
|
|
814
1070
|
if (field.values) {
|
|
815
|
-
|
|
1071
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
1072
|
+
util.assignProp(propValues, key, new Set());
|
|
1073
|
+
}
|
|
816
1074
|
for (const v of field.values)
|
|
817
1075
|
propValues[key].add(v);
|
|
1076
|
+
// 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.
|
|
1077
|
+
if (field.optin !== undefined)
|
|
1078
|
+
propValues[key].add(undefined);
|
|
818
1079
|
}
|
|
819
1080
|
}
|
|
820
1081
|
return propValues;
|
|
@@ -822,6 +1083,8 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
822
1083
|
const isObject = util.isObject;
|
|
823
1084
|
const catchall = def.catchall;
|
|
824
1085
|
let value;
|
|
1086
|
+
const memo = core.globalConfig.memoizer;
|
|
1087
|
+
memo?.attach(inst);
|
|
825
1088
|
inst._zod.parse = (payload, ctx) => {
|
|
826
1089
|
value ?? (value = _normalized.value);
|
|
827
1090
|
const input = payload.value;
|
|
@@ -834,24 +1097,34 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
|
|
|
834
1097
|
});
|
|
835
1098
|
return payload;
|
|
836
1099
|
}
|
|
837
|
-
payload.value = {};
|
|
1100
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
838
1101
|
const proms = [];
|
|
839
1102
|
const shape = value.shape;
|
|
840
|
-
|
|
1103
|
+
const abortEarly = ctx?.abortEarly;
|
|
1104
|
+
let seen = payload.issues.length;
|
|
1105
|
+
for (const key of value.allKeys) {
|
|
1106
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1107
|
+
if (util.aborted(payload, seen))
|
|
1108
|
+
break;
|
|
1109
|
+
seen = payload.issues.length;
|
|
1110
|
+
}
|
|
1111
|
+
if (key === "__proto__")
|
|
1112
|
+
continue;
|
|
841
1113
|
const el = shape[key];
|
|
842
|
-
const
|
|
1114
|
+
const optin = el._zod.optin;
|
|
1115
|
+
const optout = el._zod.optout;
|
|
843
1116
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
844
1117
|
if (r instanceof Promise) {
|
|
845
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1118
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
846
1119
|
}
|
|
847
1120
|
else {
|
|
848
|
-
handlePropertyResult(r, payload, key, input,
|
|
1121
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
849
1122
|
}
|
|
850
1123
|
}
|
|
851
1124
|
if (!catchall) {
|
|
852
1125
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
853
1126
|
}
|
|
854
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
1127
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
855
1128
|
};
|
|
856
1129
|
});
|
|
857
1130
|
exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -859,73 +1132,106 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
859
1132
|
exports.$ZodObject.init(inst, def);
|
|
860
1133
|
const superParse = inst._zod.parse;
|
|
861
1134
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
1135
|
+
const memo = core.globalConfig.memoizer;
|
|
862
1136
|
const generateFastpass = (shape) => {
|
|
863
|
-
const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
|
|
864
1137
|
const normalized = _normalized.value;
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
1138
|
+
const syms = normalized.symbolKeys;
|
|
1139
|
+
// a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
|
|
1140
|
+
const doc = new doc_js_1.Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
1141
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1142
|
+
// prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
|
|
1143
|
+
const prefixStr = (id, k) => `
|
|
1144
|
+
let ${id}_ab = false;
|
|
1145
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
1146
|
+
const iss = ${id}.issues[i];
|
|
1147
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
1148
|
+
payload.issues.push(iss);
|
|
1149
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
1150
|
+
}
|
|
1151
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
1152
|
+
payload.value = newResult;
|
|
1153
|
+
return payload;
|
|
1154
|
+
}`;
|
|
869
1155
|
doc.write(`const input = payload.value;`);
|
|
870
1156
|
const ids = Object.create(null);
|
|
871
1157
|
let counter = 0;
|
|
872
|
-
for (const key of normalized.
|
|
1158
|
+
for (const key of normalized.allKeys) {
|
|
873
1159
|
ids[key] = `key_${counter++}`;
|
|
874
1160
|
}
|
|
875
1161
|
// A: preserve key order {
|
|
876
|
-
doc.write(`const newResult = {};`);
|
|
877
|
-
for (const key of normalized.
|
|
1162
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
1163
|
+
for (const key of normalized.allKeys) {
|
|
1164
|
+
if (key === "__proto__")
|
|
1165
|
+
continue;
|
|
878
1166
|
const id = ids[key];
|
|
879
|
-
const k = util.esc(key);
|
|
1167
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
|
|
1168
|
+
const isPresent = `${k} in input`;
|
|
880
1169
|
const schema = shape[key];
|
|
1170
|
+
const optin = schema?._zod?.optin;
|
|
1171
|
+
const isOptionalIn = optin !== undefined;
|
|
881
1172
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
882
|
-
doc.write(`const ${id} = ${parseStr(
|
|
883
|
-
if (isOptionalOut) {
|
|
884
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
1173
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
1174
|
+
if (isOptionalIn && isOptionalOut) {
|
|
1175
|
+
// 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.
|
|
1176
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
885
1177
|
doc.write(`
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1178
|
+
const ${id}_present = ${isPresent};
|
|
1179
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
1180
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
if (${assign}) {
|
|
1184
|
+
newResult[${k}] = ${id}.value;
|
|
892
1185
|
}
|
|
893
1186
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1187
|
+
|
|
1188
|
+
`);
|
|
1189
|
+
}
|
|
1190
|
+
else if (!isOptionalIn) {
|
|
1191
|
+
doc.write(`
|
|
1192
|
+
const ${id}_present = ${isPresent};
|
|
1193
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1194
|
+
}
|
|
1195
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
1196
|
+
payload.issues.push({
|
|
1197
|
+
code: "invalid_type",
|
|
1198
|
+
expected: "nonoptional",
|
|
1199
|
+
input: undefined,
|
|
1200
|
+
path: [${k}]
|
|
1201
|
+
});
|
|
1202
|
+
if (ctx && ctx.abortEarly) {
|
|
1203
|
+
payload.value = newResult;
|
|
1204
|
+
return payload;
|
|
898
1205
|
}
|
|
899
|
-
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
if (${id}_present) {
|
|
900
1209
|
newResult[${k}] = ${id}.value;
|
|
901
1210
|
}
|
|
902
|
-
|
|
1211
|
+
|
|
903
1212
|
`);
|
|
904
1213
|
}
|
|
905
1214
|
else {
|
|
906
1215
|
doc.write(`
|
|
907
|
-
if (${id}.issues.length) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
newResult[${k}] = undefined;
|
|
917
|
-
}
|
|
918
|
-
} else {
|
|
1216
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1217
|
+
}
|
|
1218
|
+
`);
|
|
1219
|
+
if (optin === "defaulted") {
|
|
1220
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
doc.write(`
|
|
1224
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
919
1225
|
newResult[${k}] = ${id}.value;
|
|
920
1226
|
}
|
|
921
|
-
|
|
922
1227
|
`);
|
|
1228
|
+
}
|
|
923
1229
|
}
|
|
924
1230
|
}
|
|
925
1231
|
doc.write(`payload.value = newResult;`);
|
|
926
1232
|
doc.write(`return payload;`);
|
|
927
|
-
|
|
928
|
-
return (
|
|
1233
|
+
// 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
|
|
1234
|
+
return doc.compile();
|
|
929
1235
|
};
|
|
930
1236
|
let fastpass;
|
|
931
1237
|
const isObject = util.isObject;
|
|
@@ -953,7 +1259,7 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
953
1259
|
payload = fastpass(payload, ctx);
|
|
954
1260
|
if (!catchall)
|
|
955
1261
|
return payload;
|
|
956
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
1262
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
957
1263
|
}
|
|
958
1264
|
return superParse(payload, ctx);
|
|
959
1265
|
};
|
|
@@ -980,25 +1286,28 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
980
1286
|
}
|
|
981
1287
|
exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
|
982
1288
|
exports.$ZodType.init(inst, def);
|
|
983
|
-
util.
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1289
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
|
|
1290
|
+
? "defaulted"
|
|
1291
|
+
: zod.def.options.some((o) => o._zod.optin !== undefined)
|
|
1292
|
+
? "optional"
|
|
1293
|
+
: undefined);
|
|
1294
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
1295
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
1296
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
1297
|
+
return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
988
1298
|
}
|
|
989
1299
|
return undefined;
|
|
990
1300
|
});
|
|
991
|
-
util.
|
|
992
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
993
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1301
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
1302
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
1303
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
994
1304
|
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
|
|
995
1305
|
}
|
|
996
1306
|
return undefined;
|
|
997
1307
|
});
|
|
998
|
-
const
|
|
999
|
-
const first = def.options[0]._zod.run;
|
|
1308
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1000
1309
|
inst._zod.parse = (payload, ctx) => {
|
|
1001
|
-
if (
|
|
1310
|
+
if (first) {
|
|
1002
1311
|
return first(payload, ctx);
|
|
1003
1312
|
}
|
|
1004
1313
|
let async = false;
|
|
@@ -1026,12 +1335,16 @@ exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
|
|
|
1026
1335
|
};
|
|
1027
1336
|
});
|
|
1028
1337
|
function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1338
|
+
const matches = [];
|
|
1339
|
+
for (let i = 0; i < results.length; i++) {
|
|
1340
|
+
if (results[i].issues.length === 0)
|
|
1341
|
+
matches.push(i);
|
|
1342
|
+
}
|
|
1343
|
+
if (matches.length === 1) {
|
|
1344
|
+
final.value = results[matches[0]].value;
|
|
1032
1345
|
return final;
|
|
1033
1346
|
}
|
|
1034
|
-
if (
|
|
1347
|
+
if (matches.length === 0) {
|
|
1035
1348
|
// No matches - same as regular union
|
|
1036
1349
|
final.issues.push({
|
|
1037
1350
|
code: "invalid_union",
|
|
@@ -1048,6 +1361,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1048
1361
|
inst,
|
|
1049
1362
|
errors: [],
|
|
1050
1363
|
inclusive: false,
|
|
1364
|
+
matches,
|
|
1051
1365
|
});
|
|
1052
1366
|
}
|
|
1053
1367
|
return final;
|
|
@@ -1055,10 +1369,9 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
1055
1369
|
exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
|
|
1056
1370
|
exports.$ZodUnion.init(inst, def);
|
|
1057
1371
|
def.inclusive = false;
|
|
1058
|
-
const
|
|
1059
|
-
const first = def.options[0]._zod.run;
|
|
1372
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1060
1373
|
inst._zod.parse = (payload, ctx) => {
|
|
1061
|
-
if (
|
|
1374
|
+
if (first) {
|
|
1062
1375
|
return first(payload, ctx);
|
|
1063
1376
|
}
|
|
1064
1377
|
let async = false;
|
|
@@ -1083,44 +1396,75 @@ exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
|
|
|
1083
1396
|
});
|
|
1084
1397
|
};
|
|
1085
1398
|
});
|
|
1399
|
+
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
|
|
1400
|
+
function getDiscriminatedOption(union, value) {
|
|
1401
|
+
const internals = union._zod;
|
|
1402
|
+
let map = internals.bag.optionsMap;
|
|
1403
|
+
if (!map) {
|
|
1404
|
+
map = discriminatorMap(internals.def);
|
|
1405
|
+
internals.bag.optionsMap = map;
|
|
1406
|
+
}
|
|
1407
|
+
const option = map.get(value);
|
|
1408
|
+
if (option === null)
|
|
1409
|
+
throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
1410
|
+
return option;
|
|
1411
|
+
}
|
|
1412
|
+
function discriminatorMap(def) {
|
|
1413
|
+
const map = new Map();
|
|
1414
|
+
for (const option of def.options) {
|
|
1415
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
1416
|
+
if (!values || values.size === 0)
|
|
1417
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1418
|
+
for (const value of values) {
|
|
1419
|
+
if (map.has(value)) {
|
|
1420
|
+
if (value !== undefined)
|
|
1421
|
+
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
1422
|
+
// keep the collision marked so a later member cannot reclaim it
|
|
1423
|
+
map.set(value, null);
|
|
1424
|
+
}
|
|
1425
|
+
else {
|
|
1426
|
+
map.set(value, option);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
return map;
|
|
1431
|
+
}
|
|
1086
1432
|
exports.$ZodDiscriminatedUnion =
|
|
1087
1433
|
/*@__PURE__*/
|
|
1088
1434
|
core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1089
1435
|
def.inclusive = false;
|
|
1090
1436
|
exports.$ZodUnion.init(inst, def);
|
|
1091
1437
|
const _super = inst._zod.parse;
|
|
1092
|
-
util.
|
|
1438
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
1093
1439
|
const propValues = {};
|
|
1094
|
-
|
|
1440
|
+
let undefinedCount = 0;
|
|
1441
|
+
for (const option of zod.def.options) {
|
|
1095
1442
|
const pv = option._zod.propValues;
|
|
1096
1443
|
if (!pv || Object.keys(pv).length === 0)
|
|
1097
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1444
|
+
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
1445
|
+
if (pv[zod.def.discriminator]?.has(undefined))
|
|
1446
|
+
undefinedCount++;
|
|
1098
1447
|
for (const [k, v] of Object.entries(pv)) {
|
|
1099
|
-
if (!propValues
|
|
1100
|
-
propValues
|
|
1448
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
1449
|
+
util.assignProp(propValues, k, new Set());
|
|
1450
|
+
}
|
|
1101
1451
|
for (const val of v) {
|
|
1102
1452
|
propValues[k].add(val);
|
|
1103
1453
|
}
|
|
1104
1454
|
}
|
|
1105
1455
|
}
|
|
1456
|
+
if (!zod.def.unionFallback && undefinedCount > 1)
|
|
1457
|
+
propValues[zod.def.discriminator]?.delete(undefined);
|
|
1106
1458
|
return propValues;
|
|
1107
1459
|
});
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
if (!values || values.size === 0)
|
|
1114
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1115
|
-
for (const v of values) {
|
|
1116
|
-
if (map.has(v)) {
|
|
1117
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1118
|
-
}
|
|
1119
|
-
map.set(v, o);
|
|
1120
|
-
}
|
|
1460
|
+
// Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
|
|
1461
|
+
def.options.forEach((option, i) => {
|
|
1462
|
+
const propShape = util.rawShape(option._zod.def);
|
|
1463
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
1464
|
+
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
1121
1465
|
}
|
|
1122
|
-
return map;
|
|
1123
1466
|
});
|
|
1467
|
+
const disc = util.cached(() => discriminatorMap(def));
|
|
1124
1468
|
inst._zod.parse = (payload, ctx) => {
|
|
1125
1469
|
const input = payload.value;
|
|
1126
1470
|
if (!util.isObject(input)) {
|
|
@@ -1132,11 +1476,16 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1132
1476
|
});
|
|
1133
1477
|
return payload;
|
|
1134
1478
|
}
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1479
|
+
const value = input?.[def.discriminator];
|
|
1480
|
+
const opt = disc.value.get(value);
|
|
1481
|
+
// forward metadata cannot choose an encoder for an absent tag
|
|
1482
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
1137
1483
|
return opt._zod.run(payload, ctx);
|
|
1138
1484
|
}
|
|
1139
|
-
|
|
1485
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
1486
|
+
// - explicitly enabled via unionFallback, or
|
|
1487
|
+
// - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
|
|
1488
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
1140
1489
|
return _super(payload, ctx);
|
|
1141
1490
|
}
|
|
1142
1491
|
// no matching discriminator
|
|
@@ -1145,6 +1494,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
|
1145
1494
|
errors: [],
|
|
1146
1495
|
note: "No matching discriminator",
|
|
1147
1496
|
discriminator: def.discriminator,
|
|
1497
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
1148
1498
|
input,
|
|
1149
1499
|
path: [def.discriminator],
|
|
1150
1500
|
inst,
|
|
@@ -1180,7 +1530,11 @@ function mergeValues(a, b) {
|
|
|
1180
1530
|
const bKeys = Object.keys(b);
|
|
1181
1531
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1182
1532
|
const newObj = { ...a, ...b };
|
|
1533
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
1534
|
+
delete newObj.__proto__;
|
|
1183
1535
|
for (const key of sharedKeys) {
|
|
1536
|
+
if (key === "__proto__")
|
|
1537
|
+
continue;
|
|
1184
1538
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1185
1539
|
if (!sharedValue.valid) {
|
|
1186
1540
|
return {
|
|
@@ -1214,43 +1568,55 @@ function mergeValues(a, b) {
|
|
|
1214
1568
|
return { valid: false, mergeErrorPath: [] };
|
|
1215
1569
|
}
|
|
1216
1570
|
function handleIntersectionResults(result, left, right) {
|
|
1217
|
-
// Track which side(s)
|
|
1571
|
+
// 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.
|
|
1218
1572
|
const unrecKeys = new Map();
|
|
1219
1573
|
let unrecIssue;
|
|
1220
|
-
|
|
1221
|
-
|
|
1574
|
+
const keyIssues = new Map();
|
|
1575
|
+
const collect = (iss, side) => {
|
|
1576
|
+
let keys;
|
|
1577
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
1222
1578
|
unrecIssue ?? (unrecIssue = iss);
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1579
|
+
keys = iss.keys;
|
|
1580
|
+
}
|
|
1581
|
+
else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
1582
|
+
const k = String(iss.path[0]);
|
|
1583
|
+
if (!keyIssues.has(k))
|
|
1584
|
+
keyIssues.set(k, iss);
|
|
1585
|
+
keys = [k];
|
|
1228
1586
|
}
|
|
1229
1587
|
else {
|
|
1230
|
-
|
|
1588
|
+
return false;
|
|
1231
1589
|
}
|
|
1590
|
+
for (const k of keys) {
|
|
1591
|
+
if (!unrecKeys.has(k))
|
|
1592
|
+
unrecKeys.set(k, {});
|
|
1593
|
+
unrecKeys.get(k)[side] = true;
|
|
1594
|
+
}
|
|
1595
|
+
return true;
|
|
1596
|
+
};
|
|
1597
|
+
for (const iss of left.issues) {
|
|
1598
|
+
if (!collect(iss, "l"))
|
|
1599
|
+
result.issues.push(iss);
|
|
1232
1600
|
}
|
|
1233
1601
|
for (const iss of right.issues) {
|
|
1234
|
-
if (iss
|
|
1235
|
-
for (const k of iss.keys) {
|
|
1236
|
-
if (!unrecKeys.has(k))
|
|
1237
|
-
unrecKeys.set(k, {});
|
|
1238
|
-
unrecKeys.get(k).r = true;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
else {
|
|
1602
|
+
if (!collect(iss, "r"))
|
|
1242
1603
|
result.issues.push(iss);
|
|
1243
|
-
}
|
|
1244
1604
|
}
|
|
1245
|
-
// Report only keys
|
|
1605
|
+
// Report only keys rejected by BOTH sides
|
|
1246
1606
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1247
|
-
if (bothKeys.length
|
|
1248
|
-
|
|
1607
|
+
if (bothKeys.length) {
|
|
1608
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
1609
|
+
if (aggregated.length)
|
|
1610
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
1611
|
+
for (const k of bothKeys) {
|
|
1612
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
1613
|
+
result.issues.push(keyIssues.get(k));
|
|
1614
|
+
}
|
|
1249
1615
|
}
|
|
1250
|
-
if (util.aborted(result))
|
|
1251
|
-
return result;
|
|
1252
1616
|
const merged = mergeValues(left.value, right.value);
|
|
1253
1617
|
if (!merged.valid) {
|
|
1618
|
+
if (util.aborted(result))
|
|
1619
|
+
return result;
|
|
1254
1620
|
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1255
1621
|
}
|
|
1256
1622
|
result.value = merged.data;
|
|
@@ -1259,6 +1625,8 @@ function handleIntersectionResults(result, left, right) {
|
|
|
1259
1625
|
exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
|
|
1260
1626
|
exports.$ZodType.init(inst, def);
|
|
1261
1627
|
const items = def.items;
|
|
1628
|
+
const memo = core.globalConfig.memoizer;
|
|
1629
|
+
memo?.attach(inst);
|
|
1262
1630
|
inst._zod.parse = (payload, ctx) => {
|
|
1263
1631
|
const input = payload.value;
|
|
1264
1632
|
if (!Array.isArray(input)) {
|
|
@@ -1270,71 +1638,132 @@ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
|
|
|
1270
1638
|
});
|
|
1271
1639
|
return payload;
|
|
1272
1640
|
}
|
|
1273
|
-
payload.value = [];
|
|
1641
|
+
payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
|
|
1274
1642
|
const proms = [];
|
|
1275
|
-
const
|
|
1276
|
-
const
|
|
1643
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
1644
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
1277
1645
|
if (!def.rest) {
|
|
1278
|
-
|
|
1279
|
-
const tooSmall = input.length < optStart - 1;
|
|
1280
|
-
if (tooBig || tooSmall) {
|
|
1646
|
+
if (input.length < optinStart) {
|
|
1281
1647
|
payload.issues.push({
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1648
|
+
code: "too_small",
|
|
1649
|
+
minimum: optinStart,
|
|
1650
|
+
inclusive: true,
|
|
1285
1651
|
input,
|
|
1286
1652
|
inst,
|
|
1287
1653
|
origin: "array",
|
|
1288
1654
|
});
|
|
1289
1655
|
return payload;
|
|
1290
1656
|
}
|
|
1657
|
+
if (input.length > items.length) {
|
|
1658
|
+
payload.issues.push({
|
|
1659
|
+
code: "too_big",
|
|
1660
|
+
maximum: items.length,
|
|
1661
|
+
inclusive: true,
|
|
1662
|
+
input,
|
|
1663
|
+
inst,
|
|
1664
|
+
origin: "array",
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1291
1667
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
1668
|
+
// 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.
|
|
1669
|
+
const itemResults = new Array(items.length);
|
|
1670
|
+
// only tracked when there is a rest loop to skip
|
|
1671
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
1672
|
+
let itemAborted = false;
|
|
1673
|
+
for (let i = 0; i < items.length; i++) {
|
|
1674
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
1675
|
+
if (r instanceof Promise) {
|
|
1676
|
+
proms.push(r.then((rr) => {
|
|
1677
|
+
itemResults[i] = rr;
|
|
1678
|
+
}));
|
|
1304
1679
|
}
|
|
1305
1680
|
else {
|
|
1306
|
-
|
|
1681
|
+
itemResults[i] = r;
|
|
1682
|
+
if (abortEarly && !itemAborted && r.issues.length)
|
|
1683
|
+
itemAborted = util.aborted(r);
|
|
1307
1684
|
}
|
|
1308
1685
|
}
|
|
1309
|
-
|
|
1686
|
+
// sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
|
|
1687
|
+
if (def.rest && !itemAborted) {
|
|
1688
|
+
let i = items.length - 1;
|
|
1310
1689
|
const rest = input.slice(items.length);
|
|
1690
|
+
let seen = payload.issues.length;
|
|
1311
1691
|
for (const el of rest) {
|
|
1692
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1693
|
+
if (util.aborted(payload, seen))
|
|
1694
|
+
break;
|
|
1695
|
+
seen = payload.issues.length;
|
|
1696
|
+
}
|
|
1312
1697
|
i++;
|
|
1313
|
-
const result = def.rest._zod.run({
|
|
1314
|
-
value: el,
|
|
1315
|
-
issues: [],
|
|
1316
|
-
}, ctx);
|
|
1698
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
1317
1699
|
if (result instanceof Promise) {
|
|
1318
|
-
proms.push(result.then((
|
|
1700
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
1319
1701
|
}
|
|
1320
1702
|
else {
|
|
1321
1703
|
handleTupleResult(result, payload, i);
|
|
1322
1704
|
}
|
|
1323
1705
|
}
|
|
1324
1706
|
}
|
|
1325
|
-
if (proms.length)
|
|
1326
|
-
return Promise.all(proms).then(() => payload);
|
|
1327
|
-
|
|
1707
|
+
if (proms.length) {
|
|
1708
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
1709
|
+
}
|
|
1710
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
1328
1711
|
};
|
|
1329
1712
|
});
|
|
1713
|
+
function getTupleOptStart(items, key) {
|
|
1714
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
1715
|
+
// optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
|
|
1716
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
1717
|
+
if (!omittable)
|
|
1718
|
+
return i + 1;
|
|
1719
|
+
}
|
|
1720
|
+
return 0;
|
|
1721
|
+
}
|
|
1330
1722
|
function handleTupleResult(result, final, index) {
|
|
1331
1723
|
if (result.issues.length) {
|
|
1332
1724
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
1333
1725
|
}
|
|
1334
1726
|
final.value[index] = result.value;
|
|
1335
1727
|
}
|
|
1728
|
+
function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
1729
|
+
// 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.
|
|
1730
|
+
for (let i = 0; i < items.length; i++) {
|
|
1731
|
+
const r = itemResults[i];
|
|
1732
|
+
const isPresent = i < input.length;
|
|
1733
|
+
// 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`.
|
|
1734
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
1735
|
+
final.value.length = i;
|
|
1736
|
+
break;
|
|
1737
|
+
}
|
|
1738
|
+
if (r.issues.length) {
|
|
1739
|
+
if (!isPresent && i >= optoutStart) {
|
|
1740
|
+
final.value.length = i;
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
1744
|
+
}
|
|
1745
|
+
final.value[i] = r.value;
|
|
1746
|
+
}
|
|
1747
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
1748
|
+
// (the array analog of an absent optional key on an object). The
|
|
1749
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
1750
|
+
// *inside* the input must be preserved even when the schema is
|
|
1751
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
1752
|
+
// explicit undefined value).
|
|
1753
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
1754
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
1755
|
+
final.value.length = i;
|
|
1756
|
+
}
|
|
1757
|
+
else {
|
|
1758
|
+
break;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
return final;
|
|
1762
|
+
}
|
|
1336
1763
|
exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
1337
1764
|
exports.$ZodType.init(inst, def);
|
|
1765
|
+
const memo = core.globalConfig.memoizer;
|
|
1766
|
+
memo?.attach(inst);
|
|
1338
1767
|
inst._zod.parse = (payload, ctx) => {
|
|
1339
1768
|
const input = payload.value;
|
|
1340
1769
|
if (!util.isPlainObject(input)) {
|
|
@@ -1346,36 +1775,66 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1346
1775
|
});
|
|
1347
1776
|
return payload;
|
|
1348
1777
|
}
|
|
1778
|
+
// no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
|
|
1349
1779
|
const proms = [];
|
|
1350
1780
|
const values = def.keyType._zod.values;
|
|
1351
|
-
if (values) {
|
|
1352
|
-
payload.value = {};
|
|
1781
|
+
if (values && !def.partial) {
|
|
1782
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1353
1783
|
const recordKeys = new Set();
|
|
1354
1784
|
for (const key of values) {
|
|
1355
1785
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1356
1786
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
1787
|
+
// A declared __proto__ is stripped but is not an unrecognized key.
|
|
1788
|
+
if (key === "__proto__")
|
|
1789
|
+
continue;
|
|
1790
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1791
|
+
if (keyResult instanceof Promise) {
|
|
1792
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
1793
|
+
}
|
|
1794
|
+
if (keyResult.issues.length) {
|
|
1795
|
+
payload.issues.push({
|
|
1796
|
+
code: "invalid_key",
|
|
1797
|
+
origin: "record",
|
|
1798
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1799
|
+
input: key,
|
|
1800
|
+
path: [key],
|
|
1801
|
+
inst,
|
|
1802
|
+
});
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
const outKey = keyResult.value;
|
|
1806
|
+
if (outKey === "__proto__")
|
|
1807
|
+
continue;
|
|
1357
1808
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1358
1809
|
if (result instanceof Promise) {
|
|
1359
1810
|
proms.push(result.then((result) => {
|
|
1360
1811
|
if (result.issues.length) {
|
|
1361
1812
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1362
1813
|
}
|
|
1363
|
-
payload.value[
|
|
1814
|
+
payload.value[outKey] = result.value;
|
|
1364
1815
|
}));
|
|
1365
1816
|
}
|
|
1366
1817
|
else {
|
|
1367
1818
|
if (result.issues.length) {
|
|
1368
1819
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1369
1820
|
}
|
|
1370
|
-
payload.value[
|
|
1821
|
+
payload.value[outKey] = result.value;
|
|
1371
1822
|
}
|
|
1372
1823
|
}
|
|
1373
1824
|
}
|
|
1374
1825
|
let unrecognized;
|
|
1375
1826
|
for (const key in input) {
|
|
1376
1827
|
if (!recordKeys.has(key)) {
|
|
1377
|
-
|
|
1378
|
-
|
|
1828
|
+
if (def.mode === "loose") {
|
|
1829
|
+
// skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
|
|
1830
|
+
if (key === "__proto__")
|
|
1831
|
+
continue;
|
|
1832
|
+
payload.value[key] = input[key];
|
|
1833
|
+
}
|
|
1834
|
+
else {
|
|
1835
|
+
unrecognized = unrecognized ?? [];
|
|
1836
|
+
unrecognized.push(key);
|
|
1837
|
+
}
|
|
1379
1838
|
}
|
|
1380
1839
|
}
|
|
1381
1840
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -1384,20 +1843,25 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1384
1843
|
input,
|
|
1385
1844
|
inst,
|
|
1386
1845
|
keys: unrecognized,
|
|
1846
|
+
continue: true,
|
|
1387
1847
|
});
|
|
1388
1848
|
}
|
|
1389
1849
|
}
|
|
1390
1850
|
else {
|
|
1391
|
-
payload.value = {};
|
|
1851
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1852
|
+
// 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.
|
|
1853
|
+
let unrecognized;
|
|
1854
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
1392
1855
|
for (const key of Reflect.ownKeys(input)) {
|
|
1393
1856
|
if (key === "__proto__")
|
|
1394
1857
|
continue;
|
|
1858
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
1859
|
+
continue;
|
|
1395
1860
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1396
1861
|
if (keyResult instanceof Promise) {
|
|
1397
1862
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1398
1863
|
}
|
|
1399
|
-
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
1400
|
-
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1864
|
+
// 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
|
|
1401
1865
|
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
1402
1866
|
if (checkNumericKey) {
|
|
1403
1867
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
@@ -1413,6 +1877,10 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1413
1877
|
// Pass through unchanged
|
|
1414
1878
|
payload.value[key] = input[key];
|
|
1415
1879
|
}
|
|
1880
|
+
else if (values) {
|
|
1881
|
+
unrecognized = unrecognized ?? [];
|
|
1882
|
+
unrecognized.push(key);
|
|
1883
|
+
}
|
|
1416
1884
|
else {
|
|
1417
1885
|
// Default "strict" behavior: error on invalid key
|
|
1418
1886
|
payload.issues.push({
|
|
@@ -1426,22 +1894,35 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1426
1894
|
}
|
|
1427
1895
|
continue;
|
|
1428
1896
|
}
|
|
1897
|
+
// 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
|
|
1898
|
+
const outKey = keyResult.value;
|
|
1899
|
+
if (outKey === "__proto__")
|
|
1900
|
+
continue;
|
|
1429
1901
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1430
1902
|
if (result instanceof Promise) {
|
|
1431
1903
|
proms.push(result.then((result) => {
|
|
1432
1904
|
if (result.issues.length) {
|
|
1433
1905
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1434
1906
|
}
|
|
1435
|
-
payload.value[
|
|
1907
|
+
payload.value[outKey] = result.value;
|
|
1436
1908
|
}));
|
|
1437
1909
|
}
|
|
1438
1910
|
else {
|
|
1439
1911
|
if (result.issues.length) {
|
|
1440
1912
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
1441
1913
|
}
|
|
1442
|
-
payload.value[
|
|
1914
|
+
payload.value[outKey] = result.value;
|
|
1443
1915
|
}
|
|
1444
1916
|
}
|
|
1917
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
1918
|
+
payload.issues.push({
|
|
1919
|
+
code: "unrecognized_keys",
|
|
1920
|
+
input,
|
|
1921
|
+
inst,
|
|
1922
|
+
keys: unrecognized,
|
|
1923
|
+
continue: true,
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1445
1926
|
}
|
|
1446
1927
|
if (proms.length) {
|
|
1447
1928
|
return Promise.all(proms).then(() => payload);
|
|
@@ -1451,6 +1932,8 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1451
1932
|
});
|
|
1452
1933
|
exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
|
1453
1934
|
exports.$ZodType.init(inst, def);
|
|
1935
|
+
const memo = core.globalConfig.memoizer;
|
|
1936
|
+
memo?.attach(inst);
|
|
1454
1937
|
inst._zod.parse = (payload, ctx) => {
|
|
1455
1938
|
const input = payload.value;
|
|
1456
1939
|
if (!(input instanceof Map)) {
|
|
@@ -1463,8 +1946,15 @@ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
|
|
1463
1946
|
return payload;
|
|
1464
1947
|
}
|
|
1465
1948
|
const proms = [];
|
|
1466
|
-
payload.value = new Map();
|
|
1949
|
+
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
1950
|
+
const abortEarly = ctx?.abortEarly;
|
|
1951
|
+
let seen = payload.issues.length;
|
|
1467
1952
|
for (const [key, value] of input) {
|
|
1953
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1954
|
+
if (util.aborted(payload, seen))
|
|
1955
|
+
break;
|
|
1956
|
+
seen = payload.issues.length;
|
|
1957
|
+
}
|
|
1468
1958
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
1469
1959
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
1470
1960
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
@@ -1480,6 +1970,7 @@ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
|
|
1480
1970
|
return Promise.all(proms).then(() => payload);
|
|
1481
1971
|
return payload;
|
|
1482
1972
|
};
|
|
1973
|
+
capSize(inst, mapSize);
|
|
1483
1974
|
});
|
|
1484
1975
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
1485
1976
|
if (keyResult.issues.length) {
|
|
@@ -1515,6 +2006,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
1515
2006
|
}
|
|
1516
2007
|
exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
|
1517
2008
|
exports.$ZodType.init(inst, def);
|
|
2009
|
+
const memo = core.globalConfig.memoizer;
|
|
2010
|
+
memo?.attach(inst);
|
|
1518
2011
|
inst._zod.parse = (payload, ctx) => {
|
|
1519
2012
|
const input = payload.value;
|
|
1520
2013
|
if (!(input instanceof Set)) {
|
|
@@ -1527,8 +2020,15 @@ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
|
|
1527
2020
|
return payload;
|
|
1528
2021
|
}
|
|
1529
2022
|
const proms = [];
|
|
1530
|
-
payload.value = new Set();
|
|
2023
|
+
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
2024
|
+
const abortEarly = ctx?.abortEarly;
|
|
2025
|
+
let seen = payload.issues.length;
|
|
1531
2026
|
for (const item of input) {
|
|
2027
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2028
|
+
if (util.aborted(payload, seen))
|
|
2029
|
+
break;
|
|
2030
|
+
seen = payload.issues.length;
|
|
2031
|
+
}
|
|
1532
2032
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
1533
2033
|
if (result instanceof Promise) {
|
|
1534
2034
|
proms.push(result.then((result) => handleSetResult(result, payload)));
|
|
@@ -1540,6 +2040,7 @@ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
|
|
1540
2040
|
return Promise.all(proms).then(() => payload);
|
|
1541
2041
|
return payload;
|
|
1542
2042
|
};
|
|
2043
|
+
capSize(inst, setSize);
|
|
1543
2044
|
});
|
|
1544
2045
|
function handleSetResult(result, final) {
|
|
1545
2046
|
if (result.issues.length) {
|
|
@@ -1552,10 +2053,11 @@ exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
|
|
|
1552
2053
|
const values = util.getEnumValues(def.entries);
|
|
1553
2054
|
const valuesSet = new Set(values);
|
|
1554
2055
|
inst._zod.values = valuesSet;
|
|
1555
|
-
inst
|
|
1556
|
-
.filter((k) => util.propertyKeyTypes.has(typeof k))
|
|
1557
|
-
|
|
1558
|
-
.join("|")})$`);
|
|
2056
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2057
|
+
const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
|
|
2058
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
2059
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2060
|
+
});
|
|
1559
2061
|
inst._zod.parse = (payload, _ctx) => {
|
|
1560
2062
|
const input = payload.value;
|
|
1561
2063
|
if (valuesSet.has(input)) {
|
|
@@ -1572,14 +2074,17 @@ exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
|
|
|
1572
2074
|
});
|
|
1573
2075
|
exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
|
|
1574
2076
|
exports.$ZodType.init(inst, def);
|
|
1575
|
-
if (def.values.length === 0) {
|
|
1576
|
-
throw new Error("Cannot create literal schema with no valid values");
|
|
1577
|
-
}
|
|
1578
2077
|
const values = new Set(def.values);
|
|
1579
2078
|
inst._zod.values = values;
|
|
1580
|
-
inst
|
|
1581
|
-
|
|
1582
|
-
|
|
2079
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2080
|
+
const vals = zod.def.values;
|
|
2081
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
2082
|
+
return new RegExp(vals.length
|
|
2083
|
+
? `^(${vals
|
|
2084
|
+
.map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
|
|
2085
|
+
.join("|")})$`
|
|
2086
|
+
: "^[^\\s\\S]$");
|
|
2087
|
+
});
|
|
1583
2088
|
inst._zod.parse = (payload, _ctx) => {
|
|
1584
2089
|
const input = payload.value;
|
|
1585
2090
|
if (values.has(input)) {
|
|
@@ -1612,6 +2117,8 @@ exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
|
|
|
1612
2117
|
});
|
|
1613
2118
|
exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
|
1614
2119
|
exports.$ZodType.init(inst, def);
|
|
2120
|
+
inst._zod.optin = "optional";
|
|
2121
|
+
core.globalConfig.memoizer?.guard(inst);
|
|
1615
2122
|
inst._zod.parse = (payload, ctx) => {
|
|
1616
2123
|
if (ctx.direction === "backward") {
|
|
1617
2124
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -1631,32 +2138,34 @@ exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
|
|
|
1631
2138
|
return payload;
|
|
1632
2139
|
};
|
|
1633
2140
|
});
|
|
1634
|
-
function handleOptionalResult(
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
return result;
|
|
2141
|
+
function handleOptionalResult(payload, result) {
|
|
2142
|
+
// 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.
|
|
2143
|
+
payload.value = result.issues.length ? undefined : result.value;
|
|
2144
|
+
return payload;
|
|
1639
2145
|
}
|
|
1640
2146
|
exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
|
|
1641
2147
|
exports.$ZodType.init(inst, def);
|
|
1642
|
-
|
|
2148
|
+
// .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
|
|
2149
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
1643
2150
|
inst._zod.optout = "optional";
|
|
1644
|
-
util.
|
|
1645
|
-
|
|
2151
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2152
|
+
const values = zod.def.innerType._zod.values;
|
|
2153
|
+
return values ? new Set([...values, undefined]) : undefined;
|
|
1646
2154
|
});
|
|
1647
|
-
util.
|
|
1648
|
-
const pattern = def.innerType._zod.pattern;
|
|
2155
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2156
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1649
2157
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
|
1650
2158
|
});
|
|
1651
2159
|
inst._zod.parse = (payload, ctx) => {
|
|
1652
|
-
if (def.innerType._zod.optin === "optional") {
|
|
1653
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1654
|
-
if (result instanceof Promise)
|
|
1655
|
-
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1656
|
-
return handleOptionalResult(result, payload.value);
|
|
1657
|
-
}
|
|
1658
2160
|
if (payload.value === undefined) {
|
|
1659
|
-
|
|
2161
|
+
// Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
|
|
2162
|
+
if (def.innerType._zod.optin !== "defaulted")
|
|
2163
|
+
return payload;
|
|
2164
|
+
// 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.
|
|
2165
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2166
|
+
if (result instanceof Promise)
|
|
2167
|
+
return result.then((result) => handleOptionalResult(payload, result));
|
|
2168
|
+
return handleOptionalResult(payload, result);
|
|
1660
2169
|
}
|
|
1661
2170
|
return def.innerType._zod.run(payload, ctx);
|
|
1662
2171
|
};
|
|
@@ -1665,8 +2174,8 @@ exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) =
|
|
|
1665
2174
|
// Call parent init - inherits optin/optout = "optional"
|
|
1666
2175
|
exports.$ZodOptional.init(inst, def);
|
|
1667
2176
|
// Override values/pattern to NOT add undefined
|
|
1668
|
-
util.
|
|
1669
|
-
util.
|
|
2177
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2178
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
1670
2179
|
// Override parse to just delegate (no undefined handling)
|
|
1671
2180
|
inst._zod.parse = (payload, ctx) => {
|
|
1672
2181
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1674,14 +2183,14 @@ exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) =
|
|
|
1674
2183
|
});
|
|
1675
2184
|
exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
|
|
1676
2185
|
exports.$ZodType.init(inst, def);
|
|
1677
|
-
util.
|
|
1678
|
-
util.
|
|
1679
|
-
util.
|
|
1680
|
-
const pattern = def.innerType._zod.pattern;
|
|
2186
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2187
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2188
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2189
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1681
2190
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
1682
2191
|
});
|
|
1683
|
-
util.
|
|
1684
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
2192
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2193
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
|
|
1685
2194
|
});
|
|
1686
2195
|
inst._zod.parse = (payload, ctx) => {
|
|
1687
2196
|
// Forward direction (decode): allow null to pass through
|
|
@@ -1693,8 +2202,8 @@ exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
|
|
|
1693
2202
|
exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
|
|
1694
2203
|
exports.$ZodType.init(inst, def);
|
|
1695
2204
|
// inst._zod.qin = "true";
|
|
1696
|
-
inst._zod.optin = "
|
|
1697
|
-
util.
|
|
2205
|
+
inst._zod.optin = "defaulted";
|
|
2206
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1698
2207
|
inst._zod.parse = (payload, ctx) => {
|
|
1699
2208
|
if (ctx.direction === "backward") {
|
|
1700
2209
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1723,8 +2232,8 @@ function handleDefaultResult(payload, def) {
|
|
|
1723
2232
|
}
|
|
1724
2233
|
exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
|
|
1725
2234
|
exports.$ZodType.init(inst, def);
|
|
1726
|
-
inst._zod.optin = "
|
|
1727
|
-
util.
|
|
2235
|
+
inst._zod.optin = "defaulted";
|
|
2236
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1728
2237
|
inst._zod.parse = (payload, ctx) => {
|
|
1729
2238
|
if (ctx.direction === "backward") {
|
|
1730
2239
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1738,8 +2247,8 @@ exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
|
|
|
1738
2247
|
});
|
|
1739
2248
|
exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
|
|
1740
2249
|
exports.$ZodType.init(inst, def);
|
|
1741
|
-
util.
|
|
1742
|
-
const v = def.innerType._zod.values;
|
|
2250
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2251
|
+
const v = zod.def.innerType._zod.values;
|
|
1743
2252
|
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
1744
2253
|
});
|
|
1745
2254
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -1778,45 +2287,40 @@ exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
|
|
|
1778
2287
|
return payload;
|
|
1779
2288
|
};
|
|
1780
2289
|
});
|
|
2290
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2291
|
+
if (!result.issues.length) {
|
|
2292
|
+
payload.value = result.value;
|
|
2293
|
+
// 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.
|
|
2294
|
+
if (result.memo)
|
|
2295
|
+
payload.memo = true;
|
|
2296
|
+
return payload;
|
|
2297
|
+
}
|
|
2298
|
+
// 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.
|
|
2299
|
+
payload.value = def.catchValue({
|
|
2300
|
+
...result,
|
|
2301
|
+
value: payload.value,
|
|
2302
|
+
error: {
|
|
2303
|
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
2304
|
+
},
|
|
2305
|
+
input: payload.value,
|
|
2306
|
+
});
|
|
2307
|
+
return payload;
|
|
2308
|
+
}
|
|
1781
2309
|
exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
|
|
1782
2310
|
exports.$ZodType.init(inst, def);
|
|
1783
|
-
util.
|
|
1784
|
-
util.
|
|
1785
|
-
util.
|
|
2311
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2312
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2313
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
1786
2314
|
inst._zod.parse = (payload, ctx) => {
|
|
1787
2315
|
if (ctx.direction === "backward") {
|
|
1788
2316
|
return def.innerType._zod.run(payload, ctx);
|
|
1789
2317
|
}
|
|
1790
2318
|
// Forward direction (decode): apply catch logic
|
|
1791
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2319
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
1792
2320
|
if (result instanceof Promise) {
|
|
1793
|
-
return result.then((result) =>
|
|
1794
|
-
payload.value = result.value;
|
|
1795
|
-
if (result.issues.length) {
|
|
1796
|
-
payload.value = def.catchValue({
|
|
1797
|
-
...payload,
|
|
1798
|
-
error: {
|
|
1799
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1800
|
-
},
|
|
1801
|
-
input: payload.value,
|
|
1802
|
-
});
|
|
1803
|
-
payload.issues = [];
|
|
1804
|
-
}
|
|
1805
|
-
return payload;
|
|
1806
|
-
});
|
|
2321
|
+
return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
1807
2322
|
}
|
|
1808
|
-
payload
|
|
1809
|
-
if (result.issues.length) {
|
|
1810
|
-
payload.value = def.catchValue({
|
|
1811
|
-
...payload,
|
|
1812
|
-
error: {
|
|
1813
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
1814
|
-
},
|
|
1815
|
-
input: payload.value,
|
|
1816
|
-
});
|
|
1817
|
-
payload.issues = [];
|
|
1818
|
-
}
|
|
1819
|
-
return payload;
|
|
2323
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
1820
2324
|
};
|
|
1821
2325
|
});
|
|
1822
2326
|
exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
|
|
@@ -1836,10 +2340,10 @@ exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
|
|
|
1836
2340
|
});
|
|
1837
2341
|
exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
|
|
1838
2342
|
exports.$ZodType.init(inst, def);
|
|
1839
|
-
util.
|
|
1840
|
-
util.
|
|
1841
|
-
util.
|
|
1842
|
-
util.
|
|
2343
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2344
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2345
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2346
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1843
2347
|
inst._zod.parse = (payload, ctx) => {
|
|
1844
2348
|
if (ctx.direction === "backward") {
|
|
1845
2349
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -1856,7 +2360,8 @@ exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
|
|
|
1856
2360
|
};
|
|
1857
2361
|
});
|
|
1858
2362
|
function handlePipeResult(left, next, ctx) {
|
|
1859
|
-
|
|
2363
|
+
// 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.
|
|
2364
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
1860
2365
|
// prevent further checks
|
|
1861
2366
|
left.aborted = true;
|
|
1862
2367
|
return left;
|
|
@@ -1865,10 +2370,10 @@ function handlePipeResult(left, next, ctx) {
|
|
|
1865
2370
|
}
|
|
1866
2371
|
exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
|
|
1867
2372
|
exports.$ZodType.init(inst, def);
|
|
1868
|
-
util.
|
|
1869
|
-
util.
|
|
1870
|
-
util.
|
|
1871
|
-
util.
|
|
2373
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2374
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2375
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2376
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
1872
2377
|
inst._zod.parse = (payload, ctx) => {
|
|
1873
2378
|
const direction = ctx.direction || "forward";
|
|
1874
2379
|
if (direction === "forward") {
|
|
@@ -1917,12 +2422,15 @@ function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
|
1917
2422
|
}
|
|
1918
2423
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
1919
2424
|
}
|
|
2425
|
+
exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => {
|
|
2426
|
+
exports.$ZodPipe.init(inst, def);
|
|
2427
|
+
});
|
|
1920
2428
|
exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
|
1921
2429
|
exports.$ZodType.init(inst, def);
|
|
1922
|
-
util.
|
|
1923
|
-
util.
|
|
1924
|
-
util.
|
|
1925
|
-
util.
|
|
2430
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2431
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2432
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2433
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
1926
2434
|
inst._zod.parse = (payload, ctx) => {
|
|
1927
2435
|
if (ctx.direction === "backward") {
|
|
1928
2436
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -1935,25 +2443,72 @@ exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
|
|
|
1935
2443
|
};
|
|
1936
2444
|
});
|
|
1937
2445
|
function handleReadonlyResult(payload) {
|
|
1938
|
-
|
|
2446
|
+
// 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.
|
|
2447
|
+
if (!payload.memo)
|
|
2448
|
+
payload.value = Object.freeze(payload.value);
|
|
1939
2449
|
return payload;
|
|
1940
2450
|
}
|
|
2451
|
+
// a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
|
|
2452
|
+
function leafPattern(schema) {
|
|
2453
|
+
const def = schema._zod.def;
|
|
2454
|
+
let pattern = def.pattern;
|
|
2455
|
+
let isInt = !!def.format?.includes("int");
|
|
2456
|
+
let minimum;
|
|
2457
|
+
let maximum;
|
|
2458
|
+
for (const ch of def.checks ?? []) {
|
|
2459
|
+
const d = ch._zod.def;
|
|
2460
|
+
if (d.pattern)
|
|
2461
|
+
pattern = d.pattern;
|
|
2462
|
+
isInt || (isInt = !!d.format?.includes("int"));
|
|
2463
|
+
const lo = d.minimum ?? d.length;
|
|
2464
|
+
const hi = d.maximum ?? d.length;
|
|
2465
|
+
if (lo !== undefined && (minimum === undefined || lo > minimum))
|
|
2466
|
+
minimum = lo;
|
|
2467
|
+
if (hi !== undefined && (maximum === undefined || hi < maximum))
|
|
2468
|
+
maximum = hi;
|
|
2469
|
+
}
|
|
2470
|
+
if (pattern)
|
|
2471
|
+
return pattern.source;
|
|
2472
|
+
// an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
|
|
2473
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum)
|
|
2474
|
+
return "(?!)";
|
|
2475
|
+
if (minimum !== undefined || maximum !== undefined)
|
|
2476
|
+
return regexes.string({ minimum, maximum }).source;
|
|
2477
|
+
const own = schema._zod.pattern;
|
|
2478
|
+
return (isInt && own === regexes.number ? regexes.integer : own)?.source;
|
|
2479
|
+
}
|
|
2480
|
+
// a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
|
|
2481
|
+
function partPattern(schema) {
|
|
2482
|
+
const def = schema._zod.def;
|
|
2483
|
+
const own = schema._zod.pattern?.source;
|
|
2484
|
+
// lazy resolves its inner on the internals, not the def
|
|
2485
|
+
const inner = def.innerType ?? schema._zod.innerType;
|
|
2486
|
+
if (inner) {
|
|
2487
|
+
const before = inner._zod.pattern?.source;
|
|
2488
|
+
const after = partPattern(inner);
|
|
2489
|
+
if (own && before && after && after !== before) {
|
|
2490
|
+
return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
|
|
2491
|
+
}
|
|
2492
|
+
return own;
|
|
2493
|
+
}
|
|
2494
|
+
if (def.options) {
|
|
2495
|
+
const sources = def.options.map(partPattern);
|
|
2496
|
+
if (sources.every(Boolean))
|
|
2497
|
+
return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
|
|
2498
|
+
}
|
|
2499
|
+
return leafPattern(schema);
|
|
2500
|
+
}
|
|
1941
2501
|
exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
1942
2502
|
exports.$ZodType.init(inst, def);
|
|
1943
2503
|
const regexParts = [];
|
|
1944
2504
|
for (const part of def.parts) {
|
|
1945
2505
|
if (typeof part === "object" && part !== null) {
|
|
1946
2506
|
// is Zod schema
|
|
1947
|
-
|
|
1948
|
-
|
|
2507
|
+
const source = partPattern(part);
|
|
2508
|
+
if (!source) {
|
|
1949
2509
|
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
|
1950
2510
|
}
|
|
1951
|
-
|
|
1952
|
-
if (!source)
|
|
1953
|
-
throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
1954
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
1955
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
1956
|
-
regexParts.push(source.slice(start, end));
|
|
2511
|
+
regexParts.push(util.cleanRegex(source));
|
|
1957
2512
|
}
|
|
1958
2513
|
else if (part === null || util.primitiveTypes.has(typeof part)) {
|
|
1959
2514
|
regexParts.push(util.escapeRegex(`${part}`));
|
|
@@ -1989,33 +2544,35 @@ exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, de
|
|
|
1989
2544
|
});
|
|
1990
2545
|
exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
|
|
1991
2546
|
exports.$ZodType.init(inst, def);
|
|
1992
|
-
|
|
2547
|
+
// Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
|
|
2548
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
1993
2549
|
inst._zod.def = def;
|
|
1994
2550
|
inst.implement = (func) => {
|
|
1995
2551
|
if (typeof func !== "function") {
|
|
1996
2552
|
throw new Error("implement() must be called with a function");
|
|
1997
2553
|
}
|
|
1998
|
-
|
|
2554
|
+
// Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
|
|
2555
|
+
return Object.defineProperty(function (...args) {
|
|
1999
2556
|
const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
|
|
2000
2557
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
2001
2558
|
if (inst._def.output) {
|
|
2002
2559
|
return (0, parse_js_1.parse)(inst._def.output, result);
|
|
2003
2560
|
}
|
|
2004
2561
|
return result;
|
|
2005
|
-
};
|
|
2562
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
2006
2563
|
};
|
|
2007
2564
|
inst.implementAsync = (func) => {
|
|
2008
2565
|
if (typeof func !== "function") {
|
|
2009
2566
|
throw new Error("implementAsync() must be called with a function");
|
|
2010
2567
|
}
|
|
2011
|
-
return async function (...args) {
|
|
2568
|
+
return Object.defineProperty(async function (...args) {
|
|
2012
2569
|
const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
|
|
2013
2570
|
const result = await Reflect.apply(func, this, parsedArgs);
|
|
2014
2571
|
if (inst._def.output) {
|
|
2015
2572
|
return await (0, parse_js_1.parseAsync)(inst._def.output, result);
|
|
2016
2573
|
}
|
|
2017
2574
|
return result;
|
|
2018
|
-
};
|
|
2575
|
+
}, "_zod", { value: inst._zod, enumerable: false });
|
|
2019
2576
|
};
|
|
2020
2577
|
inst._zod.parse = (payload, _ctx) => {
|
|
2021
2578
|
if (typeof payload.value !== "function") {
|
|
@@ -2074,18 +2631,17 @@ exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
|
|
|
2074
2631
|
});
|
|
2075
2632
|
exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
|
|
2076
2633
|
exports.$ZodType.init(inst, def);
|
|
2077
|
-
//
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
util.
|
|
2085
|
-
util.
|
|
2086
|
-
util.
|
|
2087
|
-
util.
|
|
2088
|
-
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
|
|
2634
|
+
// 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.
|
|
2635
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
2636
|
+
const d = def;
|
|
2637
|
+
if (!d._cachedInner)
|
|
2638
|
+
d._cachedInner = def.getter();
|
|
2639
|
+
return d._cachedInner;
|
|
2640
|
+
});
|
|
2641
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
|
|
2642
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
|
|
2643
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
|
|
2644
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
|
|
2089
2645
|
inst._zod.parse = (payload, ctx) => {
|
|
2090
2646
|
const inner = inst._zod.innerType;
|
|
2091
2647
|
return inner._zod.run(payload, ctx);
|
|
@@ -2122,3 +2678,22 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
2122
2678
|
payload.issues.push(util.issue(_iss));
|
|
2123
2679
|
}
|
|
2124
2680
|
}
|
|
2681
|
+
|
|
2682
|
+
// seal-cjs-exports
|
|
2683
|
+
(function () {
|
|
2684
|
+
var keys = Object.getOwnPropertyNames(exports);
|
|
2685
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2686
|
+
var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
|
|
2687
|
+
if (!desc || !desc.get || !desc.configurable) continue;
|
|
2688
|
+
var value;
|
|
2689
|
+
try {
|
|
2690
|
+
value = desc.get();
|
|
2691
|
+
} catch (e) {
|
|
2692
|
+
continue;
|
|
2693
|
+
}
|
|
2694
|
+
// a circular require may not have settled this one yet, so leave it live
|
|
2695
|
+
if (value === undefined) continue;
|
|
2696
|
+
Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
|
|
2697
|
+
}
|
|
2698
|
+
Object.freeze(exports);
|
|
2699
|
+
})();
|